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