ltmain.sh revision f353fbad
1994689c1Smrg
2f353fbadSmrg# libtool (GNU libtool) 2.4
3994689c1Smrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
4994689c1Smrg
5e1e1713cSmrg# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006,
6994689c1Smrg# 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
7994689c1Smrg# This is free software; see the source for copying conditions.  There is NO
8994689c1Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9994689c1Smrg
10994689c1Smrg# GNU Libtool is free software; you can redistribute it and/or modify
117a84e134Smrg# it under the terms of the GNU General Public License as published by
127a84e134Smrg# the Free Software Foundation; either version 2 of the License, or
137a84e134Smrg# (at your option) any later version.
147a84e134Smrg#
15994689c1Smrg# As a special exception to the GNU General Public License,
16994689c1Smrg# if you distribute this file as part of a program or library that
17994689c1Smrg# is built using GNU Libtool, you may include this file under the
18994689c1Smrg# same distribution terms that you use for the rest of that program.
19994689c1Smrg#
20994689c1Smrg# GNU Libtool is distributed in the hope that it will be useful, but
217a84e134Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of
227a84e134Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
237a84e134Smrg# General Public License for more details.
247a84e134Smrg#
257a84e134Smrg# You should have received a copy of the GNU General Public License
26994689c1Smrg# along with GNU Libtool; see the file COPYING.  If not, a copy
27994689c1Smrg# can be downloaded from http://www.gnu.org/licenses/gpl.html,
28994689c1Smrg# or obtained by writing to the Free Software Foundation, Inc.,
29994689c1Smrg# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
30e1e1713cSmrg
31994689c1Smrg# Usage: $progname [OPTION]... [MODE-ARG]...
32994689c1Smrg#
33994689c1Smrg# Provide generalized library-building support services.
34994689c1Smrg#
35994689c1Smrg#       --config             show all configuration variables
36994689c1Smrg#       --debug              enable verbose shell tracing
37994689c1Smrg#   -n, --dry-run            display commands without modifying any files
38994689c1Smrg#       --features           display basic configuration information and exit
39994689c1Smrg#       --mode=MODE          use operation mode MODE
40994689c1Smrg#       --preserve-dup-deps  don't remove duplicate dependency libraries
41994689c1Smrg#       --quiet, --silent    don't print informational messages
42994689c1Smrg#       --no-quiet, --no-silent
43994689c1Smrg#                            print informational messages (default)
44994689c1Smrg#       --tag=TAG            use configuration variables from tag TAG
45994689c1Smrg#   -v, --verbose            print more informational messages than default
46994689c1Smrg#       --no-verbose         don't print the extra informational messages
47994689c1Smrg#       --version            print version information
48994689c1Smrg#   -h, --help, --help-all   print short, long, or detailed help message
49994689c1Smrg#
50994689c1Smrg# MODE must be one of the following:
51994689c1Smrg#
52994689c1Smrg#         clean              remove files from the build directory
53994689c1Smrg#         compile            compile a source file into a libtool object
54994689c1Smrg#         execute            automatically set library path, then run a program
55994689c1Smrg#         finish             complete the installation of libtool libraries
56994689c1Smrg#         install            install libraries or executables
57994689c1Smrg#         link               create a library or an executable
58994689c1Smrg#         uninstall          remove libraries from an installed directory
59994689c1Smrg#
60994689c1Smrg# MODE-ARGS vary depending on the MODE.  When passed as first option,
61994689c1Smrg# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that.
62994689c1Smrg# Try `$progname --help --mode=MODE' for a more detailed description of MODE.
63994689c1Smrg#
64994689c1Smrg# When reporting a bug, please describe a test case to reproduce it and
65994689c1Smrg# include the following information:
66994689c1Smrg#
67994689c1Smrg#         host-triplet:	$host
68994689c1Smrg#         shell:		$SHELL
69994689c1Smrg#         compiler:		$LTCC
70994689c1Smrg#         compiler flags:		$LTCFLAGS
71994689c1Smrg#         linker:		$LD (gnu? $with_gnu_ld)
72f353fbadSmrg#         $progname:	(GNU libtool) 2.4
73994689c1Smrg#         automake:	$automake_version
74994689c1Smrg#         autoconf:	$autoconf_version
75994689c1Smrg#
76994689c1Smrg# Report bugs to <bug-libtool@gnu.org>.
77f353fbadSmrg# GNU libtool home page: <http://www.gnu.org/software/libtool/>.
78f353fbadSmrg# General help using GNU software: <http://www.gnu.org/gethelp/>.
797a84e134Smrg
80994689c1SmrgPROGRAM=libtool
817a84e134SmrgPACKAGE=libtool
82f353fbadSmrgVERSION=2.4
83994689c1SmrgTIMESTAMP=""
84f353fbadSmrgpackage_revision=1.3293
85ab902922Smrg
86994689c1Smrg# Be Bourne compatible
87ab902922Smrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
88ab902922Smrg  emulate sh
89ab902922Smrg  NULLCMD=:
90ab902922Smrg  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
91ab902922Smrg  # is contrary to our usage.  Disable this feature.
92ab902922Smrg  alias -g '${1+"$@"}'='"$@"'
937a84e134Smrg  setopt NO_GLOB_SUBST
94ab902922Smrgelse
95ab902922Smrg  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
967a84e134Smrgfi
97ab902922SmrgBIN_SH=xpg4; export BIN_SH # for Tru64
98ab902922SmrgDUALCASE=1; export DUALCASE # for MKS sh
997a84e134Smrg
100994689c1Smrg# A function that is used when there is no print builtin or printf.
101994689c1Smrgfunc_fallback_echo ()
102994689c1Smrg{
103994689c1Smrg  eval 'cat <<_LTECHO_EOF
104994689c1Smrg$1
105994689c1Smrg_LTECHO_EOF'
106994689c1Smrg}
107e1e1713cSmrg
108994689c1Smrg# NLS nuisances: We save the old values to restore during execute mode.
109994689c1Smrglt_user_locale=
110994689c1Smrglt_safe_locale=
111ab902922Smrgfor lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
112ab902922Smrgdo
113ab902922Smrg  eval "if test \"\${$lt_var+set}\" = set; then
114994689c1Smrg          save_$lt_var=\$$lt_var
115994689c1Smrg          $lt_var=C
116ab902922Smrg	  export $lt_var
117994689c1Smrg	  lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\"
118994689c1Smrg	  lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
119ab902922Smrg	fi"
120ab902922Smrgdone
121994689c1SmrgLC_ALL=C
122994689c1SmrgLANGUAGE=C
123994689c1Smrgexport LANGUAGE LC_ALL
124ab902922Smrg
125994689c1Smrg$lt_unset CDPATH
126994689c1Smrg
127994689c1Smrg
128994689c1Smrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
129994689c1Smrg# is ksh but when the shell is invoked as "sh" and the current value of
130994689c1Smrg# the _XPG environment variable is not equal to 1 (one), the special
131994689c1Smrg# positional parameter $0, within a function call, is the name of the
132994689c1Smrg# function.
133994689c1Smrgprogpath="$0"
134994689c1Smrg
135994689c1Smrg
136994689c1Smrg
137994689c1Smrg: ${CP="cp -f"}
138994689c1Smrgtest "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'}
139994689c1Smrg: ${EGREP="grep -E"}
140994689c1Smrg: ${FGREP="grep -F"}
141994689c1Smrg: ${GREP="grep"}
142994689c1Smrg: ${LN_S="ln -s"}
143994689c1Smrg: ${MAKE="make"}
144994689c1Smrg: ${MKDIR="mkdir"}
145994689c1Smrg: ${MV="mv -f"}
146994689c1Smrg: ${RM="rm -f"}
147994689c1Smrg: ${SED="sed"}
148994689c1Smrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
149994689c1Smrg: ${Xsed="$SED -e 1s/^X//"}
150994689c1Smrg
151994689c1Smrg# Global variables:
152994689c1SmrgEXIT_SUCCESS=0
153994689c1SmrgEXIT_FAILURE=1
154994689c1SmrgEXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
155994689c1SmrgEXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
156994689c1Smrg
157994689c1Smrgexit_status=$EXIT_SUCCESS
1587a84e134Smrg
1597a84e134Smrg# Make sure IFS has a sensible default
1607a84e134Smrglt_nl='
1617a84e134Smrg'
1627a84e134SmrgIFS=" 	$lt_nl"
1637a84e134Smrg
164994689c1Smrgdirname="s,/[^/]*$,,"
165994689c1Smrgbasename="s,^.*/,,"
166994689c1Smrg
167f353fbadSmrg# func_dirname file append nondir_replacement
168f353fbadSmrg# Compute the dirname of FILE.  If nonempty, add APPEND to the result,
169f353fbadSmrg# otherwise set result to NONDIR_REPLACEMENT.
170f353fbadSmrgfunc_dirname ()
171f353fbadSmrg{
172f353fbadSmrg    func_dirname_result=`$ECHO "${1}" | $SED "$dirname"`
173f353fbadSmrg    if test "X$func_dirname_result" = "X${1}"; then
174f353fbadSmrg      func_dirname_result="${3}"
175f353fbadSmrg    else
176f353fbadSmrg      func_dirname_result="$func_dirname_result${2}"
177f353fbadSmrg    fi
178f353fbadSmrg} # func_dirname may be replaced by extended shell implementation
179f353fbadSmrg
180f353fbadSmrg
181f353fbadSmrg# func_basename file
182f353fbadSmrgfunc_basename ()
183f353fbadSmrg{
184f353fbadSmrg    func_basename_result=`$ECHO "${1}" | $SED "$basename"`
185f353fbadSmrg} # func_basename may be replaced by extended shell implementation
186f353fbadSmrg
187f353fbadSmrg
188994689c1Smrg# func_dirname_and_basename file append nondir_replacement
189994689c1Smrg# perform func_basename and func_dirname in a single function
190994689c1Smrg# call:
191994689c1Smrg#   dirname:  Compute the dirname of FILE.  If nonempty,
192994689c1Smrg#             add APPEND to the result, otherwise set result
193994689c1Smrg#             to NONDIR_REPLACEMENT.
194994689c1Smrg#             value returned in "$func_dirname_result"
195994689c1Smrg#   basename: Compute filename of FILE.
196994689c1Smrg#             value retuned in "$func_basename_result"
197994689c1Smrg# Implementation must be kept synchronized with func_dirname
198994689c1Smrg# and func_basename. For efficiency, we do not delegate to
199994689c1Smrg# those functions but instead duplicate the functionality here.
200994689c1Smrgfunc_dirname_and_basename ()
201994689c1Smrg{
202f353fbadSmrg    # Extract subdirectory from the argument.
203f353fbadSmrg    func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"`
204f353fbadSmrg    if test "X$func_dirname_result" = "X${1}"; then
205f353fbadSmrg      func_dirname_result="${3}"
206f353fbadSmrg    else
207f353fbadSmrg      func_dirname_result="$func_dirname_result${2}"
208f353fbadSmrg    fi
209f353fbadSmrg    func_basename_result=`$ECHO "${1}" | $SED -e "$basename"`
210f353fbadSmrg} # func_dirname_and_basename may be replaced by extended shell implementation
211f353fbadSmrg
212f353fbadSmrg
213f353fbadSmrg# func_stripname prefix suffix name
214f353fbadSmrg# strip PREFIX and SUFFIX off of NAME.
215f353fbadSmrg# PREFIX and SUFFIX must not contain globbing or regex special
216f353fbadSmrg# characters, hashes, percent signs, but SUFFIX may contain a leading
217f353fbadSmrg# dot (in which case that matches only a dot).
218f353fbadSmrg# func_strip_suffix prefix name
219f353fbadSmrgfunc_stripname ()
220f353fbadSmrg{
221f353fbadSmrg    case ${2} in
222f353fbadSmrg      .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;;
223f353fbadSmrg      *)  func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;;
224f353fbadSmrg    esac
225f353fbadSmrg} # func_stripname may be replaced by extended shell implementation
226775e7de9Smrg
227994689c1Smrg
228994689c1Smrg# These SED scripts presuppose an absolute path with a trailing slash.
229994689c1Smrgpathcar='s,^/\([^/]*\).*$,\1,'
230994689c1Smrgpathcdr='s,^/[^/]*,,'
231994689c1Smrgremovedotparts=':dotsl
232994689c1Smrg		s@/\./@/@g
233994689c1Smrg		t dotsl
234994689c1Smrg		s,/\.$,/,'
235994689c1Smrgcollapseslashes='s@/\{1,\}@/@g'
236994689c1Smrgfinalslash='s,/*$,/,'
237994689c1Smrg
238994689c1Smrg# func_normal_abspath PATH
239994689c1Smrg# Remove doubled-up and trailing slashes, "." path components,
240994689c1Smrg# and cancel out any ".." path components in PATH after making
241994689c1Smrg# it an absolute path.
242994689c1Smrg#             value returned in "$func_normal_abspath_result"
243994689c1Smrgfunc_normal_abspath ()
244994689c1Smrg{
245994689c1Smrg  # Start from root dir and reassemble the path.
246994689c1Smrg  func_normal_abspath_result=
247994689c1Smrg  func_normal_abspath_tpath=$1
248994689c1Smrg  func_normal_abspath_altnamespace=
249994689c1Smrg  case $func_normal_abspath_tpath in
250994689c1Smrg    "")
251994689c1Smrg      # Empty path, that just means $cwd.
252994689c1Smrg      func_stripname '' '/' "`pwd`"
253994689c1Smrg      func_normal_abspath_result=$func_stripname_result
254994689c1Smrg      return
255994689c1Smrg    ;;
256994689c1Smrg    # The next three entries are used to spot a run of precisely
257994689c1Smrg    # two leading slashes without using negated character classes;
258994689c1Smrg    # we take advantage of case's first-match behaviour.
259994689c1Smrg    ///*)
260994689c1Smrg      # Unusual form of absolute path, do nothing.
261994689c1Smrg    ;;
262994689c1Smrg    //*)
263994689c1Smrg      # Not necessarily an ordinary path; POSIX reserves leading '//'
264994689c1Smrg      # and for example Cygwin uses it to access remote file shares
265994689c1Smrg      # over CIFS/SMB, so we conserve a leading double slash if found.
266994689c1Smrg      func_normal_abspath_altnamespace=/
267994689c1Smrg    ;;
268994689c1Smrg    /*)
269994689c1Smrg      # Absolute path, do nothing.
270994689c1Smrg    ;;
271994689c1Smrg    *)
272994689c1Smrg      # Relative path, prepend $cwd.
273994689c1Smrg      func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
274994689c1Smrg    ;;
275994689c1Smrg  esac
276994689c1Smrg  # Cancel out all the simple stuff to save iterations.  We also want
277994689c1Smrg  # the path to end with a slash for ease of parsing, so make sure
278994689c1Smrg  # there is one (and only one) here.
279994689c1Smrg  func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
280994689c1Smrg        -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"`
281994689c1Smrg  while :; do
282994689c1Smrg    # Processed it all yet?
283994689c1Smrg    if test "$func_normal_abspath_tpath" = / ; then
284994689c1Smrg      # If we ascended to the root using ".." the result may be empty now.
285994689c1Smrg      if test -z "$func_normal_abspath_result" ; then
286994689c1Smrg        func_normal_abspath_result=/
287994689c1Smrg      fi
288994689c1Smrg      break
289994689c1Smrg    fi
290994689c1Smrg    func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
291994689c1Smrg        -e "$pathcar"`
292994689c1Smrg    func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
293994689c1Smrg        -e "$pathcdr"`
294994689c1Smrg    # Figure out what to do with it
295994689c1Smrg    case $func_normal_abspath_tcomponent in
296994689c1Smrg      "")
297994689c1Smrg        # Trailing empty path component, ignore it.
298994689c1Smrg      ;;
299994689c1Smrg      ..)
300994689c1Smrg        # Parent dir; strip last assembled component from result.
301994689c1Smrg        func_dirname "$func_normal_abspath_result"
302994689c1Smrg        func_normal_abspath_result=$func_dirname_result
303994689c1Smrg      ;;
304994689c1Smrg      *)
305994689c1Smrg        # Actual path component, append it.
306994689c1Smrg        func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent
307994689c1Smrg      ;;
308994689c1Smrg    esac
309994689c1Smrg  done
310994689c1Smrg  # Restore leading double-slash if one was found on entry.
311994689c1Smrg  func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
312994689c1Smrg}
313994689c1Smrg
314994689c1Smrg# func_relative_path SRCDIR DSTDIR
315994689c1Smrg# generates a relative path from SRCDIR to DSTDIR, with a trailing
316994689c1Smrg# slash if non-empty, suitable for immediately appending a filename
317994689c1Smrg# without needing to append a separator.
318994689c1Smrg#             value returned in "$func_relative_path_result"
319994689c1Smrgfunc_relative_path ()
320994689c1Smrg{
321994689c1Smrg  func_relative_path_result=
322994689c1Smrg  func_normal_abspath "$1"
323994689c1Smrg  func_relative_path_tlibdir=$func_normal_abspath_result
324994689c1Smrg  func_normal_abspath "$2"
325994689c1Smrg  func_relative_path_tbindir=$func_normal_abspath_result
326994689c1Smrg
327994689c1Smrg  # Ascend the tree starting from libdir
328994689c1Smrg  while :; do
329994689c1Smrg    # check if we have found a prefix of bindir
330994689c1Smrg    case $func_relative_path_tbindir in
331994689c1Smrg      $func_relative_path_tlibdir)
332994689c1Smrg        # found an exact match
333994689c1Smrg        func_relative_path_tcancelled=
334994689c1Smrg        break
335994689c1Smrg        ;;
336994689c1Smrg      $func_relative_path_tlibdir*)
337994689c1Smrg        # found a matching prefix
338994689c1Smrg        func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
339994689c1Smrg        func_relative_path_tcancelled=$func_stripname_result
340994689c1Smrg        if test -z "$func_relative_path_result"; then
341994689c1Smrg          func_relative_path_result=.
342994689c1Smrg        fi
343994689c1Smrg        break
344994689c1Smrg        ;;
345994689c1Smrg      *)
346994689c1Smrg        func_dirname $func_relative_path_tlibdir
347994689c1Smrg        func_relative_path_tlibdir=${func_dirname_result}
348994689c1Smrg        if test "x$func_relative_path_tlibdir" = x ; then
349994689c1Smrg          # Have to descend all the way to the root!
350994689c1Smrg          func_relative_path_result=../$func_relative_path_result
351994689c1Smrg          func_relative_path_tcancelled=$func_relative_path_tbindir
352994689c1Smrg          break
353994689c1Smrg        fi
354994689c1Smrg        func_relative_path_result=../$func_relative_path_result
355994689c1Smrg        ;;
356994689c1Smrg    esac
357994689c1Smrg  done
358994689c1Smrg
359994689c1Smrg  # Now calculate path; take care to avoid doubling-up slashes.
360994689c1Smrg  func_stripname '' '/' "$func_relative_path_result"
361994689c1Smrg  func_relative_path_result=$func_stripname_result
362994689c1Smrg  func_stripname '/' '/' "$func_relative_path_tcancelled"
363994689c1Smrg  if test "x$func_stripname_result" != x ; then
364994689c1Smrg    func_relative_path_result=${func_relative_path_result}/${func_stripname_result}
365994689c1Smrg  fi
366994689c1Smrg
367994689c1Smrg  # Normalisation. If bindir is libdir, return empty string,
368994689c1Smrg  # else relative path ending with a slash; either way, target
369994689c1Smrg  # file name can be directly appended.
370994689c1Smrg  if test ! -z "$func_relative_path_result"; then
371994689c1Smrg    func_stripname './' '' "$func_relative_path_result/"
372994689c1Smrg    func_relative_path_result=$func_stripname_result
373994689c1Smrg  fi
374994689c1Smrg}
375994689c1Smrg
376994689c1Smrg# The name of this program:
377994689c1Smrgfunc_dirname_and_basename "$progpath"
378994689c1Smrgprogname=$func_basename_result
379994689c1Smrg
380994689c1Smrg# Make sure we have an absolute path for reexecution:
381994689c1Smrgcase $progpath in
382994689c1Smrg  [\\/]*|[A-Za-z]:\\*) ;;
383994689c1Smrg  *[\\/]*)
384994689c1Smrg     progdir=$func_dirname_result
385994689c1Smrg     progdir=`cd "$progdir" && pwd`
386994689c1Smrg     progpath="$progdir/$progname"
387994689c1Smrg     ;;
388994689c1Smrg  *)
389994689c1Smrg     save_IFS="$IFS"
390994689c1Smrg     IFS=:
391994689c1Smrg     for progdir in $PATH; do
392994689c1Smrg       IFS="$save_IFS"
393994689c1Smrg       test -x "$progdir/$progname" && break
394994689c1Smrg     done
395994689c1Smrg     IFS="$save_IFS"
396994689c1Smrg     test -n "$progdir" || progdir=`pwd`
397994689c1Smrg     progpath="$progdir/$progname"
398994689c1Smrg     ;;
399994689c1Smrgesac
400994689c1Smrg
401994689c1Smrg# Sed substitution that helps us do robust quoting.  It backslashifies
402994689c1Smrg# metacharacters that are still active within double-quoted strings.
403994689c1SmrgXsed="${SED}"' -e 1s/^X//'
404994689c1Smrgsed_quote_subst='s/\([`"$\\]\)/\\\1/g'
405994689c1Smrg
406994689c1Smrg# Same as above, but do not quote variable references.
407994689c1Smrgdouble_quote_subst='s/\(["`\\]\)/\\\1/g'
408994689c1Smrg
409f353fbadSmrg# Sed substitution that turns a string into a regex matching for the
410f353fbadSmrg# string literally.
411f353fbadSmrgsed_make_literal_regex='s,[].[^$\\*\/],\\&,g'
412f353fbadSmrg
413f353fbadSmrg# Sed substitution that converts a w32 file name or path
414f353fbadSmrg# which contains forward slashes, into one that contains
415f353fbadSmrg# (escaped) backslashes.  A very naive implementation.
416f353fbadSmrglt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
417f353fbadSmrg
418994689c1Smrg# Re-`\' parameter expansions in output of double_quote_subst that were
419994689c1Smrg# `\'-ed in input to the same.  If an odd number of `\' preceded a '$'
420994689c1Smrg# in input to double_quote_subst, that '$' was protected from expansion.
421994689c1Smrg# Since each input `\' is now two `\'s, look for any number of runs of
422994689c1Smrg# four `\'s followed by two `\'s and then a '$'.  `\' that '$'.
423994689c1Smrgbs='\\'
424994689c1Smrgbs2='\\\\'
425994689c1Smrgbs4='\\\\\\\\'
426994689c1Smrgdollar='\$'
427994689c1Smrgsed_double_backslash="\
428994689c1Smrg  s/$bs4/&\\
429994689c1Smrg/g
430994689c1Smrg  s/^$bs2$dollar/$bs&/
431994689c1Smrg  s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
432994689c1Smrg  s/\n//g"
433994689c1Smrg
434994689c1Smrg# Standard options:
435994689c1Smrgopt_dry_run=false
436994689c1Smrgopt_help=false
437994689c1Smrgopt_quiet=false
438994689c1Smrgopt_verbose=false
439994689c1Smrgopt_warning=:
440994689c1Smrg
441994689c1Smrg# func_echo arg...
442994689c1Smrg# Echo program name prefixed message, along with the current mode
443994689c1Smrg# name if it has been set yet.
444994689c1Smrgfunc_echo ()
445994689c1Smrg{
446f353fbadSmrg    $ECHO "$progname: ${opt_mode+$opt_mode: }$*"
447994689c1Smrg}
448994689c1Smrg
449994689c1Smrg# func_verbose arg...
450994689c1Smrg# Echo program name prefixed message in verbose mode only.
451994689c1Smrgfunc_verbose ()
452994689c1Smrg{
453994689c1Smrg    $opt_verbose && func_echo ${1+"$@"}
454994689c1Smrg
455994689c1Smrg    # A bug in bash halts the script if the last line of a function
456994689c1Smrg    # fails when set -e is in force, so we need another command to
457994689c1Smrg    # work around that:
458994689c1Smrg    :
459994689c1Smrg}
460994689c1Smrg
461994689c1Smrg# func_echo_all arg...
462994689c1Smrg# Invoke $ECHO with all args, space-separated.
463994689c1Smrgfunc_echo_all ()
464994689c1Smrg{
465994689c1Smrg    $ECHO "$*"
466994689c1Smrg}
467994689c1Smrg
468994689c1Smrg# func_error arg...
469994689c1Smrg# Echo program name prefixed message to standard error.
470994689c1Smrgfunc_error ()
471994689c1Smrg{
472f353fbadSmrg    $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2
473994689c1Smrg}
474994689c1Smrg
475994689c1Smrg# func_warning arg...
476994689c1Smrg# Echo program name prefixed warning message to standard error.
477994689c1Smrgfunc_warning ()
478994689c1Smrg{
479f353fbadSmrg    $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2
480994689c1Smrg
481994689c1Smrg    # bash bug again:
482994689c1Smrg    :
483994689c1Smrg}
484994689c1Smrg
485994689c1Smrg# func_fatal_error arg...
486994689c1Smrg# Echo program name prefixed message to standard error, and exit.
487994689c1Smrgfunc_fatal_error ()
488994689c1Smrg{
489994689c1Smrg    func_error ${1+"$@"}
490994689c1Smrg    exit $EXIT_FAILURE
491994689c1Smrg}
492994689c1Smrg
493994689c1Smrg# func_fatal_help arg...
494994689c1Smrg# Echo program name prefixed message to standard error, followed by
495994689c1Smrg# a help hint, and exit.
496994689c1Smrgfunc_fatal_help ()
497994689c1Smrg{
498994689c1Smrg    func_error ${1+"$@"}
499994689c1Smrg    func_fatal_error "$help"
500994689c1Smrg}
501994689c1Smrghelp="Try \`$progname --help' for more information."  ## default
502994689c1Smrg
503994689c1Smrg
504994689c1Smrg# func_grep expression filename
505994689c1Smrg# Check whether EXPRESSION matches any line of FILENAME, without output.
506994689c1Smrgfunc_grep ()
507994689c1Smrg{
508994689c1Smrg    $GREP "$1" "$2" >/dev/null 2>&1
509994689c1Smrg}
510994689c1Smrg
511994689c1Smrg
512994689c1Smrg# func_mkdir_p directory-path
513994689c1Smrg# Make sure the entire path to DIRECTORY-PATH is available.
514994689c1Smrgfunc_mkdir_p ()
515994689c1Smrg{
516994689c1Smrg    my_directory_path="$1"
517994689c1Smrg    my_dir_list=
518994689c1Smrg
519994689c1Smrg    if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
520994689c1Smrg
521994689c1Smrg      # Protect directory names starting with `-'
522994689c1Smrg      case $my_directory_path in
523994689c1Smrg        -*) my_directory_path="./$my_directory_path" ;;
524994689c1Smrg      esac
525994689c1Smrg
526994689c1Smrg      # While some portion of DIR does not yet exist...
527994689c1Smrg      while test ! -d "$my_directory_path"; do
528994689c1Smrg        # ...make a list in topmost first order.  Use a colon delimited
529994689c1Smrg	# list incase some portion of path contains whitespace.
530994689c1Smrg        my_dir_list="$my_directory_path:$my_dir_list"
531994689c1Smrg
532994689c1Smrg        # If the last portion added has no slash in it, the list is done
533994689c1Smrg        case $my_directory_path in */*) ;; *) break ;; esac
534994689c1Smrg
535994689c1Smrg        # ...otherwise throw away the child directory and loop
536994689c1Smrg        my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"`
537994689c1Smrg      done
538994689c1Smrg      my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'`
539994689c1Smrg
540994689c1Smrg      save_mkdir_p_IFS="$IFS"; IFS=':'
541994689c1Smrg      for my_dir in $my_dir_list; do
542994689c1Smrg	IFS="$save_mkdir_p_IFS"
543994689c1Smrg        # mkdir can fail with a `File exist' error if two processes
544994689c1Smrg        # try to create one of the directories concurrently.  Don't
545994689c1Smrg        # stop in that case!
546994689c1Smrg        $MKDIR "$my_dir" 2>/dev/null || :
547994689c1Smrg      done
548994689c1Smrg      IFS="$save_mkdir_p_IFS"
549994689c1Smrg
550994689c1Smrg      # Bail out if we (or some other process) failed to create a directory.
551994689c1Smrg      test -d "$my_directory_path" || \
552994689c1Smrg        func_fatal_error "Failed to create \`$1'"
553994689c1Smrg    fi
554994689c1Smrg}
5557a84e134Smrg
5567a84e134Smrg
5577a84e134Smrg# func_mktempdir [string]
5587a84e134Smrg# Make a temporary directory that won't clash with other running
5597a84e134Smrg# libtool processes, and avoids race conditions if possible.  If
5607a84e134Smrg# given, STRING is the basename for that directory.
5617a84e134Smrgfunc_mktempdir ()
5627a84e134Smrg{
5637a84e134Smrg    my_template="${TMPDIR-/tmp}/${1-$progname}"
5647a84e134Smrg
565994689c1Smrg    if test "$opt_dry_run" = ":"; then
5667a84e134Smrg      # Return a directory name, but don't create it in dry-run mode
5677a84e134Smrg      my_tmpdir="${my_template}-$$"
5687a84e134Smrg    else
5697a84e134Smrg
5707a84e134Smrg      # If mktemp works, use that first and foremost
5717a84e134Smrg      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
5727a84e134Smrg
5737a84e134Smrg      if test ! -d "$my_tmpdir"; then
574994689c1Smrg        # Failing that, at least try and use $RANDOM to avoid a race
575994689c1Smrg        my_tmpdir="${my_template}-${RANDOM-0}$$"
5767a84e134Smrg
577994689c1Smrg        save_mktempdir_umask=`umask`
578994689c1Smrg        umask 0077
579994689c1Smrg        $MKDIR "$my_tmpdir"
580994689c1Smrg        umask $save_mktempdir_umask
5817a84e134Smrg      fi
5827a84e134Smrg
5837a84e134Smrg      # If we're not in dry-run mode, bomb out on failure
584994689c1Smrg      test -d "$my_tmpdir" || \
585994689c1Smrg        func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
5867a84e134Smrg    fi
5877a84e134Smrg
588994689c1Smrg    $ECHO "$my_tmpdir"
5897a84e134Smrg}
5907a84e134Smrg
5917a84e134Smrg
592994689c1Smrg# func_quote_for_eval arg
593994689c1Smrg# Aesthetically quote ARG to be evaled later.
594994689c1Smrg# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
595994689c1Smrg# is double-quoted, suitable for a subsequent eval, whereas
596994689c1Smrg# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
597994689c1Smrg# which are still active within double quotes backslashified.
598994689c1Smrgfunc_quote_for_eval ()
5997a84e134Smrg{
600994689c1Smrg    case $1 in
601994689c1Smrg      *[\\\`\"\$]*)
602994689c1Smrg	func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;;
603994689c1Smrg      *)
604994689c1Smrg        func_quote_for_eval_unquoted_result="$1" ;;
605994689c1Smrg    esac
606994689c1Smrg
607994689c1Smrg    case $func_quote_for_eval_unquoted_result in
608994689c1Smrg      # Double-quote args containing shell metacharacters to delay
609994689c1Smrg      # word splitting, command substitution and and variable
610994689c1Smrg      # expansion for a subsequent eval.
611994689c1Smrg      # Many Bourne shells cannot handle close brackets correctly
612994689c1Smrg      # in scan sets, so we specify it separately.
613994689c1Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
614994689c1Smrg        func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
615994689c1Smrg        ;;
616994689c1Smrg      *)
617994689c1Smrg        func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
6187a84e134Smrg    esac
6197a84e134Smrg}
6207a84e134Smrg
6217a84e134Smrg
622994689c1Smrg# func_quote_for_expand arg
623994689c1Smrg# Aesthetically quote ARG to be evaled later; same as above,
624994689c1Smrg# but do not quote variable references.
625994689c1Smrgfunc_quote_for_expand ()
6267a84e134Smrg{
627994689c1Smrg    case $1 in
628994689c1Smrg      *[\\\`\"]*)
629994689c1Smrg	my_arg=`$ECHO "$1" | $SED \
630994689c1Smrg	    -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
6317a84e134Smrg      *)
632994689c1Smrg        my_arg="$1" ;;
633994689c1Smrg    esac
634994689c1Smrg
635994689c1Smrg    case $my_arg in
636994689c1Smrg      # Double-quote args containing shell metacharacters to delay
637994689c1Smrg      # word splitting and command substitution for a subsequent eval.
638994689c1Smrg      # Many Bourne shells cannot handle close brackets correctly
639994689c1Smrg      # in scan sets, so we specify it separately.
640994689c1Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
641994689c1Smrg        my_arg="\"$my_arg\""
642994689c1Smrg        ;;
643994689c1Smrg    esac
644994689c1Smrg
645994689c1Smrg    func_quote_for_expand_result="$my_arg"
6467a84e134Smrg}
6477a84e134Smrg
6487a84e134Smrg
649994689c1Smrg# func_show_eval cmd [fail_exp]
650994689c1Smrg# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
651994689c1Smrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
652994689c1Smrg# is given, then evaluate it.
653994689c1Smrgfunc_show_eval ()
6547a84e134Smrg{
655994689c1Smrg    my_cmd="$1"
656994689c1Smrg    my_fail_exp="${2-:}"
657775e7de9Smrg
658994689c1Smrg    ${opt_silent-false} || {
659994689c1Smrg      func_quote_for_expand "$my_cmd"
660994689c1Smrg      eval "func_echo $func_quote_for_expand_result"
661994689c1Smrg    }
662994689c1Smrg
663994689c1Smrg    if ${opt_dry_run-false}; then :; else
664994689c1Smrg      eval "$my_cmd"
665994689c1Smrg      my_status=$?
666994689c1Smrg      if test "$my_status" -eq 0; then :; else
667994689c1Smrg	eval "(exit $my_status); $my_fail_exp"
668994689c1Smrg      fi
6697a84e134Smrg    fi
6707a84e134Smrg}
6717a84e134Smrg
672994689c1Smrg
673994689c1Smrg# func_show_eval_locale cmd [fail_exp]
674994689c1Smrg# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
675994689c1Smrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
676994689c1Smrg# is given, then evaluate it.  Use the saved locale for evaluation.
677994689c1Smrgfunc_show_eval_locale ()
6787a84e134Smrg{
679994689c1Smrg    my_cmd="$1"
680994689c1Smrg    my_fail_exp="${2-:}"
6817a84e134Smrg
682994689c1Smrg    ${opt_silent-false} || {
683994689c1Smrg      func_quote_for_expand "$my_cmd"
684994689c1Smrg      eval "func_echo $func_quote_for_expand_result"
685994689c1Smrg    }
686775e7de9Smrg
687994689c1Smrg    if ${opt_dry_run-false}; then :; else
688994689c1Smrg      eval "$lt_user_locale
689994689c1Smrg	    $my_cmd"
690994689c1Smrg      my_status=$?
691994689c1Smrg      eval "$lt_safe_locale"
692994689c1Smrg      if test "$my_status" -eq 0; then :; else
693994689c1Smrg	eval "(exit $my_status); $my_fail_exp"
694e1e1713cSmrg      fi
695994689c1Smrg    fi
696775e7de9Smrg}
697775e7de9Smrg
698f353fbadSmrg# func_tr_sh
699f353fbadSmrg# Turn $1 into a string suitable for a shell variable name.
700f353fbadSmrg# Result is stored in $func_tr_sh_result.  All characters
701f353fbadSmrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further,
702f353fbadSmrg# if $1 begins with a digit, a '_' is prepended as well.
703f353fbadSmrgfunc_tr_sh ()
704f353fbadSmrg{
705f353fbadSmrg  case $1 in
706f353fbadSmrg  [0-9]* | *[!a-zA-Z0-9_]*)
707f353fbadSmrg    func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'`
708f353fbadSmrg    ;;
709f353fbadSmrg  * )
710f353fbadSmrg    func_tr_sh_result=$1
711f353fbadSmrg    ;;
712f353fbadSmrg  esac
713f353fbadSmrg}
714f353fbadSmrg
715775e7de9Smrg
716994689c1Smrg# func_version
717994689c1Smrg# Echo version message to standard output and exit.
718994689c1Smrgfunc_version ()
719994689c1Smrg{
720f353fbadSmrg    $opt_debug
721f353fbadSmrg
722994689c1Smrg    $SED -n '/(C)/!b go
723994689c1Smrg	:more
724994689c1Smrg	/\./!{
725994689c1Smrg	  N
726994689c1Smrg	  s/\n# / /
727994689c1Smrg	  b more
728994689c1Smrg	}
729994689c1Smrg	:go
730994689c1Smrg	/^# '$PROGRAM' (GNU /,/# warranty; / {
731994689c1Smrg        s/^# //
732994689c1Smrg	s/^# *$//
733994689c1Smrg        s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
734994689c1Smrg        p
735994689c1Smrg     }' < "$progpath"
736994689c1Smrg     exit $?
737994689c1Smrg}
738775e7de9Smrg
739994689c1Smrg# func_usage
740994689c1Smrg# Echo short help message to standard output and exit.
741994689c1Smrgfunc_usage ()
742994689c1Smrg{
743f353fbadSmrg    $opt_debug
744f353fbadSmrg
745994689c1Smrg    $SED -n '/^# Usage:/,/^#  *.*--help/ {
746994689c1Smrg        s/^# //
747994689c1Smrg	s/^# *$//
748994689c1Smrg	s/\$progname/'$progname'/
749994689c1Smrg	p
750994689c1Smrg    }' < "$progpath"
751994689c1Smrg    echo
752994689c1Smrg    $ECHO "run \`$progname --help | more' for full usage"
753994689c1Smrg    exit $?
754994689c1Smrg}
7557a84e134Smrg
756994689c1Smrg# func_help [NOEXIT]
757994689c1Smrg# Echo long help message to standard output and exit,
758994689c1Smrg# unless 'noexit' is passed as argument.
759994689c1Smrgfunc_help ()
760994689c1Smrg{
761f353fbadSmrg    $opt_debug
762f353fbadSmrg
763994689c1Smrg    $SED -n '/^# Usage:/,/# Report bugs to/ {
764f353fbadSmrg	:print
765994689c1Smrg        s/^# //
766994689c1Smrg	s/^# *$//
767994689c1Smrg	s*\$progname*'$progname'*
768994689c1Smrg	s*\$host*'"$host"'*
769994689c1Smrg	s*\$SHELL*'"$SHELL"'*
770994689c1Smrg	s*\$LTCC*'"$LTCC"'*
771994689c1Smrg	s*\$LTCFLAGS*'"$LTCFLAGS"'*
772994689c1Smrg	s*\$LD*'"$LD"'*
773994689c1Smrg	s/\$with_gnu_ld/'"$with_gnu_ld"'/
774994689c1Smrg	s/\$automake_version/'"`(automake --version) 2>/dev/null |$SED 1q`"'/
775994689c1Smrg	s/\$autoconf_version/'"`(autoconf --version) 2>/dev/null |$SED 1q`"'/
776994689c1Smrg	p
777f353fbadSmrg	d
778f353fbadSmrg     }
779f353fbadSmrg     /^# .* home page:/b print
780f353fbadSmrg     /^# General help using/b print
781f353fbadSmrg     ' < "$progpath"
782994689c1Smrg    ret=$?
783994689c1Smrg    if test -z "$1"; then
784994689c1Smrg      exit $ret
785994689c1Smrg    fi
786994689c1Smrg}
7877a84e134Smrg
788994689c1Smrg# func_missing_arg argname
789994689c1Smrg# Echo program name prefixed message to standard error and set global
790994689c1Smrg# exit_cmd.
791994689c1Smrgfunc_missing_arg ()
792994689c1Smrg{
793f353fbadSmrg    $opt_debug
794f353fbadSmrg
795994689c1Smrg    func_error "missing argument for $1."
796994689c1Smrg    exit_cmd=exit
797994689c1Smrg}
7987a84e134Smrg
799775e7de9Smrg
800f353fbadSmrg# func_split_short_opt shortopt
801f353fbadSmrg# Set func_split_short_opt_name and func_split_short_opt_arg shell
802f353fbadSmrg# variables after splitting SHORTOPT after the 2nd character.
803f353fbadSmrgfunc_split_short_opt ()
804f353fbadSmrg{
805f353fbadSmrg    my_sed_short_opt='1s/^\(..\).*$/\1/;q'
806f353fbadSmrg    my_sed_short_rest='1s/^..\(.*\)$/\1/;q'
807f353fbadSmrg
808f353fbadSmrg    func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"`
809f353fbadSmrg    func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"`
810f353fbadSmrg} # func_split_short_opt may be replaced by extended shell implementation
811f353fbadSmrg
812f353fbadSmrg
813f353fbadSmrg# func_split_long_opt longopt
814f353fbadSmrg# Set func_split_long_opt_name and func_split_long_opt_arg shell
815f353fbadSmrg# variables after splitting LONGOPT at the `=' sign.
816f353fbadSmrgfunc_split_long_opt ()
817f353fbadSmrg{
818f353fbadSmrg    my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q'
819f353fbadSmrg    my_sed_long_arg='1s/^--[^=]*=//'
820f353fbadSmrg
821f353fbadSmrg    func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"`
822f353fbadSmrg    func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"`
823f353fbadSmrg} # func_split_long_opt may be replaced by extended shell implementation
824f353fbadSmrg
825f353fbadSmrgexit_cmd=:
8267a84e134Smrg
827ab902922Smrg
828775e7de9Smrg
8297a84e134Smrg
830994689c1Smrg
831994689c1Smrgmagic="%%%MAGIC variable%%%"
832994689c1Smrgmagic_exe="%%%MAGIC EXE variable%%%"
833994689c1Smrg
834994689c1Smrg# Global variables.
835994689c1Smrgnonopt=
836994689c1Smrgpreserve_args=
837994689c1Smrglo2o="s/\\.lo\$/.${objext}/"
838994689c1Smrgo2lo="s/\\.${objext}\$/.lo/"
839994689c1Smrgextracted_archives=
840994689c1Smrgextracted_serial=0
841994689c1Smrg
842994689c1Smrg# If this variable is set in any of the actions, the command in it
843994689c1Smrg# will be execed at the end.  This prevents here-documents from being
844994689c1Smrg# left over by shells.
845994689c1Smrgexec_cmd=
846994689c1Smrg
847f353fbadSmrg# func_append var value
848f353fbadSmrg# Append VALUE to the end of shell variable VAR.
849f353fbadSmrgfunc_append ()
850f353fbadSmrg{
851f353fbadSmrg    eval "${1}=\$${1}\${2}"
852f353fbadSmrg} # func_append may be replaced by extended shell implementation
853f353fbadSmrg
854f353fbadSmrg# func_append_quoted var value
855f353fbadSmrg# Quote VALUE and append to the end of shell variable VAR, separated
856f353fbadSmrg# by a space.
857f353fbadSmrgfunc_append_quoted ()
858f353fbadSmrg{
859f353fbadSmrg    func_quote_for_eval "${2}"
860f353fbadSmrg    eval "${1}=\$${1}\\ \$func_quote_for_eval_result"
861f353fbadSmrg} # func_append_quoted may be replaced by extended shell implementation
862f353fbadSmrg
863f353fbadSmrg
864f353fbadSmrg# func_arith arithmetic-term...
865f353fbadSmrgfunc_arith ()
866f353fbadSmrg{
867f353fbadSmrg    func_arith_result=`expr "${@}"`
868f353fbadSmrg} # func_arith may be replaced by extended shell implementation
869f353fbadSmrg
870f353fbadSmrg
871f353fbadSmrg# func_len string
872f353fbadSmrg# STRING may not start with a hyphen.
873f353fbadSmrgfunc_len ()
874f353fbadSmrg{
875f353fbadSmrg    func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len`
876f353fbadSmrg} # func_len may be replaced by extended shell implementation
877f353fbadSmrg
878f353fbadSmrg
879f353fbadSmrg# func_lo2o object
880f353fbadSmrgfunc_lo2o ()
881f353fbadSmrg{
882f353fbadSmrg    func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"`
883f353fbadSmrg} # func_lo2o may be replaced by extended shell implementation
884f353fbadSmrg
885f353fbadSmrg
886f353fbadSmrg# func_xform libobj-or-source
887f353fbadSmrgfunc_xform ()
888f353fbadSmrg{
889f353fbadSmrg    func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'`
890f353fbadSmrg} # func_xform may be replaced by extended shell implementation
891f353fbadSmrg
892f353fbadSmrg
893994689c1Smrg# func_fatal_configuration arg...
894994689c1Smrg# Echo program name prefixed message to standard error, followed by
895994689c1Smrg# a configuration failure hint, and exit.
896994689c1Smrgfunc_fatal_configuration ()
897994689c1Smrg{
898994689c1Smrg    func_error ${1+"$@"}
899994689c1Smrg    func_error "See the $PACKAGE documentation for more information."
900994689c1Smrg    func_fatal_error "Fatal configuration error."
901994689c1Smrg}
902994689c1Smrg
903994689c1Smrg
904994689c1Smrg# func_config
905994689c1Smrg# Display the configuration for all the tags in this script.
906994689c1Smrgfunc_config ()
907994689c1Smrg{
908994689c1Smrg    re_begincf='^# ### BEGIN LIBTOOL'
909994689c1Smrg    re_endcf='^# ### END LIBTOOL'
910994689c1Smrg
911994689c1Smrg    # Default configuration.
912994689c1Smrg    $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
913994689c1Smrg
9147a84e134Smrg    # Now print the configurations for the tags.
9157a84e134Smrg    for tagname in $taglist; do
916994689c1Smrg      $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
9177a84e134Smrg    done
918e1e1713cSmrg
919994689c1Smrg    exit $?
920994689c1Smrg}
921e1e1713cSmrg
922994689c1Smrg# func_features
923994689c1Smrg# Display the features supported by this script.
924994689c1Smrgfunc_features ()
925994689c1Smrg{
926994689c1Smrg    echo "host: $host"
9277a84e134Smrg    if test "$build_libtool_libs" = yes; then
928994689c1Smrg      echo "enable shared libraries"
9297a84e134Smrg    else
930994689c1Smrg      echo "disable shared libraries"
9317a84e134Smrg    fi
9327a84e134Smrg    if test "$build_old_libs" = yes; then
933994689c1Smrg      echo "enable static libraries"
9347a84e134Smrg    else
935994689c1Smrg      echo "disable static libraries"
9367a84e134Smrg    fi
937994689c1Smrg
9387a84e134Smrg    exit $?
939994689c1Smrg}
9407a84e134Smrg
941994689c1Smrg# func_enable_tag tagname
942994689c1Smrg# Verify that TAGNAME is valid, and either flag an error and exit, or
943994689c1Smrg# enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
944994689c1Smrg# variable here.
945994689c1Smrgfunc_enable_tag ()
946994689c1Smrg{
947994689c1Smrg  # Global variable:
948994689c1Smrg  tagname="$1"
9497a84e134Smrg
950994689c1Smrg  re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
951994689c1Smrg  re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
952994689c1Smrg  sed_extractcf="/$re_begincf/,/$re_endcf/p"
953775e7de9Smrg
954994689c1Smrg  # Validate tagname.
955994689c1Smrg  case $tagname in
956994689c1Smrg    *[!-_A-Za-z0-9,/]*)
957994689c1Smrg      func_fatal_error "invalid tag name: $tagname"
958994689c1Smrg      ;;
959994689c1Smrg  esac
9607a84e134Smrg
961994689c1Smrg  # Don't test for the "default" C tag, as we know it's
962994689c1Smrg  # there but not specially marked.
963994689c1Smrg  case $tagname in
964994689c1Smrg    CC) ;;
965994689c1Smrg    *)
966994689c1Smrg      if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
967994689c1Smrg	taglist="$taglist $tagname"
968994689c1Smrg
969994689c1Smrg	# Evaluate the configuration.  Be careful to quote the path
970994689c1Smrg	# and the sed script, to avoid splitting on whitespace, but
971994689c1Smrg	# also don't use non-portable quotes within backquotes within
972994689c1Smrg	# quotes we have to do it in 2 steps:
973994689c1Smrg	extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
974994689c1Smrg	eval "$extractedcf"
975994689c1Smrg      else
976994689c1Smrg	func_error "ignoring unknown tag $tagname"
977994689c1Smrg      fi
978994689c1Smrg      ;;
979994689c1Smrg  esac
980994689c1Smrg}
981994689c1Smrg
982f353fbadSmrg# func_check_version_match
983f353fbadSmrg# Ensure that we are using m4 macros, and libtool script from the same
984f353fbadSmrg# release of libtool.
985f353fbadSmrgfunc_check_version_match ()
986994689c1Smrg{
987f353fbadSmrg  if test "$package_revision" != "$macro_revision"; then
988f353fbadSmrg    if test "$VERSION" != "$macro_version"; then
989f353fbadSmrg      if test -z "$macro_version"; then
990f353fbadSmrg        cat >&2 <<_LT_EOF
991f353fbadSmrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
992f353fbadSmrg$progname: definition of this LT_INIT comes from an older release.
993f353fbadSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
994f353fbadSmrg$progname: and run autoconf again.
995f353fbadSmrg_LT_EOF
996f353fbadSmrg      else
997f353fbadSmrg        cat >&2 <<_LT_EOF
998f353fbadSmrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
999f353fbadSmrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
1000f353fbadSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
1001f353fbadSmrg$progname: and run autoconf again.
1002f353fbadSmrg_LT_EOF
1003f353fbadSmrg      fi
1004f353fbadSmrg    else
1005f353fbadSmrg      cat >&2 <<_LT_EOF
1006f353fbadSmrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
1007f353fbadSmrg$progname: but the definition of this LT_INIT comes from revision $macro_revision.
1008f353fbadSmrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision
1009f353fbadSmrg$progname: of $PACKAGE $VERSION and run autoconf again.
1010f353fbadSmrg_LT_EOF
1011f353fbadSmrg    fi
1012e1e1713cSmrg
1013f353fbadSmrg    exit $EXIT_MISMATCH
1014f353fbadSmrg  fi
1015f353fbadSmrg}
1016f353fbadSmrg
1017f353fbadSmrg
1018f353fbadSmrg# Shorthand for --mode=foo, only valid as the first argument
1019f353fbadSmrgcase $1 in
1020f353fbadSmrgclean|clea|cle|cl)
1021f353fbadSmrg  shift; set dummy --mode clean ${1+"$@"}; shift
1022f353fbadSmrg  ;;
1023f353fbadSmrgcompile|compil|compi|comp|com|co|c)
1024f353fbadSmrg  shift; set dummy --mode compile ${1+"$@"}; shift
1025f353fbadSmrg  ;;
1026f353fbadSmrgexecute|execut|execu|exec|exe|ex|e)
1027f353fbadSmrg  shift; set dummy --mode execute ${1+"$@"}; shift
1028f353fbadSmrg  ;;
1029f353fbadSmrgfinish|finis|fini|fin|fi|f)
1030f353fbadSmrg  shift; set dummy --mode finish ${1+"$@"}; shift
1031f353fbadSmrg  ;;
1032f353fbadSmrginstall|instal|insta|inst|ins|in|i)
1033f353fbadSmrg  shift; set dummy --mode install ${1+"$@"}; shift
1034f353fbadSmrg  ;;
1035f353fbadSmrglink|lin|li|l)
1036f353fbadSmrg  shift; set dummy --mode link ${1+"$@"}; shift
1037f353fbadSmrg  ;;
1038f353fbadSmrguninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
1039f353fbadSmrg  shift; set dummy --mode uninstall ${1+"$@"}; shift
1040f353fbadSmrg  ;;
1041f353fbadSmrgesac
10427a84e134Smrg
1043f353fbadSmrg
1044f353fbadSmrg
1045f353fbadSmrg# Option defaults:
1046f353fbadSmrgopt_debug=:
1047f353fbadSmrgopt_dry_run=false
1048f353fbadSmrgopt_config=false
1049f353fbadSmrgopt_preserve_dup_deps=false
1050f353fbadSmrgopt_features=false
1051f353fbadSmrgopt_finish=false
1052f353fbadSmrgopt_help=false
1053f353fbadSmrgopt_help_all=false
1054f353fbadSmrgopt_silent=:
1055f353fbadSmrgopt_verbose=:
1056f353fbadSmrgopt_silent=false
1057f353fbadSmrgopt_verbose=false
1058f353fbadSmrg
1059f353fbadSmrg
1060f353fbadSmrg# Parse options once, thoroughly.  This comes as soon as possible in the
1061f353fbadSmrg# script to make things like `--version' happen as quickly as we can.
1062f353fbadSmrg{
1063f353fbadSmrg  # this just eases exit handling
1064f353fbadSmrg  while test $# -gt 0; do
1065994689c1Smrg    opt="$1"
1066994689c1Smrg    shift
1067994689c1Smrg    case $opt in
1068f353fbadSmrg      --debug|-x)	opt_debug='set -x'
1069994689c1Smrg			func_echo "enabling shell trace mode"
1070994689c1Smrg			$opt_debug
1071994689c1Smrg			;;
1072f353fbadSmrg      --dry-run|--dryrun|-n)
1073f353fbadSmrg			opt_dry_run=:
1074994689c1Smrg			;;
1075f353fbadSmrg      --config)
1076f353fbadSmrg			opt_config=:
1077f353fbadSmrgfunc_config
1078f353fbadSmrg			;;
1079f353fbadSmrg      --dlopen|-dlopen)
1080f353fbadSmrg			optarg="$1"
1081f353fbadSmrg			opt_dlopen="${opt_dlopen+$opt_dlopen
1082f353fbadSmrg}$optarg"
1083994689c1Smrg			shift
1084994689c1Smrg			;;
1085994689c1Smrg      --preserve-dup-deps)
1086f353fbadSmrg			opt_preserve_dup_deps=:
1087994689c1Smrg			;;
1088f353fbadSmrg      --features)
1089f353fbadSmrg			opt_features=:
1090f353fbadSmrgfunc_features
1091994689c1Smrg			;;
1092f353fbadSmrg      --finish)
1093f353fbadSmrg			opt_finish=:
1094f353fbadSmrgset dummy --mode finish ${1+"$@"}; shift
1095f353fbadSmrg			;;
1096f353fbadSmrg      --help)
1097f353fbadSmrg			opt_help=:
1098f353fbadSmrg			;;
1099f353fbadSmrg      --help-all)
1100f353fbadSmrg			opt_help_all=:
1101f353fbadSmrgopt_help=': help-all'
1102f353fbadSmrg			;;
1103f353fbadSmrg      --mode)
1104f353fbadSmrg			test $# = 0 && func_missing_arg $opt && break
1105f353fbadSmrg			optarg="$1"
1106f353fbadSmrg			opt_mode="$optarg"
1107f353fbadSmrgcase $optarg in
1108f353fbadSmrg  # Valid mode arguments:
1109f353fbadSmrg  clean|compile|execute|finish|install|link|relink|uninstall) ;;
1110f353fbadSmrg
1111f353fbadSmrg  # Catch anything else as an error
1112f353fbadSmrg  *) func_error "invalid argument for $opt"
1113f353fbadSmrg     exit_cmd=exit
1114f353fbadSmrg     break
1115f353fbadSmrg     ;;
1116f353fbadSmrgesac
1117f353fbadSmrg			shift
1118f353fbadSmrg			;;
1119f353fbadSmrg      --no-silent|--no-quiet)
1120994689c1Smrg			opt_silent=false
1121f353fbadSmrgfunc_append preserve_args " $opt"
1122994689c1Smrg			;;
1123f353fbadSmrg      --no-verbose)
1124994689c1Smrg			opt_verbose=false
1125f353fbadSmrgfunc_append preserve_args " $opt"
1126994689c1Smrg			;;
1127f353fbadSmrg      --silent|--quiet)
1128f353fbadSmrg			opt_silent=:
1129f353fbadSmrgfunc_append preserve_args " $opt"
1130f353fbadSmrg        opt_verbose=false
1131f353fbadSmrg			;;
1132f353fbadSmrg      --verbose|-v)
1133f353fbadSmrg			opt_verbose=:
1134f353fbadSmrgfunc_append preserve_args " $opt"
1135f353fbadSmrgopt_silent=false
1136f353fbadSmrg			;;
1137f353fbadSmrg      --tag)
1138f353fbadSmrg			test $# = 0 && func_missing_arg $opt && break
1139f353fbadSmrg			optarg="$1"
1140f353fbadSmrg			opt_tag="$optarg"
1141f353fbadSmrgfunc_append preserve_args " $opt $optarg"
1142f353fbadSmrgfunc_enable_tag "$optarg"
1143994689c1Smrg			shift
1144994689c1Smrg			;;
1145994689c1Smrg
1146f353fbadSmrg      -\?|-h)		func_usage				;;
1147f353fbadSmrg      --help)		func_help				;;
1148f353fbadSmrg      --version)	func_version				;;
1149f353fbadSmrg
1150994689c1Smrg      # Separate optargs to long options:
1151f353fbadSmrg      --*=*)
1152f353fbadSmrg			func_split_long_opt "$opt"
1153f353fbadSmrg			set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"}
1154994689c1Smrg			shift
1155994689c1Smrg			;;
1156994689c1Smrg
1157f353fbadSmrg      # Separate non-argument short options:
1158f353fbadSmrg      -\?*|-h*|-n*|-v*)
1159f353fbadSmrg			func_split_short_opt "$opt"
1160f353fbadSmrg			set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"}
1161f353fbadSmrg			shift
1162994689c1Smrg			;;
1163f353fbadSmrg
1164f353fbadSmrg      --)		break					;;
1165f353fbadSmrg      -*)		func_fatal_help "unrecognized option \`$opt'" ;;
1166f353fbadSmrg      *)		set dummy "$opt" ${1+"$@"};	shift; break  ;;
1167994689c1Smrg    esac
1168994689c1Smrg  done
1169994689c1Smrg
1170f353fbadSmrg  # Validate options:
1171f353fbadSmrg
1172f353fbadSmrg  # save first non-option argument
1173f353fbadSmrg  if test "$#" -gt 0; then
1174f353fbadSmrg    nonopt="$opt"
1175f353fbadSmrg    shift
1176f353fbadSmrg  fi
1177f353fbadSmrg
1178f353fbadSmrg  # preserve --debug
1179f353fbadSmrg  test "$opt_debug" = : || func_append preserve_args " --debug"
1180994689c1Smrg
1181994689c1Smrg  case $host in
1182994689c1Smrg    *cygwin* | *mingw* | *pw32* | *cegcc*)
1183994689c1Smrg      # don't eliminate duplications in $postdeps and $predeps
1184994689c1Smrg      opt_duplicate_compiler_generated_deps=:
1185e1e1713cSmrg      ;;
1186e1e1713cSmrg    *)
1187f353fbadSmrg      opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
1188994689c1Smrg      ;;
1189994689c1Smrg  esac
1190775e7de9Smrg
1191f353fbadSmrg  $opt_help || {
1192f353fbadSmrg    # Sanity checks first:
1193f353fbadSmrg    func_check_version_match
1194994689c1Smrg
1195f353fbadSmrg    if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
1196f353fbadSmrg      func_fatal_configuration "not configured to build any kind of library"
1197994689c1Smrg    fi
1198994689c1Smrg
1199f353fbadSmrg    # Darwin sucks
1200f353fbadSmrg    eval std_shrext=\"$shrext_cmds\"
1201994689c1Smrg
1202f353fbadSmrg    # Only execute mode is allowed to have -dlopen flags.
1203f353fbadSmrg    if test -n "$opt_dlopen" && test "$opt_mode" != execute; then
1204f353fbadSmrg      func_error "unrecognized option \`-dlopen'"
1205f353fbadSmrg      $ECHO "$help" 1>&2
1206f353fbadSmrg      exit $EXIT_FAILURE
1207f353fbadSmrg    fi
1208994689c1Smrg
1209f353fbadSmrg    # Change the help message to a mode-specific one.
1210f353fbadSmrg    generic_help="$help"
1211f353fbadSmrg    help="Try \`$progname --help --mode=$opt_mode' for more information."
1212f353fbadSmrg  }
1213994689c1Smrg
1214994689c1Smrg
1215f353fbadSmrg  # Bail if the options were screwed
1216f353fbadSmrg  $exit_cmd $EXIT_FAILURE
1217f353fbadSmrg}
1218994689c1Smrg
1219994689c1Smrg
12207a84e134Smrg
12217a84e134Smrg
1222f353fbadSmrg## ----------- ##
1223f353fbadSmrg##    Main.    ##
1224f353fbadSmrg## ----------- ##
12257a84e134Smrg
1226994689c1Smrg# func_lalib_p file
1227994689c1Smrg# True iff FILE is a libtool `.la' library or `.lo' object file.
1228994689c1Smrg# This function is only a basic sanity check; it will hardly flush out
1229994689c1Smrg# determined imposters.
1230994689c1Smrgfunc_lalib_p ()
1231994689c1Smrg{
1232994689c1Smrg    test -f "$1" &&
1233994689c1Smrg      $SED -e 4q "$1" 2>/dev/null \
1234994689c1Smrg        | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
1235994689c1Smrg}
12367a84e134Smrg
1237994689c1Smrg# func_lalib_unsafe_p file
1238994689c1Smrg# True iff FILE is a libtool `.la' library or `.lo' object file.
1239994689c1Smrg# This function implements the same check as func_lalib_p without
1240994689c1Smrg# resorting to external programs.  To this end, it redirects stdin and
1241994689c1Smrg# closes it afterwards, without saving the original file descriptor.
1242994689c1Smrg# As a safety measure, use it only where a negative result would be
1243994689c1Smrg# fatal anyway.  Works if `file' does not exist.
1244994689c1Smrgfunc_lalib_unsafe_p ()
1245994689c1Smrg{
1246994689c1Smrg    lalib_p=no
1247994689c1Smrg    if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
1248994689c1Smrg	for lalib_p_l in 1 2 3 4
1249994689c1Smrg	do
1250994689c1Smrg	    read lalib_p_line
1251994689c1Smrg	    case "$lalib_p_line" in
1252994689c1Smrg		\#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
1253994689c1Smrg	    esac
1254994689c1Smrg	done
1255994689c1Smrg	exec 0<&5 5<&-
1256994689c1Smrg    fi
1257994689c1Smrg    test "$lalib_p" = yes
1258994689c1Smrg}
12597a84e134Smrg
1260994689c1Smrg# func_ltwrapper_script_p file
1261994689c1Smrg# True iff FILE is a libtool wrapper script
1262994689c1Smrg# This function is only a basic sanity check; it will hardly flush out
1263994689c1Smrg# determined imposters.
1264994689c1Smrgfunc_ltwrapper_script_p ()
1265994689c1Smrg{
1266994689c1Smrg    func_lalib_p "$1"
1267994689c1Smrg}
12687a84e134Smrg
1269994689c1Smrg# func_ltwrapper_executable_p file
1270994689c1Smrg# True iff FILE is a libtool wrapper executable
1271994689c1Smrg# This function is only a basic sanity check; it will hardly flush out
1272994689c1Smrg# determined imposters.
1273994689c1Smrgfunc_ltwrapper_executable_p ()
1274994689c1Smrg{
1275994689c1Smrg    func_ltwrapper_exec_suffix=
1276994689c1Smrg    case $1 in
1277994689c1Smrg    *.exe) ;;
1278994689c1Smrg    *) func_ltwrapper_exec_suffix=.exe ;;
1279994689c1Smrg    esac
1280994689c1Smrg    $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
1281994689c1Smrg}
1282994689c1Smrg
1283994689c1Smrg# func_ltwrapper_scriptname file
1284994689c1Smrg# Assumes file is an ltwrapper_executable
1285994689c1Smrg# uses $file to determine the appropriate filename for a
1286994689c1Smrg# temporary ltwrapper_script.
1287994689c1Smrgfunc_ltwrapper_scriptname ()
1288994689c1Smrg{
1289f353fbadSmrg    func_dirname_and_basename "$1" "" "."
1290f353fbadSmrg    func_stripname '' '.exe' "$func_basename_result"
1291f353fbadSmrg    func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper"
1292994689c1Smrg}
1293994689c1Smrg
1294994689c1Smrg# func_ltwrapper_p file
1295994689c1Smrg# True iff FILE is a libtool wrapper script or wrapper executable
1296994689c1Smrg# This function is only a basic sanity check; it will hardly flush out
1297994689c1Smrg# determined imposters.
1298994689c1Smrgfunc_ltwrapper_p ()
1299994689c1Smrg{
1300994689c1Smrg    func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
1301994689c1Smrg}
1302994689c1Smrg
1303994689c1Smrg
1304994689c1Smrg# func_execute_cmds commands fail_cmd
1305994689c1Smrg# Execute tilde-delimited COMMANDS.
1306994689c1Smrg# If FAIL_CMD is given, eval that upon failure.
1307994689c1Smrg# FAIL_CMD may read-access the current command in variable CMD!
1308994689c1Smrgfunc_execute_cmds ()
1309994689c1Smrg{
1310994689c1Smrg    $opt_debug
1311994689c1Smrg    save_ifs=$IFS; IFS='~'
1312994689c1Smrg    for cmd in $1; do
1313994689c1Smrg      IFS=$save_ifs
1314994689c1Smrg      eval cmd=\"$cmd\"
1315994689c1Smrg      func_show_eval "$cmd" "${2-:}"
1316994689c1Smrg    done
1317994689c1Smrg    IFS=$save_ifs
1318994689c1Smrg}
1319994689c1Smrg
1320994689c1Smrg
1321994689c1Smrg# func_source file
1322994689c1Smrg# Source FILE, adding directory component if necessary.
1323994689c1Smrg# Note that it is not necessary on cygwin/mingw to append a dot to
1324994689c1Smrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe
1325994689c1Smrg# behavior happens only for exec(3), not for open(2)!  Also, sourcing
1326994689c1Smrg# `FILE.' does not work on cygwin managed mounts.
1327994689c1Smrgfunc_source ()
1328994689c1Smrg{
1329994689c1Smrg    $opt_debug
1330994689c1Smrg    case $1 in
1331994689c1Smrg    */* | *\\*)	. "$1" ;;
1332994689c1Smrg    *)		. "./$1" ;;
1333994689c1Smrg    esac
1334994689c1Smrg}
1335994689c1Smrg
1336994689c1Smrg
1337f353fbadSmrg# func_resolve_sysroot PATH
1338f353fbadSmrg# Replace a leading = in PATH with a sysroot.  Store the result into
1339f353fbadSmrg# func_resolve_sysroot_result
1340f353fbadSmrgfunc_resolve_sysroot ()
1341f353fbadSmrg{
1342f353fbadSmrg  func_resolve_sysroot_result=$1
1343f353fbadSmrg  case $func_resolve_sysroot_result in
1344f353fbadSmrg  =*)
1345f353fbadSmrg    func_stripname '=' '' "$func_resolve_sysroot_result"
1346f353fbadSmrg    func_resolve_sysroot_result=$lt_sysroot$func_stripname_result
1347f353fbadSmrg    ;;
1348f353fbadSmrg  esac
1349f353fbadSmrg}
1350f353fbadSmrg
1351f353fbadSmrg# func_replace_sysroot PATH
1352f353fbadSmrg# If PATH begins with the sysroot, replace it with = and
1353f353fbadSmrg# store the result into func_replace_sysroot_result.
1354f353fbadSmrgfunc_replace_sysroot ()
1355f353fbadSmrg{
1356f353fbadSmrg  case "$lt_sysroot:$1" in
1357f353fbadSmrg  ?*:"$lt_sysroot"*)
1358f353fbadSmrg    func_stripname "$lt_sysroot" '' "$1"
1359f353fbadSmrg    func_replace_sysroot_result="=$func_stripname_result"
1360f353fbadSmrg    ;;
1361f353fbadSmrg  *)
1362f353fbadSmrg    # Including no sysroot.
1363f353fbadSmrg    func_replace_sysroot_result=$1
1364f353fbadSmrg    ;;
1365f353fbadSmrg  esac
1366f353fbadSmrg}
1367f353fbadSmrg
1368994689c1Smrg# func_infer_tag arg
1369994689c1Smrg# Infer tagged configuration to use if any are available and
1370994689c1Smrg# if one wasn't chosen via the "--tag" command line option.
1371994689c1Smrg# Only attempt this if the compiler in the base compile
1372994689c1Smrg# command doesn't match the default compiler.
1373994689c1Smrg# arg is usually of the form 'gcc ...'
1374994689c1Smrgfunc_infer_tag ()
1375994689c1Smrg{
1376994689c1Smrg    $opt_debug
1377994689c1Smrg    if test -n "$available_tags" && test -z "$tagname"; then
1378994689c1Smrg      CC_quoted=
1379994689c1Smrg      for arg in $CC; do
1380f353fbadSmrg	func_append_quoted CC_quoted "$arg"
1381994689c1Smrg      done
1382994689c1Smrg      CC_expanded=`func_echo_all $CC`
1383994689c1Smrg      CC_quoted_expanded=`func_echo_all $CC_quoted`
1384994689c1Smrg      case $@ in
1385994689c1Smrg      # Blanks in the command may have been stripped by the calling shell,
1386994689c1Smrg      # but not from the CC environment variable when configure was run.
1387994689c1Smrg      " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
1388994689c1Smrg      " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
1389994689c1Smrg      # Blanks at the start of $base_compile will cause this to fail
1390994689c1Smrg      # if we don't check for them as well.
1391994689c1Smrg      *)
1392994689c1Smrg	for z in $available_tags; do
1393994689c1Smrg	  if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
1394994689c1Smrg	    # Evaluate the configuration.
1395994689c1Smrg	    eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
1396994689c1Smrg	    CC_quoted=
1397994689c1Smrg	    for arg in $CC; do
1398994689c1Smrg	      # Double-quote args containing other shell metacharacters.
1399f353fbadSmrg	      func_append_quoted CC_quoted "$arg"
1400994689c1Smrg	    done
1401994689c1Smrg	    CC_expanded=`func_echo_all $CC`
1402994689c1Smrg	    CC_quoted_expanded=`func_echo_all $CC_quoted`
1403994689c1Smrg	    case "$@ " in
1404994689c1Smrg	    " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
1405994689c1Smrg	    " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
1406994689c1Smrg	      # The compiler in the base compile command matches
1407994689c1Smrg	      # the one in the tagged configuration.
1408994689c1Smrg	      # Assume this is the tagged configuration we want.
1409994689c1Smrg	      tagname=$z
1410994689c1Smrg	      break
1411994689c1Smrg	      ;;
1412994689c1Smrg	    esac
1413994689c1Smrg	  fi
1414994689c1Smrg	done
1415994689c1Smrg	# If $tagname still isn't set, then no tagged configuration
1416994689c1Smrg	# was found and let the user know that the "--tag" command
1417994689c1Smrg	# line option must be used.
1418994689c1Smrg	if test -z "$tagname"; then
1419994689c1Smrg	  func_echo "unable to infer tagged configuration"
1420994689c1Smrg	  func_fatal_error "specify a tag with \`--tag'"
1421994689c1Smrg#	else
1422994689c1Smrg#	  func_verbose "using $tagname tagged configuration"
1423994689c1Smrg	fi
1424994689c1Smrg	;;
1425994689c1Smrg      esac
1426994689c1Smrg    fi
1427994689c1Smrg}
1428994689c1Smrg
1429994689c1Smrg
1430994689c1Smrg
1431f353fbadSmrg# func_write_libtool_object output_name pic_name nonpic_name
1432f353fbadSmrg# Create a libtool object file (analogous to a ".la" file),
1433f353fbadSmrg# but don't create it if we're doing a dry run.
1434f353fbadSmrgfunc_write_libtool_object ()
1435f353fbadSmrg{
1436f353fbadSmrg    write_libobj=${1}
1437f353fbadSmrg    if test "$build_libtool_libs" = yes; then
1438f353fbadSmrg      write_lobj=\'${2}\'
1439f353fbadSmrg    else
1440f353fbadSmrg      write_lobj=none
1441f353fbadSmrg    fi
1442f353fbadSmrg
1443f353fbadSmrg    if test "$build_old_libs" = yes; then
1444f353fbadSmrg      write_oldobj=\'${3}\'
1445f353fbadSmrg    else
1446f353fbadSmrg      write_oldobj=none
1447f353fbadSmrg    fi
1448f353fbadSmrg
1449f353fbadSmrg    $opt_dry_run || {
1450f353fbadSmrg      cat >${write_libobj}T <<EOF
1451f353fbadSmrg# $write_libobj - a libtool object file
1452f353fbadSmrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
1453f353fbadSmrg#
1454f353fbadSmrg# Please DO NOT delete this file!
1455f353fbadSmrg# It is necessary for linking the library.
1456f353fbadSmrg
1457f353fbadSmrg# Name of the PIC object.
1458f353fbadSmrgpic_object=$write_lobj
1459f353fbadSmrg
1460f353fbadSmrg# Name of the non-PIC object
1461f353fbadSmrgnon_pic_object=$write_oldobj
1462f353fbadSmrg
1463f353fbadSmrgEOF
1464f353fbadSmrg      $MV "${write_libobj}T" "${write_libobj}"
1465f353fbadSmrg    }
1466f353fbadSmrg}
1467f353fbadSmrg
1468f353fbadSmrg
1469f353fbadSmrg##################################################
1470f353fbadSmrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS #
1471f353fbadSmrg##################################################
1472f353fbadSmrg
1473f353fbadSmrg# func_convert_core_file_wine_to_w32 ARG
1474f353fbadSmrg# Helper function used by file name conversion functions when $build is *nix,
1475f353fbadSmrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a
1476f353fbadSmrg# correctly configured wine environment available, with the winepath program
1477f353fbadSmrg# in $build's $PATH.
1478f353fbadSmrg#
1479f353fbadSmrg# ARG is the $build file name to be converted to w32 format.
1480f353fbadSmrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will
1481f353fbadSmrg# be empty on error (or when ARG is empty)
1482f353fbadSmrgfunc_convert_core_file_wine_to_w32 ()
1483f353fbadSmrg{
1484f353fbadSmrg  $opt_debug
1485f353fbadSmrg  func_convert_core_file_wine_to_w32_result="$1"
1486f353fbadSmrg  if test -n "$1"; then
1487f353fbadSmrg    # Unfortunately, winepath does not exit with a non-zero error code, so we
1488f353fbadSmrg    # are forced to check the contents of stdout. On the other hand, if the
1489f353fbadSmrg    # command is not found, the shell will set an exit code of 127 and print
1490f353fbadSmrg    # *an error message* to stdout. So we must check for both error code of
1491f353fbadSmrg    # zero AND non-empty stdout, which explains the odd construction:
1492f353fbadSmrg    func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
1493f353fbadSmrg    if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then
1494f353fbadSmrg      func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
1495f353fbadSmrg        $SED -e "$lt_sed_naive_backslashify"`
1496f353fbadSmrg    else
1497f353fbadSmrg      func_convert_core_file_wine_to_w32_result=
1498f353fbadSmrg    fi
1499f353fbadSmrg  fi
1500f353fbadSmrg}
1501f353fbadSmrg# end: func_convert_core_file_wine_to_w32
1502f353fbadSmrg
1503f353fbadSmrg
1504f353fbadSmrg# func_convert_core_path_wine_to_w32 ARG
1505f353fbadSmrg# Helper function used by path conversion functions when $build is *nix, and
1506f353fbadSmrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly
1507f353fbadSmrg# configured wine environment available, with the winepath program in $build's
1508f353fbadSmrg# $PATH. Assumes ARG has no leading or trailing path separator characters.
1509f353fbadSmrg#
1510f353fbadSmrg# ARG is path to be converted from $build format to win32.
1511f353fbadSmrg# Result is available in $func_convert_core_path_wine_to_w32_result.
1512f353fbadSmrg# Unconvertible file (directory) names in ARG are skipped; if no directory names
1513f353fbadSmrg# are convertible, then the result may be empty.
1514f353fbadSmrgfunc_convert_core_path_wine_to_w32 ()
1515f353fbadSmrg{
1516f353fbadSmrg  $opt_debug
1517f353fbadSmrg  # unfortunately, winepath doesn't convert paths, only file names
1518f353fbadSmrg  func_convert_core_path_wine_to_w32_result=""
1519f353fbadSmrg  if test -n "$1"; then
1520f353fbadSmrg    oldIFS=$IFS
1521f353fbadSmrg    IFS=:
1522f353fbadSmrg    for func_convert_core_path_wine_to_w32_f in $1; do
1523f353fbadSmrg      IFS=$oldIFS
1524f353fbadSmrg      func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
1525f353fbadSmrg      if test -n "$func_convert_core_file_wine_to_w32_result" ; then
1526f353fbadSmrg        if test -z "$func_convert_core_path_wine_to_w32_result"; then
1527f353fbadSmrg          func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result"
1528f353fbadSmrg        else
1529f353fbadSmrg          func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
1530f353fbadSmrg        fi
1531f353fbadSmrg      fi
1532f353fbadSmrg    done
1533f353fbadSmrg    IFS=$oldIFS
1534f353fbadSmrg  fi
1535f353fbadSmrg}
1536f353fbadSmrg# end: func_convert_core_path_wine_to_w32
1537f353fbadSmrg
1538f353fbadSmrg
1539f353fbadSmrg# func_cygpath ARGS...
1540f353fbadSmrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when
1541f353fbadSmrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2)
1542f353fbadSmrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or
1543f353fbadSmrg# (2), returns the Cygwin file name or path in func_cygpath_result (input
1544f353fbadSmrg# file name or path is assumed to be in w32 format, as previously converted
1545f353fbadSmrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name
1546f353fbadSmrg# or path in func_cygpath_result (input file name or path is assumed to be in
1547f353fbadSmrg# Cygwin format). Returns an empty string on error.
1548f353fbadSmrg#
1549f353fbadSmrg# ARGS are passed to cygpath, with the last one being the file name or path to
1550f353fbadSmrg# be converted.
1551f353fbadSmrg#
1552f353fbadSmrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH
1553f353fbadSmrg# environment variable; do not put it in $PATH.
1554f353fbadSmrgfunc_cygpath ()
1555f353fbadSmrg{
1556f353fbadSmrg  $opt_debug
1557f353fbadSmrg  if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
1558f353fbadSmrg    func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
1559f353fbadSmrg    if test "$?" -ne 0; then
1560f353fbadSmrg      # on failure, ensure result is empty
1561f353fbadSmrg      func_cygpath_result=
1562f353fbadSmrg    fi
1563f353fbadSmrg  else
1564f353fbadSmrg    func_cygpath_result=
1565f353fbadSmrg    func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'"
1566f353fbadSmrg  fi
1567f353fbadSmrg}
1568f353fbadSmrg#end: func_cygpath
1569f353fbadSmrg
1570f353fbadSmrg
1571f353fbadSmrg# func_convert_core_msys_to_w32 ARG
1572f353fbadSmrg# Convert file name or path ARG from MSYS format to w32 format.  Return
1573f353fbadSmrg# result in func_convert_core_msys_to_w32_result.
1574f353fbadSmrgfunc_convert_core_msys_to_w32 ()
1575f353fbadSmrg{
1576f353fbadSmrg  $opt_debug
1577f353fbadSmrg  # awkward: cmd appends spaces to result
1578f353fbadSmrg  func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
1579f353fbadSmrg    $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"`
1580f353fbadSmrg}
1581f353fbadSmrg#end: func_convert_core_msys_to_w32
1582f353fbadSmrg
1583f353fbadSmrg
1584f353fbadSmrg# func_convert_file_check ARG1 ARG2
1585f353fbadSmrg# Verify that ARG1 (a file name in $build format) was converted to $host
1586f353fbadSmrg# format in ARG2. Otherwise, emit an error message, but continue (resetting
1587f353fbadSmrg# func_to_host_file_result to ARG1).
1588f353fbadSmrgfunc_convert_file_check ()
1589f353fbadSmrg{
1590f353fbadSmrg  $opt_debug
1591f353fbadSmrg  if test -z "$2" && test -n "$1" ; then
1592f353fbadSmrg    func_error "Could not determine host file name corresponding to"
1593f353fbadSmrg    func_error "  \`$1'"
1594f353fbadSmrg    func_error "Continuing, but uninstalled executables may not work."
1595f353fbadSmrg    # Fallback:
1596f353fbadSmrg    func_to_host_file_result="$1"
1597f353fbadSmrg  fi
1598f353fbadSmrg}
1599f353fbadSmrg# end func_convert_file_check
1600f353fbadSmrg
1601f353fbadSmrg
1602f353fbadSmrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH
1603f353fbadSmrg# Verify that FROM_PATH (a path in $build format) was converted to $host
1604f353fbadSmrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting
1605f353fbadSmrg# func_to_host_file_result to a simplistic fallback value (see below).
1606f353fbadSmrgfunc_convert_path_check ()
1607f353fbadSmrg{
1608f353fbadSmrg  $opt_debug
1609f353fbadSmrg  if test -z "$4" && test -n "$3"; then
1610f353fbadSmrg    func_error "Could not determine the host path corresponding to"
1611f353fbadSmrg    func_error "  \`$3'"
1612f353fbadSmrg    func_error "Continuing, but uninstalled executables may not work."
1613f353fbadSmrg    # Fallback.  This is a deliberately simplistic "conversion" and
1614f353fbadSmrg    # should not be "improved".  See libtool.info.
1615f353fbadSmrg    if test "x$1" != "x$2"; then
1616f353fbadSmrg      lt_replace_pathsep_chars="s|$1|$2|g"
1617f353fbadSmrg      func_to_host_path_result=`echo "$3" |
1618f353fbadSmrg        $SED -e "$lt_replace_pathsep_chars"`
1619f353fbadSmrg    else
1620f353fbadSmrg      func_to_host_path_result="$3"
1621f353fbadSmrg    fi
1622f353fbadSmrg  fi
1623f353fbadSmrg}
1624f353fbadSmrg# end func_convert_path_check
1625f353fbadSmrg
1626f353fbadSmrg
1627f353fbadSmrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG
1628f353fbadSmrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT
1629f353fbadSmrg# and appending REPL if ORIG matches BACKPAT.
1630f353fbadSmrgfunc_convert_path_front_back_pathsep ()
1631f353fbadSmrg{
1632f353fbadSmrg  $opt_debug
1633f353fbadSmrg  case $4 in
1634f353fbadSmrg  $1 ) func_to_host_path_result="$3$func_to_host_path_result"
1635f353fbadSmrg    ;;
1636f353fbadSmrg  esac
1637f353fbadSmrg  case $4 in
1638f353fbadSmrg  $2 ) func_append func_to_host_path_result "$3"
1639f353fbadSmrg    ;;
1640f353fbadSmrg  esac
1641f353fbadSmrg}
1642f353fbadSmrg# end func_convert_path_front_back_pathsep
1643f353fbadSmrg
1644f353fbadSmrg
1645f353fbadSmrg##################################################
1646f353fbadSmrg# $build to $host FILE NAME CONVERSION FUNCTIONS #
1647f353fbadSmrg##################################################
1648f353fbadSmrg# invoked via `$to_host_file_cmd ARG'
1649f353fbadSmrg#
1650f353fbadSmrg# In each case, ARG is the path to be converted from $build to $host format.
1651f353fbadSmrg# Result will be available in $func_to_host_file_result.
1652f353fbadSmrg
1653f353fbadSmrg
1654f353fbadSmrg# func_to_host_file ARG
1655f353fbadSmrg# Converts the file name ARG from $build format to $host format. Return result
1656f353fbadSmrg# in func_to_host_file_result.
1657f353fbadSmrgfunc_to_host_file ()
1658f353fbadSmrg{
1659f353fbadSmrg  $opt_debug
1660f353fbadSmrg  $to_host_file_cmd "$1"
1661f353fbadSmrg}
1662f353fbadSmrg# end func_to_host_file
1663f353fbadSmrg
1664f353fbadSmrg
1665f353fbadSmrg# func_to_tool_file ARG LAZY
1666f353fbadSmrg# converts the file name ARG from $build format to toolchain format. Return
1667f353fbadSmrg# result in func_to_tool_file_result.  If the conversion in use is listed
1668f353fbadSmrg# in (the comma separated) LAZY, no conversion takes place.
1669f353fbadSmrgfunc_to_tool_file ()
1670f353fbadSmrg{
1671f353fbadSmrg  $opt_debug
1672f353fbadSmrg  case ,$2, in
1673f353fbadSmrg    *,"$to_tool_file_cmd",*)
1674f353fbadSmrg      func_to_tool_file_result=$1
1675f353fbadSmrg      ;;
1676f353fbadSmrg    *)
1677f353fbadSmrg      $to_tool_file_cmd "$1"
1678f353fbadSmrg      func_to_tool_file_result=$func_to_host_file_result
1679f353fbadSmrg      ;;
1680f353fbadSmrg  esac
1681f353fbadSmrg}
1682f353fbadSmrg# end func_to_tool_file
1683f353fbadSmrg
1684f353fbadSmrg
1685f353fbadSmrg# func_convert_file_noop ARG
1686f353fbadSmrg# Copy ARG to func_to_host_file_result.
1687f353fbadSmrgfunc_convert_file_noop ()
1688f353fbadSmrg{
1689f353fbadSmrg  func_to_host_file_result="$1"
1690f353fbadSmrg}
1691f353fbadSmrg# end func_convert_file_noop
1692f353fbadSmrg
1693f353fbadSmrg
1694f353fbadSmrg# func_convert_file_msys_to_w32 ARG
1695f353fbadSmrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic
1696f353fbadSmrg# conversion to w32 is not available inside the cwrapper.  Returns result in
1697f353fbadSmrg# func_to_host_file_result.
1698f353fbadSmrgfunc_convert_file_msys_to_w32 ()
1699f353fbadSmrg{
1700f353fbadSmrg  $opt_debug
1701f353fbadSmrg  func_to_host_file_result="$1"
1702f353fbadSmrg  if test -n "$1"; then
1703f353fbadSmrg    func_convert_core_msys_to_w32 "$1"
1704f353fbadSmrg    func_to_host_file_result="$func_convert_core_msys_to_w32_result"
1705f353fbadSmrg  fi
1706f353fbadSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
1707f353fbadSmrg}
1708f353fbadSmrg# end func_convert_file_msys_to_w32
1709f353fbadSmrg
1710f353fbadSmrg
1711f353fbadSmrg# func_convert_file_cygwin_to_w32 ARG
1712f353fbadSmrg# Convert file name ARG from Cygwin to w32 format.  Returns result in
1713f353fbadSmrg# func_to_host_file_result.
1714f353fbadSmrgfunc_convert_file_cygwin_to_w32 ()
1715f353fbadSmrg{
1716f353fbadSmrg  $opt_debug
1717f353fbadSmrg  func_to_host_file_result="$1"
1718f353fbadSmrg  if test -n "$1"; then
1719f353fbadSmrg    # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
1720f353fbadSmrg    # LT_CYGPATH in this case.
1721f353fbadSmrg    func_to_host_file_result=`cygpath -m "$1"`
1722f353fbadSmrg  fi
1723f353fbadSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
1724f353fbadSmrg}
1725f353fbadSmrg# end func_convert_file_cygwin_to_w32
1726f353fbadSmrg
1727f353fbadSmrg
1728f353fbadSmrg# func_convert_file_nix_to_w32 ARG
1729f353fbadSmrg# Convert file name ARG from *nix to w32 format.  Requires a wine environment
1730f353fbadSmrg# and a working winepath. Returns result in func_to_host_file_result.
1731f353fbadSmrgfunc_convert_file_nix_to_w32 ()
1732f353fbadSmrg{
1733f353fbadSmrg  $opt_debug
1734f353fbadSmrg  func_to_host_file_result="$1"
1735f353fbadSmrg  if test -n "$1"; then
1736f353fbadSmrg    func_convert_core_file_wine_to_w32 "$1"
1737f353fbadSmrg    func_to_host_file_result="$func_convert_core_file_wine_to_w32_result"
1738f353fbadSmrg  fi
1739f353fbadSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
1740f353fbadSmrg}
1741f353fbadSmrg# end func_convert_file_nix_to_w32
1742f353fbadSmrg
1743f353fbadSmrg
1744f353fbadSmrg# func_convert_file_msys_to_cygwin ARG
1745f353fbadSmrg# Convert file name ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
1746f353fbadSmrg# Returns result in func_to_host_file_result.
1747f353fbadSmrgfunc_convert_file_msys_to_cygwin ()
1748f353fbadSmrg{
1749f353fbadSmrg  $opt_debug
1750f353fbadSmrg  func_to_host_file_result="$1"
1751f353fbadSmrg  if test -n "$1"; then
1752f353fbadSmrg    func_convert_core_msys_to_w32 "$1"
1753f353fbadSmrg    func_cygpath -u "$func_convert_core_msys_to_w32_result"
1754f353fbadSmrg    func_to_host_file_result="$func_cygpath_result"
1755f353fbadSmrg  fi
1756f353fbadSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
1757f353fbadSmrg}
1758f353fbadSmrg# end func_convert_file_msys_to_cygwin
1759f353fbadSmrg
1760f353fbadSmrg
1761f353fbadSmrg# func_convert_file_nix_to_cygwin ARG
1762f353fbadSmrg# Convert file name ARG from *nix to Cygwin format.  Requires Cygwin installed
1763f353fbadSmrg# in a wine environment, working winepath, and LT_CYGPATH set.  Returns result
1764f353fbadSmrg# in func_to_host_file_result.
1765f353fbadSmrgfunc_convert_file_nix_to_cygwin ()
1766f353fbadSmrg{
1767f353fbadSmrg  $opt_debug
1768f353fbadSmrg  func_to_host_file_result="$1"
1769f353fbadSmrg  if test -n "$1"; then
1770f353fbadSmrg    # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
1771f353fbadSmrg    func_convert_core_file_wine_to_w32 "$1"
1772f353fbadSmrg    func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
1773f353fbadSmrg    func_to_host_file_result="$func_cygpath_result"
1774f353fbadSmrg  fi
1775f353fbadSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
1776f353fbadSmrg}
1777f353fbadSmrg# end func_convert_file_nix_to_cygwin
1778f353fbadSmrg
1779f353fbadSmrg
1780f353fbadSmrg#############################################
1781f353fbadSmrg# $build to $host PATH CONVERSION FUNCTIONS #
1782f353fbadSmrg#############################################
1783f353fbadSmrg# invoked via `$to_host_path_cmd ARG'
1784f353fbadSmrg#
1785f353fbadSmrg# In each case, ARG is the path to be converted from $build to $host format.
1786f353fbadSmrg# The result will be available in $func_to_host_path_result.
1787f353fbadSmrg#
1788f353fbadSmrg# Path separators are also converted from $build format to $host format.  If
1789f353fbadSmrg# ARG begins or ends with a path separator character, it is preserved (but
1790f353fbadSmrg# converted to $host format) on output.
1791f353fbadSmrg#
1792f353fbadSmrg# All path conversion functions are named using the following convention:
1793f353fbadSmrg#   file name conversion function    : func_convert_file_X_to_Y ()
1794f353fbadSmrg#   path conversion function         : func_convert_path_X_to_Y ()
1795f353fbadSmrg# where, for any given $build/$host combination the 'X_to_Y' value is the
1796f353fbadSmrg# same.  If conversion functions are added for new $build/$host combinations,
1797f353fbadSmrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd
1798f353fbadSmrg# will break.
1799f353fbadSmrg
1800f353fbadSmrg
1801f353fbadSmrg# func_init_to_host_path_cmd
1802f353fbadSmrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the
1803f353fbadSmrg# appropriate value, based on the value of $to_host_file_cmd.
1804f353fbadSmrgto_host_path_cmd=
1805f353fbadSmrgfunc_init_to_host_path_cmd ()
1806f353fbadSmrg{
1807f353fbadSmrg  $opt_debug
1808f353fbadSmrg  if test -z "$to_host_path_cmd"; then
1809f353fbadSmrg    func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
1810f353fbadSmrg    to_host_path_cmd="func_convert_path_${func_stripname_result}"
1811f353fbadSmrg  fi
1812f353fbadSmrg}
1813f353fbadSmrg
1814f353fbadSmrg
1815f353fbadSmrg# func_to_host_path ARG
1816f353fbadSmrg# Converts the path ARG from $build format to $host format. Return result
1817f353fbadSmrg# in func_to_host_path_result.
1818f353fbadSmrgfunc_to_host_path ()
1819f353fbadSmrg{
1820f353fbadSmrg  $opt_debug
1821f353fbadSmrg  func_init_to_host_path_cmd
1822f353fbadSmrg  $to_host_path_cmd "$1"
1823f353fbadSmrg}
1824f353fbadSmrg# end func_to_host_path
1825f353fbadSmrg
1826f353fbadSmrg
1827f353fbadSmrg# func_convert_path_noop ARG
1828f353fbadSmrg# Copy ARG to func_to_host_path_result.
1829f353fbadSmrgfunc_convert_path_noop ()
1830f353fbadSmrg{
1831f353fbadSmrg  func_to_host_path_result="$1"
1832f353fbadSmrg}
1833f353fbadSmrg# end func_convert_path_noop
1834f353fbadSmrg
1835f353fbadSmrg
1836f353fbadSmrg# func_convert_path_msys_to_w32 ARG
1837f353fbadSmrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic
1838f353fbadSmrg# conversion to w32 is not available inside the cwrapper.  Returns result in
1839f353fbadSmrg# func_to_host_path_result.
1840f353fbadSmrgfunc_convert_path_msys_to_w32 ()
1841994689c1Smrg{
1842f353fbadSmrg  $opt_debug
1843f353fbadSmrg  func_to_host_path_result="$1"
1844f353fbadSmrg  if test -n "$1"; then
1845f353fbadSmrg    # Remove leading and trailing path separator characters from ARG.  MSYS
1846f353fbadSmrg    # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
1847f353fbadSmrg    # and winepath ignores them completely.
1848f353fbadSmrg    func_stripname : : "$1"
1849f353fbadSmrg    func_to_host_path_tmp1=$func_stripname_result
1850f353fbadSmrg    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
1851f353fbadSmrg    func_to_host_path_result="$func_convert_core_msys_to_w32_result"
1852f353fbadSmrg    func_convert_path_check : ";" \
1853f353fbadSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1854f353fbadSmrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
1855f353fbadSmrg  fi
1856f353fbadSmrg}
1857f353fbadSmrg# end func_convert_path_msys_to_w32
1858994689c1Smrg
1859994689c1Smrg
1860f353fbadSmrg# func_convert_path_cygwin_to_w32 ARG
1861f353fbadSmrg# Convert path ARG from Cygwin to w32 format.  Returns result in
1862f353fbadSmrg# func_to_host_file_result.
1863f353fbadSmrgfunc_convert_path_cygwin_to_w32 ()
1864f353fbadSmrg{
1865f353fbadSmrg  $opt_debug
1866f353fbadSmrg  func_to_host_path_result="$1"
1867f353fbadSmrg  if test -n "$1"; then
1868f353fbadSmrg    # See func_convert_path_msys_to_w32:
1869f353fbadSmrg    func_stripname : : "$1"
1870f353fbadSmrg    func_to_host_path_tmp1=$func_stripname_result
1871f353fbadSmrg    func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"`
1872f353fbadSmrg    func_convert_path_check : ";" \
1873f353fbadSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1874f353fbadSmrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
1875f353fbadSmrg  fi
1876f353fbadSmrg}
1877f353fbadSmrg# end func_convert_path_cygwin_to_w32
1878994689c1Smrg
1879994689c1Smrg
1880f353fbadSmrg# func_convert_path_nix_to_w32 ARG
1881f353fbadSmrg# Convert path ARG from *nix to w32 format.  Requires a wine environment and
1882f353fbadSmrg# a working winepath.  Returns result in func_to_host_file_result.
1883f353fbadSmrgfunc_convert_path_nix_to_w32 ()
1884f353fbadSmrg{
1885f353fbadSmrg  $opt_debug
1886f353fbadSmrg  func_to_host_path_result="$1"
1887f353fbadSmrg  if test -n "$1"; then
1888f353fbadSmrg    # See func_convert_path_msys_to_w32:
1889f353fbadSmrg    func_stripname : : "$1"
1890f353fbadSmrg    func_to_host_path_tmp1=$func_stripname_result
1891f353fbadSmrg    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
1892f353fbadSmrg    func_to_host_path_result="$func_convert_core_path_wine_to_w32_result"
1893f353fbadSmrg    func_convert_path_check : ";" \
1894f353fbadSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1895f353fbadSmrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
1896f353fbadSmrg  fi
1897f353fbadSmrg}
1898f353fbadSmrg# end func_convert_path_nix_to_w32
1899994689c1Smrg
1900f353fbadSmrg
1901f353fbadSmrg# func_convert_path_msys_to_cygwin ARG
1902f353fbadSmrg# Convert path ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
1903f353fbadSmrg# Returns result in func_to_host_file_result.
1904f353fbadSmrgfunc_convert_path_msys_to_cygwin ()
1905f353fbadSmrg{
1906f353fbadSmrg  $opt_debug
1907f353fbadSmrg  func_to_host_path_result="$1"
1908f353fbadSmrg  if test -n "$1"; then
1909f353fbadSmrg    # See func_convert_path_msys_to_w32:
1910f353fbadSmrg    func_stripname : : "$1"
1911f353fbadSmrg    func_to_host_path_tmp1=$func_stripname_result
1912f353fbadSmrg    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
1913f353fbadSmrg    func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
1914f353fbadSmrg    func_to_host_path_result="$func_cygpath_result"
1915f353fbadSmrg    func_convert_path_check : : \
1916f353fbadSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1917f353fbadSmrg    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
1918f353fbadSmrg  fi
1919f353fbadSmrg}
1920f353fbadSmrg# end func_convert_path_msys_to_cygwin
1921f353fbadSmrg
1922f353fbadSmrg
1923f353fbadSmrg# func_convert_path_nix_to_cygwin ARG
1924f353fbadSmrg# Convert path ARG from *nix to Cygwin format.  Requires Cygwin installed in a
1925f353fbadSmrg# a wine environment, working winepath, and LT_CYGPATH set.  Returns result in
1926f353fbadSmrg# func_to_host_file_result.
1927f353fbadSmrgfunc_convert_path_nix_to_cygwin ()
1928f353fbadSmrg{
1929f353fbadSmrg  $opt_debug
1930f353fbadSmrg  func_to_host_path_result="$1"
1931f353fbadSmrg  if test -n "$1"; then
1932f353fbadSmrg    # Remove leading and trailing path separator characters from
1933f353fbadSmrg    # ARG. msys behavior is inconsistent here, cygpath turns them
1934f353fbadSmrg    # into '.;' and ';.', and winepath ignores them completely.
1935f353fbadSmrg    func_stripname : : "$1"
1936f353fbadSmrg    func_to_host_path_tmp1=$func_stripname_result
1937f353fbadSmrg    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
1938f353fbadSmrg    func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
1939f353fbadSmrg    func_to_host_path_result="$func_cygpath_result"
1940f353fbadSmrg    func_convert_path_check : : \
1941f353fbadSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1942f353fbadSmrg    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
1943f353fbadSmrg  fi
1944994689c1Smrg}
1945f353fbadSmrg# end func_convert_path_nix_to_cygwin
1946f353fbadSmrg
1947994689c1Smrg
1948994689c1Smrg# func_mode_compile arg...
1949994689c1Smrgfunc_mode_compile ()
1950994689c1Smrg{
1951994689c1Smrg    $opt_debug
1952994689c1Smrg    # Get the compilation command and the source file.
1953994689c1Smrg    base_compile=
1954994689c1Smrg    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
1955994689c1Smrg    suppress_opt=yes
1956994689c1Smrg    suppress_output=
1957994689c1Smrg    arg_mode=normal
1958994689c1Smrg    libobj=
1959994689c1Smrg    later=
1960994689c1Smrg    pie_flag=
1961994689c1Smrg
1962994689c1Smrg    for arg
1963994689c1Smrg    do
1964994689c1Smrg      case $arg_mode in
1965994689c1Smrg      arg  )
1966994689c1Smrg	# do not "continue".  Instead, add this to base_compile
1967994689c1Smrg	lastarg="$arg"
1968994689c1Smrg	arg_mode=normal
1969994689c1Smrg	;;
1970994689c1Smrg
1971994689c1Smrg      target )
1972994689c1Smrg	libobj="$arg"
1973994689c1Smrg	arg_mode=normal
1974994689c1Smrg	continue
1975994689c1Smrg	;;
1976994689c1Smrg
1977994689c1Smrg      normal )
1978994689c1Smrg	# Accept any command-line options.
1979994689c1Smrg	case $arg in
1980994689c1Smrg	-o)
1981994689c1Smrg	  test -n "$libobj" && \
1982994689c1Smrg	    func_fatal_error "you cannot specify \`-o' more than once"
1983994689c1Smrg	  arg_mode=target
1984994689c1Smrg	  continue
1985994689c1Smrg	  ;;
1986994689c1Smrg
1987994689c1Smrg	-pie | -fpie | -fPIE)
1988f353fbadSmrg          func_append pie_flag " $arg"
1989994689c1Smrg	  continue
1990994689c1Smrg	  ;;
1991994689c1Smrg
1992994689c1Smrg	-shared | -static | -prefer-pic | -prefer-non-pic)
1993f353fbadSmrg	  func_append later " $arg"
1994994689c1Smrg	  continue
1995994689c1Smrg	  ;;
19967a84e134Smrg
19977a84e134Smrg	-no-suppress)
19987a84e134Smrg	  suppress_opt=no
19997a84e134Smrg	  continue
20007a84e134Smrg	  ;;
20017a84e134Smrg
20027a84e134Smrg	-Xcompiler)
20037a84e134Smrg	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
20047a84e134Smrg	  continue      #  The current "srcfile" will either be retained or
20057a84e134Smrg	  ;;            #  replaced later.  I would guess that would be a bug.
20067a84e134Smrg
20077a84e134Smrg	-Wc,*)
2008994689c1Smrg	  func_stripname '-Wc,' '' "$arg"
2009994689c1Smrg	  args=$func_stripname_result
20107a84e134Smrg	  lastarg=
20117a84e134Smrg	  save_ifs="$IFS"; IFS=','
2012994689c1Smrg	  for arg in $args; do
20137a84e134Smrg	    IFS="$save_ifs"
2014f353fbadSmrg	    func_append_quoted lastarg "$arg"
20157a84e134Smrg	  done
20167a84e134Smrg	  IFS="$save_ifs"
2017994689c1Smrg	  func_stripname ' ' '' "$lastarg"
2018994689c1Smrg	  lastarg=$func_stripname_result
20197a84e134Smrg
20207a84e134Smrg	  # Add the arguments to base_compile.
2021f353fbadSmrg	  func_append base_compile " $lastarg"
20227a84e134Smrg	  continue
20237a84e134Smrg	  ;;
20247a84e134Smrg
2025994689c1Smrg	*)
20267a84e134Smrg	  # Accept the current argument as the source file.
20277a84e134Smrg	  # The previous "srcfile" becomes the current argument.
20287a84e134Smrg	  #
20297a84e134Smrg	  lastarg="$srcfile"
20307a84e134Smrg	  srcfile="$arg"
20317a84e134Smrg	  ;;
20327a84e134Smrg	esac  #  case $arg
20337a84e134Smrg	;;
20347a84e134Smrg      esac    #  case $arg_mode
20357a84e134Smrg
20367a84e134Smrg      # Aesthetically quote the previous argument.
2037f353fbadSmrg      func_append_quoted base_compile "$lastarg"
20387a84e134Smrg    done # for arg
20397a84e134Smrg
20407a84e134Smrg    case $arg_mode in
20417a84e134Smrg    arg)
2042994689c1Smrg      func_fatal_error "you must specify an argument for -Xcompile"
20437a84e134Smrg      ;;
20447a84e134Smrg    target)
2045994689c1Smrg      func_fatal_error "you must specify a target with \`-o'"
20467a84e134Smrg      ;;
20477a84e134Smrg    *)
20487a84e134Smrg      # Get the name of the library object.
2049994689c1Smrg      test -z "$libobj" && {
2050994689c1Smrg	func_basename "$srcfile"
2051994689c1Smrg	libobj="$func_basename_result"
2052994689c1Smrg      }
20537a84e134Smrg      ;;
20547a84e134Smrg    esac
20557a84e134Smrg
20567a84e134Smrg    # Recognize several different file suffixes.
20577a84e134Smrg    # If the user specifies -o file.o, it is replaced with file.lo
20587a84e134Smrg    case $libobj in
2059994689c1Smrg    *.[cCFSifmso] | \
2060994689c1Smrg    *.ada | *.adb | *.ads | *.asm | \
2061994689c1Smrg    *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
2062994689c1Smrg    *.[fF][09]? | *.for | *.java | *.obj | *.sx | *.cu | *.cup)
2063994689c1Smrg      func_xform "$libobj"
2064994689c1Smrg      libobj=$func_xform_result
2065994689c1Smrg      ;;
20667a84e134Smrg    esac
20677a84e134Smrg
20687a84e134Smrg    case $libobj in
2069994689c1Smrg    *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
20707a84e134Smrg    *)
2071994689c1Smrg      func_fatal_error "cannot determine name of library object from \`$libobj'"
20727a84e134Smrg      ;;
20737a84e134Smrg    esac
20747a84e134Smrg
20757a84e134Smrg    func_infer_tag $base_compile
20767a84e134Smrg
20777a84e134Smrg    for arg in $later; do
20787a84e134Smrg      case $arg in
2079994689c1Smrg      -shared)
2080994689c1Smrg	test "$build_libtool_libs" != yes && \
2081994689c1Smrg	  func_fatal_configuration "can not build a shared library"
2082994689c1Smrg	build_old_libs=no
2083994689c1Smrg	continue
2084994689c1Smrg	;;
2085994689c1Smrg
20867a84e134Smrg      -static)
2087994689c1Smrg	build_libtool_libs=no
20887a84e134Smrg	build_old_libs=yes
20897a84e134Smrg	continue
20907a84e134Smrg	;;
20917a84e134Smrg
20927a84e134Smrg      -prefer-pic)
20937a84e134Smrg	pic_mode=yes
20947a84e134Smrg	continue
20957a84e134Smrg	;;
20967a84e134Smrg
20977a84e134Smrg      -prefer-non-pic)
20987a84e134Smrg	pic_mode=no
20997a84e134Smrg	continue
21007a84e134Smrg	;;
21017a84e134Smrg      esac
21027a84e134Smrg    done
21037a84e134Smrg
2104994689c1Smrg    func_quote_for_eval "$libobj"
2105994689c1Smrg    test "X$libobj" != "X$func_quote_for_eval_result" \
2106994689c1Smrg      && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'	 &()|`$[]' \
2107994689c1Smrg      && func_warning "libobj name \`$libobj' may not contain shell special characters."
2108994689c1Smrg    func_dirname_and_basename "$obj" "/" ""
2109994689c1Smrg    objname="$func_basename_result"
2110994689c1Smrg    xdir="$func_dirname_result"
21117a84e134Smrg    lobj=${xdir}$objdir/$objname
21127a84e134Smrg
2113994689c1Smrg    test -z "$base_compile" && \
2114994689c1Smrg      func_fatal_help "you must specify a compilation command"
21157a84e134Smrg
21167a84e134Smrg    # Delete any leftover library objects.
21177a84e134Smrg    if test "$build_old_libs" = yes; then
21187a84e134Smrg      removelist="$obj $lobj $libobj ${libobj}T"
21197a84e134Smrg    else
21207a84e134Smrg      removelist="$lobj $libobj ${libobj}T"
21217a84e134Smrg    fi
21227a84e134Smrg
21237a84e134Smrg    # On Cygwin there's no "real" PIC flag so we must build both object types
21247a84e134Smrg    case $host_os in
2125994689c1Smrg    cygwin* | mingw* | pw32* | os2* | cegcc*)
21267a84e134Smrg      pic_mode=default
21277a84e134Smrg      ;;
21287a84e134Smrg    esac
21297a84e134Smrg    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
21307a84e134Smrg      # non-PIC code in shared libraries is not supported
21317a84e134Smrg      pic_mode=default
21327a84e134Smrg    fi
21337a84e134Smrg
21347a84e134Smrg    # Calculate the filename of the output object if compiler does
21357a84e134Smrg    # not support -o with -c
21367a84e134Smrg    if test "$compiler_c_o" = no; then
2137994689c1Smrg      output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext}
21387a84e134Smrg      lockfile="$output_obj.lock"
21397a84e134Smrg    else
21407a84e134Smrg      output_obj=
21417a84e134Smrg      need_locks=no
21427a84e134Smrg      lockfile=
21437a84e134Smrg    fi
21447a84e134Smrg
21457a84e134Smrg    # Lock this critical section if it is needed
21467a84e134Smrg    # We use this script file to make the link, it avoids creating a new file
21477a84e134Smrg    if test "$need_locks" = yes; then
2148994689c1Smrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
2149994689c1Smrg	func_echo "Waiting for $lockfile to be removed"
21507a84e134Smrg	sleep 2
21517a84e134Smrg      done
21527a84e134Smrg    elif test "$need_locks" = warn; then
21537a84e134Smrg      if test -f "$lockfile"; then
2154994689c1Smrg	$ECHO "\
21557a84e134Smrg*** ERROR, $lockfile exists and contains:
21567a84e134Smrg`cat $lockfile 2>/dev/null`
21577a84e134Smrg
21587a84e134SmrgThis indicates that another process is trying to use the same
21597a84e134Smrgtemporary object file, and libtool could not work around it because
21607a84e134Smrgyour compiler does not support \`-c' and \`-o' together.  If you
21617a84e134Smrgrepeat this compilation, it may succeed, by chance, but you had better
21627a84e134Smrgavoid parallel builds (make -j) in this platform, or get a better
21637a84e134Smrgcompiler."
21647a84e134Smrg
2165994689c1Smrg	$opt_dry_run || $RM $removelist
21667a84e134Smrg	exit $EXIT_FAILURE
21677a84e134Smrg      fi
2168f353fbadSmrg      func_append removelist " $output_obj"
2169994689c1Smrg      $ECHO "$srcfile" > "$lockfile"
21707a84e134Smrg    fi
21717a84e134Smrg
2172994689c1Smrg    $opt_dry_run || $RM $removelist
2173f353fbadSmrg    func_append removelist " $lockfile"
2174994689c1Smrg    trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
2175994689c1Smrg
2176f353fbadSmrg    func_to_tool_file "$srcfile" func_convert_file_msys_to_w32
2177f353fbadSmrg    srcfile=$func_to_tool_file_result
2178994689c1Smrg    func_quote_for_eval "$srcfile"
2179994689c1Smrg    qsrcfile=$func_quote_for_eval_result
21807a84e134Smrg
21817a84e134Smrg    # Only build a PIC object if we are building libtool libraries.
21827a84e134Smrg    if test "$build_libtool_libs" = yes; then
21837a84e134Smrg      # Without this assignment, base_compile gets emptied.
21847a84e134Smrg      fbsd_hideous_sh_bug=$base_compile
21857a84e134Smrg
21867a84e134Smrg      if test "$pic_mode" != no; then
21877a84e134Smrg	command="$base_compile $qsrcfile $pic_flag"
21887a84e134Smrg      else
21897a84e134Smrg	# Don't build PIC code
21907a84e134Smrg	command="$base_compile $qsrcfile"
21917a84e134Smrg      fi
21927a84e134Smrg
2193994689c1Smrg      func_mkdir_p "$xdir$objdir"
21947a84e134Smrg
21957a84e134Smrg      if test -z "$output_obj"; then
21967a84e134Smrg	# Place PIC objects in $objdir
2197f353fbadSmrg	func_append command " -o $lobj"
21987a84e134Smrg      fi
21997a84e134Smrg
2200994689c1Smrg      func_show_eval_locale "$command"	\
2201994689c1Smrg          'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
22027a84e134Smrg
22037a84e134Smrg      if test "$need_locks" = warn &&
22047a84e134Smrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
2205994689c1Smrg	$ECHO "\
22067a84e134Smrg*** ERROR, $lockfile contains:
22077a84e134Smrg`cat $lockfile 2>/dev/null`
22087a84e134Smrg
22097a84e134Smrgbut it should contain:
22107a84e134Smrg$srcfile
22117a84e134Smrg
22127a84e134SmrgThis indicates that another process is trying to use the same
22137a84e134Smrgtemporary object file, and libtool could not work around it because
22147a84e134Smrgyour compiler does not support \`-c' and \`-o' together.  If you
22157a84e134Smrgrepeat this compilation, it may succeed, by chance, but you had better
22167a84e134Smrgavoid parallel builds (make -j) in this platform, or get a better
22177a84e134Smrgcompiler."
22187a84e134Smrg
2219994689c1Smrg	$opt_dry_run || $RM $removelist
22207a84e134Smrg	exit $EXIT_FAILURE
22217a84e134Smrg      fi
22227a84e134Smrg
22237a84e134Smrg      # Just move the object if needed, then go on to compile the next one
22247a84e134Smrg      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
2225994689c1Smrg	func_show_eval '$MV "$output_obj" "$lobj"' \
2226994689c1Smrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
22277a84e134Smrg      fi
22287a84e134Smrg
22297a84e134Smrg      # Allow error messages only from the first compilation.
22307a84e134Smrg      if test "$suppress_opt" = yes; then
2231994689c1Smrg	suppress_output=' >/dev/null 2>&1'
22327a84e134Smrg      fi
22337a84e134Smrg    fi
22347a84e134Smrg
22357a84e134Smrg    # Only build a position-dependent object if we build old libraries.
22367a84e134Smrg    if test "$build_old_libs" = yes; then
22377a84e134Smrg      if test "$pic_mode" != yes; then
22387a84e134Smrg	# Don't build PIC code
2239994689c1Smrg	command="$base_compile $qsrcfile$pie_flag"
22407a84e134Smrg      else
22417a84e134Smrg	command="$base_compile $qsrcfile $pic_flag"
22427a84e134Smrg      fi
22437a84e134Smrg      if test "$compiler_c_o" = yes; then
2244f353fbadSmrg	func_append command " -o $obj"
22457a84e134Smrg      fi
22467a84e134Smrg
22477a84e134Smrg      # Suppress compiler output if we already did a PIC compilation.
2248f353fbadSmrg      func_append command "$suppress_output"
2249994689c1Smrg      func_show_eval_locale "$command" \
2250994689c1Smrg        '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
22517a84e134Smrg
22527a84e134Smrg      if test "$need_locks" = warn &&
22537a84e134Smrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
2254994689c1Smrg	$ECHO "\
22557a84e134Smrg*** ERROR, $lockfile contains:
22567a84e134Smrg`cat $lockfile 2>/dev/null`
22577a84e134Smrg
22587a84e134Smrgbut it should contain:
22597a84e134Smrg$srcfile
22607a84e134Smrg
22617a84e134SmrgThis indicates that another process is trying to use the same
22627a84e134Smrgtemporary object file, and libtool could not work around it because
22637a84e134Smrgyour compiler does not support \`-c' and \`-o' together.  If you
22647a84e134Smrgrepeat this compilation, it may succeed, by chance, but you had better
22657a84e134Smrgavoid parallel builds (make -j) in this platform, or get a better
22667a84e134Smrgcompiler."
22677a84e134Smrg
2268994689c1Smrg	$opt_dry_run || $RM $removelist
22697a84e134Smrg	exit $EXIT_FAILURE
22707a84e134Smrg      fi
22717a84e134Smrg
22727a84e134Smrg      # Just move the object if needed
22737a84e134Smrg      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
2274994689c1Smrg	func_show_eval '$MV "$output_obj" "$obj"' \
2275994689c1Smrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
22767a84e134Smrg      fi
22777a84e134Smrg    fi
22787a84e134Smrg
2279994689c1Smrg    $opt_dry_run || {
2280994689c1Smrg      func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
22817a84e134Smrg
2282994689c1Smrg      # Unlock the critical section if it was locked
2283994689c1Smrg      if test "$need_locks" != no; then
2284994689c1Smrg	removelist=$lockfile
2285994689c1Smrg        $RM "$lockfile"
2286994689c1Smrg      fi
2287994689c1Smrg    }
22887a84e134Smrg
22897a84e134Smrg    exit $EXIT_SUCCESS
2290994689c1Smrg}
22917a84e134Smrg
2292994689c1Smrg$opt_help || {
2293f353fbadSmrg  test "$opt_mode" = compile && func_mode_compile ${1+"$@"}
2294994689c1Smrg}
22957a84e134Smrg
2296994689c1Smrgfunc_mode_help ()
2297994689c1Smrg{
2298994689c1Smrg    # We need to display help for each of the modes.
2299f353fbadSmrg    case $opt_mode in
2300994689c1Smrg      "")
2301994689c1Smrg        # Generic help is extracted from the usage comments
2302994689c1Smrg        # at the start of this file.
2303994689c1Smrg        func_help
2304994689c1Smrg        ;;
23057a84e134Smrg
2306994689c1Smrg      clean)
2307994689c1Smrg        $ECHO \
2308994689c1Smrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
23097a84e134Smrg
2310994689c1SmrgRemove files from the build directory.
23117a84e134Smrg
2312994689c1SmrgRM is the name of the program to use to delete files associated with each FILE
2313994689c1Smrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
2314994689c1Smrgto RM.
23157a84e134Smrg
2316994689c1SmrgIf FILE is a libtool library, object or program, all the files associated
2317994689c1Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM."
2318994689c1Smrg        ;;
23197a84e134Smrg
2320994689c1Smrg      compile)
2321994689c1Smrg      $ECHO \
2322994689c1Smrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
23237a84e134Smrg
2324994689c1SmrgCompile a source file into a libtool library object.
23257a84e134Smrg
2326994689c1SmrgThis mode accepts the following additional options:
23277a84e134Smrg
2328994689c1Smrg  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
2329994689c1Smrg  -no-suppress      do not suppress compiler output for multiple passes
2330994689c1Smrg  -prefer-pic       try to build PIC objects only
2331994689c1Smrg  -prefer-non-pic   try to build non-PIC objects only
2332994689c1Smrg  -shared           do not build a \`.o' file suitable for static linking
2333994689c1Smrg  -static           only build a \`.o' file suitable for static linking
2334994689c1Smrg  -Wc,FLAG          pass FLAG directly to the compiler
23357a84e134Smrg
2336994689c1SmrgCOMPILE-COMMAND is a command to be used in creating a \`standard' object file
2337994689c1Smrgfrom the given SOURCEFILE.
23387a84e134Smrg
2339994689c1SmrgThe output file name is determined by removing the directory component from
2340994689c1SmrgSOURCEFILE, then substituting the C source code suffix \`.c' with the
2341994689c1Smrglibrary object suffix, \`.lo'."
2342994689c1Smrg        ;;
23437a84e134Smrg
2344994689c1Smrg      execute)
2345994689c1Smrg        $ECHO \
2346994689c1Smrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
23477a84e134Smrg
2348994689c1SmrgAutomatically set library path, then run a program.
23497a84e134Smrg
2350994689c1SmrgThis mode accepts the following additional options:
23517a84e134Smrg
2352994689c1Smrg  -dlopen FILE      add the directory containing FILE to the library path
23537a84e134Smrg
2354994689c1SmrgThis mode sets the library path environment variable according to \`-dlopen'
2355994689c1Smrgflags.
23567a84e134Smrg
2357994689c1SmrgIf any of the ARGS are libtool executable wrappers, then they are translated
2358994689c1Smrginto their corresponding uninstalled binary, and any of their required library
2359994689c1Smrgdirectories are added to the library path.
23607a84e134Smrg
2361994689c1SmrgThen, COMMAND is executed, with ARGS as arguments."
2362994689c1Smrg        ;;
23637a84e134Smrg
2364994689c1Smrg      finish)
2365994689c1Smrg        $ECHO \
2366994689c1Smrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
23677a84e134Smrg
2368994689c1SmrgComplete the installation of libtool libraries.
23697a84e134Smrg
2370994689c1SmrgEach LIBDIR is a directory that contains libtool libraries.
23717a84e134Smrg
2372994689c1SmrgThe commands that this mode executes may require superuser privileges.  Use
2373994689c1Smrgthe \`--dry-run' option if you just want to see what would be executed."
2374994689c1Smrg        ;;
23757a84e134Smrg
2376994689c1Smrg      install)
2377994689c1Smrg        $ECHO \
2378994689c1Smrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
23797a84e134Smrg
2380994689c1SmrgInstall executables or libraries.
23817a84e134Smrg
2382994689c1SmrgINSTALL-COMMAND is the installation command.  The first component should be
2383994689c1Smrgeither the \`install' or \`cp' program.
23847a84e134Smrg
2385994689c1SmrgThe following components of INSTALL-COMMAND are treated specially:
23867a84e134Smrg
2387994689c1Smrg  -inst-prefix-dir PREFIX-DIR  Use PREFIX-DIR as a staging area for installation
23887a84e134Smrg
2389994689c1SmrgThe rest of the components are interpreted as arguments to that command (only
2390994689c1SmrgBSD-compatible install options are recognized)."
2391994689c1Smrg        ;;
23927a84e134Smrg
2393994689c1Smrg      link)
2394994689c1Smrg        $ECHO \
2395994689c1Smrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
23967a84e134Smrg
2397994689c1SmrgLink object files or libraries together to form another library, or to
2398994689c1Smrgcreate an executable program.
23997a84e134Smrg
2400994689c1SmrgLINK-COMMAND is a command using the C compiler that you would use to create
2401994689c1Smrga program from several object files.
24027a84e134Smrg
2403994689c1SmrgThe following components of LINK-COMMAND are treated specially:
24047a84e134Smrg
2405994689c1Smrg  -all-static       do not do any dynamic linking at all
2406994689c1Smrg  -avoid-version    do not add a version suffix if possible
2407994689c1Smrg  -bindir BINDIR    specify path to binaries directory (for systems where
2408994689c1Smrg                    libraries must be found in the PATH setting at runtime)
2409994689c1Smrg  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
2410994689c1Smrg  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
2411994689c1Smrg  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
2412994689c1Smrg  -export-symbols SYMFILE
2413994689c1Smrg                    try to export only the symbols listed in SYMFILE
2414994689c1Smrg  -export-symbols-regex REGEX
2415994689c1Smrg                    try to export only the symbols matching REGEX
2416994689c1Smrg  -LLIBDIR          search LIBDIR for required installed libraries
2417994689c1Smrg  -lNAME            OUTPUT-FILE requires the installed library libNAME
2418994689c1Smrg  -module           build a library that can dlopened
2419994689c1Smrg  -no-fast-install  disable the fast-install mode
2420994689c1Smrg  -no-install       link a not-installable executable
2421994689c1Smrg  -no-undefined     declare that a library does not refer to external symbols
2422994689c1Smrg  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
2423994689c1Smrg  -objectlist FILE  Use a list of object files found in FILE to specify objects
2424994689c1Smrg  -precious-files-regex REGEX
2425994689c1Smrg                    don't remove output files matching REGEX
2426994689c1Smrg  -release RELEASE  specify package release information
2427994689c1Smrg  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
2428994689c1Smrg  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
2429994689c1Smrg  -shared           only do dynamic linking of libtool libraries
2430994689c1Smrg  -shrext SUFFIX    override the standard shared library file extension
2431994689c1Smrg  -static           do not do any dynamic linking of uninstalled libtool libraries
2432994689c1Smrg  -static-libtool-libs
2433994689c1Smrg                    do not do any dynamic linking of libtool libraries
2434994689c1Smrg  -version-info CURRENT[:REVISION[:AGE]]
2435994689c1Smrg                    specify library version info [each variable defaults to 0]
2436994689c1Smrg  -weak LIBNAME     declare that the target provides the LIBNAME interface
2437994689c1Smrg  -Wc,FLAG
2438994689c1Smrg  -Xcompiler FLAG   pass linker-specific FLAG directly to the compiler
2439994689c1Smrg  -Wl,FLAG
2440994689c1Smrg  -Xlinker FLAG     pass linker-specific FLAG directly to the linker
2441994689c1Smrg  -XCClinker FLAG   pass link-specific FLAG to the compiler driver (CC)
24427a84e134Smrg
2443994689c1SmrgAll other options (arguments beginning with \`-') are ignored.
24447a84e134Smrg
2445994689c1SmrgEvery other argument is treated as a filename.  Files ending in \`.la' are
2446994689c1Smrgtreated as uninstalled libtool libraries, other files are standard or library
2447994689c1Smrgobject files.
24487a84e134Smrg
2449994689c1SmrgIf the OUTPUT-FILE ends in \`.la', then a libtool library is created,
2450994689c1Smrgonly library objects (\`.lo' files) may be specified, and \`-rpath' is
2451994689c1Smrgrequired, except when creating a convenience library.
24527a84e134Smrg
2453994689c1SmrgIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
2454994689c1Smrgusing \`ar' and \`ranlib', or on Windows using \`lib'.
24557a84e134Smrg
2456994689c1SmrgIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
2457994689c1Smrgis created, otherwise an executable program is created."
2458994689c1Smrg        ;;
24597a84e134Smrg
2460994689c1Smrg      uninstall)
2461994689c1Smrg        $ECHO \
2462994689c1Smrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
24637a84e134Smrg
2464994689c1SmrgRemove libraries from an installation directory.
24657a84e134Smrg
2466994689c1SmrgRM is the name of the program to use to delete files associated with each FILE
2467994689c1Smrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
2468994689c1Smrgto RM.
24697a84e134Smrg
2470994689c1SmrgIf FILE is a libtool library, all the files associated with it are deleted.
2471994689c1SmrgOtherwise, only FILE itself is deleted using RM."
2472994689c1Smrg        ;;
24737a84e134Smrg
2474994689c1Smrg      *)
2475f353fbadSmrg        func_fatal_help "invalid operation mode \`$opt_mode'"
2476994689c1Smrg        ;;
2477994689c1Smrg    esac
24787a84e134Smrg
2479994689c1Smrg    echo
2480994689c1Smrg    $ECHO "Try \`$progname --help' for more information about other modes."
2481994689c1Smrg}
2482775e7de9Smrg
2483994689c1Smrg# Now that we've collected a possible --mode arg, show help if necessary
2484994689c1Smrgif $opt_help; then
2485994689c1Smrg  if test "$opt_help" = :; then
2486994689c1Smrg    func_mode_help
2487994689c1Smrg  else
2488994689c1Smrg    {
2489994689c1Smrg      func_help noexit
2490f353fbadSmrg      for opt_mode in compile link execute install finish uninstall clean; do
2491994689c1Smrg	func_mode_help
2492994689c1Smrg      done
2493994689c1Smrg    } | sed -n '1p; 2,$s/^Usage:/  or: /p'
2494994689c1Smrg    {
2495994689c1Smrg      func_help noexit
2496f353fbadSmrg      for opt_mode in compile link execute install finish uninstall clean; do
2497994689c1Smrg	echo
2498994689c1Smrg	func_mode_help
2499994689c1Smrg      done
2500994689c1Smrg    } |
2501994689c1Smrg    sed '1d
2502994689c1Smrg      /^When reporting/,/^Report/{
2503994689c1Smrg	H
2504994689c1Smrg	d
2505994689c1Smrg      }
2506994689c1Smrg      $x
2507994689c1Smrg      /information about other modes/d
2508994689c1Smrg      /more detailed .*MODE/d
2509994689c1Smrg      s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
2510994689c1Smrg  fi
2511994689c1Smrg  exit $?
2512994689c1Smrgfi
25137a84e134Smrg
25147a84e134Smrg
2515994689c1Smrg# func_mode_execute arg...
2516994689c1Smrgfunc_mode_execute ()
2517994689c1Smrg{
2518994689c1Smrg    $opt_debug
2519994689c1Smrg    # The first argument is the command name.
2520994689c1Smrg    cmd="$nonopt"
2521994689c1Smrg    test -z "$cmd" && \
2522994689c1Smrg      func_fatal_help "you must specify a COMMAND"
2523ab902922Smrg
2524994689c1Smrg    # Handle -dlopen flags immediately.
2525f353fbadSmrg    for file in $opt_dlopen; do
2526994689c1Smrg      test -f "$file" \
2527994689c1Smrg	|| func_fatal_help "\`$file' is not a file"
25287a84e134Smrg
2529994689c1Smrg      dir=
2530994689c1Smrg      case $file in
2531994689c1Smrg      *.la)
2532f353fbadSmrg	func_resolve_sysroot "$file"
2533f353fbadSmrg	file=$func_resolve_sysroot_result
2534f353fbadSmrg
2535994689c1Smrg	# Check to see that this really is a libtool archive.
2536994689c1Smrg	func_lalib_unsafe_p "$file" \
2537994689c1Smrg	  || func_fatal_help "\`$lib' is not a valid libtool archive"
25387a84e134Smrg
2539994689c1Smrg	# Read the libtool library.
2540994689c1Smrg	dlname=
2541994689c1Smrg	library_names=
2542994689c1Smrg	func_source "$file"
25437a84e134Smrg
2544994689c1Smrg	# Skip this library if it cannot be dlopened.
2545994689c1Smrg	if test -z "$dlname"; then
2546994689c1Smrg	  # Warn if it was a shared library.
2547994689c1Smrg	  test -n "$library_names" && \
2548994689c1Smrg	    func_warning "\`$file' was not linked with \`-export-dynamic'"
2549994689c1Smrg	  continue
2550994689c1Smrg	fi
2551e1e1713cSmrg
2552994689c1Smrg	func_dirname "$file" "" "."
2553994689c1Smrg	dir="$func_dirname_result"
2554e1e1713cSmrg
2555994689c1Smrg	if test -f "$dir/$objdir/$dlname"; then
2556f353fbadSmrg	  func_append dir "/$objdir"
2557994689c1Smrg	else
2558994689c1Smrg	  if test ! -f "$dir/$dlname"; then
2559994689c1Smrg	    func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'"
2560994689c1Smrg	  fi
2561994689c1Smrg	fi
2562775e7de9Smrg	;;
2563e1e1713cSmrg
2564994689c1Smrg      *.lo)
2565994689c1Smrg	# Just add the directory containing the .lo file.
2566994689c1Smrg	func_dirname "$file" "" "."
2567994689c1Smrg	dir="$func_dirname_result"
2568775e7de9Smrg	;;
2569994689c1Smrg
2570994689c1Smrg      *)
2571994689c1Smrg	func_warning "\`-dlopen' is ignored for non-libtool libraries and objects"
2572e1e1713cSmrg	continue
2573775e7de9Smrg	;;
2574994689c1Smrg      esac
2575775e7de9Smrg
2576994689c1Smrg      # Get the absolute pathname.
2577994689c1Smrg      absdir=`cd "$dir" && pwd`
2578994689c1Smrg      test -n "$absdir" && dir="$absdir"
2579775e7de9Smrg
2580994689c1Smrg      # Now add the directory to shlibpath_var.
2581994689c1Smrg      if eval "test -z \"\$$shlibpath_var\""; then
2582994689c1Smrg	eval "$shlibpath_var=\"\$dir\""
2583994689c1Smrg      else
2584994689c1Smrg	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
2585994689c1Smrg      fi
2586994689c1Smrg    done
2587775e7de9Smrg
2588994689c1Smrg    # This variable tells wrapper scripts just to set shlibpath_var
2589994689c1Smrg    # rather than running their programs.
2590994689c1Smrg    libtool_execute_magic="$magic"
25917a84e134Smrg
2592994689c1Smrg    # Check if any of the arguments is a wrapper script.
2593994689c1Smrg    args=
2594994689c1Smrg    for file
2595994689c1Smrg    do
2596994689c1Smrg      case $file in
2597994689c1Smrg      -* | *.la | *.lo ) ;;
2598994689c1Smrg      *)
2599994689c1Smrg	# Do a test to see if this is really a libtool program.
2600994689c1Smrg	if func_ltwrapper_script_p "$file"; then
2601994689c1Smrg	  func_source "$file"
2602994689c1Smrg	  # Transform arg to wrapped name.
2603994689c1Smrg	  file="$progdir/$program"
2604994689c1Smrg	elif func_ltwrapper_executable_p "$file"; then
2605994689c1Smrg	  func_ltwrapper_scriptname "$file"
2606994689c1Smrg	  func_source "$func_ltwrapper_scriptname_result"
2607994689c1Smrg	  # Transform arg to wrapped name.
2608994689c1Smrg	  file="$progdir/$program"
2609994689c1Smrg	fi
2610e1e1713cSmrg	;;
2611994689c1Smrg      esac
2612994689c1Smrg      # Quote arguments (to preserve shell metacharacters).
2613f353fbadSmrg      func_append_quoted args "$file"
2614994689c1Smrg    done
26157a84e134Smrg
2616994689c1Smrg    if test "X$opt_dry_run" = Xfalse; then
2617994689c1Smrg      if test -n "$shlibpath_var"; then
2618994689c1Smrg	# Export the shlibpath_var.
2619994689c1Smrg	eval "export $shlibpath_var"
2620994689c1Smrg      fi
2621775e7de9Smrg
2622994689c1Smrg      # Restore saved environment variables
2623994689c1Smrg      for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
2624994689c1Smrg      do
2625994689c1Smrg	eval "if test \"\${save_$lt_var+set}\" = set; then
2626994689c1Smrg                $lt_var=\$save_$lt_var; export $lt_var
2627994689c1Smrg	      else
2628994689c1Smrg		$lt_unset $lt_var
2629994689c1Smrg	      fi"
2630994689c1Smrg      done
26317a84e134Smrg
2632994689c1Smrg      # Now prepare to actually exec the command.
2633994689c1Smrg      exec_cmd="\$cmd$args"
2634994689c1Smrg    else
2635994689c1Smrg      # Display what would be done.
2636994689c1Smrg      if test -n "$shlibpath_var"; then
2637994689c1Smrg	eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
2638994689c1Smrg	echo "export $shlibpath_var"
2639994689c1Smrg      fi
2640994689c1Smrg      $ECHO "$cmd$args"
2641994689c1Smrg      exit $EXIT_SUCCESS
2642994689c1Smrg    fi
2643994689c1Smrg}
2644775e7de9Smrg
2645f353fbadSmrgtest "$opt_mode" = execute && func_mode_execute ${1+"$@"}
2646775e7de9Smrg
2647775e7de9Smrg
2648994689c1Smrg# func_mode_finish arg...
2649994689c1Smrgfunc_mode_finish ()
2650994689c1Smrg{
2651994689c1Smrg    $opt_debug
2652f353fbadSmrg    libs=
2653f353fbadSmrg    libdirs=
2654994689c1Smrg    admincmds=
2655775e7de9Smrg
2656f353fbadSmrg    for opt in "$nonopt" ${1+"$@"}
2657f353fbadSmrg    do
2658f353fbadSmrg      if test -d "$opt"; then
2659f353fbadSmrg	func_append libdirs " $opt"
2660f353fbadSmrg
2661f353fbadSmrg      elif test -f "$opt"; then
2662f353fbadSmrg	if func_lalib_unsafe_p "$opt"; then
2663f353fbadSmrg	  func_append libs " $opt"
2664f353fbadSmrg	else
2665f353fbadSmrg	  func_warning "\`$opt' is not a valid libtool archive"
2666f353fbadSmrg	fi
2667f353fbadSmrg
2668f353fbadSmrg      else
2669f353fbadSmrg	func_fatal_error "invalid argument \`$opt'"
2670f353fbadSmrg      fi
2671f353fbadSmrg    done
2672f353fbadSmrg
2673f353fbadSmrg    if test -n "$libs"; then
2674f353fbadSmrg      if test -n "$lt_sysroot"; then
2675f353fbadSmrg        sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"`
2676f353fbadSmrg        sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;"
2677f353fbadSmrg      else
2678f353fbadSmrg        sysroot_cmd=
2679f353fbadSmrg      fi
2680f353fbadSmrg
2681f353fbadSmrg      # Remove sysroot references
2682f353fbadSmrg      if $opt_dry_run; then
2683f353fbadSmrg        for lib in $libs; do
2684f353fbadSmrg          echo "removing references to $lt_sysroot and \`=' prefixes from $lib"
2685f353fbadSmrg        done
2686f353fbadSmrg      else
2687f353fbadSmrg        tmpdir=`func_mktempdir`
2688f353fbadSmrg        for lib in $libs; do
2689f353fbadSmrg	  sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
2690f353fbadSmrg	    > $tmpdir/tmp-la
2691f353fbadSmrg	  mv -f $tmpdir/tmp-la $lib
2692f353fbadSmrg	done
2693f353fbadSmrg        ${RM}r "$tmpdir"
2694f353fbadSmrg      fi
2695f353fbadSmrg    fi
2696775e7de9Smrg
2697f353fbadSmrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
2698994689c1Smrg      for libdir in $libdirs; do
2699994689c1Smrg	if test -n "$finish_cmds"; then
2700994689c1Smrg	  # Do each command in the finish commands.
2701994689c1Smrg	  func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
2702994689c1Smrg'"$cmd"'"'
2703994689c1Smrg	fi
2704994689c1Smrg	if test -n "$finish_eval"; then
2705994689c1Smrg	  # Do the single finish_eval.
2706994689c1Smrg	  eval cmds=\"$finish_eval\"
2707f353fbadSmrg	  $opt_dry_run || eval "$cmds" || func_append admincmds "
2708994689c1Smrg       $cmds"
2709994689c1Smrg	fi
2710994689c1Smrg      done
2711994689c1Smrg    fi
2712775e7de9Smrg
2713994689c1Smrg    # Exit here if they wanted silent mode.
2714994689c1Smrg    $opt_silent && exit $EXIT_SUCCESS
2715775e7de9Smrg
2716f353fbadSmrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
2717f353fbadSmrg      echo "----------------------------------------------------------------------"
2718f353fbadSmrg      echo "Libraries have been installed in:"
2719f353fbadSmrg      for libdir in $libdirs; do
2720f353fbadSmrg	$ECHO "   $libdir"
2721f353fbadSmrg      done
2722f353fbadSmrg      echo
2723f353fbadSmrg      echo "If you ever happen to want to link against installed libraries"
2724f353fbadSmrg      echo "in a given directory, LIBDIR, you must either use libtool, and"
2725f353fbadSmrg      echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
2726f353fbadSmrg      echo "flag during linking and do at least one of the following:"
2727f353fbadSmrg      if test -n "$shlibpath_var"; then
2728f353fbadSmrg	echo "   - add LIBDIR to the \`$shlibpath_var' environment variable"
2729f353fbadSmrg	echo "     during execution"
2730f353fbadSmrg      fi
2731f353fbadSmrg      if test -n "$runpath_var"; then
2732f353fbadSmrg	echo "   - add LIBDIR to the \`$runpath_var' environment variable"
2733f353fbadSmrg	echo "     during linking"
2734f353fbadSmrg      fi
2735f353fbadSmrg      if test -n "$hardcode_libdir_flag_spec"; then
2736f353fbadSmrg	libdir=LIBDIR
2737f353fbadSmrg	eval flag=\"$hardcode_libdir_flag_spec\"
2738775e7de9Smrg
2739f353fbadSmrg	$ECHO "   - use the \`$flag' linker flag"
2740f353fbadSmrg      fi
2741f353fbadSmrg      if test -n "$admincmds"; then
2742f353fbadSmrg	$ECHO "   - have your system administrator run these commands:$admincmds"
2743f353fbadSmrg      fi
2744f353fbadSmrg      if test -f /etc/ld.so.conf; then
2745f353fbadSmrg	echo "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
2746f353fbadSmrg      fi
2747f353fbadSmrg      echo
2748775e7de9Smrg
2749f353fbadSmrg      echo "See any operating system documentation about shared libraries for"
2750f353fbadSmrg      case $host in
2751f353fbadSmrg	solaris2.[6789]|solaris2.1[0-9])
2752f353fbadSmrg	  echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
2753f353fbadSmrg	  echo "pages."
2754f353fbadSmrg	  ;;
2755f353fbadSmrg	*)
2756f353fbadSmrg	  echo "more information, such as the ld(1) and ld.so(8) manual pages."
2757f353fbadSmrg	  ;;
2758f353fbadSmrg      esac
2759f353fbadSmrg      echo "----------------------------------------------------------------------"
2760f353fbadSmrg    fi
2761994689c1Smrg    exit $EXIT_SUCCESS
2762994689c1Smrg}
2763775e7de9Smrg
2764f353fbadSmrgtest "$opt_mode" = finish && func_mode_finish ${1+"$@"}
2765e1e1713cSmrg
27667a84e134Smrg
2767994689c1Smrg# func_mode_install arg...
2768994689c1Smrgfunc_mode_install ()
2769994689c1Smrg{
2770994689c1Smrg    $opt_debug
2771994689c1Smrg    # There may be an optional sh(1) argument at the beginning of
2772994689c1Smrg    # install_prog (especially on Windows NT).
2773994689c1Smrg    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
2774994689c1Smrg       # Allow the use of GNU shtool's install command.
2775994689c1Smrg       case $nonopt in *shtool*) :;; *) false;; esac; then
2776994689c1Smrg      # Aesthetically quote it.
2777994689c1Smrg      func_quote_for_eval "$nonopt"
2778994689c1Smrg      install_prog="$func_quote_for_eval_result "
2779994689c1Smrg      arg=$1
2780994689c1Smrg      shift
2781994689c1Smrg    else
2782994689c1Smrg      install_prog=
2783994689c1Smrg      arg=$nonopt
2784994689c1Smrg    fi
27857a84e134Smrg
2786994689c1Smrg    # The real first argument should be the name of the installation program.
2787994689c1Smrg    # Aesthetically quote it.
2788994689c1Smrg    func_quote_for_eval "$arg"
2789f353fbadSmrg    func_append install_prog "$func_quote_for_eval_result"
2790994689c1Smrg    install_shared_prog=$install_prog
2791994689c1Smrg    case " $install_prog " in
2792994689c1Smrg      *[\\\ /]cp\ *) install_cp=: ;;
2793994689c1Smrg      *) install_cp=false ;;
2794994689c1Smrg    esac
27957a84e134Smrg
2796994689c1Smrg    # We need to accept at least all the BSD install flags.
2797994689c1Smrg    dest=
2798994689c1Smrg    files=
2799994689c1Smrg    opts=
2800994689c1Smrg    prev=
2801994689c1Smrg    install_type=
2802994689c1Smrg    isdir=no
2803994689c1Smrg    stripme=
2804994689c1Smrg    no_mode=:
2805994689c1Smrg    for arg
2806994689c1Smrg    do
2807994689c1Smrg      arg2=
2808994689c1Smrg      if test -n "$dest"; then
2809f353fbadSmrg	func_append files " $dest"
2810994689c1Smrg	dest=$arg
2811e1e1713cSmrg	continue
2812994689c1Smrg      fi
28137a84e134Smrg
2814994689c1Smrg      case $arg in
2815994689c1Smrg      -d) isdir=yes ;;
2816994689c1Smrg      -f)
2817994689c1Smrg	if $install_cp; then :; else
2818994689c1Smrg	  prev=$arg
2819775e7de9Smrg	fi
2820994689c1Smrg	;;
2821994689c1Smrg      -g | -m | -o)
2822994689c1Smrg	prev=$arg
2823994689c1Smrg	;;
2824994689c1Smrg      -s)
2825994689c1Smrg	stripme=" -s"
2826e1e1713cSmrg	continue
2827e1e1713cSmrg	;;
2828994689c1Smrg      -*)
2829994689c1Smrg	;;
2830e1e1713cSmrg      *)
2831994689c1Smrg	# If the previous option needed an argument, then skip it.
2832994689c1Smrg	if test -n "$prev"; then
2833994689c1Smrg	  if test "x$prev" = x-m && test -n "$install_override_mode"; then
2834994689c1Smrg	    arg2=$install_override_mode
2835994689c1Smrg	    no_mode=false
2836994689c1Smrg	  fi
2837994689c1Smrg	  prev=
2838994689c1Smrg	else
2839994689c1Smrg	  dest=$arg
2840994689c1Smrg	  continue
2841994689c1Smrg	fi
2842775e7de9Smrg	;;
2843994689c1Smrg      esac
28447a84e134Smrg
2845994689c1Smrg      # Aesthetically quote the argument.
2846994689c1Smrg      func_quote_for_eval "$arg"
2847f353fbadSmrg      func_append install_prog " $func_quote_for_eval_result"
2848994689c1Smrg      if test -n "$arg2"; then
2849994689c1Smrg	func_quote_for_eval "$arg2"
2850e1e1713cSmrg      fi
2851f353fbadSmrg      func_append install_shared_prog " $func_quote_for_eval_result"
2852994689c1Smrg    done
28537a84e134Smrg
2854994689c1Smrg    test -z "$install_prog" && \
2855994689c1Smrg      func_fatal_help "you must specify an install program"
28567a84e134Smrg
2857994689c1Smrg    test -n "$prev" && \
2858994689c1Smrg      func_fatal_help "the \`$prev' option requires an argument"
2859775e7de9Smrg
2860994689c1Smrg    if test -n "$install_override_mode" && $no_mode; then
2861994689c1Smrg      if $install_cp; then :; else
2862994689c1Smrg	func_quote_for_eval "$install_override_mode"
2863f353fbadSmrg	func_append install_shared_prog " -m $func_quote_for_eval_result"
2864994689c1Smrg      fi
2865e1e1713cSmrg    fi
2866775e7de9Smrg
2867994689c1Smrg    if test -z "$files"; then
2868994689c1Smrg      if test -z "$dest"; then
2869994689c1Smrg	func_fatal_help "no file or destination specified"
2870994689c1Smrg      else
2871994689c1Smrg	func_fatal_help "you must specify a destination"
2872775e7de9Smrg      fi
2873775e7de9Smrg    fi
2874775e7de9Smrg
2875994689c1Smrg    # Strip any trailing slash from the destination.
2876994689c1Smrg    func_stripname '' '/' "$dest"
2877994689c1Smrg    dest=$func_stripname_result
28787a84e134Smrg
2879994689c1Smrg    # Check to see that the destination is a directory.
2880994689c1Smrg    test -d "$dest" && isdir=yes
2881994689c1Smrg    if test "$isdir" = yes; then
2882994689c1Smrg      destdir="$dest"
2883994689c1Smrg      destname=
2884994689c1Smrg    else
2885994689c1Smrg      func_dirname_and_basename "$dest" "" "."
2886994689c1Smrg      destdir="$func_dirname_result"
2887994689c1Smrg      destname="$func_basename_result"
2888994689c1Smrg
2889994689c1Smrg      # Not a directory, so check to see that there is only one file specified.
2890994689c1Smrg      set dummy $files; shift
2891994689c1Smrg      test "$#" -gt 1 && \
2892994689c1Smrg	func_fatal_help "\`$dest' is not a directory"
2893994689c1Smrg    fi
2894994689c1Smrg    case $destdir in
2895994689c1Smrg    [\\/]* | [A-Za-z]:[\\/]*) ;;
2896e1e1713cSmrg    *)
2897994689c1Smrg      for file in $files; do
2898994689c1Smrg	case $file in
2899994689c1Smrg	*.lo) ;;
2900994689c1Smrg	*)
2901994689c1Smrg	  func_fatal_help "\`$destdir' must be an absolute directory name"
2902994689c1Smrg	  ;;
2903994689c1Smrg	esac
2904994689c1Smrg      done
2905e1e1713cSmrg      ;;
2906e1e1713cSmrg    esac
29077a84e134Smrg
2908994689c1Smrg    # This variable tells wrapper scripts just to set variables rather
2909994689c1Smrg    # than running their programs.
2910994689c1Smrg    libtool_install_magic="$magic"
29117a84e134Smrg
2912994689c1Smrg    staticlibs=
2913994689c1Smrg    future_libdirs=
2914994689c1Smrg    current_libdirs=
2915994689c1Smrg    for file in $files; do
29167a84e134Smrg
2917994689c1Smrg      # Do each installation.
2918994689c1Smrg      case $file in
2919994689c1Smrg      *.$libext)
2920994689c1Smrg	# Do the static libraries later.
2921f353fbadSmrg	func_append staticlibs " $file"
2922994689c1Smrg	;;
2923994689c1Smrg
2924994689c1Smrg      *.la)
2925f353fbadSmrg	func_resolve_sysroot "$file"
2926f353fbadSmrg	file=$func_resolve_sysroot_result
2927f353fbadSmrg
2928994689c1Smrg	# Check to see that this really is a libtool archive.
2929994689c1Smrg	func_lalib_unsafe_p "$file" \
2930994689c1Smrg	  || func_fatal_help "\`$file' is not a valid libtool archive"
2931994689c1Smrg
2932994689c1Smrg	library_names=
2933994689c1Smrg	old_library=
2934994689c1Smrg	relink_command=
2935994689c1Smrg	func_source "$file"
2936994689c1Smrg
2937994689c1Smrg	# Add the libdir to current_libdirs if it is the destination.
2938994689c1Smrg	if test "X$destdir" = "X$libdir"; then
2939994689c1Smrg	  case "$current_libdirs " in
2940994689c1Smrg	  *" $libdir "*) ;;
2941f353fbadSmrg	  *) func_append current_libdirs " $libdir" ;;
2942775e7de9Smrg	  esac
2943994689c1Smrg	else
2944994689c1Smrg	  # Note the libdir as a future libdir.
2945994689c1Smrg	  case "$future_libdirs " in
2946994689c1Smrg	  *" $libdir "*) ;;
2947f353fbadSmrg	  *) func_append future_libdirs " $libdir" ;;
2948994689c1Smrg	  esac
2949994689c1Smrg	fi
2950775e7de9Smrg
2951994689c1Smrg	func_dirname "$file" "/" ""
2952994689c1Smrg	dir="$func_dirname_result"
2953f353fbadSmrg	func_append dir "$objdir"
2954994689c1Smrg
2955994689c1Smrg	if test -n "$relink_command"; then
2956994689c1Smrg	  # Determine the prefix the user has applied to our future dir.
2957994689c1Smrg	  inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
2958994689c1Smrg
2959994689c1Smrg	  # Don't allow the user to place us outside of our expected
2960994689c1Smrg	  # location b/c this prevents finding dependent libraries that
2961994689c1Smrg	  # are installed to the same prefix.
2962994689c1Smrg	  # At present, this check doesn't affect windows .dll's that
2963994689c1Smrg	  # are installed into $libdir/../bin (currently, that works fine)
2964994689c1Smrg	  # but it's something to keep an eye on.
2965994689c1Smrg	  test "$inst_prefix_dir" = "$destdir" && \
2966994689c1Smrg	    func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
2967994689c1Smrg
2968994689c1Smrg	  if test -n "$inst_prefix_dir"; then
2969994689c1Smrg	    # Stick the inst_prefix_dir data into the link command.
2970994689c1Smrg	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
2971994689c1Smrg	  else
2972994689c1Smrg	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
2973994689c1Smrg	  fi
2974994689c1Smrg
2975994689c1Smrg	  func_warning "relinking \`$file'"
2976994689c1Smrg	  func_show_eval "$relink_command" \
2977994689c1Smrg	    'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
2978994689c1Smrg	fi
2979994689c1Smrg
2980994689c1Smrg	# See the names of the shared library.
2981994689c1Smrg	set dummy $library_names; shift
2982994689c1Smrg	if test -n "$1"; then
2983994689c1Smrg	  realname="$1"
2984994689c1Smrg	  shift
2985994689c1Smrg
2986994689c1Smrg	  srcname="$realname"
2987994689c1Smrg	  test -n "$relink_command" && srcname="$realname"T
2988994689c1Smrg
2989994689c1Smrg	  # Install the shared library and build the symlinks.
2990994689c1Smrg	  func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
2991994689c1Smrg	      'exit $?'
2992994689c1Smrg	  tstripme="$stripme"
2993994689c1Smrg	  case $host_os in
2994994689c1Smrg	  cygwin* | mingw* | pw32* | cegcc*)
2995994689c1Smrg	    case $realname in
2996994689c1Smrg	    *.dll.a)
2997994689c1Smrg	      tstripme=""
2998994689c1Smrg	      ;;
2999994689c1Smrg	    esac
3000775e7de9Smrg	    ;;
3001775e7de9Smrg	  esac
3002994689c1Smrg	  if test -n "$tstripme" && test -n "$striplib"; then
3003994689c1Smrg	    func_show_eval "$striplib $destdir/$realname" 'exit $?'
3004994689c1Smrg	  fi
3005994689c1Smrg
3006994689c1Smrg	  if test "$#" -gt 0; then
3007994689c1Smrg	    # Delete the old symlinks, and create new ones.
3008994689c1Smrg	    # Try `ln -sf' first, because the `ln' binary might depend on
3009994689c1Smrg	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
3010994689c1Smrg	    # so we also need to try rm && ln -s.
3011994689c1Smrg	    for linkname
3012994689c1Smrg	    do
3013994689c1Smrg	      test "$linkname" != "$realname" \
3014994689c1Smrg		&& func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
3015994689c1Smrg	    done
3016994689c1Smrg	  fi
3017994689c1Smrg
3018994689c1Smrg	  # Do each command in the postinstall commands.
3019994689c1Smrg	  lib="$destdir/$realname"
3020994689c1Smrg	  func_execute_cmds "$postinstall_cmds" 'exit $?'
3021994689c1Smrg	fi
3022994689c1Smrg
3023994689c1Smrg	# Install the pseudo-library for information purposes.
3024994689c1Smrg	func_basename "$file"
3025994689c1Smrg	name="$func_basename_result"
3026994689c1Smrg	instname="$dir/$name"i
3027994689c1Smrg	func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
3028994689c1Smrg
3029994689c1Smrg	# Maybe install the static library, too.
3030f353fbadSmrg	test -n "$old_library" && func_append staticlibs " $dir/$old_library"
3031775e7de9Smrg	;;
3032994689c1Smrg
3033994689c1Smrg      *.lo)
3034994689c1Smrg	# Install (i.e. copy) a libtool object.
3035994689c1Smrg
3036994689c1Smrg	# Figure out destination file name, if it wasn't already specified.
3037994689c1Smrg	if test -n "$destname"; then
3038994689c1Smrg	  destfile="$destdir/$destname"
3039994689c1Smrg	else
3040994689c1Smrg	  func_basename "$file"
3041994689c1Smrg	  destfile="$func_basename_result"
3042994689c1Smrg	  destfile="$destdir/$destfile"
3043994689c1Smrg	fi
3044994689c1Smrg
3045994689c1Smrg	# Deduce the name of the destination old-style object file.
3046994689c1Smrg	case $destfile in
3047994689c1Smrg	*.lo)
3048994689c1Smrg	  func_lo2o "$destfile"
3049994689c1Smrg	  staticdest=$func_lo2o_result
3050e1e1713cSmrg	  ;;
3051994689c1Smrg	*.$objext)
3052994689c1Smrg	  staticdest="$destfile"
3053994689c1Smrg	  destfile=
3054e1e1713cSmrg	  ;;
3055994689c1Smrg	*)
3056994689c1Smrg	  func_fatal_help "cannot copy a libtool object to \`$destfile'"
3057e1e1713cSmrg	  ;;
3058994689c1Smrg	esac
3059994689c1Smrg
3060994689c1Smrg	# Install the libtool object if requested.
3061994689c1Smrg	test -n "$destfile" && \
3062994689c1Smrg	  func_show_eval "$install_prog $file $destfile" 'exit $?'
3063994689c1Smrg
3064994689c1Smrg	# Install the old object if enabled.
3065994689c1Smrg	if test "$build_old_libs" = yes; then
3066994689c1Smrg	  # Deduce the name of the old-style object file.
3067994689c1Smrg	  func_lo2o "$file"
3068994689c1Smrg	  staticobj=$func_lo2o_result
3069994689c1Smrg	  func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
3070e1e1713cSmrg	fi
3071994689c1Smrg	exit $EXIT_SUCCESS
3072994689c1Smrg	;;
30737a84e134Smrg
3074994689c1Smrg      *)
3075994689c1Smrg	# Figure out destination file name, if it wasn't already specified.
3076994689c1Smrg	if test -n "$destname"; then
3077994689c1Smrg	  destfile="$destdir/$destname"
3078e1e1713cSmrg	else
3079994689c1Smrg	  func_basename "$file"
3080994689c1Smrg	  destfile="$func_basename_result"
3081994689c1Smrg	  destfile="$destdir/$destfile"
3082e1e1713cSmrg	fi
30837a84e134Smrg
3084994689c1Smrg	# If the file is missing, and there is a .exe on the end, strip it
3085994689c1Smrg	# because it is most likely a libtool script we actually want to
3086994689c1Smrg	# install
3087994689c1Smrg	stripped_ext=""
3088994689c1Smrg	case $file in
3089994689c1Smrg	  *.exe)
3090994689c1Smrg	    if test ! -f "$file"; then
3091994689c1Smrg	      func_stripname '' '.exe' "$file"
3092994689c1Smrg	      file=$func_stripname_result
3093994689c1Smrg	      stripped_ext=".exe"
3094994689c1Smrg	    fi
3095994689c1Smrg	    ;;
3096994689c1Smrg	esac
30977a84e134Smrg
3098994689c1Smrg	# Do a test to see if this is really a libtool program.
3099994689c1Smrg	case $host in
3100994689c1Smrg	*cygwin* | *mingw*)
3101994689c1Smrg	    if func_ltwrapper_executable_p "$file"; then
3102994689c1Smrg	      func_ltwrapper_scriptname "$file"
3103994689c1Smrg	      wrapper=$func_ltwrapper_scriptname_result
3104994689c1Smrg	    else
3105994689c1Smrg	      func_stripname '' '.exe' "$file"
3106994689c1Smrg	      wrapper=$func_stripname_result
3107994689c1Smrg	    fi
3108994689c1Smrg	    ;;
3109994689c1Smrg	*)
3110994689c1Smrg	    wrapper=$file
3111994689c1Smrg	    ;;
3112994689c1Smrg	esac
3113994689c1Smrg	if func_ltwrapper_script_p "$wrapper"; then
3114994689c1Smrg	  notinst_deplibs=
3115994689c1Smrg	  relink_command=
31167a84e134Smrg
3117994689c1Smrg	  func_source "$wrapper"
31187a84e134Smrg
3119994689c1Smrg	  # Check the variables that should have been set.
3120994689c1Smrg	  test -z "$generated_by_libtool_version" && \
3121994689c1Smrg	    func_fatal_error "invalid libtool wrapper script \`$wrapper'"
31227a84e134Smrg
3123994689c1Smrg	  finalize=yes
3124994689c1Smrg	  for lib in $notinst_deplibs; do
3125994689c1Smrg	    # Check to see that each library is installed.
3126994689c1Smrg	    libdir=
3127994689c1Smrg	    if test -f "$lib"; then
3128994689c1Smrg	      func_source "$lib"
3129e1e1713cSmrg	    fi
3130994689c1Smrg	    libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test
3131994689c1Smrg	    if test -n "$libdir" && test ! -f "$libfile"; then
3132994689c1Smrg	      func_warning "\`$lib' has not been installed in \`$libdir'"
3133994689c1Smrg	      finalize=no
3134994689c1Smrg	    fi
3135994689c1Smrg	  done
31367a84e134Smrg
3137994689c1Smrg	  relink_command=
3138994689c1Smrg	  func_source "$wrapper"
31397a84e134Smrg
3140994689c1Smrg	  outputname=
3141994689c1Smrg	  if test "$fast_install" = no && test -n "$relink_command"; then
3142994689c1Smrg	    $opt_dry_run || {
3143994689c1Smrg	      if test "$finalize" = yes; then
3144994689c1Smrg	        tmpdir=`func_mktempdir`
3145994689c1Smrg		func_basename "$file$stripped_ext"
3146994689c1Smrg		file="$func_basename_result"
3147994689c1Smrg	        outputname="$tmpdir/$file"
3148994689c1Smrg	        # Replace the output file specification.
3149994689c1Smrg	        relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
3150994689c1Smrg
3151994689c1Smrg	        $opt_silent || {
3152994689c1Smrg	          func_quote_for_expand "$relink_command"
3153994689c1Smrg		  eval "func_echo $func_quote_for_expand_result"
3154994689c1Smrg	        }
3155994689c1Smrg	        if eval "$relink_command"; then :
3156994689c1Smrg	          else
3157994689c1Smrg		  func_error "error: relink \`$file' with the above command before installing it"
3158994689c1Smrg		  $opt_dry_run || ${RM}r "$tmpdir"
3159994689c1Smrg		  continue
3160994689c1Smrg	        fi
3161994689c1Smrg	        file="$outputname"
3162994689c1Smrg	      else
3163994689c1Smrg	        func_warning "cannot relink \`$file'"
3164994689c1Smrg	      fi
3165994689c1Smrg	    }
3166e1e1713cSmrg	  else
3167994689c1Smrg	    # Install the binary that we compiled earlier.
3168994689c1Smrg	    file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
3169e1e1713cSmrg	  fi
3170994689c1Smrg	fi
31717a84e134Smrg
3172994689c1Smrg	# remove .exe since cygwin /usr/bin/install will append another
3173994689c1Smrg	# one anyway
3174994689c1Smrg	case $install_prog,$host in
3175994689c1Smrg	*/usr/bin/install*,*cygwin*)
3176994689c1Smrg	  case $file:$destfile in
3177994689c1Smrg	  *.exe:*.exe)
3178994689c1Smrg	    # this is ok
3179994689c1Smrg	    ;;
3180994689c1Smrg	  *.exe:*)
3181994689c1Smrg	    destfile=$destfile.exe
3182994689c1Smrg	    ;;
3183994689c1Smrg	  *:*.exe)
3184994689c1Smrg	    func_stripname '' '.exe' "$destfile"
3185994689c1Smrg	    destfile=$func_stripname_result
3186994689c1Smrg	    ;;
3187994689c1Smrg	  esac
3188e1e1713cSmrg	  ;;
3189e1e1713cSmrg	esac
3190994689c1Smrg	func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
3191994689c1Smrg	$opt_dry_run || if test -n "$outputname"; then
3192994689c1Smrg	  ${RM}r "$tmpdir"
3193994689c1Smrg	fi
3194994689c1Smrg	;;
3195994689c1Smrg      esac
3196994689c1Smrg    done
31977a84e134Smrg
3198994689c1Smrg    for file in $staticlibs; do
3199994689c1Smrg      func_basename "$file"
3200994689c1Smrg      name="$func_basename_result"
3201994689c1Smrg
3202994689c1Smrg      # Set up the ranlib parameters.
3203994689c1Smrg      oldlib="$destdir/$name"
3204994689c1Smrg
3205994689c1Smrg      func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
3206994689c1Smrg
3207994689c1Smrg      if test -n "$stripme" && test -n "$old_striplib"; then
3208994689c1Smrg	func_show_eval "$old_striplib $oldlib" 'exit $?'
3209994689c1Smrg      fi
3210994689c1Smrg
3211994689c1Smrg      # Do each command in the postinstall commands.
3212994689c1Smrg      func_execute_cmds "$old_postinstall_cmds" 'exit $?'
3213994689c1Smrg    done
3214994689c1Smrg
3215994689c1Smrg    test -n "$future_libdirs" && \
3216994689c1Smrg      func_warning "remember to run \`$progname --finish$future_libdirs'"
3217994689c1Smrg
3218994689c1Smrg    if test -n "$current_libdirs"; then
3219994689c1Smrg      # Maybe just do a dry run.
3220994689c1Smrg      $opt_dry_run && current_libdirs=" -n$current_libdirs"
3221994689c1Smrg      exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
3222994689c1Smrg    else
3223994689c1Smrg      exit $EXIT_SUCCESS
3224994689c1Smrg    fi
3225994689c1Smrg}
3226994689c1Smrg
3227f353fbadSmrgtest "$opt_mode" = install && func_mode_install ${1+"$@"}
3228994689c1Smrg
3229994689c1Smrg
3230994689c1Smrg# func_generate_dlsyms outputname originator pic_p
3231994689c1Smrg# Extract symbols from dlprefiles and create ${outputname}S.o with
3232994689c1Smrg# a dlpreopen symbol table.
3233994689c1Smrgfunc_generate_dlsyms ()
3234994689c1Smrg{
3235994689c1Smrg    $opt_debug
3236994689c1Smrg    my_outputname="$1"
3237994689c1Smrg    my_originator="$2"
3238994689c1Smrg    my_pic_p="${3-no}"
3239994689c1Smrg    my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'`
3240994689c1Smrg    my_dlsyms=
3241994689c1Smrg
3242994689c1Smrg    if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
3243994689c1Smrg      if test -n "$NM" && test -n "$global_symbol_pipe"; then
3244994689c1Smrg	my_dlsyms="${my_outputname}S.c"
3245994689c1Smrg      else
3246994689c1Smrg	func_error "not configured to extract global symbols from dlpreopened files"
3247994689c1Smrg      fi
3248994689c1Smrg    fi
3249994689c1Smrg
3250994689c1Smrg    if test -n "$my_dlsyms"; then
3251994689c1Smrg      case $my_dlsyms in
3252994689c1Smrg      "") ;;
3253994689c1Smrg      *.c)
3254994689c1Smrg	# Discover the nlist of each of the dlfiles.
3255994689c1Smrg	nlist="$output_objdir/${my_outputname}.nm"
3256994689c1Smrg
3257994689c1Smrg	func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
3258994689c1Smrg
3259994689c1Smrg	# Parse the name list into a source file.
3260994689c1Smrg	func_verbose "creating $output_objdir/$my_dlsyms"
3261994689c1Smrg
3262994689c1Smrg	$opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
3263994689c1Smrg/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */
3264994689c1Smrg/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */
3265994689c1Smrg
3266994689c1Smrg#ifdef __cplusplus
3267994689c1Smrgextern \"C\" {
3268994689c1Smrg#endif
3269994689c1Smrg
3270994689c1Smrg#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
3271994689c1Smrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
3272994689c1Smrg#endif
3273994689c1Smrg
3274f353fbadSmrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
3275f353fbadSmrg#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
3276f353fbadSmrg/* DATA imports from DLLs on WIN32 con't be const, because runtime
3277f353fbadSmrg   relocations are performed -- see ld's documentation on pseudo-relocs.  */
3278f353fbadSmrg# define LT_DLSYM_CONST
3279f353fbadSmrg#elif defined(__osf__)
3280f353fbadSmrg/* This system does not cope well with relocations in const data.  */
3281f353fbadSmrg# define LT_DLSYM_CONST
3282f353fbadSmrg#else
3283f353fbadSmrg# define LT_DLSYM_CONST const
3284f353fbadSmrg#endif
3285f353fbadSmrg
3286994689c1Smrg/* External symbol declarations for the compiler. */\
3287994689c1Smrg"
3288994689c1Smrg
3289994689c1Smrg	if test "$dlself" = yes; then
3290994689c1Smrg	  func_verbose "generating symbol list for \`$output'"
3291994689c1Smrg
3292994689c1Smrg	  $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
3293994689c1Smrg
3294994689c1Smrg	  # Add our own program objects to the symbol list.
3295994689c1Smrg	  progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
3296994689c1Smrg	  for progfile in $progfiles; do
3297f353fbadSmrg	    func_to_tool_file "$progfile" func_convert_file_msys_to_w32
3298f353fbadSmrg	    func_verbose "extracting global C symbols from \`$func_to_tool_file_result'"
3299f353fbadSmrg	    $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
3300994689c1Smrg	  done
3301994689c1Smrg
3302994689c1Smrg	  if test -n "$exclude_expsyms"; then
3303994689c1Smrg	    $opt_dry_run || {
3304994689c1Smrg	      eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
3305994689c1Smrg	      eval '$MV "$nlist"T "$nlist"'
3306994689c1Smrg	    }
3307e1e1713cSmrg	  fi
3308994689c1Smrg
3309994689c1Smrg	  if test -n "$export_symbols_regex"; then
3310994689c1Smrg	    $opt_dry_run || {
3311994689c1Smrg	      eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
3312994689c1Smrg	      eval '$MV "$nlist"T "$nlist"'
3313994689c1Smrg	    }
3314994689c1Smrg	  fi
3315994689c1Smrg
3316994689c1Smrg	  # Prepare the list of exported symbols
3317994689c1Smrg	  if test -z "$export_symbols"; then
3318994689c1Smrg	    export_symbols="$output_objdir/$outputname.exp"
3319994689c1Smrg	    $opt_dry_run || {
3320994689c1Smrg	      $RM $export_symbols
3321994689c1Smrg	      eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
3322994689c1Smrg	      case $host in
3323994689c1Smrg	      *cygwin* | *mingw* | *cegcc* )
3324994689c1Smrg                eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
3325994689c1Smrg                eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
3326994689c1Smrg	        ;;
3327994689c1Smrg	      esac
3328994689c1Smrg	    }
3329e1e1713cSmrg	  else
3330994689c1Smrg	    $opt_dry_run || {
3331994689c1Smrg	      eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
3332994689c1Smrg	      eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
3333994689c1Smrg	      eval '$MV "$nlist"T "$nlist"'
3334994689c1Smrg	      case $host in
3335994689c1Smrg	        *cygwin* | *mingw* | *cegcc* )
3336994689c1Smrg	          eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
3337994689c1Smrg	          eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
3338994689c1Smrg	          ;;
3339994689c1Smrg	      esac
3340994689c1Smrg	    }
3341e1e1713cSmrg	  fi
3342994689c1Smrg	fi
33437a84e134Smrg
3344994689c1Smrg	for dlprefile in $dlprefiles; do
3345994689c1Smrg	  func_verbose "extracting global C symbols from \`$dlprefile'"
3346994689c1Smrg	  func_basename "$dlprefile"
3347994689c1Smrg	  name="$func_basename_result"
3348f353fbadSmrg          case $host in
3349f353fbadSmrg	    *cygwin* | *mingw* | *cegcc* )
3350f353fbadSmrg	      # if an import library, we need to obtain dlname
3351f353fbadSmrg	      if func_win32_import_lib_p "$dlprefile"; then
3352f353fbadSmrg	        func_tr_sh "$dlprefile"
3353f353fbadSmrg	        eval "curr_lafile=\$libfile_$func_tr_sh_result"
3354f353fbadSmrg	        dlprefile_dlbasename=""
3355f353fbadSmrg	        if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
3356f353fbadSmrg	          # Use subshell, to avoid clobbering current variable values
3357f353fbadSmrg	          dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
3358f353fbadSmrg	          if test -n "$dlprefile_dlname" ; then
3359f353fbadSmrg	            func_basename "$dlprefile_dlname"
3360f353fbadSmrg	            dlprefile_dlbasename="$func_basename_result"
3361f353fbadSmrg	          else
3362f353fbadSmrg	            # no lafile. user explicitly requested -dlpreopen <import library>.
3363f353fbadSmrg	            $sharedlib_from_linklib_cmd "$dlprefile"
3364f353fbadSmrg	            dlprefile_dlbasename=$sharedlib_from_linklib_result
3365f353fbadSmrg	          fi
3366f353fbadSmrg	        fi
3367f353fbadSmrg	        $opt_dry_run || {
3368f353fbadSmrg	          if test -n "$dlprefile_dlbasename" ; then
3369f353fbadSmrg	            eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
3370f353fbadSmrg	          else
3371f353fbadSmrg	            func_warning "Could not compute DLL name from $name"
3372f353fbadSmrg	            eval '$ECHO ": $name " >> "$nlist"'
3373f353fbadSmrg	          fi
3374f353fbadSmrg	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
3375f353fbadSmrg	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe |
3376f353fbadSmrg	            $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'"
3377f353fbadSmrg	        }
3378f353fbadSmrg	      else # not an import lib
3379f353fbadSmrg	        $opt_dry_run || {
3380f353fbadSmrg	          eval '$ECHO ": $name " >> "$nlist"'
3381f353fbadSmrg	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
3382f353fbadSmrg	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
3383f353fbadSmrg	        }
3384f353fbadSmrg	      fi
3385f353fbadSmrg	    ;;
3386f353fbadSmrg	    *)
3387f353fbadSmrg	      $opt_dry_run || {
3388f353fbadSmrg	        eval '$ECHO ": $name " >> "$nlist"'
3389f353fbadSmrg	        func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
3390f353fbadSmrg	        eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
3391f353fbadSmrg	      }
3392f353fbadSmrg	    ;;
3393f353fbadSmrg          esac
3394994689c1Smrg	done
3395994689c1Smrg
3396994689c1Smrg	$opt_dry_run || {
3397994689c1Smrg	  # Make sure we have at least an empty file.
3398994689c1Smrg	  test -f "$nlist" || : > "$nlist"
3399994689c1Smrg
3400994689c1Smrg	  if test -n "$exclude_expsyms"; then
3401994689c1Smrg	    $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
3402994689c1Smrg	    $MV "$nlist"T "$nlist"
3403e1e1713cSmrg	  fi
3404994689c1Smrg
3405994689c1Smrg	  # Try sorting and uniquifying the output.
3406994689c1Smrg	  if $GREP -v "^: " < "$nlist" |
3407994689c1Smrg	      if sort -k 3 </dev/null >/dev/null 2>&1; then
3408994689c1Smrg		sort -k 3
3409994689c1Smrg	      else
3410994689c1Smrg		sort +2
3411994689c1Smrg	      fi |
3412994689c1Smrg	      uniq > "$nlist"S; then
3413994689c1Smrg	    :
3414e1e1713cSmrg	  else
3415994689c1Smrg	    $GREP -v "^: " < "$nlist" > "$nlist"S
3416e1e1713cSmrg	  fi
34177a84e134Smrg
3418994689c1Smrg	  if test -f "$nlist"S; then
3419994689c1Smrg	    eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
3420e1e1713cSmrg	  else
3421994689c1Smrg	    echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
3422e1e1713cSmrg	  fi
34237a84e134Smrg
3424994689c1Smrg	  echo >> "$output_objdir/$my_dlsyms" "\
34257a84e134Smrg
3426994689c1Smrg/* The mapping between symbol names and symbols.  */
3427994689c1Smrgtypedef struct {
3428994689c1Smrg  const char *name;
3429994689c1Smrg  void *address;
3430994689c1Smrg} lt_dlsymlist;
3431f353fbadSmrgextern LT_DLSYM_CONST lt_dlsymlist
3432994689c1Smrglt_${my_prefix}_LTX_preloaded_symbols[];
3433f353fbadSmrgLT_DLSYM_CONST lt_dlsymlist
3434994689c1Smrglt_${my_prefix}_LTX_preloaded_symbols[] =
3435994689c1Smrg{\
3436994689c1Smrg  { \"$my_originator\", (void *) 0 },"
34377a84e134Smrg
3438994689c1Smrg	  case $need_lib_prefix in
3439994689c1Smrg	  no)
3440994689c1Smrg	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
3441994689c1Smrg	    ;;
3442994689c1Smrg	  *)
3443994689c1Smrg	    eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
3444994689c1Smrg	    ;;
3445994689c1Smrg	  esac
3446994689c1Smrg	  echo >> "$output_objdir/$my_dlsyms" "\
3447994689c1Smrg  {0, (void *) 0}
3448994689c1Smrg};
34497a84e134Smrg
3450994689c1Smrg/* This works around a problem in FreeBSD linker */
3451994689c1Smrg#ifdef FREEBSD_WORKAROUND
3452994689c1Smrgstatic const void *lt_preloaded_setup() {
3453994689c1Smrg  return lt_${my_prefix}_LTX_preloaded_symbols;
3454994689c1Smrg}
3455994689c1Smrg#endif
34567a84e134Smrg
3457994689c1Smrg#ifdef __cplusplus
3458994689c1Smrg}
3459994689c1Smrg#endif\
3460994689c1Smrg"
3461994689c1Smrg	} # !$opt_dry_run
3462775e7de9Smrg
3463994689c1Smrg	pic_flag_for_symtable=
3464994689c1Smrg	case "$compile_command " in
3465994689c1Smrg	*" -static "*) ;;
3466994689c1Smrg	*)
3467994689c1Smrg	  case $host in
3468994689c1Smrg	  # compiling the symbol table file with pic_flag works around
3469994689c1Smrg	  # a FreeBSD bug that causes programs to crash when -lm is
3470994689c1Smrg	  # linked before any other PIC object.  But we must not use
3471994689c1Smrg	  # pic_flag when linking with -static.  The problem exists in
3472994689c1Smrg	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
3473994689c1Smrg	  *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
3474994689c1Smrg	    pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
3475994689c1Smrg	  *-*-hpux*)
3476994689c1Smrg	    pic_flag_for_symtable=" $pic_flag"  ;;
3477994689c1Smrg	  *)
3478994689c1Smrg	    if test "X$my_pic_p" != Xno; then
3479994689c1Smrg	      pic_flag_for_symtable=" $pic_flag"
3480994689c1Smrg	    fi
3481994689c1Smrg	    ;;
3482994689c1Smrg	  esac
3483994689c1Smrg	  ;;
3484994689c1Smrg	esac
3485994689c1Smrg	symtab_cflags=
3486994689c1Smrg	for arg in $LTCFLAGS; do
3487994689c1Smrg	  case $arg in
3488994689c1Smrg	  -pie | -fpie | -fPIE) ;;
3489f353fbadSmrg	  *) func_append symtab_cflags " $arg" ;;
3490994689c1Smrg	  esac
3491994689c1Smrg	done
34927a84e134Smrg
3493994689c1Smrg	# Now compile the dynamic symbol file.
3494994689c1Smrg	func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
34957a84e134Smrg
3496994689c1Smrg	# Clean up the generated files.
3497994689c1Smrg	func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"'
3498775e7de9Smrg
3499994689c1Smrg	# Transform the symbol file into the correct name.
3500994689c1Smrg	symfileobj="$output_objdir/${my_outputname}S.$objext"
3501994689c1Smrg	case $host in
3502994689c1Smrg	*cygwin* | *mingw* | *cegcc* )
3503994689c1Smrg	  if test -f "$output_objdir/$my_outputname.def"; then
3504994689c1Smrg	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
3505994689c1Smrg	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
3506994689c1Smrg	  else
3507994689c1Smrg	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3508994689c1Smrg	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3509994689c1Smrg	  fi
3510994689c1Smrg	  ;;
3511994689c1Smrg	*)
3512994689c1Smrg	  compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3513994689c1Smrg	  finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3514994689c1Smrg	  ;;
3515994689c1Smrg	esac
3516994689c1Smrg	;;
3517994689c1Smrg      *)
3518994689c1Smrg	func_fatal_error "unknown suffix for \`$my_dlsyms'"
3519994689c1Smrg	;;
3520994689c1Smrg      esac
3521994689c1Smrg    else
3522994689c1Smrg      # We keep going just in case the user didn't refer to
3523994689c1Smrg      # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
3524994689c1Smrg      # really was required.
3525775e7de9Smrg
3526994689c1Smrg      # Nullify the symbol file.
3527994689c1Smrg      compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
3528994689c1Smrg      finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
3529994689c1Smrg    fi
3530994689c1Smrg}
3531775e7de9Smrg
3532994689c1Smrg# func_win32_libid arg
3533994689c1Smrg# return the library type of file 'arg'
3534994689c1Smrg#
3535994689c1Smrg# Need a lot of goo to handle *both* DLLs and import libs
3536994689c1Smrg# Has to be a shell function in order to 'eat' the argument
3537994689c1Smrg# that is supplied when $file_magic_command is called.
3538994689c1Smrg# Despite the name, also deal with 64 bit binaries.
3539994689c1Smrgfunc_win32_libid ()
3540994689c1Smrg{
3541994689c1Smrg  $opt_debug
3542994689c1Smrg  win32_libid_type="unknown"
3543994689c1Smrg  win32_fileres=`file -L $1 2>/dev/null`
3544994689c1Smrg  case $win32_fileres in
3545994689c1Smrg  *ar\ archive\ import\ library*) # definitely import
3546994689c1Smrg    win32_libid_type="x86 archive import"
3547994689c1Smrg    ;;
3548994689c1Smrg  *ar\ archive*) # could be an import, or static
3549994689c1Smrg    # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
3550994689c1Smrg    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
3551994689c1Smrg       $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
3552f353fbadSmrg      func_to_tool_file "$1" func_convert_file_msys_to_w32
3553f353fbadSmrg      win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
3554994689c1Smrg	$SED -n -e '
3555994689c1Smrg	    1,100{
3556994689c1Smrg		/ I /{
3557994689c1Smrg		    s,.*,import,
3558994689c1Smrg		    p
3559994689c1Smrg		    q
3560994689c1Smrg		}
3561994689c1Smrg	    }'`
3562994689c1Smrg      case $win32_nmres in
3563994689c1Smrg      import*)  win32_libid_type="x86 archive import";;
3564994689c1Smrg      *)        win32_libid_type="x86 archive static";;
3565994689c1Smrg      esac
3566994689c1Smrg    fi
3567994689c1Smrg    ;;
3568994689c1Smrg  *DLL*)
3569994689c1Smrg    win32_libid_type="x86 DLL"
3570994689c1Smrg    ;;
3571994689c1Smrg  *executable*) # but shell scripts are "executable" too...
3572994689c1Smrg    case $win32_fileres in
3573994689c1Smrg    *MS\ Windows\ PE\ Intel*)
3574994689c1Smrg      win32_libid_type="x86 DLL"
3575994689c1Smrg      ;;
3576994689c1Smrg    esac
3577994689c1Smrg    ;;
3578994689c1Smrg  esac
3579994689c1Smrg  $ECHO "$win32_libid_type"
3580994689c1Smrg}
3581775e7de9Smrg
3582f353fbadSmrg# func_cygming_dll_for_implib ARG
3583f353fbadSmrg#
3584f353fbadSmrg# Platform-specific function to extract the
3585f353fbadSmrg# name of the DLL associated with the specified
3586f353fbadSmrg# import library ARG.
3587f353fbadSmrg# Invoked by eval'ing the libtool variable
3588f353fbadSmrg#    $sharedlib_from_linklib_cmd
3589f353fbadSmrg# Result is available in the variable
3590f353fbadSmrg#    $sharedlib_from_linklib_result
3591f353fbadSmrgfunc_cygming_dll_for_implib ()
3592f353fbadSmrg{
3593f353fbadSmrg  $opt_debug
3594f353fbadSmrg  sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
3595f353fbadSmrg}
3596f353fbadSmrg
3597f353fbadSmrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs
3598f353fbadSmrg#
3599f353fbadSmrg# The is the core of a fallback implementation of a
3600f353fbadSmrg# platform-specific function to extract the name of the
3601f353fbadSmrg# DLL associated with the specified import library LIBNAME.
3602f353fbadSmrg#
3603f353fbadSmrg# SECTION_NAME is either .idata$6 or .idata$7, depending
3604f353fbadSmrg# on the platform and compiler that created the implib.
3605f353fbadSmrg#
3606f353fbadSmrg# Echos the name of the DLL associated with the
3607f353fbadSmrg# specified import library.
3608f353fbadSmrgfunc_cygming_dll_for_implib_fallback_core ()
3609f353fbadSmrg{
3610f353fbadSmrg  $opt_debug
3611f353fbadSmrg  match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
3612f353fbadSmrg  $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
3613f353fbadSmrg    $SED '/^Contents of section '"$match_literal"':/{
3614f353fbadSmrg      # Place marker at beginning of archive member dllname section
3615f353fbadSmrg      s/.*/====MARK====/
3616f353fbadSmrg      p
3617f353fbadSmrg      d
3618f353fbadSmrg    }
3619f353fbadSmrg    # These lines can sometimes be longer than 43 characters, but
3620f353fbadSmrg    # are always uninteresting
3621f353fbadSmrg    /:[	 ]*file format pe[i]\{,1\}-/d
3622f353fbadSmrg    /^In archive [^:]*:/d
3623f353fbadSmrg    # Ensure marker is printed
3624f353fbadSmrg    /^====MARK====/p
3625f353fbadSmrg    # Remove all lines with less than 43 characters
3626f353fbadSmrg    /^.\{43\}/!d
3627f353fbadSmrg    # From remaining lines, remove first 43 characters
3628f353fbadSmrg    s/^.\{43\}//' |
3629f353fbadSmrg    $SED -n '
3630f353fbadSmrg      # Join marker and all lines until next marker into a single line
3631f353fbadSmrg      /^====MARK====/ b para
3632f353fbadSmrg      H
3633f353fbadSmrg      $ b para
3634f353fbadSmrg      b
3635f353fbadSmrg      :para
3636f353fbadSmrg      x
3637f353fbadSmrg      s/\n//g
3638f353fbadSmrg      # Remove the marker
3639f353fbadSmrg      s/^====MARK====//
3640f353fbadSmrg      # Remove trailing dots and whitespace
3641f353fbadSmrg      s/[\. \t]*$//
3642f353fbadSmrg      # Print
3643f353fbadSmrg      /./p' |
3644f353fbadSmrg    # we now have a list, one entry per line, of the stringified
3645f353fbadSmrg    # contents of the appropriate section of all members of the
3646f353fbadSmrg    # archive which possess that section. Heuristic: eliminate
3647f353fbadSmrg    # all those which have a first or second character that is
3648f353fbadSmrg    # a '.' (that is, objdump's representation of an unprintable
3649f353fbadSmrg    # character.) This should work for all archives with less than
3650f353fbadSmrg    # 0x302f exports -- but will fail for DLLs whose name actually
3651f353fbadSmrg    # begins with a literal '.' or a single character followed by
3652f353fbadSmrg    # a '.'.
3653f353fbadSmrg    #
3654f353fbadSmrg    # Of those that remain, print the first one.
3655f353fbadSmrg    $SED -e '/^\./d;/^.\./d;q'
3656f353fbadSmrg}
3657f353fbadSmrg
3658f353fbadSmrg# func_cygming_gnu_implib_p ARG
3659f353fbadSmrg# This predicate returns with zero status (TRUE) if
3660f353fbadSmrg# ARG is a GNU/binutils-style import library. Returns
3661f353fbadSmrg# with nonzero status (FALSE) otherwise.
3662f353fbadSmrgfunc_cygming_gnu_implib_p ()
3663f353fbadSmrg{
3664f353fbadSmrg  $opt_debug
3665f353fbadSmrg  func_to_tool_file "$1" func_convert_file_msys_to_w32
3666f353fbadSmrg  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)$'`
3667f353fbadSmrg  test -n "$func_cygming_gnu_implib_tmp"
3668f353fbadSmrg}
3669f353fbadSmrg
3670f353fbadSmrg# func_cygming_ms_implib_p ARG
3671f353fbadSmrg# This predicate returns with zero status (TRUE) if
3672f353fbadSmrg# ARG is an MS-style import library. Returns
3673f353fbadSmrg# with nonzero status (FALSE) otherwise.
3674f353fbadSmrgfunc_cygming_ms_implib_p ()
3675f353fbadSmrg{
3676f353fbadSmrg  $opt_debug
3677f353fbadSmrg  func_to_tool_file "$1" func_convert_file_msys_to_w32
3678f353fbadSmrg  func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
3679f353fbadSmrg  test -n "$func_cygming_ms_implib_tmp"
3680f353fbadSmrg}
3681f353fbadSmrg
3682f353fbadSmrg# func_cygming_dll_for_implib_fallback ARG
3683f353fbadSmrg# Platform-specific function to extract the
3684f353fbadSmrg# name of the DLL associated with the specified
3685f353fbadSmrg# import library ARG.
3686f353fbadSmrg#
3687f353fbadSmrg# This fallback implementation is for use when $DLLTOOL
3688f353fbadSmrg# does not support the --identify-strict option.
3689f353fbadSmrg# Invoked by eval'ing the libtool variable
3690f353fbadSmrg#    $sharedlib_from_linklib_cmd
3691f353fbadSmrg# Result is available in the variable
3692f353fbadSmrg#    $sharedlib_from_linklib_result
3693f353fbadSmrgfunc_cygming_dll_for_implib_fallback ()
3694f353fbadSmrg{
3695f353fbadSmrg  $opt_debug
3696f353fbadSmrg  if func_cygming_gnu_implib_p "$1" ; then
3697f353fbadSmrg    # binutils import library
3698f353fbadSmrg    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
3699f353fbadSmrg  elif func_cygming_ms_implib_p "$1" ; then
3700f353fbadSmrg    # ms-generated import library
3701f353fbadSmrg    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
3702f353fbadSmrg  else
3703f353fbadSmrg    # unknown
3704f353fbadSmrg    sharedlib_from_linklib_result=""
3705f353fbadSmrg  fi
3706f353fbadSmrg}
37077a84e134Smrg
37087a84e134Smrg
3709994689c1Smrg# func_extract_an_archive dir oldlib
3710994689c1Smrgfunc_extract_an_archive ()
3711994689c1Smrg{
3712994689c1Smrg    $opt_debug
3713994689c1Smrg    f_ex_an_ar_dir="$1"; shift
3714994689c1Smrg    f_ex_an_ar_oldlib="$1"
3715994689c1Smrg    if test "$lock_old_archive_extraction" = yes; then
3716994689c1Smrg      lockfile=$f_ex_an_ar_oldlib.lock
3717994689c1Smrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
3718994689c1Smrg	func_echo "Waiting for $lockfile to be removed"
3719994689c1Smrg	sleep 2
3720994689c1Smrg      done
3721994689c1Smrg    fi
3722994689c1Smrg    func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
3723994689c1Smrg		   'stat=$?; rm -f "$lockfile"; exit $stat'
3724994689c1Smrg    if test "$lock_old_archive_extraction" = yes; then
3725994689c1Smrg      $opt_dry_run || rm -f "$lockfile"
3726994689c1Smrg    fi
3727994689c1Smrg    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
3728994689c1Smrg     :
3729994689c1Smrg    else
3730994689c1Smrg      func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
3731994689c1Smrg    fi
3732994689c1Smrg}
37337a84e134Smrg
37347a84e134Smrg
3735994689c1Smrg# func_extract_archives gentop oldlib ...
3736994689c1Smrgfunc_extract_archives ()
3737994689c1Smrg{
3738994689c1Smrg    $opt_debug
3739994689c1Smrg    my_gentop="$1"; shift
3740994689c1Smrg    my_oldlibs=${1+"$@"}
3741994689c1Smrg    my_oldobjs=""
3742994689c1Smrg    my_xlib=""
3743994689c1Smrg    my_xabs=""
3744994689c1Smrg    my_xdir=""
37457a84e134Smrg
3746994689c1Smrg    for my_xlib in $my_oldlibs; do
3747994689c1Smrg      # Extract the objects.
3748994689c1Smrg      case $my_xlib in
3749994689c1Smrg	[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
3750994689c1Smrg	*) my_xabs=`pwd`"/$my_xlib" ;;
3751994689c1Smrg      esac
3752994689c1Smrg      func_basename "$my_xlib"
3753994689c1Smrg      my_xlib="$func_basename_result"
3754994689c1Smrg      my_xlib_u=$my_xlib
3755994689c1Smrg      while :; do
3756994689c1Smrg        case " $extracted_archives " in
3757994689c1Smrg	*" $my_xlib_u "*)
3758994689c1Smrg	  func_arith $extracted_serial + 1
3759994689c1Smrg	  extracted_serial=$func_arith_result
3760994689c1Smrg	  my_xlib_u=lt$extracted_serial-$my_xlib ;;
3761994689c1Smrg	*) break ;;
3762994689c1Smrg	esac
3763994689c1Smrg      done
3764994689c1Smrg      extracted_archives="$extracted_archives $my_xlib_u"
3765994689c1Smrg      my_xdir="$my_gentop/$my_xlib_u"
3766775e7de9Smrg
3767994689c1Smrg      func_mkdir_p "$my_xdir"
3768994689c1Smrg
3769994689c1Smrg      case $host in
3770994689c1Smrg      *-darwin*)
3771994689c1Smrg	func_verbose "Extracting $my_xabs"
3772994689c1Smrg	# Do not bother doing anything if just a dry run
3773994689c1Smrg	$opt_dry_run || {
3774994689c1Smrg	  darwin_orig_dir=`pwd`
3775994689c1Smrg	  cd $my_xdir || exit $?
3776994689c1Smrg	  darwin_archive=$my_xabs
3777994689c1Smrg	  darwin_curdir=`pwd`
3778994689c1Smrg	  darwin_base_archive=`basename "$darwin_archive"`
3779994689c1Smrg	  darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
3780994689c1Smrg	  if test -n "$darwin_arches"; then
3781994689c1Smrg	    darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
3782994689c1Smrg	    darwin_arch=
3783994689c1Smrg	    func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
3784994689c1Smrg	    for darwin_arch in  $darwin_arches ; do
3785994689c1Smrg	      func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
3786994689c1Smrg	      $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
3787994689c1Smrg	      cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
3788994689c1Smrg	      func_extract_an_archive "`pwd`" "${darwin_base_archive}"
3789994689c1Smrg	      cd "$darwin_curdir"
3790994689c1Smrg	      $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
3791994689c1Smrg	    done # $darwin_arches
3792994689c1Smrg            ## Okay now we've a bunch of thin objects, gotta fatten them up :)
3793994689c1Smrg	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u`
3794994689c1Smrg	    darwin_file=
3795994689c1Smrg	    darwin_files=
3796994689c1Smrg	    for darwin_file in $darwin_filelist; do
3797994689c1Smrg	      darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`
3798994689c1Smrg	      $LIPO -create -output "$darwin_file" $darwin_files
3799994689c1Smrg	    done # $darwin_filelist
3800994689c1Smrg	    $RM -rf unfat-$$
3801994689c1Smrg	    cd "$darwin_orig_dir"
3802e1e1713cSmrg	  else
3803994689c1Smrg	    cd $darwin_orig_dir
3804994689c1Smrg	    func_extract_an_archive "$my_xdir" "$my_xabs"
3805994689c1Smrg	  fi # $darwin_arches
3806994689c1Smrg	} # !$opt_dry_run
3807994689c1Smrg	;;
3808994689c1Smrg      *)
3809994689c1Smrg        func_extract_an_archive "$my_xdir" "$my_xabs"
3810994689c1Smrg	;;
3811994689c1Smrg      esac
3812994689c1Smrg      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
3813994689c1Smrg    done
38147a84e134Smrg
3815994689c1Smrg    func_extract_archives_result="$my_oldobjs"
3816994689c1Smrg}
38177a84e134Smrg
38187a84e134Smrg
3819994689c1Smrg# func_emit_wrapper [arg=no]
3820994689c1Smrg#
3821994689c1Smrg# Emit a libtool wrapper script on stdout.
3822994689c1Smrg# Don't directly open a file because we may want to
3823994689c1Smrg# incorporate the script contents within a cygwin/mingw
3824994689c1Smrg# wrapper executable.  Must ONLY be called from within
3825994689c1Smrg# func_mode_link because it depends on a number of variables
3826994689c1Smrg# set therein.
3827994689c1Smrg#
3828994689c1Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
3829994689c1Smrg# variable will take.  If 'yes', then the emitted script
3830994689c1Smrg# will assume that the directory in which it is stored is
3831994689c1Smrg# the $objdir directory.  This is a cygwin/mingw-specific
3832994689c1Smrg# behavior.
3833994689c1Smrgfunc_emit_wrapper ()
3834994689c1Smrg{
3835994689c1Smrg	func_emit_wrapper_arg1=${1-no}
3836e1e1713cSmrg
3837994689c1Smrg	$ECHO "\
3838994689c1Smrg#! $SHELL
38397a84e134Smrg
3840994689c1Smrg# $output - temporary wrapper script for $objdir/$outputname
3841994689c1Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
3842994689c1Smrg#
3843994689c1Smrg# The $output program cannot be directly executed until all the libtool
3844994689c1Smrg# libraries that it depends on are installed.
3845994689c1Smrg#
3846994689c1Smrg# This wrapper script should never be moved out of the build directory.
3847994689c1Smrg# If it is, it will not operate correctly.
38487a84e134Smrg
3849994689c1Smrg# Sed substitution that helps us do robust quoting.  It backslashifies
3850994689c1Smrg# metacharacters that are still active within double-quoted strings.
3851994689c1Smrgsed_quote_subst='$sed_quote_subst'
38527a84e134Smrg
3853994689c1Smrg# Be Bourne compatible
3854994689c1Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
3855994689c1Smrg  emulate sh
3856994689c1Smrg  NULLCMD=:
3857994689c1Smrg  # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
3858994689c1Smrg  # is contrary to our usage.  Disable this feature.
3859994689c1Smrg  alias -g '\${1+\"\$@\"}'='\"\$@\"'
3860994689c1Smrg  setopt NO_GLOB_SUBST
3861994689c1Smrgelse
3862994689c1Smrg  case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
3863994689c1Smrgfi
3864994689c1SmrgBIN_SH=xpg4; export BIN_SH # for Tru64
3865994689c1SmrgDUALCASE=1; export DUALCASE # for MKS sh
38667a84e134Smrg
3867994689c1Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout
3868994689c1Smrg# if CDPATH is set.
3869994689c1Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
38707a84e134Smrg
3871994689c1Smrgrelink_command=\"$relink_command\"
38727a84e134Smrg
3873994689c1Smrg# This environment variable determines our operation mode.
3874994689c1Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then
3875994689c1Smrg  # install mode needs the following variables:
3876994689c1Smrg  generated_by_libtool_version='$macro_version'
3877994689c1Smrg  notinst_deplibs='$notinst_deplibs'
3878994689c1Smrgelse
3879994689c1Smrg  # When we are sourced in execute mode, \$file and \$ECHO are already set.
3880994689c1Smrg  if test \"\$libtool_execute_magic\" != \"$magic\"; then
3881994689c1Smrg    file=\"\$0\""
38827a84e134Smrg
3883994689c1Smrg    qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"`
3884994689c1Smrg    $ECHO "\
38857a84e134Smrg
3886994689c1Smrg# A function that is used when there is no print builtin or printf.
3887994689c1Smrgfunc_fallback_echo ()
3888994689c1Smrg{
3889994689c1Smrg  eval 'cat <<_LTECHO_EOF
3890994689c1Smrg\$1
3891994689c1Smrg_LTECHO_EOF'
3892994689c1Smrg}
3893994689c1Smrg    ECHO=\"$qECHO\"
3894994689c1Smrg  fi
3895994689c1Smrg
3896994689c1Smrg# Very basic option parsing. These options are (a) specific to
3897994689c1Smrg# the libtool wrapper, (b) are identical between the wrapper
3898994689c1Smrg# /script/ and the wrapper /executable/ which is used only on
3899994689c1Smrg# windows platforms, and (c) all begin with the string "--lt-"
3900994689c1Smrg# (application programs are unlikely to have options which match
3901994689c1Smrg# this pattern).
3902994689c1Smrg#
3903994689c1Smrg# There are only two supported options: --lt-debug and
3904994689c1Smrg# --lt-dump-script. There is, deliberately, no --lt-help.
3905994689c1Smrg#
3906994689c1Smrg# The first argument to this parsing function should be the
3907994689c1Smrg# script's $0 value, followed by "$@".
3908994689c1Smrglt_option_debug=
3909994689c1Smrgfunc_parse_lt_options ()
3910994689c1Smrg{
3911994689c1Smrg  lt_script_arg0=\$0
3912994689c1Smrg  shift
3913994689c1Smrg  for lt_opt
3914994689c1Smrg  do
3915994689c1Smrg    case \"\$lt_opt\" in
3916994689c1Smrg    --lt-debug) lt_option_debug=1 ;;
3917994689c1Smrg    --lt-dump-script)
3918994689c1Smrg        lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
3919994689c1Smrg        test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
3920994689c1Smrg        lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
3921994689c1Smrg        cat \"\$lt_dump_D/\$lt_dump_F\"
3922994689c1Smrg        exit 0
3923994689c1Smrg      ;;
3924994689c1Smrg    --lt-*)
3925994689c1Smrg        \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
3926994689c1Smrg        exit 1
3927e1e1713cSmrg      ;;
3928994689c1Smrg    esac
3929994689c1Smrg  done
39307a84e134Smrg
3931994689c1Smrg  # Print the debug banner immediately:
3932994689c1Smrg  if test -n \"\$lt_option_debug\"; then
3933994689c1Smrg    echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2
3934994689c1Smrg  fi
3935994689c1Smrg}
39367a84e134Smrg
3937994689c1Smrg# Used when --lt-debug. Prints its arguments to stdout
3938994689c1Smrg# (redirection is the responsibility of the caller)
3939994689c1Smrgfunc_lt_dump_args ()
3940994689c1Smrg{
3941994689c1Smrg  lt_dump_args_N=1;
3942994689c1Smrg  for lt_arg
3943994689c1Smrg  do
3944994689c1Smrg    \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\"
3945994689c1Smrg    lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
3946994689c1Smrg  done
3947994689c1Smrg}
39487a84e134Smrg
3949994689c1Smrg# Core function for launching the target application
3950994689c1Smrgfunc_exec_program_core ()
3951994689c1Smrg{
3952994689c1Smrg"
3953994689c1Smrg  case $host in
3954994689c1Smrg  # Backslashes separate directories on plain windows
3955994689c1Smrg  *-*-mingw | *-*-os2* | *-cegcc*)
3956994689c1Smrg    $ECHO "\
3957994689c1Smrg      if test -n \"\$lt_option_debug\"; then
3958994689c1Smrg        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2
3959994689c1Smrg        func_lt_dump_args \${1+\"\$@\"} 1>&2
3960e1e1713cSmrg      fi
3961994689c1Smrg      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
3962994689c1Smrg"
3963994689c1Smrg    ;;
39647a84e134Smrg
3965994689c1Smrg  *)
3966994689c1Smrg    $ECHO "\
3967994689c1Smrg      if test -n \"\$lt_option_debug\"; then
3968994689c1Smrg        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2
3969994689c1Smrg        func_lt_dump_args \${1+\"\$@\"} 1>&2
3970e1e1713cSmrg      fi
3971994689c1Smrg      exec \"\$progdir/\$program\" \${1+\"\$@\"}
3972994689c1Smrg"
3973994689c1Smrg    ;;
3974994689c1Smrg  esac
3975994689c1Smrg  $ECHO "\
3976994689c1Smrg      \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
3977994689c1Smrg      exit 1
3978994689c1Smrg}
39797a84e134Smrg
3980994689c1Smrg# A function to encapsulate launching the target application
3981994689c1Smrg# Strips options in the --lt-* namespace from \$@ and
3982994689c1Smrg# launches target application with the remaining arguments.
3983994689c1Smrgfunc_exec_program ()
3984994689c1Smrg{
3985994689c1Smrg  for lt_wr_arg
3986994689c1Smrg  do
3987994689c1Smrg    case \$lt_wr_arg in
3988994689c1Smrg    --lt-*) ;;
3989994689c1Smrg    *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
3990994689c1Smrg    esac
3991994689c1Smrg    shift
3992994689c1Smrg  done
3993994689c1Smrg  func_exec_program_core \${1+\"\$@\"}
3994994689c1Smrg}
39957a84e134Smrg
3996994689c1Smrg  # Parse options
3997994689c1Smrg  func_parse_lt_options \"\$0\" \${1+\"\$@\"}
39987a84e134Smrg
3999994689c1Smrg  # Find the directory that this script lives in.
4000994689c1Smrg  thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
4001994689c1Smrg  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
40027a84e134Smrg
4003994689c1Smrg  # Follow symbolic links until we get to the real thisdir.
4004994689c1Smrg  file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
4005994689c1Smrg  while test -n \"\$file\"; do
4006994689c1Smrg    destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
40077a84e134Smrg
4008994689c1Smrg    # If there was a directory component, then change thisdir.
4009994689c1Smrg    if test \"x\$destdir\" != \"x\$file\"; then
4010994689c1Smrg      case \"\$destdir\" in
4011994689c1Smrg      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
4012994689c1Smrg      *) thisdir=\"\$thisdir/\$destdir\" ;;
4013994689c1Smrg      esac
4014994689c1Smrg    fi
40157a84e134Smrg
4016994689c1Smrg    file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
4017994689c1Smrg    file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
4018994689c1Smrg  done
40197a84e134Smrg
4020994689c1Smrg  # Usually 'no', except on cygwin/mingw when embedded into
4021994689c1Smrg  # the cwrapper.
4022994689c1Smrg  WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
4023994689c1Smrg  if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
4024994689c1Smrg    # special case for '.'
4025994689c1Smrg    if test \"\$thisdir\" = \".\"; then
4026994689c1Smrg      thisdir=\`pwd\`
4027994689c1Smrg    fi
4028994689c1Smrg    # remove .libs from thisdir
4029994689c1Smrg    case \"\$thisdir\" in
4030994689c1Smrg    *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
4031994689c1Smrg    $objdir )   thisdir=. ;;
4032994689c1Smrg    esac
4033994689c1Smrg  fi
40347a84e134Smrg
4035994689c1Smrg  # Try to get the absolute directory name.
4036994689c1Smrg  absdir=\`cd \"\$thisdir\" && pwd\`
4037994689c1Smrg  test -n \"\$absdir\" && thisdir=\"\$absdir\"
4038994689c1Smrg"
40397a84e134Smrg
4040994689c1Smrg	if test "$fast_install" = yes; then
4041994689c1Smrg	  $ECHO "\
4042994689c1Smrg  program=lt-'$outputname'$exeext
4043994689c1Smrg  progdir=\"\$thisdir/$objdir\"
40447a84e134Smrg
4045994689c1Smrg  if test ! -f \"\$progdir/\$program\" ||
4046994689c1Smrg     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
4047994689c1Smrg       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
40487a84e134Smrg
4049994689c1Smrg    file=\"\$\$-\$program\"
40507a84e134Smrg
4051994689c1Smrg    if test ! -d \"\$progdir\"; then
4052994689c1Smrg      $MKDIR \"\$progdir\"
4053994689c1Smrg    else
4054994689c1Smrg      $RM \"\$progdir/\$file\"
4055994689c1Smrg    fi"
40567a84e134Smrg
4057994689c1Smrg	  $ECHO "\
40587a84e134Smrg
4059994689c1Smrg    # relink executable if necessary
4060994689c1Smrg    if test -n \"\$relink_command\"; then
4061994689c1Smrg      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
4062994689c1Smrg      else
4063994689c1Smrg	$ECHO \"\$relink_command_output\" >&2
4064994689c1Smrg	$RM \"\$progdir/\$file\"
4065994689c1Smrg	exit 1
4066994689c1Smrg      fi
4067994689c1Smrg    fi
40687a84e134Smrg
4069994689c1Smrg    $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
4070994689c1Smrg    { $RM \"\$progdir/\$program\";
4071994689c1Smrg      $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
4072994689c1Smrg    $RM \"\$progdir/\$file\"
4073994689c1Smrg  fi"
4074994689c1Smrg	else
4075994689c1Smrg	  $ECHO "\
4076994689c1Smrg  program='$outputname'
4077994689c1Smrg  progdir=\"\$thisdir/$objdir\"
4078994689c1Smrg"
4079994689c1Smrg	fi
4080775e7de9Smrg
4081994689c1Smrg	$ECHO "\
40827a84e134Smrg
4083994689c1Smrg  if test -f \"\$progdir/\$program\"; then"
40847a84e134Smrg
4085f353fbadSmrg	# fixup the dll searchpath if we need to.
4086f353fbadSmrg	#
4087f353fbadSmrg	# Fix the DLL searchpath if we need to.  Do this before prepending
4088f353fbadSmrg	# to shlibpath, because on Windows, both are PATH and uninstalled
4089f353fbadSmrg	# libraries must come first.
4090f353fbadSmrg	if test -n "$dllsearchpath"; then
4091f353fbadSmrg	  $ECHO "\
4092f353fbadSmrg    # Add the dll search path components to the executable PATH
4093f353fbadSmrg    PATH=$dllsearchpath:\$PATH
4094f353fbadSmrg"
4095f353fbadSmrg	fi
4096f353fbadSmrg
4097994689c1Smrg	# Export our shlibpath_var if we have one.
4098994689c1Smrg	if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
4099994689c1Smrg	  $ECHO "\
4100994689c1Smrg    # Add our own library path to $shlibpath_var
4101994689c1Smrg    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
41027a84e134Smrg
4103994689c1Smrg    # Some systems cannot cope with colon-terminated $shlibpath_var
4104994689c1Smrg    # The second colon is a workaround for a bug in BeOS R4 sed
4105994689c1Smrg    $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
41067a84e134Smrg
4107994689c1Smrg    export $shlibpath_var
4108994689c1Smrg"
4109994689c1Smrg	fi
41107a84e134Smrg
4111994689c1Smrg	$ECHO "\
4112994689c1Smrg    if test \"\$libtool_execute_magic\" != \"$magic\"; then
4113994689c1Smrg      # Run the actual program with our arguments.
4114994689c1Smrg      func_exec_program \${1+\"\$@\"}
4115994689c1Smrg    fi
4116994689c1Smrg  else
4117994689c1Smrg    # The program doesn't exist.
4118994689c1Smrg    \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
4119994689c1Smrg    \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
4120994689c1Smrg    \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
4121994689c1Smrg    exit 1
4122994689c1Smrg  fi
4123994689c1Smrgfi\
4124994689c1Smrg"
4125994689c1Smrg}
41267a84e134Smrg
41277a84e134Smrg
4128994689c1Smrg# func_emit_cwrapperexe_src
4129994689c1Smrg# emit the source code for a wrapper executable on stdout
4130994689c1Smrg# Must ONLY be called from within func_mode_link because
4131994689c1Smrg# it depends on a number of variable set therein.
4132994689c1Smrgfunc_emit_cwrapperexe_src ()
4133994689c1Smrg{
4134994689c1Smrg	cat <<EOF
41357a84e134Smrg
4136994689c1Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
4137994689c1Smrg   Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
41387a84e134Smrg
4139994689c1Smrg   The $output program cannot be directly executed until all the libtool
4140994689c1Smrg   libraries that it depends on are installed.
41417a84e134Smrg
4142994689c1Smrg   This wrapper executable should never be moved out of the build directory.
4143994689c1Smrg   If it is, it will not operate correctly.
4144994689c1Smrg*/
4145994689c1SmrgEOF
4146994689c1Smrg	    cat <<"EOF"
4147994689c1Smrg#ifdef _MSC_VER
4148994689c1Smrg# define _CRT_SECURE_NO_DEPRECATE 1
4149994689c1Smrg#endif
4150994689c1Smrg#include <stdio.h>
4151994689c1Smrg#include <stdlib.h>
4152994689c1Smrg#ifdef _MSC_VER
4153994689c1Smrg# include <direct.h>
4154994689c1Smrg# include <process.h>
4155994689c1Smrg# include <io.h>
4156994689c1Smrg#else
4157994689c1Smrg# include <unistd.h>
4158994689c1Smrg# include <stdint.h>
4159994689c1Smrg# ifdef __CYGWIN__
4160994689c1Smrg#  include <io.h>
4161994689c1Smrg# endif
4162994689c1Smrg#endif
4163994689c1Smrg#include <malloc.h>
4164994689c1Smrg#include <stdarg.h>
4165994689c1Smrg#include <assert.h>
4166994689c1Smrg#include <string.h>
4167994689c1Smrg#include <ctype.h>
4168994689c1Smrg#include <errno.h>
4169994689c1Smrg#include <fcntl.h>
4170994689c1Smrg#include <sys/stat.h>
41717a84e134Smrg
4172994689c1Smrg/* declarations of non-ANSI functions */
4173994689c1Smrg#if defined(__MINGW32__)
4174994689c1Smrg# ifdef __STRICT_ANSI__
4175994689c1Smrgint _putenv (const char *);
4176994689c1Smrg# endif
4177994689c1Smrg#elif defined(__CYGWIN__)
4178994689c1Smrg# ifdef __STRICT_ANSI__
4179994689c1Smrgchar *realpath (const char *, char *);
4180994689c1Smrgint putenv (char *);
4181994689c1Smrgint setenv (const char *, const char *, int);
4182994689c1Smrg# endif
4183994689c1Smrg/* #elif defined (other platforms) ... */
4184994689c1Smrg#endif
41857a84e134Smrg
4186994689c1Smrg/* portability defines, excluding path handling macros */
4187994689c1Smrg#if defined(_MSC_VER)
4188994689c1Smrg# define setmode _setmode
4189994689c1Smrg# define stat    _stat
4190994689c1Smrg# define chmod   _chmod
4191994689c1Smrg# define getcwd  _getcwd
4192994689c1Smrg# define putenv  _putenv
4193994689c1Smrg# define S_IXUSR _S_IEXEC
4194994689c1Smrg# ifndef _INTPTR_T_DEFINED
4195994689c1Smrg#  define _INTPTR_T_DEFINED
4196994689c1Smrg#  define intptr_t int
4197994689c1Smrg# endif
4198994689c1Smrg#elif defined(__MINGW32__)
4199994689c1Smrg# define setmode _setmode
4200994689c1Smrg# define stat    _stat
4201994689c1Smrg# define chmod   _chmod
4202994689c1Smrg# define getcwd  _getcwd
4203994689c1Smrg# define putenv  _putenv
4204994689c1Smrg#elif defined(__CYGWIN__)
4205994689c1Smrg# define HAVE_SETENV
4206994689c1Smrg# define FOPEN_WB "wb"
4207994689c1Smrg/* #elif defined (other platforms) ... */
4208994689c1Smrg#endif
42097a84e134Smrg
4210994689c1Smrg#if defined(PATH_MAX)
4211994689c1Smrg# define LT_PATHMAX PATH_MAX
4212994689c1Smrg#elif defined(MAXPATHLEN)
4213994689c1Smrg# define LT_PATHMAX MAXPATHLEN
4214994689c1Smrg#else
4215994689c1Smrg# define LT_PATHMAX 1024
4216994689c1Smrg#endif
42177a84e134Smrg
4218994689c1Smrg#ifndef S_IXOTH
4219994689c1Smrg# define S_IXOTH 0
4220994689c1Smrg#endif
4221994689c1Smrg#ifndef S_IXGRP
4222994689c1Smrg# define S_IXGRP 0
4223994689c1Smrg#endif
42247a84e134Smrg
4225994689c1Smrg/* path handling portability macros */
4226994689c1Smrg#ifndef DIR_SEPARATOR
4227994689c1Smrg# define DIR_SEPARATOR '/'
4228994689c1Smrg# define PATH_SEPARATOR ':'
4229994689c1Smrg#endif
42307a84e134Smrg
4231994689c1Smrg#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
4232994689c1Smrg  defined (__OS2__)
4233994689c1Smrg# define HAVE_DOS_BASED_FILE_SYSTEM
4234994689c1Smrg# define FOPEN_WB "wb"
4235994689c1Smrg# ifndef DIR_SEPARATOR_2
4236994689c1Smrg#  define DIR_SEPARATOR_2 '\\'
4237994689c1Smrg# endif
4238994689c1Smrg# ifndef PATH_SEPARATOR_2
4239994689c1Smrg#  define PATH_SEPARATOR_2 ';'
4240994689c1Smrg# endif
4241994689c1Smrg#endif
42427a84e134Smrg
4243994689c1Smrg#ifndef DIR_SEPARATOR_2
4244994689c1Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
4245994689c1Smrg#else /* DIR_SEPARATOR_2 */
4246994689c1Smrg# define IS_DIR_SEPARATOR(ch) \
4247994689c1Smrg	(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
4248994689c1Smrg#endif /* DIR_SEPARATOR_2 */
42497a84e134Smrg
4250994689c1Smrg#ifndef PATH_SEPARATOR_2
4251994689c1Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
4252994689c1Smrg#else /* PATH_SEPARATOR_2 */
4253994689c1Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
4254994689c1Smrg#endif /* PATH_SEPARATOR_2 */
4255994689c1Smrg
4256994689c1Smrg#ifndef FOPEN_WB
4257994689c1Smrg# define FOPEN_WB "w"
4258994689c1Smrg#endif
4259994689c1Smrg#ifndef _O_BINARY
4260994689c1Smrg# define _O_BINARY 0
4261994689c1Smrg#endif
4262994689c1Smrg
4263994689c1Smrg#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
4264994689c1Smrg#define XFREE(stale) do { \
4265994689c1Smrg  if (stale) { free ((void *) stale); stale = 0; } \
4266994689c1Smrg} while (0)
4267994689c1Smrg
4268994689c1Smrg#if defined(LT_DEBUGWRAPPER)
4269994689c1Smrgstatic int lt_debug = 1;
4270994689c1Smrg#else
4271994689c1Smrgstatic int lt_debug = 0;
4272994689c1Smrg#endif
4273994689c1Smrg
4274994689c1Smrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */
4275994689c1Smrg
4276994689c1Smrgvoid *xmalloc (size_t num);
4277994689c1Smrgchar *xstrdup (const char *string);
4278994689c1Smrgconst char *base_name (const char *name);
4279994689c1Smrgchar *find_executable (const char *wrapper);
4280994689c1Smrgchar *chase_symlinks (const char *pathspec);
4281994689c1Smrgint make_executable (const char *path);
4282994689c1Smrgint check_executable (const char *path);
4283994689c1Smrgchar *strendzap (char *str, const char *pat);
4284994689c1Smrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...);
4285994689c1Smrgvoid lt_fatal (const char *file, int line, const char *message, ...);
4286994689c1Smrgstatic const char *nonnull (const char *s);
4287994689c1Smrgstatic const char *nonempty (const char *s);
4288994689c1Smrgvoid lt_setenv (const char *name, const char *value);
4289994689c1Smrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end);
4290994689c1Smrgvoid lt_update_exe_path (const char *name, const char *value);
4291994689c1Smrgvoid lt_update_lib_path (const char *name, const char *value);
4292994689c1Smrgchar **prepare_spawn (char **argv);
4293994689c1Smrgvoid lt_dump_script (FILE *f);
4294994689c1SmrgEOF
4295994689c1Smrg
4296994689c1Smrg	    cat <<EOF
4297f353fbadSmrgvolatile const char * MAGIC_EXE = "$magic_exe";
4298994689c1Smrgconst char * LIB_PATH_VARNAME = "$shlibpath_var";
4299994689c1SmrgEOF
4300994689c1Smrg
4301994689c1Smrg	    if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
4302f353fbadSmrg              func_to_host_path "$temp_rpath"
4303994689c1Smrg	      cat <<EOF
4304f353fbadSmrgconst char * LIB_PATH_VALUE   = "$func_to_host_path_result";
4305e1e1713cSmrgEOF
4306e1e1713cSmrg	    else
4307994689c1Smrg	      cat <<"EOF"
4308994689c1Smrgconst char * LIB_PATH_VALUE   = "";
4309994689c1SmrgEOF
4310e1e1713cSmrg	    fi
4311994689c1Smrg
4312994689c1Smrg	    if test -n "$dllsearchpath"; then
4313f353fbadSmrg              func_to_host_path "$dllsearchpath:"
4314994689c1Smrg	      cat <<EOF
4315994689c1Smrgconst char * EXE_PATH_VARNAME = "PATH";
4316f353fbadSmrgconst char * EXE_PATH_VALUE   = "$func_to_host_path_result";
4317994689c1SmrgEOF
4318e1e1713cSmrg	    else
4319994689c1Smrg	      cat <<"EOF"
4320994689c1Smrgconst char * EXE_PATH_VARNAME = "";
4321994689c1Smrgconst char * EXE_PATH_VALUE   = "";
4322994689c1SmrgEOF
4323e1e1713cSmrg	    fi
4324994689c1Smrg
4325994689c1Smrg	    if test "$fast_install" = yes; then
4326994689c1Smrg	      cat <<EOF
4327994689c1Smrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
4328994689c1SmrgEOF
4329e1e1713cSmrg	    else
4330994689c1Smrg	      cat <<EOF
4331994689c1Smrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
4332994689c1SmrgEOF
4333e1e1713cSmrg	    fi
43347a84e134Smrg
43357a84e134Smrg
4336994689c1Smrg	    cat <<"EOF"
43377a84e134Smrg
4338994689c1Smrg#define LTWRAPPER_OPTION_PREFIX         "--lt-"
43397a84e134Smrg
4340994689c1Smrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
4341994689c1Smrgstatic const char *dumpscript_opt       = LTWRAPPER_OPTION_PREFIX "dump-script";
4342994689c1Smrgstatic const char *debug_opt            = LTWRAPPER_OPTION_PREFIX "debug";
43437a84e134Smrg
4344994689c1Smrgint
4345994689c1Smrgmain (int argc, char *argv[])
4346994689c1Smrg{
4347994689c1Smrg  char **newargz;
4348994689c1Smrg  int  newargc;
4349994689c1Smrg  char *tmp_pathspec;
4350994689c1Smrg  char *actual_cwrapper_path;
4351994689c1Smrg  char *actual_cwrapper_name;
4352994689c1Smrg  char *target_name;
4353994689c1Smrg  char *lt_argv_zero;
4354994689c1Smrg  intptr_t rval = 127;
43557a84e134Smrg
4356994689c1Smrg  int i;
43577a84e134Smrg
4358994689c1Smrg  program_name = (char *) xstrdup (base_name (argv[0]));
4359994689c1Smrg  newargz = XMALLOC (char *, argc + 1);
43607a84e134Smrg
4361994689c1Smrg  /* very simple arg parsing; don't want to rely on getopt
4362994689c1Smrg   * also, copy all non cwrapper options to newargz, except
4363994689c1Smrg   * argz[0], which is handled differently
4364994689c1Smrg   */
4365994689c1Smrg  newargc=0;
4366994689c1Smrg  for (i = 1; i < argc; i++)
4367994689c1Smrg    {
4368994689c1Smrg      if (strcmp (argv[i], dumpscript_opt) == 0)
4369994689c1Smrg	{
4370994689c1SmrgEOF
4371994689c1Smrg	    case "$host" in
4372994689c1Smrg	      *mingw* | *cygwin* )
4373994689c1Smrg		# make stdout use "unix" line endings
4374994689c1Smrg		echo "          setmode(1,_O_BINARY);"
4375994689c1Smrg		;;
4376e1e1713cSmrg	      esac
43777a84e134Smrg
4378994689c1Smrg	    cat <<"EOF"
4379994689c1Smrg	  lt_dump_script (stdout);
4380994689c1Smrg	  return 0;
4381994689c1Smrg	}
4382994689c1Smrg      if (strcmp (argv[i], debug_opt) == 0)
4383994689c1Smrg	{
4384994689c1Smrg          lt_debug = 1;
4385994689c1Smrg          continue;
4386994689c1Smrg	}
4387994689c1Smrg      if (strcmp (argv[i], ltwrapper_option_prefix) == 0)
4388994689c1Smrg        {
4389994689c1Smrg          /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
4390994689c1Smrg             namespace, but it is not one of the ones we know about and
4391994689c1Smrg             have already dealt with, above (inluding dump-script), then
4392994689c1Smrg             report an error. Otherwise, targets might begin to believe
4393994689c1Smrg             they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
4394994689c1Smrg             namespace. The first time any user complains about this, we'll
4395994689c1Smrg             need to make LTWRAPPER_OPTION_PREFIX a configure-time option
4396994689c1Smrg             or a configure.ac-settable value.
4397994689c1Smrg           */
4398994689c1Smrg          lt_fatal (__FILE__, __LINE__,
4399994689c1Smrg		    "unrecognized %s option: '%s'",
4400994689c1Smrg                    ltwrapper_option_prefix, argv[i]);
4401994689c1Smrg        }
4402994689c1Smrg      /* otherwise ... */
4403994689c1Smrg      newargz[++newargc] = xstrdup (argv[i]);
4404994689c1Smrg    }
4405994689c1Smrg  newargz[++newargc] = NULL;
44067a84e134Smrg
4407994689c1SmrgEOF
4408994689c1Smrg	    cat <<EOF
4409994689c1Smrg  /* The GNU banner must be the first non-error debug message */
4410994689c1Smrg  lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\n");
4411994689c1SmrgEOF
4412994689c1Smrg	    cat <<"EOF"
4413994689c1Smrg  lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
4414994689c1Smrg  lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name);
4415994689c1Smrg
4416994689c1Smrg  tmp_pathspec = find_executable (argv[0]);
4417994689c1Smrg  if (tmp_pathspec == NULL)
4418994689c1Smrg    lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]);
4419994689c1Smrg  lt_debugprintf (__FILE__, __LINE__,
4420994689c1Smrg                  "(main) found exe (before symlink chase) at: %s\n",
4421994689c1Smrg		  tmp_pathspec);
4422994689c1Smrg
4423994689c1Smrg  actual_cwrapper_path = chase_symlinks (tmp_pathspec);
4424994689c1Smrg  lt_debugprintf (__FILE__, __LINE__,
4425994689c1Smrg                  "(main) found exe (after symlink chase) at: %s\n",
4426994689c1Smrg		  actual_cwrapper_path);
4427994689c1Smrg  XFREE (tmp_pathspec);
4428994689c1Smrg
4429994689c1Smrg  actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));
4430994689c1Smrg  strendzap (actual_cwrapper_path, actual_cwrapper_name);
4431994689c1Smrg
4432994689c1Smrg  /* wrapper name transforms */
4433994689c1Smrg  strendzap (actual_cwrapper_name, ".exe");
4434994689c1Smrg  tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
4435994689c1Smrg  XFREE (actual_cwrapper_name);
4436994689c1Smrg  actual_cwrapper_name = tmp_pathspec;
4437994689c1Smrg  tmp_pathspec = 0;
4438994689c1Smrg
4439994689c1Smrg  /* target_name transforms -- use actual target program name; might have lt- prefix */
4440994689c1Smrg  target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
4441994689c1Smrg  strendzap (target_name, ".exe");
4442994689c1Smrg  tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
4443994689c1Smrg  XFREE (target_name);
4444994689c1Smrg  target_name = tmp_pathspec;
4445994689c1Smrg  tmp_pathspec = 0;
4446994689c1Smrg
4447994689c1Smrg  lt_debugprintf (__FILE__, __LINE__,
4448994689c1Smrg		  "(main) libtool target name: %s\n",
4449994689c1Smrg		  target_name);
4450994689c1SmrgEOF
44517a84e134Smrg
4452994689c1Smrg	    cat <<EOF
4453994689c1Smrg  newargz[0] =
4454994689c1Smrg    XMALLOC (char, (strlen (actual_cwrapper_path) +
4455994689c1Smrg		    strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
4456994689c1Smrg  strcpy (newargz[0], actual_cwrapper_path);
4457994689c1Smrg  strcat (newargz[0], "$objdir");
4458994689c1Smrg  strcat (newargz[0], "/");
4459994689c1SmrgEOF
44607a84e134Smrg
4461994689c1Smrg	    cat <<"EOF"
4462994689c1Smrg  /* stop here, and copy so we don't have to do this twice */
4463994689c1Smrg  tmp_pathspec = xstrdup (newargz[0]);
44647a84e134Smrg
4465994689c1Smrg  /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
4466994689c1Smrg  strcat (newargz[0], actual_cwrapper_name);
44677a84e134Smrg
4468994689c1Smrg  /* DO want the lt- prefix here if it exists, so use target_name */
4469994689c1Smrg  lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
4470994689c1Smrg  XFREE (tmp_pathspec);
4471994689c1Smrg  tmp_pathspec = NULL;
4472994689c1SmrgEOF
44737a84e134Smrg
4474994689c1Smrg	    case $host_os in
4475994689c1Smrg	      mingw*)
4476994689c1Smrg	    cat <<"EOF"
4477994689c1Smrg  {
4478994689c1Smrg    char* p;
4479994689c1Smrg    while ((p = strchr (newargz[0], '\\')) != NULL)
4480994689c1Smrg      {
4481994689c1Smrg	*p = '/';
4482994689c1Smrg      }
4483994689c1Smrg    while ((p = strchr (lt_argv_zero, '\\')) != NULL)
4484994689c1Smrg      {
4485994689c1Smrg	*p = '/';
4486994689c1Smrg      }
4487994689c1Smrg  }
4488994689c1SmrgEOF
4489994689c1Smrg	    ;;
4490994689c1Smrg	    esac
44917a84e134Smrg
4492994689c1Smrg	    cat <<"EOF"
4493994689c1Smrg  XFREE (target_name);
4494994689c1Smrg  XFREE (actual_cwrapper_path);
4495994689c1Smrg  XFREE (actual_cwrapper_name);
44967a84e134Smrg
4497994689c1Smrg  lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
4498994689c1Smrg  lt_setenv ("DUALCASE", "1");  /* for MSK sh */
4499f353fbadSmrg  /* Update the DLL searchpath.  EXE_PATH_VALUE ($dllsearchpath) must
4500f353fbadSmrg     be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath)
4501f353fbadSmrg     because on Windows, both *_VARNAMEs are PATH but uninstalled
4502f353fbadSmrg     libraries must come first. */
4503994689c1Smrg  lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
4504f353fbadSmrg  lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
45057a84e134Smrg
4506994689c1Smrg  lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",
4507994689c1Smrg		  nonnull (lt_argv_zero));
4508994689c1Smrg  for (i = 0; i < newargc; i++)
4509994689c1Smrg    {
4510994689c1Smrg      lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n",
4511994689c1Smrg		      i, nonnull (newargz[i]));
4512994689c1Smrg    }
45137a84e134Smrg
4514994689c1SmrgEOF
45157a84e134Smrg
4516994689c1Smrg	    case $host_os in
4517994689c1Smrg	      mingw*)
4518994689c1Smrg		cat <<"EOF"
4519994689c1Smrg  /* execv doesn't actually work on mingw as expected on unix */
4520994689c1Smrg  newargz = prepare_spawn (newargz);
4521994689c1Smrg  rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
4522994689c1Smrg  if (rval == -1)
4523994689c1Smrg    {
4524994689c1Smrg      /* failed to start process */
4525994689c1Smrg      lt_debugprintf (__FILE__, __LINE__,
4526994689c1Smrg		      "(main) failed to launch target \"%s\": %s\n",
4527994689c1Smrg		      lt_argv_zero, nonnull (strerror (errno)));
4528994689c1Smrg      return 127;
4529994689c1Smrg    }
4530994689c1Smrg  return rval;
4531994689c1SmrgEOF
4532994689c1Smrg		;;
4533994689c1Smrg	      *)
4534994689c1Smrg		cat <<"EOF"
4535994689c1Smrg  execv (lt_argv_zero, newargz);
4536994689c1Smrg  return rval; /* =127, but avoids unused variable warning */
4537994689c1SmrgEOF
4538994689c1Smrg		;;
4539994689c1Smrg	    esac
45407a84e134Smrg
4541994689c1Smrg	    cat <<"EOF"
4542994689c1Smrg}
45437a84e134Smrg
4544994689c1Smrgvoid *
4545994689c1Smrgxmalloc (size_t num)
4546994689c1Smrg{
4547994689c1Smrg  void *p = (void *) malloc (num);
4548994689c1Smrg  if (!p)
4549994689c1Smrg    lt_fatal (__FILE__, __LINE__, "memory exhausted");
45507a84e134Smrg
4551994689c1Smrg  return p;
4552994689c1Smrg}
45537a84e134Smrg
4554994689c1Smrgchar *
4555994689c1Smrgxstrdup (const char *string)
4556994689c1Smrg{
4557994689c1Smrg  return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
4558994689c1Smrg			  string) : NULL;
4559994689c1Smrg}
45607a84e134Smrg
4561994689c1Smrgconst char *
4562994689c1Smrgbase_name (const char *name)
4563994689c1Smrg{
4564994689c1Smrg  const char *base;
45657a84e134Smrg
4566994689c1Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4567994689c1Smrg  /* Skip over the disk name in MSDOS pathnames. */
4568994689c1Smrg  if (isalpha ((unsigned char) name[0]) && name[1] == ':')
4569994689c1Smrg    name += 2;
4570994689c1Smrg#endif
45717a84e134Smrg
4572994689c1Smrg  for (base = name; *name; name++)
4573994689c1Smrg    if (IS_DIR_SEPARATOR (*name))
4574994689c1Smrg      base = name + 1;
4575994689c1Smrg  return base;
4576994689c1Smrg}
45777a84e134Smrg
4578994689c1Smrgint
4579994689c1Smrgcheck_executable (const char *path)
4580994689c1Smrg{
4581994689c1Smrg  struct stat st;
45827a84e134Smrg
4583994689c1Smrg  lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n",
4584994689c1Smrg                  nonempty (path));
4585994689c1Smrg  if ((!path) || (!*path))
4586994689c1Smrg    return 0;
45877a84e134Smrg
4588994689c1Smrg  if ((stat (path, &st) >= 0)
4589994689c1Smrg      && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
4590994689c1Smrg    return 1;
4591994689c1Smrg  else
4592994689c1Smrg    return 0;
4593994689c1Smrg}
45947a84e134Smrg
4595994689c1Smrgint
4596994689c1Smrgmake_executable (const char *path)
4597994689c1Smrg{
4598994689c1Smrg  int rval = 0;
4599994689c1Smrg  struct stat st;
4600e1e1713cSmrg
4601994689c1Smrg  lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n",
4602994689c1Smrg                  nonempty (path));
4603994689c1Smrg  if ((!path) || (!*path))
4604994689c1Smrg    return 0;
4605e1e1713cSmrg
4606994689c1Smrg  if (stat (path, &st) >= 0)
4607994689c1Smrg    {
4608994689c1Smrg      rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
4609994689c1Smrg    }
4610994689c1Smrg  return rval;
4611994689c1Smrg}
4612e1e1713cSmrg
4613994689c1Smrg/* Searches for the full path of the wrapper.  Returns
4614994689c1Smrg   newly allocated full path name if found, NULL otherwise
4615994689c1Smrg   Does not chase symlinks, even on platforms that support them.
4616994689c1Smrg*/
4617994689c1Smrgchar *
4618994689c1Smrgfind_executable (const char *wrapper)
4619994689c1Smrg{
4620994689c1Smrg  int has_slash = 0;
4621994689c1Smrg  const char *p;
4622994689c1Smrg  const char *p_next;
4623994689c1Smrg  /* static buffer for getcwd */
4624994689c1Smrg  char tmp[LT_PATHMAX + 1];
4625994689c1Smrg  int tmp_len;
4626994689c1Smrg  char *concat_name;
4627e1e1713cSmrg
4628994689c1Smrg  lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
4629994689c1Smrg                  nonempty (wrapper));
4630e1e1713cSmrg
4631994689c1Smrg  if ((wrapper == NULL) || (*wrapper == '\0'))
4632994689c1Smrg    return NULL;
46337a84e134Smrg
4634994689c1Smrg  /* Absolute path? */
4635994689c1Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4636994689c1Smrg  if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
4637994689c1Smrg    {
4638994689c1Smrg      concat_name = xstrdup (wrapper);
4639994689c1Smrg      if (check_executable (concat_name))
4640994689c1Smrg	return concat_name;
4641994689c1Smrg      XFREE (concat_name);
4642994689c1Smrg    }
4643994689c1Smrg  else
4644994689c1Smrg    {
4645994689c1Smrg#endif
4646994689c1Smrg      if (IS_DIR_SEPARATOR (wrapper[0]))
4647994689c1Smrg	{
4648994689c1Smrg	  concat_name = xstrdup (wrapper);
4649994689c1Smrg	  if (check_executable (concat_name))
4650994689c1Smrg	    return concat_name;
4651994689c1Smrg	  XFREE (concat_name);
4652994689c1Smrg	}
4653994689c1Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4654994689c1Smrg    }
4655994689c1Smrg#endif
46567a84e134Smrg
4657994689c1Smrg  for (p = wrapper; *p; p++)
4658994689c1Smrg    if (*p == '/')
4659994689c1Smrg      {
4660994689c1Smrg	has_slash = 1;
4661994689c1Smrg	break;
4662994689c1Smrg      }
4663994689c1Smrg  if (!has_slash)
4664994689c1Smrg    {
4665994689c1Smrg      /* no slashes; search PATH */
4666994689c1Smrg      const char *path = getenv ("PATH");
4667994689c1Smrg      if (path != NULL)
4668994689c1Smrg	{
4669994689c1Smrg	  for (p = path; *p; p = p_next)
4670994689c1Smrg	    {
4671994689c1Smrg	      const char *q;
4672994689c1Smrg	      size_t p_len;
4673994689c1Smrg	      for (q = p; *q; q++)
4674994689c1Smrg		if (IS_PATH_SEPARATOR (*q))
4675994689c1Smrg		  break;
4676994689c1Smrg	      p_len = q - p;
4677994689c1Smrg	      p_next = (*q == '\0' ? q : q + 1);
4678994689c1Smrg	      if (p_len == 0)
4679994689c1Smrg		{
4680994689c1Smrg		  /* empty path: current directory */
4681994689c1Smrg		  if (getcwd (tmp, LT_PATHMAX) == NULL)
4682994689c1Smrg		    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
4683994689c1Smrg                              nonnull (strerror (errno)));
4684994689c1Smrg		  tmp_len = strlen (tmp);
4685994689c1Smrg		  concat_name =
4686994689c1Smrg		    XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
4687994689c1Smrg		  memcpy (concat_name, tmp, tmp_len);
4688994689c1Smrg		  concat_name[tmp_len] = '/';
4689994689c1Smrg		  strcpy (concat_name + tmp_len + 1, wrapper);
4690994689c1Smrg		}
4691994689c1Smrg	      else
4692994689c1Smrg		{
4693994689c1Smrg		  concat_name =
4694994689c1Smrg		    XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
4695994689c1Smrg		  memcpy (concat_name, p, p_len);
4696994689c1Smrg		  concat_name[p_len] = '/';
4697994689c1Smrg		  strcpy (concat_name + p_len + 1, wrapper);
4698994689c1Smrg		}
4699994689c1Smrg	      if (check_executable (concat_name))
4700994689c1Smrg		return concat_name;
4701994689c1Smrg	      XFREE (concat_name);
4702994689c1Smrg	    }
4703994689c1Smrg	}
4704994689c1Smrg      /* not found in PATH; assume curdir */
4705994689c1Smrg    }
4706994689c1Smrg  /* Relative path | not found in path: prepend cwd */
4707994689c1Smrg  if (getcwd (tmp, LT_PATHMAX) == NULL)
4708994689c1Smrg    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
4709994689c1Smrg              nonnull (strerror (errno)));
4710994689c1Smrg  tmp_len = strlen (tmp);
4711994689c1Smrg  concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
4712994689c1Smrg  memcpy (concat_name, tmp, tmp_len);
4713994689c1Smrg  concat_name[tmp_len] = '/';
4714994689c1Smrg  strcpy (concat_name + tmp_len + 1, wrapper);
47157a84e134Smrg
4716994689c1Smrg  if (check_executable (concat_name))
4717994689c1Smrg    return concat_name;
4718994689c1Smrg  XFREE (concat_name);
4719994689c1Smrg  return NULL;
4720994689c1Smrg}
4721e1e1713cSmrg
4722994689c1Smrgchar *
4723994689c1Smrgchase_symlinks (const char *pathspec)
4724994689c1Smrg{
4725994689c1Smrg#ifndef S_ISLNK
4726994689c1Smrg  return xstrdup (pathspec);
4727994689c1Smrg#else
4728994689c1Smrg  char buf[LT_PATHMAX];
4729994689c1Smrg  struct stat s;
4730994689c1Smrg  char *tmp_pathspec = xstrdup (pathspec);
4731994689c1Smrg  char *p;
4732994689c1Smrg  int has_symlinks = 0;
4733994689c1Smrg  while (strlen (tmp_pathspec) && !has_symlinks)
4734994689c1Smrg    {
4735994689c1Smrg      lt_debugprintf (__FILE__, __LINE__,
4736994689c1Smrg		      "checking path component for symlinks: %s\n",
4737994689c1Smrg		      tmp_pathspec);
4738994689c1Smrg      if (lstat (tmp_pathspec, &s) == 0)
4739994689c1Smrg	{
4740994689c1Smrg	  if (S_ISLNK (s.st_mode) != 0)
4741994689c1Smrg	    {
4742994689c1Smrg	      has_symlinks = 1;
4743994689c1Smrg	      break;
4744994689c1Smrg	    }
4745e1e1713cSmrg
4746994689c1Smrg	  /* search backwards for last DIR_SEPARATOR */
4747994689c1Smrg	  p = tmp_pathspec + strlen (tmp_pathspec) - 1;
4748994689c1Smrg	  while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
4749994689c1Smrg	    p--;
4750994689c1Smrg	  if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
4751994689c1Smrg	    {
4752994689c1Smrg	      /* no more DIR_SEPARATORS left */
4753994689c1Smrg	      break;
4754994689c1Smrg	    }
4755994689c1Smrg	  *p = '\0';
4756994689c1Smrg	}
4757994689c1Smrg      else
4758994689c1Smrg	{
4759994689c1Smrg	  lt_fatal (__FILE__, __LINE__,
4760994689c1Smrg		    "error accessing file \"%s\": %s",
4761994689c1Smrg		    tmp_pathspec, nonnull (strerror (errno)));
4762994689c1Smrg	}
4763994689c1Smrg    }
4764994689c1Smrg  XFREE (tmp_pathspec);
4765e1e1713cSmrg
4766994689c1Smrg  if (!has_symlinks)
4767994689c1Smrg    {
4768994689c1Smrg      return xstrdup (pathspec);
4769994689c1Smrg    }
4770e1e1713cSmrg
4771994689c1Smrg  tmp_pathspec = realpath (pathspec, buf);
4772994689c1Smrg  if (tmp_pathspec == 0)
4773994689c1Smrg    {
4774994689c1Smrg      lt_fatal (__FILE__, __LINE__,
4775994689c1Smrg		"could not follow symlinks for %s", pathspec);
4776994689c1Smrg    }
4777994689c1Smrg  return xstrdup (tmp_pathspec);
4778994689c1Smrg#endif
4779994689c1Smrg}
47807a84e134Smrg
4781994689c1Smrgchar *
4782994689c1Smrgstrendzap (char *str, const char *pat)
4783994689c1Smrg{
4784994689c1Smrg  size_t len, patlen;
47857a84e134Smrg
4786994689c1Smrg  assert (str != NULL);
4787994689c1Smrg  assert (pat != NULL);
47887a84e134Smrg
4789994689c1Smrg  len = strlen (str);
4790994689c1Smrg  patlen = strlen (pat);
47917a84e134Smrg
4792994689c1Smrg  if (patlen <= len)
4793994689c1Smrg    {
4794994689c1Smrg      str += len - patlen;
4795994689c1Smrg      if (strcmp (str, pat) == 0)
4796994689c1Smrg	*str = '\0';
4797994689c1Smrg    }
4798994689c1Smrg  return str;
4799994689c1Smrg}
48007a84e134Smrg
4801994689c1Smrgvoid
4802994689c1Smrglt_debugprintf (const char *file, int line, const char *fmt, ...)
4803994689c1Smrg{
4804994689c1Smrg  va_list args;
4805994689c1Smrg  if (lt_debug)
4806994689c1Smrg    {
4807994689c1Smrg      (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line);
4808994689c1Smrg      va_start (args, fmt);
4809994689c1Smrg      (void) vfprintf (stderr, fmt, args);
4810994689c1Smrg      va_end (args);
4811994689c1Smrg    }
4812994689c1Smrg}
48137a84e134Smrg
4814994689c1Smrgstatic void
4815994689c1Smrglt_error_core (int exit_status, const char *file,
4816994689c1Smrg	       int line, const char *mode,
4817994689c1Smrg	       const char *message, va_list ap)
4818994689c1Smrg{
4819994689c1Smrg  fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode);
4820994689c1Smrg  vfprintf (stderr, message, ap);
4821994689c1Smrg  fprintf (stderr, ".\n");
48227a84e134Smrg
4823994689c1Smrg  if (exit_status >= 0)
4824994689c1Smrg    exit (exit_status);
4825994689c1Smrg}
48267a84e134Smrg
4827994689c1Smrgvoid
4828994689c1Smrglt_fatal (const char *file, int line, const char *message, ...)
4829994689c1Smrg{
4830994689c1Smrg  va_list ap;
4831994689c1Smrg  va_start (ap, message);
4832994689c1Smrg  lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap);
4833994689c1Smrg  va_end (ap);
4834994689c1Smrg}
48357a84e134Smrg
4836994689c1Smrgstatic const char *
4837994689c1Smrgnonnull (const char *s)
4838994689c1Smrg{
4839994689c1Smrg  return s ? s : "(null)";
4840994689c1Smrg}
48417a84e134Smrg
4842994689c1Smrgstatic const char *
4843994689c1Smrgnonempty (const char *s)
4844994689c1Smrg{
4845994689c1Smrg  return (s && !*s) ? "(empty)" : nonnull (s);
4846994689c1Smrg}
4847775e7de9Smrg
4848994689c1Smrgvoid
4849994689c1Smrglt_setenv (const char *name, const char *value)
4850994689c1Smrg{
4851994689c1Smrg  lt_debugprintf (__FILE__, __LINE__,
4852994689c1Smrg		  "(lt_setenv) setting '%s' to '%s'\n",
4853994689c1Smrg                  nonnull (name), nonnull (value));
4854994689c1Smrg  {
4855994689c1Smrg#ifdef HAVE_SETENV
4856994689c1Smrg    /* always make a copy, for consistency with !HAVE_SETENV */
4857994689c1Smrg    char *str = xstrdup (value);
4858994689c1Smrg    setenv (name, str, 1);
4859994689c1Smrg#else
4860994689c1Smrg    int len = strlen (name) + 1 + strlen (value) + 1;
4861994689c1Smrg    char *str = XMALLOC (char, len);
4862994689c1Smrg    sprintf (str, "%s=%s", name, value);
4863994689c1Smrg    if (putenv (str) != EXIT_SUCCESS)
4864994689c1Smrg      {
4865994689c1Smrg        XFREE (str);
4866994689c1Smrg      }
4867994689c1Smrg#endif
4868994689c1Smrg  }
4869994689c1Smrg}
48707a84e134Smrg
4871994689c1Smrgchar *
4872994689c1Smrglt_extend_str (const char *orig_value, const char *add, int to_end)
4873994689c1Smrg{
4874994689c1Smrg  char *new_value;
4875994689c1Smrg  if (orig_value && *orig_value)
4876994689c1Smrg    {
4877994689c1Smrg      int orig_value_len = strlen (orig_value);
4878994689c1Smrg      int add_len = strlen (add);
4879994689c1Smrg      new_value = XMALLOC (char, add_len + orig_value_len + 1);
4880994689c1Smrg      if (to_end)
4881994689c1Smrg        {
4882994689c1Smrg          strcpy (new_value, orig_value);
4883994689c1Smrg          strcpy (new_value + orig_value_len, add);
4884994689c1Smrg        }
4885994689c1Smrg      else
4886994689c1Smrg        {
4887994689c1Smrg          strcpy (new_value, add);
4888994689c1Smrg          strcpy (new_value + add_len, orig_value);
4889994689c1Smrg        }
4890994689c1Smrg    }
4891994689c1Smrg  else
4892994689c1Smrg    {
4893994689c1Smrg      new_value = xstrdup (add);
4894994689c1Smrg    }
4895994689c1Smrg  return new_value;
4896994689c1Smrg}
48977a84e134Smrg
4898994689c1Smrgvoid
4899994689c1Smrglt_update_exe_path (const char *name, const char *value)
4900994689c1Smrg{
4901994689c1Smrg  lt_debugprintf (__FILE__, __LINE__,
4902994689c1Smrg		  "(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
4903994689c1Smrg                  nonnull (name), nonnull (value));
49047a84e134Smrg
4905994689c1Smrg  if (name && *name && value && *value)
4906994689c1Smrg    {
4907994689c1Smrg      char *new_value = lt_extend_str (getenv (name), value, 0);
4908994689c1Smrg      /* some systems can't cope with a ':'-terminated path #' */
4909994689c1Smrg      int len = strlen (new_value);
4910994689c1Smrg      while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
4911994689c1Smrg        {
4912994689c1Smrg          new_value[len-1] = '\0';
4913994689c1Smrg        }
4914994689c1Smrg      lt_setenv (name, new_value);
4915994689c1Smrg      XFREE (new_value);
4916994689c1Smrg    }
4917994689c1Smrg}
49187a84e134Smrg
4919994689c1Smrgvoid
4920994689c1Smrglt_update_lib_path (const char *name, const char *value)
4921994689c1Smrg{
4922994689c1Smrg  lt_debugprintf (__FILE__, __LINE__,
4923994689c1Smrg		  "(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
4924994689c1Smrg                  nonnull (name), nonnull (value));
49257a84e134Smrg
4926994689c1Smrg  if (name && *name && value && *value)
4927994689c1Smrg    {
4928994689c1Smrg      char *new_value = lt_extend_str (getenv (name), value, 0);
4929994689c1Smrg      lt_setenv (name, new_value);
4930994689c1Smrg      XFREE (new_value);
4931994689c1Smrg    }
4932994689c1Smrg}
49337a84e134Smrg
4934994689c1SmrgEOF
4935994689c1Smrg	    case $host_os in
4936994689c1Smrg	      mingw*)
4937994689c1Smrg		cat <<"EOF"
4938994689c1Smrg
4939994689c1Smrg/* Prepares an argument vector before calling spawn().
4940994689c1Smrg   Note that spawn() does not by itself call the command interpreter
4941994689c1Smrg     (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
4942994689c1Smrg      ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
4943994689c1Smrg         GetVersionEx(&v);
4944994689c1Smrg         v.dwPlatformId == VER_PLATFORM_WIN32_NT;
4945994689c1Smrg      }) ? "cmd.exe" : "command.com").
4946994689c1Smrg   Instead it simply concatenates the arguments, separated by ' ', and calls
4947994689c1Smrg   CreateProcess().  We must quote the arguments since Win32 CreateProcess()
4948994689c1Smrg   interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
4949994689c1Smrg   special way:
4950994689c1Smrg   - Space and tab are interpreted as delimiters. They are not treated as
4951994689c1Smrg     delimiters if they are surrounded by double quotes: "...".
4952994689c1Smrg   - Unescaped double quotes are removed from the input. Their only effect is
4953994689c1Smrg     that within double quotes, space and tab are treated like normal
4954994689c1Smrg     characters.
4955994689c1Smrg   - Backslashes not followed by double quotes are not special.
4956994689c1Smrg   - But 2*n+1 backslashes followed by a double quote become
4957994689c1Smrg     n backslashes followed by a double quote (n >= 0):
4958994689c1Smrg       \" -> "
4959994689c1Smrg       \\\" -> \"
4960994689c1Smrg       \\\\\" -> \\"
4961994689c1Smrg */
4962994689c1Smrg#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"
4963994689c1Smrg#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"
4964994689c1Smrgchar **
4965994689c1Smrgprepare_spawn (char **argv)
4966994689c1Smrg{
4967994689c1Smrg  size_t argc;
4968994689c1Smrg  char **new_argv;
4969994689c1Smrg  size_t i;
49707a84e134Smrg
4971994689c1Smrg  /* Count number of arguments.  */
4972994689c1Smrg  for (argc = 0; argv[argc] != NULL; argc++)
4973994689c1Smrg    ;
49747a84e134Smrg
4975994689c1Smrg  /* Allocate new argument vector.  */
4976994689c1Smrg  new_argv = XMALLOC (char *, argc + 1);
49777a84e134Smrg
4978994689c1Smrg  /* Put quoted arguments into the new argument vector.  */
4979994689c1Smrg  for (i = 0; i < argc; i++)
4980994689c1Smrg    {
4981994689c1Smrg      const char *string = argv[i];
4982994689c1Smrg
4983994689c1Smrg      if (string[0] == '\0')
4984994689c1Smrg	new_argv[i] = xstrdup ("\"\"");
4985994689c1Smrg      else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
4986994689c1Smrg	{
4987994689c1Smrg	  int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
4988994689c1Smrg	  size_t length;
4989994689c1Smrg	  unsigned int backslashes;
4990994689c1Smrg	  const char *s;
4991994689c1Smrg	  char *quoted_string;
4992994689c1Smrg	  char *p;
4993994689c1Smrg
4994994689c1Smrg	  length = 0;
4995994689c1Smrg	  backslashes = 0;
4996994689c1Smrg	  if (quote_around)
4997994689c1Smrg	    length++;
4998994689c1Smrg	  for (s = string; *s != '\0'; s++)
4999994689c1Smrg	    {
5000994689c1Smrg	      char c = *s;
5001994689c1Smrg	      if (c == '"')
5002994689c1Smrg		length += backslashes + 1;
5003994689c1Smrg	      length++;
5004994689c1Smrg	      if (c == '\\')
5005994689c1Smrg		backslashes++;
5006994689c1Smrg	      else
5007994689c1Smrg		backslashes = 0;
5008994689c1Smrg	    }
5009994689c1Smrg	  if (quote_around)
5010994689c1Smrg	    length += backslashes + 1;
5011994689c1Smrg
5012994689c1Smrg	  quoted_string = XMALLOC (char, length + 1);
5013994689c1Smrg
5014994689c1Smrg	  p = quoted_string;
5015994689c1Smrg	  backslashes = 0;
5016994689c1Smrg	  if (quote_around)
5017994689c1Smrg	    *p++ = '"';
5018994689c1Smrg	  for (s = string; *s != '\0'; s++)
5019994689c1Smrg	    {
5020994689c1Smrg	      char c = *s;
5021994689c1Smrg	      if (c == '"')
5022994689c1Smrg		{
5023994689c1Smrg		  unsigned int j;
5024994689c1Smrg		  for (j = backslashes + 1; j > 0; j--)
5025994689c1Smrg		    *p++ = '\\';
5026994689c1Smrg		}
5027994689c1Smrg	      *p++ = c;
5028994689c1Smrg	      if (c == '\\')
5029994689c1Smrg		backslashes++;
5030994689c1Smrg	      else
5031994689c1Smrg		backslashes = 0;
5032994689c1Smrg	    }
5033994689c1Smrg	  if (quote_around)
5034994689c1Smrg	    {
5035994689c1Smrg	      unsigned int j;
5036994689c1Smrg	      for (j = backslashes; j > 0; j--)
5037994689c1Smrg		*p++ = '\\';
5038994689c1Smrg	      *p++ = '"';
5039994689c1Smrg	    }
5040994689c1Smrg	  *p = '\0';
50417a84e134Smrg
5042994689c1Smrg	  new_argv[i] = quoted_string;
5043994689c1Smrg	}
5044994689c1Smrg      else
5045994689c1Smrg	new_argv[i] = (char *) string;
5046994689c1Smrg    }
5047994689c1Smrg  new_argv[argc] = NULL;
50487a84e134Smrg
5049994689c1Smrg  return new_argv;
5050994689c1Smrg}
5051994689c1SmrgEOF
5052e1e1713cSmrg		;;
5053994689c1Smrg	    esac
50547a84e134Smrg
5055994689c1Smrg            cat <<"EOF"
5056994689c1Smrgvoid lt_dump_script (FILE* f)
5057994689c1Smrg{
5058994689c1SmrgEOF
5059994689c1Smrg	    func_emit_wrapper yes |
5060994689c1Smrg              $SED -e 's/\([\\"]\)/\\\1/g' \
5061994689c1Smrg	           -e 's/^/  fputs ("/' -e 's/$/\\n", f);/'
50627a84e134Smrg
5063994689c1Smrg            cat <<"EOF"
5064994689c1Smrg}
5065994689c1SmrgEOF
5066994689c1Smrg}
5067994689c1Smrg# end: func_emit_cwrapperexe_src
50687a84e134Smrg
5069994689c1Smrg# func_win32_import_lib_p ARG
5070994689c1Smrg# True if ARG is an import lib, as indicated by $file_magic_cmd
5071994689c1Smrgfunc_win32_import_lib_p ()
5072994689c1Smrg{
5073994689c1Smrg    $opt_debug
5074994689c1Smrg    case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
5075994689c1Smrg    *import*) : ;;
5076994689c1Smrg    *) false ;;
5077994689c1Smrg    esac
5078994689c1Smrg}
50797a84e134Smrg
5080994689c1Smrg# func_mode_link arg...
5081994689c1Smrgfunc_mode_link ()
5082994689c1Smrg{
5083994689c1Smrg    $opt_debug
5084994689c1Smrg    case $host in
5085994689c1Smrg    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
5086994689c1Smrg      # It is impossible to link a dll without this setting, and
5087994689c1Smrg      # we shouldn't force the makefile maintainer to figure out
5088994689c1Smrg      # which system we are compiling for in order to pass an extra
5089994689c1Smrg      # flag for every libtool invocation.
5090994689c1Smrg      # allow_undefined=no
50917a84e134Smrg
5092994689c1Smrg      # FIXME: Unfortunately, there are problems with the above when trying
5093994689c1Smrg      # to make a dll which has undefined symbols, in which case not
5094994689c1Smrg      # even a static library is built.  For now, we need to specify
5095994689c1Smrg      # -no-undefined on the libtool link line when we can be certain
5096994689c1Smrg      # that all symbols are satisfied, otherwise we get a static library.
5097994689c1Smrg      allow_undefined=yes
5098994689c1Smrg      ;;
5099994689c1Smrg    *)
5100994689c1Smrg      allow_undefined=yes
5101994689c1Smrg      ;;
5102994689c1Smrg    esac
5103994689c1Smrg    libtool_args=$nonopt
5104994689c1Smrg    base_compile="$nonopt $@"
5105994689c1Smrg    compile_command=$nonopt
5106994689c1Smrg    finalize_command=$nonopt
51077a84e134Smrg
5108994689c1Smrg    compile_rpath=
5109994689c1Smrg    finalize_rpath=
5110994689c1Smrg    compile_shlibpath=
5111994689c1Smrg    finalize_shlibpath=
5112994689c1Smrg    convenience=
5113994689c1Smrg    old_convenience=
5114994689c1Smrg    deplibs=
5115994689c1Smrg    old_deplibs=
5116994689c1Smrg    compiler_flags=
5117994689c1Smrg    linker_flags=
5118994689c1Smrg    dllsearchpath=
5119994689c1Smrg    lib_search_path=`pwd`
5120994689c1Smrg    inst_prefix_dir=
5121994689c1Smrg    new_inherited_linker_flags=
51227a84e134Smrg
5123994689c1Smrg    avoid_version=no
5124994689c1Smrg    bindir=
5125994689c1Smrg    dlfiles=
5126994689c1Smrg    dlprefiles=
5127994689c1Smrg    dlself=no
5128994689c1Smrg    export_dynamic=no
5129994689c1Smrg    export_symbols=
5130994689c1Smrg    export_symbols_regex=
5131994689c1Smrg    generated=
5132994689c1Smrg    libobjs=
5133994689c1Smrg    ltlibs=
5134994689c1Smrg    module=no
5135994689c1Smrg    no_install=no
5136994689c1Smrg    objs=
5137994689c1Smrg    non_pic_objects=
5138994689c1Smrg    precious_files_regex=
5139994689c1Smrg    prefer_static_libs=no
5140994689c1Smrg    preload=no
5141994689c1Smrg    prev=
5142994689c1Smrg    prevarg=
5143994689c1Smrg    release=
5144994689c1Smrg    rpath=
5145994689c1Smrg    xrpath=
5146994689c1Smrg    perm_rpath=
5147994689c1Smrg    temp_rpath=
5148994689c1Smrg    thread_safe=no
5149994689c1Smrg    vinfo=
5150994689c1Smrg    vinfo_number=no
5151994689c1Smrg    weak_libs=
5152994689c1Smrg    single_module="${wl}-single_module"
5153994689c1Smrg    func_infer_tag $base_compile
51547a84e134Smrg
5155994689c1Smrg    # We need to know -static, to get the right output filenames.
5156994689c1Smrg    for arg
5157994689c1Smrg    do
5158994689c1Smrg      case $arg in
5159994689c1Smrg      -shared)
5160994689c1Smrg	test "$build_libtool_libs" != yes && \
5161994689c1Smrg	  func_fatal_configuration "can not build a shared library"
5162994689c1Smrg	build_old_libs=no
5163994689c1Smrg	break
5164994689c1Smrg	;;
5165994689c1Smrg      -all-static | -static | -static-libtool-libs)
5166994689c1Smrg	case $arg in
5167994689c1Smrg	-all-static)
5168994689c1Smrg	  if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
5169994689c1Smrg	    func_warning "complete static linking is impossible in this configuration"
5170994689c1Smrg	  fi
5171994689c1Smrg	  if test -n "$link_static_flag"; then
5172994689c1Smrg	    dlopen_self=$dlopen_self_static
5173994689c1Smrg	  fi
5174994689c1Smrg	  prefer_static_libs=yes
5175994689c1Smrg	  ;;
5176994689c1Smrg	-static)
5177994689c1Smrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
5178994689c1Smrg	    dlopen_self=$dlopen_self_static
5179994689c1Smrg	  fi
5180994689c1Smrg	  prefer_static_libs=built
5181994689c1Smrg	  ;;
5182994689c1Smrg	-static-libtool-libs)
5183994689c1Smrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
5184994689c1Smrg	    dlopen_self=$dlopen_self_static
5185994689c1Smrg	  fi
5186994689c1Smrg	  prefer_static_libs=yes
5187994689c1Smrg	  ;;
5188994689c1Smrg	esac
5189994689c1Smrg	build_libtool_libs=no
5190994689c1Smrg	build_old_libs=yes
5191994689c1Smrg	break
5192994689c1Smrg	;;
5193994689c1Smrg      esac
5194994689c1Smrg    done
51957a84e134Smrg
5196994689c1Smrg    # See if our shared archives depend on static archives.
5197994689c1Smrg    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
51987a84e134Smrg
5199994689c1Smrg    # Go through the arguments, transforming them on the way.
5200994689c1Smrg    while test "$#" -gt 0; do
5201994689c1Smrg      arg="$1"
5202994689c1Smrg      shift
5203994689c1Smrg      func_quote_for_eval "$arg"
5204994689c1Smrg      qarg=$func_quote_for_eval_unquoted_result
5205994689c1Smrg      func_append libtool_args " $func_quote_for_eval_result"
52067a84e134Smrg
5207994689c1Smrg      # If the previous option needs an argument, assign it.
5208994689c1Smrg      if test -n "$prev"; then
5209994689c1Smrg	case $prev in
5210994689c1Smrg	output)
5211994689c1Smrg	  func_append compile_command " @OUTPUT@"
5212994689c1Smrg	  func_append finalize_command " @OUTPUT@"
5213994689c1Smrg	  ;;
5214994689c1Smrg	esac
52157a84e134Smrg
5216994689c1Smrg	case $prev in
5217994689c1Smrg	bindir)
5218994689c1Smrg	  bindir="$arg"
5219994689c1Smrg	  prev=
5220994689c1Smrg	  continue
5221994689c1Smrg	  ;;
5222994689c1Smrg	dlfiles|dlprefiles)
5223994689c1Smrg	  if test "$preload" = no; then
5224994689c1Smrg	    # Add the symbol object into the linking commands.
5225994689c1Smrg	    func_append compile_command " @SYMFILE@"
5226994689c1Smrg	    func_append finalize_command " @SYMFILE@"
5227994689c1Smrg	    preload=yes
5228e1e1713cSmrg	  fi
5229994689c1Smrg	  case $arg in
5230994689c1Smrg	  *.la | *.lo) ;;  # We handle these cases below.
5231994689c1Smrg	  force)
5232994689c1Smrg	    if test "$dlself" = no; then
5233994689c1Smrg	      dlself=needless
5234994689c1Smrg	      export_dynamic=yes
5235e1e1713cSmrg	    fi
5236994689c1Smrg	    prev=
5237994689c1Smrg	    continue
5238994689c1Smrg	    ;;
5239994689c1Smrg	  self)
5240994689c1Smrg	    if test "$prev" = dlprefiles; then
5241994689c1Smrg	      dlself=yes
5242994689c1Smrg	    elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
5243994689c1Smrg	      dlself=yes
5244e1e1713cSmrg	    else
5245994689c1Smrg	      dlself=needless
5246994689c1Smrg	      export_dynamic=yes
5247e1e1713cSmrg	    fi
5248994689c1Smrg	    prev=
5249994689c1Smrg	    continue
5250994689c1Smrg	    ;;
5251994689c1Smrg	  *)
5252994689c1Smrg	    if test "$prev" = dlfiles; then
5253f353fbadSmrg	      func_append dlfiles " $arg"
5254e1e1713cSmrg	    else
5255f353fbadSmrg	      func_append dlprefiles " $arg"
5256e1e1713cSmrg	    fi
5257994689c1Smrg	    prev=
5258994689c1Smrg	    continue
5259994689c1Smrg	    ;;
5260994689c1Smrg	  esac
5261994689c1Smrg	  ;;
5262994689c1Smrg	expsyms)
5263994689c1Smrg	  export_symbols="$arg"
5264994689c1Smrg	  test -f "$arg" \
5265994689c1Smrg	    || func_fatal_error "symbol file \`$arg' does not exist"
5266994689c1Smrg	  prev=
5267994689c1Smrg	  continue
5268994689c1Smrg	  ;;
5269994689c1Smrg	expsyms_regex)
5270994689c1Smrg	  export_symbols_regex="$arg"
5271994689c1Smrg	  prev=
5272994689c1Smrg	  continue
5273994689c1Smrg	  ;;
5274994689c1Smrg	framework)
5275e1e1713cSmrg	  case $host in
5276994689c1Smrg	    *-*-darwin*)
5277994689c1Smrg	      case "$deplibs " in
5278994689c1Smrg		*" $qarg.ltframework "*) ;;
5279f353fbadSmrg		*) func_append deplibs " $qarg.ltframework" # this is fixed later
5280994689c1Smrg		   ;;
5281994689c1Smrg	      esac
5282994689c1Smrg	      ;;
5283e1e1713cSmrg	  esac
5284994689c1Smrg	  prev=
5285994689c1Smrg	  continue
5286e1e1713cSmrg	  ;;
5287994689c1Smrg	inst_prefix)
5288994689c1Smrg	  inst_prefix_dir="$arg"
5289994689c1Smrg	  prev=
5290994689c1Smrg	  continue
5291e1e1713cSmrg	  ;;
5292994689c1Smrg	objectlist)
5293994689c1Smrg	  if test -f "$arg"; then
5294994689c1Smrg	    save_arg=$arg
5295994689c1Smrg	    moreargs=
5296994689c1Smrg	    for fil in `cat "$save_arg"`
5297994689c1Smrg	    do
5298f353fbadSmrg#	      func_append moreargs " $fil"
5299994689c1Smrg	      arg=$fil
5300994689c1Smrg	      # A libtool-controlled object.
53017a84e134Smrg
5302994689c1Smrg	      # Check to see that this really is a libtool object.
5303994689c1Smrg	      if func_lalib_unsafe_p "$arg"; then
5304994689c1Smrg		pic_object=
5305994689c1Smrg		non_pic_object=
5306775e7de9Smrg
5307994689c1Smrg		# Read the .lo file
5308994689c1Smrg		func_source "$arg"
5309775e7de9Smrg
5310994689c1Smrg		if test -z "$pic_object" ||
5311994689c1Smrg		   test -z "$non_pic_object" ||
5312994689c1Smrg		   test "$pic_object" = none &&
5313994689c1Smrg		   test "$non_pic_object" = none; then
5314994689c1Smrg		  func_fatal_error "cannot find name of object for \`$arg'"
5315994689c1Smrg		fi
5316775e7de9Smrg
5317994689c1Smrg		# Extract subdirectory from the argument.
5318994689c1Smrg		func_dirname "$arg" "/" ""
5319994689c1Smrg		xdir="$func_dirname_result"
5320775e7de9Smrg
5321994689c1Smrg		if test "$pic_object" != none; then
5322994689c1Smrg		  # Prepend the subdirectory the object is found in.
5323994689c1Smrg		  pic_object="$xdir$pic_object"
5324775e7de9Smrg
5325994689c1Smrg		  if test "$prev" = dlfiles; then
5326994689c1Smrg		    if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
5327f353fbadSmrg		      func_append dlfiles " $pic_object"
5328994689c1Smrg		      prev=
5329994689c1Smrg		      continue
5330994689c1Smrg		    else
5331994689c1Smrg		      # If libtool objects are unsupported, then we need to preload.
5332994689c1Smrg		      prev=dlprefiles
5333994689c1Smrg		    fi
5334994689c1Smrg		  fi
5335775e7de9Smrg
5336994689c1Smrg		  # CHECK ME:  I think I busted this.  -Ossama
5337994689c1Smrg		  if test "$prev" = dlprefiles; then
5338994689c1Smrg		    # Preload the old-style object.
5339f353fbadSmrg		    func_append dlprefiles " $pic_object"
5340994689c1Smrg		    prev=
5341994689c1Smrg		  fi
5342775e7de9Smrg
5343994689c1Smrg		  # A PIC object.
5344994689c1Smrg		  func_append libobjs " $pic_object"
5345994689c1Smrg		  arg="$pic_object"
5346994689c1Smrg		fi
5347775e7de9Smrg
5348994689c1Smrg		# Non-PIC object.
5349994689c1Smrg		if test "$non_pic_object" != none; then
5350994689c1Smrg		  # Prepend the subdirectory the object is found in.
5351994689c1Smrg		  non_pic_object="$xdir$non_pic_object"
5352775e7de9Smrg
5353994689c1Smrg		  # A standard non-PIC object
5354994689c1Smrg		  func_append non_pic_objects " $non_pic_object"
5355994689c1Smrg		  if test -z "$pic_object" || test "$pic_object" = none ; then
5356994689c1Smrg		    arg="$non_pic_object"
5357994689c1Smrg		  fi
5358994689c1Smrg		else
5359994689c1Smrg		  # If the PIC object exists, use it instead.
5360994689c1Smrg		  # $xdir was prepended to $pic_object above.
5361994689c1Smrg		  non_pic_object="$pic_object"
5362994689c1Smrg		  func_append non_pic_objects " $non_pic_object"
5363994689c1Smrg		fi
5364994689c1Smrg	      else
5365994689c1Smrg		# Only an error if not doing a dry-run.
5366994689c1Smrg		if $opt_dry_run; then
5367994689c1Smrg		  # Extract subdirectory from the argument.
5368994689c1Smrg		  func_dirname "$arg" "/" ""
5369994689c1Smrg		  xdir="$func_dirname_result"
5370994689c1Smrg
5371994689c1Smrg		  func_lo2o "$arg"
5372994689c1Smrg		  pic_object=$xdir$objdir/$func_lo2o_result
5373994689c1Smrg		  non_pic_object=$xdir$func_lo2o_result
5374994689c1Smrg		  func_append libobjs " $pic_object"
5375994689c1Smrg		  func_append non_pic_objects " $non_pic_object"
5376994689c1Smrg	        else
5377994689c1Smrg		  func_fatal_error "\`$arg' is not a valid libtool object"
5378994689c1Smrg		fi
5379994689c1Smrg	      fi
5380994689c1Smrg	    done
5381e1e1713cSmrg	  else
5382994689c1Smrg	    func_fatal_error "link input file \`$arg' does not exist"
5383e1e1713cSmrg	  fi
5384994689c1Smrg	  arg=$save_arg
5385994689c1Smrg	  prev=
5386994689c1Smrg	  continue
5387994689c1Smrg	  ;;
5388994689c1Smrg	precious_regex)
5389994689c1Smrg	  precious_files_regex="$arg"
5390994689c1Smrg	  prev=
5391994689c1Smrg	  continue
5392994689c1Smrg	  ;;
5393994689c1Smrg	release)
5394994689c1Smrg	  release="-$arg"
5395994689c1Smrg	  prev=
5396994689c1Smrg	  continue
5397994689c1Smrg	  ;;
5398994689c1Smrg	rpath | xrpath)
5399994689c1Smrg	  # We need an absolute path.
5400994689c1Smrg	  case $arg in
5401994689c1Smrg	  [\\/]* | [A-Za-z]:[\\/]*) ;;
5402994689c1Smrg	  *)
5403994689c1Smrg	    func_fatal_error "only absolute run-paths are allowed"
5404994689c1Smrg	    ;;
5405994689c1Smrg	  esac
5406994689c1Smrg	  if test "$prev" = rpath; then
5407994689c1Smrg	    case "$rpath " in
5408994689c1Smrg	    *" $arg "*) ;;
5409f353fbadSmrg	    *) func_append rpath " $arg" ;;
5410994689c1Smrg	    esac
5411e1e1713cSmrg	  else
5412994689c1Smrg	    case "$xrpath " in
5413994689c1Smrg	    *" $arg "*) ;;
5414f353fbadSmrg	    *) func_append xrpath " $arg" ;;
5415994689c1Smrg	    esac
5416e1e1713cSmrg	  fi
5417994689c1Smrg	  prev=
5418994689c1Smrg	  continue
5419994689c1Smrg	  ;;
5420994689c1Smrg	shrext)
5421994689c1Smrg	  shrext_cmds="$arg"
5422994689c1Smrg	  prev=
5423994689c1Smrg	  continue
5424994689c1Smrg	  ;;
5425994689c1Smrg	weak)
5426f353fbadSmrg	  func_append weak_libs " $arg"
5427994689c1Smrg	  prev=
5428994689c1Smrg	  continue
5429994689c1Smrg	  ;;
5430994689c1Smrg	xcclinker)
5431f353fbadSmrg	  func_append linker_flags " $qarg"
5432f353fbadSmrg	  func_append compiler_flags " $qarg"
5433994689c1Smrg	  prev=
5434994689c1Smrg	  func_append compile_command " $qarg"
5435994689c1Smrg	  func_append finalize_command " $qarg"
5436994689c1Smrg	  continue
5437994689c1Smrg	  ;;
5438994689c1Smrg	xcompiler)
5439f353fbadSmrg	  func_append compiler_flags " $qarg"
5440994689c1Smrg	  prev=
5441994689c1Smrg	  func_append compile_command " $qarg"
5442994689c1Smrg	  func_append finalize_command " $qarg"
5443994689c1Smrg	  continue
5444994689c1Smrg	  ;;
5445994689c1Smrg	xlinker)
5446f353fbadSmrg	  func_append linker_flags " $qarg"
5447f353fbadSmrg	  func_append compiler_flags " $wl$qarg"
5448994689c1Smrg	  prev=
5449994689c1Smrg	  func_append compile_command " $wl$qarg"
5450994689c1Smrg	  func_append finalize_command " $wl$qarg"
5451994689c1Smrg	  continue
5452994689c1Smrg	  ;;
5453994689c1Smrg	*)
5454994689c1Smrg	  eval "$prev=\"\$arg\""
5455994689c1Smrg	  prev=
5456994689c1Smrg	  continue
5457994689c1Smrg	  ;;
5458775e7de9Smrg	esac
5459994689c1Smrg      fi # test -n "$prev"
5460775e7de9Smrg
5461994689c1Smrg      prevarg="$arg"
5462775e7de9Smrg
5463994689c1Smrg      case $arg in
5464994689c1Smrg      -all-static)
5465994689c1Smrg	if test -n "$link_static_flag"; then
5466994689c1Smrg	  # See comment for -static flag below, for more details.
5467994689c1Smrg	  func_append compile_command " $link_static_flag"
5468994689c1Smrg	  func_append finalize_command " $link_static_flag"
5469994689c1Smrg	fi
5470994689c1Smrg	continue
5471994689c1Smrg	;;
5472775e7de9Smrg
5473994689c1Smrg      -allow-undefined)
5474994689c1Smrg	# FIXME: remove this flag sometime in the future.
5475994689c1Smrg	func_fatal_error "\`-allow-undefined' must not be used because it is the default"
5476994689c1Smrg	;;
5477775e7de9Smrg
5478994689c1Smrg      -avoid-version)
5479994689c1Smrg	avoid_version=yes
5480994689c1Smrg	continue
5481994689c1Smrg	;;
5482775e7de9Smrg
5483994689c1Smrg      -bindir)
5484994689c1Smrg	prev=bindir
5485994689c1Smrg	continue
5486994689c1Smrg	;;
5487775e7de9Smrg
5488994689c1Smrg      -dlopen)
5489994689c1Smrg	prev=dlfiles
5490994689c1Smrg	continue
5491994689c1Smrg	;;
5492775e7de9Smrg
5493994689c1Smrg      -dlpreopen)
5494994689c1Smrg	prev=dlprefiles
5495994689c1Smrg	continue
5496994689c1Smrg	;;
5497775e7de9Smrg
5498994689c1Smrg      -export-dynamic)
5499994689c1Smrg	export_dynamic=yes
5500994689c1Smrg	continue
5501994689c1Smrg	;;
5502775e7de9Smrg
5503994689c1Smrg      -export-symbols | -export-symbols-regex)
5504994689c1Smrg	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
5505994689c1Smrg	  func_fatal_error "more than one -exported-symbols argument is not allowed"
5506994689c1Smrg	fi
5507994689c1Smrg	if test "X$arg" = "X-export-symbols"; then
5508994689c1Smrg	  prev=expsyms
5509994689c1Smrg	else
5510994689c1Smrg	  prev=expsyms_regex
5511994689c1Smrg	fi
5512994689c1Smrg	continue
5513994689c1Smrg	;;
5514775e7de9Smrg
5515994689c1Smrg      -framework)
5516994689c1Smrg	prev=framework
5517994689c1Smrg	continue
5518994689c1Smrg	;;
5519775e7de9Smrg
5520994689c1Smrg      -inst-prefix-dir)
5521994689c1Smrg	prev=inst_prefix
5522994689c1Smrg	continue
5523994689c1Smrg	;;
5524775e7de9Smrg
5525994689c1Smrg      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
5526994689c1Smrg      # so, if we see these flags be careful not to treat them like -L
5527994689c1Smrg      -L[A-Z][A-Z]*:*)
5528994689c1Smrg	case $with_gcc/$host in
5529994689c1Smrg	no/*-*-irix* | /*-*-irix*)
5530994689c1Smrg	  func_append compile_command " $arg"
5531994689c1Smrg	  func_append finalize_command " $arg"
5532994689c1Smrg	  ;;
5533994689c1Smrg	esac
5534994689c1Smrg	continue
5535994689c1Smrg	;;
5536775e7de9Smrg
5537994689c1Smrg      -L*)
5538f353fbadSmrg	func_stripname "-L" '' "$arg"
5539f353fbadSmrg	if test -z "$func_stripname_result"; then
5540994689c1Smrg	  if test "$#" -gt 0; then
5541994689c1Smrg	    func_fatal_error "require no space between \`-L' and \`$1'"
5542994689c1Smrg	  else
5543994689c1Smrg	    func_fatal_error "need path for \`-L' option"
5544994689c1Smrg	  fi
5545994689c1Smrg	fi
5546f353fbadSmrg	func_resolve_sysroot "$func_stripname_result"
5547f353fbadSmrg	dir=$func_resolve_sysroot_result
5548994689c1Smrg	# We need an absolute path.
5549994689c1Smrg	case $dir in
5550994689c1Smrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
5551994689c1Smrg	*)
5552994689c1Smrg	  absdir=`cd "$dir" && pwd`
5553994689c1Smrg	  test -z "$absdir" && \
5554994689c1Smrg	    func_fatal_error "cannot determine absolute directory name of \`$dir'"
5555994689c1Smrg	  dir="$absdir"
5556994689c1Smrg	  ;;
5557994689c1Smrg	esac
5558994689c1Smrg	case "$deplibs " in
5559f353fbadSmrg	*" -L$dir "* | *" $arg "*)
5560f353fbadSmrg	  # Will only happen for absolute or sysroot arguments
5561f353fbadSmrg	  ;;
5562994689c1Smrg	*)
5563f353fbadSmrg	  # Preserve sysroot, but never include relative directories
5564f353fbadSmrg	  case $dir in
5565f353fbadSmrg	    [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;;
5566f353fbadSmrg	    *) func_append deplibs " -L$dir" ;;
5567f353fbadSmrg	  esac
5568f353fbadSmrg	  func_append lib_search_path " $dir"
5569994689c1Smrg	  ;;
5570994689c1Smrg	esac
5571994689c1Smrg	case $host in
5572994689c1Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
5573994689c1Smrg	  testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
5574994689c1Smrg	  case :$dllsearchpath: in
5575994689c1Smrg	  *":$dir:"*) ;;
5576994689c1Smrg	  ::) dllsearchpath=$dir;;
5577f353fbadSmrg	  *) func_append dllsearchpath ":$dir";;
5578994689c1Smrg	  esac
5579994689c1Smrg	  case :$dllsearchpath: in
5580994689c1Smrg	  *":$testbindir:"*) ;;
5581994689c1Smrg	  ::) dllsearchpath=$testbindir;;
5582f353fbadSmrg	  *) func_append dllsearchpath ":$testbindir";;
5583994689c1Smrg	  esac
5584994689c1Smrg	  ;;
5585994689c1Smrg	esac
5586994689c1Smrg	continue
5587994689c1Smrg	;;
5588775e7de9Smrg
5589994689c1Smrg      -l*)
5590994689c1Smrg	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
5591994689c1Smrg	  case $host in
5592994689c1Smrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
5593994689c1Smrg	    # These systems don't actually have a C or math library (as such)
5594994689c1Smrg	    continue
5595994689c1Smrg	    ;;
5596994689c1Smrg	  *-*-os2*)
5597994689c1Smrg	    # These systems don't actually have a C library (as such)
5598994689c1Smrg	    test "X$arg" = "X-lc" && continue
5599994689c1Smrg	    ;;
5600994689c1Smrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
5601994689c1Smrg	    # Do not include libc due to us having libc/libc_r.
5602994689c1Smrg	    test "X$arg" = "X-lc" && continue
5603994689c1Smrg	    ;;
5604994689c1Smrg	  *-*-rhapsody* | *-*-darwin1.[012])
5605994689c1Smrg	    # Rhapsody C and math libraries are in the System framework
5606f353fbadSmrg	    func_append deplibs " System.ltframework"
5607994689c1Smrg	    continue
5608994689c1Smrg	    ;;
5609994689c1Smrg	  *-*-sco3.2v5* | *-*-sco5v6*)
5610994689c1Smrg	    # Causes problems with __ctype
5611994689c1Smrg	    test "X$arg" = "X-lc" && continue
5612994689c1Smrg	    ;;
5613994689c1Smrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
5614994689c1Smrg	    # Compiler inserts libc in the correct place for threads to work
5615994689c1Smrg	    test "X$arg" = "X-lc" && continue
5616994689c1Smrg	    ;;
5617994689c1Smrg	  esac
5618994689c1Smrg	elif test "X$arg" = "X-lc_r"; then
5619994689c1Smrg	 case $host in
5620994689c1Smrg	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
5621994689c1Smrg	   # Do not include libc_r directly, use -pthread flag.
5622994689c1Smrg	   continue
5623994689c1Smrg	   ;;
5624994689c1Smrg	 esac
5625994689c1Smrg	fi
5626f353fbadSmrg	func_append deplibs " $arg"
5627994689c1Smrg	continue
5628994689c1Smrg	;;
5629775e7de9Smrg
5630994689c1Smrg      -module)
5631994689c1Smrg	module=yes
5632994689c1Smrg	continue
5633994689c1Smrg	;;
5634775e7de9Smrg
5635994689c1Smrg      # Tru64 UNIX uses -model [arg] to determine the layout of C++
5636994689c1Smrg      # classes, name mangling, and exception handling.
5637994689c1Smrg      # Darwin uses the -arch flag to determine output architecture.
5638f353fbadSmrg      -model|-arch|-isysroot|--sysroot)
5639f353fbadSmrg	func_append compiler_flags " $arg"
5640994689c1Smrg	func_append compile_command " $arg"
5641994689c1Smrg	func_append finalize_command " $arg"
5642994689c1Smrg	prev=xcompiler
5643994689c1Smrg	continue
5644994689c1Smrg	;;
5645775e7de9Smrg
5646994689c1Smrg      -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
5647f353fbadSmrg	func_append compiler_flags " $arg"
5648994689c1Smrg	func_append compile_command " $arg"
5649994689c1Smrg	func_append finalize_command " $arg"
5650994689c1Smrg	case "$new_inherited_linker_flags " in
5651994689c1Smrg	    *" $arg "*) ;;
5652f353fbadSmrg	    * ) func_append new_inherited_linker_flags " $arg" ;;
5653994689c1Smrg	esac
5654994689c1Smrg	continue
5655994689c1Smrg	;;
5656775e7de9Smrg
5657994689c1Smrg      -multi_module)
5658994689c1Smrg	single_module="${wl}-multi_module"
5659994689c1Smrg	continue
5660994689c1Smrg	;;
5661775e7de9Smrg
5662994689c1Smrg      -no-fast-install)
5663994689c1Smrg	fast_install=no
5664994689c1Smrg	continue
5665994689c1Smrg	;;
5666775e7de9Smrg
5667994689c1Smrg      -no-install)
5668994689c1Smrg	case $host in
5669994689c1Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
5670994689c1Smrg	  # The PATH hackery in wrapper scripts is required on Windows
5671994689c1Smrg	  # and Darwin in order for the loader to find any dlls it needs.
5672994689c1Smrg	  func_warning "\`-no-install' is ignored for $host"
5673994689c1Smrg	  func_warning "assuming \`-no-fast-install' instead"
5674994689c1Smrg	  fast_install=no
5675994689c1Smrg	  ;;
5676994689c1Smrg	*) no_install=yes ;;
5677994689c1Smrg	esac
5678994689c1Smrg	continue
5679994689c1Smrg	;;
5680775e7de9Smrg
5681994689c1Smrg      -no-undefined)
5682994689c1Smrg	allow_undefined=no
5683994689c1Smrg	continue
5684994689c1Smrg	;;
5685775e7de9Smrg
5686994689c1Smrg      -objectlist)
5687994689c1Smrg	prev=objectlist
5688994689c1Smrg	continue
5689994689c1Smrg	;;
5690775e7de9Smrg
5691994689c1Smrg      -o) prev=output ;;
5692775e7de9Smrg
5693994689c1Smrg      -precious-files-regex)
5694994689c1Smrg	prev=precious_regex
5695994689c1Smrg	continue
5696994689c1Smrg	;;
5697775e7de9Smrg
5698994689c1Smrg      -release)
5699994689c1Smrg	prev=release
5700994689c1Smrg	continue
5701994689c1Smrg	;;
5702775e7de9Smrg
5703994689c1Smrg      -rpath)
5704994689c1Smrg	prev=rpath
5705994689c1Smrg	continue
5706994689c1Smrg	;;
5707775e7de9Smrg
5708994689c1Smrg      -R)
5709994689c1Smrg	prev=xrpath
5710994689c1Smrg	continue
5711994689c1Smrg	;;
5712775e7de9Smrg
5713994689c1Smrg      -R*)
5714994689c1Smrg	func_stripname '-R' '' "$arg"
5715994689c1Smrg	dir=$func_stripname_result
5716994689c1Smrg	# We need an absolute path.
5717994689c1Smrg	case $dir in
5718994689c1Smrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
5719f353fbadSmrg	=*)
5720f353fbadSmrg	  func_stripname '=' '' "$dir"
5721f353fbadSmrg	  dir=$lt_sysroot$func_stripname_result
5722f353fbadSmrg	  ;;
5723994689c1Smrg	*)
5724994689c1Smrg	  func_fatal_error "only absolute run-paths are allowed"
5725994689c1Smrg	  ;;
5726994689c1Smrg	esac
5727994689c1Smrg	case "$xrpath " in
5728994689c1Smrg	*" $dir "*) ;;
5729f353fbadSmrg	*) func_append xrpath " $dir" ;;
5730994689c1Smrg	esac
5731994689c1Smrg	continue
5732994689c1Smrg	;;
5733775e7de9Smrg
5734994689c1Smrg      -shared)
5735994689c1Smrg	# The effects of -shared are defined in a previous loop.
5736994689c1Smrg	continue
5737994689c1Smrg	;;
5738775e7de9Smrg
5739994689c1Smrg      -shrext)
5740994689c1Smrg	prev=shrext
5741994689c1Smrg	continue
5742994689c1Smrg	;;
5743775e7de9Smrg
5744994689c1Smrg      -static | -static-libtool-libs)
5745994689c1Smrg	# The effects of -static are defined in a previous loop.
5746994689c1Smrg	# We used to do the same as -all-static on platforms that
5747994689c1Smrg	# didn't have a PIC flag, but the assumption that the effects
5748994689c1Smrg	# would be equivalent was wrong.  It would break on at least
5749994689c1Smrg	# Digital Unix and AIX.
5750994689c1Smrg	continue
5751994689c1Smrg	;;
5752775e7de9Smrg
5753994689c1Smrg      -thread-safe)
5754994689c1Smrg	thread_safe=yes
5755994689c1Smrg	continue
5756994689c1Smrg	;;
5757775e7de9Smrg
5758994689c1Smrg      -version-info)
5759994689c1Smrg	prev=vinfo
5760994689c1Smrg	continue
5761994689c1Smrg	;;
5762775e7de9Smrg
5763994689c1Smrg      -version-number)
5764994689c1Smrg	prev=vinfo
5765994689c1Smrg	vinfo_number=yes
5766994689c1Smrg	continue
5767994689c1Smrg	;;
57687a84e134Smrg
5769994689c1Smrg      -weak)
5770994689c1Smrg        prev=weak
5771994689c1Smrg	continue
5772994689c1Smrg	;;
5773e1e1713cSmrg
5774994689c1Smrg      -Wc,*)
5775994689c1Smrg	func_stripname '-Wc,' '' "$arg"
5776994689c1Smrg	args=$func_stripname_result
5777994689c1Smrg	arg=
5778994689c1Smrg	save_ifs="$IFS"; IFS=','
5779994689c1Smrg	for flag in $args; do
5780994689c1Smrg	  IFS="$save_ifs"
5781994689c1Smrg          func_quote_for_eval "$flag"
5782f353fbadSmrg	  func_append arg " $func_quote_for_eval_result"
5783f353fbadSmrg	  func_append compiler_flags " $func_quote_for_eval_result"
5784994689c1Smrg	done
5785994689c1Smrg	IFS="$save_ifs"
5786994689c1Smrg	func_stripname ' ' '' "$arg"
5787994689c1Smrg	arg=$func_stripname_result
5788994689c1Smrg	;;
5789e1e1713cSmrg
5790994689c1Smrg      -Wl,*)
5791994689c1Smrg	func_stripname '-Wl,' '' "$arg"
5792994689c1Smrg	args=$func_stripname_result
5793994689c1Smrg	arg=
5794994689c1Smrg	save_ifs="$IFS"; IFS=','
5795994689c1Smrg	for flag in $args; do
5796994689c1Smrg	  IFS="$save_ifs"
5797994689c1Smrg          func_quote_for_eval "$flag"
5798f353fbadSmrg	  func_append arg " $wl$func_quote_for_eval_result"
5799f353fbadSmrg	  func_append compiler_flags " $wl$func_quote_for_eval_result"
5800f353fbadSmrg	  func_append linker_flags " $func_quote_for_eval_result"
5801994689c1Smrg	done
5802994689c1Smrg	IFS="$save_ifs"
5803994689c1Smrg	func_stripname ' ' '' "$arg"
5804994689c1Smrg	arg=$func_stripname_result
5805994689c1Smrg	;;
5806e1e1713cSmrg
5807994689c1Smrg      -Xcompiler)
5808994689c1Smrg	prev=xcompiler
5809994689c1Smrg	continue
5810994689c1Smrg	;;
5811e1e1713cSmrg
5812994689c1Smrg      -Xlinker)
5813994689c1Smrg	prev=xlinker
5814994689c1Smrg	continue
5815994689c1Smrg	;;
5816e1e1713cSmrg
5817994689c1Smrg      -XCClinker)
5818994689c1Smrg	prev=xcclinker
5819994689c1Smrg	continue
5820994689c1Smrg	;;
5821e1e1713cSmrg
5822994689c1Smrg      # -msg_* for osf cc
5823994689c1Smrg      -msg_*)
5824994689c1Smrg	func_quote_for_eval "$arg"
5825994689c1Smrg	arg="$func_quote_for_eval_result"
5826994689c1Smrg	;;
5827e1e1713cSmrg
5828994689c1Smrg      # Flags to be passed through unchanged, with rationale:
5829994689c1Smrg      # -64, -mips[0-9]      enable 64-bit mode for the SGI compiler
5830994689c1Smrg      # -r[0-9][0-9]*        specify processor for the SGI compiler
5831994689c1Smrg      # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler
5832994689c1Smrg      # +DA*, +DD*           enable 64-bit mode for the HP compiler
5833994689c1Smrg      # -q*                  compiler args for the IBM compiler
5834994689c1Smrg      # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
5835994689c1Smrg      # -F/path              path to uninstalled frameworks, gcc on darwin
5836994689c1Smrg      # -p, -pg, --coverage, -fprofile-*  profiling flags for GCC
5837994689c1Smrg      # @file                GCC response files
5838994689c1Smrg      # -tp=*                Portland pgcc target processor selection
5839f353fbadSmrg      # --sysroot=*          for sysroot support
5840f353fbadSmrg      # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
5841994689c1Smrg      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
5842f353fbadSmrg      -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
5843f353fbadSmrg      -O*|-flto*|-fwhopr*|-fuse-linker-plugin)
5844994689c1Smrg        func_quote_for_eval "$arg"
5845994689c1Smrg	arg="$func_quote_for_eval_result"
5846994689c1Smrg        func_append compile_command " $arg"
5847994689c1Smrg        func_append finalize_command " $arg"
5848f353fbadSmrg        func_append compiler_flags " $arg"
5849994689c1Smrg        continue
5850994689c1Smrg        ;;
5851e1e1713cSmrg
5852994689c1Smrg      # Some other compiler flag.
5853994689c1Smrg      -* | +*)
5854994689c1Smrg        func_quote_for_eval "$arg"
5855994689c1Smrg	arg="$func_quote_for_eval_result"
5856994689c1Smrg	;;
5857e1e1713cSmrg
5858994689c1Smrg      *.$objext)
5859994689c1Smrg	# A standard object.
5860f353fbadSmrg	func_append objs " $arg"
5861994689c1Smrg	;;
5862e1e1713cSmrg
5863994689c1Smrg      *.lo)
5864994689c1Smrg	# A libtool-controlled object.
5865e1e1713cSmrg
5866994689c1Smrg	# Check to see that this really is a libtool object.
5867994689c1Smrg	if func_lalib_unsafe_p "$arg"; then
5868994689c1Smrg	  pic_object=
5869994689c1Smrg	  non_pic_object=
5870e1e1713cSmrg
5871994689c1Smrg	  # Read the .lo file
5872994689c1Smrg	  func_source "$arg"
5873e1e1713cSmrg
5874994689c1Smrg	  if test -z "$pic_object" ||
5875994689c1Smrg	     test -z "$non_pic_object" ||
5876994689c1Smrg	     test "$pic_object" = none &&
5877994689c1Smrg	     test "$non_pic_object" = none; then
5878994689c1Smrg	    func_fatal_error "cannot find name of object for \`$arg'"
5879994689c1Smrg	  fi
5880e1e1713cSmrg
5881994689c1Smrg	  # Extract subdirectory from the argument.
5882994689c1Smrg	  func_dirname "$arg" "/" ""
5883994689c1Smrg	  xdir="$func_dirname_result"
5884e1e1713cSmrg
5885994689c1Smrg	  if test "$pic_object" != none; then
5886994689c1Smrg	    # Prepend the subdirectory the object is found in.
5887994689c1Smrg	    pic_object="$xdir$pic_object"
5888e1e1713cSmrg
5889994689c1Smrg	    if test "$prev" = dlfiles; then
5890994689c1Smrg	      if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
5891f353fbadSmrg		func_append dlfiles " $pic_object"
5892994689c1Smrg		prev=
5893994689c1Smrg		continue
5894994689c1Smrg	      else
5895994689c1Smrg		# If libtool objects are unsupported, then we need to preload.
5896994689c1Smrg		prev=dlprefiles
5897994689c1Smrg	      fi
5898994689c1Smrg	    fi
5899994689c1Smrg
5900994689c1Smrg	    # CHECK ME:  I think I busted this.  -Ossama
5901994689c1Smrg	    if test "$prev" = dlprefiles; then
5902994689c1Smrg	      # Preload the old-style object.
5903f353fbadSmrg	      func_append dlprefiles " $pic_object"
5904994689c1Smrg	      prev=
5905994689c1Smrg	    fi
5906994689c1Smrg
5907994689c1Smrg	    # A PIC object.
5908994689c1Smrg	    func_append libobjs " $pic_object"
5909994689c1Smrg	    arg="$pic_object"
5910994689c1Smrg	  fi
5911994689c1Smrg
5912994689c1Smrg	  # Non-PIC object.
5913994689c1Smrg	  if test "$non_pic_object" != none; then
5914994689c1Smrg	    # Prepend the subdirectory the object is found in.
5915994689c1Smrg	    non_pic_object="$xdir$non_pic_object"
5916994689c1Smrg
5917994689c1Smrg	    # A standard non-PIC object
5918994689c1Smrg	    func_append non_pic_objects " $non_pic_object"
5919994689c1Smrg	    if test -z "$pic_object" || test "$pic_object" = none ; then
5920994689c1Smrg	      arg="$non_pic_object"
5921994689c1Smrg	    fi
5922994689c1Smrg	  else
5923994689c1Smrg	    # If the PIC object exists, use it instead.
5924994689c1Smrg	    # $xdir was prepended to $pic_object above.
5925994689c1Smrg	    non_pic_object="$pic_object"
5926994689c1Smrg	    func_append non_pic_objects " $non_pic_object"
5927994689c1Smrg	  fi
5928994689c1Smrg	else
5929994689c1Smrg	  # Only an error if not doing a dry-run.
5930994689c1Smrg	  if $opt_dry_run; then
5931994689c1Smrg	    # Extract subdirectory from the argument.
5932994689c1Smrg	    func_dirname "$arg" "/" ""
5933994689c1Smrg	    xdir="$func_dirname_result"
5934994689c1Smrg
5935994689c1Smrg	    func_lo2o "$arg"
5936994689c1Smrg	    pic_object=$xdir$objdir/$func_lo2o_result
5937994689c1Smrg	    non_pic_object=$xdir$func_lo2o_result
5938994689c1Smrg	    func_append libobjs " $pic_object"
5939994689c1Smrg	    func_append non_pic_objects " $non_pic_object"
5940994689c1Smrg	  else
5941994689c1Smrg	    func_fatal_error "\`$arg' is not a valid libtool object"
5942994689c1Smrg	  fi
5943994689c1Smrg	fi
5944994689c1Smrg	;;
5945994689c1Smrg
5946994689c1Smrg      *.$libext)
5947994689c1Smrg	# An archive.
5948f353fbadSmrg	func_append deplibs " $arg"
5949f353fbadSmrg	func_append old_deplibs " $arg"
5950994689c1Smrg	continue
5951994689c1Smrg	;;
5952994689c1Smrg
5953994689c1Smrg      *.la)
5954994689c1Smrg	# A libtool-controlled library.
5955994689c1Smrg
5956f353fbadSmrg	func_resolve_sysroot "$arg"
5957994689c1Smrg	if test "$prev" = dlfiles; then
5958994689c1Smrg	  # This library was specified with -dlopen.
5959f353fbadSmrg	  func_append dlfiles " $func_resolve_sysroot_result"
5960994689c1Smrg	  prev=
5961994689c1Smrg	elif test "$prev" = dlprefiles; then
5962994689c1Smrg	  # The library was specified with -dlpreopen.
5963f353fbadSmrg	  func_append dlprefiles " $func_resolve_sysroot_result"
5964994689c1Smrg	  prev=
5965994689c1Smrg	else
5966f353fbadSmrg	  func_append deplibs " $func_resolve_sysroot_result"
5967994689c1Smrg	fi
5968994689c1Smrg	continue
5969994689c1Smrg	;;
5970994689c1Smrg
5971994689c1Smrg      # Some other compiler argument.
5972994689c1Smrg      *)
5973994689c1Smrg	# Unknown arguments in both finalize_command and compile_command need
5974994689c1Smrg	# to be aesthetically quoted because they are evaled later.
5975994689c1Smrg	func_quote_for_eval "$arg"
5976994689c1Smrg	arg="$func_quote_for_eval_result"
5977994689c1Smrg	;;
5978994689c1Smrg      esac # arg
5979994689c1Smrg
5980994689c1Smrg      # Now actually substitute the argument into the commands.
5981994689c1Smrg      if test -n "$arg"; then
5982994689c1Smrg	func_append compile_command " $arg"
5983994689c1Smrg	func_append finalize_command " $arg"
5984994689c1Smrg      fi
5985994689c1Smrg    done # argument parsing loop
5986994689c1Smrg
5987994689c1Smrg    test -n "$prev" && \
5988994689c1Smrg      func_fatal_help "the \`$prevarg' option requires an argument"
5989994689c1Smrg
5990994689c1Smrg    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
5991994689c1Smrg      eval arg=\"$export_dynamic_flag_spec\"
5992994689c1Smrg      func_append compile_command " $arg"
5993994689c1Smrg      func_append finalize_command " $arg"
5994994689c1Smrg    fi
5995994689c1Smrg
5996994689c1Smrg    oldlibs=
5997994689c1Smrg    # calculate the name of the file, without its directory
5998994689c1Smrg    func_basename "$output"
5999994689c1Smrg    outputname="$func_basename_result"
6000994689c1Smrg    libobjs_save="$libobjs"
6001994689c1Smrg
6002994689c1Smrg    if test -n "$shlibpath_var"; then
6003994689c1Smrg      # get the directories listed in $shlibpath_var
6004994689c1Smrg      eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\`
6005e1e1713cSmrg    else
6006994689c1Smrg      shlib_search_path=
6007e1e1713cSmrg    fi
6008994689c1Smrg    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
6009994689c1Smrg    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
60107a84e134Smrg
6011994689c1Smrg    func_dirname "$output" "/" ""
6012994689c1Smrg    output_objdir="$func_dirname_result$objdir"
6013f353fbadSmrg    func_to_tool_file "$output_objdir/"
6014f353fbadSmrg    tool_output_objdir=$func_to_tool_file_result
6015994689c1Smrg    # Create the object directory.
6016994689c1Smrg    func_mkdir_p "$output_objdir"
60177a84e134Smrg
6018994689c1Smrg    # Determine the type of output
6019994689c1Smrg    case $output in
6020994689c1Smrg    "")
6021994689c1Smrg      func_fatal_help "you must specify an output file"
6022994689c1Smrg      ;;
6023994689c1Smrg    *.$libext) linkmode=oldlib ;;
6024994689c1Smrg    *.lo | *.$objext) linkmode=obj ;;
6025994689c1Smrg    *.la) linkmode=lib ;;
6026994689c1Smrg    *) linkmode=prog ;; # Anything else should be a program.
6027994689c1Smrg    esac
6028994689c1Smrg
6029994689c1Smrg    specialdeplibs=
6030994689c1Smrg
6031994689c1Smrg    libs=
6032994689c1Smrg    # Find all interdependent deplibs by searching for libraries
6033994689c1Smrg    # that are linked more than once (e.g. -la -lb -la)
6034994689c1Smrg    for deplib in $deplibs; do
6035f353fbadSmrg      if $opt_preserve_dup_deps ; then
6036994689c1Smrg	case "$libs " in
6037f353fbadSmrg	*" $deplib "*) func_append specialdeplibs " $deplib" ;;
6038994689c1Smrg	esac
6039994689c1Smrg      fi
6040f353fbadSmrg      func_append libs " $deplib"
6041994689c1Smrg    done
6042994689c1Smrg
6043994689c1Smrg    if test "$linkmode" = lib; then
6044994689c1Smrg      libs="$predeps $libs $compiler_lib_search_path $postdeps"
6045994689c1Smrg
6046994689c1Smrg      # Compute libraries that are listed more than once in $predeps
6047994689c1Smrg      # $postdeps and mark them as special (i.e., whose duplicates are
6048994689c1Smrg      # not to be eliminated).
6049994689c1Smrg      pre_post_deps=
6050994689c1Smrg      if $opt_duplicate_compiler_generated_deps; then
6051994689c1Smrg	for pre_post_dep in $predeps $postdeps; do
6052994689c1Smrg	  case "$pre_post_deps " in
6053f353fbadSmrg	  *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;;
6054994689c1Smrg	  esac
6055f353fbadSmrg	  func_append pre_post_deps " $pre_post_dep"
6056994689c1Smrg	done
6057994689c1Smrg      fi
6058994689c1Smrg      pre_post_deps=
6059994689c1Smrg    fi
6060994689c1Smrg
6061994689c1Smrg    deplibs=
6062994689c1Smrg    newdependency_libs=
6063994689c1Smrg    newlib_search_path=
6064994689c1Smrg    need_relink=no # whether we're linking any uninstalled libtool libraries
6065994689c1Smrg    notinst_deplibs= # not-installed libtool libraries
6066994689c1Smrg    notinst_path= # paths that contain not-installed libtool libraries
6067994689c1Smrg
6068994689c1Smrg    case $linkmode in
6069994689c1Smrg    lib)
6070994689c1Smrg	passes="conv dlpreopen link"
6071994689c1Smrg	for file in $dlfiles $dlprefiles; do
6072994689c1Smrg	  case $file in
6073994689c1Smrg	  *.la) ;;
6074994689c1Smrg	  *)
6075994689c1Smrg	    func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file"
6076994689c1Smrg	    ;;
6077994689c1Smrg	  esac
6078994689c1Smrg	done
6079994689c1Smrg	;;
6080994689c1Smrg    prog)
6081994689c1Smrg	compile_deplibs=
6082994689c1Smrg	finalize_deplibs=
6083994689c1Smrg	alldeplibs=no
6084994689c1Smrg	newdlfiles=
6085994689c1Smrg	newdlprefiles=
6086994689c1Smrg	passes="conv scan dlopen dlpreopen link"
6087994689c1Smrg	;;
6088994689c1Smrg    *)  passes="conv"
6089994689c1Smrg	;;
6090994689c1Smrg    esac
6091994689c1Smrg
6092994689c1Smrg    for pass in $passes; do
6093994689c1Smrg      # The preopen pass in lib mode reverses $deplibs; put it back here
6094994689c1Smrg      # so that -L comes before libs that need it for instance...
6095994689c1Smrg      if test "$linkmode,$pass" = "lib,link"; then
6096994689c1Smrg	## FIXME: Find the place where the list is rebuilt in the wrong
6097994689c1Smrg	##        order, and fix it there properly
6098994689c1Smrg        tmp_deplibs=
6099994689c1Smrg	for deplib in $deplibs; do
6100994689c1Smrg	  tmp_deplibs="$deplib $tmp_deplibs"
6101994689c1Smrg	done
6102994689c1Smrg	deplibs="$tmp_deplibs"
6103994689c1Smrg      fi
6104994689c1Smrg
6105994689c1Smrg      if test "$linkmode,$pass" = "lib,link" ||
6106994689c1Smrg	 test "$linkmode,$pass" = "prog,scan"; then
6107994689c1Smrg	libs="$deplibs"
6108994689c1Smrg	deplibs=
6109994689c1Smrg      fi
6110994689c1Smrg      if test "$linkmode" = prog; then
6111994689c1Smrg	case $pass in
6112994689c1Smrg	dlopen) libs="$dlfiles" ;;
6113994689c1Smrg	dlpreopen) libs="$dlprefiles" ;;
6114994689c1Smrg	link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
6115994689c1Smrg	esac
6116994689c1Smrg      fi
6117994689c1Smrg      if test "$linkmode,$pass" = "lib,dlpreopen"; then
6118994689c1Smrg	# Collect and forward deplibs of preopened libtool libs
6119994689c1Smrg	for lib in $dlprefiles; do
6120994689c1Smrg	  # Ignore non-libtool-libs
6121994689c1Smrg	  dependency_libs=
6122f353fbadSmrg	  func_resolve_sysroot "$lib"
6123994689c1Smrg	  case $lib in
6124f353fbadSmrg	  *.la)	func_source "$func_resolve_sysroot_result" ;;
6125994689c1Smrg	  esac
6126994689c1Smrg
6127994689c1Smrg	  # Collect preopened libtool deplibs, except any this library
6128994689c1Smrg	  # has declared as weak libs
6129994689c1Smrg	  for deplib in $dependency_libs; do
6130994689c1Smrg	    func_basename "$deplib"
6131994689c1Smrg            deplib_base=$func_basename_result
6132994689c1Smrg	    case " $weak_libs " in
6133994689c1Smrg	    *" $deplib_base "*) ;;
6134f353fbadSmrg	    *) func_append deplibs " $deplib" ;;
6135994689c1Smrg	    esac
6136994689c1Smrg	  done
6137994689c1Smrg	done
6138994689c1Smrg	libs="$dlprefiles"
6139994689c1Smrg      fi
6140994689c1Smrg      if test "$pass" = dlopen; then
6141994689c1Smrg	# Collect dlpreopened libraries
6142994689c1Smrg	save_deplibs="$deplibs"
6143994689c1Smrg	deplibs=
6144994689c1Smrg      fi
6145994689c1Smrg
6146994689c1Smrg      for deplib in $libs; do
6147994689c1Smrg	lib=
6148994689c1Smrg	found=no
6149994689c1Smrg	case $deplib in
6150994689c1Smrg	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
6151994689c1Smrg	  if test "$linkmode,$pass" = "prog,link"; then
6152994689c1Smrg	    compile_deplibs="$deplib $compile_deplibs"
6153994689c1Smrg	    finalize_deplibs="$deplib $finalize_deplibs"
6154994689c1Smrg	  else
6155f353fbadSmrg	    func_append compiler_flags " $deplib"
6156994689c1Smrg	    if test "$linkmode" = lib ; then
6157994689c1Smrg		case "$new_inherited_linker_flags " in
6158994689c1Smrg		    *" $deplib "*) ;;
6159f353fbadSmrg		    * ) func_append new_inherited_linker_flags " $deplib" ;;
6160994689c1Smrg		esac
6161994689c1Smrg	    fi
6162994689c1Smrg	  fi
6163994689c1Smrg	  continue
6164994689c1Smrg	  ;;
6165994689c1Smrg	-l*)
6166994689c1Smrg	  if test "$linkmode" != lib && test "$linkmode" != prog; then
6167994689c1Smrg	    func_warning "\`-l' is ignored for archives/objects"
6168994689c1Smrg	    continue
6169994689c1Smrg	  fi
6170994689c1Smrg	  func_stripname '-l' '' "$deplib"
6171994689c1Smrg	  name=$func_stripname_result
6172994689c1Smrg	  if test "$linkmode" = lib; then
6173994689c1Smrg	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
6174994689c1Smrg	  else
6175994689c1Smrg	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
6176994689c1Smrg	  fi
6177994689c1Smrg	  for searchdir in $searchdirs; do
6178994689c1Smrg	    for search_ext in .la $std_shrext .so .a; do
6179994689c1Smrg	      # Search the libtool library
6180994689c1Smrg	      lib="$searchdir/lib${name}${search_ext}"
6181994689c1Smrg	      if test -f "$lib"; then
6182994689c1Smrg		if test "$search_ext" = ".la"; then
6183994689c1Smrg		  found=yes
6184994689c1Smrg		else
6185994689c1Smrg		  found=no
6186994689c1Smrg		fi
6187994689c1Smrg		break 2
6188994689c1Smrg	      fi
6189994689c1Smrg	    done
6190994689c1Smrg	  done
6191994689c1Smrg	  if test "$found" != yes; then
6192994689c1Smrg	    # deplib doesn't seem to be a libtool library
6193994689c1Smrg	    if test "$linkmode,$pass" = "prog,link"; then
6194994689c1Smrg	      compile_deplibs="$deplib $compile_deplibs"
6195994689c1Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
6196994689c1Smrg	    else
6197994689c1Smrg	      deplibs="$deplib $deplibs"
6198994689c1Smrg	      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
6199994689c1Smrg	    fi
6200994689c1Smrg	    continue
6201994689c1Smrg	  else # deplib is a libtool library
6202994689c1Smrg	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
6203994689c1Smrg	    # We need to do some special things here, and not later.
6204994689c1Smrg	    if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6205994689c1Smrg	      case " $predeps $postdeps " in
6206994689c1Smrg	      *" $deplib "*)
6207994689c1Smrg		if func_lalib_p "$lib"; then
6208994689c1Smrg		  library_names=
6209994689c1Smrg		  old_library=
6210994689c1Smrg		  func_source "$lib"
6211994689c1Smrg		  for l in $old_library $library_names; do
6212994689c1Smrg		    ll="$l"
6213994689c1Smrg		  done
6214994689c1Smrg		  if test "X$ll" = "X$old_library" ; then # only static version available
6215994689c1Smrg		    found=no
6216994689c1Smrg		    func_dirname "$lib" "" "."
6217994689c1Smrg		    ladir="$func_dirname_result"
6218994689c1Smrg		    lib=$ladir/$old_library
6219994689c1Smrg		    if test "$linkmode,$pass" = "prog,link"; then
6220994689c1Smrg		      compile_deplibs="$deplib $compile_deplibs"
6221994689c1Smrg		      finalize_deplibs="$deplib $finalize_deplibs"
6222994689c1Smrg		    else
6223994689c1Smrg		      deplibs="$deplib $deplibs"
6224994689c1Smrg		      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
6225994689c1Smrg		    fi
6226994689c1Smrg		    continue
6227994689c1Smrg		  fi
6228994689c1Smrg		fi
6229994689c1Smrg		;;
6230994689c1Smrg	      *) ;;
6231994689c1Smrg	      esac
6232994689c1Smrg	    fi
6233994689c1Smrg	  fi
6234994689c1Smrg	  ;; # -l
6235994689c1Smrg	*.ltframework)
6236994689c1Smrg	  if test "$linkmode,$pass" = "prog,link"; then
6237994689c1Smrg	    compile_deplibs="$deplib $compile_deplibs"
6238994689c1Smrg	    finalize_deplibs="$deplib $finalize_deplibs"
6239994689c1Smrg	  else
6240994689c1Smrg	    deplibs="$deplib $deplibs"
6241994689c1Smrg	    if test "$linkmode" = lib ; then
6242994689c1Smrg		case "$new_inherited_linker_flags " in
6243994689c1Smrg		    *" $deplib "*) ;;
6244f353fbadSmrg		    * ) func_append new_inherited_linker_flags " $deplib" ;;
6245994689c1Smrg		esac
6246994689c1Smrg	    fi
6247994689c1Smrg	  fi
6248994689c1Smrg	  continue
6249994689c1Smrg	  ;;
6250994689c1Smrg	-L*)
6251994689c1Smrg	  case $linkmode in
6252994689c1Smrg	  lib)
6253994689c1Smrg	    deplibs="$deplib $deplibs"
6254994689c1Smrg	    test "$pass" = conv && continue
6255994689c1Smrg	    newdependency_libs="$deplib $newdependency_libs"
6256994689c1Smrg	    func_stripname '-L' '' "$deplib"
6257f353fbadSmrg	    func_resolve_sysroot "$func_stripname_result"
6258f353fbadSmrg	    func_append newlib_search_path " $func_resolve_sysroot_result"
6259994689c1Smrg	    ;;
6260994689c1Smrg	  prog)
6261994689c1Smrg	    if test "$pass" = conv; then
6262994689c1Smrg	      deplibs="$deplib $deplibs"
6263994689c1Smrg	      continue
6264994689c1Smrg	    fi
6265994689c1Smrg	    if test "$pass" = scan; then
6266994689c1Smrg	      deplibs="$deplib $deplibs"
6267994689c1Smrg	    else
6268994689c1Smrg	      compile_deplibs="$deplib $compile_deplibs"
6269994689c1Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
6270994689c1Smrg	    fi
6271994689c1Smrg	    func_stripname '-L' '' "$deplib"
6272f353fbadSmrg	    func_resolve_sysroot "$func_stripname_result"
6273f353fbadSmrg	    func_append newlib_search_path " $func_resolve_sysroot_result"
6274994689c1Smrg	    ;;
6275994689c1Smrg	  *)
6276994689c1Smrg	    func_warning "\`-L' is ignored for archives/objects"
6277994689c1Smrg	    ;;
6278994689c1Smrg	  esac # linkmode
6279994689c1Smrg	  continue
6280994689c1Smrg	  ;; # -L
6281994689c1Smrg	-R*)
6282994689c1Smrg	  if test "$pass" = link; then
6283994689c1Smrg	    func_stripname '-R' '' "$deplib"
6284f353fbadSmrg	    func_resolve_sysroot "$func_stripname_result"
6285f353fbadSmrg	    dir=$func_resolve_sysroot_result
6286994689c1Smrg	    # Make sure the xrpath contains only unique directories.
6287994689c1Smrg	    case "$xrpath " in
6288994689c1Smrg	    *" $dir "*) ;;
6289f353fbadSmrg	    *) func_append xrpath " $dir" ;;
6290994689c1Smrg	    esac
6291994689c1Smrg	  fi
6292994689c1Smrg	  deplibs="$deplib $deplibs"
6293994689c1Smrg	  continue
6294994689c1Smrg	  ;;
6295f353fbadSmrg	*.la)
6296f353fbadSmrg	  func_resolve_sysroot "$deplib"
6297f353fbadSmrg	  lib=$func_resolve_sysroot_result
6298f353fbadSmrg	  ;;
6299994689c1Smrg	*.$libext)
6300994689c1Smrg	  if test "$pass" = conv; then
6301994689c1Smrg	    deplibs="$deplib $deplibs"
6302994689c1Smrg	    continue
6303994689c1Smrg	  fi
6304994689c1Smrg	  case $linkmode in
6305994689c1Smrg	  lib)
6306994689c1Smrg	    # Linking convenience modules into shared libraries is allowed,
6307994689c1Smrg	    # but linking other static libraries is non-portable.
6308994689c1Smrg	    case " $dlpreconveniencelibs " in
6309994689c1Smrg	    *" $deplib "*) ;;
6310994689c1Smrg	    *)
6311994689c1Smrg	      valid_a_lib=no
6312994689c1Smrg	      case $deplibs_check_method in
6313994689c1Smrg		match_pattern*)
6314994689c1Smrg		  set dummy $deplibs_check_method; shift
6315994689c1Smrg		  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
6316994689c1Smrg		  if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
6317994689c1Smrg		    | $EGREP "$match_pattern_regex" > /dev/null; then
6318994689c1Smrg		    valid_a_lib=yes
6319994689c1Smrg		  fi
6320994689c1Smrg		;;
6321994689c1Smrg		pass_all)
6322994689c1Smrg		  valid_a_lib=yes
6323994689c1Smrg		;;
6324994689c1Smrg	      esac
6325994689c1Smrg	      if test "$valid_a_lib" != yes; then
6326994689c1Smrg		echo
6327994689c1Smrg		$ECHO "*** Warning: Trying to link with static lib archive $deplib."
6328994689c1Smrg		echo "*** I have the capability to make that library automatically link in when"
6329994689c1Smrg		echo "*** you link to this library.  But I can only do this if you have a"
6330994689c1Smrg		echo "*** shared version of the library, which you do not appear to have"
6331994689c1Smrg		echo "*** because the file extensions .$libext of this argument makes me believe"
6332994689c1Smrg		echo "*** that it is just a static archive that I should not use here."
6333994689c1Smrg	      else
6334994689c1Smrg		echo
6335994689c1Smrg		$ECHO "*** Warning: Linking the shared library $output against the"
6336994689c1Smrg		$ECHO "*** static library $deplib is not portable!"
6337994689c1Smrg		deplibs="$deplib $deplibs"
6338994689c1Smrg	      fi
6339994689c1Smrg	      ;;
6340994689c1Smrg	    esac
6341994689c1Smrg	    continue
6342994689c1Smrg	    ;;
6343994689c1Smrg	  prog)
6344994689c1Smrg	    if test "$pass" != link; then
6345994689c1Smrg	      deplibs="$deplib $deplibs"
6346994689c1Smrg	    else
6347994689c1Smrg	      compile_deplibs="$deplib $compile_deplibs"
6348994689c1Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
6349994689c1Smrg	    fi
6350994689c1Smrg	    continue
6351994689c1Smrg	    ;;
6352994689c1Smrg	  esac # linkmode
6353994689c1Smrg	  ;; # *.$libext
6354994689c1Smrg	*.lo | *.$objext)
6355994689c1Smrg	  if test "$pass" = conv; then
6356994689c1Smrg	    deplibs="$deplib $deplibs"
6357994689c1Smrg	  elif test "$linkmode" = prog; then
6358994689c1Smrg	    if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
6359994689c1Smrg	      # If there is no dlopen support or we're linking statically,
6360994689c1Smrg	      # we need to preload.
6361f353fbadSmrg	      func_append newdlprefiles " $deplib"
6362994689c1Smrg	      compile_deplibs="$deplib $compile_deplibs"
6363994689c1Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
6364994689c1Smrg	    else
6365f353fbadSmrg	      func_append newdlfiles " $deplib"
6366994689c1Smrg	    fi
6367994689c1Smrg	  fi
6368994689c1Smrg	  continue
6369994689c1Smrg	  ;;
6370994689c1Smrg	%DEPLIBS%)
6371994689c1Smrg	  alldeplibs=yes
6372994689c1Smrg	  continue
6373994689c1Smrg	  ;;
6374994689c1Smrg	esac # case $deplib
6375994689c1Smrg
6376994689c1Smrg	if test "$found" = yes || test -f "$lib"; then :
6377994689c1Smrg	else
6378994689c1Smrg	  func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'"
6379994689c1Smrg	fi
6380994689c1Smrg
6381994689c1Smrg	# Check to see that this really is a libtool archive.
6382994689c1Smrg	func_lalib_unsafe_p "$lib" \
6383994689c1Smrg	  || func_fatal_error "\`$lib' is not a valid libtool archive"
6384994689c1Smrg
6385994689c1Smrg	func_dirname "$lib" "" "."
6386994689c1Smrg	ladir="$func_dirname_result"
6387994689c1Smrg
6388994689c1Smrg	dlname=
6389994689c1Smrg	dlopen=
6390994689c1Smrg	dlpreopen=
6391994689c1Smrg	libdir=
6392994689c1Smrg	library_names=
6393994689c1Smrg	old_library=
6394994689c1Smrg	inherited_linker_flags=
6395994689c1Smrg	# If the library was installed with an old release of libtool,
6396994689c1Smrg	# it will not redefine variables installed, or shouldnotlink
6397994689c1Smrg	installed=yes
6398994689c1Smrg	shouldnotlink=no
6399994689c1Smrg	avoidtemprpath=
6400994689c1Smrg
6401994689c1Smrg
6402994689c1Smrg	# Read the .la file
6403994689c1Smrg	func_source "$lib"
6404994689c1Smrg
6405994689c1Smrg	# Convert "-framework foo" to "foo.ltframework"
6406994689c1Smrg	if test -n "$inherited_linker_flags"; then
6407994689c1Smrg	  tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
6408994689c1Smrg	  for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
6409994689c1Smrg	    case " $new_inherited_linker_flags " in
6410994689c1Smrg	      *" $tmp_inherited_linker_flag "*) ;;
6411f353fbadSmrg	      *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";;
6412994689c1Smrg	    esac
6413994689c1Smrg	  done
6414994689c1Smrg	fi
6415994689c1Smrg	dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
6416994689c1Smrg	if test "$linkmode,$pass" = "lib,link" ||
6417994689c1Smrg	   test "$linkmode,$pass" = "prog,scan" ||
6418994689c1Smrg	   { test "$linkmode" != prog && test "$linkmode" != lib; }; then
6419f353fbadSmrg	  test -n "$dlopen" && func_append dlfiles " $dlopen"
6420f353fbadSmrg	  test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen"
6421994689c1Smrg	fi
6422994689c1Smrg
6423994689c1Smrg	if test "$pass" = conv; then
6424994689c1Smrg	  # Only check for convenience libraries
6425994689c1Smrg	  deplibs="$lib $deplibs"
6426994689c1Smrg	  if test -z "$libdir"; then
6427994689c1Smrg	    if test -z "$old_library"; then
6428994689c1Smrg	      func_fatal_error "cannot find name of link library for \`$lib'"
6429994689c1Smrg	    fi
6430994689c1Smrg	    # It is a libtool convenience library, so add in its objects.
6431f353fbadSmrg	    func_append convenience " $ladir/$objdir/$old_library"
6432f353fbadSmrg	    func_append old_convenience " $ladir/$objdir/$old_library"
6433994689c1Smrg	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
6434994689c1Smrg	    func_fatal_error "\`$lib' is not a convenience library"
6435994689c1Smrg	  fi
6436994689c1Smrg	  tmp_libs=
6437994689c1Smrg	  for deplib in $dependency_libs; do
6438994689c1Smrg	    deplibs="$deplib $deplibs"
6439f353fbadSmrg	    if $opt_preserve_dup_deps ; then
6440994689c1Smrg	      case "$tmp_libs " in
6441f353fbadSmrg	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
6442994689c1Smrg	      esac
6443994689c1Smrg	    fi
6444f353fbadSmrg	    func_append tmp_libs " $deplib"
6445994689c1Smrg	  done
6446994689c1Smrg	  continue
6447994689c1Smrg	fi # $pass = conv
6448994689c1Smrg
6449994689c1Smrg
6450994689c1Smrg	# Get the name of the library we link against.
6451994689c1Smrg	linklib=
6452f353fbadSmrg	if test -n "$old_library" &&
6453f353fbadSmrg	   { test "$prefer_static_libs" = yes ||
6454f353fbadSmrg	     test "$prefer_static_libs,$installed" = "built,no"; }; then
6455f353fbadSmrg	  linklib=$old_library
6456f353fbadSmrg	else
6457f353fbadSmrg	  for l in $old_library $library_names; do
6458f353fbadSmrg	    linklib="$l"
6459f353fbadSmrg	  done
6460f353fbadSmrg	fi
6461994689c1Smrg	if test -z "$linklib"; then
6462994689c1Smrg	  func_fatal_error "cannot find name of link library for \`$lib'"
6463994689c1Smrg	fi
6464994689c1Smrg
6465994689c1Smrg	# This library was specified with -dlopen.
6466994689c1Smrg	if test "$pass" = dlopen; then
6467994689c1Smrg	  if test -z "$libdir"; then
6468994689c1Smrg	    func_fatal_error "cannot -dlopen a convenience library: \`$lib'"
6469994689c1Smrg	  fi
6470994689c1Smrg	  if test -z "$dlname" ||
6471994689c1Smrg	     test "$dlopen_support" != yes ||
6472994689c1Smrg	     test "$build_libtool_libs" = no; then
6473994689c1Smrg	    # If there is no dlname, no dlopen support or we're linking
6474994689c1Smrg	    # statically, we need to preload.  We also need to preload any
6475994689c1Smrg	    # dependent libraries so libltdl's deplib preloader doesn't
6476994689c1Smrg	    # bomb out in the load deplibs phase.
6477f353fbadSmrg	    func_append dlprefiles " $lib $dependency_libs"
6478994689c1Smrg	  else
6479f353fbadSmrg	    func_append newdlfiles " $lib"
6480994689c1Smrg	  fi
6481994689c1Smrg	  continue
6482994689c1Smrg	fi # $pass = dlopen
6483994689c1Smrg
6484994689c1Smrg	# We need an absolute path.
6485994689c1Smrg	case $ladir in
6486994689c1Smrg	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
6487994689c1Smrg	*)
6488994689c1Smrg	  abs_ladir=`cd "$ladir" && pwd`
6489994689c1Smrg	  if test -z "$abs_ladir"; then
6490994689c1Smrg	    func_warning "cannot determine absolute directory name of \`$ladir'"
6491994689c1Smrg	    func_warning "passing it literally to the linker, although it might fail"
6492994689c1Smrg	    abs_ladir="$ladir"
6493994689c1Smrg	  fi
6494994689c1Smrg	  ;;
6495994689c1Smrg	esac
6496994689c1Smrg	func_basename "$lib"
6497994689c1Smrg	laname="$func_basename_result"
6498994689c1Smrg
6499994689c1Smrg	# Find the relevant object directory and library name.
6500994689c1Smrg	if test "X$installed" = Xyes; then
6501f353fbadSmrg	  if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
6502994689c1Smrg	    func_warning "library \`$lib' was moved."
6503994689c1Smrg	    dir="$ladir"
6504994689c1Smrg	    absdir="$abs_ladir"
6505994689c1Smrg	    libdir="$abs_ladir"
6506994689c1Smrg	  else
6507f353fbadSmrg	    dir="$lt_sysroot$libdir"
6508f353fbadSmrg	    absdir="$lt_sysroot$libdir"
6509994689c1Smrg	  fi
6510994689c1Smrg	  test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
6511994689c1Smrg	else
6512994689c1Smrg	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
6513994689c1Smrg	    dir="$ladir"
6514994689c1Smrg	    absdir="$abs_ladir"
6515994689c1Smrg	    # Remove this search path later
6516f353fbadSmrg	    func_append notinst_path " $abs_ladir"
6517994689c1Smrg	  else
6518994689c1Smrg	    dir="$ladir/$objdir"
6519994689c1Smrg	    absdir="$abs_ladir/$objdir"
6520994689c1Smrg	    # Remove this search path later
6521f353fbadSmrg	    func_append notinst_path " $abs_ladir"
6522994689c1Smrg	  fi
6523994689c1Smrg	fi # $installed = yes
6524994689c1Smrg	func_stripname 'lib' '.la' "$laname"
6525994689c1Smrg	name=$func_stripname_result
6526994689c1Smrg
6527994689c1Smrg	# This library was specified with -dlpreopen.
6528994689c1Smrg	if test "$pass" = dlpreopen; then
6529994689c1Smrg	  if test -z "$libdir" && test "$linkmode" = prog; then
6530994689c1Smrg	    func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'"
6531994689c1Smrg	  fi
6532f353fbadSmrg	  case "$host" in
6533f353fbadSmrg	    # special handling for platforms with PE-DLLs.
6534f353fbadSmrg	    *cygwin* | *mingw* | *cegcc* )
6535f353fbadSmrg	      # Linker will automatically link against shared library if both
6536f353fbadSmrg	      # static and shared are present.  Therefore, ensure we extract
6537f353fbadSmrg	      # symbols from the import library if a shared library is present
6538f353fbadSmrg	      # (otherwise, the dlopen module name will be incorrect).  We do
6539f353fbadSmrg	      # this by putting the import library name into $newdlprefiles.
6540f353fbadSmrg	      # We recover the dlopen module name by 'saving' the la file
6541f353fbadSmrg	      # name in a special purpose variable, and (later) extracting the
6542f353fbadSmrg	      # dlname from the la file.
6543f353fbadSmrg	      if test -n "$dlname"; then
6544f353fbadSmrg	        func_tr_sh "$dir/$linklib"
6545f353fbadSmrg	        eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname"
6546f353fbadSmrg	        func_append newdlprefiles " $dir/$linklib"
6547f353fbadSmrg	      else
6548f353fbadSmrg	        func_append newdlprefiles " $dir/$old_library"
6549f353fbadSmrg	        # Keep a list of preopened convenience libraries to check
6550f353fbadSmrg	        # that they are being used correctly in the link pass.
6551f353fbadSmrg	        test -z "$libdir" && \
6552f353fbadSmrg	          func_append dlpreconveniencelibs " $dir/$old_library"
6553f353fbadSmrg	      fi
6554f353fbadSmrg	    ;;
6555f353fbadSmrg	    * )
6556f353fbadSmrg	      # Prefer using a static library (so that no silly _DYNAMIC symbols
6557f353fbadSmrg	      # are required to link).
6558f353fbadSmrg	      if test -n "$old_library"; then
6559f353fbadSmrg	        func_append newdlprefiles " $dir/$old_library"
6560f353fbadSmrg	        # Keep a list of preopened convenience libraries to check
6561f353fbadSmrg	        # that they are being used correctly in the link pass.
6562f353fbadSmrg	        test -z "$libdir" && \
6563f353fbadSmrg	          func_append dlpreconveniencelibs " $dir/$old_library"
6564f353fbadSmrg	      # Otherwise, use the dlname, so that lt_dlopen finds it.
6565f353fbadSmrg	      elif test -n "$dlname"; then
6566f353fbadSmrg	        func_append newdlprefiles " $dir/$dlname"
6567f353fbadSmrg	      else
6568f353fbadSmrg	        func_append newdlprefiles " $dir/$linklib"
6569f353fbadSmrg	      fi
6570f353fbadSmrg	    ;;
6571f353fbadSmrg	  esac
6572994689c1Smrg	fi # $pass = dlpreopen
6573994689c1Smrg
6574994689c1Smrg	if test -z "$libdir"; then
6575994689c1Smrg	  # Link the convenience library
6576994689c1Smrg	  if test "$linkmode" = lib; then
6577994689c1Smrg	    deplibs="$dir/$old_library $deplibs"
6578994689c1Smrg	  elif test "$linkmode,$pass" = "prog,link"; then
6579994689c1Smrg	    compile_deplibs="$dir/$old_library $compile_deplibs"
6580994689c1Smrg	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
6581994689c1Smrg	  else
6582994689c1Smrg	    deplibs="$lib $deplibs" # used for prog,scan pass
6583994689c1Smrg	  fi
6584994689c1Smrg	  continue
6585994689c1Smrg	fi
6586994689c1Smrg
6587994689c1Smrg
6588994689c1Smrg	if test "$linkmode" = prog && test "$pass" != link; then
6589f353fbadSmrg	  func_append newlib_search_path " $ladir"
6590994689c1Smrg	  deplibs="$lib $deplibs"
6591994689c1Smrg
6592994689c1Smrg	  linkalldeplibs=no
6593994689c1Smrg	  if test "$link_all_deplibs" != no || test -z "$library_names" ||
6594994689c1Smrg	     test "$build_libtool_libs" = no; then
6595994689c1Smrg	    linkalldeplibs=yes
6596994689c1Smrg	  fi
6597994689c1Smrg
6598994689c1Smrg	  tmp_libs=
6599994689c1Smrg	  for deplib in $dependency_libs; do
6600994689c1Smrg	    case $deplib in
6601994689c1Smrg	    -L*) func_stripname '-L' '' "$deplib"
6602f353fbadSmrg	         func_resolve_sysroot "$func_stripname_result"
6603f353fbadSmrg	         func_append newlib_search_path " $func_resolve_sysroot_result"
6604994689c1Smrg		 ;;
6605994689c1Smrg	    esac
6606994689c1Smrg	    # Need to link against all dependency_libs?
6607994689c1Smrg	    if test "$linkalldeplibs" = yes; then
6608994689c1Smrg	      deplibs="$deplib $deplibs"
6609994689c1Smrg	    else
6610994689c1Smrg	      # Need to hardcode shared library paths
6611994689c1Smrg	      # or/and link against static libraries
6612994689c1Smrg	      newdependency_libs="$deplib $newdependency_libs"
6613994689c1Smrg	    fi
6614f353fbadSmrg	    if $opt_preserve_dup_deps ; then
6615994689c1Smrg	      case "$tmp_libs " in
6616f353fbadSmrg	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
6617994689c1Smrg	      esac
6618994689c1Smrg	    fi
6619f353fbadSmrg	    func_append tmp_libs " $deplib"
6620994689c1Smrg	  done # for deplib
6621994689c1Smrg	  continue
6622994689c1Smrg	fi # $linkmode = prog...
6623994689c1Smrg
6624994689c1Smrg	if test "$linkmode,$pass" = "prog,link"; then
6625994689c1Smrg	  if test -n "$library_names" &&
6626994689c1Smrg	     { { test "$prefer_static_libs" = no ||
6627994689c1Smrg	         test "$prefer_static_libs,$installed" = "built,yes"; } ||
6628994689c1Smrg	       test -z "$old_library"; }; then
6629994689c1Smrg	    # We need to hardcode the library path
6630994689c1Smrg	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
6631994689c1Smrg	      # Make sure the rpath contains only unique directories.
6632994689c1Smrg	      case "$temp_rpath:" in
6633994689c1Smrg	      *"$absdir:"*) ;;
6634f353fbadSmrg	      *) func_append temp_rpath "$absdir:" ;;
6635994689c1Smrg	      esac
6636994689c1Smrg	    fi
6637994689c1Smrg
6638994689c1Smrg	    # Hardcode the library path.
6639994689c1Smrg	    # Skip directories that are in the system default run-time
6640994689c1Smrg	    # search path.
6641994689c1Smrg	    case " $sys_lib_dlsearch_path " in
6642994689c1Smrg	    *" $absdir "*) ;;
6643994689c1Smrg	    *)
6644994689c1Smrg	      case "$compile_rpath " in
6645994689c1Smrg	      *" $absdir "*) ;;
6646f353fbadSmrg	      *) func_append compile_rpath " $absdir" ;;
6647994689c1Smrg	      esac
6648994689c1Smrg	      ;;
6649994689c1Smrg	    esac
6650994689c1Smrg	    case " $sys_lib_dlsearch_path " in
6651994689c1Smrg	    *" $libdir "*) ;;
6652994689c1Smrg	    *)
6653994689c1Smrg	      case "$finalize_rpath " in
6654994689c1Smrg	      *" $libdir "*) ;;
6655f353fbadSmrg	      *) func_append finalize_rpath " $libdir" ;;
6656994689c1Smrg	      esac
6657994689c1Smrg	      ;;
6658994689c1Smrg	    esac
6659994689c1Smrg	  fi # $linkmode,$pass = prog,link...
6660994689c1Smrg
6661994689c1Smrg	  if test "$alldeplibs" = yes &&
6662994689c1Smrg	     { test "$deplibs_check_method" = pass_all ||
6663994689c1Smrg	       { test "$build_libtool_libs" = yes &&
6664994689c1Smrg		 test -n "$library_names"; }; }; then
6665994689c1Smrg	    # We only need to search for static libraries
6666994689c1Smrg	    continue
6667994689c1Smrg	  fi
6668994689c1Smrg	fi
6669994689c1Smrg
6670994689c1Smrg	link_static=no # Whether the deplib will be linked statically
6671994689c1Smrg	use_static_libs=$prefer_static_libs
6672994689c1Smrg	if test "$use_static_libs" = built && test "$installed" = yes; then
6673994689c1Smrg	  use_static_libs=no
6674994689c1Smrg	fi
6675994689c1Smrg	if test -n "$library_names" &&
6676994689c1Smrg	   { test "$use_static_libs" = no || test -z "$old_library"; }; then
6677994689c1Smrg	  case $host in
6678994689c1Smrg	  *cygwin* | *mingw* | *cegcc*)
6679994689c1Smrg	      # No point in relinking DLLs because paths are not encoded
6680f353fbadSmrg	      func_append notinst_deplibs " $lib"
6681994689c1Smrg	      need_relink=no
6682994689c1Smrg	    ;;
6683994689c1Smrg	  *)
6684994689c1Smrg	    if test "$installed" = no; then
6685f353fbadSmrg	      func_append notinst_deplibs " $lib"
6686994689c1Smrg	      need_relink=yes
6687994689c1Smrg	    fi
6688994689c1Smrg	    ;;
6689994689c1Smrg	  esac
6690994689c1Smrg	  # This is a shared library
6691994689c1Smrg
6692994689c1Smrg	  # Warn about portability, can't link against -module's on some
6693994689c1Smrg	  # systems (darwin).  Don't bleat about dlopened modules though!
6694994689c1Smrg	  dlopenmodule=""
6695994689c1Smrg	  for dlpremoduletest in $dlprefiles; do
6696994689c1Smrg	    if test "X$dlpremoduletest" = "X$lib"; then
6697994689c1Smrg	      dlopenmodule="$dlpremoduletest"
6698994689c1Smrg	      break
6699994689c1Smrg	    fi
6700994689c1Smrg	  done
6701994689c1Smrg	  if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then
6702994689c1Smrg	    echo
6703994689c1Smrg	    if test "$linkmode" = prog; then
6704994689c1Smrg	      $ECHO "*** Warning: Linking the executable $output against the loadable module"
6705994689c1Smrg	    else
6706994689c1Smrg	      $ECHO "*** Warning: Linking the shared library $output against the loadable module"
6707994689c1Smrg	    fi
6708994689c1Smrg	    $ECHO "*** $linklib is not portable!"
6709994689c1Smrg	  fi
6710994689c1Smrg	  if test "$linkmode" = lib &&
6711994689c1Smrg	     test "$hardcode_into_libs" = yes; then
6712994689c1Smrg	    # Hardcode the library path.
6713994689c1Smrg	    # Skip directories that are in the system default run-time
6714994689c1Smrg	    # search path.
6715994689c1Smrg	    case " $sys_lib_dlsearch_path " in
6716994689c1Smrg	    *" $absdir "*) ;;
6717994689c1Smrg	    *)
6718994689c1Smrg	      case "$compile_rpath " in
6719994689c1Smrg	      *" $absdir "*) ;;
6720f353fbadSmrg	      *) func_append compile_rpath " $absdir" ;;
6721994689c1Smrg	      esac
6722994689c1Smrg	      ;;
6723994689c1Smrg	    esac
6724994689c1Smrg	    case " $sys_lib_dlsearch_path " in
6725994689c1Smrg	    *" $libdir "*) ;;
6726994689c1Smrg	    *)
6727994689c1Smrg	      case "$finalize_rpath " in
6728994689c1Smrg	      *" $libdir "*) ;;
6729f353fbadSmrg	      *) func_append finalize_rpath " $libdir" ;;
6730994689c1Smrg	      esac
6731994689c1Smrg	      ;;
6732994689c1Smrg	    esac
6733994689c1Smrg	  fi
6734994689c1Smrg
6735994689c1Smrg	  if test -n "$old_archive_from_expsyms_cmds"; then
6736994689c1Smrg	    # figure out the soname
6737994689c1Smrg	    set dummy $library_names
6738994689c1Smrg	    shift
6739994689c1Smrg	    realname="$1"
6740994689c1Smrg	    shift
6741994689c1Smrg	    libname=`eval "\\$ECHO \"$libname_spec\""`
6742994689c1Smrg	    # use dlname if we got it. it's perfectly good, no?
6743994689c1Smrg	    if test -n "$dlname"; then
6744994689c1Smrg	      soname="$dlname"
6745994689c1Smrg	    elif test -n "$soname_spec"; then
6746994689c1Smrg	      # bleh windows
6747994689c1Smrg	      case $host in
6748994689c1Smrg	      *cygwin* | mingw* | *cegcc*)
6749994689c1Smrg	        func_arith $current - $age
6750994689c1Smrg		major=$func_arith_result
6751994689c1Smrg		versuffix="-$major"
6752994689c1Smrg		;;
6753994689c1Smrg	      esac
6754994689c1Smrg	      eval soname=\"$soname_spec\"
6755994689c1Smrg	    else
6756994689c1Smrg	      soname="$realname"
6757994689c1Smrg	    fi
6758994689c1Smrg
6759994689c1Smrg	    # Make a new name for the extract_expsyms_cmds to use
6760994689c1Smrg	    soroot="$soname"
6761994689c1Smrg	    func_basename "$soroot"
6762994689c1Smrg	    soname="$func_basename_result"
6763994689c1Smrg	    func_stripname 'lib' '.dll' "$soname"
6764994689c1Smrg	    newlib=libimp-$func_stripname_result.a
6765994689c1Smrg
6766994689c1Smrg	    # If the library has no export list, then create one now
6767994689c1Smrg	    if test -f "$output_objdir/$soname-def"; then :
6768994689c1Smrg	    else
6769994689c1Smrg	      func_verbose "extracting exported symbol list from \`$soname'"
6770994689c1Smrg	      func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
6771994689c1Smrg	    fi
6772994689c1Smrg
6773994689c1Smrg	    # Create $newlib
6774994689c1Smrg	    if test -f "$output_objdir/$newlib"; then :; else
6775994689c1Smrg	      func_verbose "generating import library for \`$soname'"
6776994689c1Smrg	      func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
6777994689c1Smrg	    fi
6778994689c1Smrg	    # make sure the library variables are pointing to the new library
6779994689c1Smrg	    dir=$output_objdir
6780994689c1Smrg	    linklib=$newlib
6781994689c1Smrg	  fi # test -n "$old_archive_from_expsyms_cmds"
6782994689c1Smrg
6783f353fbadSmrg	  if test "$linkmode" = prog || test "$opt_mode" != relink; then
6784994689c1Smrg	    add_shlibpath=
6785994689c1Smrg	    add_dir=
6786994689c1Smrg	    add=
6787994689c1Smrg	    lib_linked=yes
6788994689c1Smrg	    case $hardcode_action in
6789994689c1Smrg	    immediate | unsupported)
6790994689c1Smrg	      if test "$hardcode_direct" = no; then
6791994689c1Smrg		add="$dir/$linklib"
6792994689c1Smrg		case $host in
6793994689c1Smrg		  *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
6794994689c1Smrg		  *-*-sysv4*uw2*) add_dir="-L$dir" ;;
6795994689c1Smrg		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
6796994689c1Smrg		    *-*-unixware7*) add_dir="-L$dir" ;;
6797994689c1Smrg		  *-*-darwin* )
6798994689c1Smrg		    # if the lib is a (non-dlopened) module then we can not
6799994689c1Smrg		    # link against it, someone is ignoring the earlier warnings
6800994689c1Smrg		    if /usr/bin/file -L $add 2> /dev/null |
6801994689c1Smrg			 $GREP ": [^:]* bundle" >/dev/null ; then
6802994689c1Smrg		      if test "X$dlopenmodule" != "X$lib"; then
6803994689c1Smrg			$ECHO "*** Warning: lib $linklib is a module, not a shared library"
6804994689c1Smrg			if test -z "$old_library" ; then
6805994689c1Smrg			  echo
6806994689c1Smrg			  echo "*** And there doesn't seem to be a static archive available"
6807994689c1Smrg			  echo "*** The link will probably fail, sorry"
6808994689c1Smrg			else
6809994689c1Smrg			  add="$dir/$old_library"
6810994689c1Smrg			fi
6811994689c1Smrg		      elif test -n "$old_library"; then
6812994689c1Smrg			add="$dir/$old_library"
6813994689c1Smrg		      fi
6814994689c1Smrg		    fi
6815994689c1Smrg		esac
6816994689c1Smrg	      elif test "$hardcode_minus_L" = no; then
6817994689c1Smrg		case $host in
6818994689c1Smrg		*-*-sunos*) add_shlibpath="$dir" ;;
6819994689c1Smrg		esac
6820994689c1Smrg		add_dir="-L$dir"
6821994689c1Smrg		add="-l$name"
6822994689c1Smrg	      elif test "$hardcode_shlibpath_var" = no; then
6823994689c1Smrg		add_shlibpath="$dir"
6824994689c1Smrg		add="-l$name"
6825994689c1Smrg	      else
6826994689c1Smrg		lib_linked=no
6827994689c1Smrg	      fi
6828994689c1Smrg	      ;;
6829994689c1Smrg	    relink)
6830994689c1Smrg	      if test "$hardcode_direct" = yes &&
6831994689c1Smrg	         test "$hardcode_direct_absolute" = no; then
6832994689c1Smrg		add="$dir/$linklib"
6833994689c1Smrg	      elif test "$hardcode_minus_L" = yes; then
6834994689c1Smrg		add_dir="-L$dir"
6835994689c1Smrg		# Try looking first in the location we're being installed to.
6836994689c1Smrg		if test -n "$inst_prefix_dir"; then
6837994689c1Smrg		  case $libdir in
6838994689c1Smrg		    [\\/]*)
6839f353fbadSmrg		      func_append add_dir " -L$inst_prefix_dir$libdir"
6840994689c1Smrg		      ;;
6841994689c1Smrg		  esac
6842994689c1Smrg		fi
6843994689c1Smrg		add="-l$name"
6844994689c1Smrg	      elif test "$hardcode_shlibpath_var" = yes; then
6845994689c1Smrg		add_shlibpath="$dir"
6846994689c1Smrg		add="-l$name"
6847994689c1Smrg	      else
6848994689c1Smrg		lib_linked=no
6849994689c1Smrg	      fi
6850994689c1Smrg	      ;;
6851994689c1Smrg	    *) lib_linked=no ;;
6852994689c1Smrg	    esac
6853994689c1Smrg
6854994689c1Smrg	    if test "$lib_linked" != yes; then
6855994689c1Smrg	      func_fatal_configuration "unsupported hardcode properties"
6856994689c1Smrg	    fi
6857994689c1Smrg
6858994689c1Smrg	    if test -n "$add_shlibpath"; then
6859994689c1Smrg	      case :$compile_shlibpath: in
6860994689c1Smrg	      *":$add_shlibpath:"*) ;;
6861f353fbadSmrg	      *) func_append compile_shlibpath "$add_shlibpath:" ;;
6862994689c1Smrg	      esac
6863994689c1Smrg	    fi
6864994689c1Smrg	    if test "$linkmode" = prog; then
6865994689c1Smrg	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
6866994689c1Smrg	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
6867994689c1Smrg	    else
6868994689c1Smrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
6869994689c1Smrg	      test -n "$add" && deplibs="$add $deplibs"
6870994689c1Smrg	      if test "$hardcode_direct" != yes &&
6871994689c1Smrg		 test "$hardcode_minus_L" != yes &&
6872994689c1Smrg		 test "$hardcode_shlibpath_var" = yes; then
6873994689c1Smrg		case :$finalize_shlibpath: in
6874994689c1Smrg		*":$libdir:"*) ;;
6875f353fbadSmrg		*) func_append finalize_shlibpath "$libdir:" ;;
6876994689c1Smrg		esac
6877994689c1Smrg	      fi
6878994689c1Smrg	    fi
6879994689c1Smrg	  fi
6880994689c1Smrg
6881f353fbadSmrg	  if test "$linkmode" = prog || test "$opt_mode" = relink; then
6882994689c1Smrg	    add_shlibpath=
6883994689c1Smrg	    add_dir=
6884994689c1Smrg	    add=
6885994689c1Smrg	    # Finalize command for both is simple: just hardcode it.
6886994689c1Smrg	    if test "$hardcode_direct" = yes &&
6887994689c1Smrg	       test "$hardcode_direct_absolute" = no; then
6888994689c1Smrg	      add="$libdir/$linklib"
6889994689c1Smrg	    elif test "$hardcode_minus_L" = yes; then
6890994689c1Smrg	      add_dir="-L$libdir"
6891994689c1Smrg	      add="-l$name"
6892994689c1Smrg	    elif test "$hardcode_shlibpath_var" = yes; then
6893994689c1Smrg	      case :$finalize_shlibpath: in
6894994689c1Smrg	      *":$libdir:"*) ;;
6895f353fbadSmrg	      *) func_append finalize_shlibpath "$libdir:" ;;
6896994689c1Smrg	      esac
6897994689c1Smrg	      add="-l$name"
6898994689c1Smrg	    elif test "$hardcode_automatic" = yes; then
6899994689c1Smrg	      if test -n "$inst_prefix_dir" &&
6900994689c1Smrg		 test -f "$inst_prefix_dir$libdir/$linklib" ; then
6901994689c1Smrg		add="$inst_prefix_dir$libdir/$linklib"
6902994689c1Smrg	      else
6903994689c1Smrg		add="$libdir/$linklib"
6904994689c1Smrg	      fi
6905994689c1Smrg	    else
6906994689c1Smrg	      # We cannot seem to hardcode it, guess we'll fake it.
6907994689c1Smrg	      add_dir="-L$libdir"
6908994689c1Smrg	      # Try looking first in the location we're being installed to.
6909994689c1Smrg	      if test -n "$inst_prefix_dir"; then
6910994689c1Smrg		case $libdir in
6911994689c1Smrg		  [\\/]*)
6912f353fbadSmrg		    func_append add_dir " -L$inst_prefix_dir$libdir"
6913994689c1Smrg		    ;;
6914994689c1Smrg		esac
6915994689c1Smrg	      fi
6916994689c1Smrg	      add="-l$name"
6917994689c1Smrg	    fi
6918994689c1Smrg
6919994689c1Smrg	    if test "$linkmode" = prog; then
6920994689c1Smrg	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
6921994689c1Smrg	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
6922994689c1Smrg	    else
6923994689c1Smrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
6924994689c1Smrg	      test -n "$add" && deplibs="$add $deplibs"
6925994689c1Smrg	    fi
6926994689c1Smrg	  fi
6927994689c1Smrg	elif test "$linkmode" = prog; then
6928994689c1Smrg	  # Here we assume that one of hardcode_direct or hardcode_minus_L
6929994689c1Smrg	  # is not unsupported.  This is valid on all known static and
6930994689c1Smrg	  # shared platforms.
6931994689c1Smrg	  if test "$hardcode_direct" != unsupported; then
6932994689c1Smrg	    test -n "$old_library" && linklib="$old_library"
6933994689c1Smrg	    compile_deplibs="$dir/$linklib $compile_deplibs"
6934994689c1Smrg	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
6935994689c1Smrg	  else
6936994689c1Smrg	    compile_deplibs="-l$name -L$dir $compile_deplibs"
6937994689c1Smrg	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
6938994689c1Smrg	  fi
6939994689c1Smrg	elif test "$build_libtool_libs" = yes; then
6940994689c1Smrg	  # Not a shared library
6941994689c1Smrg	  if test "$deplibs_check_method" != pass_all; then
6942994689c1Smrg	    # We're trying link a shared library against a static one
6943994689c1Smrg	    # but the system doesn't support it.
6944994689c1Smrg
6945994689c1Smrg	    # Just print a warning and add the library to dependency_libs so
6946994689c1Smrg	    # that the program can be linked against the static library.
6947994689c1Smrg	    echo
6948994689c1Smrg	    $ECHO "*** Warning: This system can not link to static lib archive $lib."
6949994689c1Smrg	    echo "*** I have the capability to make that library automatically link in when"
6950994689c1Smrg	    echo "*** you link to this library.  But I can only do this if you have a"
6951994689c1Smrg	    echo "*** shared version of the library, which you do not appear to have."
6952994689c1Smrg	    if test "$module" = yes; then
6953994689c1Smrg	      echo "*** But as you try to build a module library, libtool will still create "
6954994689c1Smrg	      echo "*** a static module, that should work as long as the dlopening application"
6955994689c1Smrg	      echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
6956994689c1Smrg	      if test -z "$global_symbol_pipe"; then
6957994689c1Smrg		echo
6958994689c1Smrg		echo "*** However, this would only work if libtool was able to extract symbol"
6959994689c1Smrg		echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
6960994689c1Smrg		echo "*** not find such a program.  So, this module is probably useless."
6961994689c1Smrg		echo "*** \`nm' from GNU binutils and a full rebuild may help."
6962994689c1Smrg	      fi
6963994689c1Smrg	      if test "$build_old_libs" = no; then
6964994689c1Smrg		build_libtool_libs=module
6965994689c1Smrg		build_old_libs=yes
6966994689c1Smrg	      else
6967994689c1Smrg		build_libtool_libs=no
6968994689c1Smrg	      fi
6969994689c1Smrg	    fi
6970994689c1Smrg	  else
6971994689c1Smrg	    deplibs="$dir/$old_library $deplibs"
6972994689c1Smrg	    link_static=yes
6973994689c1Smrg	  fi
6974994689c1Smrg	fi # link shared/static library?
6975994689c1Smrg
6976994689c1Smrg	if test "$linkmode" = lib; then
6977994689c1Smrg	  if test -n "$dependency_libs" &&
6978994689c1Smrg	     { test "$hardcode_into_libs" != yes ||
6979994689c1Smrg	       test "$build_old_libs" = yes ||
6980994689c1Smrg	       test "$link_static" = yes; }; then
6981994689c1Smrg	    # Extract -R from dependency_libs
6982994689c1Smrg	    temp_deplibs=
6983994689c1Smrg	    for libdir in $dependency_libs; do
6984994689c1Smrg	      case $libdir in
6985994689c1Smrg	      -R*) func_stripname '-R' '' "$libdir"
6986994689c1Smrg	           temp_xrpath=$func_stripname_result
6987994689c1Smrg		   case " $xrpath " in
6988994689c1Smrg		   *" $temp_xrpath "*) ;;
6989f353fbadSmrg		   *) func_append xrpath " $temp_xrpath";;
6990994689c1Smrg		   esac;;
6991f353fbadSmrg	      *) func_append temp_deplibs " $libdir";;
6992994689c1Smrg	      esac
6993994689c1Smrg	    done
6994994689c1Smrg	    dependency_libs="$temp_deplibs"
6995994689c1Smrg	  fi
6996994689c1Smrg
6997f353fbadSmrg	  func_append newlib_search_path " $absdir"
6998994689c1Smrg	  # Link against this library
6999994689c1Smrg	  test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
7000994689c1Smrg	  # ... and its dependency_libs
7001994689c1Smrg	  tmp_libs=
7002994689c1Smrg	  for deplib in $dependency_libs; do
7003994689c1Smrg	    newdependency_libs="$deplib $newdependency_libs"
7004f353fbadSmrg	    case $deplib in
7005f353fbadSmrg              -L*) func_stripname '-L' '' "$deplib"
7006f353fbadSmrg                   func_resolve_sysroot "$func_stripname_result";;
7007f353fbadSmrg              *) func_resolve_sysroot "$deplib" ;;
7008f353fbadSmrg            esac
7009f353fbadSmrg	    if $opt_preserve_dup_deps ; then
7010994689c1Smrg	      case "$tmp_libs " in
7011f353fbadSmrg	      *" $func_resolve_sysroot_result "*)
7012f353fbadSmrg                func_append specialdeplibs " $func_resolve_sysroot_result" ;;
7013994689c1Smrg	      esac
7014994689c1Smrg	    fi
7015f353fbadSmrg	    func_append tmp_libs " $func_resolve_sysroot_result"
7016994689c1Smrg	  done
7017994689c1Smrg
7018994689c1Smrg	  if test "$link_all_deplibs" != no; then
7019994689c1Smrg	    # Add the search paths of all dependency libraries
7020994689c1Smrg	    for deplib in $dependency_libs; do
7021994689c1Smrg	      path=
7022994689c1Smrg	      case $deplib in
7023994689c1Smrg	      -L*) path="$deplib" ;;
7024994689c1Smrg	      *.la)
7025f353fbadSmrg	        func_resolve_sysroot "$deplib"
7026f353fbadSmrg	        deplib=$func_resolve_sysroot_result
7027994689c1Smrg	        func_dirname "$deplib" "" "."
7028f353fbadSmrg		dir=$func_dirname_result
7029994689c1Smrg		# We need an absolute path.
7030994689c1Smrg		case $dir in
7031994689c1Smrg		[\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
7032994689c1Smrg		*)
7033994689c1Smrg		  absdir=`cd "$dir" && pwd`
7034994689c1Smrg		  if test -z "$absdir"; then
7035994689c1Smrg		    func_warning "cannot determine absolute directory name of \`$dir'"
7036994689c1Smrg		    absdir="$dir"
7037994689c1Smrg		  fi
7038994689c1Smrg		  ;;
7039994689c1Smrg		esac
7040994689c1Smrg		if $GREP "^installed=no" $deplib > /dev/null; then
7041994689c1Smrg		case $host in
7042994689c1Smrg		*-*-darwin*)
7043994689c1Smrg		  depdepl=
7044994689c1Smrg		  eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
7045994689c1Smrg		  if test -n "$deplibrary_names" ; then
7046994689c1Smrg		    for tmp in $deplibrary_names ; do
7047994689c1Smrg		      depdepl=$tmp
7048994689c1Smrg		    done
7049994689c1Smrg		    if test -f "$absdir/$objdir/$depdepl" ; then
7050994689c1Smrg		      depdepl="$absdir/$objdir/$depdepl"
7051994689c1Smrg		      darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
7052994689c1Smrg                      if test -z "$darwin_install_name"; then
7053994689c1Smrg                          darwin_install_name=`${OTOOL64} -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
7054994689c1Smrg                      fi
7055f353fbadSmrg		      func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}"
7056f353fbadSmrg		      func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}"
7057994689c1Smrg		      path=
7058994689c1Smrg		    fi
7059994689c1Smrg		  fi
7060994689c1Smrg		  ;;
7061994689c1Smrg		*)
7062994689c1Smrg		  path="-L$absdir/$objdir"
7063994689c1Smrg		  ;;
7064994689c1Smrg		esac
7065994689c1Smrg		else
7066994689c1Smrg		  eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
7067994689c1Smrg		  test -z "$libdir" && \
7068994689c1Smrg		    func_fatal_error "\`$deplib' is not a valid libtool archive"
7069994689c1Smrg		  test "$absdir" != "$libdir" && \
7070994689c1Smrg		    func_warning "\`$deplib' seems to be moved"
7071994689c1Smrg
7072994689c1Smrg		  path="-L$absdir"
7073994689c1Smrg		fi
7074994689c1Smrg		;;
7075994689c1Smrg	      esac
7076994689c1Smrg	      case " $deplibs " in
7077994689c1Smrg	      *" $path "*) ;;
7078994689c1Smrg	      *) deplibs="$path $deplibs" ;;
7079994689c1Smrg	      esac
7080994689c1Smrg	    done
7081994689c1Smrg	  fi # link_all_deplibs != no
7082994689c1Smrg	fi # linkmode = lib
7083994689c1Smrg      done # for deplib in $libs
7084994689c1Smrg      if test "$pass" = link; then
7085994689c1Smrg	if test "$linkmode" = "prog"; then
7086994689c1Smrg	  compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
7087994689c1Smrg	  finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
7088994689c1Smrg	else
7089994689c1Smrg	  compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
7090994689c1Smrg	fi
7091994689c1Smrg      fi
7092994689c1Smrg      dependency_libs="$newdependency_libs"
7093994689c1Smrg      if test "$pass" = dlpreopen; then
7094994689c1Smrg	# Link the dlpreopened libraries before other libraries
7095994689c1Smrg	for deplib in $save_deplibs; do
7096994689c1Smrg	  deplibs="$deplib $deplibs"
7097994689c1Smrg	done
7098994689c1Smrg      fi
7099994689c1Smrg      if test "$pass" != dlopen; then
7100994689c1Smrg	if test "$pass" != conv; then
7101994689c1Smrg	  # Make sure lib_search_path contains only unique directories.
7102994689c1Smrg	  lib_search_path=
7103994689c1Smrg	  for dir in $newlib_search_path; do
7104994689c1Smrg	    case "$lib_search_path " in
7105994689c1Smrg	    *" $dir "*) ;;
7106f353fbadSmrg	    *) func_append lib_search_path " $dir" ;;
7107994689c1Smrg	    esac
7108994689c1Smrg	  done
7109994689c1Smrg	  newlib_search_path=
7110994689c1Smrg	fi
7111994689c1Smrg
7112994689c1Smrg	if test "$linkmode,$pass" != "prog,link"; then
7113994689c1Smrg	  vars="deplibs"
7114994689c1Smrg	else
7115994689c1Smrg	  vars="compile_deplibs finalize_deplibs"
7116994689c1Smrg	fi
7117994689c1Smrg	for var in $vars dependency_libs; do
7118994689c1Smrg	  # Add libraries to $var in reverse order
7119994689c1Smrg	  eval tmp_libs=\"\$$var\"
7120994689c1Smrg	  new_libs=
7121994689c1Smrg	  for deplib in $tmp_libs; do
7122994689c1Smrg	    # FIXME: Pedantically, this is the right thing to do, so
7123994689c1Smrg	    #        that some nasty dependency loop isn't accidentally
7124994689c1Smrg	    #        broken:
7125994689c1Smrg	    #new_libs="$deplib $new_libs"
7126994689c1Smrg	    # Pragmatically, this seems to cause very few problems in
7127994689c1Smrg	    # practice:
7128994689c1Smrg	    case $deplib in
7129994689c1Smrg	    -L*) new_libs="$deplib $new_libs" ;;
7130994689c1Smrg	    -R*) ;;
7131994689c1Smrg	    *)
7132994689c1Smrg	      # And here is the reason: when a library appears more
7133994689c1Smrg	      # than once as an explicit dependence of a library, or
7134994689c1Smrg	      # is implicitly linked in more than once by the
7135994689c1Smrg	      # compiler, it is considered special, and multiple
7136994689c1Smrg	      # occurrences thereof are not removed.  Compare this
7137994689c1Smrg	      # with having the same library being listed as a
7138994689c1Smrg	      # dependency of multiple other libraries: in this case,
7139994689c1Smrg	      # we know (pedantically, we assume) the library does not
7140994689c1Smrg	      # need to be listed more than once, so we keep only the
7141994689c1Smrg	      # last copy.  This is not always right, but it is rare
7142994689c1Smrg	      # enough that we require users that really mean to play
7143994689c1Smrg	      # such unportable linking tricks to link the library
7144994689c1Smrg	      # using -Wl,-lname, so that libtool does not consider it
7145994689c1Smrg	      # for duplicate removal.
7146994689c1Smrg	      case " $specialdeplibs " in
7147994689c1Smrg	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
7148994689c1Smrg	      *)
7149994689c1Smrg		case " $new_libs " in
7150994689c1Smrg		*" $deplib "*) ;;
7151994689c1Smrg		*) new_libs="$deplib $new_libs" ;;
7152994689c1Smrg		esac
7153994689c1Smrg		;;
7154994689c1Smrg	      esac
7155994689c1Smrg	      ;;
7156994689c1Smrg	    esac
7157994689c1Smrg	  done
7158994689c1Smrg	  tmp_libs=
7159994689c1Smrg	  for deplib in $new_libs; do
7160994689c1Smrg	    case $deplib in
7161994689c1Smrg	    -L*)
7162994689c1Smrg	      case " $tmp_libs " in
7163994689c1Smrg	      *" $deplib "*) ;;
7164f353fbadSmrg	      *) func_append tmp_libs " $deplib" ;;
7165994689c1Smrg	      esac
7166994689c1Smrg	      ;;
7167f353fbadSmrg	    *) func_append tmp_libs " $deplib" ;;
7168994689c1Smrg	    esac
7169994689c1Smrg	  done
7170994689c1Smrg	  eval $var=\"$tmp_libs\"
7171994689c1Smrg	done # for var
7172994689c1Smrg      fi
7173994689c1Smrg      # Last step: remove runtime libs from dependency_libs
7174994689c1Smrg      # (they stay in deplibs)
7175994689c1Smrg      tmp_libs=
7176994689c1Smrg      for i in $dependency_libs ; do
7177994689c1Smrg	case " $predeps $postdeps $compiler_lib_search_path " in
7178994689c1Smrg	*" $i "*)
7179994689c1Smrg	  i=""
7180994689c1Smrg	  ;;
7181994689c1Smrg	esac
7182994689c1Smrg	if test -n "$i" ; then
7183f353fbadSmrg	  func_append tmp_libs " $i"
7184994689c1Smrg	fi
7185994689c1Smrg      done
7186994689c1Smrg      dependency_libs=$tmp_libs
7187994689c1Smrg    done # for pass
7188994689c1Smrg    if test "$linkmode" = prog; then
7189994689c1Smrg      dlfiles="$newdlfiles"
7190994689c1Smrg    fi
7191994689c1Smrg    if test "$linkmode" = prog || test "$linkmode" = lib; then
7192994689c1Smrg      dlprefiles="$newdlprefiles"
7193994689c1Smrg    fi
7194994689c1Smrg
7195994689c1Smrg    case $linkmode in
7196994689c1Smrg    oldlib)
7197994689c1Smrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
7198994689c1Smrg	func_warning "\`-dlopen' is ignored for archives"
7199994689c1Smrg      fi
7200994689c1Smrg
7201994689c1Smrg      case " $deplibs" in
7202994689c1Smrg      *\ -l* | *\ -L*)
7203994689c1Smrg	func_warning "\`-l' and \`-L' are ignored for archives" ;;
7204994689c1Smrg      esac
7205994689c1Smrg
7206994689c1Smrg      test -n "$rpath" && \
7207994689c1Smrg	func_warning "\`-rpath' is ignored for archives"
7208994689c1Smrg
7209994689c1Smrg      test -n "$xrpath" && \
7210994689c1Smrg	func_warning "\`-R' is ignored for archives"
7211994689c1Smrg
7212994689c1Smrg      test -n "$vinfo" && \
7213994689c1Smrg	func_warning "\`-version-info/-version-number' is ignored for archives"
7214994689c1Smrg
7215994689c1Smrg      test -n "$release" && \
7216994689c1Smrg	func_warning "\`-release' is ignored for archives"
7217994689c1Smrg
7218994689c1Smrg      test -n "$export_symbols$export_symbols_regex" && \
7219994689c1Smrg	func_warning "\`-export-symbols' is ignored for archives"
7220994689c1Smrg
7221994689c1Smrg      # Now set the variables for building old libraries.
7222994689c1Smrg      build_libtool_libs=no
7223994689c1Smrg      oldlibs="$output"
7224f353fbadSmrg      func_append objs "$old_deplibs"
7225994689c1Smrg      ;;
7226994689c1Smrg
7227994689c1Smrg    lib)
7228994689c1Smrg      # Make sure we only generate libraries of the form `libNAME.la'.
7229994689c1Smrg      case $outputname in
7230994689c1Smrg      lib*)
7231994689c1Smrg	func_stripname 'lib' '.la' "$outputname"
7232994689c1Smrg	name=$func_stripname_result
7233994689c1Smrg	eval shared_ext=\"$shrext_cmds\"
7234994689c1Smrg	eval libname=\"$libname_spec\"
7235994689c1Smrg	;;
7236994689c1Smrg      *)
7237994689c1Smrg	test "$module" = no && \
7238994689c1Smrg	  func_fatal_help "libtool library \`$output' must begin with \`lib'"
7239994689c1Smrg
7240994689c1Smrg	if test "$need_lib_prefix" != no; then
7241994689c1Smrg	  # Add the "lib" prefix for modules if required
7242994689c1Smrg	  func_stripname '' '.la' "$outputname"
7243994689c1Smrg	  name=$func_stripname_result
7244994689c1Smrg	  eval shared_ext=\"$shrext_cmds\"
7245994689c1Smrg	  eval libname=\"$libname_spec\"
7246994689c1Smrg	else
7247994689c1Smrg	  func_stripname '' '.la' "$outputname"
7248994689c1Smrg	  libname=$func_stripname_result
7249994689c1Smrg	fi
7250994689c1Smrg	;;
7251994689c1Smrg      esac
7252994689c1Smrg
7253994689c1Smrg      if test -n "$objs"; then
7254994689c1Smrg	if test "$deplibs_check_method" != pass_all; then
7255994689c1Smrg	  func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs"
7256994689c1Smrg	else
7257994689c1Smrg	  echo
7258994689c1Smrg	  $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
7259994689c1Smrg	  $ECHO "*** objects $objs is not portable!"
7260f353fbadSmrg	  func_append libobjs " $objs"
7261994689c1Smrg	fi
7262994689c1Smrg      fi
7263994689c1Smrg
7264994689c1Smrg      test "$dlself" != no && \
7265994689c1Smrg	func_warning "\`-dlopen self' is ignored for libtool libraries"
7266994689c1Smrg
7267994689c1Smrg      set dummy $rpath
7268994689c1Smrg      shift
7269994689c1Smrg      test "$#" -gt 1 && \
7270994689c1Smrg	func_warning "ignoring multiple \`-rpath's for a libtool library"
7271994689c1Smrg
7272994689c1Smrg      install_libdir="$1"
7273994689c1Smrg
7274994689c1Smrg      oldlibs=
7275994689c1Smrg      if test -z "$rpath"; then
7276994689c1Smrg	if test "$build_libtool_libs" = yes; then
7277994689c1Smrg	  # Building a libtool convenience library.
7278994689c1Smrg	  # Some compilers have problems with a `.al' extension so
7279994689c1Smrg	  # convenience libraries should have the same extension an
7280994689c1Smrg	  # archive normally would.
7281994689c1Smrg	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
7282994689c1Smrg	  build_libtool_libs=convenience
7283994689c1Smrg	  build_old_libs=yes
7284994689c1Smrg	fi
7285994689c1Smrg
7286994689c1Smrg	test -n "$vinfo" && \
7287994689c1Smrg	  func_warning "\`-version-info/-version-number' is ignored for convenience libraries"
7288994689c1Smrg
7289994689c1Smrg	test -n "$release" && \
7290994689c1Smrg	  func_warning "\`-release' is ignored for convenience libraries"
7291994689c1Smrg      else
7292994689c1Smrg
7293994689c1Smrg	# Parse the version information argument.
7294994689c1Smrg	save_ifs="$IFS"; IFS=':'
7295994689c1Smrg	set dummy $vinfo 0 0 0
7296994689c1Smrg	shift
7297994689c1Smrg	IFS="$save_ifs"
7298994689c1Smrg
7299994689c1Smrg	test -n "$7" && \
7300994689c1Smrg	  func_fatal_help "too many parameters to \`-version-info'"
7301994689c1Smrg
7302994689c1Smrg	# convert absolute version numbers to libtool ages
7303994689c1Smrg	# this retains compatibility with .la files and attempts
7304994689c1Smrg	# to make the code below a bit more comprehensible
7305994689c1Smrg
7306994689c1Smrg	case $vinfo_number in
7307994689c1Smrg	yes)
7308994689c1Smrg	  number_major="$1"
7309994689c1Smrg	  number_minor="$2"
7310994689c1Smrg	  number_revision="$3"
7311994689c1Smrg	  #
7312994689c1Smrg	  # There are really only two kinds -- those that
7313994689c1Smrg	  # use the current revision as the major version
7314994689c1Smrg	  # and those that subtract age and use age as
7315994689c1Smrg	  # a minor version.  But, then there is irix
7316994689c1Smrg	  # which has an extra 1 added just for fun
7317994689c1Smrg	  #
7318994689c1Smrg	  case $version_type in
7319994689c1Smrg	  darwin|linux|osf|windows|none)
7320994689c1Smrg	    func_arith $number_major + $number_minor
7321994689c1Smrg	    current=$func_arith_result
7322994689c1Smrg	    age="$number_minor"
7323994689c1Smrg	    revision="$number_revision"
7324994689c1Smrg	    ;;
7325994689c1Smrg	  freebsd-aout|freebsd-elf|qnx|sunos)
7326994689c1Smrg	    current="$number_major"
7327994689c1Smrg	    revision="$number_minor"
7328994689c1Smrg	    age="0"
7329994689c1Smrg	    ;;
7330994689c1Smrg	  irix|nonstopux)
7331994689c1Smrg	    func_arith $number_major + $number_minor
7332994689c1Smrg	    current=$func_arith_result
7333994689c1Smrg	    age="$number_minor"
7334994689c1Smrg	    revision="$number_minor"
7335994689c1Smrg	    lt_irix_increment=no
7336994689c1Smrg	    ;;
7337994689c1Smrg	  esac
7338994689c1Smrg	  ;;
7339994689c1Smrg	no)
7340994689c1Smrg	  current="$1"
7341994689c1Smrg	  revision="$2"
7342994689c1Smrg	  age="$3"
7343994689c1Smrg	  ;;
7344994689c1Smrg	esac
7345994689c1Smrg
7346994689c1Smrg	# Check that each of the things are valid numbers.
7347994689c1Smrg	case $current in
7348994689c1Smrg	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]) ;;
7349994689c1Smrg	*)
7350994689c1Smrg	  func_error "CURRENT \`$current' must be a nonnegative integer"
7351994689c1Smrg	  func_fatal_error "\`$vinfo' is not valid version information"
7352994689c1Smrg	  ;;
7353994689c1Smrg	esac
7354994689c1Smrg
7355994689c1Smrg	case $revision in
7356994689c1Smrg	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]) ;;
7357994689c1Smrg	*)
7358994689c1Smrg	  func_error "REVISION \`$revision' must be a nonnegative integer"
7359994689c1Smrg	  func_fatal_error "\`$vinfo' is not valid version information"
7360994689c1Smrg	  ;;
7361994689c1Smrg	esac
7362994689c1Smrg
7363994689c1Smrg	case $age in
7364994689c1Smrg	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]) ;;
7365994689c1Smrg	*)
7366994689c1Smrg	  func_error "AGE \`$age' must be a nonnegative integer"
7367994689c1Smrg	  func_fatal_error "\`$vinfo' is not valid version information"
7368994689c1Smrg	  ;;
7369994689c1Smrg	esac
7370994689c1Smrg
7371994689c1Smrg	if test "$age" -gt "$current"; then
7372994689c1Smrg	  func_error "AGE \`$age' is greater than the current interface number \`$current'"
7373994689c1Smrg	  func_fatal_error "\`$vinfo' is not valid version information"
7374994689c1Smrg	fi
7375994689c1Smrg
7376994689c1Smrg	# Calculate the version variables.
7377994689c1Smrg	major=
7378994689c1Smrg	versuffix=
7379994689c1Smrg	verstring=
7380994689c1Smrg	case $version_type in
7381994689c1Smrg	none) ;;
7382994689c1Smrg
7383994689c1Smrg	darwin)
7384994689c1Smrg	  # Like Linux, but with the current version available in
7385994689c1Smrg	  # verstring for coding it into the library header
7386994689c1Smrg	  func_arith $current - $age
7387994689c1Smrg	  major=.$func_arith_result
7388994689c1Smrg	  versuffix="$major.$age.$revision"
7389994689c1Smrg	  # Darwin ld doesn't like 0 for these options...
7390994689c1Smrg	  func_arith $current + 1
7391994689c1Smrg	  minor_current=$func_arith_result
7392994689c1Smrg	  xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
7393994689c1Smrg	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
7394994689c1Smrg	  ;;
7395994689c1Smrg
7396994689c1Smrg	freebsd-aout)
7397994689c1Smrg	  major=".$current"
7398994689c1Smrg	  versuffix=".$current.$revision";
7399994689c1Smrg	  ;;
7400994689c1Smrg
7401994689c1Smrg	freebsd-elf)
7402994689c1Smrg	  major=".$current"
7403994689c1Smrg	  versuffix=".$current"
7404994689c1Smrg	  ;;
7405994689c1Smrg
7406994689c1Smrg	irix | nonstopux)
7407994689c1Smrg	  if test "X$lt_irix_increment" = "Xno"; then
7408994689c1Smrg	    func_arith $current - $age
7409994689c1Smrg	  else
7410994689c1Smrg	    func_arith $current - $age + 1
7411994689c1Smrg	  fi
7412994689c1Smrg	  major=$func_arith_result
7413994689c1Smrg
7414994689c1Smrg	  case $version_type in
7415994689c1Smrg	    nonstopux) verstring_prefix=nonstopux ;;
7416994689c1Smrg	    *)         verstring_prefix=sgi ;;
7417994689c1Smrg	  esac
7418994689c1Smrg	  verstring="$verstring_prefix$major.$revision"
7419994689c1Smrg
7420994689c1Smrg	  # Add in all the interfaces that we are compatible with.
7421994689c1Smrg	  loop=$revision
7422994689c1Smrg	  while test "$loop" -ne 0; do
7423994689c1Smrg	    func_arith $revision - $loop
7424994689c1Smrg	    iface=$func_arith_result
7425994689c1Smrg	    func_arith $loop - 1
7426994689c1Smrg	    loop=$func_arith_result
7427994689c1Smrg	    verstring="$verstring_prefix$major.$iface:$verstring"
7428994689c1Smrg	  done
7429994689c1Smrg
7430994689c1Smrg	  # Before this point, $major must not contain `.'.
7431994689c1Smrg	  major=.$major
7432994689c1Smrg	  versuffix="$major.$revision"
7433994689c1Smrg	  ;;
7434994689c1Smrg
7435994689c1Smrg	linux)
7436994689c1Smrg	  func_arith $current - $age
7437994689c1Smrg	  major=.$func_arith_result
7438994689c1Smrg	  versuffix="$major.$age.$revision"
7439994689c1Smrg	  ;;
7440994689c1Smrg
7441994689c1Smrg	osf)
7442994689c1Smrg	  func_arith $current - $age
7443994689c1Smrg	  major=.$func_arith_result
7444994689c1Smrg	  versuffix=".$current.$age.$revision"
7445994689c1Smrg	  verstring="$current.$age.$revision"
7446994689c1Smrg
7447994689c1Smrg	  # Add in all the interfaces that we are compatible with.
7448994689c1Smrg	  loop=$age
7449994689c1Smrg	  while test "$loop" -ne 0; do
7450994689c1Smrg	    func_arith $current - $loop
7451994689c1Smrg	    iface=$func_arith_result
7452994689c1Smrg	    func_arith $loop - 1
7453994689c1Smrg	    loop=$func_arith_result
7454994689c1Smrg	    verstring="$verstring:${iface}.0"
7455994689c1Smrg	  done
7456994689c1Smrg
7457994689c1Smrg	  # Make executables depend on our current version.
7458f353fbadSmrg	  func_append verstring ":${current}.0"
7459994689c1Smrg	  ;;
7460994689c1Smrg
7461994689c1Smrg	qnx)
7462994689c1Smrg	  major=".$current"
7463994689c1Smrg	  versuffix=".$current"
7464994689c1Smrg	  ;;
7465994689c1Smrg
7466994689c1Smrg	sunos)
7467994689c1Smrg	  major=".$current"
7468994689c1Smrg	  versuffix=".$current.$revision"
7469994689c1Smrg	  ;;
7470994689c1Smrg
7471994689c1Smrg	windows)
7472994689c1Smrg	  # Use '-' rather than '.', since we only want one
7473994689c1Smrg	  # extension on DOS 8.3 filesystems.
7474994689c1Smrg	  func_arith $current - $age
7475994689c1Smrg	  major=$func_arith_result
7476994689c1Smrg	  versuffix="-$major"
7477994689c1Smrg	  ;;
7478994689c1Smrg
7479994689c1Smrg	*)
7480994689c1Smrg	  func_fatal_configuration "unknown library version type \`$version_type'"
7481994689c1Smrg	  ;;
7482994689c1Smrg	esac
7483994689c1Smrg
7484994689c1Smrg	# Clear the version info if we defaulted, and they specified a release.
7485994689c1Smrg	if test -z "$vinfo" && test -n "$release"; then
7486994689c1Smrg	  major=
7487994689c1Smrg	  case $version_type in
7488994689c1Smrg	  darwin)
7489994689c1Smrg	    # we can't check for "0.0" in archive_cmds due to quoting
7490994689c1Smrg	    # problems, so we reset it completely
7491994689c1Smrg	    verstring=
7492994689c1Smrg	    ;;
7493994689c1Smrg	  *)
7494994689c1Smrg	    verstring="0.0"
7495994689c1Smrg	    ;;
7496994689c1Smrg	  esac
7497994689c1Smrg	  if test "$need_version" = no; then
7498994689c1Smrg	    versuffix=
7499994689c1Smrg	  else
7500994689c1Smrg	    versuffix=".0.0"
7501994689c1Smrg	  fi
7502994689c1Smrg	fi
7503994689c1Smrg
7504994689c1Smrg	# Remove version info from name if versioning should be avoided
7505994689c1Smrg	if test "$avoid_version" = yes && test "$need_version" = no; then
7506994689c1Smrg	  major=
7507994689c1Smrg	  versuffix=
7508994689c1Smrg	  verstring=""
7509994689c1Smrg	fi
7510994689c1Smrg
7511994689c1Smrg	# Check to see if the archive will have undefined symbols.
7512994689c1Smrg	if test "$allow_undefined" = yes; then
7513994689c1Smrg	  if test "$allow_undefined_flag" = unsupported; then
7514994689c1Smrg	    func_warning "undefined symbols not allowed in $host shared libraries"
7515994689c1Smrg	    build_libtool_libs=no
7516994689c1Smrg	    build_old_libs=yes
7517994689c1Smrg	  fi
7518994689c1Smrg	else
7519994689c1Smrg	  # Don't allow undefined symbols.
7520994689c1Smrg	  allow_undefined_flag="$no_undefined_flag"
7521994689c1Smrg	fi
7522994689c1Smrg
7523994689c1Smrg      fi
7524994689c1Smrg
7525994689c1Smrg      func_generate_dlsyms "$libname" "$libname" "yes"
7526f353fbadSmrg      func_append libobjs " $symfileobj"
7527994689c1Smrg      test "X$libobjs" = "X " && libobjs=
7528994689c1Smrg
7529f353fbadSmrg      if test "$opt_mode" != relink; then
7530994689c1Smrg	# Remove our outputs, but don't remove object files since they
7531994689c1Smrg	# may have been created when compiling PIC objects.
7532994689c1Smrg	removelist=
7533994689c1Smrg	tempremovelist=`$ECHO "$output_objdir/*"`
7534994689c1Smrg	for p in $tempremovelist; do
7535994689c1Smrg	  case $p in
7536994689c1Smrg	    *.$objext | *.gcno)
7537994689c1Smrg	       ;;
7538994689c1Smrg	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
7539994689c1Smrg	       if test "X$precious_files_regex" != "X"; then
7540994689c1Smrg		 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
7541994689c1Smrg		 then
7542994689c1Smrg		   continue
7543994689c1Smrg		 fi
7544994689c1Smrg	       fi
7545f353fbadSmrg	       func_append removelist " $p"
7546994689c1Smrg	       ;;
7547994689c1Smrg	    *) ;;
7548994689c1Smrg	  esac
7549994689c1Smrg	done
7550994689c1Smrg	test -n "$removelist" && \
7551994689c1Smrg	  func_show_eval "${RM}r \$removelist"
7552994689c1Smrg      fi
7553994689c1Smrg
7554994689c1Smrg      # Now set the variables for building old libraries.
7555994689c1Smrg      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
7556f353fbadSmrg	func_append oldlibs " $output_objdir/$libname.$libext"
7557994689c1Smrg
7558994689c1Smrg	# Transform .lo files to .o files.
7559994689c1Smrg	oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP`
7560994689c1Smrg      fi
7561994689c1Smrg
7562994689c1Smrg      # Eliminate all temporary directories.
7563994689c1Smrg      #for path in $notinst_path; do
7564994689c1Smrg      #	lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
7565994689c1Smrg      #	deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
7566994689c1Smrg      #	dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
7567994689c1Smrg      #done
7568994689c1Smrg
7569994689c1Smrg      if test -n "$xrpath"; then
7570994689c1Smrg	# If the user specified any rpath flags, then add them.
7571994689c1Smrg	temp_xrpath=
7572994689c1Smrg	for libdir in $xrpath; do
7573f353fbadSmrg	  func_replace_sysroot "$libdir"
7574f353fbadSmrg	  func_append temp_xrpath " -R$func_replace_sysroot_result"
7575994689c1Smrg	  case "$finalize_rpath " in
7576994689c1Smrg	  *" $libdir "*) ;;
7577f353fbadSmrg	  *) func_append finalize_rpath " $libdir" ;;
7578994689c1Smrg	  esac
7579994689c1Smrg	done
7580994689c1Smrg	if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
7581994689c1Smrg	  dependency_libs="$temp_xrpath $dependency_libs"
7582994689c1Smrg	fi
7583994689c1Smrg      fi
7584994689c1Smrg
7585994689c1Smrg      # Make sure dlfiles contains only unique files that won't be dlpreopened
7586994689c1Smrg      old_dlfiles="$dlfiles"
7587994689c1Smrg      dlfiles=
7588994689c1Smrg      for lib in $old_dlfiles; do
7589994689c1Smrg	case " $dlprefiles $dlfiles " in
7590994689c1Smrg	*" $lib "*) ;;
7591f353fbadSmrg	*) func_append dlfiles " $lib" ;;
7592994689c1Smrg	esac
7593994689c1Smrg      done
7594994689c1Smrg
7595994689c1Smrg      # Make sure dlprefiles contains only unique files
7596994689c1Smrg      old_dlprefiles="$dlprefiles"
7597994689c1Smrg      dlprefiles=
7598994689c1Smrg      for lib in $old_dlprefiles; do
7599994689c1Smrg	case "$dlprefiles " in
7600994689c1Smrg	*" $lib "*) ;;
7601f353fbadSmrg	*) func_append dlprefiles " $lib" ;;
7602994689c1Smrg	esac
7603994689c1Smrg      done
7604994689c1Smrg
7605994689c1Smrg      if test "$build_libtool_libs" = yes; then
7606994689c1Smrg	if test -n "$rpath"; then
7607994689c1Smrg	  case $host in
7608994689c1Smrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
7609994689c1Smrg	    # these systems don't actually have a c library (as such)!
7610994689c1Smrg	    ;;
7611994689c1Smrg	  *-*-rhapsody* | *-*-darwin1.[012])
7612994689c1Smrg	    # Rhapsody C library is in the System framework
7613f353fbadSmrg	    func_append deplibs " System.ltframework"
7614994689c1Smrg	    ;;
7615994689c1Smrg	  *-*-netbsd*)
7616994689c1Smrg	    # Don't link with libc until the a.out ld.so is fixed.
7617994689c1Smrg	    ;;
7618994689c1Smrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
7619994689c1Smrg	    # Do not include libc due to us having libc/libc_r.
7620994689c1Smrg	    ;;
7621994689c1Smrg	  *-*-sco3.2v5* | *-*-sco5v6*)
7622994689c1Smrg	    # Causes problems with __ctype
7623994689c1Smrg	    ;;
7624994689c1Smrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
7625994689c1Smrg	    # Compiler inserts libc in the correct place for threads to work
7626994689c1Smrg	    ;;
7627994689c1Smrg	  *)
7628994689c1Smrg	    # Add libc to deplibs on all other systems if necessary.
7629994689c1Smrg	    if test "$build_libtool_need_lc" = "yes"; then
7630f353fbadSmrg	      func_append deplibs " -lc"
7631994689c1Smrg	    fi
7632994689c1Smrg	    ;;
7633994689c1Smrg	  esac
7634994689c1Smrg	fi
7635994689c1Smrg
7636994689c1Smrg	# Transform deplibs into only deplibs that can be linked in shared.
7637994689c1Smrg	name_save=$name
7638994689c1Smrg	libname_save=$libname
7639994689c1Smrg	release_save=$release
7640994689c1Smrg	versuffix_save=$versuffix
7641994689c1Smrg	major_save=$major
7642994689c1Smrg	# I'm not sure if I'm treating the release correctly.  I think
7643994689c1Smrg	# release should show up in the -l (ie -lgmp5) so we don't want to
7644994689c1Smrg	# add it in twice.  Is that correct?
7645994689c1Smrg	release=""
7646994689c1Smrg	versuffix=""
7647994689c1Smrg	major=""
7648994689c1Smrg	newdeplibs=
7649994689c1Smrg	droppeddeps=no
7650994689c1Smrg	case $deplibs_check_method in
7651994689c1Smrg	pass_all)
7652994689c1Smrg	  # Don't check for shared/static.  Everything works.
7653994689c1Smrg	  # This might be a little naive.  We might want to check
7654994689c1Smrg	  # whether the library exists or not.  But this is on
7655994689c1Smrg	  # osf3 & osf4 and I'm not really sure... Just
7656994689c1Smrg	  # implementing what was already the behavior.
7657994689c1Smrg	  newdeplibs=$deplibs
7658994689c1Smrg	  ;;
7659994689c1Smrg	test_compile)
7660994689c1Smrg	  # This code stresses the "libraries are programs" paradigm to its
7661994689c1Smrg	  # limits. Maybe even breaks it.  We compile a program, linking it
7662994689c1Smrg	  # against the deplibs as a proxy for the library.  Then we can check
7663994689c1Smrg	  # whether they linked in statically or dynamically with ldd.
7664994689c1Smrg	  $opt_dry_run || $RM conftest.c
7665994689c1Smrg	  cat > conftest.c <<EOF
7666994689c1Smrg	  int main() { return 0; }
7667994689c1SmrgEOF
7668994689c1Smrg	  $opt_dry_run || $RM conftest
7669994689c1Smrg	  if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
7670994689c1Smrg	    ldd_output=`ldd conftest`
7671994689c1Smrg	    for i in $deplibs; do
7672994689c1Smrg	      case $i in
7673994689c1Smrg	      -l*)
7674994689c1Smrg		func_stripname -l '' "$i"
7675994689c1Smrg		name=$func_stripname_result
7676994689c1Smrg		if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7677994689c1Smrg		  case " $predeps $postdeps " in
7678994689c1Smrg		  *" $i "*)
7679f353fbadSmrg		    func_append newdeplibs " $i"
7680994689c1Smrg		    i=""
7681994689c1Smrg		    ;;
7682994689c1Smrg		  esac
7683994689c1Smrg		fi
7684994689c1Smrg		if test -n "$i" ; then
7685994689c1Smrg		  libname=`eval "\\$ECHO \"$libname_spec\""`
7686994689c1Smrg		  deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
7687994689c1Smrg		  set dummy $deplib_matches; shift
7688994689c1Smrg		  deplib_match=$1
7689994689c1Smrg		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
7690f353fbadSmrg		    func_append newdeplibs " $i"
7691994689c1Smrg		  else
7692994689c1Smrg		    droppeddeps=yes
7693994689c1Smrg		    echo
7694994689c1Smrg		    $ECHO "*** Warning: dynamic linker does not accept needed library $i."
7695994689c1Smrg		    echo "*** I have the capability to make that library automatically link in when"
7696994689c1Smrg		    echo "*** you link to this library.  But I can only do this if you have a"
7697994689c1Smrg		    echo "*** shared version of the library, which I believe you do not have"
7698994689c1Smrg		    echo "*** because a test_compile did reveal that the linker did not use it for"
7699994689c1Smrg		    echo "*** its dynamic dependency list that programs get resolved with at runtime."
7700994689c1Smrg		  fi
7701994689c1Smrg		fi
7702994689c1Smrg		;;
7703994689c1Smrg	      *)
7704f353fbadSmrg		func_append newdeplibs " $i"
7705994689c1Smrg		;;
7706994689c1Smrg	      esac
7707994689c1Smrg	    done
7708994689c1Smrg	  else
7709994689c1Smrg	    # Error occurred in the first compile.  Let's try to salvage
7710994689c1Smrg	    # the situation: Compile a separate program for each library.
7711994689c1Smrg	    for i in $deplibs; do
7712994689c1Smrg	      case $i in
7713994689c1Smrg	      -l*)
7714994689c1Smrg		func_stripname -l '' "$i"
7715994689c1Smrg		name=$func_stripname_result
7716994689c1Smrg		$opt_dry_run || $RM conftest
7717994689c1Smrg		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
7718994689c1Smrg		  ldd_output=`ldd conftest`
7719994689c1Smrg		  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7720994689c1Smrg		    case " $predeps $postdeps " in
7721994689c1Smrg		    *" $i "*)
7722f353fbadSmrg		      func_append newdeplibs " $i"
7723994689c1Smrg		      i=""
7724994689c1Smrg		      ;;
7725994689c1Smrg		    esac
7726994689c1Smrg		  fi
7727994689c1Smrg		  if test -n "$i" ; then
7728994689c1Smrg		    libname=`eval "\\$ECHO \"$libname_spec\""`
7729994689c1Smrg		    deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
7730994689c1Smrg		    set dummy $deplib_matches; shift
7731994689c1Smrg		    deplib_match=$1
7732994689c1Smrg		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
7733f353fbadSmrg		      func_append newdeplibs " $i"
7734994689c1Smrg		    else
7735994689c1Smrg		      droppeddeps=yes
7736994689c1Smrg		      echo
7737994689c1Smrg		      $ECHO "*** Warning: dynamic linker does not accept needed library $i."
7738994689c1Smrg		      echo "*** I have the capability to make that library automatically link in when"
7739994689c1Smrg		      echo "*** you link to this library.  But I can only do this if you have a"
7740994689c1Smrg		      echo "*** shared version of the library, which you do not appear to have"
7741994689c1Smrg		      echo "*** because a test_compile did reveal that the linker did not use this one"
7742994689c1Smrg		      echo "*** as a dynamic dependency that programs can get resolved with at runtime."
7743994689c1Smrg		    fi
7744994689c1Smrg		  fi
7745994689c1Smrg		else
7746994689c1Smrg		  droppeddeps=yes
7747994689c1Smrg		  echo
7748994689c1Smrg		  $ECHO "*** Warning!  Library $i is needed by this library but I was not able to"
7749994689c1Smrg		  echo "*** make it link in!  You will probably need to install it or some"
7750994689c1Smrg		  echo "*** library that it depends on before this library will be fully"
7751994689c1Smrg		  echo "*** functional.  Installing it before continuing would be even better."
7752994689c1Smrg		fi
7753994689c1Smrg		;;
7754994689c1Smrg	      *)
7755f353fbadSmrg		func_append newdeplibs " $i"
7756994689c1Smrg		;;
7757994689c1Smrg	      esac
7758994689c1Smrg	    done
7759994689c1Smrg	  fi
7760994689c1Smrg	  ;;
7761994689c1Smrg	file_magic*)
7762994689c1Smrg	  set dummy $deplibs_check_method; shift
7763994689c1Smrg	  file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
7764994689c1Smrg	  for a_deplib in $deplibs; do
7765994689c1Smrg	    case $a_deplib in
7766994689c1Smrg	    -l*)
7767994689c1Smrg	      func_stripname -l '' "$a_deplib"
7768994689c1Smrg	      name=$func_stripname_result
7769994689c1Smrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7770994689c1Smrg		case " $predeps $postdeps " in
7771994689c1Smrg		*" $a_deplib "*)
7772f353fbadSmrg		  func_append newdeplibs " $a_deplib"
7773994689c1Smrg		  a_deplib=""
7774994689c1Smrg		  ;;
7775994689c1Smrg		esac
7776994689c1Smrg	      fi
7777994689c1Smrg	      if test -n "$a_deplib" ; then
7778994689c1Smrg		libname=`eval "\\$ECHO \"$libname_spec\""`
7779f353fbadSmrg		if test -n "$file_magic_glob"; then
7780f353fbadSmrg		  libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob`
7781f353fbadSmrg		else
7782f353fbadSmrg		  libnameglob=$libname
7783f353fbadSmrg		fi
7784f353fbadSmrg		test "$want_nocaseglob" = yes && nocaseglob=`shopt -p nocaseglob`
7785994689c1Smrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
7786f353fbadSmrg		  if test "$want_nocaseglob" = yes; then
7787f353fbadSmrg		    shopt -s nocaseglob
7788f353fbadSmrg		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
7789f353fbadSmrg		    $nocaseglob
7790f353fbadSmrg		  else
7791f353fbadSmrg		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
7792f353fbadSmrg		  fi
7793994689c1Smrg		  for potent_lib in $potential_libs; do
7794994689c1Smrg		      # Follow soft links.
7795994689c1Smrg		      if ls -lLd "$potent_lib" 2>/dev/null |
7796994689c1Smrg			 $GREP " -> " >/dev/null; then
7797994689c1Smrg			continue
7798994689c1Smrg		      fi
7799994689c1Smrg		      # The statement above tries to avoid entering an
7800994689c1Smrg		      # endless loop below, in case of cyclic links.
7801994689c1Smrg		      # We might still enter an endless loop, since a link
7802994689c1Smrg		      # loop can be closed while we follow links,
7803994689c1Smrg		      # but so what?
7804994689c1Smrg		      potlib="$potent_lib"
7805994689c1Smrg		      while test -h "$potlib" 2>/dev/null; do
7806994689c1Smrg			potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
7807994689c1Smrg			case $potliblink in
7808994689c1Smrg			[\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
7809994689c1Smrg			*) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";;
7810994689c1Smrg			esac
7811994689c1Smrg		      done
7812994689c1Smrg		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
7813994689c1Smrg			 $SED -e 10q |
7814994689c1Smrg			 $EGREP "$file_magic_regex" > /dev/null; then
7815f353fbadSmrg			func_append newdeplibs " $a_deplib"
7816994689c1Smrg			a_deplib=""
7817994689c1Smrg			break 2
7818994689c1Smrg		      fi
7819994689c1Smrg		  done
7820994689c1Smrg		done
7821994689c1Smrg	      fi
7822994689c1Smrg	      if test -n "$a_deplib" ; then
7823994689c1Smrg		droppeddeps=yes
7824994689c1Smrg		echo
7825994689c1Smrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
7826994689c1Smrg		echo "*** I have the capability to make that library automatically link in when"
7827994689c1Smrg		echo "*** you link to this library.  But I can only do this if you have a"
7828994689c1Smrg		echo "*** shared version of the library, which you do not appear to have"
7829994689c1Smrg		echo "*** because I did check the linker path looking for a file starting"
7830994689c1Smrg		if test -z "$potlib" ; then
7831994689c1Smrg		  $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
7832994689c1Smrg		else
7833994689c1Smrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
7834994689c1Smrg		  $ECHO "*** using a file magic. Last file checked: $potlib"
7835994689c1Smrg		fi
7836994689c1Smrg	      fi
7837994689c1Smrg	      ;;
7838994689c1Smrg	    *)
7839994689c1Smrg	      # Add a -L argument.
7840f353fbadSmrg	      func_append newdeplibs " $a_deplib"
7841994689c1Smrg	      ;;
7842994689c1Smrg	    esac
7843994689c1Smrg	  done # Gone through all deplibs.
7844994689c1Smrg	  ;;
7845994689c1Smrg	match_pattern*)
7846994689c1Smrg	  set dummy $deplibs_check_method; shift
7847994689c1Smrg	  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
7848994689c1Smrg	  for a_deplib in $deplibs; do
7849994689c1Smrg	    case $a_deplib in
7850994689c1Smrg	    -l*)
7851994689c1Smrg	      func_stripname -l '' "$a_deplib"
7852994689c1Smrg	      name=$func_stripname_result
7853994689c1Smrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7854994689c1Smrg		case " $predeps $postdeps " in
7855994689c1Smrg		*" $a_deplib "*)
7856f353fbadSmrg		  func_append newdeplibs " $a_deplib"
7857994689c1Smrg		  a_deplib=""
7858994689c1Smrg		  ;;
7859994689c1Smrg		esac
7860994689c1Smrg	      fi
7861994689c1Smrg	      if test -n "$a_deplib" ; then
7862994689c1Smrg		libname=`eval "\\$ECHO \"$libname_spec\""`
7863994689c1Smrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
7864994689c1Smrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
7865994689c1Smrg		  for potent_lib in $potential_libs; do
7866994689c1Smrg		    potlib="$potent_lib" # see symlink-check above in file_magic test
7867994689c1Smrg		    if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
7868994689c1Smrg		       $EGREP "$match_pattern_regex" > /dev/null; then
7869f353fbadSmrg		      func_append newdeplibs " $a_deplib"
7870994689c1Smrg		      a_deplib=""
7871994689c1Smrg		      break 2
7872994689c1Smrg		    fi
7873994689c1Smrg		  done
7874994689c1Smrg		done
7875994689c1Smrg	      fi
7876994689c1Smrg	      if test -n "$a_deplib" ; then
7877994689c1Smrg		droppeddeps=yes
7878994689c1Smrg		echo
7879994689c1Smrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
7880994689c1Smrg		echo "*** I have the capability to make that library automatically link in when"
7881994689c1Smrg		echo "*** you link to this library.  But I can only do this if you have a"
7882994689c1Smrg		echo "*** shared version of the library, which you do not appear to have"
7883994689c1Smrg		echo "*** because I did check the linker path looking for a file starting"
7884994689c1Smrg		if test -z "$potlib" ; then
7885994689c1Smrg		  $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
7886994689c1Smrg		else
7887994689c1Smrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
7888994689c1Smrg		  $ECHO "*** using a regex pattern. Last file checked: $potlib"
7889994689c1Smrg		fi
7890994689c1Smrg	      fi
7891994689c1Smrg	      ;;
7892994689c1Smrg	    *)
7893994689c1Smrg	      # Add a -L argument.
7894f353fbadSmrg	      func_append newdeplibs " $a_deplib"
7895994689c1Smrg	      ;;
7896994689c1Smrg	    esac
7897994689c1Smrg	  done # Gone through all deplibs.
7898994689c1Smrg	  ;;
7899994689c1Smrg	none | unknown | *)
7900994689c1Smrg	  newdeplibs=""
7901994689c1Smrg	  tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
7902994689c1Smrg	  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7903994689c1Smrg	    for i in $predeps $postdeps ; do
7904994689c1Smrg	      # can't use Xsed below, because $i might contain '/'
7905994689c1Smrg	      tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"`
7906994689c1Smrg	    done
7907994689c1Smrg	  fi
7908994689c1Smrg	  case $tmp_deplibs in
7909994689c1Smrg	  *[!\	\ ]*)
7910994689c1Smrg	    echo
7911994689c1Smrg	    if test "X$deplibs_check_method" = "Xnone"; then
7912994689c1Smrg	      echo "*** Warning: inter-library dependencies are not supported in this platform."
7913994689c1Smrg	    else
7914994689c1Smrg	      echo "*** Warning: inter-library dependencies are not known to be supported."
7915994689c1Smrg	    fi
7916994689c1Smrg	    echo "*** All declared inter-library dependencies are being dropped."
7917994689c1Smrg	    droppeddeps=yes
7918994689c1Smrg	    ;;
7919994689c1Smrg	  esac
7920994689c1Smrg	  ;;
7921994689c1Smrg	esac
7922994689c1Smrg	versuffix=$versuffix_save
7923994689c1Smrg	major=$major_save
7924994689c1Smrg	release=$release_save
7925994689c1Smrg	libname=$libname_save
7926994689c1Smrg	name=$name_save
7927994689c1Smrg
7928994689c1Smrg	case $host in
7929994689c1Smrg	*-*-rhapsody* | *-*-darwin1.[012])
7930994689c1Smrg	  # On Rhapsody replace the C library with the System framework
7931994689c1Smrg	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
7932994689c1Smrg	  ;;
7933994689c1Smrg	esac
7934994689c1Smrg
7935994689c1Smrg	if test "$droppeddeps" = yes; then
7936994689c1Smrg	  if test "$module" = yes; then
7937994689c1Smrg	    echo
7938994689c1Smrg	    echo "*** Warning: libtool could not satisfy all declared inter-library"
7939994689c1Smrg	    $ECHO "*** dependencies of module $libname.  Therefore, libtool will create"
7940994689c1Smrg	    echo "*** a static module, that should work as long as the dlopening"
7941994689c1Smrg	    echo "*** application is linked with the -dlopen flag."
7942994689c1Smrg	    if test -z "$global_symbol_pipe"; then
7943994689c1Smrg	      echo
7944994689c1Smrg	      echo "*** However, this would only work if libtool was able to extract symbol"
7945994689c1Smrg	      echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
7946994689c1Smrg	      echo "*** not find such a program.  So, this module is probably useless."
7947994689c1Smrg	      echo "*** \`nm' from GNU binutils and a full rebuild may help."
7948994689c1Smrg	    fi
7949994689c1Smrg	    if test "$build_old_libs" = no; then
7950994689c1Smrg	      oldlibs="$output_objdir/$libname.$libext"
7951994689c1Smrg	      build_libtool_libs=module
7952994689c1Smrg	      build_old_libs=yes
7953994689c1Smrg	    else
7954994689c1Smrg	      build_libtool_libs=no
7955994689c1Smrg	    fi
7956994689c1Smrg	  else
7957994689c1Smrg	    echo "*** The inter-library dependencies that have been dropped here will be"
7958994689c1Smrg	    echo "*** automatically added whenever a program is linked with this library"
7959994689c1Smrg	    echo "*** or is declared to -dlopen it."
7960994689c1Smrg
7961994689c1Smrg	    if test "$allow_undefined" = no; then
7962994689c1Smrg	      echo
7963994689c1Smrg	      echo "*** Since this library must not contain undefined symbols,"
7964994689c1Smrg	      echo "*** because either the platform does not support them or"
7965994689c1Smrg	      echo "*** it was explicitly requested with -no-undefined,"
7966994689c1Smrg	      echo "*** libtool will only create a static version of it."
7967994689c1Smrg	      if test "$build_old_libs" = no; then
7968994689c1Smrg		oldlibs="$output_objdir/$libname.$libext"
7969994689c1Smrg		build_libtool_libs=module
7970994689c1Smrg		build_old_libs=yes
7971994689c1Smrg	      else
7972994689c1Smrg		build_libtool_libs=no
7973994689c1Smrg	      fi
7974994689c1Smrg	    fi
7975994689c1Smrg	  fi
7976994689c1Smrg	fi
7977994689c1Smrg	# Done checking deplibs!
7978994689c1Smrg	deplibs=$newdeplibs
7979994689c1Smrg      fi
7980994689c1Smrg      # Time to change all our "foo.ltframework" stuff back to "-framework foo"
7981994689c1Smrg      case $host in
7982994689c1Smrg	*-*-darwin*)
7983994689c1Smrg	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
7984994689c1Smrg	  new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
7985994689c1Smrg	  deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
7986994689c1Smrg	  ;;
7987994689c1Smrg      esac
7988994689c1Smrg
7989994689c1Smrg      # move library search paths that coincide with paths to not yet
7990994689c1Smrg      # installed libraries to the beginning of the library search list
7991994689c1Smrg      new_libs=
7992994689c1Smrg      for path in $notinst_path; do
7993994689c1Smrg	case " $new_libs " in
7994994689c1Smrg	*" -L$path/$objdir "*) ;;
7995994689c1Smrg	*)
7996994689c1Smrg	  case " $deplibs " in
7997994689c1Smrg	  *" -L$path/$objdir "*)
7998f353fbadSmrg	    func_append new_libs " -L$path/$objdir" ;;
7999994689c1Smrg	  esac
8000994689c1Smrg	  ;;
8001994689c1Smrg	esac
8002994689c1Smrg      done
8003994689c1Smrg      for deplib in $deplibs; do
8004994689c1Smrg	case $deplib in
8005994689c1Smrg	-L*)
8006994689c1Smrg	  case " $new_libs " in
8007994689c1Smrg	  *" $deplib "*) ;;
8008f353fbadSmrg	  *) func_append new_libs " $deplib" ;;
8009994689c1Smrg	  esac
8010994689c1Smrg	  ;;
8011f353fbadSmrg	*) func_append new_libs " $deplib" ;;
8012994689c1Smrg	esac
8013994689c1Smrg      done
8014994689c1Smrg      deplibs="$new_libs"
8015994689c1Smrg
8016994689c1Smrg      # All the library-specific variables (install_libdir is set above).
8017994689c1Smrg      library_names=
8018994689c1Smrg      old_library=
8019994689c1Smrg      dlname=
8020994689c1Smrg
8021994689c1Smrg      # Test again, we may have decided not to build it any more
8022994689c1Smrg      if test "$build_libtool_libs" = yes; then
8023994689c1Smrg	if test "$hardcode_into_libs" = yes; then
8024994689c1Smrg	  # Hardcode the library paths
8025994689c1Smrg	  hardcode_libdirs=
8026994689c1Smrg	  dep_rpath=
8027994689c1Smrg	  rpath="$finalize_rpath"
8028f353fbadSmrg	  test "$opt_mode" != relink && rpath="$compile_rpath$rpath"
8029994689c1Smrg	  for libdir in $rpath; do
8030994689c1Smrg	    if test -n "$hardcode_libdir_flag_spec"; then
8031994689c1Smrg	      if test -n "$hardcode_libdir_separator"; then
8032f353fbadSmrg		func_replace_sysroot "$libdir"
8033f353fbadSmrg		libdir=$func_replace_sysroot_result
8034994689c1Smrg		if test -z "$hardcode_libdirs"; then
8035994689c1Smrg		  hardcode_libdirs="$libdir"
8036994689c1Smrg		else
8037994689c1Smrg		  # Just accumulate the unique libdirs.
8038994689c1Smrg		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
8039994689c1Smrg		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
8040994689c1Smrg		    ;;
8041994689c1Smrg		  *)
8042f353fbadSmrg		    func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
8043994689c1Smrg		    ;;
8044994689c1Smrg		  esac
8045994689c1Smrg		fi
8046994689c1Smrg	      else
8047994689c1Smrg		eval flag=\"$hardcode_libdir_flag_spec\"
8048f353fbadSmrg		func_append dep_rpath " $flag"
8049994689c1Smrg	      fi
8050994689c1Smrg	    elif test -n "$runpath_var"; then
8051994689c1Smrg	      case "$perm_rpath " in
8052994689c1Smrg	      *" $libdir "*) ;;
8053f353fbadSmrg	      *) func_apped perm_rpath " $libdir" ;;
8054994689c1Smrg	      esac
8055994689c1Smrg	    fi
8056994689c1Smrg	  done
8057994689c1Smrg	  # Substitute the hardcoded libdirs into the rpath.
8058994689c1Smrg	  if test -n "$hardcode_libdir_separator" &&
8059994689c1Smrg	     test -n "$hardcode_libdirs"; then
8060994689c1Smrg	    libdir="$hardcode_libdirs"
8061994689c1Smrg	    if test -n "$hardcode_libdir_flag_spec_ld"; then
8062994689c1Smrg	      eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\"
8063994689c1Smrg	    else
8064994689c1Smrg	      eval dep_rpath=\"$hardcode_libdir_flag_spec\"
8065994689c1Smrg	    fi
8066994689c1Smrg	  fi
8067994689c1Smrg	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
8068994689c1Smrg	    # We should set the runpath_var.
8069994689c1Smrg	    rpath=
8070994689c1Smrg	    for dir in $perm_rpath; do
8071f353fbadSmrg	      func_append rpath "$dir:"
8072994689c1Smrg	    done
8073994689c1Smrg	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
8074994689c1Smrg	  fi
8075994689c1Smrg	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
8076994689c1Smrg	fi
80777a84e134Smrg
8078994689c1Smrg	shlibpath="$finalize_shlibpath"
8079f353fbadSmrg	test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
8080994689c1Smrg	if test -n "$shlibpath"; then
8081994689c1Smrg	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
8082994689c1Smrg	fi
80837a84e134Smrg
8084994689c1Smrg	# Get the real and link names of the library.
8085994689c1Smrg	eval shared_ext=\"$shrext_cmds\"
8086994689c1Smrg	eval library_names=\"$library_names_spec\"
8087994689c1Smrg	set dummy $library_names
8088994689c1Smrg	shift
8089994689c1Smrg	realname="$1"
8090994689c1Smrg	shift
80917a84e134Smrg
8092994689c1Smrg	if test -n "$soname_spec"; then
8093994689c1Smrg	  eval soname=\"$soname_spec\"
8094994689c1Smrg	else
8095994689c1Smrg	  soname="$realname"
8096994689c1Smrg	fi
8097994689c1Smrg	if test -z "$dlname"; then
8098994689c1Smrg	  dlname=$soname
8099994689c1Smrg	fi
81007a84e134Smrg
8101994689c1Smrg	lib="$output_objdir/$realname"
8102994689c1Smrg	linknames=
8103994689c1Smrg	for link
8104994689c1Smrg	do
8105f353fbadSmrg	  func_append linknames " $link"
8106994689c1Smrg	done
81077a84e134Smrg
8108994689c1Smrg	# Use standard objects if they are pic
8109994689c1Smrg	test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
8110994689c1Smrg	test "X$libobjs" = "X " && libobjs=
81117a84e134Smrg
8112994689c1Smrg	delfiles=
8113994689c1Smrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
8114994689c1Smrg	  $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
8115994689c1Smrg	  export_symbols="$output_objdir/$libname.uexp"
8116f353fbadSmrg	  func_append delfiles " $export_symbols"
8117994689c1Smrg	fi
81187a84e134Smrg
8119994689c1Smrg	orig_export_symbols=
8120994689c1Smrg	case $host_os in
8121994689c1Smrg	cygwin* | mingw* | cegcc*)
8122994689c1Smrg	  if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
8123994689c1Smrg	    # exporting using user supplied symfile
8124994689c1Smrg	    if test "x`$SED 1q $export_symbols`" != xEXPORTS; then
8125994689c1Smrg	      # and it's NOT already a .def file. Must figure out
8126994689c1Smrg	      # which of the given symbols are data symbols and tag
8127994689c1Smrg	      # them as such. So, trigger use of export_symbols_cmds.
8128994689c1Smrg	      # export_symbols gets reassigned inside the "prepare
8129994689c1Smrg	      # the list of exported symbols" if statement, so the
8130994689c1Smrg	      # include_expsyms logic still works.
8131994689c1Smrg	      orig_export_symbols="$export_symbols"
8132994689c1Smrg	      export_symbols=
8133994689c1Smrg	      always_export_symbols=yes
8134994689c1Smrg	    fi
8135994689c1Smrg	  fi
8136994689c1Smrg	  ;;
8137994689c1Smrg	esac
81387a84e134Smrg
8139994689c1Smrg	# Prepare the list of exported symbols
8140994689c1Smrg	if test -z "$export_symbols"; then
8141994689c1Smrg	  if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
8142994689c1Smrg	    func_verbose "generating symbol list for \`$libname.la'"
8143994689c1Smrg	    export_symbols="$output_objdir/$libname.exp"
8144994689c1Smrg	    $opt_dry_run || $RM $export_symbols
8145994689c1Smrg	    cmds=$export_symbols_cmds
8146994689c1Smrg	    save_ifs="$IFS"; IFS='~'
8147f353fbadSmrg	    for cmd1 in $cmds; do
8148994689c1Smrg	      IFS="$save_ifs"
8149f353fbadSmrg	      # Take the normal branch if the nm_file_list_spec branch
8150f353fbadSmrg	      # doesn't work or if tool conversion is not needed.
8151f353fbadSmrg	      case $nm_file_list_spec~$to_tool_file_cmd in
8152f353fbadSmrg		*~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*)
8153f353fbadSmrg		  try_normal_branch=yes
8154f353fbadSmrg		  eval cmd=\"$cmd1\"
8155f353fbadSmrg		  func_len " $cmd"
8156f353fbadSmrg		  len=$func_len_result
8157f353fbadSmrg		  ;;
8158f353fbadSmrg		*)
8159f353fbadSmrg		  try_normal_branch=no
8160f353fbadSmrg		  ;;
8161f353fbadSmrg	      esac
8162f353fbadSmrg	      if test "$try_normal_branch" = yes \
8163f353fbadSmrg		 && { test "$len" -lt "$max_cmd_len" \
8164f353fbadSmrg		      || test "$max_cmd_len" -le -1; }
8165f353fbadSmrg	      then
8166f353fbadSmrg		func_show_eval "$cmd" 'exit $?'
8167f353fbadSmrg		skipped_export=false
8168f353fbadSmrg	      elif test -n "$nm_file_list_spec"; then
8169f353fbadSmrg		func_basename "$output"
8170f353fbadSmrg		output_la=$func_basename_result
8171f353fbadSmrg		save_libobjs=$libobjs
8172f353fbadSmrg		save_output=$output
8173f353fbadSmrg		output=${output_objdir}/${output_la}.nm
8174f353fbadSmrg		func_to_tool_file "$output"
8175f353fbadSmrg		libobjs=$nm_file_list_spec$func_to_tool_file_result
8176f353fbadSmrg		func_append delfiles " $output"
8177f353fbadSmrg		func_verbose "creating $NM input file list: $output"
8178f353fbadSmrg		for obj in $save_libobjs; do
8179f353fbadSmrg		  func_to_tool_file "$obj"
8180f353fbadSmrg		  $ECHO "$func_to_tool_file_result"
8181f353fbadSmrg		done > "$output"
8182f353fbadSmrg		eval cmd=\"$cmd1\"
8183994689c1Smrg		func_show_eval "$cmd" 'exit $?'
8184f353fbadSmrg		output=$save_output
8185f353fbadSmrg		libobjs=$save_libobjs
8186994689c1Smrg		skipped_export=false
8187994689c1Smrg	      else
8188994689c1Smrg		# The command line is too long to execute in one step.
8189994689c1Smrg		func_verbose "using reloadable object file for export list..."
8190994689c1Smrg		skipped_export=:
8191994689c1Smrg		# Break out early, otherwise skipped_export may be
8192994689c1Smrg		# set to false by a later but shorter cmd.
8193994689c1Smrg		break
8194994689c1Smrg	      fi
8195994689c1Smrg	    done
8196994689c1Smrg	    IFS="$save_ifs"
8197994689c1Smrg	    if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then
8198994689c1Smrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
8199994689c1Smrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
8200994689c1Smrg	    fi
8201994689c1Smrg	  fi
8202994689c1Smrg	fi
82037a84e134Smrg
8204994689c1Smrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
8205994689c1Smrg	  tmp_export_symbols="$export_symbols"
8206994689c1Smrg	  test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
8207994689c1Smrg	  $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
8208994689c1Smrg	fi
82097a84e134Smrg
8210994689c1Smrg	if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then
8211994689c1Smrg	  # The given exports_symbols file has to be filtered, so filter it.
8212994689c1Smrg	  func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
8213994689c1Smrg	  # FIXME: $output_objdir/$libname.filter potentially contains lots of
8214994689c1Smrg	  # 's' commands which not all seds can handle. GNU sed should be fine
8215994689c1Smrg	  # though. Also, the filter scales superlinearly with the number of
8216994689c1Smrg	  # global variables. join(1) would be nice here, but unfortunately
8217994689c1Smrg	  # isn't a blessed tool.
8218994689c1Smrg	  $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
8219f353fbadSmrg	  func_append delfiles " $export_symbols $output_objdir/$libname.filter"
8220994689c1Smrg	  export_symbols=$output_objdir/$libname.def
8221994689c1Smrg	  $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
82227a84e134Smrg	fi
82237a84e134Smrg
8224994689c1Smrg	tmp_deplibs=
8225994689c1Smrg	for test_deplib in $deplibs; do
8226994689c1Smrg	  case " $convenience " in
8227994689c1Smrg	  *" $test_deplib "*) ;;
8228994689c1Smrg	  *)
8229f353fbadSmrg	    func_append tmp_deplibs " $test_deplib"
8230994689c1Smrg	    ;;
8231994689c1Smrg	  esac
8232994689c1Smrg	done
8233994689c1Smrg	deplibs="$tmp_deplibs"
82347a84e134Smrg
8235994689c1Smrg	if test -n "$convenience"; then
8236994689c1Smrg	  if test -n "$whole_archive_flag_spec" &&
8237994689c1Smrg	    test "$compiler_needs_object" = yes &&
8238994689c1Smrg	    test -z "$libobjs"; then
8239994689c1Smrg	    # extract the archives, so we have objects to list.
8240994689c1Smrg	    # TODO: could optimize this to just extract one archive.
8241994689c1Smrg	    whole_archive_flag_spec=
8242994689c1Smrg	  fi
8243994689c1Smrg	  if test -n "$whole_archive_flag_spec"; then
8244994689c1Smrg	    save_libobjs=$libobjs
8245994689c1Smrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
8246994689c1Smrg	    test "X$libobjs" = "X " && libobjs=
8247994689c1Smrg	  else
8248994689c1Smrg	    gentop="$output_objdir/${outputname}x"
8249f353fbadSmrg	    func_append generated " $gentop"
82507a84e134Smrg
8251994689c1Smrg	    func_extract_archives $gentop $convenience
8252f353fbadSmrg	    func_append libobjs " $func_extract_archives_result"
8253994689c1Smrg	    test "X$libobjs" = "X " && libobjs=
8254994689c1Smrg	  fi
8255994689c1Smrg	fi
82567a84e134Smrg
8257994689c1Smrg	if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
8258994689c1Smrg	  eval flag=\"$thread_safe_flag_spec\"
8259f353fbadSmrg	  func_append linker_flags " $flag"
8260994689c1Smrg	fi
82617a84e134Smrg
8262994689c1Smrg	# Make a backup of the uninstalled library when relinking
8263f353fbadSmrg	if test "$opt_mode" = relink; then
8264994689c1Smrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
8265e1e1713cSmrg	fi
82667a84e134Smrg
8267994689c1Smrg	# Do each of the archive commands.
8268994689c1Smrg	if test "$module" = yes && test -n "$module_cmds" ; then
8269994689c1Smrg	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
8270994689c1Smrg	    eval test_cmds=\"$module_expsym_cmds\"
8271994689c1Smrg	    cmds=$module_expsym_cmds
8272994689c1Smrg	  else
8273994689c1Smrg	    eval test_cmds=\"$module_cmds\"
8274994689c1Smrg	    cmds=$module_cmds
8275994689c1Smrg	  fi
8276994689c1Smrg	else
8277994689c1Smrg	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
8278994689c1Smrg	    eval test_cmds=\"$archive_expsym_cmds\"
8279994689c1Smrg	    cmds=$archive_expsym_cmds
8280994689c1Smrg	  else
8281994689c1Smrg	    eval test_cmds=\"$archive_cmds\"
8282994689c1Smrg	    cmds=$archive_cmds
8283994689c1Smrg	  fi
8284e1e1713cSmrg	fi
8285775e7de9Smrg
8286994689c1Smrg	if test "X$skipped_export" != "X:" &&
8287994689c1Smrg	   func_len " $test_cmds" &&
8288994689c1Smrg	   len=$func_len_result &&
8289994689c1Smrg	   test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
8290994689c1Smrg	  :
8291994689c1Smrg	else
8292994689c1Smrg	  # The command line is too long to link in one step, link piecewise
8293994689c1Smrg	  # or, if using GNU ld and skipped_export is not :, use a linker
8294994689c1Smrg	  # script.
82957a84e134Smrg
8296994689c1Smrg	  # Save the value of $output and $libobjs because we want to
8297994689c1Smrg	  # use them later.  If we have whole_archive_flag_spec, we
8298994689c1Smrg	  # want to use save_libobjs as it was before
8299994689c1Smrg	  # whole_archive_flag_spec was expanded, because we can't
8300994689c1Smrg	  # assume the linker understands whole_archive_flag_spec.
8301994689c1Smrg	  # This may have to be revisited, in case too many
8302994689c1Smrg	  # convenience libraries get linked in and end up exceeding
8303994689c1Smrg	  # the spec.
8304994689c1Smrg	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
8305994689c1Smrg	    save_libobjs=$libobjs
8306994689c1Smrg	  fi
8307994689c1Smrg	  save_output=$output
8308994689c1Smrg	  func_basename "$output"
8309994689c1Smrg	  output_la=$func_basename_result
83107a84e134Smrg
8311994689c1Smrg	  # Clear the reloadable object creation command queue and
8312994689c1Smrg	  # initialize k to one.
8313994689c1Smrg	  test_cmds=
8314994689c1Smrg	  concat_cmds=
8315994689c1Smrg	  objlist=
8316994689c1Smrg	  last_robj=
8317994689c1Smrg	  k=1
83187a84e134Smrg
8319994689c1Smrg	  if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
8320994689c1Smrg	    output=${output_objdir}/${output_la}.lnkscript
8321994689c1Smrg	    func_verbose "creating GNU ld script: $output"
8322994689c1Smrg	    echo 'INPUT (' > $output
8323994689c1Smrg	    for obj in $save_libobjs
8324994689c1Smrg	    do
8325f353fbadSmrg	      func_to_tool_file "$obj"
8326f353fbadSmrg	      $ECHO "$func_to_tool_file_result" >> $output
8327994689c1Smrg	    done
8328994689c1Smrg	    echo ')' >> $output
8329f353fbadSmrg	    func_append delfiles " $output"
8330f353fbadSmrg	    func_to_tool_file "$output"
8331f353fbadSmrg	    output=$func_to_tool_file_result
8332994689c1Smrg	  elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then
8333994689c1Smrg	    output=${output_objdir}/${output_la}.lnk
8334994689c1Smrg	    func_verbose "creating linker input file list: $output"
8335994689c1Smrg	    : > $output
8336994689c1Smrg	    set x $save_libobjs
8337994689c1Smrg	    shift
8338994689c1Smrg	    firstobj=
8339994689c1Smrg	    if test "$compiler_needs_object" = yes; then
8340994689c1Smrg	      firstobj="$1 "
8341994689c1Smrg	      shift
8342994689c1Smrg	    fi
8343994689c1Smrg	    for obj
8344994689c1Smrg	    do
8345f353fbadSmrg	      func_to_tool_file "$obj"
8346f353fbadSmrg	      $ECHO "$func_to_tool_file_result" >> $output
8347994689c1Smrg	    done
8348f353fbadSmrg	    func_append delfiles " $output"
8349f353fbadSmrg	    func_to_tool_file "$output"
8350f353fbadSmrg	    output=$firstobj\"$file_list_spec$func_to_tool_file_result\"
8351994689c1Smrg	  else
8352994689c1Smrg	    if test -n "$save_libobjs"; then
8353994689c1Smrg	      func_verbose "creating reloadable object files..."
8354994689c1Smrg	      output=$output_objdir/$output_la-${k}.$objext
8355994689c1Smrg	      eval test_cmds=\"$reload_cmds\"
8356994689c1Smrg	      func_len " $test_cmds"
8357994689c1Smrg	      len0=$func_len_result
8358994689c1Smrg	      len=$len0
8359994689c1Smrg
8360994689c1Smrg	      # Loop over the list of objects to be linked.
8361994689c1Smrg	      for obj in $save_libobjs
8362994689c1Smrg	      do
8363994689c1Smrg		func_len " $obj"
8364994689c1Smrg		func_arith $len + $func_len_result
8365994689c1Smrg		len=$func_arith_result
8366994689c1Smrg		if test "X$objlist" = X ||
8367994689c1Smrg		   test "$len" -lt "$max_cmd_len"; then
8368994689c1Smrg		  func_append objlist " $obj"
8369994689c1Smrg		else
8370994689c1Smrg		  # The command $test_cmds is almost too long, add a
8371994689c1Smrg		  # command to the queue.
8372994689c1Smrg		  if test "$k" -eq 1 ; then
8373994689c1Smrg		    # The first file doesn't have a previous command to add.
8374994689c1Smrg		    reload_objs=$objlist
8375994689c1Smrg		    eval concat_cmds=\"$reload_cmds\"
8376994689c1Smrg		  else
8377994689c1Smrg		    # All subsequent reloadable object files will link in
8378994689c1Smrg		    # the last one created.
8379994689c1Smrg		    reload_objs="$objlist $last_robj"
8380994689c1Smrg		    eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
8381994689c1Smrg		  fi
8382994689c1Smrg		  last_robj=$output_objdir/$output_la-${k}.$objext
8383994689c1Smrg		  func_arith $k + 1
8384994689c1Smrg		  k=$func_arith_result
8385994689c1Smrg		  output=$output_objdir/$output_la-${k}.$objext
8386994689c1Smrg		  objlist=" $obj"
8387994689c1Smrg		  func_len " $last_robj"
8388994689c1Smrg		  func_arith $len0 + $func_len_result
8389994689c1Smrg		  len=$func_arith_result
8390994689c1Smrg		fi
8391994689c1Smrg	      done
8392994689c1Smrg	      # Handle the remaining objects by creating one last
8393994689c1Smrg	      # reloadable object file.  All subsequent reloadable object
8394994689c1Smrg	      # files will link in the last one created.
8395994689c1Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
8396994689c1Smrg	      reload_objs="$objlist $last_robj"
8397994689c1Smrg	      eval concat_cmds=\"\${concat_cmds}$reload_cmds\"
8398994689c1Smrg	      if test -n "$last_robj"; then
8399994689c1Smrg	        eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\"
8400994689c1Smrg	      fi
8401f353fbadSmrg	      func_append delfiles " $output"
8402994689c1Smrg
8403994689c1Smrg	    else
8404994689c1Smrg	      output=
8405994689c1Smrg	    fi
84067a84e134Smrg
8407994689c1Smrg	    if ${skipped_export-false}; then
8408994689c1Smrg	      func_verbose "generating symbol list for \`$libname.la'"
8409994689c1Smrg	      export_symbols="$output_objdir/$libname.exp"
8410994689c1Smrg	      $opt_dry_run || $RM $export_symbols
8411994689c1Smrg	      libobjs=$output
8412994689c1Smrg	      # Append the command to create the export file.
8413994689c1Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
8414994689c1Smrg	      eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
8415994689c1Smrg	      if test -n "$last_robj"; then
8416994689c1Smrg		eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
8417994689c1Smrg	      fi
8418994689c1Smrg	    fi
84197a84e134Smrg
8420994689c1Smrg	    test -n "$save_libobjs" &&
8421994689c1Smrg	      func_verbose "creating a temporary reloadable object file: $output"
84227a84e134Smrg
8423994689c1Smrg	    # Loop through the commands generated above and execute them.
8424994689c1Smrg	    save_ifs="$IFS"; IFS='~'
8425994689c1Smrg	    for cmd in $concat_cmds; do
8426994689c1Smrg	      IFS="$save_ifs"
8427994689c1Smrg	      $opt_silent || {
8428994689c1Smrg		  func_quote_for_expand "$cmd"
8429994689c1Smrg		  eval "func_echo $func_quote_for_expand_result"
8430994689c1Smrg	      }
8431994689c1Smrg	      $opt_dry_run || eval "$cmd" || {
8432994689c1Smrg		lt_exit=$?
8433994689c1Smrg
8434994689c1Smrg		# Restore the uninstalled library and exit
8435f353fbadSmrg		if test "$opt_mode" = relink; then
8436994689c1Smrg		  ( cd "$output_objdir" && \
8437994689c1Smrg		    $RM "${realname}T" && \
8438994689c1Smrg		    $MV "${realname}U" "$realname" )
8439994689c1Smrg		fi
84407a84e134Smrg
8441994689c1Smrg		exit $lt_exit
8442994689c1Smrg	      }
8443994689c1Smrg	    done
8444994689c1Smrg	    IFS="$save_ifs"
84457a84e134Smrg
8446994689c1Smrg	    if test -n "$export_symbols_regex" && ${skipped_export-false}; then
8447994689c1Smrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
8448994689c1Smrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
8449775e7de9Smrg	    fi
8450775e7de9Smrg	  fi
84517a84e134Smrg
8452994689c1Smrg          if ${skipped_export-false}; then
8453994689c1Smrg	    if test -n "$export_symbols" && test -n "$include_expsyms"; then
8454994689c1Smrg	      tmp_export_symbols="$export_symbols"
8455994689c1Smrg	      test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
8456994689c1Smrg	      $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
8457994689c1Smrg	    fi
84587a84e134Smrg
8459994689c1Smrg	    if test -n "$orig_export_symbols"; then
8460994689c1Smrg	      # The given exports_symbols file has to be filtered, so filter it.
8461994689c1Smrg	      func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
8462994689c1Smrg	      # FIXME: $output_objdir/$libname.filter potentially contains lots of
8463994689c1Smrg	      # 's' commands which not all seds can handle. GNU sed should be fine
8464994689c1Smrg	      # though. Also, the filter scales superlinearly with the number of
8465994689c1Smrg	      # global variables. join(1) would be nice here, but unfortunately
8466994689c1Smrg	      # isn't a blessed tool.
8467994689c1Smrg	      $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
8468f353fbadSmrg	      func_append delfiles " $export_symbols $output_objdir/$libname.filter"
8469994689c1Smrg	      export_symbols=$output_objdir/$libname.def
8470994689c1Smrg	      $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
8471994689c1Smrg	    fi
8472994689c1Smrg	  fi
84737a84e134Smrg
8474994689c1Smrg	  libobjs=$output
8475994689c1Smrg	  # Restore the value of output.
8476994689c1Smrg	  output=$save_output
8477e1e1713cSmrg
8478994689c1Smrg	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
8479994689c1Smrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
8480994689c1Smrg	    test "X$libobjs" = "X " && libobjs=
8481994689c1Smrg	  fi
8482994689c1Smrg	  # Expand the library linking commands again to reset the
8483994689c1Smrg	  # value of $libobjs for piecewise linking.
8484994689c1Smrg
8485994689c1Smrg	  # Do each of the archive commands.
8486994689c1Smrg	  if test "$module" = yes && test -n "$module_cmds" ; then
8487994689c1Smrg	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
8488994689c1Smrg	      cmds=$module_expsym_cmds
8489775e7de9Smrg	    else
8490994689c1Smrg	      cmds=$module_cmds
84917a84e134Smrg	    fi
84927a84e134Smrg	  else
8493994689c1Smrg	    if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
8494994689c1Smrg	      cmds=$archive_expsym_cmds
8495994689c1Smrg	    else
8496994689c1Smrg	      cmds=$archive_cmds
8497994689c1Smrg	    fi
84987a84e134Smrg	  fi
8499775e7de9Smrg	fi
85007a84e134Smrg
8501994689c1Smrg	if test -n "$delfiles"; then
8502994689c1Smrg	  # Append the command to remove temporary files to $cmds.
8503994689c1Smrg	  eval cmds=\"\$cmds~\$RM $delfiles\"
8504994689c1Smrg	fi
8505775e7de9Smrg
8506994689c1Smrg	# Add any objects from preloaded convenience libraries
8507994689c1Smrg	if test -n "$dlprefiles"; then
8508994689c1Smrg	  gentop="$output_objdir/${outputname}x"
8509f353fbadSmrg	  func_append generated " $gentop"
85107a84e134Smrg
8511994689c1Smrg	  func_extract_archives $gentop $dlprefiles
8512f353fbadSmrg	  func_append libobjs " $func_extract_archives_result"
8513994689c1Smrg	  test "X$libobjs" = "X " && libobjs=
8514775e7de9Smrg	fi
85157a84e134Smrg
8516994689c1Smrg	save_ifs="$IFS"; IFS='~'
8517994689c1Smrg	for cmd in $cmds; do
8518994689c1Smrg	  IFS="$save_ifs"
8519994689c1Smrg	  eval cmd=\"$cmd\"
8520994689c1Smrg	  $opt_silent || {
8521994689c1Smrg	    func_quote_for_expand "$cmd"
8522994689c1Smrg	    eval "func_echo $func_quote_for_expand_result"
8523994689c1Smrg	  }
8524994689c1Smrg	  $opt_dry_run || eval "$cmd" || {
8525994689c1Smrg	    lt_exit=$?
85267a84e134Smrg
8527994689c1Smrg	    # Restore the uninstalled library and exit
8528f353fbadSmrg	    if test "$opt_mode" = relink; then
8529994689c1Smrg	      ( cd "$output_objdir" && \
8530994689c1Smrg	        $RM "${realname}T" && \
8531994689c1Smrg		$MV "${realname}U" "$realname" )
8532e1e1713cSmrg	    fi
85337a84e134Smrg
8534994689c1Smrg	    exit $lt_exit
8535994689c1Smrg	  }
8536994689c1Smrg	done
8537994689c1Smrg	IFS="$save_ifs"
85387a84e134Smrg
8539994689c1Smrg	# Restore the uninstalled library and exit
8540f353fbadSmrg	if test "$opt_mode" = relink; then
8541994689c1Smrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
85427a84e134Smrg
8543994689c1Smrg	  if test -n "$convenience"; then
8544994689c1Smrg	    if test -z "$whole_archive_flag_spec"; then
8545994689c1Smrg	      func_show_eval '${RM}r "$gentop"'
8546994689c1Smrg	    fi
8547994689c1Smrg	  fi
85487a84e134Smrg
8549994689c1Smrg	  exit $EXIT_SUCCESS
8550994689c1Smrg	fi
8551775e7de9Smrg
8552994689c1Smrg	# Create links to the real library.
8553994689c1Smrg	for linkname in $linknames; do
8554994689c1Smrg	  if test "$realname" != "$linkname"; then
8555994689c1Smrg	    func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
8556994689c1Smrg	  fi
8557994689c1Smrg	done
8558775e7de9Smrg
8559994689c1Smrg	# If -module or -export-dynamic was specified, set the dlname.
8560994689c1Smrg	if test "$module" = yes || test "$export_dynamic" = yes; then
8561994689c1Smrg	  # On all known operating systems, these are identical.
8562994689c1Smrg	  dlname="$soname"
8563994689c1Smrg	fi
8564994689c1Smrg      fi
8565994689c1Smrg      ;;
8566775e7de9Smrg
8567994689c1Smrg    obj)
8568994689c1Smrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
8569994689c1Smrg	func_warning "\`-dlopen' is ignored for objects"
8570994689c1Smrg      fi
8571775e7de9Smrg
8572994689c1Smrg      case " $deplibs" in
8573994689c1Smrg      *\ -l* | *\ -L*)
8574994689c1Smrg	func_warning "\`-l' and \`-L' are ignored for objects" ;;
8575994689c1Smrg      esac
8576775e7de9Smrg
8577994689c1Smrg      test -n "$rpath" && \
8578994689c1Smrg	func_warning "\`-rpath' is ignored for objects"
8579775e7de9Smrg
8580994689c1Smrg      test -n "$xrpath" && \
8581994689c1Smrg	func_warning "\`-R' is ignored for objects"
8582994689c1Smrg
8583994689c1Smrg      test -n "$vinfo" && \
8584994689c1Smrg	func_warning "\`-version-info' is ignored for objects"
85857a84e134Smrg
8586994689c1Smrg      test -n "$release" && \
8587994689c1Smrg	func_warning "\`-release' is ignored for objects"
8588e1e1713cSmrg
8589994689c1Smrg      case $output in
8590994689c1Smrg      *.lo)
8591994689c1Smrg	test -n "$objs$old_deplibs" && \
8592994689c1Smrg	  func_fatal_error "cannot build library object \`$output' from non-libtool objects"
8593994689c1Smrg
8594994689c1Smrg	libobj=$output
8595994689c1Smrg	func_lo2o "$libobj"
8596994689c1Smrg	obj=$func_lo2o_result
8597994689c1Smrg	;;
8598994689c1Smrg      *)
8599994689c1Smrg	libobj=
8600994689c1Smrg	obj="$output"
8601e1e1713cSmrg	;;
8602775e7de9Smrg      esac
86037a84e134Smrg
8604994689c1Smrg      # Delete the old objects.
8605994689c1Smrg      $opt_dry_run || $RM $obj $libobj
86067a84e134Smrg
8607994689c1Smrg      # Objects from convenience libraries.  This assumes
8608994689c1Smrg      # single-version convenience libraries.  Whenever we create
8609994689c1Smrg      # different ones for PIC/non-PIC, this we'll have to duplicate
8610994689c1Smrg      # the extraction.
8611994689c1Smrg      reload_conv_objs=
8612994689c1Smrg      gentop=
8613994689c1Smrg      # reload_cmds runs $LD directly, so let us get rid of
8614994689c1Smrg      # -Wl from whole_archive_flag_spec and hope we can get by with
8615994689c1Smrg      # turning comma into space..
8616994689c1Smrg      wl=
8617775e7de9Smrg
8618994689c1Smrg      if test -n "$convenience"; then
8619994689c1Smrg	if test -n "$whole_archive_flag_spec"; then
8620994689c1Smrg	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
8621994689c1Smrg	  reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
8622e1e1713cSmrg	else
8623994689c1Smrg	  gentop="$output_objdir/${obj}x"
8624f353fbadSmrg	  func_append generated " $gentop"
8625994689c1Smrg
8626994689c1Smrg	  func_extract_archives $gentop $convenience
8627994689c1Smrg	  reload_conv_objs="$reload_objs $func_extract_archives_result"
8628e1e1713cSmrg	fi
8629994689c1Smrg      fi
86307a84e134Smrg
8631f353fbadSmrg      # If we're not building shared, we need to use non_pic_objs
8632f353fbadSmrg      test "$build_libtool_libs" != yes && libobjs="$non_pic_objects"
8633f353fbadSmrg
8634994689c1Smrg      # Create the old-style object.
8635994689c1Smrg      reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
86367a84e134Smrg
8637994689c1Smrg      output="$obj"
8638994689c1Smrg      func_execute_cmds "$reload_cmds" 'exit $?'
86397a84e134Smrg
8640994689c1Smrg      # Exit if we aren't doing a library object file.
8641994689c1Smrg      if test -z "$libobj"; then
8642994689c1Smrg	if test -n "$gentop"; then
8643994689c1Smrg	  func_show_eval '${RM}r "$gentop"'
8644994689c1Smrg	fi
8645e1e1713cSmrg
8646994689c1Smrg	exit $EXIT_SUCCESS
8647e1e1713cSmrg      fi
8648e1e1713cSmrg
8649994689c1Smrg      if test "$build_libtool_libs" != yes; then
8650994689c1Smrg	if test -n "$gentop"; then
8651994689c1Smrg	  func_show_eval '${RM}r "$gentop"'
8652994689c1Smrg	fi
8653e1e1713cSmrg
8654994689c1Smrg	# Create an invalid libtool object if no PIC, so that we don't
8655994689c1Smrg	# accidentally link it into a program.
8656994689c1Smrg	# $show "echo timestamp > $libobj"
8657994689c1Smrg	# $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
8658994689c1Smrg	exit $EXIT_SUCCESS
8659994689c1Smrg      fi
8660e1e1713cSmrg
8661994689c1Smrg      if test -n "$pic_flag" || test "$pic_mode" != default; then
8662994689c1Smrg	# Only do commands if we really have different PIC objects.
8663994689c1Smrg	reload_objs="$libobjs $reload_conv_objs"
8664994689c1Smrg	output="$libobj"
8665994689c1Smrg	func_execute_cmds "$reload_cmds" 'exit $?'
8666e1e1713cSmrg      fi
8667994689c1Smrg
8668994689c1Smrg      if test -n "$gentop"; then
8669994689c1Smrg	func_show_eval '${RM}r "$gentop"'
8670994689c1Smrg      fi
8671994689c1Smrg
8672994689c1Smrg      exit $EXIT_SUCCESS
8673e1e1713cSmrg      ;;
86747a84e134Smrg
8675994689c1Smrg    prog)
8676994689c1Smrg      case $host in
8677994689c1Smrg	*cygwin*) func_stripname '' '.exe' "$output"
8678994689c1Smrg	          output=$func_stripname_result.exe;;
8679994689c1Smrg      esac
8680994689c1Smrg      test -n "$vinfo" && \
8681994689c1Smrg	func_warning "\`-version-info' is ignored for programs"
86827a84e134Smrg
8683994689c1Smrg      test -n "$release" && \
8684994689c1Smrg	func_warning "\`-release' is ignored for programs"
86857a84e134Smrg
8686994689c1Smrg      test "$preload" = yes \
8687994689c1Smrg        && test "$dlopen_support" = unknown \
8688994689c1Smrg	&& test "$dlopen_self" = unknown \
8689994689c1Smrg	&& test "$dlopen_self_static" = unknown && \
8690994689c1Smrg	  func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support."
8691994689c1Smrg
8692994689c1Smrg      case $host in
8693994689c1Smrg      *-*-rhapsody* | *-*-darwin1.[012])
8694994689c1Smrg	# On Rhapsody replace the C library is the System framework
8695994689c1Smrg	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
8696994689c1Smrg	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
8697e1e1713cSmrg	;;
8698994689c1Smrg      esac
8699e1e1713cSmrg
8700994689c1Smrg      case $host in
8701994689c1Smrg      *-*-darwin*)
8702994689c1Smrg	# Don't allow lazy linking, it breaks C++ global constructors
8703994689c1Smrg	# But is supposedly fixed on 10.4 or later (yay!).
8704994689c1Smrg	if test "$tagname" = CXX ; then
8705994689c1Smrg	  case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
8706994689c1Smrg	    10.[0123])
8707f353fbadSmrg	      func_append compile_command " ${wl}-bind_at_load"
8708f353fbadSmrg	      func_append finalize_command " ${wl}-bind_at_load"
8709994689c1Smrg	    ;;
8710994689c1Smrg	  esac
8711e1e1713cSmrg	fi
8712994689c1Smrg	# Time to change all our "foo.ltframework" stuff back to "-framework foo"
8713994689c1Smrg	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8714994689c1Smrg	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8715994689c1Smrg	;;
8716994689c1Smrg      esac
8717e1e1713cSmrg
8718e1e1713cSmrg
8719994689c1Smrg      # move library search paths that coincide with paths to not yet
8720994689c1Smrg      # installed libraries to the beginning of the library search list
8721994689c1Smrg      new_libs=
8722994689c1Smrg      for path in $notinst_path; do
8723994689c1Smrg	case " $new_libs " in
8724994689c1Smrg	*" -L$path/$objdir "*) ;;
8725994689c1Smrg	*)
8726994689c1Smrg	  case " $compile_deplibs " in
8727994689c1Smrg	  *" -L$path/$objdir "*)
8728f353fbadSmrg	    func_append new_libs " -L$path/$objdir" ;;
8729775e7de9Smrg	  esac
8730994689c1Smrg	  ;;
8731994689c1Smrg	esac
8732994689c1Smrg      done
8733994689c1Smrg      for deplib in $compile_deplibs; do
8734994689c1Smrg	case $deplib in
8735994689c1Smrg	-L*)
8736994689c1Smrg	  case " $new_libs " in
8737994689c1Smrg	  *" $deplib "*) ;;
8738f353fbadSmrg	  *) func_append new_libs " $deplib" ;;
8739775e7de9Smrg	  esac
8740994689c1Smrg	  ;;
8741f353fbadSmrg	*) func_append new_libs " $deplib" ;;
8742994689c1Smrg	esac
8743994689c1Smrg      done
8744994689c1Smrg      compile_deplibs="$new_libs"
87457a84e134Smrg
8746e1e1713cSmrg
8747f353fbadSmrg      func_append compile_command " $compile_deplibs"
8748f353fbadSmrg      func_append finalize_command " $finalize_deplibs"
8749e1e1713cSmrg
8750994689c1Smrg      if test -n "$rpath$xrpath"; then
8751994689c1Smrg	# If the user specified any rpath flags, then add them.
8752994689c1Smrg	for libdir in $rpath $xrpath; do
8753994689c1Smrg	  # This is the magic to use -rpath.
8754994689c1Smrg	  case "$finalize_rpath " in
8755994689c1Smrg	  *" $libdir "*) ;;
8756f353fbadSmrg	  *) func_append finalize_rpath " $libdir" ;;
8757994689c1Smrg	  esac
8758994689c1Smrg	done
8759994689c1Smrg      fi
8760e1e1713cSmrg
8761994689c1Smrg      # Now hardcode the library paths
8762994689c1Smrg      rpath=
8763994689c1Smrg      hardcode_libdirs=
8764994689c1Smrg      for libdir in $compile_rpath $finalize_rpath; do
8765994689c1Smrg	if test -n "$hardcode_libdir_flag_spec"; then
8766994689c1Smrg	  if test -n "$hardcode_libdir_separator"; then
8767994689c1Smrg	    if test -z "$hardcode_libdirs"; then
8768994689c1Smrg	      hardcode_libdirs="$libdir"
8769994689c1Smrg	    else
8770994689c1Smrg	      # Just accumulate the unique libdirs.
8771994689c1Smrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
8772994689c1Smrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
8773994689c1Smrg		;;
8774994689c1Smrg	      *)
8775f353fbadSmrg		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
8776994689c1Smrg		;;
8777994689c1Smrg	      esac
8778994689c1Smrg	    fi
8779e1e1713cSmrg	  else
8780994689c1Smrg	    eval flag=\"$hardcode_libdir_flag_spec\"
8781f353fbadSmrg	    func_append rpath " $flag"
8782e1e1713cSmrg	  fi
8783994689c1Smrg	elif test -n "$runpath_var"; then
8784994689c1Smrg	  case "$perm_rpath " in
8785994689c1Smrg	  *" $libdir "*) ;;
8786f353fbadSmrg	  *) func_append perm_rpath " $libdir" ;;
8787994689c1Smrg	  esac
8788994689c1Smrg	fi
8789994689c1Smrg	case $host in
8790994689c1Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
8791994689c1Smrg	  testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'`
8792994689c1Smrg	  case :$dllsearchpath: in
8793994689c1Smrg	  *":$libdir:"*) ;;
8794994689c1Smrg	  ::) dllsearchpath=$libdir;;
8795f353fbadSmrg	  *) func_append dllsearchpath ":$libdir";;
8796994689c1Smrg	  esac
8797994689c1Smrg	  case :$dllsearchpath: in
8798994689c1Smrg	  *":$testbindir:"*) ;;
8799994689c1Smrg	  ::) dllsearchpath=$testbindir;;
8800f353fbadSmrg	  *) func_append dllsearchpath ":$testbindir";;
8801994689c1Smrg	  esac
8802994689c1Smrg	  ;;
8803994689c1Smrg	esac
8804994689c1Smrg      done
8805994689c1Smrg      # Substitute the hardcoded libdirs into the rpath.
8806994689c1Smrg      if test -n "$hardcode_libdir_separator" &&
8807994689c1Smrg	 test -n "$hardcode_libdirs"; then
8808994689c1Smrg	libdir="$hardcode_libdirs"
8809994689c1Smrg	eval rpath=\" $hardcode_libdir_flag_spec\"
8810994689c1Smrg      fi
8811994689c1Smrg      compile_rpath="$rpath"
8812e1e1713cSmrg
8813994689c1Smrg      rpath=
8814994689c1Smrg      hardcode_libdirs=
8815994689c1Smrg      for libdir in $finalize_rpath; do
8816994689c1Smrg	if test -n "$hardcode_libdir_flag_spec"; then
8817994689c1Smrg	  if test -n "$hardcode_libdir_separator"; then
8818994689c1Smrg	    if test -z "$hardcode_libdirs"; then
8819994689c1Smrg	      hardcode_libdirs="$libdir"
8820994689c1Smrg	    else
8821994689c1Smrg	      # Just accumulate the unique libdirs.
8822994689c1Smrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
8823994689c1Smrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
8824994689c1Smrg		;;
8825994689c1Smrg	      *)
8826f353fbadSmrg		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
8827994689c1Smrg		;;
8828994689c1Smrg	      esac
8829994689c1Smrg	    fi
88307a84e134Smrg	  else
8831994689c1Smrg	    eval flag=\"$hardcode_libdir_flag_spec\"
8832f353fbadSmrg	    func_append rpath " $flag"
88337a84e134Smrg	  fi
8834994689c1Smrg	elif test -n "$runpath_var"; then
8835994689c1Smrg	  case "$finalize_perm_rpath " in
8836994689c1Smrg	  *" $libdir "*) ;;
8837f353fbadSmrg	  *) func_append finalize_perm_rpath " $libdir" ;;
8838994689c1Smrg	  esac
88397a84e134Smrg	fi
8840994689c1Smrg      done
8841994689c1Smrg      # Substitute the hardcoded libdirs into the rpath.
8842994689c1Smrg      if test -n "$hardcode_libdir_separator" &&
8843994689c1Smrg	 test -n "$hardcode_libdirs"; then
8844994689c1Smrg	libdir="$hardcode_libdirs"
8845994689c1Smrg	eval rpath=\" $hardcode_libdir_flag_spec\"
8846994689c1Smrg      fi
8847994689c1Smrg      finalize_rpath="$rpath"
88487a84e134Smrg
8849994689c1Smrg      if test -n "$libobjs" && test "$build_old_libs" = yes; then
8850994689c1Smrg	# Transform all the library objects into standard objects.
8851994689c1Smrg	compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
8852994689c1Smrg	finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
8853994689c1Smrg      fi
88547a84e134Smrg
8855994689c1Smrg      func_generate_dlsyms "$outputname" "@PROGRAM@" "no"
88567a84e134Smrg
8857994689c1Smrg      # template prelinking step
8858994689c1Smrg      if test -n "$prelink_cmds"; then
8859994689c1Smrg	func_execute_cmds "$prelink_cmds" 'exit $?'
8860994689c1Smrg      fi
88617a84e134Smrg
8862994689c1Smrg      wrappers_required=yes
8863994689c1Smrg      case $host in
8864994689c1Smrg      *cegcc* | *mingw32ce*)
8865994689c1Smrg        # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
8866994689c1Smrg        wrappers_required=no
8867994689c1Smrg        ;;
8868994689c1Smrg      *cygwin* | *mingw* )
8869994689c1Smrg        if test "$build_libtool_libs" != yes; then
8870994689c1Smrg          wrappers_required=no
8871994689c1Smrg        fi
8872994689c1Smrg        ;;
8873994689c1Smrg      *)
8874994689c1Smrg        if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
8875994689c1Smrg          wrappers_required=no
8876994689c1Smrg        fi
8877994689c1Smrg        ;;
8878994689c1Smrg      esac
8879994689c1Smrg      if test "$wrappers_required" = no; then
8880994689c1Smrg	# Replace the output file specification.
8881994689c1Smrg	compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
8882994689c1Smrg	link_command="$compile_command$compile_rpath"
88837a84e134Smrg
8884994689c1Smrg	# We have no uninstalled library dependencies, so finalize right now.
8885994689c1Smrg	exit_status=0
8886994689c1Smrg	func_show_eval "$link_command" 'exit_status=$?'
88877a84e134Smrg
8888f353fbadSmrg	if test -n "$postlink_cmds"; then
8889f353fbadSmrg	  func_to_tool_file "$output"
8890f353fbadSmrg	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
8891f353fbadSmrg	  func_execute_cmds "$postlink_cmds" 'exit $?'
8892f353fbadSmrg	fi
8893f353fbadSmrg
8894994689c1Smrg	# Delete the generated files.
8895994689c1Smrg	if test -f "$output_objdir/${outputname}S.${objext}"; then
8896994689c1Smrg	  func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"'
88977a84e134Smrg	fi
88987a84e134Smrg
8899994689c1Smrg	exit $exit_status
8900994689c1Smrg      fi
89017a84e134Smrg
8902994689c1Smrg      if test -n "$compile_shlibpath$finalize_shlibpath"; then
8903994689c1Smrg	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
8904994689c1Smrg      fi
8905994689c1Smrg      if test -n "$finalize_shlibpath"; then
8906994689c1Smrg	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
8907994689c1Smrg      fi
8908e1e1713cSmrg
8909994689c1Smrg      compile_var=
8910994689c1Smrg      finalize_var=
8911994689c1Smrg      if test -n "$runpath_var"; then
8912994689c1Smrg	if test -n "$perm_rpath"; then
8913994689c1Smrg	  # We should set the runpath_var.
8914994689c1Smrg	  rpath=
8915994689c1Smrg	  for dir in $perm_rpath; do
8916f353fbadSmrg	    func_append rpath "$dir:"
8917994689c1Smrg	  done
8918994689c1Smrg	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
89197a84e134Smrg	fi
8920994689c1Smrg	if test -n "$finalize_perm_rpath"; then
8921994689c1Smrg	  # We should set the runpath_var.
8922994689c1Smrg	  rpath=
8923994689c1Smrg	  for dir in $finalize_perm_rpath; do
8924f353fbadSmrg	    func_append rpath "$dir:"
8925994689c1Smrg	  done
8926994689c1Smrg	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
89277a84e134Smrg	fi
8928994689c1Smrg      fi
89297a84e134Smrg
8930994689c1Smrg      if test "$no_install" = yes; then
8931994689c1Smrg	# We don't need to create a wrapper script.
8932994689c1Smrg	link_command="$compile_var$compile_command$compile_rpath"
8933994689c1Smrg	# Replace the output file specification.
8934994689c1Smrg	link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
8935994689c1Smrg	# Delete the old output file.
8936994689c1Smrg	$opt_dry_run || $RM $output
8937994689c1Smrg	# Link the executable and exit
8938994689c1Smrg	func_show_eval "$link_command" 'exit $?'
8939f353fbadSmrg
8940f353fbadSmrg	if test -n "$postlink_cmds"; then
8941f353fbadSmrg	  func_to_tool_file "$output"
8942f353fbadSmrg	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
8943f353fbadSmrg	  func_execute_cmds "$postlink_cmds" 'exit $?'
8944f353fbadSmrg	fi
8945f353fbadSmrg
8946e1e1713cSmrg	exit $EXIT_SUCCESS
8947994689c1Smrg      fi
8948775e7de9Smrg
8949994689c1Smrg      if test "$hardcode_action" = relink; then
8950994689c1Smrg	# Fast installation is not supported
8951994689c1Smrg	link_command="$compile_var$compile_command$compile_rpath"
8952994689c1Smrg	relink_command="$finalize_var$finalize_command$finalize_rpath"
8953994689c1Smrg
8954994689c1Smrg	func_warning "this platform does not like uninstalled shared libraries"
8955994689c1Smrg	func_warning "\`$output' will be relinked during installation"
8956994689c1Smrg      else
8957994689c1Smrg	if test "$fast_install" != no; then
8958994689c1Smrg	  link_command="$finalize_var$compile_command$finalize_rpath"
8959994689c1Smrg	  if test "$fast_install" = yes; then
8960994689c1Smrg	    relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
8961994689c1Smrg	  else
8962994689c1Smrg	    # fast_install is set to needless
8963994689c1Smrg	    relink_command=
8964994689c1Smrg	  fi
89657a84e134Smrg	else
8966994689c1Smrg	  link_command="$compile_var$compile_command$compile_rpath"
8967994689c1Smrg	  relink_command="$finalize_var$finalize_command$finalize_rpath"
89687a84e134Smrg	fi
8969994689c1Smrg      fi
89707a84e134Smrg
8971994689c1Smrg      # Replace the output file specification.
8972994689c1Smrg      link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
89737a84e134Smrg
8974994689c1Smrg      # Delete the old output files.
8975994689c1Smrg      $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
89767a84e134Smrg
8977994689c1Smrg      func_show_eval "$link_command" 'exit $?'
8978e1e1713cSmrg
8979f353fbadSmrg      if test -n "$postlink_cmds"; then
8980f353fbadSmrg	func_to_tool_file "$output_objdir/$outputname"
8981f353fbadSmrg	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'`
8982f353fbadSmrg	func_execute_cmds "$postlink_cmds" 'exit $?'
8983f353fbadSmrg      fi
8984f353fbadSmrg
8985994689c1Smrg      # Now create the wrapper script.
8986994689c1Smrg      func_verbose "creating $output"
8987e1e1713cSmrg
8988994689c1Smrg      # Quote the relink command for shipping.
8989994689c1Smrg      if test -n "$relink_command"; then
8990994689c1Smrg	# Preserve any variables that may affect compiler behavior
8991994689c1Smrg	for var in $variables_saved_for_relink; do
8992994689c1Smrg	  if eval test -z \"\${$var+set}\"; then
8993994689c1Smrg	    relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
8994994689c1Smrg	  elif eval var_value=\$$var; test -z "$var_value"; then
8995994689c1Smrg	    relink_command="$var=; export $var; $relink_command"
89967a84e134Smrg	  else
8997994689c1Smrg	    func_quote_for_eval "$var_value"
8998994689c1Smrg	    relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
89997a84e134Smrg	  fi
9000994689c1Smrg	done
9001994689c1Smrg	relink_command="(cd `pwd`; $relink_command)"
9002994689c1Smrg	relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
9003994689c1Smrg      fi
9004775e7de9Smrg
9005994689c1Smrg      # Only actually do things if not in dry run mode.
9006994689c1Smrg      $opt_dry_run || {
9007994689c1Smrg	# win32 will think the script is a binary if it has
9008994689c1Smrg	# a .exe suffix, so we strip it off here.
9009994689c1Smrg	case $output in
9010994689c1Smrg	  *.exe) func_stripname '' '.exe' "$output"
9011994689c1Smrg	         output=$func_stripname_result ;;
9012994689c1Smrg	esac
9013994689c1Smrg	# test for cygwin because mv fails w/o .exe extensions
9014994689c1Smrg	case $host in
9015994689c1Smrg	  *cygwin*)
9016994689c1Smrg	    exeext=.exe
9017994689c1Smrg	    func_stripname '' '.exe' "$outputname"
9018994689c1Smrg	    outputname=$func_stripname_result ;;
9019994689c1Smrg	  *) exeext= ;;
90207a84e134Smrg	esac
9021994689c1Smrg	case $host in
9022994689c1Smrg	  *cygwin* | *mingw* )
9023994689c1Smrg	    func_dirname_and_basename "$output" "" "."
9024994689c1Smrg	    output_name=$func_basename_result
9025994689c1Smrg	    output_path=$func_dirname_result
9026994689c1Smrg	    cwrappersource="$output_path/$objdir/lt-$output_name.c"
9027994689c1Smrg	    cwrapper="$output_path/$output_name.exe"
9028994689c1Smrg	    $RM $cwrappersource $cwrapper
9029994689c1Smrg	    trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
9030994689c1Smrg
9031994689c1Smrg	    func_emit_cwrapperexe_src > $cwrappersource
9032994689c1Smrg
9033994689c1Smrg	    # The wrapper executable is built using the $host compiler,
9034994689c1Smrg	    # because it contains $host paths and files. If cross-
9035994689c1Smrg	    # compiling, it, like the target executable, must be
9036994689c1Smrg	    # executed on the $host or under an emulation environment.
9037994689c1Smrg	    $opt_dry_run || {
9038994689c1Smrg	      $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
9039994689c1Smrg	      $STRIP $cwrapper
9040994689c1Smrg	    }
90417a84e134Smrg
9042994689c1Smrg	    # Now, create the wrapper script for func_source use:
9043994689c1Smrg	    func_ltwrapper_scriptname $cwrapper
9044994689c1Smrg	    $RM $func_ltwrapper_scriptname_result
9045994689c1Smrg	    trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
9046994689c1Smrg	    $opt_dry_run || {
9047994689c1Smrg	      # note: this script will not be executed, so do not chmod.
9048994689c1Smrg	      if test "x$build" = "x$host" ; then
9049994689c1Smrg		$cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
9050994689c1Smrg	      else
9051994689c1Smrg		func_emit_wrapper no > $func_ltwrapper_scriptname_result
9052994689c1Smrg	      fi
9053994689c1Smrg	    }
9054994689c1Smrg	  ;;
9055994689c1Smrg	  * )
9056994689c1Smrg	    $RM $output
9057994689c1Smrg	    trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
90587a84e134Smrg
9059994689c1Smrg	    func_emit_wrapper no > $output
9060994689c1Smrg	    chmod +x $output
9061994689c1Smrg	  ;;
9062994689c1Smrg	esac
9063994689c1Smrg      }
9064994689c1Smrg      exit $EXIT_SUCCESS
9065994689c1Smrg      ;;
9066994689c1Smrg    esac
90677a84e134Smrg
9068994689c1Smrg    # See if we need to build an old-fashioned archive.
9069994689c1Smrg    for oldlib in $oldlibs; do
90707a84e134Smrg
9071994689c1Smrg      if test "$build_libtool_libs" = convenience; then
9072994689c1Smrg	oldobjs="$libobjs_save $symfileobj"
9073994689c1Smrg	addlibs="$convenience"
9074994689c1Smrg	build_libtool_libs=no
9075994689c1Smrg      else
9076994689c1Smrg	if test "$build_libtool_libs" = module; then
9077994689c1Smrg	  oldobjs="$libobjs_save"
9078994689c1Smrg	  build_libtool_libs=no
9079994689c1Smrg	else
9080994689c1Smrg	  oldobjs="$old_deplibs $non_pic_objects"
9081994689c1Smrg	  if test "$preload" = yes && test -f "$symfileobj"; then
9082f353fbadSmrg	    func_append oldobjs " $symfileobj"
9083994689c1Smrg	  fi
9084994689c1Smrg	fi
9085994689c1Smrg	addlibs="$old_convenience"
90867a84e134Smrg      fi
90877a84e134Smrg
9088994689c1Smrg      if test -n "$addlibs"; then
9089994689c1Smrg	gentop="$output_objdir/${outputname}x"
9090f353fbadSmrg	func_append generated " $gentop"
90917a84e134Smrg
9092994689c1Smrg	func_extract_archives $gentop $addlibs
9093f353fbadSmrg	func_append oldobjs " $func_extract_archives_result"
9094994689c1Smrg      fi
90957a84e134Smrg
9096994689c1Smrg      # Do each command in the archive commands.
9097994689c1Smrg      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
9098994689c1Smrg	cmds=$old_archive_from_new_cmds
9099994689c1Smrg      else
91007a84e134Smrg
9101994689c1Smrg	# Add any objects from preloaded convenience libraries
9102994689c1Smrg	if test -n "$dlprefiles"; then
9103994689c1Smrg	  gentop="$output_objdir/${outputname}x"
9104f353fbadSmrg	  func_append generated " $gentop"
91057a84e134Smrg
9106994689c1Smrg	  func_extract_archives $gentop $dlprefiles
9107f353fbadSmrg	  func_append oldobjs " $func_extract_archives_result"
9108994689c1Smrg	fi
91097a84e134Smrg
9110994689c1Smrg	# POSIX demands no paths to be encoded in archives.  We have
9111994689c1Smrg	# to avoid creating archives with duplicate basenames if we
9112994689c1Smrg	# might have to extract them afterwards, e.g., when creating a
9113994689c1Smrg	# static archive out of a convenience library, or when linking
9114994689c1Smrg	# the entirety of a libtool archive into another (currently
9115994689c1Smrg	# not supported by libtool).
9116994689c1Smrg	if (for obj in $oldobjs
9117994689c1Smrg	    do
9118994689c1Smrg	      func_basename "$obj"
9119994689c1Smrg	      $ECHO "$func_basename_result"
9120994689c1Smrg	    done | sort | sort -uc >/dev/null 2>&1); then
9121994689c1Smrg	  :
9122994689c1Smrg	else
9123994689c1Smrg	  echo "copying selected object files to avoid basename conflicts..."
9124994689c1Smrg	  gentop="$output_objdir/${outputname}x"
9125f353fbadSmrg	  func_append generated " $gentop"
9126994689c1Smrg	  func_mkdir_p "$gentop"
9127994689c1Smrg	  save_oldobjs=$oldobjs
9128994689c1Smrg	  oldobjs=
9129994689c1Smrg	  counter=1
9130994689c1Smrg	  for obj in $save_oldobjs
9131994689c1Smrg	  do
9132994689c1Smrg	    func_basename "$obj"
9133994689c1Smrg	    objbase="$func_basename_result"
9134994689c1Smrg	    case " $oldobjs " in
9135994689c1Smrg	    " ") oldobjs=$obj ;;
9136994689c1Smrg	    *[\ /]"$objbase "*)
9137994689c1Smrg	      while :; do
9138994689c1Smrg		# Make sure we don't pick an alternate name that also
9139994689c1Smrg		# overlaps.
9140994689c1Smrg		newobj=lt$counter-$objbase
9141994689c1Smrg		func_arith $counter + 1
9142994689c1Smrg		counter=$func_arith_result
9143994689c1Smrg		case " $oldobjs " in
9144994689c1Smrg		*[\ /]"$newobj "*) ;;
9145994689c1Smrg		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
9146994689c1Smrg		esac
9147994689c1Smrg	      done
9148994689c1Smrg	      func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
9149f353fbadSmrg	      func_append oldobjs " $gentop/$newobj"
9150994689c1Smrg	      ;;
9151f353fbadSmrg	    *) func_append oldobjs " $obj" ;;
9152994689c1Smrg	    esac
91537a84e134Smrg	  done
9154775e7de9Smrg	fi
9155994689c1Smrg	eval cmds=\"$old_archive_cmds\"
9156e1e1713cSmrg
9157994689c1Smrg	func_len " $cmds"
9158994689c1Smrg	len=$func_len_result
9159994689c1Smrg	if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
9160994689c1Smrg	  cmds=$old_archive_cmds
9161f353fbadSmrg	elif test -n "$archiver_list_spec"; then
9162f353fbadSmrg	  func_verbose "using command file archive linking..."
9163f353fbadSmrg	  for obj in $oldobjs
9164f353fbadSmrg	  do
9165f353fbadSmrg	    func_to_tool_file "$obj"
9166f353fbadSmrg	    $ECHO "$func_to_tool_file_result"
9167f353fbadSmrg	  done > $output_objdir/$libname.libcmd
9168f353fbadSmrg	  func_to_tool_file "$output_objdir/$libname.libcmd"
9169f353fbadSmrg	  oldobjs=" $archiver_list_spec$func_to_tool_file_result"
9170f353fbadSmrg	  cmds=$old_archive_cmds
9171994689c1Smrg	else
9172994689c1Smrg	  # the command line is too long to link in one step, link in parts
9173994689c1Smrg	  func_verbose "using piecewise archive linking..."
9174994689c1Smrg	  save_RANLIB=$RANLIB
9175994689c1Smrg	  RANLIB=:
9176994689c1Smrg	  objlist=
9177994689c1Smrg	  concat_cmds=
9178994689c1Smrg	  save_oldobjs=$oldobjs
9179994689c1Smrg	  oldobjs=
9180994689c1Smrg	  # Is there a better way of finding the last object in the list?
9181994689c1Smrg	  for obj in $save_oldobjs
9182994689c1Smrg	  do
9183994689c1Smrg	    last_oldobj=$obj
9184994689c1Smrg	  done
9185994689c1Smrg	  eval test_cmds=\"$old_archive_cmds\"
9186994689c1Smrg	  func_len " $test_cmds"
9187994689c1Smrg	  len0=$func_len_result
9188994689c1Smrg	  len=$len0
9189994689c1Smrg	  for obj in $save_oldobjs
9190994689c1Smrg	  do
9191994689c1Smrg	    func_len " $obj"
9192994689c1Smrg	    func_arith $len + $func_len_result
9193994689c1Smrg	    len=$func_arith_result
9194994689c1Smrg	    func_append objlist " $obj"
9195994689c1Smrg	    if test "$len" -lt "$max_cmd_len"; then
9196994689c1Smrg	      :
9197994689c1Smrg	    else
9198994689c1Smrg	      # the above command should be used before it gets too long
9199994689c1Smrg	      oldobjs=$objlist
9200994689c1Smrg	      if test "$obj" = "$last_oldobj" ; then
9201994689c1Smrg		RANLIB=$save_RANLIB
9202994689c1Smrg	      fi
9203994689c1Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
9204994689c1Smrg	      eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
9205994689c1Smrg	      objlist=
9206994689c1Smrg	      len=$len0
9207994689c1Smrg	    fi
9208994689c1Smrg	  done
9209994689c1Smrg	  RANLIB=$save_RANLIB
9210994689c1Smrg	  oldobjs=$objlist
9211994689c1Smrg	  if test "X$oldobjs" = "X" ; then
9212994689c1Smrg	    eval cmds=\"\$concat_cmds\"
9213994689c1Smrg	  else
9214994689c1Smrg	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
9215994689c1Smrg	  fi
9216994689c1Smrg	fi
9217994689c1Smrg      fi
9218994689c1Smrg      func_execute_cmds "$cmds" 'exit $?'
92197a84e134Smrg    done
92207a84e134Smrg
9221994689c1Smrg    test -n "$generated" && \
9222994689c1Smrg      func_show_eval "${RM}r$generated"
92237a84e134Smrg
9224994689c1Smrg    # Now create the libtool archive.
9225994689c1Smrg    case $output in
9226994689c1Smrg    *.la)
9227994689c1Smrg      old_library=
9228994689c1Smrg      test "$build_old_libs" = yes && old_library="$libname.$libext"
9229994689c1Smrg      func_verbose "creating $output"
9230775e7de9Smrg
9231994689c1Smrg      # Preserve any variables that may affect compiler behavior
9232994689c1Smrg      for var in $variables_saved_for_relink; do
9233994689c1Smrg	if eval test -z \"\${$var+set}\"; then
9234994689c1Smrg	  relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
9235994689c1Smrg	elif eval var_value=\$$var; test -z "$var_value"; then
9236994689c1Smrg	  relink_command="$var=; export $var; $relink_command"
9237e1e1713cSmrg	else
9238994689c1Smrg	  func_quote_for_eval "$var_value"
9239994689c1Smrg	  relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
9240e1e1713cSmrg	fi
9241994689c1Smrg      done
9242994689c1Smrg      # Quote the link command for shipping.
9243994689c1Smrg      relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
9244994689c1Smrg      relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
9245994689c1Smrg      if test "$hardcode_automatic" = yes ; then
9246994689c1Smrg	relink_command=
9247994689c1Smrg      fi
92487a84e134Smrg
9249994689c1Smrg      # Only create the output if not a dry run.
9250994689c1Smrg      $opt_dry_run || {
9251994689c1Smrg	for installed in no yes; do
9252994689c1Smrg	  if test "$installed" = yes; then
9253994689c1Smrg	    if test -z "$install_libdir"; then
9254994689c1Smrg	      break
9255994689c1Smrg	    fi
9256994689c1Smrg	    output="$output_objdir/$outputname"i
9257994689c1Smrg	    # Replace all uninstalled libtool libraries with the installed ones
9258994689c1Smrg	    newdependency_libs=
9259994689c1Smrg	    for deplib in $dependency_libs; do
9260994689c1Smrg	      case $deplib in
9261994689c1Smrg	      *.la)
9262994689c1Smrg		func_basename "$deplib"
9263994689c1Smrg		name="$func_basename_result"
9264994689c1Smrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
9265994689c1Smrg		test -z "$libdir" && \
9266994689c1Smrg		  func_fatal_error "\`$deplib' is not a valid libtool archive"
9267f353fbadSmrg		func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"
9268f353fbadSmrg		;;
9269f353fbadSmrg	      -L*)
9270f353fbadSmrg		func_stripname -L '' "$deplib"
9271f353fbadSmrg		func_replace_sysroot "$func_stripname_result"
9272f353fbadSmrg		func_append newdependency_libs " -L$func_replace_sysroot_result"
9273f353fbadSmrg		;;
9274f353fbadSmrg	      -R*)
9275f353fbadSmrg		func_stripname -R '' "$deplib"
9276f353fbadSmrg		func_replace_sysroot "$func_stripname_result"
9277f353fbadSmrg		func_append newdependency_libs " -R$func_replace_sysroot_result"
9278994689c1Smrg		;;
9279f353fbadSmrg	      *) func_append newdependency_libs " $deplib" ;;
9280994689c1Smrg	      esac
9281994689c1Smrg	    done
9282994689c1Smrg	    dependency_libs="$newdependency_libs"
9283994689c1Smrg	    newdlfiles=
9284994689c1Smrg
9285994689c1Smrg	    for lib in $dlfiles; do
9286994689c1Smrg	      case $lib in
9287994689c1Smrg	      *.la)
9288994689c1Smrg	        func_basename "$lib"
9289994689c1Smrg		name="$func_basename_result"
9290994689c1Smrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
9291994689c1Smrg		test -z "$libdir" && \
9292994689c1Smrg		  func_fatal_error "\`$lib' is not a valid libtool archive"
9293f353fbadSmrg		func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name"
9294994689c1Smrg		;;
9295f353fbadSmrg	      *) func_append newdlfiles " $lib" ;;
9296994689c1Smrg	      esac
9297994689c1Smrg	    done
9298994689c1Smrg	    dlfiles="$newdlfiles"
9299994689c1Smrg	    newdlprefiles=
9300994689c1Smrg	    for lib in $dlprefiles; do
9301994689c1Smrg	      case $lib in
9302994689c1Smrg	      *.la)
9303994689c1Smrg		# Only pass preopened files to the pseudo-archive (for
9304994689c1Smrg		# eventual linking with the app. that links it) if we
9305994689c1Smrg		# didn't already link the preopened objects directly into
9306994689c1Smrg		# the library:
9307994689c1Smrg		func_basename "$lib"
9308994689c1Smrg		name="$func_basename_result"
9309994689c1Smrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
9310994689c1Smrg		test -z "$libdir" && \
9311994689c1Smrg		  func_fatal_error "\`$lib' is not a valid libtool archive"
9312f353fbadSmrg		func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name"
9313994689c1Smrg		;;
9314994689c1Smrg	      esac
9315994689c1Smrg	    done
9316994689c1Smrg	    dlprefiles="$newdlprefiles"
9317994689c1Smrg	  else
9318994689c1Smrg	    newdlfiles=
9319994689c1Smrg	    for lib in $dlfiles; do
9320994689c1Smrg	      case $lib in
9321994689c1Smrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
9322994689c1Smrg		*) abs=`pwd`"/$lib" ;;
9323994689c1Smrg	      esac
9324f353fbadSmrg	      func_append newdlfiles " $abs"
9325994689c1Smrg	    done
9326994689c1Smrg	    dlfiles="$newdlfiles"
9327994689c1Smrg	    newdlprefiles=
9328994689c1Smrg	    for lib in $dlprefiles; do
9329994689c1Smrg	      case $lib in
9330994689c1Smrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
9331994689c1Smrg		*) abs=`pwd`"/$lib" ;;
9332994689c1Smrg	      esac
9333f353fbadSmrg	      func_append newdlprefiles " $abs"
9334994689c1Smrg	    done
9335994689c1Smrg	    dlprefiles="$newdlprefiles"
9336994689c1Smrg	  fi
9337994689c1Smrg	  $RM $output
9338994689c1Smrg	  # place dlname in correct position for cygwin
9339994689c1Smrg	  # In fact, it would be nice if we could use this code for all target
9340994689c1Smrg	  # systems that can't hard-code library paths into their executables
9341994689c1Smrg	  # and that have no shared library path variable independent of PATH,
9342994689c1Smrg	  # but it turns out we can't easily determine that from inspecting
9343994689c1Smrg	  # libtool variables, so we have to hard-code the OSs to which it
9344994689c1Smrg	  # applies here; at the moment, that means platforms that use the PE
9345994689c1Smrg	  # object format with DLL files.  See the long comment at the top of
9346994689c1Smrg	  # tests/bindir.at for full details.
9347994689c1Smrg	  tdlname=$dlname
9348994689c1Smrg	  case $host,$output,$installed,$module,$dlname in
9349994689c1Smrg	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
9350994689c1Smrg	      # If a -bindir argument was supplied, place the dll there.
9351994689c1Smrg	      if test "x$bindir" != x ;
9352994689c1Smrg	      then
9353994689c1Smrg		func_relative_path "$install_libdir" "$bindir"
9354994689c1Smrg		tdlname=$func_relative_path_result$dlname
9355994689c1Smrg	      else
9356994689c1Smrg		# Otherwise fall back on heuristic.
9357994689c1Smrg		tdlname=../bin/$dlname
9358994689c1Smrg	      fi
9359994689c1Smrg	      ;;
9360994689c1Smrg	  esac
9361994689c1Smrg	  $ECHO > $output "\
9362994689c1Smrg# $outputname - a libtool library file
9363994689c1Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
9364994689c1Smrg#
9365994689c1Smrg# Please DO NOT delete this file!
9366994689c1Smrg# It is necessary for linking the library.
93677a84e134Smrg
9368994689c1Smrg# The name that we can dlopen(3).
9369994689c1Smrgdlname='$tdlname'
93707a84e134Smrg
9371994689c1Smrg# Names of this library.
9372994689c1Smrglibrary_names='$library_names'
93737a84e134Smrg
9374994689c1Smrg# The name of the static archive.
9375994689c1Smrgold_library='$old_library'
93767a84e134Smrg
9377994689c1Smrg# Linker flags that can not go in dependency_libs.
9378994689c1Smrginherited_linker_flags='$new_inherited_linker_flags'
93797a84e134Smrg
9380994689c1Smrg# Libraries that this one depends upon.
9381994689c1Smrgdependency_libs='$dependency_libs'
93827a84e134Smrg
9383994689c1Smrg# Names of additional weak libraries provided by this library
9384994689c1Smrgweak_library_names='$weak_libs'
93857a84e134Smrg
9386994689c1Smrg# Version information for $libname.
9387994689c1Smrgcurrent=$current
9388994689c1Smrgage=$age
9389994689c1Smrgrevision=$revision
93907a84e134Smrg
9391994689c1Smrg# Is this an already installed library?
9392994689c1Smrginstalled=$installed
93937a84e134Smrg
9394994689c1Smrg# Should we warn about portability when linking against -modules?
9395994689c1Smrgshouldnotlink=$module
93967a84e134Smrg
9397994689c1Smrg# Files to dlopen/dlpreopen
9398994689c1Smrgdlopen='$dlfiles'
9399994689c1Smrgdlpreopen='$dlprefiles'
94007a84e134Smrg
9401994689c1Smrg# Directory that this library needs to be installed in:
9402994689c1Smrglibdir='$install_libdir'"
9403994689c1Smrg	  if test "$installed" = no && test "$need_relink" = yes; then
9404994689c1Smrg	    $ECHO >> $output "\
9405994689c1Smrgrelink_command=\"$relink_command\""
9406994689c1Smrg	  fi
9407994689c1Smrg	done
9408994689c1Smrg      }
94097a84e134Smrg
9410994689c1Smrg      # Do a symbolic link so that the libtool archive can be found in
9411994689c1Smrg      # LD_LIBRARY_PATH before the program is installed.
9412994689c1Smrg      func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
9413994689c1Smrg      ;;
9414994689c1Smrg    esac
9415994689c1Smrg    exit $EXIT_SUCCESS
9416994689c1Smrg}
9417e1e1713cSmrg
9418f353fbadSmrg{ test "$opt_mode" = link || test "$opt_mode" = relink; } &&
9419994689c1Smrg    func_mode_link ${1+"$@"}
94207a84e134Smrg
94217a84e134Smrg
9422994689c1Smrg# func_mode_uninstall arg...
9423994689c1Smrgfunc_mode_uninstall ()
9424994689c1Smrg{
9425994689c1Smrg    $opt_debug
9426994689c1Smrg    RM="$nonopt"
94277a84e134Smrg    files=
94287a84e134Smrg    rmforce=
94297a84e134Smrg    exit_status=0
94307a84e134Smrg
94317a84e134Smrg    # This variable tells wrapper scripts just to set variables rather
94327a84e134Smrg    # than running their programs.
94337a84e134Smrg    libtool_install_magic="$magic"
94347a84e134Smrg
94357a84e134Smrg    for arg
94367a84e134Smrg    do
94377a84e134Smrg      case $arg in
9438f353fbadSmrg      -f) func_append RM " $arg"; rmforce=yes ;;
9439f353fbadSmrg      -*) func_append RM " $arg" ;;
9440f353fbadSmrg      *) func_append files " $arg" ;;
94417a84e134Smrg      esac
94427a84e134Smrg    done
94437a84e134Smrg
9444994689c1Smrg    test -z "$RM" && \
9445994689c1Smrg      func_fatal_help "you must specify an RM program"
94467a84e134Smrg
94477a84e134Smrg    rmdirs=
94487a84e134Smrg
94497a84e134Smrg    for file in $files; do
9450994689c1Smrg      func_dirname "$file" "" "."
9451994689c1Smrg      dir="$func_dirname_result"
9452994689c1Smrg      if test "X$dir" = X.; then
9453f353fbadSmrg	odir="$objdir"
94547a84e134Smrg      else
9455f353fbadSmrg	odir="$dir/$objdir"
94567a84e134Smrg      fi
9457994689c1Smrg      func_basename "$file"
9458994689c1Smrg      name="$func_basename_result"
9459f353fbadSmrg      test "$opt_mode" = uninstall && odir="$dir"
94607a84e134Smrg
9461f353fbadSmrg      # Remember odir for removal later, being careful to avoid duplicates
9462f353fbadSmrg      if test "$opt_mode" = clean; then
94637a84e134Smrg	case " $rmdirs " in
9464f353fbadSmrg	  *" $odir "*) ;;
9465f353fbadSmrg	  *) func_append rmdirs " $odir" ;;
94667a84e134Smrg	esac
94677a84e134Smrg      fi
94687a84e134Smrg
94697a84e134Smrg      # Don't error if the file doesn't exist and rm -f was used.
9470994689c1Smrg      if { test -L "$file"; } >/dev/null 2>&1 ||
9471994689c1Smrg	 { test -h "$file"; } >/dev/null 2>&1 ||
9472994689c1Smrg	 test -f "$file"; then
94737a84e134Smrg	:
94747a84e134Smrg      elif test -d "$file"; then
94757a84e134Smrg	exit_status=1
94767a84e134Smrg	continue
94777a84e134Smrg      elif test "$rmforce" = yes; then
94787a84e134Smrg	continue
94797a84e134Smrg      fi
94807a84e134Smrg
94817a84e134Smrg      rmfiles="$file"
94827a84e134Smrg
94837a84e134Smrg      case $name in
94847a84e134Smrg      *.la)
94857a84e134Smrg	# Possibly a libtool archive, so verify it.
9486994689c1Smrg	if func_lalib_p "$file"; then
9487994689c1Smrg	  func_source $dir/$name
94887a84e134Smrg
94897a84e134Smrg	  # Delete the libtool libraries and symlinks.
94907a84e134Smrg	  for n in $library_names; do
9491f353fbadSmrg	    func_append rmfiles " $odir/$n"
94927a84e134Smrg	  done
9493f353fbadSmrg	  test -n "$old_library" && func_append rmfiles " $odir/$old_library"
94947a84e134Smrg
9495f353fbadSmrg	  case "$opt_mode" in
94967a84e134Smrg	  clean)
9497f353fbadSmrg	    case " $library_names " in
94987a84e134Smrg	    *" $dlname "*) ;;
9499f353fbadSmrg	    *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;;
95007a84e134Smrg	    esac
9501f353fbadSmrg	    test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i"
95027a84e134Smrg	    ;;
95037a84e134Smrg	  uninstall)
95047a84e134Smrg	    if test -n "$library_names"; then
95057a84e134Smrg	      # Do each command in the postuninstall commands.
9506994689c1Smrg	      func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
95077a84e134Smrg	    fi
95087a84e134Smrg
95097a84e134Smrg	    if test -n "$old_library"; then
95107a84e134Smrg	      # Do each command in the old_postuninstall commands.
9511994689c1Smrg	      func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
95127a84e134Smrg	    fi
95137a84e134Smrg	    # FIXME: should reinstall the best remaining shared library.
95147a84e134Smrg	    ;;
95157a84e134Smrg	  esac
95167a84e134Smrg	fi
95177a84e134Smrg	;;
95187a84e134Smrg
95197a84e134Smrg      *.lo)
95207a84e134Smrg	# Possibly a libtool object, so verify it.
9521994689c1Smrg	if func_lalib_p "$file"; then
95227a84e134Smrg
95237a84e134Smrg	  # Read the .lo file
9524994689c1Smrg	  func_source $dir/$name
95257a84e134Smrg
95267a84e134Smrg	  # Add PIC object to the list of files to remove.
9527994689c1Smrg	  if test -n "$pic_object" &&
9528994689c1Smrg	     test "$pic_object" != none; then
9529f353fbadSmrg	    func_append rmfiles " $dir/$pic_object"
95307a84e134Smrg	  fi
95317a84e134Smrg
95327a84e134Smrg	  # Add non-PIC object to the list of files to remove.
9533994689c1Smrg	  if test -n "$non_pic_object" &&
9534994689c1Smrg	     test "$non_pic_object" != none; then
9535f353fbadSmrg	    func_append rmfiles " $dir/$non_pic_object"
95367a84e134Smrg	  fi
95377a84e134Smrg	fi
95387a84e134Smrg	;;
95397a84e134Smrg
95407a84e134Smrg      *)
9541f353fbadSmrg	if test "$opt_mode" = clean ; then
95427a84e134Smrg	  noexename=$name
95437a84e134Smrg	  case $file in
95447a84e134Smrg	  *.exe)
9545994689c1Smrg	    func_stripname '' '.exe' "$file"
9546994689c1Smrg	    file=$func_stripname_result
9547994689c1Smrg	    func_stripname '' '.exe' "$name"
9548994689c1Smrg	    noexename=$func_stripname_result
95497a84e134Smrg	    # $file with .exe has already been added to rmfiles,
95507a84e134Smrg	    # add $file without .exe
9551f353fbadSmrg	    func_append rmfiles " $file"
95527a84e134Smrg	    ;;
95537a84e134Smrg	  esac
95547a84e134Smrg	  # Do a test to see if this is a libtool program.
9555994689c1Smrg	  if func_ltwrapper_p "$file"; then
9556994689c1Smrg	    if func_ltwrapper_executable_p "$file"; then
9557994689c1Smrg	      func_ltwrapper_scriptname "$file"
9558994689c1Smrg	      relink_command=
9559994689c1Smrg	      func_source $func_ltwrapper_scriptname_result
9560f353fbadSmrg	      func_append rmfiles " $func_ltwrapper_scriptname_result"
9561994689c1Smrg	    else
9562994689c1Smrg	      relink_command=
9563994689c1Smrg	      func_source $dir/$noexename
9564994689c1Smrg	    fi
95657a84e134Smrg
95667a84e134Smrg	    # note $name still contains .exe if it was in $file originally
95677a84e134Smrg	    # as does the version of $file that was added into $rmfiles
9568f353fbadSmrg	    func_append rmfiles " $odir/$name $odir/${name}S.${objext}"
95697a84e134Smrg	    if test "$fast_install" = yes && test -n "$relink_command"; then
9570f353fbadSmrg	      func_append rmfiles " $odir/lt-$name"
95717a84e134Smrg	    fi
95727a84e134Smrg	    if test "X$noexename" != "X$name" ; then
9573f353fbadSmrg	      func_append rmfiles " $odir/lt-${noexename}.c"
95747a84e134Smrg	    fi
95757a84e134Smrg	  fi
95767a84e134Smrg	fi
95777a84e134Smrg	;;
95787a84e134Smrg      esac
9579994689c1Smrg      func_show_eval "$RM $rmfiles" 'exit_status=1'
95807a84e134Smrg    done
95817a84e134Smrg
95827a84e134Smrg    # Try to remove the ${objdir}s in the directories where we deleted files
95837a84e134Smrg    for dir in $rmdirs; do
95847a84e134Smrg      if test -d "$dir"; then
9585994689c1Smrg	func_show_eval "rmdir $dir >/dev/null 2>&1"
95867a84e134Smrg      fi
95877a84e134Smrg    done
95887a84e134Smrg
95897a84e134Smrg    exit $exit_status
9590994689c1Smrg}
95917a84e134Smrg
9592f353fbadSmrg{ test "$opt_mode" = uninstall || test "$opt_mode" = clean; } &&
9593994689c1Smrg    func_mode_uninstall ${1+"$@"}
9594775e7de9Smrg
9595f353fbadSmrgtest -z "$opt_mode" && {
9596994689c1Smrg  help="$generic_help"
9597994689c1Smrg  func_fatal_help "you must specify a MODE"
9598994689c1Smrg}
9599994689c1Smrg
9600994689c1Smrgtest -z "$exec_cmd" && \
9601f353fbadSmrg  func_fatal_help "invalid operation mode \`$opt_mode'"
96027a84e134Smrg
96037a84e134Smrgif test -n "$exec_cmd"; then
9604994689c1Smrg  eval exec "$exec_cmd"
96057a84e134Smrg  exit $EXIT_FAILURE
96067a84e134Smrgfi
96077a84e134Smrg
9608994689c1Smrgexit $exit_status
9609e1e1713cSmrg
96107a84e134Smrg
96117a84e134Smrg# The TAGs below are defined such that we never get into a situation
96127a84e134Smrg# in which we disable both kinds of libraries.  Given conflicting
96137a84e134Smrg# choices, we go for a static library, that is the most portable,
96147a84e134Smrg# since we can't tell whether shared libraries were disabled because
96157a84e134Smrg# the user asked for that or because the platform doesn't support
96167a84e134Smrg# them.  This is particularly important on AIX, because we don't
96177a84e134Smrg# support having both static and shared libraries enabled at the same
96187a84e134Smrg# time on that platform, so we default to a shared-only configuration.
96197a84e134Smrg# If a disable-shared tag is given, we'll fallback to a static-only
96207a84e134Smrg# configuration.  But we'll never go from static-only to shared-only.
96217a84e134Smrg
96227a84e134Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
9623994689c1Smrgbuild_libtool_libs=no
9624994689c1Smrgbuild_old_libs=yes
96257a84e134Smrg# ### END LIBTOOL TAG CONFIG: disable-shared
96267a84e134Smrg
96277a84e134Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static
9628994689c1Smrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
96297a84e134Smrg# ### END LIBTOOL TAG CONFIG: disable-static
96307a84e134Smrg
96317a84e134Smrg# Local Variables:
96327a84e134Smrg# mode:shell-script
96337a84e134Smrg# sh-indentation:2
96347a84e134Smrg# End:
9635994689c1Smrg# vi:sw=2
9636994689c1Smrg
9637