ltmain.sh revision 421c997b
1994689c1Smrg
2421c997bSmrg# libtool (GNU libtool) 2.4.2
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,
6421c997bSmrg# 2007, 2008, 2009, 2010, 2011 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)
44421c997bSmrg#       --no-warn            don't display warning messages
45994689c1Smrg#       --tag=TAG            use configuration variables from tag TAG
46994689c1Smrg#   -v, --verbose            print more informational messages than default
47994689c1Smrg#       --no-verbose         don't print the extra informational messages
48994689c1Smrg#       --version            print version information
49994689c1Smrg#   -h, --help, --help-all   print short, long, or detailed help message
50994689c1Smrg#
51994689c1Smrg# MODE must be one of the following:
52994689c1Smrg#
53994689c1Smrg#         clean              remove files from the build directory
54994689c1Smrg#         compile            compile a source file into a libtool object
55994689c1Smrg#         execute            automatically set library path, then run a program
56994689c1Smrg#         finish             complete the installation of libtool libraries
57994689c1Smrg#         install            install libraries or executables
58994689c1Smrg#         link               create a library or an executable
59994689c1Smrg#         uninstall          remove libraries from an installed directory
60994689c1Smrg#
61994689c1Smrg# MODE-ARGS vary depending on the MODE.  When passed as first option,
62994689c1Smrg# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that.
63994689c1Smrg# Try `$progname --help --mode=MODE' for a more detailed description of MODE.
64994689c1Smrg#
65994689c1Smrg# When reporting a bug, please describe a test case to reproduce it and
66994689c1Smrg# include the following information:
67994689c1Smrg#
68994689c1Smrg#         host-triplet:	$host
69994689c1Smrg#         shell:		$SHELL
70994689c1Smrg#         compiler:		$LTCC
71994689c1Smrg#         compiler flags:		$LTCFLAGS
72994689c1Smrg#         linker:		$LD (gnu? $with_gnu_ld)
73421c997bSmrg#         $progname:	(GNU libtool) 2.4.2
74994689c1Smrg#         automake:	$automake_version
75994689c1Smrg#         autoconf:	$autoconf_version
76994689c1Smrg#
77994689c1Smrg# Report bugs to <bug-libtool@gnu.org>.
78f353fbadSmrg# GNU libtool home page: <http://www.gnu.org/software/libtool/>.
79f353fbadSmrg# General help using GNU software: <http://www.gnu.org/gethelp/>.
807a84e134Smrg
81994689c1SmrgPROGRAM=libtool
827a84e134SmrgPACKAGE=libtool
83421c997bSmrgVERSION=2.4.2
84994689c1SmrgTIMESTAMP=""
85421c997bSmrgpackage_revision=1.3337
86ab902922Smrg
87994689c1Smrg# Be Bourne compatible
88ab902922Smrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
89ab902922Smrg  emulate sh
90ab902922Smrg  NULLCMD=:
91ab902922Smrg  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
92ab902922Smrg  # is contrary to our usage.  Disable this feature.
93ab902922Smrg  alias -g '${1+"$@"}'='"$@"'
947a84e134Smrg  setopt NO_GLOB_SUBST
95ab902922Smrgelse
96ab902922Smrg  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
977a84e134Smrgfi
98ab902922SmrgBIN_SH=xpg4; export BIN_SH # for Tru64
99ab902922SmrgDUALCASE=1; export DUALCASE # for MKS sh
1007a84e134Smrg
101994689c1Smrg# A function that is used when there is no print builtin or printf.
102994689c1Smrgfunc_fallback_echo ()
103994689c1Smrg{
104994689c1Smrg  eval 'cat <<_LTECHO_EOF
105994689c1Smrg$1
106994689c1Smrg_LTECHO_EOF'
107994689c1Smrg}
108e1e1713cSmrg
109994689c1Smrg# NLS nuisances: We save the old values to restore during execute mode.
110994689c1Smrglt_user_locale=
111994689c1Smrglt_safe_locale=
112ab902922Smrgfor lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
113ab902922Smrgdo
114ab902922Smrg  eval "if test \"\${$lt_var+set}\" = set; then
115994689c1Smrg          save_$lt_var=\$$lt_var
116994689c1Smrg          $lt_var=C
117ab902922Smrg	  export $lt_var
118994689c1Smrg	  lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\"
119994689c1Smrg	  lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
120ab902922Smrg	fi"
121ab902922Smrgdone
122994689c1SmrgLC_ALL=C
123994689c1SmrgLANGUAGE=C
124994689c1Smrgexport LANGUAGE LC_ALL
125ab902922Smrg
126994689c1Smrg$lt_unset CDPATH
127994689c1Smrg
128994689c1Smrg
129994689c1Smrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
130994689c1Smrg# is ksh but when the shell is invoked as "sh" and the current value of
131994689c1Smrg# the _XPG environment variable is not equal to 1 (one), the special
132994689c1Smrg# positional parameter $0, within a function call, is the name of the
133994689c1Smrg# function.
134994689c1Smrgprogpath="$0"
135994689c1Smrg
136994689c1Smrg
137994689c1Smrg
138994689c1Smrg: ${CP="cp -f"}
139994689c1Smrgtest "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'}
140994689c1Smrg: ${MAKE="make"}
141994689c1Smrg: ${MKDIR="mkdir"}
142994689c1Smrg: ${MV="mv -f"}
143994689c1Smrg: ${RM="rm -f"}
144994689c1Smrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
145994689c1Smrg: ${Xsed="$SED -e 1s/^X//"}
146994689c1Smrg
147994689c1Smrg# Global variables:
148994689c1SmrgEXIT_SUCCESS=0
149994689c1SmrgEXIT_FAILURE=1
150994689c1SmrgEXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
151994689c1SmrgEXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
152994689c1Smrg
153994689c1Smrgexit_status=$EXIT_SUCCESS
1547a84e134Smrg
1557a84e134Smrg# Make sure IFS has a sensible default
1567a84e134Smrglt_nl='
1577a84e134Smrg'
1587a84e134SmrgIFS=" 	$lt_nl"
1597a84e134Smrg
160994689c1Smrgdirname="s,/[^/]*$,,"
161994689c1Smrgbasename="s,^.*/,,"
162994689c1Smrg
163f353fbadSmrg# func_dirname file append nondir_replacement
164f353fbadSmrg# Compute the dirname of FILE.  If nonempty, add APPEND to the result,
165f353fbadSmrg# otherwise set result to NONDIR_REPLACEMENT.
166f353fbadSmrgfunc_dirname ()
167f353fbadSmrg{
168f353fbadSmrg    func_dirname_result=`$ECHO "${1}" | $SED "$dirname"`
169f353fbadSmrg    if test "X$func_dirname_result" = "X${1}"; then
170f353fbadSmrg      func_dirname_result="${3}"
171f353fbadSmrg    else
172f353fbadSmrg      func_dirname_result="$func_dirname_result${2}"
173f353fbadSmrg    fi
174f353fbadSmrg} # func_dirname may be replaced by extended shell implementation
175f353fbadSmrg
176f353fbadSmrg
177f353fbadSmrg# func_basename file
178f353fbadSmrgfunc_basename ()
179f353fbadSmrg{
180f353fbadSmrg    func_basename_result=`$ECHO "${1}" | $SED "$basename"`
181f353fbadSmrg} # func_basename may be replaced by extended shell implementation
182f353fbadSmrg
183f353fbadSmrg
184994689c1Smrg# func_dirname_and_basename file append nondir_replacement
185994689c1Smrg# perform func_basename and func_dirname in a single function
186994689c1Smrg# call:
187994689c1Smrg#   dirname:  Compute the dirname of FILE.  If nonempty,
188994689c1Smrg#             add APPEND to the result, otherwise set result
189994689c1Smrg#             to NONDIR_REPLACEMENT.
190994689c1Smrg#             value returned in "$func_dirname_result"
191994689c1Smrg#   basename: Compute filename of FILE.
192994689c1Smrg#             value retuned in "$func_basename_result"
193994689c1Smrg# Implementation must be kept synchronized with func_dirname
194994689c1Smrg# and func_basename. For efficiency, we do not delegate to
195994689c1Smrg# those functions but instead duplicate the functionality here.
196994689c1Smrgfunc_dirname_and_basename ()
197994689c1Smrg{
198f353fbadSmrg    # Extract subdirectory from the argument.
199f353fbadSmrg    func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"`
200f353fbadSmrg    if test "X$func_dirname_result" = "X${1}"; then
201f353fbadSmrg      func_dirname_result="${3}"
202f353fbadSmrg    else
203f353fbadSmrg      func_dirname_result="$func_dirname_result${2}"
204f353fbadSmrg    fi
205f353fbadSmrg    func_basename_result=`$ECHO "${1}" | $SED -e "$basename"`
206f353fbadSmrg} # func_dirname_and_basename may be replaced by extended shell implementation
207f353fbadSmrg
208f353fbadSmrg
209f353fbadSmrg# func_stripname prefix suffix name
210f353fbadSmrg# strip PREFIX and SUFFIX off of NAME.
211f353fbadSmrg# PREFIX and SUFFIX must not contain globbing or regex special
212f353fbadSmrg# characters, hashes, percent signs, but SUFFIX may contain a leading
213f353fbadSmrg# dot (in which case that matches only a dot).
214f353fbadSmrg# func_strip_suffix prefix name
215f353fbadSmrgfunc_stripname ()
216f353fbadSmrg{
217f353fbadSmrg    case ${2} in
218f353fbadSmrg      .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;;
219f353fbadSmrg      *)  func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;;
220f353fbadSmrg    esac
221f353fbadSmrg} # func_stripname may be replaced by extended shell implementation
222775e7de9Smrg
223994689c1Smrg
224994689c1Smrg# These SED scripts presuppose an absolute path with a trailing slash.
225994689c1Smrgpathcar='s,^/\([^/]*\).*$,\1,'
226994689c1Smrgpathcdr='s,^/[^/]*,,'
227994689c1Smrgremovedotparts=':dotsl
228994689c1Smrg		s@/\./@/@g
229994689c1Smrg		t dotsl
230994689c1Smrg		s,/\.$,/,'
231994689c1Smrgcollapseslashes='s@/\{1,\}@/@g'
232994689c1Smrgfinalslash='s,/*$,/,'
233994689c1Smrg
234994689c1Smrg# func_normal_abspath PATH
235994689c1Smrg# Remove doubled-up and trailing slashes, "." path components,
236994689c1Smrg# and cancel out any ".." path components in PATH after making
237994689c1Smrg# it an absolute path.
238994689c1Smrg#             value returned in "$func_normal_abspath_result"
239994689c1Smrgfunc_normal_abspath ()
240994689c1Smrg{
241994689c1Smrg  # Start from root dir and reassemble the path.
242994689c1Smrg  func_normal_abspath_result=
243994689c1Smrg  func_normal_abspath_tpath=$1
244994689c1Smrg  func_normal_abspath_altnamespace=
245994689c1Smrg  case $func_normal_abspath_tpath in
246994689c1Smrg    "")
247994689c1Smrg      # Empty path, that just means $cwd.
248994689c1Smrg      func_stripname '' '/' "`pwd`"
249994689c1Smrg      func_normal_abspath_result=$func_stripname_result
250994689c1Smrg      return
251994689c1Smrg    ;;
252994689c1Smrg    # The next three entries are used to spot a run of precisely
253994689c1Smrg    # two leading slashes without using negated character classes;
254994689c1Smrg    # we take advantage of case's first-match behaviour.
255994689c1Smrg    ///*)
256994689c1Smrg      # Unusual form of absolute path, do nothing.
257994689c1Smrg    ;;
258994689c1Smrg    //*)
259994689c1Smrg      # Not necessarily an ordinary path; POSIX reserves leading '//'
260994689c1Smrg      # and for example Cygwin uses it to access remote file shares
261994689c1Smrg      # over CIFS/SMB, so we conserve a leading double slash if found.
262994689c1Smrg      func_normal_abspath_altnamespace=/
263994689c1Smrg    ;;
264994689c1Smrg    /*)
265994689c1Smrg      # Absolute path, do nothing.
266994689c1Smrg    ;;
267994689c1Smrg    *)
268994689c1Smrg      # Relative path, prepend $cwd.
269994689c1Smrg      func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
270994689c1Smrg    ;;
271994689c1Smrg  esac
272994689c1Smrg  # Cancel out all the simple stuff to save iterations.  We also want
273994689c1Smrg  # the path to end with a slash for ease of parsing, so make sure
274994689c1Smrg  # there is one (and only one) here.
275994689c1Smrg  func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
276994689c1Smrg        -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"`
277994689c1Smrg  while :; do
278994689c1Smrg    # Processed it all yet?
279994689c1Smrg    if test "$func_normal_abspath_tpath" = / ; then
280994689c1Smrg      # If we ascended to the root using ".." the result may be empty now.
281994689c1Smrg      if test -z "$func_normal_abspath_result" ; then
282994689c1Smrg        func_normal_abspath_result=/
283994689c1Smrg      fi
284994689c1Smrg      break
285994689c1Smrg    fi
286994689c1Smrg    func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
287994689c1Smrg        -e "$pathcar"`
288994689c1Smrg    func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
289994689c1Smrg        -e "$pathcdr"`
290994689c1Smrg    # Figure out what to do with it
291994689c1Smrg    case $func_normal_abspath_tcomponent in
292994689c1Smrg      "")
293994689c1Smrg        # Trailing empty path component, ignore it.
294994689c1Smrg      ;;
295994689c1Smrg      ..)
296994689c1Smrg        # Parent dir; strip last assembled component from result.
297994689c1Smrg        func_dirname "$func_normal_abspath_result"
298994689c1Smrg        func_normal_abspath_result=$func_dirname_result
299994689c1Smrg      ;;
300994689c1Smrg      *)
301994689c1Smrg        # Actual path component, append it.
302994689c1Smrg        func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent
303994689c1Smrg      ;;
304994689c1Smrg    esac
305994689c1Smrg  done
306994689c1Smrg  # Restore leading double-slash if one was found on entry.
307994689c1Smrg  func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
308994689c1Smrg}
309994689c1Smrg
310994689c1Smrg# func_relative_path SRCDIR DSTDIR
311994689c1Smrg# generates a relative path from SRCDIR to DSTDIR, with a trailing
312994689c1Smrg# slash if non-empty, suitable for immediately appending a filename
313994689c1Smrg# without needing to append a separator.
314994689c1Smrg#             value returned in "$func_relative_path_result"
315994689c1Smrgfunc_relative_path ()
316994689c1Smrg{
317994689c1Smrg  func_relative_path_result=
318994689c1Smrg  func_normal_abspath "$1"
319994689c1Smrg  func_relative_path_tlibdir=$func_normal_abspath_result
320994689c1Smrg  func_normal_abspath "$2"
321994689c1Smrg  func_relative_path_tbindir=$func_normal_abspath_result
322994689c1Smrg
323994689c1Smrg  # Ascend the tree starting from libdir
324994689c1Smrg  while :; do
325994689c1Smrg    # check if we have found a prefix of bindir
326994689c1Smrg    case $func_relative_path_tbindir in
327994689c1Smrg      $func_relative_path_tlibdir)
328994689c1Smrg        # found an exact match
329994689c1Smrg        func_relative_path_tcancelled=
330994689c1Smrg        break
331994689c1Smrg        ;;
332994689c1Smrg      $func_relative_path_tlibdir*)
333994689c1Smrg        # found a matching prefix
334994689c1Smrg        func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
335994689c1Smrg        func_relative_path_tcancelled=$func_stripname_result
336994689c1Smrg        if test -z "$func_relative_path_result"; then
337994689c1Smrg          func_relative_path_result=.
338994689c1Smrg        fi
339994689c1Smrg        break
340994689c1Smrg        ;;
341994689c1Smrg      *)
342994689c1Smrg        func_dirname $func_relative_path_tlibdir
343994689c1Smrg        func_relative_path_tlibdir=${func_dirname_result}
344994689c1Smrg        if test "x$func_relative_path_tlibdir" = x ; then
345994689c1Smrg          # Have to descend all the way to the root!
346994689c1Smrg          func_relative_path_result=../$func_relative_path_result
347994689c1Smrg          func_relative_path_tcancelled=$func_relative_path_tbindir
348994689c1Smrg          break
349994689c1Smrg        fi
350994689c1Smrg        func_relative_path_result=../$func_relative_path_result
351994689c1Smrg        ;;
352994689c1Smrg    esac
353994689c1Smrg  done
354994689c1Smrg
355994689c1Smrg  # Now calculate path; take care to avoid doubling-up slashes.
356994689c1Smrg  func_stripname '' '/' "$func_relative_path_result"
357994689c1Smrg  func_relative_path_result=$func_stripname_result
358994689c1Smrg  func_stripname '/' '/' "$func_relative_path_tcancelled"
359994689c1Smrg  if test "x$func_stripname_result" != x ; then
360994689c1Smrg    func_relative_path_result=${func_relative_path_result}/${func_stripname_result}
361994689c1Smrg  fi
362994689c1Smrg
363994689c1Smrg  # Normalisation. If bindir is libdir, return empty string,
364994689c1Smrg  # else relative path ending with a slash; either way, target
365994689c1Smrg  # file name can be directly appended.
366994689c1Smrg  if test ! -z "$func_relative_path_result"; then
367994689c1Smrg    func_stripname './' '' "$func_relative_path_result/"
368994689c1Smrg    func_relative_path_result=$func_stripname_result
369994689c1Smrg  fi
370994689c1Smrg}
371994689c1Smrg
372994689c1Smrg# The name of this program:
373994689c1Smrgfunc_dirname_and_basename "$progpath"
374994689c1Smrgprogname=$func_basename_result
375994689c1Smrg
376994689c1Smrg# Make sure we have an absolute path for reexecution:
377994689c1Smrgcase $progpath in
378994689c1Smrg  [\\/]*|[A-Za-z]:\\*) ;;
379994689c1Smrg  *[\\/]*)
380994689c1Smrg     progdir=$func_dirname_result
381994689c1Smrg     progdir=`cd "$progdir" && pwd`
382994689c1Smrg     progpath="$progdir/$progname"
383994689c1Smrg     ;;
384994689c1Smrg  *)
385994689c1Smrg     save_IFS="$IFS"
386421c997bSmrg     IFS=${PATH_SEPARATOR-:}
387994689c1Smrg     for progdir in $PATH; do
388994689c1Smrg       IFS="$save_IFS"
389994689c1Smrg       test -x "$progdir/$progname" && break
390994689c1Smrg     done
391994689c1Smrg     IFS="$save_IFS"
392994689c1Smrg     test -n "$progdir" || progdir=`pwd`
393994689c1Smrg     progpath="$progdir/$progname"
394994689c1Smrg     ;;
395994689c1Smrgesac
396994689c1Smrg
397994689c1Smrg# Sed substitution that helps us do robust quoting.  It backslashifies
398994689c1Smrg# metacharacters that are still active within double-quoted strings.
399994689c1SmrgXsed="${SED}"' -e 1s/^X//'
400994689c1Smrgsed_quote_subst='s/\([`"$\\]\)/\\\1/g'
401994689c1Smrg
402994689c1Smrg# Same as above, but do not quote variable references.
403994689c1Smrgdouble_quote_subst='s/\(["`\\]\)/\\\1/g'
404994689c1Smrg
405f353fbadSmrg# Sed substitution that turns a string into a regex matching for the
406f353fbadSmrg# string literally.
407f353fbadSmrgsed_make_literal_regex='s,[].[^$\\*\/],\\&,g'
408f353fbadSmrg
409f353fbadSmrg# Sed substitution that converts a w32 file name or path
410f353fbadSmrg# which contains forward slashes, into one that contains
411f353fbadSmrg# (escaped) backslashes.  A very naive implementation.
412f353fbadSmrglt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
413f353fbadSmrg
414994689c1Smrg# Re-`\' parameter expansions in output of double_quote_subst that were
415994689c1Smrg# `\'-ed in input to the same.  If an odd number of `\' preceded a '$'
416994689c1Smrg# in input to double_quote_subst, that '$' was protected from expansion.
417994689c1Smrg# Since each input `\' is now two `\'s, look for any number of runs of
418994689c1Smrg# four `\'s followed by two `\'s and then a '$'.  `\' that '$'.
419994689c1Smrgbs='\\'
420994689c1Smrgbs2='\\\\'
421994689c1Smrgbs4='\\\\\\\\'
422994689c1Smrgdollar='\$'
423994689c1Smrgsed_double_backslash="\
424994689c1Smrg  s/$bs4/&\\
425994689c1Smrg/g
426994689c1Smrg  s/^$bs2$dollar/$bs&/
427994689c1Smrg  s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
428994689c1Smrg  s/\n//g"
429994689c1Smrg
430994689c1Smrg# Standard options:
431994689c1Smrgopt_dry_run=false
432994689c1Smrgopt_help=false
433994689c1Smrgopt_quiet=false
434994689c1Smrgopt_verbose=false
435994689c1Smrgopt_warning=:
436994689c1Smrg
437994689c1Smrg# func_echo arg...
438994689c1Smrg# Echo program name prefixed message, along with the current mode
439994689c1Smrg# name if it has been set yet.
440994689c1Smrgfunc_echo ()
441994689c1Smrg{
442f353fbadSmrg    $ECHO "$progname: ${opt_mode+$opt_mode: }$*"
443994689c1Smrg}
444994689c1Smrg
445994689c1Smrg# func_verbose arg...
446994689c1Smrg# Echo program name prefixed message in verbose mode only.
447994689c1Smrgfunc_verbose ()
448994689c1Smrg{
449994689c1Smrg    $opt_verbose && func_echo ${1+"$@"}
450994689c1Smrg
451994689c1Smrg    # A bug in bash halts the script if the last line of a function
452994689c1Smrg    # fails when set -e is in force, so we need another command to
453994689c1Smrg    # work around that:
454994689c1Smrg    :
455994689c1Smrg}
456994689c1Smrg
457994689c1Smrg# func_echo_all arg...
458994689c1Smrg# Invoke $ECHO with all args, space-separated.
459994689c1Smrgfunc_echo_all ()
460994689c1Smrg{
461994689c1Smrg    $ECHO "$*"
462994689c1Smrg}
463994689c1Smrg
464994689c1Smrg# func_error arg...
465994689c1Smrg# Echo program name prefixed message to standard error.
466994689c1Smrgfunc_error ()
467994689c1Smrg{
468f353fbadSmrg    $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2
469994689c1Smrg}
470994689c1Smrg
471994689c1Smrg# func_warning arg...
472994689c1Smrg# Echo program name prefixed warning message to standard error.
473994689c1Smrgfunc_warning ()
474994689c1Smrg{
475f353fbadSmrg    $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2
476994689c1Smrg
477994689c1Smrg    # bash bug again:
478994689c1Smrg    :
479994689c1Smrg}
480994689c1Smrg
481994689c1Smrg# func_fatal_error arg...
482994689c1Smrg# Echo program name prefixed message to standard error, and exit.
483994689c1Smrgfunc_fatal_error ()
484994689c1Smrg{
485994689c1Smrg    func_error ${1+"$@"}
486994689c1Smrg    exit $EXIT_FAILURE
487994689c1Smrg}
488994689c1Smrg
489994689c1Smrg# func_fatal_help arg...
490994689c1Smrg# Echo program name prefixed message to standard error, followed by
491994689c1Smrg# a help hint, and exit.
492994689c1Smrgfunc_fatal_help ()
493994689c1Smrg{
494994689c1Smrg    func_error ${1+"$@"}
495994689c1Smrg    func_fatal_error "$help"
496994689c1Smrg}
497994689c1Smrghelp="Try \`$progname --help' for more information."  ## default
498994689c1Smrg
499994689c1Smrg
500994689c1Smrg# func_grep expression filename
501994689c1Smrg# Check whether EXPRESSION matches any line of FILENAME, without output.
502994689c1Smrgfunc_grep ()
503994689c1Smrg{
504994689c1Smrg    $GREP "$1" "$2" >/dev/null 2>&1
505994689c1Smrg}
506994689c1Smrg
507994689c1Smrg
508994689c1Smrg# func_mkdir_p directory-path
509994689c1Smrg# Make sure the entire path to DIRECTORY-PATH is available.
510994689c1Smrgfunc_mkdir_p ()
511994689c1Smrg{
512994689c1Smrg    my_directory_path="$1"
513994689c1Smrg    my_dir_list=
514994689c1Smrg
515994689c1Smrg    if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
516994689c1Smrg
517994689c1Smrg      # Protect directory names starting with `-'
518994689c1Smrg      case $my_directory_path in
519994689c1Smrg        -*) my_directory_path="./$my_directory_path" ;;
520994689c1Smrg      esac
521994689c1Smrg
522994689c1Smrg      # While some portion of DIR does not yet exist...
523994689c1Smrg      while test ! -d "$my_directory_path"; do
524994689c1Smrg        # ...make a list in topmost first order.  Use a colon delimited
525994689c1Smrg	# list incase some portion of path contains whitespace.
526994689c1Smrg        my_dir_list="$my_directory_path:$my_dir_list"
527994689c1Smrg
528994689c1Smrg        # If the last portion added has no slash in it, the list is done
529994689c1Smrg        case $my_directory_path in */*) ;; *) break ;; esac
530994689c1Smrg
531994689c1Smrg        # ...otherwise throw away the child directory and loop
532994689c1Smrg        my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"`
533994689c1Smrg      done
534994689c1Smrg      my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'`
535994689c1Smrg
536994689c1Smrg      save_mkdir_p_IFS="$IFS"; IFS=':'
537994689c1Smrg      for my_dir in $my_dir_list; do
538994689c1Smrg	IFS="$save_mkdir_p_IFS"
539994689c1Smrg        # mkdir can fail with a `File exist' error if two processes
540994689c1Smrg        # try to create one of the directories concurrently.  Don't
541994689c1Smrg        # stop in that case!
542994689c1Smrg        $MKDIR "$my_dir" 2>/dev/null || :
543994689c1Smrg      done
544994689c1Smrg      IFS="$save_mkdir_p_IFS"
545994689c1Smrg
546994689c1Smrg      # Bail out if we (or some other process) failed to create a directory.
547994689c1Smrg      test -d "$my_directory_path" || \
548994689c1Smrg        func_fatal_error "Failed to create \`$1'"
549994689c1Smrg    fi
550994689c1Smrg}
5517a84e134Smrg
5527a84e134Smrg
5537a84e134Smrg# func_mktempdir [string]
5547a84e134Smrg# Make a temporary directory that won't clash with other running
5557a84e134Smrg# libtool processes, and avoids race conditions if possible.  If
5567a84e134Smrg# given, STRING is the basename for that directory.
5577a84e134Smrgfunc_mktempdir ()
5587a84e134Smrg{
5597a84e134Smrg    my_template="${TMPDIR-/tmp}/${1-$progname}"
5607a84e134Smrg
561994689c1Smrg    if test "$opt_dry_run" = ":"; then
5627a84e134Smrg      # Return a directory name, but don't create it in dry-run mode
5637a84e134Smrg      my_tmpdir="${my_template}-$$"
5647a84e134Smrg    else
5657a84e134Smrg
5667a84e134Smrg      # If mktemp works, use that first and foremost
5677a84e134Smrg      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
5687a84e134Smrg
5697a84e134Smrg      if test ! -d "$my_tmpdir"; then
570994689c1Smrg        # Failing that, at least try and use $RANDOM to avoid a race
571994689c1Smrg        my_tmpdir="${my_template}-${RANDOM-0}$$"
5727a84e134Smrg
573994689c1Smrg        save_mktempdir_umask=`umask`
574994689c1Smrg        umask 0077
575994689c1Smrg        $MKDIR "$my_tmpdir"
576994689c1Smrg        umask $save_mktempdir_umask
5777a84e134Smrg      fi
5787a84e134Smrg
5797a84e134Smrg      # If we're not in dry-run mode, bomb out on failure
580994689c1Smrg      test -d "$my_tmpdir" || \
581994689c1Smrg        func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
5827a84e134Smrg    fi
5837a84e134Smrg
584994689c1Smrg    $ECHO "$my_tmpdir"
5857a84e134Smrg}
5867a84e134Smrg
5877a84e134Smrg
588994689c1Smrg# func_quote_for_eval arg
589994689c1Smrg# Aesthetically quote ARG to be evaled later.
590994689c1Smrg# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
591994689c1Smrg# is double-quoted, suitable for a subsequent eval, whereas
592994689c1Smrg# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
593994689c1Smrg# which are still active within double quotes backslashified.
594994689c1Smrgfunc_quote_for_eval ()
5957a84e134Smrg{
596994689c1Smrg    case $1 in
597994689c1Smrg      *[\\\`\"\$]*)
598994689c1Smrg	func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;;
599994689c1Smrg      *)
600994689c1Smrg        func_quote_for_eval_unquoted_result="$1" ;;
601994689c1Smrg    esac
602994689c1Smrg
603994689c1Smrg    case $func_quote_for_eval_unquoted_result in
604994689c1Smrg      # Double-quote args containing shell metacharacters to delay
605994689c1Smrg      # word splitting, command substitution and and variable
606994689c1Smrg      # expansion for a subsequent eval.
607994689c1Smrg      # Many Bourne shells cannot handle close brackets correctly
608994689c1Smrg      # in scan sets, so we specify it separately.
609994689c1Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
610994689c1Smrg        func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
611994689c1Smrg        ;;
612994689c1Smrg      *)
613994689c1Smrg        func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
6147a84e134Smrg    esac
6157a84e134Smrg}
6167a84e134Smrg
6177a84e134Smrg
618994689c1Smrg# func_quote_for_expand arg
619994689c1Smrg# Aesthetically quote ARG to be evaled later; same as above,
620994689c1Smrg# but do not quote variable references.
621994689c1Smrgfunc_quote_for_expand ()
6227a84e134Smrg{
623994689c1Smrg    case $1 in
624994689c1Smrg      *[\\\`\"]*)
625994689c1Smrg	my_arg=`$ECHO "$1" | $SED \
626994689c1Smrg	    -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
6277a84e134Smrg      *)
628994689c1Smrg        my_arg="$1" ;;
629994689c1Smrg    esac
630994689c1Smrg
631994689c1Smrg    case $my_arg in
632994689c1Smrg      # Double-quote args containing shell metacharacters to delay
633994689c1Smrg      # word splitting and command substitution for a subsequent eval.
634994689c1Smrg      # Many Bourne shells cannot handle close brackets correctly
635994689c1Smrg      # in scan sets, so we specify it separately.
636994689c1Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
637994689c1Smrg        my_arg="\"$my_arg\""
638994689c1Smrg        ;;
639994689c1Smrg    esac
640994689c1Smrg
641994689c1Smrg    func_quote_for_expand_result="$my_arg"
6427a84e134Smrg}
6437a84e134Smrg
6447a84e134Smrg
645994689c1Smrg# func_show_eval cmd [fail_exp]
646994689c1Smrg# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
647994689c1Smrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
648994689c1Smrg# is given, then evaluate it.
649994689c1Smrgfunc_show_eval ()
6507a84e134Smrg{
651994689c1Smrg    my_cmd="$1"
652994689c1Smrg    my_fail_exp="${2-:}"
653775e7de9Smrg
654994689c1Smrg    ${opt_silent-false} || {
655994689c1Smrg      func_quote_for_expand "$my_cmd"
656994689c1Smrg      eval "func_echo $func_quote_for_expand_result"
657994689c1Smrg    }
658994689c1Smrg
659994689c1Smrg    if ${opt_dry_run-false}; then :; else
660994689c1Smrg      eval "$my_cmd"
661994689c1Smrg      my_status=$?
662994689c1Smrg      if test "$my_status" -eq 0; then :; else
663994689c1Smrg	eval "(exit $my_status); $my_fail_exp"
664994689c1Smrg      fi
6657a84e134Smrg    fi
6667a84e134Smrg}
6677a84e134Smrg
668994689c1Smrg
669994689c1Smrg# func_show_eval_locale cmd [fail_exp]
670994689c1Smrg# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
671994689c1Smrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
672994689c1Smrg# is given, then evaluate it.  Use the saved locale for evaluation.
673994689c1Smrgfunc_show_eval_locale ()
6747a84e134Smrg{
675994689c1Smrg    my_cmd="$1"
676994689c1Smrg    my_fail_exp="${2-:}"
6777a84e134Smrg
678994689c1Smrg    ${opt_silent-false} || {
679994689c1Smrg      func_quote_for_expand "$my_cmd"
680994689c1Smrg      eval "func_echo $func_quote_for_expand_result"
681994689c1Smrg    }
682775e7de9Smrg
683994689c1Smrg    if ${opt_dry_run-false}; then :; else
684994689c1Smrg      eval "$lt_user_locale
685994689c1Smrg	    $my_cmd"
686994689c1Smrg      my_status=$?
687994689c1Smrg      eval "$lt_safe_locale"
688994689c1Smrg      if test "$my_status" -eq 0; then :; else
689994689c1Smrg	eval "(exit $my_status); $my_fail_exp"
690e1e1713cSmrg      fi
691994689c1Smrg    fi
692775e7de9Smrg}
693775e7de9Smrg
694f353fbadSmrg# func_tr_sh
695f353fbadSmrg# Turn $1 into a string suitable for a shell variable name.
696f353fbadSmrg# Result is stored in $func_tr_sh_result.  All characters
697f353fbadSmrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further,
698f353fbadSmrg# if $1 begins with a digit, a '_' is prepended as well.
699f353fbadSmrgfunc_tr_sh ()
700f353fbadSmrg{
701f353fbadSmrg  case $1 in
702f353fbadSmrg  [0-9]* | *[!a-zA-Z0-9_]*)
703f353fbadSmrg    func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'`
704f353fbadSmrg    ;;
705f353fbadSmrg  * )
706f353fbadSmrg    func_tr_sh_result=$1
707f353fbadSmrg    ;;
708f353fbadSmrg  esac
709f353fbadSmrg}
710f353fbadSmrg
711775e7de9Smrg
712994689c1Smrg# func_version
713994689c1Smrg# Echo version message to standard output and exit.
714994689c1Smrgfunc_version ()
715994689c1Smrg{
716f353fbadSmrg    $opt_debug
717f353fbadSmrg
718994689c1Smrg    $SED -n '/(C)/!b go
719994689c1Smrg	:more
720994689c1Smrg	/\./!{
721994689c1Smrg	  N
722994689c1Smrg	  s/\n# / /
723994689c1Smrg	  b more
724994689c1Smrg	}
725994689c1Smrg	:go
726994689c1Smrg	/^# '$PROGRAM' (GNU /,/# warranty; / {
727994689c1Smrg        s/^# //
728994689c1Smrg	s/^# *$//
729994689c1Smrg        s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
730994689c1Smrg        p
731994689c1Smrg     }' < "$progpath"
732994689c1Smrg     exit $?
733994689c1Smrg}
734775e7de9Smrg
735994689c1Smrg# func_usage
736994689c1Smrg# Echo short help message to standard output and exit.
737994689c1Smrgfunc_usage ()
738994689c1Smrg{
739f353fbadSmrg    $opt_debug
740f353fbadSmrg
741994689c1Smrg    $SED -n '/^# Usage:/,/^#  *.*--help/ {
742994689c1Smrg        s/^# //
743994689c1Smrg	s/^# *$//
744994689c1Smrg	s/\$progname/'$progname'/
745994689c1Smrg	p
746994689c1Smrg    }' < "$progpath"
747994689c1Smrg    echo
748994689c1Smrg    $ECHO "run \`$progname --help | more' for full usage"
749994689c1Smrg    exit $?
750994689c1Smrg}
7517a84e134Smrg
752994689c1Smrg# func_help [NOEXIT]
753994689c1Smrg# Echo long help message to standard output and exit,
754994689c1Smrg# unless 'noexit' is passed as argument.
755994689c1Smrgfunc_help ()
756994689c1Smrg{
757f353fbadSmrg    $opt_debug
758f353fbadSmrg
759994689c1Smrg    $SED -n '/^# Usage:/,/# Report bugs to/ {
760f353fbadSmrg	:print
761994689c1Smrg        s/^# //
762994689c1Smrg	s/^# *$//
763994689c1Smrg	s*\$progname*'$progname'*
764994689c1Smrg	s*\$host*'"$host"'*
765994689c1Smrg	s*\$SHELL*'"$SHELL"'*
766994689c1Smrg	s*\$LTCC*'"$LTCC"'*
767994689c1Smrg	s*\$LTCFLAGS*'"$LTCFLAGS"'*
768994689c1Smrg	s*\$LD*'"$LD"'*
769994689c1Smrg	s/\$with_gnu_ld/'"$with_gnu_ld"'/
770421c997bSmrg	s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/
771421c997bSmrg	s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/
772994689c1Smrg	p
773f353fbadSmrg	d
774f353fbadSmrg     }
775f353fbadSmrg     /^# .* home page:/b print
776f353fbadSmrg     /^# General help using/b print
777f353fbadSmrg     ' < "$progpath"
778994689c1Smrg    ret=$?
779994689c1Smrg    if test -z "$1"; then
780994689c1Smrg      exit $ret
781994689c1Smrg    fi
782994689c1Smrg}
7837a84e134Smrg
784994689c1Smrg# func_missing_arg argname
785994689c1Smrg# Echo program name prefixed message to standard error and set global
786994689c1Smrg# exit_cmd.
787994689c1Smrgfunc_missing_arg ()
788994689c1Smrg{
789f353fbadSmrg    $opt_debug
790f353fbadSmrg
791994689c1Smrg    func_error "missing argument for $1."
792994689c1Smrg    exit_cmd=exit
793994689c1Smrg}
7947a84e134Smrg
795775e7de9Smrg
796f353fbadSmrg# func_split_short_opt shortopt
797f353fbadSmrg# Set func_split_short_opt_name and func_split_short_opt_arg shell
798f353fbadSmrg# variables after splitting SHORTOPT after the 2nd character.
799f353fbadSmrgfunc_split_short_opt ()
800f353fbadSmrg{
801f353fbadSmrg    my_sed_short_opt='1s/^\(..\).*$/\1/;q'
802f353fbadSmrg    my_sed_short_rest='1s/^..\(.*\)$/\1/;q'
803f353fbadSmrg
804f353fbadSmrg    func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"`
805f353fbadSmrg    func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"`
806f353fbadSmrg} # func_split_short_opt may be replaced by extended shell implementation
807f353fbadSmrg
808f353fbadSmrg
809f353fbadSmrg# func_split_long_opt longopt
810f353fbadSmrg# Set func_split_long_opt_name and func_split_long_opt_arg shell
811f353fbadSmrg# variables after splitting LONGOPT at the `=' sign.
812f353fbadSmrgfunc_split_long_opt ()
813f353fbadSmrg{
814f353fbadSmrg    my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q'
815f353fbadSmrg    my_sed_long_arg='1s/^--[^=]*=//'
816f353fbadSmrg
817f353fbadSmrg    func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"`
818f353fbadSmrg    func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"`
819f353fbadSmrg} # func_split_long_opt may be replaced by extended shell implementation
820f353fbadSmrg
821f353fbadSmrgexit_cmd=:
8227a84e134Smrg
823ab902922Smrg
824775e7de9Smrg
8257a84e134Smrg
826994689c1Smrg
827994689c1Smrgmagic="%%%MAGIC variable%%%"
828994689c1Smrgmagic_exe="%%%MAGIC EXE variable%%%"
829994689c1Smrg
830994689c1Smrg# Global variables.
831994689c1Smrgnonopt=
832994689c1Smrgpreserve_args=
833994689c1Smrglo2o="s/\\.lo\$/.${objext}/"
834994689c1Smrgo2lo="s/\\.${objext}\$/.lo/"
835994689c1Smrgextracted_archives=
836994689c1Smrgextracted_serial=0
837994689c1Smrg
838994689c1Smrg# If this variable is set in any of the actions, the command in it
839994689c1Smrg# will be execed at the end.  This prevents here-documents from being
840994689c1Smrg# left over by shells.
841994689c1Smrgexec_cmd=
842994689c1Smrg
843f353fbadSmrg# func_append var value
844f353fbadSmrg# Append VALUE to the end of shell variable VAR.
845f353fbadSmrgfunc_append ()
846f353fbadSmrg{
847f353fbadSmrg    eval "${1}=\$${1}\${2}"
848f353fbadSmrg} # func_append may be replaced by extended shell implementation
849f353fbadSmrg
850f353fbadSmrg# func_append_quoted var value
851f353fbadSmrg# Quote VALUE and append to the end of shell variable VAR, separated
852f353fbadSmrg# by a space.
853f353fbadSmrgfunc_append_quoted ()
854f353fbadSmrg{
855f353fbadSmrg    func_quote_for_eval "${2}"
856f353fbadSmrg    eval "${1}=\$${1}\\ \$func_quote_for_eval_result"
857f353fbadSmrg} # func_append_quoted may be replaced by extended shell implementation
858f353fbadSmrg
859f353fbadSmrg
860f353fbadSmrg# func_arith arithmetic-term...
861f353fbadSmrgfunc_arith ()
862f353fbadSmrg{
863f353fbadSmrg    func_arith_result=`expr "${@}"`
864f353fbadSmrg} # func_arith may be replaced by extended shell implementation
865f353fbadSmrg
866f353fbadSmrg
867f353fbadSmrg# func_len string
868f353fbadSmrg# STRING may not start with a hyphen.
869f353fbadSmrgfunc_len ()
870f353fbadSmrg{
871f353fbadSmrg    func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len`
872f353fbadSmrg} # func_len may be replaced by extended shell implementation
873f353fbadSmrg
874f353fbadSmrg
875f353fbadSmrg# func_lo2o object
876f353fbadSmrgfunc_lo2o ()
877f353fbadSmrg{
878f353fbadSmrg    func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"`
879f353fbadSmrg} # func_lo2o may be replaced by extended shell implementation
880f353fbadSmrg
881f353fbadSmrg
882f353fbadSmrg# func_xform libobj-or-source
883f353fbadSmrgfunc_xform ()
884f353fbadSmrg{
885f353fbadSmrg    func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'`
886f353fbadSmrg} # func_xform may be replaced by extended shell implementation
887f353fbadSmrg
888f353fbadSmrg
889994689c1Smrg# func_fatal_configuration arg...
890994689c1Smrg# Echo program name prefixed message to standard error, followed by
891994689c1Smrg# a configuration failure hint, and exit.
892994689c1Smrgfunc_fatal_configuration ()
893994689c1Smrg{
894994689c1Smrg    func_error ${1+"$@"}
895994689c1Smrg    func_error "See the $PACKAGE documentation for more information."
896994689c1Smrg    func_fatal_error "Fatal configuration error."
897994689c1Smrg}
898994689c1Smrg
899994689c1Smrg
900994689c1Smrg# func_config
901994689c1Smrg# Display the configuration for all the tags in this script.
902994689c1Smrgfunc_config ()
903994689c1Smrg{
904994689c1Smrg    re_begincf='^# ### BEGIN LIBTOOL'
905994689c1Smrg    re_endcf='^# ### END LIBTOOL'
906994689c1Smrg
907994689c1Smrg    # Default configuration.
908994689c1Smrg    $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
909994689c1Smrg
9107a84e134Smrg    # Now print the configurations for the tags.
9117a84e134Smrg    for tagname in $taglist; do
912994689c1Smrg      $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
9137a84e134Smrg    done
914e1e1713cSmrg
915994689c1Smrg    exit $?
916994689c1Smrg}
917e1e1713cSmrg
918994689c1Smrg# func_features
919994689c1Smrg# Display the features supported by this script.
920994689c1Smrgfunc_features ()
921994689c1Smrg{
922994689c1Smrg    echo "host: $host"
9237a84e134Smrg    if test "$build_libtool_libs" = yes; then
924994689c1Smrg      echo "enable shared libraries"
9257a84e134Smrg    else
926994689c1Smrg      echo "disable shared libraries"
9277a84e134Smrg    fi
9287a84e134Smrg    if test "$build_old_libs" = yes; then
929994689c1Smrg      echo "enable static libraries"
9307a84e134Smrg    else
931994689c1Smrg      echo "disable static libraries"
9327a84e134Smrg    fi
933994689c1Smrg
9347a84e134Smrg    exit $?
935994689c1Smrg}
9367a84e134Smrg
937994689c1Smrg# func_enable_tag tagname
938994689c1Smrg# Verify that TAGNAME is valid, and either flag an error and exit, or
939994689c1Smrg# enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
940994689c1Smrg# variable here.
941994689c1Smrgfunc_enable_tag ()
942994689c1Smrg{
943994689c1Smrg  # Global variable:
944994689c1Smrg  tagname="$1"
9457a84e134Smrg
946994689c1Smrg  re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
947994689c1Smrg  re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
948994689c1Smrg  sed_extractcf="/$re_begincf/,/$re_endcf/p"
949775e7de9Smrg
950994689c1Smrg  # Validate tagname.
951994689c1Smrg  case $tagname in
952994689c1Smrg    *[!-_A-Za-z0-9,/]*)
953994689c1Smrg      func_fatal_error "invalid tag name: $tagname"
954994689c1Smrg      ;;
955994689c1Smrg  esac
9567a84e134Smrg
957994689c1Smrg  # Don't test for the "default" C tag, as we know it's
958994689c1Smrg  # there but not specially marked.
959994689c1Smrg  case $tagname in
960994689c1Smrg    CC) ;;
961994689c1Smrg    *)
962994689c1Smrg      if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
963994689c1Smrg	taglist="$taglist $tagname"
964994689c1Smrg
965994689c1Smrg	# Evaluate the configuration.  Be careful to quote the path
966994689c1Smrg	# and the sed script, to avoid splitting on whitespace, but
967994689c1Smrg	# also don't use non-portable quotes within backquotes within
968994689c1Smrg	# quotes we have to do it in 2 steps:
969994689c1Smrg	extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
970994689c1Smrg	eval "$extractedcf"
971994689c1Smrg      else
972994689c1Smrg	func_error "ignoring unknown tag $tagname"
973994689c1Smrg      fi
974994689c1Smrg      ;;
975994689c1Smrg  esac
976994689c1Smrg}
977994689c1Smrg
978f353fbadSmrg# func_check_version_match
979f353fbadSmrg# Ensure that we are using m4 macros, and libtool script from the same
980f353fbadSmrg# release of libtool.
981f353fbadSmrgfunc_check_version_match ()
982994689c1Smrg{
983f353fbadSmrg  if test "$package_revision" != "$macro_revision"; then
984f353fbadSmrg    if test "$VERSION" != "$macro_version"; then
985f353fbadSmrg      if test -z "$macro_version"; then
986f353fbadSmrg        cat >&2 <<_LT_EOF
987f353fbadSmrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
988f353fbadSmrg$progname: definition of this LT_INIT comes from an older release.
989f353fbadSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
990f353fbadSmrg$progname: and run autoconf again.
991f353fbadSmrg_LT_EOF
992f353fbadSmrg      else
993f353fbadSmrg        cat >&2 <<_LT_EOF
994f353fbadSmrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
995f353fbadSmrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
996f353fbadSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
997f353fbadSmrg$progname: and run autoconf again.
998f353fbadSmrg_LT_EOF
999f353fbadSmrg      fi
1000f353fbadSmrg    else
1001f353fbadSmrg      cat >&2 <<_LT_EOF
1002f353fbadSmrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
1003f353fbadSmrg$progname: but the definition of this LT_INIT comes from revision $macro_revision.
1004f353fbadSmrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision
1005f353fbadSmrg$progname: of $PACKAGE $VERSION and run autoconf again.
1006f353fbadSmrg_LT_EOF
1007f353fbadSmrg    fi
1008e1e1713cSmrg
1009f353fbadSmrg    exit $EXIT_MISMATCH
1010f353fbadSmrg  fi
1011f353fbadSmrg}
1012f353fbadSmrg
1013f353fbadSmrg
1014f353fbadSmrg# Shorthand for --mode=foo, only valid as the first argument
1015f353fbadSmrgcase $1 in
1016f353fbadSmrgclean|clea|cle|cl)
1017f353fbadSmrg  shift; set dummy --mode clean ${1+"$@"}; shift
1018f353fbadSmrg  ;;
1019f353fbadSmrgcompile|compil|compi|comp|com|co|c)
1020f353fbadSmrg  shift; set dummy --mode compile ${1+"$@"}; shift
1021f353fbadSmrg  ;;
1022f353fbadSmrgexecute|execut|execu|exec|exe|ex|e)
1023f353fbadSmrg  shift; set dummy --mode execute ${1+"$@"}; shift
1024f353fbadSmrg  ;;
1025f353fbadSmrgfinish|finis|fini|fin|fi|f)
1026f353fbadSmrg  shift; set dummy --mode finish ${1+"$@"}; shift
1027f353fbadSmrg  ;;
1028f353fbadSmrginstall|instal|insta|inst|ins|in|i)
1029f353fbadSmrg  shift; set dummy --mode install ${1+"$@"}; shift
1030f353fbadSmrg  ;;
1031f353fbadSmrglink|lin|li|l)
1032f353fbadSmrg  shift; set dummy --mode link ${1+"$@"}; shift
1033f353fbadSmrg  ;;
1034f353fbadSmrguninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
1035f353fbadSmrg  shift; set dummy --mode uninstall ${1+"$@"}; shift
1036f353fbadSmrg  ;;
1037f353fbadSmrgesac
10387a84e134Smrg
1039f353fbadSmrg
1040f353fbadSmrg
1041f353fbadSmrg# Option defaults:
1042f353fbadSmrgopt_debug=:
1043f353fbadSmrgopt_dry_run=false
1044f353fbadSmrgopt_config=false
1045f353fbadSmrgopt_preserve_dup_deps=false
1046f353fbadSmrgopt_features=false
1047f353fbadSmrgopt_finish=false
1048f353fbadSmrgopt_help=false
1049f353fbadSmrgopt_help_all=false
1050f353fbadSmrgopt_silent=:
1051421c997bSmrgopt_warning=:
1052f353fbadSmrgopt_verbose=:
1053f353fbadSmrgopt_silent=false
1054f353fbadSmrgopt_verbose=false
1055f353fbadSmrg
1056f353fbadSmrg
1057f353fbadSmrg# Parse options once, thoroughly.  This comes as soon as possible in the
1058f353fbadSmrg# script to make things like `--version' happen as quickly as we can.
1059f353fbadSmrg{
1060f353fbadSmrg  # this just eases exit handling
1061f353fbadSmrg  while test $# -gt 0; do
1062994689c1Smrg    opt="$1"
1063994689c1Smrg    shift
1064994689c1Smrg    case $opt in
1065f353fbadSmrg      --debug|-x)	opt_debug='set -x'
1066994689c1Smrg			func_echo "enabling shell trace mode"
1067994689c1Smrg			$opt_debug
1068994689c1Smrg			;;
1069f353fbadSmrg      --dry-run|--dryrun|-n)
1070f353fbadSmrg			opt_dry_run=:
1071994689c1Smrg			;;
1072f353fbadSmrg      --config)
1073f353fbadSmrg			opt_config=:
1074f353fbadSmrgfunc_config
1075f353fbadSmrg			;;
1076f353fbadSmrg      --dlopen|-dlopen)
1077f353fbadSmrg			optarg="$1"
1078f353fbadSmrg			opt_dlopen="${opt_dlopen+$opt_dlopen
1079f353fbadSmrg}$optarg"
1080994689c1Smrg			shift
1081994689c1Smrg			;;
1082994689c1Smrg      --preserve-dup-deps)
1083f353fbadSmrg			opt_preserve_dup_deps=:
1084994689c1Smrg			;;
1085f353fbadSmrg      --features)
1086f353fbadSmrg			opt_features=:
1087f353fbadSmrgfunc_features
1088994689c1Smrg			;;
1089f353fbadSmrg      --finish)
1090f353fbadSmrg			opt_finish=:
1091f353fbadSmrgset dummy --mode finish ${1+"$@"}; shift
1092f353fbadSmrg			;;
1093f353fbadSmrg      --help)
1094f353fbadSmrg			opt_help=:
1095f353fbadSmrg			;;
1096f353fbadSmrg      --help-all)
1097f353fbadSmrg			opt_help_all=:
1098f353fbadSmrgopt_help=': help-all'
1099f353fbadSmrg			;;
1100f353fbadSmrg      --mode)
1101f353fbadSmrg			test $# = 0 && func_missing_arg $opt && break
1102f353fbadSmrg			optarg="$1"
1103f353fbadSmrg			opt_mode="$optarg"
1104f353fbadSmrgcase $optarg in
1105f353fbadSmrg  # Valid mode arguments:
1106f353fbadSmrg  clean|compile|execute|finish|install|link|relink|uninstall) ;;
1107f353fbadSmrg
1108f353fbadSmrg  # Catch anything else as an error
1109f353fbadSmrg  *) func_error "invalid argument for $opt"
1110f353fbadSmrg     exit_cmd=exit
1111f353fbadSmrg     break
1112f353fbadSmrg     ;;
1113f353fbadSmrgesac
1114f353fbadSmrg			shift
1115f353fbadSmrg			;;
1116f353fbadSmrg      --no-silent|--no-quiet)
1117994689c1Smrg			opt_silent=false
1118421c997bSmrgfunc_append preserve_args " $opt"
1119421c997bSmrg			;;
1120421c997bSmrg      --no-warning|--no-warn)
1121421c997bSmrg			opt_warning=false
1122f353fbadSmrgfunc_append preserve_args " $opt"
1123994689c1Smrg			;;
1124f353fbadSmrg      --no-verbose)
1125994689c1Smrg			opt_verbose=false
1126f353fbadSmrgfunc_append preserve_args " $opt"
1127994689c1Smrg			;;
1128f353fbadSmrg      --silent|--quiet)
1129f353fbadSmrg			opt_silent=:
1130f353fbadSmrgfunc_append preserve_args " $opt"
1131f353fbadSmrg        opt_verbose=false
1132f353fbadSmrg			;;
1133f353fbadSmrg      --verbose|-v)
1134f353fbadSmrg			opt_verbose=:
1135f353fbadSmrgfunc_append preserve_args " $opt"
1136f353fbadSmrgopt_silent=false
1137f353fbadSmrg			;;
1138f353fbadSmrg      --tag)
1139f353fbadSmrg			test $# = 0 && func_missing_arg $opt && break
1140f353fbadSmrg			optarg="$1"
1141f353fbadSmrg			opt_tag="$optarg"
1142f353fbadSmrgfunc_append preserve_args " $opt $optarg"
1143f353fbadSmrgfunc_enable_tag "$optarg"
1144994689c1Smrg			shift
1145994689c1Smrg			;;
1146994689c1Smrg
1147f353fbadSmrg      -\?|-h)		func_usage				;;
1148f353fbadSmrg      --help)		func_help				;;
1149f353fbadSmrg      --version)	func_version				;;
1150f353fbadSmrg
1151994689c1Smrg      # Separate optargs to long options:
1152f353fbadSmrg      --*=*)
1153f353fbadSmrg			func_split_long_opt "$opt"
1154f353fbadSmrg			set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"}
1155994689c1Smrg			shift
1156994689c1Smrg			;;
1157994689c1Smrg
1158f353fbadSmrg      # Separate non-argument short options:
1159f353fbadSmrg      -\?*|-h*|-n*|-v*)
1160f353fbadSmrg			func_split_short_opt "$opt"
1161f353fbadSmrg			set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"}
1162f353fbadSmrg			shift
1163994689c1Smrg			;;
1164f353fbadSmrg
1165f353fbadSmrg      --)		break					;;
1166f353fbadSmrg      -*)		func_fatal_help "unrecognized option \`$opt'" ;;
1167f353fbadSmrg      *)		set dummy "$opt" ${1+"$@"};	shift; break  ;;
1168994689c1Smrg    esac
1169994689c1Smrg  done
1170994689c1Smrg
1171f353fbadSmrg  # Validate options:
1172f353fbadSmrg
1173f353fbadSmrg  # save first non-option argument
1174f353fbadSmrg  if test "$#" -gt 0; then
1175f353fbadSmrg    nonopt="$opt"
1176f353fbadSmrg    shift
1177f353fbadSmrg  fi
1178f353fbadSmrg
1179f353fbadSmrg  # preserve --debug
1180f353fbadSmrg  test "$opt_debug" = : || func_append preserve_args " --debug"
1181994689c1Smrg
1182994689c1Smrg  case $host in
1183994689c1Smrg    *cygwin* | *mingw* | *pw32* | *cegcc*)
1184994689c1Smrg      # don't eliminate duplications in $postdeps and $predeps
1185994689c1Smrg      opt_duplicate_compiler_generated_deps=:
1186e1e1713cSmrg      ;;
1187e1e1713cSmrg    *)
1188f353fbadSmrg      opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
1189994689c1Smrg      ;;
1190994689c1Smrg  esac
1191775e7de9Smrg
1192f353fbadSmrg  $opt_help || {
1193f353fbadSmrg    # Sanity checks first:
1194f353fbadSmrg    func_check_version_match
1195994689c1Smrg
1196f353fbadSmrg    if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
1197f353fbadSmrg      func_fatal_configuration "not configured to build any kind of library"
1198994689c1Smrg    fi
1199994689c1Smrg
1200f353fbadSmrg    # Darwin sucks
1201f353fbadSmrg    eval std_shrext=\"$shrext_cmds\"
1202994689c1Smrg
1203f353fbadSmrg    # Only execute mode is allowed to have -dlopen flags.
1204f353fbadSmrg    if test -n "$opt_dlopen" && test "$opt_mode" != execute; then
1205f353fbadSmrg      func_error "unrecognized option \`-dlopen'"
1206f353fbadSmrg      $ECHO "$help" 1>&2
1207f353fbadSmrg      exit $EXIT_FAILURE
1208f353fbadSmrg    fi
1209994689c1Smrg
1210f353fbadSmrg    # Change the help message to a mode-specific one.
1211f353fbadSmrg    generic_help="$help"
1212f353fbadSmrg    help="Try \`$progname --help --mode=$opt_mode' for more information."
1213f353fbadSmrg  }
1214994689c1Smrg
1215994689c1Smrg
1216f353fbadSmrg  # Bail if the options were screwed
1217f353fbadSmrg  $exit_cmd $EXIT_FAILURE
1218f353fbadSmrg}
1219994689c1Smrg
1220994689c1Smrg
12217a84e134Smrg
12227a84e134Smrg
1223f353fbadSmrg## ----------- ##
1224f353fbadSmrg##    Main.    ##
1225f353fbadSmrg## ----------- ##
12267a84e134Smrg
1227994689c1Smrg# func_lalib_p file
1228994689c1Smrg# True iff FILE is a libtool `.la' library or `.lo' object file.
1229994689c1Smrg# This function is only a basic sanity check; it will hardly flush out
1230994689c1Smrg# determined imposters.
1231994689c1Smrgfunc_lalib_p ()
1232994689c1Smrg{
1233994689c1Smrg    test -f "$1" &&
1234994689c1Smrg      $SED -e 4q "$1" 2>/dev/null \
1235994689c1Smrg        | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
1236994689c1Smrg}
12377a84e134Smrg
1238994689c1Smrg# func_lalib_unsafe_p file
1239994689c1Smrg# True iff FILE is a libtool `.la' library or `.lo' object file.
1240994689c1Smrg# This function implements the same check as func_lalib_p without
1241994689c1Smrg# resorting to external programs.  To this end, it redirects stdin and
1242994689c1Smrg# closes it afterwards, without saving the original file descriptor.
1243994689c1Smrg# As a safety measure, use it only where a negative result would be
1244994689c1Smrg# fatal anyway.  Works if `file' does not exist.
1245994689c1Smrgfunc_lalib_unsafe_p ()
1246994689c1Smrg{
1247994689c1Smrg    lalib_p=no
1248994689c1Smrg    if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
1249994689c1Smrg	for lalib_p_l in 1 2 3 4
1250994689c1Smrg	do
1251994689c1Smrg	    read lalib_p_line
1252994689c1Smrg	    case "$lalib_p_line" in
1253994689c1Smrg		\#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
1254994689c1Smrg	    esac
1255994689c1Smrg	done
1256994689c1Smrg	exec 0<&5 5<&-
1257994689c1Smrg    fi
1258994689c1Smrg    test "$lalib_p" = yes
1259994689c1Smrg}
12607a84e134Smrg
1261994689c1Smrg# func_ltwrapper_script_p file
1262994689c1Smrg# True iff FILE is a libtool wrapper script
1263994689c1Smrg# This function is only a basic sanity check; it will hardly flush out
1264994689c1Smrg# determined imposters.
1265994689c1Smrgfunc_ltwrapper_script_p ()
1266994689c1Smrg{
1267994689c1Smrg    func_lalib_p "$1"
1268994689c1Smrg}
12697a84e134Smrg
1270994689c1Smrg# func_ltwrapper_executable_p file
1271994689c1Smrg# True iff FILE is a libtool wrapper executable
1272994689c1Smrg# This function is only a basic sanity check; it will hardly flush out
1273994689c1Smrg# determined imposters.
1274994689c1Smrgfunc_ltwrapper_executable_p ()
1275994689c1Smrg{
1276994689c1Smrg    func_ltwrapper_exec_suffix=
1277994689c1Smrg    case $1 in
1278994689c1Smrg    *.exe) ;;
1279994689c1Smrg    *) func_ltwrapper_exec_suffix=.exe ;;
1280994689c1Smrg    esac
1281994689c1Smrg    $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
1282994689c1Smrg}
1283994689c1Smrg
1284994689c1Smrg# func_ltwrapper_scriptname file
1285994689c1Smrg# Assumes file is an ltwrapper_executable
1286994689c1Smrg# uses $file to determine the appropriate filename for a
1287994689c1Smrg# temporary ltwrapper_script.
1288994689c1Smrgfunc_ltwrapper_scriptname ()
1289994689c1Smrg{
1290f353fbadSmrg    func_dirname_and_basename "$1" "" "."
1291f353fbadSmrg    func_stripname '' '.exe' "$func_basename_result"
1292f353fbadSmrg    func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper"
1293994689c1Smrg}
1294994689c1Smrg
1295994689c1Smrg# func_ltwrapper_p file
1296994689c1Smrg# True iff FILE is a libtool wrapper script or wrapper executable
1297994689c1Smrg# This function is only a basic sanity check; it will hardly flush out
1298994689c1Smrg# determined imposters.
1299994689c1Smrgfunc_ltwrapper_p ()
1300994689c1Smrg{
1301994689c1Smrg    func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
1302994689c1Smrg}
1303994689c1Smrg
1304994689c1Smrg
1305994689c1Smrg# func_execute_cmds commands fail_cmd
1306994689c1Smrg# Execute tilde-delimited COMMANDS.
1307994689c1Smrg# If FAIL_CMD is given, eval that upon failure.
1308994689c1Smrg# FAIL_CMD may read-access the current command in variable CMD!
1309994689c1Smrgfunc_execute_cmds ()
1310994689c1Smrg{
1311994689c1Smrg    $opt_debug
1312994689c1Smrg    save_ifs=$IFS; IFS='~'
1313994689c1Smrg    for cmd in $1; do
1314994689c1Smrg      IFS=$save_ifs
1315994689c1Smrg      eval cmd=\"$cmd\"
1316994689c1Smrg      func_show_eval "$cmd" "${2-:}"
1317994689c1Smrg    done
1318994689c1Smrg    IFS=$save_ifs
1319994689c1Smrg}
1320994689c1Smrg
1321994689c1Smrg
1322994689c1Smrg# func_source file
1323994689c1Smrg# Source FILE, adding directory component if necessary.
1324994689c1Smrg# Note that it is not necessary on cygwin/mingw to append a dot to
1325994689c1Smrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe
1326994689c1Smrg# behavior happens only for exec(3), not for open(2)!  Also, sourcing
1327994689c1Smrg# `FILE.' does not work on cygwin managed mounts.
1328994689c1Smrgfunc_source ()
1329994689c1Smrg{
1330994689c1Smrg    $opt_debug
1331994689c1Smrg    case $1 in
1332994689c1Smrg    */* | *\\*)	. "$1" ;;
1333994689c1Smrg    *)		. "./$1" ;;
1334994689c1Smrg    esac
1335994689c1Smrg}
1336994689c1Smrg
1337994689c1Smrg
1338f353fbadSmrg# func_resolve_sysroot PATH
1339f353fbadSmrg# Replace a leading = in PATH with a sysroot.  Store the result into
1340f353fbadSmrg# func_resolve_sysroot_result
1341f353fbadSmrgfunc_resolve_sysroot ()
1342f353fbadSmrg{
1343f353fbadSmrg  func_resolve_sysroot_result=$1
1344f353fbadSmrg  case $func_resolve_sysroot_result in
1345f353fbadSmrg  =*)
1346f353fbadSmrg    func_stripname '=' '' "$func_resolve_sysroot_result"
1347f353fbadSmrg    func_resolve_sysroot_result=$lt_sysroot$func_stripname_result
1348f353fbadSmrg    ;;
1349f353fbadSmrg  esac
1350f353fbadSmrg}
1351f353fbadSmrg
1352f353fbadSmrg# func_replace_sysroot PATH
1353f353fbadSmrg# If PATH begins with the sysroot, replace it with = and
1354f353fbadSmrg# store the result into func_replace_sysroot_result.
1355f353fbadSmrgfunc_replace_sysroot ()
1356f353fbadSmrg{
1357f353fbadSmrg  case "$lt_sysroot:$1" in
1358f353fbadSmrg  ?*:"$lt_sysroot"*)
1359f353fbadSmrg    func_stripname "$lt_sysroot" '' "$1"
1360f353fbadSmrg    func_replace_sysroot_result="=$func_stripname_result"
1361f353fbadSmrg    ;;
1362f353fbadSmrg  *)
1363f353fbadSmrg    # Including no sysroot.
1364f353fbadSmrg    func_replace_sysroot_result=$1
1365f353fbadSmrg    ;;
1366f353fbadSmrg  esac
1367f353fbadSmrg}
1368f353fbadSmrg
1369994689c1Smrg# func_infer_tag arg
1370994689c1Smrg# Infer tagged configuration to use if any are available and
1371994689c1Smrg# if one wasn't chosen via the "--tag" command line option.
1372994689c1Smrg# Only attempt this if the compiler in the base compile
1373994689c1Smrg# command doesn't match the default compiler.
1374994689c1Smrg# arg is usually of the form 'gcc ...'
1375994689c1Smrgfunc_infer_tag ()
1376994689c1Smrg{
1377994689c1Smrg    $opt_debug
1378994689c1Smrg    if test -n "$available_tags" && test -z "$tagname"; then
1379994689c1Smrg      CC_quoted=
1380994689c1Smrg      for arg in $CC; do
1381f353fbadSmrg	func_append_quoted CC_quoted "$arg"
1382994689c1Smrg      done
1383994689c1Smrg      CC_expanded=`func_echo_all $CC`
1384994689c1Smrg      CC_quoted_expanded=`func_echo_all $CC_quoted`
1385994689c1Smrg      case $@ in
1386994689c1Smrg      # Blanks in the command may have been stripped by the calling shell,
1387994689c1Smrg      # but not from the CC environment variable when configure was run.
1388994689c1Smrg      " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
1389994689c1Smrg      " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
1390994689c1Smrg      # Blanks at the start of $base_compile will cause this to fail
1391994689c1Smrg      # if we don't check for them as well.
1392994689c1Smrg      *)
1393994689c1Smrg	for z in $available_tags; do
1394994689c1Smrg	  if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
1395994689c1Smrg	    # Evaluate the configuration.
1396994689c1Smrg	    eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
1397994689c1Smrg	    CC_quoted=
1398994689c1Smrg	    for arg in $CC; do
1399994689c1Smrg	      # Double-quote args containing other shell metacharacters.
1400f353fbadSmrg	      func_append_quoted CC_quoted "$arg"
1401994689c1Smrg	    done
1402994689c1Smrg	    CC_expanded=`func_echo_all $CC`
1403994689c1Smrg	    CC_quoted_expanded=`func_echo_all $CC_quoted`
1404994689c1Smrg	    case "$@ " in
1405994689c1Smrg	    " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
1406994689c1Smrg	    " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
1407994689c1Smrg	      # The compiler in the base compile command matches
1408994689c1Smrg	      # the one in the tagged configuration.
1409994689c1Smrg	      # Assume this is the tagged configuration we want.
1410994689c1Smrg	      tagname=$z
1411994689c1Smrg	      break
1412994689c1Smrg	      ;;
1413994689c1Smrg	    esac
1414994689c1Smrg	  fi
1415994689c1Smrg	done
1416994689c1Smrg	# If $tagname still isn't set, then no tagged configuration
1417994689c1Smrg	# was found and let the user know that the "--tag" command
1418994689c1Smrg	# line option must be used.
1419994689c1Smrg	if test -z "$tagname"; then
1420994689c1Smrg	  func_echo "unable to infer tagged configuration"
1421994689c1Smrg	  func_fatal_error "specify a tag with \`--tag'"
1422994689c1Smrg#	else
1423994689c1Smrg#	  func_verbose "using $tagname tagged configuration"
1424994689c1Smrg	fi
1425994689c1Smrg	;;
1426994689c1Smrg      esac
1427994689c1Smrg    fi
1428994689c1Smrg}
1429994689c1Smrg
1430994689c1Smrg
1431994689c1Smrg
1432f353fbadSmrg# func_write_libtool_object output_name pic_name nonpic_name
1433f353fbadSmrg# Create a libtool object file (analogous to a ".la" file),
1434f353fbadSmrg# but don't create it if we're doing a dry run.
1435f353fbadSmrgfunc_write_libtool_object ()
1436f353fbadSmrg{
1437f353fbadSmrg    write_libobj=${1}
1438f353fbadSmrg    if test "$build_libtool_libs" = yes; then
1439f353fbadSmrg      write_lobj=\'${2}\'
1440f353fbadSmrg    else
1441f353fbadSmrg      write_lobj=none
1442f353fbadSmrg    fi
1443f353fbadSmrg
1444f353fbadSmrg    if test "$build_old_libs" = yes; then
1445f353fbadSmrg      write_oldobj=\'${3}\'
1446f353fbadSmrg    else
1447f353fbadSmrg      write_oldobj=none
1448f353fbadSmrg    fi
1449f353fbadSmrg
1450f353fbadSmrg    $opt_dry_run || {
1451f353fbadSmrg      cat >${write_libobj}T <<EOF
1452f353fbadSmrg# $write_libobj - a libtool object file
1453f353fbadSmrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
1454f353fbadSmrg#
1455f353fbadSmrg# Please DO NOT delete this file!
1456f353fbadSmrg# It is necessary for linking the library.
1457f353fbadSmrg
1458f353fbadSmrg# Name of the PIC object.
1459f353fbadSmrgpic_object=$write_lobj
1460f353fbadSmrg
1461f353fbadSmrg# Name of the non-PIC object
1462f353fbadSmrgnon_pic_object=$write_oldobj
1463f353fbadSmrg
1464f353fbadSmrgEOF
1465f353fbadSmrg      $MV "${write_libobj}T" "${write_libobj}"
1466f353fbadSmrg    }
1467f353fbadSmrg}
1468f353fbadSmrg
1469f353fbadSmrg
1470f353fbadSmrg##################################################
1471f353fbadSmrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS #
1472f353fbadSmrg##################################################
1473f353fbadSmrg
1474f353fbadSmrg# func_convert_core_file_wine_to_w32 ARG
1475f353fbadSmrg# Helper function used by file name conversion functions when $build is *nix,
1476f353fbadSmrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a
1477f353fbadSmrg# correctly configured wine environment available, with the winepath program
1478f353fbadSmrg# in $build's $PATH.
1479f353fbadSmrg#
1480f353fbadSmrg# ARG is the $build file name to be converted to w32 format.
1481f353fbadSmrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will
1482f353fbadSmrg# be empty on error (or when ARG is empty)
1483f353fbadSmrgfunc_convert_core_file_wine_to_w32 ()
1484f353fbadSmrg{
1485f353fbadSmrg  $opt_debug
1486f353fbadSmrg  func_convert_core_file_wine_to_w32_result="$1"
1487f353fbadSmrg  if test -n "$1"; then
1488f353fbadSmrg    # Unfortunately, winepath does not exit with a non-zero error code, so we
1489f353fbadSmrg    # are forced to check the contents of stdout. On the other hand, if the
1490f353fbadSmrg    # command is not found, the shell will set an exit code of 127 and print
1491f353fbadSmrg    # *an error message* to stdout. So we must check for both error code of
1492f353fbadSmrg    # zero AND non-empty stdout, which explains the odd construction:
1493f353fbadSmrg    func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
1494f353fbadSmrg    if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then
1495f353fbadSmrg      func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
1496f353fbadSmrg        $SED -e "$lt_sed_naive_backslashify"`
1497f353fbadSmrg    else
1498f353fbadSmrg      func_convert_core_file_wine_to_w32_result=
1499f353fbadSmrg    fi
1500f353fbadSmrg  fi
1501f353fbadSmrg}
1502f353fbadSmrg# end: func_convert_core_file_wine_to_w32
1503f353fbadSmrg
1504f353fbadSmrg
1505f353fbadSmrg# func_convert_core_path_wine_to_w32 ARG
1506f353fbadSmrg# Helper function used by path conversion functions when $build is *nix, and
1507f353fbadSmrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly
1508f353fbadSmrg# configured wine environment available, with the winepath program in $build's
1509f353fbadSmrg# $PATH. Assumes ARG has no leading or trailing path separator characters.
1510f353fbadSmrg#
1511f353fbadSmrg# ARG is path to be converted from $build format to win32.
1512f353fbadSmrg# Result is available in $func_convert_core_path_wine_to_w32_result.
1513f353fbadSmrg# Unconvertible file (directory) names in ARG are skipped; if no directory names
1514f353fbadSmrg# are convertible, then the result may be empty.
1515f353fbadSmrgfunc_convert_core_path_wine_to_w32 ()
1516f353fbadSmrg{
1517f353fbadSmrg  $opt_debug
1518f353fbadSmrg  # unfortunately, winepath doesn't convert paths, only file names
1519f353fbadSmrg  func_convert_core_path_wine_to_w32_result=""
1520f353fbadSmrg  if test -n "$1"; then
1521f353fbadSmrg    oldIFS=$IFS
1522f353fbadSmrg    IFS=:
1523f353fbadSmrg    for func_convert_core_path_wine_to_w32_f in $1; do
1524f353fbadSmrg      IFS=$oldIFS
1525f353fbadSmrg      func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
1526f353fbadSmrg      if test -n "$func_convert_core_file_wine_to_w32_result" ; then
1527f353fbadSmrg        if test -z "$func_convert_core_path_wine_to_w32_result"; then
1528f353fbadSmrg          func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result"
1529f353fbadSmrg        else
1530f353fbadSmrg          func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
1531f353fbadSmrg        fi
1532f353fbadSmrg      fi
1533f353fbadSmrg    done
1534f353fbadSmrg    IFS=$oldIFS
1535f353fbadSmrg  fi
1536f353fbadSmrg}
1537f353fbadSmrg# end: func_convert_core_path_wine_to_w32
1538f353fbadSmrg
1539f353fbadSmrg
1540f353fbadSmrg# func_cygpath ARGS...
1541f353fbadSmrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when
1542f353fbadSmrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2)
1543f353fbadSmrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or
1544f353fbadSmrg# (2), returns the Cygwin file name or path in func_cygpath_result (input
1545f353fbadSmrg# file name or path is assumed to be in w32 format, as previously converted
1546f353fbadSmrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name
1547f353fbadSmrg# or path in func_cygpath_result (input file name or path is assumed to be in
1548f353fbadSmrg# Cygwin format). Returns an empty string on error.
1549f353fbadSmrg#
1550f353fbadSmrg# ARGS are passed to cygpath, with the last one being the file name or path to
1551f353fbadSmrg# be converted.
1552f353fbadSmrg#
1553f353fbadSmrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH
1554f353fbadSmrg# environment variable; do not put it in $PATH.
1555f353fbadSmrgfunc_cygpath ()
1556f353fbadSmrg{
1557f353fbadSmrg  $opt_debug
1558f353fbadSmrg  if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
1559f353fbadSmrg    func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
1560f353fbadSmrg    if test "$?" -ne 0; then
1561f353fbadSmrg      # on failure, ensure result is empty
1562f353fbadSmrg      func_cygpath_result=
1563f353fbadSmrg    fi
1564f353fbadSmrg  else
1565f353fbadSmrg    func_cygpath_result=
1566f353fbadSmrg    func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'"
1567f353fbadSmrg  fi
1568f353fbadSmrg}
1569f353fbadSmrg#end: func_cygpath
1570f353fbadSmrg
1571f353fbadSmrg
1572f353fbadSmrg# func_convert_core_msys_to_w32 ARG
1573f353fbadSmrg# Convert file name or path ARG from MSYS format to w32 format.  Return
1574f353fbadSmrg# result in func_convert_core_msys_to_w32_result.
1575f353fbadSmrgfunc_convert_core_msys_to_w32 ()
1576f353fbadSmrg{
1577f353fbadSmrg  $opt_debug
1578f353fbadSmrg  # awkward: cmd appends spaces to result
1579f353fbadSmrg  func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
1580f353fbadSmrg    $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"`
1581f353fbadSmrg}
1582f353fbadSmrg#end: func_convert_core_msys_to_w32
1583f353fbadSmrg
1584f353fbadSmrg
1585f353fbadSmrg# func_convert_file_check ARG1 ARG2
1586f353fbadSmrg# Verify that ARG1 (a file name in $build format) was converted to $host
1587f353fbadSmrg# format in ARG2. Otherwise, emit an error message, but continue (resetting
1588f353fbadSmrg# func_to_host_file_result to ARG1).
1589f353fbadSmrgfunc_convert_file_check ()
1590f353fbadSmrg{
1591f353fbadSmrg  $opt_debug
1592f353fbadSmrg  if test -z "$2" && test -n "$1" ; then
1593f353fbadSmrg    func_error "Could not determine host file name corresponding to"
1594f353fbadSmrg    func_error "  \`$1'"
1595f353fbadSmrg    func_error "Continuing, but uninstalled executables may not work."
1596f353fbadSmrg    # Fallback:
1597f353fbadSmrg    func_to_host_file_result="$1"
1598f353fbadSmrg  fi
1599f353fbadSmrg}
1600f353fbadSmrg# end func_convert_file_check
1601f353fbadSmrg
1602f353fbadSmrg
1603f353fbadSmrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH
1604f353fbadSmrg# Verify that FROM_PATH (a path in $build format) was converted to $host
1605f353fbadSmrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting
1606f353fbadSmrg# func_to_host_file_result to a simplistic fallback value (see below).
1607f353fbadSmrgfunc_convert_path_check ()
1608f353fbadSmrg{
1609f353fbadSmrg  $opt_debug
1610f353fbadSmrg  if test -z "$4" && test -n "$3"; then
1611f353fbadSmrg    func_error "Could not determine the host path corresponding to"
1612f353fbadSmrg    func_error "  \`$3'"
1613f353fbadSmrg    func_error "Continuing, but uninstalled executables may not work."
1614f353fbadSmrg    # Fallback.  This is a deliberately simplistic "conversion" and
1615f353fbadSmrg    # should not be "improved".  See libtool.info.
1616f353fbadSmrg    if test "x$1" != "x$2"; then
1617f353fbadSmrg      lt_replace_pathsep_chars="s|$1|$2|g"
1618f353fbadSmrg      func_to_host_path_result=`echo "$3" |
1619f353fbadSmrg        $SED -e "$lt_replace_pathsep_chars"`
1620f353fbadSmrg    else
1621f353fbadSmrg      func_to_host_path_result="$3"
1622f353fbadSmrg    fi
1623f353fbadSmrg  fi
1624f353fbadSmrg}
1625f353fbadSmrg# end func_convert_path_check
1626f353fbadSmrg
1627f353fbadSmrg
1628f353fbadSmrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG
1629f353fbadSmrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT
1630f353fbadSmrg# and appending REPL if ORIG matches BACKPAT.
1631f353fbadSmrgfunc_convert_path_front_back_pathsep ()
1632f353fbadSmrg{
1633f353fbadSmrg  $opt_debug
1634f353fbadSmrg  case $4 in
1635f353fbadSmrg  $1 ) func_to_host_path_result="$3$func_to_host_path_result"
1636f353fbadSmrg    ;;
1637f353fbadSmrg  esac
1638f353fbadSmrg  case $4 in
1639f353fbadSmrg  $2 ) func_append func_to_host_path_result "$3"
1640f353fbadSmrg    ;;
1641f353fbadSmrg  esac
1642f353fbadSmrg}
1643f353fbadSmrg# end func_convert_path_front_back_pathsep
1644f353fbadSmrg
1645f353fbadSmrg
1646f353fbadSmrg##################################################
1647f353fbadSmrg# $build to $host FILE NAME CONVERSION FUNCTIONS #
1648f353fbadSmrg##################################################
1649f353fbadSmrg# invoked via `$to_host_file_cmd ARG'
1650f353fbadSmrg#
1651f353fbadSmrg# In each case, ARG is the path to be converted from $build to $host format.
1652f353fbadSmrg# Result will be available in $func_to_host_file_result.
1653f353fbadSmrg
1654f353fbadSmrg
1655f353fbadSmrg# func_to_host_file ARG
1656f353fbadSmrg# Converts the file name ARG from $build format to $host format. Return result
1657f353fbadSmrg# in func_to_host_file_result.
1658f353fbadSmrgfunc_to_host_file ()
1659f353fbadSmrg{
1660f353fbadSmrg  $opt_debug
1661f353fbadSmrg  $to_host_file_cmd "$1"
1662f353fbadSmrg}
1663f353fbadSmrg# end func_to_host_file
1664f353fbadSmrg
1665f353fbadSmrg
1666f353fbadSmrg# func_to_tool_file ARG LAZY
1667f353fbadSmrg# converts the file name ARG from $build format to toolchain format. Return
1668f353fbadSmrg# result in func_to_tool_file_result.  If the conversion in use is listed
1669f353fbadSmrg# in (the comma separated) LAZY, no conversion takes place.
1670f353fbadSmrgfunc_to_tool_file ()
1671f353fbadSmrg{
1672f353fbadSmrg  $opt_debug
1673f353fbadSmrg  case ,$2, in
1674f353fbadSmrg    *,"$to_tool_file_cmd",*)
1675f353fbadSmrg      func_to_tool_file_result=$1
1676f353fbadSmrg      ;;
1677f353fbadSmrg    *)
1678f353fbadSmrg      $to_tool_file_cmd "$1"
1679f353fbadSmrg      func_to_tool_file_result=$func_to_host_file_result
1680f353fbadSmrg      ;;
1681f353fbadSmrg  esac
1682f353fbadSmrg}
1683f353fbadSmrg# end func_to_tool_file
1684f353fbadSmrg
1685f353fbadSmrg
1686f353fbadSmrg# func_convert_file_noop ARG
1687f353fbadSmrg# Copy ARG to func_to_host_file_result.
1688f353fbadSmrgfunc_convert_file_noop ()
1689f353fbadSmrg{
1690f353fbadSmrg  func_to_host_file_result="$1"
1691f353fbadSmrg}
1692f353fbadSmrg# end func_convert_file_noop
1693f353fbadSmrg
1694f353fbadSmrg
1695f353fbadSmrg# func_convert_file_msys_to_w32 ARG
1696f353fbadSmrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic
1697f353fbadSmrg# conversion to w32 is not available inside the cwrapper.  Returns result in
1698f353fbadSmrg# func_to_host_file_result.
1699f353fbadSmrgfunc_convert_file_msys_to_w32 ()
1700f353fbadSmrg{
1701f353fbadSmrg  $opt_debug
1702f353fbadSmrg  func_to_host_file_result="$1"
1703f353fbadSmrg  if test -n "$1"; then
1704f353fbadSmrg    func_convert_core_msys_to_w32 "$1"
1705f353fbadSmrg    func_to_host_file_result="$func_convert_core_msys_to_w32_result"
1706f353fbadSmrg  fi
1707f353fbadSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
1708f353fbadSmrg}
1709f353fbadSmrg# end func_convert_file_msys_to_w32
1710f353fbadSmrg
1711f353fbadSmrg
1712f353fbadSmrg# func_convert_file_cygwin_to_w32 ARG
1713f353fbadSmrg# Convert file name ARG from Cygwin to w32 format.  Returns result in
1714f353fbadSmrg# func_to_host_file_result.
1715f353fbadSmrgfunc_convert_file_cygwin_to_w32 ()
1716f353fbadSmrg{
1717f353fbadSmrg  $opt_debug
1718f353fbadSmrg  func_to_host_file_result="$1"
1719f353fbadSmrg  if test -n "$1"; then
1720f353fbadSmrg    # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
1721f353fbadSmrg    # LT_CYGPATH in this case.
1722f353fbadSmrg    func_to_host_file_result=`cygpath -m "$1"`
1723f353fbadSmrg  fi
1724f353fbadSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
1725f353fbadSmrg}
1726f353fbadSmrg# end func_convert_file_cygwin_to_w32
1727f353fbadSmrg
1728f353fbadSmrg
1729f353fbadSmrg# func_convert_file_nix_to_w32 ARG
1730f353fbadSmrg# Convert file name ARG from *nix to w32 format.  Requires a wine environment
1731f353fbadSmrg# and a working winepath. Returns result in func_to_host_file_result.
1732f353fbadSmrgfunc_convert_file_nix_to_w32 ()
1733f353fbadSmrg{
1734f353fbadSmrg  $opt_debug
1735f353fbadSmrg  func_to_host_file_result="$1"
1736f353fbadSmrg  if test -n "$1"; then
1737f353fbadSmrg    func_convert_core_file_wine_to_w32 "$1"
1738f353fbadSmrg    func_to_host_file_result="$func_convert_core_file_wine_to_w32_result"
1739f353fbadSmrg  fi
1740f353fbadSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
1741f353fbadSmrg}
1742f353fbadSmrg# end func_convert_file_nix_to_w32
1743f353fbadSmrg
1744f353fbadSmrg
1745f353fbadSmrg# func_convert_file_msys_to_cygwin ARG
1746f353fbadSmrg# Convert file name ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
1747f353fbadSmrg# Returns result in func_to_host_file_result.
1748f353fbadSmrgfunc_convert_file_msys_to_cygwin ()
1749f353fbadSmrg{
1750f353fbadSmrg  $opt_debug
1751f353fbadSmrg  func_to_host_file_result="$1"
1752f353fbadSmrg  if test -n "$1"; then
1753f353fbadSmrg    func_convert_core_msys_to_w32 "$1"
1754f353fbadSmrg    func_cygpath -u "$func_convert_core_msys_to_w32_result"
1755f353fbadSmrg    func_to_host_file_result="$func_cygpath_result"
1756f353fbadSmrg  fi
1757f353fbadSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
1758f353fbadSmrg}
1759f353fbadSmrg# end func_convert_file_msys_to_cygwin
1760f353fbadSmrg
1761f353fbadSmrg
1762f353fbadSmrg# func_convert_file_nix_to_cygwin ARG
1763f353fbadSmrg# Convert file name ARG from *nix to Cygwin format.  Requires Cygwin installed
1764f353fbadSmrg# in a wine environment, working winepath, and LT_CYGPATH set.  Returns result
1765f353fbadSmrg# in func_to_host_file_result.
1766f353fbadSmrgfunc_convert_file_nix_to_cygwin ()
1767f353fbadSmrg{
1768f353fbadSmrg  $opt_debug
1769f353fbadSmrg  func_to_host_file_result="$1"
1770f353fbadSmrg  if test -n "$1"; then
1771f353fbadSmrg    # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
1772f353fbadSmrg    func_convert_core_file_wine_to_w32 "$1"
1773f353fbadSmrg    func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
1774f353fbadSmrg    func_to_host_file_result="$func_cygpath_result"
1775f353fbadSmrg  fi
1776f353fbadSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
1777f353fbadSmrg}
1778f353fbadSmrg# end func_convert_file_nix_to_cygwin
1779f353fbadSmrg
1780f353fbadSmrg
1781f353fbadSmrg#############################################
1782f353fbadSmrg# $build to $host PATH CONVERSION FUNCTIONS #
1783f353fbadSmrg#############################################
1784f353fbadSmrg# invoked via `$to_host_path_cmd ARG'
1785f353fbadSmrg#
1786f353fbadSmrg# In each case, ARG is the path to be converted from $build to $host format.
1787f353fbadSmrg# The result will be available in $func_to_host_path_result.
1788f353fbadSmrg#
1789f353fbadSmrg# Path separators are also converted from $build format to $host format.  If
1790f353fbadSmrg# ARG begins or ends with a path separator character, it is preserved (but
1791f353fbadSmrg# converted to $host format) on output.
1792f353fbadSmrg#
1793f353fbadSmrg# All path conversion functions are named using the following convention:
1794f353fbadSmrg#   file name conversion function    : func_convert_file_X_to_Y ()
1795f353fbadSmrg#   path conversion function         : func_convert_path_X_to_Y ()
1796f353fbadSmrg# where, for any given $build/$host combination the 'X_to_Y' value is the
1797f353fbadSmrg# same.  If conversion functions are added for new $build/$host combinations,
1798f353fbadSmrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd
1799f353fbadSmrg# will break.
1800f353fbadSmrg
1801f353fbadSmrg
1802f353fbadSmrg# func_init_to_host_path_cmd
1803f353fbadSmrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the
1804f353fbadSmrg# appropriate value, based on the value of $to_host_file_cmd.
1805f353fbadSmrgto_host_path_cmd=
1806f353fbadSmrgfunc_init_to_host_path_cmd ()
1807f353fbadSmrg{
1808f353fbadSmrg  $opt_debug
1809f353fbadSmrg  if test -z "$to_host_path_cmd"; then
1810f353fbadSmrg    func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
1811f353fbadSmrg    to_host_path_cmd="func_convert_path_${func_stripname_result}"
1812f353fbadSmrg  fi
1813f353fbadSmrg}
1814f353fbadSmrg
1815f353fbadSmrg
1816f353fbadSmrg# func_to_host_path ARG
1817f353fbadSmrg# Converts the path ARG from $build format to $host format. Return result
1818f353fbadSmrg# in func_to_host_path_result.
1819f353fbadSmrgfunc_to_host_path ()
1820f353fbadSmrg{
1821f353fbadSmrg  $opt_debug
1822f353fbadSmrg  func_init_to_host_path_cmd
1823f353fbadSmrg  $to_host_path_cmd "$1"
1824f353fbadSmrg}
1825f353fbadSmrg# end func_to_host_path
1826f353fbadSmrg
1827f353fbadSmrg
1828f353fbadSmrg# func_convert_path_noop ARG
1829f353fbadSmrg# Copy ARG to func_to_host_path_result.
1830f353fbadSmrgfunc_convert_path_noop ()
1831f353fbadSmrg{
1832f353fbadSmrg  func_to_host_path_result="$1"
1833f353fbadSmrg}
1834f353fbadSmrg# end func_convert_path_noop
1835f353fbadSmrg
1836f353fbadSmrg
1837f353fbadSmrg# func_convert_path_msys_to_w32 ARG
1838f353fbadSmrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic
1839f353fbadSmrg# conversion to w32 is not available inside the cwrapper.  Returns result in
1840f353fbadSmrg# func_to_host_path_result.
1841f353fbadSmrgfunc_convert_path_msys_to_w32 ()
1842994689c1Smrg{
1843f353fbadSmrg  $opt_debug
1844f353fbadSmrg  func_to_host_path_result="$1"
1845f353fbadSmrg  if test -n "$1"; then
1846f353fbadSmrg    # Remove leading and trailing path separator characters from ARG.  MSYS
1847f353fbadSmrg    # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
1848f353fbadSmrg    # and winepath ignores them completely.
1849f353fbadSmrg    func_stripname : : "$1"
1850f353fbadSmrg    func_to_host_path_tmp1=$func_stripname_result
1851f353fbadSmrg    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
1852f353fbadSmrg    func_to_host_path_result="$func_convert_core_msys_to_w32_result"
1853f353fbadSmrg    func_convert_path_check : ";" \
1854f353fbadSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1855f353fbadSmrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
1856f353fbadSmrg  fi
1857f353fbadSmrg}
1858f353fbadSmrg# end func_convert_path_msys_to_w32
1859994689c1Smrg
1860994689c1Smrg
1861f353fbadSmrg# func_convert_path_cygwin_to_w32 ARG
1862f353fbadSmrg# Convert path ARG from Cygwin to w32 format.  Returns result in
1863f353fbadSmrg# func_to_host_file_result.
1864f353fbadSmrgfunc_convert_path_cygwin_to_w32 ()
1865f353fbadSmrg{
1866f353fbadSmrg  $opt_debug
1867f353fbadSmrg  func_to_host_path_result="$1"
1868f353fbadSmrg  if test -n "$1"; then
1869f353fbadSmrg    # See func_convert_path_msys_to_w32:
1870f353fbadSmrg    func_stripname : : "$1"
1871f353fbadSmrg    func_to_host_path_tmp1=$func_stripname_result
1872f353fbadSmrg    func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"`
1873f353fbadSmrg    func_convert_path_check : ";" \
1874f353fbadSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1875f353fbadSmrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
1876f353fbadSmrg  fi
1877f353fbadSmrg}
1878f353fbadSmrg# end func_convert_path_cygwin_to_w32
1879994689c1Smrg
1880994689c1Smrg
1881f353fbadSmrg# func_convert_path_nix_to_w32 ARG
1882f353fbadSmrg# Convert path ARG from *nix to w32 format.  Requires a wine environment and
1883f353fbadSmrg# a working winepath.  Returns result in func_to_host_file_result.
1884f353fbadSmrgfunc_convert_path_nix_to_w32 ()
1885f353fbadSmrg{
1886f353fbadSmrg  $opt_debug
1887f353fbadSmrg  func_to_host_path_result="$1"
1888f353fbadSmrg  if test -n "$1"; then
1889f353fbadSmrg    # See func_convert_path_msys_to_w32:
1890f353fbadSmrg    func_stripname : : "$1"
1891f353fbadSmrg    func_to_host_path_tmp1=$func_stripname_result
1892f353fbadSmrg    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
1893f353fbadSmrg    func_to_host_path_result="$func_convert_core_path_wine_to_w32_result"
1894f353fbadSmrg    func_convert_path_check : ";" \
1895f353fbadSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1896f353fbadSmrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
1897f353fbadSmrg  fi
1898f353fbadSmrg}
1899f353fbadSmrg# end func_convert_path_nix_to_w32
1900994689c1Smrg
1901f353fbadSmrg
1902f353fbadSmrg# func_convert_path_msys_to_cygwin ARG
1903f353fbadSmrg# Convert path ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
1904f353fbadSmrg# Returns result in func_to_host_file_result.
1905f353fbadSmrgfunc_convert_path_msys_to_cygwin ()
1906f353fbadSmrg{
1907f353fbadSmrg  $opt_debug
1908f353fbadSmrg  func_to_host_path_result="$1"
1909f353fbadSmrg  if test -n "$1"; then
1910f353fbadSmrg    # See func_convert_path_msys_to_w32:
1911f353fbadSmrg    func_stripname : : "$1"
1912f353fbadSmrg    func_to_host_path_tmp1=$func_stripname_result
1913f353fbadSmrg    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
1914f353fbadSmrg    func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
1915f353fbadSmrg    func_to_host_path_result="$func_cygpath_result"
1916f353fbadSmrg    func_convert_path_check : : \
1917f353fbadSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1918f353fbadSmrg    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
1919f353fbadSmrg  fi
1920f353fbadSmrg}
1921f353fbadSmrg# end func_convert_path_msys_to_cygwin
1922f353fbadSmrg
1923f353fbadSmrg
1924f353fbadSmrg# func_convert_path_nix_to_cygwin ARG
1925f353fbadSmrg# Convert path ARG from *nix to Cygwin format.  Requires Cygwin installed in a
1926f353fbadSmrg# a wine environment, working winepath, and LT_CYGPATH set.  Returns result in
1927f353fbadSmrg# func_to_host_file_result.
1928f353fbadSmrgfunc_convert_path_nix_to_cygwin ()
1929f353fbadSmrg{
1930f353fbadSmrg  $opt_debug
1931f353fbadSmrg  func_to_host_path_result="$1"
1932f353fbadSmrg  if test -n "$1"; then
1933f353fbadSmrg    # Remove leading and trailing path separator characters from
1934f353fbadSmrg    # ARG. msys behavior is inconsistent here, cygpath turns them
1935f353fbadSmrg    # into '.;' and ';.', and winepath ignores them completely.
1936f353fbadSmrg    func_stripname : : "$1"
1937f353fbadSmrg    func_to_host_path_tmp1=$func_stripname_result
1938f353fbadSmrg    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
1939f353fbadSmrg    func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
1940f353fbadSmrg    func_to_host_path_result="$func_cygpath_result"
1941f353fbadSmrg    func_convert_path_check : : \
1942f353fbadSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1943f353fbadSmrg    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
1944f353fbadSmrg  fi
1945994689c1Smrg}
1946f353fbadSmrg# end func_convert_path_nix_to_cygwin
1947f353fbadSmrg
1948994689c1Smrg
1949994689c1Smrg# func_mode_compile arg...
1950994689c1Smrgfunc_mode_compile ()
1951994689c1Smrg{
1952994689c1Smrg    $opt_debug
1953994689c1Smrg    # Get the compilation command and the source file.
1954994689c1Smrg    base_compile=
1955994689c1Smrg    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
1956994689c1Smrg    suppress_opt=yes
1957994689c1Smrg    suppress_output=
1958994689c1Smrg    arg_mode=normal
1959994689c1Smrg    libobj=
1960994689c1Smrg    later=
1961994689c1Smrg    pie_flag=
1962994689c1Smrg
1963994689c1Smrg    for arg
1964994689c1Smrg    do
1965994689c1Smrg      case $arg_mode in
1966994689c1Smrg      arg  )
1967994689c1Smrg	# do not "continue".  Instead, add this to base_compile
1968994689c1Smrg	lastarg="$arg"
1969994689c1Smrg	arg_mode=normal
1970994689c1Smrg	;;
1971994689c1Smrg
1972994689c1Smrg      target )
1973994689c1Smrg	libobj="$arg"
1974994689c1Smrg	arg_mode=normal
1975994689c1Smrg	continue
1976994689c1Smrg	;;
1977994689c1Smrg
1978994689c1Smrg      normal )
1979994689c1Smrg	# Accept any command-line options.
1980994689c1Smrg	case $arg in
1981994689c1Smrg	-o)
1982994689c1Smrg	  test -n "$libobj" && \
1983994689c1Smrg	    func_fatal_error "you cannot specify \`-o' more than once"
1984994689c1Smrg	  arg_mode=target
1985994689c1Smrg	  continue
1986994689c1Smrg	  ;;
1987994689c1Smrg
1988994689c1Smrg	-pie | -fpie | -fPIE)
1989f353fbadSmrg          func_append pie_flag " $arg"
1990994689c1Smrg	  continue
1991994689c1Smrg	  ;;
1992994689c1Smrg
1993994689c1Smrg	-shared | -static | -prefer-pic | -prefer-non-pic)
1994f353fbadSmrg	  func_append later " $arg"
1995994689c1Smrg	  continue
1996994689c1Smrg	  ;;
19977a84e134Smrg
19987a84e134Smrg	-no-suppress)
19997a84e134Smrg	  suppress_opt=no
20007a84e134Smrg	  continue
20017a84e134Smrg	  ;;
20027a84e134Smrg
20037a84e134Smrg	-Xcompiler)
20047a84e134Smrg	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
20057a84e134Smrg	  continue      #  The current "srcfile" will either be retained or
20067a84e134Smrg	  ;;            #  replaced later.  I would guess that would be a bug.
20077a84e134Smrg
20087a84e134Smrg	-Wc,*)
2009994689c1Smrg	  func_stripname '-Wc,' '' "$arg"
2010994689c1Smrg	  args=$func_stripname_result
20117a84e134Smrg	  lastarg=
20127a84e134Smrg	  save_ifs="$IFS"; IFS=','
2013994689c1Smrg	  for arg in $args; do
20147a84e134Smrg	    IFS="$save_ifs"
2015f353fbadSmrg	    func_append_quoted lastarg "$arg"
20167a84e134Smrg	  done
20177a84e134Smrg	  IFS="$save_ifs"
2018994689c1Smrg	  func_stripname ' ' '' "$lastarg"
2019994689c1Smrg	  lastarg=$func_stripname_result
20207a84e134Smrg
20217a84e134Smrg	  # Add the arguments to base_compile.
2022f353fbadSmrg	  func_append base_compile " $lastarg"
20237a84e134Smrg	  continue
20247a84e134Smrg	  ;;
20257a84e134Smrg
2026994689c1Smrg	*)
20277a84e134Smrg	  # Accept the current argument as the source file.
20287a84e134Smrg	  # The previous "srcfile" becomes the current argument.
20297a84e134Smrg	  #
20307a84e134Smrg	  lastarg="$srcfile"
20317a84e134Smrg	  srcfile="$arg"
20327a84e134Smrg	  ;;
20337a84e134Smrg	esac  #  case $arg
20347a84e134Smrg	;;
20357a84e134Smrg      esac    #  case $arg_mode
20367a84e134Smrg
20377a84e134Smrg      # Aesthetically quote the previous argument.
2038f353fbadSmrg      func_append_quoted base_compile "$lastarg"
20397a84e134Smrg    done # for arg
20407a84e134Smrg
20417a84e134Smrg    case $arg_mode in
20427a84e134Smrg    arg)
2043994689c1Smrg      func_fatal_error "you must specify an argument for -Xcompile"
20447a84e134Smrg      ;;
20457a84e134Smrg    target)
2046994689c1Smrg      func_fatal_error "you must specify a target with \`-o'"
20477a84e134Smrg      ;;
20487a84e134Smrg    *)
20497a84e134Smrg      # Get the name of the library object.
2050994689c1Smrg      test -z "$libobj" && {
2051994689c1Smrg	func_basename "$srcfile"
2052994689c1Smrg	libobj="$func_basename_result"
2053994689c1Smrg      }
20547a84e134Smrg      ;;
20557a84e134Smrg    esac
20567a84e134Smrg
20577a84e134Smrg    # Recognize several different file suffixes.
20587a84e134Smrg    # If the user specifies -o file.o, it is replaced with file.lo
20597a84e134Smrg    case $libobj in
2060994689c1Smrg    *.[cCFSifmso] | \
2061994689c1Smrg    *.ada | *.adb | *.ads | *.asm | \
2062994689c1Smrg    *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
2063421c997bSmrg    *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup)
2064994689c1Smrg      func_xform "$libobj"
2065994689c1Smrg      libobj=$func_xform_result
2066994689c1Smrg      ;;
20677a84e134Smrg    esac
20687a84e134Smrg
20697a84e134Smrg    case $libobj in
2070994689c1Smrg    *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
20717a84e134Smrg    *)
2072994689c1Smrg      func_fatal_error "cannot determine name of library object from \`$libobj'"
20737a84e134Smrg      ;;
20747a84e134Smrg    esac
20757a84e134Smrg
20767a84e134Smrg    func_infer_tag $base_compile
20777a84e134Smrg
20787a84e134Smrg    for arg in $later; do
20797a84e134Smrg      case $arg in
2080994689c1Smrg      -shared)
2081994689c1Smrg	test "$build_libtool_libs" != yes && \
2082994689c1Smrg	  func_fatal_configuration "can not build a shared library"
2083994689c1Smrg	build_old_libs=no
2084994689c1Smrg	continue
2085994689c1Smrg	;;
2086994689c1Smrg
20877a84e134Smrg      -static)
2088994689c1Smrg	build_libtool_libs=no
20897a84e134Smrg	build_old_libs=yes
20907a84e134Smrg	continue
20917a84e134Smrg	;;
20927a84e134Smrg
20937a84e134Smrg      -prefer-pic)
20947a84e134Smrg	pic_mode=yes
20957a84e134Smrg	continue
20967a84e134Smrg	;;
20977a84e134Smrg
20987a84e134Smrg      -prefer-non-pic)
20997a84e134Smrg	pic_mode=no
21007a84e134Smrg	continue
21017a84e134Smrg	;;
21027a84e134Smrg      esac
21037a84e134Smrg    done
21047a84e134Smrg
2105994689c1Smrg    func_quote_for_eval "$libobj"
2106994689c1Smrg    test "X$libobj" != "X$func_quote_for_eval_result" \
2107994689c1Smrg      && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'	 &()|`$[]' \
2108994689c1Smrg      && func_warning "libobj name \`$libobj' may not contain shell special characters."
2109994689c1Smrg    func_dirname_and_basename "$obj" "/" ""
2110994689c1Smrg    objname="$func_basename_result"
2111994689c1Smrg    xdir="$func_dirname_result"
21127a84e134Smrg    lobj=${xdir}$objdir/$objname
21137a84e134Smrg
2114994689c1Smrg    test -z "$base_compile" && \
2115994689c1Smrg      func_fatal_help "you must specify a compilation command"
21167a84e134Smrg
21177a84e134Smrg    # Delete any leftover library objects.
21187a84e134Smrg    if test "$build_old_libs" = yes; then
21197a84e134Smrg      removelist="$obj $lobj $libobj ${libobj}T"
21207a84e134Smrg    else
21217a84e134Smrg      removelist="$lobj $libobj ${libobj}T"
21227a84e134Smrg    fi
21237a84e134Smrg
21247a84e134Smrg    # On Cygwin there's no "real" PIC flag so we must build both object types
21257a84e134Smrg    case $host_os in
2126994689c1Smrg    cygwin* | mingw* | pw32* | os2* | cegcc*)
21277a84e134Smrg      pic_mode=default
21287a84e134Smrg      ;;
21297a84e134Smrg    esac
21307a84e134Smrg    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
21317a84e134Smrg      # non-PIC code in shared libraries is not supported
21327a84e134Smrg      pic_mode=default
21337a84e134Smrg    fi
21347a84e134Smrg
21357a84e134Smrg    # Calculate the filename of the output object if compiler does
21367a84e134Smrg    # not support -o with -c
21377a84e134Smrg    if test "$compiler_c_o" = no; then
2138994689c1Smrg      output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext}
21397a84e134Smrg      lockfile="$output_obj.lock"
21407a84e134Smrg    else
21417a84e134Smrg      output_obj=
21427a84e134Smrg      need_locks=no
21437a84e134Smrg      lockfile=
21447a84e134Smrg    fi
21457a84e134Smrg
21467a84e134Smrg    # Lock this critical section if it is needed
21477a84e134Smrg    # We use this script file to make the link, it avoids creating a new file
21487a84e134Smrg    if test "$need_locks" = yes; then
2149994689c1Smrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
2150994689c1Smrg	func_echo "Waiting for $lockfile to be removed"
21517a84e134Smrg	sleep 2
21527a84e134Smrg      done
21537a84e134Smrg    elif test "$need_locks" = warn; then
21547a84e134Smrg      if test -f "$lockfile"; then
2155994689c1Smrg	$ECHO "\
21567a84e134Smrg*** ERROR, $lockfile exists and contains:
21577a84e134Smrg`cat $lockfile 2>/dev/null`
21587a84e134Smrg
21597a84e134SmrgThis indicates that another process is trying to use the same
21607a84e134Smrgtemporary object file, and libtool could not work around it because
21617a84e134Smrgyour compiler does not support \`-c' and \`-o' together.  If you
21627a84e134Smrgrepeat this compilation, it may succeed, by chance, but you had better
21637a84e134Smrgavoid parallel builds (make -j) in this platform, or get a better
21647a84e134Smrgcompiler."
21657a84e134Smrg
2166994689c1Smrg	$opt_dry_run || $RM $removelist
21677a84e134Smrg	exit $EXIT_FAILURE
21687a84e134Smrg      fi
2169f353fbadSmrg      func_append removelist " $output_obj"
2170994689c1Smrg      $ECHO "$srcfile" > "$lockfile"
21717a84e134Smrg    fi
21727a84e134Smrg
2173994689c1Smrg    $opt_dry_run || $RM $removelist
2174f353fbadSmrg    func_append removelist " $lockfile"
2175994689c1Smrg    trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
2176994689c1Smrg
2177f353fbadSmrg    func_to_tool_file "$srcfile" func_convert_file_msys_to_w32
2178f353fbadSmrg    srcfile=$func_to_tool_file_result
2179994689c1Smrg    func_quote_for_eval "$srcfile"
2180994689c1Smrg    qsrcfile=$func_quote_for_eval_result
21817a84e134Smrg
21827a84e134Smrg    # Only build a PIC object if we are building libtool libraries.
21837a84e134Smrg    if test "$build_libtool_libs" = yes; then
21847a84e134Smrg      # Without this assignment, base_compile gets emptied.
21857a84e134Smrg      fbsd_hideous_sh_bug=$base_compile
21867a84e134Smrg
21877a84e134Smrg      if test "$pic_mode" != no; then
21887a84e134Smrg	command="$base_compile $qsrcfile $pic_flag"
21897a84e134Smrg      else
21907a84e134Smrg	# Don't build PIC code
21917a84e134Smrg	command="$base_compile $qsrcfile"
21927a84e134Smrg      fi
21937a84e134Smrg
2194994689c1Smrg      func_mkdir_p "$xdir$objdir"
21957a84e134Smrg
21967a84e134Smrg      if test -z "$output_obj"; then
21977a84e134Smrg	# Place PIC objects in $objdir
2198f353fbadSmrg	func_append command " -o $lobj"
21997a84e134Smrg      fi
22007a84e134Smrg
2201994689c1Smrg      func_show_eval_locale "$command"	\
2202994689c1Smrg          'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
22037a84e134Smrg
22047a84e134Smrg      if test "$need_locks" = warn &&
22057a84e134Smrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
2206994689c1Smrg	$ECHO "\
22077a84e134Smrg*** ERROR, $lockfile contains:
22087a84e134Smrg`cat $lockfile 2>/dev/null`
22097a84e134Smrg
22107a84e134Smrgbut it should contain:
22117a84e134Smrg$srcfile
22127a84e134Smrg
22137a84e134SmrgThis indicates that another process is trying to use the same
22147a84e134Smrgtemporary object file, and libtool could not work around it because
22157a84e134Smrgyour compiler does not support \`-c' and \`-o' together.  If you
22167a84e134Smrgrepeat this compilation, it may succeed, by chance, but you had better
22177a84e134Smrgavoid parallel builds (make -j) in this platform, or get a better
22187a84e134Smrgcompiler."
22197a84e134Smrg
2220994689c1Smrg	$opt_dry_run || $RM $removelist
22217a84e134Smrg	exit $EXIT_FAILURE
22227a84e134Smrg      fi
22237a84e134Smrg
22247a84e134Smrg      # Just move the object if needed, then go on to compile the next one
22257a84e134Smrg      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
2226994689c1Smrg	func_show_eval '$MV "$output_obj" "$lobj"' \
2227994689c1Smrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
22287a84e134Smrg      fi
22297a84e134Smrg
22307a84e134Smrg      # Allow error messages only from the first compilation.
22317a84e134Smrg      if test "$suppress_opt" = yes; then
2232994689c1Smrg	suppress_output=' >/dev/null 2>&1'
22337a84e134Smrg      fi
22347a84e134Smrg    fi
22357a84e134Smrg
22367a84e134Smrg    # Only build a position-dependent object if we build old libraries.
22377a84e134Smrg    if test "$build_old_libs" = yes; then
22387a84e134Smrg      if test "$pic_mode" != yes; then
22397a84e134Smrg	# Don't build PIC code
2240994689c1Smrg	command="$base_compile $qsrcfile$pie_flag"
22417a84e134Smrg      else
22427a84e134Smrg	command="$base_compile $qsrcfile $pic_flag"
22437a84e134Smrg      fi
22447a84e134Smrg      if test "$compiler_c_o" = yes; then
2245f353fbadSmrg	func_append command " -o $obj"
22467a84e134Smrg      fi
22477a84e134Smrg
22487a84e134Smrg      # Suppress compiler output if we already did a PIC compilation.
2249f353fbadSmrg      func_append command "$suppress_output"
2250994689c1Smrg      func_show_eval_locale "$command" \
2251994689c1Smrg        '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
22527a84e134Smrg
22537a84e134Smrg      if test "$need_locks" = warn &&
22547a84e134Smrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
2255994689c1Smrg	$ECHO "\
22567a84e134Smrg*** ERROR, $lockfile contains:
22577a84e134Smrg`cat $lockfile 2>/dev/null`
22587a84e134Smrg
22597a84e134Smrgbut it should contain:
22607a84e134Smrg$srcfile
22617a84e134Smrg
22627a84e134SmrgThis indicates that another process is trying to use the same
22637a84e134Smrgtemporary object file, and libtool could not work around it because
22647a84e134Smrgyour compiler does not support \`-c' and \`-o' together.  If you
22657a84e134Smrgrepeat this compilation, it may succeed, by chance, but you had better
22667a84e134Smrgavoid parallel builds (make -j) in this platform, or get a better
22677a84e134Smrgcompiler."
22687a84e134Smrg
2269994689c1Smrg	$opt_dry_run || $RM $removelist
22707a84e134Smrg	exit $EXIT_FAILURE
22717a84e134Smrg      fi
22727a84e134Smrg
22737a84e134Smrg      # Just move the object if needed
22747a84e134Smrg      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
2275994689c1Smrg	func_show_eval '$MV "$output_obj" "$obj"' \
2276994689c1Smrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
22777a84e134Smrg      fi
22787a84e134Smrg    fi
22797a84e134Smrg
2280994689c1Smrg    $opt_dry_run || {
2281994689c1Smrg      func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
22827a84e134Smrg
2283994689c1Smrg      # Unlock the critical section if it was locked
2284994689c1Smrg      if test "$need_locks" != no; then
2285994689c1Smrg	removelist=$lockfile
2286994689c1Smrg        $RM "$lockfile"
2287994689c1Smrg      fi
2288994689c1Smrg    }
22897a84e134Smrg
22907a84e134Smrg    exit $EXIT_SUCCESS
2291994689c1Smrg}
22927a84e134Smrg
2293994689c1Smrg$opt_help || {
2294f353fbadSmrg  test "$opt_mode" = compile && func_mode_compile ${1+"$@"}
2295994689c1Smrg}
22967a84e134Smrg
2297994689c1Smrgfunc_mode_help ()
2298994689c1Smrg{
2299994689c1Smrg    # We need to display help for each of the modes.
2300f353fbadSmrg    case $opt_mode in
2301994689c1Smrg      "")
2302994689c1Smrg        # Generic help is extracted from the usage comments
2303994689c1Smrg        # at the start of this file.
2304994689c1Smrg        func_help
2305994689c1Smrg        ;;
23067a84e134Smrg
2307994689c1Smrg      clean)
2308994689c1Smrg        $ECHO \
2309994689c1Smrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
23107a84e134Smrg
2311994689c1SmrgRemove files from the build directory.
23127a84e134Smrg
2313994689c1SmrgRM is the name of the program to use to delete files associated with each FILE
2314994689c1Smrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
2315994689c1Smrgto RM.
23167a84e134Smrg
2317994689c1SmrgIf FILE is a libtool library, object or program, all the files associated
2318994689c1Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM."
2319994689c1Smrg        ;;
23207a84e134Smrg
2321994689c1Smrg      compile)
2322994689c1Smrg      $ECHO \
2323994689c1Smrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
23247a84e134Smrg
2325994689c1SmrgCompile a source file into a libtool library object.
23267a84e134Smrg
2327994689c1SmrgThis mode accepts the following additional options:
23287a84e134Smrg
2329994689c1Smrg  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
2330994689c1Smrg  -no-suppress      do not suppress compiler output for multiple passes
2331994689c1Smrg  -prefer-pic       try to build PIC objects only
2332994689c1Smrg  -prefer-non-pic   try to build non-PIC objects only
2333994689c1Smrg  -shared           do not build a \`.o' file suitable for static linking
2334994689c1Smrg  -static           only build a \`.o' file suitable for static linking
2335994689c1Smrg  -Wc,FLAG          pass FLAG directly to the compiler
23367a84e134Smrg
2337994689c1SmrgCOMPILE-COMMAND is a command to be used in creating a \`standard' object file
2338994689c1Smrgfrom the given SOURCEFILE.
23397a84e134Smrg
2340994689c1SmrgThe output file name is determined by removing the directory component from
2341994689c1SmrgSOURCEFILE, then substituting the C source code suffix \`.c' with the
2342994689c1Smrglibrary object suffix, \`.lo'."
2343994689c1Smrg        ;;
23447a84e134Smrg
2345994689c1Smrg      execute)
2346994689c1Smrg        $ECHO \
2347994689c1Smrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
23487a84e134Smrg
2349994689c1SmrgAutomatically set library path, then run a program.
23507a84e134Smrg
2351994689c1SmrgThis mode accepts the following additional options:
23527a84e134Smrg
2353994689c1Smrg  -dlopen FILE      add the directory containing FILE to the library path
23547a84e134Smrg
2355994689c1SmrgThis mode sets the library path environment variable according to \`-dlopen'
2356994689c1Smrgflags.
23577a84e134Smrg
2358994689c1SmrgIf any of the ARGS are libtool executable wrappers, then they are translated
2359994689c1Smrginto their corresponding uninstalled binary, and any of their required library
2360994689c1Smrgdirectories are added to the library path.
23617a84e134Smrg
2362994689c1SmrgThen, COMMAND is executed, with ARGS as arguments."
2363994689c1Smrg        ;;
23647a84e134Smrg
2365994689c1Smrg      finish)
2366994689c1Smrg        $ECHO \
2367994689c1Smrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
23687a84e134Smrg
2369994689c1SmrgComplete the installation of libtool libraries.
23707a84e134Smrg
2371994689c1SmrgEach LIBDIR is a directory that contains libtool libraries.
23727a84e134Smrg
2373994689c1SmrgThe commands that this mode executes may require superuser privileges.  Use
2374994689c1Smrgthe \`--dry-run' option if you just want to see what would be executed."
2375994689c1Smrg        ;;
23767a84e134Smrg
2377994689c1Smrg      install)
2378994689c1Smrg        $ECHO \
2379994689c1Smrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
23807a84e134Smrg
2381994689c1SmrgInstall executables or libraries.
23827a84e134Smrg
2383994689c1SmrgINSTALL-COMMAND is the installation command.  The first component should be
2384994689c1Smrgeither the \`install' or \`cp' program.
23857a84e134Smrg
2386994689c1SmrgThe following components of INSTALL-COMMAND are treated specially:
23877a84e134Smrg
2388994689c1Smrg  -inst-prefix-dir PREFIX-DIR  Use PREFIX-DIR as a staging area for installation
23897a84e134Smrg
2390994689c1SmrgThe rest of the components are interpreted as arguments to that command (only
2391994689c1SmrgBSD-compatible install options are recognized)."
2392994689c1Smrg        ;;
23937a84e134Smrg
2394994689c1Smrg      link)
2395994689c1Smrg        $ECHO \
2396994689c1Smrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
23977a84e134Smrg
2398994689c1SmrgLink object files or libraries together to form another library, or to
2399994689c1Smrgcreate an executable program.
24007a84e134Smrg
2401994689c1SmrgLINK-COMMAND is a command using the C compiler that you would use to create
2402994689c1Smrga program from several object files.
24037a84e134Smrg
2404994689c1SmrgThe following components of LINK-COMMAND are treated specially:
24057a84e134Smrg
2406994689c1Smrg  -all-static       do not do any dynamic linking at all
2407994689c1Smrg  -avoid-version    do not add a version suffix if possible
2408994689c1Smrg  -bindir BINDIR    specify path to binaries directory (for systems where
2409994689c1Smrg                    libraries must be found in the PATH setting at runtime)
2410994689c1Smrg  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
2411994689c1Smrg  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
2412994689c1Smrg  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
2413994689c1Smrg  -export-symbols SYMFILE
2414994689c1Smrg                    try to export only the symbols listed in SYMFILE
2415994689c1Smrg  -export-symbols-regex REGEX
2416994689c1Smrg                    try to export only the symbols matching REGEX
2417994689c1Smrg  -LLIBDIR          search LIBDIR for required installed libraries
2418994689c1Smrg  -lNAME            OUTPUT-FILE requires the installed library libNAME
2419994689c1Smrg  -module           build a library that can dlopened
2420994689c1Smrg  -no-fast-install  disable the fast-install mode
2421994689c1Smrg  -no-install       link a not-installable executable
2422994689c1Smrg  -no-undefined     declare that a library does not refer to external symbols
2423994689c1Smrg  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
2424994689c1Smrg  -objectlist FILE  Use a list of object files found in FILE to specify objects
2425994689c1Smrg  -precious-files-regex REGEX
2426994689c1Smrg                    don't remove output files matching REGEX
2427994689c1Smrg  -release RELEASE  specify package release information
2428994689c1Smrg  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
2429994689c1Smrg  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
2430994689c1Smrg  -shared           only do dynamic linking of libtool libraries
2431994689c1Smrg  -shrext SUFFIX    override the standard shared library file extension
2432994689c1Smrg  -static           do not do any dynamic linking of uninstalled libtool libraries
2433994689c1Smrg  -static-libtool-libs
2434994689c1Smrg                    do not do any dynamic linking of libtool libraries
2435994689c1Smrg  -version-info CURRENT[:REVISION[:AGE]]
2436994689c1Smrg                    specify library version info [each variable defaults to 0]
2437994689c1Smrg  -weak LIBNAME     declare that the target provides the LIBNAME interface
2438994689c1Smrg  -Wc,FLAG
2439994689c1Smrg  -Xcompiler FLAG   pass linker-specific FLAG directly to the compiler
2440994689c1Smrg  -Wl,FLAG
2441994689c1Smrg  -Xlinker FLAG     pass linker-specific FLAG directly to the linker
2442994689c1Smrg  -XCClinker FLAG   pass link-specific FLAG to the compiler driver (CC)
24437a84e134Smrg
2444994689c1SmrgAll other options (arguments beginning with \`-') are ignored.
24457a84e134Smrg
2446994689c1SmrgEvery other argument is treated as a filename.  Files ending in \`.la' are
2447994689c1Smrgtreated as uninstalled libtool libraries, other files are standard or library
2448994689c1Smrgobject files.
24497a84e134Smrg
2450994689c1SmrgIf the OUTPUT-FILE ends in \`.la', then a libtool library is created,
2451994689c1Smrgonly library objects (\`.lo' files) may be specified, and \`-rpath' is
2452994689c1Smrgrequired, except when creating a convenience library.
24537a84e134Smrg
2454994689c1SmrgIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
2455994689c1Smrgusing \`ar' and \`ranlib', or on Windows using \`lib'.
24567a84e134Smrg
2457994689c1SmrgIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
2458994689c1Smrgis created, otherwise an executable program is created."
2459994689c1Smrg        ;;
24607a84e134Smrg
2461994689c1Smrg      uninstall)
2462994689c1Smrg        $ECHO \
2463994689c1Smrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
24647a84e134Smrg
2465994689c1SmrgRemove libraries from an installation directory.
24667a84e134Smrg
2467994689c1SmrgRM is the name of the program to use to delete files associated with each FILE
2468994689c1Smrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
2469994689c1Smrgto RM.
24707a84e134Smrg
2471994689c1SmrgIf FILE is a libtool library, all the files associated with it are deleted.
2472994689c1SmrgOtherwise, only FILE itself is deleted using RM."
2473994689c1Smrg        ;;
24747a84e134Smrg
2475994689c1Smrg      *)
2476f353fbadSmrg        func_fatal_help "invalid operation mode \`$opt_mode'"
2477994689c1Smrg        ;;
2478994689c1Smrg    esac
24797a84e134Smrg
2480994689c1Smrg    echo
2481994689c1Smrg    $ECHO "Try \`$progname --help' for more information about other modes."
2482994689c1Smrg}
2483775e7de9Smrg
2484994689c1Smrg# Now that we've collected a possible --mode arg, show help if necessary
2485994689c1Smrgif $opt_help; then
2486994689c1Smrg  if test "$opt_help" = :; then
2487994689c1Smrg    func_mode_help
2488994689c1Smrg  else
2489994689c1Smrg    {
2490994689c1Smrg      func_help noexit
2491f353fbadSmrg      for opt_mode in compile link execute install finish uninstall clean; do
2492994689c1Smrg	func_mode_help
2493994689c1Smrg      done
2494994689c1Smrg    } | sed -n '1p; 2,$s/^Usage:/  or: /p'
2495994689c1Smrg    {
2496994689c1Smrg      func_help noexit
2497f353fbadSmrg      for opt_mode in compile link execute install finish uninstall clean; do
2498994689c1Smrg	echo
2499994689c1Smrg	func_mode_help
2500994689c1Smrg      done
2501994689c1Smrg    } |
2502994689c1Smrg    sed '1d
2503994689c1Smrg      /^When reporting/,/^Report/{
2504994689c1Smrg	H
2505994689c1Smrg	d
2506994689c1Smrg      }
2507994689c1Smrg      $x
2508994689c1Smrg      /information about other modes/d
2509994689c1Smrg      /more detailed .*MODE/d
2510994689c1Smrg      s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
2511994689c1Smrg  fi
2512994689c1Smrg  exit $?
2513994689c1Smrgfi
25147a84e134Smrg
25157a84e134Smrg
2516994689c1Smrg# func_mode_execute arg...
2517994689c1Smrgfunc_mode_execute ()
2518994689c1Smrg{
2519994689c1Smrg    $opt_debug
2520994689c1Smrg    # The first argument is the command name.
2521994689c1Smrg    cmd="$nonopt"
2522994689c1Smrg    test -z "$cmd" && \
2523994689c1Smrg      func_fatal_help "you must specify a COMMAND"
2524ab902922Smrg
2525994689c1Smrg    # Handle -dlopen flags immediately.
2526f353fbadSmrg    for file in $opt_dlopen; do
2527994689c1Smrg      test -f "$file" \
2528994689c1Smrg	|| func_fatal_help "\`$file' is not a file"
25297a84e134Smrg
2530994689c1Smrg      dir=
2531994689c1Smrg      case $file in
2532994689c1Smrg      *.la)
2533f353fbadSmrg	func_resolve_sysroot "$file"
2534f353fbadSmrg	file=$func_resolve_sysroot_result
2535f353fbadSmrg
2536994689c1Smrg	# Check to see that this really is a libtool archive.
2537994689c1Smrg	func_lalib_unsafe_p "$file" \
2538994689c1Smrg	  || func_fatal_help "\`$lib' is not a valid libtool archive"
25397a84e134Smrg
2540994689c1Smrg	# Read the libtool library.
2541994689c1Smrg	dlname=
2542994689c1Smrg	library_names=
2543994689c1Smrg	func_source "$file"
25447a84e134Smrg
2545994689c1Smrg	# Skip this library if it cannot be dlopened.
2546994689c1Smrg	if test -z "$dlname"; then
2547994689c1Smrg	  # Warn if it was a shared library.
2548994689c1Smrg	  test -n "$library_names" && \
2549994689c1Smrg	    func_warning "\`$file' was not linked with \`-export-dynamic'"
2550994689c1Smrg	  continue
2551994689c1Smrg	fi
2552e1e1713cSmrg
2553994689c1Smrg	func_dirname "$file" "" "."
2554994689c1Smrg	dir="$func_dirname_result"
2555e1e1713cSmrg
2556994689c1Smrg	if test -f "$dir/$objdir/$dlname"; then
2557f353fbadSmrg	  func_append dir "/$objdir"
2558994689c1Smrg	else
2559994689c1Smrg	  if test ! -f "$dir/$dlname"; then
2560994689c1Smrg	    func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'"
2561994689c1Smrg	  fi
2562994689c1Smrg	fi
2563775e7de9Smrg	;;
2564e1e1713cSmrg
2565994689c1Smrg      *.lo)
2566994689c1Smrg	# Just add the directory containing the .lo file.
2567994689c1Smrg	func_dirname "$file" "" "."
2568994689c1Smrg	dir="$func_dirname_result"
2569775e7de9Smrg	;;
2570994689c1Smrg
2571994689c1Smrg      *)
2572994689c1Smrg	func_warning "\`-dlopen' is ignored for non-libtool libraries and objects"
2573e1e1713cSmrg	continue
2574775e7de9Smrg	;;
2575994689c1Smrg      esac
2576775e7de9Smrg
2577994689c1Smrg      # Get the absolute pathname.
2578994689c1Smrg      absdir=`cd "$dir" && pwd`
2579994689c1Smrg      test -n "$absdir" && dir="$absdir"
2580775e7de9Smrg
2581994689c1Smrg      # Now add the directory to shlibpath_var.
2582994689c1Smrg      if eval "test -z \"\$$shlibpath_var\""; then
2583994689c1Smrg	eval "$shlibpath_var=\"\$dir\""
2584994689c1Smrg      else
2585994689c1Smrg	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
2586994689c1Smrg      fi
2587994689c1Smrg    done
2588775e7de9Smrg
2589994689c1Smrg    # This variable tells wrapper scripts just to set shlibpath_var
2590994689c1Smrg    # rather than running their programs.
2591994689c1Smrg    libtool_execute_magic="$magic"
25927a84e134Smrg
2593994689c1Smrg    # Check if any of the arguments is a wrapper script.
2594994689c1Smrg    args=
2595994689c1Smrg    for file
2596994689c1Smrg    do
2597994689c1Smrg      case $file in
2598994689c1Smrg      -* | *.la | *.lo ) ;;
2599994689c1Smrg      *)
2600994689c1Smrg	# Do a test to see if this is really a libtool program.
2601994689c1Smrg	if func_ltwrapper_script_p "$file"; then
2602994689c1Smrg	  func_source "$file"
2603994689c1Smrg	  # Transform arg to wrapped name.
2604994689c1Smrg	  file="$progdir/$program"
2605994689c1Smrg	elif func_ltwrapper_executable_p "$file"; then
2606994689c1Smrg	  func_ltwrapper_scriptname "$file"
2607994689c1Smrg	  func_source "$func_ltwrapper_scriptname_result"
2608994689c1Smrg	  # Transform arg to wrapped name.
2609994689c1Smrg	  file="$progdir/$program"
2610994689c1Smrg	fi
2611e1e1713cSmrg	;;
2612994689c1Smrg      esac
2613994689c1Smrg      # Quote arguments (to preserve shell metacharacters).
2614f353fbadSmrg      func_append_quoted args "$file"
2615994689c1Smrg    done
26167a84e134Smrg
2617994689c1Smrg    if test "X$opt_dry_run" = Xfalse; then
2618994689c1Smrg      if test -n "$shlibpath_var"; then
2619994689c1Smrg	# Export the shlibpath_var.
2620994689c1Smrg	eval "export $shlibpath_var"
2621994689c1Smrg      fi
2622775e7de9Smrg
2623994689c1Smrg      # Restore saved environment variables
2624994689c1Smrg      for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
2625994689c1Smrg      do
2626994689c1Smrg	eval "if test \"\${save_$lt_var+set}\" = set; then
2627994689c1Smrg                $lt_var=\$save_$lt_var; export $lt_var
2628994689c1Smrg	      else
2629994689c1Smrg		$lt_unset $lt_var
2630994689c1Smrg	      fi"
2631994689c1Smrg      done
26327a84e134Smrg
2633994689c1Smrg      # Now prepare to actually exec the command.
2634994689c1Smrg      exec_cmd="\$cmd$args"
2635994689c1Smrg    else
2636994689c1Smrg      # Display what would be done.
2637994689c1Smrg      if test -n "$shlibpath_var"; then
2638994689c1Smrg	eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
2639994689c1Smrg	echo "export $shlibpath_var"
2640994689c1Smrg      fi
2641994689c1Smrg      $ECHO "$cmd$args"
2642994689c1Smrg      exit $EXIT_SUCCESS
2643994689c1Smrg    fi
2644994689c1Smrg}
2645775e7de9Smrg
2646f353fbadSmrgtest "$opt_mode" = execute && func_mode_execute ${1+"$@"}
2647775e7de9Smrg
2648775e7de9Smrg
2649994689c1Smrg# func_mode_finish arg...
2650994689c1Smrgfunc_mode_finish ()
2651994689c1Smrg{
2652994689c1Smrg    $opt_debug
2653f353fbadSmrg    libs=
2654f353fbadSmrg    libdirs=
2655994689c1Smrg    admincmds=
2656775e7de9Smrg
2657f353fbadSmrg    for opt in "$nonopt" ${1+"$@"}
2658f353fbadSmrg    do
2659f353fbadSmrg      if test -d "$opt"; then
2660f353fbadSmrg	func_append libdirs " $opt"
2661f353fbadSmrg
2662f353fbadSmrg      elif test -f "$opt"; then
2663f353fbadSmrg	if func_lalib_unsafe_p "$opt"; then
2664f353fbadSmrg	  func_append libs " $opt"
2665f353fbadSmrg	else
2666f353fbadSmrg	  func_warning "\`$opt' is not a valid libtool archive"
2667f353fbadSmrg	fi
2668f353fbadSmrg
2669f353fbadSmrg      else
2670f353fbadSmrg	func_fatal_error "invalid argument \`$opt'"
2671f353fbadSmrg      fi
2672f353fbadSmrg    done
2673f353fbadSmrg
2674f353fbadSmrg    if test -n "$libs"; then
2675f353fbadSmrg      if test -n "$lt_sysroot"; then
2676f353fbadSmrg        sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"`
2677f353fbadSmrg        sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;"
2678f353fbadSmrg      else
2679f353fbadSmrg        sysroot_cmd=
2680f353fbadSmrg      fi
2681f353fbadSmrg
2682f353fbadSmrg      # Remove sysroot references
2683f353fbadSmrg      if $opt_dry_run; then
2684f353fbadSmrg        for lib in $libs; do
2685f353fbadSmrg          echo "removing references to $lt_sysroot and \`=' prefixes from $lib"
2686f353fbadSmrg        done
2687f353fbadSmrg      else
2688f353fbadSmrg        tmpdir=`func_mktempdir`
2689f353fbadSmrg        for lib in $libs; do
2690f353fbadSmrg	  sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
2691f353fbadSmrg	    > $tmpdir/tmp-la
2692f353fbadSmrg	  mv -f $tmpdir/tmp-la $lib
2693f353fbadSmrg	done
2694f353fbadSmrg        ${RM}r "$tmpdir"
2695f353fbadSmrg      fi
2696f353fbadSmrg    fi
2697775e7de9Smrg
2698f353fbadSmrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
2699994689c1Smrg      for libdir in $libdirs; do
2700994689c1Smrg	if test -n "$finish_cmds"; then
2701994689c1Smrg	  # Do each command in the finish commands.
2702994689c1Smrg	  func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
2703994689c1Smrg'"$cmd"'"'
2704994689c1Smrg	fi
2705994689c1Smrg	if test -n "$finish_eval"; then
2706994689c1Smrg	  # Do the single finish_eval.
2707994689c1Smrg	  eval cmds=\"$finish_eval\"
2708f353fbadSmrg	  $opt_dry_run || eval "$cmds" || func_append admincmds "
2709994689c1Smrg       $cmds"
2710994689c1Smrg	fi
2711994689c1Smrg      done
2712994689c1Smrg    fi
2713775e7de9Smrg
2714994689c1Smrg    # Exit here if they wanted silent mode.
2715994689c1Smrg    $opt_silent && exit $EXIT_SUCCESS
2716775e7de9Smrg
2717f353fbadSmrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
2718f353fbadSmrg      echo "----------------------------------------------------------------------"
2719f353fbadSmrg      echo "Libraries have been installed in:"
2720f353fbadSmrg      for libdir in $libdirs; do
2721f353fbadSmrg	$ECHO "   $libdir"
2722f353fbadSmrg      done
2723f353fbadSmrg      echo
2724f353fbadSmrg      echo "If you ever happen to want to link against installed libraries"
2725f353fbadSmrg      echo "in a given directory, LIBDIR, you must either use libtool, and"
2726f353fbadSmrg      echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
2727f353fbadSmrg      echo "flag during linking and do at least one of the following:"
2728f353fbadSmrg      if test -n "$shlibpath_var"; then
2729f353fbadSmrg	echo "   - add LIBDIR to the \`$shlibpath_var' environment variable"
2730f353fbadSmrg	echo "     during execution"
2731f353fbadSmrg      fi
2732f353fbadSmrg      if test -n "$runpath_var"; then
2733f353fbadSmrg	echo "   - add LIBDIR to the \`$runpath_var' environment variable"
2734f353fbadSmrg	echo "     during linking"
2735f353fbadSmrg      fi
2736f353fbadSmrg      if test -n "$hardcode_libdir_flag_spec"; then
2737f353fbadSmrg	libdir=LIBDIR
2738f353fbadSmrg	eval flag=\"$hardcode_libdir_flag_spec\"
2739775e7de9Smrg
2740f353fbadSmrg	$ECHO "   - use the \`$flag' linker flag"
2741f353fbadSmrg      fi
2742f353fbadSmrg      if test -n "$admincmds"; then
2743f353fbadSmrg	$ECHO "   - have your system administrator run these commands:$admincmds"
2744f353fbadSmrg      fi
2745f353fbadSmrg      if test -f /etc/ld.so.conf; then
2746f353fbadSmrg	echo "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
2747f353fbadSmrg      fi
2748f353fbadSmrg      echo
2749775e7de9Smrg
2750f353fbadSmrg      echo "See any operating system documentation about shared libraries for"
2751f353fbadSmrg      case $host in
2752f353fbadSmrg	solaris2.[6789]|solaris2.1[0-9])
2753f353fbadSmrg	  echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
2754f353fbadSmrg	  echo "pages."
2755f353fbadSmrg	  ;;
2756f353fbadSmrg	*)
2757f353fbadSmrg	  echo "more information, such as the ld(1) and ld.so(8) manual pages."
2758f353fbadSmrg	  ;;
2759f353fbadSmrg      esac
2760f353fbadSmrg      echo "----------------------------------------------------------------------"
2761f353fbadSmrg    fi
2762994689c1Smrg    exit $EXIT_SUCCESS
2763994689c1Smrg}
2764775e7de9Smrg
2765f353fbadSmrgtest "$opt_mode" = finish && func_mode_finish ${1+"$@"}
2766e1e1713cSmrg
27677a84e134Smrg
2768994689c1Smrg# func_mode_install arg...
2769994689c1Smrgfunc_mode_install ()
2770994689c1Smrg{
2771994689c1Smrg    $opt_debug
2772994689c1Smrg    # There may be an optional sh(1) argument at the beginning of
2773994689c1Smrg    # install_prog (especially on Windows NT).
2774994689c1Smrg    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
2775994689c1Smrg       # Allow the use of GNU shtool's install command.
2776994689c1Smrg       case $nonopt in *shtool*) :;; *) false;; esac; then
2777994689c1Smrg      # Aesthetically quote it.
2778994689c1Smrg      func_quote_for_eval "$nonopt"
2779994689c1Smrg      install_prog="$func_quote_for_eval_result "
2780994689c1Smrg      arg=$1
2781994689c1Smrg      shift
2782994689c1Smrg    else
2783994689c1Smrg      install_prog=
2784994689c1Smrg      arg=$nonopt
2785994689c1Smrg    fi
27867a84e134Smrg
2787994689c1Smrg    # The real first argument should be the name of the installation program.
2788994689c1Smrg    # Aesthetically quote it.
2789994689c1Smrg    func_quote_for_eval "$arg"
2790f353fbadSmrg    func_append install_prog "$func_quote_for_eval_result"
2791994689c1Smrg    install_shared_prog=$install_prog
2792994689c1Smrg    case " $install_prog " in
2793994689c1Smrg      *[\\\ /]cp\ *) install_cp=: ;;
2794994689c1Smrg      *) install_cp=false ;;
2795994689c1Smrg    esac
27967a84e134Smrg
2797994689c1Smrg    # We need to accept at least all the BSD install flags.
2798994689c1Smrg    dest=
2799994689c1Smrg    files=
2800994689c1Smrg    opts=
2801994689c1Smrg    prev=
2802994689c1Smrg    install_type=
2803994689c1Smrg    isdir=no
2804994689c1Smrg    stripme=
2805994689c1Smrg    no_mode=:
2806994689c1Smrg    for arg
2807994689c1Smrg    do
2808994689c1Smrg      arg2=
2809994689c1Smrg      if test -n "$dest"; then
2810f353fbadSmrg	func_append files " $dest"
2811994689c1Smrg	dest=$arg
2812e1e1713cSmrg	continue
2813994689c1Smrg      fi
28147a84e134Smrg
2815994689c1Smrg      case $arg in
2816994689c1Smrg      -d) isdir=yes ;;
2817994689c1Smrg      -f)
2818994689c1Smrg	if $install_cp; then :; else
2819994689c1Smrg	  prev=$arg
2820775e7de9Smrg	fi
2821994689c1Smrg	;;
2822994689c1Smrg      -g | -m | -o)
2823994689c1Smrg	prev=$arg
2824994689c1Smrg	;;
2825994689c1Smrg      -s)
2826994689c1Smrg	stripme=" -s"
2827e1e1713cSmrg	continue
2828e1e1713cSmrg	;;
2829994689c1Smrg      -*)
2830994689c1Smrg	;;
2831e1e1713cSmrg      *)
2832994689c1Smrg	# If the previous option needed an argument, then skip it.
2833994689c1Smrg	if test -n "$prev"; then
2834994689c1Smrg	  if test "x$prev" = x-m && test -n "$install_override_mode"; then
2835994689c1Smrg	    arg2=$install_override_mode
2836994689c1Smrg	    no_mode=false
2837994689c1Smrg	  fi
2838994689c1Smrg	  prev=
2839994689c1Smrg	else
2840994689c1Smrg	  dest=$arg
2841994689c1Smrg	  continue
2842994689c1Smrg	fi
2843775e7de9Smrg	;;
2844994689c1Smrg      esac
28457a84e134Smrg
2846994689c1Smrg      # Aesthetically quote the argument.
2847994689c1Smrg      func_quote_for_eval "$arg"
2848f353fbadSmrg      func_append install_prog " $func_quote_for_eval_result"
2849994689c1Smrg      if test -n "$arg2"; then
2850994689c1Smrg	func_quote_for_eval "$arg2"
2851e1e1713cSmrg      fi
2852f353fbadSmrg      func_append install_shared_prog " $func_quote_for_eval_result"
2853994689c1Smrg    done
28547a84e134Smrg
2855994689c1Smrg    test -z "$install_prog" && \
2856994689c1Smrg      func_fatal_help "you must specify an install program"
28577a84e134Smrg
2858994689c1Smrg    test -n "$prev" && \
2859994689c1Smrg      func_fatal_help "the \`$prev' option requires an argument"
2860775e7de9Smrg
2861994689c1Smrg    if test -n "$install_override_mode" && $no_mode; then
2862994689c1Smrg      if $install_cp; then :; else
2863994689c1Smrg	func_quote_for_eval "$install_override_mode"
2864f353fbadSmrg	func_append install_shared_prog " -m $func_quote_for_eval_result"
2865994689c1Smrg      fi
2866e1e1713cSmrg    fi
2867775e7de9Smrg
2868994689c1Smrg    if test -z "$files"; then
2869994689c1Smrg      if test -z "$dest"; then
2870994689c1Smrg	func_fatal_help "no file or destination specified"
2871994689c1Smrg      else
2872994689c1Smrg	func_fatal_help "you must specify a destination"
2873775e7de9Smrg      fi
2874775e7de9Smrg    fi
2875775e7de9Smrg
2876994689c1Smrg    # Strip any trailing slash from the destination.
2877994689c1Smrg    func_stripname '' '/' "$dest"
2878994689c1Smrg    dest=$func_stripname_result
28797a84e134Smrg
2880994689c1Smrg    # Check to see that the destination is a directory.
2881994689c1Smrg    test -d "$dest" && isdir=yes
2882994689c1Smrg    if test "$isdir" = yes; then
2883994689c1Smrg      destdir="$dest"
2884994689c1Smrg      destname=
2885994689c1Smrg    else
2886994689c1Smrg      func_dirname_and_basename "$dest" "" "."
2887994689c1Smrg      destdir="$func_dirname_result"
2888994689c1Smrg      destname="$func_basename_result"
2889994689c1Smrg
2890994689c1Smrg      # Not a directory, so check to see that there is only one file specified.
2891994689c1Smrg      set dummy $files; shift
2892994689c1Smrg      test "$#" -gt 1 && \
2893994689c1Smrg	func_fatal_help "\`$dest' is not a directory"
2894994689c1Smrg    fi
2895994689c1Smrg    case $destdir in
2896994689c1Smrg    [\\/]* | [A-Za-z]:[\\/]*) ;;
2897e1e1713cSmrg    *)
2898994689c1Smrg      for file in $files; do
2899994689c1Smrg	case $file in
2900994689c1Smrg	*.lo) ;;
2901994689c1Smrg	*)
2902994689c1Smrg	  func_fatal_help "\`$destdir' must be an absolute directory name"
2903994689c1Smrg	  ;;
2904994689c1Smrg	esac
2905994689c1Smrg      done
2906e1e1713cSmrg      ;;
2907e1e1713cSmrg    esac
29087a84e134Smrg
2909994689c1Smrg    # This variable tells wrapper scripts just to set variables rather
2910994689c1Smrg    # than running their programs.
2911994689c1Smrg    libtool_install_magic="$magic"
29127a84e134Smrg
2913994689c1Smrg    staticlibs=
2914994689c1Smrg    future_libdirs=
2915994689c1Smrg    current_libdirs=
2916994689c1Smrg    for file in $files; do
29177a84e134Smrg
2918994689c1Smrg      # Do each installation.
2919994689c1Smrg      case $file in
2920994689c1Smrg      *.$libext)
2921994689c1Smrg	# Do the static libraries later.
2922f353fbadSmrg	func_append staticlibs " $file"
2923994689c1Smrg	;;
2924994689c1Smrg
2925994689c1Smrg      *.la)
2926f353fbadSmrg	func_resolve_sysroot "$file"
2927f353fbadSmrg	file=$func_resolve_sysroot_result
2928f353fbadSmrg
2929994689c1Smrg	# Check to see that this really is a libtool archive.
2930994689c1Smrg	func_lalib_unsafe_p "$file" \
2931994689c1Smrg	  || func_fatal_help "\`$file' is not a valid libtool archive"
2932994689c1Smrg
2933994689c1Smrg	library_names=
2934994689c1Smrg	old_library=
2935994689c1Smrg	relink_command=
2936994689c1Smrg	func_source "$file"
2937994689c1Smrg
2938994689c1Smrg	# Add the libdir to current_libdirs if it is the destination.
2939994689c1Smrg	if test "X$destdir" = "X$libdir"; then
2940994689c1Smrg	  case "$current_libdirs " in
2941994689c1Smrg	  *" $libdir "*) ;;
2942f353fbadSmrg	  *) func_append current_libdirs " $libdir" ;;
2943775e7de9Smrg	  esac
2944994689c1Smrg	else
2945994689c1Smrg	  # Note the libdir as a future libdir.
2946994689c1Smrg	  case "$future_libdirs " in
2947994689c1Smrg	  *" $libdir "*) ;;
2948f353fbadSmrg	  *) func_append future_libdirs " $libdir" ;;
2949994689c1Smrg	  esac
2950994689c1Smrg	fi
2951775e7de9Smrg
2952994689c1Smrg	func_dirname "$file" "/" ""
2953994689c1Smrg	dir="$func_dirname_result"
2954f353fbadSmrg	func_append dir "$objdir"
2955994689c1Smrg
2956994689c1Smrg	if test -n "$relink_command"; then
2957994689c1Smrg	  # Determine the prefix the user has applied to our future dir.
2958994689c1Smrg	  inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
2959994689c1Smrg
2960994689c1Smrg	  # Don't allow the user to place us outside of our expected
2961994689c1Smrg	  # location b/c this prevents finding dependent libraries that
2962994689c1Smrg	  # are installed to the same prefix.
2963994689c1Smrg	  # At present, this check doesn't affect windows .dll's that
2964994689c1Smrg	  # are installed into $libdir/../bin (currently, that works fine)
2965994689c1Smrg	  # but it's something to keep an eye on.
2966994689c1Smrg	  test "$inst_prefix_dir" = "$destdir" && \
2967994689c1Smrg	    func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
2968994689c1Smrg
2969994689c1Smrg	  if test -n "$inst_prefix_dir"; then
2970994689c1Smrg	    # Stick the inst_prefix_dir data into the link command.
2971994689c1Smrg	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
2972994689c1Smrg	  else
2973994689c1Smrg	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
2974994689c1Smrg	  fi
2975994689c1Smrg
2976994689c1Smrg	  func_warning "relinking \`$file'"
2977994689c1Smrg	  func_show_eval "$relink_command" \
2978994689c1Smrg	    'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
2979994689c1Smrg	fi
2980994689c1Smrg
2981994689c1Smrg	# See the names of the shared library.
2982994689c1Smrg	set dummy $library_names; shift
2983994689c1Smrg	if test -n "$1"; then
2984994689c1Smrg	  realname="$1"
2985994689c1Smrg	  shift
2986994689c1Smrg
2987994689c1Smrg	  srcname="$realname"
2988994689c1Smrg	  test -n "$relink_command" && srcname="$realname"T
2989994689c1Smrg
2990994689c1Smrg	  # Install the shared library and build the symlinks.
2991994689c1Smrg	  func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
2992994689c1Smrg	      'exit $?'
2993994689c1Smrg	  tstripme="$stripme"
2994994689c1Smrg	  case $host_os in
2995994689c1Smrg	  cygwin* | mingw* | pw32* | cegcc*)
2996994689c1Smrg	    case $realname in
2997994689c1Smrg	    *.dll.a)
2998994689c1Smrg	      tstripme=""
2999994689c1Smrg	      ;;
3000994689c1Smrg	    esac
3001775e7de9Smrg	    ;;
3002775e7de9Smrg	  esac
3003994689c1Smrg	  if test -n "$tstripme" && test -n "$striplib"; then
3004994689c1Smrg	    func_show_eval "$striplib $destdir/$realname" 'exit $?'
3005994689c1Smrg	  fi
3006994689c1Smrg
3007994689c1Smrg	  if test "$#" -gt 0; then
3008994689c1Smrg	    # Delete the old symlinks, and create new ones.
3009994689c1Smrg	    # Try `ln -sf' first, because the `ln' binary might depend on
3010994689c1Smrg	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
3011994689c1Smrg	    # so we also need to try rm && ln -s.
3012994689c1Smrg	    for linkname
3013994689c1Smrg	    do
3014994689c1Smrg	      test "$linkname" != "$realname" \
3015994689c1Smrg		&& func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
3016994689c1Smrg	    done
3017994689c1Smrg	  fi
3018994689c1Smrg
3019994689c1Smrg	  # Do each command in the postinstall commands.
3020994689c1Smrg	  lib="$destdir/$realname"
3021994689c1Smrg	  func_execute_cmds "$postinstall_cmds" 'exit $?'
3022994689c1Smrg	fi
3023994689c1Smrg
3024994689c1Smrg	# Install the pseudo-library for information purposes.
3025994689c1Smrg	func_basename "$file"
3026994689c1Smrg	name="$func_basename_result"
3027994689c1Smrg	instname="$dir/$name"i
3028994689c1Smrg	func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
3029994689c1Smrg
3030994689c1Smrg	# Maybe install the static library, too.
3031f353fbadSmrg	test -n "$old_library" && func_append staticlibs " $dir/$old_library"
3032775e7de9Smrg	;;
3033994689c1Smrg
3034994689c1Smrg      *.lo)
3035994689c1Smrg	# Install (i.e. copy) a libtool object.
3036994689c1Smrg
3037994689c1Smrg	# Figure out destination file name, if it wasn't already specified.
3038994689c1Smrg	if test -n "$destname"; then
3039994689c1Smrg	  destfile="$destdir/$destname"
3040994689c1Smrg	else
3041994689c1Smrg	  func_basename "$file"
3042994689c1Smrg	  destfile="$func_basename_result"
3043994689c1Smrg	  destfile="$destdir/$destfile"
3044994689c1Smrg	fi
3045994689c1Smrg
3046994689c1Smrg	# Deduce the name of the destination old-style object file.
3047994689c1Smrg	case $destfile in
3048994689c1Smrg	*.lo)
3049994689c1Smrg	  func_lo2o "$destfile"
3050994689c1Smrg	  staticdest=$func_lo2o_result
3051e1e1713cSmrg	  ;;
3052994689c1Smrg	*.$objext)
3053994689c1Smrg	  staticdest="$destfile"
3054994689c1Smrg	  destfile=
3055e1e1713cSmrg	  ;;
3056994689c1Smrg	*)
3057994689c1Smrg	  func_fatal_help "cannot copy a libtool object to \`$destfile'"
3058e1e1713cSmrg	  ;;
3059994689c1Smrg	esac
3060994689c1Smrg
3061994689c1Smrg	# Install the libtool object if requested.
3062994689c1Smrg	test -n "$destfile" && \
3063994689c1Smrg	  func_show_eval "$install_prog $file $destfile" 'exit $?'
3064994689c1Smrg
3065994689c1Smrg	# Install the old object if enabled.
3066994689c1Smrg	if test "$build_old_libs" = yes; then
3067994689c1Smrg	  # Deduce the name of the old-style object file.
3068994689c1Smrg	  func_lo2o "$file"
3069994689c1Smrg	  staticobj=$func_lo2o_result
3070994689c1Smrg	  func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
3071e1e1713cSmrg	fi
3072994689c1Smrg	exit $EXIT_SUCCESS
3073994689c1Smrg	;;
30747a84e134Smrg
3075994689c1Smrg      *)
3076994689c1Smrg	# Figure out destination file name, if it wasn't already specified.
3077994689c1Smrg	if test -n "$destname"; then
3078994689c1Smrg	  destfile="$destdir/$destname"
3079e1e1713cSmrg	else
3080994689c1Smrg	  func_basename "$file"
3081994689c1Smrg	  destfile="$func_basename_result"
3082994689c1Smrg	  destfile="$destdir/$destfile"
3083e1e1713cSmrg	fi
30847a84e134Smrg
3085994689c1Smrg	# If the file is missing, and there is a .exe on the end, strip it
3086994689c1Smrg	# because it is most likely a libtool script we actually want to
3087994689c1Smrg	# install
3088994689c1Smrg	stripped_ext=""
3089994689c1Smrg	case $file in
3090994689c1Smrg	  *.exe)
3091994689c1Smrg	    if test ! -f "$file"; then
3092994689c1Smrg	      func_stripname '' '.exe' "$file"
3093994689c1Smrg	      file=$func_stripname_result
3094994689c1Smrg	      stripped_ext=".exe"
3095994689c1Smrg	    fi
3096994689c1Smrg	    ;;
3097994689c1Smrg	esac
30987a84e134Smrg
3099994689c1Smrg	# Do a test to see if this is really a libtool program.
3100994689c1Smrg	case $host in
3101994689c1Smrg	*cygwin* | *mingw*)
3102994689c1Smrg	    if func_ltwrapper_executable_p "$file"; then
3103994689c1Smrg	      func_ltwrapper_scriptname "$file"
3104994689c1Smrg	      wrapper=$func_ltwrapper_scriptname_result
3105994689c1Smrg	    else
3106994689c1Smrg	      func_stripname '' '.exe' "$file"
3107994689c1Smrg	      wrapper=$func_stripname_result
3108994689c1Smrg	    fi
3109994689c1Smrg	    ;;
3110994689c1Smrg	*)
3111994689c1Smrg	    wrapper=$file
3112994689c1Smrg	    ;;
3113994689c1Smrg	esac
3114994689c1Smrg	if func_ltwrapper_script_p "$wrapper"; then
3115994689c1Smrg	  notinst_deplibs=
3116994689c1Smrg	  relink_command=
31177a84e134Smrg
3118994689c1Smrg	  func_source "$wrapper"
31197a84e134Smrg
3120994689c1Smrg	  # Check the variables that should have been set.
3121994689c1Smrg	  test -z "$generated_by_libtool_version" && \
3122994689c1Smrg	    func_fatal_error "invalid libtool wrapper script \`$wrapper'"
31237a84e134Smrg
3124994689c1Smrg	  finalize=yes
3125994689c1Smrg	  for lib in $notinst_deplibs; do
3126994689c1Smrg	    # Check to see that each library is installed.
3127994689c1Smrg	    libdir=
3128994689c1Smrg	    if test -f "$lib"; then
3129994689c1Smrg	      func_source "$lib"
3130e1e1713cSmrg	    fi
3131994689c1Smrg	    libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test
3132994689c1Smrg	    if test -n "$libdir" && test ! -f "$libfile"; then
3133994689c1Smrg	      func_warning "\`$lib' has not been installed in \`$libdir'"
3134994689c1Smrg	      finalize=no
3135994689c1Smrg	    fi
3136994689c1Smrg	  done
31377a84e134Smrg
3138994689c1Smrg	  relink_command=
3139994689c1Smrg	  func_source "$wrapper"
31407a84e134Smrg
3141994689c1Smrg	  outputname=
3142994689c1Smrg	  if test "$fast_install" = no && test -n "$relink_command"; then
3143994689c1Smrg	    $opt_dry_run || {
3144994689c1Smrg	      if test "$finalize" = yes; then
3145994689c1Smrg	        tmpdir=`func_mktempdir`
3146994689c1Smrg		func_basename "$file$stripped_ext"
3147994689c1Smrg		file="$func_basename_result"
3148994689c1Smrg	        outputname="$tmpdir/$file"
3149994689c1Smrg	        # Replace the output file specification.
3150994689c1Smrg	        relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
3151994689c1Smrg
3152994689c1Smrg	        $opt_silent || {
3153994689c1Smrg	          func_quote_for_expand "$relink_command"
3154994689c1Smrg		  eval "func_echo $func_quote_for_expand_result"
3155994689c1Smrg	        }
3156994689c1Smrg	        if eval "$relink_command"; then :
3157994689c1Smrg	          else
3158994689c1Smrg		  func_error "error: relink \`$file' with the above command before installing it"
3159994689c1Smrg		  $opt_dry_run || ${RM}r "$tmpdir"
3160994689c1Smrg		  continue
3161994689c1Smrg	        fi
3162994689c1Smrg	        file="$outputname"
3163994689c1Smrg	      else
3164994689c1Smrg	        func_warning "cannot relink \`$file'"
3165994689c1Smrg	      fi
3166994689c1Smrg	    }
3167e1e1713cSmrg	  else
3168994689c1Smrg	    # Install the binary that we compiled earlier.
3169994689c1Smrg	    file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
3170e1e1713cSmrg	  fi
3171994689c1Smrg	fi
31727a84e134Smrg
3173994689c1Smrg	# remove .exe since cygwin /usr/bin/install will append another
3174994689c1Smrg	# one anyway
3175994689c1Smrg	case $install_prog,$host in
3176994689c1Smrg	*/usr/bin/install*,*cygwin*)
3177994689c1Smrg	  case $file:$destfile in
3178994689c1Smrg	  *.exe:*.exe)
3179994689c1Smrg	    # this is ok
3180994689c1Smrg	    ;;
3181994689c1Smrg	  *.exe:*)
3182994689c1Smrg	    destfile=$destfile.exe
3183994689c1Smrg	    ;;
3184994689c1Smrg	  *:*.exe)
3185994689c1Smrg	    func_stripname '' '.exe' "$destfile"
3186994689c1Smrg	    destfile=$func_stripname_result
3187994689c1Smrg	    ;;
3188994689c1Smrg	  esac
3189e1e1713cSmrg	  ;;
3190e1e1713cSmrg	esac
3191994689c1Smrg	func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
3192994689c1Smrg	$opt_dry_run || if test -n "$outputname"; then
3193994689c1Smrg	  ${RM}r "$tmpdir"
3194994689c1Smrg	fi
3195994689c1Smrg	;;
3196994689c1Smrg      esac
3197994689c1Smrg    done
31987a84e134Smrg
3199994689c1Smrg    for file in $staticlibs; do
3200994689c1Smrg      func_basename "$file"
3201994689c1Smrg      name="$func_basename_result"
3202994689c1Smrg
3203994689c1Smrg      # Set up the ranlib parameters.
3204994689c1Smrg      oldlib="$destdir/$name"
3205421c997bSmrg      func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
3206421c997bSmrg      tool_oldlib=$func_to_tool_file_result
3207994689c1Smrg
3208994689c1Smrg      func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
3209994689c1Smrg
3210994689c1Smrg      if test -n "$stripme" && test -n "$old_striplib"; then
3211421c997bSmrg	func_show_eval "$old_striplib $tool_oldlib" 'exit $?'
3212994689c1Smrg      fi
3213994689c1Smrg
3214994689c1Smrg      # Do each command in the postinstall commands.
3215994689c1Smrg      func_execute_cmds "$old_postinstall_cmds" 'exit $?'
3216994689c1Smrg    done
3217994689c1Smrg
3218994689c1Smrg    test -n "$future_libdirs" && \
3219994689c1Smrg      func_warning "remember to run \`$progname --finish$future_libdirs'"
3220994689c1Smrg
3221994689c1Smrg    if test -n "$current_libdirs"; then
3222994689c1Smrg      # Maybe just do a dry run.
3223994689c1Smrg      $opt_dry_run && current_libdirs=" -n$current_libdirs"
3224994689c1Smrg      exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
3225994689c1Smrg    else
3226994689c1Smrg      exit $EXIT_SUCCESS
3227994689c1Smrg    fi
3228994689c1Smrg}
3229994689c1Smrg
3230f353fbadSmrgtest "$opt_mode" = install && func_mode_install ${1+"$@"}
3231994689c1Smrg
3232994689c1Smrg
3233994689c1Smrg# func_generate_dlsyms outputname originator pic_p
3234994689c1Smrg# Extract symbols from dlprefiles and create ${outputname}S.o with
3235994689c1Smrg# a dlpreopen symbol table.
3236994689c1Smrgfunc_generate_dlsyms ()
3237994689c1Smrg{
3238994689c1Smrg    $opt_debug
3239994689c1Smrg    my_outputname="$1"
3240994689c1Smrg    my_originator="$2"
3241994689c1Smrg    my_pic_p="${3-no}"
3242994689c1Smrg    my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'`
3243994689c1Smrg    my_dlsyms=
3244994689c1Smrg
3245994689c1Smrg    if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
3246994689c1Smrg      if test -n "$NM" && test -n "$global_symbol_pipe"; then
3247994689c1Smrg	my_dlsyms="${my_outputname}S.c"
3248994689c1Smrg      else
3249994689c1Smrg	func_error "not configured to extract global symbols from dlpreopened files"
3250994689c1Smrg      fi
3251994689c1Smrg    fi
3252994689c1Smrg
3253994689c1Smrg    if test -n "$my_dlsyms"; then
3254994689c1Smrg      case $my_dlsyms in
3255994689c1Smrg      "") ;;
3256994689c1Smrg      *.c)
3257994689c1Smrg	# Discover the nlist of each of the dlfiles.
3258994689c1Smrg	nlist="$output_objdir/${my_outputname}.nm"
3259994689c1Smrg
3260994689c1Smrg	func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
3261994689c1Smrg
3262994689c1Smrg	# Parse the name list into a source file.
3263994689c1Smrg	func_verbose "creating $output_objdir/$my_dlsyms"
3264994689c1Smrg
3265994689c1Smrg	$opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
3266994689c1Smrg/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */
3267994689c1Smrg/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */
3268994689c1Smrg
3269994689c1Smrg#ifdef __cplusplus
3270994689c1Smrgextern \"C\" {
3271994689c1Smrg#endif
3272994689c1Smrg
3273994689c1Smrg#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
3274994689c1Smrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
3275994689c1Smrg#endif
3276994689c1Smrg
3277f353fbadSmrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
3278f353fbadSmrg#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
3279f353fbadSmrg/* DATA imports from DLLs on WIN32 con't be const, because runtime
3280f353fbadSmrg   relocations are performed -- see ld's documentation on pseudo-relocs.  */
3281f353fbadSmrg# define LT_DLSYM_CONST
3282f353fbadSmrg#elif defined(__osf__)
3283f353fbadSmrg/* This system does not cope well with relocations in const data.  */
3284f353fbadSmrg# define LT_DLSYM_CONST
3285f353fbadSmrg#else
3286f353fbadSmrg# define LT_DLSYM_CONST const
3287f353fbadSmrg#endif
3288f353fbadSmrg
3289994689c1Smrg/* External symbol declarations for the compiler. */\
3290994689c1Smrg"
3291994689c1Smrg
3292994689c1Smrg	if test "$dlself" = yes; then
3293994689c1Smrg	  func_verbose "generating symbol list for \`$output'"
3294994689c1Smrg
3295994689c1Smrg	  $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
3296994689c1Smrg
3297994689c1Smrg	  # Add our own program objects to the symbol list.
3298994689c1Smrg	  progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
3299994689c1Smrg	  for progfile in $progfiles; do
3300f353fbadSmrg	    func_to_tool_file "$progfile" func_convert_file_msys_to_w32
3301f353fbadSmrg	    func_verbose "extracting global C symbols from \`$func_to_tool_file_result'"
3302f353fbadSmrg	    $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
3303994689c1Smrg	  done
3304994689c1Smrg
3305994689c1Smrg	  if test -n "$exclude_expsyms"; then
3306994689c1Smrg	    $opt_dry_run || {
3307994689c1Smrg	      eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
3308994689c1Smrg	      eval '$MV "$nlist"T "$nlist"'
3309994689c1Smrg	    }
3310e1e1713cSmrg	  fi
3311994689c1Smrg
3312994689c1Smrg	  if test -n "$export_symbols_regex"; then
3313994689c1Smrg	    $opt_dry_run || {
3314994689c1Smrg	      eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
3315994689c1Smrg	      eval '$MV "$nlist"T "$nlist"'
3316994689c1Smrg	    }
3317994689c1Smrg	  fi
3318994689c1Smrg
3319994689c1Smrg	  # Prepare the list of exported symbols
3320994689c1Smrg	  if test -z "$export_symbols"; then
3321994689c1Smrg	    export_symbols="$output_objdir/$outputname.exp"
3322994689c1Smrg	    $opt_dry_run || {
3323994689c1Smrg	      $RM $export_symbols
3324994689c1Smrg	      eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
3325994689c1Smrg	      case $host in
3326994689c1Smrg	      *cygwin* | *mingw* | *cegcc* )
3327994689c1Smrg                eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
3328994689c1Smrg                eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
3329994689c1Smrg	        ;;
3330994689c1Smrg	      esac
3331994689c1Smrg	    }
3332e1e1713cSmrg	  else
3333994689c1Smrg	    $opt_dry_run || {
3334994689c1Smrg	      eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
3335994689c1Smrg	      eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
3336994689c1Smrg	      eval '$MV "$nlist"T "$nlist"'
3337994689c1Smrg	      case $host in
3338994689c1Smrg	        *cygwin* | *mingw* | *cegcc* )
3339994689c1Smrg	          eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
3340994689c1Smrg	          eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
3341994689c1Smrg	          ;;
3342994689c1Smrg	      esac
3343994689c1Smrg	    }
3344e1e1713cSmrg	  fi
3345994689c1Smrg	fi
33467a84e134Smrg
3347994689c1Smrg	for dlprefile in $dlprefiles; do
3348994689c1Smrg	  func_verbose "extracting global C symbols from \`$dlprefile'"
3349994689c1Smrg	  func_basename "$dlprefile"
3350994689c1Smrg	  name="$func_basename_result"
3351f353fbadSmrg          case $host in
3352f353fbadSmrg	    *cygwin* | *mingw* | *cegcc* )
3353f353fbadSmrg	      # if an import library, we need to obtain dlname
3354f353fbadSmrg	      if func_win32_import_lib_p "$dlprefile"; then
3355f353fbadSmrg	        func_tr_sh "$dlprefile"
3356f353fbadSmrg	        eval "curr_lafile=\$libfile_$func_tr_sh_result"
3357f353fbadSmrg	        dlprefile_dlbasename=""
3358f353fbadSmrg	        if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
3359f353fbadSmrg	          # Use subshell, to avoid clobbering current variable values
3360f353fbadSmrg	          dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
3361f353fbadSmrg	          if test -n "$dlprefile_dlname" ; then
3362f353fbadSmrg	            func_basename "$dlprefile_dlname"
3363f353fbadSmrg	            dlprefile_dlbasename="$func_basename_result"
3364f353fbadSmrg	          else
3365f353fbadSmrg	            # no lafile. user explicitly requested -dlpreopen <import library>.
3366f353fbadSmrg	            $sharedlib_from_linklib_cmd "$dlprefile"
3367f353fbadSmrg	            dlprefile_dlbasename=$sharedlib_from_linklib_result
3368f353fbadSmrg	          fi
3369f353fbadSmrg	        fi
3370f353fbadSmrg	        $opt_dry_run || {
3371f353fbadSmrg	          if test -n "$dlprefile_dlbasename" ; then
3372f353fbadSmrg	            eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
3373f353fbadSmrg	          else
3374f353fbadSmrg	            func_warning "Could not compute DLL name from $name"
3375f353fbadSmrg	            eval '$ECHO ": $name " >> "$nlist"'
3376f353fbadSmrg	          fi
3377f353fbadSmrg	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
3378f353fbadSmrg	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe |
3379f353fbadSmrg	            $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'"
3380f353fbadSmrg	        }
3381f353fbadSmrg	      else # not an import lib
3382f353fbadSmrg	        $opt_dry_run || {
3383f353fbadSmrg	          eval '$ECHO ": $name " >> "$nlist"'
3384f353fbadSmrg	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
3385f353fbadSmrg	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
3386f353fbadSmrg	        }
3387f353fbadSmrg	      fi
3388f353fbadSmrg	    ;;
3389f353fbadSmrg	    *)
3390f353fbadSmrg	      $opt_dry_run || {
3391f353fbadSmrg	        eval '$ECHO ": $name " >> "$nlist"'
3392f353fbadSmrg	        func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
3393f353fbadSmrg	        eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
3394f353fbadSmrg	      }
3395f353fbadSmrg	    ;;
3396f353fbadSmrg          esac
3397994689c1Smrg	done
3398994689c1Smrg
3399994689c1Smrg	$opt_dry_run || {
3400994689c1Smrg	  # Make sure we have at least an empty file.
3401994689c1Smrg	  test -f "$nlist" || : > "$nlist"
3402994689c1Smrg
3403994689c1Smrg	  if test -n "$exclude_expsyms"; then
3404994689c1Smrg	    $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
3405994689c1Smrg	    $MV "$nlist"T "$nlist"
3406e1e1713cSmrg	  fi
3407994689c1Smrg
3408994689c1Smrg	  # Try sorting and uniquifying the output.
3409994689c1Smrg	  if $GREP -v "^: " < "$nlist" |
3410994689c1Smrg	      if sort -k 3 </dev/null >/dev/null 2>&1; then
3411994689c1Smrg		sort -k 3
3412994689c1Smrg	      else
3413994689c1Smrg		sort +2
3414994689c1Smrg	      fi |
3415994689c1Smrg	      uniq > "$nlist"S; then
3416994689c1Smrg	    :
3417e1e1713cSmrg	  else
3418994689c1Smrg	    $GREP -v "^: " < "$nlist" > "$nlist"S
3419e1e1713cSmrg	  fi
34207a84e134Smrg
3421994689c1Smrg	  if test -f "$nlist"S; then
3422994689c1Smrg	    eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
3423e1e1713cSmrg	  else
3424994689c1Smrg	    echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
3425e1e1713cSmrg	  fi
34267a84e134Smrg
3427994689c1Smrg	  echo >> "$output_objdir/$my_dlsyms" "\
34287a84e134Smrg
3429994689c1Smrg/* The mapping between symbol names and symbols.  */
3430994689c1Smrgtypedef struct {
3431994689c1Smrg  const char *name;
3432994689c1Smrg  void *address;
3433994689c1Smrg} lt_dlsymlist;
3434f353fbadSmrgextern LT_DLSYM_CONST lt_dlsymlist
3435994689c1Smrglt_${my_prefix}_LTX_preloaded_symbols[];
3436f353fbadSmrgLT_DLSYM_CONST lt_dlsymlist
3437994689c1Smrglt_${my_prefix}_LTX_preloaded_symbols[] =
3438994689c1Smrg{\
3439994689c1Smrg  { \"$my_originator\", (void *) 0 },"
34407a84e134Smrg
3441994689c1Smrg	  case $need_lib_prefix in
3442994689c1Smrg	  no)
3443994689c1Smrg	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
3444994689c1Smrg	    ;;
3445994689c1Smrg	  *)
3446994689c1Smrg	    eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
3447994689c1Smrg	    ;;
3448994689c1Smrg	  esac
3449994689c1Smrg	  echo >> "$output_objdir/$my_dlsyms" "\
3450994689c1Smrg  {0, (void *) 0}
3451994689c1Smrg};
34527a84e134Smrg
3453994689c1Smrg/* This works around a problem in FreeBSD linker */
3454994689c1Smrg#ifdef FREEBSD_WORKAROUND
3455994689c1Smrgstatic const void *lt_preloaded_setup() {
3456994689c1Smrg  return lt_${my_prefix}_LTX_preloaded_symbols;
3457994689c1Smrg}
3458994689c1Smrg#endif
34597a84e134Smrg
3460994689c1Smrg#ifdef __cplusplus
3461994689c1Smrg}
3462994689c1Smrg#endif\
3463994689c1Smrg"
3464994689c1Smrg	} # !$opt_dry_run
3465775e7de9Smrg
3466994689c1Smrg	pic_flag_for_symtable=
3467994689c1Smrg	case "$compile_command " in
3468994689c1Smrg	*" -static "*) ;;
3469994689c1Smrg	*)
3470994689c1Smrg	  case $host in
3471994689c1Smrg	  # compiling the symbol table file with pic_flag works around
3472994689c1Smrg	  # a FreeBSD bug that causes programs to crash when -lm is
3473994689c1Smrg	  # linked before any other PIC object.  But we must not use
3474994689c1Smrg	  # pic_flag when linking with -static.  The problem exists in
3475994689c1Smrg	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
3476421c997bSmrg	  *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
3477994689c1Smrg	    pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
3478994689c1Smrg	  *-*-hpux*)
3479994689c1Smrg	    pic_flag_for_symtable=" $pic_flag"  ;;
3480994689c1Smrg	  *)
3481994689c1Smrg	    if test "X$my_pic_p" != Xno; then
3482994689c1Smrg	      pic_flag_for_symtable=" $pic_flag"
3483994689c1Smrg	    fi
3484994689c1Smrg	    ;;
3485994689c1Smrg	  esac
3486994689c1Smrg	  ;;
3487994689c1Smrg	esac
3488994689c1Smrg	symtab_cflags=
3489994689c1Smrg	for arg in $LTCFLAGS; do
3490994689c1Smrg	  case $arg in
3491994689c1Smrg	  -pie | -fpie | -fPIE) ;;
3492f353fbadSmrg	  *) func_append symtab_cflags " $arg" ;;
3493994689c1Smrg	  esac
3494994689c1Smrg	done
34957a84e134Smrg
3496994689c1Smrg	# Now compile the dynamic symbol file.
3497994689c1Smrg	func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
34987a84e134Smrg
3499994689c1Smrg	# Clean up the generated files.
3500994689c1Smrg	func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"'
3501775e7de9Smrg
3502994689c1Smrg	# Transform the symbol file into the correct name.
3503994689c1Smrg	symfileobj="$output_objdir/${my_outputname}S.$objext"
3504994689c1Smrg	case $host in
3505994689c1Smrg	*cygwin* | *mingw* | *cegcc* )
3506994689c1Smrg	  if test -f "$output_objdir/$my_outputname.def"; then
3507994689c1Smrg	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
3508994689c1Smrg	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
3509994689c1Smrg	  else
3510994689c1Smrg	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3511994689c1Smrg	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3512994689c1Smrg	  fi
3513994689c1Smrg	  ;;
3514994689c1Smrg	*)
3515994689c1Smrg	  compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3516994689c1Smrg	  finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3517994689c1Smrg	  ;;
3518994689c1Smrg	esac
3519994689c1Smrg	;;
3520994689c1Smrg      *)
3521994689c1Smrg	func_fatal_error "unknown suffix for \`$my_dlsyms'"
3522994689c1Smrg	;;
3523994689c1Smrg      esac
3524994689c1Smrg    else
3525994689c1Smrg      # We keep going just in case the user didn't refer to
3526994689c1Smrg      # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
3527994689c1Smrg      # really was required.
3528775e7de9Smrg
3529994689c1Smrg      # Nullify the symbol file.
3530994689c1Smrg      compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
3531994689c1Smrg      finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
3532994689c1Smrg    fi
3533994689c1Smrg}
3534775e7de9Smrg
3535994689c1Smrg# func_win32_libid arg
3536994689c1Smrg# return the library type of file 'arg'
3537994689c1Smrg#
3538994689c1Smrg# Need a lot of goo to handle *both* DLLs and import libs
3539994689c1Smrg# Has to be a shell function in order to 'eat' the argument
3540994689c1Smrg# that is supplied when $file_magic_command is called.
3541994689c1Smrg# Despite the name, also deal with 64 bit binaries.
3542994689c1Smrgfunc_win32_libid ()
3543994689c1Smrg{
3544994689c1Smrg  $opt_debug
3545994689c1Smrg  win32_libid_type="unknown"
3546994689c1Smrg  win32_fileres=`file -L $1 2>/dev/null`
3547994689c1Smrg  case $win32_fileres in
3548994689c1Smrg  *ar\ archive\ import\ library*) # definitely import
3549994689c1Smrg    win32_libid_type="x86 archive import"
3550994689c1Smrg    ;;
3551994689c1Smrg  *ar\ archive*) # could be an import, or static
3552994689c1Smrg    # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
3553994689c1Smrg    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
3554994689c1Smrg       $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
3555f353fbadSmrg      func_to_tool_file "$1" func_convert_file_msys_to_w32
3556f353fbadSmrg      win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
3557994689c1Smrg	$SED -n -e '
3558994689c1Smrg	    1,100{
3559994689c1Smrg		/ I /{
3560994689c1Smrg		    s,.*,import,
3561994689c1Smrg		    p
3562994689c1Smrg		    q
3563994689c1Smrg		}
3564994689c1Smrg	    }'`
3565994689c1Smrg      case $win32_nmres in
3566994689c1Smrg      import*)  win32_libid_type="x86 archive import";;
3567994689c1Smrg      *)        win32_libid_type="x86 archive static";;
3568994689c1Smrg      esac
3569994689c1Smrg    fi
3570994689c1Smrg    ;;
3571994689c1Smrg  *DLL*)
3572994689c1Smrg    win32_libid_type="x86 DLL"
3573994689c1Smrg    ;;
3574994689c1Smrg  *executable*) # but shell scripts are "executable" too...
3575994689c1Smrg    case $win32_fileres in
3576994689c1Smrg    *MS\ Windows\ PE\ Intel*)
3577994689c1Smrg      win32_libid_type="x86 DLL"
3578994689c1Smrg      ;;
3579994689c1Smrg    esac
3580994689c1Smrg    ;;
3581994689c1Smrg  esac
3582994689c1Smrg  $ECHO "$win32_libid_type"
3583994689c1Smrg}
3584775e7de9Smrg
3585f353fbadSmrg# func_cygming_dll_for_implib ARG
3586f353fbadSmrg#
3587f353fbadSmrg# Platform-specific function to extract the
3588f353fbadSmrg# name of the DLL associated with the specified
3589f353fbadSmrg# import library ARG.
3590f353fbadSmrg# Invoked by eval'ing the libtool variable
3591f353fbadSmrg#    $sharedlib_from_linklib_cmd
3592f353fbadSmrg# Result is available in the variable
3593f353fbadSmrg#    $sharedlib_from_linklib_result
3594f353fbadSmrgfunc_cygming_dll_for_implib ()
3595f353fbadSmrg{
3596f353fbadSmrg  $opt_debug
3597f353fbadSmrg  sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
3598f353fbadSmrg}
3599f353fbadSmrg
3600f353fbadSmrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs
3601f353fbadSmrg#
3602f353fbadSmrg# The is the core of a fallback implementation of a
3603f353fbadSmrg# platform-specific function to extract the name of the
3604f353fbadSmrg# DLL associated with the specified import library LIBNAME.
3605f353fbadSmrg#
3606f353fbadSmrg# SECTION_NAME is either .idata$6 or .idata$7, depending
3607f353fbadSmrg# on the platform and compiler that created the implib.
3608f353fbadSmrg#
3609f353fbadSmrg# Echos the name of the DLL associated with the
3610f353fbadSmrg# specified import library.
3611f353fbadSmrgfunc_cygming_dll_for_implib_fallback_core ()
3612f353fbadSmrg{
3613f353fbadSmrg  $opt_debug
3614f353fbadSmrg  match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
3615f353fbadSmrg  $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
3616f353fbadSmrg    $SED '/^Contents of section '"$match_literal"':/{
3617f353fbadSmrg      # Place marker at beginning of archive member dllname section
3618f353fbadSmrg      s/.*/====MARK====/
3619f353fbadSmrg      p
3620f353fbadSmrg      d
3621f353fbadSmrg    }
3622f353fbadSmrg    # These lines can sometimes be longer than 43 characters, but
3623f353fbadSmrg    # are always uninteresting
3624f353fbadSmrg    /:[	 ]*file format pe[i]\{,1\}-/d
3625f353fbadSmrg    /^In archive [^:]*:/d
3626f353fbadSmrg    # Ensure marker is printed
3627f353fbadSmrg    /^====MARK====/p
3628f353fbadSmrg    # Remove all lines with less than 43 characters
3629f353fbadSmrg    /^.\{43\}/!d
3630f353fbadSmrg    # From remaining lines, remove first 43 characters
3631f353fbadSmrg    s/^.\{43\}//' |
3632f353fbadSmrg    $SED -n '
3633f353fbadSmrg      # Join marker and all lines until next marker into a single line
3634f353fbadSmrg      /^====MARK====/ b para
3635f353fbadSmrg      H
3636f353fbadSmrg      $ b para
3637f353fbadSmrg      b
3638f353fbadSmrg      :para
3639f353fbadSmrg      x
3640f353fbadSmrg      s/\n//g
3641f353fbadSmrg      # Remove the marker
3642f353fbadSmrg      s/^====MARK====//
3643f353fbadSmrg      # Remove trailing dots and whitespace
3644f353fbadSmrg      s/[\. \t]*$//
3645f353fbadSmrg      # Print
3646f353fbadSmrg      /./p' |
3647f353fbadSmrg    # we now have a list, one entry per line, of the stringified
3648f353fbadSmrg    # contents of the appropriate section of all members of the
3649f353fbadSmrg    # archive which possess that section. Heuristic: eliminate
3650f353fbadSmrg    # all those which have a first or second character that is
3651f353fbadSmrg    # a '.' (that is, objdump's representation of an unprintable
3652f353fbadSmrg    # character.) This should work for all archives with less than
3653f353fbadSmrg    # 0x302f exports -- but will fail for DLLs whose name actually
3654f353fbadSmrg    # begins with a literal '.' or a single character followed by
3655f353fbadSmrg    # a '.'.
3656f353fbadSmrg    #
3657f353fbadSmrg    # Of those that remain, print the first one.
3658f353fbadSmrg    $SED -e '/^\./d;/^.\./d;q'
3659f353fbadSmrg}
3660f353fbadSmrg
3661f353fbadSmrg# func_cygming_gnu_implib_p ARG
3662f353fbadSmrg# This predicate returns with zero status (TRUE) if
3663f353fbadSmrg# ARG is a GNU/binutils-style import library. Returns
3664f353fbadSmrg# with nonzero status (FALSE) otherwise.
3665f353fbadSmrgfunc_cygming_gnu_implib_p ()
3666f353fbadSmrg{
3667f353fbadSmrg  $opt_debug
3668f353fbadSmrg  func_to_tool_file "$1" func_convert_file_msys_to_w32
3669f353fbadSmrg  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)$'`
3670f353fbadSmrg  test -n "$func_cygming_gnu_implib_tmp"
3671f353fbadSmrg}
3672f353fbadSmrg
3673f353fbadSmrg# func_cygming_ms_implib_p ARG
3674f353fbadSmrg# This predicate returns with zero status (TRUE) if
3675f353fbadSmrg# ARG is an MS-style import library. Returns
3676f353fbadSmrg# with nonzero status (FALSE) otherwise.
3677f353fbadSmrgfunc_cygming_ms_implib_p ()
3678f353fbadSmrg{
3679f353fbadSmrg  $opt_debug
3680f353fbadSmrg  func_to_tool_file "$1" func_convert_file_msys_to_w32
3681f353fbadSmrg  func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
3682f353fbadSmrg  test -n "$func_cygming_ms_implib_tmp"
3683f353fbadSmrg}
3684f353fbadSmrg
3685f353fbadSmrg# func_cygming_dll_for_implib_fallback ARG
3686f353fbadSmrg# Platform-specific function to extract the
3687f353fbadSmrg# name of the DLL associated with the specified
3688f353fbadSmrg# import library ARG.
3689f353fbadSmrg#
3690f353fbadSmrg# This fallback implementation is for use when $DLLTOOL
3691f353fbadSmrg# does not support the --identify-strict option.
3692f353fbadSmrg# Invoked by eval'ing the libtool variable
3693f353fbadSmrg#    $sharedlib_from_linklib_cmd
3694f353fbadSmrg# Result is available in the variable
3695f353fbadSmrg#    $sharedlib_from_linklib_result
3696f353fbadSmrgfunc_cygming_dll_for_implib_fallback ()
3697f353fbadSmrg{
3698f353fbadSmrg  $opt_debug
3699f353fbadSmrg  if func_cygming_gnu_implib_p "$1" ; then
3700f353fbadSmrg    # binutils import library
3701f353fbadSmrg    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
3702f353fbadSmrg  elif func_cygming_ms_implib_p "$1" ; then
3703f353fbadSmrg    # ms-generated import library
3704f353fbadSmrg    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
3705f353fbadSmrg  else
3706f353fbadSmrg    # unknown
3707f353fbadSmrg    sharedlib_from_linklib_result=""
3708f353fbadSmrg  fi
3709f353fbadSmrg}
37107a84e134Smrg
37117a84e134Smrg
3712994689c1Smrg# func_extract_an_archive dir oldlib
3713994689c1Smrgfunc_extract_an_archive ()
3714994689c1Smrg{
3715994689c1Smrg    $opt_debug
3716994689c1Smrg    f_ex_an_ar_dir="$1"; shift
3717994689c1Smrg    f_ex_an_ar_oldlib="$1"
3718994689c1Smrg    if test "$lock_old_archive_extraction" = yes; then
3719994689c1Smrg      lockfile=$f_ex_an_ar_oldlib.lock
3720994689c1Smrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
3721994689c1Smrg	func_echo "Waiting for $lockfile to be removed"
3722994689c1Smrg	sleep 2
3723994689c1Smrg      done
3724994689c1Smrg    fi
3725994689c1Smrg    func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
3726994689c1Smrg		   'stat=$?; rm -f "$lockfile"; exit $stat'
3727994689c1Smrg    if test "$lock_old_archive_extraction" = yes; then
3728994689c1Smrg      $opt_dry_run || rm -f "$lockfile"
3729994689c1Smrg    fi
3730994689c1Smrg    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
3731994689c1Smrg     :
3732994689c1Smrg    else
3733994689c1Smrg      func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
3734994689c1Smrg    fi
3735994689c1Smrg}
37367a84e134Smrg
37377a84e134Smrg
3738994689c1Smrg# func_extract_archives gentop oldlib ...
3739994689c1Smrgfunc_extract_archives ()
3740994689c1Smrg{
3741994689c1Smrg    $opt_debug
3742994689c1Smrg    my_gentop="$1"; shift
3743994689c1Smrg    my_oldlibs=${1+"$@"}
3744994689c1Smrg    my_oldobjs=""
3745994689c1Smrg    my_xlib=""
3746994689c1Smrg    my_xabs=""
3747994689c1Smrg    my_xdir=""
37487a84e134Smrg
3749994689c1Smrg    for my_xlib in $my_oldlibs; do
3750994689c1Smrg      # Extract the objects.
3751994689c1Smrg      case $my_xlib in
3752994689c1Smrg	[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
3753994689c1Smrg	*) my_xabs=`pwd`"/$my_xlib" ;;
3754994689c1Smrg      esac
3755994689c1Smrg      func_basename "$my_xlib"
3756994689c1Smrg      my_xlib="$func_basename_result"
3757994689c1Smrg      my_xlib_u=$my_xlib
3758994689c1Smrg      while :; do
3759994689c1Smrg        case " $extracted_archives " in
3760994689c1Smrg	*" $my_xlib_u "*)
3761994689c1Smrg	  func_arith $extracted_serial + 1
3762994689c1Smrg	  extracted_serial=$func_arith_result
3763994689c1Smrg	  my_xlib_u=lt$extracted_serial-$my_xlib ;;
3764994689c1Smrg	*) break ;;
3765994689c1Smrg	esac
3766994689c1Smrg      done
3767994689c1Smrg      extracted_archives="$extracted_archives $my_xlib_u"
3768994689c1Smrg      my_xdir="$my_gentop/$my_xlib_u"
3769775e7de9Smrg
3770994689c1Smrg      func_mkdir_p "$my_xdir"
3771994689c1Smrg
3772994689c1Smrg      case $host in
3773994689c1Smrg      *-darwin*)
3774994689c1Smrg	func_verbose "Extracting $my_xabs"
3775994689c1Smrg	# Do not bother doing anything if just a dry run
3776994689c1Smrg	$opt_dry_run || {
3777994689c1Smrg	  darwin_orig_dir=`pwd`
3778994689c1Smrg	  cd $my_xdir || exit $?
3779994689c1Smrg	  darwin_archive=$my_xabs
3780994689c1Smrg	  darwin_curdir=`pwd`
3781994689c1Smrg	  darwin_base_archive=`basename "$darwin_archive"`
3782994689c1Smrg	  darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
3783994689c1Smrg	  if test -n "$darwin_arches"; then
3784994689c1Smrg	    darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
3785994689c1Smrg	    darwin_arch=
3786994689c1Smrg	    func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
3787994689c1Smrg	    for darwin_arch in  $darwin_arches ; do
3788994689c1Smrg	      func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
3789994689c1Smrg	      $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
3790994689c1Smrg	      cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
3791994689c1Smrg	      func_extract_an_archive "`pwd`" "${darwin_base_archive}"
3792994689c1Smrg	      cd "$darwin_curdir"
3793994689c1Smrg	      $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
3794994689c1Smrg	    done # $darwin_arches
3795994689c1Smrg            ## Okay now we've a bunch of thin objects, gotta fatten them up :)
3796994689c1Smrg	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u`
3797994689c1Smrg	    darwin_file=
3798994689c1Smrg	    darwin_files=
3799994689c1Smrg	    for darwin_file in $darwin_filelist; do
3800994689c1Smrg	      darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`
3801994689c1Smrg	      $LIPO -create -output "$darwin_file" $darwin_files
3802994689c1Smrg	    done # $darwin_filelist
3803994689c1Smrg	    $RM -rf unfat-$$
3804994689c1Smrg	    cd "$darwin_orig_dir"
3805e1e1713cSmrg	  else
3806994689c1Smrg	    cd $darwin_orig_dir
3807994689c1Smrg	    func_extract_an_archive "$my_xdir" "$my_xabs"
3808994689c1Smrg	  fi # $darwin_arches
3809994689c1Smrg	} # !$opt_dry_run
3810994689c1Smrg	;;
3811994689c1Smrg      *)
3812994689c1Smrg        func_extract_an_archive "$my_xdir" "$my_xabs"
3813994689c1Smrg	;;
3814994689c1Smrg      esac
3815994689c1Smrg      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
3816994689c1Smrg    done
38177a84e134Smrg
3818994689c1Smrg    func_extract_archives_result="$my_oldobjs"
3819994689c1Smrg}
38207a84e134Smrg
38217a84e134Smrg
3822994689c1Smrg# func_emit_wrapper [arg=no]
3823994689c1Smrg#
3824994689c1Smrg# Emit a libtool wrapper script on stdout.
3825994689c1Smrg# Don't directly open a file because we may want to
3826994689c1Smrg# incorporate the script contents within a cygwin/mingw
3827994689c1Smrg# wrapper executable.  Must ONLY be called from within
3828994689c1Smrg# func_mode_link because it depends on a number of variables
3829994689c1Smrg# set therein.
3830994689c1Smrg#
3831994689c1Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
3832994689c1Smrg# variable will take.  If 'yes', then the emitted script
3833994689c1Smrg# will assume that the directory in which it is stored is
3834994689c1Smrg# the $objdir directory.  This is a cygwin/mingw-specific
3835994689c1Smrg# behavior.
3836994689c1Smrgfunc_emit_wrapper ()
3837994689c1Smrg{
3838994689c1Smrg	func_emit_wrapper_arg1=${1-no}
3839e1e1713cSmrg
3840994689c1Smrg	$ECHO "\
3841994689c1Smrg#! $SHELL
38427a84e134Smrg
3843994689c1Smrg# $output - temporary wrapper script for $objdir/$outputname
3844994689c1Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
3845994689c1Smrg#
3846994689c1Smrg# The $output program cannot be directly executed until all the libtool
3847994689c1Smrg# libraries that it depends on are installed.
3848994689c1Smrg#
3849994689c1Smrg# This wrapper script should never be moved out of the build directory.
3850994689c1Smrg# If it is, it will not operate correctly.
38517a84e134Smrg
3852994689c1Smrg# Sed substitution that helps us do robust quoting.  It backslashifies
3853994689c1Smrg# metacharacters that are still active within double-quoted strings.
3854994689c1Smrgsed_quote_subst='$sed_quote_subst'
38557a84e134Smrg
3856994689c1Smrg# Be Bourne compatible
3857994689c1Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
3858994689c1Smrg  emulate sh
3859994689c1Smrg  NULLCMD=:
3860994689c1Smrg  # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
3861994689c1Smrg  # is contrary to our usage.  Disable this feature.
3862994689c1Smrg  alias -g '\${1+\"\$@\"}'='\"\$@\"'
3863994689c1Smrg  setopt NO_GLOB_SUBST
3864994689c1Smrgelse
3865994689c1Smrg  case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
3866994689c1Smrgfi
3867994689c1SmrgBIN_SH=xpg4; export BIN_SH # for Tru64
3868994689c1SmrgDUALCASE=1; export DUALCASE # for MKS sh
38697a84e134Smrg
3870994689c1Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout
3871994689c1Smrg# if CDPATH is set.
3872994689c1Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
38737a84e134Smrg
3874994689c1Smrgrelink_command=\"$relink_command\"
38757a84e134Smrg
3876994689c1Smrg# This environment variable determines our operation mode.
3877994689c1Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then
3878994689c1Smrg  # install mode needs the following variables:
3879994689c1Smrg  generated_by_libtool_version='$macro_version'
3880994689c1Smrg  notinst_deplibs='$notinst_deplibs'
3881994689c1Smrgelse
3882994689c1Smrg  # When we are sourced in execute mode, \$file and \$ECHO are already set.
3883994689c1Smrg  if test \"\$libtool_execute_magic\" != \"$magic\"; then
3884994689c1Smrg    file=\"\$0\""
38857a84e134Smrg
3886994689c1Smrg    qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"`
3887994689c1Smrg    $ECHO "\
38887a84e134Smrg
3889994689c1Smrg# A function that is used when there is no print builtin or printf.
3890994689c1Smrgfunc_fallback_echo ()
3891994689c1Smrg{
3892994689c1Smrg  eval 'cat <<_LTECHO_EOF
3893994689c1Smrg\$1
3894994689c1Smrg_LTECHO_EOF'
3895994689c1Smrg}
3896994689c1Smrg    ECHO=\"$qECHO\"
3897994689c1Smrg  fi
3898994689c1Smrg
3899994689c1Smrg# Very basic option parsing. These options are (a) specific to
3900994689c1Smrg# the libtool wrapper, (b) are identical between the wrapper
3901994689c1Smrg# /script/ and the wrapper /executable/ which is used only on
3902994689c1Smrg# windows platforms, and (c) all begin with the string "--lt-"
3903994689c1Smrg# (application programs are unlikely to have options which match
3904994689c1Smrg# this pattern).
3905994689c1Smrg#
3906994689c1Smrg# There are only two supported options: --lt-debug and
3907994689c1Smrg# --lt-dump-script. There is, deliberately, no --lt-help.
3908994689c1Smrg#
3909994689c1Smrg# The first argument to this parsing function should be the
3910994689c1Smrg# script's $0 value, followed by "$@".
3911994689c1Smrglt_option_debug=
3912994689c1Smrgfunc_parse_lt_options ()
3913994689c1Smrg{
3914994689c1Smrg  lt_script_arg0=\$0
3915994689c1Smrg  shift
3916994689c1Smrg  for lt_opt
3917994689c1Smrg  do
3918994689c1Smrg    case \"\$lt_opt\" in
3919994689c1Smrg    --lt-debug) lt_option_debug=1 ;;
3920994689c1Smrg    --lt-dump-script)
3921994689c1Smrg        lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
3922994689c1Smrg        test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
3923994689c1Smrg        lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
3924994689c1Smrg        cat \"\$lt_dump_D/\$lt_dump_F\"
3925994689c1Smrg        exit 0
3926994689c1Smrg      ;;
3927994689c1Smrg    --lt-*)
3928994689c1Smrg        \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
3929994689c1Smrg        exit 1
3930e1e1713cSmrg      ;;
3931994689c1Smrg    esac
3932994689c1Smrg  done
39337a84e134Smrg
3934994689c1Smrg  # Print the debug banner immediately:
3935994689c1Smrg  if test -n \"\$lt_option_debug\"; then
3936994689c1Smrg    echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2
3937994689c1Smrg  fi
3938994689c1Smrg}
39397a84e134Smrg
3940994689c1Smrg# Used when --lt-debug. Prints its arguments to stdout
3941994689c1Smrg# (redirection is the responsibility of the caller)
3942994689c1Smrgfunc_lt_dump_args ()
3943994689c1Smrg{
3944994689c1Smrg  lt_dump_args_N=1;
3945994689c1Smrg  for lt_arg
3946994689c1Smrg  do
3947994689c1Smrg    \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\"
3948994689c1Smrg    lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
3949994689c1Smrg  done
3950994689c1Smrg}
39517a84e134Smrg
3952994689c1Smrg# Core function for launching the target application
3953994689c1Smrgfunc_exec_program_core ()
3954994689c1Smrg{
3955994689c1Smrg"
3956994689c1Smrg  case $host in
3957994689c1Smrg  # Backslashes separate directories on plain windows
3958994689c1Smrg  *-*-mingw | *-*-os2* | *-cegcc*)
3959994689c1Smrg    $ECHO "\
3960994689c1Smrg      if test -n \"\$lt_option_debug\"; then
3961994689c1Smrg        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2
3962994689c1Smrg        func_lt_dump_args \${1+\"\$@\"} 1>&2
3963e1e1713cSmrg      fi
3964994689c1Smrg      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
3965994689c1Smrg"
3966994689c1Smrg    ;;
39677a84e134Smrg
3968994689c1Smrg  *)
3969994689c1Smrg    $ECHO "\
3970994689c1Smrg      if test -n \"\$lt_option_debug\"; then
3971994689c1Smrg        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2
3972994689c1Smrg        func_lt_dump_args \${1+\"\$@\"} 1>&2
3973e1e1713cSmrg      fi
3974994689c1Smrg      exec \"\$progdir/\$program\" \${1+\"\$@\"}
3975994689c1Smrg"
3976994689c1Smrg    ;;
3977994689c1Smrg  esac
3978994689c1Smrg  $ECHO "\
3979994689c1Smrg      \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
3980994689c1Smrg      exit 1
3981994689c1Smrg}
39827a84e134Smrg
3983994689c1Smrg# A function to encapsulate launching the target application
3984994689c1Smrg# Strips options in the --lt-* namespace from \$@ and
3985994689c1Smrg# launches target application with the remaining arguments.
3986994689c1Smrgfunc_exec_program ()
3987994689c1Smrg{
3988421c997bSmrg  case \" \$* \" in
3989421c997bSmrg  *\\ --lt-*)
3990421c997bSmrg    for lt_wr_arg
3991421c997bSmrg    do
3992421c997bSmrg      case \$lt_wr_arg in
3993421c997bSmrg      --lt-*) ;;
3994421c997bSmrg      *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
3995421c997bSmrg      esac
3996421c997bSmrg      shift
3997421c997bSmrg    done ;;
3998421c997bSmrg  esac
3999994689c1Smrg  func_exec_program_core \${1+\"\$@\"}
4000994689c1Smrg}
40017a84e134Smrg
4002994689c1Smrg  # Parse options
4003994689c1Smrg  func_parse_lt_options \"\$0\" \${1+\"\$@\"}
40047a84e134Smrg
4005994689c1Smrg  # Find the directory that this script lives in.
4006994689c1Smrg  thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
4007994689c1Smrg  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
40087a84e134Smrg
4009994689c1Smrg  # Follow symbolic links until we get to the real thisdir.
4010994689c1Smrg  file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
4011994689c1Smrg  while test -n \"\$file\"; do
4012994689c1Smrg    destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
40137a84e134Smrg
4014994689c1Smrg    # If there was a directory component, then change thisdir.
4015994689c1Smrg    if test \"x\$destdir\" != \"x\$file\"; then
4016994689c1Smrg      case \"\$destdir\" in
4017994689c1Smrg      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
4018994689c1Smrg      *) thisdir=\"\$thisdir/\$destdir\" ;;
4019994689c1Smrg      esac
4020994689c1Smrg    fi
40217a84e134Smrg
4022994689c1Smrg    file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
4023994689c1Smrg    file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
4024994689c1Smrg  done
40257a84e134Smrg
4026994689c1Smrg  # Usually 'no', except on cygwin/mingw when embedded into
4027994689c1Smrg  # the cwrapper.
4028994689c1Smrg  WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
4029994689c1Smrg  if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
4030994689c1Smrg    # special case for '.'
4031994689c1Smrg    if test \"\$thisdir\" = \".\"; then
4032994689c1Smrg      thisdir=\`pwd\`
4033994689c1Smrg    fi
4034994689c1Smrg    # remove .libs from thisdir
4035994689c1Smrg    case \"\$thisdir\" in
4036994689c1Smrg    *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
4037994689c1Smrg    $objdir )   thisdir=. ;;
4038994689c1Smrg    esac
4039994689c1Smrg  fi
40407a84e134Smrg
4041994689c1Smrg  # Try to get the absolute directory name.
4042994689c1Smrg  absdir=\`cd \"\$thisdir\" && pwd\`
4043994689c1Smrg  test -n \"\$absdir\" && thisdir=\"\$absdir\"
4044994689c1Smrg"
40457a84e134Smrg
4046994689c1Smrg	if test "$fast_install" = yes; then
4047994689c1Smrg	  $ECHO "\
4048994689c1Smrg  program=lt-'$outputname'$exeext
4049994689c1Smrg  progdir=\"\$thisdir/$objdir\"
40507a84e134Smrg
4051994689c1Smrg  if test ! -f \"\$progdir/\$program\" ||
4052994689c1Smrg     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
4053994689c1Smrg       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
40547a84e134Smrg
4055994689c1Smrg    file=\"\$\$-\$program\"
40567a84e134Smrg
4057994689c1Smrg    if test ! -d \"\$progdir\"; then
4058994689c1Smrg      $MKDIR \"\$progdir\"
4059994689c1Smrg    else
4060994689c1Smrg      $RM \"\$progdir/\$file\"
4061994689c1Smrg    fi"
40627a84e134Smrg
4063994689c1Smrg	  $ECHO "\
40647a84e134Smrg
4065994689c1Smrg    # relink executable if necessary
4066994689c1Smrg    if test -n \"\$relink_command\"; then
4067994689c1Smrg      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
4068994689c1Smrg      else
4069994689c1Smrg	$ECHO \"\$relink_command_output\" >&2
4070994689c1Smrg	$RM \"\$progdir/\$file\"
4071994689c1Smrg	exit 1
4072994689c1Smrg      fi
4073994689c1Smrg    fi
40747a84e134Smrg
4075994689c1Smrg    $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
4076994689c1Smrg    { $RM \"\$progdir/\$program\";
4077994689c1Smrg      $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
4078994689c1Smrg    $RM \"\$progdir/\$file\"
4079994689c1Smrg  fi"
4080994689c1Smrg	else
4081994689c1Smrg	  $ECHO "\
4082994689c1Smrg  program='$outputname'
4083994689c1Smrg  progdir=\"\$thisdir/$objdir\"
4084994689c1Smrg"
4085994689c1Smrg	fi
4086775e7de9Smrg
4087994689c1Smrg	$ECHO "\
40887a84e134Smrg
4089994689c1Smrg  if test -f \"\$progdir/\$program\"; then"
40907a84e134Smrg
4091f353fbadSmrg	# fixup the dll searchpath if we need to.
4092f353fbadSmrg	#
4093f353fbadSmrg	# Fix the DLL searchpath if we need to.  Do this before prepending
4094f353fbadSmrg	# to shlibpath, because on Windows, both are PATH and uninstalled
4095f353fbadSmrg	# libraries must come first.
4096f353fbadSmrg	if test -n "$dllsearchpath"; then
4097f353fbadSmrg	  $ECHO "\
4098f353fbadSmrg    # Add the dll search path components to the executable PATH
4099f353fbadSmrg    PATH=$dllsearchpath:\$PATH
4100f353fbadSmrg"
4101f353fbadSmrg	fi
4102f353fbadSmrg
4103994689c1Smrg	# Export our shlibpath_var if we have one.
4104994689c1Smrg	if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
4105994689c1Smrg	  $ECHO "\
4106994689c1Smrg    # Add our own library path to $shlibpath_var
4107994689c1Smrg    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
41087a84e134Smrg
4109994689c1Smrg    # Some systems cannot cope with colon-terminated $shlibpath_var
4110994689c1Smrg    # The second colon is a workaround for a bug in BeOS R4 sed
4111994689c1Smrg    $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
41127a84e134Smrg
4113994689c1Smrg    export $shlibpath_var
4114994689c1Smrg"
4115994689c1Smrg	fi
41167a84e134Smrg
4117994689c1Smrg	$ECHO "\
4118994689c1Smrg    if test \"\$libtool_execute_magic\" != \"$magic\"; then
4119994689c1Smrg      # Run the actual program with our arguments.
4120994689c1Smrg      func_exec_program \${1+\"\$@\"}
4121994689c1Smrg    fi
4122994689c1Smrg  else
4123994689c1Smrg    # The program doesn't exist.
4124994689c1Smrg    \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
4125994689c1Smrg    \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
4126994689c1Smrg    \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
4127994689c1Smrg    exit 1
4128994689c1Smrg  fi
4129994689c1Smrgfi\
4130994689c1Smrg"
4131994689c1Smrg}
41327a84e134Smrg
41337a84e134Smrg
4134994689c1Smrg# func_emit_cwrapperexe_src
4135994689c1Smrg# emit the source code for a wrapper executable on stdout
4136994689c1Smrg# Must ONLY be called from within func_mode_link because
4137994689c1Smrg# it depends on a number of variable set therein.
4138994689c1Smrgfunc_emit_cwrapperexe_src ()
4139994689c1Smrg{
4140994689c1Smrg	cat <<EOF
41417a84e134Smrg
4142994689c1Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
4143994689c1Smrg   Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
41447a84e134Smrg
4145994689c1Smrg   The $output program cannot be directly executed until all the libtool
4146994689c1Smrg   libraries that it depends on are installed.
41477a84e134Smrg
4148994689c1Smrg   This wrapper executable should never be moved out of the build directory.
4149994689c1Smrg   If it is, it will not operate correctly.
4150994689c1Smrg*/
4151994689c1SmrgEOF
4152994689c1Smrg	    cat <<"EOF"
4153994689c1Smrg#ifdef _MSC_VER
4154994689c1Smrg# define _CRT_SECURE_NO_DEPRECATE 1
4155994689c1Smrg#endif
4156994689c1Smrg#include <stdio.h>
4157994689c1Smrg#include <stdlib.h>
4158994689c1Smrg#ifdef _MSC_VER
4159994689c1Smrg# include <direct.h>
4160994689c1Smrg# include <process.h>
4161994689c1Smrg# include <io.h>
4162994689c1Smrg#else
4163994689c1Smrg# include <unistd.h>
4164994689c1Smrg# include <stdint.h>
4165994689c1Smrg# ifdef __CYGWIN__
4166994689c1Smrg#  include <io.h>
4167994689c1Smrg# endif
4168994689c1Smrg#endif
4169994689c1Smrg#include <malloc.h>
4170994689c1Smrg#include <stdarg.h>
4171994689c1Smrg#include <assert.h>
4172994689c1Smrg#include <string.h>
4173994689c1Smrg#include <ctype.h>
4174994689c1Smrg#include <errno.h>
4175994689c1Smrg#include <fcntl.h>
4176994689c1Smrg#include <sys/stat.h>
41777a84e134Smrg
4178994689c1Smrg/* declarations of non-ANSI functions */
4179994689c1Smrg#if defined(__MINGW32__)
4180994689c1Smrg# ifdef __STRICT_ANSI__
4181994689c1Smrgint _putenv (const char *);
4182994689c1Smrg# endif
4183994689c1Smrg#elif defined(__CYGWIN__)
4184994689c1Smrg# ifdef __STRICT_ANSI__
4185994689c1Smrgchar *realpath (const char *, char *);
4186994689c1Smrgint putenv (char *);
4187994689c1Smrgint setenv (const char *, const char *, int);
4188994689c1Smrg# endif
4189994689c1Smrg/* #elif defined (other platforms) ... */
4190994689c1Smrg#endif
41917a84e134Smrg
4192994689c1Smrg/* portability defines, excluding path handling macros */
4193994689c1Smrg#if defined(_MSC_VER)
4194994689c1Smrg# define setmode _setmode
4195994689c1Smrg# define stat    _stat
4196994689c1Smrg# define chmod   _chmod
4197994689c1Smrg# define getcwd  _getcwd
4198994689c1Smrg# define putenv  _putenv
4199994689c1Smrg# define S_IXUSR _S_IEXEC
4200994689c1Smrg# ifndef _INTPTR_T_DEFINED
4201994689c1Smrg#  define _INTPTR_T_DEFINED
4202994689c1Smrg#  define intptr_t int
4203994689c1Smrg# endif
4204994689c1Smrg#elif defined(__MINGW32__)
4205994689c1Smrg# define setmode _setmode
4206994689c1Smrg# define stat    _stat
4207994689c1Smrg# define chmod   _chmod
4208994689c1Smrg# define getcwd  _getcwd
4209994689c1Smrg# define putenv  _putenv
4210994689c1Smrg#elif defined(__CYGWIN__)
4211994689c1Smrg# define HAVE_SETENV
4212994689c1Smrg# define FOPEN_WB "wb"
4213994689c1Smrg/* #elif defined (other platforms) ... */
4214994689c1Smrg#endif
42157a84e134Smrg
4216994689c1Smrg#if defined(PATH_MAX)
4217994689c1Smrg# define LT_PATHMAX PATH_MAX
4218994689c1Smrg#elif defined(MAXPATHLEN)
4219994689c1Smrg# define LT_PATHMAX MAXPATHLEN
4220994689c1Smrg#else
4221994689c1Smrg# define LT_PATHMAX 1024
4222994689c1Smrg#endif
42237a84e134Smrg
4224994689c1Smrg#ifndef S_IXOTH
4225994689c1Smrg# define S_IXOTH 0
4226994689c1Smrg#endif
4227994689c1Smrg#ifndef S_IXGRP
4228994689c1Smrg# define S_IXGRP 0
4229994689c1Smrg#endif
42307a84e134Smrg
4231994689c1Smrg/* path handling portability macros */
4232994689c1Smrg#ifndef DIR_SEPARATOR
4233994689c1Smrg# define DIR_SEPARATOR '/'
4234994689c1Smrg# define PATH_SEPARATOR ':'
4235994689c1Smrg#endif
42367a84e134Smrg
4237994689c1Smrg#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
4238994689c1Smrg  defined (__OS2__)
4239994689c1Smrg# define HAVE_DOS_BASED_FILE_SYSTEM
4240994689c1Smrg# define FOPEN_WB "wb"
4241994689c1Smrg# ifndef DIR_SEPARATOR_2
4242994689c1Smrg#  define DIR_SEPARATOR_2 '\\'
4243994689c1Smrg# endif
4244994689c1Smrg# ifndef PATH_SEPARATOR_2
4245994689c1Smrg#  define PATH_SEPARATOR_2 ';'
4246994689c1Smrg# endif
4247994689c1Smrg#endif
42487a84e134Smrg
4249994689c1Smrg#ifndef DIR_SEPARATOR_2
4250994689c1Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
4251994689c1Smrg#else /* DIR_SEPARATOR_2 */
4252994689c1Smrg# define IS_DIR_SEPARATOR(ch) \
4253994689c1Smrg	(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
4254994689c1Smrg#endif /* DIR_SEPARATOR_2 */
42557a84e134Smrg
4256994689c1Smrg#ifndef PATH_SEPARATOR_2
4257994689c1Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
4258994689c1Smrg#else /* PATH_SEPARATOR_2 */
4259994689c1Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
4260994689c1Smrg#endif /* PATH_SEPARATOR_2 */
4261994689c1Smrg
4262994689c1Smrg#ifndef FOPEN_WB
4263994689c1Smrg# define FOPEN_WB "w"
4264994689c1Smrg#endif
4265994689c1Smrg#ifndef _O_BINARY
4266994689c1Smrg# define _O_BINARY 0
4267994689c1Smrg#endif
4268994689c1Smrg
4269994689c1Smrg#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
4270994689c1Smrg#define XFREE(stale) do { \
4271994689c1Smrg  if (stale) { free ((void *) stale); stale = 0; } \
4272994689c1Smrg} while (0)
4273994689c1Smrg
4274994689c1Smrg#if defined(LT_DEBUGWRAPPER)
4275994689c1Smrgstatic int lt_debug = 1;
4276994689c1Smrg#else
4277994689c1Smrgstatic int lt_debug = 0;
4278994689c1Smrg#endif
4279994689c1Smrg
4280994689c1Smrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */
4281994689c1Smrg
4282994689c1Smrgvoid *xmalloc (size_t num);
4283994689c1Smrgchar *xstrdup (const char *string);
4284994689c1Smrgconst char *base_name (const char *name);
4285994689c1Smrgchar *find_executable (const char *wrapper);
4286994689c1Smrgchar *chase_symlinks (const char *pathspec);
4287994689c1Smrgint make_executable (const char *path);
4288994689c1Smrgint check_executable (const char *path);
4289994689c1Smrgchar *strendzap (char *str, const char *pat);
4290994689c1Smrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...);
4291994689c1Smrgvoid lt_fatal (const char *file, int line, const char *message, ...);
4292994689c1Smrgstatic const char *nonnull (const char *s);
4293994689c1Smrgstatic const char *nonempty (const char *s);
4294994689c1Smrgvoid lt_setenv (const char *name, const char *value);
4295994689c1Smrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end);
4296994689c1Smrgvoid lt_update_exe_path (const char *name, const char *value);
4297994689c1Smrgvoid lt_update_lib_path (const char *name, const char *value);
4298994689c1Smrgchar **prepare_spawn (char **argv);
4299994689c1Smrgvoid lt_dump_script (FILE *f);
4300994689c1SmrgEOF
4301994689c1Smrg
4302994689c1Smrg	    cat <<EOF
4303f353fbadSmrgvolatile const char * MAGIC_EXE = "$magic_exe";
4304994689c1Smrgconst char * LIB_PATH_VARNAME = "$shlibpath_var";
4305994689c1SmrgEOF
4306994689c1Smrg
4307994689c1Smrg	    if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
4308f353fbadSmrg              func_to_host_path "$temp_rpath"
4309994689c1Smrg	      cat <<EOF
4310f353fbadSmrgconst char * LIB_PATH_VALUE   = "$func_to_host_path_result";
4311e1e1713cSmrgEOF
4312e1e1713cSmrg	    else
4313994689c1Smrg	      cat <<"EOF"
4314994689c1Smrgconst char * LIB_PATH_VALUE   = "";
4315994689c1SmrgEOF
4316e1e1713cSmrg	    fi
4317994689c1Smrg
4318994689c1Smrg	    if test -n "$dllsearchpath"; then
4319f353fbadSmrg              func_to_host_path "$dllsearchpath:"
4320994689c1Smrg	      cat <<EOF
4321994689c1Smrgconst char * EXE_PATH_VARNAME = "PATH";
4322f353fbadSmrgconst char * EXE_PATH_VALUE   = "$func_to_host_path_result";
4323994689c1SmrgEOF
4324e1e1713cSmrg	    else
4325994689c1Smrg	      cat <<"EOF"
4326994689c1Smrgconst char * EXE_PATH_VARNAME = "";
4327994689c1Smrgconst char * EXE_PATH_VALUE   = "";
4328994689c1SmrgEOF
4329e1e1713cSmrg	    fi
4330994689c1Smrg
4331994689c1Smrg	    if test "$fast_install" = yes; then
4332994689c1Smrg	      cat <<EOF
4333994689c1Smrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
4334994689c1SmrgEOF
4335e1e1713cSmrg	    else
4336994689c1Smrg	      cat <<EOF
4337994689c1Smrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
4338994689c1SmrgEOF
4339e1e1713cSmrg	    fi
43407a84e134Smrg
43417a84e134Smrg
4342994689c1Smrg	    cat <<"EOF"
43437a84e134Smrg
4344994689c1Smrg#define LTWRAPPER_OPTION_PREFIX         "--lt-"
43457a84e134Smrg
4346994689c1Smrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
4347994689c1Smrgstatic const char *dumpscript_opt       = LTWRAPPER_OPTION_PREFIX "dump-script";
4348994689c1Smrgstatic const char *debug_opt            = LTWRAPPER_OPTION_PREFIX "debug";
43497a84e134Smrg
4350994689c1Smrgint
4351994689c1Smrgmain (int argc, char *argv[])
4352994689c1Smrg{
4353994689c1Smrg  char **newargz;
4354994689c1Smrg  int  newargc;
4355994689c1Smrg  char *tmp_pathspec;
4356994689c1Smrg  char *actual_cwrapper_path;
4357994689c1Smrg  char *actual_cwrapper_name;
4358994689c1Smrg  char *target_name;
4359994689c1Smrg  char *lt_argv_zero;
4360994689c1Smrg  intptr_t rval = 127;
43617a84e134Smrg
4362994689c1Smrg  int i;
43637a84e134Smrg
4364994689c1Smrg  program_name = (char *) xstrdup (base_name (argv[0]));
4365994689c1Smrg  newargz = XMALLOC (char *, argc + 1);
43667a84e134Smrg
4367994689c1Smrg  /* very simple arg parsing; don't want to rely on getopt
4368994689c1Smrg   * also, copy all non cwrapper options to newargz, except
4369994689c1Smrg   * argz[0], which is handled differently
4370994689c1Smrg   */
4371994689c1Smrg  newargc=0;
4372994689c1Smrg  for (i = 1; i < argc; i++)
4373994689c1Smrg    {
4374994689c1Smrg      if (strcmp (argv[i], dumpscript_opt) == 0)
4375994689c1Smrg	{
4376994689c1SmrgEOF
4377994689c1Smrg	    case "$host" in
4378994689c1Smrg	      *mingw* | *cygwin* )
4379994689c1Smrg		# make stdout use "unix" line endings
4380994689c1Smrg		echo "          setmode(1,_O_BINARY);"
4381994689c1Smrg		;;
4382e1e1713cSmrg	      esac
43837a84e134Smrg
4384994689c1Smrg	    cat <<"EOF"
4385994689c1Smrg	  lt_dump_script (stdout);
4386994689c1Smrg	  return 0;
4387994689c1Smrg	}
4388994689c1Smrg      if (strcmp (argv[i], debug_opt) == 0)
4389994689c1Smrg	{
4390994689c1Smrg          lt_debug = 1;
4391994689c1Smrg          continue;
4392994689c1Smrg	}
4393994689c1Smrg      if (strcmp (argv[i], ltwrapper_option_prefix) == 0)
4394994689c1Smrg        {
4395994689c1Smrg          /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
4396994689c1Smrg             namespace, but it is not one of the ones we know about and
4397994689c1Smrg             have already dealt with, above (inluding dump-script), then
4398994689c1Smrg             report an error. Otherwise, targets might begin to believe
4399994689c1Smrg             they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
4400994689c1Smrg             namespace. The first time any user complains about this, we'll
4401994689c1Smrg             need to make LTWRAPPER_OPTION_PREFIX a configure-time option
4402994689c1Smrg             or a configure.ac-settable value.
4403994689c1Smrg           */
4404994689c1Smrg          lt_fatal (__FILE__, __LINE__,
4405994689c1Smrg		    "unrecognized %s option: '%s'",
4406994689c1Smrg                    ltwrapper_option_prefix, argv[i]);
4407994689c1Smrg        }
4408994689c1Smrg      /* otherwise ... */
4409994689c1Smrg      newargz[++newargc] = xstrdup (argv[i]);
4410994689c1Smrg    }
4411994689c1Smrg  newargz[++newargc] = NULL;
44127a84e134Smrg
4413994689c1SmrgEOF
4414994689c1Smrg	    cat <<EOF
4415994689c1Smrg  /* The GNU banner must be the first non-error debug message */
4416994689c1Smrg  lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\n");
4417994689c1SmrgEOF
4418994689c1Smrg	    cat <<"EOF"
4419994689c1Smrg  lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
4420994689c1Smrg  lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name);
4421994689c1Smrg
4422994689c1Smrg  tmp_pathspec = find_executable (argv[0]);
4423994689c1Smrg  if (tmp_pathspec == NULL)
4424994689c1Smrg    lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]);
4425994689c1Smrg  lt_debugprintf (__FILE__, __LINE__,
4426994689c1Smrg                  "(main) found exe (before symlink chase) at: %s\n",
4427994689c1Smrg		  tmp_pathspec);
4428994689c1Smrg
4429994689c1Smrg  actual_cwrapper_path = chase_symlinks (tmp_pathspec);
4430994689c1Smrg  lt_debugprintf (__FILE__, __LINE__,
4431994689c1Smrg                  "(main) found exe (after symlink chase) at: %s\n",
4432994689c1Smrg		  actual_cwrapper_path);
4433994689c1Smrg  XFREE (tmp_pathspec);
4434994689c1Smrg
4435994689c1Smrg  actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));
4436994689c1Smrg  strendzap (actual_cwrapper_path, actual_cwrapper_name);
4437994689c1Smrg
4438994689c1Smrg  /* wrapper name transforms */
4439994689c1Smrg  strendzap (actual_cwrapper_name, ".exe");
4440994689c1Smrg  tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
4441994689c1Smrg  XFREE (actual_cwrapper_name);
4442994689c1Smrg  actual_cwrapper_name = tmp_pathspec;
4443994689c1Smrg  tmp_pathspec = 0;
4444994689c1Smrg
4445994689c1Smrg  /* target_name transforms -- use actual target program name; might have lt- prefix */
4446994689c1Smrg  target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
4447994689c1Smrg  strendzap (target_name, ".exe");
4448994689c1Smrg  tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
4449994689c1Smrg  XFREE (target_name);
4450994689c1Smrg  target_name = tmp_pathspec;
4451994689c1Smrg  tmp_pathspec = 0;
4452994689c1Smrg
4453994689c1Smrg  lt_debugprintf (__FILE__, __LINE__,
4454994689c1Smrg		  "(main) libtool target name: %s\n",
4455994689c1Smrg		  target_name);
4456994689c1SmrgEOF
44577a84e134Smrg
4458994689c1Smrg	    cat <<EOF
4459994689c1Smrg  newargz[0] =
4460994689c1Smrg    XMALLOC (char, (strlen (actual_cwrapper_path) +
4461994689c1Smrg		    strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
4462994689c1Smrg  strcpy (newargz[0], actual_cwrapper_path);
4463994689c1Smrg  strcat (newargz[0], "$objdir");
4464994689c1Smrg  strcat (newargz[0], "/");
4465994689c1SmrgEOF
44667a84e134Smrg
4467994689c1Smrg	    cat <<"EOF"
4468994689c1Smrg  /* stop here, and copy so we don't have to do this twice */
4469994689c1Smrg  tmp_pathspec = xstrdup (newargz[0]);
44707a84e134Smrg
4471994689c1Smrg  /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
4472994689c1Smrg  strcat (newargz[0], actual_cwrapper_name);
44737a84e134Smrg
4474994689c1Smrg  /* DO want the lt- prefix here if it exists, so use target_name */
4475994689c1Smrg  lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
4476994689c1Smrg  XFREE (tmp_pathspec);
4477994689c1Smrg  tmp_pathspec = NULL;
4478994689c1SmrgEOF
44797a84e134Smrg
4480994689c1Smrg	    case $host_os in
4481994689c1Smrg	      mingw*)
4482994689c1Smrg	    cat <<"EOF"
4483994689c1Smrg  {
4484994689c1Smrg    char* p;
4485994689c1Smrg    while ((p = strchr (newargz[0], '\\')) != NULL)
4486994689c1Smrg      {
4487994689c1Smrg	*p = '/';
4488994689c1Smrg      }
4489994689c1Smrg    while ((p = strchr (lt_argv_zero, '\\')) != NULL)
4490994689c1Smrg      {
4491994689c1Smrg	*p = '/';
4492994689c1Smrg      }
4493994689c1Smrg  }
4494994689c1SmrgEOF
4495994689c1Smrg	    ;;
4496994689c1Smrg	    esac
44977a84e134Smrg
4498994689c1Smrg	    cat <<"EOF"
4499994689c1Smrg  XFREE (target_name);
4500994689c1Smrg  XFREE (actual_cwrapper_path);
4501994689c1Smrg  XFREE (actual_cwrapper_name);
45027a84e134Smrg
4503994689c1Smrg  lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
4504994689c1Smrg  lt_setenv ("DUALCASE", "1");  /* for MSK sh */
4505f353fbadSmrg  /* Update the DLL searchpath.  EXE_PATH_VALUE ($dllsearchpath) must
4506f353fbadSmrg     be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath)
4507f353fbadSmrg     because on Windows, both *_VARNAMEs are PATH but uninstalled
4508f353fbadSmrg     libraries must come first. */
4509994689c1Smrg  lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
4510f353fbadSmrg  lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
45117a84e134Smrg
4512994689c1Smrg  lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",
4513994689c1Smrg		  nonnull (lt_argv_zero));
4514994689c1Smrg  for (i = 0; i < newargc; i++)
4515994689c1Smrg    {
4516994689c1Smrg      lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n",
4517994689c1Smrg		      i, nonnull (newargz[i]));
4518994689c1Smrg    }
45197a84e134Smrg
4520994689c1SmrgEOF
45217a84e134Smrg
4522994689c1Smrg	    case $host_os in
4523994689c1Smrg	      mingw*)
4524994689c1Smrg		cat <<"EOF"
4525994689c1Smrg  /* execv doesn't actually work on mingw as expected on unix */
4526994689c1Smrg  newargz = prepare_spawn (newargz);
4527994689c1Smrg  rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
4528994689c1Smrg  if (rval == -1)
4529994689c1Smrg    {
4530994689c1Smrg      /* failed to start process */
4531994689c1Smrg      lt_debugprintf (__FILE__, __LINE__,
4532994689c1Smrg		      "(main) failed to launch target \"%s\": %s\n",
4533994689c1Smrg		      lt_argv_zero, nonnull (strerror (errno)));
4534994689c1Smrg      return 127;
4535994689c1Smrg    }
4536994689c1Smrg  return rval;
4537994689c1SmrgEOF
4538994689c1Smrg		;;
4539994689c1Smrg	      *)
4540994689c1Smrg		cat <<"EOF"
4541994689c1Smrg  execv (lt_argv_zero, newargz);
4542994689c1Smrg  return rval; /* =127, but avoids unused variable warning */
4543994689c1SmrgEOF
4544994689c1Smrg		;;
4545994689c1Smrg	    esac
45467a84e134Smrg
4547994689c1Smrg	    cat <<"EOF"
4548994689c1Smrg}
45497a84e134Smrg
4550994689c1Smrgvoid *
4551994689c1Smrgxmalloc (size_t num)
4552994689c1Smrg{
4553994689c1Smrg  void *p = (void *) malloc (num);
4554994689c1Smrg  if (!p)
4555994689c1Smrg    lt_fatal (__FILE__, __LINE__, "memory exhausted");
45567a84e134Smrg
4557994689c1Smrg  return p;
4558994689c1Smrg}
45597a84e134Smrg
4560994689c1Smrgchar *
4561994689c1Smrgxstrdup (const char *string)
4562994689c1Smrg{
4563994689c1Smrg  return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
4564994689c1Smrg			  string) : NULL;
4565994689c1Smrg}
45667a84e134Smrg
4567994689c1Smrgconst char *
4568994689c1Smrgbase_name (const char *name)
4569994689c1Smrg{
4570994689c1Smrg  const char *base;
45717a84e134Smrg
4572994689c1Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4573994689c1Smrg  /* Skip over the disk name in MSDOS pathnames. */
4574994689c1Smrg  if (isalpha ((unsigned char) name[0]) && name[1] == ':')
4575994689c1Smrg    name += 2;
4576994689c1Smrg#endif
45777a84e134Smrg
4578994689c1Smrg  for (base = name; *name; name++)
4579994689c1Smrg    if (IS_DIR_SEPARATOR (*name))
4580994689c1Smrg      base = name + 1;
4581994689c1Smrg  return base;
4582994689c1Smrg}
45837a84e134Smrg
4584994689c1Smrgint
4585994689c1Smrgcheck_executable (const char *path)
4586994689c1Smrg{
4587994689c1Smrg  struct stat st;
45887a84e134Smrg
4589994689c1Smrg  lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n",
4590994689c1Smrg                  nonempty (path));
4591994689c1Smrg  if ((!path) || (!*path))
4592994689c1Smrg    return 0;
45937a84e134Smrg
4594994689c1Smrg  if ((stat (path, &st) >= 0)
4595994689c1Smrg      && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
4596994689c1Smrg    return 1;
4597994689c1Smrg  else
4598994689c1Smrg    return 0;
4599994689c1Smrg}
46007a84e134Smrg
4601994689c1Smrgint
4602994689c1Smrgmake_executable (const char *path)
4603994689c1Smrg{
4604994689c1Smrg  int rval = 0;
4605994689c1Smrg  struct stat st;
4606e1e1713cSmrg
4607994689c1Smrg  lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n",
4608994689c1Smrg                  nonempty (path));
4609994689c1Smrg  if ((!path) || (!*path))
4610994689c1Smrg    return 0;
4611e1e1713cSmrg
4612994689c1Smrg  if (stat (path, &st) >= 0)
4613994689c1Smrg    {
4614994689c1Smrg      rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
4615994689c1Smrg    }
4616994689c1Smrg  return rval;
4617994689c1Smrg}
4618e1e1713cSmrg
4619994689c1Smrg/* Searches for the full path of the wrapper.  Returns
4620994689c1Smrg   newly allocated full path name if found, NULL otherwise
4621994689c1Smrg   Does not chase symlinks, even on platforms that support them.
4622994689c1Smrg*/
4623994689c1Smrgchar *
4624994689c1Smrgfind_executable (const char *wrapper)
4625994689c1Smrg{
4626994689c1Smrg  int has_slash = 0;
4627994689c1Smrg  const char *p;
4628994689c1Smrg  const char *p_next;
4629994689c1Smrg  /* static buffer for getcwd */
4630994689c1Smrg  char tmp[LT_PATHMAX + 1];
4631994689c1Smrg  int tmp_len;
4632994689c1Smrg  char *concat_name;
4633e1e1713cSmrg
4634994689c1Smrg  lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
4635994689c1Smrg                  nonempty (wrapper));
4636e1e1713cSmrg
4637994689c1Smrg  if ((wrapper == NULL) || (*wrapper == '\0'))
4638994689c1Smrg    return NULL;
46397a84e134Smrg
4640994689c1Smrg  /* Absolute path? */
4641994689c1Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4642994689c1Smrg  if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
4643994689c1Smrg    {
4644994689c1Smrg      concat_name = xstrdup (wrapper);
4645994689c1Smrg      if (check_executable (concat_name))
4646994689c1Smrg	return concat_name;
4647994689c1Smrg      XFREE (concat_name);
4648994689c1Smrg    }
4649994689c1Smrg  else
4650994689c1Smrg    {
4651994689c1Smrg#endif
4652994689c1Smrg      if (IS_DIR_SEPARATOR (wrapper[0]))
4653994689c1Smrg	{
4654994689c1Smrg	  concat_name = xstrdup (wrapper);
4655994689c1Smrg	  if (check_executable (concat_name))
4656994689c1Smrg	    return concat_name;
4657994689c1Smrg	  XFREE (concat_name);
4658994689c1Smrg	}
4659994689c1Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4660994689c1Smrg    }
4661994689c1Smrg#endif
46627a84e134Smrg
4663994689c1Smrg  for (p = wrapper; *p; p++)
4664994689c1Smrg    if (*p == '/')
4665994689c1Smrg      {
4666994689c1Smrg	has_slash = 1;
4667994689c1Smrg	break;
4668994689c1Smrg      }
4669994689c1Smrg  if (!has_slash)
4670994689c1Smrg    {
4671994689c1Smrg      /* no slashes; search PATH */
4672994689c1Smrg      const char *path = getenv ("PATH");
4673994689c1Smrg      if (path != NULL)
4674994689c1Smrg	{
4675994689c1Smrg	  for (p = path; *p; p = p_next)
4676994689c1Smrg	    {
4677994689c1Smrg	      const char *q;
4678994689c1Smrg	      size_t p_len;
4679994689c1Smrg	      for (q = p; *q; q++)
4680994689c1Smrg		if (IS_PATH_SEPARATOR (*q))
4681994689c1Smrg		  break;
4682994689c1Smrg	      p_len = q - p;
4683994689c1Smrg	      p_next = (*q == '\0' ? q : q + 1);
4684994689c1Smrg	      if (p_len == 0)
4685994689c1Smrg		{
4686994689c1Smrg		  /* empty path: current directory */
4687994689c1Smrg		  if (getcwd (tmp, LT_PATHMAX) == NULL)
4688994689c1Smrg		    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
4689994689c1Smrg                              nonnull (strerror (errno)));
4690994689c1Smrg		  tmp_len = strlen (tmp);
4691994689c1Smrg		  concat_name =
4692994689c1Smrg		    XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
4693994689c1Smrg		  memcpy (concat_name, tmp, tmp_len);
4694994689c1Smrg		  concat_name[tmp_len] = '/';
4695994689c1Smrg		  strcpy (concat_name + tmp_len + 1, wrapper);
4696994689c1Smrg		}
4697994689c1Smrg	      else
4698994689c1Smrg		{
4699994689c1Smrg		  concat_name =
4700994689c1Smrg		    XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
4701994689c1Smrg		  memcpy (concat_name, p, p_len);
4702994689c1Smrg		  concat_name[p_len] = '/';
4703994689c1Smrg		  strcpy (concat_name + p_len + 1, wrapper);
4704994689c1Smrg		}
4705994689c1Smrg	      if (check_executable (concat_name))
4706994689c1Smrg		return concat_name;
4707994689c1Smrg	      XFREE (concat_name);
4708994689c1Smrg	    }
4709994689c1Smrg	}
4710994689c1Smrg      /* not found in PATH; assume curdir */
4711994689c1Smrg    }
4712994689c1Smrg  /* Relative path | not found in path: prepend cwd */
4713994689c1Smrg  if (getcwd (tmp, LT_PATHMAX) == NULL)
4714994689c1Smrg    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
4715994689c1Smrg              nonnull (strerror (errno)));
4716994689c1Smrg  tmp_len = strlen (tmp);
4717994689c1Smrg  concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
4718994689c1Smrg  memcpy (concat_name, tmp, tmp_len);
4719994689c1Smrg  concat_name[tmp_len] = '/';
4720994689c1Smrg  strcpy (concat_name + tmp_len + 1, wrapper);
47217a84e134Smrg
4722994689c1Smrg  if (check_executable (concat_name))
4723994689c1Smrg    return concat_name;
4724994689c1Smrg  XFREE (concat_name);
4725994689c1Smrg  return NULL;
4726994689c1Smrg}
4727e1e1713cSmrg
4728994689c1Smrgchar *
4729994689c1Smrgchase_symlinks (const char *pathspec)
4730994689c1Smrg{
4731994689c1Smrg#ifndef S_ISLNK
4732994689c1Smrg  return xstrdup (pathspec);
4733994689c1Smrg#else
4734994689c1Smrg  char buf[LT_PATHMAX];
4735994689c1Smrg  struct stat s;
4736994689c1Smrg  char *tmp_pathspec = xstrdup (pathspec);
4737994689c1Smrg  char *p;
4738994689c1Smrg  int has_symlinks = 0;
4739994689c1Smrg  while (strlen (tmp_pathspec) && !has_symlinks)
4740994689c1Smrg    {
4741994689c1Smrg      lt_debugprintf (__FILE__, __LINE__,
4742994689c1Smrg		      "checking path component for symlinks: %s\n",
4743994689c1Smrg		      tmp_pathspec);
4744994689c1Smrg      if (lstat (tmp_pathspec, &s) == 0)
4745994689c1Smrg	{
4746994689c1Smrg	  if (S_ISLNK (s.st_mode) != 0)
4747994689c1Smrg	    {
4748994689c1Smrg	      has_symlinks = 1;
4749994689c1Smrg	      break;
4750994689c1Smrg	    }
4751e1e1713cSmrg
4752994689c1Smrg	  /* search backwards for last DIR_SEPARATOR */
4753994689c1Smrg	  p = tmp_pathspec + strlen (tmp_pathspec) - 1;
4754994689c1Smrg	  while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
4755994689c1Smrg	    p--;
4756994689c1Smrg	  if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
4757994689c1Smrg	    {
4758994689c1Smrg	      /* no more DIR_SEPARATORS left */
4759994689c1Smrg	      break;
4760994689c1Smrg	    }
4761994689c1Smrg	  *p = '\0';
4762994689c1Smrg	}
4763994689c1Smrg      else
4764994689c1Smrg	{
4765994689c1Smrg	  lt_fatal (__FILE__, __LINE__,
4766994689c1Smrg		    "error accessing file \"%s\": %s",
4767994689c1Smrg		    tmp_pathspec, nonnull (strerror (errno)));
4768994689c1Smrg	}
4769994689c1Smrg    }
4770994689c1Smrg  XFREE (tmp_pathspec);
4771e1e1713cSmrg
4772994689c1Smrg  if (!has_symlinks)
4773994689c1Smrg    {
4774994689c1Smrg      return xstrdup (pathspec);
4775994689c1Smrg    }
4776e1e1713cSmrg
4777994689c1Smrg  tmp_pathspec = realpath (pathspec, buf);
4778994689c1Smrg  if (tmp_pathspec == 0)
4779994689c1Smrg    {
4780994689c1Smrg      lt_fatal (__FILE__, __LINE__,
4781994689c1Smrg		"could not follow symlinks for %s", pathspec);
4782994689c1Smrg    }
4783994689c1Smrg  return xstrdup (tmp_pathspec);
4784994689c1Smrg#endif
4785994689c1Smrg}
47867a84e134Smrg
4787994689c1Smrgchar *
4788994689c1Smrgstrendzap (char *str, const char *pat)
4789994689c1Smrg{
4790994689c1Smrg  size_t len, patlen;
47917a84e134Smrg
4792994689c1Smrg  assert (str != NULL);
4793994689c1Smrg  assert (pat != NULL);
47947a84e134Smrg
4795994689c1Smrg  len = strlen (str);
4796994689c1Smrg  patlen = strlen (pat);
47977a84e134Smrg
4798994689c1Smrg  if (patlen <= len)
4799994689c1Smrg    {
4800994689c1Smrg      str += len - patlen;
4801994689c1Smrg      if (strcmp (str, pat) == 0)
4802994689c1Smrg	*str = '\0';
4803994689c1Smrg    }
4804994689c1Smrg  return str;
4805994689c1Smrg}
48067a84e134Smrg
4807994689c1Smrgvoid
4808994689c1Smrglt_debugprintf (const char *file, int line, const char *fmt, ...)
4809994689c1Smrg{
4810994689c1Smrg  va_list args;
4811994689c1Smrg  if (lt_debug)
4812994689c1Smrg    {
4813994689c1Smrg      (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line);
4814994689c1Smrg      va_start (args, fmt);
4815994689c1Smrg      (void) vfprintf (stderr, fmt, args);
4816994689c1Smrg      va_end (args);
4817994689c1Smrg    }
4818994689c1Smrg}
48197a84e134Smrg
4820994689c1Smrgstatic void
4821994689c1Smrglt_error_core (int exit_status, const char *file,
4822994689c1Smrg	       int line, const char *mode,
4823994689c1Smrg	       const char *message, va_list ap)
4824994689c1Smrg{
4825994689c1Smrg  fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode);
4826994689c1Smrg  vfprintf (stderr, message, ap);
4827994689c1Smrg  fprintf (stderr, ".\n");
48287a84e134Smrg
4829994689c1Smrg  if (exit_status >= 0)
4830994689c1Smrg    exit (exit_status);
4831994689c1Smrg}
48327a84e134Smrg
4833994689c1Smrgvoid
4834994689c1Smrglt_fatal (const char *file, int line, const char *message, ...)
4835994689c1Smrg{
4836994689c1Smrg  va_list ap;
4837994689c1Smrg  va_start (ap, message);
4838994689c1Smrg  lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap);
4839994689c1Smrg  va_end (ap);
4840994689c1Smrg}
48417a84e134Smrg
4842994689c1Smrgstatic const char *
4843994689c1Smrgnonnull (const char *s)
4844994689c1Smrg{
4845994689c1Smrg  return s ? s : "(null)";
4846994689c1Smrg}
48477a84e134Smrg
4848994689c1Smrgstatic const char *
4849994689c1Smrgnonempty (const char *s)
4850994689c1Smrg{
4851994689c1Smrg  return (s && !*s) ? "(empty)" : nonnull (s);
4852994689c1Smrg}
4853775e7de9Smrg
4854994689c1Smrgvoid
4855994689c1Smrglt_setenv (const char *name, const char *value)
4856994689c1Smrg{
4857994689c1Smrg  lt_debugprintf (__FILE__, __LINE__,
4858994689c1Smrg		  "(lt_setenv) setting '%s' to '%s'\n",
4859994689c1Smrg                  nonnull (name), nonnull (value));
4860994689c1Smrg  {
4861994689c1Smrg#ifdef HAVE_SETENV
4862994689c1Smrg    /* always make a copy, for consistency with !HAVE_SETENV */
4863994689c1Smrg    char *str = xstrdup (value);
4864994689c1Smrg    setenv (name, str, 1);
4865994689c1Smrg#else
4866994689c1Smrg    int len = strlen (name) + 1 + strlen (value) + 1;
4867994689c1Smrg    char *str = XMALLOC (char, len);
4868994689c1Smrg    sprintf (str, "%s=%s", name, value);
4869994689c1Smrg    if (putenv (str) != EXIT_SUCCESS)
4870994689c1Smrg      {
4871994689c1Smrg        XFREE (str);
4872994689c1Smrg      }
4873994689c1Smrg#endif
4874994689c1Smrg  }
4875994689c1Smrg}
48767a84e134Smrg
4877994689c1Smrgchar *
4878994689c1Smrglt_extend_str (const char *orig_value, const char *add, int to_end)
4879994689c1Smrg{
4880994689c1Smrg  char *new_value;
4881994689c1Smrg  if (orig_value && *orig_value)
4882994689c1Smrg    {
4883994689c1Smrg      int orig_value_len = strlen (orig_value);
4884994689c1Smrg      int add_len = strlen (add);
4885994689c1Smrg      new_value = XMALLOC (char, add_len + orig_value_len + 1);
4886994689c1Smrg      if (to_end)
4887994689c1Smrg        {
4888994689c1Smrg          strcpy (new_value, orig_value);
4889994689c1Smrg          strcpy (new_value + orig_value_len, add);
4890994689c1Smrg        }
4891994689c1Smrg      else
4892994689c1Smrg        {
4893994689c1Smrg          strcpy (new_value, add);
4894994689c1Smrg          strcpy (new_value + add_len, orig_value);
4895994689c1Smrg        }
4896994689c1Smrg    }
4897994689c1Smrg  else
4898994689c1Smrg    {
4899994689c1Smrg      new_value = xstrdup (add);
4900994689c1Smrg    }
4901994689c1Smrg  return new_value;
4902994689c1Smrg}
49037a84e134Smrg
4904994689c1Smrgvoid
4905994689c1Smrglt_update_exe_path (const char *name, const char *value)
4906994689c1Smrg{
4907994689c1Smrg  lt_debugprintf (__FILE__, __LINE__,
4908994689c1Smrg		  "(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
4909994689c1Smrg                  nonnull (name), nonnull (value));
49107a84e134Smrg
4911994689c1Smrg  if (name && *name && value && *value)
4912994689c1Smrg    {
4913994689c1Smrg      char *new_value = lt_extend_str (getenv (name), value, 0);
4914994689c1Smrg      /* some systems can't cope with a ':'-terminated path #' */
4915994689c1Smrg      int len = strlen (new_value);
4916994689c1Smrg      while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
4917994689c1Smrg        {
4918994689c1Smrg          new_value[len-1] = '\0';
4919994689c1Smrg        }
4920994689c1Smrg      lt_setenv (name, new_value);
4921994689c1Smrg      XFREE (new_value);
4922994689c1Smrg    }
4923994689c1Smrg}
49247a84e134Smrg
4925994689c1Smrgvoid
4926994689c1Smrglt_update_lib_path (const char *name, const char *value)
4927994689c1Smrg{
4928994689c1Smrg  lt_debugprintf (__FILE__, __LINE__,
4929994689c1Smrg		  "(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
4930994689c1Smrg                  nonnull (name), nonnull (value));
49317a84e134Smrg
4932994689c1Smrg  if (name && *name && value && *value)
4933994689c1Smrg    {
4934994689c1Smrg      char *new_value = lt_extend_str (getenv (name), value, 0);
4935994689c1Smrg      lt_setenv (name, new_value);
4936994689c1Smrg      XFREE (new_value);
4937994689c1Smrg    }
4938994689c1Smrg}
49397a84e134Smrg
4940994689c1SmrgEOF
4941994689c1Smrg	    case $host_os in
4942994689c1Smrg	      mingw*)
4943994689c1Smrg		cat <<"EOF"
4944994689c1Smrg
4945994689c1Smrg/* Prepares an argument vector before calling spawn().
4946994689c1Smrg   Note that spawn() does not by itself call the command interpreter
4947994689c1Smrg     (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
4948994689c1Smrg      ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
4949994689c1Smrg         GetVersionEx(&v);
4950994689c1Smrg         v.dwPlatformId == VER_PLATFORM_WIN32_NT;
4951994689c1Smrg      }) ? "cmd.exe" : "command.com").
4952994689c1Smrg   Instead it simply concatenates the arguments, separated by ' ', and calls
4953994689c1Smrg   CreateProcess().  We must quote the arguments since Win32 CreateProcess()
4954994689c1Smrg   interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
4955994689c1Smrg   special way:
4956994689c1Smrg   - Space and tab are interpreted as delimiters. They are not treated as
4957994689c1Smrg     delimiters if they are surrounded by double quotes: "...".
4958994689c1Smrg   - Unescaped double quotes are removed from the input. Their only effect is
4959994689c1Smrg     that within double quotes, space and tab are treated like normal
4960994689c1Smrg     characters.
4961994689c1Smrg   - Backslashes not followed by double quotes are not special.
4962994689c1Smrg   - But 2*n+1 backslashes followed by a double quote become
4963994689c1Smrg     n backslashes followed by a double quote (n >= 0):
4964994689c1Smrg       \" -> "
4965994689c1Smrg       \\\" -> \"
4966994689c1Smrg       \\\\\" -> \\"
4967994689c1Smrg */
4968994689c1Smrg#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"
4969994689c1Smrg#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"
4970994689c1Smrgchar **
4971994689c1Smrgprepare_spawn (char **argv)
4972994689c1Smrg{
4973994689c1Smrg  size_t argc;
4974994689c1Smrg  char **new_argv;
4975994689c1Smrg  size_t i;
49767a84e134Smrg
4977994689c1Smrg  /* Count number of arguments.  */
4978994689c1Smrg  for (argc = 0; argv[argc] != NULL; argc++)
4979994689c1Smrg    ;
49807a84e134Smrg
4981994689c1Smrg  /* Allocate new argument vector.  */
4982994689c1Smrg  new_argv = XMALLOC (char *, argc + 1);
49837a84e134Smrg
4984994689c1Smrg  /* Put quoted arguments into the new argument vector.  */
4985994689c1Smrg  for (i = 0; i < argc; i++)
4986994689c1Smrg    {
4987994689c1Smrg      const char *string = argv[i];
4988994689c1Smrg
4989994689c1Smrg      if (string[0] == '\0')
4990994689c1Smrg	new_argv[i] = xstrdup ("\"\"");
4991994689c1Smrg      else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
4992994689c1Smrg	{
4993994689c1Smrg	  int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
4994994689c1Smrg	  size_t length;
4995994689c1Smrg	  unsigned int backslashes;
4996994689c1Smrg	  const char *s;
4997994689c1Smrg	  char *quoted_string;
4998994689c1Smrg	  char *p;
4999994689c1Smrg
5000994689c1Smrg	  length = 0;
5001994689c1Smrg	  backslashes = 0;
5002994689c1Smrg	  if (quote_around)
5003994689c1Smrg	    length++;
5004994689c1Smrg	  for (s = string; *s != '\0'; s++)
5005994689c1Smrg	    {
5006994689c1Smrg	      char c = *s;
5007994689c1Smrg	      if (c == '"')
5008994689c1Smrg		length += backslashes + 1;
5009994689c1Smrg	      length++;
5010994689c1Smrg	      if (c == '\\')
5011994689c1Smrg		backslashes++;
5012994689c1Smrg	      else
5013994689c1Smrg		backslashes = 0;
5014994689c1Smrg	    }
5015994689c1Smrg	  if (quote_around)
5016994689c1Smrg	    length += backslashes + 1;
5017994689c1Smrg
5018994689c1Smrg	  quoted_string = XMALLOC (char, length + 1);
5019994689c1Smrg
5020994689c1Smrg	  p = quoted_string;
5021994689c1Smrg	  backslashes = 0;
5022994689c1Smrg	  if (quote_around)
5023994689c1Smrg	    *p++ = '"';
5024994689c1Smrg	  for (s = string; *s != '\0'; s++)
5025994689c1Smrg	    {
5026994689c1Smrg	      char c = *s;
5027994689c1Smrg	      if (c == '"')
5028994689c1Smrg		{
5029994689c1Smrg		  unsigned int j;
5030994689c1Smrg		  for (j = backslashes + 1; j > 0; j--)
5031994689c1Smrg		    *p++ = '\\';
5032994689c1Smrg		}
5033994689c1Smrg	      *p++ = c;
5034994689c1Smrg	      if (c == '\\')
5035994689c1Smrg		backslashes++;
5036994689c1Smrg	      else
5037994689c1Smrg		backslashes = 0;
5038994689c1Smrg	    }
5039994689c1Smrg	  if (quote_around)
5040994689c1Smrg	    {
5041994689c1Smrg	      unsigned int j;
5042994689c1Smrg	      for (j = backslashes; j > 0; j--)
5043994689c1Smrg		*p++ = '\\';
5044994689c1Smrg	      *p++ = '"';
5045994689c1Smrg	    }
5046994689c1Smrg	  *p = '\0';
50477a84e134Smrg
5048994689c1Smrg	  new_argv[i] = quoted_string;
5049994689c1Smrg	}
5050994689c1Smrg      else
5051994689c1Smrg	new_argv[i] = (char *) string;
5052994689c1Smrg    }
5053994689c1Smrg  new_argv[argc] = NULL;
50547a84e134Smrg
5055994689c1Smrg  return new_argv;
5056994689c1Smrg}
5057994689c1SmrgEOF
5058e1e1713cSmrg		;;
5059994689c1Smrg	    esac
50607a84e134Smrg
5061994689c1Smrg            cat <<"EOF"
5062994689c1Smrgvoid lt_dump_script (FILE* f)
5063994689c1Smrg{
5064994689c1SmrgEOF
5065994689c1Smrg	    func_emit_wrapper yes |
5066421c997bSmrg	      $SED -n -e '
5067421c997bSmrgs/^\(.\{79\}\)\(..*\)/\1\
5068421c997bSmrg\2/
5069421c997bSmrgh
5070421c997bSmrgs/\([\\"]\)/\\\1/g
5071421c997bSmrgs/$/\\n/
5072421c997bSmrgs/\([^\n]*\).*/  fputs ("\1", f);/p
5073421c997bSmrgg
5074421c997bSmrgD'
5075994689c1Smrg            cat <<"EOF"
5076994689c1Smrg}
5077994689c1SmrgEOF
5078994689c1Smrg}
5079994689c1Smrg# end: func_emit_cwrapperexe_src
50807a84e134Smrg
5081994689c1Smrg# func_win32_import_lib_p ARG
5082994689c1Smrg# True if ARG is an import lib, as indicated by $file_magic_cmd
5083994689c1Smrgfunc_win32_import_lib_p ()
5084994689c1Smrg{
5085994689c1Smrg    $opt_debug
5086994689c1Smrg    case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
5087994689c1Smrg    *import*) : ;;
5088994689c1Smrg    *) false ;;
5089994689c1Smrg    esac
5090994689c1Smrg}
50917a84e134Smrg
5092994689c1Smrg# func_mode_link arg...
5093994689c1Smrgfunc_mode_link ()
5094994689c1Smrg{
5095994689c1Smrg    $opt_debug
5096994689c1Smrg    case $host in
5097994689c1Smrg    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
5098994689c1Smrg      # It is impossible to link a dll without this setting, and
5099994689c1Smrg      # we shouldn't force the makefile maintainer to figure out
5100994689c1Smrg      # which system we are compiling for in order to pass an extra
5101994689c1Smrg      # flag for every libtool invocation.
5102994689c1Smrg      # allow_undefined=no
51037a84e134Smrg
5104994689c1Smrg      # FIXME: Unfortunately, there are problems with the above when trying
5105994689c1Smrg      # to make a dll which has undefined symbols, in which case not
5106994689c1Smrg      # even a static library is built.  For now, we need to specify
5107994689c1Smrg      # -no-undefined on the libtool link line when we can be certain
5108994689c1Smrg      # that all symbols are satisfied, otherwise we get a static library.
5109994689c1Smrg      allow_undefined=yes
5110994689c1Smrg      ;;
5111994689c1Smrg    *)
5112994689c1Smrg      allow_undefined=yes
5113994689c1Smrg      ;;
5114994689c1Smrg    esac
5115994689c1Smrg    libtool_args=$nonopt
5116994689c1Smrg    base_compile="$nonopt $@"
5117994689c1Smrg    compile_command=$nonopt
5118994689c1Smrg    finalize_command=$nonopt
51197a84e134Smrg
5120994689c1Smrg    compile_rpath=
5121994689c1Smrg    finalize_rpath=
5122994689c1Smrg    compile_shlibpath=
5123994689c1Smrg    finalize_shlibpath=
5124994689c1Smrg    convenience=
5125994689c1Smrg    old_convenience=
5126994689c1Smrg    deplibs=
5127994689c1Smrg    old_deplibs=
5128994689c1Smrg    compiler_flags=
5129994689c1Smrg    linker_flags=
5130994689c1Smrg    dllsearchpath=
5131994689c1Smrg    lib_search_path=`pwd`
5132994689c1Smrg    inst_prefix_dir=
5133994689c1Smrg    new_inherited_linker_flags=
51347a84e134Smrg
5135994689c1Smrg    avoid_version=no
5136994689c1Smrg    bindir=
5137994689c1Smrg    dlfiles=
5138994689c1Smrg    dlprefiles=
5139994689c1Smrg    dlself=no
5140994689c1Smrg    export_dynamic=no
5141994689c1Smrg    export_symbols=
5142994689c1Smrg    export_symbols_regex=
5143994689c1Smrg    generated=
5144994689c1Smrg    libobjs=
5145994689c1Smrg    ltlibs=
5146994689c1Smrg    module=no
5147994689c1Smrg    no_install=no
5148994689c1Smrg    objs=
5149994689c1Smrg    non_pic_objects=
5150994689c1Smrg    precious_files_regex=
5151994689c1Smrg    prefer_static_libs=no
5152994689c1Smrg    preload=no
5153994689c1Smrg    prev=
5154994689c1Smrg    prevarg=
5155994689c1Smrg    release=
5156994689c1Smrg    rpath=
5157994689c1Smrg    xrpath=
5158994689c1Smrg    perm_rpath=
5159994689c1Smrg    temp_rpath=
5160994689c1Smrg    thread_safe=no
5161994689c1Smrg    vinfo=
5162994689c1Smrg    vinfo_number=no
5163994689c1Smrg    weak_libs=
5164994689c1Smrg    single_module="${wl}-single_module"
5165994689c1Smrg    func_infer_tag $base_compile
51667a84e134Smrg
5167994689c1Smrg    # We need to know -static, to get the right output filenames.
5168994689c1Smrg    for arg
5169994689c1Smrg    do
5170994689c1Smrg      case $arg in
5171994689c1Smrg      -shared)
5172994689c1Smrg	test "$build_libtool_libs" != yes && \
5173994689c1Smrg	  func_fatal_configuration "can not build a shared library"
5174994689c1Smrg	build_old_libs=no
5175994689c1Smrg	break
5176994689c1Smrg	;;
5177994689c1Smrg      -all-static | -static | -static-libtool-libs)
5178994689c1Smrg	case $arg in
5179994689c1Smrg	-all-static)
5180994689c1Smrg	  if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
5181994689c1Smrg	    func_warning "complete static linking is impossible in this configuration"
5182994689c1Smrg	  fi
5183994689c1Smrg	  if test -n "$link_static_flag"; then
5184994689c1Smrg	    dlopen_self=$dlopen_self_static
5185994689c1Smrg	  fi
5186994689c1Smrg	  prefer_static_libs=yes
5187994689c1Smrg	  ;;
5188994689c1Smrg	-static)
5189994689c1Smrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
5190994689c1Smrg	    dlopen_self=$dlopen_self_static
5191994689c1Smrg	  fi
5192994689c1Smrg	  prefer_static_libs=built
5193994689c1Smrg	  ;;
5194994689c1Smrg	-static-libtool-libs)
5195994689c1Smrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
5196994689c1Smrg	    dlopen_self=$dlopen_self_static
5197994689c1Smrg	  fi
5198994689c1Smrg	  prefer_static_libs=yes
5199994689c1Smrg	  ;;
5200994689c1Smrg	esac
5201994689c1Smrg	build_libtool_libs=no
5202994689c1Smrg	build_old_libs=yes
5203994689c1Smrg	break
5204994689c1Smrg	;;
5205994689c1Smrg      esac
5206994689c1Smrg    done
52077a84e134Smrg
5208994689c1Smrg    # See if our shared archives depend on static archives.
5209994689c1Smrg    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
52107a84e134Smrg
5211994689c1Smrg    # Go through the arguments, transforming them on the way.
5212994689c1Smrg    while test "$#" -gt 0; do
5213994689c1Smrg      arg="$1"
5214994689c1Smrg      shift
5215994689c1Smrg      func_quote_for_eval "$arg"
5216994689c1Smrg      qarg=$func_quote_for_eval_unquoted_result
5217994689c1Smrg      func_append libtool_args " $func_quote_for_eval_result"
52187a84e134Smrg
5219994689c1Smrg      # If the previous option needs an argument, assign it.
5220994689c1Smrg      if test -n "$prev"; then
5221994689c1Smrg	case $prev in
5222994689c1Smrg	output)
5223994689c1Smrg	  func_append compile_command " @OUTPUT@"
5224994689c1Smrg	  func_append finalize_command " @OUTPUT@"
5225994689c1Smrg	  ;;
5226994689c1Smrg	esac
52277a84e134Smrg
5228994689c1Smrg	case $prev in
5229994689c1Smrg	bindir)
5230994689c1Smrg	  bindir="$arg"
5231994689c1Smrg	  prev=
5232994689c1Smrg	  continue
5233994689c1Smrg	  ;;
5234994689c1Smrg	dlfiles|dlprefiles)
5235994689c1Smrg	  if test "$preload" = no; then
5236994689c1Smrg	    # Add the symbol object into the linking commands.
5237994689c1Smrg	    func_append compile_command " @SYMFILE@"
5238994689c1Smrg	    func_append finalize_command " @SYMFILE@"
5239994689c1Smrg	    preload=yes
5240e1e1713cSmrg	  fi
5241994689c1Smrg	  case $arg in
5242994689c1Smrg	  *.la | *.lo) ;;  # We handle these cases below.
5243994689c1Smrg	  force)
5244994689c1Smrg	    if test "$dlself" = no; then
5245994689c1Smrg	      dlself=needless
5246994689c1Smrg	      export_dynamic=yes
5247e1e1713cSmrg	    fi
5248994689c1Smrg	    prev=
5249994689c1Smrg	    continue
5250994689c1Smrg	    ;;
5251994689c1Smrg	  self)
5252994689c1Smrg	    if test "$prev" = dlprefiles; then
5253994689c1Smrg	      dlself=yes
5254994689c1Smrg	    elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
5255994689c1Smrg	      dlself=yes
5256e1e1713cSmrg	    else
5257994689c1Smrg	      dlself=needless
5258994689c1Smrg	      export_dynamic=yes
5259e1e1713cSmrg	    fi
5260994689c1Smrg	    prev=
5261994689c1Smrg	    continue
5262994689c1Smrg	    ;;
5263994689c1Smrg	  *)
5264994689c1Smrg	    if test "$prev" = dlfiles; then
5265f353fbadSmrg	      func_append dlfiles " $arg"
5266e1e1713cSmrg	    else
5267f353fbadSmrg	      func_append dlprefiles " $arg"
5268e1e1713cSmrg	    fi
5269994689c1Smrg	    prev=
5270994689c1Smrg	    continue
5271994689c1Smrg	    ;;
5272994689c1Smrg	  esac
5273994689c1Smrg	  ;;
5274994689c1Smrg	expsyms)
5275994689c1Smrg	  export_symbols="$arg"
5276994689c1Smrg	  test -f "$arg" \
5277994689c1Smrg	    || func_fatal_error "symbol file \`$arg' does not exist"
5278994689c1Smrg	  prev=
5279994689c1Smrg	  continue
5280994689c1Smrg	  ;;
5281994689c1Smrg	expsyms_regex)
5282994689c1Smrg	  export_symbols_regex="$arg"
5283994689c1Smrg	  prev=
5284994689c1Smrg	  continue
5285994689c1Smrg	  ;;
5286994689c1Smrg	framework)
5287e1e1713cSmrg	  case $host in
5288994689c1Smrg	    *-*-darwin*)
5289994689c1Smrg	      case "$deplibs " in
5290994689c1Smrg		*" $qarg.ltframework "*) ;;
5291f353fbadSmrg		*) func_append deplibs " $qarg.ltframework" # this is fixed later
5292994689c1Smrg		   ;;
5293994689c1Smrg	      esac
5294994689c1Smrg	      ;;
5295e1e1713cSmrg	  esac
5296994689c1Smrg	  prev=
5297994689c1Smrg	  continue
5298e1e1713cSmrg	  ;;
5299994689c1Smrg	inst_prefix)
5300994689c1Smrg	  inst_prefix_dir="$arg"
5301994689c1Smrg	  prev=
5302994689c1Smrg	  continue
5303e1e1713cSmrg	  ;;
5304994689c1Smrg	objectlist)
5305994689c1Smrg	  if test -f "$arg"; then
5306994689c1Smrg	    save_arg=$arg
5307994689c1Smrg	    moreargs=
5308994689c1Smrg	    for fil in `cat "$save_arg"`
5309994689c1Smrg	    do
5310f353fbadSmrg#	      func_append moreargs " $fil"
5311994689c1Smrg	      arg=$fil
5312994689c1Smrg	      # A libtool-controlled object.
53137a84e134Smrg
5314994689c1Smrg	      # Check to see that this really is a libtool object.
5315994689c1Smrg	      if func_lalib_unsafe_p "$arg"; then
5316994689c1Smrg		pic_object=
5317994689c1Smrg		non_pic_object=
5318775e7de9Smrg
5319994689c1Smrg		# Read the .lo file
5320994689c1Smrg		func_source "$arg"
5321775e7de9Smrg
5322994689c1Smrg		if test -z "$pic_object" ||
5323994689c1Smrg		   test -z "$non_pic_object" ||
5324994689c1Smrg		   test "$pic_object" = none &&
5325994689c1Smrg		   test "$non_pic_object" = none; then
5326994689c1Smrg		  func_fatal_error "cannot find name of object for \`$arg'"
5327994689c1Smrg		fi
5328775e7de9Smrg
5329994689c1Smrg		# Extract subdirectory from the argument.
5330994689c1Smrg		func_dirname "$arg" "/" ""
5331994689c1Smrg		xdir="$func_dirname_result"
5332775e7de9Smrg
5333994689c1Smrg		if test "$pic_object" != none; then
5334994689c1Smrg		  # Prepend the subdirectory the object is found in.
5335994689c1Smrg		  pic_object="$xdir$pic_object"
5336775e7de9Smrg
5337994689c1Smrg		  if test "$prev" = dlfiles; then
5338994689c1Smrg		    if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
5339f353fbadSmrg		      func_append dlfiles " $pic_object"
5340994689c1Smrg		      prev=
5341994689c1Smrg		      continue
5342994689c1Smrg		    else
5343994689c1Smrg		      # If libtool objects are unsupported, then we need to preload.
5344994689c1Smrg		      prev=dlprefiles
5345994689c1Smrg		    fi
5346994689c1Smrg		  fi
5347775e7de9Smrg
5348994689c1Smrg		  # CHECK ME:  I think I busted this.  -Ossama
5349994689c1Smrg		  if test "$prev" = dlprefiles; then
5350994689c1Smrg		    # Preload the old-style object.
5351f353fbadSmrg		    func_append dlprefiles " $pic_object"
5352994689c1Smrg		    prev=
5353994689c1Smrg		  fi
5354775e7de9Smrg
5355994689c1Smrg		  # A PIC object.
5356994689c1Smrg		  func_append libobjs " $pic_object"
5357994689c1Smrg		  arg="$pic_object"
5358994689c1Smrg		fi
5359775e7de9Smrg
5360994689c1Smrg		# Non-PIC object.
5361994689c1Smrg		if test "$non_pic_object" != none; then
5362994689c1Smrg		  # Prepend the subdirectory the object is found in.
5363994689c1Smrg		  non_pic_object="$xdir$non_pic_object"
5364775e7de9Smrg
5365994689c1Smrg		  # A standard non-PIC object
5366994689c1Smrg		  func_append non_pic_objects " $non_pic_object"
5367994689c1Smrg		  if test -z "$pic_object" || test "$pic_object" = none ; then
5368994689c1Smrg		    arg="$non_pic_object"
5369994689c1Smrg		  fi
5370994689c1Smrg		else
5371994689c1Smrg		  # If the PIC object exists, use it instead.
5372994689c1Smrg		  # $xdir was prepended to $pic_object above.
5373994689c1Smrg		  non_pic_object="$pic_object"
5374994689c1Smrg		  func_append non_pic_objects " $non_pic_object"
5375994689c1Smrg		fi
5376994689c1Smrg	      else
5377994689c1Smrg		# Only an error if not doing a dry-run.
5378994689c1Smrg		if $opt_dry_run; then
5379994689c1Smrg		  # Extract subdirectory from the argument.
5380994689c1Smrg		  func_dirname "$arg" "/" ""
5381994689c1Smrg		  xdir="$func_dirname_result"
5382994689c1Smrg
5383994689c1Smrg		  func_lo2o "$arg"
5384994689c1Smrg		  pic_object=$xdir$objdir/$func_lo2o_result
5385994689c1Smrg		  non_pic_object=$xdir$func_lo2o_result
5386994689c1Smrg		  func_append libobjs " $pic_object"
5387994689c1Smrg		  func_append non_pic_objects " $non_pic_object"
5388994689c1Smrg	        else
5389994689c1Smrg		  func_fatal_error "\`$arg' is not a valid libtool object"
5390994689c1Smrg		fi
5391994689c1Smrg	      fi
5392994689c1Smrg	    done
5393e1e1713cSmrg	  else
5394994689c1Smrg	    func_fatal_error "link input file \`$arg' does not exist"
5395e1e1713cSmrg	  fi
5396994689c1Smrg	  arg=$save_arg
5397994689c1Smrg	  prev=
5398994689c1Smrg	  continue
5399994689c1Smrg	  ;;
5400994689c1Smrg	precious_regex)
5401994689c1Smrg	  precious_files_regex="$arg"
5402994689c1Smrg	  prev=
5403994689c1Smrg	  continue
5404994689c1Smrg	  ;;
5405994689c1Smrg	release)
5406994689c1Smrg	  release="-$arg"
5407994689c1Smrg	  prev=
5408994689c1Smrg	  continue
5409994689c1Smrg	  ;;
5410994689c1Smrg	rpath | xrpath)
5411994689c1Smrg	  # We need an absolute path.
5412994689c1Smrg	  case $arg in
5413994689c1Smrg	  [\\/]* | [A-Za-z]:[\\/]*) ;;
5414994689c1Smrg	  *)
5415994689c1Smrg	    func_fatal_error "only absolute run-paths are allowed"
5416994689c1Smrg	    ;;
5417994689c1Smrg	  esac
5418994689c1Smrg	  if test "$prev" = rpath; then
5419994689c1Smrg	    case "$rpath " in
5420994689c1Smrg	    *" $arg "*) ;;
5421f353fbadSmrg	    *) func_append rpath " $arg" ;;
5422994689c1Smrg	    esac
5423e1e1713cSmrg	  else
5424994689c1Smrg	    case "$xrpath " in
5425994689c1Smrg	    *" $arg "*) ;;
5426f353fbadSmrg	    *) func_append xrpath " $arg" ;;
5427994689c1Smrg	    esac
5428e1e1713cSmrg	  fi
5429994689c1Smrg	  prev=
5430994689c1Smrg	  continue
5431994689c1Smrg	  ;;
5432994689c1Smrg	shrext)
5433994689c1Smrg	  shrext_cmds="$arg"
5434994689c1Smrg	  prev=
5435994689c1Smrg	  continue
5436994689c1Smrg	  ;;
5437994689c1Smrg	weak)
5438f353fbadSmrg	  func_append weak_libs " $arg"
5439994689c1Smrg	  prev=
5440994689c1Smrg	  continue
5441994689c1Smrg	  ;;
5442994689c1Smrg	xcclinker)
5443f353fbadSmrg	  func_append linker_flags " $qarg"
5444f353fbadSmrg	  func_append compiler_flags " $qarg"
5445994689c1Smrg	  prev=
5446994689c1Smrg	  func_append compile_command " $qarg"
5447994689c1Smrg	  func_append finalize_command " $qarg"
5448994689c1Smrg	  continue
5449994689c1Smrg	  ;;
5450994689c1Smrg	xcompiler)
5451f353fbadSmrg	  func_append compiler_flags " $qarg"
5452994689c1Smrg	  prev=
5453994689c1Smrg	  func_append compile_command " $qarg"
5454994689c1Smrg	  func_append finalize_command " $qarg"
5455994689c1Smrg	  continue
5456994689c1Smrg	  ;;
5457994689c1Smrg	xlinker)
5458f353fbadSmrg	  func_append linker_flags " $qarg"
5459f353fbadSmrg	  func_append compiler_flags " $wl$qarg"
5460994689c1Smrg	  prev=
5461994689c1Smrg	  func_append compile_command " $wl$qarg"
5462994689c1Smrg	  func_append finalize_command " $wl$qarg"
5463994689c1Smrg	  continue
5464994689c1Smrg	  ;;
5465994689c1Smrg	*)
5466994689c1Smrg	  eval "$prev=\"\$arg\""
5467994689c1Smrg	  prev=
5468994689c1Smrg	  continue
5469994689c1Smrg	  ;;
5470775e7de9Smrg	esac
5471994689c1Smrg      fi # test -n "$prev"
5472775e7de9Smrg
5473994689c1Smrg      prevarg="$arg"
5474775e7de9Smrg
5475994689c1Smrg      case $arg in
5476994689c1Smrg      -all-static)
5477994689c1Smrg	if test -n "$link_static_flag"; then
5478994689c1Smrg	  # See comment for -static flag below, for more details.
5479994689c1Smrg	  func_append compile_command " $link_static_flag"
5480994689c1Smrg	  func_append finalize_command " $link_static_flag"
5481994689c1Smrg	fi
5482994689c1Smrg	continue
5483994689c1Smrg	;;
5484775e7de9Smrg
5485994689c1Smrg      -allow-undefined)
5486994689c1Smrg	# FIXME: remove this flag sometime in the future.
5487994689c1Smrg	func_fatal_error "\`-allow-undefined' must not be used because it is the default"
5488994689c1Smrg	;;
5489775e7de9Smrg
5490994689c1Smrg      -avoid-version)
5491994689c1Smrg	avoid_version=yes
5492994689c1Smrg	continue
5493994689c1Smrg	;;
5494775e7de9Smrg
5495994689c1Smrg      -bindir)
5496994689c1Smrg	prev=bindir
5497994689c1Smrg	continue
5498994689c1Smrg	;;
5499775e7de9Smrg
5500994689c1Smrg      -dlopen)
5501994689c1Smrg	prev=dlfiles
5502994689c1Smrg	continue
5503994689c1Smrg	;;
5504775e7de9Smrg
5505994689c1Smrg      -dlpreopen)
5506994689c1Smrg	prev=dlprefiles
5507994689c1Smrg	continue
5508994689c1Smrg	;;
5509775e7de9Smrg
5510994689c1Smrg      -export-dynamic)
5511994689c1Smrg	export_dynamic=yes
5512994689c1Smrg	continue
5513994689c1Smrg	;;
5514775e7de9Smrg
5515994689c1Smrg      -export-symbols | -export-symbols-regex)
5516994689c1Smrg	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
5517994689c1Smrg	  func_fatal_error "more than one -exported-symbols argument is not allowed"
5518994689c1Smrg	fi
5519994689c1Smrg	if test "X$arg" = "X-export-symbols"; then
5520994689c1Smrg	  prev=expsyms
5521994689c1Smrg	else
5522994689c1Smrg	  prev=expsyms_regex
5523994689c1Smrg	fi
5524994689c1Smrg	continue
5525994689c1Smrg	;;
5526775e7de9Smrg
5527994689c1Smrg      -framework)
5528994689c1Smrg	prev=framework
5529994689c1Smrg	continue
5530994689c1Smrg	;;
5531775e7de9Smrg
5532994689c1Smrg      -inst-prefix-dir)
5533994689c1Smrg	prev=inst_prefix
5534994689c1Smrg	continue
5535994689c1Smrg	;;
5536775e7de9Smrg
5537994689c1Smrg      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
5538994689c1Smrg      # so, if we see these flags be careful not to treat them like -L
5539994689c1Smrg      -L[A-Z][A-Z]*:*)
5540994689c1Smrg	case $with_gcc/$host in
5541994689c1Smrg	no/*-*-irix* | /*-*-irix*)
5542994689c1Smrg	  func_append compile_command " $arg"
5543994689c1Smrg	  func_append finalize_command " $arg"
5544994689c1Smrg	  ;;
5545994689c1Smrg	esac
5546994689c1Smrg	continue
5547994689c1Smrg	;;
5548775e7de9Smrg
5549994689c1Smrg      -L*)
5550f353fbadSmrg	func_stripname "-L" '' "$arg"
5551f353fbadSmrg	if test -z "$func_stripname_result"; then
5552994689c1Smrg	  if test "$#" -gt 0; then
5553994689c1Smrg	    func_fatal_error "require no space between \`-L' and \`$1'"
5554994689c1Smrg	  else
5555994689c1Smrg	    func_fatal_error "need path for \`-L' option"
5556994689c1Smrg	  fi
5557994689c1Smrg	fi
5558f353fbadSmrg	func_resolve_sysroot "$func_stripname_result"
5559f353fbadSmrg	dir=$func_resolve_sysroot_result
5560994689c1Smrg	# We need an absolute path.
5561994689c1Smrg	case $dir in
5562994689c1Smrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
5563994689c1Smrg	*)
5564994689c1Smrg	  absdir=`cd "$dir" && pwd`
5565994689c1Smrg	  test -z "$absdir" && \
5566994689c1Smrg	    func_fatal_error "cannot determine absolute directory name of \`$dir'"
5567994689c1Smrg	  dir="$absdir"
5568994689c1Smrg	  ;;
5569994689c1Smrg	esac
5570994689c1Smrg	case "$deplibs " in
5571f353fbadSmrg	*" -L$dir "* | *" $arg "*)
5572f353fbadSmrg	  # Will only happen for absolute or sysroot arguments
5573f353fbadSmrg	  ;;
5574994689c1Smrg	*)
5575f353fbadSmrg	  # Preserve sysroot, but never include relative directories
5576f353fbadSmrg	  case $dir in
5577f353fbadSmrg	    [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;;
5578f353fbadSmrg	    *) func_append deplibs " -L$dir" ;;
5579f353fbadSmrg	  esac
5580f353fbadSmrg	  func_append lib_search_path " $dir"
5581994689c1Smrg	  ;;
5582994689c1Smrg	esac
5583994689c1Smrg	case $host in
5584994689c1Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
5585994689c1Smrg	  testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
5586994689c1Smrg	  case :$dllsearchpath: in
5587994689c1Smrg	  *":$dir:"*) ;;
5588994689c1Smrg	  ::) dllsearchpath=$dir;;
5589f353fbadSmrg	  *) func_append dllsearchpath ":$dir";;
5590994689c1Smrg	  esac
5591994689c1Smrg	  case :$dllsearchpath: in
5592994689c1Smrg	  *":$testbindir:"*) ;;
5593994689c1Smrg	  ::) dllsearchpath=$testbindir;;
5594f353fbadSmrg	  *) func_append dllsearchpath ":$testbindir";;
5595994689c1Smrg	  esac
5596994689c1Smrg	  ;;
5597994689c1Smrg	esac
5598994689c1Smrg	continue
5599994689c1Smrg	;;
5600775e7de9Smrg
5601994689c1Smrg      -l*)
5602994689c1Smrg	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
5603994689c1Smrg	  case $host in
5604994689c1Smrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
5605994689c1Smrg	    # These systems don't actually have a C or math library (as such)
5606994689c1Smrg	    continue
5607994689c1Smrg	    ;;
5608994689c1Smrg	  *-*-os2*)
5609994689c1Smrg	    # These systems don't actually have a C library (as such)
5610994689c1Smrg	    test "X$arg" = "X-lc" && continue
5611994689c1Smrg	    ;;
5612994689c1Smrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
5613994689c1Smrg	    # Do not include libc due to us having libc/libc_r.
5614994689c1Smrg	    test "X$arg" = "X-lc" && continue
5615994689c1Smrg	    ;;
5616994689c1Smrg	  *-*-rhapsody* | *-*-darwin1.[012])
5617994689c1Smrg	    # Rhapsody C and math libraries are in the System framework
5618f353fbadSmrg	    func_append deplibs " System.ltframework"
5619994689c1Smrg	    continue
5620994689c1Smrg	    ;;
5621994689c1Smrg	  *-*-sco3.2v5* | *-*-sco5v6*)
5622994689c1Smrg	    # Causes problems with __ctype
5623994689c1Smrg	    test "X$arg" = "X-lc" && continue
5624994689c1Smrg	    ;;
5625994689c1Smrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
5626994689c1Smrg	    # Compiler inserts libc in the correct place for threads to work
5627994689c1Smrg	    test "X$arg" = "X-lc" && continue
5628994689c1Smrg	    ;;
5629994689c1Smrg	  esac
5630994689c1Smrg	elif test "X$arg" = "X-lc_r"; then
5631994689c1Smrg	 case $host in
5632994689c1Smrg	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
5633994689c1Smrg	   # Do not include libc_r directly, use -pthread flag.
5634994689c1Smrg	   continue
5635994689c1Smrg	   ;;
5636994689c1Smrg	 esac
5637994689c1Smrg	fi
5638f353fbadSmrg	func_append deplibs " $arg"
5639994689c1Smrg	continue
5640994689c1Smrg	;;
5641775e7de9Smrg
5642994689c1Smrg      -module)
5643994689c1Smrg	module=yes
5644994689c1Smrg	continue
5645994689c1Smrg	;;
5646775e7de9Smrg
5647994689c1Smrg      # Tru64 UNIX uses -model [arg] to determine the layout of C++
5648994689c1Smrg      # classes, name mangling, and exception handling.
5649994689c1Smrg      # Darwin uses the -arch flag to determine output architecture.
5650f353fbadSmrg      -model|-arch|-isysroot|--sysroot)
5651f353fbadSmrg	func_append compiler_flags " $arg"
5652994689c1Smrg	func_append compile_command " $arg"
5653994689c1Smrg	func_append finalize_command " $arg"
5654994689c1Smrg	prev=xcompiler
5655994689c1Smrg	continue
5656994689c1Smrg	;;
5657775e7de9Smrg
5658421c997bSmrg      -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
5659421c997bSmrg      |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
5660f353fbadSmrg	func_append compiler_flags " $arg"
5661994689c1Smrg	func_append compile_command " $arg"
5662994689c1Smrg	func_append finalize_command " $arg"
5663994689c1Smrg	case "$new_inherited_linker_flags " in
5664994689c1Smrg	    *" $arg "*) ;;
5665f353fbadSmrg	    * ) func_append new_inherited_linker_flags " $arg" ;;
5666994689c1Smrg	esac
5667994689c1Smrg	continue
5668994689c1Smrg	;;
5669775e7de9Smrg
5670994689c1Smrg      -multi_module)
5671994689c1Smrg	single_module="${wl}-multi_module"
5672994689c1Smrg	continue
5673994689c1Smrg	;;
5674775e7de9Smrg
5675994689c1Smrg      -no-fast-install)
5676994689c1Smrg	fast_install=no
5677994689c1Smrg	continue
5678994689c1Smrg	;;
5679775e7de9Smrg
5680994689c1Smrg      -no-install)
5681994689c1Smrg	case $host in
5682994689c1Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
5683994689c1Smrg	  # The PATH hackery in wrapper scripts is required on Windows
5684994689c1Smrg	  # and Darwin in order for the loader to find any dlls it needs.
5685994689c1Smrg	  func_warning "\`-no-install' is ignored for $host"
5686994689c1Smrg	  func_warning "assuming \`-no-fast-install' instead"
5687994689c1Smrg	  fast_install=no
5688994689c1Smrg	  ;;
5689994689c1Smrg	*) no_install=yes ;;
5690994689c1Smrg	esac
5691994689c1Smrg	continue
5692994689c1Smrg	;;
5693775e7de9Smrg
5694994689c1Smrg      -no-undefined)
5695994689c1Smrg	allow_undefined=no
5696994689c1Smrg	continue
5697994689c1Smrg	;;
5698775e7de9Smrg
5699994689c1Smrg      -objectlist)
5700994689c1Smrg	prev=objectlist
5701994689c1Smrg	continue
5702994689c1Smrg	;;
5703775e7de9Smrg
5704994689c1Smrg      -o) prev=output ;;
5705775e7de9Smrg
5706994689c1Smrg      -precious-files-regex)
5707994689c1Smrg	prev=precious_regex
5708994689c1Smrg	continue
5709994689c1Smrg	;;
5710775e7de9Smrg
5711994689c1Smrg      -release)
5712994689c1Smrg	prev=release
5713994689c1Smrg	continue
5714994689c1Smrg	;;
5715775e7de9Smrg
5716994689c1Smrg      -rpath)
5717994689c1Smrg	prev=rpath
5718994689c1Smrg	continue
5719994689c1Smrg	;;
5720775e7de9Smrg
5721994689c1Smrg      -R)
5722994689c1Smrg	prev=xrpath
5723994689c1Smrg	continue
5724994689c1Smrg	;;
5725775e7de9Smrg
5726994689c1Smrg      -R*)
5727994689c1Smrg	func_stripname '-R' '' "$arg"
5728994689c1Smrg	dir=$func_stripname_result
5729994689c1Smrg	# We need an absolute path.
5730994689c1Smrg	case $dir in
5731994689c1Smrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
5732f353fbadSmrg	=*)
5733f353fbadSmrg	  func_stripname '=' '' "$dir"
5734f353fbadSmrg	  dir=$lt_sysroot$func_stripname_result
5735f353fbadSmrg	  ;;
5736994689c1Smrg	*)
5737994689c1Smrg	  func_fatal_error "only absolute run-paths are allowed"
5738994689c1Smrg	  ;;
5739994689c1Smrg	esac
5740994689c1Smrg	case "$xrpath " in
5741994689c1Smrg	*" $dir "*) ;;
5742f353fbadSmrg	*) func_append xrpath " $dir" ;;
5743994689c1Smrg	esac
5744994689c1Smrg	continue
5745994689c1Smrg	;;
5746775e7de9Smrg
5747994689c1Smrg      -shared)
5748994689c1Smrg	# The effects of -shared are defined in a previous loop.
5749994689c1Smrg	continue
5750994689c1Smrg	;;
5751775e7de9Smrg
5752994689c1Smrg      -shrext)
5753994689c1Smrg	prev=shrext
5754994689c1Smrg	continue
5755994689c1Smrg	;;
5756775e7de9Smrg
5757994689c1Smrg      -static | -static-libtool-libs)
5758994689c1Smrg	# The effects of -static are defined in a previous loop.
5759994689c1Smrg	# We used to do the same as -all-static on platforms that
5760994689c1Smrg	# didn't have a PIC flag, but the assumption that the effects
5761994689c1Smrg	# would be equivalent was wrong.  It would break on at least
5762994689c1Smrg	# Digital Unix and AIX.
5763994689c1Smrg	continue
5764994689c1Smrg	;;
5765775e7de9Smrg
5766994689c1Smrg      -thread-safe)
5767994689c1Smrg	thread_safe=yes
5768994689c1Smrg	continue
5769994689c1Smrg	;;
5770775e7de9Smrg
5771994689c1Smrg      -version-info)
5772994689c1Smrg	prev=vinfo
5773994689c1Smrg	continue
5774994689c1Smrg	;;
5775775e7de9Smrg
5776994689c1Smrg      -version-number)
5777994689c1Smrg	prev=vinfo
5778994689c1Smrg	vinfo_number=yes
5779994689c1Smrg	continue
5780994689c1Smrg	;;
57817a84e134Smrg
5782994689c1Smrg      -weak)
5783994689c1Smrg        prev=weak
5784994689c1Smrg	continue
5785994689c1Smrg	;;
5786e1e1713cSmrg
5787994689c1Smrg      -Wc,*)
5788994689c1Smrg	func_stripname '-Wc,' '' "$arg"
5789994689c1Smrg	args=$func_stripname_result
5790994689c1Smrg	arg=
5791994689c1Smrg	save_ifs="$IFS"; IFS=','
5792994689c1Smrg	for flag in $args; do
5793994689c1Smrg	  IFS="$save_ifs"
5794994689c1Smrg          func_quote_for_eval "$flag"
5795f353fbadSmrg	  func_append arg " $func_quote_for_eval_result"
5796f353fbadSmrg	  func_append compiler_flags " $func_quote_for_eval_result"
5797994689c1Smrg	done
5798994689c1Smrg	IFS="$save_ifs"
5799994689c1Smrg	func_stripname ' ' '' "$arg"
5800994689c1Smrg	arg=$func_stripname_result
5801994689c1Smrg	;;
5802e1e1713cSmrg
5803994689c1Smrg      -Wl,*)
5804994689c1Smrg	func_stripname '-Wl,' '' "$arg"
5805994689c1Smrg	args=$func_stripname_result
5806994689c1Smrg	arg=
5807994689c1Smrg	save_ifs="$IFS"; IFS=','
5808994689c1Smrg	for flag in $args; do
5809994689c1Smrg	  IFS="$save_ifs"
5810994689c1Smrg          func_quote_for_eval "$flag"
5811f353fbadSmrg	  func_append arg " $wl$func_quote_for_eval_result"
5812f353fbadSmrg	  func_append compiler_flags " $wl$func_quote_for_eval_result"
5813f353fbadSmrg	  func_append linker_flags " $func_quote_for_eval_result"
5814994689c1Smrg	done
5815994689c1Smrg	IFS="$save_ifs"
5816994689c1Smrg	func_stripname ' ' '' "$arg"
5817994689c1Smrg	arg=$func_stripname_result
5818994689c1Smrg	;;
5819e1e1713cSmrg
5820994689c1Smrg      -Xcompiler)
5821994689c1Smrg	prev=xcompiler
5822994689c1Smrg	continue
5823994689c1Smrg	;;
5824e1e1713cSmrg
5825994689c1Smrg      -Xlinker)
5826994689c1Smrg	prev=xlinker
5827994689c1Smrg	continue
5828994689c1Smrg	;;
5829e1e1713cSmrg
5830994689c1Smrg      -XCClinker)
5831994689c1Smrg	prev=xcclinker
5832994689c1Smrg	continue
5833994689c1Smrg	;;
5834e1e1713cSmrg
5835994689c1Smrg      # -msg_* for osf cc
5836994689c1Smrg      -msg_*)
5837994689c1Smrg	func_quote_for_eval "$arg"
5838994689c1Smrg	arg="$func_quote_for_eval_result"
5839994689c1Smrg	;;
5840e1e1713cSmrg
5841994689c1Smrg      # Flags to be passed through unchanged, with rationale:
5842994689c1Smrg      # -64, -mips[0-9]      enable 64-bit mode for the SGI compiler
5843994689c1Smrg      # -r[0-9][0-9]*        specify processor for the SGI compiler
5844994689c1Smrg      # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler
5845994689c1Smrg      # +DA*, +DD*           enable 64-bit mode for the HP compiler
5846994689c1Smrg      # -q*                  compiler args for the IBM compiler
5847994689c1Smrg      # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
5848994689c1Smrg      # -F/path              path to uninstalled frameworks, gcc on darwin
5849994689c1Smrg      # -p, -pg, --coverage, -fprofile-*  profiling flags for GCC
5850994689c1Smrg      # @file                GCC response files
5851994689c1Smrg      # -tp=*                Portland pgcc target processor selection
5852f353fbadSmrg      # --sysroot=*          for sysroot support
5853f353fbadSmrg      # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
5854994689c1Smrg      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
5855f353fbadSmrg      -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
5856f353fbadSmrg      -O*|-flto*|-fwhopr*|-fuse-linker-plugin)
5857994689c1Smrg        func_quote_for_eval "$arg"
5858994689c1Smrg	arg="$func_quote_for_eval_result"
5859994689c1Smrg        func_append compile_command " $arg"
5860994689c1Smrg        func_append finalize_command " $arg"
5861f353fbadSmrg        func_append compiler_flags " $arg"
5862994689c1Smrg        continue
5863994689c1Smrg        ;;
5864e1e1713cSmrg
5865994689c1Smrg      # Some other compiler flag.
5866994689c1Smrg      -* | +*)
5867994689c1Smrg        func_quote_for_eval "$arg"
5868994689c1Smrg	arg="$func_quote_for_eval_result"
5869994689c1Smrg	;;
5870e1e1713cSmrg
5871994689c1Smrg      *.$objext)
5872994689c1Smrg	# A standard object.
5873f353fbadSmrg	func_append objs " $arg"
5874994689c1Smrg	;;
5875e1e1713cSmrg
5876994689c1Smrg      *.lo)
5877994689c1Smrg	# A libtool-controlled object.
5878e1e1713cSmrg
5879994689c1Smrg	# Check to see that this really is a libtool object.
5880994689c1Smrg	if func_lalib_unsafe_p "$arg"; then
5881994689c1Smrg	  pic_object=
5882994689c1Smrg	  non_pic_object=
5883e1e1713cSmrg
5884994689c1Smrg	  # Read the .lo file
5885994689c1Smrg	  func_source "$arg"
5886e1e1713cSmrg
5887994689c1Smrg	  if test -z "$pic_object" ||
5888994689c1Smrg	     test -z "$non_pic_object" ||
5889994689c1Smrg	     test "$pic_object" = none &&
5890994689c1Smrg	     test "$non_pic_object" = none; then
5891994689c1Smrg	    func_fatal_error "cannot find name of object for \`$arg'"
5892994689c1Smrg	  fi
5893e1e1713cSmrg
5894994689c1Smrg	  # Extract subdirectory from the argument.
5895994689c1Smrg	  func_dirname "$arg" "/" ""
5896994689c1Smrg	  xdir="$func_dirname_result"
5897e1e1713cSmrg
5898994689c1Smrg	  if test "$pic_object" != none; then
5899994689c1Smrg	    # Prepend the subdirectory the object is found in.
5900994689c1Smrg	    pic_object="$xdir$pic_object"
5901e1e1713cSmrg
5902994689c1Smrg	    if test "$prev" = dlfiles; then
5903994689c1Smrg	      if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
5904f353fbadSmrg		func_append dlfiles " $pic_object"
5905994689c1Smrg		prev=
5906994689c1Smrg		continue
5907994689c1Smrg	      else
5908994689c1Smrg		# If libtool objects are unsupported, then we need to preload.
5909994689c1Smrg		prev=dlprefiles
5910994689c1Smrg	      fi
5911994689c1Smrg	    fi
5912994689c1Smrg
5913994689c1Smrg	    # CHECK ME:  I think I busted this.  -Ossama
5914994689c1Smrg	    if test "$prev" = dlprefiles; then
5915994689c1Smrg	      # Preload the old-style object.
5916f353fbadSmrg	      func_append dlprefiles " $pic_object"
5917994689c1Smrg	      prev=
5918994689c1Smrg	    fi
5919994689c1Smrg
5920994689c1Smrg	    # A PIC object.
5921994689c1Smrg	    func_append libobjs " $pic_object"
5922994689c1Smrg	    arg="$pic_object"
5923994689c1Smrg	  fi
5924994689c1Smrg
5925994689c1Smrg	  # Non-PIC object.
5926994689c1Smrg	  if test "$non_pic_object" != none; then
5927994689c1Smrg	    # Prepend the subdirectory the object is found in.
5928994689c1Smrg	    non_pic_object="$xdir$non_pic_object"
5929994689c1Smrg
5930994689c1Smrg	    # A standard non-PIC object
5931994689c1Smrg	    func_append non_pic_objects " $non_pic_object"
5932994689c1Smrg	    if test -z "$pic_object" || test "$pic_object" = none ; then
5933994689c1Smrg	      arg="$non_pic_object"
5934994689c1Smrg	    fi
5935994689c1Smrg	  else
5936994689c1Smrg	    # If the PIC object exists, use it instead.
5937994689c1Smrg	    # $xdir was prepended to $pic_object above.
5938994689c1Smrg	    non_pic_object="$pic_object"
5939994689c1Smrg	    func_append non_pic_objects " $non_pic_object"
5940994689c1Smrg	  fi
5941994689c1Smrg	else
5942994689c1Smrg	  # Only an error if not doing a dry-run.
5943994689c1Smrg	  if $opt_dry_run; then
5944994689c1Smrg	    # Extract subdirectory from the argument.
5945994689c1Smrg	    func_dirname "$arg" "/" ""
5946994689c1Smrg	    xdir="$func_dirname_result"
5947994689c1Smrg
5948994689c1Smrg	    func_lo2o "$arg"
5949994689c1Smrg	    pic_object=$xdir$objdir/$func_lo2o_result
5950994689c1Smrg	    non_pic_object=$xdir$func_lo2o_result
5951994689c1Smrg	    func_append libobjs " $pic_object"
5952994689c1Smrg	    func_append non_pic_objects " $non_pic_object"
5953994689c1Smrg	  else
5954994689c1Smrg	    func_fatal_error "\`$arg' is not a valid libtool object"
5955994689c1Smrg	  fi
5956994689c1Smrg	fi
5957994689c1Smrg	;;
5958994689c1Smrg
5959994689c1Smrg      *.$libext)
5960994689c1Smrg	# An archive.
5961f353fbadSmrg	func_append deplibs " $arg"
5962f353fbadSmrg	func_append old_deplibs " $arg"
5963994689c1Smrg	continue
5964994689c1Smrg	;;
5965994689c1Smrg
5966994689c1Smrg      *.la)
5967994689c1Smrg	# A libtool-controlled library.
5968994689c1Smrg
5969f353fbadSmrg	func_resolve_sysroot "$arg"
5970994689c1Smrg	if test "$prev" = dlfiles; then
5971994689c1Smrg	  # This library was specified with -dlopen.
5972f353fbadSmrg	  func_append dlfiles " $func_resolve_sysroot_result"
5973994689c1Smrg	  prev=
5974994689c1Smrg	elif test "$prev" = dlprefiles; then
5975994689c1Smrg	  # The library was specified with -dlpreopen.
5976f353fbadSmrg	  func_append dlprefiles " $func_resolve_sysroot_result"
5977994689c1Smrg	  prev=
5978994689c1Smrg	else
5979f353fbadSmrg	  func_append deplibs " $func_resolve_sysroot_result"
5980994689c1Smrg	fi
5981994689c1Smrg	continue
5982994689c1Smrg	;;
5983994689c1Smrg
5984994689c1Smrg      # Some other compiler argument.
5985994689c1Smrg      *)
5986994689c1Smrg	# Unknown arguments in both finalize_command and compile_command need
5987994689c1Smrg	# to be aesthetically quoted because they are evaled later.
5988994689c1Smrg	func_quote_for_eval "$arg"
5989994689c1Smrg	arg="$func_quote_for_eval_result"
5990994689c1Smrg	;;
5991994689c1Smrg      esac # arg
5992994689c1Smrg
5993994689c1Smrg      # Now actually substitute the argument into the commands.
5994994689c1Smrg      if test -n "$arg"; then
5995994689c1Smrg	func_append compile_command " $arg"
5996994689c1Smrg	func_append finalize_command " $arg"
5997994689c1Smrg      fi
5998994689c1Smrg    done # argument parsing loop
5999994689c1Smrg
6000994689c1Smrg    test -n "$prev" && \
6001994689c1Smrg      func_fatal_help "the \`$prevarg' option requires an argument"
6002994689c1Smrg
6003994689c1Smrg    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
6004994689c1Smrg      eval arg=\"$export_dynamic_flag_spec\"
6005994689c1Smrg      func_append compile_command " $arg"
6006994689c1Smrg      func_append finalize_command " $arg"
6007994689c1Smrg    fi
6008994689c1Smrg
6009994689c1Smrg    oldlibs=
6010994689c1Smrg    # calculate the name of the file, without its directory
6011994689c1Smrg    func_basename "$output"
6012994689c1Smrg    outputname="$func_basename_result"
6013994689c1Smrg    libobjs_save="$libobjs"
6014994689c1Smrg
6015994689c1Smrg    if test -n "$shlibpath_var"; then
6016994689c1Smrg      # get the directories listed in $shlibpath_var
6017994689c1Smrg      eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\`
6018e1e1713cSmrg    else
6019994689c1Smrg      shlib_search_path=
6020e1e1713cSmrg    fi
6021994689c1Smrg    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
6022994689c1Smrg    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
60237a84e134Smrg
6024994689c1Smrg    func_dirname "$output" "/" ""
6025994689c1Smrg    output_objdir="$func_dirname_result$objdir"
6026f353fbadSmrg    func_to_tool_file "$output_objdir/"
6027f353fbadSmrg    tool_output_objdir=$func_to_tool_file_result
6028994689c1Smrg    # Create the object directory.
6029994689c1Smrg    func_mkdir_p "$output_objdir"
60307a84e134Smrg
6031994689c1Smrg    # Determine the type of output
6032994689c1Smrg    case $output in
6033994689c1Smrg    "")
6034994689c1Smrg      func_fatal_help "you must specify an output file"
6035994689c1Smrg      ;;
6036994689c1Smrg    *.$libext) linkmode=oldlib ;;
6037994689c1Smrg    *.lo | *.$objext) linkmode=obj ;;
6038994689c1Smrg    *.la) linkmode=lib ;;
6039994689c1Smrg    *) linkmode=prog ;; # Anything else should be a program.
6040994689c1Smrg    esac
6041994689c1Smrg
6042994689c1Smrg    specialdeplibs=
6043994689c1Smrg
6044994689c1Smrg    libs=
6045994689c1Smrg    # Find all interdependent deplibs by searching for libraries
6046994689c1Smrg    # that are linked more than once (e.g. -la -lb -la)
6047994689c1Smrg    for deplib in $deplibs; do
6048f353fbadSmrg      if $opt_preserve_dup_deps ; then
6049994689c1Smrg	case "$libs " in
6050f353fbadSmrg	*" $deplib "*) func_append specialdeplibs " $deplib" ;;
6051994689c1Smrg	esac
6052994689c1Smrg      fi
6053f353fbadSmrg      func_append libs " $deplib"
6054994689c1Smrg    done
6055994689c1Smrg
6056994689c1Smrg    if test "$linkmode" = lib; then
6057994689c1Smrg      libs="$predeps $libs $compiler_lib_search_path $postdeps"
6058994689c1Smrg
6059994689c1Smrg      # Compute libraries that are listed more than once in $predeps
6060994689c1Smrg      # $postdeps and mark them as special (i.e., whose duplicates are
6061994689c1Smrg      # not to be eliminated).
6062994689c1Smrg      pre_post_deps=
6063994689c1Smrg      if $opt_duplicate_compiler_generated_deps; then
6064994689c1Smrg	for pre_post_dep in $predeps $postdeps; do
6065994689c1Smrg	  case "$pre_post_deps " in
6066f353fbadSmrg	  *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;;
6067994689c1Smrg	  esac
6068f353fbadSmrg	  func_append pre_post_deps " $pre_post_dep"
6069994689c1Smrg	done
6070994689c1Smrg      fi
6071994689c1Smrg      pre_post_deps=
6072994689c1Smrg    fi
6073994689c1Smrg
6074994689c1Smrg    deplibs=
6075994689c1Smrg    newdependency_libs=
6076994689c1Smrg    newlib_search_path=
6077994689c1Smrg    need_relink=no # whether we're linking any uninstalled libtool libraries
6078994689c1Smrg    notinst_deplibs= # not-installed libtool libraries
6079994689c1Smrg    notinst_path= # paths that contain not-installed libtool libraries
6080994689c1Smrg
6081994689c1Smrg    case $linkmode in
6082994689c1Smrg    lib)
6083994689c1Smrg	passes="conv dlpreopen link"
6084994689c1Smrg	for file in $dlfiles $dlprefiles; do
6085994689c1Smrg	  case $file in
6086994689c1Smrg	  *.la) ;;
6087994689c1Smrg	  *)
6088994689c1Smrg	    func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file"
6089994689c1Smrg	    ;;
6090994689c1Smrg	  esac
6091994689c1Smrg	done
6092994689c1Smrg	;;
6093994689c1Smrg    prog)
6094994689c1Smrg	compile_deplibs=
6095994689c1Smrg	finalize_deplibs=
6096994689c1Smrg	alldeplibs=no
6097994689c1Smrg	newdlfiles=
6098994689c1Smrg	newdlprefiles=
6099994689c1Smrg	passes="conv scan dlopen dlpreopen link"
6100994689c1Smrg	;;
6101994689c1Smrg    *)  passes="conv"
6102994689c1Smrg	;;
6103994689c1Smrg    esac
6104994689c1Smrg
6105994689c1Smrg    for pass in $passes; do
6106994689c1Smrg      # The preopen pass in lib mode reverses $deplibs; put it back here
6107994689c1Smrg      # so that -L comes before libs that need it for instance...
6108994689c1Smrg      if test "$linkmode,$pass" = "lib,link"; then
6109994689c1Smrg	## FIXME: Find the place where the list is rebuilt in the wrong
6110994689c1Smrg	##        order, and fix it there properly
6111994689c1Smrg        tmp_deplibs=
6112994689c1Smrg	for deplib in $deplibs; do
6113994689c1Smrg	  tmp_deplibs="$deplib $tmp_deplibs"
6114994689c1Smrg	done
6115994689c1Smrg	deplibs="$tmp_deplibs"
6116994689c1Smrg      fi
6117994689c1Smrg
6118994689c1Smrg      if test "$linkmode,$pass" = "lib,link" ||
6119994689c1Smrg	 test "$linkmode,$pass" = "prog,scan"; then
6120994689c1Smrg	libs="$deplibs"
6121994689c1Smrg	deplibs=
6122994689c1Smrg      fi
6123994689c1Smrg      if test "$linkmode" = prog; then
6124994689c1Smrg	case $pass in
6125994689c1Smrg	dlopen) libs="$dlfiles" ;;
6126994689c1Smrg	dlpreopen) libs="$dlprefiles" ;;
6127994689c1Smrg	link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
6128994689c1Smrg	esac
6129994689c1Smrg      fi
6130994689c1Smrg      if test "$linkmode,$pass" = "lib,dlpreopen"; then
6131994689c1Smrg	# Collect and forward deplibs of preopened libtool libs
6132994689c1Smrg	for lib in $dlprefiles; do
6133994689c1Smrg	  # Ignore non-libtool-libs
6134994689c1Smrg	  dependency_libs=
6135f353fbadSmrg	  func_resolve_sysroot "$lib"
6136994689c1Smrg	  case $lib in
6137f353fbadSmrg	  *.la)	func_source "$func_resolve_sysroot_result" ;;
6138994689c1Smrg	  esac
6139994689c1Smrg
6140994689c1Smrg	  # Collect preopened libtool deplibs, except any this library
6141994689c1Smrg	  # has declared as weak libs
6142994689c1Smrg	  for deplib in $dependency_libs; do
6143994689c1Smrg	    func_basename "$deplib"
6144994689c1Smrg            deplib_base=$func_basename_result
6145994689c1Smrg	    case " $weak_libs " in
6146994689c1Smrg	    *" $deplib_base "*) ;;
6147f353fbadSmrg	    *) func_append deplibs " $deplib" ;;
6148994689c1Smrg	    esac
6149994689c1Smrg	  done
6150994689c1Smrg	done
6151994689c1Smrg	libs="$dlprefiles"
6152994689c1Smrg      fi
6153994689c1Smrg      if test "$pass" = dlopen; then
6154994689c1Smrg	# Collect dlpreopened libraries
6155994689c1Smrg	save_deplibs="$deplibs"
6156994689c1Smrg	deplibs=
6157994689c1Smrg      fi
6158994689c1Smrg
6159994689c1Smrg      for deplib in $libs; do
6160994689c1Smrg	lib=
6161994689c1Smrg	found=no
6162994689c1Smrg	case $deplib in
6163421c997bSmrg	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
6164421c997bSmrg        |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
6165994689c1Smrg	  if test "$linkmode,$pass" = "prog,link"; then
6166994689c1Smrg	    compile_deplibs="$deplib $compile_deplibs"
6167994689c1Smrg	    finalize_deplibs="$deplib $finalize_deplibs"
6168994689c1Smrg	  else
6169f353fbadSmrg	    func_append compiler_flags " $deplib"
6170994689c1Smrg	    if test "$linkmode" = lib ; then
6171994689c1Smrg		case "$new_inherited_linker_flags " in
6172994689c1Smrg		    *" $deplib "*) ;;
6173f353fbadSmrg		    * ) func_append new_inherited_linker_flags " $deplib" ;;
6174994689c1Smrg		esac
6175994689c1Smrg	    fi
6176994689c1Smrg	  fi
6177994689c1Smrg	  continue
6178994689c1Smrg	  ;;
6179994689c1Smrg	-l*)
6180994689c1Smrg	  if test "$linkmode" != lib && test "$linkmode" != prog; then
6181994689c1Smrg	    func_warning "\`-l' is ignored for archives/objects"
6182994689c1Smrg	    continue
6183994689c1Smrg	  fi
6184994689c1Smrg	  func_stripname '-l' '' "$deplib"
6185994689c1Smrg	  name=$func_stripname_result
6186994689c1Smrg	  if test "$linkmode" = lib; then
6187994689c1Smrg	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
6188994689c1Smrg	  else
6189994689c1Smrg	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
6190994689c1Smrg	  fi
6191994689c1Smrg	  for searchdir in $searchdirs; do
6192994689c1Smrg	    for search_ext in .la $std_shrext .so .a; do
6193994689c1Smrg	      # Search the libtool library
6194994689c1Smrg	      lib="$searchdir/lib${name}${search_ext}"
6195994689c1Smrg	      if test -f "$lib"; then
6196994689c1Smrg		if test "$search_ext" = ".la"; then
6197994689c1Smrg		  found=yes
6198994689c1Smrg		else
6199994689c1Smrg		  found=no
6200994689c1Smrg		fi
6201994689c1Smrg		break 2
6202994689c1Smrg	      fi
6203994689c1Smrg	    done
6204994689c1Smrg	  done
6205994689c1Smrg	  if test "$found" != yes; then
6206994689c1Smrg	    # deplib doesn't seem to be a libtool library
6207994689c1Smrg	    if test "$linkmode,$pass" = "prog,link"; then
6208994689c1Smrg	      compile_deplibs="$deplib $compile_deplibs"
6209994689c1Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
6210994689c1Smrg	    else
6211994689c1Smrg	      deplibs="$deplib $deplibs"
6212994689c1Smrg	      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
6213994689c1Smrg	    fi
6214994689c1Smrg	    continue
6215994689c1Smrg	  else # deplib is a libtool library
6216994689c1Smrg	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
6217994689c1Smrg	    # We need to do some special things here, and not later.
6218994689c1Smrg	    if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6219994689c1Smrg	      case " $predeps $postdeps " in
6220994689c1Smrg	      *" $deplib "*)
6221994689c1Smrg		if func_lalib_p "$lib"; then
6222994689c1Smrg		  library_names=
6223994689c1Smrg		  old_library=
6224994689c1Smrg		  func_source "$lib"
6225994689c1Smrg		  for l in $old_library $library_names; do
6226994689c1Smrg		    ll="$l"
6227994689c1Smrg		  done
6228994689c1Smrg		  if test "X$ll" = "X$old_library" ; then # only static version available
6229994689c1Smrg		    found=no
6230994689c1Smrg		    func_dirname "$lib" "" "."
6231994689c1Smrg		    ladir="$func_dirname_result"
6232994689c1Smrg		    lib=$ladir/$old_library
6233994689c1Smrg		    if test "$linkmode,$pass" = "prog,link"; then
6234994689c1Smrg		      compile_deplibs="$deplib $compile_deplibs"
6235994689c1Smrg		      finalize_deplibs="$deplib $finalize_deplibs"
6236994689c1Smrg		    else
6237994689c1Smrg		      deplibs="$deplib $deplibs"
6238994689c1Smrg		      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
6239994689c1Smrg		    fi
6240994689c1Smrg		    continue
6241994689c1Smrg		  fi
6242994689c1Smrg		fi
6243994689c1Smrg		;;
6244994689c1Smrg	      *) ;;
6245994689c1Smrg	      esac
6246994689c1Smrg	    fi
6247994689c1Smrg	  fi
6248994689c1Smrg	  ;; # -l
6249994689c1Smrg	*.ltframework)
6250994689c1Smrg	  if test "$linkmode,$pass" = "prog,link"; then
6251994689c1Smrg	    compile_deplibs="$deplib $compile_deplibs"
6252994689c1Smrg	    finalize_deplibs="$deplib $finalize_deplibs"
6253994689c1Smrg	  else
6254994689c1Smrg	    deplibs="$deplib $deplibs"
6255994689c1Smrg	    if test "$linkmode" = lib ; then
6256994689c1Smrg		case "$new_inherited_linker_flags " in
6257994689c1Smrg		    *" $deplib "*) ;;
6258f353fbadSmrg		    * ) func_append new_inherited_linker_flags " $deplib" ;;
6259994689c1Smrg		esac
6260994689c1Smrg	    fi
6261994689c1Smrg	  fi
6262994689c1Smrg	  continue
6263994689c1Smrg	  ;;
6264994689c1Smrg	-L*)
6265994689c1Smrg	  case $linkmode in
6266994689c1Smrg	  lib)
6267994689c1Smrg	    deplibs="$deplib $deplibs"
6268994689c1Smrg	    test "$pass" = conv && continue
6269994689c1Smrg	    newdependency_libs="$deplib $newdependency_libs"
6270994689c1Smrg	    func_stripname '-L' '' "$deplib"
6271f353fbadSmrg	    func_resolve_sysroot "$func_stripname_result"
6272f353fbadSmrg	    func_append newlib_search_path " $func_resolve_sysroot_result"
6273994689c1Smrg	    ;;
6274994689c1Smrg	  prog)
6275994689c1Smrg	    if test "$pass" = conv; then
6276994689c1Smrg	      deplibs="$deplib $deplibs"
6277994689c1Smrg	      continue
6278994689c1Smrg	    fi
6279994689c1Smrg	    if test "$pass" = scan; then
6280994689c1Smrg	      deplibs="$deplib $deplibs"
6281994689c1Smrg	    else
6282994689c1Smrg	      compile_deplibs="$deplib $compile_deplibs"
6283994689c1Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
6284994689c1Smrg	    fi
6285994689c1Smrg	    func_stripname '-L' '' "$deplib"
6286f353fbadSmrg	    func_resolve_sysroot "$func_stripname_result"
6287f353fbadSmrg	    func_append newlib_search_path " $func_resolve_sysroot_result"
6288994689c1Smrg	    ;;
6289994689c1Smrg	  *)
6290994689c1Smrg	    func_warning "\`-L' is ignored for archives/objects"
6291994689c1Smrg	    ;;
6292994689c1Smrg	  esac # linkmode
6293994689c1Smrg	  continue
6294994689c1Smrg	  ;; # -L
6295994689c1Smrg	-R*)
6296994689c1Smrg	  if test "$pass" = link; then
6297994689c1Smrg	    func_stripname '-R' '' "$deplib"
6298f353fbadSmrg	    func_resolve_sysroot "$func_stripname_result"
6299f353fbadSmrg	    dir=$func_resolve_sysroot_result
6300994689c1Smrg	    # Make sure the xrpath contains only unique directories.
6301994689c1Smrg	    case "$xrpath " in
6302994689c1Smrg	    *" $dir "*) ;;
6303f353fbadSmrg	    *) func_append xrpath " $dir" ;;
6304994689c1Smrg	    esac
6305994689c1Smrg	  fi
6306994689c1Smrg	  deplibs="$deplib $deplibs"
6307994689c1Smrg	  continue
6308994689c1Smrg	  ;;
6309f353fbadSmrg	*.la)
6310f353fbadSmrg	  func_resolve_sysroot "$deplib"
6311f353fbadSmrg	  lib=$func_resolve_sysroot_result
6312f353fbadSmrg	  ;;
6313994689c1Smrg	*.$libext)
6314994689c1Smrg	  if test "$pass" = conv; then
6315994689c1Smrg	    deplibs="$deplib $deplibs"
6316994689c1Smrg	    continue
6317994689c1Smrg	  fi
6318994689c1Smrg	  case $linkmode in
6319994689c1Smrg	  lib)
6320994689c1Smrg	    # Linking convenience modules into shared libraries is allowed,
6321994689c1Smrg	    # but linking other static libraries is non-portable.
6322994689c1Smrg	    case " $dlpreconveniencelibs " in
6323994689c1Smrg	    *" $deplib "*) ;;
6324994689c1Smrg	    *)
6325994689c1Smrg	      valid_a_lib=no
6326994689c1Smrg	      case $deplibs_check_method in
6327994689c1Smrg		match_pattern*)
6328994689c1Smrg		  set dummy $deplibs_check_method; shift
6329994689c1Smrg		  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
6330994689c1Smrg		  if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
6331994689c1Smrg		    | $EGREP "$match_pattern_regex" > /dev/null; then
6332994689c1Smrg		    valid_a_lib=yes
6333994689c1Smrg		  fi
6334994689c1Smrg		;;
6335994689c1Smrg		pass_all)
6336994689c1Smrg		  valid_a_lib=yes
6337994689c1Smrg		;;
6338994689c1Smrg	      esac
6339994689c1Smrg	      if test "$valid_a_lib" != yes; then
6340994689c1Smrg		echo
6341994689c1Smrg		$ECHO "*** Warning: Trying to link with static lib archive $deplib."
6342994689c1Smrg		echo "*** I have the capability to make that library automatically link in when"
6343994689c1Smrg		echo "*** you link to this library.  But I can only do this if you have a"
6344994689c1Smrg		echo "*** shared version of the library, which you do not appear to have"
6345994689c1Smrg		echo "*** because the file extensions .$libext of this argument makes me believe"
6346994689c1Smrg		echo "*** that it is just a static archive that I should not use here."
6347994689c1Smrg	      else
6348994689c1Smrg		echo
6349994689c1Smrg		$ECHO "*** Warning: Linking the shared library $output against the"
6350994689c1Smrg		$ECHO "*** static library $deplib is not portable!"
6351994689c1Smrg		deplibs="$deplib $deplibs"
6352994689c1Smrg	      fi
6353994689c1Smrg	      ;;
6354994689c1Smrg	    esac
6355994689c1Smrg	    continue
6356994689c1Smrg	    ;;
6357994689c1Smrg	  prog)
6358994689c1Smrg	    if test "$pass" != link; then
6359994689c1Smrg	      deplibs="$deplib $deplibs"
6360994689c1Smrg	    else
6361994689c1Smrg	      compile_deplibs="$deplib $compile_deplibs"
6362994689c1Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
6363994689c1Smrg	    fi
6364994689c1Smrg	    continue
6365994689c1Smrg	    ;;
6366994689c1Smrg	  esac # linkmode
6367994689c1Smrg	  ;; # *.$libext
6368994689c1Smrg	*.lo | *.$objext)
6369994689c1Smrg	  if test "$pass" = conv; then
6370994689c1Smrg	    deplibs="$deplib $deplibs"
6371994689c1Smrg	  elif test "$linkmode" = prog; then
6372994689c1Smrg	    if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
6373994689c1Smrg	      # If there is no dlopen support or we're linking statically,
6374994689c1Smrg	      # we need to preload.
6375f353fbadSmrg	      func_append newdlprefiles " $deplib"
6376994689c1Smrg	      compile_deplibs="$deplib $compile_deplibs"
6377994689c1Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
6378994689c1Smrg	    else
6379f353fbadSmrg	      func_append newdlfiles " $deplib"
6380994689c1Smrg	    fi
6381994689c1Smrg	  fi
6382994689c1Smrg	  continue
6383994689c1Smrg	  ;;
6384994689c1Smrg	%DEPLIBS%)
6385994689c1Smrg	  alldeplibs=yes
6386994689c1Smrg	  continue
6387994689c1Smrg	  ;;
6388994689c1Smrg	esac # case $deplib
6389994689c1Smrg
6390994689c1Smrg	if test "$found" = yes || test -f "$lib"; then :
6391994689c1Smrg	else
6392994689c1Smrg	  func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'"
6393994689c1Smrg	fi
6394994689c1Smrg
6395994689c1Smrg	# Check to see that this really is a libtool archive.
6396994689c1Smrg	func_lalib_unsafe_p "$lib" \
6397994689c1Smrg	  || func_fatal_error "\`$lib' is not a valid libtool archive"
6398994689c1Smrg
6399994689c1Smrg	func_dirname "$lib" "" "."
6400994689c1Smrg	ladir="$func_dirname_result"
6401994689c1Smrg
6402994689c1Smrg	dlname=
6403994689c1Smrg	dlopen=
6404994689c1Smrg	dlpreopen=
6405994689c1Smrg	libdir=
6406994689c1Smrg	library_names=
6407994689c1Smrg	old_library=
6408994689c1Smrg	inherited_linker_flags=
6409994689c1Smrg	# If the library was installed with an old release of libtool,
6410994689c1Smrg	# it will not redefine variables installed, or shouldnotlink
6411994689c1Smrg	installed=yes
6412994689c1Smrg	shouldnotlink=no
6413994689c1Smrg	avoidtemprpath=
6414994689c1Smrg
6415994689c1Smrg
6416994689c1Smrg	# Read the .la file
6417994689c1Smrg	func_source "$lib"
6418994689c1Smrg
6419994689c1Smrg	# Convert "-framework foo" to "foo.ltframework"
6420994689c1Smrg	if test -n "$inherited_linker_flags"; then
6421994689c1Smrg	  tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
6422994689c1Smrg	  for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
6423994689c1Smrg	    case " $new_inherited_linker_flags " in
6424994689c1Smrg	      *" $tmp_inherited_linker_flag "*) ;;
6425f353fbadSmrg	      *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";;
6426994689c1Smrg	    esac
6427994689c1Smrg	  done
6428994689c1Smrg	fi
6429994689c1Smrg	dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
6430994689c1Smrg	if test "$linkmode,$pass" = "lib,link" ||
6431994689c1Smrg	   test "$linkmode,$pass" = "prog,scan" ||
6432994689c1Smrg	   { test "$linkmode" != prog && test "$linkmode" != lib; }; then
6433f353fbadSmrg	  test -n "$dlopen" && func_append dlfiles " $dlopen"
6434f353fbadSmrg	  test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen"
6435994689c1Smrg	fi
6436994689c1Smrg
6437994689c1Smrg	if test "$pass" = conv; then
6438994689c1Smrg	  # Only check for convenience libraries
6439994689c1Smrg	  deplibs="$lib $deplibs"
6440994689c1Smrg	  if test -z "$libdir"; then
6441994689c1Smrg	    if test -z "$old_library"; then
6442994689c1Smrg	      func_fatal_error "cannot find name of link library for \`$lib'"
6443994689c1Smrg	    fi
6444994689c1Smrg	    # It is a libtool convenience library, so add in its objects.
6445f353fbadSmrg	    func_append convenience " $ladir/$objdir/$old_library"
6446f353fbadSmrg	    func_append old_convenience " $ladir/$objdir/$old_library"
6447994689c1Smrg	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
6448994689c1Smrg	    func_fatal_error "\`$lib' is not a convenience library"
6449994689c1Smrg	  fi
6450994689c1Smrg	  tmp_libs=
6451994689c1Smrg	  for deplib in $dependency_libs; do
6452994689c1Smrg	    deplibs="$deplib $deplibs"
6453f353fbadSmrg	    if $opt_preserve_dup_deps ; then
6454994689c1Smrg	      case "$tmp_libs " in
6455f353fbadSmrg	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
6456994689c1Smrg	      esac
6457994689c1Smrg	    fi
6458f353fbadSmrg	    func_append tmp_libs " $deplib"
6459994689c1Smrg	  done
6460994689c1Smrg	  continue
6461994689c1Smrg	fi # $pass = conv
6462994689c1Smrg
6463994689c1Smrg
6464994689c1Smrg	# Get the name of the library we link against.
6465994689c1Smrg	linklib=
6466f353fbadSmrg	if test -n "$old_library" &&
6467f353fbadSmrg	   { test "$prefer_static_libs" = yes ||
6468f353fbadSmrg	     test "$prefer_static_libs,$installed" = "built,no"; }; then
6469f353fbadSmrg	  linklib=$old_library
6470f353fbadSmrg	else
6471f353fbadSmrg	  for l in $old_library $library_names; do
6472f353fbadSmrg	    linklib="$l"
6473f353fbadSmrg	  done
6474f353fbadSmrg	fi
6475994689c1Smrg	if test -z "$linklib"; then
6476994689c1Smrg	  func_fatal_error "cannot find name of link library for \`$lib'"
6477994689c1Smrg	fi
6478994689c1Smrg
6479994689c1Smrg	# This library was specified with -dlopen.
6480994689c1Smrg	if test "$pass" = dlopen; then
6481994689c1Smrg	  if test -z "$libdir"; then
6482994689c1Smrg	    func_fatal_error "cannot -dlopen a convenience library: \`$lib'"
6483994689c1Smrg	  fi
6484994689c1Smrg	  if test -z "$dlname" ||
6485994689c1Smrg	     test "$dlopen_support" != yes ||
6486994689c1Smrg	     test "$build_libtool_libs" = no; then
6487994689c1Smrg	    # If there is no dlname, no dlopen support or we're linking
6488994689c1Smrg	    # statically, we need to preload.  We also need to preload any
6489994689c1Smrg	    # dependent libraries so libltdl's deplib preloader doesn't
6490994689c1Smrg	    # bomb out in the load deplibs phase.
6491f353fbadSmrg	    func_append dlprefiles " $lib $dependency_libs"
6492994689c1Smrg	  else
6493f353fbadSmrg	    func_append newdlfiles " $lib"
6494994689c1Smrg	  fi
6495994689c1Smrg	  continue
6496994689c1Smrg	fi # $pass = dlopen
6497994689c1Smrg
6498994689c1Smrg	# We need an absolute path.
6499994689c1Smrg	case $ladir in
6500994689c1Smrg	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
6501994689c1Smrg	*)
6502994689c1Smrg	  abs_ladir=`cd "$ladir" && pwd`
6503994689c1Smrg	  if test -z "$abs_ladir"; then
6504994689c1Smrg	    func_warning "cannot determine absolute directory name of \`$ladir'"
6505994689c1Smrg	    func_warning "passing it literally to the linker, although it might fail"
6506994689c1Smrg	    abs_ladir="$ladir"
6507994689c1Smrg	  fi
6508994689c1Smrg	  ;;
6509994689c1Smrg	esac
6510994689c1Smrg	func_basename "$lib"
6511994689c1Smrg	laname="$func_basename_result"
6512994689c1Smrg
6513994689c1Smrg	# Find the relevant object directory and library name.
6514994689c1Smrg	if test "X$installed" = Xyes; then
6515f353fbadSmrg	  if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
6516994689c1Smrg	    func_warning "library \`$lib' was moved."
6517994689c1Smrg	    dir="$ladir"
6518994689c1Smrg	    absdir="$abs_ladir"
6519994689c1Smrg	    libdir="$abs_ladir"
6520994689c1Smrg	  else
6521f353fbadSmrg	    dir="$lt_sysroot$libdir"
6522f353fbadSmrg	    absdir="$lt_sysroot$libdir"
6523994689c1Smrg	  fi
6524994689c1Smrg	  test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
6525994689c1Smrg	else
6526994689c1Smrg	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
6527994689c1Smrg	    dir="$ladir"
6528994689c1Smrg	    absdir="$abs_ladir"
6529994689c1Smrg	    # Remove this search path later
6530f353fbadSmrg	    func_append notinst_path " $abs_ladir"
6531994689c1Smrg	  else
6532994689c1Smrg	    dir="$ladir/$objdir"
6533994689c1Smrg	    absdir="$abs_ladir/$objdir"
6534994689c1Smrg	    # Remove this search path later
6535f353fbadSmrg	    func_append notinst_path " $abs_ladir"
6536994689c1Smrg	  fi
6537994689c1Smrg	fi # $installed = yes
6538994689c1Smrg	func_stripname 'lib' '.la' "$laname"
6539994689c1Smrg	name=$func_stripname_result
6540994689c1Smrg
6541994689c1Smrg	# This library was specified with -dlpreopen.
6542994689c1Smrg	if test "$pass" = dlpreopen; then
6543994689c1Smrg	  if test -z "$libdir" && test "$linkmode" = prog; then
6544994689c1Smrg	    func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'"
6545994689c1Smrg	  fi
6546f353fbadSmrg	  case "$host" in
6547f353fbadSmrg	    # special handling for platforms with PE-DLLs.
6548f353fbadSmrg	    *cygwin* | *mingw* | *cegcc* )
6549f353fbadSmrg	      # Linker will automatically link against shared library if both
6550f353fbadSmrg	      # static and shared are present.  Therefore, ensure we extract
6551f353fbadSmrg	      # symbols from the import library if a shared library is present
6552f353fbadSmrg	      # (otherwise, the dlopen module name will be incorrect).  We do
6553f353fbadSmrg	      # this by putting the import library name into $newdlprefiles.
6554f353fbadSmrg	      # We recover the dlopen module name by 'saving' the la file
6555f353fbadSmrg	      # name in a special purpose variable, and (later) extracting the
6556f353fbadSmrg	      # dlname from the la file.
6557f353fbadSmrg	      if test -n "$dlname"; then
6558f353fbadSmrg	        func_tr_sh "$dir/$linklib"
6559f353fbadSmrg	        eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname"
6560f353fbadSmrg	        func_append newdlprefiles " $dir/$linklib"
6561f353fbadSmrg	      else
6562f353fbadSmrg	        func_append newdlprefiles " $dir/$old_library"
6563f353fbadSmrg	        # Keep a list of preopened convenience libraries to check
6564f353fbadSmrg	        # that they are being used correctly in the link pass.
6565f353fbadSmrg	        test -z "$libdir" && \
6566f353fbadSmrg	          func_append dlpreconveniencelibs " $dir/$old_library"
6567f353fbadSmrg	      fi
6568f353fbadSmrg	    ;;
6569f353fbadSmrg	    * )
6570f353fbadSmrg	      # Prefer using a static library (so that no silly _DYNAMIC symbols
6571f353fbadSmrg	      # are required to link).
6572f353fbadSmrg	      if test -n "$old_library"; then
6573f353fbadSmrg	        func_append newdlprefiles " $dir/$old_library"
6574f353fbadSmrg	        # Keep a list of preopened convenience libraries to check
6575f353fbadSmrg	        # that they are being used correctly in the link pass.
6576f353fbadSmrg	        test -z "$libdir" && \
6577f353fbadSmrg	          func_append dlpreconveniencelibs " $dir/$old_library"
6578f353fbadSmrg	      # Otherwise, use the dlname, so that lt_dlopen finds it.
6579f353fbadSmrg	      elif test -n "$dlname"; then
6580f353fbadSmrg	        func_append newdlprefiles " $dir/$dlname"
6581f353fbadSmrg	      else
6582f353fbadSmrg	        func_append newdlprefiles " $dir/$linklib"
6583f353fbadSmrg	      fi
6584f353fbadSmrg	    ;;
6585f353fbadSmrg	  esac
6586994689c1Smrg	fi # $pass = dlpreopen
6587994689c1Smrg
6588994689c1Smrg	if test -z "$libdir"; then
6589994689c1Smrg	  # Link the convenience library
6590994689c1Smrg	  if test "$linkmode" = lib; then
6591994689c1Smrg	    deplibs="$dir/$old_library $deplibs"
6592994689c1Smrg	  elif test "$linkmode,$pass" = "prog,link"; then
6593994689c1Smrg	    compile_deplibs="$dir/$old_library $compile_deplibs"
6594994689c1Smrg	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
6595994689c1Smrg	  else
6596994689c1Smrg	    deplibs="$lib $deplibs" # used for prog,scan pass
6597994689c1Smrg	  fi
6598994689c1Smrg	  continue
6599994689c1Smrg	fi
6600994689c1Smrg
6601994689c1Smrg
6602994689c1Smrg	if test "$linkmode" = prog && test "$pass" != link; then
6603f353fbadSmrg	  func_append newlib_search_path " $ladir"
6604994689c1Smrg	  deplibs="$lib $deplibs"
6605994689c1Smrg
6606994689c1Smrg	  linkalldeplibs=no
6607994689c1Smrg	  if test "$link_all_deplibs" != no || test -z "$library_names" ||
6608994689c1Smrg	     test "$build_libtool_libs" = no; then
6609994689c1Smrg	    linkalldeplibs=yes
6610994689c1Smrg	  fi
6611994689c1Smrg
6612994689c1Smrg	  tmp_libs=
6613994689c1Smrg	  for deplib in $dependency_libs; do
6614994689c1Smrg	    case $deplib in
6615994689c1Smrg	    -L*) func_stripname '-L' '' "$deplib"
6616f353fbadSmrg	         func_resolve_sysroot "$func_stripname_result"
6617f353fbadSmrg	         func_append newlib_search_path " $func_resolve_sysroot_result"
6618994689c1Smrg		 ;;
6619994689c1Smrg	    esac
6620994689c1Smrg	    # Need to link against all dependency_libs?
6621994689c1Smrg	    if test "$linkalldeplibs" = yes; then
6622994689c1Smrg	      deplibs="$deplib $deplibs"
6623994689c1Smrg	    else
6624994689c1Smrg	      # Need to hardcode shared library paths
6625994689c1Smrg	      # or/and link against static libraries
6626994689c1Smrg	      newdependency_libs="$deplib $newdependency_libs"
6627994689c1Smrg	    fi
6628f353fbadSmrg	    if $opt_preserve_dup_deps ; then
6629994689c1Smrg	      case "$tmp_libs " in
6630f353fbadSmrg	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
6631994689c1Smrg	      esac
6632994689c1Smrg	    fi
6633f353fbadSmrg	    func_append tmp_libs " $deplib"
6634994689c1Smrg	  done # for deplib
6635994689c1Smrg	  continue
6636994689c1Smrg	fi # $linkmode = prog...
6637994689c1Smrg
6638994689c1Smrg	if test "$linkmode,$pass" = "prog,link"; then
6639994689c1Smrg	  if test -n "$library_names" &&
6640994689c1Smrg	     { { test "$prefer_static_libs" = no ||
6641994689c1Smrg	         test "$prefer_static_libs,$installed" = "built,yes"; } ||
6642994689c1Smrg	       test -z "$old_library"; }; then
6643994689c1Smrg	    # We need to hardcode the library path
6644994689c1Smrg	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
6645994689c1Smrg	      # Make sure the rpath contains only unique directories.
6646994689c1Smrg	      case "$temp_rpath:" in
6647994689c1Smrg	      *"$absdir:"*) ;;
6648f353fbadSmrg	      *) func_append temp_rpath "$absdir:" ;;
6649994689c1Smrg	      esac
6650994689c1Smrg	    fi
6651994689c1Smrg
6652994689c1Smrg	    # Hardcode the library path.
6653994689c1Smrg	    # Skip directories that are in the system default run-time
6654994689c1Smrg	    # search path.
6655994689c1Smrg	    case " $sys_lib_dlsearch_path " in
6656994689c1Smrg	    *" $absdir "*) ;;
6657994689c1Smrg	    *)
6658994689c1Smrg	      case "$compile_rpath " in
6659994689c1Smrg	      *" $absdir "*) ;;
6660f353fbadSmrg	      *) func_append compile_rpath " $absdir" ;;
6661994689c1Smrg	      esac
6662994689c1Smrg	      ;;
6663994689c1Smrg	    esac
6664994689c1Smrg	    case " $sys_lib_dlsearch_path " in
6665994689c1Smrg	    *" $libdir "*) ;;
6666994689c1Smrg	    *)
6667994689c1Smrg	      case "$finalize_rpath " in
6668994689c1Smrg	      *" $libdir "*) ;;
6669f353fbadSmrg	      *) func_append finalize_rpath " $libdir" ;;
6670994689c1Smrg	      esac
6671994689c1Smrg	      ;;
6672994689c1Smrg	    esac
6673994689c1Smrg	  fi # $linkmode,$pass = prog,link...
6674994689c1Smrg
6675994689c1Smrg	  if test "$alldeplibs" = yes &&
6676994689c1Smrg	     { test "$deplibs_check_method" = pass_all ||
6677994689c1Smrg	       { test "$build_libtool_libs" = yes &&
6678994689c1Smrg		 test -n "$library_names"; }; }; then
6679994689c1Smrg	    # We only need to search for static libraries
6680994689c1Smrg	    continue
6681994689c1Smrg	  fi
6682994689c1Smrg	fi
6683994689c1Smrg
6684994689c1Smrg	link_static=no # Whether the deplib will be linked statically
6685994689c1Smrg	use_static_libs=$prefer_static_libs
6686994689c1Smrg	if test "$use_static_libs" = built && test "$installed" = yes; then
6687994689c1Smrg	  use_static_libs=no
6688994689c1Smrg	fi
6689994689c1Smrg	if test -n "$library_names" &&
6690994689c1Smrg	   { test "$use_static_libs" = no || test -z "$old_library"; }; then
6691994689c1Smrg	  case $host in
6692994689c1Smrg	  *cygwin* | *mingw* | *cegcc*)
6693994689c1Smrg	      # No point in relinking DLLs because paths are not encoded
6694f353fbadSmrg	      func_append notinst_deplibs " $lib"
6695994689c1Smrg	      need_relink=no
6696994689c1Smrg	    ;;
6697994689c1Smrg	  *)
6698994689c1Smrg	    if test "$installed" = no; then
6699f353fbadSmrg	      func_append notinst_deplibs " $lib"
6700994689c1Smrg	      need_relink=yes
6701994689c1Smrg	    fi
6702994689c1Smrg	    ;;
6703994689c1Smrg	  esac
6704994689c1Smrg	  # This is a shared library
6705994689c1Smrg
6706994689c1Smrg	  # Warn about portability, can't link against -module's on some
6707994689c1Smrg	  # systems (darwin).  Don't bleat about dlopened modules though!
6708994689c1Smrg	  dlopenmodule=""
6709994689c1Smrg	  for dlpremoduletest in $dlprefiles; do
6710994689c1Smrg	    if test "X$dlpremoduletest" = "X$lib"; then
6711994689c1Smrg	      dlopenmodule="$dlpremoduletest"
6712994689c1Smrg	      break
6713994689c1Smrg	    fi
6714994689c1Smrg	  done
6715994689c1Smrg	  if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then
6716994689c1Smrg	    echo
6717994689c1Smrg	    if test "$linkmode" = prog; then
6718994689c1Smrg	      $ECHO "*** Warning: Linking the executable $output against the loadable module"
6719994689c1Smrg	    else
6720994689c1Smrg	      $ECHO "*** Warning: Linking the shared library $output against the loadable module"
6721994689c1Smrg	    fi
6722994689c1Smrg	    $ECHO "*** $linklib is not portable!"
6723994689c1Smrg	  fi
6724994689c1Smrg	  if test "$linkmode" = lib &&
6725994689c1Smrg	     test "$hardcode_into_libs" = yes; then
6726994689c1Smrg	    # Hardcode the library path.
6727994689c1Smrg	    # Skip directories that are in the system default run-time
6728994689c1Smrg	    # search path.
6729994689c1Smrg	    case " $sys_lib_dlsearch_path " in
6730994689c1Smrg	    *" $absdir "*) ;;
6731994689c1Smrg	    *)
6732994689c1Smrg	      case "$compile_rpath " in
6733994689c1Smrg	      *" $absdir "*) ;;
6734f353fbadSmrg	      *) func_append compile_rpath " $absdir" ;;
6735994689c1Smrg	      esac
6736994689c1Smrg	      ;;
6737994689c1Smrg	    esac
6738994689c1Smrg	    case " $sys_lib_dlsearch_path " in
6739994689c1Smrg	    *" $libdir "*) ;;
6740994689c1Smrg	    *)
6741994689c1Smrg	      case "$finalize_rpath " in
6742994689c1Smrg	      *" $libdir "*) ;;
6743f353fbadSmrg	      *) func_append finalize_rpath " $libdir" ;;
6744994689c1Smrg	      esac
6745994689c1Smrg	      ;;
6746994689c1Smrg	    esac
6747994689c1Smrg	  fi
6748994689c1Smrg
6749994689c1Smrg	  if test -n "$old_archive_from_expsyms_cmds"; then
6750994689c1Smrg	    # figure out the soname
6751994689c1Smrg	    set dummy $library_names
6752994689c1Smrg	    shift
6753994689c1Smrg	    realname="$1"
6754994689c1Smrg	    shift
6755994689c1Smrg	    libname=`eval "\\$ECHO \"$libname_spec\""`
6756994689c1Smrg	    # use dlname if we got it. it's perfectly good, no?
6757994689c1Smrg	    if test -n "$dlname"; then
6758994689c1Smrg	      soname="$dlname"
6759994689c1Smrg	    elif test -n "$soname_spec"; then
6760994689c1Smrg	      # bleh windows
6761994689c1Smrg	      case $host in
6762994689c1Smrg	      *cygwin* | mingw* | *cegcc*)
6763994689c1Smrg	        func_arith $current - $age
6764994689c1Smrg		major=$func_arith_result
6765994689c1Smrg		versuffix="-$major"
6766994689c1Smrg		;;
6767994689c1Smrg	      esac
6768994689c1Smrg	      eval soname=\"$soname_spec\"
6769994689c1Smrg	    else
6770994689c1Smrg	      soname="$realname"
6771994689c1Smrg	    fi
6772994689c1Smrg
6773994689c1Smrg	    # Make a new name for the extract_expsyms_cmds to use
6774994689c1Smrg	    soroot="$soname"
6775994689c1Smrg	    func_basename "$soroot"
6776994689c1Smrg	    soname="$func_basename_result"
6777994689c1Smrg	    func_stripname 'lib' '.dll' "$soname"
6778994689c1Smrg	    newlib=libimp-$func_stripname_result.a
6779994689c1Smrg
6780994689c1Smrg	    # If the library has no export list, then create one now
6781994689c1Smrg	    if test -f "$output_objdir/$soname-def"; then :
6782994689c1Smrg	    else
6783994689c1Smrg	      func_verbose "extracting exported symbol list from \`$soname'"
6784994689c1Smrg	      func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
6785994689c1Smrg	    fi
6786994689c1Smrg
6787994689c1Smrg	    # Create $newlib
6788994689c1Smrg	    if test -f "$output_objdir/$newlib"; then :; else
6789994689c1Smrg	      func_verbose "generating import library for \`$soname'"
6790994689c1Smrg	      func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
6791994689c1Smrg	    fi
6792994689c1Smrg	    # make sure the library variables are pointing to the new library
6793994689c1Smrg	    dir=$output_objdir
6794994689c1Smrg	    linklib=$newlib
6795994689c1Smrg	  fi # test -n "$old_archive_from_expsyms_cmds"
6796994689c1Smrg
6797f353fbadSmrg	  if test "$linkmode" = prog || test "$opt_mode" != relink; then
6798994689c1Smrg	    add_shlibpath=
6799994689c1Smrg	    add_dir=
6800994689c1Smrg	    add=
6801994689c1Smrg	    lib_linked=yes
6802994689c1Smrg	    case $hardcode_action in
6803994689c1Smrg	    immediate | unsupported)
6804994689c1Smrg	      if test "$hardcode_direct" = no; then
6805994689c1Smrg		add="$dir/$linklib"
6806994689c1Smrg		case $host in
6807994689c1Smrg		  *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
6808994689c1Smrg		  *-*-sysv4*uw2*) add_dir="-L$dir" ;;
6809994689c1Smrg		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
6810994689c1Smrg		    *-*-unixware7*) add_dir="-L$dir" ;;
6811994689c1Smrg		  *-*-darwin* )
6812994689c1Smrg		    # if the lib is a (non-dlopened) module then we can not
6813994689c1Smrg		    # link against it, someone is ignoring the earlier warnings
6814994689c1Smrg		    if /usr/bin/file -L $add 2> /dev/null |
6815994689c1Smrg			 $GREP ": [^:]* bundle" >/dev/null ; then
6816994689c1Smrg		      if test "X$dlopenmodule" != "X$lib"; then
6817994689c1Smrg			$ECHO "*** Warning: lib $linklib is a module, not a shared library"
6818994689c1Smrg			if test -z "$old_library" ; then
6819994689c1Smrg			  echo
6820994689c1Smrg			  echo "*** And there doesn't seem to be a static archive available"
6821994689c1Smrg			  echo "*** The link will probably fail, sorry"
6822994689c1Smrg			else
6823994689c1Smrg			  add="$dir/$old_library"
6824994689c1Smrg			fi
6825994689c1Smrg		      elif test -n "$old_library"; then
6826994689c1Smrg			add="$dir/$old_library"
6827994689c1Smrg		      fi
6828994689c1Smrg		    fi
6829994689c1Smrg		esac
6830994689c1Smrg	      elif test "$hardcode_minus_L" = no; then
6831994689c1Smrg		case $host in
6832994689c1Smrg		*-*-sunos*) add_shlibpath="$dir" ;;
6833994689c1Smrg		esac
6834994689c1Smrg		add_dir="-L$dir"
6835994689c1Smrg		add="-l$name"
6836994689c1Smrg	      elif test "$hardcode_shlibpath_var" = no; then
6837994689c1Smrg		add_shlibpath="$dir"
6838994689c1Smrg		add="-l$name"
6839994689c1Smrg	      else
6840994689c1Smrg		lib_linked=no
6841994689c1Smrg	      fi
6842994689c1Smrg	      ;;
6843994689c1Smrg	    relink)
6844994689c1Smrg	      if test "$hardcode_direct" = yes &&
6845994689c1Smrg	         test "$hardcode_direct_absolute" = no; then
6846994689c1Smrg		add="$dir/$linklib"
6847994689c1Smrg	      elif test "$hardcode_minus_L" = yes; then
6848421c997bSmrg		add_dir="-L$absdir"
6849994689c1Smrg		# Try looking first in the location we're being installed to.
6850994689c1Smrg		if test -n "$inst_prefix_dir"; then
6851994689c1Smrg		  case $libdir in
6852994689c1Smrg		    [\\/]*)
6853f353fbadSmrg		      func_append add_dir " -L$inst_prefix_dir$libdir"
6854994689c1Smrg		      ;;
6855994689c1Smrg		  esac
6856994689c1Smrg		fi
6857994689c1Smrg		add="-l$name"
6858994689c1Smrg	      elif test "$hardcode_shlibpath_var" = yes; then
6859994689c1Smrg		add_shlibpath="$dir"
6860994689c1Smrg		add="-l$name"
6861994689c1Smrg	      else
6862994689c1Smrg		lib_linked=no
6863994689c1Smrg	      fi
6864994689c1Smrg	      ;;
6865994689c1Smrg	    *) lib_linked=no ;;
6866994689c1Smrg	    esac
6867994689c1Smrg
6868994689c1Smrg	    if test "$lib_linked" != yes; then
6869994689c1Smrg	      func_fatal_configuration "unsupported hardcode properties"
6870994689c1Smrg	    fi
6871994689c1Smrg
6872994689c1Smrg	    if test -n "$add_shlibpath"; then
6873994689c1Smrg	      case :$compile_shlibpath: in
6874994689c1Smrg	      *":$add_shlibpath:"*) ;;
6875f353fbadSmrg	      *) func_append compile_shlibpath "$add_shlibpath:" ;;
6876994689c1Smrg	      esac
6877994689c1Smrg	    fi
6878994689c1Smrg	    if test "$linkmode" = prog; then
6879994689c1Smrg	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
6880994689c1Smrg	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
6881994689c1Smrg	    else
6882994689c1Smrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
6883994689c1Smrg	      test -n "$add" && deplibs="$add $deplibs"
6884994689c1Smrg	      if test "$hardcode_direct" != yes &&
6885994689c1Smrg		 test "$hardcode_minus_L" != yes &&
6886994689c1Smrg		 test "$hardcode_shlibpath_var" = yes; then
6887994689c1Smrg		case :$finalize_shlibpath: in
6888994689c1Smrg		*":$libdir:"*) ;;
6889f353fbadSmrg		*) func_append finalize_shlibpath "$libdir:" ;;
6890994689c1Smrg		esac
6891994689c1Smrg	      fi
6892994689c1Smrg	    fi
6893994689c1Smrg	  fi
6894994689c1Smrg
6895f353fbadSmrg	  if test "$linkmode" = prog || test "$opt_mode" = relink; then
6896994689c1Smrg	    add_shlibpath=
6897994689c1Smrg	    add_dir=
6898994689c1Smrg	    add=
6899994689c1Smrg	    # Finalize command for both is simple: just hardcode it.
6900994689c1Smrg	    if test "$hardcode_direct" = yes &&
6901994689c1Smrg	       test "$hardcode_direct_absolute" = no; then
6902994689c1Smrg	      add="$libdir/$linklib"
6903994689c1Smrg	    elif test "$hardcode_minus_L" = yes; then
6904994689c1Smrg	      add_dir="-L$libdir"
6905994689c1Smrg	      add="-l$name"
6906994689c1Smrg	    elif test "$hardcode_shlibpath_var" = yes; then
6907994689c1Smrg	      case :$finalize_shlibpath: in
6908994689c1Smrg	      *":$libdir:"*) ;;
6909f353fbadSmrg	      *) func_append finalize_shlibpath "$libdir:" ;;
6910994689c1Smrg	      esac
6911994689c1Smrg	      add="-l$name"
6912994689c1Smrg	    elif test "$hardcode_automatic" = yes; then
6913994689c1Smrg	      if test -n "$inst_prefix_dir" &&
6914994689c1Smrg		 test -f "$inst_prefix_dir$libdir/$linklib" ; then
6915994689c1Smrg		add="$inst_prefix_dir$libdir/$linklib"
6916994689c1Smrg	      else
6917994689c1Smrg		add="$libdir/$linklib"
6918994689c1Smrg	      fi
6919994689c1Smrg	    else
6920994689c1Smrg	      # We cannot seem to hardcode it, guess we'll fake it.
6921994689c1Smrg	      add_dir="-L$libdir"
6922994689c1Smrg	      # Try looking first in the location we're being installed to.
6923994689c1Smrg	      if test -n "$inst_prefix_dir"; then
6924994689c1Smrg		case $libdir in
6925994689c1Smrg		  [\\/]*)
6926f353fbadSmrg		    func_append add_dir " -L$inst_prefix_dir$libdir"
6927994689c1Smrg		    ;;
6928994689c1Smrg		esac
6929994689c1Smrg	      fi
6930994689c1Smrg	      add="-l$name"
6931994689c1Smrg	    fi
6932994689c1Smrg
6933994689c1Smrg	    if test "$linkmode" = prog; then
6934994689c1Smrg	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
6935994689c1Smrg	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
6936994689c1Smrg	    else
6937994689c1Smrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
6938994689c1Smrg	      test -n "$add" && deplibs="$add $deplibs"
6939994689c1Smrg	    fi
6940994689c1Smrg	  fi
6941994689c1Smrg	elif test "$linkmode" = prog; then
6942994689c1Smrg	  # Here we assume that one of hardcode_direct or hardcode_minus_L
6943994689c1Smrg	  # is not unsupported.  This is valid on all known static and
6944994689c1Smrg	  # shared platforms.
6945994689c1Smrg	  if test "$hardcode_direct" != unsupported; then
6946994689c1Smrg	    test -n "$old_library" && linklib="$old_library"
6947994689c1Smrg	    compile_deplibs="$dir/$linklib $compile_deplibs"
6948994689c1Smrg	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
6949994689c1Smrg	  else
6950994689c1Smrg	    compile_deplibs="-l$name -L$dir $compile_deplibs"
6951994689c1Smrg	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
6952994689c1Smrg	  fi
6953994689c1Smrg	elif test "$build_libtool_libs" = yes; then
6954994689c1Smrg	  # Not a shared library
6955994689c1Smrg	  if test "$deplibs_check_method" != pass_all; then
6956994689c1Smrg	    # We're trying link a shared library against a static one
6957994689c1Smrg	    # but the system doesn't support it.
6958994689c1Smrg
6959994689c1Smrg	    # Just print a warning and add the library to dependency_libs so
6960994689c1Smrg	    # that the program can be linked against the static library.
6961994689c1Smrg	    echo
6962994689c1Smrg	    $ECHO "*** Warning: This system can not link to static lib archive $lib."
6963994689c1Smrg	    echo "*** I have the capability to make that library automatically link in when"
6964994689c1Smrg	    echo "*** you link to this library.  But I can only do this if you have a"
6965994689c1Smrg	    echo "*** shared version of the library, which you do not appear to have."
6966994689c1Smrg	    if test "$module" = yes; then
6967994689c1Smrg	      echo "*** But as you try to build a module library, libtool will still create "
6968994689c1Smrg	      echo "*** a static module, that should work as long as the dlopening application"
6969994689c1Smrg	      echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
6970994689c1Smrg	      if test -z "$global_symbol_pipe"; then
6971994689c1Smrg		echo
6972994689c1Smrg		echo "*** However, this would only work if libtool was able to extract symbol"
6973994689c1Smrg		echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
6974994689c1Smrg		echo "*** not find such a program.  So, this module is probably useless."
6975994689c1Smrg		echo "*** \`nm' from GNU binutils and a full rebuild may help."
6976994689c1Smrg	      fi
6977994689c1Smrg	      if test "$build_old_libs" = no; then
6978994689c1Smrg		build_libtool_libs=module
6979994689c1Smrg		build_old_libs=yes
6980994689c1Smrg	      else
6981994689c1Smrg		build_libtool_libs=no
6982994689c1Smrg	      fi
6983994689c1Smrg	    fi
6984994689c1Smrg	  else
6985994689c1Smrg	    deplibs="$dir/$old_library $deplibs"
6986994689c1Smrg	    link_static=yes
6987994689c1Smrg	  fi
6988994689c1Smrg	fi # link shared/static library?
6989994689c1Smrg
6990994689c1Smrg	if test "$linkmode" = lib; then
6991994689c1Smrg	  if test -n "$dependency_libs" &&
6992994689c1Smrg	     { test "$hardcode_into_libs" != yes ||
6993994689c1Smrg	       test "$build_old_libs" = yes ||
6994994689c1Smrg	       test "$link_static" = yes; }; then
6995994689c1Smrg	    # Extract -R from dependency_libs
6996994689c1Smrg	    temp_deplibs=
6997994689c1Smrg	    for libdir in $dependency_libs; do
6998994689c1Smrg	      case $libdir in
6999994689c1Smrg	      -R*) func_stripname '-R' '' "$libdir"
7000994689c1Smrg	           temp_xrpath=$func_stripname_result
7001994689c1Smrg		   case " $xrpath " in
7002994689c1Smrg		   *" $temp_xrpath "*) ;;
7003f353fbadSmrg		   *) func_append xrpath " $temp_xrpath";;
7004994689c1Smrg		   esac;;
7005f353fbadSmrg	      *) func_append temp_deplibs " $libdir";;
7006994689c1Smrg	      esac
7007994689c1Smrg	    done
7008994689c1Smrg	    dependency_libs="$temp_deplibs"
7009994689c1Smrg	  fi
7010994689c1Smrg
7011f353fbadSmrg	  func_append newlib_search_path " $absdir"
7012994689c1Smrg	  # Link against this library
7013994689c1Smrg	  test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
7014994689c1Smrg	  # ... and its dependency_libs
7015994689c1Smrg	  tmp_libs=
7016994689c1Smrg	  for deplib in $dependency_libs; do
7017994689c1Smrg	    newdependency_libs="$deplib $newdependency_libs"
7018f353fbadSmrg	    case $deplib in
7019f353fbadSmrg              -L*) func_stripname '-L' '' "$deplib"
7020f353fbadSmrg                   func_resolve_sysroot "$func_stripname_result";;
7021f353fbadSmrg              *) func_resolve_sysroot "$deplib" ;;
7022f353fbadSmrg            esac
7023f353fbadSmrg	    if $opt_preserve_dup_deps ; then
7024994689c1Smrg	      case "$tmp_libs " in
7025f353fbadSmrg	      *" $func_resolve_sysroot_result "*)
7026f353fbadSmrg                func_append specialdeplibs " $func_resolve_sysroot_result" ;;
7027994689c1Smrg	      esac
7028994689c1Smrg	    fi
7029f353fbadSmrg	    func_append tmp_libs " $func_resolve_sysroot_result"
7030994689c1Smrg	  done
7031994689c1Smrg
7032994689c1Smrg	  if test "$link_all_deplibs" != no; then
7033994689c1Smrg	    # Add the search paths of all dependency libraries
7034994689c1Smrg	    for deplib in $dependency_libs; do
7035994689c1Smrg	      path=
7036994689c1Smrg	      case $deplib in
7037994689c1Smrg	      -L*) path="$deplib" ;;
7038994689c1Smrg	      *.la)
7039f353fbadSmrg	        func_resolve_sysroot "$deplib"
7040f353fbadSmrg	        deplib=$func_resolve_sysroot_result
7041994689c1Smrg	        func_dirname "$deplib" "" "."
7042f353fbadSmrg		dir=$func_dirname_result
7043994689c1Smrg		# We need an absolute path.
7044994689c1Smrg		case $dir in
7045994689c1Smrg		[\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
7046994689c1Smrg		*)
7047994689c1Smrg		  absdir=`cd "$dir" && pwd`
7048994689c1Smrg		  if test -z "$absdir"; then
7049994689c1Smrg		    func_warning "cannot determine absolute directory name of \`$dir'"
7050994689c1Smrg		    absdir="$dir"
7051994689c1Smrg		  fi
7052994689c1Smrg		  ;;
7053994689c1Smrg		esac
7054994689c1Smrg		if $GREP "^installed=no" $deplib > /dev/null; then
7055994689c1Smrg		case $host in
7056994689c1Smrg		*-*-darwin*)
7057994689c1Smrg		  depdepl=
7058994689c1Smrg		  eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
7059994689c1Smrg		  if test -n "$deplibrary_names" ; then
7060994689c1Smrg		    for tmp in $deplibrary_names ; do
7061994689c1Smrg		      depdepl=$tmp
7062994689c1Smrg		    done
7063994689c1Smrg		    if test -f "$absdir/$objdir/$depdepl" ; then
7064994689c1Smrg		      depdepl="$absdir/$objdir/$depdepl"
7065994689c1Smrg		      darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
7066994689c1Smrg                      if test -z "$darwin_install_name"; then
7067994689c1Smrg                          darwin_install_name=`${OTOOL64} -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
7068994689c1Smrg                      fi
7069f353fbadSmrg		      func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}"
7070f353fbadSmrg		      func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}"
7071994689c1Smrg		      path=
7072994689c1Smrg		    fi
7073994689c1Smrg		  fi
7074994689c1Smrg		  ;;
7075994689c1Smrg		*)
7076994689c1Smrg		  path="-L$absdir/$objdir"
7077994689c1Smrg		  ;;
7078994689c1Smrg		esac
7079994689c1Smrg		else
7080994689c1Smrg		  eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
7081994689c1Smrg		  test -z "$libdir" && \
7082994689c1Smrg		    func_fatal_error "\`$deplib' is not a valid libtool archive"
7083994689c1Smrg		  test "$absdir" != "$libdir" && \
7084994689c1Smrg		    func_warning "\`$deplib' seems to be moved"
7085994689c1Smrg
7086994689c1Smrg		  path="-L$absdir"
7087994689c1Smrg		fi
7088994689c1Smrg		;;
7089994689c1Smrg	      esac
7090994689c1Smrg	      case " $deplibs " in
7091994689c1Smrg	      *" $path "*) ;;
7092994689c1Smrg	      *) deplibs="$path $deplibs" ;;
7093994689c1Smrg	      esac
7094994689c1Smrg	    done
7095994689c1Smrg	  fi # link_all_deplibs != no
7096994689c1Smrg	fi # linkmode = lib
7097994689c1Smrg      done # for deplib in $libs
7098994689c1Smrg      if test "$pass" = link; then
7099994689c1Smrg	if test "$linkmode" = "prog"; then
7100994689c1Smrg	  compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
7101994689c1Smrg	  finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
7102994689c1Smrg	else
7103994689c1Smrg	  compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
7104994689c1Smrg	fi
7105994689c1Smrg      fi
7106994689c1Smrg      dependency_libs="$newdependency_libs"
7107994689c1Smrg      if test "$pass" = dlpreopen; then
7108994689c1Smrg	# Link the dlpreopened libraries before other libraries
7109994689c1Smrg	for deplib in $save_deplibs; do
7110994689c1Smrg	  deplibs="$deplib $deplibs"
7111994689c1Smrg	done
7112994689c1Smrg      fi
7113994689c1Smrg      if test "$pass" != dlopen; then
7114994689c1Smrg	if test "$pass" != conv; then
7115994689c1Smrg	  # Make sure lib_search_path contains only unique directories.
7116994689c1Smrg	  lib_search_path=
7117994689c1Smrg	  for dir in $newlib_search_path; do
7118994689c1Smrg	    case "$lib_search_path " in
7119994689c1Smrg	    *" $dir "*) ;;
7120f353fbadSmrg	    *) func_append lib_search_path " $dir" ;;
7121994689c1Smrg	    esac
7122994689c1Smrg	  done
7123994689c1Smrg	  newlib_search_path=
7124994689c1Smrg	fi
7125994689c1Smrg
7126994689c1Smrg	if test "$linkmode,$pass" != "prog,link"; then
7127994689c1Smrg	  vars="deplibs"
7128994689c1Smrg	else
7129994689c1Smrg	  vars="compile_deplibs finalize_deplibs"
7130994689c1Smrg	fi
7131994689c1Smrg	for var in $vars dependency_libs; do
7132994689c1Smrg	  # Add libraries to $var in reverse order
7133994689c1Smrg	  eval tmp_libs=\"\$$var\"
7134994689c1Smrg	  new_libs=
7135994689c1Smrg	  for deplib in $tmp_libs; do
7136994689c1Smrg	    # FIXME: Pedantically, this is the right thing to do, so
7137994689c1Smrg	    #        that some nasty dependency loop isn't accidentally
7138994689c1Smrg	    #        broken:
7139994689c1Smrg	    #new_libs="$deplib $new_libs"
7140994689c1Smrg	    # Pragmatically, this seems to cause very few problems in
7141994689c1Smrg	    # practice:
7142994689c1Smrg	    case $deplib in
7143994689c1Smrg	    -L*) new_libs="$deplib $new_libs" ;;
7144994689c1Smrg	    -R*) ;;
7145994689c1Smrg	    *)
7146994689c1Smrg	      # And here is the reason: when a library appears more
7147994689c1Smrg	      # than once as an explicit dependence of a library, or
7148994689c1Smrg	      # is implicitly linked in more than once by the
7149994689c1Smrg	      # compiler, it is considered special, and multiple
7150994689c1Smrg	      # occurrences thereof are not removed.  Compare this
7151994689c1Smrg	      # with having the same library being listed as a
7152994689c1Smrg	      # dependency of multiple other libraries: in this case,
7153994689c1Smrg	      # we know (pedantically, we assume) the library does not
7154994689c1Smrg	      # need to be listed more than once, so we keep only the
7155994689c1Smrg	      # last copy.  This is not always right, but it is rare
7156994689c1Smrg	      # enough that we require users that really mean to play
7157994689c1Smrg	      # such unportable linking tricks to link the library
7158994689c1Smrg	      # using -Wl,-lname, so that libtool does not consider it
7159994689c1Smrg	      # for duplicate removal.
7160994689c1Smrg	      case " $specialdeplibs " in
7161994689c1Smrg	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
7162994689c1Smrg	      *)
7163994689c1Smrg		case " $new_libs " in
7164994689c1Smrg		*" $deplib "*) ;;
7165994689c1Smrg		*) new_libs="$deplib $new_libs" ;;
7166994689c1Smrg		esac
7167994689c1Smrg		;;
7168994689c1Smrg	      esac
7169994689c1Smrg	      ;;
7170994689c1Smrg	    esac
7171994689c1Smrg	  done
7172994689c1Smrg	  tmp_libs=
7173994689c1Smrg	  for deplib in $new_libs; do
7174994689c1Smrg	    case $deplib in
7175994689c1Smrg	    -L*)
7176994689c1Smrg	      case " $tmp_libs " in
7177994689c1Smrg	      *" $deplib "*) ;;
7178f353fbadSmrg	      *) func_append tmp_libs " $deplib" ;;
7179994689c1Smrg	      esac
7180994689c1Smrg	      ;;
7181f353fbadSmrg	    *) func_append tmp_libs " $deplib" ;;
7182994689c1Smrg	    esac
7183994689c1Smrg	  done
7184994689c1Smrg	  eval $var=\"$tmp_libs\"
7185994689c1Smrg	done # for var
7186994689c1Smrg      fi
7187994689c1Smrg      # Last step: remove runtime libs from dependency_libs
7188994689c1Smrg      # (they stay in deplibs)
7189994689c1Smrg      tmp_libs=
7190994689c1Smrg      for i in $dependency_libs ; do
7191994689c1Smrg	case " $predeps $postdeps $compiler_lib_search_path " in
7192994689c1Smrg	*" $i "*)
7193994689c1Smrg	  i=""
7194994689c1Smrg	  ;;
7195994689c1Smrg	esac
7196994689c1Smrg	if test -n "$i" ; then
7197f353fbadSmrg	  func_append tmp_libs " $i"
7198994689c1Smrg	fi
7199994689c1Smrg      done
7200994689c1Smrg      dependency_libs=$tmp_libs
7201994689c1Smrg    done # for pass
7202994689c1Smrg    if test "$linkmode" = prog; then
7203994689c1Smrg      dlfiles="$newdlfiles"
7204994689c1Smrg    fi
7205994689c1Smrg    if test "$linkmode" = prog || test "$linkmode" = lib; then
7206994689c1Smrg      dlprefiles="$newdlprefiles"
7207994689c1Smrg    fi
7208994689c1Smrg
7209994689c1Smrg    case $linkmode in
7210994689c1Smrg    oldlib)
7211994689c1Smrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
7212994689c1Smrg	func_warning "\`-dlopen' is ignored for archives"
7213994689c1Smrg      fi
7214994689c1Smrg
7215994689c1Smrg      case " $deplibs" in
7216994689c1Smrg      *\ -l* | *\ -L*)
7217994689c1Smrg	func_warning "\`-l' and \`-L' are ignored for archives" ;;
7218994689c1Smrg      esac
7219994689c1Smrg
7220994689c1Smrg      test -n "$rpath" && \
7221994689c1Smrg	func_warning "\`-rpath' is ignored for archives"
7222994689c1Smrg
7223994689c1Smrg      test -n "$xrpath" && \
7224994689c1Smrg	func_warning "\`-R' is ignored for archives"
7225994689c1Smrg
7226994689c1Smrg      test -n "$vinfo" && \
7227994689c1Smrg	func_warning "\`-version-info/-version-number' is ignored for archives"
7228994689c1Smrg
7229994689c1Smrg      test -n "$release" && \
7230994689c1Smrg	func_warning "\`-release' is ignored for archives"
7231994689c1Smrg
7232994689c1Smrg      test -n "$export_symbols$export_symbols_regex" && \
7233994689c1Smrg	func_warning "\`-export-symbols' is ignored for archives"
7234994689c1Smrg
7235994689c1Smrg      # Now set the variables for building old libraries.
7236994689c1Smrg      build_libtool_libs=no
7237994689c1Smrg      oldlibs="$output"
7238f353fbadSmrg      func_append objs "$old_deplibs"
7239994689c1Smrg      ;;
7240994689c1Smrg
7241994689c1Smrg    lib)
7242994689c1Smrg      # Make sure we only generate libraries of the form `libNAME.la'.
7243994689c1Smrg      case $outputname in
7244994689c1Smrg      lib*)
7245994689c1Smrg	func_stripname 'lib' '.la' "$outputname"
7246994689c1Smrg	name=$func_stripname_result
7247994689c1Smrg	eval shared_ext=\"$shrext_cmds\"
7248994689c1Smrg	eval libname=\"$libname_spec\"
7249994689c1Smrg	;;
7250994689c1Smrg      *)
7251994689c1Smrg	test "$module" = no && \
7252994689c1Smrg	  func_fatal_help "libtool library \`$output' must begin with \`lib'"
7253994689c1Smrg
7254994689c1Smrg	if test "$need_lib_prefix" != no; then
7255994689c1Smrg	  # Add the "lib" prefix for modules if required
7256994689c1Smrg	  func_stripname '' '.la' "$outputname"
7257994689c1Smrg	  name=$func_stripname_result
7258994689c1Smrg	  eval shared_ext=\"$shrext_cmds\"
7259994689c1Smrg	  eval libname=\"$libname_spec\"
7260994689c1Smrg	else
7261994689c1Smrg	  func_stripname '' '.la' "$outputname"
7262994689c1Smrg	  libname=$func_stripname_result
7263994689c1Smrg	fi
7264994689c1Smrg	;;
7265994689c1Smrg      esac
7266994689c1Smrg
7267994689c1Smrg      if test -n "$objs"; then
7268994689c1Smrg	if test "$deplibs_check_method" != pass_all; then
7269994689c1Smrg	  func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs"
7270994689c1Smrg	else
7271994689c1Smrg	  echo
7272994689c1Smrg	  $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
7273994689c1Smrg	  $ECHO "*** objects $objs is not portable!"
7274f353fbadSmrg	  func_append libobjs " $objs"
7275994689c1Smrg	fi
7276994689c1Smrg      fi
7277994689c1Smrg
7278994689c1Smrg      test "$dlself" != no && \
7279994689c1Smrg	func_warning "\`-dlopen self' is ignored for libtool libraries"
7280994689c1Smrg
7281994689c1Smrg      set dummy $rpath
7282994689c1Smrg      shift
7283994689c1Smrg      test "$#" -gt 1 && \
7284994689c1Smrg	func_warning "ignoring multiple \`-rpath's for a libtool library"
7285994689c1Smrg
7286994689c1Smrg      install_libdir="$1"
7287994689c1Smrg
7288994689c1Smrg      oldlibs=
7289994689c1Smrg      if test -z "$rpath"; then
7290994689c1Smrg	if test "$build_libtool_libs" = yes; then
7291994689c1Smrg	  # Building a libtool convenience library.
7292994689c1Smrg	  # Some compilers have problems with a `.al' extension so
7293994689c1Smrg	  # convenience libraries should have the same extension an
7294994689c1Smrg	  # archive normally would.
7295994689c1Smrg	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
7296994689c1Smrg	  build_libtool_libs=convenience
7297994689c1Smrg	  build_old_libs=yes
7298994689c1Smrg	fi
7299994689c1Smrg
7300994689c1Smrg	test -n "$vinfo" && \
7301994689c1Smrg	  func_warning "\`-version-info/-version-number' is ignored for convenience libraries"
7302994689c1Smrg
7303994689c1Smrg	test -n "$release" && \
7304994689c1Smrg	  func_warning "\`-release' is ignored for convenience libraries"
7305994689c1Smrg      else
7306994689c1Smrg
7307994689c1Smrg	# Parse the version information argument.
7308994689c1Smrg	save_ifs="$IFS"; IFS=':'
7309994689c1Smrg	set dummy $vinfo 0 0 0
7310994689c1Smrg	shift
7311994689c1Smrg	IFS="$save_ifs"
7312994689c1Smrg
7313994689c1Smrg	test -n "$7" && \
7314994689c1Smrg	  func_fatal_help "too many parameters to \`-version-info'"
7315994689c1Smrg
7316994689c1Smrg	# convert absolute version numbers to libtool ages
7317994689c1Smrg	# this retains compatibility with .la files and attempts
7318994689c1Smrg	# to make the code below a bit more comprehensible
7319994689c1Smrg
7320994689c1Smrg	case $vinfo_number in
7321994689c1Smrg	yes)
7322994689c1Smrg	  number_major="$1"
7323994689c1Smrg	  number_minor="$2"
7324994689c1Smrg	  number_revision="$3"
7325994689c1Smrg	  #
7326994689c1Smrg	  # There are really only two kinds -- those that
7327994689c1Smrg	  # use the current revision as the major version
7328994689c1Smrg	  # and those that subtract age and use age as
7329994689c1Smrg	  # a minor version.  But, then there is irix
7330994689c1Smrg	  # which has an extra 1 added just for fun
7331994689c1Smrg	  #
7332994689c1Smrg	  case $version_type in
7333421c997bSmrg	  # correct linux to gnu/linux during the next big refactor
7334994689c1Smrg	  darwin|linux|osf|windows|none)
7335994689c1Smrg	    func_arith $number_major + $number_minor
7336994689c1Smrg	    current=$func_arith_result
7337994689c1Smrg	    age="$number_minor"
7338994689c1Smrg	    revision="$number_revision"
7339994689c1Smrg	    ;;
7340994689c1Smrg	  freebsd-aout|freebsd-elf|qnx|sunos)
7341994689c1Smrg	    current="$number_major"
7342994689c1Smrg	    revision="$number_minor"
7343994689c1Smrg	    age="0"
7344994689c1Smrg	    ;;
7345994689c1Smrg	  irix|nonstopux)
7346994689c1Smrg	    func_arith $number_major + $number_minor
7347994689c1Smrg	    current=$func_arith_result
7348994689c1Smrg	    age="$number_minor"
7349994689c1Smrg	    revision="$number_minor"
7350994689c1Smrg	    lt_irix_increment=no
7351994689c1Smrg	    ;;
7352994689c1Smrg	  esac
7353994689c1Smrg	  ;;
7354994689c1Smrg	no)
7355994689c1Smrg	  current="$1"
7356994689c1Smrg	  revision="$2"
7357994689c1Smrg	  age="$3"
7358994689c1Smrg	  ;;
7359994689c1Smrg	esac
7360994689c1Smrg
7361994689c1Smrg	# Check that each of the things are valid numbers.
7362994689c1Smrg	case $current in
7363994689c1Smrg	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]) ;;
7364994689c1Smrg	*)
7365994689c1Smrg	  func_error "CURRENT \`$current' must be a nonnegative integer"
7366994689c1Smrg	  func_fatal_error "\`$vinfo' is not valid version information"
7367994689c1Smrg	  ;;
7368994689c1Smrg	esac
7369994689c1Smrg
7370994689c1Smrg	case $revision in
7371994689c1Smrg	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]) ;;
7372994689c1Smrg	*)
7373994689c1Smrg	  func_error "REVISION \`$revision' must be a nonnegative integer"
7374994689c1Smrg	  func_fatal_error "\`$vinfo' is not valid version information"
7375994689c1Smrg	  ;;
7376994689c1Smrg	esac
7377994689c1Smrg
7378994689c1Smrg	case $age in
7379994689c1Smrg	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]) ;;
7380994689c1Smrg	*)
7381994689c1Smrg	  func_error "AGE \`$age' must be a nonnegative integer"
7382994689c1Smrg	  func_fatal_error "\`$vinfo' is not valid version information"
7383994689c1Smrg	  ;;
7384994689c1Smrg	esac
7385994689c1Smrg
7386994689c1Smrg	if test "$age" -gt "$current"; then
7387994689c1Smrg	  func_error "AGE \`$age' is greater than the current interface number \`$current'"
7388994689c1Smrg	  func_fatal_error "\`$vinfo' is not valid version information"
7389994689c1Smrg	fi
7390994689c1Smrg
7391994689c1Smrg	# Calculate the version variables.
7392994689c1Smrg	major=
7393994689c1Smrg	versuffix=
7394994689c1Smrg	verstring=
7395994689c1Smrg	case $version_type in
7396994689c1Smrg	none) ;;
7397994689c1Smrg
7398994689c1Smrg	darwin)
7399994689c1Smrg	  # Like Linux, but with the current version available in
7400994689c1Smrg	  # verstring for coding it into the library header
7401994689c1Smrg	  func_arith $current - $age
7402994689c1Smrg	  major=.$func_arith_result
7403994689c1Smrg	  versuffix="$major.$age.$revision"
7404994689c1Smrg	  # Darwin ld doesn't like 0 for these options...
7405994689c1Smrg	  func_arith $current + 1
7406994689c1Smrg	  minor_current=$func_arith_result
7407994689c1Smrg	  xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
7408994689c1Smrg	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
7409994689c1Smrg	  ;;
7410994689c1Smrg
7411994689c1Smrg	freebsd-aout)
7412994689c1Smrg	  major=".$current"
7413994689c1Smrg	  versuffix=".$current.$revision";
7414994689c1Smrg	  ;;
7415994689c1Smrg
7416994689c1Smrg	freebsd-elf)
7417994689c1Smrg	  major=".$current"
7418994689c1Smrg	  versuffix=".$current"
7419994689c1Smrg	  ;;
7420994689c1Smrg
7421994689c1Smrg	irix | nonstopux)
7422994689c1Smrg	  if test "X$lt_irix_increment" = "Xno"; then
7423994689c1Smrg	    func_arith $current - $age
7424994689c1Smrg	  else
7425994689c1Smrg	    func_arith $current - $age + 1
7426994689c1Smrg	  fi
7427994689c1Smrg	  major=$func_arith_result
7428994689c1Smrg
7429994689c1Smrg	  case $version_type in
7430994689c1Smrg	    nonstopux) verstring_prefix=nonstopux ;;
7431994689c1Smrg	    *)         verstring_prefix=sgi ;;
7432994689c1Smrg	  esac
7433994689c1Smrg	  verstring="$verstring_prefix$major.$revision"
7434994689c1Smrg
7435994689c1Smrg	  # Add in all the interfaces that we are compatible with.
7436994689c1Smrg	  loop=$revision
7437994689c1Smrg	  while test "$loop" -ne 0; do
7438994689c1Smrg	    func_arith $revision - $loop
7439994689c1Smrg	    iface=$func_arith_result
7440994689c1Smrg	    func_arith $loop - 1
7441994689c1Smrg	    loop=$func_arith_result
7442994689c1Smrg	    verstring="$verstring_prefix$major.$iface:$verstring"
7443994689c1Smrg	  done
7444994689c1Smrg
7445994689c1Smrg	  # Before this point, $major must not contain `.'.
7446994689c1Smrg	  major=.$major
7447994689c1Smrg	  versuffix="$major.$revision"
7448994689c1Smrg	  ;;
7449994689c1Smrg
7450421c997bSmrg	linux) # correct to gnu/linux during the next big refactor
7451994689c1Smrg	  func_arith $current - $age
7452994689c1Smrg	  major=.$func_arith_result
7453994689c1Smrg	  versuffix="$major.$age.$revision"
7454994689c1Smrg	  ;;
7455994689c1Smrg
7456994689c1Smrg	osf)
7457994689c1Smrg	  func_arith $current - $age
7458994689c1Smrg	  major=.$func_arith_result
7459994689c1Smrg	  versuffix=".$current.$age.$revision"
7460994689c1Smrg	  verstring="$current.$age.$revision"
7461994689c1Smrg
7462994689c1Smrg	  # Add in all the interfaces that we are compatible with.
7463994689c1Smrg	  loop=$age
7464994689c1Smrg	  while test "$loop" -ne 0; do
7465994689c1Smrg	    func_arith $current - $loop
7466994689c1Smrg	    iface=$func_arith_result
7467994689c1Smrg	    func_arith $loop - 1
7468994689c1Smrg	    loop=$func_arith_result
7469994689c1Smrg	    verstring="$verstring:${iface}.0"
7470994689c1Smrg	  done
7471994689c1Smrg
7472994689c1Smrg	  # Make executables depend on our current version.
7473f353fbadSmrg	  func_append verstring ":${current}.0"
7474994689c1Smrg	  ;;
7475994689c1Smrg
7476994689c1Smrg	qnx)
7477994689c1Smrg	  major=".$current"
7478994689c1Smrg	  versuffix=".$current"
7479994689c1Smrg	  ;;
7480994689c1Smrg
7481994689c1Smrg	sunos)
7482994689c1Smrg	  major=".$current"
7483994689c1Smrg	  versuffix=".$current.$revision"
7484994689c1Smrg	  ;;
7485994689c1Smrg
7486994689c1Smrg	windows)
7487994689c1Smrg	  # Use '-' rather than '.', since we only want one
7488994689c1Smrg	  # extension on DOS 8.3 filesystems.
7489994689c1Smrg	  func_arith $current - $age
7490994689c1Smrg	  major=$func_arith_result
7491994689c1Smrg	  versuffix="-$major"
7492994689c1Smrg	  ;;
7493994689c1Smrg
7494994689c1Smrg	*)
7495994689c1Smrg	  func_fatal_configuration "unknown library version type \`$version_type'"
7496994689c1Smrg	  ;;
7497994689c1Smrg	esac
7498994689c1Smrg
7499994689c1Smrg	# Clear the version info if we defaulted, and they specified a release.
7500994689c1Smrg	if test -z "$vinfo" && test -n "$release"; then
7501994689c1Smrg	  major=
7502994689c1Smrg	  case $version_type in
7503994689c1Smrg	  darwin)
7504994689c1Smrg	    # we can't check for "0.0" in archive_cmds due to quoting
7505994689c1Smrg	    # problems, so we reset it completely
7506994689c1Smrg	    verstring=
7507994689c1Smrg	    ;;
7508994689c1Smrg	  *)
7509994689c1Smrg	    verstring="0.0"
7510994689c1Smrg	    ;;
7511994689c1Smrg	  esac
7512994689c1Smrg	  if test "$need_version" = no; then
7513994689c1Smrg	    versuffix=
7514994689c1Smrg	  else
7515994689c1Smrg	    versuffix=".0.0"
7516994689c1Smrg	  fi
7517994689c1Smrg	fi
7518994689c1Smrg
7519994689c1Smrg	# Remove version info from name if versioning should be avoided
7520994689c1Smrg	if test "$avoid_version" = yes && test "$need_version" = no; then
7521994689c1Smrg	  major=
7522994689c1Smrg	  versuffix=
7523994689c1Smrg	  verstring=""
7524994689c1Smrg	fi
7525994689c1Smrg
7526994689c1Smrg	# Check to see if the archive will have undefined symbols.
7527994689c1Smrg	if test "$allow_undefined" = yes; then
7528994689c1Smrg	  if test "$allow_undefined_flag" = unsupported; then
7529994689c1Smrg	    func_warning "undefined symbols not allowed in $host shared libraries"
7530994689c1Smrg	    build_libtool_libs=no
7531994689c1Smrg	    build_old_libs=yes
7532994689c1Smrg	  fi
7533994689c1Smrg	else
7534994689c1Smrg	  # Don't allow undefined symbols.
7535994689c1Smrg	  allow_undefined_flag="$no_undefined_flag"
7536994689c1Smrg	fi
7537994689c1Smrg
7538994689c1Smrg      fi
7539994689c1Smrg
7540994689c1Smrg      func_generate_dlsyms "$libname" "$libname" "yes"
7541f353fbadSmrg      func_append libobjs " $symfileobj"
7542994689c1Smrg      test "X$libobjs" = "X " && libobjs=
7543994689c1Smrg
7544f353fbadSmrg      if test "$opt_mode" != relink; then
7545994689c1Smrg	# Remove our outputs, but don't remove object files since they
7546994689c1Smrg	# may have been created when compiling PIC objects.
7547994689c1Smrg	removelist=
7548994689c1Smrg	tempremovelist=`$ECHO "$output_objdir/*"`
7549994689c1Smrg	for p in $tempremovelist; do
7550994689c1Smrg	  case $p in
7551994689c1Smrg	    *.$objext | *.gcno)
7552994689c1Smrg	       ;;
7553994689c1Smrg	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
7554994689c1Smrg	       if test "X$precious_files_regex" != "X"; then
7555994689c1Smrg		 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
7556994689c1Smrg		 then
7557994689c1Smrg		   continue
7558994689c1Smrg		 fi
7559994689c1Smrg	       fi
7560f353fbadSmrg	       func_append removelist " $p"
7561994689c1Smrg	       ;;
7562994689c1Smrg	    *) ;;
7563994689c1Smrg	  esac
7564994689c1Smrg	done
7565994689c1Smrg	test -n "$removelist" && \
7566994689c1Smrg	  func_show_eval "${RM}r \$removelist"
7567994689c1Smrg      fi
7568994689c1Smrg
7569994689c1Smrg      # Now set the variables for building old libraries.
7570994689c1Smrg      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
7571f353fbadSmrg	func_append oldlibs " $output_objdir/$libname.$libext"
7572994689c1Smrg
7573994689c1Smrg	# Transform .lo files to .o files.
7574994689c1Smrg	oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP`
7575994689c1Smrg      fi
7576994689c1Smrg
7577994689c1Smrg      # Eliminate all temporary directories.
7578994689c1Smrg      #for path in $notinst_path; do
7579994689c1Smrg      #	lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
7580994689c1Smrg      #	deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
7581994689c1Smrg      #	dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
7582994689c1Smrg      #done
7583994689c1Smrg
7584994689c1Smrg      if test -n "$xrpath"; then
7585994689c1Smrg	# If the user specified any rpath flags, then add them.
7586994689c1Smrg	temp_xrpath=
7587994689c1Smrg	for libdir in $xrpath; do
7588f353fbadSmrg	  func_replace_sysroot "$libdir"
7589f353fbadSmrg	  func_append temp_xrpath " -R$func_replace_sysroot_result"
7590994689c1Smrg	  case "$finalize_rpath " in
7591994689c1Smrg	  *" $libdir "*) ;;
7592f353fbadSmrg	  *) func_append finalize_rpath " $libdir" ;;
7593994689c1Smrg	  esac
7594994689c1Smrg	done
7595994689c1Smrg	if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
7596994689c1Smrg	  dependency_libs="$temp_xrpath $dependency_libs"
7597994689c1Smrg	fi
7598994689c1Smrg      fi
7599994689c1Smrg
7600994689c1Smrg      # Make sure dlfiles contains only unique files that won't be dlpreopened
7601994689c1Smrg      old_dlfiles="$dlfiles"
7602994689c1Smrg      dlfiles=
7603994689c1Smrg      for lib in $old_dlfiles; do
7604994689c1Smrg	case " $dlprefiles $dlfiles " in
7605994689c1Smrg	*" $lib "*) ;;
7606f353fbadSmrg	*) func_append dlfiles " $lib" ;;
7607994689c1Smrg	esac
7608994689c1Smrg      done
7609994689c1Smrg
7610994689c1Smrg      # Make sure dlprefiles contains only unique files
7611994689c1Smrg      old_dlprefiles="$dlprefiles"
7612994689c1Smrg      dlprefiles=
7613994689c1Smrg      for lib in $old_dlprefiles; do
7614994689c1Smrg	case "$dlprefiles " in
7615994689c1Smrg	*" $lib "*) ;;
7616f353fbadSmrg	*) func_append dlprefiles " $lib" ;;
7617994689c1Smrg	esac
7618994689c1Smrg      done
7619994689c1Smrg
7620994689c1Smrg      if test "$build_libtool_libs" = yes; then
7621994689c1Smrg	if test -n "$rpath"; then
7622994689c1Smrg	  case $host in
7623994689c1Smrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
7624994689c1Smrg	    # these systems don't actually have a c library (as such)!
7625994689c1Smrg	    ;;
7626994689c1Smrg	  *-*-rhapsody* | *-*-darwin1.[012])
7627994689c1Smrg	    # Rhapsody C library is in the System framework
7628f353fbadSmrg	    func_append deplibs " System.ltframework"
7629994689c1Smrg	    ;;
7630994689c1Smrg	  *-*-netbsd*)
7631994689c1Smrg	    # Don't link with libc until the a.out ld.so is fixed.
7632994689c1Smrg	    ;;
7633994689c1Smrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
7634994689c1Smrg	    # Do not include libc due to us having libc/libc_r.
7635994689c1Smrg	    ;;
7636994689c1Smrg	  *-*-sco3.2v5* | *-*-sco5v6*)
7637994689c1Smrg	    # Causes problems with __ctype
7638994689c1Smrg	    ;;
7639994689c1Smrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
7640994689c1Smrg	    # Compiler inserts libc in the correct place for threads to work
7641994689c1Smrg	    ;;
7642994689c1Smrg	  *)
7643994689c1Smrg	    # Add libc to deplibs on all other systems if necessary.
7644994689c1Smrg	    if test "$build_libtool_need_lc" = "yes"; then
7645f353fbadSmrg	      func_append deplibs " -lc"
7646994689c1Smrg	    fi
7647994689c1Smrg	    ;;
7648994689c1Smrg	  esac
7649994689c1Smrg	fi
7650994689c1Smrg
7651994689c1Smrg	# Transform deplibs into only deplibs that can be linked in shared.
7652994689c1Smrg	name_save=$name
7653994689c1Smrg	libname_save=$libname
7654994689c1Smrg	release_save=$release
7655994689c1Smrg	versuffix_save=$versuffix
7656994689c1Smrg	major_save=$major
7657994689c1Smrg	# I'm not sure if I'm treating the release correctly.  I think
7658994689c1Smrg	# release should show up in the -l (ie -lgmp5) so we don't want to
7659994689c1Smrg	# add it in twice.  Is that correct?
7660994689c1Smrg	release=""
7661994689c1Smrg	versuffix=""
7662994689c1Smrg	major=""
7663994689c1Smrg	newdeplibs=
7664994689c1Smrg	droppeddeps=no
7665994689c1Smrg	case $deplibs_check_method in
7666994689c1Smrg	pass_all)
7667994689c1Smrg	  # Don't check for shared/static.  Everything works.
7668994689c1Smrg	  # This might be a little naive.  We might want to check
7669994689c1Smrg	  # whether the library exists or not.  But this is on
7670994689c1Smrg	  # osf3 & osf4 and I'm not really sure... Just
7671994689c1Smrg	  # implementing what was already the behavior.
7672994689c1Smrg	  newdeplibs=$deplibs
7673994689c1Smrg	  ;;
7674994689c1Smrg	test_compile)
7675994689c1Smrg	  # This code stresses the "libraries are programs" paradigm to its
7676994689c1Smrg	  # limits. Maybe even breaks it.  We compile a program, linking it
7677994689c1Smrg	  # against the deplibs as a proxy for the library.  Then we can check
7678994689c1Smrg	  # whether they linked in statically or dynamically with ldd.
7679994689c1Smrg	  $opt_dry_run || $RM conftest.c
7680994689c1Smrg	  cat > conftest.c <<EOF
7681994689c1Smrg	  int main() { return 0; }
7682994689c1SmrgEOF
7683994689c1Smrg	  $opt_dry_run || $RM conftest
7684994689c1Smrg	  if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
7685994689c1Smrg	    ldd_output=`ldd conftest`
7686994689c1Smrg	    for i in $deplibs; do
7687994689c1Smrg	      case $i in
7688994689c1Smrg	      -l*)
7689994689c1Smrg		func_stripname -l '' "$i"
7690994689c1Smrg		name=$func_stripname_result
7691994689c1Smrg		if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7692994689c1Smrg		  case " $predeps $postdeps " in
7693994689c1Smrg		  *" $i "*)
7694f353fbadSmrg		    func_append newdeplibs " $i"
7695994689c1Smrg		    i=""
7696994689c1Smrg		    ;;
7697994689c1Smrg		  esac
7698994689c1Smrg		fi
7699994689c1Smrg		if test -n "$i" ; then
7700994689c1Smrg		  libname=`eval "\\$ECHO \"$libname_spec\""`
7701994689c1Smrg		  deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
7702994689c1Smrg		  set dummy $deplib_matches; shift
7703994689c1Smrg		  deplib_match=$1
7704994689c1Smrg		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
7705f353fbadSmrg		    func_append newdeplibs " $i"
7706994689c1Smrg		  else
7707994689c1Smrg		    droppeddeps=yes
7708994689c1Smrg		    echo
7709994689c1Smrg		    $ECHO "*** Warning: dynamic linker does not accept needed library $i."
7710994689c1Smrg		    echo "*** I have the capability to make that library automatically link in when"
7711994689c1Smrg		    echo "*** you link to this library.  But I can only do this if you have a"
7712994689c1Smrg		    echo "*** shared version of the library, which I believe you do not have"
7713994689c1Smrg		    echo "*** because a test_compile did reveal that the linker did not use it for"
7714994689c1Smrg		    echo "*** its dynamic dependency list that programs get resolved with at runtime."
7715994689c1Smrg		  fi
7716994689c1Smrg		fi
7717994689c1Smrg		;;
7718994689c1Smrg	      *)
7719f353fbadSmrg		func_append newdeplibs " $i"
7720994689c1Smrg		;;
7721994689c1Smrg	      esac
7722994689c1Smrg	    done
7723994689c1Smrg	  else
7724994689c1Smrg	    # Error occurred in the first compile.  Let's try to salvage
7725994689c1Smrg	    # the situation: Compile a separate program for each library.
7726994689c1Smrg	    for i in $deplibs; do
7727994689c1Smrg	      case $i in
7728994689c1Smrg	      -l*)
7729994689c1Smrg		func_stripname -l '' "$i"
7730994689c1Smrg		name=$func_stripname_result
7731994689c1Smrg		$opt_dry_run || $RM conftest
7732994689c1Smrg		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
7733994689c1Smrg		  ldd_output=`ldd conftest`
7734994689c1Smrg		  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7735994689c1Smrg		    case " $predeps $postdeps " in
7736994689c1Smrg		    *" $i "*)
7737f353fbadSmrg		      func_append newdeplibs " $i"
7738994689c1Smrg		      i=""
7739994689c1Smrg		      ;;
7740994689c1Smrg		    esac
7741994689c1Smrg		  fi
7742994689c1Smrg		  if test -n "$i" ; then
7743994689c1Smrg		    libname=`eval "\\$ECHO \"$libname_spec\""`
7744994689c1Smrg		    deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
7745994689c1Smrg		    set dummy $deplib_matches; shift
7746994689c1Smrg		    deplib_match=$1
7747994689c1Smrg		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
7748f353fbadSmrg		      func_append newdeplibs " $i"
7749994689c1Smrg		    else
7750994689c1Smrg		      droppeddeps=yes
7751994689c1Smrg		      echo
7752994689c1Smrg		      $ECHO "*** Warning: dynamic linker does not accept needed library $i."
7753994689c1Smrg		      echo "*** I have the capability to make that library automatically link in when"
7754994689c1Smrg		      echo "*** you link to this library.  But I can only do this if you have a"
7755994689c1Smrg		      echo "*** shared version of the library, which you do not appear to have"
7756994689c1Smrg		      echo "*** because a test_compile did reveal that the linker did not use this one"
7757994689c1Smrg		      echo "*** as a dynamic dependency that programs can get resolved with at runtime."
7758994689c1Smrg		    fi
7759994689c1Smrg		  fi
7760994689c1Smrg		else
7761994689c1Smrg		  droppeddeps=yes
7762994689c1Smrg		  echo
7763994689c1Smrg		  $ECHO "*** Warning!  Library $i is needed by this library but I was not able to"
7764994689c1Smrg		  echo "*** make it link in!  You will probably need to install it or some"
7765994689c1Smrg		  echo "*** library that it depends on before this library will be fully"
7766994689c1Smrg		  echo "*** functional.  Installing it before continuing would be even better."
7767994689c1Smrg		fi
7768994689c1Smrg		;;
7769994689c1Smrg	      *)
7770f353fbadSmrg		func_append newdeplibs " $i"
7771994689c1Smrg		;;
7772994689c1Smrg	      esac
7773994689c1Smrg	    done
7774994689c1Smrg	  fi
7775994689c1Smrg	  ;;
7776994689c1Smrg	file_magic*)
7777994689c1Smrg	  set dummy $deplibs_check_method; shift
7778994689c1Smrg	  file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
7779994689c1Smrg	  for a_deplib in $deplibs; do
7780994689c1Smrg	    case $a_deplib in
7781994689c1Smrg	    -l*)
7782994689c1Smrg	      func_stripname -l '' "$a_deplib"
7783994689c1Smrg	      name=$func_stripname_result
7784994689c1Smrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7785994689c1Smrg		case " $predeps $postdeps " in
7786994689c1Smrg		*" $a_deplib "*)
7787f353fbadSmrg		  func_append newdeplibs " $a_deplib"
7788994689c1Smrg		  a_deplib=""
7789994689c1Smrg		  ;;
7790994689c1Smrg		esac
7791994689c1Smrg	      fi
7792994689c1Smrg	      if test -n "$a_deplib" ; then
7793994689c1Smrg		libname=`eval "\\$ECHO \"$libname_spec\""`
7794f353fbadSmrg		if test -n "$file_magic_glob"; then
7795f353fbadSmrg		  libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob`
7796f353fbadSmrg		else
7797f353fbadSmrg		  libnameglob=$libname
7798f353fbadSmrg		fi
7799f353fbadSmrg		test "$want_nocaseglob" = yes && nocaseglob=`shopt -p nocaseglob`
7800994689c1Smrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
7801f353fbadSmrg		  if test "$want_nocaseglob" = yes; then
7802f353fbadSmrg		    shopt -s nocaseglob
7803f353fbadSmrg		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
7804f353fbadSmrg		    $nocaseglob
7805f353fbadSmrg		  else
7806f353fbadSmrg		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
7807f353fbadSmrg		  fi
7808994689c1Smrg		  for potent_lib in $potential_libs; do
7809994689c1Smrg		      # Follow soft links.
7810994689c1Smrg		      if ls -lLd "$potent_lib" 2>/dev/null |
7811994689c1Smrg			 $GREP " -> " >/dev/null; then
7812994689c1Smrg			continue
7813994689c1Smrg		      fi
7814994689c1Smrg		      # The statement above tries to avoid entering an
7815994689c1Smrg		      # endless loop below, in case of cyclic links.
7816994689c1Smrg		      # We might still enter an endless loop, since a link
7817994689c1Smrg		      # loop can be closed while we follow links,
7818994689c1Smrg		      # but so what?
7819994689c1Smrg		      potlib="$potent_lib"
7820994689c1Smrg		      while test -h "$potlib" 2>/dev/null; do
7821994689c1Smrg			potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
7822994689c1Smrg			case $potliblink in
7823994689c1Smrg			[\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
7824994689c1Smrg			*) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";;
7825994689c1Smrg			esac
7826994689c1Smrg		      done
7827994689c1Smrg		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
7828994689c1Smrg			 $SED -e 10q |
7829994689c1Smrg			 $EGREP "$file_magic_regex" > /dev/null; then
7830f353fbadSmrg			func_append newdeplibs " $a_deplib"
7831994689c1Smrg			a_deplib=""
7832994689c1Smrg			break 2
7833994689c1Smrg		      fi
7834994689c1Smrg		  done
7835994689c1Smrg		done
7836994689c1Smrg	      fi
7837994689c1Smrg	      if test -n "$a_deplib" ; then
7838994689c1Smrg		droppeddeps=yes
7839994689c1Smrg		echo
7840994689c1Smrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
7841994689c1Smrg		echo "*** I have the capability to make that library automatically link in when"
7842994689c1Smrg		echo "*** you link to this library.  But I can only do this if you have a"
7843994689c1Smrg		echo "*** shared version of the library, which you do not appear to have"
7844994689c1Smrg		echo "*** because I did check the linker path looking for a file starting"
7845994689c1Smrg		if test -z "$potlib" ; then
7846994689c1Smrg		  $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
7847994689c1Smrg		else
7848994689c1Smrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
7849994689c1Smrg		  $ECHO "*** using a file magic. Last file checked: $potlib"
7850994689c1Smrg		fi
7851994689c1Smrg	      fi
7852994689c1Smrg	      ;;
7853994689c1Smrg	    *)
7854994689c1Smrg	      # Add a -L argument.
7855f353fbadSmrg	      func_append newdeplibs " $a_deplib"
7856994689c1Smrg	      ;;
7857994689c1Smrg	    esac
7858994689c1Smrg	  done # Gone through all deplibs.
7859994689c1Smrg	  ;;
7860994689c1Smrg	match_pattern*)
7861994689c1Smrg	  set dummy $deplibs_check_method; shift
7862994689c1Smrg	  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
7863994689c1Smrg	  for a_deplib in $deplibs; do
7864994689c1Smrg	    case $a_deplib in
7865994689c1Smrg	    -l*)
7866994689c1Smrg	      func_stripname -l '' "$a_deplib"
7867994689c1Smrg	      name=$func_stripname_result
7868994689c1Smrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7869994689c1Smrg		case " $predeps $postdeps " in
7870994689c1Smrg		*" $a_deplib "*)
7871f353fbadSmrg		  func_append newdeplibs " $a_deplib"
7872994689c1Smrg		  a_deplib=""
7873994689c1Smrg		  ;;
7874994689c1Smrg		esac
7875994689c1Smrg	      fi
7876994689c1Smrg	      if test -n "$a_deplib" ; then
7877994689c1Smrg		libname=`eval "\\$ECHO \"$libname_spec\""`
7878994689c1Smrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
7879994689c1Smrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
7880994689c1Smrg		  for potent_lib in $potential_libs; do
7881994689c1Smrg		    potlib="$potent_lib" # see symlink-check above in file_magic test
7882994689c1Smrg		    if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
7883994689c1Smrg		       $EGREP "$match_pattern_regex" > /dev/null; then
7884f353fbadSmrg		      func_append newdeplibs " $a_deplib"
7885994689c1Smrg		      a_deplib=""
7886994689c1Smrg		      break 2
7887994689c1Smrg		    fi
7888994689c1Smrg		  done
7889994689c1Smrg		done
7890994689c1Smrg	      fi
7891994689c1Smrg	      if test -n "$a_deplib" ; then
7892994689c1Smrg		droppeddeps=yes
7893994689c1Smrg		echo
7894994689c1Smrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
7895994689c1Smrg		echo "*** I have the capability to make that library automatically link in when"
7896994689c1Smrg		echo "*** you link to this library.  But I can only do this if you have a"
7897994689c1Smrg		echo "*** shared version of the library, which you do not appear to have"
7898994689c1Smrg		echo "*** because I did check the linker path looking for a file starting"
7899994689c1Smrg		if test -z "$potlib" ; then
7900994689c1Smrg		  $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
7901994689c1Smrg		else
7902994689c1Smrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
7903994689c1Smrg		  $ECHO "*** using a regex pattern. Last file checked: $potlib"
7904994689c1Smrg		fi
7905994689c1Smrg	      fi
7906994689c1Smrg	      ;;
7907994689c1Smrg	    *)
7908994689c1Smrg	      # Add a -L argument.
7909f353fbadSmrg	      func_append newdeplibs " $a_deplib"
7910994689c1Smrg	      ;;
7911994689c1Smrg	    esac
7912994689c1Smrg	  done # Gone through all deplibs.
7913994689c1Smrg	  ;;
7914994689c1Smrg	none | unknown | *)
7915994689c1Smrg	  newdeplibs=""
7916994689c1Smrg	  tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
7917994689c1Smrg	  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7918994689c1Smrg	    for i in $predeps $postdeps ; do
7919994689c1Smrg	      # can't use Xsed below, because $i might contain '/'
7920994689c1Smrg	      tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"`
7921994689c1Smrg	    done
7922994689c1Smrg	  fi
7923994689c1Smrg	  case $tmp_deplibs in
7924994689c1Smrg	  *[!\	\ ]*)
7925994689c1Smrg	    echo
7926994689c1Smrg	    if test "X$deplibs_check_method" = "Xnone"; then
7927994689c1Smrg	      echo "*** Warning: inter-library dependencies are not supported in this platform."
7928994689c1Smrg	    else
7929994689c1Smrg	      echo "*** Warning: inter-library dependencies are not known to be supported."
7930994689c1Smrg	    fi
7931994689c1Smrg	    echo "*** All declared inter-library dependencies are being dropped."
7932994689c1Smrg	    droppeddeps=yes
7933994689c1Smrg	    ;;
7934994689c1Smrg	  esac
7935994689c1Smrg	  ;;
7936994689c1Smrg	esac
7937994689c1Smrg	versuffix=$versuffix_save
7938994689c1Smrg	major=$major_save
7939994689c1Smrg	release=$release_save
7940994689c1Smrg	libname=$libname_save
7941994689c1Smrg	name=$name_save
7942994689c1Smrg
7943994689c1Smrg	case $host in
7944994689c1Smrg	*-*-rhapsody* | *-*-darwin1.[012])
7945994689c1Smrg	  # On Rhapsody replace the C library with the System framework
7946994689c1Smrg	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
7947994689c1Smrg	  ;;
7948994689c1Smrg	esac
7949994689c1Smrg
7950994689c1Smrg	if test "$droppeddeps" = yes; then
7951994689c1Smrg	  if test "$module" = yes; then
7952994689c1Smrg	    echo
7953994689c1Smrg	    echo "*** Warning: libtool could not satisfy all declared inter-library"
7954994689c1Smrg	    $ECHO "*** dependencies of module $libname.  Therefore, libtool will create"
7955994689c1Smrg	    echo "*** a static module, that should work as long as the dlopening"
7956994689c1Smrg	    echo "*** application is linked with the -dlopen flag."
7957994689c1Smrg	    if test -z "$global_symbol_pipe"; then
7958994689c1Smrg	      echo
7959994689c1Smrg	      echo "*** However, this would only work if libtool was able to extract symbol"
7960994689c1Smrg	      echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
7961994689c1Smrg	      echo "*** not find such a program.  So, this module is probably useless."
7962994689c1Smrg	      echo "*** \`nm' from GNU binutils and a full rebuild may help."
7963994689c1Smrg	    fi
7964994689c1Smrg	    if test "$build_old_libs" = no; then
7965994689c1Smrg	      oldlibs="$output_objdir/$libname.$libext"
7966994689c1Smrg	      build_libtool_libs=module
7967994689c1Smrg	      build_old_libs=yes
7968994689c1Smrg	    else
7969994689c1Smrg	      build_libtool_libs=no
7970994689c1Smrg	    fi
7971994689c1Smrg	  else
7972994689c1Smrg	    echo "*** The inter-library dependencies that have been dropped here will be"
7973994689c1Smrg	    echo "*** automatically added whenever a program is linked with this library"
7974994689c1Smrg	    echo "*** or is declared to -dlopen it."
7975994689c1Smrg
7976994689c1Smrg	    if test "$allow_undefined" = no; then
7977994689c1Smrg	      echo
7978994689c1Smrg	      echo "*** Since this library must not contain undefined symbols,"
7979994689c1Smrg	      echo "*** because either the platform does not support them or"
7980994689c1Smrg	      echo "*** it was explicitly requested with -no-undefined,"
7981994689c1Smrg	      echo "*** libtool will only create a static version of it."
7982994689c1Smrg	      if test "$build_old_libs" = no; then
7983994689c1Smrg		oldlibs="$output_objdir/$libname.$libext"
7984994689c1Smrg		build_libtool_libs=module
7985994689c1Smrg		build_old_libs=yes
7986994689c1Smrg	      else
7987994689c1Smrg		build_libtool_libs=no
7988994689c1Smrg	      fi
7989994689c1Smrg	    fi
7990994689c1Smrg	  fi
7991994689c1Smrg	fi
7992994689c1Smrg	# Done checking deplibs!
7993994689c1Smrg	deplibs=$newdeplibs
7994994689c1Smrg      fi
7995994689c1Smrg      # Time to change all our "foo.ltframework" stuff back to "-framework foo"
7996994689c1Smrg      case $host in
7997994689c1Smrg	*-*-darwin*)
7998994689c1Smrg	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
7999994689c1Smrg	  new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8000994689c1Smrg	  deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8001994689c1Smrg	  ;;
8002994689c1Smrg      esac
8003994689c1Smrg
8004994689c1Smrg      # move library search paths that coincide with paths to not yet
8005994689c1Smrg      # installed libraries to the beginning of the library search list
8006994689c1Smrg      new_libs=
8007994689c1Smrg      for path in $notinst_path; do
8008994689c1Smrg	case " $new_libs " in
8009994689c1Smrg	*" -L$path/$objdir "*) ;;
8010994689c1Smrg	*)
8011994689c1Smrg	  case " $deplibs " in
8012994689c1Smrg	  *" -L$path/$objdir "*)
8013f353fbadSmrg	    func_append new_libs " -L$path/$objdir" ;;
8014994689c1Smrg	  esac
8015994689c1Smrg	  ;;
8016994689c1Smrg	esac
8017994689c1Smrg      done
8018994689c1Smrg      for deplib in $deplibs; do
8019994689c1Smrg	case $deplib in
8020994689c1Smrg	-L*)
8021994689c1Smrg	  case " $new_libs " in
8022994689c1Smrg	  *" $deplib "*) ;;
8023f353fbadSmrg	  *) func_append new_libs " $deplib" ;;
8024994689c1Smrg	  esac
8025994689c1Smrg	  ;;
8026f353fbadSmrg	*) func_append new_libs " $deplib" ;;
8027994689c1Smrg	esac
8028994689c1Smrg      done
8029994689c1Smrg      deplibs="$new_libs"
8030994689c1Smrg
8031994689c1Smrg      # All the library-specific variables (install_libdir is set above).
8032994689c1Smrg      library_names=
8033994689c1Smrg      old_library=
8034994689c1Smrg      dlname=
8035994689c1Smrg
8036994689c1Smrg      # Test again, we may have decided not to build it any more
8037994689c1Smrg      if test "$build_libtool_libs" = yes; then
8038421c997bSmrg	# Remove ${wl} instances when linking with ld.
8039421c997bSmrg	# FIXME: should test the right _cmds variable.
8040421c997bSmrg	case $archive_cmds in
8041421c997bSmrg	  *\$LD\ *) wl= ;;
8042421c997bSmrg        esac
8043994689c1Smrg	if test "$hardcode_into_libs" = yes; then
8044994689c1Smrg	  # Hardcode the library paths
8045994689c1Smrg	  hardcode_libdirs=
8046994689c1Smrg	  dep_rpath=
8047994689c1Smrg	  rpath="$finalize_rpath"
8048f353fbadSmrg	  test "$opt_mode" != relink && rpath="$compile_rpath$rpath"
8049994689c1Smrg	  for libdir in $rpath; do
8050994689c1Smrg	    if test -n "$hardcode_libdir_flag_spec"; then
8051994689c1Smrg	      if test -n "$hardcode_libdir_separator"; then
8052f353fbadSmrg		func_replace_sysroot "$libdir"
8053f353fbadSmrg		libdir=$func_replace_sysroot_result
8054994689c1Smrg		if test -z "$hardcode_libdirs"; then
8055994689c1Smrg		  hardcode_libdirs="$libdir"
8056994689c1Smrg		else
8057994689c1Smrg		  # Just accumulate the unique libdirs.
8058994689c1Smrg		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
8059994689c1Smrg		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
8060994689c1Smrg		    ;;
8061994689c1Smrg		  *)
8062f353fbadSmrg		    func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
8063994689c1Smrg		    ;;
8064994689c1Smrg		  esac
8065994689c1Smrg		fi
8066994689c1Smrg	      else
8067994689c1Smrg		eval flag=\"$hardcode_libdir_flag_spec\"
8068f353fbadSmrg		func_append dep_rpath " $flag"
8069994689c1Smrg	      fi
8070994689c1Smrg	    elif test -n "$runpath_var"; then
8071994689c1Smrg	      case "$perm_rpath " in
8072994689c1Smrg	      *" $libdir "*) ;;
8073421c997bSmrg	      *) func_append perm_rpath " $libdir" ;;
8074994689c1Smrg	      esac
8075994689c1Smrg	    fi
8076994689c1Smrg	  done
8077994689c1Smrg	  # Substitute the hardcoded libdirs into the rpath.
8078994689c1Smrg	  if test -n "$hardcode_libdir_separator" &&
8079994689c1Smrg	     test -n "$hardcode_libdirs"; then
8080994689c1Smrg	    libdir="$hardcode_libdirs"
8081421c997bSmrg	    eval "dep_rpath=\"$hardcode_libdir_flag_spec\""
8082994689c1Smrg	  fi
8083994689c1Smrg	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
8084994689c1Smrg	    # We should set the runpath_var.
8085994689c1Smrg	    rpath=
8086994689c1Smrg	    for dir in $perm_rpath; do
8087f353fbadSmrg	      func_append rpath "$dir:"
8088994689c1Smrg	    done
8089994689c1Smrg	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
8090994689c1Smrg	  fi
8091994689c1Smrg	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
8092994689c1Smrg	fi
80937a84e134Smrg
8094994689c1Smrg	shlibpath="$finalize_shlibpath"
8095f353fbadSmrg	test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
8096994689c1Smrg	if test -n "$shlibpath"; then
8097994689c1Smrg	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
8098994689c1Smrg	fi
80997a84e134Smrg
8100994689c1Smrg	# Get the real and link names of the library.
8101994689c1Smrg	eval shared_ext=\"$shrext_cmds\"
8102994689c1Smrg	eval library_names=\"$library_names_spec\"
8103994689c1Smrg	set dummy $library_names
8104994689c1Smrg	shift
8105994689c1Smrg	realname="$1"
8106994689c1Smrg	shift
81077a84e134Smrg
8108994689c1Smrg	if test -n "$soname_spec"; then
8109994689c1Smrg	  eval soname=\"$soname_spec\"
8110994689c1Smrg	else
8111994689c1Smrg	  soname="$realname"
8112994689c1Smrg	fi
8113994689c1Smrg	if test -z "$dlname"; then
8114994689c1Smrg	  dlname=$soname
8115994689c1Smrg	fi
81167a84e134Smrg
8117994689c1Smrg	lib="$output_objdir/$realname"
8118994689c1Smrg	linknames=
8119994689c1Smrg	for link
8120994689c1Smrg	do
8121f353fbadSmrg	  func_append linknames " $link"
8122994689c1Smrg	done
81237a84e134Smrg
8124994689c1Smrg	# Use standard objects if they are pic
8125994689c1Smrg	test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
8126994689c1Smrg	test "X$libobjs" = "X " && libobjs=
81277a84e134Smrg
8128994689c1Smrg	delfiles=
8129994689c1Smrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
8130994689c1Smrg	  $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
8131994689c1Smrg	  export_symbols="$output_objdir/$libname.uexp"
8132f353fbadSmrg	  func_append delfiles " $export_symbols"
8133994689c1Smrg	fi
81347a84e134Smrg
8135994689c1Smrg	orig_export_symbols=
8136994689c1Smrg	case $host_os in
8137994689c1Smrg	cygwin* | mingw* | cegcc*)
8138994689c1Smrg	  if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
8139994689c1Smrg	    # exporting using user supplied symfile
8140994689c1Smrg	    if test "x`$SED 1q $export_symbols`" != xEXPORTS; then
8141994689c1Smrg	      # and it's NOT already a .def file. Must figure out
8142994689c1Smrg	      # which of the given symbols are data symbols and tag
8143994689c1Smrg	      # them as such. So, trigger use of export_symbols_cmds.
8144994689c1Smrg	      # export_symbols gets reassigned inside the "prepare
8145994689c1Smrg	      # the list of exported symbols" if statement, so the
8146994689c1Smrg	      # include_expsyms logic still works.
8147994689c1Smrg	      orig_export_symbols="$export_symbols"
8148994689c1Smrg	      export_symbols=
8149994689c1Smrg	      always_export_symbols=yes
8150994689c1Smrg	    fi
8151994689c1Smrg	  fi
8152994689c1Smrg	  ;;
8153994689c1Smrg	esac
81547a84e134Smrg
8155994689c1Smrg	# Prepare the list of exported symbols
8156994689c1Smrg	if test -z "$export_symbols"; then
8157994689c1Smrg	  if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
8158994689c1Smrg	    func_verbose "generating symbol list for \`$libname.la'"
8159994689c1Smrg	    export_symbols="$output_objdir/$libname.exp"
8160994689c1Smrg	    $opt_dry_run || $RM $export_symbols
8161994689c1Smrg	    cmds=$export_symbols_cmds
8162994689c1Smrg	    save_ifs="$IFS"; IFS='~'
8163f353fbadSmrg	    for cmd1 in $cmds; do
8164994689c1Smrg	      IFS="$save_ifs"
8165f353fbadSmrg	      # Take the normal branch if the nm_file_list_spec branch
8166f353fbadSmrg	      # doesn't work or if tool conversion is not needed.
8167f353fbadSmrg	      case $nm_file_list_spec~$to_tool_file_cmd in
8168f353fbadSmrg		*~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*)
8169f353fbadSmrg		  try_normal_branch=yes
8170f353fbadSmrg		  eval cmd=\"$cmd1\"
8171f353fbadSmrg		  func_len " $cmd"
8172f353fbadSmrg		  len=$func_len_result
8173f353fbadSmrg		  ;;
8174f353fbadSmrg		*)
8175f353fbadSmrg		  try_normal_branch=no
8176f353fbadSmrg		  ;;
8177f353fbadSmrg	      esac
8178f353fbadSmrg	      if test "$try_normal_branch" = yes \
8179f353fbadSmrg		 && { test "$len" -lt "$max_cmd_len" \
8180f353fbadSmrg		      || test "$max_cmd_len" -le -1; }
8181f353fbadSmrg	      then
8182f353fbadSmrg		func_show_eval "$cmd" 'exit $?'
8183f353fbadSmrg		skipped_export=false
8184f353fbadSmrg	      elif test -n "$nm_file_list_spec"; then
8185f353fbadSmrg		func_basename "$output"
8186f353fbadSmrg		output_la=$func_basename_result
8187f353fbadSmrg		save_libobjs=$libobjs
8188f353fbadSmrg		save_output=$output
8189f353fbadSmrg		output=${output_objdir}/${output_la}.nm
8190f353fbadSmrg		func_to_tool_file "$output"
8191f353fbadSmrg		libobjs=$nm_file_list_spec$func_to_tool_file_result
8192f353fbadSmrg		func_append delfiles " $output"
8193f353fbadSmrg		func_verbose "creating $NM input file list: $output"
8194f353fbadSmrg		for obj in $save_libobjs; do
8195f353fbadSmrg		  func_to_tool_file "$obj"
8196f353fbadSmrg		  $ECHO "$func_to_tool_file_result"
8197f353fbadSmrg		done > "$output"
8198f353fbadSmrg		eval cmd=\"$cmd1\"
8199994689c1Smrg		func_show_eval "$cmd" 'exit $?'
8200f353fbadSmrg		output=$save_output
8201f353fbadSmrg		libobjs=$save_libobjs
8202994689c1Smrg		skipped_export=false
8203994689c1Smrg	      else
8204994689c1Smrg		# The command line is too long to execute in one step.
8205994689c1Smrg		func_verbose "using reloadable object file for export list..."
8206994689c1Smrg		skipped_export=:
8207994689c1Smrg		# Break out early, otherwise skipped_export may be
8208994689c1Smrg		# set to false by a later but shorter cmd.
8209994689c1Smrg		break
8210994689c1Smrg	      fi
8211994689c1Smrg	    done
8212994689c1Smrg	    IFS="$save_ifs"
8213994689c1Smrg	    if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then
8214994689c1Smrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
8215994689c1Smrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
8216994689c1Smrg	    fi
8217994689c1Smrg	  fi
8218994689c1Smrg	fi
82197a84e134Smrg
8220994689c1Smrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
8221994689c1Smrg	  tmp_export_symbols="$export_symbols"
8222994689c1Smrg	  test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
8223994689c1Smrg	  $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
8224994689c1Smrg	fi
82257a84e134Smrg
8226994689c1Smrg	if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then
8227994689c1Smrg	  # The given exports_symbols file has to be filtered, so filter it.
8228994689c1Smrg	  func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
8229994689c1Smrg	  # FIXME: $output_objdir/$libname.filter potentially contains lots of
8230994689c1Smrg	  # 's' commands which not all seds can handle. GNU sed should be fine
8231994689c1Smrg	  # though. Also, the filter scales superlinearly with the number of
8232994689c1Smrg	  # global variables. join(1) would be nice here, but unfortunately
8233994689c1Smrg	  # isn't a blessed tool.
8234994689c1Smrg	  $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
8235f353fbadSmrg	  func_append delfiles " $export_symbols $output_objdir/$libname.filter"
8236994689c1Smrg	  export_symbols=$output_objdir/$libname.def
8237994689c1Smrg	  $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
82387a84e134Smrg	fi
82397a84e134Smrg
8240994689c1Smrg	tmp_deplibs=
8241994689c1Smrg	for test_deplib in $deplibs; do
8242994689c1Smrg	  case " $convenience " in
8243994689c1Smrg	  *" $test_deplib "*) ;;
8244994689c1Smrg	  *)
8245f353fbadSmrg	    func_append tmp_deplibs " $test_deplib"
8246994689c1Smrg	    ;;
8247994689c1Smrg	  esac
8248994689c1Smrg	done
8249994689c1Smrg	deplibs="$tmp_deplibs"
82507a84e134Smrg
8251994689c1Smrg	if test -n "$convenience"; then
8252994689c1Smrg	  if test -n "$whole_archive_flag_spec" &&
8253994689c1Smrg	    test "$compiler_needs_object" = yes &&
8254994689c1Smrg	    test -z "$libobjs"; then
8255994689c1Smrg	    # extract the archives, so we have objects to list.
8256994689c1Smrg	    # TODO: could optimize this to just extract one archive.
8257994689c1Smrg	    whole_archive_flag_spec=
8258994689c1Smrg	  fi
8259994689c1Smrg	  if test -n "$whole_archive_flag_spec"; then
8260994689c1Smrg	    save_libobjs=$libobjs
8261994689c1Smrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
8262994689c1Smrg	    test "X$libobjs" = "X " && libobjs=
8263994689c1Smrg	  else
8264994689c1Smrg	    gentop="$output_objdir/${outputname}x"
8265f353fbadSmrg	    func_append generated " $gentop"
82667a84e134Smrg
8267994689c1Smrg	    func_extract_archives $gentop $convenience
8268f353fbadSmrg	    func_append libobjs " $func_extract_archives_result"
8269994689c1Smrg	    test "X$libobjs" = "X " && libobjs=
8270994689c1Smrg	  fi
8271994689c1Smrg	fi
82727a84e134Smrg
8273994689c1Smrg	if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
8274994689c1Smrg	  eval flag=\"$thread_safe_flag_spec\"
8275f353fbadSmrg	  func_append linker_flags " $flag"
8276994689c1Smrg	fi
82777a84e134Smrg
8278994689c1Smrg	# Make a backup of the uninstalled library when relinking
8279f353fbadSmrg	if test "$opt_mode" = relink; then
8280994689c1Smrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
8281e1e1713cSmrg	fi
82827a84e134Smrg
8283994689c1Smrg	# Do each of the archive commands.
8284994689c1Smrg	if test "$module" = yes && test -n "$module_cmds" ; then
8285994689c1Smrg	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
8286994689c1Smrg	    eval test_cmds=\"$module_expsym_cmds\"
8287994689c1Smrg	    cmds=$module_expsym_cmds
8288994689c1Smrg	  else
8289994689c1Smrg	    eval test_cmds=\"$module_cmds\"
8290994689c1Smrg	    cmds=$module_cmds
8291994689c1Smrg	  fi
8292994689c1Smrg	else
8293994689c1Smrg	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
8294994689c1Smrg	    eval test_cmds=\"$archive_expsym_cmds\"
8295994689c1Smrg	    cmds=$archive_expsym_cmds
8296994689c1Smrg	  else
8297994689c1Smrg	    eval test_cmds=\"$archive_cmds\"
8298994689c1Smrg	    cmds=$archive_cmds
8299994689c1Smrg	  fi
8300e1e1713cSmrg	fi
8301775e7de9Smrg
8302994689c1Smrg	if test "X$skipped_export" != "X:" &&
8303994689c1Smrg	   func_len " $test_cmds" &&
8304994689c1Smrg	   len=$func_len_result &&
8305994689c1Smrg	   test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
8306994689c1Smrg	  :
8307994689c1Smrg	else
8308994689c1Smrg	  # The command line is too long to link in one step, link piecewise
8309994689c1Smrg	  # or, if using GNU ld and skipped_export is not :, use a linker
8310994689c1Smrg	  # script.
83117a84e134Smrg
8312994689c1Smrg	  # Save the value of $output and $libobjs because we want to
8313994689c1Smrg	  # use them later.  If we have whole_archive_flag_spec, we
8314994689c1Smrg	  # want to use save_libobjs as it was before
8315994689c1Smrg	  # whole_archive_flag_spec was expanded, because we can't
8316994689c1Smrg	  # assume the linker understands whole_archive_flag_spec.
8317994689c1Smrg	  # This may have to be revisited, in case too many
8318994689c1Smrg	  # convenience libraries get linked in and end up exceeding
8319994689c1Smrg	  # the spec.
8320994689c1Smrg	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
8321994689c1Smrg	    save_libobjs=$libobjs
8322994689c1Smrg	  fi
8323994689c1Smrg	  save_output=$output
8324994689c1Smrg	  func_basename "$output"
8325994689c1Smrg	  output_la=$func_basename_result
83267a84e134Smrg
8327994689c1Smrg	  # Clear the reloadable object creation command queue and
8328994689c1Smrg	  # initialize k to one.
8329994689c1Smrg	  test_cmds=
8330994689c1Smrg	  concat_cmds=
8331994689c1Smrg	  objlist=
8332994689c1Smrg	  last_robj=
8333994689c1Smrg	  k=1
83347a84e134Smrg
8335994689c1Smrg	  if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
8336994689c1Smrg	    output=${output_objdir}/${output_la}.lnkscript
8337994689c1Smrg	    func_verbose "creating GNU ld script: $output"
8338994689c1Smrg	    echo 'INPUT (' > $output
8339994689c1Smrg	    for obj in $save_libobjs
8340994689c1Smrg	    do
8341f353fbadSmrg	      func_to_tool_file "$obj"
8342f353fbadSmrg	      $ECHO "$func_to_tool_file_result" >> $output
8343994689c1Smrg	    done
8344994689c1Smrg	    echo ')' >> $output
8345f353fbadSmrg	    func_append delfiles " $output"
8346f353fbadSmrg	    func_to_tool_file "$output"
8347f353fbadSmrg	    output=$func_to_tool_file_result
8348994689c1Smrg	  elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then
8349994689c1Smrg	    output=${output_objdir}/${output_la}.lnk
8350994689c1Smrg	    func_verbose "creating linker input file list: $output"
8351994689c1Smrg	    : > $output
8352994689c1Smrg	    set x $save_libobjs
8353994689c1Smrg	    shift
8354994689c1Smrg	    firstobj=
8355994689c1Smrg	    if test "$compiler_needs_object" = yes; then
8356994689c1Smrg	      firstobj="$1 "
8357994689c1Smrg	      shift
8358994689c1Smrg	    fi
8359994689c1Smrg	    for obj
8360994689c1Smrg	    do
8361f353fbadSmrg	      func_to_tool_file "$obj"
8362f353fbadSmrg	      $ECHO "$func_to_tool_file_result" >> $output
8363994689c1Smrg	    done
8364f353fbadSmrg	    func_append delfiles " $output"
8365f353fbadSmrg	    func_to_tool_file "$output"
8366f353fbadSmrg	    output=$firstobj\"$file_list_spec$func_to_tool_file_result\"
8367994689c1Smrg	  else
8368994689c1Smrg	    if test -n "$save_libobjs"; then
8369994689c1Smrg	      func_verbose "creating reloadable object files..."
8370994689c1Smrg	      output=$output_objdir/$output_la-${k}.$objext
8371994689c1Smrg	      eval test_cmds=\"$reload_cmds\"
8372994689c1Smrg	      func_len " $test_cmds"
8373994689c1Smrg	      len0=$func_len_result
8374994689c1Smrg	      len=$len0
8375994689c1Smrg
8376994689c1Smrg	      # Loop over the list of objects to be linked.
8377994689c1Smrg	      for obj in $save_libobjs
8378994689c1Smrg	      do
8379994689c1Smrg		func_len " $obj"
8380994689c1Smrg		func_arith $len + $func_len_result
8381994689c1Smrg		len=$func_arith_result
8382994689c1Smrg		if test "X$objlist" = X ||
8383994689c1Smrg		   test "$len" -lt "$max_cmd_len"; then
8384994689c1Smrg		  func_append objlist " $obj"
8385994689c1Smrg		else
8386994689c1Smrg		  # The command $test_cmds is almost too long, add a
8387994689c1Smrg		  # command to the queue.
8388994689c1Smrg		  if test "$k" -eq 1 ; then
8389994689c1Smrg		    # The first file doesn't have a previous command to add.
8390994689c1Smrg		    reload_objs=$objlist
8391994689c1Smrg		    eval concat_cmds=\"$reload_cmds\"
8392994689c1Smrg		  else
8393994689c1Smrg		    # All subsequent reloadable object files will link in
8394994689c1Smrg		    # the last one created.
8395994689c1Smrg		    reload_objs="$objlist $last_robj"
8396994689c1Smrg		    eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
8397994689c1Smrg		  fi
8398994689c1Smrg		  last_robj=$output_objdir/$output_la-${k}.$objext
8399994689c1Smrg		  func_arith $k + 1
8400994689c1Smrg		  k=$func_arith_result
8401994689c1Smrg		  output=$output_objdir/$output_la-${k}.$objext
8402994689c1Smrg		  objlist=" $obj"
8403994689c1Smrg		  func_len " $last_robj"
8404994689c1Smrg		  func_arith $len0 + $func_len_result
8405994689c1Smrg		  len=$func_arith_result
8406994689c1Smrg		fi
8407994689c1Smrg	      done
8408994689c1Smrg	      # Handle the remaining objects by creating one last
8409994689c1Smrg	      # reloadable object file.  All subsequent reloadable object
8410994689c1Smrg	      # files will link in the last one created.
8411994689c1Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
8412994689c1Smrg	      reload_objs="$objlist $last_robj"
8413994689c1Smrg	      eval concat_cmds=\"\${concat_cmds}$reload_cmds\"
8414994689c1Smrg	      if test -n "$last_robj"; then
8415994689c1Smrg	        eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\"
8416994689c1Smrg	      fi
8417f353fbadSmrg	      func_append delfiles " $output"
8418994689c1Smrg
8419994689c1Smrg	    else
8420994689c1Smrg	      output=
8421994689c1Smrg	    fi
84227a84e134Smrg
8423994689c1Smrg	    if ${skipped_export-false}; then
8424994689c1Smrg	      func_verbose "generating symbol list for \`$libname.la'"
8425994689c1Smrg	      export_symbols="$output_objdir/$libname.exp"
8426994689c1Smrg	      $opt_dry_run || $RM $export_symbols
8427994689c1Smrg	      libobjs=$output
8428994689c1Smrg	      # Append the command to create the export file.
8429994689c1Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
8430994689c1Smrg	      eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
8431994689c1Smrg	      if test -n "$last_robj"; then
8432994689c1Smrg		eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
8433994689c1Smrg	      fi
8434994689c1Smrg	    fi
84357a84e134Smrg
8436994689c1Smrg	    test -n "$save_libobjs" &&
8437994689c1Smrg	      func_verbose "creating a temporary reloadable object file: $output"
84387a84e134Smrg
8439994689c1Smrg	    # Loop through the commands generated above and execute them.
8440994689c1Smrg	    save_ifs="$IFS"; IFS='~'
8441994689c1Smrg	    for cmd in $concat_cmds; do
8442994689c1Smrg	      IFS="$save_ifs"
8443994689c1Smrg	      $opt_silent || {
8444994689c1Smrg		  func_quote_for_expand "$cmd"
8445994689c1Smrg		  eval "func_echo $func_quote_for_expand_result"
8446994689c1Smrg	      }
8447994689c1Smrg	      $opt_dry_run || eval "$cmd" || {
8448994689c1Smrg		lt_exit=$?
8449994689c1Smrg
8450994689c1Smrg		# Restore the uninstalled library and exit
8451f353fbadSmrg		if test "$opt_mode" = relink; then
8452994689c1Smrg		  ( cd "$output_objdir" && \
8453994689c1Smrg		    $RM "${realname}T" && \
8454994689c1Smrg		    $MV "${realname}U" "$realname" )
8455994689c1Smrg		fi
84567a84e134Smrg
8457994689c1Smrg		exit $lt_exit
8458994689c1Smrg	      }
8459994689c1Smrg	    done
8460994689c1Smrg	    IFS="$save_ifs"
84617a84e134Smrg
8462994689c1Smrg	    if test -n "$export_symbols_regex" && ${skipped_export-false}; then
8463994689c1Smrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
8464994689c1Smrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
8465775e7de9Smrg	    fi
8466775e7de9Smrg	  fi
84677a84e134Smrg
8468994689c1Smrg          if ${skipped_export-false}; then
8469994689c1Smrg	    if test -n "$export_symbols" && test -n "$include_expsyms"; then
8470994689c1Smrg	      tmp_export_symbols="$export_symbols"
8471994689c1Smrg	      test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
8472994689c1Smrg	      $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
8473994689c1Smrg	    fi
84747a84e134Smrg
8475994689c1Smrg	    if test -n "$orig_export_symbols"; then
8476994689c1Smrg	      # The given exports_symbols file has to be filtered, so filter it.
8477994689c1Smrg	      func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
8478994689c1Smrg	      # FIXME: $output_objdir/$libname.filter potentially contains lots of
8479994689c1Smrg	      # 's' commands which not all seds can handle. GNU sed should be fine
8480994689c1Smrg	      # though. Also, the filter scales superlinearly with the number of
8481994689c1Smrg	      # global variables. join(1) would be nice here, but unfortunately
8482994689c1Smrg	      # isn't a blessed tool.
8483994689c1Smrg	      $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
8484f353fbadSmrg	      func_append delfiles " $export_symbols $output_objdir/$libname.filter"
8485994689c1Smrg	      export_symbols=$output_objdir/$libname.def
8486994689c1Smrg	      $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
8487994689c1Smrg	    fi
8488994689c1Smrg	  fi
84897a84e134Smrg
8490994689c1Smrg	  libobjs=$output
8491994689c1Smrg	  # Restore the value of output.
8492994689c1Smrg	  output=$save_output
8493e1e1713cSmrg
8494994689c1Smrg	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
8495994689c1Smrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
8496994689c1Smrg	    test "X$libobjs" = "X " && libobjs=
8497994689c1Smrg	  fi
8498994689c1Smrg	  # Expand the library linking commands again to reset the
8499994689c1Smrg	  # value of $libobjs for piecewise linking.
8500994689c1Smrg
8501994689c1Smrg	  # Do each of the archive commands.
8502994689c1Smrg	  if test "$module" = yes && test -n "$module_cmds" ; then
8503994689c1Smrg	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
8504994689c1Smrg	      cmds=$module_expsym_cmds
8505775e7de9Smrg	    else
8506994689c1Smrg	      cmds=$module_cmds
85077a84e134Smrg	    fi
85087a84e134Smrg	  else
8509994689c1Smrg	    if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
8510994689c1Smrg	      cmds=$archive_expsym_cmds
8511994689c1Smrg	    else
8512994689c1Smrg	      cmds=$archive_cmds
8513994689c1Smrg	    fi
85147a84e134Smrg	  fi
8515775e7de9Smrg	fi
85167a84e134Smrg
8517994689c1Smrg	if test -n "$delfiles"; then
8518994689c1Smrg	  # Append the command to remove temporary files to $cmds.
8519994689c1Smrg	  eval cmds=\"\$cmds~\$RM $delfiles\"
8520994689c1Smrg	fi
8521775e7de9Smrg
8522994689c1Smrg	# Add any objects from preloaded convenience libraries
8523994689c1Smrg	if test -n "$dlprefiles"; then
8524994689c1Smrg	  gentop="$output_objdir/${outputname}x"
8525f353fbadSmrg	  func_append generated " $gentop"
85267a84e134Smrg
8527994689c1Smrg	  func_extract_archives $gentop $dlprefiles
8528f353fbadSmrg	  func_append libobjs " $func_extract_archives_result"
8529994689c1Smrg	  test "X$libobjs" = "X " && libobjs=
8530775e7de9Smrg	fi
85317a84e134Smrg
8532994689c1Smrg	save_ifs="$IFS"; IFS='~'
8533994689c1Smrg	for cmd in $cmds; do
8534994689c1Smrg	  IFS="$save_ifs"
8535994689c1Smrg	  eval cmd=\"$cmd\"
8536994689c1Smrg	  $opt_silent || {
8537994689c1Smrg	    func_quote_for_expand "$cmd"
8538994689c1Smrg	    eval "func_echo $func_quote_for_expand_result"
8539994689c1Smrg	  }
8540994689c1Smrg	  $opt_dry_run || eval "$cmd" || {
8541994689c1Smrg	    lt_exit=$?
85427a84e134Smrg
8543994689c1Smrg	    # Restore the uninstalled library and exit
8544f353fbadSmrg	    if test "$opt_mode" = relink; then
8545994689c1Smrg	      ( cd "$output_objdir" && \
8546994689c1Smrg	        $RM "${realname}T" && \
8547994689c1Smrg		$MV "${realname}U" "$realname" )
8548e1e1713cSmrg	    fi
85497a84e134Smrg
8550994689c1Smrg	    exit $lt_exit
8551994689c1Smrg	  }
8552994689c1Smrg	done
8553994689c1Smrg	IFS="$save_ifs"
85547a84e134Smrg
8555994689c1Smrg	# Restore the uninstalled library and exit
8556f353fbadSmrg	if test "$opt_mode" = relink; then
8557994689c1Smrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
85587a84e134Smrg
8559994689c1Smrg	  if test -n "$convenience"; then
8560994689c1Smrg	    if test -z "$whole_archive_flag_spec"; then
8561994689c1Smrg	      func_show_eval '${RM}r "$gentop"'
8562994689c1Smrg	    fi
8563994689c1Smrg	  fi
85647a84e134Smrg
8565994689c1Smrg	  exit $EXIT_SUCCESS
8566994689c1Smrg	fi
8567775e7de9Smrg
8568994689c1Smrg	# Create links to the real library.
8569994689c1Smrg	for linkname in $linknames; do
8570994689c1Smrg	  if test "$realname" != "$linkname"; then
8571994689c1Smrg	    func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
8572994689c1Smrg	  fi
8573994689c1Smrg	done
8574775e7de9Smrg
8575994689c1Smrg	# If -module or -export-dynamic was specified, set the dlname.
8576994689c1Smrg	if test "$module" = yes || test "$export_dynamic" = yes; then
8577994689c1Smrg	  # On all known operating systems, these are identical.
8578994689c1Smrg	  dlname="$soname"
8579994689c1Smrg	fi
8580994689c1Smrg      fi
8581994689c1Smrg      ;;
8582775e7de9Smrg
8583994689c1Smrg    obj)
8584994689c1Smrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
8585994689c1Smrg	func_warning "\`-dlopen' is ignored for objects"
8586994689c1Smrg      fi
8587775e7de9Smrg
8588994689c1Smrg      case " $deplibs" in
8589994689c1Smrg      *\ -l* | *\ -L*)
8590994689c1Smrg	func_warning "\`-l' and \`-L' are ignored for objects" ;;
8591994689c1Smrg      esac
8592775e7de9Smrg
8593994689c1Smrg      test -n "$rpath" && \
8594994689c1Smrg	func_warning "\`-rpath' is ignored for objects"
8595775e7de9Smrg
8596994689c1Smrg      test -n "$xrpath" && \
8597994689c1Smrg	func_warning "\`-R' is ignored for objects"
8598994689c1Smrg
8599994689c1Smrg      test -n "$vinfo" && \
8600994689c1Smrg	func_warning "\`-version-info' is ignored for objects"
86017a84e134Smrg
8602994689c1Smrg      test -n "$release" && \
8603994689c1Smrg	func_warning "\`-release' is ignored for objects"
8604e1e1713cSmrg
8605994689c1Smrg      case $output in
8606994689c1Smrg      *.lo)
8607994689c1Smrg	test -n "$objs$old_deplibs" && \
8608994689c1Smrg	  func_fatal_error "cannot build library object \`$output' from non-libtool objects"
8609994689c1Smrg
8610994689c1Smrg	libobj=$output
8611994689c1Smrg	func_lo2o "$libobj"
8612994689c1Smrg	obj=$func_lo2o_result
8613994689c1Smrg	;;
8614994689c1Smrg      *)
8615994689c1Smrg	libobj=
8616994689c1Smrg	obj="$output"
8617e1e1713cSmrg	;;
8618775e7de9Smrg      esac
86197a84e134Smrg
8620994689c1Smrg      # Delete the old objects.
8621994689c1Smrg      $opt_dry_run || $RM $obj $libobj
86227a84e134Smrg
8623994689c1Smrg      # Objects from convenience libraries.  This assumes
8624994689c1Smrg      # single-version convenience libraries.  Whenever we create
8625994689c1Smrg      # different ones for PIC/non-PIC, this we'll have to duplicate
8626994689c1Smrg      # the extraction.
8627994689c1Smrg      reload_conv_objs=
8628994689c1Smrg      gentop=
8629994689c1Smrg      # reload_cmds runs $LD directly, so let us get rid of
8630994689c1Smrg      # -Wl from whole_archive_flag_spec and hope we can get by with
8631994689c1Smrg      # turning comma into space..
8632994689c1Smrg      wl=
8633775e7de9Smrg
8634994689c1Smrg      if test -n "$convenience"; then
8635994689c1Smrg	if test -n "$whole_archive_flag_spec"; then
8636994689c1Smrg	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
8637994689c1Smrg	  reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
8638e1e1713cSmrg	else
8639994689c1Smrg	  gentop="$output_objdir/${obj}x"
8640f353fbadSmrg	  func_append generated " $gentop"
8641994689c1Smrg
8642994689c1Smrg	  func_extract_archives $gentop $convenience
8643994689c1Smrg	  reload_conv_objs="$reload_objs $func_extract_archives_result"
8644e1e1713cSmrg	fi
8645994689c1Smrg      fi
86467a84e134Smrg
8647f353fbadSmrg      # If we're not building shared, we need to use non_pic_objs
8648f353fbadSmrg      test "$build_libtool_libs" != yes && libobjs="$non_pic_objects"
8649f353fbadSmrg
8650994689c1Smrg      # Create the old-style object.
8651994689c1Smrg      reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
86527a84e134Smrg
8653994689c1Smrg      output="$obj"
8654994689c1Smrg      func_execute_cmds "$reload_cmds" 'exit $?'
86557a84e134Smrg
8656994689c1Smrg      # Exit if we aren't doing a library object file.
8657994689c1Smrg      if test -z "$libobj"; then
8658994689c1Smrg	if test -n "$gentop"; then
8659994689c1Smrg	  func_show_eval '${RM}r "$gentop"'
8660994689c1Smrg	fi
8661e1e1713cSmrg
8662994689c1Smrg	exit $EXIT_SUCCESS
8663e1e1713cSmrg      fi
8664e1e1713cSmrg
8665994689c1Smrg      if test "$build_libtool_libs" != yes; then
8666994689c1Smrg	if test -n "$gentop"; then
8667994689c1Smrg	  func_show_eval '${RM}r "$gentop"'
8668994689c1Smrg	fi
8669e1e1713cSmrg
8670994689c1Smrg	# Create an invalid libtool object if no PIC, so that we don't
8671994689c1Smrg	# accidentally link it into a program.
8672994689c1Smrg	# $show "echo timestamp > $libobj"
8673994689c1Smrg	# $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
8674994689c1Smrg	exit $EXIT_SUCCESS
8675994689c1Smrg      fi
8676e1e1713cSmrg
8677994689c1Smrg      if test -n "$pic_flag" || test "$pic_mode" != default; then
8678994689c1Smrg	# Only do commands if we really have different PIC objects.
8679994689c1Smrg	reload_objs="$libobjs $reload_conv_objs"
8680994689c1Smrg	output="$libobj"
8681994689c1Smrg	func_execute_cmds "$reload_cmds" 'exit $?'
8682e1e1713cSmrg      fi
8683994689c1Smrg
8684994689c1Smrg      if test -n "$gentop"; then
8685994689c1Smrg	func_show_eval '${RM}r "$gentop"'
8686994689c1Smrg      fi
8687994689c1Smrg
8688994689c1Smrg      exit $EXIT_SUCCESS
8689e1e1713cSmrg      ;;
86907a84e134Smrg
8691994689c1Smrg    prog)
8692994689c1Smrg      case $host in
8693994689c1Smrg	*cygwin*) func_stripname '' '.exe' "$output"
8694994689c1Smrg	          output=$func_stripname_result.exe;;
8695994689c1Smrg      esac
8696994689c1Smrg      test -n "$vinfo" && \
8697994689c1Smrg	func_warning "\`-version-info' is ignored for programs"
86987a84e134Smrg
8699994689c1Smrg      test -n "$release" && \
8700994689c1Smrg	func_warning "\`-release' is ignored for programs"
87017a84e134Smrg
8702994689c1Smrg      test "$preload" = yes \
8703994689c1Smrg        && test "$dlopen_support" = unknown \
8704994689c1Smrg	&& test "$dlopen_self" = unknown \
8705994689c1Smrg	&& test "$dlopen_self_static" = unknown && \
8706994689c1Smrg	  func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support."
8707994689c1Smrg
8708994689c1Smrg      case $host in
8709994689c1Smrg      *-*-rhapsody* | *-*-darwin1.[012])
8710994689c1Smrg	# On Rhapsody replace the C library is the System framework
8711994689c1Smrg	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
8712994689c1Smrg	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
8713e1e1713cSmrg	;;
8714994689c1Smrg      esac
8715e1e1713cSmrg
8716994689c1Smrg      case $host in
8717994689c1Smrg      *-*-darwin*)
8718994689c1Smrg	# Don't allow lazy linking, it breaks C++ global constructors
8719994689c1Smrg	# But is supposedly fixed on 10.4 or later (yay!).
8720994689c1Smrg	if test "$tagname" = CXX ; then
8721994689c1Smrg	  case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
8722994689c1Smrg	    10.[0123])
8723f353fbadSmrg	      func_append compile_command " ${wl}-bind_at_load"
8724f353fbadSmrg	      func_append finalize_command " ${wl}-bind_at_load"
8725994689c1Smrg	    ;;
8726994689c1Smrg	  esac
8727e1e1713cSmrg	fi
8728994689c1Smrg	# Time to change all our "foo.ltframework" stuff back to "-framework foo"
8729994689c1Smrg	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8730994689c1Smrg	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8731994689c1Smrg	;;
8732994689c1Smrg      esac
8733e1e1713cSmrg
8734e1e1713cSmrg
8735994689c1Smrg      # move library search paths that coincide with paths to not yet
8736994689c1Smrg      # installed libraries to the beginning of the library search list
8737994689c1Smrg      new_libs=
8738994689c1Smrg      for path in $notinst_path; do
8739994689c1Smrg	case " $new_libs " in
8740994689c1Smrg	*" -L$path/$objdir "*) ;;
8741994689c1Smrg	*)
8742994689c1Smrg	  case " $compile_deplibs " in
8743994689c1Smrg	  *" -L$path/$objdir "*)
8744f353fbadSmrg	    func_append new_libs " -L$path/$objdir" ;;
8745775e7de9Smrg	  esac
8746994689c1Smrg	  ;;
8747994689c1Smrg	esac
8748994689c1Smrg      done
8749994689c1Smrg      for deplib in $compile_deplibs; do
8750994689c1Smrg	case $deplib in
8751994689c1Smrg	-L*)
8752994689c1Smrg	  case " $new_libs " in
8753994689c1Smrg	  *" $deplib "*) ;;
8754f353fbadSmrg	  *) func_append new_libs " $deplib" ;;
8755775e7de9Smrg	  esac
8756994689c1Smrg	  ;;
8757f353fbadSmrg	*) func_append new_libs " $deplib" ;;
8758994689c1Smrg	esac
8759994689c1Smrg      done
8760994689c1Smrg      compile_deplibs="$new_libs"
87617a84e134Smrg
8762e1e1713cSmrg
8763f353fbadSmrg      func_append compile_command " $compile_deplibs"
8764f353fbadSmrg      func_append finalize_command " $finalize_deplibs"
8765e1e1713cSmrg
8766994689c1Smrg      if test -n "$rpath$xrpath"; then
8767994689c1Smrg	# If the user specified any rpath flags, then add them.
8768994689c1Smrg	for libdir in $rpath $xrpath; do
8769994689c1Smrg	  # This is the magic to use -rpath.
8770994689c1Smrg	  case "$finalize_rpath " in
8771994689c1Smrg	  *" $libdir "*) ;;
8772f353fbadSmrg	  *) func_append finalize_rpath " $libdir" ;;
8773994689c1Smrg	  esac
8774994689c1Smrg	done
8775994689c1Smrg      fi
8776e1e1713cSmrg
8777994689c1Smrg      # Now hardcode the library paths
8778994689c1Smrg      rpath=
8779994689c1Smrg      hardcode_libdirs=
8780994689c1Smrg      for libdir in $compile_rpath $finalize_rpath; do
8781994689c1Smrg	if test -n "$hardcode_libdir_flag_spec"; then
8782994689c1Smrg	  if test -n "$hardcode_libdir_separator"; then
8783994689c1Smrg	    if test -z "$hardcode_libdirs"; then
8784994689c1Smrg	      hardcode_libdirs="$libdir"
8785994689c1Smrg	    else
8786994689c1Smrg	      # Just accumulate the unique libdirs.
8787994689c1Smrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
8788994689c1Smrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
8789994689c1Smrg		;;
8790994689c1Smrg	      *)
8791f353fbadSmrg		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
8792994689c1Smrg		;;
8793994689c1Smrg	      esac
8794994689c1Smrg	    fi
8795e1e1713cSmrg	  else
8796994689c1Smrg	    eval flag=\"$hardcode_libdir_flag_spec\"
8797f353fbadSmrg	    func_append rpath " $flag"
8798e1e1713cSmrg	  fi
8799994689c1Smrg	elif test -n "$runpath_var"; then
8800994689c1Smrg	  case "$perm_rpath " in
8801994689c1Smrg	  *" $libdir "*) ;;
8802f353fbadSmrg	  *) func_append perm_rpath " $libdir" ;;
8803994689c1Smrg	  esac
8804994689c1Smrg	fi
8805994689c1Smrg	case $host in
8806994689c1Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
8807994689c1Smrg	  testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'`
8808994689c1Smrg	  case :$dllsearchpath: in
8809994689c1Smrg	  *":$libdir:"*) ;;
8810994689c1Smrg	  ::) dllsearchpath=$libdir;;
8811f353fbadSmrg	  *) func_append dllsearchpath ":$libdir";;
8812994689c1Smrg	  esac
8813994689c1Smrg	  case :$dllsearchpath: in
8814994689c1Smrg	  *":$testbindir:"*) ;;
8815994689c1Smrg	  ::) dllsearchpath=$testbindir;;
8816f353fbadSmrg	  *) func_append dllsearchpath ":$testbindir";;
8817994689c1Smrg	  esac
8818994689c1Smrg	  ;;
8819994689c1Smrg	esac
8820994689c1Smrg      done
8821994689c1Smrg      # Substitute the hardcoded libdirs into the rpath.
8822994689c1Smrg      if test -n "$hardcode_libdir_separator" &&
8823994689c1Smrg	 test -n "$hardcode_libdirs"; then
8824994689c1Smrg	libdir="$hardcode_libdirs"
8825994689c1Smrg	eval rpath=\" $hardcode_libdir_flag_spec\"
8826994689c1Smrg      fi
8827994689c1Smrg      compile_rpath="$rpath"
8828e1e1713cSmrg
8829994689c1Smrg      rpath=
8830994689c1Smrg      hardcode_libdirs=
8831994689c1Smrg      for libdir in $finalize_rpath; do
8832994689c1Smrg	if test -n "$hardcode_libdir_flag_spec"; then
8833994689c1Smrg	  if test -n "$hardcode_libdir_separator"; then
8834994689c1Smrg	    if test -z "$hardcode_libdirs"; then
8835994689c1Smrg	      hardcode_libdirs="$libdir"
8836994689c1Smrg	    else
8837994689c1Smrg	      # Just accumulate the unique libdirs.
8838994689c1Smrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
8839994689c1Smrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
8840994689c1Smrg		;;
8841994689c1Smrg	      *)
8842f353fbadSmrg		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
8843994689c1Smrg		;;
8844994689c1Smrg	      esac
8845994689c1Smrg	    fi
88467a84e134Smrg	  else
8847994689c1Smrg	    eval flag=\"$hardcode_libdir_flag_spec\"
8848f353fbadSmrg	    func_append rpath " $flag"
88497a84e134Smrg	  fi
8850994689c1Smrg	elif test -n "$runpath_var"; then
8851994689c1Smrg	  case "$finalize_perm_rpath " in
8852994689c1Smrg	  *" $libdir "*) ;;
8853f353fbadSmrg	  *) func_append finalize_perm_rpath " $libdir" ;;
8854994689c1Smrg	  esac
88557a84e134Smrg	fi
8856994689c1Smrg      done
8857994689c1Smrg      # Substitute the hardcoded libdirs into the rpath.
8858994689c1Smrg      if test -n "$hardcode_libdir_separator" &&
8859994689c1Smrg	 test -n "$hardcode_libdirs"; then
8860994689c1Smrg	libdir="$hardcode_libdirs"
8861994689c1Smrg	eval rpath=\" $hardcode_libdir_flag_spec\"
8862994689c1Smrg      fi
8863994689c1Smrg      finalize_rpath="$rpath"
88647a84e134Smrg
8865994689c1Smrg      if test -n "$libobjs" && test "$build_old_libs" = yes; then
8866994689c1Smrg	# Transform all the library objects into standard objects.
8867994689c1Smrg	compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
8868994689c1Smrg	finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
8869994689c1Smrg      fi
88707a84e134Smrg
8871994689c1Smrg      func_generate_dlsyms "$outputname" "@PROGRAM@" "no"
88727a84e134Smrg
8873994689c1Smrg      # template prelinking step
8874994689c1Smrg      if test -n "$prelink_cmds"; then
8875994689c1Smrg	func_execute_cmds "$prelink_cmds" 'exit $?'
8876994689c1Smrg      fi
88777a84e134Smrg
8878994689c1Smrg      wrappers_required=yes
8879994689c1Smrg      case $host in
8880994689c1Smrg      *cegcc* | *mingw32ce*)
8881994689c1Smrg        # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
8882994689c1Smrg        wrappers_required=no
8883994689c1Smrg        ;;
8884994689c1Smrg      *cygwin* | *mingw* )
8885994689c1Smrg        if test "$build_libtool_libs" != yes; then
8886994689c1Smrg          wrappers_required=no
8887994689c1Smrg        fi
8888994689c1Smrg        ;;
8889994689c1Smrg      *)
8890994689c1Smrg        if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
8891994689c1Smrg          wrappers_required=no
8892994689c1Smrg        fi
8893994689c1Smrg        ;;
8894994689c1Smrg      esac
8895994689c1Smrg      if test "$wrappers_required" = no; then
8896994689c1Smrg	# Replace the output file specification.
8897994689c1Smrg	compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
8898994689c1Smrg	link_command="$compile_command$compile_rpath"
88997a84e134Smrg
8900994689c1Smrg	# We have no uninstalled library dependencies, so finalize right now.
8901994689c1Smrg	exit_status=0
8902994689c1Smrg	func_show_eval "$link_command" 'exit_status=$?'
89037a84e134Smrg
8904f353fbadSmrg	if test -n "$postlink_cmds"; then
8905f353fbadSmrg	  func_to_tool_file "$output"
8906f353fbadSmrg	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
8907f353fbadSmrg	  func_execute_cmds "$postlink_cmds" 'exit $?'
8908f353fbadSmrg	fi
8909f353fbadSmrg
8910994689c1Smrg	# Delete the generated files.
8911994689c1Smrg	if test -f "$output_objdir/${outputname}S.${objext}"; then
8912994689c1Smrg	  func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"'
89137a84e134Smrg	fi
89147a84e134Smrg
8915994689c1Smrg	exit $exit_status
8916994689c1Smrg      fi
89177a84e134Smrg
8918994689c1Smrg      if test -n "$compile_shlibpath$finalize_shlibpath"; then
8919994689c1Smrg	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
8920994689c1Smrg      fi
8921994689c1Smrg      if test -n "$finalize_shlibpath"; then
8922994689c1Smrg	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
8923994689c1Smrg      fi
8924e1e1713cSmrg
8925994689c1Smrg      compile_var=
8926994689c1Smrg      finalize_var=
8927994689c1Smrg      if test -n "$runpath_var"; then
8928994689c1Smrg	if test -n "$perm_rpath"; then
8929994689c1Smrg	  # We should set the runpath_var.
8930994689c1Smrg	  rpath=
8931994689c1Smrg	  for dir in $perm_rpath; do
8932f353fbadSmrg	    func_append rpath "$dir:"
8933994689c1Smrg	  done
8934994689c1Smrg	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
89357a84e134Smrg	fi
8936994689c1Smrg	if test -n "$finalize_perm_rpath"; then
8937994689c1Smrg	  # We should set the runpath_var.
8938994689c1Smrg	  rpath=
8939994689c1Smrg	  for dir in $finalize_perm_rpath; do
8940f353fbadSmrg	    func_append rpath "$dir:"
8941994689c1Smrg	  done
8942994689c1Smrg	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
89437a84e134Smrg	fi
8944994689c1Smrg      fi
89457a84e134Smrg
8946994689c1Smrg      if test "$no_install" = yes; then
8947994689c1Smrg	# We don't need to create a wrapper script.
8948994689c1Smrg	link_command="$compile_var$compile_command$compile_rpath"
8949994689c1Smrg	# Replace the output file specification.
8950994689c1Smrg	link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
8951994689c1Smrg	# Delete the old output file.
8952994689c1Smrg	$opt_dry_run || $RM $output
8953994689c1Smrg	# Link the executable and exit
8954994689c1Smrg	func_show_eval "$link_command" 'exit $?'
8955f353fbadSmrg
8956f353fbadSmrg	if test -n "$postlink_cmds"; then
8957f353fbadSmrg	  func_to_tool_file "$output"
8958f353fbadSmrg	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
8959f353fbadSmrg	  func_execute_cmds "$postlink_cmds" 'exit $?'
8960f353fbadSmrg	fi
8961f353fbadSmrg
8962e1e1713cSmrg	exit $EXIT_SUCCESS
8963994689c1Smrg      fi
8964775e7de9Smrg
8965994689c1Smrg      if test "$hardcode_action" = relink; then
8966994689c1Smrg	# Fast installation is not supported
8967994689c1Smrg	link_command="$compile_var$compile_command$compile_rpath"
8968994689c1Smrg	relink_command="$finalize_var$finalize_command$finalize_rpath"
8969994689c1Smrg
8970994689c1Smrg	func_warning "this platform does not like uninstalled shared libraries"
8971994689c1Smrg	func_warning "\`$output' will be relinked during installation"
8972994689c1Smrg      else
8973994689c1Smrg	if test "$fast_install" != no; then
8974994689c1Smrg	  link_command="$finalize_var$compile_command$finalize_rpath"
8975994689c1Smrg	  if test "$fast_install" = yes; then
8976994689c1Smrg	    relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
8977994689c1Smrg	  else
8978994689c1Smrg	    # fast_install is set to needless
8979994689c1Smrg	    relink_command=
8980994689c1Smrg	  fi
89817a84e134Smrg	else
8982994689c1Smrg	  link_command="$compile_var$compile_command$compile_rpath"
8983994689c1Smrg	  relink_command="$finalize_var$finalize_command$finalize_rpath"
89847a84e134Smrg	fi
8985994689c1Smrg      fi
89867a84e134Smrg
8987994689c1Smrg      # Replace the output file specification.
8988994689c1Smrg      link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
89897a84e134Smrg
8990994689c1Smrg      # Delete the old output files.
8991994689c1Smrg      $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
89927a84e134Smrg
8993994689c1Smrg      func_show_eval "$link_command" 'exit $?'
8994e1e1713cSmrg
8995f353fbadSmrg      if test -n "$postlink_cmds"; then
8996f353fbadSmrg	func_to_tool_file "$output_objdir/$outputname"
8997f353fbadSmrg	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'`
8998f353fbadSmrg	func_execute_cmds "$postlink_cmds" 'exit $?'
8999f353fbadSmrg      fi
9000f353fbadSmrg
9001994689c1Smrg      # Now create the wrapper script.
9002994689c1Smrg      func_verbose "creating $output"
9003e1e1713cSmrg
9004994689c1Smrg      # Quote the relink command for shipping.
9005994689c1Smrg      if test -n "$relink_command"; then
9006994689c1Smrg	# Preserve any variables that may affect compiler behavior
9007994689c1Smrg	for var in $variables_saved_for_relink; do
9008994689c1Smrg	  if eval test -z \"\${$var+set}\"; then
9009994689c1Smrg	    relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
9010994689c1Smrg	  elif eval var_value=\$$var; test -z "$var_value"; then
9011994689c1Smrg	    relink_command="$var=; export $var; $relink_command"
90127a84e134Smrg	  else
9013994689c1Smrg	    func_quote_for_eval "$var_value"
9014994689c1Smrg	    relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
90157a84e134Smrg	  fi
9016994689c1Smrg	done
9017994689c1Smrg	relink_command="(cd `pwd`; $relink_command)"
9018994689c1Smrg	relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
9019994689c1Smrg      fi
9020775e7de9Smrg
9021994689c1Smrg      # Only actually do things if not in dry run mode.
9022994689c1Smrg      $opt_dry_run || {
9023994689c1Smrg	# win32 will think the script is a binary if it has
9024994689c1Smrg	# a .exe suffix, so we strip it off here.
9025994689c1Smrg	case $output in
9026994689c1Smrg	  *.exe) func_stripname '' '.exe' "$output"
9027994689c1Smrg	         output=$func_stripname_result ;;
9028994689c1Smrg	esac
9029994689c1Smrg	# test for cygwin because mv fails w/o .exe extensions
9030994689c1Smrg	case $host in
9031994689c1Smrg	  *cygwin*)
9032994689c1Smrg	    exeext=.exe
9033994689c1Smrg	    func_stripname '' '.exe' "$outputname"
9034994689c1Smrg	    outputname=$func_stripname_result ;;
9035994689c1Smrg	  *) exeext= ;;
90367a84e134Smrg	esac
9037994689c1Smrg	case $host in
9038994689c1Smrg	  *cygwin* | *mingw* )
9039994689c1Smrg	    func_dirname_and_basename "$output" "" "."
9040994689c1Smrg	    output_name=$func_basename_result
9041994689c1Smrg	    output_path=$func_dirname_result
9042994689c1Smrg	    cwrappersource="$output_path/$objdir/lt-$output_name.c"
9043994689c1Smrg	    cwrapper="$output_path/$output_name.exe"
9044994689c1Smrg	    $RM $cwrappersource $cwrapper
9045994689c1Smrg	    trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
9046994689c1Smrg
9047994689c1Smrg	    func_emit_cwrapperexe_src > $cwrappersource
9048994689c1Smrg
9049994689c1Smrg	    # The wrapper executable is built using the $host compiler,
9050994689c1Smrg	    # because it contains $host paths and files. If cross-
9051994689c1Smrg	    # compiling, it, like the target executable, must be
9052994689c1Smrg	    # executed on the $host or under an emulation environment.
9053994689c1Smrg	    $opt_dry_run || {
9054994689c1Smrg	      $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
9055994689c1Smrg	      $STRIP $cwrapper
9056994689c1Smrg	    }
90577a84e134Smrg
9058994689c1Smrg	    # Now, create the wrapper script for func_source use:
9059994689c1Smrg	    func_ltwrapper_scriptname $cwrapper
9060994689c1Smrg	    $RM $func_ltwrapper_scriptname_result
9061994689c1Smrg	    trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
9062994689c1Smrg	    $opt_dry_run || {
9063994689c1Smrg	      # note: this script will not be executed, so do not chmod.
9064994689c1Smrg	      if test "x$build" = "x$host" ; then
9065994689c1Smrg		$cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
9066994689c1Smrg	      else
9067994689c1Smrg		func_emit_wrapper no > $func_ltwrapper_scriptname_result
9068994689c1Smrg	      fi
9069994689c1Smrg	    }
9070994689c1Smrg	  ;;
9071994689c1Smrg	  * )
9072994689c1Smrg	    $RM $output
9073994689c1Smrg	    trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
90747a84e134Smrg
9075994689c1Smrg	    func_emit_wrapper no > $output
9076994689c1Smrg	    chmod +x $output
9077994689c1Smrg	  ;;
9078994689c1Smrg	esac
9079994689c1Smrg      }
9080994689c1Smrg      exit $EXIT_SUCCESS
9081994689c1Smrg      ;;
9082994689c1Smrg    esac
90837a84e134Smrg
9084994689c1Smrg    # See if we need to build an old-fashioned archive.
9085994689c1Smrg    for oldlib in $oldlibs; do
90867a84e134Smrg
9087994689c1Smrg      if test "$build_libtool_libs" = convenience; then
9088994689c1Smrg	oldobjs="$libobjs_save $symfileobj"
9089994689c1Smrg	addlibs="$convenience"
9090994689c1Smrg	build_libtool_libs=no
9091994689c1Smrg      else
9092994689c1Smrg	if test "$build_libtool_libs" = module; then
9093994689c1Smrg	  oldobjs="$libobjs_save"
9094994689c1Smrg	  build_libtool_libs=no
9095994689c1Smrg	else
9096994689c1Smrg	  oldobjs="$old_deplibs $non_pic_objects"
9097994689c1Smrg	  if test "$preload" = yes && test -f "$symfileobj"; then
9098f353fbadSmrg	    func_append oldobjs " $symfileobj"
9099994689c1Smrg	  fi
9100994689c1Smrg	fi
9101994689c1Smrg	addlibs="$old_convenience"
91027a84e134Smrg      fi
91037a84e134Smrg
9104994689c1Smrg      if test -n "$addlibs"; then
9105994689c1Smrg	gentop="$output_objdir/${outputname}x"
9106f353fbadSmrg	func_append generated " $gentop"
91077a84e134Smrg
9108994689c1Smrg	func_extract_archives $gentop $addlibs
9109f353fbadSmrg	func_append oldobjs " $func_extract_archives_result"
9110994689c1Smrg      fi
91117a84e134Smrg
9112994689c1Smrg      # Do each command in the archive commands.
9113994689c1Smrg      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
9114994689c1Smrg	cmds=$old_archive_from_new_cmds
9115994689c1Smrg      else
91167a84e134Smrg
9117994689c1Smrg	# Add any objects from preloaded convenience libraries
9118994689c1Smrg	if test -n "$dlprefiles"; then
9119994689c1Smrg	  gentop="$output_objdir/${outputname}x"
9120f353fbadSmrg	  func_append generated " $gentop"
91217a84e134Smrg
9122994689c1Smrg	  func_extract_archives $gentop $dlprefiles
9123f353fbadSmrg	  func_append oldobjs " $func_extract_archives_result"
9124994689c1Smrg	fi
91257a84e134Smrg
9126994689c1Smrg	# POSIX demands no paths to be encoded in archives.  We have
9127994689c1Smrg	# to avoid creating archives with duplicate basenames if we
9128994689c1Smrg	# might have to extract them afterwards, e.g., when creating a
9129994689c1Smrg	# static archive out of a convenience library, or when linking
9130994689c1Smrg	# the entirety of a libtool archive into another (currently
9131994689c1Smrg	# not supported by libtool).
9132994689c1Smrg	if (for obj in $oldobjs
9133994689c1Smrg	    do
9134994689c1Smrg	      func_basename "$obj"
9135994689c1Smrg	      $ECHO "$func_basename_result"
9136994689c1Smrg	    done | sort | sort -uc >/dev/null 2>&1); then
9137994689c1Smrg	  :
9138994689c1Smrg	else
9139994689c1Smrg	  echo "copying selected object files to avoid basename conflicts..."
9140994689c1Smrg	  gentop="$output_objdir/${outputname}x"
9141f353fbadSmrg	  func_append generated " $gentop"
9142994689c1Smrg	  func_mkdir_p "$gentop"
9143994689c1Smrg	  save_oldobjs=$oldobjs
9144994689c1Smrg	  oldobjs=
9145994689c1Smrg	  counter=1
9146994689c1Smrg	  for obj in $save_oldobjs
9147994689c1Smrg	  do
9148994689c1Smrg	    func_basename "$obj"
9149994689c1Smrg	    objbase="$func_basename_result"
9150994689c1Smrg	    case " $oldobjs " in
9151994689c1Smrg	    " ") oldobjs=$obj ;;
9152994689c1Smrg	    *[\ /]"$objbase "*)
9153994689c1Smrg	      while :; do
9154994689c1Smrg		# Make sure we don't pick an alternate name that also
9155994689c1Smrg		# overlaps.
9156994689c1Smrg		newobj=lt$counter-$objbase
9157994689c1Smrg		func_arith $counter + 1
9158994689c1Smrg		counter=$func_arith_result
9159994689c1Smrg		case " $oldobjs " in
9160994689c1Smrg		*[\ /]"$newobj "*) ;;
9161994689c1Smrg		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
9162994689c1Smrg		esac
9163994689c1Smrg	      done
9164994689c1Smrg	      func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
9165f353fbadSmrg	      func_append oldobjs " $gentop/$newobj"
9166994689c1Smrg	      ;;
9167f353fbadSmrg	    *) func_append oldobjs " $obj" ;;
9168994689c1Smrg	    esac
91697a84e134Smrg	  done
9170775e7de9Smrg	fi
9171421c997bSmrg	func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
9172421c997bSmrg	tool_oldlib=$func_to_tool_file_result
9173994689c1Smrg	eval cmds=\"$old_archive_cmds\"
9174e1e1713cSmrg
9175994689c1Smrg	func_len " $cmds"
9176994689c1Smrg	len=$func_len_result
9177994689c1Smrg	if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
9178994689c1Smrg	  cmds=$old_archive_cmds
9179f353fbadSmrg	elif test -n "$archiver_list_spec"; then
9180f353fbadSmrg	  func_verbose "using command file archive linking..."
9181f353fbadSmrg	  for obj in $oldobjs
9182f353fbadSmrg	  do
9183f353fbadSmrg	    func_to_tool_file "$obj"
9184f353fbadSmrg	    $ECHO "$func_to_tool_file_result"
9185f353fbadSmrg	  done > $output_objdir/$libname.libcmd
9186f353fbadSmrg	  func_to_tool_file "$output_objdir/$libname.libcmd"
9187f353fbadSmrg	  oldobjs=" $archiver_list_spec$func_to_tool_file_result"
9188f353fbadSmrg	  cmds=$old_archive_cmds
9189994689c1Smrg	else
9190994689c1Smrg	  # the command line is too long to link in one step, link in parts
9191994689c1Smrg	  func_verbose "using piecewise archive linking..."
9192994689c1Smrg	  save_RANLIB=$RANLIB
9193994689c1Smrg	  RANLIB=:
9194994689c1Smrg	  objlist=
9195994689c1Smrg	  concat_cmds=
9196994689c1Smrg	  save_oldobjs=$oldobjs
9197994689c1Smrg	  oldobjs=
9198994689c1Smrg	  # Is there a better way of finding the last object in the list?
9199994689c1Smrg	  for obj in $save_oldobjs
9200994689c1Smrg	  do
9201994689c1Smrg	    last_oldobj=$obj
9202994689c1Smrg	  done
9203994689c1Smrg	  eval test_cmds=\"$old_archive_cmds\"
9204994689c1Smrg	  func_len " $test_cmds"
9205994689c1Smrg	  len0=$func_len_result
9206994689c1Smrg	  len=$len0
9207994689c1Smrg	  for obj in $save_oldobjs
9208994689c1Smrg	  do
9209994689c1Smrg	    func_len " $obj"
9210994689c1Smrg	    func_arith $len + $func_len_result
9211994689c1Smrg	    len=$func_arith_result
9212994689c1Smrg	    func_append objlist " $obj"
9213994689c1Smrg	    if test "$len" -lt "$max_cmd_len"; then
9214994689c1Smrg	      :
9215994689c1Smrg	    else
9216994689c1Smrg	      # the above command should be used before it gets too long
9217994689c1Smrg	      oldobjs=$objlist
9218994689c1Smrg	      if test "$obj" = "$last_oldobj" ; then
9219994689c1Smrg		RANLIB=$save_RANLIB
9220994689c1Smrg	      fi
9221994689c1Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
9222994689c1Smrg	      eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
9223994689c1Smrg	      objlist=
9224994689c1Smrg	      len=$len0
9225994689c1Smrg	    fi
9226994689c1Smrg	  done
9227994689c1Smrg	  RANLIB=$save_RANLIB
9228994689c1Smrg	  oldobjs=$objlist
9229994689c1Smrg	  if test "X$oldobjs" = "X" ; then
9230994689c1Smrg	    eval cmds=\"\$concat_cmds\"
9231994689c1Smrg	  else
9232994689c1Smrg	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
9233994689c1Smrg	  fi
9234994689c1Smrg	fi
9235994689c1Smrg      fi
9236994689c1Smrg      func_execute_cmds "$cmds" 'exit $?'
92377a84e134Smrg    done
92387a84e134Smrg
9239994689c1Smrg    test -n "$generated" && \
9240994689c1Smrg      func_show_eval "${RM}r$generated"
92417a84e134Smrg
9242994689c1Smrg    # Now create the libtool archive.
9243994689c1Smrg    case $output in
9244994689c1Smrg    *.la)
9245994689c1Smrg      old_library=
9246994689c1Smrg      test "$build_old_libs" = yes && old_library="$libname.$libext"
9247994689c1Smrg      func_verbose "creating $output"
9248775e7de9Smrg
9249994689c1Smrg      # Preserve any variables that may affect compiler behavior
9250994689c1Smrg      for var in $variables_saved_for_relink; do
9251994689c1Smrg	if eval test -z \"\${$var+set}\"; then
9252994689c1Smrg	  relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
9253994689c1Smrg	elif eval var_value=\$$var; test -z "$var_value"; then
9254994689c1Smrg	  relink_command="$var=; export $var; $relink_command"
9255e1e1713cSmrg	else
9256994689c1Smrg	  func_quote_for_eval "$var_value"
9257994689c1Smrg	  relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
9258e1e1713cSmrg	fi
9259994689c1Smrg      done
9260994689c1Smrg      # Quote the link command for shipping.
9261994689c1Smrg      relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
9262994689c1Smrg      relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
9263994689c1Smrg      if test "$hardcode_automatic" = yes ; then
9264994689c1Smrg	relink_command=
9265994689c1Smrg      fi
92667a84e134Smrg
9267994689c1Smrg      # Only create the output if not a dry run.
9268994689c1Smrg      $opt_dry_run || {
9269994689c1Smrg	for installed in no yes; do
9270994689c1Smrg	  if test "$installed" = yes; then
9271994689c1Smrg	    if test -z "$install_libdir"; then
9272994689c1Smrg	      break
9273994689c1Smrg	    fi
9274994689c1Smrg	    output="$output_objdir/$outputname"i
9275994689c1Smrg	    # Replace all uninstalled libtool libraries with the installed ones
9276994689c1Smrg	    newdependency_libs=
9277994689c1Smrg	    for deplib in $dependency_libs; do
9278994689c1Smrg	      case $deplib in
9279994689c1Smrg	      *.la)
9280994689c1Smrg		func_basename "$deplib"
9281994689c1Smrg		name="$func_basename_result"
9282421c997bSmrg		func_resolve_sysroot "$deplib"
9283421c997bSmrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result`
9284994689c1Smrg		test -z "$libdir" && \
9285994689c1Smrg		  func_fatal_error "\`$deplib' is not a valid libtool archive"
9286f353fbadSmrg		func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"
9287f353fbadSmrg		;;
9288f353fbadSmrg	      -L*)
9289f353fbadSmrg		func_stripname -L '' "$deplib"
9290f353fbadSmrg		func_replace_sysroot "$func_stripname_result"
9291f353fbadSmrg		func_append newdependency_libs " -L$func_replace_sysroot_result"
9292f353fbadSmrg		;;
9293f353fbadSmrg	      -R*)
9294f353fbadSmrg		func_stripname -R '' "$deplib"
9295f353fbadSmrg		func_replace_sysroot "$func_stripname_result"
9296f353fbadSmrg		func_append newdependency_libs " -R$func_replace_sysroot_result"
9297994689c1Smrg		;;
9298f353fbadSmrg	      *) func_append newdependency_libs " $deplib" ;;
9299994689c1Smrg	      esac
9300994689c1Smrg	    done
9301994689c1Smrg	    dependency_libs="$newdependency_libs"
9302994689c1Smrg	    newdlfiles=
9303994689c1Smrg
9304994689c1Smrg	    for lib in $dlfiles; do
9305994689c1Smrg	      case $lib in
9306994689c1Smrg	      *.la)
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 newdlfiles " ${lt_sysroot:+=}$libdir/$name"
9313994689c1Smrg		;;
9314f353fbadSmrg	      *) func_append newdlfiles " $lib" ;;
9315994689c1Smrg	      esac
9316994689c1Smrg	    done
9317994689c1Smrg	    dlfiles="$newdlfiles"
9318994689c1Smrg	    newdlprefiles=
9319994689c1Smrg	    for lib in $dlprefiles; do
9320994689c1Smrg	      case $lib in
9321994689c1Smrg	      *.la)
9322994689c1Smrg		# Only pass preopened files to the pseudo-archive (for
9323994689c1Smrg		# eventual linking with the app. that links it) if we
9324994689c1Smrg		# didn't already link the preopened objects directly into
9325994689c1Smrg		# the library:
9326994689c1Smrg		func_basename "$lib"
9327994689c1Smrg		name="$func_basename_result"
9328994689c1Smrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
9329994689c1Smrg		test -z "$libdir" && \
9330994689c1Smrg		  func_fatal_error "\`$lib' is not a valid libtool archive"
9331f353fbadSmrg		func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name"
9332994689c1Smrg		;;
9333994689c1Smrg	      esac
9334994689c1Smrg	    done
9335994689c1Smrg	    dlprefiles="$newdlprefiles"
9336994689c1Smrg	  else
9337994689c1Smrg	    newdlfiles=
9338994689c1Smrg	    for lib in $dlfiles; do
9339994689c1Smrg	      case $lib in
9340994689c1Smrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
9341994689c1Smrg		*) abs=`pwd`"/$lib" ;;
9342994689c1Smrg	      esac
9343f353fbadSmrg	      func_append newdlfiles " $abs"
9344994689c1Smrg	    done
9345994689c1Smrg	    dlfiles="$newdlfiles"
9346994689c1Smrg	    newdlprefiles=
9347994689c1Smrg	    for lib in $dlprefiles; do
9348994689c1Smrg	      case $lib in
9349994689c1Smrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
9350994689c1Smrg		*) abs=`pwd`"/$lib" ;;
9351994689c1Smrg	      esac
9352f353fbadSmrg	      func_append newdlprefiles " $abs"
9353994689c1Smrg	    done
9354994689c1Smrg	    dlprefiles="$newdlprefiles"
9355994689c1Smrg	  fi
9356994689c1Smrg	  $RM $output
9357994689c1Smrg	  # place dlname in correct position for cygwin
9358994689c1Smrg	  # In fact, it would be nice if we could use this code for all target
9359994689c1Smrg	  # systems that can't hard-code library paths into their executables
9360994689c1Smrg	  # and that have no shared library path variable independent of PATH,
9361994689c1Smrg	  # but it turns out we can't easily determine that from inspecting
9362994689c1Smrg	  # libtool variables, so we have to hard-code the OSs to which it
9363994689c1Smrg	  # applies here; at the moment, that means platforms that use the PE
9364994689c1Smrg	  # object format with DLL files.  See the long comment at the top of
9365994689c1Smrg	  # tests/bindir.at for full details.
9366994689c1Smrg	  tdlname=$dlname
9367994689c1Smrg	  case $host,$output,$installed,$module,$dlname in
9368994689c1Smrg	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
9369994689c1Smrg	      # If a -bindir argument was supplied, place the dll there.
9370994689c1Smrg	      if test "x$bindir" != x ;
9371994689c1Smrg	      then
9372994689c1Smrg		func_relative_path "$install_libdir" "$bindir"
9373994689c1Smrg		tdlname=$func_relative_path_result$dlname
9374994689c1Smrg	      else
9375994689c1Smrg		# Otherwise fall back on heuristic.
9376994689c1Smrg		tdlname=../bin/$dlname
9377994689c1Smrg	      fi
9378994689c1Smrg	      ;;
9379994689c1Smrg	  esac
9380994689c1Smrg	  $ECHO > $output "\
9381994689c1Smrg# $outputname - a libtool library file
9382994689c1Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
9383994689c1Smrg#
9384994689c1Smrg# Please DO NOT delete this file!
9385994689c1Smrg# It is necessary for linking the library.
93867a84e134Smrg
9387994689c1Smrg# The name that we can dlopen(3).
9388994689c1Smrgdlname='$tdlname'
93897a84e134Smrg
9390994689c1Smrg# Names of this library.
9391994689c1Smrglibrary_names='$library_names'
93927a84e134Smrg
9393994689c1Smrg# The name of the static archive.
9394994689c1Smrgold_library='$old_library'
93957a84e134Smrg
9396994689c1Smrg# Linker flags that can not go in dependency_libs.
9397994689c1Smrginherited_linker_flags='$new_inherited_linker_flags'
93987a84e134Smrg
9399994689c1Smrg# Libraries that this one depends upon.
9400994689c1Smrgdependency_libs='$dependency_libs'
94017a84e134Smrg
9402994689c1Smrg# Names of additional weak libraries provided by this library
9403994689c1Smrgweak_library_names='$weak_libs'
94047a84e134Smrg
9405994689c1Smrg# Version information for $libname.
9406994689c1Smrgcurrent=$current
9407994689c1Smrgage=$age
9408994689c1Smrgrevision=$revision
94097a84e134Smrg
9410994689c1Smrg# Is this an already installed library?
9411994689c1Smrginstalled=$installed
94127a84e134Smrg
9413994689c1Smrg# Should we warn about portability when linking against -modules?
9414994689c1Smrgshouldnotlink=$module
94157a84e134Smrg
9416994689c1Smrg# Files to dlopen/dlpreopen
9417994689c1Smrgdlopen='$dlfiles'
9418994689c1Smrgdlpreopen='$dlprefiles'
94197a84e134Smrg
9420994689c1Smrg# Directory that this library needs to be installed in:
9421994689c1Smrglibdir='$install_libdir'"
9422994689c1Smrg	  if test "$installed" = no && test "$need_relink" = yes; then
9423994689c1Smrg	    $ECHO >> $output "\
9424994689c1Smrgrelink_command=\"$relink_command\""
9425994689c1Smrg	  fi
9426994689c1Smrg	done
9427994689c1Smrg      }
94287a84e134Smrg
9429994689c1Smrg      # Do a symbolic link so that the libtool archive can be found in
9430994689c1Smrg      # LD_LIBRARY_PATH before the program is installed.
9431994689c1Smrg      func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
9432994689c1Smrg      ;;
9433994689c1Smrg    esac
9434994689c1Smrg    exit $EXIT_SUCCESS
9435994689c1Smrg}
9436e1e1713cSmrg
9437f353fbadSmrg{ test "$opt_mode" = link || test "$opt_mode" = relink; } &&
9438994689c1Smrg    func_mode_link ${1+"$@"}
94397a84e134Smrg
94407a84e134Smrg
9441994689c1Smrg# func_mode_uninstall arg...
9442994689c1Smrgfunc_mode_uninstall ()
9443994689c1Smrg{
9444994689c1Smrg    $opt_debug
9445994689c1Smrg    RM="$nonopt"
94467a84e134Smrg    files=
94477a84e134Smrg    rmforce=
94487a84e134Smrg    exit_status=0
94497a84e134Smrg
94507a84e134Smrg    # This variable tells wrapper scripts just to set variables rather
94517a84e134Smrg    # than running their programs.
94527a84e134Smrg    libtool_install_magic="$magic"
94537a84e134Smrg
94547a84e134Smrg    for arg
94557a84e134Smrg    do
94567a84e134Smrg      case $arg in
9457f353fbadSmrg      -f) func_append RM " $arg"; rmforce=yes ;;
9458f353fbadSmrg      -*) func_append RM " $arg" ;;
9459f353fbadSmrg      *) func_append files " $arg" ;;
94607a84e134Smrg      esac
94617a84e134Smrg    done
94627a84e134Smrg
9463994689c1Smrg    test -z "$RM" && \
9464994689c1Smrg      func_fatal_help "you must specify an RM program"
94657a84e134Smrg
94667a84e134Smrg    rmdirs=
94677a84e134Smrg
94687a84e134Smrg    for file in $files; do
9469994689c1Smrg      func_dirname "$file" "" "."
9470994689c1Smrg      dir="$func_dirname_result"
9471994689c1Smrg      if test "X$dir" = X.; then
9472f353fbadSmrg	odir="$objdir"
94737a84e134Smrg      else
9474f353fbadSmrg	odir="$dir/$objdir"
94757a84e134Smrg      fi
9476994689c1Smrg      func_basename "$file"
9477994689c1Smrg      name="$func_basename_result"
9478f353fbadSmrg      test "$opt_mode" = uninstall && odir="$dir"
94797a84e134Smrg
9480f353fbadSmrg      # Remember odir for removal later, being careful to avoid duplicates
9481f353fbadSmrg      if test "$opt_mode" = clean; then
94827a84e134Smrg	case " $rmdirs " in
9483f353fbadSmrg	  *" $odir "*) ;;
9484f353fbadSmrg	  *) func_append rmdirs " $odir" ;;
94857a84e134Smrg	esac
94867a84e134Smrg      fi
94877a84e134Smrg
94887a84e134Smrg      # Don't error if the file doesn't exist and rm -f was used.
9489994689c1Smrg      if { test -L "$file"; } >/dev/null 2>&1 ||
9490994689c1Smrg	 { test -h "$file"; } >/dev/null 2>&1 ||
9491994689c1Smrg	 test -f "$file"; then
94927a84e134Smrg	:
94937a84e134Smrg      elif test -d "$file"; then
94947a84e134Smrg	exit_status=1
94957a84e134Smrg	continue
94967a84e134Smrg      elif test "$rmforce" = yes; then
94977a84e134Smrg	continue
94987a84e134Smrg      fi
94997a84e134Smrg
95007a84e134Smrg      rmfiles="$file"
95017a84e134Smrg
95027a84e134Smrg      case $name in
95037a84e134Smrg      *.la)
95047a84e134Smrg	# Possibly a libtool archive, so verify it.
9505994689c1Smrg	if func_lalib_p "$file"; then
9506994689c1Smrg	  func_source $dir/$name
95077a84e134Smrg
95087a84e134Smrg	  # Delete the libtool libraries and symlinks.
95097a84e134Smrg	  for n in $library_names; do
9510f353fbadSmrg	    func_append rmfiles " $odir/$n"
95117a84e134Smrg	  done
9512f353fbadSmrg	  test -n "$old_library" && func_append rmfiles " $odir/$old_library"
95137a84e134Smrg
9514f353fbadSmrg	  case "$opt_mode" in
95157a84e134Smrg	  clean)
9516f353fbadSmrg	    case " $library_names " in
95177a84e134Smrg	    *" $dlname "*) ;;
9518f353fbadSmrg	    *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;;
95197a84e134Smrg	    esac
9520f353fbadSmrg	    test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i"
95217a84e134Smrg	    ;;
95227a84e134Smrg	  uninstall)
95237a84e134Smrg	    if test -n "$library_names"; then
95247a84e134Smrg	      # Do each command in the postuninstall commands.
9525994689c1Smrg	      func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
95267a84e134Smrg	    fi
95277a84e134Smrg
95287a84e134Smrg	    if test -n "$old_library"; then
95297a84e134Smrg	      # Do each command in the old_postuninstall commands.
9530994689c1Smrg	      func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
95317a84e134Smrg	    fi
95327a84e134Smrg	    # FIXME: should reinstall the best remaining shared library.
95337a84e134Smrg	    ;;
95347a84e134Smrg	  esac
95357a84e134Smrg	fi
95367a84e134Smrg	;;
95377a84e134Smrg
95387a84e134Smrg      *.lo)
95397a84e134Smrg	# Possibly a libtool object, so verify it.
9540994689c1Smrg	if func_lalib_p "$file"; then
95417a84e134Smrg
95427a84e134Smrg	  # Read the .lo file
9543994689c1Smrg	  func_source $dir/$name
95447a84e134Smrg
95457a84e134Smrg	  # Add PIC object to the list of files to remove.
9546994689c1Smrg	  if test -n "$pic_object" &&
9547994689c1Smrg	     test "$pic_object" != none; then
9548f353fbadSmrg	    func_append rmfiles " $dir/$pic_object"
95497a84e134Smrg	  fi
95507a84e134Smrg
95517a84e134Smrg	  # Add non-PIC object to the list of files to remove.
9552994689c1Smrg	  if test -n "$non_pic_object" &&
9553994689c1Smrg	     test "$non_pic_object" != none; then
9554f353fbadSmrg	    func_append rmfiles " $dir/$non_pic_object"
95557a84e134Smrg	  fi
95567a84e134Smrg	fi
95577a84e134Smrg	;;
95587a84e134Smrg
95597a84e134Smrg      *)
9560f353fbadSmrg	if test "$opt_mode" = clean ; then
95617a84e134Smrg	  noexename=$name
95627a84e134Smrg	  case $file in
95637a84e134Smrg	  *.exe)
9564994689c1Smrg	    func_stripname '' '.exe' "$file"
9565994689c1Smrg	    file=$func_stripname_result
9566994689c1Smrg	    func_stripname '' '.exe' "$name"
9567994689c1Smrg	    noexename=$func_stripname_result
95687a84e134Smrg	    # $file with .exe has already been added to rmfiles,
95697a84e134Smrg	    # add $file without .exe
9570f353fbadSmrg	    func_append rmfiles " $file"
95717a84e134Smrg	    ;;
95727a84e134Smrg	  esac
95737a84e134Smrg	  # Do a test to see if this is a libtool program.
9574994689c1Smrg	  if func_ltwrapper_p "$file"; then
9575994689c1Smrg	    if func_ltwrapper_executable_p "$file"; then
9576994689c1Smrg	      func_ltwrapper_scriptname "$file"
9577994689c1Smrg	      relink_command=
9578994689c1Smrg	      func_source $func_ltwrapper_scriptname_result
9579f353fbadSmrg	      func_append rmfiles " $func_ltwrapper_scriptname_result"
9580994689c1Smrg	    else
9581994689c1Smrg	      relink_command=
9582994689c1Smrg	      func_source $dir/$noexename
9583994689c1Smrg	    fi
95847a84e134Smrg
95857a84e134Smrg	    # note $name still contains .exe if it was in $file originally
95867a84e134Smrg	    # as does the version of $file that was added into $rmfiles
9587f353fbadSmrg	    func_append rmfiles " $odir/$name $odir/${name}S.${objext}"
95887a84e134Smrg	    if test "$fast_install" = yes && test -n "$relink_command"; then
9589f353fbadSmrg	      func_append rmfiles " $odir/lt-$name"
95907a84e134Smrg	    fi
95917a84e134Smrg	    if test "X$noexename" != "X$name" ; then
9592f353fbadSmrg	      func_append rmfiles " $odir/lt-${noexename}.c"
95937a84e134Smrg	    fi
95947a84e134Smrg	  fi
95957a84e134Smrg	fi
95967a84e134Smrg	;;
95977a84e134Smrg      esac
9598994689c1Smrg      func_show_eval "$RM $rmfiles" 'exit_status=1'
95997a84e134Smrg    done
96007a84e134Smrg
96017a84e134Smrg    # Try to remove the ${objdir}s in the directories where we deleted files
96027a84e134Smrg    for dir in $rmdirs; do
96037a84e134Smrg      if test -d "$dir"; then
9604994689c1Smrg	func_show_eval "rmdir $dir >/dev/null 2>&1"
96057a84e134Smrg      fi
96067a84e134Smrg    done
96077a84e134Smrg
96087a84e134Smrg    exit $exit_status
9609994689c1Smrg}
96107a84e134Smrg
9611f353fbadSmrg{ test "$opt_mode" = uninstall || test "$opt_mode" = clean; } &&
9612994689c1Smrg    func_mode_uninstall ${1+"$@"}
9613775e7de9Smrg
9614f353fbadSmrgtest -z "$opt_mode" && {
9615994689c1Smrg  help="$generic_help"
9616994689c1Smrg  func_fatal_help "you must specify a MODE"
9617994689c1Smrg}
9618994689c1Smrg
9619994689c1Smrgtest -z "$exec_cmd" && \
9620f353fbadSmrg  func_fatal_help "invalid operation mode \`$opt_mode'"
96217a84e134Smrg
96227a84e134Smrgif test -n "$exec_cmd"; then
9623994689c1Smrg  eval exec "$exec_cmd"
96247a84e134Smrg  exit $EXIT_FAILURE
96257a84e134Smrgfi
96267a84e134Smrg
9627994689c1Smrgexit $exit_status
9628e1e1713cSmrg
96297a84e134Smrg
96307a84e134Smrg# The TAGs below are defined such that we never get into a situation
96317a84e134Smrg# in which we disable both kinds of libraries.  Given conflicting
96327a84e134Smrg# choices, we go for a static library, that is the most portable,
96337a84e134Smrg# since we can't tell whether shared libraries were disabled because
96347a84e134Smrg# the user asked for that or because the platform doesn't support
96357a84e134Smrg# them.  This is particularly important on AIX, because we don't
96367a84e134Smrg# support having both static and shared libraries enabled at the same
96377a84e134Smrg# time on that platform, so we default to a shared-only configuration.
96387a84e134Smrg# If a disable-shared tag is given, we'll fallback to a static-only
96397a84e134Smrg# configuration.  But we'll never go from static-only to shared-only.
96407a84e134Smrg
96417a84e134Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
9642994689c1Smrgbuild_libtool_libs=no
9643994689c1Smrgbuild_old_libs=yes
96447a84e134Smrg# ### END LIBTOOL TAG CONFIG: disable-shared
96457a84e134Smrg
96467a84e134Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static
9647994689c1Smrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
96487a84e134Smrg# ### END LIBTOOL TAG CONFIG: disable-static
96497a84e134Smrg
96507a84e134Smrg# Local Variables:
96517a84e134Smrg# mode:shell-script
96527a84e134Smrg# sh-indentation:2
96537a84e134Smrg# End:
9654994689c1Smrg# vi:sw=2
9655994689c1Smrg
9656