1428d7b3dSmrg
2428d7b3dSmrg# libtool (GNU libtool) 2.4.2
3428d7b3dSmrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
4428d7b3dSmrg
5428d7b3dSmrg# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006,
6428d7b3dSmrg# 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
7428d7b3dSmrg# This is free software; see the source for copying conditions.  There is NO
8428d7b3dSmrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9428d7b3dSmrg
10428d7b3dSmrg# GNU Libtool is free software; you can redistribute it and/or modify
11428d7b3dSmrg# it under the terms of the GNU General Public License as published by
12428d7b3dSmrg# the Free Software Foundation; either version 2 of the License, or
13428d7b3dSmrg# (at your option) any later version.
14428d7b3dSmrg#
15428d7b3dSmrg# As a special exception to the GNU General Public License,
16428d7b3dSmrg# if you distribute this file as part of a program or library that
17428d7b3dSmrg# is built using GNU Libtool, you may include this file under the
18428d7b3dSmrg# same distribution terms that you use for the rest of that program.
19428d7b3dSmrg#
20428d7b3dSmrg# GNU Libtool is distributed in the hope that it will be useful, but
21428d7b3dSmrg# WITHOUT ANY WARRANTY; without even the implied warranty of
22428d7b3dSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
23428d7b3dSmrg# General Public License for more details.
24428d7b3dSmrg#
25428d7b3dSmrg# You should have received a copy of the GNU General Public License
26428d7b3dSmrg# along with GNU Libtool; see the file COPYING.  If not, a copy
27428d7b3dSmrg# can be downloaded from http://www.gnu.org/licenses/gpl.html,
28428d7b3dSmrg# or obtained by writing to the Free Software Foundation, Inc.,
29428d7b3dSmrg# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
30428d7b3dSmrg
31428d7b3dSmrg# Usage: $progname [OPTION]... [MODE-ARG]...
32428d7b3dSmrg#
33428d7b3dSmrg# Provide generalized library-building support services.
34428d7b3dSmrg#
35428d7b3dSmrg#       --config             show all configuration variables
36428d7b3dSmrg#       --debug              enable verbose shell tracing
37428d7b3dSmrg#   -n, --dry-run            display commands without modifying any files
38428d7b3dSmrg#       --features           display basic configuration information and exit
39428d7b3dSmrg#       --mode=MODE          use operation mode MODE
40428d7b3dSmrg#       --preserve-dup-deps  don't remove duplicate dependency libraries
41428d7b3dSmrg#       --quiet, --silent    don't print informational messages
42428d7b3dSmrg#       --no-quiet, --no-silent
43428d7b3dSmrg#                            print informational messages (default)
44428d7b3dSmrg#       --no-warn            don't display warning messages
45428d7b3dSmrg#       --tag=TAG            use configuration variables from tag TAG
46428d7b3dSmrg#   -v, --verbose            print more informational messages than default
47428d7b3dSmrg#       --no-verbose         don't print the extra informational messages
48428d7b3dSmrg#       --version            print version information
49428d7b3dSmrg#   -h, --help, --help-all   print short, long, or detailed help message
50428d7b3dSmrg#
51428d7b3dSmrg# MODE must be one of the following:
52428d7b3dSmrg#
53428d7b3dSmrg#         clean              remove files from the build directory
54428d7b3dSmrg#         compile            compile a source file into a libtool object
55428d7b3dSmrg#         execute            automatically set library path, then run a program
56428d7b3dSmrg#         finish             complete the installation of libtool libraries
57428d7b3dSmrg#         install            install libraries or executables
58428d7b3dSmrg#         link               create a library or an executable
59428d7b3dSmrg#         uninstall          remove libraries from an installed directory
60428d7b3dSmrg#
61428d7b3dSmrg# MODE-ARGS vary depending on the MODE.  When passed as first option,
62428d7b3dSmrg# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that.
63428d7b3dSmrg# Try `$progname --help --mode=MODE' for a more detailed description of MODE.
64428d7b3dSmrg#
65428d7b3dSmrg# When reporting a bug, please describe a test case to reproduce it and
66428d7b3dSmrg# include the following information:
67428d7b3dSmrg#
68428d7b3dSmrg#         host-triplet:	$host
69428d7b3dSmrg#         shell:		$SHELL
70428d7b3dSmrg#         compiler:		$LTCC
71428d7b3dSmrg#         compiler flags:		$LTCFLAGS
72428d7b3dSmrg#         linker:		$LD (gnu? $with_gnu_ld)
73428d7b3dSmrg#         $progname:	(GNU libtool) 2.4.2 Debian-2.4.2-1.7ubuntu1
74428d7b3dSmrg#         automake:	$automake_version
75428d7b3dSmrg#         autoconf:	$autoconf_version
76428d7b3dSmrg#
77428d7b3dSmrg# Report bugs to <bug-libtool@gnu.org>.
78428d7b3dSmrg# GNU libtool home page: <http://www.gnu.org/software/libtool/>.
79428d7b3dSmrg# General help using GNU software: <http://www.gnu.org/gethelp/>.
80428d7b3dSmrg
81428d7b3dSmrgPROGRAM=libtool
82428d7b3dSmrgPACKAGE=libtool
83428d7b3dSmrgVERSION="2.4.2 Debian-2.4.2-1.7ubuntu1"
84428d7b3dSmrgTIMESTAMP=""
85428d7b3dSmrgpackage_revision=1.3337
86428d7b3dSmrg
87428d7b3dSmrg# Be Bourne compatible
88428d7b3dSmrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
89428d7b3dSmrg  emulate sh
90428d7b3dSmrg  NULLCMD=:
91428d7b3dSmrg  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
92428d7b3dSmrg  # is contrary to our usage.  Disable this feature.
93428d7b3dSmrg  alias -g '${1+"$@"}'='"$@"'
94428d7b3dSmrg  setopt NO_GLOB_SUBST
95428d7b3dSmrgelse
96428d7b3dSmrg  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
97428d7b3dSmrgfi
98428d7b3dSmrgBIN_SH=xpg4; export BIN_SH # for Tru64
99428d7b3dSmrgDUALCASE=1; export DUALCASE # for MKS sh
100428d7b3dSmrg
101428d7b3dSmrg# A function that is used when there is no print builtin or printf.
102428d7b3dSmrgfunc_fallback_echo ()
103428d7b3dSmrg{
104428d7b3dSmrg  eval 'cat <<_LTECHO_EOF
105428d7b3dSmrg$1
106428d7b3dSmrg_LTECHO_EOF'
107428d7b3dSmrg}
108428d7b3dSmrg
109428d7b3dSmrg# NLS nuisances: We save the old values to restore during execute mode.
110428d7b3dSmrglt_user_locale=
111428d7b3dSmrglt_safe_locale=
112428d7b3dSmrgfor lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
113428d7b3dSmrgdo
114428d7b3dSmrg  eval "if test \"\${$lt_var+set}\" = set; then
115428d7b3dSmrg          save_$lt_var=\$$lt_var
116428d7b3dSmrg          $lt_var=C
117428d7b3dSmrg	  export $lt_var
118428d7b3dSmrg	  lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\"
119428d7b3dSmrg	  lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
120428d7b3dSmrg	fi"
121428d7b3dSmrgdone
122428d7b3dSmrgLC_ALL=C
123428d7b3dSmrgLANGUAGE=C
124428d7b3dSmrgexport LANGUAGE LC_ALL
125428d7b3dSmrg
126428d7b3dSmrg$lt_unset CDPATH
127428d7b3dSmrg
128428d7b3dSmrg
129428d7b3dSmrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
130428d7b3dSmrg# is ksh but when the shell is invoked as "sh" and the current value of
131428d7b3dSmrg# the _XPG environment variable is not equal to 1 (one), the special
132428d7b3dSmrg# positional parameter $0, within a function call, is the name of the
133428d7b3dSmrg# function.
134428d7b3dSmrgprogpath="$0"
135428d7b3dSmrg
136428d7b3dSmrg
137428d7b3dSmrg
138428d7b3dSmrg: ${CP="cp -f"}
139428d7b3dSmrgtest "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'}
140428d7b3dSmrg: ${MAKE="make"}
141428d7b3dSmrg: ${MKDIR="mkdir"}
142428d7b3dSmrg: ${MV="mv -f"}
143428d7b3dSmrg: ${RM="rm -f"}
144428d7b3dSmrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
145428d7b3dSmrg: ${Xsed="$SED -e 1s/^X//"}
146428d7b3dSmrg
147428d7b3dSmrg# Global variables:
148428d7b3dSmrgEXIT_SUCCESS=0
149428d7b3dSmrgEXIT_FAILURE=1
150428d7b3dSmrgEXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
151428d7b3dSmrgEXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
152428d7b3dSmrg
153428d7b3dSmrgexit_status=$EXIT_SUCCESS
154428d7b3dSmrg
155428d7b3dSmrg# Make sure IFS has a sensible default
156428d7b3dSmrglt_nl='
157428d7b3dSmrg'
158428d7b3dSmrgIFS=" 	$lt_nl"
159428d7b3dSmrg
160428d7b3dSmrgdirname="s,/[^/]*$,,"
161428d7b3dSmrgbasename="s,^.*/,,"
162428d7b3dSmrg
163428d7b3dSmrg# func_dirname file append nondir_replacement
164428d7b3dSmrg# Compute the dirname of FILE.  If nonempty, add APPEND to the result,
165428d7b3dSmrg# otherwise set result to NONDIR_REPLACEMENT.
166428d7b3dSmrgfunc_dirname ()
167428d7b3dSmrg{
168428d7b3dSmrg    func_dirname_result=`$ECHO "${1}" | $SED "$dirname"`
169428d7b3dSmrg    if test "X$func_dirname_result" = "X${1}"; then
170428d7b3dSmrg      func_dirname_result="${3}"
171428d7b3dSmrg    else
172428d7b3dSmrg      func_dirname_result="$func_dirname_result${2}"
173428d7b3dSmrg    fi
174428d7b3dSmrg} # func_dirname may be replaced by extended shell implementation
175428d7b3dSmrg
176428d7b3dSmrg
177428d7b3dSmrg# func_basename file
178428d7b3dSmrgfunc_basename ()
179428d7b3dSmrg{
180428d7b3dSmrg    func_basename_result=`$ECHO "${1}" | $SED "$basename"`
181428d7b3dSmrg} # func_basename may be replaced by extended shell implementation
182428d7b3dSmrg
183428d7b3dSmrg
184428d7b3dSmrg# func_dirname_and_basename file append nondir_replacement
185428d7b3dSmrg# perform func_basename and func_dirname in a single function
186428d7b3dSmrg# call:
187428d7b3dSmrg#   dirname:  Compute the dirname of FILE.  If nonempty,
188428d7b3dSmrg#             add APPEND to the result, otherwise set result
189428d7b3dSmrg#             to NONDIR_REPLACEMENT.
190428d7b3dSmrg#             value returned in "$func_dirname_result"
191428d7b3dSmrg#   basename: Compute filename of FILE.
192428d7b3dSmrg#             value retuned in "$func_basename_result"
193428d7b3dSmrg# Implementation must be kept synchronized with func_dirname
194428d7b3dSmrg# and func_basename. For efficiency, we do not delegate to
195428d7b3dSmrg# those functions but instead duplicate the functionality here.
196428d7b3dSmrgfunc_dirname_and_basename ()
197428d7b3dSmrg{
198428d7b3dSmrg    # Extract subdirectory from the argument.
199428d7b3dSmrg    func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"`
200428d7b3dSmrg    if test "X$func_dirname_result" = "X${1}"; then
201428d7b3dSmrg      func_dirname_result="${3}"
202428d7b3dSmrg    else
203428d7b3dSmrg      func_dirname_result="$func_dirname_result${2}"
204428d7b3dSmrg    fi
205428d7b3dSmrg    func_basename_result=`$ECHO "${1}" | $SED -e "$basename"`
206428d7b3dSmrg} # func_dirname_and_basename may be replaced by extended shell implementation
207428d7b3dSmrg
208428d7b3dSmrg
209428d7b3dSmrg# func_stripname prefix suffix name
210428d7b3dSmrg# strip PREFIX and SUFFIX off of NAME.
211428d7b3dSmrg# PREFIX and SUFFIX must not contain globbing or regex special
212428d7b3dSmrg# characters, hashes, percent signs, but SUFFIX may contain a leading
213428d7b3dSmrg# dot (in which case that matches only a dot).
214428d7b3dSmrg# func_strip_suffix prefix name
215428d7b3dSmrgfunc_stripname ()
216428d7b3dSmrg{
217428d7b3dSmrg    case ${2} in
218428d7b3dSmrg      .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;;
219428d7b3dSmrg      *)  func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;;
220428d7b3dSmrg    esac
221428d7b3dSmrg} # func_stripname may be replaced by extended shell implementation
222428d7b3dSmrg
223428d7b3dSmrg
224428d7b3dSmrg# These SED scripts presuppose an absolute path with a trailing slash.
225428d7b3dSmrgpathcar='s,^/\([^/]*\).*$,\1,'
226428d7b3dSmrgpathcdr='s,^/[^/]*,,'
227428d7b3dSmrgremovedotparts=':dotsl
228428d7b3dSmrg		s@/\./@/@g
229428d7b3dSmrg		t dotsl
230428d7b3dSmrg		s,/\.$,/,'
231428d7b3dSmrgcollapseslashes='s@/\{1,\}@/@g'
232428d7b3dSmrgfinalslash='s,/*$,/,'
233428d7b3dSmrg
234428d7b3dSmrg# func_normal_abspath PATH
235428d7b3dSmrg# Remove doubled-up and trailing slashes, "." path components,
236428d7b3dSmrg# and cancel out any ".." path components in PATH after making
237428d7b3dSmrg# it an absolute path.
238428d7b3dSmrg#             value returned in "$func_normal_abspath_result"
239428d7b3dSmrgfunc_normal_abspath ()
240428d7b3dSmrg{
241428d7b3dSmrg  # Start from root dir and reassemble the path.
242428d7b3dSmrg  func_normal_abspath_result=
243428d7b3dSmrg  func_normal_abspath_tpath=$1
244428d7b3dSmrg  func_normal_abspath_altnamespace=
245428d7b3dSmrg  case $func_normal_abspath_tpath in
246428d7b3dSmrg    "")
247428d7b3dSmrg      # Empty path, that just means $cwd.
248428d7b3dSmrg      func_stripname '' '/' "`pwd`"
249428d7b3dSmrg      func_normal_abspath_result=$func_stripname_result
250428d7b3dSmrg      return
251428d7b3dSmrg    ;;
252428d7b3dSmrg    # The next three entries are used to spot a run of precisely
253428d7b3dSmrg    # two leading slashes without using negated character classes;
254428d7b3dSmrg    # we take advantage of case's first-match behaviour.
255428d7b3dSmrg    ///*)
256428d7b3dSmrg      # Unusual form of absolute path, do nothing.
257428d7b3dSmrg    ;;
258428d7b3dSmrg    //*)
259428d7b3dSmrg      # Not necessarily an ordinary path; POSIX reserves leading '//'
260428d7b3dSmrg      # and for example Cygwin uses it to access remote file shares
261428d7b3dSmrg      # over CIFS/SMB, so we conserve a leading double slash if found.
262428d7b3dSmrg      func_normal_abspath_altnamespace=/
263428d7b3dSmrg    ;;
264428d7b3dSmrg    /*)
265428d7b3dSmrg      # Absolute path, do nothing.
266428d7b3dSmrg    ;;
267428d7b3dSmrg    *)
268428d7b3dSmrg      # Relative path, prepend $cwd.
269428d7b3dSmrg      func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
270428d7b3dSmrg    ;;
271428d7b3dSmrg  esac
272428d7b3dSmrg  # Cancel out all the simple stuff to save iterations.  We also want
273428d7b3dSmrg  # the path to end with a slash for ease of parsing, so make sure
274428d7b3dSmrg  # there is one (and only one) here.
275428d7b3dSmrg  func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
276428d7b3dSmrg        -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"`
277428d7b3dSmrg  while :; do
278428d7b3dSmrg    # Processed it all yet?
279428d7b3dSmrg    if test "$func_normal_abspath_tpath" = / ; then
280428d7b3dSmrg      # If we ascended to the root using ".." the result may be empty now.
281428d7b3dSmrg      if test -z "$func_normal_abspath_result" ; then
282428d7b3dSmrg        func_normal_abspath_result=/
283428d7b3dSmrg      fi
284428d7b3dSmrg      break
285428d7b3dSmrg    fi
286428d7b3dSmrg    func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
287428d7b3dSmrg        -e "$pathcar"`
288428d7b3dSmrg    func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
289428d7b3dSmrg        -e "$pathcdr"`
290428d7b3dSmrg    # Figure out what to do with it
291428d7b3dSmrg    case $func_normal_abspath_tcomponent in
292428d7b3dSmrg      "")
293428d7b3dSmrg        # Trailing empty path component, ignore it.
294428d7b3dSmrg      ;;
295428d7b3dSmrg      ..)
296428d7b3dSmrg        # Parent dir; strip last assembled component from result.
297428d7b3dSmrg        func_dirname "$func_normal_abspath_result"
298428d7b3dSmrg        func_normal_abspath_result=$func_dirname_result
299428d7b3dSmrg      ;;
300428d7b3dSmrg      *)
301428d7b3dSmrg        # Actual path component, append it.
302428d7b3dSmrg        func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent
303428d7b3dSmrg      ;;
304428d7b3dSmrg    esac
305428d7b3dSmrg  done
306428d7b3dSmrg  # Restore leading double-slash if one was found on entry.
307428d7b3dSmrg  func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
308428d7b3dSmrg}
309428d7b3dSmrg
310428d7b3dSmrg# func_relative_path SRCDIR DSTDIR
311428d7b3dSmrg# generates a relative path from SRCDIR to DSTDIR, with a trailing
312428d7b3dSmrg# slash if non-empty, suitable for immediately appending a filename
313428d7b3dSmrg# without needing to append a separator.
314428d7b3dSmrg#             value returned in "$func_relative_path_result"
315428d7b3dSmrgfunc_relative_path ()
316428d7b3dSmrg{
317428d7b3dSmrg  func_relative_path_result=
318428d7b3dSmrg  func_normal_abspath "$1"
319428d7b3dSmrg  func_relative_path_tlibdir=$func_normal_abspath_result
320428d7b3dSmrg  func_normal_abspath "$2"
321428d7b3dSmrg  func_relative_path_tbindir=$func_normal_abspath_result
322428d7b3dSmrg
323428d7b3dSmrg  # Ascend the tree starting from libdir
324428d7b3dSmrg  while :; do
325428d7b3dSmrg    # check if we have found a prefix of bindir
326428d7b3dSmrg    case $func_relative_path_tbindir in
327428d7b3dSmrg      $func_relative_path_tlibdir)
328428d7b3dSmrg        # found an exact match
329428d7b3dSmrg        func_relative_path_tcancelled=
330428d7b3dSmrg        break
331428d7b3dSmrg        ;;
332428d7b3dSmrg      $func_relative_path_tlibdir*)
333428d7b3dSmrg        # found a matching prefix
334428d7b3dSmrg        func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
335428d7b3dSmrg        func_relative_path_tcancelled=$func_stripname_result
336428d7b3dSmrg        if test -z "$func_relative_path_result"; then
337428d7b3dSmrg          func_relative_path_result=.
338428d7b3dSmrg        fi
339428d7b3dSmrg        break
340428d7b3dSmrg        ;;
341428d7b3dSmrg      *)
342428d7b3dSmrg        func_dirname $func_relative_path_tlibdir
343428d7b3dSmrg        func_relative_path_tlibdir=${func_dirname_result}
344428d7b3dSmrg        if test "x$func_relative_path_tlibdir" = x ; then
345428d7b3dSmrg          # Have to descend all the way to the root!
346428d7b3dSmrg          func_relative_path_result=../$func_relative_path_result
347428d7b3dSmrg          func_relative_path_tcancelled=$func_relative_path_tbindir
348428d7b3dSmrg          break
349428d7b3dSmrg        fi
350428d7b3dSmrg        func_relative_path_result=../$func_relative_path_result
351428d7b3dSmrg        ;;
352428d7b3dSmrg    esac
353428d7b3dSmrg  done
354428d7b3dSmrg
355428d7b3dSmrg  # Now calculate path; take care to avoid doubling-up slashes.
356428d7b3dSmrg  func_stripname '' '/' "$func_relative_path_result"
357428d7b3dSmrg  func_relative_path_result=$func_stripname_result
358428d7b3dSmrg  func_stripname '/' '/' "$func_relative_path_tcancelled"
359428d7b3dSmrg  if test "x$func_stripname_result" != x ; then
360428d7b3dSmrg    func_relative_path_result=${func_relative_path_result}/${func_stripname_result}
361428d7b3dSmrg  fi
362428d7b3dSmrg
363428d7b3dSmrg  # Normalisation. If bindir is libdir, return empty string,
364428d7b3dSmrg  # else relative path ending with a slash; either way, target
365428d7b3dSmrg  # file name can be directly appended.
366428d7b3dSmrg  if test ! -z "$func_relative_path_result"; then
367428d7b3dSmrg    func_stripname './' '' "$func_relative_path_result/"
368428d7b3dSmrg    func_relative_path_result=$func_stripname_result
369428d7b3dSmrg  fi
370428d7b3dSmrg}
371428d7b3dSmrg
372428d7b3dSmrg# The name of this program:
373428d7b3dSmrgfunc_dirname_and_basename "$progpath"
374428d7b3dSmrgprogname=$func_basename_result
375428d7b3dSmrg
376428d7b3dSmrg# Make sure we have an absolute path for reexecution:
377428d7b3dSmrgcase $progpath in
378428d7b3dSmrg  [\\/]*|[A-Za-z]:\\*) ;;
379428d7b3dSmrg  *[\\/]*)
380428d7b3dSmrg     progdir=$func_dirname_result
381428d7b3dSmrg     progdir=`cd "$progdir" && pwd`
382428d7b3dSmrg     progpath="$progdir/$progname"
383428d7b3dSmrg     ;;
384428d7b3dSmrg  *)
385428d7b3dSmrg     save_IFS="$IFS"
386428d7b3dSmrg     IFS=${PATH_SEPARATOR-:}
387428d7b3dSmrg     for progdir in $PATH; do
388428d7b3dSmrg       IFS="$save_IFS"
389428d7b3dSmrg       test -x "$progdir/$progname" && break
390428d7b3dSmrg     done
391428d7b3dSmrg     IFS="$save_IFS"
392428d7b3dSmrg     test -n "$progdir" || progdir=`pwd`
393428d7b3dSmrg     progpath="$progdir/$progname"
394428d7b3dSmrg     ;;
395428d7b3dSmrgesac
396428d7b3dSmrg
397428d7b3dSmrg# Sed substitution that helps us do robust quoting.  It backslashifies
398428d7b3dSmrg# metacharacters that are still active within double-quoted strings.
399428d7b3dSmrgXsed="${SED}"' -e 1s/^X//'
400428d7b3dSmrgsed_quote_subst='s/\([`"$\\]\)/\\\1/g'
401428d7b3dSmrg
402428d7b3dSmrg# Same as above, but do not quote variable references.
403428d7b3dSmrgdouble_quote_subst='s/\(["`\\]\)/\\\1/g'
404428d7b3dSmrg
405428d7b3dSmrg# Sed substitution that turns a string into a regex matching for the
406428d7b3dSmrg# string literally.
407428d7b3dSmrgsed_make_literal_regex='s,[].[^$\\*\/],\\&,g'
408428d7b3dSmrg
409428d7b3dSmrg# Sed substitution that converts a w32 file name or path
410428d7b3dSmrg# which contains forward slashes, into one that contains
411428d7b3dSmrg# (escaped) backslashes.  A very naive implementation.
412428d7b3dSmrglt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
413428d7b3dSmrg
414428d7b3dSmrg# Re-`\' parameter expansions in output of double_quote_subst that were
415428d7b3dSmrg# `\'-ed in input to the same.  If an odd number of `\' preceded a '$'
416428d7b3dSmrg# in input to double_quote_subst, that '$' was protected from expansion.
417428d7b3dSmrg# Since each input `\' is now two `\'s, look for any number of runs of
418428d7b3dSmrg# four `\'s followed by two `\'s and then a '$'.  `\' that '$'.
419428d7b3dSmrgbs='\\'
420428d7b3dSmrgbs2='\\\\'
421428d7b3dSmrgbs4='\\\\\\\\'
422428d7b3dSmrgdollar='\$'
423428d7b3dSmrgsed_double_backslash="\
424428d7b3dSmrg  s/$bs4/&\\
425428d7b3dSmrg/g
426428d7b3dSmrg  s/^$bs2$dollar/$bs&/
427428d7b3dSmrg  s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
428428d7b3dSmrg  s/\n//g"
429428d7b3dSmrg
430428d7b3dSmrg# Standard options:
431428d7b3dSmrgopt_dry_run=false
432428d7b3dSmrgopt_help=false
433428d7b3dSmrgopt_quiet=false
434428d7b3dSmrgopt_verbose=false
435428d7b3dSmrgopt_warning=:
436428d7b3dSmrg
437428d7b3dSmrg# func_echo arg...
438428d7b3dSmrg# Echo program name prefixed message, along with the current mode
439428d7b3dSmrg# name if it has been set yet.
440428d7b3dSmrgfunc_echo ()
441428d7b3dSmrg{
442428d7b3dSmrg    $ECHO "$progname: ${opt_mode+$opt_mode: }$*"
443428d7b3dSmrg}
444428d7b3dSmrg
445428d7b3dSmrg# func_verbose arg...
446428d7b3dSmrg# Echo program name prefixed message in verbose mode only.
447428d7b3dSmrgfunc_verbose ()
448428d7b3dSmrg{
449428d7b3dSmrg    $opt_verbose && func_echo ${1+"$@"}
450428d7b3dSmrg
451428d7b3dSmrg    # A bug in bash halts the script if the last line of a function
452428d7b3dSmrg    # fails when set -e is in force, so we need another command to
453428d7b3dSmrg    # work around that:
454428d7b3dSmrg    :
455428d7b3dSmrg}
456428d7b3dSmrg
457428d7b3dSmrg# func_echo_all arg...
458428d7b3dSmrg# Invoke $ECHO with all args, space-separated.
459428d7b3dSmrgfunc_echo_all ()
460428d7b3dSmrg{
461428d7b3dSmrg    $ECHO "$*"
462428d7b3dSmrg}
463428d7b3dSmrg
464428d7b3dSmrg# func_error arg...
465428d7b3dSmrg# Echo program name prefixed message to standard error.
466428d7b3dSmrgfunc_error ()
467428d7b3dSmrg{
468428d7b3dSmrg    $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2
469428d7b3dSmrg}
470428d7b3dSmrg
471428d7b3dSmrg# func_warning arg...
472428d7b3dSmrg# Echo program name prefixed warning message to standard error.
473428d7b3dSmrgfunc_warning ()
474428d7b3dSmrg{
475428d7b3dSmrg    $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2
476428d7b3dSmrg
477428d7b3dSmrg    # bash bug again:
478428d7b3dSmrg    :
479428d7b3dSmrg}
480428d7b3dSmrg
481428d7b3dSmrg# func_fatal_error arg...
482428d7b3dSmrg# Echo program name prefixed message to standard error, and exit.
483428d7b3dSmrgfunc_fatal_error ()
484428d7b3dSmrg{
485428d7b3dSmrg    func_error ${1+"$@"}
486428d7b3dSmrg    exit $EXIT_FAILURE
487428d7b3dSmrg}
488428d7b3dSmrg
489428d7b3dSmrg# func_fatal_help arg...
490428d7b3dSmrg# Echo program name prefixed message to standard error, followed by
491428d7b3dSmrg# a help hint, and exit.
492428d7b3dSmrgfunc_fatal_help ()
493428d7b3dSmrg{
494428d7b3dSmrg    func_error ${1+"$@"}
495428d7b3dSmrg    func_fatal_error "$help"
496428d7b3dSmrg}
497428d7b3dSmrghelp="Try \`$progname --help' for more information."  ## default
498428d7b3dSmrg
499428d7b3dSmrg
500428d7b3dSmrg# func_grep expression filename
501428d7b3dSmrg# Check whether EXPRESSION matches any line of FILENAME, without output.
502428d7b3dSmrgfunc_grep ()
503428d7b3dSmrg{
504428d7b3dSmrg    $GREP "$1" "$2" >/dev/null 2>&1
505428d7b3dSmrg}
506428d7b3dSmrg
507428d7b3dSmrg
508428d7b3dSmrg# func_mkdir_p directory-path
509428d7b3dSmrg# Make sure the entire path to DIRECTORY-PATH is available.
510428d7b3dSmrgfunc_mkdir_p ()
511428d7b3dSmrg{
512428d7b3dSmrg    my_directory_path="$1"
513428d7b3dSmrg    my_dir_list=
514428d7b3dSmrg
515428d7b3dSmrg    if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
516428d7b3dSmrg
517428d7b3dSmrg      # Protect directory names starting with `-'
518428d7b3dSmrg      case $my_directory_path in
519428d7b3dSmrg        -*) my_directory_path="./$my_directory_path" ;;
520428d7b3dSmrg      esac
521428d7b3dSmrg
522428d7b3dSmrg      # While some portion of DIR does not yet exist...
523428d7b3dSmrg      while test ! -d "$my_directory_path"; do
524428d7b3dSmrg        # ...make a list in topmost first order.  Use a colon delimited
525428d7b3dSmrg	# list incase some portion of path contains whitespace.
526428d7b3dSmrg        my_dir_list="$my_directory_path:$my_dir_list"
527428d7b3dSmrg
528428d7b3dSmrg        # If the last portion added has no slash in it, the list is done
529428d7b3dSmrg        case $my_directory_path in */*) ;; *) break ;; esac
530428d7b3dSmrg
531428d7b3dSmrg        # ...otherwise throw away the child directory and loop
532428d7b3dSmrg        my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"`
533428d7b3dSmrg      done
534428d7b3dSmrg      my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'`
535428d7b3dSmrg
536428d7b3dSmrg      save_mkdir_p_IFS="$IFS"; IFS=':'
537428d7b3dSmrg      for my_dir in $my_dir_list; do
538428d7b3dSmrg	IFS="$save_mkdir_p_IFS"
539428d7b3dSmrg        # mkdir can fail with a `File exist' error if two processes
540428d7b3dSmrg        # try to create one of the directories concurrently.  Don't
541428d7b3dSmrg        # stop in that case!
542428d7b3dSmrg        $MKDIR "$my_dir" 2>/dev/null || :
543428d7b3dSmrg      done
544428d7b3dSmrg      IFS="$save_mkdir_p_IFS"
545428d7b3dSmrg
546428d7b3dSmrg      # Bail out if we (or some other process) failed to create a directory.
547428d7b3dSmrg      test -d "$my_directory_path" || \
548428d7b3dSmrg        func_fatal_error "Failed to create \`$1'"
549428d7b3dSmrg    fi
550428d7b3dSmrg}
551428d7b3dSmrg
552428d7b3dSmrg
553428d7b3dSmrg# func_mktempdir [string]
554428d7b3dSmrg# Make a temporary directory that won't clash with other running
555428d7b3dSmrg# libtool processes, and avoids race conditions if possible.  If
556428d7b3dSmrg# given, STRING is the basename for that directory.
557428d7b3dSmrgfunc_mktempdir ()
558428d7b3dSmrg{
559428d7b3dSmrg    my_template="${TMPDIR-/tmp}/${1-$progname}"
560428d7b3dSmrg
561428d7b3dSmrg    if test "$opt_dry_run" = ":"; then
562428d7b3dSmrg      # Return a directory name, but don't create it in dry-run mode
563428d7b3dSmrg      my_tmpdir="${my_template}-$$"
564428d7b3dSmrg    else
565428d7b3dSmrg
566428d7b3dSmrg      # If mktemp works, use that first and foremost
567428d7b3dSmrg      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
568428d7b3dSmrg
569428d7b3dSmrg      if test ! -d "$my_tmpdir"; then
570428d7b3dSmrg        # Failing that, at least try and use $RANDOM to avoid a race
571428d7b3dSmrg        my_tmpdir="${my_template}-${RANDOM-0}$$"
572428d7b3dSmrg
573428d7b3dSmrg        save_mktempdir_umask=`umask`
574428d7b3dSmrg        umask 0077
575428d7b3dSmrg        $MKDIR "$my_tmpdir"
576428d7b3dSmrg        umask $save_mktempdir_umask
577428d7b3dSmrg      fi
578428d7b3dSmrg
579428d7b3dSmrg      # If we're not in dry-run mode, bomb out on failure
580428d7b3dSmrg      test -d "$my_tmpdir" || \
581428d7b3dSmrg        func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
582428d7b3dSmrg    fi
583428d7b3dSmrg
584428d7b3dSmrg    $ECHO "$my_tmpdir"
585428d7b3dSmrg}
586428d7b3dSmrg
587428d7b3dSmrg
588428d7b3dSmrg# func_quote_for_eval arg
589428d7b3dSmrg# Aesthetically quote ARG to be evaled later.
590428d7b3dSmrg# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
591428d7b3dSmrg# is double-quoted, suitable for a subsequent eval, whereas
592428d7b3dSmrg# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
593428d7b3dSmrg# which are still active within double quotes backslashified.
594428d7b3dSmrgfunc_quote_for_eval ()
595428d7b3dSmrg{
596428d7b3dSmrg    case $1 in
597428d7b3dSmrg      *[\\\`\"\$]*)
598428d7b3dSmrg	func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;;
599428d7b3dSmrg      *)
600428d7b3dSmrg        func_quote_for_eval_unquoted_result="$1" ;;
601428d7b3dSmrg    esac
602428d7b3dSmrg
603428d7b3dSmrg    case $func_quote_for_eval_unquoted_result in
604428d7b3dSmrg      # Double-quote args containing shell metacharacters to delay
605428d7b3dSmrg      # word splitting, command substitution and and variable
606428d7b3dSmrg      # expansion for a subsequent eval.
607428d7b3dSmrg      # Many Bourne shells cannot handle close brackets correctly
608428d7b3dSmrg      # in scan sets, so we specify it separately.
609428d7b3dSmrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
610428d7b3dSmrg        func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
611428d7b3dSmrg        ;;
612428d7b3dSmrg      *)
613428d7b3dSmrg        func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
614428d7b3dSmrg    esac
615428d7b3dSmrg}
616428d7b3dSmrg
617428d7b3dSmrg
618428d7b3dSmrg# func_quote_for_expand arg
619428d7b3dSmrg# Aesthetically quote ARG to be evaled later; same as above,
620428d7b3dSmrg# but do not quote variable references.
621428d7b3dSmrgfunc_quote_for_expand ()
622428d7b3dSmrg{
623428d7b3dSmrg    case $1 in
624428d7b3dSmrg      *[\\\`\"]*)
625428d7b3dSmrg	my_arg=`$ECHO "$1" | $SED \
626428d7b3dSmrg	    -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
627428d7b3dSmrg      *)
628428d7b3dSmrg        my_arg="$1" ;;
629428d7b3dSmrg    esac
630428d7b3dSmrg
631428d7b3dSmrg    case $my_arg in
632428d7b3dSmrg      # Double-quote args containing shell metacharacters to delay
633428d7b3dSmrg      # word splitting and command substitution for a subsequent eval.
634428d7b3dSmrg      # Many Bourne shells cannot handle close brackets correctly
635428d7b3dSmrg      # in scan sets, so we specify it separately.
636428d7b3dSmrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
637428d7b3dSmrg        my_arg="\"$my_arg\""
638428d7b3dSmrg        ;;
639428d7b3dSmrg    esac
640428d7b3dSmrg
641428d7b3dSmrg    func_quote_for_expand_result="$my_arg"
642428d7b3dSmrg}
643428d7b3dSmrg
644428d7b3dSmrg
645428d7b3dSmrg# func_show_eval cmd [fail_exp]
646428d7b3dSmrg# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
647428d7b3dSmrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
648428d7b3dSmrg# is given, then evaluate it.
649428d7b3dSmrgfunc_show_eval ()
650428d7b3dSmrg{
651428d7b3dSmrg    my_cmd="$1"
652428d7b3dSmrg    my_fail_exp="${2-:}"
653428d7b3dSmrg
654428d7b3dSmrg    ${opt_silent-false} || {
655428d7b3dSmrg      func_quote_for_expand "$my_cmd"
656428d7b3dSmrg      eval "func_echo $func_quote_for_expand_result"
657428d7b3dSmrg    }
658428d7b3dSmrg
659428d7b3dSmrg    if ${opt_dry_run-false}; then :; else
660428d7b3dSmrg      eval "$my_cmd"
661428d7b3dSmrg      my_status=$?
662428d7b3dSmrg      if test "$my_status" -eq 0; then :; else
663428d7b3dSmrg	eval "(exit $my_status); $my_fail_exp"
664428d7b3dSmrg      fi
665428d7b3dSmrg    fi
666428d7b3dSmrg}
667428d7b3dSmrg
668428d7b3dSmrg
669428d7b3dSmrg# func_show_eval_locale cmd [fail_exp]
670428d7b3dSmrg# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
671428d7b3dSmrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
672428d7b3dSmrg# is given, then evaluate it.  Use the saved locale for evaluation.
673428d7b3dSmrgfunc_show_eval_locale ()
674428d7b3dSmrg{
675428d7b3dSmrg    my_cmd="$1"
676428d7b3dSmrg    my_fail_exp="${2-:}"
677428d7b3dSmrg
678428d7b3dSmrg    ${opt_silent-false} || {
679428d7b3dSmrg      func_quote_for_expand "$my_cmd"
680428d7b3dSmrg      eval "func_echo $func_quote_for_expand_result"
681428d7b3dSmrg    }
682428d7b3dSmrg
683428d7b3dSmrg    if ${opt_dry_run-false}; then :; else
684428d7b3dSmrg      eval "$lt_user_locale
685428d7b3dSmrg	    $my_cmd"
686428d7b3dSmrg      my_status=$?
687428d7b3dSmrg      eval "$lt_safe_locale"
688428d7b3dSmrg      if test "$my_status" -eq 0; then :; else
689428d7b3dSmrg	eval "(exit $my_status); $my_fail_exp"
690428d7b3dSmrg      fi
691428d7b3dSmrg    fi
692428d7b3dSmrg}
693428d7b3dSmrg
694428d7b3dSmrg# func_tr_sh
695428d7b3dSmrg# Turn $1 into a string suitable for a shell variable name.
696428d7b3dSmrg# Result is stored in $func_tr_sh_result.  All characters
697428d7b3dSmrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further,
698428d7b3dSmrg# if $1 begins with a digit, a '_' is prepended as well.
699428d7b3dSmrgfunc_tr_sh ()
700428d7b3dSmrg{
701428d7b3dSmrg  case $1 in
702428d7b3dSmrg  [0-9]* | *[!a-zA-Z0-9_]*)
703428d7b3dSmrg    func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'`
704428d7b3dSmrg    ;;
705428d7b3dSmrg  * )
706428d7b3dSmrg    func_tr_sh_result=$1
707428d7b3dSmrg    ;;
708428d7b3dSmrg  esac
709428d7b3dSmrg}
710428d7b3dSmrg
711428d7b3dSmrg
712428d7b3dSmrg# func_version
713428d7b3dSmrg# Echo version message to standard output and exit.
714428d7b3dSmrgfunc_version ()
715428d7b3dSmrg{
716428d7b3dSmrg    $opt_debug
717428d7b3dSmrg
718428d7b3dSmrg    $SED -n '/(C)/!b go
719428d7b3dSmrg	:more
720428d7b3dSmrg	/\./!{
721428d7b3dSmrg	  N
722428d7b3dSmrg	  s/\n# / /
723428d7b3dSmrg	  b more
724428d7b3dSmrg	}
725428d7b3dSmrg	:go
726428d7b3dSmrg	/^# '$PROGRAM' (GNU /,/# warranty; / {
727428d7b3dSmrg        s/^# //
728428d7b3dSmrg	s/^# *$//
729428d7b3dSmrg        s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
730428d7b3dSmrg        p
731428d7b3dSmrg     }' < "$progpath"
732428d7b3dSmrg     exit $?
733428d7b3dSmrg}
734428d7b3dSmrg
735428d7b3dSmrg# func_usage
736428d7b3dSmrg# Echo short help message to standard output and exit.
737428d7b3dSmrgfunc_usage ()
738428d7b3dSmrg{
739428d7b3dSmrg    $opt_debug
740428d7b3dSmrg
741428d7b3dSmrg    $SED -n '/^# Usage:/,/^#  *.*--help/ {
742428d7b3dSmrg        s/^# //
743428d7b3dSmrg	s/^# *$//
744428d7b3dSmrg	s/\$progname/'$progname'/
745428d7b3dSmrg	p
746428d7b3dSmrg    }' < "$progpath"
747428d7b3dSmrg    echo
748428d7b3dSmrg    $ECHO "run \`$progname --help | more' for full usage"
749428d7b3dSmrg    exit $?
750428d7b3dSmrg}
751428d7b3dSmrg
752428d7b3dSmrg# func_help [NOEXIT]
753428d7b3dSmrg# Echo long help message to standard output and exit,
754428d7b3dSmrg# unless 'noexit' is passed as argument.
755428d7b3dSmrgfunc_help ()
756428d7b3dSmrg{
757428d7b3dSmrg    $opt_debug
758428d7b3dSmrg
759428d7b3dSmrg    $SED -n '/^# Usage:/,/# Report bugs to/ {
760428d7b3dSmrg	:print
761428d7b3dSmrg        s/^# //
762428d7b3dSmrg	s/^# *$//
763428d7b3dSmrg	s*\$progname*'$progname'*
764428d7b3dSmrg	s*\$host*'"$host"'*
765428d7b3dSmrg	s*\$SHELL*'"$SHELL"'*
766428d7b3dSmrg	s*\$LTCC*'"$LTCC"'*
767428d7b3dSmrg	s*\$LTCFLAGS*'"$LTCFLAGS"'*
768428d7b3dSmrg	s*\$LD*'"$LD"'*
769428d7b3dSmrg	s/\$with_gnu_ld/'"$with_gnu_ld"'/
770428d7b3dSmrg	s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/
771428d7b3dSmrg	s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/
772428d7b3dSmrg	p
773428d7b3dSmrg	d
774428d7b3dSmrg     }
775428d7b3dSmrg     /^# .* home page:/b print
776428d7b3dSmrg     /^# General help using/b print
777428d7b3dSmrg     ' < "$progpath"
778428d7b3dSmrg    ret=$?
779428d7b3dSmrg    if test -z "$1"; then
780428d7b3dSmrg      exit $ret
781428d7b3dSmrg    fi
782428d7b3dSmrg}
783428d7b3dSmrg
784428d7b3dSmrg# func_missing_arg argname
785428d7b3dSmrg# Echo program name prefixed message to standard error and set global
786428d7b3dSmrg# exit_cmd.
787428d7b3dSmrgfunc_missing_arg ()
788428d7b3dSmrg{
789428d7b3dSmrg    $opt_debug
790428d7b3dSmrg
791428d7b3dSmrg    func_error "missing argument for $1."
792428d7b3dSmrg    exit_cmd=exit
793428d7b3dSmrg}
794428d7b3dSmrg
795428d7b3dSmrg
796428d7b3dSmrg# func_split_short_opt shortopt
797428d7b3dSmrg# Set func_split_short_opt_name and func_split_short_opt_arg shell
798428d7b3dSmrg# variables after splitting SHORTOPT after the 2nd character.
799428d7b3dSmrgfunc_split_short_opt ()
800428d7b3dSmrg{
801428d7b3dSmrg    my_sed_short_opt='1s/^\(..\).*$/\1/;q'
802428d7b3dSmrg    my_sed_short_rest='1s/^..\(.*\)$/\1/;q'
803428d7b3dSmrg
804428d7b3dSmrg    func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"`
805428d7b3dSmrg    func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"`
806428d7b3dSmrg} # func_split_short_opt may be replaced by extended shell implementation
807428d7b3dSmrg
808428d7b3dSmrg
809428d7b3dSmrg# func_split_long_opt longopt
810428d7b3dSmrg# Set func_split_long_opt_name and func_split_long_opt_arg shell
811428d7b3dSmrg# variables after splitting LONGOPT at the `=' sign.
812428d7b3dSmrgfunc_split_long_opt ()
813428d7b3dSmrg{
814428d7b3dSmrg    my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q'
815428d7b3dSmrg    my_sed_long_arg='1s/^--[^=]*=//'
816428d7b3dSmrg
817428d7b3dSmrg    func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"`
818428d7b3dSmrg    func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"`
819428d7b3dSmrg} # func_split_long_opt may be replaced by extended shell implementation
820428d7b3dSmrg
821428d7b3dSmrgexit_cmd=:
822428d7b3dSmrg
823428d7b3dSmrg
824428d7b3dSmrg
825428d7b3dSmrg
826428d7b3dSmrg
827428d7b3dSmrgmagic="%%%MAGIC variable%%%"
828428d7b3dSmrgmagic_exe="%%%MAGIC EXE variable%%%"
829428d7b3dSmrg
830428d7b3dSmrg# Global variables.
831428d7b3dSmrgnonopt=
832428d7b3dSmrgpreserve_args=
833428d7b3dSmrglo2o="s/\\.lo\$/.${objext}/"
834428d7b3dSmrgo2lo="s/\\.${objext}\$/.lo/"
835428d7b3dSmrgextracted_archives=
836428d7b3dSmrgextracted_serial=0
837428d7b3dSmrg
838428d7b3dSmrg# If this variable is set in any of the actions, the command in it
839428d7b3dSmrg# will be execed at the end.  This prevents here-documents from being
840428d7b3dSmrg# left over by shells.
841428d7b3dSmrgexec_cmd=
842428d7b3dSmrg
843428d7b3dSmrg# func_append var value
844428d7b3dSmrg# Append VALUE to the end of shell variable VAR.
845428d7b3dSmrgfunc_append ()
846428d7b3dSmrg{
847428d7b3dSmrg    eval "${1}=\$${1}\${2}"
848428d7b3dSmrg} # func_append may be replaced by extended shell implementation
849428d7b3dSmrg
850428d7b3dSmrg# func_append_quoted var value
851428d7b3dSmrg# Quote VALUE and append to the end of shell variable VAR, separated
852428d7b3dSmrg# by a space.
853428d7b3dSmrgfunc_append_quoted ()
854428d7b3dSmrg{
855428d7b3dSmrg    func_quote_for_eval "${2}"
856428d7b3dSmrg    eval "${1}=\$${1}\\ \$func_quote_for_eval_result"
857428d7b3dSmrg} # func_append_quoted may be replaced by extended shell implementation
858428d7b3dSmrg
859428d7b3dSmrg
860428d7b3dSmrg# func_arith arithmetic-term...
861428d7b3dSmrgfunc_arith ()
862428d7b3dSmrg{
863428d7b3dSmrg    func_arith_result=`expr "${@}"`
864428d7b3dSmrg} # func_arith may be replaced by extended shell implementation
865428d7b3dSmrg
866428d7b3dSmrg
867428d7b3dSmrg# func_len string
868428d7b3dSmrg# STRING may not start with a hyphen.
869428d7b3dSmrgfunc_len ()
870428d7b3dSmrg{
871428d7b3dSmrg    func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len`
872428d7b3dSmrg} # func_len may be replaced by extended shell implementation
873428d7b3dSmrg
874428d7b3dSmrg
875428d7b3dSmrg# func_lo2o object
876428d7b3dSmrgfunc_lo2o ()
877428d7b3dSmrg{
878428d7b3dSmrg    func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"`
879428d7b3dSmrg} # func_lo2o may be replaced by extended shell implementation
880428d7b3dSmrg
881428d7b3dSmrg
882428d7b3dSmrg# func_xform libobj-or-source
883428d7b3dSmrgfunc_xform ()
884428d7b3dSmrg{
885428d7b3dSmrg    func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'`
886428d7b3dSmrg} # func_xform may be replaced by extended shell implementation
887428d7b3dSmrg
888428d7b3dSmrg
889428d7b3dSmrg# func_fatal_configuration arg...
890428d7b3dSmrg# Echo program name prefixed message to standard error, followed by
891428d7b3dSmrg# a configuration failure hint, and exit.
892428d7b3dSmrgfunc_fatal_configuration ()
893428d7b3dSmrg{
894428d7b3dSmrg    func_error ${1+"$@"}
895428d7b3dSmrg    func_error "See the $PACKAGE documentation for more information."
896428d7b3dSmrg    func_fatal_error "Fatal configuration error."
897428d7b3dSmrg}
898428d7b3dSmrg
899428d7b3dSmrg
900428d7b3dSmrg# func_config
901428d7b3dSmrg# Display the configuration for all the tags in this script.
902428d7b3dSmrgfunc_config ()
903428d7b3dSmrg{
904428d7b3dSmrg    re_begincf='^# ### BEGIN LIBTOOL'
905428d7b3dSmrg    re_endcf='^# ### END LIBTOOL'
906428d7b3dSmrg
907428d7b3dSmrg    # Default configuration.
908428d7b3dSmrg    $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
909428d7b3dSmrg
910428d7b3dSmrg    # Now print the configurations for the tags.
911428d7b3dSmrg    for tagname in $taglist; do
912428d7b3dSmrg      $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
913428d7b3dSmrg    done
914428d7b3dSmrg
915428d7b3dSmrg    exit $?
916428d7b3dSmrg}
917428d7b3dSmrg
918428d7b3dSmrg# func_features
919428d7b3dSmrg# Display the features supported by this script.
920428d7b3dSmrgfunc_features ()
921428d7b3dSmrg{
922428d7b3dSmrg    echo "host: $host"
923428d7b3dSmrg    if test "$build_libtool_libs" = yes; then
924428d7b3dSmrg      echo "enable shared libraries"
925428d7b3dSmrg    else
926428d7b3dSmrg      echo "disable shared libraries"
927428d7b3dSmrg    fi
928428d7b3dSmrg    if test "$build_old_libs" = yes; then
929428d7b3dSmrg      echo "enable static libraries"
930428d7b3dSmrg    else
931428d7b3dSmrg      echo "disable static libraries"
932428d7b3dSmrg    fi
933428d7b3dSmrg
934428d7b3dSmrg    exit $?
935428d7b3dSmrg}
936428d7b3dSmrg
937428d7b3dSmrg# func_enable_tag tagname
938428d7b3dSmrg# Verify that TAGNAME is valid, and either flag an error and exit, or
939428d7b3dSmrg# enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
940428d7b3dSmrg# variable here.
941428d7b3dSmrgfunc_enable_tag ()
942428d7b3dSmrg{
943428d7b3dSmrg  # Global variable:
944428d7b3dSmrg  tagname="$1"
945428d7b3dSmrg
946428d7b3dSmrg  re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
947428d7b3dSmrg  re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
948428d7b3dSmrg  sed_extractcf="/$re_begincf/,/$re_endcf/p"
949428d7b3dSmrg
950428d7b3dSmrg  # Validate tagname.
951428d7b3dSmrg  case $tagname in
952428d7b3dSmrg    *[!-_A-Za-z0-9,/]*)
953428d7b3dSmrg      func_fatal_error "invalid tag name: $tagname"
954428d7b3dSmrg      ;;
955428d7b3dSmrg  esac
956428d7b3dSmrg
957428d7b3dSmrg  # Don't test for the "default" C tag, as we know it's
958428d7b3dSmrg  # there but not specially marked.
959428d7b3dSmrg  case $tagname in
960428d7b3dSmrg    CC) ;;
961428d7b3dSmrg    *)
962428d7b3dSmrg      if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
963428d7b3dSmrg	taglist="$taglist $tagname"
964428d7b3dSmrg
965428d7b3dSmrg	# Evaluate the configuration.  Be careful to quote the path
966428d7b3dSmrg	# and the sed script, to avoid splitting on whitespace, but
967428d7b3dSmrg	# also don't use non-portable quotes within backquotes within
968428d7b3dSmrg	# quotes we have to do it in 2 steps:
969428d7b3dSmrg	extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
970428d7b3dSmrg	eval "$extractedcf"
971428d7b3dSmrg      else
972428d7b3dSmrg	func_error "ignoring unknown tag $tagname"
973428d7b3dSmrg      fi
974428d7b3dSmrg      ;;
975428d7b3dSmrg  esac
976428d7b3dSmrg}
977428d7b3dSmrg
978428d7b3dSmrg# func_check_version_match
979428d7b3dSmrg# Ensure that we are using m4 macros, and libtool script from the same
980428d7b3dSmrg# release of libtool.
981428d7b3dSmrgfunc_check_version_match ()
982428d7b3dSmrg{
983428d7b3dSmrg  if test "$package_revision" != "$macro_revision"; then
984428d7b3dSmrg    if test "$VERSION" != "$macro_version"; then
985428d7b3dSmrg      if test -z "$macro_version"; then
986428d7b3dSmrg        cat >&2 <<_LT_EOF
987428d7b3dSmrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
988428d7b3dSmrg$progname: definition of this LT_INIT comes from an older release.
989428d7b3dSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
990428d7b3dSmrg$progname: and run autoconf again.
991428d7b3dSmrg_LT_EOF
992428d7b3dSmrg      else
993428d7b3dSmrg        cat >&2 <<_LT_EOF
994428d7b3dSmrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
995428d7b3dSmrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
996428d7b3dSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
997428d7b3dSmrg$progname: and run autoconf again.
998428d7b3dSmrg_LT_EOF
999428d7b3dSmrg      fi
1000428d7b3dSmrg    else
1001428d7b3dSmrg      cat >&2 <<_LT_EOF
1002428d7b3dSmrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
1003428d7b3dSmrg$progname: but the definition of this LT_INIT comes from revision $macro_revision.
1004428d7b3dSmrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision
1005428d7b3dSmrg$progname: of $PACKAGE $VERSION and run autoconf again.
1006428d7b3dSmrg_LT_EOF
1007428d7b3dSmrg    fi
1008428d7b3dSmrg
1009428d7b3dSmrg    exit $EXIT_MISMATCH
1010428d7b3dSmrg  fi
1011428d7b3dSmrg}
1012428d7b3dSmrg
1013428d7b3dSmrg
1014428d7b3dSmrg# Shorthand for --mode=foo, only valid as the first argument
1015428d7b3dSmrgcase $1 in
1016428d7b3dSmrgclean|clea|cle|cl)
1017428d7b3dSmrg  shift; set dummy --mode clean ${1+"$@"}; shift
1018428d7b3dSmrg  ;;
1019428d7b3dSmrgcompile|compil|compi|comp|com|co|c)
1020428d7b3dSmrg  shift; set dummy --mode compile ${1+"$@"}; shift
1021428d7b3dSmrg  ;;
1022428d7b3dSmrgexecute|execut|execu|exec|exe|ex|e)
1023428d7b3dSmrg  shift; set dummy --mode execute ${1+"$@"}; shift
1024428d7b3dSmrg  ;;
1025428d7b3dSmrgfinish|finis|fini|fin|fi|f)
1026428d7b3dSmrg  shift; set dummy --mode finish ${1+"$@"}; shift
1027428d7b3dSmrg  ;;
1028428d7b3dSmrginstall|instal|insta|inst|ins|in|i)
1029428d7b3dSmrg  shift; set dummy --mode install ${1+"$@"}; shift
1030428d7b3dSmrg  ;;
1031428d7b3dSmrglink|lin|li|l)
1032428d7b3dSmrg  shift; set dummy --mode link ${1+"$@"}; shift
1033428d7b3dSmrg  ;;
1034428d7b3dSmrguninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
1035428d7b3dSmrg  shift; set dummy --mode uninstall ${1+"$@"}; shift
1036428d7b3dSmrg  ;;
1037428d7b3dSmrgesac
1038428d7b3dSmrg
1039428d7b3dSmrg
1040428d7b3dSmrg
1041428d7b3dSmrg# Option defaults:
1042428d7b3dSmrgopt_debug=:
1043428d7b3dSmrgopt_dry_run=false
1044428d7b3dSmrgopt_config=false
1045428d7b3dSmrgopt_preserve_dup_deps=false
1046428d7b3dSmrgopt_features=false
1047428d7b3dSmrgopt_finish=false
1048428d7b3dSmrgopt_help=false
1049428d7b3dSmrgopt_help_all=false
1050428d7b3dSmrgopt_silent=:
1051428d7b3dSmrgopt_warning=:
1052428d7b3dSmrgopt_verbose=:
1053428d7b3dSmrgopt_silent=false
1054428d7b3dSmrgopt_verbose=false
1055428d7b3dSmrg
1056428d7b3dSmrg
1057428d7b3dSmrg# Parse options once, thoroughly.  This comes as soon as possible in the
1058428d7b3dSmrg# script to make things like `--version' happen as quickly as we can.
1059428d7b3dSmrg{
1060428d7b3dSmrg  # this just eases exit handling
1061428d7b3dSmrg  while test $# -gt 0; do
1062428d7b3dSmrg    opt="$1"
1063428d7b3dSmrg    shift
1064428d7b3dSmrg    case $opt in
1065428d7b3dSmrg      --debug|-x)	opt_debug='set -x'
1066428d7b3dSmrg			func_echo "enabling shell trace mode"
1067428d7b3dSmrg			$opt_debug
1068428d7b3dSmrg			;;
1069428d7b3dSmrg      --dry-run|--dryrun|-n)
1070428d7b3dSmrg			opt_dry_run=:
1071428d7b3dSmrg			;;
1072428d7b3dSmrg      --config)
1073428d7b3dSmrg			opt_config=:
1074428d7b3dSmrgfunc_config
1075428d7b3dSmrg			;;
1076428d7b3dSmrg      --dlopen|-dlopen)
1077428d7b3dSmrg			optarg="$1"
1078428d7b3dSmrg			opt_dlopen="${opt_dlopen+$opt_dlopen
1079428d7b3dSmrg}$optarg"
1080428d7b3dSmrg			shift
1081428d7b3dSmrg			;;
1082428d7b3dSmrg      --preserve-dup-deps)
1083428d7b3dSmrg			opt_preserve_dup_deps=:
1084428d7b3dSmrg			;;
1085428d7b3dSmrg      --features)
1086428d7b3dSmrg			opt_features=:
1087428d7b3dSmrgfunc_features
1088428d7b3dSmrg			;;
1089428d7b3dSmrg      --finish)
1090428d7b3dSmrg			opt_finish=:
1091428d7b3dSmrgset dummy --mode finish ${1+"$@"}; shift
1092428d7b3dSmrg			;;
1093428d7b3dSmrg      --help)
1094428d7b3dSmrg			opt_help=:
1095428d7b3dSmrg			;;
1096428d7b3dSmrg      --help-all)
1097428d7b3dSmrg			opt_help_all=:
1098428d7b3dSmrgopt_help=': help-all'
1099428d7b3dSmrg			;;
1100428d7b3dSmrg      --mode)
1101428d7b3dSmrg			test $# = 0 && func_missing_arg $opt && break
1102428d7b3dSmrg			optarg="$1"
1103428d7b3dSmrg			opt_mode="$optarg"
1104428d7b3dSmrgcase $optarg in
1105428d7b3dSmrg  # Valid mode arguments:
1106428d7b3dSmrg  clean|compile|execute|finish|install|link|relink|uninstall) ;;
1107428d7b3dSmrg
1108428d7b3dSmrg  # Catch anything else as an error
1109428d7b3dSmrg  *) func_error "invalid argument for $opt"
1110428d7b3dSmrg     exit_cmd=exit
1111428d7b3dSmrg     break
1112428d7b3dSmrg     ;;
1113428d7b3dSmrgesac
1114428d7b3dSmrg			shift
1115428d7b3dSmrg			;;
1116428d7b3dSmrg      --no-silent|--no-quiet)
1117428d7b3dSmrg			opt_silent=false
1118428d7b3dSmrgfunc_append preserve_args " $opt"
1119428d7b3dSmrg			;;
1120428d7b3dSmrg      --no-warning|--no-warn)
1121428d7b3dSmrg			opt_warning=false
1122428d7b3dSmrgfunc_append preserve_args " $opt"
1123428d7b3dSmrg			;;
1124428d7b3dSmrg      --no-verbose)
1125428d7b3dSmrg			opt_verbose=false
1126428d7b3dSmrgfunc_append preserve_args " $opt"
1127428d7b3dSmrg			;;
1128428d7b3dSmrg      --silent|--quiet)
1129428d7b3dSmrg			opt_silent=:
1130428d7b3dSmrgfunc_append preserve_args " $opt"
1131428d7b3dSmrg        opt_verbose=false
1132428d7b3dSmrg			;;
1133428d7b3dSmrg      --verbose|-v)
1134428d7b3dSmrg			opt_verbose=:
1135428d7b3dSmrgfunc_append preserve_args " $opt"
1136428d7b3dSmrgopt_silent=false
1137428d7b3dSmrg			;;
1138428d7b3dSmrg      --tag)
1139428d7b3dSmrg			test $# = 0 && func_missing_arg $opt && break
1140428d7b3dSmrg			optarg="$1"
1141428d7b3dSmrg			opt_tag="$optarg"
1142428d7b3dSmrgfunc_append preserve_args " $opt $optarg"
1143428d7b3dSmrgfunc_enable_tag "$optarg"
1144428d7b3dSmrg			shift
1145428d7b3dSmrg			;;
1146428d7b3dSmrg
1147428d7b3dSmrg      -\?|-h)		func_usage				;;
1148428d7b3dSmrg      --help)		func_help				;;
1149428d7b3dSmrg      --version)	func_version				;;
1150428d7b3dSmrg
1151428d7b3dSmrg      # Separate optargs to long options:
1152428d7b3dSmrg      --*=*)
1153428d7b3dSmrg			func_split_long_opt "$opt"
1154428d7b3dSmrg			set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"}
1155428d7b3dSmrg			shift
1156428d7b3dSmrg			;;
1157428d7b3dSmrg
1158428d7b3dSmrg      # Separate non-argument short options:
1159428d7b3dSmrg      -\?*|-h*|-n*|-v*)
1160428d7b3dSmrg			func_split_short_opt "$opt"
1161428d7b3dSmrg			set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"}
1162428d7b3dSmrg			shift
1163428d7b3dSmrg			;;
1164428d7b3dSmrg
1165428d7b3dSmrg      --)		break					;;
1166428d7b3dSmrg      -*)		func_fatal_help "unrecognized option \`$opt'" ;;
1167428d7b3dSmrg      *)		set dummy "$opt" ${1+"$@"};	shift; break  ;;
1168428d7b3dSmrg    esac
1169428d7b3dSmrg  done
1170428d7b3dSmrg
1171428d7b3dSmrg  # Validate options:
1172428d7b3dSmrg
1173428d7b3dSmrg  # save first non-option argument
1174428d7b3dSmrg  if test "$#" -gt 0; then
1175428d7b3dSmrg    nonopt="$opt"
1176428d7b3dSmrg    shift
1177428d7b3dSmrg  fi
1178428d7b3dSmrg
1179428d7b3dSmrg  # preserve --debug
1180428d7b3dSmrg  test "$opt_debug" = : || func_append preserve_args " --debug"
1181428d7b3dSmrg
1182428d7b3dSmrg  case $host in
1183428d7b3dSmrg    *cygwin* | *mingw* | *pw32* | *cegcc*)
1184428d7b3dSmrg      # don't eliminate duplications in $postdeps and $predeps
1185428d7b3dSmrg      opt_duplicate_compiler_generated_deps=:
1186428d7b3dSmrg      ;;
1187428d7b3dSmrg    *)
1188428d7b3dSmrg      opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
1189428d7b3dSmrg      ;;
1190428d7b3dSmrg  esac
1191428d7b3dSmrg
1192428d7b3dSmrg  $opt_help || {
1193428d7b3dSmrg    # Sanity checks first:
1194428d7b3dSmrg    func_check_version_match
1195428d7b3dSmrg
1196428d7b3dSmrg    if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
1197428d7b3dSmrg      func_fatal_configuration "not configured to build any kind of library"
1198428d7b3dSmrg    fi
1199428d7b3dSmrg
1200428d7b3dSmrg    # Darwin sucks
1201428d7b3dSmrg    eval std_shrext=\"$shrext_cmds\"
1202428d7b3dSmrg
1203428d7b3dSmrg    # Only execute mode is allowed to have -dlopen flags.
1204428d7b3dSmrg    if test -n "$opt_dlopen" && test "$opt_mode" != execute; then
1205428d7b3dSmrg      func_error "unrecognized option \`-dlopen'"
1206428d7b3dSmrg      $ECHO "$help" 1>&2
1207428d7b3dSmrg      exit $EXIT_FAILURE
1208428d7b3dSmrg    fi
1209428d7b3dSmrg
1210428d7b3dSmrg    # Change the help message to a mode-specific one.
1211428d7b3dSmrg    generic_help="$help"
1212428d7b3dSmrg    help="Try \`$progname --help --mode=$opt_mode' for more information."
1213428d7b3dSmrg  }
1214428d7b3dSmrg
1215428d7b3dSmrg
1216428d7b3dSmrg  # Bail if the options were screwed
1217428d7b3dSmrg  $exit_cmd $EXIT_FAILURE
1218428d7b3dSmrg}
1219428d7b3dSmrg
1220428d7b3dSmrg
1221428d7b3dSmrg
1222428d7b3dSmrg
1223428d7b3dSmrg## ----------- ##
1224428d7b3dSmrg##    Main.    ##
1225428d7b3dSmrg## ----------- ##
1226428d7b3dSmrg
1227428d7b3dSmrg# func_lalib_p file
1228428d7b3dSmrg# True iff FILE is a libtool `.la' library or `.lo' object file.
1229428d7b3dSmrg# This function is only a basic sanity check; it will hardly flush out
1230428d7b3dSmrg# determined imposters.
1231428d7b3dSmrgfunc_lalib_p ()
1232428d7b3dSmrg{
1233428d7b3dSmrg    test -f "$1" &&
1234428d7b3dSmrg      $SED -e 4q "$1" 2>/dev/null \
1235428d7b3dSmrg        | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
1236428d7b3dSmrg}
1237428d7b3dSmrg
1238428d7b3dSmrg# func_lalib_unsafe_p file
1239428d7b3dSmrg# True iff FILE is a libtool `.la' library or `.lo' object file.
1240428d7b3dSmrg# This function implements the same check as func_lalib_p without
1241428d7b3dSmrg# resorting to external programs.  To this end, it redirects stdin and
1242428d7b3dSmrg# closes it afterwards, without saving the original file descriptor.
1243428d7b3dSmrg# As a safety measure, use it only where a negative result would be
1244428d7b3dSmrg# fatal anyway.  Works if `file' does not exist.
1245428d7b3dSmrgfunc_lalib_unsafe_p ()
1246428d7b3dSmrg{
1247428d7b3dSmrg    lalib_p=no
1248428d7b3dSmrg    if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
1249428d7b3dSmrg	for lalib_p_l in 1 2 3 4
1250428d7b3dSmrg	do
1251428d7b3dSmrg	    read lalib_p_line
1252428d7b3dSmrg	    case "$lalib_p_line" in
1253428d7b3dSmrg		\#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
1254428d7b3dSmrg	    esac
1255428d7b3dSmrg	done
1256428d7b3dSmrg	exec 0<&5 5<&-
1257428d7b3dSmrg    fi
1258428d7b3dSmrg    test "$lalib_p" = yes
1259428d7b3dSmrg}
1260428d7b3dSmrg
1261428d7b3dSmrg# func_ltwrapper_script_p file
1262428d7b3dSmrg# True iff FILE is a libtool wrapper script
1263428d7b3dSmrg# This function is only a basic sanity check; it will hardly flush out
1264428d7b3dSmrg# determined imposters.
1265428d7b3dSmrgfunc_ltwrapper_script_p ()
1266428d7b3dSmrg{
1267428d7b3dSmrg    func_lalib_p "$1"
1268428d7b3dSmrg}
1269428d7b3dSmrg
1270428d7b3dSmrg# func_ltwrapper_executable_p file
1271428d7b3dSmrg# True iff FILE is a libtool wrapper executable
1272428d7b3dSmrg# This function is only a basic sanity check; it will hardly flush out
1273428d7b3dSmrg# determined imposters.
1274428d7b3dSmrgfunc_ltwrapper_executable_p ()
1275428d7b3dSmrg{
1276428d7b3dSmrg    func_ltwrapper_exec_suffix=
1277428d7b3dSmrg    case $1 in
1278428d7b3dSmrg    *.exe) ;;
1279428d7b3dSmrg    *) func_ltwrapper_exec_suffix=.exe ;;
1280428d7b3dSmrg    esac
1281428d7b3dSmrg    $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
1282428d7b3dSmrg}
1283428d7b3dSmrg
1284428d7b3dSmrg# func_ltwrapper_scriptname file
1285428d7b3dSmrg# Assumes file is an ltwrapper_executable
1286428d7b3dSmrg# uses $file to determine the appropriate filename for a
1287428d7b3dSmrg# temporary ltwrapper_script.
1288428d7b3dSmrgfunc_ltwrapper_scriptname ()
1289428d7b3dSmrg{
1290428d7b3dSmrg    func_dirname_and_basename "$1" "" "."
1291428d7b3dSmrg    func_stripname '' '.exe' "$func_basename_result"
1292428d7b3dSmrg    func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper"
1293428d7b3dSmrg}
1294428d7b3dSmrg
1295428d7b3dSmrg# func_ltwrapper_p file
1296428d7b3dSmrg# True iff FILE is a libtool wrapper script or wrapper executable
1297428d7b3dSmrg# This function is only a basic sanity check; it will hardly flush out
1298428d7b3dSmrg# determined imposters.
1299428d7b3dSmrgfunc_ltwrapper_p ()
1300428d7b3dSmrg{
1301428d7b3dSmrg    func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
1302428d7b3dSmrg}
1303428d7b3dSmrg
1304428d7b3dSmrg
1305428d7b3dSmrg# func_execute_cmds commands fail_cmd
1306428d7b3dSmrg# Execute tilde-delimited COMMANDS.
1307428d7b3dSmrg# If FAIL_CMD is given, eval that upon failure.
1308428d7b3dSmrg# FAIL_CMD may read-access the current command in variable CMD!
1309428d7b3dSmrgfunc_execute_cmds ()
1310428d7b3dSmrg{
1311428d7b3dSmrg    $opt_debug
1312428d7b3dSmrg    save_ifs=$IFS; IFS='~'
1313428d7b3dSmrg    for cmd in $1; do
1314428d7b3dSmrg      IFS=$save_ifs
1315428d7b3dSmrg      eval cmd=\"$cmd\"
1316428d7b3dSmrg      func_show_eval "$cmd" "${2-:}"
1317428d7b3dSmrg    done
1318428d7b3dSmrg    IFS=$save_ifs
1319428d7b3dSmrg}
1320428d7b3dSmrg
1321428d7b3dSmrg
1322428d7b3dSmrg# func_source file
1323428d7b3dSmrg# Source FILE, adding directory component if necessary.
1324428d7b3dSmrg# Note that it is not necessary on cygwin/mingw to append a dot to
1325428d7b3dSmrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe
1326428d7b3dSmrg# behavior happens only for exec(3), not for open(2)!  Also, sourcing
1327428d7b3dSmrg# `FILE.' does not work on cygwin managed mounts.
1328428d7b3dSmrgfunc_source ()
1329428d7b3dSmrg{
1330428d7b3dSmrg    $opt_debug
1331428d7b3dSmrg    case $1 in
1332428d7b3dSmrg    */* | *\\*)	. "$1" ;;
1333428d7b3dSmrg    *)		. "./$1" ;;
1334428d7b3dSmrg    esac
1335428d7b3dSmrg}
1336428d7b3dSmrg
1337428d7b3dSmrg
1338428d7b3dSmrg# func_resolve_sysroot PATH
1339428d7b3dSmrg# Replace a leading = in PATH with a sysroot.  Store the result into
1340428d7b3dSmrg# func_resolve_sysroot_result
1341428d7b3dSmrgfunc_resolve_sysroot ()
1342428d7b3dSmrg{
1343428d7b3dSmrg  func_resolve_sysroot_result=$1
1344428d7b3dSmrg  case $func_resolve_sysroot_result in
1345428d7b3dSmrg  =*)
1346428d7b3dSmrg    func_stripname '=' '' "$func_resolve_sysroot_result"
1347428d7b3dSmrg    func_resolve_sysroot_result=$lt_sysroot$func_stripname_result
1348428d7b3dSmrg    ;;
1349428d7b3dSmrg  esac
1350428d7b3dSmrg}
1351428d7b3dSmrg
1352428d7b3dSmrg# func_replace_sysroot PATH
1353428d7b3dSmrg# If PATH begins with the sysroot, replace it with = and
1354428d7b3dSmrg# store the result into func_replace_sysroot_result.
1355428d7b3dSmrgfunc_replace_sysroot ()
1356428d7b3dSmrg{
1357428d7b3dSmrg  case "$lt_sysroot:$1" in
1358428d7b3dSmrg  ?*:"$lt_sysroot"*)
1359428d7b3dSmrg    func_stripname "$lt_sysroot" '' "$1"
1360428d7b3dSmrg    func_replace_sysroot_result="=$func_stripname_result"
1361428d7b3dSmrg    ;;
1362428d7b3dSmrg  *)
1363428d7b3dSmrg    # Including no sysroot.
1364428d7b3dSmrg    func_replace_sysroot_result=$1
1365428d7b3dSmrg    ;;
1366428d7b3dSmrg  esac
1367428d7b3dSmrg}
1368428d7b3dSmrg
1369428d7b3dSmrg# func_infer_tag arg
1370428d7b3dSmrg# Infer tagged configuration to use if any are available and
1371428d7b3dSmrg# if one wasn't chosen via the "--tag" command line option.
1372428d7b3dSmrg# Only attempt this if the compiler in the base compile
1373428d7b3dSmrg# command doesn't match the default compiler.
1374428d7b3dSmrg# arg is usually of the form 'gcc ...'
1375428d7b3dSmrgfunc_infer_tag ()
1376428d7b3dSmrg{
1377428d7b3dSmrg    $opt_debug
1378428d7b3dSmrg    if test -n "$available_tags" && test -z "$tagname"; then
1379428d7b3dSmrg      CC_quoted=
1380428d7b3dSmrg      for arg in $CC; do
1381428d7b3dSmrg	func_append_quoted CC_quoted "$arg"
1382428d7b3dSmrg      done
1383428d7b3dSmrg      CC_expanded=`func_echo_all $CC`
1384428d7b3dSmrg      CC_quoted_expanded=`func_echo_all $CC_quoted`
1385428d7b3dSmrg      case $@ in
1386428d7b3dSmrg      # Blanks in the command may have been stripped by the calling shell,
1387428d7b3dSmrg      # but not from the CC environment variable when configure was run.
1388428d7b3dSmrg      " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
1389428d7b3dSmrg      " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
1390428d7b3dSmrg      # Blanks at the start of $base_compile will cause this to fail
1391428d7b3dSmrg      # if we don't check for them as well.
1392428d7b3dSmrg      *)
1393428d7b3dSmrg	for z in $available_tags; do
1394428d7b3dSmrg	  if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
1395428d7b3dSmrg	    # Evaluate the configuration.
1396428d7b3dSmrg	    eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
1397428d7b3dSmrg	    CC_quoted=
1398428d7b3dSmrg	    for arg in $CC; do
1399428d7b3dSmrg	      # Double-quote args containing other shell metacharacters.
1400428d7b3dSmrg	      func_append_quoted CC_quoted "$arg"
1401428d7b3dSmrg	    done
1402428d7b3dSmrg	    CC_expanded=`func_echo_all $CC`
1403428d7b3dSmrg	    CC_quoted_expanded=`func_echo_all $CC_quoted`
1404428d7b3dSmrg	    case "$@ " in
1405428d7b3dSmrg	    " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
1406428d7b3dSmrg	    " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
1407428d7b3dSmrg	      # The compiler in the base compile command matches
1408428d7b3dSmrg	      # the one in the tagged configuration.
1409428d7b3dSmrg	      # Assume this is the tagged configuration we want.
1410428d7b3dSmrg	      tagname=$z
1411428d7b3dSmrg	      break
1412428d7b3dSmrg	      ;;
1413428d7b3dSmrg	    esac
1414428d7b3dSmrg	  fi
1415428d7b3dSmrg	done
1416428d7b3dSmrg	# If $tagname still isn't set, then no tagged configuration
1417428d7b3dSmrg	# was found and let the user know that the "--tag" command
1418428d7b3dSmrg	# line option must be used.
1419428d7b3dSmrg	if test -z "$tagname"; then
1420428d7b3dSmrg	  func_echo "unable to infer tagged configuration"
1421428d7b3dSmrg	  func_fatal_error "specify a tag with \`--tag'"
1422428d7b3dSmrg#	else
1423428d7b3dSmrg#	  func_verbose "using $tagname tagged configuration"
1424428d7b3dSmrg	fi
1425428d7b3dSmrg	;;
1426428d7b3dSmrg      esac
1427428d7b3dSmrg    fi
1428428d7b3dSmrg}
1429428d7b3dSmrg
1430428d7b3dSmrg
1431428d7b3dSmrg
1432428d7b3dSmrg# func_write_libtool_object output_name pic_name nonpic_name
1433428d7b3dSmrg# Create a libtool object file (analogous to a ".la" file),
1434428d7b3dSmrg# but don't create it if we're doing a dry run.
1435428d7b3dSmrgfunc_write_libtool_object ()
1436428d7b3dSmrg{
1437428d7b3dSmrg    write_libobj=${1}
1438428d7b3dSmrg    if test "$build_libtool_libs" = yes; then
1439428d7b3dSmrg      write_lobj=\'${2}\'
1440428d7b3dSmrg    else
1441428d7b3dSmrg      write_lobj=none
1442428d7b3dSmrg    fi
1443428d7b3dSmrg
1444428d7b3dSmrg    if test "$build_old_libs" = yes; then
1445428d7b3dSmrg      write_oldobj=\'${3}\'
1446428d7b3dSmrg    else
1447428d7b3dSmrg      write_oldobj=none
1448428d7b3dSmrg    fi
1449428d7b3dSmrg
1450428d7b3dSmrg    $opt_dry_run || {
1451428d7b3dSmrg      cat >${write_libobj}T <<EOF
1452428d7b3dSmrg# $write_libobj - a libtool object file
1453428d7b3dSmrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
1454428d7b3dSmrg#
1455428d7b3dSmrg# Please DO NOT delete this file!
1456428d7b3dSmrg# It is necessary for linking the library.
1457428d7b3dSmrg
1458428d7b3dSmrg# Name of the PIC object.
1459428d7b3dSmrgpic_object=$write_lobj
1460428d7b3dSmrg
1461428d7b3dSmrg# Name of the non-PIC object
1462428d7b3dSmrgnon_pic_object=$write_oldobj
1463428d7b3dSmrg
1464428d7b3dSmrgEOF
1465428d7b3dSmrg      $MV "${write_libobj}T" "${write_libobj}"
1466428d7b3dSmrg    }
1467428d7b3dSmrg}
1468428d7b3dSmrg
1469428d7b3dSmrg
1470428d7b3dSmrg##################################################
1471428d7b3dSmrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS #
1472428d7b3dSmrg##################################################
1473428d7b3dSmrg
1474428d7b3dSmrg# func_convert_core_file_wine_to_w32 ARG
1475428d7b3dSmrg# Helper function used by file name conversion functions when $build is *nix,
1476428d7b3dSmrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a
1477428d7b3dSmrg# correctly configured wine environment available, with the winepath program
1478428d7b3dSmrg# in $build's $PATH.
1479428d7b3dSmrg#
1480428d7b3dSmrg# ARG is the $build file name to be converted to w32 format.
1481428d7b3dSmrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will
1482428d7b3dSmrg# be empty on error (or when ARG is empty)
1483428d7b3dSmrgfunc_convert_core_file_wine_to_w32 ()
1484428d7b3dSmrg{
1485428d7b3dSmrg  $opt_debug
1486428d7b3dSmrg  func_convert_core_file_wine_to_w32_result="$1"
1487428d7b3dSmrg  if test -n "$1"; then
1488428d7b3dSmrg    # Unfortunately, winepath does not exit with a non-zero error code, so we
1489428d7b3dSmrg    # are forced to check the contents of stdout. On the other hand, if the
1490428d7b3dSmrg    # command is not found, the shell will set an exit code of 127 and print
1491428d7b3dSmrg    # *an error message* to stdout. So we must check for both error code of
1492428d7b3dSmrg    # zero AND non-empty stdout, which explains the odd construction:
1493428d7b3dSmrg    func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
1494428d7b3dSmrg    if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then
1495428d7b3dSmrg      func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
1496428d7b3dSmrg        $SED -e "$lt_sed_naive_backslashify"`
1497428d7b3dSmrg    else
1498428d7b3dSmrg      func_convert_core_file_wine_to_w32_result=
1499428d7b3dSmrg    fi
1500428d7b3dSmrg  fi
1501428d7b3dSmrg}
1502428d7b3dSmrg# end: func_convert_core_file_wine_to_w32
1503428d7b3dSmrg
1504428d7b3dSmrg
1505428d7b3dSmrg# func_convert_core_path_wine_to_w32 ARG
1506428d7b3dSmrg# Helper function used by path conversion functions when $build is *nix, and
1507428d7b3dSmrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly
1508428d7b3dSmrg# configured wine environment available, with the winepath program in $build's
1509428d7b3dSmrg# $PATH. Assumes ARG has no leading or trailing path separator characters.
1510428d7b3dSmrg#
1511428d7b3dSmrg# ARG is path to be converted from $build format to win32.
1512428d7b3dSmrg# Result is available in $func_convert_core_path_wine_to_w32_result.
1513428d7b3dSmrg# Unconvertible file (directory) names in ARG are skipped; if no directory names
1514428d7b3dSmrg# are convertible, then the result may be empty.
1515428d7b3dSmrgfunc_convert_core_path_wine_to_w32 ()
1516428d7b3dSmrg{
1517428d7b3dSmrg  $opt_debug
1518428d7b3dSmrg  # unfortunately, winepath doesn't convert paths, only file names
1519428d7b3dSmrg  func_convert_core_path_wine_to_w32_result=""
1520428d7b3dSmrg  if test -n "$1"; then
1521428d7b3dSmrg    oldIFS=$IFS
1522428d7b3dSmrg    IFS=:
1523428d7b3dSmrg    for func_convert_core_path_wine_to_w32_f in $1; do
1524428d7b3dSmrg      IFS=$oldIFS
1525428d7b3dSmrg      func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
1526428d7b3dSmrg      if test -n "$func_convert_core_file_wine_to_w32_result" ; then
1527428d7b3dSmrg        if test -z "$func_convert_core_path_wine_to_w32_result"; then
1528428d7b3dSmrg          func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result"
1529428d7b3dSmrg        else
1530428d7b3dSmrg          func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
1531428d7b3dSmrg        fi
1532428d7b3dSmrg      fi
1533428d7b3dSmrg    done
1534428d7b3dSmrg    IFS=$oldIFS
1535428d7b3dSmrg  fi
1536428d7b3dSmrg}
1537428d7b3dSmrg# end: func_convert_core_path_wine_to_w32
1538428d7b3dSmrg
1539428d7b3dSmrg
1540428d7b3dSmrg# func_cygpath ARGS...
1541428d7b3dSmrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when
1542428d7b3dSmrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2)
1543428d7b3dSmrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or
1544428d7b3dSmrg# (2), returns the Cygwin file name or path in func_cygpath_result (input
1545428d7b3dSmrg# file name or path is assumed to be in w32 format, as previously converted
1546428d7b3dSmrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name
1547428d7b3dSmrg# or path in func_cygpath_result (input file name or path is assumed to be in
1548428d7b3dSmrg# Cygwin format). Returns an empty string on error.
1549428d7b3dSmrg#
1550428d7b3dSmrg# ARGS are passed to cygpath, with the last one being the file name or path to
1551428d7b3dSmrg# be converted.
1552428d7b3dSmrg#
1553428d7b3dSmrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH
1554428d7b3dSmrg# environment variable; do not put it in $PATH.
1555428d7b3dSmrgfunc_cygpath ()
1556428d7b3dSmrg{
1557428d7b3dSmrg  $opt_debug
1558428d7b3dSmrg  if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
1559428d7b3dSmrg    func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
1560428d7b3dSmrg    if test "$?" -ne 0; then
1561428d7b3dSmrg      # on failure, ensure result is empty
1562428d7b3dSmrg      func_cygpath_result=
1563428d7b3dSmrg    fi
1564428d7b3dSmrg  else
1565428d7b3dSmrg    func_cygpath_result=
1566428d7b3dSmrg    func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'"
1567428d7b3dSmrg  fi
1568428d7b3dSmrg}
1569428d7b3dSmrg#end: func_cygpath
1570428d7b3dSmrg
1571428d7b3dSmrg
1572428d7b3dSmrg# func_convert_core_msys_to_w32 ARG
1573428d7b3dSmrg# Convert file name or path ARG from MSYS format to w32 format.  Return
1574428d7b3dSmrg# result in func_convert_core_msys_to_w32_result.
1575428d7b3dSmrgfunc_convert_core_msys_to_w32 ()
1576428d7b3dSmrg{
1577428d7b3dSmrg  $opt_debug
1578428d7b3dSmrg  # awkward: cmd appends spaces to result
1579428d7b3dSmrg  func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
1580428d7b3dSmrg    $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"`
1581428d7b3dSmrg}
1582428d7b3dSmrg#end: func_convert_core_msys_to_w32
1583428d7b3dSmrg
1584428d7b3dSmrg
1585428d7b3dSmrg# func_convert_file_check ARG1 ARG2
1586428d7b3dSmrg# Verify that ARG1 (a file name in $build format) was converted to $host
1587428d7b3dSmrg# format in ARG2. Otherwise, emit an error message, but continue (resetting
1588428d7b3dSmrg# func_to_host_file_result to ARG1).
1589428d7b3dSmrgfunc_convert_file_check ()
1590428d7b3dSmrg{
1591428d7b3dSmrg  $opt_debug
1592428d7b3dSmrg  if test -z "$2" && test -n "$1" ; then
1593428d7b3dSmrg    func_error "Could not determine host file name corresponding to"
1594428d7b3dSmrg    func_error "  \`$1'"
1595428d7b3dSmrg    func_error "Continuing, but uninstalled executables may not work."
1596428d7b3dSmrg    # Fallback:
1597428d7b3dSmrg    func_to_host_file_result="$1"
1598428d7b3dSmrg  fi
1599428d7b3dSmrg}
1600428d7b3dSmrg# end func_convert_file_check
1601428d7b3dSmrg
1602428d7b3dSmrg
1603428d7b3dSmrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH
1604428d7b3dSmrg# Verify that FROM_PATH (a path in $build format) was converted to $host
1605428d7b3dSmrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting
1606428d7b3dSmrg# func_to_host_file_result to a simplistic fallback value (see below).
1607428d7b3dSmrgfunc_convert_path_check ()
1608428d7b3dSmrg{
1609428d7b3dSmrg  $opt_debug
1610428d7b3dSmrg  if test -z "$4" && test -n "$3"; then
1611428d7b3dSmrg    func_error "Could not determine the host path corresponding to"
1612428d7b3dSmrg    func_error "  \`$3'"
1613428d7b3dSmrg    func_error "Continuing, but uninstalled executables may not work."
1614428d7b3dSmrg    # Fallback.  This is a deliberately simplistic "conversion" and
1615428d7b3dSmrg    # should not be "improved".  See libtool.info.
1616428d7b3dSmrg    if test "x$1" != "x$2"; then
1617428d7b3dSmrg      lt_replace_pathsep_chars="s|$1|$2|g"
1618428d7b3dSmrg      func_to_host_path_result=`echo "$3" |
1619428d7b3dSmrg        $SED -e "$lt_replace_pathsep_chars"`
1620428d7b3dSmrg    else
1621428d7b3dSmrg      func_to_host_path_result="$3"
1622428d7b3dSmrg    fi
1623428d7b3dSmrg  fi
1624428d7b3dSmrg}
1625428d7b3dSmrg# end func_convert_path_check
1626428d7b3dSmrg
1627428d7b3dSmrg
1628428d7b3dSmrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG
1629428d7b3dSmrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT
1630428d7b3dSmrg# and appending REPL if ORIG matches BACKPAT.
1631428d7b3dSmrgfunc_convert_path_front_back_pathsep ()
1632428d7b3dSmrg{
1633428d7b3dSmrg  $opt_debug
1634428d7b3dSmrg  case $4 in
1635428d7b3dSmrg  $1 ) func_to_host_path_result="$3$func_to_host_path_result"
1636428d7b3dSmrg    ;;
1637428d7b3dSmrg  esac
1638428d7b3dSmrg  case $4 in
1639428d7b3dSmrg  $2 ) func_append func_to_host_path_result "$3"
1640428d7b3dSmrg    ;;
1641428d7b3dSmrg  esac
1642428d7b3dSmrg}
1643428d7b3dSmrg# end func_convert_path_front_back_pathsep
1644428d7b3dSmrg
1645428d7b3dSmrg
1646428d7b3dSmrg##################################################
1647428d7b3dSmrg# $build to $host FILE NAME CONVERSION FUNCTIONS #
1648428d7b3dSmrg##################################################
1649428d7b3dSmrg# invoked via `$to_host_file_cmd ARG'
1650428d7b3dSmrg#
1651428d7b3dSmrg# In each case, ARG is the path to be converted from $build to $host format.
1652428d7b3dSmrg# Result will be available in $func_to_host_file_result.
1653428d7b3dSmrg
1654428d7b3dSmrg
1655428d7b3dSmrg# func_to_host_file ARG
1656428d7b3dSmrg# Converts the file name ARG from $build format to $host format. Return result
1657428d7b3dSmrg# in func_to_host_file_result.
1658428d7b3dSmrgfunc_to_host_file ()
1659428d7b3dSmrg{
1660428d7b3dSmrg  $opt_debug
1661428d7b3dSmrg  $to_host_file_cmd "$1"
1662428d7b3dSmrg}
1663428d7b3dSmrg# end func_to_host_file
1664428d7b3dSmrg
1665428d7b3dSmrg
1666428d7b3dSmrg# func_to_tool_file ARG LAZY
1667428d7b3dSmrg# converts the file name ARG from $build format to toolchain format. Return
1668428d7b3dSmrg# result in func_to_tool_file_result.  If the conversion in use is listed
1669428d7b3dSmrg# in (the comma separated) LAZY, no conversion takes place.
1670428d7b3dSmrgfunc_to_tool_file ()
1671428d7b3dSmrg{
1672428d7b3dSmrg  $opt_debug
1673428d7b3dSmrg  case ,$2, in
1674428d7b3dSmrg    *,"$to_tool_file_cmd",*)
1675428d7b3dSmrg      func_to_tool_file_result=$1
1676428d7b3dSmrg      ;;
1677428d7b3dSmrg    *)
1678428d7b3dSmrg      $to_tool_file_cmd "$1"
1679428d7b3dSmrg      func_to_tool_file_result=$func_to_host_file_result
1680428d7b3dSmrg      ;;
1681428d7b3dSmrg  esac
1682428d7b3dSmrg}
1683428d7b3dSmrg# end func_to_tool_file
1684428d7b3dSmrg
1685428d7b3dSmrg
1686428d7b3dSmrg# func_convert_file_noop ARG
1687428d7b3dSmrg# Copy ARG to func_to_host_file_result.
1688428d7b3dSmrgfunc_convert_file_noop ()
1689428d7b3dSmrg{
1690428d7b3dSmrg  func_to_host_file_result="$1"
1691428d7b3dSmrg}
1692428d7b3dSmrg# end func_convert_file_noop
1693428d7b3dSmrg
1694428d7b3dSmrg
1695428d7b3dSmrg# func_convert_file_msys_to_w32 ARG
1696428d7b3dSmrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic
1697428d7b3dSmrg# conversion to w32 is not available inside the cwrapper.  Returns result in
1698428d7b3dSmrg# func_to_host_file_result.
1699428d7b3dSmrgfunc_convert_file_msys_to_w32 ()
1700428d7b3dSmrg{
1701428d7b3dSmrg  $opt_debug
1702428d7b3dSmrg  func_to_host_file_result="$1"
1703428d7b3dSmrg  if test -n "$1"; then
1704428d7b3dSmrg    func_convert_core_msys_to_w32 "$1"
1705428d7b3dSmrg    func_to_host_file_result="$func_convert_core_msys_to_w32_result"
1706428d7b3dSmrg  fi
1707428d7b3dSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
1708428d7b3dSmrg}
1709428d7b3dSmrg# end func_convert_file_msys_to_w32
1710428d7b3dSmrg
1711428d7b3dSmrg
1712428d7b3dSmrg# func_convert_file_cygwin_to_w32 ARG
1713428d7b3dSmrg# Convert file name ARG from Cygwin to w32 format.  Returns result in
1714428d7b3dSmrg# func_to_host_file_result.
1715428d7b3dSmrgfunc_convert_file_cygwin_to_w32 ()
1716428d7b3dSmrg{
1717428d7b3dSmrg  $opt_debug
1718428d7b3dSmrg  func_to_host_file_result="$1"
1719428d7b3dSmrg  if test -n "$1"; then
1720428d7b3dSmrg    # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
1721428d7b3dSmrg    # LT_CYGPATH in this case.
1722428d7b3dSmrg    func_to_host_file_result=`cygpath -m "$1"`
1723428d7b3dSmrg  fi
1724428d7b3dSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
1725428d7b3dSmrg}
1726428d7b3dSmrg# end func_convert_file_cygwin_to_w32
1727428d7b3dSmrg
1728428d7b3dSmrg
1729428d7b3dSmrg# func_convert_file_nix_to_w32 ARG
1730428d7b3dSmrg# Convert file name ARG from *nix to w32 format.  Requires a wine environment
1731428d7b3dSmrg# and a working winepath. Returns result in func_to_host_file_result.
1732428d7b3dSmrgfunc_convert_file_nix_to_w32 ()
1733428d7b3dSmrg{
1734428d7b3dSmrg  $opt_debug
1735428d7b3dSmrg  func_to_host_file_result="$1"
1736428d7b3dSmrg  if test -n "$1"; then
1737428d7b3dSmrg    func_convert_core_file_wine_to_w32 "$1"
1738428d7b3dSmrg    func_to_host_file_result="$func_convert_core_file_wine_to_w32_result"
1739428d7b3dSmrg  fi
1740428d7b3dSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
1741428d7b3dSmrg}
1742428d7b3dSmrg# end func_convert_file_nix_to_w32
1743428d7b3dSmrg
1744428d7b3dSmrg
1745428d7b3dSmrg# func_convert_file_msys_to_cygwin ARG
1746428d7b3dSmrg# Convert file name ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
1747428d7b3dSmrg# Returns result in func_to_host_file_result.
1748428d7b3dSmrgfunc_convert_file_msys_to_cygwin ()
1749428d7b3dSmrg{
1750428d7b3dSmrg  $opt_debug
1751428d7b3dSmrg  func_to_host_file_result="$1"
1752428d7b3dSmrg  if test -n "$1"; then
1753428d7b3dSmrg    func_convert_core_msys_to_w32 "$1"
1754428d7b3dSmrg    func_cygpath -u "$func_convert_core_msys_to_w32_result"
1755428d7b3dSmrg    func_to_host_file_result="$func_cygpath_result"
1756428d7b3dSmrg  fi
1757428d7b3dSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
1758428d7b3dSmrg}
1759428d7b3dSmrg# end func_convert_file_msys_to_cygwin
1760428d7b3dSmrg
1761428d7b3dSmrg
1762428d7b3dSmrg# func_convert_file_nix_to_cygwin ARG
1763428d7b3dSmrg# Convert file name ARG from *nix to Cygwin format.  Requires Cygwin installed
1764428d7b3dSmrg# in a wine environment, working winepath, and LT_CYGPATH set.  Returns result
1765428d7b3dSmrg# in func_to_host_file_result.
1766428d7b3dSmrgfunc_convert_file_nix_to_cygwin ()
1767428d7b3dSmrg{
1768428d7b3dSmrg  $opt_debug
1769428d7b3dSmrg  func_to_host_file_result="$1"
1770428d7b3dSmrg  if test -n "$1"; then
1771428d7b3dSmrg    # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
1772428d7b3dSmrg    func_convert_core_file_wine_to_w32 "$1"
1773428d7b3dSmrg    func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
1774428d7b3dSmrg    func_to_host_file_result="$func_cygpath_result"
1775428d7b3dSmrg  fi
1776428d7b3dSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
1777428d7b3dSmrg}
1778428d7b3dSmrg# end func_convert_file_nix_to_cygwin
1779428d7b3dSmrg
1780428d7b3dSmrg
1781428d7b3dSmrg#############################################
1782428d7b3dSmrg# $build to $host PATH CONVERSION FUNCTIONS #
1783428d7b3dSmrg#############################################
1784428d7b3dSmrg# invoked via `$to_host_path_cmd ARG'
1785428d7b3dSmrg#
1786428d7b3dSmrg# In each case, ARG is the path to be converted from $build to $host format.
1787428d7b3dSmrg# The result will be available in $func_to_host_path_result.
1788428d7b3dSmrg#
1789428d7b3dSmrg# Path separators are also converted from $build format to $host format.  If
1790428d7b3dSmrg# ARG begins or ends with a path separator character, it is preserved (but
1791428d7b3dSmrg# converted to $host format) on output.
1792428d7b3dSmrg#
1793428d7b3dSmrg# All path conversion functions are named using the following convention:
1794428d7b3dSmrg#   file name conversion function    : func_convert_file_X_to_Y ()
1795428d7b3dSmrg#   path conversion function         : func_convert_path_X_to_Y ()
1796428d7b3dSmrg# where, for any given $build/$host combination the 'X_to_Y' value is the
1797428d7b3dSmrg# same.  If conversion functions are added for new $build/$host combinations,
1798428d7b3dSmrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd
1799428d7b3dSmrg# will break.
1800428d7b3dSmrg
1801428d7b3dSmrg
1802428d7b3dSmrg# func_init_to_host_path_cmd
1803428d7b3dSmrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the
1804428d7b3dSmrg# appropriate value, based on the value of $to_host_file_cmd.
1805428d7b3dSmrgto_host_path_cmd=
1806428d7b3dSmrgfunc_init_to_host_path_cmd ()
1807428d7b3dSmrg{
1808428d7b3dSmrg  $opt_debug
1809428d7b3dSmrg  if test -z "$to_host_path_cmd"; then
1810428d7b3dSmrg    func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
1811428d7b3dSmrg    to_host_path_cmd="func_convert_path_${func_stripname_result}"
1812428d7b3dSmrg  fi
1813428d7b3dSmrg}
1814428d7b3dSmrg
1815428d7b3dSmrg
1816428d7b3dSmrg# func_to_host_path ARG
1817428d7b3dSmrg# Converts the path ARG from $build format to $host format. Return result
1818428d7b3dSmrg# in func_to_host_path_result.
1819428d7b3dSmrgfunc_to_host_path ()
1820428d7b3dSmrg{
1821428d7b3dSmrg  $opt_debug
1822428d7b3dSmrg  func_init_to_host_path_cmd
1823428d7b3dSmrg  $to_host_path_cmd "$1"
1824428d7b3dSmrg}
1825428d7b3dSmrg# end func_to_host_path
1826428d7b3dSmrg
1827428d7b3dSmrg
1828428d7b3dSmrg# func_convert_path_noop ARG
1829428d7b3dSmrg# Copy ARG to func_to_host_path_result.
1830428d7b3dSmrgfunc_convert_path_noop ()
1831428d7b3dSmrg{
1832428d7b3dSmrg  func_to_host_path_result="$1"
1833428d7b3dSmrg}
1834428d7b3dSmrg# end func_convert_path_noop
1835428d7b3dSmrg
1836428d7b3dSmrg
1837428d7b3dSmrg# func_convert_path_msys_to_w32 ARG
1838428d7b3dSmrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic
1839428d7b3dSmrg# conversion to w32 is not available inside the cwrapper.  Returns result in
1840428d7b3dSmrg# func_to_host_path_result.
1841428d7b3dSmrgfunc_convert_path_msys_to_w32 ()
1842428d7b3dSmrg{
1843428d7b3dSmrg  $opt_debug
1844428d7b3dSmrg  func_to_host_path_result="$1"
1845428d7b3dSmrg  if test -n "$1"; then
1846428d7b3dSmrg    # Remove leading and trailing path separator characters from ARG.  MSYS
1847428d7b3dSmrg    # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
1848428d7b3dSmrg    # and winepath ignores them completely.
1849428d7b3dSmrg    func_stripname : : "$1"
1850428d7b3dSmrg    func_to_host_path_tmp1=$func_stripname_result
1851428d7b3dSmrg    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
1852428d7b3dSmrg    func_to_host_path_result="$func_convert_core_msys_to_w32_result"
1853428d7b3dSmrg    func_convert_path_check : ";" \
1854428d7b3dSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1855428d7b3dSmrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
1856428d7b3dSmrg  fi
1857428d7b3dSmrg}
1858428d7b3dSmrg# end func_convert_path_msys_to_w32
1859428d7b3dSmrg
1860428d7b3dSmrg
1861428d7b3dSmrg# func_convert_path_cygwin_to_w32 ARG
1862428d7b3dSmrg# Convert path ARG from Cygwin to w32 format.  Returns result in
1863428d7b3dSmrg# func_to_host_file_result.
1864428d7b3dSmrgfunc_convert_path_cygwin_to_w32 ()
1865428d7b3dSmrg{
1866428d7b3dSmrg  $opt_debug
1867428d7b3dSmrg  func_to_host_path_result="$1"
1868428d7b3dSmrg  if test -n "$1"; then
1869428d7b3dSmrg    # See func_convert_path_msys_to_w32:
1870428d7b3dSmrg    func_stripname : : "$1"
1871428d7b3dSmrg    func_to_host_path_tmp1=$func_stripname_result
1872428d7b3dSmrg    func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"`
1873428d7b3dSmrg    func_convert_path_check : ";" \
1874428d7b3dSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1875428d7b3dSmrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
1876428d7b3dSmrg  fi
1877428d7b3dSmrg}
1878428d7b3dSmrg# end func_convert_path_cygwin_to_w32
1879428d7b3dSmrg
1880428d7b3dSmrg
1881428d7b3dSmrg# func_convert_path_nix_to_w32 ARG
1882428d7b3dSmrg# Convert path ARG from *nix to w32 format.  Requires a wine environment and
1883428d7b3dSmrg# a working winepath.  Returns result in func_to_host_file_result.
1884428d7b3dSmrgfunc_convert_path_nix_to_w32 ()
1885428d7b3dSmrg{
1886428d7b3dSmrg  $opt_debug
1887428d7b3dSmrg  func_to_host_path_result="$1"
1888428d7b3dSmrg  if test -n "$1"; then
1889428d7b3dSmrg    # See func_convert_path_msys_to_w32:
1890428d7b3dSmrg    func_stripname : : "$1"
1891428d7b3dSmrg    func_to_host_path_tmp1=$func_stripname_result
1892428d7b3dSmrg    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
1893428d7b3dSmrg    func_to_host_path_result="$func_convert_core_path_wine_to_w32_result"
1894428d7b3dSmrg    func_convert_path_check : ";" \
1895428d7b3dSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1896428d7b3dSmrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
1897428d7b3dSmrg  fi
1898428d7b3dSmrg}
1899428d7b3dSmrg# end func_convert_path_nix_to_w32
1900428d7b3dSmrg
1901428d7b3dSmrg
1902428d7b3dSmrg# func_convert_path_msys_to_cygwin ARG
1903428d7b3dSmrg# Convert path ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
1904428d7b3dSmrg# Returns result in func_to_host_file_result.
1905428d7b3dSmrgfunc_convert_path_msys_to_cygwin ()
1906428d7b3dSmrg{
1907428d7b3dSmrg  $opt_debug
1908428d7b3dSmrg  func_to_host_path_result="$1"
1909428d7b3dSmrg  if test -n "$1"; then
1910428d7b3dSmrg    # See func_convert_path_msys_to_w32:
1911428d7b3dSmrg    func_stripname : : "$1"
1912428d7b3dSmrg    func_to_host_path_tmp1=$func_stripname_result
1913428d7b3dSmrg    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
1914428d7b3dSmrg    func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
1915428d7b3dSmrg    func_to_host_path_result="$func_cygpath_result"
1916428d7b3dSmrg    func_convert_path_check : : \
1917428d7b3dSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1918428d7b3dSmrg    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
1919428d7b3dSmrg  fi
1920428d7b3dSmrg}
1921428d7b3dSmrg# end func_convert_path_msys_to_cygwin
1922428d7b3dSmrg
1923428d7b3dSmrg
1924428d7b3dSmrg# func_convert_path_nix_to_cygwin ARG
1925428d7b3dSmrg# Convert path ARG from *nix to Cygwin format.  Requires Cygwin installed in a
1926428d7b3dSmrg# a wine environment, working winepath, and LT_CYGPATH set.  Returns result in
1927428d7b3dSmrg# func_to_host_file_result.
1928428d7b3dSmrgfunc_convert_path_nix_to_cygwin ()
1929428d7b3dSmrg{
1930428d7b3dSmrg  $opt_debug
1931428d7b3dSmrg  func_to_host_path_result="$1"
1932428d7b3dSmrg  if test -n "$1"; then
1933428d7b3dSmrg    # Remove leading and trailing path separator characters from
1934428d7b3dSmrg    # ARG. msys behavior is inconsistent here, cygpath turns them
1935428d7b3dSmrg    # into '.;' and ';.', and winepath ignores them completely.
1936428d7b3dSmrg    func_stripname : : "$1"
1937428d7b3dSmrg    func_to_host_path_tmp1=$func_stripname_result
1938428d7b3dSmrg    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
1939428d7b3dSmrg    func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
1940428d7b3dSmrg    func_to_host_path_result="$func_cygpath_result"
1941428d7b3dSmrg    func_convert_path_check : : \
1942428d7b3dSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1943428d7b3dSmrg    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
1944428d7b3dSmrg  fi
1945428d7b3dSmrg}
1946428d7b3dSmrg# end func_convert_path_nix_to_cygwin
1947428d7b3dSmrg
1948428d7b3dSmrg
1949428d7b3dSmrg# func_mode_compile arg...
1950428d7b3dSmrgfunc_mode_compile ()
1951428d7b3dSmrg{
1952428d7b3dSmrg    $opt_debug
1953428d7b3dSmrg    # Get the compilation command and the source file.
1954428d7b3dSmrg    base_compile=
1955428d7b3dSmrg    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
1956428d7b3dSmrg    suppress_opt=yes
1957428d7b3dSmrg    suppress_output=
1958428d7b3dSmrg    arg_mode=normal
1959428d7b3dSmrg    libobj=
1960428d7b3dSmrg    later=
1961428d7b3dSmrg    pie_flag=
1962428d7b3dSmrg
1963428d7b3dSmrg    for arg
1964428d7b3dSmrg    do
1965428d7b3dSmrg      case $arg_mode in
1966428d7b3dSmrg      arg  )
1967428d7b3dSmrg	# do not "continue".  Instead, add this to base_compile
1968428d7b3dSmrg	lastarg="$arg"
1969428d7b3dSmrg	arg_mode=normal
1970428d7b3dSmrg	;;
1971428d7b3dSmrg
1972428d7b3dSmrg      target )
1973428d7b3dSmrg	libobj="$arg"
1974428d7b3dSmrg	arg_mode=normal
1975428d7b3dSmrg	continue
1976428d7b3dSmrg	;;
1977428d7b3dSmrg
1978428d7b3dSmrg      normal )
1979428d7b3dSmrg	# Accept any command-line options.
1980428d7b3dSmrg	case $arg in
1981428d7b3dSmrg	-o)
1982428d7b3dSmrg	  test -n "$libobj" && \
1983428d7b3dSmrg	    func_fatal_error "you cannot specify \`-o' more than once"
1984428d7b3dSmrg	  arg_mode=target
1985428d7b3dSmrg	  continue
1986428d7b3dSmrg	  ;;
1987428d7b3dSmrg
1988428d7b3dSmrg	-pie | -fpie | -fPIE)
1989428d7b3dSmrg          func_append pie_flag " $arg"
1990428d7b3dSmrg	  continue
1991428d7b3dSmrg	  ;;
1992428d7b3dSmrg
1993428d7b3dSmrg	-shared | -static | -prefer-pic | -prefer-non-pic)
1994428d7b3dSmrg	  func_append later " $arg"
1995428d7b3dSmrg	  continue
1996428d7b3dSmrg	  ;;
1997428d7b3dSmrg
1998428d7b3dSmrg	-no-suppress)
1999428d7b3dSmrg	  suppress_opt=no
2000428d7b3dSmrg	  continue
2001428d7b3dSmrg	  ;;
2002428d7b3dSmrg
2003428d7b3dSmrg	-Xcompiler)
2004428d7b3dSmrg	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
2005428d7b3dSmrg	  continue      #  The current "srcfile" will either be retained or
2006428d7b3dSmrg	  ;;            #  replaced later.  I would guess that would be a bug.
2007428d7b3dSmrg
2008428d7b3dSmrg	-Wc,*)
2009428d7b3dSmrg	  func_stripname '-Wc,' '' "$arg"
2010428d7b3dSmrg	  args=$func_stripname_result
2011428d7b3dSmrg	  lastarg=
2012428d7b3dSmrg	  save_ifs="$IFS"; IFS=','
2013428d7b3dSmrg	  for arg in $args; do
2014428d7b3dSmrg	    IFS="$save_ifs"
2015428d7b3dSmrg	    func_append_quoted lastarg "$arg"
2016428d7b3dSmrg	  done
2017428d7b3dSmrg	  IFS="$save_ifs"
2018428d7b3dSmrg	  func_stripname ' ' '' "$lastarg"
2019428d7b3dSmrg	  lastarg=$func_stripname_result
2020428d7b3dSmrg
2021428d7b3dSmrg	  # Add the arguments to base_compile.
2022428d7b3dSmrg	  func_append base_compile " $lastarg"
2023428d7b3dSmrg	  continue
2024428d7b3dSmrg	  ;;
2025428d7b3dSmrg
2026428d7b3dSmrg	*)
2027428d7b3dSmrg	  # Accept the current argument as the source file.
2028428d7b3dSmrg	  # The previous "srcfile" becomes the current argument.
2029428d7b3dSmrg	  #
2030428d7b3dSmrg	  lastarg="$srcfile"
2031428d7b3dSmrg	  srcfile="$arg"
2032428d7b3dSmrg	  ;;
2033428d7b3dSmrg	esac  #  case $arg
2034428d7b3dSmrg	;;
2035428d7b3dSmrg      esac    #  case $arg_mode
2036428d7b3dSmrg
2037428d7b3dSmrg      # Aesthetically quote the previous argument.
2038428d7b3dSmrg      func_append_quoted base_compile "$lastarg"
2039428d7b3dSmrg    done # for arg
2040428d7b3dSmrg
2041428d7b3dSmrg    case $arg_mode in
2042428d7b3dSmrg    arg)
2043428d7b3dSmrg      func_fatal_error "you must specify an argument for -Xcompile"
2044428d7b3dSmrg      ;;
2045428d7b3dSmrg    target)
2046428d7b3dSmrg      func_fatal_error "you must specify a target with \`-o'"
2047428d7b3dSmrg      ;;
2048428d7b3dSmrg    *)
2049428d7b3dSmrg      # Get the name of the library object.
2050428d7b3dSmrg      test -z "$libobj" && {
2051428d7b3dSmrg	func_basename "$srcfile"
2052428d7b3dSmrg	libobj="$func_basename_result"
2053428d7b3dSmrg      }
2054428d7b3dSmrg      ;;
2055428d7b3dSmrg    esac
2056428d7b3dSmrg
2057428d7b3dSmrg    # Recognize several different file suffixes.
2058428d7b3dSmrg    # If the user specifies -o file.o, it is replaced with file.lo
2059428d7b3dSmrg    case $libobj in
2060428d7b3dSmrg    *.[cCFSifmso] | \
2061428d7b3dSmrg    *.ada | *.adb | *.ads | *.asm | \
2062428d7b3dSmrg    *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
2063428d7b3dSmrg    *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup)
2064428d7b3dSmrg      func_xform "$libobj"
2065428d7b3dSmrg      libobj=$func_xform_result
2066428d7b3dSmrg      ;;
2067428d7b3dSmrg    esac
2068428d7b3dSmrg
2069428d7b3dSmrg    case $libobj in
2070428d7b3dSmrg    *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
2071428d7b3dSmrg    *)
2072428d7b3dSmrg      func_fatal_error "cannot determine name of library object from \`$libobj'"
2073428d7b3dSmrg      ;;
2074428d7b3dSmrg    esac
2075428d7b3dSmrg
2076428d7b3dSmrg    func_infer_tag $base_compile
2077428d7b3dSmrg
2078428d7b3dSmrg    for arg in $later; do
2079428d7b3dSmrg      case $arg in
2080428d7b3dSmrg      -shared)
2081428d7b3dSmrg	test "$build_libtool_libs" != yes && \
2082428d7b3dSmrg	  func_fatal_configuration "can not build a shared library"
2083428d7b3dSmrg	build_old_libs=no
2084428d7b3dSmrg	continue
2085428d7b3dSmrg	;;
2086428d7b3dSmrg
2087428d7b3dSmrg      -static)
2088428d7b3dSmrg	build_libtool_libs=no
2089428d7b3dSmrg	build_old_libs=yes
2090428d7b3dSmrg	continue
2091428d7b3dSmrg	;;
2092428d7b3dSmrg
2093428d7b3dSmrg      -prefer-pic)
2094428d7b3dSmrg	pic_mode=yes
2095428d7b3dSmrg	continue
2096428d7b3dSmrg	;;
2097428d7b3dSmrg
2098428d7b3dSmrg      -prefer-non-pic)
2099428d7b3dSmrg	pic_mode=no
2100428d7b3dSmrg	continue
2101428d7b3dSmrg	;;
2102428d7b3dSmrg      esac
2103428d7b3dSmrg    done
2104428d7b3dSmrg
2105428d7b3dSmrg    func_quote_for_eval "$libobj"
2106428d7b3dSmrg    test "X$libobj" != "X$func_quote_for_eval_result" \
2107428d7b3dSmrg      && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'	 &()|`$[]' \
2108428d7b3dSmrg      && func_warning "libobj name \`$libobj' may not contain shell special characters."
2109428d7b3dSmrg    func_dirname_and_basename "$obj" "/" ""
2110428d7b3dSmrg    objname="$func_basename_result"
2111428d7b3dSmrg    xdir="$func_dirname_result"
2112428d7b3dSmrg    lobj=${xdir}$objdir/$objname
2113428d7b3dSmrg
2114428d7b3dSmrg    test -z "$base_compile" && \
2115428d7b3dSmrg      func_fatal_help "you must specify a compilation command"
2116428d7b3dSmrg
2117428d7b3dSmrg    # Delete any leftover library objects.
2118428d7b3dSmrg    if test "$build_old_libs" = yes; then
2119428d7b3dSmrg      removelist="$obj $lobj $libobj ${libobj}T"
2120428d7b3dSmrg    else
2121428d7b3dSmrg      removelist="$lobj $libobj ${libobj}T"
2122428d7b3dSmrg    fi
2123428d7b3dSmrg
2124428d7b3dSmrg    # On Cygwin there's no "real" PIC flag so we must build both object types
2125428d7b3dSmrg    case $host_os in
2126428d7b3dSmrg    cygwin* | mingw* | pw32* | os2* | cegcc*)
2127428d7b3dSmrg      pic_mode=default
2128428d7b3dSmrg      ;;
2129428d7b3dSmrg    esac
2130428d7b3dSmrg    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
2131428d7b3dSmrg      # non-PIC code in shared libraries is not supported
2132428d7b3dSmrg      pic_mode=default
2133428d7b3dSmrg    fi
2134428d7b3dSmrg
2135428d7b3dSmrg    # Calculate the filename of the output object if compiler does
2136428d7b3dSmrg    # not support -o with -c
2137428d7b3dSmrg    if test "$compiler_c_o" = no; then
2138428d7b3dSmrg      output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext}
2139428d7b3dSmrg      lockfile="$output_obj.lock"
2140428d7b3dSmrg    else
2141428d7b3dSmrg      output_obj=
2142428d7b3dSmrg      need_locks=no
2143428d7b3dSmrg      lockfile=
2144428d7b3dSmrg    fi
2145428d7b3dSmrg
2146428d7b3dSmrg    # Lock this critical section if it is needed
2147428d7b3dSmrg    # We use this script file to make the link, it avoids creating a new file
2148428d7b3dSmrg    if test "$need_locks" = yes; then
2149428d7b3dSmrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
2150428d7b3dSmrg	func_echo "Waiting for $lockfile to be removed"
2151428d7b3dSmrg	sleep 2
2152428d7b3dSmrg      done
2153428d7b3dSmrg    elif test "$need_locks" = warn; then
2154428d7b3dSmrg      if test -f "$lockfile"; then
2155428d7b3dSmrg	$ECHO "\
2156428d7b3dSmrg*** ERROR, $lockfile exists and contains:
2157428d7b3dSmrg`cat $lockfile 2>/dev/null`
2158428d7b3dSmrg
2159428d7b3dSmrgThis indicates that another process is trying to use the same
2160428d7b3dSmrgtemporary object file, and libtool could not work around it because
2161428d7b3dSmrgyour compiler does not support \`-c' and \`-o' together.  If you
2162428d7b3dSmrgrepeat this compilation, it may succeed, by chance, but you had better
2163428d7b3dSmrgavoid parallel builds (make -j) in this platform, or get a better
2164428d7b3dSmrgcompiler."
2165428d7b3dSmrg
2166428d7b3dSmrg	$opt_dry_run || $RM $removelist
2167428d7b3dSmrg	exit $EXIT_FAILURE
2168428d7b3dSmrg      fi
2169428d7b3dSmrg      func_append removelist " $output_obj"
2170428d7b3dSmrg      $ECHO "$srcfile" > "$lockfile"
2171428d7b3dSmrg    fi
2172428d7b3dSmrg
2173428d7b3dSmrg    $opt_dry_run || $RM $removelist
2174428d7b3dSmrg    func_append removelist " $lockfile"
2175428d7b3dSmrg    trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
2176428d7b3dSmrg
2177428d7b3dSmrg    func_to_tool_file "$srcfile" func_convert_file_msys_to_w32
2178428d7b3dSmrg    srcfile=$func_to_tool_file_result
2179428d7b3dSmrg    func_quote_for_eval "$srcfile"
2180428d7b3dSmrg    qsrcfile=$func_quote_for_eval_result
2181428d7b3dSmrg
2182428d7b3dSmrg    # Only build a PIC object if we are building libtool libraries.
2183428d7b3dSmrg    if test "$build_libtool_libs" = yes; then
2184428d7b3dSmrg      # Without this assignment, base_compile gets emptied.
2185428d7b3dSmrg      fbsd_hideous_sh_bug=$base_compile
2186428d7b3dSmrg
2187428d7b3dSmrg      if test "$pic_mode" != no; then
2188428d7b3dSmrg	command="$base_compile $qsrcfile $pic_flag"
2189428d7b3dSmrg      else
2190428d7b3dSmrg	# Don't build PIC code
2191428d7b3dSmrg	command="$base_compile $qsrcfile"
2192428d7b3dSmrg      fi
2193428d7b3dSmrg
2194428d7b3dSmrg      func_mkdir_p "$xdir$objdir"
2195428d7b3dSmrg
2196428d7b3dSmrg      if test -z "$output_obj"; then
2197428d7b3dSmrg	# Place PIC objects in $objdir
2198428d7b3dSmrg	func_append command " -o $lobj"
2199428d7b3dSmrg      fi
2200428d7b3dSmrg
2201428d7b3dSmrg      func_show_eval_locale "$command"	\
2202428d7b3dSmrg          'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
2203428d7b3dSmrg
2204428d7b3dSmrg      if test "$need_locks" = warn &&
2205428d7b3dSmrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
2206428d7b3dSmrg	$ECHO "\
2207428d7b3dSmrg*** ERROR, $lockfile contains:
2208428d7b3dSmrg`cat $lockfile 2>/dev/null`
2209428d7b3dSmrg
2210428d7b3dSmrgbut it should contain:
2211428d7b3dSmrg$srcfile
2212428d7b3dSmrg
2213428d7b3dSmrgThis indicates that another process is trying to use the same
2214428d7b3dSmrgtemporary object file, and libtool could not work around it because
2215428d7b3dSmrgyour compiler does not support \`-c' and \`-o' together.  If you
2216428d7b3dSmrgrepeat this compilation, it may succeed, by chance, but you had better
2217428d7b3dSmrgavoid parallel builds (make -j) in this platform, or get a better
2218428d7b3dSmrgcompiler."
2219428d7b3dSmrg
2220428d7b3dSmrg	$opt_dry_run || $RM $removelist
2221428d7b3dSmrg	exit $EXIT_FAILURE
2222428d7b3dSmrg      fi
2223428d7b3dSmrg
2224428d7b3dSmrg      # Just move the object if needed, then go on to compile the next one
2225428d7b3dSmrg      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
2226428d7b3dSmrg	func_show_eval '$MV "$output_obj" "$lobj"' \
2227428d7b3dSmrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
2228428d7b3dSmrg      fi
2229428d7b3dSmrg
2230428d7b3dSmrg      # Allow error messages only from the first compilation.
2231428d7b3dSmrg      if test "$suppress_opt" = yes; then
2232428d7b3dSmrg	suppress_output=' >/dev/null 2>&1'
2233428d7b3dSmrg      fi
2234428d7b3dSmrg    fi
2235428d7b3dSmrg
2236428d7b3dSmrg    # Only build a position-dependent object if we build old libraries.
2237428d7b3dSmrg    if test "$build_old_libs" = yes; then
2238428d7b3dSmrg      if test "$pic_mode" != yes; then
2239428d7b3dSmrg	# Don't build PIC code
2240428d7b3dSmrg	command="$base_compile $qsrcfile$pie_flag"
2241428d7b3dSmrg      else
2242428d7b3dSmrg	command="$base_compile $qsrcfile $pic_flag"
2243428d7b3dSmrg      fi
2244428d7b3dSmrg      if test "$compiler_c_o" = yes; then
2245428d7b3dSmrg	func_append command " -o $obj"
2246428d7b3dSmrg      fi
2247428d7b3dSmrg
2248428d7b3dSmrg      # Suppress compiler output if we already did a PIC compilation.
2249428d7b3dSmrg      func_append command "$suppress_output"
2250428d7b3dSmrg      func_show_eval_locale "$command" \
2251428d7b3dSmrg        '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
2252428d7b3dSmrg
2253428d7b3dSmrg      if test "$need_locks" = warn &&
2254428d7b3dSmrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
2255428d7b3dSmrg	$ECHO "\
2256428d7b3dSmrg*** ERROR, $lockfile contains:
2257428d7b3dSmrg`cat $lockfile 2>/dev/null`
2258428d7b3dSmrg
2259428d7b3dSmrgbut it should contain:
2260428d7b3dSmrg$srcfile
2261428d7b3dSmrg
2262428d7b3dSmrgThis indicates that another process is trying to use the same
2263428d7b3dSmrgtemporary object file, and libtool could not work around it because
2264428d7b3dSmrgyour compiler does not support \`-c' and \`-o' together.  If you
2265428d7b3dSmrgrepeat this compilation, it may succeed, by chance, but you had better
2266428d7b3dSmrgavoid parallel builds (make -j) in this platform, or get a better
2267428d7b3dSmrgcompiler."
2268428d7b3dSmrg
2269428d7b3dSmrg	$opt_dry_run || $RM $removelist
2270428d7b3dSmrg	exit $EXIT_FAILURE
2271428d7b3dSmrg      fi
2272428d7b3dSmrg
2273428d7b3dSmrg      # Just move the object if needed
2274428d7b3dSmrg      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
2275428d7b3dSmrg	func_show_eval '$MV "$output_obj" "$obj"' \
2276428d7b3dSmrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
2277428d7b3dSmrg      fi
2278428d7b3dSmrg    fi
2279428d7b3dSmrg
2280428d7b3dSmrg    $opt_dry_run || {
2281428d7b3dSmrg      func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
2282428d7b3dSmrg
2283428d7b3dSmrg      # Unlock the critical section if it was locked
2284428d7b3dSmrg      if test "$need_locks" != no; then
2285428d7b3dSmrg	removelist=$lockfile
2286428d7b3dSmrg        $RM "$lockfile"
2287428d7b3dSmrg      fi
2288428d7b3dSmrg    }
2289428d7b3dSmrg
2290428d7b3dSmrg    exit $EXIT_SUCCESS
2291428d7b3dSmrg}
2292428d7b3dSmrg
2293428d7b3dSmrg$opt_help || {
2294428d7b3dSmrg  test "$opt_mode" = compile && func_mode_compile ${1+"$@"}
2295428d7b3dSmrg}
2296428d7b3dSmrg
2297428d7b3dSmrgfunc_mode_help ()
2298428d7b3dSmrg{
2299428d7b3dSmrg    # We need to display help for each of the modes.
2300428d7b3dSmrg    case $opt_mode in
2301428d7b3dSmrg      "")
2302428d7b3dSmrg        # Generic help is extracted from the usage comments
2303428d7b3dSmrg        # at the start of this file.
2304428d7b3dSmrg        func_help
2305428d7b3dSmrg        ;;
2306428d7b3dSmrg
2307428d7b3dSmrg      clean)
2308428d7b3dSmrg        $ECHO \
2309428d7b3dSmrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
2310428d7b3dSmrg
2311428d7b3dSmrgRemove files from the build directory.
2312428d7b3dSmrg
2313428d7b3dSmrgRM is the name of the program to use to delete files associated with each FILE
2314428d7b3dSmrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
2315428d7b3dSmrgto RM.
2316428d7b3dSmrg
2317428d7b3dSmrgIf FILE is a libtool library, object or program, all the files associated
2318428d7b3dSmrgwith it are deleted. Otherwise, only FILE itself is deleted using RM."
2319428d7b3dSmrg        ;;
2320428d7b3dSmrg
2321428d7b3dSmrg      compile)
2322428d7b3dSmrg      $ECHO \
2323428d7b3dSmrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
2324428d7b3dSmrg
2325428d7b3dSmrgCompile a source file into a libtool library object.
2326428d7b3dSmrg
2327428d7b3dSmrgThis mode accepts the following additional options:
2328428d7b3dSmrg
2329428d7b3dSmrg  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
2330428d7b3dSmrg  -no-suppress      do not suppress compiler output for multiple passes
2331428d7b3dSmrg  -prefer-pic       try to build PIC objects only
2332428d7b3dSmrg  -prefer-non-pic   try to build non-PIC objects only
2333428d7b3dSmrg  -shared           do not build a \`.o' file suitable for static linking
2334428d7b3dSmrg  -static           only build a \`.o' file suitable for static linking
2335428d7b3dSmrg  -Wc,FLAG          pass FLAG directly to the compiler
2336428d7b3dSmrg
2337428d7b3dSmrgCOMPILE-COMMAND is a command to be used in creating a \`standard' object file
2338428d7b3dSmrgfrom the given SOURCEFILE.
2339428d7b3dSmrg
2340428d7b3dSmrgThe output file name is determined by removing the directory component from
2341428d7b3dSmrgSOURCEFILE, then substituting the C source code suffix \`.c' with the
2342428d7b3dSmrglibrary object suffix, \`.lo'."
2343428d7b3dSmrg        ;;
2344428d7b3dSmrg
2345428d7b3dSmrg      execute)
2346428d7b3dSmrg        $ECHO \
2347428d7b3dSmrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
2348428d7b3dSmrg
2349428d7b3dSmrgAutomatically set library path, then run a program.
2350428d7b3dSmrg
2351428d7b3dSmrgThis mode accepts the following additional options:
2352428d7b3dSmrg
2353428d7b3dSmrg  -dlopen FILE      add the directory containing FILE to the library path
2354428d7b3dSmrg
2355428d7b3dSmrgThis mode sets the library path environment variable according to \`-dlopen'
2356428d7b3dSmrgflags.
2357428d7b3dSmrg
2358428d7b3dSmrgIf any of the ARGS are libtool executable wrappers, then they are translated
2359428d7b3dSmrginto their corresponding uninstalled binary, and any of their required library
2360428d7b3dSmrgdirectories are added to the library path.
2361428d7b3dSmrg
2362428d7b3dSmrgThen, COMMAND is executed, with ARGS as arguments."
2363428d7b3dSmrg        ;;
2364428d7b3dSmrg
2365428d7b3dSmrg      finish)
2366428d7b3dSmrg        $ECHO \
2367428d7b3dSmrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
2368428d7b3dSmrg
2369428d7b3dSmrgComplete the installation of libtool libraries.
2370428d7b3dSmrg
2371428d7b3dSmrgEach LIBDIR is a directory that contains libtool libraries.
2372428d7b3dSmrg
2373428d7b3dSmrgThe commands that this mode executes may require superuser privileges.  Use
2374428d7b3dSmrgthe \`--dry-run' option if you just want to see what would be executed."
2375428d7b3dSmrg        ;;
2376428d7b3dSmrg
2377428d7b3dSmrg      install)
2378428d7b3dSmrg        $ECHO \
2379428d7b3dSmrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
2380428d7b3dSmrg
2381428d7b3dSmrgInstall executables or libraries.
2382428d7b3dSmrg
2383428d7b3dSmrgINSTALL-COMMAND is the installation command.  The first component should be
2384428d7b3dSmrgeither the \`install' or \`cp' program.
2385428d7b3dSmrg
2386428d7b3dSmrgThe following components of INSTALL-COMMAND are treated specially:
2387428d7b3dSmrg
2388428d7b3dSmrg  -inst-prefix-dir PREFIX-DIR  Use PREFIX-DIR as a staging area for installation
2389428d7b3dSmrg
2390428d7b3dSmrgThe rest of the components are interpreted as arguments to that command (only
2391428d7b3dSmrgBSD-compatible install options are recognized)."
2392428d7b3dSmrg        ;;
2393428d7b3dSmrg
2394428d7b3dSmrg      link)
2395428d7b3dSmrg        $ECHO \
2396428d7b3dSmrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
2397428d7b3dSmrg
2398428d7b3dSmrgLink object files or libraries together to form another library, or to
2399428d7b3dSmrgcreate an executable program.
2400428d7b3dSmrg
2401428d7b3dSmrgLINK-COMMAND is a command using the C compiler that you would use to create
2402428d7b3dSmrga program from several object files.
2403428d7b3dSmrg
2404428d7b3dSmrgThe following components of LINK-COMMAND are treated specially:
2405428d7b3dSmrg
2406428d7b3dSmrg  -all-static       do not do any dynamic linking at all
2407428d7b3dSmrg  -avoid-version    do not add a version suffix if possible
2408428d7b3dSmrg  -bindir BINDIR    specify path to binaries directory (for systems where
2409428d7b3dSmrg                    libraries must be found in the PATH setting at runtime)
2410428d7b3dSmrg  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
2411428d7b3dSmrg  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
2412428d7b3dSmrg  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
2413428d7b3dSmrg  -export-symbols SYMFILE
2414428d7b3dSmrg                    try to export only the symbols listed in SYMFILE
2415428d7b3dSmrg  -export-symbols-regex REGEX
2416428d7b3dSmrg                    try to export only the symbols matching REGEX
2417428d7b3dSmrg  -LLIBDIR          search LIBDIR for required installed libraries
2418428d7b3dSmrg  -lNAME            OUTPUT-FILE requires the installed library libNAME
2419428d7b3dSmrg  -module           build a library that can dlopened
2420428d7b3dSmrg  -no-fast-install  disable the fast-install mode
2421428d7b3dSmrg  -no-install       link a not-installable executable
2422428d7b3dSmrg  -no-undefined     declare that a library does not refer to external symbols
2423428d7b3dSmrg  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
2424428d7b3dSmrg  -objectlist FILE  Use a list of object files found in FILE to specify objects
2425428d7b3dSmrg  -precious-files-regex REGEX
2426428d7b3dSmrg                    don't remove output files matching REGEX
2427428d7b3dSmrg  -release RELEASE  specify package release information
2428428d7b3dSmrg  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
2429428d7b3dSmrg  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
2430428d7b3dSmrg  -shared           only do dynamic linking of libtool libraries
2431428d7b3dSmrg  -shrext SUFFIX    override the standard shared library file extension
2432428d7b3dSmrg  -static           do not do any dynamic linking of uninstalled libtool libraries
2433428d7b3dSmrg  -static-libtool-libs
2434428d7b3dSmrg                    do not do any dynamic linking of libtool libraries
2435428d7b3dSmrg  -version-info CURRENT[:REVISION[:AGE]]
2436428d7b3dSmrg                    specify library version info [each variable defaults to 0]
2437428d7b3dSmrg  -weak LIBNAME     declare that the target provides the LIBNAME interface
2438428d7b3dSmrg  -Wc,FLAG
2439428d7b3dSmrg  -Xcompiler FLAG   pass linker-specific FLAG directly to the compiler
2440428d7b3dSmrg  -Wl,FLAG
2441428d7b3dSmrg  -Xlinker FLAG     pass linker-specific FLAG directly to the linker
2442428d7b3dSmrg  -XCClinker FLAG   pass link-specific FLAG to the compiler driver (CC)
2443428d7b3dSmrg
2444428d7b3dSmrgAll other options (arguments beginning with \`-') are ignored.
2445428d7b3dSmrg
2446428d7b3dSmrgEvery other argument is treated as a filename.  Files ending in \`.la' are
2447428d7b3dSmrgtreated as uninstalled libtool libraries, other files are standard or library
2448428d7b3dSmrgobject files.
2449428d7b3dSmrg
2450428d7b3dSmrgIf the OUTPUT-FILE ends in \`.la', then a libtool library is created,
2451428d7b3dSmrgonly library objects (\`.lo' files) may be specified, and \`-rpath' is
2452428d7b3dSmrgrequired, except when creating a convenience library.
2453428d7b3dSmrg
2454428d7b3dSmrgIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
2455428d7b3dSmrgusing \`ar' and \`ranlib', or on Windows using \`lib'.
2456428d7b3dSmrg
2457428d7b3dSmrgIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
2458428d7b3dSmrgis created, otherwise an executable program is created."
2459428d7b3dSmrg        ;;
2460428d7b3dSmrg
2461428d7b3dSmrg      uninstall)
2462428d7b3dSmrg        $ECHO \
2463428d7b3dSmrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
2464428d7b3dSmrg
2465428d7b3dSmrgRemove libraries from an installation directory.
2466428d7b3dSmrg
2467428d7b3dSmrgRM is the name of the program to use to delete files associated with each FILE
2468428d7b3dSmrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
2469428d7b3dSmrgto RM.
2470428d7b3dSmrg
2471428d7b3dSmrgIf FILE is a libtool library, all the files associated with it are deleted.
2472428d7b3dSmrgOtherwise, only FILE itself is deleted using RM."
2473428d7b3dSmrg        ;;
2474428d7b3dSmrg
2475428d7b3dSmrg      *)
2476428d7b3dSmrg        func_fatal_help "invalid operation mode \`$opt_mode'"
2477428d7b3dSmrg        ;;
2478428d7b3dSmrg    esac
2479428d7b3dSmrg
2480428d7b3dSmrg    echo
2481428d7b3dSmrg    $ECHO "Try \`$progname --help' for more information about other modes."
2482428d7b3dSmrg}
2483428d7b3dSmrg
2484428d7b3dSmrg# Now that we've collected a possible --mode arg, show help if necessary
2485428d7b3dSmrgif $opt_help; then
2486428d7b3dSmrg  if test "$opt_help" = :; then
2487428d7b3dSmrg    func_mode_help
2488428d7b3dSmrg  else
2489428d7b3dSmrg    {
2490428d7b3dSmrg      func_help noexit
2491428d7b3dSmrg      for opt_mode in compile link execute install finish uninstall clean; do
2492428d7b3dSmrg	func_mode_help
2493428d7b3dSmrg      done
2494428d7b3dSmrg    } | sed -n '1p; 2,$s/^Usage:/  or: /p'
2495428d7b3dSmrg    {
2496428d7b3dSmrg      func_help noexit
2497428d7b3dSmrg      for opt_mode in compile link execute install finish uninstall clean; do
2498428d7b3dSmrg	echo
2499428d7b3dSmrg	func_mode_help
2500428d7b3dSmrg      done
2501428d7b3dSmrg    } |
2502428d7b3dSmrg    sed '1d
2503428d7b3dSmrg      /^When reporting/,/^Report/{
2504428d7b3dSmrg	H
2505428d7b3dSmrg	d
2506428d7b3dSmrg      }
2507428d7b3dSmrg      $x
2508428d7b3dSmrg      /information about other modes/d
2509428d7b3dSmrg      /more detailed .*MODE/d
2510428d7b3dSmrg      s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
2511428d7b3dSmrg  fi
2512428d7b3dSmrg  exit $?
2513428d7b3dSmrgfi
2514428d7b3dSmrg
2515428d7b3dSmrg
2516428d7b3dSmrg# func_mode_execute arg...
2517428d7b3dSmrgfunc_mode_execute ()
2518428d7b3dSmrg{
2519428d7b3dSmrg    $opt_debug
2520428d7b3dSmrg    # The first argument is the command name.
2521428d7b3dSmrg    cmd="$nonopt"
2522428d7b3dSmrg    test -z "$cmd" && \
2523428d7b3dSmrg      func_fatal_help "you must specify a COMMAND"
2524428d7b3dSmrg
2525428d7b3dSmrg    # Handle -dlopen flags immediately.
2526428d7b3dSmrg    for file in $opt_dlopen; do
2527428d7b3dSmrg      test -f "$file" \
2528428d7b3dSmrg	|| func_fatal_help "\`$file' is not a file"
2529428d7b3dSmrg
2530428d7b3dSmrg      dir=
2531428d7b3dSmrg      case $file in
2532428d7b3dSmrg      *.la)
2533428d7b3dSmrg	func_resolve_sysroot "$file"
2534428d7b3dSmrg	file=$func_resolve_sysroot_result
2535428d7b3dSmrg
2536428d7b3dSmrg	# Check to see that this really is a libtool archive.
2537428d7b3dSmrg	func_lalib_unsafe_p "$file" \
2538428d7b3dSmrg	  || func_fatal_help "\`$lib' is not a valid libtool archive"
2539428d7b3dSmrg
2540428d7b3dSmrg	# Read the libtool library.
2541428d7b3dSmrg	dlname=
2542428d7b3dSmrg	library_names=
2543428d7b3dSmrg	func_source "$file"
2544428d7b3dSmrg
2545428d7b3dSmrg	# Skip this library if it cannot be dlopened.
2546428d7b3dSmrg	if test -z "$dlname"; then
2547428d7b3dSmrg	  # Warn if it was a shared library.
2548428d7b3dSmrg	  test -n "$library_names" && \
2549428d7b3dSmrg	    func_warning "\`$file' was not linked with \`-export-dynamic'"
2550428d7b3dSmrg	  continue
2551428d7b3dSmrg	fi
2552428d7b3dSmrg
2553428d7b3dSmrg	func_dirname "$file" "" "."
2554428d7b3dSmrg	dir="$func_dirname_result"
2555428d7b3dSmrg
2556428d7b3dSmrg	if test -f "$dir/$objdir/$dlname"; then
2557428d7b3dSmrg	  func_append dir "/$objdir"
2558428d7b3dSmrg	else
2559428d7b3dSmrg	  if test ! -f "$dir/$dlname"; then
2560428d7b3dSmrg	    func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'"
2561428d7b3dSmrg	  fi
2562428d7b3dSmrg	fi
2563428d7b3dSmrg	;;
2564428d7b3dSmrg
2565428d7b3dSmrg      *.lo)
2566428d7b3dSmrg	# Just add the directory containing the .lo file.
2567428d7b3dSmrg	func_dirname "$file" "" "."
2568428d7b3dSmrg	dir="$func_dirname_result"
2569428d7b3dSmrg	;;
2570428d7b3dSmrg
2571428d7b3dSmrg      *)
2572428d7b3dSmrg	func_warning "\`-dlopen' is ignored for non-libtool libraries and objects"
2573428d7b3dSmrg	continue
2574428d7b3dSmrg	;;
2575428d7b3dSmrg      esac
2576428d7b3dSmrg
2577428d7b3dSmrg      # Get the absolute pathname.
2578428d7b3dSmrg      absdir=`cd "$dir" && pwd`
2579428d7b3dSmrg      test -n "$absdir" && dir="$absdir"
2580428d7b3dSmrg
2581428d7b3dSmrg      # Now add the directory to shlibpath_var.
2582428d7b3dSmrg      if eval "test -z \"\$$shlibpath_var\""; then
2583428d7b3dSmrg	eval "$shlibpath_var=\"\$dir\""
2584428d7b3dSmrg      else
2585428d7b3dSmrg	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
2586428d7b3dSmrg      fi
2587428d7b3dSmrg    done
2588428d7b3dSmrg
2589428d7b3dSmrg    # This variable tells wrapper scripts just to set shlibpath_var
2590428d7b3dSmrg    # rather than running their programs.
2591428d7b3dSmrg    libtool_execute_magic="$magic"
2592428d7b3dSmrg
2593428d7b3dSmrg    # Check if any of the arguments is a wrapper script.
2594428d7b3dSmrg    args=
2595428d7b3dSmrg    for file
2596428d7b3dSmrg    do
2597428d7b3dSmrg      case $file in
2598428d7b3dSmrg      -* | *.la | *.lo ) ;;
2599428d7b3dSmrg      *)
2600428d7b3dSmrg	# Do a test to see if this is really a libtool program.
2601428d7b3dSmrg	if func_ltwrapper_script_p "$file"; then
2602428d7b3dSmrg	  func_source "$file"
2603428d7b3dSmrg	  # Transform arg to wrapped name.
2604428d7b3dSmrg	  file="$progdir/$program"
2605428d7b3dSmrg	elif func_ltwrapper_executable_p "$file"; then
2606428d7b3dSmrg	  func_ltwrapper_scriptname "$file"
2607428d7b3dSmrg	  func_source "$func_ltwrapper_scriptname_result"
2608428d7b3dSmrg	  # Transform arg to wrapped name.
2609428d7b3dSmrg	  file="$progdir/$program"
2610428d7b3dSmrg	fi
2611428d7b3dSmrg	;;
2612428d7b3dSmrg      esac
2613428d7b3dSmrg      # Quote arguments (to preserve shell metacharacters).
2614428d7b3dSmrg      func_append_quoted args "$file"
2615428d7b3dSmrg    done
2616428d7b3dSmrg
2617428d7b3dSmrg    if test "X$opt_dry_run" = Xfalse; then
2618428d7b3dSmrg      if test -n "$shlibpath_var"; then
2619428d7b3dSmrg	# Export the shlibpath_var.
2620428d7b3dSmrg	eval "export $shlibpath_var"
2621428d7b3dSmrg      fi
2622428d7b3dSmrg
2623428d7b3dSmrg      # Restore saved environment variables
2624428d7b3dSmrg      for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
2625428d7b3dSmrg      do
2626428d7b3dSmrg	eval "if test \"\${save_$lt_var+set}\" = set; then
2627428d7b3dSmrg                $lt_var=\$save_$lt_var; export $lt_var
2628428d7b3dSmrg	      else
2629428d7b3dSmrg		$lt_unset $lt_var
2630428d7b3dSmrg	      fi"
2631428d7b3dSmrg      done
2632428d7b3dSmrg
2633428d7b3dSmrg      # Now prepare to actually exec the command.
2634428d7b3dSmrg      exec_cmd="\$cmd$args"
2635428d7b3dSmrg    else
2636428d7b3dSmrg      # Display what would be done.
2637428d7b3dSmrg      if test -n "$shlibpath_var"; then
2638428d7b3dSmrg	eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
2639428d7b3dSmrg	echo "export $shlibpath_var"
2640428d7b3dSmrg      fi
2641428d7b3dSmrg      $ECHO "$cmd$args"
2642428d7b3dSmrg      exit $EXIT_SUCCESS
2643428d7b3dSmrg    fi
2644428d7b3dSmrg}
2645428d7b3dSmrg
2646428d7b3dSmrgtest "$opt_mode" = execute && func_mode_execute ${1+"$@"}
2647428d7b3dSmrg
2648428d7b3dSmrg
2649428d7b3dSmrg# func_mode_finish arg...
2650428d7b3dSmrgfunc_mode_finish ()
2651428d7b3dSmrg{
2652428d7b3dSmrg    $opt_debug
2653428d7b3dSmrg    libs=
2654428d7b3dSmrg    libdirs=
2655428d7b3dSmrg    admincmds=
2656428d7b3dSmrg
2657428d7b3dSmrg    for opt in "$nonopt" ${1+"$@"}
2658428d7b3dSmrg    do
2659428d7b3dSmrg      if test -d "$opt"; then
2660428d7b3dSmrg	func_append libdirs " $opt"
2661428d7b3dSmrg
2662428d7b3dSmrg      elif test -f "$opt"; then
2663428d7b3dSmrg	if func_lalib_unsafe_p "$opt"; then
2664428d7b3dSmrg	  func_append libs " $opt"
2665428d7b3dSmrg	else
2666428d7b3dSmrg	  func_warning "\`$opt' is not a valid libtool archive"
2667428d7b3dSmrg	fi
2668428d7b3dSmrg
2669428d7b3dSmrg      else
2670428d7b3dSmrg	func_fatal_error "invalid argument \`$opt'"
2671428d7b3dSmrg      fi
2672428d7b3dSmrg    done
2673428d7b3dSmrg
2674428d7b3dSmrg    if test -n "$libs"; then
2675428d7b3dSmrg      if test -n "$lt_sysroot"; then
2676428d7b3dSmrg        sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"`
2677428d7b3dSmrg        sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;"
2678428d7b3dSmrg      else
2679428d7b3dSmrg        sysroot_cmd=
2680428d7b3dSmrg      fi
2681428d7b3dSmrg
2682428d7b3dSmrg      # Remove sysroot references
2683428d7b3dSmrg      if $opt_dry_run; then
2684428d7b3dSmrg        for lib in $libs; do
2685428d7b3dSmrg          echo "removing references to $lt_sysroot and \`=' prefixes from $lib"
2686428d7b3dSmrg        done
2687428d7b3dSmrg      else
2688428d7b3dSmrg        tmpdir=`func_mktempdir`
2689428d7b3dSmrg        for lib in $libs; do
2690428d7b3dSmrg	  sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
2691428d7b3dSmrg	    > $tmpdir/tmp-la
2692428d7b3dSmrg	  mv -f $tmpdir/tmp-la $lib
2693428d7b3dSmrg	done
2694428d7b3dSmrg        ${RM}r "$tmpdir"
2695428d7b3dSmrg      fi
2696428d7b3dSmrg    fi
2697428d7b3dSmrg
2698428d7b3dSmrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
2699428d7b3dSmrg      for libdir in $libdirs; do
2700428d7b3dSmrg	if test -n "$finish_cmds"; then
2701428d7b3dSmrg	  # Do each command in the finish commands.
2702428d7b3dSmrg	  func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
2703428d7b3dSmrg'"$cmd"'"'
2704428d7b3dSmrg	fi
2705428d7b3dSmrg	if test -n "$finish_eval"; then
2706428d7b3dSmrg	  # Do the single finish_eval.
2707428d7b3dSmrg	  eval cmds=\"$finish_eval\"
2708428d7b3dSmrg	  $opt_dry_run || eval "$cmds" || func_append admincmds "
2709428d7b3dSmrg       $cmds"
2710428d7b3dSmrg	fi
2711428d7b3dSmrg      done
2712428d7b3dSmrg    fi
2713428d7b3dSmrg
2714428d7b3dSmrg    # Exit here if they wanted silent mode.
2715428d7b3dSmrg    $opt_silent && exit $EXIT_SUCCESS
2716428d7b3dSmrg
2717428d7b3dSmrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
2718428d7b3dSmrg      echo "----------------------------------------------------------------------"
2719428d7b3dSmrg      echo "Libraries have been installed in:"
2720428d7b3dSmrg      for libdir in $libdirs; do
2721428d7b3dSmrg	$ECHO "   $libdir"
2722428d7b3dSmrg      done
2723428d7b3dSmrg      echo
2724428d7b3dSmrg      echo "If you ever happen to want to link against installed libraries"
2725428d7b3dSmrg      echo "in a given directory, LIBDIR, you must either use libtool, and"
2726428d7b3dSmrg      echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
2727428d7b3dSmrg      echo "flag during linking and do at least one of the following:"
2728428d7b3dSmrg      if test -n "$shlibpath_var"; then
2729428d7b3dSmrg	echo "   - add LIBDIR to the \`$shlibpath_var' environment variable"
2730428d7b3dSmrg	echo "     during execution"
2731428d7b3dSmrg      fi
2732428d7b3dSmrg      if test -n "$runpath_var"; then
2733428d7b3dSmrg	echo "   - add LIBDIR to the \`$runpath_var' environment variable"
2734428d7b3dSmrg	echo "     during linking"
2735428d7b3dSmrg      fi
2736428d7b3dSmrg      if test -n "$hardcode_libdir_flag_spec"; then
2737428d7b3dSmrg	libdir=LIBDIR
2738428d7b3dSmrg	eval flag=\"$hardcode_libdir_flag_spec\"
2739428d7b3dSmrg
2740428d7b3dSmrg	$ECHO "   - use the \`$flag' linker flag"
2741428d7b3dSmrg      fi
2742428d7b3dSmrg      if test -n "$admincmds"; then
2743428d7b3dSmrg	$ECHO "   - have your system administrator run these commands:$admincmds"
2744428d7b3dSmrg      fi
2745428d7b3dSmrg      if test -f /etc/ld.so.conf; then
2746428d7b3dSmrg	echo "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
2747428d7b3dSmrg      fi
2748428d7b3dSmrg      echo
2749428d7b3dSmrg
2750428d7b3dSmrg      echo "See any operating system documentation about shared libraries for"
2751428d7b3dSmrg      case $host in
2752428d7b3dSmrg	solaris2.[6789]|solaris2.1[0-9])
2753428d7b3dSmrg	  echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
2754428d7b3dSmrg	  echo "pages."
2755428d7b3dSmrg	  ;;
2756428d7b3dSmrg	*)
2757428d7b3dSmrg	  echo "more information, such as the ld(1) and ld.so(8) manual pages."
2758428d7b3dSmrg	  ;;
2759428d7b3dSmrg      esac
2760428d7b3dSmrg      echo "----------------------------------------------------------------------"
2761428d7b3dSmrg    fi
2762428d7b3dSmrg    exit $EXIT_SUCCESS
2763428d7b3dSmrg}
2764428d7b3dSmrg
2765428d7b3dSmrgtest "$opt_mode" = finish && func_mode_finish ${1+"$@"}
2766428d7b3dSmrg
2767428d7b3dSmrg
2768428d7b3dSmrg# func_mode_install arg...
2769428d7b3dSmrgfunc_mode_install ()
2770428d7b3dSmrg{
2771428d7b3dSmrg    $opt_debug
2772428d7b3dSmrg    # There may be an optional sh(1) argument at the beginning of
2773428d7b3dSmrg    # install_prog (especially on Windows NT).
2774428d7b3dSmrg    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
2775428d7b3dSmrg       # Allow the use of GNU shtool's install command.
2776428d7b3dSmrg       case $nonopt in *shtool*) :;; *) false;; esac; then
2777428d7b3dSmrg      # Aesthetically quote it.
2778428d7b3dSmrg      func_quote_for_eval "$nonopt"
2779428d7b3dSmrg      install_prog="$func_quote_for_eval_result "
2780428d7b3dSmrg      arg=$1
2781428d7b3dSmrg      shift
2782428d7b3dSmrg    else
2783428d7b3dSmrg      install_prog=
2784428d7b3dSmrg      arg=$nonopt
2785428d7b3dSmrg    fi
2786428d7b3dSmrg
2787428d7b3dSmrg    # The real first argument should be the name of the installation program.
2788428d7b3dSmrg    # Aesthetically quote it.
2789428d7b3dSmrg    func_quote_for_eval "$arg"
2790428d7b3dSmrg    func_append install_prog "$func_quote_for_eval_result"
2791428d7b3dSmrg    install_shared_prog=$install_prog
2792428d7b3dSmrg    case " $install_prog " in
2793428d7b3dSmrg      *[\\\ /]cp\ *) install_cp=: ;;
2794428d7b3dSmrg      *) install_cp=false ;;
2795428d7b3dSmrg    esac
2796428d7b3dSmrg
2797428d7b3dSmrg    # We need to accept at least all the BSD install flags.
2798428d7b3dSmrg    dest=
2799428d7b3dSmrg    files=
2800428d7b3dSmrg    opts=
2801428d7b3dSmrg    prev=
2802428d7b3dSmrg    install_type=
2803428d7b3dSmrg    isdir=no
2804428d7b3dSmrg    stripme=
2805428d7b3dSmrg    no_mode=:
2806428d7b3dSmrg    for arg
2807428d7b3dSmrg    do
2808428d7b3dSmrg      arg2=
2809428d7b3dSmrg      if test -n "$dest"; then
2810428d7b3dSmrg	func_append files " $dest"
2811428d7b3dSmrg	dest=$arg
2812428d7b3dSmrg	continue
2813428d7b3dSmrg      fi
2814428d7b3dSmrg
2815428d7b3dSmrg      case $arg in
2816428d7b3dSmrg      -d) isdir=yes ;;
2817428d7b3dSmrg      -f)
2818428d7b3dSmrg	if $install_cp; then :; else
2819428d7b3dSmrg	  prev=$arg
2820428d7b3dSmrg	fi
2821428d7b3dSmrg	;;
2822428d7b3dSmrg      -g | -m | -o)
2823428d7b3dSmrg	prev=$arg
2824428d7b3dSmrg	;;
2825428d7b3dSmrg      -s)
2826428d7b3dSmrg	stripme=" -s"
2827428d7b3dSmrg	continue
2828428d7b3dSmrg	;;
2829428d7b3dSmrg      -*)
2830428d7b3dSmrg	;;
2831428d7b3dSmrg      *)
2832428d7b3dSmrg	# If the previous option needed an argument, then skip it.
2833428d7b3dSmrg	if test -n "$prev"; then
2834428d7b3dSmrg	  if test "x$prev" = x-m && test -n "$install_override_mode"; then
2835428d7b3dSmrg	    arg2=$install_override_mode
2836428d7b3dSmrg	    no_mode=false
2837428d7b3dSmrg	  fi
2838428d7b3dSmrg	  prev=
2839428d7b3dSmrg	else
2840428d7b3dSmrg	  dest=$arg
2841428d7b3dSmrg	  continue
2842428d7b3dSmrg	fi
2843428d7b3dSmrg	;;
2844428d7b3dSmrg      esac
2845428d7b3dSmrg
2846428d7b3dSmrg      # Aesthetically quote the argument.
2847428d7b3dSmrg      func_quote_for_eval "$arg"
2848428d7b3dSmrg      func_append install_prog " $func_quote_for_eval_result"
2849428d7b3dSmrg      if test -n "$arg2"; then
2850428d7b3dSmrg	func_quote_for_eval "$arg2"
2851428d7b3dSmrg      fi
2852428d7b3dSmrg      func_append install_shared_prog " $func_quote_for_eval_result"
2853428d7b3dSmrg    done
2854428d7b3dSmrg
2855428d7b3dSmrg    test -z "$install_prog" && \
2856428d7b3dSmrg      func_fatal_help "you must specify an install program"
2857428d7b3dSmrg
2858428d7b3dSmrg    test -n "$prev" && \
2859428d7b3dSmrg      func_fatal_help "the \`$prev' option requires an argument"
2860428d7b3dSmrg
2861428d7b3dSmrg    if test -n "$install_override_mode" && $no_mode; then
2862428d7b3dSmrg      if $install_cp; then :; else
2863428d7b3dSmrg	func_quote_for_eval "$install_override_mode"
2864428d7b3dSmrg	func_append install_shared_prog " -m $func_quote_for_eval_result"
2865428d7b3dSmrg      fi
2866428d7b3dSmrg    fi
2867428d7b3dSmrg
2868428d7b3dSmrg    if test -z "$files"; then
2869428d7b3dSmrg      if test -z "$dest"; then
2870428d7b3dSmrg	func_fatal_help "no file or destination specified"
2871428d7b3dSmrg      else
2872428d7b3dSmrg	func_fatal_help "you must specify a destination"
2873428d7b3dSmrg      fi
2874428d7b3dSmrg    fi
2875428d7b3dSmrg
2876428d7b3dSmrg    # Strip any trailing slash from the destination.
2877428d7b3dSmrg    func_stripname '' '/' "$dest"
2878428d7b3dSmrg    dest=$func_stripname_result
2879428d7b3dSmrg
2880428d7b3dSmrg    # Check to see that the destination is a directory.
2881428d7b3dSmrg    test -d "$dest" && isdir=yes
2882428d7b3dSmrg    if test "$isdir" = yes; then
2883428d7b3dSmrg      destdir="$dest"
2884428d7b3dSmrg      destname=
2885428d7b3dSmrg    else
2886428d7b3dSmrg      func_dirname_and_basename "$dest" "" "."
2887428d7b3dSmrg      destdir="$func_dirname_result"
2888428d7b3dSmrg      destname="$func_basename_result"
2889428d7b3dSmrg
2890428d7b3dSmrg      # Not a directory, so check to see that there is only one file specified.
2891428d7b3dSmrg      set dummy $files; shift
2892428d7b3dSmrg      test "$#" -gt 1 && \
2893428d7b3dSmrg	func_fatal_help "\`$dest' is not a directory"
2894428d7b3dSmrg    fi
2895428d7b3dSmrg    case $destdir in
2896428d7b3dSmrg    [\\/]* | [A-Za-z]:[\\/]*) ;;
2897428d7b3dSmrg    *)
2898428d7b3dSmrg      for file in $files; do
2899428d7b3dSmrg	case $file in
2900428d7b3dSmrg	*.lo) ;;
2901428d7b3dSmrg	*)
2902428d7b3dSmrg	  func_fatal_help "\`$destdir' must be an absolute directory name"
2903428d7b3dSmrg	  ;;
2904428d7b3dSmrg	esac
2905428d7b3dSmrg      done
2906428d7b3dSmrg      ;;
2907428d7b3dSmrg    esac
2908428d7b3dSmrg
2909428d7b3dSmrg    # This variable tells wrapper scripts just to set variables rather
2910428d7b3dSmrg    # than running their programs.
2911428d7b3dSmrg    libtool_install_magic="$magic"
2912428d7b3dSmrg
2913428d7b3dSmrg    staticlibs=
2914428d7b3dSmrg    future_libdirs=
2915428d7b3dSmrg    current_libdirs=
2916428d7b3dSmrg    for file in $files; do
2917428d7b3dSmrg
2918428d7b3dSmrg      # Do each installation.
2919428d7b3dSmrg      case $file in
2920428d7b3dSmrg      *.$libext)
2921428d7b3dSmrg	# Do the static libraries later.
2922428d7b3dSmrg	func_append staticlibs " $file"
2923428d7b3dSmrg	;;
2924428d7b3dSmrg
2925428d7b3dSmrg      *.la)
2926428d7b3dSmrg	func_resolve_sysroot "$file"
2927428d7b3dSmrg	file=$func_resolve_sysroot_result
2928428d7b3dSmrg
2929428d7b3dSmrg	# Check to see that this really is a libtool archive.
2930428d7b3dSmrg	func_lalib_unsafe_p "$file" \
2931428d7b3dSmrg	  || func_fatal_help "\`$file' is not a valid libtool archive"
2932428d7b3dSmrg
2933428d7b3dSmrg	library_names=
2934428d7b3dSmrg	old_library=
2935428d7b3dSmrg	relink_command=
2936428d7b3dSmrg	func_source "$file"
2937428d7b3dSmrg
2938428d7b3dSmrg	# Add the libdir to current_libdirs if it is the destination.
2939428d7b3dSmrg	if test "X$destdir" = "X$libdir"; then
2940428d7b3dSmrg	  case "$current_libdirs " in
2941428d7b3dSmrg	  *" $libdir "*) ;;
2942428d7b3dSmrg	  *) func_append current_libdirs " $libdir" ;;
2943428d7b3dSmrg	  esac
2944428d7b3dSmrg	else
2945428d7b3dSmrg	  # Note the libdir as a future libdir.
2946428d7b3dSmrg	  case "$future_libdirs " in
2947428d7b3dSmrg	  *" $libdir "*) ;;
2948428d7b3dSmrg	  *) func_append future_libdirs " $libdir" ;;
2949428d7b3dSmrg	  esac
2950428d7b3dSmrg	fi
2951428d7b3dSmrg
2952428d7b3dSmrg	func_dirname "$file" "/" ""
2953428d7b3dSmrg	dir="$func_dirname_result"
2954428d7b3dSmrg	func_append dir "$objdir"
2955428d7b3dSmrg
2956428d7b3dSmrg	if test -n "$relink_command"; then
2957428d7b3dSmrg	  # Determine the prefix the user has applied to our future dir.
2958428d7b3dSmrg	  inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
2959428d7b3dSmrg
2960428d7b3dSmrg	  # Don't allow the user to place us outside of our expected
2961428d7b3dSmrg	  # location b/c this prevents finding dependent libraries that
2962428d7b3dSmrg	  # are installed to the same prefix.
2963428d7b3dSmrg	  # At present, this check doesn't affect windows .dll's that
2964428d7b3dSmrg	  # are installed into $libdir/../bin (currently, that works fine)
2965428d7b3dSmrg	  # but it's something to keep an eye on.
2966428d7b3dSmrg	  test "$inst_prefix_dir" = "$destdir" && \
2967428d7b3dSmrg	    func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
2968428d7b3dSmrg
2969428d7b3dSmrg	  if test -n "$inst_prefix_dir"; then
2970428d7b3dSmrg	    # Stick the inst_prefix_dir data into the link command.
2971428d7b3dSmrg	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
2972428d7b3dSmrg	  else
2973428d7b3dSmrg	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
2974428d7b3dSmrg	  fi
2975428d7b3dSmrg
2976428d7b3dSmrg	  func_warning "relinking \`$file'"
2977428d7b3dSmrg	  func_show_eval "$relink_command" \
2978428d7b3dSmrg	    'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
2979428d7b3dSmrg	fi
2980428d7b3dSmrg
2981428d7b3dSmrg	# See the names of the shared library.
2982428d7b3dSmrg	set dummy $library_names; shift
2983428d7b3dSmrg	if test -n "$1"; then
2984428d7b3dSmrg	  realname="$1"
2985428d7b3dSmrg	  shift
2986428d7b3dSmrg
2987428d7b3dSmrg	  srcname="$realname"
2988428d7b3dSmrg	  test -n "$relink_command" && srcname="$realname"T
2989428d7b3dSmrg
2990428d7b3dSmrg	  # Install the shared library and build the symlinks.
2991428d7b3dSmrg	  func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
2992428d7b3dSmrg	      'exit $?'
2993428d7b3dSmrg	  tstripme="$stripme"
2994428d7b3dSmrg	  case $host_os in
2995428d7b3dSmrg	  cygwin* | mingw* | pw32* | cegcc*)
2996428d7b3dSmrg	    case $realname in
2997428d7b3dSmrg	    *.dll.a)
2998428d7b3dSmrg	      tstripme=""
2999428d7b3dSmrg	      ;;
3000428d7b3dSmrg	    esac
3001428d7b3dSmrg	    ;;
3002428d7b3dSmrg	  esac
3003428d7b3dSmrg	  if test -n "$tstripme" && test -n "$striplib"; then
3004428d7b3dSmrg	    func_show_eval "$striplib $destdir/$realname" 'exit $?'
3005428d7b3dSmrg	  fi
3006428d7b3dSmrg
3007428d7b3dSmrg	  if test "$#" -gt 0; then
3008428d7b3dSmrg	    # Delete the old symlinks, and create new ones.
3009428d7b3dSmrg	    # Try `ln -sf' first, because the `ln' binary might depend on
3010428d7b3dSmrg	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
3011428d7b3dSmrg	    # so we also need to try rm && ln -s.
3012428d7b3dSmrg	    for linkname
3013428d7b3dSmrg	    do
3014428d7b3dSmrg	      test "$linkname" != "$realname" \
3015428d7b3dSmrg		&& func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
3016428d7b3dSmrg	    done
3017428d7b3dSmrg	  fi
3018428d7b3dSmrg
3019428d7b3dSmrg	  # Do each command in the postinstall commands.
3020428d7b3dSmrg	  lib="$destdir/$realname"
3021428d7b3dSmrg	  func_execute_cmds "$postinstall_cmds" 'exit $?'
3022428d7b3dSmrg	fi
3023428d7b3dSmrg
3024428d7b3dSmrg	# Install the pseudo-library for information purposes.
3025428d7b3dSmrg	func_basename "$file"
3026428d7b3dSmrg	name="$func_basename_result"
3027428d7b3dSmrg	instname="$dir/$name"i
3028428d7b3dSmrg	func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
3029428d7b3dSmrg
3030428d7b3dSmrg	# Maybe install the static library, too.
3031428d7b3dSmrg	test -n "$old_library" && func_append staticlibs " $dir/$old_library"
3032428d7b3dSmrg	;;
3033428d7b3dSmrg
3034428d7b3dSmrg      *.lo)
3035428d7b3dSmrg	# Install (i.e. copy) a libtool object.
3036428d7b3dSmrg
3037428d7b3dSmrg	# Figure out destination file name, if it wasn't already specified.
3038428d7b3dSmrg	if test -n "$destname"; then
3039428d7b3dSmrg	  destfile="$destdir/$destname"
3040428d7b3dSmrg	else
3041428d7b3dSmrg	  func_basename "$file"
3042428d7b3dSmrg	  destfile="$func_basename_result"
3043428d7b3dSmrg	  destfile="$destdir/$destfile"
3044428d7b3dSmrg	fi
3045428d7b3dSmrg
3046428d7b3dSmrg	# Deduce the name of the destination old-style object file.
3047428d7b3dSmrg	case $destfile in
3048428d7b3dSmrg	*.lo)
3049428d7b3dSmrg	  func_lo2o "$destfile"
3050428d7b3dSmrg	  staticdest=$func_lo2o_result
3051428d7b3dSmrg	  ;;
3052428d7b3dSmrg	*.$objext)
3053428d7b3dSmrg	  staticdest="$destfile"
3054428d7b3dSmrg	  destfile=
3055428d7b3dSmrg	  ;;
3056428d7b3dSmrg	*)
3057428d7b3dSmrg	  func_fatal_help "cannot copy a libtool object to \`$destfile'"
3058428d7b3dSmrg	  ;;
3059428d7b3dSmrg	esac
3060428d7b3dSmrg
3061428d7b3dSmrg	# Install the libtool object if requested.
3062428d7b3dSmrg	test -n "$destfile" && \
3063428d7b3dSmrg	  func_show_eval "$install_prog $file $destfile" 'exit $?'
3064428d7b3dSmrg
3065428d7b3dSmrg	# Install the old object if enabled.
3066428d7b3dSmrg	if test "$build_old_libs" = yes; then
3067428d7b3dSmrg	  # Deduce the name of the old-style object file.
3068428d7b3dSmrg	  func_lo2o "$file"
3069428d7b3dSmrg	  staticobj=$func_lo2o_result
3070428d7b3dSmrg	  func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
3071428d7b3dSmrg	fi
3072428d7b3dSmrg	exit $EXIT_SUCCESS
3073428d7b3dSmrg	;;
3074428d7b3dSmrg
3075428d7b3dSmrg      *)
3076428d7b3dSmrg	# Figure out destination file name, if it wasn't already specified.
3077428d7b3dSmrg	if test -n "$destname"; then
3078428d7b3dSmrg	  destfile="$destdir/$destname"
3079428d7b3dSmrg	else
3080428d7b3dSmrg	  func_basename "$file"
3081428d7b3dSmrg	  destfile="$func_basename_result"
3082428d7b3dSmrg	  destfile="$destdir/$destfile"
3083428d7b3dSmrg	fi
3084428d7b3dSmrg
3085428d7b3dSmrg	# If the file is missing, and there is a .exe on the end, strip it
3086428d7b3dSmrg	# because it is most likely a libtool script we actually want to
3087428d7b3dSmrg	# install
3088428d7b3dSmrg	stripped_ext=""
3089428d7b3dSmrg	case $file in
3090428d7b3dSmrg	  *.exe)
3091428d7b3dSmrg	    if test ! -f "$file"; then
3092428d7b3dSmrg	      func_stripname '' '.exe' "$file"
3093428d7b3dSmrg	      file=$func_stripname_result
3094428d7b3dSmrg	      stripped_ext=".exe"
3095428d7b3dSmrg	    fi
3096428d7b3dSmrg	    ;;
3097428d7b3dSmrg	esac
3098428d7b3dSmrg
3099428d7b3dSmrg	# Do a test to see if this is really a libtool program.
3100428d7b3dSmrg	case $host in
3101428d7b3dSmrg	*cygwin* | *mingw*)
3102428d7b3dSmrg	    if func_ltwrapper_executable_p "$file"; then
3103428d7b3dSmrg	      func_ltwrapper_scriptname "$file"
3104428d7b3dSmrg	      wrapper=$func_ltwrapper_scriptname_result
3105428d7b3dSmrg	    else
3106428d7b3dSmrg	      func_stripname '' '.exe' "$file"
3107428d7b3dSmrg	      wrapper=$func_stripname_result
3108428d7b3dSmrg	    fi
3109428d7b3dSmrg	    ;;
3110428d7b3dSmrg	*)
3111428d7b3dSmrg	    wrapper=$file
3112428d7b3dSmrg	    ;;
3113428d7b3dSmrg	esac
3114428d7b3dSmrg	if func_ltwrapper_script_p "$wrapper"; then
3115428d7b3dSmrg	  notinst_deplibs=
3116428d7b3dSmrg	  relink_command=
3117428d7b3dSmrg
3118428d7b3dSmrg	  func_source "$wrapper"
3119428d7b3dSmrg
3120428d7b3dSmrg	  # Check the variables that should have been set.
3121428d7b3dSmrg	  test -z "$generated_by_libtool_version" && \
3122428d7b3dSmrg	    func_fatal_error "invalid libtool wrapper script \`$wrapper'"
3123428d7b3dSmrg
3124428d7b3dSmrg	  finalize=yes
3125428d7b3dSmrg	  for lib in $notinst_deplibs; do
3126428d7b3dSmrg	    # Check to see that each library is installed.
3127428d7b3dSmrg	    libdir=
3128428d7b3dSmrg	    if test -f "$lib"; then
3129428d7b3dSmrg	      func_source "$lib"
3130428d7b3dSmrg	    fi
3131428d7b3dSmrg	    libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test
3132428d7b3dSmrg	    if test -n "$libdir" && test ! -f "$libfile"; then
3133428d7b3dSmrg	      func_warning "\`$lib' has not been installed in \`$libdir'"
3134428d7b3dSmrg	      finalize=no
3135428d7b3dSmrg	    fi
3136428d7b3dSmrg	  done
3137428d7b3dSmrg
3138428d7b3dSmrg	  relink_command=
3139428d7b3dSmrg	  func_source "$wrapper"
3140428d7b3dSmrg
3141428d7b3dSmrg	  outputname=
3142428d7b3dSmrg	  if test "$fast_install" = no && test -n "$relink_command"; then
3143428d7b3dSmrg	    $opt_dry_run || {
3144428d7b3dSmrg	      if test "$finalize" = yes; then
3145428d7b3dSmrg	        tmpdir=`func_mktempdir`
3146428d7b3dSmrg		func_basename "$file$stripped_ext"
3147428d7b3dSmrg		file="$func_basename_result"
3148428d7b3dSmrg	        outputname="$tmpdir/$file"
3149428d7b3dSmrg	        # Replace the output file specification.
3150428d7b3dSmrg	        relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
3151428d7b3dSmrg
3152428d7b3dSmrg	        $opt_silent || {
3153428d7b3dSmrg	          func_quote_for_expand "$relink_command"
3154428d7b3dSmrg		  eval "func_echo $func_quote_for_expand_result"
3155428d7b3dSmrg	        }
3156428d7b3dSmrg	        if eval "$relink_command"; then :
3157428d7b3dSmrg	          else
3158428d7b3dSmrg		  func_error "error: relink \`$file' with the above command before installing it"
3159428d7b3dSmrg		  $opt_dry_run || ${RM}r "$tmpdir"
3160428d7b3dSmrg		  continue
3161428d7b3dSmrg	        fi
3162428d7b3dSmrg	        file="$outputname"
3163428d7b3dSmrg	      else
3164428d7b3dSmrg	        func_warning "cannot relink \`$file'"
3165428d7b3dSmrg	      fi
3166428d7b3dSmrg	    }
3167428d7b3dSmrg	  else
3168428d7b3dSmrg	    # Install the binary that we compiled earlier.
3169428d7b3dSmrg	    file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
3170428d7b3dSmrg	  fi
3171428d7b3dSmrg	fi
3172428d7b3dSmrg
3173428d7b3dSmrg	# remove .exe since cygwin /usr/bin/install will append another
3174428d7b3dSmrg	# one anyway
3175428d7b3dSmrg	case $install_prog,$host in
3176428d7b3dSmrg	*/usr/bin/install*,*cygwin*)
3177428d7b3dSmrg	  case $file:$destfile in
3178428d7b3dSmrg	  *.exe:*.exe)
3179428d7b3dSmrg	    # this is ok
3180428d7b3dSmrg	    ;;
3181428d7b3dSmrg	  *.exe:*)
3182428d7b3dSmrg	    destfile=$destfile.exe
3183428d7b3dSmrg	    ;;
3184428d7b3dSmrg	  *:*.exe)
3185428d7b3dSmrg	    func_stripname '' '.exe' "$destfile"
3186428d7b3dSmrg	    destfile=$func_stripname_result
3187428d7b3dSmrg	    ;;
3188428d7b3dSmrg	  esac
3189428d7b3dSmrg	  ;;
3190428d7b3dSmrg	esac
3191428d7b3dSmrg	func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
3192428d7b3dSmrg	$opt_dry_run || if test -n "$outputname"; then
3193428d7b3dSmrg	  ${RM}r "$tmpdir"
3194428d7b3dSmrg	fi
3195428d7b3dSmrg	;;
3196428d7b3dSmrg      esac
3197428d7b3dSmrg    done
3198428d7b3dSmrg
3199428d7b3dSmrg    for file in $staticlibs; do
3200428d7b3dSmrg      func_basename "$file"
3201428d7b3dSmrg      name="$func_basename_result"
3202428d7b3dSmrg
3203428d7b3dSmrg      # Set up the ranlib parameters.
3204428d7b3dSmrg      oldlib="$destdir/$name"
3205428d7b3dSmrg      func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
3206428d7b3dSmrg      tool_oldlib=$func_to_tool_file_result
3207428d7b3dSmrg
3208428d7b3dSmrg      func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
3209428d7b3dSmrg
3210428d7b3dSmrg      if test -n "$stripme" && test -n "$old_striplib"; then
3211428d7b3dSmrg	func_show_eval "$old_striplib $tool_oldlib" 'exit $?'
3212428d7b3dSmrg      fi
3213428d7b3dSmrg
3214428d7b3dSmrg      # Do each command in the postinstall commands.
3215428d7b3dSmrg      func_execute_cmds "$old_postinstall_cmds" 'exit $?'
3216428d7b3dSmrg    done
3217428d7b3dSmrg
3218428d7b3dSmrg    test -n "$future_libdirs" && \
3219428d7b3dSmrg      func_warning "remember to run \`$progname --finish$future_libdirs'"
3220428d7b3dSmrg
3221428d7b3dSmrg    if test -n "$current_libdirs"; then
3222428d7b3dSmrg      # Maybe just do a dry run.
3223428d7b3dSmrg      $opt_dry_run && current_libdirs=" -n$current_libdirs"
3224428d7b3dSmrg      exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
3225428d7b3dSmrg    else
3226428d7b3dSmrg      exit $EXIT_SUCCESS
3227428d7b3dSmrg    fi
3228428d7b3dSmrg}
3229428d7b3dSmrg
3230428d7b3dSmrgtest "$opt_mode" = install && func_mode_install ${1+"$@"}
3231428d7b3dSmrg
3232428d7b3dSmrg
3233428d7b3dSmrg# func_generate_dlsyms outputname originator pic_p
3234428d7b3dSmrg# Extract symbols from dlprefiles and create ${outputname}S.o with
3235428d7b3dSmrg# a dlpreopen symbol table.
3236428d7b3dSmrgfunc_generate_dlsyms ()
3237428d7b3dSmrg{
3238428d7b3dSmrg    $opt_debug
3239428d7b3dSmrg    my_outputname="$1"
3240428d7b3dSmrg    my_originator="$2"
3241428d7b3dSmrg    my_pic_p="${3-no}"
3242428d7b3dSmrg    my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'`
3243428d7b3dSmrg    my_dlsyms=
3244428d7b3dSmrg
3245428d7b3dSmrg    if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
3246428d7b3dSmrg      if test -n "$NM" && test -n "$global_symbol_pipe"; then
3247428d7b3dSmrg	my_dlsyms="${my_outputname}S.c"
3248428d7b3dSmrg      else
3249428d7b3dSmrg	func_error "not configured to extract global symbols from dlpreopened files"
3250428d7b3dSmrg      fi
3251428d7b3dSmrg    fi
3252428d7b3dSmrg
3253428d7b3dSmrg    if test -n "$my_dlsyms"; then
3254428d7b3dSmrg      case $my_dlsyms in
3255428d7b3dSmrg      "") ;;
3256428d7b3dSmrg      *.c)
3257428d7b3dSmrg	# Discover the nlist of each of the dlfiles.
3258428d7b3dSmrg	nlist="$output_objdir/${my_outputname}.nm"
3259428d7b3dSmrg
3260428d7b3dSmrg	func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
3261428d7b3dSmrg
3262428d7b3dSmrg	# Parse the name list into a source file.
3263428d7b3dSmrg	func_verbose "creating $output_objdir/$my_dlsyms"
3264428d7b3dSmrg
3265428d7b3dSmrg	$opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
3266428d7b3dSmrg/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */
3267428d7b3dSmrg/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */
3268428d7b3dSmrg
3269428d7b3dSmrg#ifdef __cplusplus
3270428d7b3dSmrgextern \"C\" {
3271428d7b3dSmrg#endif
3272428d7b3dSmrg
3273428d7b3dSmrg#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
3274428d7b3dSmrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
3275428d7b3dSmrg#endif
3276428d7b3dSmrg
3277428d7b3dSmrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
3278428d7b3dSmrg#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
3279428d7b3dSmrg/* DATA imports from DLLs on WIN32 con't be const, because runtime
3280428d7b3dSmrg   relocations are performed -- see ld's documentation on pseudo-relocs.  */
3281428d7b3dSmrg# define LT_DLSYM_CONST
3282428d7b3dSmrg#elif defined(__osf__)
3283428d7b3dSmrg/* This system does not cope well with relocations in const data.  */
3284428d7b3dSmrg# define LT_DLSYM_CONST
3285428d7b3dSmrg#else
3286428d7b3dSmrg# define LT_DLSYM_CONST const
3287428d7b3dSmrg#endif
3288428d7b3dSmrg
3289428d7b3dSmrg/* External symbol declarations for the compiler. */\
3290428d7b3dSmrg"
3291428d7b3dSmrg
3292428d7b3dSmrg	if test "$dlself" = yes; then
3293428d7b3dSmrg	  func_verbose "generating symbol list for \`$output'"
3294428d7b3dSmrg
3295428d7b3dSmrg	  $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
3296428d7b3dSmrg
3297428d7b3dSmrg	  # Add our own program objects to the symbol list.
3298428d7b3dSmrg	  progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
3299428d7b3dSmrg	  for progfile in $progfiles; do
3300428d7b3dSmrg	    func_to_tool_file "$progfile" func_convert_file_msys_to_w32
3301428d7b3dSmrg	    func_verbose "extracting global C symbols from \`$func_to_tool_file_result'"
3302428d7b3dSmrg	    $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
3303428d7b3dSmrg	  done
3304428d7b3dSmrg
3305428d7b3dSmrg	  if test -n "$exclude_expsyms"; then
3306428d7b3dSmrg	    $opt_dry_run || {
3307428d7b3dSmrg	      eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
3308428d7b3dSmrg	      eval '$MV "$nlist"T "$nlist"'
3309428d7b3dSmrg	    }
3310428d7b3dSmrg	  fi
3311428d7b3dSmrg
3312428d7b3dSmrg	  if test -n "$export_symbols_regex"; then
3313428d7b3dSmrg	    $opt_dry_run || {
3314428d7b3dSmrg	      eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
3315428d7b3dSmrg	      eval '$MV "$nlist"T "$nlist"'
3316428d7b3dSmrg	    }
3317428d7b3dSmrg	  fi
3318428d7b3dSmrg
3319428d7b3dSmrg	  # Prepare the list of exported symbols
3320428d7b3dSmrg	  if test -z "$export_symbols"; then
3321428d7b3dSmrg	    export_symbols="$output_objdir/$outputname.exp"
3322428d7b3dSmrg	    $opt_dry_run || {
3323428d7b3dSmrg	      $RM $export_symbols
3324428d7b3dSmrg	      eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
3325428d7b3dSmrg	      case $host in
3326428d7b3dSmrg	      *cygwin* | *mingw* | *cegcc* )
3327428d7b3dSmrg                eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
3328428d7b3dSmrg                eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
3329428d7b3dSmrg	        ;;
3330428d7b3dSmrg	      esac
3331428d7b3dSmrg	    }
3332428d7b3dSmrg	  else
3333428d7b3dSmrg	    $opt_dry_run || {
3334428d7b3dSmrg	      eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
3335428d7b3dSmrg	      eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
3336428d7b3dSmrg	      eval '$MV "$nlist"T "$nlist"'
3337428d7b3dSmrg	      case $host in
3338428d7b3dSmrg	        *cygwin* | *mingw* | *cegcc* )
3339428d7b3dSmrg	          eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
3340428d7b3dSmrg	          eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
3341428d7b3dSmrg	          ;;
3342428d7b3dSmrg	      esac
3343428d7b3dSmrg	    }
3344428d7b3dSmrg	  fi
3345428d7b3dSmrg	fi
3346428d7b3dSmrg
3347428d7b3dSmrg	for dlprefile in $dlprefiles; do
3348428d7b3dSmrg	  func_verbose "extracting global C symbols from \`$dlprefile'"
3349428d7b3dSmrg	  func_basename "$dlprefile"
3350428d7b3dSmrg	  name="$func_basename_result"
3351428d7b3dSmrg          case $host in
3352428d7b3dSmrg	    *cygwin* | *mingw* | *cegcc* )
3353428d7b3dSmrg	      # if an import library, we need to obtain dlname
3354428d7b3dSmrg	      if func_win32_import_lib_p "$dlprefile"; then
3355428d7b3dSmrg	        func_tr_sh "$dlprefile"
3356428d7b3dSmrg	        eval "curr_lafile=\$libfile_$func_tr_sh_result"
3357428d7b3dSmrg	        dlprefile_dlbasename=""
3358428d7b3dSmrg	        if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
3359428d7b3dSmrg	          # Use subshell, to avoid clobbering current variable values
3360428d7b3dSmrg	          dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
3361428d7b3dSmrg	          if test -n "$dlprefile_dlname" ; then
3362428d7b3dSmrg	            func_basename "$dlprefile_dlname"
3363428d7b3dSmrg	            dlprefile_dlbasename="$func_basename_result"
3364428d7b3dSmrg	          else
3365428d7b3dSmrg	            # no lafile. user explicitly requested -dlpreopen <import library>.
3366428d7b3dSmrg	            $sharedlib_from_linklib_cmd "$dlprefile"
3367428d7b3dSmrg	            dlprefile_dlbasename=$sharedlib_from_linklib_result
3368428d7b3dSmrg	          fi
3369428d7b3dSmrg	        fi
3370428d7b3dSmrg	        $opt_dry_run || {
3371428d7b3dSmrg	          if test -n "$dlprefile_dlbasename" ; then
3372428d7b3dSmrg	            eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
3373428d7b3dSmrg	          else
3374428d7b3dSmrg	            func_warning "Could not compute DLL name from $name"
3375428d7b3dSmrg	            eval '$ECHO ": $name " >> "$nlist"'
3376428d7b3dSmrg	          fi
3377428d7b3dSmrg	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
3378428d7b3dSmrg	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe |
3379428d7b3dSmrg	            $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'"
3380428d7b3dSmrg	        }
3381428d7b3dSmrg	      else # not an import lib
3382428d7b3dSmrg	        $opt_dry_run || {
3383428d7b3dSmrg	          eval '$ECHO ": $name " >> "$nlist"'
3384428d7b3dSmrg	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
3385428d7b3dSmrg	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
3386428d7b3dSmrg	        }
3387428d7b3dSmrg	      fi
3388428d7b3dSmrg	    ;;
3389428d7b3dSmrg	    *)
3390428d7b3dSmrg	      $opt_dry_run || {
3391428d7b3dSmrg	        eval '$ECHO ": $name " >> "$nlist"'
3392428d7b3dSmrg	        func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
3393428d7b3dSmrg	        eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
3394428d7b3dSmrg	      }
3395428d7b3dSmrg	    ;;
3396428d7b3dSmrg          esac
3397428d7b3dSmrg	done
3398428d7b3dSmrg
3399428d7b3dSmrg	$opt_dry_run || {
3400428d7b3dSmrg	  # Make sure we have at least an empty file.
3401428d7b3dSmrg	  test -f "$nlist" || : > "$nlist"
3402428d7b3dSmrg
3403428d7b3dSmrg	  if test -n "$exclude_expsyms"; then
3404428d7b3dSmrg	    $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
3405428d7b3dSmrg	    $MV "$nlist"T "$nlist"
3406428d7b3dSmrg	  fi
3407428d7b3dSmrg
3408428d7b3dSmrg	  # Try sorting and uniquifying the output.
3409428d7b3dSmrg	  if $GREP -v "^: " < "$nlist" |
3410428d7b3dSmrg	      if sort -k 3 </dev/null >/dev/null 2>&1; then
3411428d7b3dSmrg		sort -k 3
3412428d7b3dSmrg	      else
3413428d7b3dSmrg		sort +2
3414428d7b3dSmrg	      fi |
3415428d7b3dSmrg	      uniq > "$nlist"S; then
3416428d7b3dSmrg	    :
3417428d7b3dSmrg	  else
3418428d7b3dSmrg	    $GREP -v "^: " < "$nlist" > "$nlist"S
3419428d7b3dSmrg	  fi
3420428d7b3dSmrg
3421428d7b3dSmrg	  if test -f "$nlist"S; then
3422428d7b3dSmrg	    eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
3423428d7b3dSmrg	  else
3424428d7b3dSmrg	    echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
3425428d7b3dSmrg	  fi
3426428d7b3dSmrg
3427428d7b3dSmrg	  echo >> "$output_objdir/$my_dlsyms" "\
3428428d7b3dSmrg
3429428d7b3dSmrg/* The mapping between symbol names and symbols.  */
3430428d7b3dSmrgtypedef struct {
3431428d7b3dSmrg  const char *name;
3432428d7b3dSmrg  void *address;
3433428d7b3dSmrg} lt_dlsymlist;
3434428d7b3dSmrgextern LT_DLSYM_CONST lt_dlsymlist
3435428d7b3dSmrglt_${my_prefix}_LTX_preloaded_symbols[];
3436428d7b3dSmrgLT_DLSYM_CONST lt_dlsymlist
3437428d7b3dSmrglt_${my_prefix}_LTX_preloaded_symbols[] =
3438428d7b3dSmrg{\
3439428d7b3dSmrg  { \"$my_originator\", (void *) 0 },"
3440428d7b3dSmrg
3441428d7b3dSmrg	  case $need_lib_prefix in
3442428d7b3dSmrg	  no)
3443428d7b3dSmrg	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
3444428d7b3dSmrg	    ;;
3445428d7b3dSmrg	  *)
3446428d7b3dSmrg	    eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
3447428d7b3dSmrg	    ;;
3448428d7b3dSmrg	  esac
3449428d7b3dSmrg	  echo >> "$output_objdir/$my_dlsyms" "\
3450428d7b3dSmrg  {0, (void *) 0}
3451428d7b3dSmrg};
3452428d7b3dSmrg
3453428d7b3dSmrg/* This works around a problem in FreeBSD linker */
3454428d7b3dSmrg#ifdef FREEBSD_WORKAROUND
3455428d7b3dSmrgstatic const void *lt_preloaded_setup() {
3456428d7b3dSmrg  return lt_${my_prefix}_LTX_preloaded_symbols;
3457428d7b3dSmrg}
3458428d7b3dSmrg#endif
3459428d7b3dSmrg
3460428d7b3dSmrg#ifdef __cplusplus
3461428d7b3dSmrg}
3462428d7b3dSmrg#endif\
3463428d7b3dSmrg"
3464428d7b3dSmrg	} # !$opt_dry_run
3465428d7b3dSmrg
3466428d7b3dSmrg	pic_flag_for_symtable=
3467428d7b3dSmrg	case "$compile_command " in
3468428d7b3dSmrg	*" -static "*) ;;
3469428d7b3dSmrg	*)
3470428d7b3dSmrg	  case $host in
3471428d7b3dSmrg	  # compiling the symbol table file with pic_flag works around
3472428d7b3dSmrg	  # a FreeBSD bug that causes programs to crash when -lm is
3473428d7b3dSmrg	  # linked before any other PIC object.  But we must not use
3474428d7b3dSmrg	  # pic_flag when linking with -static.  The problem exists in
3475428d7b3dSmrg	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
3476428d7b3dSmrg	  *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
3477428d7b3dSmrg	    pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
3478428d7b3dSmrg	  *-*-hpux*)
3479428d7b3dSmrg	    pic_flag_for_symtable=" $pic_flag"  ;;
3480428d7b3dSmrg	  *)
3481428d7b3dSmrg	    if test "X$my_pic_p" != Xno; then
3482428d7b3dSmrg	      pic_flag_for_symtable=" $pic_flag"
3483428d7b3dSmrg	    fi
3484428d7b3dSmrg	    ;;
3485428d7b3dSmrg	  esac
3486428d7b3dSmrg	  ;;
3487428d7b3dSmrg	esac
3488428d7b3dSmrg	symtab_cflags=
3489428d7b3dSmrg	for arg in $LTCFLAGS; do
3490428d7b3dSmrg	  case $arg in
3491428d7b3dSmrg	  -pie | -fpie | -fPIE) ;;
3492428d7b3dSmrg	  *) func_append symtab_cflags " $arg" ;;
3493428d7b3dSmrg	  esac
3494428d7b3dSmrg	done
3495428d7b3dSmrg
3496428d7b3dSmrg	# Now compile the dynamic symbol file.
3497428d7b3dSmrg	func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
3498428d7b3dSmrg
3499428d7b3dSmrg	# Clean up the generated files.
3500428d7b3dSmrg	func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"'
3501428d7b3dSmrg
3502428d7b3dSmrg	# Transform the symbol file into the correct name.
3503428d7b3dSmrg	symfileobj="$output_objdir/${my_outputname}S.$objext"
3504428d7b3dSmrg	case $host in
3505428d7b3dSmrg	*cygwin* | *mingw* | *cegcc* )
3506428d7b3dSmrg	  if test -f "$output_objdir/$my_outputname.def"; then
3507428d7b3dSmrg	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
3508428d7b3dSmrg	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
3509428d7b3dSmrg	  else
3510428d7b3dSmrg	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3511428d7b3dSmrg	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3512428d7b3dSmrg	  fi
3513428d7b3dSmrg	  ;;
3514428d7b3dSmrg	*)
3515428d7b3dSmrg	  compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3516428d7b3dSmrg	  finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3517428d7b3dSmrg	  ;;
3518428d7b3dSmrg	esac
3519428d7b3dSmrg	;;
3520428d7b3dSmrg      *)
3521428d7b3dSmrg	func_fatal_error "unknown suffix for \`$my_dlsyms'"
3522428d7b3dSmrg	;;
3523428d7b3dSmrg      esac
3524428d7b3dSmrg    else
3525428d7b3dSmrg      # We keep going just in case the user didn't refer to
3526428d7b3dSmrg      # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
3527428d7b3dSmrg      # really was required.
3528428d7b3dSmrg
3529428d7b3dSmrg      # Nullify the symbol file.
3530428d7b3dSmrg      compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
3531428d7b3dSmrg      finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
3532428d7b3dSmrg    fi
3533428d7b3dSmrg}
3534428d7b3dSmrg
3535428d7b3dSmrg# func_win32_libid arg
3536428d7b3dSmrg# return the library type of file 'arg'
3537428d7b3dSmrg#
3538428d7b3dSmrg# Need a lot of goo to handle *both* DLLs and import libs
3539428d7b3dSmrg# Has to be a shell function in order to 'eat' the argument
3540428d7b3dSmrg# that is supplied when $file_magic_command is called.
3541428d7b3dSmrg# Despite the name, also deal with 64 bit binaries.
3542428d7b3dSmrgfunc_win32_libid ()
3543428d7b3dSmrg{
3544428d7b3dSmrg  $opt_debug
3545428d7b3dSmrg  win32_libid_type="unknown"
3546428d7b3dSmrg  win32_fileres=`file -L $1 2>/dev/null`
3547428d7b3dSmrg  case $win32_fileres in
3548428d7b3dSmrg  *ar\ archive\ import\ library*) # definitely import
3549428d7b3dSmrg    win32_libid_type="x86 archive import"
3550428d7b3dSmrg    ;;
3551428d7b3dSmrg  *ar\ archive*) # could be an import, or static
3552428d7b3dSmrg    # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
3553428d7b3dSmrg    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
3554428d7b3dSmrg       $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
3555428d7b3dSmrg      func_to_tool_file "$1" func_convert_file_msys_to_w32
3556428d7b3dSmrg      win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
3557428d7b3dSmrg	$SED -n -e '
3558428d7b3dSmrg	    1,100{
3559428d7b3dSmrg		/ I /{
3560428d7b3dSmrg		    s,.*,import,
3561428d7b3dSmrg		    p
3562428d7b3dSmrg		    q
3563428d7b3dSmrg		}
3564428d7b3dSmrg	    }'`
3565428d7b3dSmrg      case $win32_nmres in
3566428d7b3dSmrg      import*)  win32_libid_type="x86 archive import";;
3567428d7b3dSmrg      *)        win32_libid_type="x86 archive static";;
3568428d7b3dSmrg      esac
3569428d7b3dSmrg    fi
3570428d7b3dSmrg    ;;
3571428d7b3dSmrg  *DLL*)
3572428d7b3dSmrg    win32_libid_type="x86 DLL"
3573428d7b3dSmrg    ;;
3574428d7b3dSmrg  *executable*) # but shell scripts are "executable" too...
3575428d7b3dSmrg    case $win32_fileres in
3576428d7b3dSmrg    *MS\ Windows\ PE\ Intel*)
3577428d7b3dSmrg      win32_libid_type="x86 DLL"
3578428d7b3dSmrg      ;;
3579428d7b3dSmrg    esac
3580428d7b3dSmrg    ;;
3581428d7b3dSmrg  esac
3582428d7b3dSmrg  $ECHO "$win32_libid_type"
3583428d7b3dSmrg}
3584428d7b3dSmrg
3585428d7b3dSmrg# func_cygming_dll_for_implib ARG
3586428d7b3dSmrg#
3587428d7b3dSmrg# Platform-specific function to extract the
3588428d7b3dSmrg# name of the DLL associated with the specified
3589428d7b3dSmrg# import library ARG.
3590428d7b3dSmrg# Invoked by eval'ing the libtool variable
3591428d7b3dSmrg#    $sharedlib_from_linklib_cmd
3592428d7b3dSmrg# Result is available in the variable
3593428d7b3dSmrg#    $sharedlib_from_linklib_result
3594428d7b3dSmrgfunc_cygming_dll_for_implib ()
3595428d7b3dSmrg{
3596428d7b3dSmrg  $opt_debug
3597428d7b3dSmrg  sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
3598428d7b3dSmrg}
3599428d7b3dSmrg
3600428d7b3dSmrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs
3601428d7b3dSmrg#
3602428d7b3dSmrg# The is the core of a fallback implementation of a
3603428d7b3dSmrg# platform-specific function to extract the name of the
3604428d7b3dSmrg# DLL associated with the specified import library LIBNAME.
3605428d7b3dSmrg#
3606428d7b3dSmrg# SECTION_NAME is either .idata$6 or .idata$7, depending
3607428d7b3dSmrg# on the platform and compiler that created the implib.
3608428d7b3dSmrg#
3609428d7b3dSmrg# Echos the name of the DLL associated with the
3610428d7b3dSmrg# specified import library.
3611428d7b3dSmrgfunc_cygming_dll_for_implib_fallback_core ()
3612428d7b3dSmrg{
3613428d7b3dSmrg  $opt_debug
3614428d7b3dSmrg  match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
3615428d7b3dSmrg  $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
3616428d7b3dSmrg    $SED '/^Contents of section '"$match_literal"':/{
3617428d7b3dSmrg      # Place marker at beginning of archive member dllname section
3618428d7b3dSmrg      s/.*/====MARK====/
3619428d7b3dSmrg      p
3620428d7b3dSmrg      d
3621428d7b3dSmrg    }
3622428d7b3dSmrg    # These lines can sometimes be longer than 43 characters, but
3623428d7b3dSmrg    # are always uninteresting
3624428d7b3dSmrg    /:[	 ]*file format pe[i]\{,1\}-/d
3625428d7b3dSmrg    /^In archive [^:]*:/d
3626428d7b3dSmrg    # Ensure marker is printed
3627428d7b3dSmrg    /^====MARK====/p
3628428d7b3dSmrg    # Remove all lines with less than 43 characters
3629428d7b3dSmrg    /^.\{43\}/!d
3630428d7b3dSmrg    # From remaining lines, remove first 43 characters
3631428d7b3dSmrg    s/^.\{43\}//' |
3632428d7b3dSmrg    $SED -n '
3633428d7b3dSmrg      # Join marker and all lines until next marker into a single line
3634428d7b3dSmrg      /^====MARK====/ b para
3635428d7b3dSmrg      H
3636428d7b3dSmrg      $ b para
3637428d7b3dSmrg      b
3638428d7b3dSmrg      :para
3639428d7b3dSmrg      x
3640428d7b3dSmrg      s/\n//g
3641428d7b3dSmrg      # Remove the marker
3642428d7b3dSmrg      s/^====MARK====//
3643428d7b3dSmrg      # Remove trailing dots and whitespace
3644428d7b3dSmrg      s/[\. \t]*$//
3645428d7b3dSmrg      # Print
3646428d7b3dSmrg      /./p' |
3647428d7b3dSmrg    # we now have a list, one entry per line, of the stringified
3648428d7b3dSmrg    # contents of the appropriate section of all members of the
3649428d7b3dSmrg    # archive which possess that section. Heuristic: eliminate
3650428d7b3dSmrg    # all those which have a first or second character that is
3651428d7b3dSmrg    # a '.' (that is, objdump's representation of an unprintable
3652428d7b3dSmrg    # character.) This should work for all archives with less than
3653428d7b3dSmrg    # 0x302f exports -- but will fail for DLLs whose name actually
3654428d7b3dSmrg    # begins with a literal '.' or a single character followed by
3655428d7b3dSmrg    # a '.'.
3656428d7b3dSmrg    #
3657428d7b3dSmrg    # Of those that remain, print the first one.
3658428d7b3dSmrg    $SED -e '/^\./d;/^.\./d;q'
3659428d7b3dSmrg}
3660428d7b3dSmrg
3661428d7b3dSmrg# func_cygming_gnu_implib_p ARG
3662428d7b3dSmrg# This predicate returns with zero status (TRUE) if
3663428d7b3dSmrg# ARG is a GNU/binutils-style import library. Returns
3664428d7b3dSmrg# with nonzero status (FALSE) otherwise.
3665428d7b3dSmrgfunc_cygming_gnu_implib_p ()
3666428d7b3dSmrg{
3667428d7b3dSmrg  $opt_debug
3668428d7b3dSmrg  func_to_tool_file "$1" func_convert_file_msys_to_w32
3669428d7b3dSmrg  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)$'`
3670428d7b3dSmrg  test -n "$func_cygming_gnu_implib_tmp"
3671428d7b3dSmrg}
3672428d7b3dSmrg
3673428d7b3dSmrg# func_cygming_ms_implib_p ARG
3674428d7b3dSmrg# This predicate returns with zero status (TRUE) if
3675428d7b3dSmrg# ARG is an MS-style import library. Returns
3676428d7b3dSmrg# with nonzero status (FALSE) otherwise.
3677428d7b3dSmrgfunc_cygming_ms_implib_p ()
3678428d7b3dSmrg{
3679428d7b3dSmrg  $opt_debug
3680428d7b3dSmrg  func_to_tool_file "$1" func_convert_file_msys_to_w32
3681428d7b3dSmrg  func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
3682428d7b3dSmrg  test -n "$func_cygming_ms_implib_tmp"
3683428d7b3dSmrg}
3684428d7b3dSmrg
3685428d7b3dSmrg# func_cygming_dll_for_implib_fallback ARG
3686428d7b3dSmrg# Platform-specific function to extract the
3687428d7b3dSmrg# name of the DLL associated with the specified
3688428d7b3dSmrg# import library ARG.
3689428d7b3dSmrg#
3690428d7b3dSmrg# This fallback implementation is for use when $DLLTOOL
3691428d7b3dSmrg# does not support the --identify-strict option.
3692428d7b3dSmrg# Invoked by eval'ing the libtool variable
3693428d7b3dSmrg#    $sharedlib_from_linklib_cmd
3694428d7b3dSmrg# Result is available in the variable
3695428d7b3dSmrg#    $sharedlib_from_linklib_result
3696428d7b3dSmrgfunc_cygming_dll_for_implib_fallback ()
3697428d7b3dSmrg{
3698428d7b3dSmrg  $opt_debug
3699428d7b3dSmrg  if func_cygming_gnu_implib_p "$1" ; then
3700428d7b3dSmrg    # binutils import library
3701428d7b3dSmrg    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
3702428d7b3dSmrg  elif func_cygming_ms_implib_p "$1" ; then
3703428d7b3dSmrg    # ms-generated import library
3704428d7b3dSmrg    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
3705428d7b3dSmrg  else
3706428d7b3dSmrg    # unknown
3707428d7b3dSmrg    sharedlib_from_linklib_result=""
3708428d7b3dSmrg  fi
3709428d7b3dSmrg}
3710428d7b3dSmrg
3711428d7b3dSmrg
3712428d7b3dSmrg# func_extract_an_archive dir oldlib
3713428d7b3dSmrgfunc_extract_an_archive ()
3714428d7b3dSmrg{
3715428d7b3dSmrg    $opt_debug
3716428d7b3dSmrg    f_ex_an_ar_dir="$1"; shift
3717428d7b3dSmrg    f_ex_an_ar_oldlib="$1"
3718428d7b3dSmrg    if test "$lock_old_archive_extraction" = yes; then
3719428d7b3dSmrg      lockfile=$f_ex_an_ar_oldlib.lock
3720428d7b3dSmrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
3721428d7b3dSmrg	func_echo "Waiting for $lockfile to be removed"
3722428d7b3dSmrg	sleep 2
3723428d7b3dSmrg      done
3724428d7b3dSmrg    fi
3725428d7b3dSmrg    func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
3726428d7b3dSmrg		   'stat=$?; rm -f "$lockfile"; exit $stat'
3727428d7b3dSmrg    if test "$lock_old_archive_extraction" = yes; then
3728428d7b3dSmrg      $opt_dry_run || rm -f "$lockfile"
3729428d7b3dSmrg    fi
3730428d7b3dSmrg    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
3731428d7b3dSmrg     :
3732428d7b3dSmrg    else
3733428d7b3dSmrg      func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
3734428d7b3dSmrg    fi
3735428d7b3dSmrg}
3736428d7b3dSmrg
3737428d7b3dSmrg
3738428d7b3dSmrg# func_extract_archives gentop oldlib ...
3739428d7b3dSmrgfunc_extract_archives ()
3740428d7b3dSmrg{
3741428d7b3dSmrg    $opt_debug
3742428d7b3dSmrg    my_gentop="$1"; shift
3743428d7b3dSmrg    my_oldlibs=${1+"$@"}
3744428d7b3dSmrg    my_oldobjs=""
3745428d7b3dSmrg    my_xlib=""
3746428d7b3dSmrg    my_xabs=""
3747428d7b3dSmrg    my_xdir=""
3748428d7b3dSmrg
3749428d7b3dSmrg    for my_xlib in $my_oldlibs; do
3750428d7b3dSmrg      # Extract the objects.
3751428d7b3dSmrg      case $my_xlib in
3752428d7b3dSmrg	[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
3753428d7b3dSmrg	*) my_xabs=`pwd`"/$my_xlib" ;;
3754428d7b3dSmrg      esac
3755428d7b3dSmrg      func_basename "$my_xlib"
3756428d7b3dSmrg      my_xlib="$func_basename_result"
3757428d7b3dSmrg      my_xlib_u=$my_xlib
3758428d7b3dSmrg      while :; do
3759428d7b3dSmrg        case " $extracted_archives " in
3760428d7b3dSmrg	*" $my_xlib_u "*)
3761428d7b3dSmrg	  func_arith $extracted_serial + 1
3762428d7b3dSmrg	  extracted_serial=$func_arith_result
3763428d7b3dSmrg	  my_xlib_u=lt$extracted_serial-$my_xlib ;;
3764428d7b3dSmrg	*) break ;;
3765428d7b3dSmrg	esac
3766428d7b3dSmrg      done
3767428d7b3dSmrg      extracted_archives="$extracted_archives $my_xlib_u"
3768428d7b3dSmrg      my_xdir="$my_gentop/$my_xlib_u"
3769428d7b3dSmrg
3770428d7b3dSmrg      func_mkdir_p "$my_xdir"
3771428d7b3dSmrg
3772428d7b3dSmrg      case $host in
3773428d7b3dSmrg      *-darwin*)
3774428d7b3dSmrg	func_verbose "Extracting $my_xabs"
3775428d7b3dSmrg	# Do not bother doing anything if just a dry run
3776428d7b3dSmrg	$opt_dry_run || {
3777428d7b3dSmrg	  darwin_orig_dir=`pwd`
3778428d7b3dSmrg	  cd $my_xdir || exit $?
3779428d7b3dSmrg	  darwin_archive=$my_xabs
3780428d7b3dSmrg	  darwin_curdir=`pwd`
3781428d7b3dSmrg	  darwin_base_archive=`basename "$darwin_archive"`
3782428d7b3dSmrg	  darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
3783428d7b3dSmrg	  if test -n "$darwin_arches"; then
3784428d7b3dSmrg	    darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
3785428d7b3dSmrg	    darwin_arch=
3786428d7b3dSmrg	    func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
3787428d7b3dSmrg	    for darwin_arch in  $darwin_arches ; do
3788428d7b3dSmrg	      func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
3789428d7b3dSmrg	      $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
3790428d7b3dSmrg	      cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
3791428d7b3dSmrg	      func_extract_an_archive "`pwd`" "${darwin_base_archive}"
3792428d7b3dSmrg	      cd "$darwin_curdir"
3793428d7b3dSmrg	      $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
3794428d7b3dSmrg	    done # $darwin_arches
3795428d7b3dSmrg            ## Okay now we've a bunch of thin objects, gotta fatten them up :)
3796428d7b3dSmrg	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u`
3797428d7b3dSmrg	    darwin_file=
3798428d7b3dSmrg	    darwin_files=
3799428d7b3dSmrg	    for darwin_file in $darwin_filelist; do
3800428d7b3dSmrg	      darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`
3801428d7b3dSmrg	      $LIPO -create -output "$darwin_file" $darwin_files
3802428d7b3dSmrg	    done # $darwin_filelist
3803428d7b3dSmrg	    $RM -rf unfat-$$
3804428d7b3dSmrg	    cd "$darwin_orig_dir"
3805428d7b3dSmrg	  else
3806428d7b3dSmrg	    cd $darwin_orig_dir
3807428d7b3dSmrg	    func_extract_an_archive "$my_xdir" "$my_xabs"
3808428d7b3dSmrg	  fi # $darwin_arches
3809428d7b3dSmrg	} # !$opt_dry_run
3810428d7b3dSmrg	;;
3811428d7b3dSmrg      *)
3812428d7b3dSmrg        func_extract_an_archive "$my_xdir" "$my_xabs"
3813428d7b3dSmrg	;;
3814428d7b3dSmrg      esac
3815428d7b3dSmrg      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
3816428d7b3dSmrg    done
3817428d7b3dSmrg
3818428d7b3dSmrg    func_extract_archives_result="$my_oldobjs"
3819428d7b3dSmrg}
3820428d7b3dSmrg
3821428d7b3dSmrg
3822428d7b3dSmrg# func_emit_wrapper [arg=no]
3823428d7b3dSmrg#
3824428d7b3dSmrg# Emit a libtool wrapper script on stdout.
3825428d7b3dSmrg# Don't directly open a file because we may want to
3826428d7b3dSmrg# incorporate the script contents within a cygwin/mingw
3827428d7b3dSmrg# wrapper executable.  Must ONLY be called from within
3828428d7b3dSmrg# func_mode_link because it depends on a number of variables
3829428d7b3dSmrg# set therein.
3830428d7b3dSmrg#
3831428d7b3dSmrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
3832428d7b3dSmrg# variable will take.  If 'yes', then the emitted script
3833428d7b3dSmrg# will assume that the directory in which it is stored is
3834428d7b3dSmrg# the $objdir directory.  This is a cygwin/mingw-specific
3835428d7b3dSmrg# behavior.
3836428d7b3dSmrgfunc_emit_wrapper ()
3837428d7b3dSmrg{
3838428d7b3dSmrg	func_emit_wrapper_arg1=${1-no}
3839428d7b3dSmrg
3840428d7b3dSmrg	$ECHO "\
3841428d7b3dSmrg#! $SHELL
3842428d7b3dSmrg
3843428d7b3dSmrg# $output - temporary wrapper script for $objdir/$outputname
3844428d7b3dSmrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
3845428d7b3dSmrg#
3846428d7b3dSmrg# The $output program cannot be directly executed until all the libtool
3847428d7b3dSmrg# libraries that it depends on are installed.
3848428d7b3dSmrg#
3849428d7b3dSmrg# This wrapper script should never be moved out of the build directory.
3850428d7b3dSmrg# If it is, it will not operate correctly.
3851428d7b3dSmrg
3852428d7b3dSmrg# Sed substitution that helps us do robust quoting.  It backslashifies
3853428d7b3dSmrg# metacharacters that are still active within double-quoted strings.
3854428d7b3dSmrgsed_quote_subst='$sed_quote_subst'
3855428d7b3dSmrg
3856428d7b3dSmrg# Be Bourne compatible
3857428d7b3dSmrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
3858428d7b3dSmrg  emulate sh
3859428d7b3dSmrg  NULLCMD=:
3860428d7b3dSmrg  # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
3861428d7b3dSmrg  # is contrary to our usage.  Disable this feature.
3862428d7b3dSmrg  alias -g '\${1+\"\$@\"}'='\"\$@\"'
3863428d7b3dSmrg  setopt NO_GLOB_SUBST
3864428d7b3dSmrgelse
3865428d7b3dSmrg  case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
3866428d7b3dSmrgfi
3867428d7b3dSmrgBIN_SH=xpg4; export BIN_SH # for Tru64
3868428d7b3dSmrgDUALCASE=1; export DUALCASE # for MKS sh
3869428d7b3dSmrg
3870428d7b3dSmrg# The HP-UX ksh and POSIX shell print the target directory to stdout
3871428d7b3dSmrg# if CDPATH is set.
3872428d7b3dSmrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
3873428d7b3dSmrg
3874428d7b3dSmrgrelink_command=\"$relink_command\"
3875428d7b3dSmrg
3876428d7b3dSmrg# This environment variable determines our operation mode.
3877428d7b3dSmrgif test \"\$libtool_install_magic\" = \"$magic\"; then
3878428d7b3dSmrg  # install mode needs the following variables:
3879428d7b3dSmrg  generated_by_libtool_version='$macro_version'
3880428d7b3dSmrg  notinst_deplibs='$notinst_deplibs'
3881428d7b3dSmrgelse
3882428d7b3dSmrg  # When we are sourced in execute mode, \$file and \$ECHO are already set.
3883428d7b3dSmrg  if test \"\$libtool_execute_magic\" != \"$magic\"; then
3884428d7b3dSmrg    file=\"\$0\""
3885428d7b3dSmrg
3886428d7b3dSmrg    qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"`
3887428d7b3dSmrg    $ECHO "\
3888428d7b3dSmrg
3889428d7b3dSmrg# A function that is used when there is no print builtin or printf.
3890428d7b3dSmrgfunc_fallback_echo ()
3891428d7b3dSmrg{
3892428d7b3dSmrg  eval 'cat <<_LTECHO_EOF
3893428d7b3dSmrg\$1
3894428d7b3dSmrg_LTECHO_EOF'
3895428d7b3dSmrg}
3896428d7b3dSmrg    ECHO=\"$qECHO\"
3897428d7b3dSmrg  fi
3898428d7b3dSmrg
3899428d7b3dSmrg# Very basic option parsing. These options are (a) specific to
3900428d7b3dSmrg# the libtool wrapper, (b) are identical between the wrapper
3901428d7b3dSmrg# /script/ and the wrapper /executable/ which is used only on
3902428d7b3dSmrg# windows platforms, and (c) all begin with the string "--lt-"
3903428d7b3dSmrg# (application programs are unlikely to have options which match
3904428d7b3dSmrg# this pattern).
3905428d7b3dSmrg#
3906428d7b3dSmrg# There are only two supported options: --lt-debug and
3907428d7b3dSmrg# --lt-dump-script. There is, deliberately, no --lt-help.
3908428d7b3dSmrg#
3909428d7b3dSmrg# The first argument to this parsing function should be the
3910428d7b3dSmrg# script's $0 value, followed by "$@".
3911428d7b3dSmrglt_option_debug=
3912428d7b3dSmrgfunc_parse_lt_options ()
3913428d7b3dSmrg{
3914428d7b3dSmrg  lt_script_arg0=\$0
3915428d7b3dSmrg  shift
3916428d7b3dSmrg  for lt_opt
3917428d7b3dSmrg  do
3918428d7b3dSmrg    case \"\$lt_opt\" in
3919428d7b3dSmrg    --lt-debug) lt_option_debug=1 ;;
3920428d7b3dSmrg    --lt-dump-script)
3921428d7b3dSmrg        lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
3922428d7b3dSmrg        test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
3923428d7b3dSmrg        lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
3924428d7b3dSmrg        cat \"\$lt_dump_D/\$lt_dump_F\"
3925428d7b3dSmrg        exit 0
3926428d7b3dSmrg      ;;
3927428d7b3dSmrg    --lt-*)
3928428d7b3dSmrg        \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
3929428d7b3dSmrg        exit 1
3930428d7b3dSmrg      ;;
3931428d7b3dSmrg    esac
3932428d7b3dSmrg  done
3933428d7b3dSmrg
3934428d7b3dSmrg  # Print the debug banner immediately:
3935428d7b3dSmrg  if test -n \"\$lt_option_debug\"; then
3936428d7b3dSmrg    echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2
3937428d7b3dSmrg  fi
3938428d7b3dSmrg}
3939428d7b3dSmrg
3940428d7b3dSmrg# Used when --lt-debug. Prints its arguments to stdout
3941428d7b3dSmrg# (redirection is the responsibility of the caller)
3942428d7b3dSmrgfunc_lt_dump_args ()
3943428d7b3dSmrg{
3944428d7b3dSmrg  lt_dump_args_N=1;
3945428d7b3dSmrg  for lt_arg
3946428d7b3dSmrg  do
3947428d7b3dSmrg    \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\"
3948428d7b3dSmrg    lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
3949428d7b3dSmrg  done
3950428d7b3dSmrg}
3951428d7b3dSmrg
3952428d7b3dSmrg# Core function for launching the target application
3953428d7b3dSmrgfunc_exec_program_core ()
3954428d7b3dSmrg{
3955428d7b3dSmrg"
3956428d7b3dSmrg  case $host in
3957428d7b3dSmrg  # Backslashes separate directories on plain windows
3958428d7b3dSmrg  *-*-mingw | *-*-os2* | *-cegcc*)
3959428d7b3dSmrg    $ECHO "\
3960428d7b3dSmrg      if test -n \"\$lt_option_debug\"; then
3961428d7b3dSmrg        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2
3962428d7b3dSmrg        func_lt_dump_args \${1+\"\$@\"} 1>&2
3963428d7b3dSmrg      fi
3964428d7b3dSmrg      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
3965428d7b3dSmrg"
3966428d7b3dSmrg    ;;
3967428d7b3dSmrg
3968428d7b3dSmrg  *)
3969428d7b3dSmrg    $ECHO "\
3970428d7b3dSmrg      if test -n \"\$lt_option_debug\"; then
3971428d7b3dSmrg        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2
3972428d7b3dSmrg        func_lt_dump_args \${1+\"\$@\"} 1>&2
3973428d7b3dSmrg      fi
3974428d7b3dSmrg      exec \"\$progdir/\$program\" \${1+\"\$@\"}
3975428d7b3dSmrg"
3976428d7b3dSmrg    ;;
3977428d7b3dSmrg  esac
3978428d7b3dSmrg  $ECHO "\
3979428d7b3dSmrg      \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
3980428d7b3dSmrg      exit 1
3981428d7b3dSmrg}
3982428d7b3dSmrg
3983428d7b3dSmrg# A function to encapsulate launching the target application
3984428d7b3dSmrg# Strips options in the --lt-* namespace from \$@ and
3985428d7b3dSmrg# launches target application with the remaining arguments.
3986428d7b3dSmrgfunc_exec_program ()
3987428d7b3dSmrg{
3988428d7b3dSmrg  case \" \$* \" in
3989428d7b3dSmrg  *\\ --lt-*)
3990428d7b3dSmrg    for lt_wr_arg
3991428d7b3dSmrg    do
3992428d7b3dSmrg      case \$lt_wr_arg in
3993428d7b3dSmrg      --lt-*) ;;
3994428d7b3dSmrg      *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
3995428d7b3dSmrg      esac
3996428d7b3dSmrg      shift
3997428d7b3dSmrg    done ;;
3998428d7b3dSmrg  esac
3999428d7b3dSmrg  func_exec_program_core \${1+\"\$@\"}
4000428d7b3dSmrg}
4001428d7b3dSmrg
4002428d7b3dSmrg  # Parse options
4003428d7b3dSmrg  func_parse_lt_options \"\$0\" \${1+\"\$@\"}
4004428d7b3dSmrg
4005428d7b3dSmrg  # Find the directory that this script lives in.
4006428d7b3dSmrg  thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
4007428d7b3dSmrg  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
4008428d7b3dSmrg
4009428d7b3dSmrg  # Follow symbolic links until we get to the real thisdir.
4010428d7b3dSmrg  file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
4011428d7b3dSmrg  while test -n \"\$file\"; do
4012428d7b3dSmrg    destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
4013428d7b3dSmrg
4014428d7b3dSmrg    # If there was a directory component, then change thisdir.
4015428d7b3dSmrg    if test \"x\$destdir\" != \"x\$file\"; then
4016428d7b3dSmrg      case \"\$destdir\" in
4017428d7b3dSmrg      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
4018428d7b3dSmrg      *) thisdir=\"\$thisdir/\$destdir\" ;;
4019428d7b3dSmrg      esac
4020428d7b3dSmrg    fi
4021428d7b3dSmrg
4022428d7b3dSmrg    file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
4023428d7b3dSmrg    file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
4024428d7b3dSmrg  done
4025428d7b3dSmrg
4026428d7b3dSmrg  # Usually 'no', except on cygwin/mingw when embedded into
4027428d7b3dSmrg  # the cwrapper.
4028428d7b3dSmrg  WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
4029428d7b3dSmrg  if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
4030428d7b3dSmrg    # special case for '.'
4031428d7b3dSmrg    if test \"\$thisdir\" = \".\"; then
4032428d7b3dSmrg      thisdir=\`pwd\`
4033428d7b3dSmrg    fi
4034428d7b3dSmrg    # remove .libs from thisdir
4035428d7b3dSmrg    case \"\$thisdir\" in
4036428d7b3dSmrg    *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
4037428d7b3dSmrg    $objdir )   thisdir=. ;;
4038428d7b3dSmrg    esac
4039428d7b3dSmrg  fi
4040428d7b3dSmrg
4041428d7b3dSmrg  # Try to get the absolute directory name.
4042428d7b3dSmrg  absdir=\`cd \"\$thisdir\" && pwd\`
4043428d7b3dSmrg  test -n \"\$absdir\" && thisdir=\"\$absdir\"
4044428d7b3dSmrg"
4045428d7b3dSmrg
4046428d7b3dSmrg	if test "$fast_install" = yes; then
4047428d7b3dSmrg	  $ECHO "\
4048428d7b3dSmrg  program=lt-'$outputname'$exeext
4049428d7b3dSmrg  progdir=\"\$thisdir/$objdir\"
4050428d7b3dSmrg
4051428d7b3dSmrg  if test ! -f \"\$progdir/\$program\" ||
4052428d7b3dSmrg     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
4053428d7b3dSmrg       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
4054428d7b3dSmrg
4055428d7b3dSmrg    file=\"\$\$-\$program\"
4056428d7b3dSmrg
4057428d7b3dSmrg    if test ! -d \"\$progdir\"; then
4058428d7b3dSmrg      $MKDIR \"\$progdir\"
4059428d7b3dSmrg    else
4060428d7b3dSmrg      $RM \"\$progdir/\$file\"
4061428d7b3dSmrg    fi"
4062428d7b3dSmrg
4063428d7b3dSmrg	  $ECHO "\
4064428d7b3dSmrg
4065428d7b3dSmrg    # relink executable if necessary
4066428d7b3dSmrg    if test -n \"\$relink_command\"; then
4067428d7b3dSmrg      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
4068428d7b3dSmrg      else
4069428d7b3dSmrg	$ECHO \"\$relink_command_output\" >&2
4070428d7b3dSmrg	$RM \"\$progdir/\$file\"
4071428d7b3dSmrg	exit 1
4072428d7b3dSmrg      fi
4073428d7b3dSmrg    fi
4074428d7b3dSmrg
4075428d7b3dSmrg    $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
4076428d7b3dSmrg    { $RM \"\$progdir/\$program\";
4077428d7b3dSmrg      $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
4078428d7b3dSmrg    $RM \"\$progdir/\$file\"
4079428d7b3dSmrg  fi"
4080428d7b3dSmrg	else
4081428d7b3dSmrg	  $ECHO "\
4082428d7b3dSmrg  program='$outputname'
4083428d7b3dSmrg  progdir=\"\$thisdir/$objdir\"
4084428d7b3dSmrg"
4085428d7b3dSmrg	fi
4086428d7b3dSmrg
4087428d7b3dSmrg	$ECHO "\
4088428d7b3dSmrg
4089428d7b3dSmrg  if test -f \"\$progdir/\$program\"; then"
4090428d7b3dSmrg
4091428d7b3dSmrg	# fixup the dll searchpath if we need to.
4092428d7b3dSmrg	#
4093428d7b3dSmrg	# Fix the DLL searchpath if we need to.  Do this before prepending
4094428d7b3dSmrg	# to shlibpath, because on Windows, both are PATH and uninstalled
4095428d7b3dSmrg	# libraries must come first.
4096428d7b3dSmrg	if test -n "$dllsearchpath"; then
4097428d7b3dSmrg	  $ECHO "\
4098428d7b3dSmrg    # Add the dll search path components to the executable PATH
4099428d7b3dSmrg    PATH=$dllsearchpath:\$PATH
4100428d7b3dSmrg"
4101428d7b3dSmrg	fi
4102428d7b3dSmrg
4103428d7b3dSmrg	# Export our shlibpath_var if we have one.
4104428d7b3dSmrg	if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
4105428d7b3dSmrg	  $ECHO "\
4106428d7b3dSmrg    # Add our own library path to $shlibpath_var
4107428d7b3dSmrg    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
4108428d7b3dSmrg
4109428d7b3dSmrg    # Some systems cannot cope with colon-terminated $shlibpath_var
4110428d7b3dSmrg    # The second colon is a workaround for a bug in BeOS R4 sed
4111428d7b3dSmrg    $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
4112428d7b3dSmrg
4113428d7b3dSmrg    export $shlibpath_var
4114428d7b3dSmrg"
4115428d7b3dSmrg	fi
4116428d7b3dSmrg
4117428d7b3dSmrg	$ECHO "\
4118428d7b3dSmrg    if test \"\$libtool_execute_magic\" != \"$magic\"; then
4119428d7b3dSmrg      # Run the actual program with our arguments.
4120428d7b3dSmrg      func_exec_program \${1+\"\$@\"}
4121428d7b3dSmrg    fi
4122428d7b3dSmrg  else
4123428d7b3dSmrg    # The program doesn't exist.
4124428d7b3dSmrg    \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
4125428d7b3dSmrg    \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
4126428d7b3dSmrg    \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
4127428d7b3dSmrg    exit 1
4128428d7b3dSmrg  fi
4129428d7b3dSmrgfi\
4130428d7b3dSmrg"
4131428d7b3dSmrg}
4132428d7b3dSmrg
4133428d7b3dSmrg
4134428d7b3dSmrg# func_emit_cwrapperexe_src
4135428d7b3dSmrg# emit the source code for a wrapper executable on stdout
4136428d7b3dSmrg# Must ONLY be called from within func_mode_link because
4137428d7b3dSmrg# it depends on a number of variable set therein.
4138428d7b3dSmrgfunc_emit_cwrapperexe_src ()
4139428d7b3dSmrg{
4140428d7b3dSmrg	cat <<EOF
4141428d7b3dSmrg
4142428d7b3dSmrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
4143428d7b3dSmrg   Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
4144428d7b3dSmrg
4145428d7b3dSmrg   The $output program cannot be directly executed until all the libtool
4146428d7b3dSmrg   libraries that it depends on are installed.
4147428d7b3dSmrg
4148428d7b3dSmrg   This wrapper executable should never be moved out of the build directory.
4149428d7b3dSmrg   If it is, it will not operate correctly.
4150428d7b3dSmrg*/
4151428d7b3dSmrgEOF
4152428d7b3dSmrg	    cat <<"EOF"
4153428d7b3dSmrg#ifdef _MSC_VER
4154428d7b3dSmrg# define _CRT_SECURE_NO_DEPRECATE 1
4155428d7b3dSmrg#endif
4156428d7b3dSmrg#include <stdio.h>
4157428d7b3dSmrg#include <stdlib.h>
4158428d7b3dSmrg#ifdef _MSC_VER
4159428d7b3dSmrg# include <direct.h>
4160428d7b3dSmrg# include <process.h>
4161428d7b3dSmrg# include <io.h>
4162428d7b3dSmrg#else
4163428d7b3dSmrg# include <unistd.h>
4164428d7b3dSmrg# include <stdint.h>
4165428d7b3dSmrg# ifdef __CYGWIN__
4166428d7b3dSmrg#  include <io.h>
4167428d7b3dSmrg# endif
4168428d7b3dSmrg#endif
4169428d7b3dSmrg#include <malloc.h>
4170428d7b3dSmrg#include <stdarg.h>
4171428d7b3dSmrg#include <assert.h>
4172428d7b3dSmrg#include <string.h>
4173428d7b3dSmrg#include <ctype.h>
4174428d7b3dSmrg#include <errno.h>
4175428d7b3dSmrg#include <fcntl.h>
4176428d7b3dSmrg#include <sys/stat.h>
4177428d7b3dSmrg
4178428d7b3dSmrg/* declarations of non-ANSI functions */
4179428d7b3dSmrg#if defined(__MINGW32__)
4180428d7b3dSmrg# ifdef __STRICT_ANSI__
4181428d7b3dSmrgint _putenv (const char *);
4182428d7b3dSmrg# endif
4183428d7b3dSmrg#elif defined(__CYGWIN__)
4184428d7b3dSmrg# ifdef __STRICT_ANSI__
4185428d7b3dSmrgchar *realpath (const char *, char *);
4186428d7b3dSmrgint putenv (char *);
4187428d7b3dSmrgint setenv (const char *, const char *, int);
4188428d7b3dSmrg# endif
4189428d7b3dSmrg/* #elif defined (other platforms) ... */
4190428d7b3dSmrg#endif
4191428d7b3dSmrg
4192428d7b3dSmrg/* portability defines, excluding path handling macros */
4193428d7b3dSmrg#if defined(_MSC_VER)
4194428d7b3dSmrg# define setmode _setmode
4195428d7b3dSmrg# define stat    _stat
4196428d7b3dSmrg# define chmod   _chmod
4197428d7b3dSmrg# define getcwd  _getcwd
4198428d7b3dSmrg# define putenv  _putenv
4199428d7b3dSmrg# define S_IXUSR _S_IEXEC
4200428d7b3dSmrg# ifndef _INTPTR_T_DEFINED
4201428d7b3dSmrg#  define _INTPTR_T_DEFINED
4202428d7b3dSmrg#  define intptr_t int
4203428d7b3dSmrg# endif
4204428d7b3dSmrg#elif defined(__MINGW32__)
4205428d7b3dSmrg# define setmode _setmode
4206428d7b3dSmrg# define stat    _stat
4207428d7b3dSmrg# define chmod   _chmod
4208428d7b3dSmrg# define getcwd  _getcwd
4209428d7b3dSmrg# define putenv  _putenv
4210428d7b3dSmrg#elif defined(__CYGWIN__)
4211428d7b3dSmrg# define HAVE_SETENV
4212428d7b3dSmrg# define FOPEN_WB "wb"
4213428d7b3dSmrg/* #elif defined (other platforms) ... */
4214428d7b3dSmrg#endif
4215428d7b3dSmrg
4216428d7b3dSmrg#if defined(PATH_MAX)
4217428d7b3dSmrg# define LT_PATHMAX PATH_MAX
4218428d7b3dSmrg#elif defined(MAXPATHLEN)
4219428d7b3dSmrg# define LT_PATHMAX MAXPATHLEN
4220428d7b3dSmrg#else
4221428d7b3dSmrg# define LT_PATHMAX 1024
4222428d7b3dSmrg#endif
4223428d7b3dSmrg
4224428d7b3dSmrg#ifndef S_IXOTH
4225428d7b3dSmrg# define S_IXOTH 0
4226428d7b3dSmrg#endif
4227428d7b3dSmrg#ifndef S_IXGRP
4228428d7b3dSmrg# define S_IXGRP 0
4229428d7b3dSmrg#endif
4230428d7b3dSmrg
4231428d7b3dSmrg/* path handling portability macros */
4232428d7b3dSmrg#ifndef DIR_SEPARATOR
4233428d7b3dSmrg# define DIR_SEPARATOR '/'
4234428d7b3dSmrg# define PATH_SEPARATOR ':'
4235428d7b3dSmrg#endif
4236428d7b3dSmrg
4237428d7b3dSmrg#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
4238428d7b3dSmrg  defined (__OS2__)
4239428d7b3dSmrg# define HAVE_DOS_BASED_FILE_SYSTEM
4240428d7b3dSmrg# define FOPEN_WB "wb"
4241428d7b3dSmrg# ifndef DIR_SEPARATOR_2
4242428d7b3dSmrg#  define DIR_SEPARATOR_2 '\\'
4243428d7b3dSmrg# endif
4244428d7b3dSmrg# ifndef PATH_SEPARATOR_2
4245428d7b3dSmrg#  define PATH_SEPARATOR_2 ';'
4246428d7b3dSmrg# endif
4247428d7b3dSmrg#endif
4248428d7b3dSmrg
4249428d7b3dSmrg#ifndef DIR_SEPARATOR_2
4250428d7b3dSmrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
4251428d7b3dSmrg#else /* DIR_SEPARATOR_2 */
4252428d7b3dSmrg# define IS_DIR_SEPARATOR(ch) \
4253428d7b3dSmrg	(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
4254428d7b3dSmrg#endif /* DIR_SEPARATOR_2 */
4255428d7b3dSmrg
4256428d7b3dSmrg#ifndef PATH_SEPARATOR_2
4257428d7b3dSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
4258428d7b3dSmrg#else /* PATH_SEPARATOR_2 */
4259428d7b3dSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
4260428d7b3dSmrg#endif /* PATH_SEPARATOR_2 */
4261428d7b3dSmrg
4262428d7b3dSmrg#ifndef FOPEN_WB
4263428d7b3dSmrg# define FOPEN_WB "w"
4264428d7b3dSmrg#endif
4265428d7b3dSmrg#ifndef _O_BINARY
4266428d7b3dSmrg# define _O_BINARY 0
4267428d7b3dSmrg#endif
4268428d7b3dSmrg
4269428d7b3dSmrg#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
4270428d7b3dSmrg#define XFREE(stale) do { \
4271428d7b3dSmrg  if (stale) { free ((void *) stale); stale = 0; } \
4272428d7b3dSmrg} while (0)
4273428d7b3dSmrg
4274428d7b3dSmrg#if defined(LT_DEBUGWRAPPER)
4275428d7b3dSmrgstatic int lt_debug = 1;
4276428d7b3dSmrg#else
4277428d7b3dSmrgstatic int lt_debug = 0;
4278428d7b3dSmrg#endif
4279428d7b3dSmrg
4280428d7b3dSmrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */
4281428d7b3dSmrg
4282428d7b3dSmrgvoid *xmalloc (size_t num);
4283428d7b3dSmrgchar *xstrdup (const char *string);
4284428d7b3dSmrgconst char *base_name (const char *name);
4285428d7b3dSmrgchar *find_executable (const char *wrapper);
4286428d7b3dSmrgchar *chase_symlinks (const char *pathspec);
4287428d7b3dSmrgint make_executable (const char *path);
4288428d7b3dSmrgint check_executable (const char *path);
4289428d7b3dSmrgchar *strendzap (char *str, const char *pat);
4290428d7b3dSmrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...);
4291428d7b3dSmrgvoid lt_fatal (const char *file, int line, const char *message, ...);
4292428d7b3dSmrgstatic const char *nonnull (const char *s);
4293428d7b3dSmrgstatic const char *nonempty (const char *s);
4294428d7b3dSmrgvoid lt_setenv (const char *name, const char *value);
4295428d7b3dSmrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end);
4296428d7b3dSmrgvoid lt_update_exe_path (const char *name, const char *value);
4297428d7b3dSmrgvoid lt_update_lib_path (const char *name, const char *value);
4298428d7b3dSmrgchar **prepare_spawn (char **argv);
4299428d7b3dSmrgvoid lt_dump_script (FILE *f);
4300428d7b3dSmrgEOF
4301428d7b3dSmrg
4302428d7b3dSmrg	    cat <<EOF
4303428d7b3dSmrgvolatile const char * MAGIC_EXE = "$magic_exe";
4304428d7b3dSmrgconst char * LIB_PATH_VARNAME = "$shlibpath_var";
4305428d7b3dSmrgEOF
4306428d7b3dSmrg
4307428d7b3dSmrg	    if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
4308428d7b3dSmrg              func_to_host_path "$temp_rpath"
4309428d7b3dSmrg	      cat <<EOF
4310428d7b3dSmrgconst char * LIB_PATH_VALUE   = "$func_to_host_path_result";
4311428d7b3dSmrgEOF
4312428d7b3dSmrg	    else
4313428d7b3dSmrg	      cat <<"EOF"
4314428d7b3dSmrgconst char * LIB_PATH_VALUE   = "";
4315428d7b3dSmrgEOF
4316428d7b3dSmrg	    fi
4317428d7b3dSmrg
4318428d7b3dSmrg	    if test -n "$dllsearchpath"; then
4319428d7b3dSmrg              func_to_host_path "$dllsearchpath:"
4320428d7b3dSmrg	      cat <<EOF
4321428d7b3dSmrgconst char * EXE_PATH_VARNAME = "PATH";
4322428d7b3dSmrgconst char * EXE_PATH_VALUE   = "$func_to_host_path_result";
4323428d7b3dSmrgEOF
4324428d7b3dSmrg	    else
4325428d7b3dSmrg	      cat <<"EOF"
4326428d7b3dSmrgconst char * EXE_PATH_VARNAME = "";
4327428d7b3dSmrgconst char * EXE_PATH_VALUE   = "";
4328428d7b3dSmrgEOF
4329428d7b3dSmrg	    fi
4330428d7b3dSmrg
4331428d7b3dSmrg	    if test "$fast_install" = yes; then
4332428d7b3dSmrg	      cat <<EOF
4333428d7b3dSmrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
4334428d7b3dSmrgEOF
4335428d7b3dSmrg	    else
4336428d7b3dSmrg	      cat <<EOF
4337428d7b3dSmrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
4338428d7b3dSmrgEOF
4339428d7b3dSmrg	    fi
4340428d7b3dSmrg
4341428d7b3dSmrg
4342428d7b3dSmrg	    cat <<"EOF"
4343428d7b3dSmrg
4344428d7b3dSmrg#define LTWRAPPER_OPTION_PREFIX         "--lt-"
4345428d7b3dSmrg
4346428d7b3dSmrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
4347428d7b3dSmrgstatic const char *dumpscript_opt       = LTWRAPPER_OPTION_PREFIX "dump-script";
4348428d7b3dSmrgstatic const char *debug_opt            = LTWRAPPER_OPTION_PREFIX "debug";
4349428d7b3dSmrg
4350428d7b3dSmrgint
4351428d7b3dSmrgmain (int argc, char *argv[])
4352428d7b3dSmrg{
4353428d7b3dSmrg  char **newargz;
4354428d7b3dSmrg  int  newargc;
4355428d7b3dSmrg  char *tmp_pathspec;
4356428d7b3dSmrg  char *actual_cwrapper_path;
4357428d7b3dSmrg  char *actual_cwrapper_name;
4358428d7b3dSmrg  char *target_name;
4359428d7b3dSmrg  char *lt_argv_zero;
4360428d7b3dSmrg  intptr_t rval = 127;
4361428d7b3dSmrg
4362428d7b3dSmrg  int i;
4363428d7b3dSmrg
4364428d7b3dSmrg  program_name = (char *) xstrdup (base_name (argv[0]));
4365428d7b3dSmrg  newargz = XMALLOC (char *, argc + 1);
4366428d7b3dSmrg
4367428d7b3dSmrg  /* very simple arg parsing; don't want to rely on getopt
4368428d7b3dSmrg   * also, copy all non cwrapper options to newargz, except
4369428d7b3dSmrg   * argz[0], which is handled differently
4370428d7b3dSmrg   */
4371428d7b3dSmrg  newargc=0;
4372428d7b3dSmrg  for (i = 1; i < argc; i++)
4373428d7b3dSmrg    {
4374428d7b3dSmrg      if (strcmp (argv[i], dumpscript_opt) == 0)
4375428d7b3dSmrg	{
4376428d7b3dSmrgEOF
4377428d7b3dSmrg	    case "$host" in
4378428d7b3dSmrg	      *mingw* | *cygwin* )
4379428d7b3dSmrg		# make stdout use "unix" line endings
4380428d7b3dSmrg		echo "          setmode(1,_O_BINARY);"
4381428d7b3dSmrg		;;
4382428d7b3dSmrg	      esac
4383428d7b3dSmrg
4384428d7b3dSmrg	    cat <<"EOF"
4385428d7b3dSmrg	  lt_dump_script (stdout);
4386428d7b3dSmrg	  return 0;
4387428d7b3dSmrg	}
4388428d7b3dSmrg      if (strcmp (argv[i], debug_opt) == 0)
4389428d7b3dSmrg	{
4390428d7b3dSmrg          lt_debug = 1;
4391428d7b3dSmrg          continue;
4392428d7b3dSmrg	}
4393428d7b3dSmrg      if (strcmp (argv[i], ltwrapper_option_prefix) == 0)
4394428d7b3dSmrg        {
4395428d7b3dSmrg          /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
4396428d7b3dSmrg             namespace, but it is not one of the ones we know about and
4397428d7b3dSmrg             have already dealt with, above (inluding dump-script), then
4398428d7b3dSmrg             report an error. Otherwise, targets might begin to believe
4399428d7b3dSmrg             they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
4400428d7b3dSmrg             namespace. The first time any user complains about this, we'll
4401428d7b3dSmrg             need to make LTWRAPPER_OPTION_PREFIX a configure-time option
4402428d7b3dSmrg             or a configure.ac-settable value.
4403428d7b3dSmrg           */
4404428d7b3dSmrg          lt_fatal (__FILE__, __LINE__,
4405428d7b3dSmrg		    "unrecognized %s option: '%s'",
4406428d7b3dSmrg                    ltwrapper_option_prefix, argv[i]);
4407428d7b3dSmrg        }
4408428d7b3dSmrg      /* otherwise ... */
4409428d7b3dSmrg      newargz[++newargc] = xstrdup (argv[i]);
4410428d7b3dSmrg    }
4411428d7b3dSmrg  newargz[++newargc] = NULL;
4412428d7b3dSmrg
4413428d7b3dSmrgEOF
4414428d7b3dSmrg	    cat <<EOF
4415428d7b3dSmrg  /* The GNU banner must be the first non-error debug message */
4416428d7b3dSmrg  lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\n");
4417428d7b3dSmrgEOF
4418428d7b3dSmrg	    cat <<"EOF"
4419428d7b3dSmrg  lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
4420428d7b3dSmrg  lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name);
4421428d7b3dSmrg
4422428d7b3dSmrg  tmp_pathspec = find_executable (argv[0]);
4423428d7b3dSmrg  if (tmp_pathspec == NULL)
4424428d7b3dSmrg    lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]);
4425428d7b3dSmrg  lt_debugprintf (__FILE__, __LINE__,
4426428d7b3dSmrg                  "(main) found exe (before symlink chase) at: %s\n",
4427428d7b3dSmrg		  tmp_pathspec);
4428428d7b3dSmrg
4429428d7b3dSmrg  actual_cwrapper_path = chase_symlinks (tmp_pathspec);
4430428d7b3dSmrg  lt_debugprintf (__FILE__, __LINE__,
4431428d7b3dSmrg                  "(main) found exe (after symlink chase) at: %s\n",
4432428d7b3dSmrg		  actual_cwrapper_path);
4433428d7b3dSmrg  XFREE (tmp_pathspec);
4434428d7b3dSmrg
4435428d7b3dSmrg  actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));
4436428d7b3dSmrg  strendzap (actual_cwrapper_path, actual_cwrapper_name);
4437428d7b3dSmrg
4438428d7b3dSmrg  /* wrapper name transforms */
4439428d7b3dSmrg  strendzap (actual_cwrapper_name, ".exe");
4440428d7b3dSmrg  tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
4441428d7b3dSmrg  XFREE (actual_cwrapper_name);
4442428d7b3dSmrg  actual_cwrapper_name = tmp_pathspec;
4443428d7b3dSmrg  tmp_pathspec = 0;
4444428d7b3dSmrg
4445428d7b3dSmrg  /* target_name transforms -- use actual target program name; might have lt- prefix */
4446428d7b3dSmrg  target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
4447428d7b3dSmrg  strendzap (target_name, ".exe");
4448428d7b3dSmrg  tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
4449428d7b3dSmrg  XFREE (target_name);
4450428d7b3dSmrg  target_name = tmp_pathspec;
4451428d7b3dSmrg  tmp_pathspec = 0;
4452428d7b3dSmrg
4453428d7b3dSmrg  lt_debugprintf (__FILE__, __LINE__,
4454428d7b3dSmrg		  "(main) libtool target name: %s\n",
4455428d7b3dSmrg		  target_name);
4456428d7b3dSmrgEOF
4457428d7b3dSmrg
4458428d7b3dSmrg	    cat <<EOF
4459428d7b3dSmrg  newargz[0] =
4460428d7b3dSmrg    XMALLOC (char, (strlen (actual_cwrapper_path) +
4461428d7b3dSmrg		    strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
4462428d7b3dSmrg  strcpy (newargz[0], actual_cwrapper_path);
4463428d7b3dSmrg  strcat (newargz[0], "$objdir");
4464428d7b3dSmrg  strcat (newargz[0], "/");
4465428d7b3dSmrgEOF
4466428d7b3dSmrg
4467428d7b3dSmrg	    cat <<"EOF"
4468428d7b3dSmrg  /* stop here, and copy so we don't have to do this twice */
4469428d7b3dSmrg  tmp_pathspec = xstrdup (newargz[0]);
4470428d7b3dSmrg
4471428d7b3dSmrg  /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
4472428d7b3dSmrg  strcat (newargz[0], actual_cwrapper_name);
4473428d7b3dSmrg
4474428d7b3dSmrg  /* DO want the lt- prefix here if it exists, so use target_name */
4475428d7b3dSmrg  lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
4476428d7b3dSmrg  XFREE (tmp_pathspec);
4477428d7b3dSmrg  tmp_pathspec = NULL;
4478428d7b3dSmrgEOF
4479428d7b3dSmrg
4480428d7b3dSmrg	    case $host_os in
4481428d7b3dSmrg	      mingw*)
4482428d7b3dSmrg	    cat <<"EOF"
4483428d7b3dSmrg  {
4484428d7b3dSmrg    char* p;
4485428d7b3dSmrg    while ((p = strchr (newargz[0], '\\')) != NULL)
4486428d7b3dSmrg      {
4487428d7b3dSmrg	*p = '/';
4488428d7b3dSmrg      }
4489428d7b3dSmrg    while ((p = strchr (lt_argv_zero, '\\')) != NULL)
4490428d7b3dSmrg      {
4491428d7b3dSmrg	*p = '/';
4492428d7b3dSmrg      }
4493428d7b3dSmrg  }
4494428d7b3dSmrgEOF
4495428d7b3dSmrg	    ;;
4496428d7b3dSmrg	    esac
4497428d7b3dSmrg
4498428d7b3dSmrg	    cat <<"EOF"
4499428d7b3dSmrg  XFREE (target_name);
4500428d7b3dSmrg  XFREE (actual_cwrapper_path);
4501428d7b3dSmrg  XFREE (actual_cwrapper_name);
4502428d7b3dSmrg
4503428d7b3dSmrg  lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
4504428d7b3dSmrg  lt_setenv ("DUALCASE", "1");  /* for MSK sh */
4505428d7b3dSmrg  /* Update the DLL searchpath.  EXE_PATH_VALUE ($dllsearchpath) must
4506428d7b3dSmrg     be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath)
4507428d7b3dSmrg     because on Windows, both *_VARNAMEs are PATH but uninstalled
4508428d7b3dSmrg     libraries must come first. */
4509428d7b3dSmrg  lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
4510428d7b3dSmrg  lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
4511428d7b3dSmrg
4512428d7b3dSmrg  lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",
4513428d7b3dSmrg		  nonnull (lt_argv_zero));
4514428d7b3dSmrg  for (i = 0; i < newargc; i++)
4515428d7b3dSmrg    {
4516428d7b3dSmrg      lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n",
4517428d7b3dSmrg		      i, nonnull (newargz[i]));
4518428d7b3dSmrg    }
4519428d7b3dSmrg
4520428d7b3dSmrgEOF
4521428d7b3dSmrg
4522428d7b3dSmrg	    case $host_os in
4523428d7b3dSmrg	      mingw*)
4524428d7b3dSmrg		cat <<"EOF"
4525428d7b3dSmrg  /* execv doesn't actually work on mingw as expected on unix */
4526428d7b3dSmrg  newargz = prepare_spawn (newargz);
4527428d7b3dSmrg  rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
4528428d7b3dSmrg  if (rval == -1)
4529428d7b3dSmrg    {
4530428d7b3dSmrg      /* failed to start process */
4531428d7b3dSmrg      lt_debugprintf (__FILE__, __LINE__,
4532428d7b3dSmrg		      "(main) failed to launch target \"%s\": %s\n",
4533428d7b3dSmrg		      lt_argv_zero, nonnull (strerror (errno)));
4534428d7b3dSmrg      return 127;
4535428d7b3dSmrg    }
4536428d7b3dSmrg  return rval;
4537428d7b3dSmrgEOF
4538428d7b3dSmrg		;;
4539428d7b3dSmrg	      *)
4540428d7b3dSmrg		cat <<"EOF"
4541428d7b3dSmrg  execv (lt_argv_zero, newargz);
4542428d7b3dSmrg  return rval; /* =127, but avoids unused variable warning */
4543428d7b3dSmrgEOF
4544428d7b3dSmrg		;;
4545428d7b3dSmrg	    esac
4546428d7b3dSmrg
4547428d7b3dSmrg	    cat <<"EOF"
4548428d7b3dSmrg}
4549428d7b3dSmrg
4550428d7b3dSmrgvoid *
4551428d7b3dSmrgxmalloc (size_t num)
4552428d7b3dSmrg{
4553428d7b3dSmrg  void *p = (void *) malloc (num);
4554428d7b3dSmrg  if (!p)
4555428d7b3dSmrg    lt_fatal (__FILE__, __LINE__, "memory exhausted");
4556428d7b3dSmrg
4557428d7b3dSmrg  return p;
4558428d7b3dSmrg}
4559428d7b3dSmrg
4560428d7b3dSmrgchar *
4561428d7b3dSmrgxstrdup (const char *string)
4562428d7b3dSmrg{
4563428d7b3dSmrg  return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
4564428d7b3dSmrg			  string) : NULL;
4565428d7b3dSmrg}
4566428d7b3dSmrg
4567428d7b3dSmrgconst char *
4568428d7b3dSmrgbase_name (const char *name)
4569428d7b3dSmrg{
4570428d7b3dSmrg  const char *base;
4571428d7b3dSmrg
4572428d7b3dSmrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4573428d7b3dSmrg  /* Skip over the disk name in MSDOS pathnames. */
4574428d7b3dSmrg  if (isalpha ((unsigned char) name[0]) && name[1] == ':')
4575428d7b3dSmrg    name += 2;
4576428d7b3dSmrg#endif
4577428d7b3dSmrg
4578428d7b3dSmrg  for (base = name; *name; name++)
4579428d7b3dSmrg    if (IS_DIR_SEPARATOR (*name))
4580428d7b3dSmrg      base = name + 1;
4581428d7b3dSmrg  return base;
4582428d7b3dSmrg}
4583428d7b3dSmrg
4584428d7b3dSmrgint
4585428d7b3dSmrgcheck_executable (const char *path)
4586428d7b3dSmrg{
4587428d7b3dSmrg  struct stat st;
4588428d7b3dSmrg
4589428d7b3dSmrg  lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n",
4590428d7b3dSmrg                  nonempty (path));
4591428d7b3dSmrg  if ((!path) || (!*path))
4592428d7b3dSmrg    return 0;
4593428d7b3dSmrg
4594428d7b3dSmrg  if ((stat (path, &st) >= 0)
4595428d7b3dSmrg      && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
4596428d7b3dSmrg    return 1;
4597428d7b3dSmrg  else
4598428d7b3dSmrg    return 0;
4599428d7b3dSmrg}
4600428d7b3dSmrg
4601428d7b3dSmrgint
4602428d7b3dSmrgmake_executable (const char *path)
4603428d7b3dSmrg{
4604428d7b3dSmrg  int rval = 0;
4605428d7b3dSmrg  struct stat st;
4606428d7b3dSmrg
4607428d7b3dSmrg  lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n",
4608428d7b3dSmrg                  nonempty (path));
4609428d7b3dSmrg  if ((!path) || (!*path))
4610428d7b3dSmrg    return 0;
4611428d7b3dSmrg
4612428d7b3dSmrg  if (stat (path, &st) >= 0)
4613428d7b3dSmrg    {
4614428d7b3dSmrg      rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
4615428d7b3dSmrg    }
4616428d7b3dSmrg  return rval;
4617428d7b3dSmrg}
4618428d7b3dSmrg
4619428d7b3dSmrg/* Searches for the full path of the wrapper.  Returns
4620428d7b3dSmrg   newly allocated full path name if found, NULL otherwise
4621428d7b3dSmrg   Does not chase symlinks, even on platforms that support them.
4622428d7b3dSmrg*/
4623428d7b3dSmrgchar *
4624428d7b3dSmrgfind_executable (const char *wrapper)
4625428d7b3dSmrg{
4626428d7b3dSmrg  int has_slash = 0;
4627428d7b3dSmrg  const char *p;
4628428d7b3dSmrg  const char *p_next;
4629428d7b3dSmrg  /* static buffer for getcwd */
4630428d7b3dSmrg  char tmp[LT_PATHMAX + 1];
4631428d7b3dSmrg  int tmp_len;
4632428d7b3dSmrg  char *concat_name;
4633428d7b3dSmrg
4634428d7b3dSmrg  lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
4635428d7b3dSmrg                  nonempty (wrapper));
4636428d7b3dSmrg
4637428d7b3dSmrg  if ((wrapper == NULL) || (*wrapper == '\0'))
4638428d7b3dSmrg    return NULL;
4639428d7b3dSmrg
4640428d7b3dSmrg  /* Absolute path? */
4641428d7b3dSmrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4642428d7b3dSmrg  if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
4643428d7b3dSmrg    {
4644428d7b3dSmrg      concat_name = xstrdup (wrapper);
4645428d7b3dSmrg      if (check_executable (concat_name))
4646428d7b3dSmrg	return concat_name;
4647428d7b3dSmrg      XFREE (concat_name);
4648428d7b3dSmrg    }
4649428d7b3dSmrg  else
4650428d7b3dSmrg    {
4651428d7b3dSmrg#endif
4652428d7b3dSmrg      if (IS_DIR_SEPARATOR (wrapper[0]))
4653428d7b3dSmrg	{
4654428d7b3dSmrg	  concat_name = xstrdup (wrapper);
4655428d7b3dSmrg	  if (check_executable (concat_name))
4656428d7b3dSmrg	    return concat_name;
4657428d7b3dSmrg	  XFREE (concat_name);
4658428d7b3dSmrg	}
4659428d7b3dSmrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4660428d7b3dSmrg    }
4661428d7b3dSmrg#endif
4662428d7b3dSmrg
4663428d7b3dSmrg  for (p = wrapper; *p; p++)
4664428d7b3dSmrg    if (*p == '/')
4665428d7b3dSmrg      {
4666428d7b3dSmrg	has_slash = 1;
4667428d7b3dSmrg	break;
4668428d7b3dSmrg      }
4669428d7b3dSmrg  if (!has_slash)
4670428d7b3dSmrg    {
4671428d7b3dSmrg      /* no slashes; search PATH */
4672428d7b3dSmrg      const char *path = getenv ("PATH");
4673428d7b3dSmrg      if (path != NULL)
4674428d7b3dSmrg	{
4675428d7b3dSmrg	  for (p = path; *p; p = p_next)
4676428d7b3dSmrg	    {
4677428d7b3dSmrg	      const char *q;
4678428d7b3dSmrg	      size_t p_len;
4679428d7b3dSmrg	      for (q = p; *q; q++)
4680428d7b3dSmrg		if (IS_PATH_SEPARATOR (*q))
4681428d7b3dSmrg		  break;
4682428d7b3dSmrg	      p_len = q - p;
4683428d7b3dSmrg	      p_next = (*q == '\0' ? q : q + 1);
4684428d7b3dSmrg	      if (p_len == 0)
4685428d7b3dSmrg		{
4686428d7b3dSmrg		  /* empty path: current directory */
4687428d7b3dSmrg		  if (getcwd (tmp, LT_PATHMAX) == NULL)
4688428d7b3dSmrg		    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
4689428d7b3dSmrg                              nonnull (strerror (errno)));
4690428d7b3dSmrg		  tmp_len = strlen (tmp);
4691428d7b3dSmrg		  concat_name =
4692428d7b3dSmrg		    XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
4693428d7b3dSmrg		  memcpy (concat_name, tmp, tmp_len);
4694428d7b3dSmrg		  concat_name[tmp_len] = '/';
4695428d7b3dSmrg		  strcpy (concat_name + tmp_len + 1, wrapper);
4696428d7b3dSmrg		}
4697428d7b3dSmrg	      else
4698428d7b3dSmrg		{
4699428d7b3dSmrg		  concat_name =
4700428d7b3dSmrg		    XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
4701428d7b3dSmrg		  memcpy (concat_name, p, p_len);
4702428d7b3dSmrg		  concat_name[p_len] = '/';
4703428d7b3dSmrg		  strcpy (concat_name + p_len + 1, wrapper);
4704428d7b3dSmrg		}
4705428d7b3dSmrg	      if (check_executable (concat_name))
4706428d7b3dSmrg		return concat_name;
4707428d7b3dSmrg	      XFREE (concat_name);
4708428d7b3dSmrg	    }
4709428d7b3dSmrg	}
4710428d7b3dSmrg      /* not found in PATH; assume curdir */
4711428d7b3dSmrg    }
4712428d7b3dSmrg  /* Relative path | not found in path: prepend cwd */
4713428d7b3dSmrg  if (getcwd (tmp, LT_PATHMAX) == NULL)
4714428d7b3dSmrg    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
4715428d7b3dSmrg              nonnull (strerror (errno)));
4716428d7b3dSmrg  tmp_len = strlen (tmp);
4717428d7b3dSmrg  concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
4718428d7b3dSmrg  memcpy (concat_name, tmp, tmp_len);
4719428d7b3dSmrg  concat_name[tmp_len] = '/';
4720428d7b3dSmrg  strcpy (concat_name + tmp_len + 1, wrapper);
4721428d7b3dSmrg
4722428d7b3dSmrg  if (check_executable (concat_name))
4723428d7b3dSmrg    return concat_name;
4724428d7b3dSmrg  XFREE (concat_name);
4725428d7b3dSmrg  return NULL;
4726428d7b3dSmrg}
4727428d7b3dSmrg
4728428d7b3dSmrgchar *
4729428d7b3dSmrgchase_symlinks (const char *pathspec)
4730428d7b3dSmrg{
4731428d7b3dSmrg#ifndef S_ISLNK
4732428d7b3dSmrg  return xstrdup (pathspec);
4733428d7b3dSmrg#else
4734428d7b3dSmrg  char buf[LT_PATHMAX];
4735428d7b3dSmrg  struct stat s;
4736428d7b3dSmrg  char *tmp_pathspec = xstrdup (pathspec);
4737428d7b3dSmrg  char *p;
4738428d7b3dSmrg  int has_symlinks = 0;
4739428d7b3dSmrg  while (strlen (tmp_pathspec) && !has_symlinks)
4740428d7b3dSmrg    {
4741428d7b3dSmrg      lt_debugprintf (__FILE__, __LINE__,
4742428d7b3dSmrg		      "checking path component for symlinks: %s\n",
4743428d7b3dSmrg		      tmp_pathspec);
4744428d7b3dSmrg      if (lstat (tmp_pathspec, &s) == 0)
4745428d7b3dSmrg	{
4746428d7b3dSmrg	  if (S_ISLNK (s.st_mode) != 0)
4747428d7b3dSmrg	    {
4748428d7b3dSmrg	      has_symlinks = 1;
4749428d7b3dSmrg	      break;
4750428d7b3dSmrg	    }
4751428d7b3dSmrg
4752428d7b3dSmrg	  /* search backwards for last DIR_SEPARATOR */
4753428d7b3dSmrg	  p = tmp_pathspec + strlen (tmp_pathspec) - 1;
4754428d7b3dSmrg	  while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
4755428d7b3dSmrg	    p--;
4756428d7b3dSmrg	  if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
4757428d7b3dSmrg	    {
4758428d7b3dSmrg	      /* no more DIR_SEPARATORS left */
4759428d7b3dSmrg	      break;
4760428d7b3dSmrg	    }
4761428d7b3dSmrg	  *p = '\0';
4762428d7b3dSmrg	}
4763428d7b3dSmrg      else
4764428d7b3dSmrg	{
4765428d7b3dSmrg	  lt_fatal (__FILE__, __LINE__,
4766428d7b3dSmrg		    "error accessing file \"%s\": %s",
4767428d7b3dSmrg		    tmp_pathspec, nonnull (strerror (errno)));
4768428d7b3dSmrg	}
4769428d7b3dSmrg    }
4770428d7b3dSmrg  XFREE (tmp_pathspec);
4771428d7b3dSmrg
4772428d7b3dSmrg  if (!has_symlinks)
4773428d7b3dSmrg    {
4774428d7b3dSmrg      return xstrdup (pathspec);
4775428d7b3dSmrg    }
4776428d7b3dSmrg
4777428d7b3dSmrg  tmp_pathspec = realpath (pathspec, buf);
4778428d7b3dSmrg  if (tmp_pathspec == 0)
4779428d7b3dSmrg    {
4780428d7b3dSmrg      lt_fatal (__FILE__, __LINE__,
4781428d7b3dSmrg		"could not follow symlinks for %s", pathspec);
4782428d7b3dSmrg    }
4783428d7b3dSmrg  return xstrdup (tmp_pathspec);
4784428d7b3dSmrg#endif
4785428d7b3dSmrg}
4786428d7b3dSmrg
4787428d7b3dSmrgchar *
4788428d7b3dSmrgstrendzap (char *str, const char *pat)
4789428d7b3dSmrg{
4790428d7b3dSmrg  size_t len, patlen;
4791428d7b3dSmrg
4792428d7b3dSmrg  assert (str != NULL);
4793428d7b3dSmrg  assert (pat != NULL);
4794428d7b3dSmrg
4795428d7b3dSmrg  len = strlen (str);
4796428d7b3dSmrg  patlen = strlen (pat);
4797428d7b3dSmrg
4798428d7b3dSmrg  if (patlen <= len)
4799428d7b3dSmrg    {
4800428d7b3dSmrg      str += len - patlen;
4801428d7b3dSmrg      if (strcmp (str, pat) == 0)
4802428d7b3dSmrg	*str = '\0';
4803428d7b3dSmrg    }
4804428d7b3dSmrg  return str;
4805428d7b3dSmrg}
4806428d7b3dSmrg
4807428d7b3dSmrgvoid
4808428d7b3dSmrglt_debugprintf (const char *file, int line, const char *fmt, ...)
4809428d7b3dSmrg{
4810428d7b3dSmrg  va_list args;
4811428d7b3dSmrg  if (lt_debug)
4812428d7b3dSmrg    {
4813428d7b3dSmrg      (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line);
4814428d7b3dSmrg      va_start (args, fmt);
4815428d7b3dSmrg      (void) vfprintf (stderr, fmt, args);
4816428d7b3dSmrg      va_end (args);
4817428d7b3dSmrg    }
4818428d7b3dSmrg}
4819428d7b3dSmrg
4820428d7b3dSmrgstatic void
4821428d7b3dSmrglt_error_core (int exit_status, const char *file,
4822428d7b3dSmrg	       int line, const char *mode,
4823428d7b3dSmrg	       const char *message, va_list ap)
4824428d7b3dSmrg{
4825428d7b3dSmrg  fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode);
4826428d7b3dSmrg  vfprintf (stderr, message, ap);
4827428d7b3dSmrg  fprintf (stderr, ".\n");
4828428d7b3dSmrg
4829428d7b3dSmrg  if (exit_status >= 0)
4830428d7b3dSmrg    exit (exit_status);
4831428d7b3dSmrg}
4832428d7b3dSmrg
4833428d7b3dSmrgvoid
4834428d7b3dSmrglt_fatal (const char *file, int line, const char *message, ...)
4835428d7b3dSmrg{
4836428d7b3dSmrg  va_list ap;
4837428d7b3dSmrg  va_start (ap, message);
4838428d7b3dSmrg  lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap);
4839428d7b3dSmrg  va_end (ap);
4840428d7b3dSmrg}
4841428d7b3dSmrg
4842428d7b3dSmrgstatic const char *
4843428d7b3dSmrgnonnull (const char *s)
4844428d7b3dSmrg{
4845428d7b3dSmrg  return s ? s : "(null)";
4846428d7b3dSmrg}
4847428d7b3dSmrg
4848428d7b3dSmrgstatic const char *
4849428d7b3dSmrgnonempty (const char *s)
4850428d7b3dSmrg{
4851428d7b3dSmrg  return (s && !*s) ? "(empty)" : nonnull (s);
4852428d7b3dSmrg}
4853428d7b3dSmrg
4854428d7b3dSmrgvoid
4855428d7b3dSmrglt_setenv (const char *name, const char *value)
4856428d7b3dSmrg{
4857428d7b3dSmrg  lt_debugprintf (__FILE__, __LINE__,
4858428d7b3dSmrg		  "(lt_setenv) setting '%s' to '%s'\n",
4859428d7b3dSmrg                  nonnull (name), nonnull (value));
4860428d7b3dSmrg  {
4861428d7b3dSmrg#ifdef HAVE_SETENV
4862428d7b3dSmrg    /* always make a copy, for consistency with !HAVE_SETENV */
4863428d7b3dSmrg    char *str = xstrdup (value);
4864428d7b3dSmrg    setenv (name, str, 1);
4865428d7b3dSmrg#else
4866428d7b3dSmrg    int len = strlen (name) + 1 + strlen (value) + 1;
4867428d7b3dSmrg    char *str = XMALLOC (char, len);
4868428d7b3dSmrg    sprintf (str, "%s=%s", name, value);
4869428d7b3dSmrg    if (putenv (str) != EXIT_SUCCESS)
4870428d7b3dSmrg      {
4871428d7b3dSmrg        XFREE (str);
4872428d7b3dSmrg      }
4873428d7b3dSmrg#endif
4874428d7b3dSmrg  }
4875428d7b3dSmrg}
4876428d7b3dSmrg
4877428d7b3dSmrgchar *
4878428d7b3dSmrglt_extend_str (const char *orig_value, const char *add, int to_end)
4879428d7b3dSmrg{
4880428d7b3dSmrg  char *new_value;
4881428d7b3dSmrg  if (orig_value && *orig_value)
4882428d7b3dSmrg    {
4883428d7b3dSmrg      int orig_value_len = strlen (orig_value);
4884428d7b3dSmrg      int add_len = strlen (add);
4885428d7b3dSmrg      new_value = XMALLOC (char, add_len + orig_value_len + 1);
4886428d7b3dSmrg      if (to_end)
4887428d7b3dSmrg        {
4888428d7b3dSmrg          strcpy (new_value, orig_value);
4889428d7b3dSmrg          strcpy (new_value + orig_value_len, add);
4890428d7b3dSmrg        }
4891428d7b3dSmrg      else
4892428d7b3dSmrg        {
4893428d7b3dSmrg          strcpy (new_value, add);
4894428d7b3dSmrg          strcpy (new_value + add_len, orig_value);
4895428d7b3dSmrg        }
4896428d7b3dSmrg    }
4897428d7b3dSmrg  else
4898428d7b3dSmrg    {
4899428d7b3dSmrg      new_value = xstrdup (add);
4900428d7b3dSmrg    }
4901428d7b3dSmrg  return new_value;
4902428d7b3dSmrg}
4903428d7b3dSmrg
4904428d7b3dSmrgvoid
4905428d7b3dSmrglt_update_exe_path (const char *name, const char *value)
4906428d7b3dSmrg{
4907428d7b3dSmrg  lt_debugprintf (__FILE__, __LINE__,
4908428d7b3dSmrg		  "(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
4909428d7b3dSmrg                  nonnull (name), nonnull (value));
4910428d7b3dSmrg
4911428d7b3dSmrg  if (name && *name && value && *value)
4912428d7b3dSmrg    {
4913428d7b3dSmrg      char *new_value = lt_extend_str (getenv (name), value, 0);
4914428d7b3dSmrg      /* some systems can't cope with a ':'-terminated path #' */
4915428d7b3dSmrg      int len = strlen (new_value);
4916428d7b3dSmrg      while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
4917428d7b3dSmrg        {
4918428d7b3dSmrg          new_value[len-1] = '\0';
4919428d7b3dSmrg        }
4920428d7b3dSmrg      lt_setenv (name, new_value);
4921428d7b3dSmrg      XFREE (new_value);
4922428d7b3dSmrg    }
4923428d7b3dSmrg}
4924428d7b3dSmrg
4925428d7b3dSmrgvoid
4926428d7b3dSmrglt_update_lib_path (const char *name, const char *value)
4927428d7b3dSmrg{
4928428d7b3dSmrg  lt_debugprintf (__FILE__, __LINE__,
4929428d7b3dSmrg		  "(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
4930428d7b3dSmrg                  nonnull (name), nonnull (value));
4931428d7b3dSmrg
4932428d7b3dSmrg  if (name && *name && value && *value)
4933428d7b3dSmrg    {
4934428d7b3dSmrg      char *new_value = lt_extend_str (getenv (name), value, 0);
4935428d7b3dSmrg      lt_setenv (name, new_value);
4936428d7b3dSmrg      XFREE (new_value);
4937428d7b3dSmrg    }
4938428d7b3dSmrg}
4939428d7b3dSmrg
4940428d7b3dSmrgEOF
4941428d7b3dSmrg	    case $host_os in
4942428d7b3dSmrg	      mingw*)
4943428d7b3dSmrg		cat <<"EOF"
4944428d7b3dSmrg
4945428d7b3dSmrg/* Prepares an argument vector before calling spawn().
4946428d7b3dSmrg   Note that spawn() does not by itself call the command interpreter
4947428d7b3dSmrg     (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
4948428d7b3dSmrg      ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
4949428d7b3dSmrg         GetVersionEx(&v);
4950428d7b3dSmrg         v.dwPlatformId == VER_PLATFORM_WIN32_NT;
4951428d7b3dSmrg      }) ? "cmd.exe" : "command.com").
4952428d7b3dSmrg   Instead it simply concatenates the arguments, separated by ' ', and calls
4953428d7b3dSmrg   CreateProcess().  We must quote the arguments since Win32 CreateProcess()
4954428d7b3dSmrg   interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
4955428d7b3dSmrg   special way:
4956428d7b3dSmrg   - Space and tab are interpreted as delimiters. They are not treated as
4957428d7b3dSmrg     delimiters if they are surrounded by double quotes: "...".
4958428d7b3dSmrg   - Unescaped double quotes are removed from the input. Their only effect is
4959428d7b3dSmrg     that within double quotes, space and tab are treated like normal
4960428d7b3dSmrg     characters.
4961428d7b3dSmrg   - Backslashes not followed by double quotes are not special.
4962428d7b3dSmrg   - But 2*n+1 backslashes followed by a double quote become
4963428d7b3dSmrg     n backslashes followed by a double quote (n >= 0):
4964428d7b3dSmrg       \" -> "
4965428d7b3dSmrg       \\\" -> \"
4966428d7b3dSmrg       \\\\\" -> \\"
4967428d7b3dSmrg */
4968428d7b3dSmrg#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"
4969428d7b3dSmrg#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"
4970428d7b3dSmrgchar **
4971428d7b3dSmrgprepare_spawn (char **argv)
4972428d7b3dSmrg{
4973428d7b3dSmrg  size_t argc;
4974428d7b3dSmrg  char **new_argv;
4975428d7b3dSmrg  size_t i;
4976428d7b3dSmrg
4977428d7b3dSmrg  /* Count number of arguments.  */
4978428d7b3dSmrg  for (argc = 0; argv[argc] != NULL; argc++)
4979428d7b3dSmrg    ;
4980428d7b3dSmrg
4981428d7b3dSmrg  /* Allocate new argument vector.  */
4982428d7b3dSmrg  new_argv = XMALLOC (char *, argc + 1);
4983428d7b3dSmrg
4984428d7b3dSmrg  /* Put quoted arguments into the new argument vector.  */
4985428d7b3dSmrg  for (i = 0; i < argc; i++)
4986428d7b3dSmrg    {
4987428d7b3dSmrg      const char *string = argv[i];
4988428d7b3dSmrg
4989428d7b3dSmrg      if (string[0] == '\0')
4990428d7b3dSmrg	new_argv[i] = xstrdup ("\"\"");
4991428d7b3dSmrg      else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
4992428d7b3dSmrg	{
4993428d7b3dSmrg	  int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
4994428d7b3dSmrg	  size_t length;
4995428d7b3dSmrg	  unsigned int backslashes;
4996428d7b3dSmrg	  const char *s;
4997428d7b3dSmrg	  char *quoted_string;
4998428d7b3dSmrg	  char *p;
4999428d7b3dSmrg
5000428d7b3dSmrg	  length = 0;
5001428d7b3dSmrg	  backslashes = 0;
5002428d7b3dSmrg	  if (quote_around)
5003428d7b3dSmrg	    length++;
5004428d7b3dSmrg	  for (s = string; *s != '\0'; s++)
5005428d7b3dSmrg	    {
5006428d7b3dSmrg	      char c = *s;
5007428d7b3dSmrg	      if (c == '"')
5008428d7b3dSmrg		length += backslashes + 1;
5009428d7b3dSmrg	      length++;
5010428d7b3dSmrg	      if (c == '\\')
5011428d7b3dSmrg		backslashes++;
5012428d7b3dSmrg	      else
5013428d7b3dSmrg		backslashes = 0;
5014428d7b3dSmrg	    }
5015428d7b3dSmrg	  if (quote_around)
5016428d7b3dSmrg	    length += backslashes + 1;
5017428d7b3dSmrg
5018428d7b3dSmrg	  quoted_string = XMALLOC (char, length + 1);
5019428d7b3dSmrg
5020428d7b3dSmrg	  p = quoted_string;
5021428d7b3dSmrg	  backslashes = 0;
5022428d7b3dSmrg	  if (quote_around)
5023428d7b3dSmrg	    *p++ = '"';
5024428d7b3dSmrg	  for (s = string; *s != '\0'; s++)
5025428d7b3dSmrg	    {
5026428d7b3dSmrg	      char c = *s;
5027428d7b3dSmrg	      if (c == '"')
5028428d7b3dSmrg		{
5029428d7b3dSmrg		  unsigned int j;
5030428d7b3dSmrg		  for (j = backslashes + 1; j > 0; j--)
5031428d7b3dSmrg		    *p++ = '\\';
5032428d7b3dSmrg		}
5033428d7b3dSmrg	      *p++ = c;
5034428d7b3dSmrg	      if (c == '\\')
5035428d7b3dSmrg		backslashes++;
5036428d7b3dSmrg	      else
5037428d7b3dSmrg		backslashes = 0;
5038428d7b3dSmrg	    }
5039428d7b3dSmrg	  if (quote_around)
5040428d7b3dSmrg	    {
5041428d7b3dSmrg	      unsigned int j;
5042428d7b3dSmrg	      for (j = backslashes; j > 0; j--)
5043428d7b3dSmrg		*p++ = '\\';
5044428d7b3dSmrg	      *p++ = '"';
5045428d7b3dSmrg	    }
5046428d7b3dSmrg	  *p = '\0';
5047428d7b3dSmrg
5048428d7b3dSmrg	  new_argv[i] = quoted_string;
5049428d7b3dSmrg	}
5050428d7b3dSmrg      else
5051428d7b3dSmrg	new_argv[i] = (char *) string;
5052428d7b3dSmrg    }
5053428d7b3dSmrg  new_argv[argc] = NULL;
5054428d7b3dSmrg
5055428d7b3dSmrg  return new_argv;
5056428d7b3dSmrg}
5057428d7b3dSmrgEOF
5058428d7b3dSmrg		;;
5059428d7b3dSmrg	    esac
5060428d7b3dSmrg
5061428d7b3dSmrg            cat <<"EOF"
5062428d7b3dSmrgvoid lt_dump_script (FILE* f)
5063428d7b3dSmrg{
5064428d7b3dSmrgEOF
5065428d7b3dSmrg	    func_emit_wrapper yes |
5066428d7b3dSmrg	      $SED -n -e '
5067428d7b3dSmrgs/^\(.\{79\}\)\(..*\)/\1\
5068428d7b3dSmrg\2/
5069428d7b3dSmrgh
5070428d7b3dSmrgs/\([\\"]\)/\\\1/g
5071428d7b3dSmrgs/$/\\n/
5072428d7b3dSmrgs/\([^\n]*\).*/  fputs ("\1", f);/p
5073428d7b3dSmrgg
5074428d7b3dSmrgD'
5075428d7b3dSmrg            cat <<"EOF"
5076428d7b3dSmrg}
5077428d7b3dSmrgEOF
5078428d7b3dSmrg}
5079428d7b3dSmrg# end: func_emit_cwrapperexe_src
5080428d7b3dSmrg
5081428d7b3dSmrg# func_win32_import_lib_p ARG
5082428d7b3dSmrg# True if ARG is an import lib, as indicated by $file_magic_cmd
5083428d7b3dSmrgfunc_win32_import_lib_p ()
5084428d7b3dSmrg{
5085428d7b3dSmrg    $opt_debug
5086428d7b3dSmrg    case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
5087428d7b3dSmrg    *import*) : ;;
5088428d7b3dSmrg    *) false ;;
5089428d7b3dSmrg    esac
5090428d7b3dSmrg}
5091428d7b3dSmrg
5092428d7b3dSmrg# func_mode_link arg...
5093428d7b3dSmrgfunc_mode_link ()
5094428d7b3dSmrg{
5095428d7b3dSmrg    $opt_debug
5096428d7b3dSmrg    case $host in
5097428d7b3dSmrg    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
5098428d7b3dSmrg      # It is impossible to link a dll without this setting, and
5099428d7b3dSmrg      # we shouldn't force the makefile maintainer to figure out
5100428d7b3dSmrg      # which system we are compiling for in order to pass an extra
5101428d7b3dSmrg      # flag for every libtool invocation.
5102428d7b3dSmrg      # allow_undefined=no
5103428d7b3dSmrg
5104428d7b3dSmrg      # FIXME: Unfortunately, there are problems with the above when trying
5105428d7b3dSmrg      # to make a dll which has undefined symbols, in which case not
5106428d7b3dSmrg      # even a static library is built.  For now, we need to specify
5107428d7b3dSmrg      # -no-undefined on the libtool link line when we can be certain
5108428d7b3dSmrg      # that all symbols are satisfied, otherwise we get a static library.
5109428d7b3dSmrg      allow_undefined=yes
5110428d7b3dSmrg      ;;
5111428d7b3dSmrg    *)
5112428d7b3dSmrg      allow_undefined=yes
5113428d7b3dSmrg      ;;
5114428d7b3dSmrg    esac
5115428d7b3dSmrg    libtool_args=$nonopt
5116428d7b3dSmrg    base_compile="$nonopt $@"
5117428d7b3dSmrg    compile_command=$nonopt
5118428d7b3dSmrg    finalize_command=$nonopt
5119428d7b3dSmrg
5120428d7b3dSmrg    compile_rpath=
5121428d7b3dSmrg    finalize_rpath=
5122428d7b3dSmrg    compile_shlibpath=
5123428d7b3dSmrg    finalize_shlibpath=
5124428d7b3dSmrg    convenience=
5125428d7b3dSmrg    old_convenience=
5126428d7b3dSmrg    deplibs=
5127428d7b3dSmrg    old_deplibs=
5128428d7b3dSmrg    compiler_flags=
5129428d7b3dSmrg    linker_flags=
5130428d7b3dSmrg    dllsearchpath=
5131428d7b3dSmrg    lib_search_path=`pwd`
5132428d7b3dSmrg    inst_prefix_dir=
5133428d7b3dSmrg    new_inherited_linker_flags=
5134428d7b3dSmrg
5135428d7b3dSmrg    avoid_version=no
5136428d7b3dSmrg    bindir=
5137428d7b3dSmrg    dlfiles=
5138428d7b3dSmrg    dlprefiles=
5139428d7b3dSmrg    dlself=no
5140428d7b3dSmrg    export_dynamic=no
5141428d7b3dSmrg    export_symbols=
5142428d7b3dSmrg    export_symbols_regex=
5143428d7b3dSmrg    generated=
5144428d7b3dSmrg    libobjs=
5145428d7b3dSmrg    ltlibs=
5146428d7b3dSmrg    module=no
5147428d7b3dSmrg    no_install=no
5148428d7b3dSmrg    objs=
5149428d7b3dSmrg    non_pic_objects=
5150428d7b3dSmrg    precious_files_regex=
5151428d7b3dSmrg    prefer_static_libs=no
5152428d7b3dSmrg    preload=no
5153428d7b3dSmrg    prev=
5154428d7b3dSmrg    prevarg=
5155428d7b3dSmrg    release=
5156428d7b3dSmrg    rpath=
5157428d7b3dSmrg    xrpath=
5158428d7b3dSmrg    perm_rpath=
5159428d7b3dSmrg    temp_rpath=
5160428d7b3dSmrg    thread_safe=no
5161428d7b3dSmrg    vinfo=
5162428d7b3dSmrg    vinfo_number=no
5163428d7b3dSmrg    weak_libs=
5164428d7b3dSmrg    single_module="${wl}-single_module"
5165428d7b3dSmrg    func_infer_tag $base_compile
5166428d7b3dSmrg
5167428d7b3dSmrg    # We need to know -static, to get the right output filenames.
5168428d7b3dSmrg    for arg
5169428d7b3dSmrg    do
5170428d7b3dSmrg      case $arg in
5171428d7b3dSmrg      -shared)
5172428d7b3dSmrg	test "$build_libtool_libs" != yes && \
5173428d7b3dSmrg	  func_fatal_configuration "can not build a shared library"
5174428d7b3dSmrg	build_old_libs=no
5175428d7b3dSmrg	break
5176428d7b3dSmrg	;;
5177428d7b3dSmrg      -all-static | -static | -static-libtool-libs)
5178428d7b3dSmrg	case $arg in
5179428d7b3dSmrg	-all-static)
5180428d7b3dSmrg	  if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
5181428d7b3dSmrg	    func_warning "complete static linking is impossible in this configuration"
5182428d7b3dSmrg	  fi
5183428d7b3dSmrg	  if test -n "$link_static_flag"; then
5184428d7b3dSmrg	    dlopen_self=$dlopen_self_static
5185428d7b3dSmrg	  fi
5186428d7b3dSmrg	  prefer_static_libs=yes
5187428d7b3dSmrg	  ;;
5188428d7b3dSmrg	-static)
5189428d7b3dSmrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
5190428d7b3dSmrg	    dlopen_self=$dlopen_self_static
5191428d7b3dSmrg	  fi
5192428d7b3dSmrg	  prefer_static_libs=built
5193428d7b3dSmrg	  ;;
5194428d7b3dSmrg	-static-libtool-libs)
5195428d7b3dSmrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
5196428d7b3dSmrg	    dlopen_self=$dlopen_self_static
5197428d7b3dSmrg	  fi
5198428d7b3dSmrg	  prefer_static_libs=yes
5199428d7b3dSmrg	  ;;
5200428d7b3dSmrg	esac
5201428d7b3dSmrg	build_libtool_libs=no
5202428d7b3dSmrg	build_old_libs=yes
5203428d7b3dSmrg	break
5204428d7b3dSmrg	;;
5205428d7b3dSmrg      esac
5206428d7b3dSmrg    done
5207428d7b3dSmrg
5208428d7b3dSmrg    # See if our shared archives depend on static archives.
5209428d7b3dSmrg    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
5210428d7b3dSmrg
5211428d7b3dSmrg    # Go through the arguments, transforming them on the way.
5212428d7b3dSmrg    while test "$#" -gt 0; do
5213428d7b3dSmrg      arg="$1"
5214428d7b3dSmrg      shift
5215428d7b3dSmrg      func_quote_for_eval "$arg"
5216428d7b3dSmrg      qarg=$func_quote_for_eval_unquoted_result
5217428d7b3dSmrg      func_append libtool_args " $func_quote_for_eval_result"
5218428d7b3dSmrg
5219428d7b3dSmrg      # If the previous option needs an argument, assign it.
5220428d7b3dSmrg      if test -n "$prev"; then
5221428d7b3dSmrg	case $prev in
5222428d7b3dSmrg	output)
5223428d7b3dSmrg	  func_append compile_command " @OUTPUT@"
5224428d7b3dSmrg	  func_append finalize_command " @OUTPUT@"
5225428d7b3dSmrg	  ;;
5226428d7b3dSmrg	esac
5227428d7b3dSmrg
5228428d7b3dSmrg	case $prev in
5229428d7b3dSmrg	bindir)
5230428d7b3dSmrg	  bindir="$arg"
5231428d7b3dSmrg	  prev=
5232428d7b3dSmrg	  continue
5233428d7b3dSmrg	  ;;
5234428d7b3dSmrg	dlfiles|dlprefiles)
5235428d7b3dSmrg	  if test "$preload" = no; then
5236428d7b3dSmrg	    # Add the symbol object into the linking commands.
5237428d7b3dSmrg	    func_append compile_command " @SYMFILE@"
5238428d7b3dSmrg	    func_append finalize_command " @SYMFILE@"
5239428d7b3dSmrg	    preload=yes
5240428d7b3dSmrg	  fi
5241428d7b3dSmrg	  case $arg in
5242428d7b3dSmrg	  *.la | *.lo) ;;  # We handle these cases below.
5243428d7b3dSmrg	  force)
5244428d7b3dSmrg	    if test "$dlself" = no; then
5245428d7b3dSmrg	      dlself=needless
5246428d7b3dSmrg	      export_dynamic=yes
5247428d7b3dSmrg	    fi
5248428d7b3dSmrg	    prev=
5249428d7b3dSmrg	    continue
5250428d7b3dSmrg	    ;;
5251428d7b3dSmrg	  self)
5252428d7b3dSmrg	    if test "$prev" = dlprefiles; then
5253428d7b3dSmrg	      dlself=yes
5254428d7b3dSmrg	    elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
5255428d7b3dSmrg	      dlself=yes
5256428d7b3dSmrg	    else
5257428d7b3dSmrg	      dlself=needless
5258428d7b3dSmrg	      export_dynamic=yes
5259428d7b3dSmrg	    fi
5260428d7b3dSmrg	    prev=
5261428d7b3dSmrg	    continue
5262428d7b3dSmrg	    ;;
5263428d7b3dSmrg	  *)
5264428d7b3dSmrg	    if test "$prev" = dlfiles; then
5265428d7b3dSmrg	      func_append dlfiles " $arg"
5266428d7b3dSmrg	    else
5267428d7b3dSmrg	      func_append dlprefiles " $arg"
5268428d7b3dSmrg	    fi
5269428d7b3dSmrg	    prev=
5270428d7b3dSmrg	    continue
5271428d7b3dSmrg	    ;;
5272428d7b3dSmrg	  esac
5273428d7b3dSmrg	  ;;
5274428d7b3dSmrg	expsyms)
5275428d7b3dSmrg	  export_symbols="$arg"
5276428d7b3dSmrg	  test -f "$arg" \
5277428d7b3dSmrg	    || func_fatal_error "symbol file \`$arg' does not exist"
5278428d7b3dSmrg	  prev=
5279428d7b3dSmrg	  continue
5280428d7b3dSmrg	  ;;
5281428d7b3dSmrg	expsyms_regex)
5282428d7b3dSmrg	  export_symbols_regex="$arg"
5283428d7b3dSmrg	  prev=
5284428d7b3dSmrg	  continue
5285428d7b3dSmrg	  ;;
5286428d7b3dSmrg	framework)
5287428d7b3dSmrg	  case $host in
5288428d7b3dSmrg	    *-*-darwin*)
5289428d7b3dSmrg	      case "$deplibs " in
5290428d7b3dSmrg		*" $qarg.ltframework "*) ;;
5291428d7b3dSmrg		*) func_append deplibs " $qarg.ltframework" # this is fixed later
5292428d7b3dSmrg		   ;;
5293428d7b3dSmrg	      esac
5294428d7b3dSmrg	      ;;
5295428d7b3dSmrg	  esac
5296428d7b3dSmrg	  prev=
5297428d7b3dSmrg	  continue
5298428d7b3dSmrg	  ;;
5299428d7b3dSmrg	inst_prefix)
5300428d7b3dSmrg	  inst_prefix_dir="$arg"
5301428d7b3dSmrg	  prev=
5302428d7b3dSmrg	  continue
5303428d7b3dSmrg	  ;;
5304428d7b3dSmrg	objectlist)
5305428d7b3dSmrg	  if test -f "$arg"; then
5306428d7b3dSmrg	    save_arg=$arg
5307428d7b3dSmrg	    moreargs=
5308428d7b3dSmrg	    for fil in `cat "$save_arg"`
5309428d7b3dSmrg	    do
5310428d7b3dSmrg#	      func_append moreargs " $fil"
5311428d7b3dSmrg	      arg=$fil
5312428d7b3dSmrg	      # A libtool-controlled object.
5313428d7b3dSmrg
5314428d7b3dSmrg	      # Check to see that this really is a libtool object.
5315428d7b3dSmrg	      if func_lalib_unsafe_p "$arg"; then
5316428d7b3dSmrg		pic_object=
5317428d7b3dSmrg		non_pic_object=
5318428d7b3dSmrg
5319428d7b3dSmrg		# Read the .lo file
5320428d7b3dSmrg		func_source "$arg"
5321428d7b3dSmrg
5322428d7b3dSmrg		if test -z "$pic_object" ||
5323428d7b3dSmrg		   test -z "$non_pic_object" ||
5324428d7b3dSmrg		   test "$pic_object" = none &&
5325428d7b3dSmrg		   test "$non_pic_object" = none; then
5326428d7b3dSmrg		  func_fatal_error "cannot find name of object for \`$arg'"
5327428d7b3dSmrg		fi
5328428d7b3dSmrg
5329428d7b3dSmrg		# Extract subdirectory from the argument.
5330428d7b3dSmrg		func_dirname "$arg" "/" ""
5331428d7b3dSmrg		xdir="$func_dirname_result"
5332428d7b3dSmrg
5333428d7b3dSmrg		if test "$pic_object" != none; then
5334428d7b3dSmrg		  # Prepend the subdirectory the object is found in.
5335428d7b3dSmrg		  pic_object="$xdir$pic_object"
5336428d7b3dSmrg
5337428d7b3dSmrg		  if test "$prev" = dlfiles; then
5338428d7b3dSmrg		    if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
5339428d7b3dSmrg		      func_append dlfiles " $pic_object"
5340428d7b3dSmrg		      prev=
5341428d7b3dSmrg		      continue
5342428d7b3dSmrg		    else
5343428d7b3dSmrg		      # If libtool objects are unsupported, then we need to preload.
5344428d7b3dSmrg		      prev=dlprefiles
5345428d7b3dSmrg		    fi
5346428d7b3dSmrg		  fi
5347428d7b3dSmrg
5348428d7b3dSmrg		  # CHECK ME:  I think I busted this.  -Ossama
5349428d7b3dSmrg		  if test "$prev" = dlprefiles; then
5350428d7b3dSmrg		    # Preload the old-style object.
5351428d7b3dSmrg		    func_append dlprefiles " $pic_object"
5352428d7b3dSmrg		    prev=
5353428d7b3dSmrg		  fi
5354428d7b3dSmrg
5355428d7b3dSmrg		  # A PIC object.
5356428d7b3dSmrg		  func_append libobjs " $pic_object"
5357428d7b3dSmrg		  arg="$pic_object"
5358428d7b3dSmrg		fi
5359428d7b3dSmrg
5360428d7b3dSmrg		# Non-PIC object.
5361428d7b3dSmrg		if test "$non_pic_object" != none; then
5362428d7b3dSmrg		  # Prepend the subdirectory the object is found in.
5363428d7b3dSmrg		  non_pic_object="$xdir$non_pic_object"
5364428d7b3dSmrg
5365428d7b3dSmrg		  # A standard non-PIC object
5366428d7b3dSmrg		  func_append non_pic_objects " $non_pic_object"
5367428d7b3dSmrg		  if test -z "$pic_object" || test "$pic_object" = none ; then
5368428d7b3dSmrg		    arg="$non_pic_object"
5369428d7b3dSmrg		  fi
5370428d7b3dSmrg		else
5371428d7b3dSmrg		  # If the PIC object exists, use it instead.
5372428d7b3dSmrg		  # $xdir was prepended to $pic_object above.
5373428d7b3dSmrg		  non_pic_object="$pic_object"
5374428d7b3dSmrg		  func_append non_pic_objects " $non_pic_object"
5375428d7b3dSmrg		fi
5376428d7b3dSmrg	      else
5377428d7b3dSmrg		# Only an error if not doing a dry-run.
5378428d7b3dSmrg		if $opt_dry_run; then
5379428d7b3dSmrg		  # Extract subdirectory from the argument.
5380428d7b3dSmrg		  func_dirname "$arg" "/" ""
5381428d7b3dSmrg		  xdir="$func_dirname_result"
5382428d7b3dSmrg
5383428d7b3dSmrg		  func_lo2o "$arg"
5384428d7b3dSmrg		  pic_object=$xdir$objdir/$func_lo2o_result
5385428d7b3dSmrg		  non_pic_object=$xdir$func_lo2o_result
5386428d7b3dSmrg		  func_append libobjs " $pic_object"
5387428d7b3dSmrg		  func_append non_pic_objects " $non_pic_object"
5388428d7b3dSmrg	        else
5389428d7b3dSmrg		  func_fatal_error "\`$arg' is not a valid libtool object"
5390428d7b3dSmrg		fi
5391428d7b3dSmrg	      fi
5392428d7b3dSmrg	    done
5393428d7b3dSmrg	  else
5394428d7b3dSmrg	    func_fatal_error "link input file \`$arg' does not exist"
5395428d7b3dSmrg	  fi
5396428d7b3dSmrg	  arg=$save_arg
5397428d7b3dSmrg	  prev=
5398428d7b3dSmrg	  continue
5399428d7b3dSmrg	  ;;
5400428d7b3dSmrg	precious_regex)
5401428d7b3dSmrg	  precious_files_regex="$arg"
5402428d7b3dSmrg	  prev=
5403428d7b3dSmrg	  continue
5404428d7b3dSmrg	  ;;
5405428d7b3dSmrg	release)
5406428d7b3dSmrg	  release="-$arg"
5407428d7b3dSmrg	  prev=
5408428d7b3dSmrg	  continue
5409428d7b3dSmrg	  ;;
5410428d7b3dSmrg	rpath | xrpath)
5411428d7b3dSmrg	  # We need an absolute path.
5412428d7b3dSmrg	  case $arg in
5413428d7b3dSmrg	  [\\/]* | [A-Za-z]:[\\/]*) ;;
5414428d7b3dSmrg	  *)
5415428d7b3dSmrg	    func_fatal_error "only absolute run-paths are allowed"
5416428d7b3dSmrg	    ;;
5417428d7b3dSmrg	  esac
5418428d7b3dSmrg	  if test "$prev" = rpath; then
5419428d7b3dSmrg	    case "$rpath " in
5420428d7b3dSmrg	    *" $arg "*) ;;
5421428d7b3dSmrg	    *) func_append rpath " $arg" ;;
5422428d7b3dSmrg	    esac
5423428d7b3dSmrg	  else
5424428d7b3dSmrg	    case "$xrpath " in
5425428d7b3dSmrg	    *" $arg "*) ;;
5426428d7b3dSmrg	    *) func_append xrpath " $arg" ;;
5427428d7b3dSmrg	    esac
5428428d7b3dSmrg	  fi
5429428d7b3dSmrg	  prev=
5430428d7b3dSmrg	  continue
5431428d7b3dSmrg	  ;;
5432428d7b3dSmrg	shrext)
5433428d7b3dSmrg	  shrext_cmds="$arg"
5434428d7b3dSmrg	  prev=
5435428d7b3dSmrg	  continue
5436428d7b3dSmrg	  ;;
5437428d7b3dSmrg	weak)
5438428d7b3dSmrg	  func_append weak_libs " $arg"
5439428d7b3dSmrg	  prev=
5440428d7b3dSmrg	  continue
5441428d7b3dSmrg	  ;;
5442428d7b3dSmrg	xcclinker)
5443428d7b3dSmrg	  func_append linker_flags " $qarg"
5444428d7b3dSmrg	  func_append compiler_flags " $qarg"
5445428d7b3dSmrg	  prev=
5446428d7b3dSmrg	  func_append compile_command " $qarg"
5447428d7b3dSmrg	  func_append finalize_command " $qarg"
5448428d7b3dSmrg	  continue
5449428d7b3dSmrg	  ;;
5450428d7b3dSmrg	xcompiler)
5451428d7b3dSmrg	  func_append compiler_flags " $qarg"
5452428d7b3dSmrg	  prev=
5453428d7b3dSmrg	  func_append compile_command " $qarg"
5454428d7b3dSmrg	  func_append finalize_command " $qarg"
5455428d7b3dSmrg	  continue
5456428d7b3dSmrg	  ;;
5457428d7b3dSmrg	xlinker)
5458428d7b3dSmrg	  func_append linker_flags " $qarg"
5459428d7b3dSmrg	  func_append compiler_flags " $wl$qarg"
5460428d7b3dSmrg	  prev=
5461428d7b3dSmrg	  func_append compile_command " $wl$qarg"
5462428d7b3dSmrg	  func_append finalize_command " $wl$qarg"
5463428d7b3dSmrg	  continue
5464428d7b3dSmrg	  ;;
5465428d7b3dSmrg	*)
5466428d7b3dSmrg	  eval "$prev=\"\$arg\""
5467428d7b3dSmrg	  prev=
5468428d7b3dSmrg	  continue
5469428d7b3dSmrg	  ;;
5470428d7b3dSmrg	esac
5471428d7b3dSmrg      fi # test -n "$prev"
5472428d7b3dSmrg
5473428d7b3dSmrg      prevarg="$arg"
5474428d7b3dSmrg
5475428d7b3dSmrg      case $arg in
5476428d7b3dSmrg      -all-static)
5477428d7b3dSmrg	if test -n "$link_static_flag"; then
5478428d7b3dSmrg	  # See comment for -static flag below, for more details.
5479428d7b3dSmrg	  func_append compile_command " $link_static_flag"
5480428d7b3dSmrg	  func_append finalize_command " $link_static_flag"
5481428d7b3dSmrg	fi
5482428d7b3dSmrg	continue
5483428d7b3dSmrg	;;
5484428d7b3dSmrg
5485428d7b3dSmrg      -allow-undefined)
5486428d7b3dSmrg	# FIXME: remove this flag sometime in the future.
5487428d7b3dSmrg	func_fatal_error "\`-allow-undefined' must not be used because it is the default"
5488428d7b3dSmrg	;;
5489428d7b3dSmrg
5490428d7b3dSmrg      -avoid-version)
5491428d7b3dSmrg	avoid_version=yes
5492428d7b3dSmrg	continue
5493428d7b3dSmrg	;;
5494428d7b3dSmrg
5495428d7b3dSmrg      -bindir)
5496428d7b3dSmrg	prev=bindir
5497428d7b3dSmrg	continue
5498428d7b3dSmrg	;;
5499428d7b3dSmrg
5500428d7b3dSmrg      -dlopen)
5501428d7b3dSmrg	prev=dlfiles
5502428d7b3dSmrg	continue
5503428d7b3dSmrg	;;
5504428d7b3dSmrg
5505428d7b3dSmrg      -dlpreopen)
5506428d7b3dSmrg	prev=dlprefiles
5507428d7b3dSmrg	continue
5508428d7b3dSmrg	;;
5509428d7b3dSmrg
5510428d7b3dSmrg      -export-dynamic)
5511428d7b3dSmrg	export_dynamic=yes
5512428d7b3dSmrg	continue
5513428d7b3dSmrg	;;
5514428d7b3dSmrg
5515428d7b3dSmrg      -export-symbols | -export-symbols-regex)
5516428d7b3dSmrg	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
5517428d7b3dSmrg	  func_fatal_error "more than one -exported-symbols argument is not allowed"
5518428d7b3dSmrg	fi
5519428d7b3dSmrg	if test "X$arg" = "X-export-symbols"; then
5520428d7b3dSmrg	  prev=expsyms
5521428d7b3dSmrg	else
5522428d7b3dSmrg	  prev=expsyms_regex
5523428d7b3dSmrg	fi
5524428d7b3dSmrg	continue
5525428d7b3dSmrg	;;
5526428d7b3dSmrg
5527428d7b3dSmrg      -framework)
5528428d7b3dSmrg	prev=framework
5529428d7b3dSmrg	continue
5530428d7b3dSmrg	;;
5531428d7b3dSmrg
5532428d7b3dSmrg      -inst-prefix-dir)
5533428d7b3dSmrg	prev=inst_prefix
5534428d7b3dSmrg	continue
5535428d7b3dSmrg	;;
5536428d7b3dSmrg
5537428d7b3dSmrg      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
5538428d7b3dSmrg      # so, if we see these flags be careful not to treat them like -L
5539428d7b3dSmrg      -L[A-Z][A-Z]*:*)
5540428d7b3dSmrg	case $with_gcc/$host in
5541428d7b3dSmrg	no/*-*-irix* | /*-*-irix*)
5542428d7b3dSmrg	  func_append compile_command " $arg"
5543428d7b3dSmrg	  func_append finalize_command " $arg"
5544428d7b3dSmrg	  ;;
5545428d7b3dSmrg	esac
5546428d7b3dSmrg	continue
5547428d7b3dSmrg	;;
5548428d7b3dSmrg
5549428d7b3dSmrg      -L*)
5550428d7b3dSmrg	func_stripname "-L" '' "$arg"
5551428d7b3dSmrg	if test -z "$func_stripname_result"; then
5552428d7b3dSmrg	  if test "$#" -gt 0; then
5553428d7b3dSmrg	    func_fatal_error "require no space between \`-L' and \`$1'"
5554428d7b3dSmrg	  else
5555428d7b3dSmrg	    func_fatal_error "need path for \`-L' option"
5556428d7b3dSmrg	  fi
5557428d7b3dSmrg	fi
5558428d7b3dSmrg	func_resolve_sysroot "$func_stripname_result"
5559428d7b3dSmrg	dir=$func_resolve_sysroot_result
5560428d7b3dSmrg	# We need an absolute path.
5561428d7b3dSmrg	case $dir in
5562428d7b3dSmrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
5563428d7b3dSmrg	*)
5564428d7b3dSmrg	  absdir=`cd "$dir" && pwd`
5565428d7b3dSmrg	  test -z "$absdir" && \
5566428d7b3dSmrg	    func_fatal_error "cannot determine absolute directory name of \`$dir'"
5567428d7b3dSmrg	  dir="$absdir"
5568428d7b3dSmrg	  ;;
5569428d7b3dSmrg	esac
5570428d7b3dSmrg	case "$deplibs " in
5571428d7b3dSmrg	*" -L$dir "* | *" $arg "*)
5572428d7b3dSmrg	  # Will only happen for absolute or sysroot arguments
5573428d7b3dSmrg	  ;;
5574428d7b3dSmrg	*)
5575428d7b3dSmrg	  # Preserve sysroot, but never include relative directories
5576428d7b3dSmrg	  case $dir in
5577428d7b3dSmrg	    [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;;
5578428d7b3dSmrg	    *) func_append deplibs " -L$dir" ;;
5579428d7b3dSmrg	  esac
5580428d7b3dSmrg	  func_append lib_search_path " $dir"
5581428d7b3dSmrg	  ;;
5582428d7b3dSmrg	esac
5583428d7b3dSmrg	case $host in
5584428d7b3dSmrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
5585428d7b3dSmrg	  testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
5586428d7b3dSmrg	  case :$dllsearchpath: in
5587428d7b3dSmrg	  *":$dir:"*) ;;
5588428d7b3dSmrg	  ::) dllsearchpath=$dir;;
5589428d7b3dSmrg	  *) func_append dllsearchpath ":$dir";;
5590428d7b3dSmrg	  esac
5591428d7b3dSmrg	  case :$dllsearchpath: in
5592428d7b3dSmrg	  *":$testbindir:"*) ;;
5593428d7b3dSmrg	  ::) dllsearchpath=$testbindir;;
5594428d7b3dSmrg	  *) func_append dllsearchpath ":$testbindir";;
5595428d7b3dSmrg	  esac
5596428d7b3dSmrg	  ;;
5597428d7b3dSmrg	esac
5598428d7b3dSmrg	continue
5599428d7b3dSmrg	;;
5600428d7b3dSmrg
5601428d7b3dSmrg      -l*)
5602428d7b3dSmrg	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
5603428d7b3dSmrg	  case $host in
5604428d7b3dSmrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
5605428d7b3dSmrg	    # These systems don't actually have a C or math library (as such)
5606428d7b3dSmrg	    continue
5607428d7b3dSmrg	    ;;
5608428d7b3dSmrg	  *-*-os2*)
5609428d7b3dSmrg	    # These systems don't actually have a C library (as such)
5610428d7b3dSmrg	    test "X$arg" = "X-lc" && continue
5611428d7b3dSmrg	    ;;
5612428d7b3dSmrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
5613428d7b3dSmrg	    # Do not include libc due to us having libc/libc_r.
5614428d7b3dSmrg	    test "X$arg" = "X-lc" && continue
5615428d7b3dSmrg	    ;;
5616428d7b3dSmrg	  *-*-rhapsody* | *-*-darwin1.[012])
5617428d7b3dSmrg	    # Rhapsody C and math libraries are in the System framework
5618428d7b3dSmrg	    func_append deplibs " System.ltframework"
5619428d7b3dSmrg	    continue
5620428d7b3dSmrg	    ;;
5621428d7b3dSmrg	  *-*-sco3.2v5* | *-*-sco5v6*)
5622428d7b3dSmrg	    # Causes problems with __ctype
5623428d7b3dSmrg	    test "X$arg" = "X-lc" && continue
5624428d7b3dSmrg	    ;;
5625428d7b3dSmrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
5626428d7b3dSmrg	    # Compiler inserts libc in the correct place for threads to work
5627428d7b3dSmrg	    test "X$arg" = "X-lc" && continue
5628428d7b3dSmrg	    ;;
5629428d7b3dSmrg	  esac
5630428d7b3dSmrg	elif test "X$arg" = "X-lc_r"; then
5631428d7b3dSmrg	 case $host in
5632428d7b3dSmrg	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
5633428d7b3dSmrg	   # Do not include libc_r directly, use -pthread flag.
5634428d7b3dSmrg	   continue
5635428d7b3dSmrg	   ;;
5636428d7b3dSmrg	 esac
5637428d7b3dSmrg	fi
5638428d7b3dSmrg	func_append deplibs " $arg"
5639428d7b3dSmrg	continue
5640428d7b3dSmrg	;;
5641428d7b3dSmrg
5642428d7b3dSmrg      -module)
5643428d7b3dSmrg	module=yes
5644428d7b3dSmrg	continue
5645428d7b3dSmrg	;;
5646428d7b3dSmrg
5647428d7b3dSmrg      # Tru64 UNIX uses -model [arg] to determine the layout of C++
5648428d7b3dSmrg      # classes, name mangling, and exception handling.
5649428d7b3dSmrg      # Darwin uses the -arch flag to determine output architecture.
5650428d7b3dSmrg      -model|-arch|-isysroot|--sysroot)
5651428d7b3dSmrg	func_append compiler_flags " $arg"
5652428d7b3dSmrg	func_append compile_command " $arg"
5653428d7b3dSmrg	func_append finalize_command " $arg"
5654428d7b3dSmrg	prev=xcompiler
5655428d7b3dSmrg	continue
5656428d7b3dSmrg	;;
5657428d7b3dSmrg
5658428d7b3dSmrg      -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
5659428d7b3dSmrg      |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
5660428d7b3dSmrg	func_append compiler_flags " $arg"
5661428d7b3dSmrg	func_append compile_command " $arg"
5662428d7b3dSmrg	func_append finalize_command " $arg"
5663428d7b3dSmrg	case "$new_inherited_linker_flags " in
5664428d7b3dSmrg	    *" $arg "*) ;;
5665428d7b3dSmrg	    * ) func_append new_inherited_linker_flags " $arg" ;;
5666428d7b3dSmrg	esac
5667428d7b3dSmrg	continue
5668428d7b3dSmrg	;;
5669428d7b3dSmrg
5670428d7b3dSmrg      -multi_module)
5671428d7b3dSmrg	single_module="${wl}-multi_module"
5672428d7b3dSmrg	continue
5673428d7b3dSmrg	;;
5674428d7b3dSmrg
5675428d7b3dSmrg      -no-fast-install)
5676428d7b3dSmrg	fast_install=no
5677428d7b3dSmrg	continue
5678428d7b3dSmrg	;;
5679428d7b3dSmrg
5680428d7b3dSmrg      -no-install)
5681428d7b3dSmrg	case $host in
5682428d7b3dSmrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
5683428d7b3dSmrg	  # The PATH hackery in wrapper scripts is required on Windows
5684428d7b3dSmrg	  # and Darwin in order for the loader to find any dlls it needs.
5685428d7b3dSmrg	  func_warning "\`-no-install' is ignored for $host"
5686428d7b3dSmrg	  func_warning "assuming \`-no-fast-install' instead"
5687428d7b3dSmrg	  fast_install=no
5688428d7b3dSmrg	  ;;
5689428d7b3dSmrg	*) no_install=yes ;;
5690428d7b3dSmrg	esac
5691428d7b3dSmrg	continue
5692428d7b3dSmrg	;;
5693428d7b3dSmrg
5694428d7b3dSmrg      -no-undefined)
5695428d7b3dSmrg	allow_undefined=no
5696428d7b3dSmrg	continue
5697428d7b3dSmrg	;;
5698428d7b3dSmrg
5699428d7b3dSmrg      -objectlist)
5700428d7b3dSmrg	prev=objectlist
5701428d7b3dSmrg	continue
5702428d7b3dSmrg	;;
5703428d7b3dSmrg
5704428d7b3dSmrg      -o) prev=output ;;
5705428d7b3dSmrg
5706428d7b3dSmrg      -precious-files-regex)
5707428d7b3dSmrg	prev=precious_regex
5708428d7b3dSmrg	continue
5709428d7b3dSmrg	;;
5710428d7b3dSmrg
5711428d7b3dSmrg      -release)
5712428d7b3dSmrg	prev=release
5713428d7b3dSmrg	continue
5714428d7b3dSmrg	;;
5715428d7b3dSmrg
5716428d7b3dSmrg      -rpath)
5717428d7b3dSmrg	prev=rpath
5718428d7b3dSmrg	continue
5719428d7b3dSmrg	;;
5720428d7b3dSmrg
5721428d7b3dSmrg      -R)
5722428d7b3dSmrg	prev=xrpath
5723428d7b3dSmrg	continue
5724428d7b3dSmrg	;;
5725428d7b3dSmrg
5726428d7b3dSmrg      -R*)
5727428d7b3dSmrg	func_stripname '-R' '' "$arg"
5728428d7b3dSmrg	dir=$func_stripname_result
5729428d7b3dSmrg	# We need an absolute path.
5730428d7b3dSmrg	case $dir in
5731428d7b3dSmrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
5732428d7b3dSmrg	=*)
5733428d7b3dSmrg	  func_stripname '=' '' "$dir"
5734428d7b3dSmrg	  dir=$lt_sysroot$func_stripname_result
5735428d7b3dSmrg	  ;;
5736428d7b3dSmrg	*)
5737428d7b3dSmrg	  func_fatal_error "only absolute run-paths are allowed"
5738428d7b3dSmrg	  ;;
5739428d7b3dSmrg	esac
5740428d7b3dSmrg	case "$xrpath " in
5741428d7b3dSmrg	*" $dir "*) ;;
5742428d7b3dSmrg	*) func_append xrpath " $dir" ;;
5743428d7b3dSmrg	esac
5744428d7b3dSmrg	continue
5745428d7b3dSmrg	;;
5746428d7b3dSmrg
5747428d7b3dSmrg      -shared)
5748428d7b3dSmrg	# The effects of -shared are defined in a previous loop.
5749428d7b3dSmrg	continue
5750428d7b3dSmrg	;;
5751428d7b3dSmrg
5752428d7b3dSmrg      -shrext)
5753428d7b3dSmrg	prev=shrext
5754428d7b3dSmrg	continue
5755428d7b3dSmrg	;;
5756428d7b3dSmrg
5757428d7b3dSmrg      -static | -static-libtool-libs)
5758428d7b3dSmrg	# The effects of -static are defined in a previous loop.
5759428d7b3dSmrg	# We used to do the same as -all-static on platforms that
5760428d7b3dSmrg	# didn't have a PIC flag, but the assumption that the effects
5761428d7b3dSmrg	# would be equivalent was wrong.  It would break on at least
5762428d7b3dSmrg	# Digital Unix and AIX.
5763428d7b3dSmrg	continue
5764428d7b3dSmrg	;;
5765428d7b3dSmrg
5766428d7b3dSmrg      -thread-safe)
5767428d7b3dSmrg	thread_safe=yes
5768428d7b3dSmrg	continue
5769428d7b3dSmrg	;;
5770428d7b3dSmrg
5771428d7b3dSmrg      -version-info)
5772428d7b3dSmrg	prev=vinfo
5773428d7b3dSmrg	continue
5774428d7b3dSmrg	;;
5775428d7b3dSmrg
5776428d7b3dSmrg      -version-number)
5777428d7b3dSmrg	prev=vinfo
5778428d7b3dSmrg	vinfo_number=yes
5779428d7b3dSmrg	continue
5780428d7b3dSmrg	;;
5781428d7b3dSmrg
5782428d7b3dSmrg      -weak)
5783428d7b3dSmrg        prev=weak
5784428d7b3dSmrg	continue
5785428d7b3dSmrg	;;
5786428d7b3dSmrg
5787428d7b3dSmrg      -Wc,*)
5788428d7b3dSmrg	func_stripname '-Wc,' '' "$arg"
5789428d7b3dSmrg	args=$func_stripname_result
5790428d7b3dSmrg	arg=
5791428d7b3dSmrg	save_ifs="$IFS"; IFS=','
5792428d7b3dSmrg	for flag in $args; do
5793428d7b3dSmrg	  IFS="$save_ifs"
5794428d7b3dSmrg          func_quote_for_eval "$flag"
5795428d7b3dSmrg	  func_append arg " $func_quote_for_eval_result"
5796428d7b3dSmrg	  func_append compiler_flags " $func_quote_for_eval_result"
5797428d7b3dSmrg	done
5798428d7b3dSmrg	IFS="$save_ifs"
5799428d7b3dSmrg	func_stripname ' ' '' "$arg"
5800428d7b3dSmrg	arg=$func_stripname_result
5801428d7b3dSmrg	;;
5802428d7b3dSmrg
5803428d7b3dSmrg      -Wl,*)
5804428d7b3dSmrg	func_stripname '-Wl,' '' "$arg"
5805428d7b3dSmrg	args=$func_stripname_result
5806428d7b3dSmrg	arg=
5807428d7b3dSmrg	save_ifs="$IFS"; IFS=','
5808428d7b3dSmrg	for flag in $args; do
5809428d7b3dSmrg	  IFS="$save_ifs"
5810428d7b3dSmrg          func_quote_for_eval "$flag"
5811428d7b3dSmrg	  func_append arg " $wl$func_quote_for_eval_result"
5812428d7b3dSmrg	  func_append compiler_flags " $wl$func_quote_for_eval_result"
5813428d7b3dSmrg	  func_append linker_flags " $func_quote_for_eval_result"
5814428d7b3dSmrg	done
5815428d7b3dSmrg	IFS="$save_ifs"
5816428d7b3dSmrg	func_stripname ' ' '' "$arg"
5817428d7b3dSmrg	arg=$func_stripname_result
5818428d7b3dSmrg	;;
5819428d7b3dSmrg
5820428d7b3dSmrg      -Xcompiler)
5821428d7b3dSmrg	prev=xcompiler
5822428d7b3dSmrg	continue
5823428d7b3dSmrg	;;
5824428d7b3dSmrg
5825428d7b3dSmrg      -Xlinker)
5826428d7b3dSmrg	prev=xlinker
5827428d7b3dSmrg	continue
5828428d7b3dSmrg	;;
5829428d7b3dSmrg
5830428d7b3dSmrg      -XCClinker)
5831428d7b3dSmrg	prev=xcclinker
5832428d7b3dSmrg	continue
5833428d7b3dSmrg	;;
5834428d7b3dSmrg
5835428d7b3dSmrg      # -msg_* for osf cc
5836428d7b3dSmrg      -msg_*)
5837428d7b3dSmrg	func_quote_for_eval "$arg"
5838428d7b3dSmrg	arg="$func_quote_for_eval_result"
5839428d7b3dSmrg	;;
5840428d7b3dSmrg
5841428d7b3dSmrg      # Flags to be passed through unchanged, with rationale:
5842428d7b3dSmrg      # -64, -mips[0-9]      enable 64-bit mode for the SGI compiler
5843428d7b3dSmrg      # -r[0-9][0-9]*        specify processor for the SGI compiler
5844428d7b3dSmrg      # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler
5845428d7b3dSmrg      # +DA*, +DD*           enable 64-bit mode for the HP compiler
5846428d7b3dSmrg      # -q*                  compiler args for the IBM compiler
5847428d7b3dSmrg      # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
5848428d7b3dSmrg      # -F/path              path to uninstalled frameworks, gcc on darwin
5849428d7b3dSmrg      # -p, -pg, --coverage, -fprofile-*  profiling flags for GCC
5850428d7b3dSmrg      # @file                GCC response files
5851428d7b3dSmrg      # -tp=*                Portland pgcc target processor selection
5852428d7b3dSmrg      # --sysroot=*          for sysroot support
5853428d7b3dSmrg      # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
5854428d7b3dSmrg      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
5855428d7b3dSmrg      -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
5856428d7b3dSmrg      -O*|-flto*|-fwhopr*|-fuse-linker-plugin)
5857428d7b3dSmrg        func_quote_for_eval "$arg"
5858428d7b3dSmrg	arg="$func_quote_for_eval_result"
5859428d7b3dSmrg        func_append compile_command " $arg"
5860428d7b3dSmrg        func_append finalize_command " $arg"
5861428d7b3dSmrg        func_append compiler_flags " $arg"
5862428d7b3dSmrg        continue
5863428d7b3dSmrg        ;;
5864428d7b3dSmrg
5865428d7b3dSmrg      # Some other compiler flag.
5866428d7b3dSmrg      -* | +*)
5867428d7b3dSmrg        func_quote_for_eval "$arg"
5868428d7b3dSmrg	arg="$func_quote_for_eval_result"
5869428d7b3dSmrg	;;
5870428d7b3dSmrg
5871428d7b3dSmrg      *.$objext)
5872428d7b3dSmrg	# A standard object.
5873428d7b3dSmrg	func_append objs " $arg"
5874428d7b3dSmrg	;;
5875428d7b3dSmrg
5876428d7b3dSmrg      *.lo)
5877428d7b3dSmrg	# A libtool-controlled object.
5878428d7b3dSmrg
5879428d7b3dSmrg	# Check to see that this really is a libtool object.
5880428d7b3dSmrg	if func_lalib_unsafe_p "$arg"; then
5881428d7b3dSmrg	  pic_object=
5882428d7b3dSmrg	  non_pic_object=
5883428d7b3dSmrg
5884428d7b3dSmrg	  # Read the .lo file
5885428d7b3dSmrg	  func_source "$arg"
5886428d7b3dSmrg
5887428d7b3dSmrg	  if test -z "$pic_object" ||
5888428d7b3dSmrg	     test -z "$non_pic_object" ||
5889428d7b3dSmrg	     test "$pic_object" = none &&
5890428d7b3dSmrg	     test "$non_pic_object" = none; then
5891428d7b3dSmrg	    func_fatal_error "cannot find name of object for \`$arg'"
5892428d7b3dSmrg	  fi
5893428d7b3dSmrg
5894428d7b3dSmrg	  # Extract subdirectory from the argument.
5895428d7b3dSmrg	  func_dirname "$arg" "/" ""
5896428d7b3dSmrg	  xdir="$func_dirname_result"
5897428d7b3dSmrg
5898428d7b3dSmrg	  if test "$pic_object" != none; then
5899428d7b3dSmrg	    # Prepend the subdirectory the object is found in.
5900428d7b3dSmrg	    pic_object="$xdir$pic_object"
5901428d7b3dSmrg
5902428d7b3dSmrg	    if test "$prev" = dlfiles; then
5903428d7b3dSmrg	      if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
5904428d7b3dSmrg		func_append dlfiles " $pic_object"
5905428d7b3dSmrg		prev=
5906428d7b3dSmrg		continue
5907428d7b3dSmrg	      else
5908428d7b3dSmrg		# If libtool objects are unsupported, then we need to preload.
5909428d7b3dSmrg		prev=dlprefiles
5910428d7b3dSmrg	      fi
5911428d7b3dSmrg	    fi
5912428d7b3dSmrg
5913428d7b3dSmrg	    # CHECK ME:  I think I busted this.  -Ossama
5914428d7b3dSmrg	    if test "$prev" = dlprefiles; then
5915428d7b3dSmrg	      # Preload the old-style object.
5916428d7b3dSmrg	      func_append dlprefiles " $pic_object"
5917428d7b3dSmrg	      prev=
5918428d7b3dSmrg	    fi
5919428d7b3dSmrg
5920428d7b3dSmrg	    # A PIC object.
5921428d7b3dSmrg	    func_append libobjs " $pic_object"
5922428d7b3dSmrg	    arg="$pic_object"
5923428d7b3dSmrg	  fi
5924428d7b3dSmrg
5925428d7b3dSmrg	  # Non-PIC object.
5926428d7b3dSmrg	  if test "$non_pic_object" != none; then
5927428d7b3dSmrg	    # Prepend the subdirectory the object is found in.
5928428d7b3dSmrg	    non_pic_object="$xdir$non_pic_object"
5929428d7b3dSmrg
5930428d7b3dSmrg	    # A standard non-PIC object
5931428d7b3dSmrg	    func_append non_pic_objects " $non_pic_object"
5932428d7b3dSmrg	    if test -z "$pic_object" || test "$pic_object" = none ; then
5933428d7b3dSmrg	      arg="$non_pic_object"
5934428d7b3dSmrg	    fi
5935428d7b3dSmrg	  else
5936428d7b3dSmrg	    # If the PIC object exists, use it instead.
5937428d7b3dSmrg	    # $xdir was prepended to $pic_object above.
5938428d7b3dSmrg	    non_pic_object="$pic_object"
5939428d7b3dSmrg	    func_append non_pic_objects " $non_pic_object"
5940428d7b3dSmrg	  fi
5941428d7b3dSmrg	else
5942428d7b3dSmrg	  # Only an error if not doing a dry-run.
5943428d7b3dSmrg	  if $opt_dry_run; then
5944428d7b3dSmrg	    # Extract subdirectory from the argument.
5945428d7b3dSmrg	    func_dirname "$arg" "/" ""
5946428d7b3dSmrg	    xdir="$func_dirname_result"
5947428d7b3dSmrg
5948428d7b3dSmrg	    func_lo2o "$arg"
5949428d7b3dSmrg	    pic_object=$xdir$objdir/$func_lo2o_result
5950428d7b3dSmrg	    non_pic_object=$xdir$func_lo2o_result
5951428d7b3dSmrg	    func_append libobjs " $pic_object"
5952428d7b3dSmrg	    func_append non_pic_objects " $non_pic_object"
5953428d7b3dSmrg	  else
5954428d7b3dSmrg	    func_fatal_error "\`$arg' is not a valid libtool object"
5955428d7b3dSmrg	  fi
5956428d7b3dSmrg	fi
5957428d7b3dSmrg	;;
5958428d7b3dSmrg
5959428d7b3dSmrg      *.$libext)
5960428d7b3dSmrg	# An archive.
5961428d7b3dSmrg	func_append deplibs " $arg"
5962428d7b3dSmrg	func_append old_deplibs " $arg"
5963428d7b3dSmrg	continue
5964428d7b3dSmrg	;;
5965428d7b3dSmrg
5966428d7b3dSmrg      *.la)
5967428d7b3dSmrg	# A libtool-controlled library.
5968428d7b3dSmrg
5969428d7b3dSmrg	func_resolve_sysroot "$arg"
5970428d7b3dSmrg	if test "$prev" = dlfiles; then
5971428d7b3dSmrg	  # This library was specified with -dlopen.
5972428d7b3dSmrg	  func_append dlfiles " $func_resolve_sysroot_result"
5973428d7b3dSmrg	  prev=
5974428d7b3dSmrg	elif test "$prev" = dlprefiles; then
5975428d7b3dSmrg	  # The library was specified with -dlpreopen.
5976428d7b3dSmrg	  func_append dlprefiles " $func_resolve_sysroot_result"
5977428d7b3dSmrg	  prev=
5978428d7b3dSmrg	else
5979428d7b3dSmrg	  func_append deplibs " $func_resolve_sysroot_result"
5980428d7b3dSmrg	fi
5981428d7b3dSmrg	continue
5982428d7b3dSmrg	;;
5983428d7b3dSmrg
5984428d7b3dSmrg      # Some other compiler argument.
5985428d7b3dSmrg      *)
5986428d7b3dSmrg	# Unknown arguments in both finalize_command and compile_command need
5987428d7b3dSmrg	# to be aesthetically quoted because they are evaled later.
5988428d7b3dSmrg	func_quote_for_eval "$arg"
5989428d7b3dSmrg	arg="$func_quote_for_eval_result"
5990428d7b3dSmrg	;;
5991428d7b3dSmrg      esac # arg
5992428d7b3dSmrg
5993428d7b3dSmrg      # Now actually substitute the argument into the commands.
5994428d7b3dSmrg      if test -n "$arg"; then
5995428d7b3dSmrg	func_append compile_command " $arg"
5996428d7b3dSmrg	func_append finalize_command " $arg"
5997428d7b3dSmrg      fi
5998428d7b3dSmrg    done # argument parsing loop
5999428d7b3dSmrg
6000428d7b3dSmrg    test -n "$prev" && \
6001428d7b3dSmrg      func_fatal_help "the \`$prevarg' option requires an argument"
6002428d7b3dSmrg
6003428d7b3dSmrg    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
6004428d7b3dSmrg      eval arg=\"$export_dynamic_flag_spec\"
6005428d7b3dSmrg      func_append compile_command " $arg"
6006428d7b3dSmrg      func_append finalize_command " $arg"
6007428d7b3dSmrg    fi
6008428d7b3dSmrg
6009428d7b3dSmrg    oldlibs=
6010428d7b3dSmrg    # calculate the name of the file, without its directory
6011428d7b3dSmrg    func_basename "$output"
6012428d7b3dSmrg    outputname="$func_basename_result"
6013428d7b3dSmrg    libobjs_save="$libobjs"
6014428d7b3dSmrg
6015428d7b3dSmrg    if test -n "$shlibpath_var"; then
6016428d7b3dSmrg      # get the directories listed in $shlibpath_var
6017428d7b3dSmrg      eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\`
6018428d7b3dSmrg    else
6019428d7b3dSmrg      shlib_search_path=
6020428d7b3dSmrg    fi
6021428d7b3dSmrg    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
6022428d7b3dSmrg    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
6023428d7b3dSmrg
6024428d7b3dSmrg    func_dirname "$output" "/" ""
6025428d7b3dSmrg    output_objdir="$func_dirname_result$objdir"
6026428d7b3dSmrg    func_to_tool_file "$output_objdir/"
6027428d7b3dSmrg    tool_output_objdir=$func_to_tool_file_result
6028428d7b3dSmrg    # Create the object directory.
6029428d7b3dSmrg    func_mkdir_p "$output_objdir"
6030428d7b3dSmrg
6031428d7b3dSmrg    # Determine the type of output
6032428d7b3dSmrg    case $output in
6033428d7b3dSmrg    "")
6034428d7b3dSmrg      func_fatal_help "you must specify an output file"
6035428d7b3dSmrg      ;;
6036428d7b3dSmrg    *.$libext) linkmode=oldlib ;;
6037428d7b3dSmrg    *.lo | *.$objext) linkmode=obj ;;
6038428d7b3dSmrg    *.la) linkmode=lib ;;
6039428d7b3dSmrg    *) linkmode=prog ;; # Anything else should be a program.
6040428d7b3dSmrg    esac
6041428d7b3dSmrg
6042428d7b3dSmrg    specialdeplibs=
6043428d7b3dSmrg
6044428d7b3dSmrg    libs=
6045428d7b3dSmrg    # Find all interdependent deplibs by searching for libraries
6046428d7b3dSmrg    # that are linked more than once (e.g. -la -lb -la)
6047428d7b3dSmrg    for deplib in $deplibs; do
6048428d7b3dSmrg      if $opt_preserve_dup_deps ; then
6049428d7b3dSmrg	case "$libs " in
6050428d7b3dSmrg	*" $deplib "*) func_append specialdeplibs " $deplib" ;;
6051428d7b3dSmrg	esac
6052428d7b3dSmrg      fi
6053428d7b3dSmrg      func_append libs " $deplib"
6054428d7b3dSmrg    done
6055428d7b3dSmrg
6056428d7b3dSmrg    if test "$linkmode" = lib; then
6057428d7b3dSmrg      libs="$predeps $libs $compiler_lib_search_path $postdeps"
6058428d7b3dSmrg
6059428d7b3dSmrg      # Compute libraries that are listed more than once in $predeps
6060428d7b3dSmrg      # $postdeps and mark them as special (i.e., whose duplicates are
6061428d7b3dSmrg      # not to be eliminated).
6062428d7b3dSmrg      pre_post_deps=
6063428d7b3dSmrg      if $opt_duplicate_compiler_generated_deps; then
6064428d7b3dSmrg	for pre_post_dep in $predeps $postdeps; do
6065428d7b3dSmrg	  case "$pre_post_deps " in
6066428d7b3dSmrg	  *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;;
6067428d7b3dSmrg	  esac
6068428d7b3dSmrg	  func_append pre_post_deps " $pre_post_dep"
6069428d7b3dSmrg	done
6070428d7b3dSmrg      fi
6071428d7b3dSmrg      pre_post_deps=
6072428d7b3dSmrg    fi
6073428d7b3dSmrg
6074428d7b3dSmrg    deplibs=
6075428d7b3dSmrg    newdependency_libs=
6076428d7b3dSmrg    newlib_search_path=
6077428d7b3dSmrg    need_relink=no # whether we're linking any uninstalled libtool libraries
6078428d7b3dSmrg    notinst_deplibs= # not-installed libtool libraries
6079428d7b3dSmrg    notinst_path= # paths that contain not-installed libtool libraries
6080428d7b3dSmrg
6081428d7b3dSmrg    case $linkmode in
6082428d7b3dSmrg    lib)
6083428d7b3dSmrg	passes="conv dlpreopen link"
6084428d7b3dSmrg	for file in $dlfiles $dlprefiles; do
6085428d7b3dSmrg	  case $file in
6086428d7b3dSmrg	  *.la) ;;
6087428d7b3dSmrg	  *)
6088428d7b3dSmrg	    func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file"
6089428d7b3dSmrg	    ;;
6090428d7b3dSmrg	  esac
6091428d7b3dSmrg	done
6092428d7b3dSmrg	;;
6093428d7b3dSmrg    prog)
6094428d7b3dSmrg	compile_deplibs=
6095428d7b3dSmrg	finalize_deplibs=
6096428d7b3dSmrg	alldeplibs=no
6097428d7b3dSmrg	newdlfiles=
6098428d7b3dSmrg	newdlprefiles=
6099428d7b3dSmrg	passes="conv scan dlopen dlpreopen link"
6100428d7b3dSmrg	;;
6101428d7b3dSmrg    *)  passes="conv"
6102428d7b3dSmrg	;;
6103428d7b3dSmrg    esac
6104428d7b3dSmrg
6105428d7b3dSmrg    for pass in $passes; do
6106428d7b3dSmrg      # The preopen pass in lib mode reverses $deplibs; put it back here
6107428d7b3dSmrg      # so that -L comes before libs that need it for instance...
6108428d7b3dSmrg      if test "$linkmode,$pass" = "lib,link"; then
6109428d7b3dSmrg	## FIXME: Find the place where the list is rebuilt in the wrong
6110428d7b3dSmrg	##        order, and fix it there properly
6111428d7b3dSmrg        tmp_deplibs=
6112428d7b3dSmrg	for deplib in $deplibs; do
6113428d7b3dSmrg	  tmp_deplibs="$deplib $tmp_deplibs"
6114428d7b3dSmrg	done
6115428d7b3dSmrg	deplibs="$tmp_deplibs"
6116428d7b3dSmrg      fi
6117428d7b3dSmrg
6118428d7b3dSmrg      if test "$linkmode,$pass" = "lib,link" ||
6119428d7b3dSmrg	 test "$linkmode,$pass" = "prog,scan"; then
6120428d7b3dSmrg	libs="$deplibs"
6121428d7b3dSmrg	deplibs=
6122428d7b3dSmrg      fi
6123428d7b3dSmrg      if test "$linkmode" = prog; then
6124428d7b3dSmrg	case $pass in
6125428d7b3dSmrg	dlopen) libs="$dlfiles" ;;
6126428d7b3dSmrg	dlpreopen) libs="$dlprefiles" ;;
6127428d7b3dSmrg	link)
6128428d7b3dSmrg	  libs="$deplibs %DEPLIBS%"
6129428d7b3dSmrg	  test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs"
6130428d7b3dSmrg	  ;;
6131428d7b3dSmrg	esac
6132428d7b3dSmrg      fi
6133428d7b3dSmrg      if test "$linkmode,$pass" = "lib,dlpreopen"; then
6134428d7b3dSmrg	# Collect and forward deplibs of preopened libtool libs
6135428d7b3dSmrg	for lib in $dlprefiles; do
6136428d7b3dSmrg	  # Ignore non-libtool-libs
6137428d7b3dSmrg	  dependency_libs=
6138428d7b3dSmrg	  func_resolve_sysroot "$lib"
6139428d7b3dSmrg	  case $lib in
6140428d7b3dSmrg	  *.la)	func_source "$func_resolve_sysroot_result" ;;
6141428d7b3dSmrg	  esac
6142428d7b3dSmrg
6143428d7b3dSmrg	  # Collect preopened libtool deplibs, except any this library
6144428d7b3dSmrg	  # has declared as weak libs
6145428d7b3dSmrg	  for deplib in $dependency_libs; do
6146428d7b3dSmrg	    func_basename "$deplib"
6147428d7b3dSmrg            deplib_base=$func_basename_result
6148428d7b3dSmrg	    case " $weak_libs " in
6149428d7b3dSmrg	    *" $deplib_base "*) ;;
6150428d7b3dSmrg	    *) func_append deplibs " $deplib" ;;
6151428d7b3dSmrg	    esac
6152428d7b3dSmrg	  done
6153428d7b3dSmrg	done
6154428d7b3dSmrg	libs="$dlprefiles"
6155428d7b3dSmrg      fi
6156428d7b3dSmrg      if test "$pass" = dlopen; then
6157428d7b3dSmrg	# Collect dlpreopened libraries
6158428d7b3dSmrg	save_deplibs="$deplibs"
6159428d7b3dSmrg	deplibs=
6160428d7b3dSmrg      fi
6161428d7b3dSmrg
6162428d7b3dSmrg      for deplib in $libs; do
6163428d7b3dSmrg	lib=
6164428d7b3dSmrg	found=no
6165428d7b3dSmrg	case $deplib in
6166428d7b3dSmrg	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
6167428d7b3dSmrg        |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
6168428d7b3dSmrg	  if test "$linkmode,$pass" = "prog,link"; then
6169428d7b3dSmrg	    compile_deplibs="$deplib $compile_deplibs"
6170428d7b3dSmrg	    finalize_deplibs="$deplib $finalize_deplibs"
6171428d7b3dSmrg	  else
6172428d7b3dSmrg	    func_append compiler_flags " $deplib"
6173428d7b3dSmrg	    if test "$linkmode" = lib ; then
6174428d7b3dSmrg		case "$new_inherited_linker_flags " in
6175428d7b3dSmrg		    *" $deplib "*) ;;
6176428d7b3dSmrg		    * ) func_append new_inherited_linker_flags " $deplib" ;;
6177428d7b3dSmrg		esac
6178428d7b3dSmrg	    fi
6179428d7b3dSmrg	  fi
6180428d7b3dSmrg	  continue
6181428d7b3dSmrg	  ;;
6182428d7b3dSmrg	-l*)
6183428d7b3dSmrg	  if test "$linkmode" != lib && test "$linkmode" != prog; then
6184428d7b3dSmrg	    func_warning "\`-l' is ignored for archives/objects"
6185428d7b3dSmrg	    continue
6186428d7b3dSmrg	  fi
6187428d7b3dSmrg	  func_stripname '-l' '' "$deplib"
6188428d7b3dSmrg	  name=$func_stripname_result
6189428d7b3dSmrg	  if test "$linkmode" = lib; then
6190428d7b3dSmrg	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
6191428d7b3dSmrg	  else
6192428d7b3dSmrg	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
6193428d7b3dSmrg	  fi
6194428d7b3dSmrg	  for searchdir in $searchdirs; do
6195428d7b3dSmrg	    for search_ext in .la $std_shrext .so .a; do
6196428d7b3dSmrg	      # Search the libtool library
6197428d7b3dSmrg	      lib="$searchdir/lib${name}${search_ext}"
6198428d7b3dSmrg	      if test -f "$lib"; then
6199428d7b3dSmrg		if test "$search_ext" = ".la"; then
6200428d7b3dSmrg		  found=yes
6201428d7b3dSmrg		else
6202428d7b3dSmrg		  found=no
6203428d7b3dSmrg		fi
6204428d7b3dSmrg		break 2
6205428d7b3dSmrg	      fi
6206428d7b3dSmrg	    done
6207428d7b3dSmrg	  done
6208428d7b3dSmrg	  if test "$found" != yes; then
6209428d7b3dSmrg	    # deplib doesn't seem to be a libtool library
6210428d7b3dSmrg	    if test "$linkmode,$pass" = "prog,link"; then
6211428d7b3dSmrg	      compile_deplibs="$deplib $compile_deplibs"
6212428d7b3dSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
6213428d7b3dSmrg	    else
6214428d7b3dSmrg	      deplibs="$deplib $deplibs"
6215428d7b3dSmrg	      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
6216428d7b3dSmrg	    fi
6217428d7b3dSmrg	    continue
6218428d7b3dSmrg	  else # deplib is a libtool library
6219428d7b3dSmrg	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
6220428d7b3dSmrg	    # We need to do some special things here, and not later.
6221428d7b3dSmrg	    if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6222428d7b3dSmrg	      case " $predeps $postdeps " in
6223428d7b3dSmrg	      *" $deplib "*)
6224428d7b3dSmrg		if func_lalib_p "$lib"; then
6225428d7b3dSmrg		  library_names=
6226428d7b3dSmrg		  old_library=
6227428d7b3dSmrg		  func_source "$lib"
6228428d7b3dSmrg		  for l in $old_library $library_names; do
6229428d7b3dSmrg		    ll="$l"
6230428d7b3dSmrg		  done
6231428d7b3dSmrg		  if test "X$ll" = "X$old_library" ; then # only static version available
6232428d7b3dSmrg		    found=no
6233428d7b3dSmrg		    func_dirname "$lib" "" "."
6234428d7b3dSmrg		    ladir="$func_dirname_result"
6235428d7b3dSmrg		    lib=$ladir/$old_library
6236428d7b3dSmrg		    if test "$linkmode,$pass" = "prog,link"; then
6237428d7b3dSmrg		      compile_deplibs="$deplib $compile_deplibs"
6238428d7b3dSmrg		      finalize_deplibs="$deplib $finalize_deplibs"
6239428d7b3dSmrg		    else
6240428d7b3dSmrg		      deplibs="$deplib $deplibs"
6241428d7b3dSmrg		      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
6242428d7b3dSmrg		    fi
6243428d7b3dSmrg		    continue
6244428d7b3dSmrg		  fi
6245428d7b3dSmrg		fi
6246428d7b3dSmrg		;;
6247428d7b3dSmrg	      *) ;;
6248428d7b3dSmrg	      esac
6249428d7b3dSmrg	    fi
6250428d7b3dSmrg	  fi
6251428d7b3dSmrg	  ;; # -l
6252428d7b3dSmrg	*.ltframework)
6253428d7b3dSmrg	  if test "$linkmode,$pass" = "prog,link"; then
6254428d7b3dSmrg	    compile_deplibs="$deplib $compile_deplibs"
6255428d7b3dSmrg	    finalize_deplibs="$deplib $finalize_deplibs"
6256428d7b3dSmrg	  else
6257428d7b3dSmrg	    deplibs="$deplib $deplibs"
6258428d7b3dSmrg	    if test "$linkmode" = lib ; then
6259428d7b3dSmrg		case "$new_inherited_linker_flags " in
6260428d7b3dSmrg		    *" $deplib "*) ;;
6261428d7b3dSmrg		    * ) func_append new_inherited_linker_flags " $deplib" ;;
6262428d7b3dSmrg		esac
6263428d7b3dSmrg	    fi
6264428d7b3dSmrg	  fi
6265428d7b3dSmrg	  continue
6266428d7b3dSmrg	  ;;
6267428d7b3dSmrg	-L*)
6268428d7b3dSmrg	  case $linkmode in
6269428d7b3dSmrg	  lib)
6270428d7b3dSmrg	    deplibs="$deplib $deplibs"
6271428d7b3dSmrg	    test "$pass" = conv && continue
6272428d7b3dSmrg	    newdependency_libs="$deplib $newdependency_libs"
6273428d7b3dSmrg	    func_stripname '-L' '' "$deplib"
6274428d7b3dSmrg	    func_resolve_sysroot "$func_stripname_result"
6275428d7b3dSmrg	    func_append newlib_search_path " $func_resolve_sysroot_result"
6276428d7b3dSmrg	    ;;
6277428d7b3dSmrg	  prog)
6278428d7b3dSmrg	    if test "$pass" = conv; then
6279428d7b3dSmrg	      deplibs="$deplib $deplibs"
6280428d7b3dSmrg	      continue
6281428d7b3dSmrg	    fi
6282428d7b3dSmrg	    if test "$pass" = scan; then
6283428d7b3dSmrg	      deplibs="$deplib $deplibs"
6284428d7b3dSmrg	    else
6285428d7b3dSmrg	      compile_deplibs="$deplib $compile_deplibs"
6286428d7b3dSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
6287428d7b3dSmrg	    fi
6288428d7b3dSmrg	    func_stripname '-L' '' "$deplib"
6289428d7b3dSmrg	    func_resolve_sysroot "$func_stripname_result"
6290428d7b3dSmrg	    func_append newlib_search_path " $func_resolve_sysroot_result"
6291428d7b3dSmrg	    ;;
6292428d7b3dSmrg	  *)
6293428d7b3dSmrg	    func_warning "\`-L' is ignored for archives/objects"
6294428d7b3dSmrg	    ;;
6295428d7b3dSmrg	  esac # linkmode
6296428d7b3dSmrg	  continue
6297428d7b3dSmrg	  ;; # -L
6298428d7b3dSmrg	-R*)
6299428d7b3dSmrg	  if test "$pass" = link; then
6300428d7b3dSmrg	    func_stripname '-R' '' "$deplib"
6301428d7b3dSmrg	    func_resolve_sysroot "$func_stripname_result"
6302428d7b3dSmrg	    dir=$func_resolve_sysroot_result
6303428d7b3dSmrg	    # Make sure the xrpath contains only unique directories.
6304428d7b3dSmrg	    case "$xrpath " in
6305428d7b3dSmrg	    *" $dir "*) ;;
6306428d7b3dSmrg	    *) func_append xrpath " $dir" ;;
6307428d7b3dSmrg	    esac
6308428d7b3dSmrg	  fi
6309428d7b3dSmrg	  deplibs="$deplib $deplibs"
6310428d7b3dSmrg	  continue
6311428d7b3dSmrg	  ;;
6312428d7b3dSmrg	*.la)
6313428d7b3dSmrg	  func_resolve_sysroot "$deplib"
6314428d7b3dSmrg	  lib=$func_resolve_sysroot_result
6315428d7b3dSmrg	  ;;
6316428d7b3dSmrg	*.$libext)
6317428d7b3dSmrg	  if test "$pass" = conv; then
6318428d7b3dSmrg	    deplibs="$deplib $deplibs"
6319428d7b3dSmrg	    continue
6320428d7b3dSmrg	  fi
6321428d7b3dSmrg	  case $linkmode in
6322428d7b3dSmrg	  lib)
6323428d7b3dSmrg	    # Linking convenience modules into shared libraries is allowed,
6324428d7b3dSmrg	    # but linking other static libraries is non-portable.
6325428d7b3dSmrg	    case " $dlpreconveniencelibs " in
6326428d7b3dSmrg	    *" $deplib "*) ;;
6327428d7b3dSmrg	    *)
6328428d7b3dSmrg	      valid_a_lib=no
6329428d7b3dSmrg	      case $deplibs_check_method in
6330428d7b3dSmrg		match_pattern*)
6331428d7b3dSmrg		  set dummy $deplibs_check_method; shift
6332428d7b3dSmrg		  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
6333428d7b3dSmrg		  if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
6334428d7b3dSmrg		    | $EGREP "$match_pattern_regex" > /dev/null; then
6335428d7b3dSmrg		    valid_a_lib=yes
6336428d7b3dSmrg		  fi
6337428d7b3dSmrg		;;
6338428d7b3dSmrg		pass_all)
6339428d7b3dSmrg		  valid_a_lib=yes
6340428d7b3dSmrg		;;
6341428d7b3dSmrg	      esac
6342428d7b3dSmrg	      if test "$valid_a_lib" != yes; then
6343428d7b3dSmrg		echo
6344428d7b3dSmrg		$ECHO "*** Warning: Trying to link with static lib archive $deplib."
6345428d7b3dSmrg		echo "*** I have the capability to make that library automatically link in when"
6346428d7b3dSmrg		echo "*** you link to this library.  But I can only do this if you have a"
6347428d7b3dSmrg		echo "*** shared version of the library, which you do not appear to have"
6348428d7b3dSmrg		echo "*** because the file extensions .$libext of this argument makes me believe"
6349428d7b3dSmrg		echo "*** that it is just a static archive that I should not use here."
6350428d7b3dSmrg	      else
6351428d7b3dSmrg		echo
6352428d7b3dSmrg		$ECHO "*** Warning: Linking the shared library $output against the"
6353428d7b3dSmrg		$ECHO "*** static library $deplib is not portable!"
6354428d7b3dSmrg		deplibs="$deplib $deplibs"
6355428d7b3dSmrg	      fi
6356428d7b3dSmrg	      ;;
6357428d7b3dSmrg	    esac
6358428d7b3dSmrg	    continue
6359428d7b3dSmrg	    ;;
6360428d7b3dSmrg	  prog)
6361428d7b3dSmrg	    if test "$pass" != link; then
6362428d7b3dSmrg	      deplibs="$deplib $deplibs"
6363428d7b3dSmrg	    else
6364428d7b3dSmrg	      compile_deplibs="$deplib $compile_deplibs"
6365428d7b3dSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
6366428d7b3dSmrg	    fi
6367428d7b3dSmrg	    continue
6368428d7b3dSmrg	    ;;
6369428d7b3dSmrg	  esac # linkmode
6370428d7b3dSmrg	  ;; # *.$libext
6371428d7b3dSmrg	*.lo | *.$objext)
6372428d7b3dSmrg	  if test "$pass" = conv; then
6373428d7b3dSmrg	    deplibs="$deplib $deplibs"
6374428d7b3dSmrg	  elif test "$linkmode" = prog; then
6375428d7b3dSmrg	    if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
6376428d7b3dSmrg	      # If there is no dlopen support or we're linking statically,
6377428d7b3dSmrg	      # we need to preload.
6378428d7b3dSmrg	      func_append newdlprefiles " $deplib"
6379428d7b3dSmrg	      compile_deplibs="$deplib $compile_deplibs"
6380428d7b3dSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
6381428d7b3dSmrg	    else
6382428d7b3dSmrg	      func_append newdlfiles " $deplib"
6383428d7b3dSmrg	    fi
6384428d7b3dSmrg	  fi
6385428d7b3dSmrg	  continue
6386428d7b3dSmrg	  ;;
6387428d7b3dSmrg	%DEPLIBS%)
6388428d7b3dSmrg	  alldeplibs=yes
6389428d7b3dSmrg	  continue
6390428d7b3dSmrg	  ;;
6391428d7b3dSmrg	esac # case $deplib
6392428d7b3dSmrg
6393428d7b3dSmrg	if test "$found" = yes || test -f "$lib"; then :
6394428d7b3dSmrg	else
6395428d7b3dSmrg	  func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'"
6396428d7b3dSmrg	fi
6397428d7b3dSmrg
6398428d7b3dSmrg	# Check to see that this really is a libtool archive.
6399428d7b3dSmrg	func_lalib_unsafe_p "$lib" \
6400428d7b3dSmrg	  || func_fatal_error "\`$lib' is not a valid libtool archive"
6401428d7b3dSmrg
6402428d7b3dSmrg	func_dirname "$lib" "" "."
6403428d7b3dSmrg	ladir="$func_dirname_result"
6404428d7b3dSmrg
6405428d7b3dSmrg	dlname=
6406428d7b3dSmrg	dlopen=
6407428d7b3dSmrg	dlpreopen=
6408428d7b3dSmrg	libdir=
6409428d7b3dSmrg	library_names=
6410428d7b3dSmrg	old_library=
6411428d7b3dSmrg	inherited_linker_flags=
6412428d7b3dSmrg	# If the library was installed with an old release of libtool,
6413428d7b3dSmrg	# it will not redefine variables installed, or shouldnotlink
6414428d7b3dSmrg	installed=yes
6415428d7b3dSmrg	shouldnotlink=no
6416428d7b3dSmrg	avoidtemprpath=
6417428d7b3dSmrg
6418428d7b3dSmrg
6419428d7b3dSmrg	# Read the .la file
6420428d7b3dSmrg	func_source "$lib"
6421428d7b3dSmrg
6422428d7b3dSmrg	# Convert "-framework foo" to "foo.ltframework"
6423428d7b3dSmrg	if test -n "$inherited_linker_flags"; then
6424428d7b3dSmrg	  tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
6425428d7b3dSmrg	  for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
6426428d7b3dSmrg	    case " $new_inherited_linker_flags " in
6427428d7b3dSmrg	      *" $tmp_inherited_linker_flag "*) ;;
6428428d7b3dSmrg	      *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";;
6429428d7b3dSmrg	    esac
6430428d7b3dSmrg	  done
6431428d7b3dSmrg	fi
6432428d7b3dSmrg	dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
6433428d7b3dSmrg	if test "$linkmode,$pass" = "lib,link" ||
6434428d7b3dSmrg	   test "$linkmode,$pass" = "prog,scan" ||
6435428d7b3dSmrg	   { test "$linkmode" != prog && test "$linkmode" != lib; }; then
6436428d7b3dSmrg	  test -n "$dlopen" && func_append dlfiles " $dlopen"
6437428d7b3dSmrg	  test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen"
6438428d7b3dSmrg	fi
6439428d7b3dSmrg
6440428d7b3dSmrg	if test "$pass" = conv; then
6441428d7b3dSmrg	  # Only check for convenience libraries
6442428d7b3dSmrg	  deplibs="$lib $deplibs"
6443428d7b3dSmrg	  if test -z "$libdir"; then
6444428d7b3dSmrg	    if test -z "$old_library"; then
6445428d7b3dSmrg	      func_fatal_error "cannot find name of link library for \`$lib'"
6446428d7b3dSmrg	    fi
6447428d7b3dSmrg	    # It is a libtool convenience library, so add in its objects.
6448428d7b3dSmrg	    func_append convenience " $ladir/$objdir/$old_library"
6449428d7b3dSmrg	    func_append old_convenience " $ladir/$objdir/$old_library"
6450428d7b3dSmrg	    tmp_libs=
6451428d7b3dSmrg	    for deplib in $dependency_libs; do
6452428d7b3dSmrg	      deplibs="$deplib $deplibs"
6453428d7b3dSmrg	      if $opt_preserve_dup_deps ; then
6454428d7b3dSmrg		case "$tmp_libs " in
6455428d7b3dSmrg		*" $deplib "*) func_append specialdeplibs " $deplib" ;;
6456428d7b3dSmrg		esac
6457428d7b3dSmrg	      fi
6458428d7b3dSmrg	      func_append tmp_libs " $deplib"
6459428d7b3dSmrg	    done
6460428d7b3dSmrg	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
6461428d7b3dSmrg	    func_fatal_error "\`$lib' is not a convenience library"
6462428d7b3dSmrg	  fi
6463428d7b3dSmrg	  continue
6464428d7b3dSmrg	fi # $pass = conv
6465428d7b3dSmrg
6466428d7b3dSmrg
6467428d7b3dSmrg	# Get the name of the library we link against.
6468428d7b3dSmrg	linklib=
6469428d7b3dSmrg	if test -n "$old_library" &&
6470428d7b3dSmrg	   { test "$prefer_static_libs" = yes ||
6471428d7b3dSmrg	     test "$prefer_static_libs,$installed" = "built,no"; }; then
6472428d7b3dSmrg	  linklib=$old_library
6473428d7b3dSmrg	else
6474428d7b3dSmrg	  for l in $old_library $library_names; do
6475428d7b3dSmrg	    linklib="$l"
6476428d7b3dSmrg	  done
6477428d7b3dSmrg	fi
6478428d7b3dSmrg	if test -z "$linklib"; then
6479428d7b3dSmrg	  func_fatal_error "cannot find name of link library for \`$lib'"
6480428d7b3dSmrg	fi
6481428d7b3dSmrg
6482428d7b3dSmrg	# This library was specified with -dlopen.
6483428d7b3dSmrg	if test "$pass" = dlopen; then
6484428d7b3dSmrg	  if test -z "$libdir"; then
6485428d7b3dSmrg	    func_fatal_error "cannot -dlopen a convenience library: \`$lib'"
6486428d7b3dSmrg	  fi
6487428d7b3dSmrg	  if test -z "$dlname" ||
6488428d7b3dSmrg	     test "$dlopen_support" != yes ||
6489428d7b3dSmrg	     test "$build_libtool_libs" = no; then
6490428d7b3dSmrg	    # If there is no dlname, no dlopen support or we're linking
6491428d7b3dSmrg	    # statically, we need to preload.  We also need to preload any
6492428d7b3dSmrg	    # dependent libraries so libltdl's deplib preloader doesn't
6493428d7b3dSmrg	    # bomb out in the load deplibs phase.
6494428d7b3dSmrg	    func_append dlprefiles " $lib $dependency_libs"
6495428d7b3dSmrg	  else
6496428d7b3dSmrg	    func_append newdlfiles " $lib"
6497428d7b3dSmrg	  fi
6498428d7b3dSmrg	  continue
6499428d7b3dSmrg	fi # $pass = dlopen
6500428d7b3dSmrg
6501428d7b3dSmrg	# We need an absolute path.
6502428d7b3dSmrg	case $ladir in
6503428d7b3dSmrg	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
6504428d7b3dSmrg	*)
6505428d7b3dSmrg	  abs_ladir=`cd "$ladir" && pwd`
6506428d7b3dSmrg	  if test -z "$abs_ladir"; then
6507428d7b3dSmrg	    func_warning "cannot determine absolute directory name of \`$ladir'"
6508428d7b3dSmrg	    func_warning "passing it literally to the linker, although it might fail"
6509428d7b3dSmrg	    abs_ladir="$ladir"
6510428d7b3dSmrg	  fi
6511428d7b3dSmrg	  ;;
6512428d7b3dSmrg	esac
6513428d7b3dSmrg	func_basename "$lib"
6514428d7b3dSmrg	laname="$func_basename_result"
6515428d7b3dSmrg
6516428d7b3dSmrg	# Find the relevant object directory and library name.
6517428d7b3dSmrg	if test "X$installed" = Xyes; then
6518428d7b3dSmrg	  if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
6519428d7b3dSmrg	    func_warning "library \`$lib' was moved."
6520428d7b3dSmrg	    dir="$ladir"
6521428d7b3dSmrg	    absdir="$abs_ladir"
6522428d7b3dSmrg	    libdir="$abs_ladir"
6523428d7b3dSmrg	  else
6524428d7b3dSmrg	    dir="$lt_sysroot$libdir"
6525428d7b3dSmrg	    absdir="$lt_sysroot$libdir"
6526428d7b3dSmrg	  fi
6527428d7b3dSmrg	  test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
6528428d7b3dSmrg	else
6529428d7b3dSmrg	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
6530428d7b3dSmrg	    dir="$ladir"
6531428d7b3dSmrg	    absdir="$abs_ladir"
6532428d7b3dSmrg	    # Remove this search path later
6533428d7b3dSmrg	    func_append notinst_path " $abs_ladir"
6534428d7b3dSmrg	  else
6535428d7b3dSmrg	    dir="$ladir/$objdir"
6536428d7b3dSmrg	    absdir="$abs_ladir/$objdir"
6537428d7b3dSmrg	    # Remove this search path later
6538428d7b3dSmrg	    func_append notinst_path " $abs_ladir"
6539428d7b3dSmrg	  fi
6540428d7b3dSmrg	fi # $installed = yes
6541428d7b3dSmrg	func_stripname 'lib' '.la' "$laname"
6542428d7b3dSmrg	name=$func_stripname_result
6543428d7b3dSmrg
6544428d7b3dSmrg	# This library was specified with -dlpreopen.
6545428d7b3dSmrg	if test "$pass" = dlpreopen; then
6546428d7b3dSmrg	  if test -z "$libdir" && test "$linkmode" = prog; then
6547428d7b3dSmrg	    func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'"
6548428d7b3dSmrg	  fi
6549428d7b3dSmrg	  case "$host" in
6550428d7b3dSmrg	    # special handling for platforms with PE-DLLs.
6551428d7b3dSmrg	    *cygwin* | *mingw* | *cegcc* )
6552428d7b3dSmrg	      # Linker will automatically link against shared library if both
6553428d7b3dSmrg	      # static and shared are present.  Therefore, ensure we extract
6554428d7b3dSmrg	      # symbols from the import library if a shared library is present
6555428d7b3dSmrg	      # (otherwise, the dlopen module name will be incorrect).  We do
6556428d7b3dSmrg	      # this by putting the import library name into $newdlprefiles.
6557428d7b3dSmrg	      # We recover the dlopen module name by 'saving' the la file
6558428d7b3dSmrg	      # name in a special purpose variable, and (later) extracting the
6559428d7b3dSmrg	      # dlname from the la file.
6560428d7b3dSmrg	      if test -n "$dlname"; then
6561428d7b3dSmrg	        func_tr_sh "$dir/$linklib"
6562428d7b3dSmrg	        eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname"
6563428d7b3dSmrg	        func_append newdlprefiles " $dir/$linklib"
6564428d7b3dSmrg	      else
6565428d7b3dSmrg	        func_append newdlprefiles " $dir/$old_library"
6566428d7b3dSmrg	        # Keep a list of preopened convenience libraries to check
6567428d7b3dSmrg	        # that they are being used correctly in the link pass.
6568428d7b3dSmrg	        test -z "$libdir" && \
6569428d7b3dSmrg	          func_append dlpreconveniencelibs " $dir/$old_library"
6570428d7b3dSmrg	      fi
6571428d7b3dSmrg	    ;;
6572428d7b3dSmrg	    * )
6573428d7b3dSmrg	      # Prefer using a static library (so that no silly _DYNAMIC symbols
6574428d7b3dSmrg	      # are required to link).
6575428d7b3dSmrg	      if test -n "$old_library"; then
6576428d7b3dSmrg	        func_append newdlprefiles " $dir/$old_library"
6577428d7b3dSmrg	        # Keep a list of preopened convenience libraries to check
6578428d7b3dSmrg	        # that they are being used correctly in the link pass.
6579428d7b3dSmrg	        test -z "$libdir" && \
6580428d7b3dSmrg	          func_append dlpreconveniencelibs " $dir/$old_library"
6581428d7b3dSmrg	      # Otherwise, use the dlname, so that lt_dlopen finds it.
6582428d7b3dSmrg	      elif test -n "$dlname"; then
6583428d7b3dSmrg	        func_append newdlprefiles " $dir/$dlname"
6584428d7b3dSmrg	      else
6585428d7b3dSmrg	        func_append newdlprefiles " $dir/$linklib"
6586428d7b3dSmrg	      fi
6587428d7b3dSmrg	    ;;
6588428d7b3dSmrg	  esac
6589428d7b3dSmrg	fi # $pass = dlpreopen
6590428d7b3dSmrg
6591428d7b3dSmrg	if test -z "$libdir"; then
6592428d7b3dSmrg	  # Link the convenience library
6593428d7b3dSmrg	  if test "$linkmode" = lib; then
6594428d7b3dSmrg	    deplibs="$dir/$old_library $deplibs"
6595428d7b3dSmrg	  elif test "$linkmode,$pass" = "prog,link"; then
6596428d7b3dSmrg	    compile_deplibs="$dir/$old_library $compile_deplibs"
6597428d7b3dSmrg	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
6598428d7b3dSmrg	  else
6599428d7b3dSmrg	    deplibs="$lib $deplibs" # used for prog,scan pass
6600428d7b3dSmrg	  fi
6601428d7b3dSmrg	  continue
6602428d7b3dSmrg	fi
6603428d7b3dSmrg
6604428d7b3dSmrg
6605428d7b3dSmrg	if test "$linkmode" = prog && test "$pass" != link; then
6606428d7b3dSmrg	  func_append newlib_search_path " $ladir"
6607428d7b3dSmrg	  deplibs="$lib $deplibs"
6608428d7b3dSmrg
6609428d7b3dSmrg	  linkalldeplibs=no
6610428d7b3dSmrg	  if test "$link_all_deplibs" != no || test -z "$library_names" ||
6611428d7b3dSmrg	     test "$build_libtool_libs" = no; then
6612428d7b3dSmrg	    linkalldeplibs=yes
6613428d7b3dSmrg	  fi
6614428d7b3dSmrg
6615428d7b3dSmrg	  tmp_libs=
6616428d7b3dSmrg	  for deplib in $dependency_libs; do
6617428d7b3dSmrg	    case $deplib in
6618428d7b3dSmrg	    -L*) func_stripname '-L' '' "$deplib"
6619428d7b3dSmrg	         func_resolve_sysroot "$func_stripname_result"
6620428d7b3dSmrg	         func_append newlib_search_path " $func_resolve_sysroot_result"
6621428d7b3dSmrg		 ;;
6622428d7b3dSmrg	    esac
6623428d7b3dSmrg	    # Need to link against all dependency_libs?
6624428d7b3dSmrg	    if test "$linkalldeplibs" = yes; then
6625428d7b3dSmrg	      deplibs="$deplib $deplibs"
6626428d7b3dSmrg	    else
6627428d7b3dSmrg	      # Need to hardcode shared library paths
6628428d7b3dSmrg	      # or/and link against static libraries
6629428d7b3dSmrg	      newdependency_libs="$deplib $newdependency_libs"
6630428d7b3dSmrg	    fi
6631428d7b3dSmrg	    if $opt_preserve_dup_deps ; then
6632428d7b3dSmrg	      case "$tmp_libs " in
6633428d7b3dSmrg	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
6634428d7b3dSmrg	      esac
6635428d7b3dSmrg	    fi
6636428d7b3dSmrg	    func_append tmp_libs " $deplib"
6637428d7b3dSmrg	  done # for deplib
6638428d7b3dSmrg	  continue
6639428d7b3dSmrg	fi # $linkmode = prog...
6640428d7b3dSmrg
6641428d7b3dSmrg	if test "$linkmode,$pass" = "prog,link"; then
6642428d7b3dSmrg	  if test -n "$library_names" &&
6643428d7b3dSmrg	     { { test "$prefer_static_libs" = no ||
6644428d7b3dSmrg	         test "$prefer_static_libs,$installed" = "built,yes"; } ||
6645428d7b3dSmrg	       test -z "$old_library"; }; then
6646428d7b3dSmrg	    # We need to hardcode the library path
6647428d7b3dSmrg	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
6648428d7b3dSmrg	      # Make sure the rpath contains only unique directories.
6649428d7b3dSmrg	      case "$temp_rpath:" in
6650428d7b3dSmrg	      *"$absdir:"*) ;;
6651428d7b3dSmrg	      *) func_append temp_rpath "$absdir:" ;;
6652428d7b3dSmrg	      esac
6653428d7b3dSmrg	    fi
6654428d7b3dSmrg
6655428d7b3dSmrg	    # Hardcode the library path.
6656428d7b3dSmrg	    # Skip directories that are in the system default run-time
6657428d7b3dSmrg	    # search path.
6658428d7b3dSmrg	    case " $sys_lib_dlsearch_path " in
6659428d7b3dSmrg	    *" $absdir "*) ;;
6660428d7b3dSmrg	    *)
6661428d7b3dSmrg	      case "$compile_rpath " in
6662428d7b3dSmrg	      *" $absdir "*) ;;
6663428d7b3dSmrg	      *) func_append compile_rpath " $absdir" ;;
6664428d7b3dSmrg	      esac
6665428d7b3dSmrg	      ;;
6666428d7b3dSmrg	    esac
6667428d7b3dSmrg	    case " $sys_lib_dlsearch_path " in
6668428d7b3dSmrg	    *" $libdir "*) ;;
6669428d7b3dSmrg	    *)
6670428d7b3dSmrg	      case "$finalize_rpath " in
6671428d7b3dSmrg	      *" $libdir "*) ;;
6672428d7b3dSmrg	      *) func_append finalize_rpath " $libdir" ;;
6673428d7b3dSmrg	      esac
6674428d7b3dSmrg	      ;;
6675428d7b3dSmrg	    esac
6676428d7b3dSmrg	  fi # $linkmode,$pass = prog,link...
6677428d7b3dSmrg
6678428d7b3dSmrg	  if test "$alldeplibs" = yes &&
6679428d7b3dSmrg	     { test "$deplibs_check_method" = pass_all ||
6680428d7b3dSmrg	       { test "$build_libtool_libs" = yes &&
6681428d7b3dSmrg		 test -n "$library_names"; }; }; then
6682428d7b3dSmrg	    # We only need to search for static libraries
6683428d7b3dSmrg	    continue
6684428d7b3dSmrg	  fi
6685428d7b3dSmrg	fi
6686428d7b3dSmrg
6687428d7b3dSmrg	link_static=no # Whether the deplib will be linked statically
6688428d7b3dSmrg	use_static_libs=$prefer_static_libs
6689428d7b3dSmrg	if test "$use_static_libs" = built && test "$installed" = yes; then
6690428d7b3dSmrg	  use_static_libs=no
6691428d7b3dSmrg	fi
6692428d7b3dSmrg	if test -n "$library_names" &&
6693428d7b3dSmrg	   { test "$use_static_libs" = no || test -z "$old_library"; }; then
6694428d7b3dSmrg	  case $host in
6695428d7b3dSmrg	  *cygwin* | *mingw* | *cegcc*)
6696428d7b3dSmrg	      # No point in relinking DLLs because paths are not encoded
6697428d7b3dSmrg	      func_append notinst_deplibs " $lib"
6698428d7b3dSmrg	      need_relink=no
6699428d7b3dSmrg	    ;;
6700428d7b3dSmrg	  *)
6701428d7b3dSmrg	    if test "$installed" = no; then
6702428d7b3dSmrg	      func_append notinst_deplibs " $lib"
6703428d7b3dSmrg	      need_relink=yes
6704428d7b3dSmrg	    fi
6705428d7b3dSmrg	    ;;
6706428d7b3dSmrg	  esac
6707428d7b3dSmrg	  # This is a shared library
6708428d7b3dSmrg
6709428d7b3dSmrg	  # Warn about portability, can't link against -module's on some
6710428d7b3dSmrg	  # systems (darwin).  Don't bleat about dlopened modules though!
6711428d7b3dSmrg	  dlopenmodule=""
6712428d7b3dSmrg	  for dlpremoduletest in $dlprefiles; do
6713428d7b3dSmrg	    if test "X$dlpremoduletest" = "X$lib"; then
6714428d7b3dSmrg	      dlopenmodule="$dlpremoduletest"
6715428d7b3dSmrg	      break
6716428d7b3dSmrg	    fi
6717428d7b3dSmrg	  done
6718428d7b3dSmrg	  if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then
6719428d7b3dSmrg	    echo
6720428d7b3dSmrg	    if test "$linkmode" = prog; then
6721428d7b3dSmrg	      $ECHO "*** Warning: Linking the executable $output against the loadable module"
6722428d7b3dSmrg	    else
6723428d7b3dSmrg	      $ECHO "*** Warning: Linking the shared library $output against the loadable module"
6724428d7b3dSmrg	    fi
6725428d7b3dSmrg	    $ECHO "*** $linklib is not portable!"
6726428d7b3dSmrg	  fi
6727428d7b3dSmrg	  if test "$linkmode" = lib &&
6728428d7b3dSmrg	     test "$hardcode_into_libs" = yes; then
6729428d7b3dSmrg	    # Hardcode the library path.
6730428d7b3dSmrg	    # Skip directories that are in the system default run-time
6731428d7b3dSmrg	    # search path.
6732428d7b3dSmrg	    case " $sys_lib_dlsearch_path " in
6733428d7b3dSmrg	    *" $absdir "*) ;;
6734428d7b3dSmrg	    *)
6735428d7b3dSmrg	      case "$compile_rpath " in
6736428d7b3dSmrg	      *" $absdir "*) ;;
6737428d7b3dSmrg	      *) func_append compile_rpath " $absdir" ;;
6738428d7b3dSmrg	      esac
6739428d7b3dSmrg	      ;;
6740428d7b3dSmrg	    esac
6741428d7b3dSmrg	    case " $sys_lib_dlsearch_path " in
6742428d7b3dSmrg	    *" $libdir "*) ;;
6743428d7b3dSmrg	    *)
6744428d7b3dSmrg	      case "$finalize_rpath " in
6745428d7b3dSmrg	      *" $libdir "*) ;;
6746428d7b3dSmrg	      *) func_append finalize_rpath " $libdir" ;;
6747428d7b3dSmrg	      esac
6748428d7b3dSmrg	      ;;
6749428d7b3dSmrg	    esac
6750428d7b3dSmrg	  fi
6751428d7b3dSmrg
6752428d7b3dSmrg	  if test -n "$old_archive_from_expsyms_cmds"; then
6753428d7b3dSmrg	    # figure out the soname
6754428d7b3dSmrg	    set dummy $library_names
6755428d7b3dSmrg	    shift
6756428d7b3dSmrg	    realname="$1"
6757428d7b3dSmrg	    shift
6758428d7b3dSmrg	    libname=`eval "\\$ECHO \"$libname_spec\""`
6759428d7b3dSmrg	    # use dlname if we got it. it's perfectly good, no?
6760428d7b3dSmrg	    if test -n "$dlname"; then
6761428d7b3dSmrg	      soname="$dlname"
6762428d7b3dSmrg	    elif test -n "$soname_spec"; then
6763428d7b3dSmrg	      # bleh windows
6764428d7b3dSmrg	      case $host in
6765428d7b3dSmrg	      *cygwin* | mingw* | *cegcc*)
6766428d7b3dSmrg	        func_arith $current - $age
6767428d7b3dSmrg		major=$func_arith_result
6768428d7b3dSmrg		versuffix="-$major"
6769428d7b3dSmrg		;;
6770428d7b3dSmrg	      esac
6771428d7b3dSmrg	      eval soname=\"$soname_spec\"
6772428d7b3dSmrg	    else
6773428d7b3dSmrg	      soname="$realname"
6774428d7b3dSmrg	    fi
6775428d7b3dSmrg
6776428d7b3dSmrg	    # Make a new name for the extract_expsyms_cmds to use
6777428d7b3dSmrg	    soroot="$soname"
6778428d7b3dSmrg	    func_basename "$soroot"
6779428d7b3dSmrg	    soname="$func_basename_result"
6780428d7b3dSmrg	    func_stripname 'lib' '.dll' "$soname"
6781428d7b3dSmrg	    newlib=libimp-$func_stripname_result.a
6782428d7b3dSmrg
6783428d7b3dSmrg	    # If the library has no export list, then create one now
6784428d7b3dSmrg	    if test -f "$output_objdir/$soname-def"; then :
6785428d7b3dSmrg	    else
6786428d7b3dSmrg	      func_verbose "extracting exported symbol list from \`$soname'"
6787428d7b3dSmrg	      func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
6788428d7b3dSmrg	    fi
6789428d7b3dSmrg
6790428d7b3dSmrg	    # Create $newlib
6791428d7b3dSmrg	    if test -f "$output_objdir/$newlib"; then :; else
6792428d7b3dSmrg	      func_verbose "generating import library for \`$soname'"
6793428d7b3dSmrg	      func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
6794428d7b3dSmrg	    fi
6795428d7b3dSmrg	    # make sure the library variables are pointing to the new library
6796428d7b3dSmrg	    dir=$output_objdir
6797428d7b3dSmrg	    linklib=$newlib
6798428d7b3dSmrg	  fi # test -n "$old_archive_from_expsyms_cmds"
6799428d7b3dSmrg
6800428d7b3dSmrg	  if test "$linkmode" = prog || test "$opt_mode" != relink; then
6801428d7b3dSmrg	    add_shlibpath=
6802428d7b3dSmrg	    add_dir=
6803428d7b3dSmrg	    add=
6804428d7b3dSmrg	    lib_linked=yes
6805428d7b3dSmrg	    case $hardcode_action in
6806428d7b3dSmrg	    immediate | unsupported)
6807428d7b3dSmrg	      if test "$hardcode_direct" = no; then
6808428d7b3dSmrg		add="$dir/$linklib"
6809428d7b3dSmrg		case $host in
6810428d7b3dSmrg		  *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
6811428d7b3dSmrg		  *-*-sysv4*uw2*) add_dir="-L$dir" ;;
6812428d7b3dSmrg		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
6813428d7b3dSmrg		    *-*-unixware7*) add_dir="-L$dir" ;;
6814428d7b3dSmrg		  *-*-darwin* )
6815428d7b3dSmrg		    # if the lib is a (non-dlopened) module then we can not
6816428d7b3dSmrg		    # link against it, someone is ignoring the earlier warnings
6817428d7b3dSmrg		    if /usr/bin/file -L $add 2> /dev/null |
6818428d7b3dSmrg			 $GREP ": [^:]* bundle" >/dev/null ; then
6819428d7b3dSmrg		      if test "X$dlopenmodule" != "X$lib"; then
6820428d7b3dSmrg			$ECHO "*** Warning: lib $linklib is a module, not a shared library"
6821428d7b3dSmrg			if test -z "$old_library" ; then
6822428d7b3dSmrg			  echo
6823428d7b3dSmrg			  echo "*** And there doesn't seem to be a static archive available"
6824428d7b3dSmrg			  echo "*** The link will probably fail, sorry"
6825428d7b3dSmrg			else
6826428d7b3dSmrg			  add="$dir/$old_library"
6827428d7b3dSmrg			fi
6828428d7b3dSmrg		      elif test -n "$old_library"; then
6829428d7b3dSmrg			add="$dir/$old_library"
6830428d7b3dSmrg		      fi
6831428d7b3dSmrg		    fi
6832428d7b3dSmrg		esac
6833428d7b3dSmrg	      elif test "$hardcode_minus_L" = no; then
6834428d7b3dSmrg		case $host in
6835428d7b3dSmrg		*-*-sunos*) add_shlibpath="$dir" ;;
6836428d7b3dSmrg		esac
6837428d7b3dSmrg		add_dir="-L$dir"
6838428d7b3dSmrg		add="-l$name"
6839428d7b3dSmrg	      elif test "$hardcode_shlibpath_var" = no; then
6840428d7b3dSmrg		add_shlibpath="$dir"
6841428d7b3dSmrg		add="-l$name"
6842428d7b3dSmrg	      else
6843428d7b3dSmrg		lib_linked=no
6844428d7b3dSmrg	      fi
6845428d7b3dSmrg	      ;;
6846428d7b3dSmrg	    relink)
6847428d7b3dSmrg	      if test "$hardcode_direct" = yes &&
6848428d7b3dSmrg	         test "$hardcode_direct_absolute" = no; then
6849428d7b3dSmrg		add="$dir/$linklib"
6850428d7b3dSmrg	      elif test "$hardcode_minus_L" = yes; then
6851428d7b3dSmrg		add_dir="-L$absdir"
6852428d7b3dSmrg		# Try looking first in the location we're being installed to.
6853428d7b3dSmrg		if test -n "$inst_prefix_dir"; then
6854428d7b3dSmrg		  case $libdir in
6855428d7b3dSmrg		    [\\/]*)
6856428d7b3dSmrg		      func_append add_dir " -L$inst_prefix_dir$libdir"
6857428d7b3dSmrg		      ;;
6858428d7b3dSmrg		  esac
6859428d7b3dSmrg		fi
6860428d7b3dSmrg		add="-l$name"
6861428d7b3dSmrg	      elif test "$hardcode_shlibpath_var" = yes; then
6862428d7b3dSmrg		add_shlibpath="$dir"
6863428d7b3dSmrg		add="-l$name"
6864428d7b3dSmrg	      else
6865428d7b3dSmrg		lib_linked=no
6866428d7b3dSmrg	      fi
6867428d7b3dSmrg	      ;;
6868428d7b3dSmrg	    *) lib_linked=no ;;
6869428d7b3dSmrg	    esac
6870428d7b3dSmrg
6871428d7b3dSmrg	    if test "$lib_linked" != yes; then
6872428d7b3dSmrg	      func_fatal_configuration "unsupported hardcode properties"
6873428d7b3dSmrg	    fi
6874428d7b3dSmrg
6875428d7b3dSmrg	    if test -n "$add_shlibpath"; then
6876428d7b3dSmrg	      case :$compile_shlibpath: in
6877428d7b3dSmrg	      *":$add_shlibpath:"*) ;;
6878428d7b3dSmrg	      *) func_append compile_shlibpath "$add_shlibpath:" ;;
6879428d7b3dSmrg	      esac
6880428d7b3dSmrg	    fi
6881428d7b3dSmrg	    if test "$linkmode" = prog; then
6882428d7b3dSmrg	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
6883428d7b3dSmrg	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
6884428d7b3dSmrg	    else
6885428d7b3dSmrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
6886428d7b3dSmrg	      test -n "$add" && deplibs="$add $deplibs"
6887428d7b3dSmrg	      if test "$hardcode_direct" != yes &&
6888428d7b3dSmrg		 test "$hardcode_minus_L" != yes &&
6889428d7b3dSmrg		 test "$hardcode_shlibpath_var" = yes; then
6890428d7b3dSmrg		case :$finalize_shlibpath: in
6891428d7b3dSmrg		*":$libdir:"*) ;;
6892428d7b3dSmrg		*) func_append finalize_shlibpath "$libdir:" ;;
6893428d7b3dSmrg		esac
6894428d7b3dSmrg	      fi
6895428d7b3dSmrg	    fi
6896428d7b3dSmrg	  fi
6897428d7b3dSmrg
6898428d7b3dSmrg	  if test "$linkmode" = prog || test "$opt_mode" = relink; then
6899428d7b3dSmrg	    add_shlibpath=
6900428d7b3dSmrg	    add_dir=
6901428d7b3dSmrg	    add=
6902428d7b3dSmrg	    # Finalize command for both is simple: just hardcode it.
6903428d7b3dSmrg	    if test "$hardcode_direct" = yes &&
6904428d7b3dSmrg	       test "$hardcode_direct_absolute" = no; then
6905428d7b3dSmrg	      add="$libdir/$linklib"
6906428d7b3dSmrg	    elif test "$hardcode_minus_L" = yes; then
6907428d7b3dSmrg	      add_dir="-L$libdir"
6908428d7b3dSmrg	      add="-l$name"
6909428d7b3dSmrg	    elif test "$hardcode_shlibpath_var" = yes; then
6910428d7b3dSmrg	      case :$finalize_shlibpath: in
6911428d7b3dSmrg	      *":$libdir:"*) ;;
6912428d7b3dSmrg	      *) func_append finalize_shlibpath "$libdir:" ;;
6913428d7b3dSmrg	      esac
6914428d7b3dSmrg	      add="-l$name"
6915428d7b3dSmrg	    elif test "$hardcode_automatic" = yes; then
6916428d7b3dSmrg	      if test -n "$inst_prefix_dir" &&
6917428d7b3dSmrg		 test -f "$inst_prefix_dir$libdir/$linklib" ; then
6918428d7b3dSmrg		add="$inst_prefix_dir$libdir/$linklib"
6919428d7b3dSmrg	      else
6920428d7b3dSmrg		add="$libdir/$linklib"
6921428d7b3dSmrg	      fi
6922428d7b3dSmrg	    else
6923428d7b3dSmrg	      # We cannot seem to hardcode it, guess we'll fake it.
6924428d7b3dSmrg	      add_dir="-L$libdir"
6925428d7b3dSmrg	      # Try looking first in the location we're being installed to.
6926428d7b3dSmrg	      if test -n "$inst_prefix_dir"; then
6927428d7b3dSmrg		case $libdir in
6928428d7b3dSmrg		  [\\/]*)
6929428d7b3dSmrg		    func_append add_dir " -L$inst_prefix_dir$libdir"
6930428d7b3dSmrg		    ;;
6931428d7b3dSmrg		esac
6932428d7b3dSmrg	      fi
6933428d7b3dSmrg	      add="-l$name"
6934428d7b3dSmrg	    fi
6935428d7b3dSmrg
6936428d7b3dSmrg	    if test "$linkmode" = prog; then
6937428d7b3dSmrg	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
6938428d7b3dSmrg	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
6939428d7b3dSmrg	    else
6940428d7b3dSmrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
6941428d7b3dSmrg	      test -n "$add" && deplibs="$add $deplibs"
6942428d7b3dSmrg	    fi
6943428d7b3dSmrg	  fi
6944428d7b3dSmrg	elif test "$linkmode" = prog; then
6945428d7b3dSmrg	  # Here we assume that one of hardcode_direct or hardcode_minus_L
6946428d7b3dSmrg	  # is not unsupported.  This is valid on all known static and
6947428d7b3dSmrg	  # shared platforms.
6948428d7b3dSmrg	  if test "$hardcode_direct" != unsupported; then
6949428d7b3dSmrg	    test -n "$old_library" && linklib="$old_library"
6950428d7b3dSmrg	    compile_deplibs="$dir/$linklib $compile_deplibs"
6951428d7b3dSmrg	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
6952428d7b3dSmrg	  else
6953428d7b3dSmrg	    compile_deplibs="-l$name -L$dir $compile_deplibs"
6954428d7b3dSmrg	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
6955428d7b3dSmrg	  fi
6956428d7b3dSmrg	elif test "$build_libtool_libs" = yes; then
6957428d7b3dSmrg	  # Not a shared library
6958428d7b3dSmrg	  if test "$deplibs_check_method" != pass_all; then
6959428d7b3dSmrg	    # We're trying link a shared library against a static one
6960428d7b3dSmrg	    # but the system doesn't support it.
6961428d7b3dSmrg
6962428d7b3dSmrg	    # Just print a warning and add the library to dependency_libs so
6963428d7b3dSmrg	    # that the program can be linked against the static library.
6964428d7b3dSmrg	    echo
6965428d7b3dSmrg	    $ECHO "*** Warning: This system can not link to static lib archive $lib."
6966428d7b3dSmrg	    echo "*** I have the capability to make that library automatically link in when"
6967428d7b3dSmrg	    echo "*** you link to this library.  But I can only do this if you have a"
6968428d7b3dSmrg	    echo "*** shared version of the library, which you do not appear to have."
6969428d7b3dSmrg	    if test "$module" = yes; then
6970428d7b3dSmrg	      echo "*** But as you try to build a module library, libtool will still create "
6971428d7b3dSmrg	      echo "*** a static module, that should work as long as the dlopening application"
6972428d7b3dSmrg	      echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
6973428d7b3dSmrg	      if test -z "$global_symbol_pipe"; then
6974428d7b3dSmrg		echo
6975428d7b3dSmrg		echo "*** However, this would only work if libtool was able to extract symbol"
6976428d7b3dSmrg		echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
6977428d7b3dSmrg		echo "*** not find such a program.  So, this module is probably useless."
6978428d7b3dSmrg		echo "*** \`nm' from GNU binutils and a full rebuild may help."
6979428d7b3dSmrg	      fi
6980428d7b3dSmrg	      if test "$build_old_libs" = no; then
6981428d7b3dSmrg		build_libtool_libs=module
6982428d7b3dSmrg		build_old_libs=yes
6983428d7b3dSmrg	      else
6984428d7b3dSmrg		build_libtool_libs=no
6985428d7b3dSmrg	      fi
6986428d7b3dSmrg	    fi
6987428d7b3dSmrg	  else
6988428d7b3dSmrg	    deplibs="$dir/$old_library $deplibs"
6989428d7b3dSmrg	    link_static=yes
6990428d7b3dSmrg	  fi
6991428d7b3dSmrg	fi # link shared/static library?
6992428d7b3dSmrg
6993428d7b3dSmrg	if test "$linkmode" = lib; then
6994428d7b3dSmrg	  if test -n "$dependency_libs" &&
6995428d7b3dSmrg	     { test "$hardcode_into_libs" != yes ||
6996428d7b3dSmrg	       test "$build_old_libs" = yes ||
6997428d7b3dSmrg	       test "$link_static" = yes; }; then
6998428d7b3dSmrg	    # Extract -R from dependency_libs
6999428d7b3dSmrg	    temp_deplibs=
7000428d7b3dSmrg	    for libdir in $dependency_libs; do
7001428d7b3dSmrg	      case $libdir in
7002428d7b3dSmrg	      -R*) func_stripname '-R' '' "$libdir"
7003428d7b3dSmrg	           temp_xrpath=$func_stripname_result
7004428d7b3dSmrg		   case " $xrpath " in
7005428d7b3dSmrg		   *" $temp_xrpath "*) ;;
7006428d7b3dSmrg		   *) func_append xrpath " $temp_xrpath";;
7007428d7b3dSmrg		   esac;;
7008428d7b3dSmrg	      *) func_append temp_deplibs " $libdir";;
7009428d7b3dSmrg	      esac
7010428d7b3dSmrg	    done
7011428d7b3dSmrg	    dependency_libs="$temp_deplibs"
7012428d7b3dSmrg	  fi
7013428d7b3dSmrg
7014428d7b3dSmrg	  func_append newlib_search_path " $absdir"
7015428d7b3dSmrg	  # Link against this library
7016428d7b3dSmrg	  test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
7017428d7b3dSmrg	  # ... and its dependency_libs
7018428d7b3dSmrg	  tmp_libs=
7019428d7b3dSmrg	  for deplib in $dependency_libs; do
7020428d7b3dSmrg	    newdependency_libs="$deplib $newdependency_libs"
7021428d7b3dSmrg	    case $deplib in
7022428d7b3dSmrg              -L*) func_stripname '-L' '' "$deplib"
7023428d7b3dSmrg                   func_resolve_sysroot "$func_stripname_result";;
7024428d7b3dSmrg              *) func_resolve_sysroot "$deplib" ;;
7025428d7b3dSmrg            esac
7026428d7b3dSmrg	    if $opt_preserve_dup_deps ; then
7027428d7b3dSmrg	      case "$tmp_libs " in
7028428d7b3dSmrg	      *" $func_resolve_sysroot_result "*)
7029428d7b3dSmrg                func_append specialdeplibs " $func_resolve_sysroot_result" ;;
7030428d7b3dSmrg	      esac
7031428d7b3dSmrg	    fi
7032428d7b3dSmrg	    func_append tmp_libs " $func_resolve_sysroot_result"
7033428d7b3dSmrg	  done
7034428d7b3dSmrg
7035428d7b3dSmrg	  if test "$link_all_deplibs" != no; then
7036428d7b3dSmrg	    # Add the search paths of all dependency libraries
7037428d7b3dSmrg	    for deplib in $dependency_libs; do
7038428d7b3dSmrg	      path=
7039428d7b3dSmrg	      case $deplib in
7040428d7b3dSmrg	      -L*) path="$deplib" ;;
7041428d7b3dSmrg	      *.la)
7042428d7b3dSmrg	        func_resolve_sysroot "$deplib"
7043428d7b3dSmrg	        deplib=$func_resolve_sysroot_result
7044428d7b3dSmrg	        func_dirname "$deplib" "" "."
7045428d7b3dSmrg		dir=$func_dirname_result
7046428d7b3dSmrg		# We need an absolute path.
7047428d7b3dSmrg		case $dir in
7048428d7b3dSmrg		[\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
7049428d7b3dSmrg		*)
7050428d7b3dSmrg		  absdir=`cd "$dir" && pwd`
7051428d7b3dSmrg		  if test -z "$absdir"; then
7052428d7b3dSmrg		    func_warning "cannot determine absolute directory name of \`$dir'"
7053428d7b3dSmrg		    absdir="$dir"
7054428d7b3dSmrg		  fi
7055428d7b3dSmrg		  ;;
7056428d7b3dSmrg		esac
7057428d7b3dSmrg		if $GREP "^installed=no" $deplib > /dev/null; then
7058428d7b3dSmrg		case $host in
7059428d7b3dSmrg		*-*-darwin*)
7060428d7b3dSmrg		  depdepl=
7061428d7b3dSmrg		  eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
7062428d7b3dSmrg		  if test -n "$deplibrary_names" ; then
7063428d7b3dSmrg		    for tmp in $deplibrary_names ; do
7064428d7b3dSmrg		      depdepl=$tmp
7065428d7b3dSmrg		    done
7066428d7b3dSmrg		    if test -f "$absdir/$objdir/$depdepl" ; then
7067428d7b3dSmrg		      depdepl="$absdir/$objdir/$depdepl"
7068428d7b3dSmrg		      darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
7069428d7b3dSmrg                      if test -z "$darwin_install_name"; then
7070428d7b3dSmrg                          darwin_install_name=`${OTOOL64} -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
7071428d7b3dSmrg                      fi
7072428d7b3dSmrg		      func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}"
7073428d7b3dSmrg		      func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}"
7074428d7b3dSmrg		      path=
7075428d7b3dSmrg		    fi
7076428d7b3dSmrg		  fi
7077428d7b3dSmrg		  ;;
7078428d7b3dSmrg		*)
7079428d7b3dSmrg		  path="-L$absdir/$objdir"
7080428d7b3dSmrg		  ;;
7081428d7b3dSmrg		esac
7082428d7b3dSmrg		else
7083428d7b3dSmrg		  eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
7084428d7b3dSmrg		  test -z "$libdir" && \
7085428d7b3dSmrg		    func_fatal_error "\`$deplib' is not a valid libtool archive"
7086428d7b3dSmrg		  test "$absdir" != "$libdir" && \
7087428d7b3dSmrg		    func_warning "\`$deplib' seems to be moved"
7088428d7b3dSmrg
7089428d7b3dSmrg		  path="-L$absdir"
7090428d7b3dSmrg		fi
7091428d7b3dSmrg		;;
7092428d7b3dSmrg	      esac
7093428d7b3dSmrg	      case " $deplibs " in
7094428d7b3dSmrg	      *" $path "*) ;;
7095428d7b3dSmrg	      *) deplibs="$path $deplibs" ;;
7096428d7b3dSmrg	      esac
7097428d7b3dSmrg	    done
7098428d7b3dSmrg	  fi # link_all_deplibs != no
7099428d7b3dSmrg	fi # linkmode = lib
7100428d7b3dSmrg      done # for deplib in $libs
7101428d7b3dSmrg      if test "$pass" = link; then
7102428d7b3dSmrg	if test "$linkmode" = "prog"; then
7103428d7b3dSmrg	  compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
7104428d7b3dSmrg	  finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
7105428d7b3dSmrg	else
7106428d7b3dSmrg	  compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
7107428d7b3dSmrg	fi
7108428d7b3dSmrg      fi
7109428d7b3dSmrg      dependency_libs="$newdependency_libs"
7110428d7b3dSmrg      if test "$pass" = dlpreopen; then
7111428d7b3dSmrg	# Link the dlpreopened libraries before other libraries
7112428d7b3dSmrg	for deplib in $save_deplibs; do
7113428d7b3dSmrg	  deplibs="$deplib $deplibs"
7114428d7b3dSmrg	done
7115428d7b3dSmrg      fi
7116428d7b3dSmrg      if test "$pass" != dlopen; then
7117428d7b3dSmrg	if test "$pass" != conv; then
7118428d7b3dSmrg	  # Make sure lib_search_path contains only unique directories.
7119428d7b3dSmrg	  lib_search_path=
7120428d7b3dSmrg	  for dir in $newlib_search_path; do
7121428d7b3dSmrg	    case "$lib_search_path " in
7122428d7b3dSmrg	    *" $dir "*) ;;
7123428d7b3dSmrg	    *) func_append lib_search_path " $dir" ;;
7124428d7b3dSmrg	    esac
7125428d7b3dSmrg	  done
7126428d7b3dSmrg	  newlib_search_path=
7127428d7b3dSmrg	fi
7128428d7b3dSmrg
7129428d7b3dSmrg	if test "$linkmode,$pass" != "prog,link"; then
7130428d7b3dSmrg	  vars="deplibs"
7131428d7b3dSmrg	else
7132428d7b3dSmrg	  vars="compile_deplibs finalize_deplibs"
7133428d7b3dSmrg	fi
7134428d7b3dSmrg	for var in $vars dependency_libs; do
7135428d7b3dSmrg	  # Add libraries to $var in reverse order
7136428d7b3dSmrg	  eval tmp_libs=\"\$$var\"
7137428d7b3dSmrg	  new_libs=
7138428d7b3dSmrg	  for deplib in $tmp_libs; do
7139428d7b3dSmrg	    # FIXME: Pedantically, this is the right thing to do, so
7140428d7b3dSmrg	    #        that some nasty dependency loop isn't accidentally
7141428d7b3dSmrg	    #        broken:
7142428d7b3dSmrg	    #new_libs="$deplib $new_libs"
7143428d7b3dSmrg	    # Pragmatically, this seems to cause very few problems in
7144428d7b3dSmrg	    # practice:
7145428d7b3dSmrg	    case $deplib in
7146428d7b3dSmrg	    -L*) new_libs="$deplib $new_libs" ;;
7147428d7b3dSmrg	    -R*) ;;
7148428d7b3dSmrg	    *)
7149428d7b3dSmrg	      # And here is the reason: when a library appears more
7150428d7b3dSmrg	      # than once as an explicit dependence of a library, or
7151428d7b3dSmrg	      # is implicitly linked in more than once by the
7152428d7b3dSmrg	      # compiler, it is considered special, and multiple
7153428d7b3dSmrg	      # occurrences thereof are not removed.  Compare this
7154428d7b3dSmrg	      # with having the same library being listed as a
7155428d7b3dSmrg	      # dependency of multiple other libraries: in this case,
7156428d7b3dSmrg	      # we know (pedantically, we assume) the library does not
7157428d7b3dSmrg	      # need to be listed more than once, so we keep only the
7158428d7b3dSmrg	      # last copy.  This is not always right, but it is rare
7159428d7b3dSmrg	      # enough that we require users that really mean to play
7160428d7b3dSmrg	      # such unportable linking tricks to link the library
7161428d7b3dSmrg	      # using -Wl,-lname, so that libtool does not consider it
7162428d7b3dSmrg	      # for duplicate removal.
7163428d7b3dSmrg	      case " $specialdeplibs " in
7164428d7b3dSmrg	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
7165428d7b3dSmrg	      *)
7166428d7b3dSmrg		case " $new_libs " in
7167428d7b3dSmrg		*" $deplib "*) ;;
7168428d7b3dSmrg		*) new_libs="$deplib $new_libs" ;;
7169428d7b3dSmrg		esac
7170428d7b3dSmrg		;;
7171428d7b3dSmrg	      esac
7172428d7b3dSmrg	      ;;
7173428d7b3dSmrg	    esac
7174428d7b3dSmrg	  done
7175428d7b3dSmrg	  tmp_libs=
7176428d7b3dSmrg	  for deplib in $new_libs; do
7177428d7b3dSmrg	    case $deplib in
7178428d7b3dSmrg	    -L*)
7179428d7b3dSmrg	      case " $tmp_libs " in
7180428d7b3dSmrg	      *" $deplib "*) ;;
7181428d7b3dSmrg	      *) func_append tmp_libs " $deplib" ;;
7182428d7b3dSmrg	      esac
7183428d7b3dSmrg	      ;;
7184428d7b3dSmrg	    *) func_append tmp_libs " $deplib" ;;
7185428d7b3dSmrg	    esac
7186428d7b3dSmrg	  done
7187428d7b3dSmrg	  eval $var=\"$tmp_libs\"
7188428d7b3dSmrg	done # for var
7189428d7b3dSmrg      fi
7190428d7b3dSmrg      # Last step: remove runtime libs from dependency_libs
7191428d7b3dSmrg      # (they stay in deplibs)
7192428d7b3dSmrg      tmp_libs=
7193428d7b3dSmrg      for i in $dependency_libs ; do
7194428d7b3dSmrg	case " $predeps $postdeps $compiler_lib_search_path " in
7195428d7b3dSmrg	*" $i "*)
7196428d7b3dSmrg	  i=""
7197428d7b3dSmrg	  ;;
7198428d7b3dSmrg	esac
7199428d7b3dSmrg	if test -n "$i" ; then
7200428d7b3dSmrg	  func_append tmp_libs " $i"
7201428d7b3dSmrg	fi
7202428d7b3dSmrg      done
7203428d7b3dSmrg      dependency_libs=$tmp_libs
7204428d7b3dSmrg    done # for pass
7205428d7b3dSmrg    if test "$linkmode" = prog; then
7206428d7b3dSmrg      dlfiles="$newdlfiles"
7207428d7b3dSmrg    fi
7208428d7b3dSmrg    if test "$linkmode" = prog || test "$linkmode" = lib; then
7209428d7b3dSmrg      dlprefiles="$newdlprefiles"
7210428d7b3dSmrg    fi
7211428d7b3dSmrg
7212428d7b3dSmrg    case $linkmode in
7213428d7b3dSmrg    oldlib)
7214428d7b3dSmrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
7215428d7b3dSmrg	func_warning "\`-dlopen' is ignored for archives"
7216428d7b3dSmrg      fi
7217428d7b3dSmrg
7218428d7b3dSmrg      case " $deplibs" in
7219428d7b3dSmrg      *\ -l* | *\ -L*)
7220428d7b3dSmrg	func_warning "\`-l' and \`-L' are ignored for archives" ;;
7221428d7b3dSmrg      esac
7222428d7b3dSmrg
7223428d7b3dSmrg      test -n "$rpath" && \
7224428d7b3dSmrg	func_warning "\`-rpath' is ignored for archives"
7225428d7b3dSmrg
7226428d7b3dSmrg      test -n "$xrpath" && \
7227428d7b3dSmrg	func_warning "\`-R' is ignored for archives"
7228428d7b3dSmrg
7229428d7b3dSmrg      test -n "$vinfo" && \
7230428d7b3dSmrg	func_warning "\`-version-info/-version-number' is ignored for archives"
7231428d7b3dSmrg
7232428d7b3dSmrg      test -n "$release" && \
7233428d7b3dSmrg	func_warning "\`-release' is ignored for archives"
7234428d7b3dSmrg
7235428d7b3dSmrg      test -n "$export_symbols$export_symbols_regex" && \
7236428d7b3dSmrg	func_warning "\`-export-symbols' is ignored for archives"
7237428d7b3dSmrg
7238428d7b3dSmrg      # Now set the variables for building old libraries.
7239428d7b3dSmrg      build_libtool_libs=no
7240428d7b3dSmrg      oldlibs="$output"
7241428d7b3dSmrg      func_append objs "$old_deplibs"
7242428d7b3dSmrg      ;;
7243428d7b3dSmrg
7244428d7b3dSmrg    lib)
7245428d7b3dSmrg      # Make sure we only generate libraries of the form `libNAME.la'.
7246428d7b3dSmrg      case $outputname in
7247428d7b3dSmrg      lib*)
7248428d7b3dSmrg	func_stripname 'lib' '.la' "$outputname"
7249428d7b3dSmrg	name=$func_stripname_result
7250428d7b3dSmrg	eval shared_ext=\"$shrext_cmds\"
7251428d7b3dSmrg	eval libname=\"$libname_spec\"
7252428d7b3dSmrg	;;
7253428d7b3dSmrg      *)
7254428d7b3dSmrg	test "$module" = no && \
7255428d7b3dSmrg	  func_fatal_help "libtool library \`$output' must begin with \`lib'"
7256428d7b3dSmrg
7257428d7b3dSmrg	if test "$need_lib_prefix" != no; then
7258428d7b3dSmrg	  # Add the "lib" prefix for modules if required
7259428d7b3dSmrg	  func_stripname '' '.la' "$outputname"
7260428d7b3dSmrg	  name=$func_stripname_result
7261428d7b3dSmrg	  eval shared_ext=\"$shrext_cmds\"
7262428d7b3dSmrg	  eval libname=\"$libname_spec\"
7263428d7b3dSmrg	else
7264428d7b3dSmrg	  func_stripname '' '.la' "$outputname"
7265428d7b3dSmrg	  libname=$func_stripname_result
7266428d7b3dSmrg	fi
7267428d7b3dSmrg	;;
7268428d7b3dSmrg      esac
7269428d7b3dSmrg
7270428d7b3dSmrg      if test -n "$objs"; then
7271428d7b3dSmrg	if test "$deplibs_check_method" != pass_all; then
7272428d7b3dSmrg	  func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs"
7273428d7b3dSmrg	else
7274428d7b3dSmrg	  echo
7275428d7b3dSmrg	  $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
7276428d7b3dSmrg	  $ECHO "*** objects $objs is not portable!"
7277428d7b3dSmrg	  func_append libobjs " $objs"
7278428d7b3dSmrg	fi
7279428d7b3dSmrg      fi
7280428d7b3dSmrg
7281428d7b3dSmrg      test "$dlself" != no && \
7282428d7b3dSmrg	func_warning "\`-dlopen self' is ignored for libtool libraries"
7283428d7b3dSmrg
7284428d7b3dSmrg      set dummy $rpath
7285428d7b3dSmrg      shift
7286428d7b3dSmrg      test "$#" -gt 1 && \
7287428d7b3dSmrg	func_warning "ignoring multiple \`-rpath's for a libtool library"
7288428d7b3dSmrg
7289428d7b3dSmrg      install_libdir="$1"
7290428d7b3dSmrg
7291428d7b3dSmrg      oldlibs=
7292428d7b3dSmrg      if test -z "$rpath"; then
7293428d7b3dSmrg	if test "$build_libtool_libs" = yes; then
7294428d7b3dSmrg	  # Building a libtool convenience library.
7295428d7b3dSmrg	  # Some compilers have problems with a `.al' extension so
7296428d7b3dSmrg	  # convenience libraries should have the same extension an
7297428d7b3dSmrg	  # archive normally would.
7298428d7b3dSmrg	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
7299428d7b3dSmrg	  build_libtool_libs=convenience
7300428d7b3dSmrg	  build_old_libs=yes
7301428d7b3dSmrg	fi
7302428d7b3dSmrg
7303428d7b3dSmrg	test -n "$vinfo" && \
7304428d7b3dSmrg	  func_warning "\`-version-info/-version-number' is ignored for convenience libraries"
7305428d7b3dSmrg
7306428d7b3dSmrg	test -n "$release" && \
7307428d7b3dSmrg	  func_warning "\`-release' is ignored for convenience libraries"
7308428d7b3dSmrg      else
7309428d7b3dSmrg
7310428d7b3dSmrg	# Parse the version information argument.
7311428d7b3dSmrg	save_ifs="$IFS"; IFS=':'
7312428d7b3dSmrg	set dummy $vinfo 0 0 0
7313428d7b3dSmrg	shift
7314428d7b3dSmrg	IFS="$save_ifs"
7315428d7b3dSmrg
7316428d7b3dSmrg	test -n "$7" && \
7317428d7b3dSmrg	  func_fatal_help "too many parameters to \`-version-info'"
7318428d7b3dSmrg
7319428d7b3dSmrg	# convert absolute version numbers to libtool ages
7320428d7b3dSmrg	# this retains compatibility with .la files and attempts
7321428d7b3dSmrg	# to make the code below a bit more comprehensible
7322428d7b3dSmrg
7323428d7b3dSmrg	case $vinfo_number in
7324428d7b3dSmrg	yes)
7325428d7b3dSmrg	  number_major="$1"
7326428d7b3dSmrg	  number_minor="$2"
7327428d7b3dSmrg	  number_revision="$3"
7328428d7b3dSmrg	  #
7329428d7b3dSmrg	  # There are really only two kinds -- those that
7330428d7b3dSmrg	  # use the current revision as the major version
7331428d7b3dSmrg	  # and those that subtract age and use age as
7332428d7b3dSmrg	  # a minor version.  But, then there is irix
7333428d7b3dSmrg	  # which has an extra 1 added just for fun
7334428d7b3dSmrg	  #
7335428d7b3dSmrg	  case $version_type in
7336428d7b3dSmrg	  # correct linux to gnu/linux during the next big refactor
7337428d7b3dSmrg	  darwin|linux|osf|windows|none)
7338428d7b3dSmrg	    func_arith $number_major + $number_minor
7339428d7b3dSmrg	    current=$func_arith_result
7340428d7b3dSmrg	    age="$number_minor"
7341428d7b3dSmrg	    revision="$number_revision"
7342428d7b3dSmrg	    ;;
7343428d7b3dSmrg	  freebsd-aout|freebsd-elf|qnx|sunos)
7344428d7b3dSmrg	    current="$number_major"
7345428d7b3dSmrg	    revision="$number_minor"
7346428d7b3dSmrg	    age="0"
7347428d7b3dSmrg	    ;;
7348428d7b3dSmrg	  irix|nonstopux)
7349428d7b3dSmrg	    func_arith $number_major + $number_minor
7350428d7b3dSmrg	    current=$func_arith_result
7351428d7b3dSmrg	    age="$number_minor"
7352428d7b3dSmrg	    revision="$number_minor"
7353428d7b3dSmrg	    lt_irix_increment=no
7354428d7b3dSmrg	    ;;
7355428d7b3dSmrg	  *)
7356428d7b3dSmrg	    func_fatal_configuration "$modename: unknown library version type \`$version_type'"
7357428d7b3dSmrg	    ;;
7358428d7b3dSmrg	  esac
7359428d7b3dSmrg	  ;;
7360428d7b3dSmrg	no)
7361428d7b3dSmrg	  current="$1"
7362428d7b3dSmrg	  revision="$2"
7363428d7b3dSmrg	  age="$3"
7364428d7b3dSmrg	  ;;
7365428d7b3dSmrg	esac
7366428d7b3dSmrg
7367428d7b3dSmrg	# Check that each of the things are valid numbers.
7368428d7b3dSmrg	case $current in
7369428d7b3dSmrg	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]) ;;
7370428d7b3dSmrg	*)
7371428d7b3dSmrg	  func_error "CURRENT \`$current' must be a nonnegative integer"
7372428d7b3dSmrg	  func_fatal_error "\`$vinfo' is not valid version information"
7373428d7b3dSmrg	  ;;
7374428d7b3dSmrg	esac
7375428d7b3dSmrg
7376428d7b3dSmrg	case $revision in
7377428d7b3dSmrg	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]) ;;
7378428d7b3dSmrg	*)
7379428d7b3dSmrg	  func_error "REVISION \`$revision' must be a nonnegative integer"
7380428d7b3dSmrg	  func_fatal_error "\`$vinfo' is not valid version information"
7381428d7b3dSmrg	  ;;
7382428d7b3dSmrg	esac
7383428d7b3dSmrg
7384428d7b3dSmrg	case $age in
7385428d7b3dSmrg	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]) ;;
7386428d7b3dSmrg	*)
7387428d7b3dSmrg	  func_error "AGE \`$age' must be a nonnegative integer"
7388428d7b3dSmrg	  func_fatal_error "\`$vinfo' is not valid version information"
7389428d7b3dSmrg	  ;;
7390428d7b3dSmrg	esac
7391428d7b3dSmrg
7392428d7b3dSmrg	if test "$age" -gt "$current"; then
7393428d7b3dSmrg	  func_error "AGE \`$age' is greater than the current interface number \`$current'"
7394428d7b3dSmrg	  func_fatal_error "\`$vinfo' is not valid version information"
7395428d7b3dSmrg	fi
7396428d7b3dSmrg
7397428d7b3dSmrg	# Calculate the version variables.
7398428d7b3dSmrg	major=
7399428d7b3dSmrg	versuffix=
7400428d7b3dSmrg	verstring=
7401428d7b3dSmrg	case $version_type in
7402428d7b3dSmrg	none) ;;
7403428d7b3dSmrg
7404428d7b3dSmrg	darwin)
7405428d7b3dSmrg	  # Like Linux, but with the current version available in
7406428d7b3dSmrg	  # verstring for coding it into the library header
7407428d7b3dSmrg	  func_arith $current - $age
7408428d7b3dSmrg	  major=.$func_arith_result
7409428d7b3dSmrg	  versuffix="$major.$age.$revision"
7410428d7b3dSmrg	  # Darwin ld doesn't like 0 for these options...
7411428d7b3dSmrg	  func_arith $current + 1
7412428d7b3dSmrg	  minor_current=$func_arith_result
7413428d7b3dSmrg	  xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
7414428d7b3dSmrg	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
7415428d7b3dSmrg	  ;;
7416428d7b3dSmrg
7417428d7b3dSmrg	freebsd-aout)
7418428d7b3dSmrg	  major=".$current"
7419428d7b3dSmrg	  versuffix=".$current.$revision";
7420428d7b3dSmrg	  ;;
7421428d7b3dSmrg
7422428d7b3dSmrg	freebsd-elf)
7423428d7b3dSmrg	  major=".$current"
7424428d7b3dSmrg	  versuffix=".$current"
7425428d7b3dSmrg	  ;;
7426428d7b3dSmrg
7427428d7b3dSmrg	irix | nonstopux)
7428428d7b3dSmrg	  if test "X$lt_irix_increment" = "Xno"; then
7429428d7b3dSmrg	    func_arith $current - $age
7430428d7b3dSmrg	  else
7431428d7b3dSmrg	    func_arith $current - $age + 1
7432428d7b3dSmrg	  fi
7433428d7b3dSmrg	  major=$func_arith_result
7434428d7b3dSmrg
7435428d7b3dSmrg	  case $version_type in
7436428d7b3dSmrg	    nonstopux) verstring_prefix=nonstopux ;;
7437428d7b3dSmrg	    *)         verstring_prefix=sgi ;;
7438428d7b3dSmrg	  esac
7439428d7b3dSmrg	  verstring="$verstring_prefix$major.$revision"
7440428d7b3dSmrg
7441428d7b3dSmrg	  # Add in all the interfaces that we are compatible with.
7442428d7b3dSmrg	  loop=$revision
7443428d7b3dSmrg	  while test "$loop" -ne 0; do
7444428d7b3dSmrg	    func_arith $revision - $loop
7445428d7b3dSmrg	    iface=$func_arith_result
7446428d7b3dSmrg	    func_arith $loop - 1
7447428d7b3dSmrg	    loop=$func_arith_result
7448428d7b3dSmrg	    verstring="$verstring_prefix$major.$iface:$verstring"
7449428d7b3dSmrg	  done
7450428d7b3dSmrg
7451428d7b3dSmrg	  # Before this point, $major must not contain `.'.
7452428d7b3dSmrg	  major=.$major
7453428d7b3dSmrg	  versuffix="$major.$revision"
7454428d7b3dSmrg	  ;;
7455428d7b3dSmrg
7456428d7b3dSmrg	linux) # correct to gnu/linux during the next big refactor
7457428d7b3dSmrg	  func_arith $current - $age
7458428d7b3dSmrg	  major=.$func_arith_result
7459428d7b3dSmrg	  versuffix="$major.$age.$revision"
7460428d7b3dSmrg	  ;;
7461428d7b3dSmrg
7462428d7b3dSmrg	osf)
7463428d7b3dSmrg	  func_arith $current - $age
7464428d7b3dSmrg	  major=.$func_arith_result
7465428d7b3dSmrg	  versuffix=".$current.$age.$revision"
7466428d7b3dSmrg	  verstring="$current.$age.$revision"
7467428d7b3dSmrg
7468428d7b3dSmrg	  # Add in all the interfaces that we are compatible with.
7469428d7b3dSmrg	  loop=$age
7470428d7b3dSmrg	  while test "$loop" -ne 0; do
7471428d7b3dSmrg	    func_arith $current - $loop
7472428d7b3dSmrg	    iface=$func_arith_result
7473428d7b3dSmrg	    func_arith $loop - 1
7474428d7b3dSmrg	    loop=$func_arith_result
7475428d7b3dSmrg	    verstring="$verstring:${iface}.0"
7476428d7b3dSmrg	  done
7477428d7b3dSmrg
7478428d7b3dSmrg	  # Make executables depend on our current version.
7479428d7b3dSmrg	  func_append verstring ":${current}.0"
7480428d7b3dSmrg	  ;;
7481428d7b3dSmrg
7482428d7b3dSmrg	qnx)
7483428d7b3dSmrg	  major=".$current"
7484428d7b3dSmrg	  versuffix=".$current"
7485428d7b3dSmrg	  ;;
7486428d7b3dSmrg
7487428d7b3dSmrg	sunos)
7488428d7b3dSmrg	  major=".$current"
7489428d7b3dSmrg	  versuffix=".$current.$revision"
7490428d7b3dSmrg	  ;;
7491428d7b3dSmrg
7492428d7b3dSmrg	windows)
7493428d7b3dSmrg	  # Use '-' rather than '.', since we only want one
7494428d7b3dSmrg	  # extension on DOS 8.3 filesystems.
7495428d7b3dSmrg	  func_arith $current - $age
7496428d7b3dSmrg	  major=$func_arith_result
7497428d7b3dSmrg	  versuffix="-$major"
7498428d7b3dSmrg	  ;;
7499428d7b3dSmrg
7500428d7b3dSmrg	*)
7501428d7b3dSmrg	  func_fatal_configuration "unknown library version type \`$version_type'"
7502428d7b3dSmrg	  ;;
7503428d7b3dSmrg	esac
7504428d7b3dSmrg
7505428d7b3dSmrg	# Clear the version info if we defaulted, and they specified a release.
7506428d7b3dSmrg	if test -z "$vinfo" && test -n "$release"; then
7507428d7b3dSmrg	  major=
7508428d7b3dSmrg	  case $version_type in
7509428d7b3dSmrg	  darwin)
7510428d7b3dSmrg	    # we can't check for "0.0" in archive_cmds due to quoting
7511428d7b3dSmrg	    # problems, so we reset it completely
7512428d7b3dSmrg	    verstring=
7513428d7b3dSmrg	    ;;
7514428d7b3dSmrg	  *)
7515428d7b3dSmrg	    verstring="0.0"
7516428d7b3dSmrg	    ;;
7517428d7b3dSmrg	  esac
7518428d7b3dSmrg	  if test "$need_version" = no; then
7519428d7b3dSmrg	    versuffix=
7520428d7b3dSmrg	  else
7521428d7b3dSmrg	    versuffix=".0.0"
7522428d7b3dSmrg	  fi
7523428d7b3dSmrg	fi
7524428d7b3dSmrg
7525428d7b3dSmrg	# Remove version info from name if versioning should be avoided
7526428d7b3dSmrg	if test "$avoid_version" = yes && test "$need_version" = no; then
7527428d7b3dSmrg	  major=
7528428d7b3dSmrg	  versuffix=
7529428d7b3dSmrg	  verstring=""
7530428d7b3dSmrg	fi
7531428d7b3dSmrg
7532428d7b3dSmrg	# Check to see if the archive will have undefined symbols.
7533428d7b3dSmrg	if test "$allow_undefined" = yes; then
7534428d7b3dSmrg	  if test "$allow_undefined_flag" = unsupported; then
7535428d7b3dSmrg	    func_warning "undefined symbols not allowed in $host shared libraries"
7536428d7b3dSmrg	    build_libtool_libs=no
7537428d7b3dSmrg	    build_old_libs=yes
7538428d7b3dSmrg	  fi
7539428d7b3dSmrg	else
7540428d7b3dSmrg	  # Don't allow undefined symbols.
7541428d7b3dSmrg	  allow_undefined_flag="$no_undefined_flag"
7542428d7b3dSmrg	fi
7543428d7b3dSmrg
7544428d7b3dSmrg      fi
7545428d7b3dSmrg
7546428d7b3dSmrg      func_generate_dlsyms "$libname" "$libname" "yes"
7547428d7b3dSmrg      func_append libobjs " $symfileobj"
7548428d7b3dSmrg      test "X$libobjs" = "X " && libobjs=
7549428d7b3dSmrg
7550428d7b3dSmrg      if test "$opt_mode" != relink; then
7551428d7b3dSmrg	# Remove our outputs, but don't remove object files since they
7552428d7b3dSmrg	# may have been created when compiling PIC objects.
7553428d7b3dSmrg	removelist=
7554428d7b3dSmrg	tempremovelist=`$ECHO "$output_objdir/*"`
7555428d7b3dSmrg	for p in $tempremovelist; do
7556428d7b3dSmrg	  case $p in
7557428d7b3dSmrg	    *.$objext | *.gcno)
7558428d7b3dSmrg	       ;;
7559428d7b3dSmrg	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
7560428d7b3dSmrg	       if test "X$precious_files_regex" != "X"; then
7561428d7b3dSmrg		 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
7562428d7b3dSmrg		 then
7563428d7b3dSmrg		   continue
7564428d7b3dSmrg		 fi
7565428d7b3dSmrg	       fi
7566428d7b3dSmrg	       func_append removelist " $p"
7567428d7b3dSmrg	       ;;
7568428d7b3dSmrg	    *) ;;
7569428d7b3dSmrg	  esac
7570428d7b3dSmrg	done
7571428d7b3dSmrg	test -n "$removelist" && \
7572428d7b3dSmrg	  func_show_eval "${RM}r \$removelist"
7573428d7b3dSmrg      fi
7574428d7b3dSmrg
7575428d7b3dSmrg      # Now set the variables for building old libraries.
7576428d7b3dSmrg      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
7577428d7b3dSmrg	func_append oldlibs " $output_objdir/$libname.$libext"
7578428d7b3dSmrg
7579428d7b3dSmrg	# Transform .lo files to .o files.
7580428d7b3dSmrg	oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP`
7581428d7b3dSmrg      fi
7582428d7b3dSmrg
7583428d7b3dSmrg      # Eliminate all temporary directories.
7584428d7b3dSmrg      #for path in $notinst_path; do
7585428d7b3dSmrg      #	lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
7586428d7b3dSmrg      #	deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
7587428d7b3dSmrg      #	dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
7588428d7b3dSmrg      #done
7589428d7b3dSmrg
7590428d7b3dSmrg      if test -n "$xrpath"; then
7591428d7b3dSmrg	# If the user specified any rpath flags, then add them.
7592428d7b3dSmrg	temp_xrpath=
7593428d7b3dSmrg	for libdir in $xrpath; do
7594428d7b3dSmrg	  func_replace_sysroot "$libdir"
7595428d7b3dSmrg	  func_append temp_xrpath " -R$func_replace_sysroot_result"
7596428d7b3dSmrg	  case "$finalize_rpath " in
7597428d7b3dSmrg	  *" $libdir "*) ;;
7598428d7b3dSmrg	  *) func_append finalize_rpath " $libdir" ;;
7599428d7b3dSmrg	  esac
7600428d7b3dSmrg	done
7601428d7b3dSmrg	if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
7602428d7b3dSmrg	  dependency_libs="$temp_xrpath $dependency_libs"
7603428d7b3dSmrg	fi
7604428d7b3dSmrg      fi
7605428d7b3dSmrg
7606428d7b3dSmrg      # Make sure dlfiles contains only unique files that won't be dlpreopened
7607428d7b3dSmrg      old_dlfiles="$dlfiles"
7608428d7b3dSmrg      dlfiles=
7609428d7b3dSmrg      for lib in $old_dlfiles; do
7610428d7b3dSmrg	case " $dlprefiles $dlfiles " in
7611428d7b3dSmrg	*" $lib "*) ;;
7612428d7b3dSmrg	*) func_append dlfiles " $lib" ;;
7613428d7b3dSmrg	esac
7614428d7b3dSmrg      done
7615428d7b3dSmrg
7616428d7b3dSmrg      # Make sure dlprefiles contains only unique files
7617428d7b3dSmrg      old_dlprefiles="$dlprefiles"
7618428d7b3dSmrg      dlprefiles=
7619428d7b3dSmrg      for lib in $old_dlprefiles; do
7620428d7b3dSmrg	case "$dlprefiles " in
7621428d7b3dSmrg	*" $lib "*) ;;
7622428d7b3dSmrg	*) func_append dlprefiles " $lib" ;;
7623428d7b3dSmrg	esac
7624428d7b3dSmrg      done
7625428d7b3dSmrg
7626428d7b3dSmrg      if test "$build_libtool_libs" = yes; then
7627428d7b3dSmrg	if test -n "$rpath"; then
7628428d7b3dSmrg	  case $host in
7629428d7b3dSmrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
7630428d7b3dSmrg	    # these systems don't actually have a c library (as such)!
7631428d7b3dSmrg	    ;;
7632428d7b3dSmrg	  *-*-rhapsody* | *-*-darwin1.[012])
7633428d7b3dSmrg	    # Rhapsody C library is in the System framework
7634428d7b3dSmrg	    func_append deplibs " System.ltframework"
7635428d7b3dSmrg	    ;;
7636428d7b3dSmrg	  *-*-netbsd*)
7637428d7b3dSmrg	    # Don't link with libc until the a.out ld.so is fixed.
7638428d7b3dSmrg	    ;;
7639428d7b3dSmrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
7640428d7b3dSmrg	    # Do not include libc due to us having libc/libc_r.
7641428d7b3dSmrg	    ;;
7642428d7b3dSmrg	  *-*-sco3.2v5* | *-*-sco5v6*)
7643428d7b3dSmrg	    # Causes problems with __ctype
7644428d7b3dSmrg	    ;;
7645428d7b3dSmrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
7646428d7b3dSmrg	    # Compiler inserts libc in the correct place for threads to work
7647428d7b3dSmrg	    ;;
7648428d7b3dSmrg	  *)
7649428d7b3dSmrg	    # Add libc to deplibs on all other systems if necessary.
7650428d7b3dSmrg	    if test "$build_libtool_need_lc" = "yes"; then
7651428d7b3dSmrg	      func_append deplibs " -lc"
7652428d7b3dSmrg	    fi
7653428d7b3dSmrg	    ;;
7654428d7b3dSmrg	  esac
7655428d7b3dSmrg	fi
7656428d7b3dSmrg
7657428d7b3dSmrg	# Transform deplibs into only deplibs that can be linked in shared.
7658428d7b3dSmrg	name_save=$name
7659428d7b3dSmrg	libname_save=$libname
7660428d7b3dSmrg	release_save=$release
7661428d7b3dSmrg	versuffix_save=$versuffix
7662428d7b3dSmrg	major_save=$major
7663428d7b3dSmrg	# I'm not sure if I'm treating the release correctly.  I think
7664428d7b3dSmrg	# release should show up in the -l (ie -lgmp5) so we don't want to
7665428d7b3dSmrg	# add it in twice.  Is that correct?
7666428d7b3dSmrg	release=""
7667428d7b3dSmrg	versuffix=""
7668428d7b3dSmrg	major=""
7669428d7b3dSmrg	newdeplibs=
7670428d7b3dSmrg	droppeddeps=no
7671428d7b3dSmrg	case $deplibs_check_method in
7672428d7b3dSmrg	pass_all)
7673428d7b3dSmrg	  # Don't check for shared/static.  Everything works.
7674428d7b3dSmrg	  # This might be a little naive.  We might want to check
7675428d7b3dSmrg	  # whether the library exists or not.  But this is on
7676428d7b3dSmrg	  # osf3 & osf4 and I'm not really sure... Just
7677428d7b3dSmrg	  # implementing what was already the behavior.
7678428d7b3dSmrg	  newdeplibs=$deplibs
7679428d7b3dSmrg	  ;;
7680428d7b3dSmrg	test_compile)
7681428d7b3dSmrg	  # This code stresses the "libraries are programs" paradigm to its
7682428d7b3dSmrg	  # limits. Maybe even breaks it.  We compile a program, linking it
7683428d7b3dSmrg	  # against the deplibs as a proxy for the library.  Then we can check
7684428d7b3dSmrg	  # whether they linked in statically or dynamically with ldd.
7685428d7b3dSmrg	  $opt_dry_run || $RM conftest.c
7686428d7b3dSmrg	  cat > conftest.c <<EOF
7687428d7b3dSmrg	  int main() { return 0; }
7688428d7b3dSmrgEOF
7689428d7b3dSmrg	  $opt_dry_run || $RM conftest
7690428d7b3dSmrg	  if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
7691428d7b3dSmrg	    ldd_output=`ldd conftest`
7692428d7b3dSmrg	    for i in $deplibs; do
7693428d7b3dSmrg	      case $i in
7694428d7b3dSmrg	      -l*)
7695428d7b3dSmrg		func_stripname -l '' "$i"
7696428d7b3dSmrg		name=$func_stripname_result
7697428d7b3dSmrg		if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7698428d7b3dSmrg		  case " $predeps $postdeps " in
7699428d7b3dSmrg		  *" $i "*)
7700428d7b3dSmrg		    func_append newdeplibs " $i"
7701428d7b3dSmrg		    i=""
7702428d7b3dSmrg		    ;;
7703428d7b3dSmrg		  esac
7704428d7b3dSmrg		fi
7705428d7b3dSmrg		if test -n "$i" ; then
7706428d7b3dSmrg		  libname=`eval "\\$ECHO \"$libname_spec\""`
7707428d7b3dSmrg		  deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
7708428d7b3dSmrg		  set dummy $deplib_matches; shift
7709428d7b3dSmrg		  deplib_match=$1
7710428d7b3dSmrg		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
7711428d7b3dSmrg		    func_append newdeplibs " $i"
7712428d7b3dSmrg		  else
7713428d7b3dSmrg		    droppeddeps=yes
7714428d7b3dSmrg		    echo
7715428d7b3dSmrg		    $ECHO "*** Warning: dynamic linker does not accept needed library $i."
7716428d7b3dSmrg		    echo "*** I have the capability to make that library automatically link in when"
7717428d7b3dSmrg		    echo "*** you link to this library.  But I can only do this if you have a"
7718428d7b3dSmrg		    echo "*** shared version of the library, which I believe you do not have"
7719428d7b3dSmrg		    echo "*** because a test_compile did reveal that the linker did not use it for"
7720428d7b3dSmrg		    echo "*** its dynamic dependency list that programs get resolved with at runtime."
7721428d7b3dSmrg		  fi
7722428d7b3dSmrg		fi
7723428d7b3dSmrg		;;
7724428d7b3dSmrg	      *)
7725428d7b3dSmrg		func_append newdeplibs " $i"
7726428d7b3dSmrg		;;
7727428d7b3dSmrg	      esac
7728428d7b3dSmrg	    done
7729428d7b3dSmrg	  else
7730428d7b3dSmrg	    # Error occurred in the first compile.  Let's try to salvage
7731428d7b3dSmrg	    # the situation: Compile a separate program for each library.
7732428d7b3dSmrg	    for i in $deplibs; do
7733428d7b3dSmrg	      case $i in
7734428d7b3dSmrg	      -l*)
7735428d7b3dSmrg		func_stripname -l '' "$i"
7736428d7b3dSmrg		name=$func_stripname_result
7737428d7b3dSmrg		$opt_dry_run || $RM conftest
7738428d7b3dSmrg		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
7739428d7b3dSmrg		  ldd_output=`ldd conftest`
7740428d7b3dSmrg		  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7741428d7b3dSmrg		    case " $predeps $postdeps " in
7742428d7b3dSmrg		    *" $i "*)
7743428d7b3dSmrg		      func_append newdeplibs " $i"
7744428d7b3dSmrg		      i=""
7745428d7b3dSmrg		      ;;
7746428d7b3dSmrg		    esac
7747428d7b3dSmrg		  fi
7748428d7b3dSmrg		  if test -n "$i" ; then
7749428d7b3dSmrg		    libname=`eval "\\$ECHO \"$libname_spec\""`
7750428d7b3dSmrg		    deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
7751428d7b3dSmrg		    set dummy $deplib_matches; shift
7752428d7b3dSmrg		    deplib_match=$1
7753428d7b3dSmrg		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
7754428d7b3dSmrg		      func_append newdeplibs " $i"
7755428d7b3dSmrg		    else
7756428d7b3dSmrg		      droppeddeps=yes
7757428d7b3dSmrg		      echo
7758428d7b3dSmrg		      $ECHO "*** Warning: dynamic linker does not accept needed library $i."
7759428d7b3dSmrg		      echo "*** I have the capability to make that library automatically link in when"
7760428d7b3dSmrg		      echo "*** you link to this library.  But I can only do this if you have a"
7761428d7b3dSmrg		      echo "*** shared version of the library, which you do not appear to have"
7762428d7b3dSmrg		      echo "*** because a test_compile did reveal that the linker did not use this one"
7763428d7b3dSmrg		      echo "*** as a dynamic dependency that programs can get resolved with at runtime."
7764428d7b3dSmrg		    fi
7765428d7b3dSmrg		  fi
7766428d7b3dSmrg		else
7767428d7b3dSmrg		  droppeddeps=yes
7768428d7b3dSmrg		  echo
7769428d7b3dSmrg		  $ECHO "*** Warning!  Library $i is needed by this library but I was not able to"
7770428d7b3dSmrg		  echo "*** make it link in!  You will probably need to install it or some"
7771428d7b3dSmrg		  echo "*** library that it depends on before this library will be fully"
7772428d7b3dSmrg		  echo "*** functional.  Installing it before continuing would be even better."
7773428d7b3dSmrg		fi
7774428d7b3dSmrg		;;
7775428d7b3dSmrg	      *)
7776428d7b3dSmrg		func_append newdeplibs " $i"
7777428d7b3dSmrg		;;
7778428d7b3dSmrg	      esac
7779428d7b3dSmrg	    done
7780428d7b3dSmrg	  fi
7781428d7b3dSmrg	  ;;
7782428d7b3dSmrg	file_magic*)
7783428d7b3dSmrg	  set dummy $deplibs_check_method; shift
7784428d7b3dSmrg	  file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
7785428d7b3dSmrg	  for a_deplib in $deplibs; do
7786428d7b3dSmrg	    case $a_deplib in
7787428d7b3dSmrg	    -l*)
7788428d7b3dSmrg	      func_stripname -l '' "$a_deplib"
7789428d7b3dSmrg	      name=$func_stripname_result
7790428d7b3dSmrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7791428d7b3dSmrg		case " $predeps $postdeps " in
7792428d7b3dSmrg		*" $a_deplib "*)
7793428d7b3dSmrg		  func_append newdeplibs " $a_deplib"
7794428d7b3dSmrg		  a_deplib=""
7795428d7b3dSmrg		  ;;
7796428d7b3dSmrg		esac
7797428d7b3dSmrg	      fi
7798428d7b3dSmrg	      if test -n "$a_deplib" ; then
7799428d7b3dSmrg		libname=`eval "\\$ECHO \"$libname_spec\""`
7800428d7b3dSmrg		if test -n "$file_magic_glob"; then
7801428d7b3dSmrg		  libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob`
7802428d7b3dSmrg		else
7803428d7b3dSmrg		  libnameglob=$libname
7804428d7b3dSmrg		fi
7805428d7b3dSmrg		test "$want_nocaseglob" = yes && nocaseglob=`shopt -p nocaseglob`
7806428d7b3dSmrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
7807428d7b3dSmrg		  if test "$want_nocaseglob" = yes; then
7808428d7b3dSmrg		    shopt -s nocaseglob
7809428d7b3dSmrg		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
7810428d7b3dSmrg		    $nocaseglob
7811428d7b3dSmrg		  else
7812428d7b3dSmrg		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
7813428d7b3dSmrg		  fi
7814428d7b3dSmrg		  for potent_lib in $potential_libs; do
7815428d7b3dSmrg		      # Follow soft links.
7816428d7b3dSmrg		      if ls -lLd "$potent_lib" 2>/dev/null |
7817428d7b3dSmrg			 $GREP " -> " >/dev/null; then
7818428d7b3dSmrg			continue
7819428d7b3dSmrg		      fi
7820428d7b3dSmrg		      # The statement above tries to avoid entering an
7821428d7b3dSmrg		      # endless loop below, in case of cyclic links.
7822428d7b3dSmrg		      # We might still enter an endless loop, since a link
7823428d7b3dSmrg		      # loop can be closed while we follow links,
7824428d7b3dSmrg		      # but so what?
7825428d7b3dSmrg		      potlib="$potent_lib"
7826428d7b3dSmrg		      while test -h "$potlib" 2>/dev/null; do
7827428d7b3dSmrg			potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
7828428d7b3dSmrg			case $potliblink in
7829428d7b3dSmrg			[\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
7830428d7b3dSmrg			*) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";;
7831428d7b3dSmrg			esac
7832428d7b3dSmrg		      done
7833428d7b3dSmrg		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
7834428d7b3dSmrg			 $SED -e 10q |
7835428d7b3dSmrg			 $EGREP "$file_magic_regex" > /dev/null; then
7836428d7b3dSmrg			func_append newdeplibs " $a_deplib"
7837428d7b3dSmrg			a_deplib=""
7838428d7b3dSmrg			break 2
7839428d7b3dSmrg		      fi
7840428d7b3dSmrg		  done
7841428d7b3dSmrg		done
7842428d7b3dSmrg	      fi
7843428d7b3dSmrg	      if test -n "$a_deplib" ; then
7844428d7b3dSmrg		droppeddeps=yes
7845428d7b3dSmrg		echo
7846428d7b3dSmrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
7847428d7b3dSmrg		echo "*** I have the capability to make that library automatically link in when"
7848428d7b3dSmrg		echo "*** you link to this library.  But I can only do this if you have a"
7849428d7b3dSmrg		echo "*** shared version of the library, which you do not appear to have"
7850428d7b3dSmrg		echo "*** because I did check the linker path looking for a file starting"
7851428d7b3dSmrg		if test -z "$potlib" ; then
7852428d7b3dSmrg		  $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
7853428d7b3dSmrg		else
7854428d7b3dSmrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
7855428d7b3dSmrg		  $ECHO "*** using a file magic. Last file checked: $potlib"
7856428d7b3dSmrg		fi
7857428d7b3dSmrg	      fi
7858428d7b3dSmrg	      ;;
7859428d7b3dSmrg	    *)
7860428d7b3dSmrg	      # Add a -L argument.
7861428d7b3dSmrg	      func_append newdeplibs " $a_deplib"
7862428d7b3dSmrg	      ;;
7863428d7b3dSmrg	    esac
7864428d7b3dSmrg	  done # Gone through all deplibs.
7865428d7b3dSmrg	  ;;
7866428d7b3dSmrg	match_pattern*)
7867428d7b3dSmrg	  set dummy $deplibs_check_method; shift
7868428d7b3dSmrg	  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
7869428d7b3dSmrg	  for a_deplib in $deplibs; do
7870428d7b3dSmrg	    case $a_deplib in
7871428d7b3dSmrg	    -l*)
7872428d7b3dSmrg	      func_stripname -l '' "$a_deplib"
7873428d7b3dSmrg	      name=$func_stripname_result
7874428d7b3dSmrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7875428d7b3dSmrg		case " $predeps $postdeps " in
7876428d7b3dSmrg		*" $a_deplib "*)
7877428d7b3dSmrg		  func_append newdeplibs " $a_deplib"
7878428d7b3dSmrg		  a_deplib=""
7879428d7b3dSmrg		  ;;
7880428d7b3dSmrg		esac
7881428d7b3dSmrg	      fi
7882428d7b3dSmrg	      if test -n "$a_deplib" ; then
7883428d7b3dSmrg		libname=`eval "\\$ECHO \"$libname_spec\""`
7884428d7b3dSmrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
7885428d7b3dSmrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
7886428d7b3dSmrg		  for potent_lib in $potential_libs; do
7887428d7b3dSmrg		    potlib="$potent_lib" # see symlink-check above in file_magic test
7888428d7b3dSmrg		    if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
7889428d7b3dSmrg		       $EGREP "$match_pattern_regex" > /dev/null; then
7890428d7b3dSmrg		      func_append newdeplibs " $a_deplib"
7891428d7b3dSmrg		      a_deplib=""
7892428d7b3dSmrg		      break 2
7893428d7b3dSmrg		    fi
7894428d7b3dSmrg		  done
7895428d7b3dSmrg		done
7896428d7b3dSmrg	      fi
7897428d7b3dSmrg	      if test -n "$a_deplib" ; then
7898428d7b3dSmrg		droppeddeps=yes
7899428d7b3dSmrg		echo
7900428d7b3dSmrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
7901428d7b3dSmrg		echo "*** I have the capability to make that library automatically link in when"
7902428d7b3dSmrg		echo "*** you link to this library.  But I can only do this if you have a"
7903428d7b3dSmrg		echo "*** shared version of the library, which you do not appear to have"
7904428d7b3dSmrg		echo "*** because I did check the linker path looking for a file starting"
7905428d7b3dSmrg		if test -z "$potlib" ; then
7906428d7b3dSmrg		  $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
7907428d7b3dSmrg		else
7908428d7b3dSmrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
7909428d7b3dSmrg		  $ECHO "*** using a regex pattern. Last file checked: $potlib"
7910428d7b3dSmrg		fi
7911428d7b3dSmrg	      fi
7912428d7b3dSmrg	      ;;
7913428d7b3dSmrg	    *)
7914428d7b3dSmrg	      # Add a -L argument.
7915428d7b3dSmrg	      func_append newdeplibs " $a_deplib"
7916428d7b3dSmrg	      ;;
7917428d7b3dSmrg	    esac
7918428d7b3dSmrg	  done # Gone through all deplibs.
7919428d7b3dSmrg	  ;;
7920428d7b3dSmrg	none | unknown | *)
7921428d7b3dSmrg	  newdeplibs=""
7922428d7b3dSmrg	  tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
7923428d7b3dSmrg	  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7924428d7b3dSmrg	    for i in $predeps $postdeps ; do
7925428d7b3dSmrg	      # can't use Xsed below, because $i might contain '/'
7926428d7b3dSmrg	      tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"`
7927428d7b3dSmrg	    done
7928428d7b3dSmrg	  fi
7929428d7b3dSmrg	  case $tmp_deplibs in
7930428d7b3dSmrg	  *[!\	\ ]*)
7931428d7b3dSmrg	    echo
7932428d7b3dSmrg	    if test "X$deplibs_check_method" = "Xnone"; then
7933428d7b3dSmrg	      echo "*** Warning: inter-library dependencies are not supported in this platform."
7934428d7b3dSmrg	    else
7935428d7b3dSmrg	      echo "*** Warning: inter-library dependencies are not known to be supported."
7936428d7b3dSmrg	    fi
7937428d7b3dSmrg	    echo "*** All declared inter-library dependencies are being dropped."
7938428d7b3dSmrg	    droppeddeps=yes
7939428d7b3dSmrg	    ;;
7940428d7b3dSmrg	  esac
7941428d7b3dSmrg	  ;;
7942428d7b3dSmrg	esac
7943428d7b3dSmrg	versuffix=$versuffix_save
7944428d7b3dSmrg	major=$major_save
7945428d7b3dSmrg	release=$release_save
7946428d7b3dSmrg	libname=$libname_save
7947428d7b3dSmrg	name=$name_save
7948428d7b3dSmrg
7949428d7b3dSmrg	case $host in
7950428d7b3dSmrg	*-*-rhapsody* | *-*-darwin1.[012])
7951428d7b3dSmrg	  # On Rhapsody replace the C library with the System framework
7952428d7b3dSmrg	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
7953428d7b3dSmrg	  ;;
7954428d7b3dSmrg	esac
7955428d7b3dSmrg
7956428d7b3dSmrg	if test "$droppeddeps" = yes; then
7957428d7b3dSmrg	  if test "$module" = yes; then
7958428d7b3dSmrg	    echo
7959428d7b3dSmrg	    echo "*** Warning: libtool could not satisfy all declared inter-library"
7960428d7b3dSmrg	    $ECHO "*** dependencies of module $libname.  Therefore, libtool will create"
7961428d7b3dSmrg	    echo "*** a static module, that should work as long as the dlopening"
7962428d7b3dSmrg	    echo "*** application is linked with the -dlopen flag."
7963428d7b3dSmrg	    if test -z "$global_symbol_pipe"; then
7964428d7b3dSmrg	      echo
7965428d7b3dSmrg	      echo "*** However, this would only work if libtool was able to extract symbol"
7966428d7b3dSmrg	      echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
7967428d7b3dSmrg	      echo "*** not find such a program.  So, this module is probably useless."
7968428d7b3dSmrg	      echo "*** \`nm' from GNU binutils and a full rebuild may help."
7969428d7b3dSmrg	    fi
7970428d7b3dSmrg	    if test "$build_old_libs" = no; then
7971428d7b3dSmrg	      oldlibs="$output_objdir/$libname.$libext"
7972428d7b3dSmrg	      build_libtool_libs=module
7973428d7b3dSmrg	      build_old_libs=yes
7974428d7b3dSmrg	    else
7975428d7b3dSmrg	      build_libtool_libs=no
7976428d7b3dSmrg	    fi
7977428d7b3dSmrg	  else
7978428d7b3dSmrg	    echo "*** The inter-library dependencies that have been dropped here will be"
7979428d7b3dSmrg	    echo "*** automatically added whenever a program is linked with this library"
7980428d7b3dSmrg	    echo "*** or is declared to -dlopen it."
7981428d7b3dSmrg
7982428d7b3dSmrg	    if test "$allow_undefined" = no; then
7983428d7b3dSmrg	      echo
7984428d7b3dSmrg	      echo "*** Since this library must not contain undefined symbols,"
7985428d7b3dSmrg	      echo "*** because either the platform does not support them or"
7986428d7b3dSmrg	      echo "*** it was explicitly requested with -no-undefined,"
7987428d7b3dSmrg	      echo "*** libtool will only create a static version of it."
7988428d7b3dSmrg	      if test "$build_old_libs" = no; then
7989428d7b3dSmrg		oldlibs="$output_objdir/$libname.$libext"
7990428d7b3dSmrg		build_libtool_libs=module
7991428d7b3dSmrg		build_old_libs=yes
7992428d7b3dSmrg	      else
7993428d7b3dSmrg		build_libtool_libs=no
7994428d7b3dSmrg	      fi
7995428d7b3dSmrg	    fi
7996428d7b3dSmrg	  fi
7997428d7b3dSmrg	fi
7998428d7b3dSmrg	# Done checking deplibs!
7999428d7b3dSmrg	deplibs=$newdeplibs
8000428d7b3dSmrg      fi
8001428d7b3dSmrg      # Time to change all our "foo.ltframework" stuff back to "-framework foo"
8002428d7b3dSmrg      case $host in
8003428d7b3dSmrg	*-*-darwin*)
8004428d7b3dSmrg	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8005428d7b3dSmrg	  new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8006428d7b3dSmrg	  deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8007428d7b3dSmrg	  ;;
8008428d7b3dSmrg      esac
8009428d7b3dSmrg
8010428d7b3dSmrg      # move library search paths that coincide with paths to not yet
8011428d7b3dSmrg      # installed libraries to the beginning of the library search list
8012428d7b3dSmrg      new_libs=
8013428d7b3dSmrg      for path in $notinst_path; do
8014428d7b3dSmrg	case " $new_libs " in
8015428d7b3dSmrg	*" -L$path/$objdir "*) ;;
8016428d7b3dSmrg	*)
8017428d7b3dSmrg	  case " $deplibs " in
8018428d7b3dSmrg	  *" -L$path/$objdir "*)
8019428d7b3dSmrg	    func_append new_libs " -L$path/$objdir" ;;
8020428d7b3dSmrg	  esac
8021428d7b3dSmrg	  ;;
8022428d7b3dSmrg	esac
8023428d7b3dSmrg      done
8024428d7b3dSmrg      for deplib in $deplibs; do
8025428d7b3dSmrg	case $deplib in
8026428d7b3dSmrg	-L*)
8027428d7b3dSmrg	  case " $new_libs " in
8028428d7b3dSmrg	  *" $deplib "*) ;;
8029428d7b3dSmrg	  *) func_append new_libs " $deplib" ;;
8030428d7b3dSmrg	  esac
8031428d7b3dSmrg	  ;;
8032428d7b3dSmrg	*) func_append new_libs " $deplib" ;;
8033428d7b3dSmrg	esac
8034428d7b3dSmrg      done
8035428d7b3dSmrg      deplibs="$new_libs"
8036428d7b3dSmrg
8037428d7b3dSmrg      # All the library-specific variables (install_libdir is set above).
8038428d7b3dSmrg      library_names=
8039428d7b3dSmrg      old_library=
8040428d7b3dSmrg      dlname=
8041428d7b3dSmrg
8042428d7b3dSmrg      # Test again, we may have decided not to build it any more
8043428d7b3dSmrg      if test "$build_libtool_libs" = yes; then
8044428d7b3dSmrg	# Remove ${wl} instances when linking with ld.
8045428d7b3dSmrg	# FIXME: should test the right _cmds variable.
8046428d7b3dSmrg	case $archive_cmds in
8047428d7b3dSmrg	  *\$LD\ *) wl= ;;
8048428d7b3dSmrg        esac
8049428d7b3dSmrg	if test "$hardcode_into_libs" = yes; then
8050428d7b3dSmrg	  # Hardcode the library paths
8051428d7b3dSmrg	  hardcode_libdirs=
8052428d7b3dSmrg	  dep_rpath=
8053428d7b3dSmrg	  rpath="$finalize_rpath"
8054428d7b3dSmrg	  test "$opt_mode" != relink && rpath="$compile_rpath$rpath"
8055428d7b3dSmrg	  for libdir in $rpath; do
8056428d7b3dSmrg	    if test -n "$hardcode_libdir_flag_spec"; then
8057428d7b3dSmrg	      if test -n "$hardcode_libdir_separator"; then
8058428d7b3dSmrg		func_replace_sysroot "$libdir"
8059428d7b3dSmrg		libdir=$func_replace_sysroot_result
8060428d7b3dSmrg		if test -z "$hardcode_libdirs"; then
8061428d7b3dSmrg		  hardcode_libdirs="$libdir"
8062428d7b3dSmrg		else
8063428d7b3dSmrg		  # Just accumulate the unique libdirs.
8064428d7b3dSmrg		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
8065428d7b3dSmrg		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
8066428d7b3dSmrg		    ;;
8067428d7b3dSmrg		  *)
8068428d7b3dSmrg		    func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
8069428d7b3dSmrg		    ;;
8070428d7b3dSmrg		  esac
8071428d7b3dSmrg		fi
8072428d7b3dSmrg	      else
8073428d7b3dSmrg		eval flag=\"$hardcode_libdir_flag_spec\"
8074428d7b3dSmrg		func_append dep_rpath " $flag"
8075428d7b3dSmrg	      fi
8076428d7b3dSmrg	    elif test -n "$runpath_var"; then
8077428d7b3dSmrg	      case "$perm_rpath " in
8078428d7b3dSmrg	      *" $libdir "*) ;;
8079428d7b3dSmrg	      *) func_append perm_rpath " $libdir" ;;
8080428d7b3dSmrg	      esac
8081428d7b3dSmrg	    fi
8082428d7b3dSmrg	  done
8083428d7b3dSmrg	  # Substitute the hardcoded libdirs into the rpath.
8084428d7b3dSmrg	  if test -n "$hardcode_libdir_separator" &&
8085428d7b3dSmrg	     test -n "$hardcode_libdirs"; then
8086428d7b3dSmrg	    libdir="$hardcode_libdirs"
8087428d7b3dSmrg	    eval "dep_rpath=\"$hardcode_libdir_flag_spec\""
8088428d7b3dSmrg	  fi
8089428d7b3dSmrg	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
8090428d7b3dSmrg	    # We should set the runpath_var.
8091428d7b3dSmrg	    rpath=
8092428d7b3dSmrg	    for dir in $perm_rpath; do
8093428d7b3dSmrg	      func_append rpath "$dir:"
8094428d7b3dSmrg	    done
8095428d7b3dSmrg	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
8096428d7b3dSmrg	  fi
8097428d7b3dSmrg	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
8098428d7b3dSmrg	fi
8099428d7b3dSmrg
8100428d7b3dSmrg	shlibpath="$finalize_shlibpath"
8101428d7b3dSmrg	test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
8102428d7b3dSmrg	if test -n "$shlibpath"; then
8103428d7b3dSmrg	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
8104428d7b3dSmrg	fi
8105428d7b3dSmrg
8106428d7b3dSmrg	# Get the real and link names of the library.
8107428d7b3dSmrg	eval shared_ext=\"$shrext_cmds\"
8108428d7b3dSmrg	eval library_names=\"$library_names_spec\"
8109428d7b3dSmrg	set dummy $library_names
8110428d7b3dSmrg	shift
8111428d7b3dSmrg	realname="$1"
8112428d7b3dSmrg	shift
8113428d7b3dSmrg
8114428d7b3dSmrg	if test -n "$soname_spec"; then
8115428d7b3dSmrg	  eval soname=\"$soname_spec\"
8116428d7b3dSmrg	else
8117428d7b3dSmrg	  soname="$realname"
8118428d7b3dSmrg	fi
8119428d7b3dSmrg	if test -z "$dlname"; then
8120428d7b3dSmrg	  dlname=$soname
8121428d7b3dSmrg	fi
8122428d7b3dSmrg
8123428d7b3dSmrg	lib="$output_objdir/$realname"
8124428d7b3dSmrg	linknames=
8125428d7b3dSmrg	for link
8126428d7b3dSmrg	do
8127428d7b3dSmrg	  func_append linknames " $link"
8128428d7b3dSmrg	done
8129428d7b3dSmrg
8130428d7b3dSmrg	# Use standard objects if they are pic
8131428d7b3dSmrg	test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
8132428d7b3dSmrg	test "X$libobjs" = "X " && libobjs=
8133428d7b3dSmrg
8134428d7b3dSmrg	delfiles=
8135428d7b3dSmrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
8136428d7b3dSmrg	  $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
8137428d7b3dSmrg	  export_symbols="$output_objdir/$libname.uexp"
8138428d7b3dSmrg	  func_append delfiles " $export_symbols"
8139428d7b3dSmrg	fi
8140428d7b3dSmrg
8141428d7b3dSmrg	orig_export_symbols=
8142428d7b3dSmrg	case $host_os in
8143428d7b3dSmrg	cygwin* | mingw* | cegcc*)
8144428d7b3dSmrg	  if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
8145428d7b3dSmrg	    # exporting using user supplied symfile
8146428d7b3dSmrg	    if test "x`$SED 1q $export_symbols`" != xEXPORTS; then
8147428d7b3dSmrg	      # and it's NOT already a .def file. Must figure out
8148428d7b3dSmrg	      # which of the given symbols are data symbols and tag
8149428d7b3dSmrg	      # them as such. So, trigger use of export_symbols_cmds.
8150428d7b3dSmrg	      # export_symbols gets reassigned inside the "prepare
8151428d7b3dSmrg	      # the list of exported symbols" if statement, so the
8152428d7b3dSmrg	      # include_expsyms logic still works.
8153428d7b3dSmrg	      orig_export_symbols="$export_symbols"
8154428d7b3dSmrg	      export_symbols=
8155428d7b3dSmrg	      always_export_symbols=yes
8156428d7b3dSmrg	    fi
8157428d7b3dSmrg	  fi
8158428d7b3dSmrg	  ;;
8159428d7b3dSmrg	esac
8160428d7b3dSmrg
8161428d7b3dSmrg	# Prepare the list of exported symbols
8162428d7b3dSmrg	if test -z "$export_symbols"; then
8163428d7b3dSmrg	  if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
8164428d7b3dSmrg	    func_verbose "generating symbol list for \`$libname.la'"
8165428d7b3dSmrg	    export_symbols="$output_objdir/$libname.exp"
8166428d7b3dSmrg	    $opt_dry_run || $RM $export_symbols
8167428d7b3dSmrg	    cmds=$export_symbols_cmds
8168428d7b3dSmrg	    save_ifs="$IFS"; IFS='~'
8169428d7b3dSmrg	    for cmd1 in $cmds; do
8170428d7b3dSmrg	      IFS="$save_ifs"
8171428d7b3dSmrg	      # Take the normal branch if the nm_file_list_spec branch
8172428d7b3dSmrg	      # doesn't work or if tool conversion is not needed.
8173428d7b3dSmrg	      case $nm_file_list_spec~$to_tool_file_cmd in
8174428d7b3dSmrg		*~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*)
8175428d7b3dSmrg		  try_normal_branch=yes
8176428d7b3dSmrg		  eval cmd=\"$cmd1\"
8177428d7b3dSmrg		  func_len " $cmd"
8178428d7b3dSmrg		  len=$func_len_result
8179428d7b3dSmrg		  ;;
8180428d7b3dSmrg		*)
8181428d7b3dSmrg		  try_normal_branch=no
8182428d7b3dSmrg		  ;;
8183428d7b3dSmrg	      esac
8184428d7b3dSmrg	      if test "$try_normal_branch" = yes \
8185428d7b3dSmrg		 && { test "$len" -lt "$max_cmd_len" \
8186428d7b3dSmrg		      || test "$max_cmd_len" -le -1; }
8187428d7b3dSmrg	      then
8188428d7b3dSmrg		func_show_eval "$cmd" 'exit $?'
8189428d7b3dSmrg		skipped_export=false
8190428d7b3dSmrg	      elif test -n "$nm_file_list_spec"; then
8191428d7b3dSmrg		func_basename "$output"
8192428d7b3dSmrg		output_la=$func_basename_result
8193428d7b3dSmrg		save_libobjs=$libobjs
8194428d7b3dSmrg		save_output=$output
8195428d7b3dSmrg		output=${output_objdir}/${output_la}.nm
8196428d7b3dSmrg		func_to_tool_file "$output"
8197428d7b3dSmrg		libobjs=$nm_file_list_spec$func_to_tool_file_result
8198428d7b3dSmrg		func_append delfiles " $output"
8199428d7b3dSmrg		func_verbose "creating $NM input file list: $output"
8200428d7b3dSmrg		for obj in $save_libobjs; do
8201428d7b3dSmrg		  func_to_tool_file "$obj"
8202428d7b3dSmrg		  $ECHO "$func_to_tool_file_result"
8203428d7b3dSmrg		done > "$output"
8204428d7b3dSmrg		eval cmd=\"$cmd1\"
8205428d7b3dSmrg		func_show_eval "$cmd" 'exit $?'
8206428d7b3dSmrg		output=$save_output
8207428d7b3dSmrg		libobjs=$save_libobjs
8208428d7b3dSmrg		skipped_export=false
8209428d7b3dSmrg	      else
8210428d7b3dSmrg		# The command line is too long to execute in one step.
8211428d7b3dSmrg		func_verbose "using reloadable object file for export list..."
8212428d7b3dSmrg		skipped_export=:
8213428d7b3dSmrg		# Break out early, otherwise skipped_export may be
8214428d7b3dSmrg		# set to false by a later but shorter cmd.
8215428d7b3dSmrg		break
8216428d7b3dSmrg	      fi
8217428d7b3dSmrg	    done
8218428d7b3dSmrg	    IFS="$save_ifs"
8219428d7b3dSmrg	    if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then
8220428d7b3dSmrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
8221428d7b3dSmrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
8222428d7b3dSmrg	    fi
8223428d7b3dSmrg	  fi
8224428d7b3dSmrg	fi
8225428d7b3dSmrg
8226428d7b3dSmrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
8227428d7b3dSmrg	  tmp_export_symbols="$export_symbols"
8228428d7b3dSmrg	  test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
8229428d7b3dSmrg	  $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
8230428d7b3dSmrg	fi
8231428d7b3dSmrg
8232428d7b3dSmrg	if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then
8233428d7b3dSmrg	  # The given exports_symbols file has to be filtered, so filter it.
8234428d7b3dSmrg	  func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
8235428d7b3dSmrg	  # FIXME: $output_objdir/$libname.filter potentially contains lots of
8236428d7b3dSmrg	  # 's' commands which not all seds can handle. GNU sed should be fine
8237428d7b3dSmrg	  # though. Also, the filter scales superlinearly with the number of
8238428d7b3dSmrg	  # global variables. join(1) would be nice here, but unfortunately
8239428d7b3dSmrg	  # isn't a blessed tool.
8240428d7b3dSmrg	  $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
8241428d7b3dSmrg	  func_append delfiles " $export_symbols $output_objdir/$libname.filter"
8242428d7b3dSmrg	  export_symbols=$output_objdir/$libname.def
8243428d7b3dSmrg	  $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
8244428d7b3dSmrg	fi
8245428d7b3dSmrg
8246428d7b3dSmrg	tmp_deplibs=
8247428d7b3dSmrg	for test_deplib in $deplibs; do
8248428d7b3dSmrg	  case " $convenience " in
8249428d7b3dSmrg	  *" $test_deplib "*) ;;
8250428d7b3dSmrg	  *)
8251428d7b3dSmrg	    func_append tmp_deplibs " $test_deplib"
8252428d7b3dSmrg	    ;;
8253428d7b3dSmrg	  esac
8254428d7b3dSmrg	done
8255428d7b3dSmrg	deplibs="$tmp_deplibs"
8256428d7b3dSmrg
8257428d7b3dSmrg	if test -n "$convenience"; then
8258428d7b3dSmrg	  if test -n "$whole_archive_flag_spec" &&
8259428d7b3dSmrg	    test "$compiler_needs_object" = yes &&
8260428d7b3dSmrg	    test -z "$libobjs"; then
8261428d7b3dSmrg	    # extract the archives, so we have objects to list.
8262428d7b3dSmrg	    # TODO: could optimize this to just extract one archive.
8263428d7b3dSmrg	    whole_archive_flag_spec=
8264428d7b3dSmrg	  fi
8265428d7b3dSmrg	  if test -n "$whole_archive_flag_spec"; then
8266428d7b3dSmrg	    save_libobjs=$libobjs
8267428d7b3dSmrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
8268428d7b3dSmrg	    test "X$libobjs" = "X " && libobjs=
8269428d7b3dSmrg	  else
8270428d7b3dSmrg	    gentop="$output_objdir/${outputname}x"
8271428d7b3dSmrg	    func_append generated " $gentop"
8272428d7b3dSmrg
8273428d7b3dSmrg	    func_extract_archives $gentop $convenience
8274428d7b3dSmrg	    func_append libobjs " $func_extract_archives_result"
8275428d7b3dSmrg	    test "X$libobjs" = "X " && libobjs=
8276428d7b3dSmrg	  fi
8277428d7b3dSmrg	fi
8278428d7b3dSmrg
8279428d7b3dSmrg	if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
8280428d7b3dSmrg	  eval flag=\"$thread_safe_flag_spec\"
8281428d7b3dSmrg	  func_append linker_flags " $flag"
8282428d7b3dSmrg	fi
8283428d7b3dSmrg
8284428d7b3dSmrg	# Make a backup of the uninstalled library when relinking
8285428d7b3dSmrg	if test "$opt_mode" = relink; then
8286428d7b3dSmrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
8287428d7b3dSmrg	fi
8288428d7b3dSmrg
8289428d7b3dSmrg	# Do each of the archive commands.
8290428d7b3dSmrg	if test "$module" = yes && test -n "$module_cmds" ; then
8291428d7b3dSmrg	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
8292428d7b3dSmrg	    eval test_cmds=\"$module_expsym_cmds\"
8293428d7b3dSmrg	    cmds=$module_expsym_cmds
8294428d7b3dSmrg	  else
8295428d7b3dSmrg	    eval test_cmds=\"$module_cmds\"
8296428d7b3dSmrg	    cmds=$module_cmds
8297428d7b3dSmrg	  fi
8298428d7b3dSmrg	else
8299428d7b3dSmrg	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
8300428d7b3dSmrg	    eval test_cmds=\"$archive_expsym_cmds\"
8301428d7b3dSmrg	    cmds=$archive_expsym_cmds
8302428d7b3dSmrg	  else
8303428d7b3dSmrg	    eval test_cmds=\"$archive_cmds\"
8304428d7b3dSmrg	    cmds=$archive_cmds
8305428d7b3dSmrg	  fi
8306428d7b3dSmrg	fi
8307428d7b3dSmrg
8308428d7b3dSmrg	if test "X$skipped_export" != "X:" &&
8309428d7b3dSmrg	   func_len " $test_cmds" &&
8310428d7b3dSmrg	   len=$func_len_result &&
8311428d7b3dSmrg	   test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
8312428d7b3dSmrg	  :
8313428d7b3dSmrg	else
8314428d7b3dSmrg	  # The command line is too long to link in one step, link piecewise
8315428d7b3dSmrg	  # or, if using GNU ld and skipped_export is not :, use a linker
8316428d7b3dSmrg	  # script.
8317428d7b3dSmrg
8318428d7b3dSmrg	  # Save the value of $output and $libobjs because we want to
8319428d7b3dSmrg	  # use them later.  If we have whole_archive_flag_spec, we
8320428d7b3dSmrg	  # want to use save_libobjs as it was before
8321428d7b3dSmrg	  # whole_archive_flag_spec was expanded, because we can't
8322428d7b3dSmrg	  # assume the linker understands whole_archive_flag_spec.
8323428d7b3dSmrg	  # This may have to be revisited, in case too many
8324428d7b3dSmrg	  # convenience libraries get linked in and end up exceeding
8325428d7b3dSmrg	  # the spec.
8326428d7b3dSmrg	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
8327428d7b3dSmrg	    save_libobjs=$libobjs
8328428d7b3dSmrg	  fi
8329428d7b3dSmrg	  save_output=$output
8330428d7b3dSmrg	  func_basename "$output"
8331428d7b3dSmrg	  output_la=$func_basename_result
8332428d7b3dSmrg
8333428d7b3dSmrg	  # Clear the reloadable object creation command queue and
8334428d7b3dSmrg	  # initialize k to one.
8335428d7b3dSmrg	  test_cmds=
8336428d7b3dSmrg	  concat_cmds=
8337428d7b3dSmrg	  objlist=
8338428d7b3dSmrg	  last_robj=
8339428d7b3dSmrg	  k=1
8340428d7b3dSmrg
8341428d7b3dSmrg	  if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
8342428d7b3dSmrg	    output=${output_objdir}/${output_la}.lnkscript
8343428d7b3dSmrg	    func_verbose "creating GNU ld script: $output"
8344428d7b3dSmrg	    echo 'INPUT (' > $output
8345428d7b3dSmrg	    for obj in $save_libobjs
8346428d7b3dSmrg	    do
8347428d7b3dSmrg	      func_to_tool_file "$obj"
8348428d7b3dSmrg	      $ECHO "$func_to_tool_file_result" >> $output
8349428d7b3dSmrg	    done
8350428d7b3dSmrg	    echo ')' >> $output
8351428d7b3dSmrg	    func_append delfiles " $output"
8352428d7b3dSmrg	    func_to_tool_file "$output"
8353428d7b3dSmrg	    output=$func_to_tool_file_result
8354428d7b3dSmrg	  elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then
8355428d7b3dSmrg	    output=${output_objdir}/${output_la}.lnk
8356428d7b3dSmrg	    func_verbose "creating linker input file list: $output"
8357428d7b3dSmrg	    : > $output
8358428d7b3dSmrg	    set x $save_libobjs
8359428d7b3dSmrg	    shift
8360428d7b3dSmrg	    firstobj=
8361428d7b3dSmrg	    if test "$compiler_needs_object" = yes; then
8362428d7b3dSmrg	      firstobj="$1 "
8363428d7b3dSmrg	      shift
8364428d7b3dSmrg	    fi
8365428d7b3dSmrg	    for obj
8366428d7b3dSmrg	    do
8367428d7b3dSmrg	      func_to_tool_file "$obj"
8368428d7b3dSmrg	      $ECHO "$func_to_tool_file_result" >> $output
8369428d7b3dSmrg	    done
8370428d7b3dSmrg	    func_append delfiles " $output"
8371428d7b3dSmrg	    func_to_tool_file "$output"
8372428d7b3dSmrg	    output=$firstobj\"$file_list_spec$func_to_tool_file_result\"
8373428d7b3dSmrg	  else
8374428d7b3dSmrg	    if test -n "$save_libobjs"; then
8375428d7b3dSmrg	      func_verbose "creating reloadable object files..."
8376428d7b3dSmrg	      output=$output_objdir/$output_la-${k}.$objext
8377428d7b3dSmrg	      eval test_cmds=\"$reload_cmds\"
8378428d7b3dSmrg	      func_len " $test_cmds"
8379428d7b3dSmrg	      len0=$func_len_result
8380428d7b3dSmrg	      len=$len0
8381428d7b3dSmrg
8382428d7b3dSmrg	      # Loop over the list of objects to be linked.
8383428d7b3dSmrg	      for obj in $save_libobjs
8384428d7b3dSmrg	      do
8385428d7b3dSmrg		func_len " $obj"
8386428d7b3dSmrg		func_arith $len + $func_len_result
8387428d7b3dSmrg		len=$func_arith_result
8388428d7b3dSmrg		if test "X$objlist" = X ||
8389428d7b3dSmrg		   test "$len" -lt "$max_cmd_len"; then
8390428d7b3dSmrg		  func_append objlist " $obj"
8391428d7b3dSmrg		else
8392428d7b3dSmrg		  # The command $test_cmds is almost too long, add a
8393428d7b3dSmrg		  # command to the queue.
8394428d7b3dSmrg		  if test "$k" -eq 1 ; then
8395428d7b3dSmrg		    # The first file doesn't have a previous command to add.
8396428d7b3dSmrg		    reload_objs=$objlist
8397428d7b3dSmrg		    eval concat_cmds=\"$reload_cmds\"
8398428d7b3dSmrg		  else
8399428d7b3dSmrg		    # All subsequent reloadable object files will link in
8400428d7b3dSmrg		    # the last one created.
8401428d7b3dSmrg		    reload_objs="$objlist $last_robj"
8402428d7b3dSmrg		    eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
8403428d7b3dSmrg		  fi
8404428d7b3dSmrg		  last_robj=$output_objdir/$output_la-${k}.$objext
8405428d7b3dSmrg		  func_arith $k + 1
8406428d7b3dSmrg		  k=$func_arith_result
8407428d7b3dSmrg		  output=$output_objdir/$output_la-${k}.$objext
8408428d7b3dSmrg		  objlist=" $obj"
8409428d7b3dSmrg		  func_len " $last_robj"
8410428d7b3dSmrg		  func_arith $len0 + $func_len_result
8411428d7b3dSmrg		  len=$func_arith_result
8412428d7b3dSmrg		fi
8413428d7b3dSmrg	      done
8414428d7b3dSmrg	      # Handle the remaining objects by creating one last
8415428d7b3dSmrg	      # reloadable object file.  All subsequent reloadable object
8416428d7b3dSmrg	      # files will link in the last one created.
8417428d7b3dSmrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
8418428d7b3dSmrg	      reload_objs="$objlist $last_robj"
8419428d7b3dSmrg	      eval concat_cmds=\"\${concat_cmds}$reload_cmds\"
8420428d7b3dSmrg	      if test -n "$last_robj"; then
8421428d7b3dSmrg	        eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\"
8422428d7b3dSmrg	      fi
8423428d7b3dSmrg	      func_append delfiles " $output"
8424428d7b3dSmrg
8425428d7b3dSmrg	    else
8426428d7b3dSmrg	      output=
8427428d7b3dSmrg	    fi
8428428d7b3dSmrg
8429428d7b3dSmrg	    if ${skipped_export-false}; then
8430428d7b3dSmrg	      func_verbose "generating symbol list for \`$libname.la'"
8431428d7b3dSmrg	      export_symbols="$output_objdir/$libname.exp"
8432428d7b3dSmrg	      $opt_dry_run || $RM $export_symbols
8433428d7b3dSmrg	      libobjs=$output
8434428d7b3dSmrg	      # Append the command to create the export file.
8435428d7b3dSmrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
8436428d7b3dSmrg	      eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
8437428d7b3dSmrg	      if test -n "$last_robj"; then
8438428d7b3dSmrg		eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
8439428d7b3dSmrg	      fi
8440428d7b3dSmrg	    fi
8441428d7b3dSmrg
8442428d7b3dSmrg	    test -n "$save_libobjs" &&
8443428d7b3dSmrg	      func_verbose "creating a temporary reloadable object file: $output"
8444428d7b3dSmrg
8445428d7b3dSmrg	    # Loop through the commands generated above and execute them.
8446428d7b3dSmrg	    save_ifs="$IFS"; IFS='~'
8447428d7b3dSmrg	    for cmd in $concat_cmds; do
8448428d7b3dSmrg	      IFS="$save_ifs"
8449428d7b3dSmrg	      $opt_silent || {
8450428d7b3dSmrg		  func_quote_for_expand "$cmd"
8451428d7b3dSmrg		  eval "func_echo $func_quote_for_expand_result"
8452428d7b3dSmrg	      }
8453428d7b3dSmrg	      $opt_dry_run || eval "$cmd" || {
8454428d7b3dSmrg		lt_exit=$?
8455428d7b3dSmrg
8456428d7b3dSmrg		# Restore the uninstalled library and exit
8457428d7b3dSmrg		if test "$opt_mode" = relink; then
8458428d7b3dSmrg		  ( cd "$output_objdir" && \
8459428d7b3dSmrg		    $RM "${realname}T" && \
8460428d7b3dSmrg		    $MV "${realname}U" "$realname" )
8461428d7b3dSmrg		fi
8462428d7b3dSmrg
8463428d7b3dSmrg		exit $lt_exit
8464428d7b3dSmrg	      }
8465428d7b3dSmrg	    done
8466428d7b3dSmrg	    IFS="$save_ifs"
8467428d7b3dSmrg
8468428d7b3dSmrg	    if test -n "$export_symbols_regex" && ${skipped_export-false}; then
8469428d7b3dSmrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
8470428d7b3dSmrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
8471428d7b3dSmrg	    fi
8472428d7b3dSmrg	  fi
8473428d7b3dSmrg
8474428d7b3dSmrg          if ${skipped_export-false}; then
8475428d7b3dSmrg	    if test -n "$export_symbols" && test -n "$include_expsyms"; then
8476428d7b3dSmrg	      tmp_export_symbols="$export_symbols"
8477428d7b3dSmrg	      test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
8478428d7b3dSmrg	      $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
8479428d7b3dSmrg	    fi
8480428d7b3dSmrg
8481428d7b3dSmrg	    if test -n "$orig_export_symbols"; then
8482428d7b3dSmrg	      # The given exports_symbols file has to be filtered, so filter it.
8483428d7b3dSmrg	      func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
8484428d7b3dSmrg	      # FIXME: $output_objdir/$libname.filter potentially contains lots of
8485428d7b3dSmrg	      # 's' commands which not all seds can handle. GNU sed should be fine
8486428d7b3dSmrg	      # though. Also, the filter scales superlinearly with the number of
8487428d7b3dSmrg	      # global variables. join(1) would be nice here, but unfortunately
8488428d7b3dSmrg	      # isn't a blessed tool.
8489428d7b3dSmrg	      $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
8490428d7b3dSmrg	      func_append delfiles " $export_symbols $output_objdir/$libname.filter"
8491428d7b3dSmrg	      export_symbols=$output_objdir/$libname.def
8492428d7b3dSmrg	      $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
8493428d7b3dSmrg	    fi
8494428d7b3dSmrg	  fi
8495428d7b3dSmrg
8496428d7b3dSmrg	  libobjs=$output
8497428d7b3dSmrg	  # Restore the value of output.
8498428d7b3dSmrg	  output=$save_output
8499428d7b3dSmrg
8500428d7b3dSmrg	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
8501428d7b3dSmrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
8502428d7b3dSmrg	    test "X$libobjs" = "X " && libobjs=
8503428d7b3dSmrg	  fi
8504428d7b3dSmrg	  # Expand the library linking commands again to reset the
8505428d7b3dSmrg	  # value of $libobjs for piecewise linking.
8506428d7b3dSmrg
8507428d7b3dSmrg	  # Do each of the archive commands.
8508428d7b3dSmrg	  if test "$module" = yes && test -n "$module_cmds" ; then
8509428d7b3dSmrg	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
8510428d7b3dSmrg	      cmds=$module_expsym_cmds
8511428d7b3dSmrg	    else
8512428d7b3dSmrg	      cmds=$module_cmds
8513428d7b3dSmrg	    fi
8514428d7b3dSmrg	  else
8515428d7b3dSmrg	    if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
8516428d7b3dSmrg	      cmds=$archive_expsym_cmds
8517428d7b3dSmrg	    else
8518428d7b3dSmrg	      cmds=$archive_cmds
8519428d7b3dSmrg	    fi
8520428d7b3dSmrg	  fi
8521428d7b3dSmrg	fi
8522428d7b3dSmrg
8523428d7b3dSmrg	if test -n "$delfiles"; then
8524428d7b3dSmrg	  # Append the command to remove temporary files to $cmds.
8525428d7b3dSmrg	  eval cmds=\"\$cmds~\$RM $delfiles\"
8526428d7b3dSmrg	fi
8527428d7b3dSmrg
8528428d7b3dSmrg	# Add any objects from preloaded convenience libraries
8529428d7b3dSmrg	if test -n "$dlprefiles"; then
8530428d7b3dSmrg	  gentop="$output_objdir/${outputname}x"
8531428d7b3dSmrg	  func_append generated " $gentop"
8532428d7b3dSmrg
8533428d7b3dSmrg	  func_extract_archives $gentop $dlprefiles
8534428d7b3dSmrg	  func_append libobjs " $func_extract_archives_result"
8535428d7b3dSmrg	  test "X$libobjs" = "X " && libobjs=
8536428d7b3dSmrg	fi
8537428d7b3dSmrg
8538428d7b3dSmrg	save_ifs="$IFS"; IFS='~'
8539428d7b3dSmrg	for cmd in $cmds; do
8540428d7b3dSmrg	  IFS="$save_ifs"
8541428d7b3dSmrg	  eval cmd=\"$cmd\"
8542428d7b3dSmrg	  $opt_silent || {
8543428d7b3dSmrg	    func_quote_for_expand "$cmd"
8544428d7b3dSmrg	    eval "func_echo $func_quote_for_expand_result"
8545428d7b3dSmrg	  }
8546428d7b3dSmrg	  $opt_dry_run || eval "$cmd" || {
8547428d7b3dSmrg	    lt_exit=$?
8548428d7b3dSmrg
8549428d7b3dSmrg	    # Restore the uninstalled library and exit
8550428d7b3dSmrg	    if test "$opt_mode" = relink; then
8551428d7b3dSmrg	      ( cd "$output_objdir" && \
8552428d7b3dSmrg	        $RM "${realname}T" && \
8553428d7b3dSmrg		$MV "${realname}U" "$realname" )
8554428d7b3dSmrg	    fi
8555428d7b3dSmrg
8556428d7b3dSmrg	    exit $lt_exit
8557428d7b3dSmrg	  }
8558428d7b3dSmrg	done
8559428d7b3dSmrg	IFS="$save_ifs"
8560428d7b3dSmrg
8561428d7b3dSmrg	# Restore the uninstalled library and exit
8562428d7b3dSmrg	if test "$opt_mode" = relink; then
8563428d7b3dSmrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
8564428d7b3dSmrg
8565428d7b3dSmrg	  if test -n "$convenience"; then
8566428d7b3dSmrg	    if test -z "$whole_archive_flag_spec"; then
8567428d7b3dSmrg	      func_show_eval '${RM}r "$gentop"'
8568428d7b3dSmrg	    fi
8569428d7b3dSmrg	  fi
8570428d7b3dSmrg
8571428d7b3dSmrg	  exit $EXIT_SUCCESS
8572428d7b3dSmrg	fi
8573428d7b3dSmrg
8574428d7b3dSmrg	# Create links to the real library.
8575428d7b3dSmrg	for linkname in $linknames; do
8576428d7b3dSmrg	  if test "$realname" != "$linkname"; then
8577428d7b3dSmrg	    func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
8578428d7b3dSmrg	  fi
8579428d7b3dSmrg	done
8580428d7b3dSmrg
8581428d7b3dSmrg	# If -module or -export-dynamic was specified, set the dlname.
8582428d7b3dSmrg	if test "$module" = yes || test "$export_dynamic" = yes; then
8583428d7b3dSmrg	  # On all known operating systems, these are identical.
8584428d7b3dSmrg	  dlname="$soname"
8585428d7b3dSmrg	fi
8586428d7b3dSmrg      fi
8587428d7b3dSmrg      ;;
8588428d7b3dSmrg
8589428d7b3dSmrg    obj)
8590428d7b3dSmrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
8591428d7b3dSmrg	func_warning "\`-dlopen' is ignored for objects"
8592428d7b3dSmrg      fi
8593428d7b3dSmrg
8594428d7b3dSmrg      case " $deplibs" in
8595428d7b3dSmrg      *\ -l* | *\ -L*)
8596428d7b3dSmrg	func_warning "\`-l' and \`-L' are ignored for objects" ;;
8597428d7b3dSmrg      esac
8598428d7b3dSmrg
8599428d7b3dSmrg      test -n "$rpath" && \
8600428d7b3dSmrg	func_warning "\`-rpath' is ignored for objects"
8601428d7b3dSmrg
8602428d7b3dSmrg      test -n "$xrpath" && \
8603428d7b3dSmrg	func_warning "\`-R' is ignored for objects"
8604428d7b3dSmrg
8605428d7b3dSmrg      test -n "$vinfo" && \
8606428d7b3dSmrg	func_warning "\`-version-info' is ignored for objects"
8607428d7b3dSmrg
8608428d7b3dSmrg      test -n "$release" && \
8609428d7b3dSmrg	func_warning "\`-release' is ignored for objects"
8610428d7b3dSmrg
8611428d7b3dSmrg      case $output in
8612428d7b3dSmrg      *.lo)
8613428d7b3dSmrg	test -n "$objs$old_deplibs" && \
8614428d7b3dSmrg	  func_fatal_error "cannot build library object \`$output' from non-libtool objects"
8615428d7b3dSmrg
8616428d7b3dSmrg	libobj=$output
8617428d7b3dSmrg	func_lo2o "$libobj"
8618428d7b3dSmrg	obj=$func_lo2o_result
8619428d7b3dSmrg	;;
8620428d7b3dSmrg      *)
8621428d7b3dSmrg	libobj=
8622428d7b3dSmrg	obj="$output"
8623428d7b3dSmrg	;;
8624428d7b3dSmrg      esac
8625428d7b3dSmrg
8626428d7b3dSmrg      # Delete the old objects.
8627428d7b3dSmrg      $opt_dry_run || $RM $obj $libobj
8628428d7b3dSmrg
8629428d7b3dSmrg      # Objects from convenience libraries.  This assumes
8630428d7b3dSmrg      # single-version convenience libraries.  Whenever we create
8631428d7b3dSmrg      # different ones for PIC/non-PIC, this we'll have to duplicate
8632428d7b3dSmrg      # the extraction.
8633428d7b3dSmrg      reload_conv_objs=
8634428d7b3dSmrg      gentop=
8635428d7b3dSmrg      # reload_cmds runs $LD directly, so let us get rid of
8636428d7b3dSmrg      # -Wl from whole_archive_flag_spec and hope we can get by with
8637428d7b3dSmrg      # turning comma into space..
8638428d7b3dSmrg      wl=
8639428d7b3dSmrg
8640428d7b3dSmrg      if test -n "$convenience"; then
8641428d7b3dSmrg	if test -n "$whole_archive_flag_spec"; then
8642428d7b3dSmrg	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
8643428d7b3dSmrg	  reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
8644428d7b3dSmrg	else
8645428d7b3dSmrg	  gentop="$output_objdir/${obj}x"
8646428d7b3dSmrg	  func_append generated " $gentop"
8647428d7b3dSmrg
8648428d7b3dSmrg	  func_extract_archives $gentop $convenience
8649428d7b3dSmrg	  reload_conv_objs="$reload_objs $func_extract_archives_result"
8650428d7b3dSmrg	fi
8651428d7b3dSmrg      fi
8652428d7b3dSmrg
8653428d7b3dSmrg      # If we're not building shared, we need to use non_pic_objs
8654428d7b3dSmrg      test "$build_libtool_libs" != yes && libobjs="$non_pic_objects"
8655428d7b3dSmrg
8656428d7b3dSmrg      # Create the old-style object.
8657428d7b3dSmrg      reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
8658428d7b3dSmrg
8659428d7b3dSmrg      output="$obj"
8660428d7b3dSmrg      func_execute_cmds "$reload_cmds" 'exit $?'
8661428d7b3dSmrg
8662428d7b3dSmrg      # Exit if we aren't doing a library object file.
8663428d7b3dSmrg      if test -z "$libobj"; then
8664428d7b3dSmrg	if test -n "$gentop"; then
8665428d7b3dSmrg	  func_show_eval '${RM}r "$gentop"'
8666428d7b3dSmrg	fi
8667428d7b3dSmrg
8668428d7b3dSmrg	exit $EXIT_SUCCESS
8669428d7b3dSmrg      fi
8670428d7b3dSmrg
8671428d7b3dSmrg      if test "$build_libtool_libs" != yes; then
8672428d7b3dSmrg	if test -n "$gentop"; then
8673428d7b3dSmrg	  func_show_eval '${RM}r "$gentop"'
8674428d7b3dSmrg	fi
8675428d7b3dSmrg
8676428d7b3dSmrg	# Create an invalid libtool object if no PIC, so that we don't
8677428d7b3dSmrg	# accidentally link it into a program.
8678428d7b3dSmrg	# $show "echo timestamp > $libobj"
8679428d7b3dSmrg	# $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
8680428d7b3dSmrg	exit $EXIT_SUCCESS
8681428d7b3dSmrg      fi
8682428d7b3dSmrg
8683428d7b3dSmrg      if test -n "$pic_flag" || test "$pic_mode" != default; then
8684428d7b3dSmrg	# Only do commands if we really have different PIC objects.
8685428d7b3dSmrg	reload_objs="$libobjs $reload_conv_objs"
8686428d7b3dSmrg	output="$libobj"
8687428d7b3dSmrg	func_execute_cmds "$reload_cmds" 'exit $?'
8688428d7b3dSmrg      fi
8689428d7b3dSmrg
8690428d7b3dSmrg      if test -n "$gentop"; then
8691428d7b3dSmrg	func_show_eval '${RM}r "$gentop"'
8692428d7b3dSmrg      fi
8693428d7b3dSmrg
8694428d7b3dSmrg      exit $EXIT_SUCCESS
8695428d7b3dSmrg      ;;
8696428d7b3dSmrg
8697428d7b3dSmrg    prog)
8698428d7b3dSmrg      case $host in
8699428d7b3dSmrg	*cygwin*) func_stripname '' '.exe' "$output"
8700428d7b3dSmrg	          output=$func_stripname_result.exe;;
8701428d7b3dSmrg      esac
8702428d7b3dSmrg      test -n "$vinfo" && \
8703428d7b3dSmrg	func_warning "\`-version-info' is ignored for programs"
8704428d7b3dSmrg
8705428d7b3dSmrg      test -n "$release" && \
8706428d7b3dSmrg	func_warning "\`-release' is ignored for programs"
8707428d7b3dSmrg
8708428d7b3dSmrg      test "$preload" = yes \
8709428d7b3dSmrg        && test "$dlopen_support" = unknown \
8710428d7b3dSmrg	&& test "$dlopen_self" = unknown \
8711428d7b3dSmrg	&& test "$dlopen_self_static" = unknown && \
8712428d7b3dSmrg	  func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support."
8713428d7b3dSmrg
8714428d7b3dSmrg      case $host in
8715428d7b3dSmrg      *-*-rhapsody* | *-*-darwin1.[012])
8716428d7b3dSmrg	# On Rhapsody replace the C library is the System framework
8717428d7b3dSmrg	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
8718428d7b3dSmrg	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
8719428d7b3dSmrg	;;
8720428d7b3dSmrg      esac
8721428d7b3dSmrg
8722428d7b3dSmrg      case $host in
8723428d7b3dSmrg      *-*-darwin*)
8724428d7b3dSmrg	# Don't allow lazy linking, it breaks C++ global constructors
8725428d7b3dSmrg	# But is supposedly fixed on 10.4 or later (yay!).
8726428d7b3dSmrg	if test "$tagname" = CXX ; then
8727428d7b3dSmrg	  case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
8728428d7b3dSmrg	    10.[0123])
8729428d7b3dSmrg	      func_append compile_command " ${wl}-bind_at_load"
8730428d7b3dSmrg	      func_append finalize_command " ${wl}-bind_at_load"
8731428d7b3dSmrg	    ;;
8732428d7b3dSmrg	  esac
8733428d7b3dSmrg	fi
8734428d7b3dSmrg	# Time to change all our "foo.ltframework" stuff back to "-framework foo"
8735428d7b3dSmrg	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8736428d7b3dSmrg	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8737428d7b3dSmrg	;;
8738428d7b3dSmrg      esac
8739428d7b3dSmrg
8740428d7b3dSmrg
8741428d7b3dSmrg      # move library search paths that coincide with paths to not yet
8742428d7b3dSmrg      # installed libraries to the beginning of the library search list
8743428d7b3dSmrg      new_libs=
8744428d7b3dSmrg      for path in $notinst_path; do
8745428d7b3dSmrg	case " $new_libs " in
8746428d7b3dSmrg	*" -L$path/$objdir "*) ;;
8747428d7b3dSmrg	*)
8748428d7b3dSmrg	  case " $compile_deplibs " in
8749428d7b3dSmrg	  *" -L$path/$objdir "*)
8750428d7b3dSmrg	    func_append new_libs " -L$path/$objdir" ;;
8751428d7b3dSmrg	  esac
8752428d7b3dSmrg	  ;;
8753428d7b3dSmrg	esac
8754428d7b3dSmrg      done
8755428d7b3dSmrg      for deplib in $compile_deplibs; do
8756428d7b3dSmrg	case $deplib in
8757428d7b3dSmrg	-L*)
8758428d7b3dSmrg	  case " $new_libs " in
8759428d7b3dSmrg	  *" $deplib "*) ;;
8760428d7b3dSmrg	  *) func_append new_libs " $deplib" ;;
8761428d7b3dSmrg	  esac
8762428d7b3dSmrg	  ;;
8763428d7b3dSmrg	*) func_append new_libs " $deplib" ;;
8764428d7b3dSmrg	esac
8765428d7b3dSmrg      done
8766428d7b3dSmrg      compile_deplibs="$new_libs"
8767428d7b3dSmrg
8768428d7b3dSmrg
8769428d7b3dSmrg      func_append compile_command " $compile_deplibs"
8770428d7b3dSmrg      func_append finalize_command " $finalize_deplibs"
8771428d7b3dSmrg
8772428d7b3dSmrg      if test -n "$rpath$xrpath"; then
8773428d7b3dSmrg	# If the user specified any rpath flags, then add them.
8774428d7b3dSmrg	for libdir in $rpath $xrpath; do
8775428d7b3dSmrg	  # This is the magic to use -rpath.
8776428d7b3dSmrg	  case "$finalize_rpath " in
8777428d7b3dSmrg	  *" $libdir "*) ;;
8778428d7b3dSmrg	  *) func_append finalize_rpath " $libdir" ;;
8779428d7b3dSmrg	  esac
8780428d7b3dSmrg	done
8781428d7b3dSmrg      fi
8782428d7b3dSmrg
8783428d7b3dSmrg      # Now hardcode the library paths
8784428d7b3dSmrg      rpath=
8785428d7b3dSmrg      hardcode_libdirs=
8786428d7b3dSmrg      for libdir in $compile_rpath $finalize_rpath; do
8787428d7b3dSmrg	if test -n "$hardcode_libdir_flag_spec"; then
8788428d7b3dSmrg	  if test -n "$hardcode_libdir_separator"; then
8789428d7b3dSmrg	    if test -z "$hardcode_libdirs"; then
8790428d7b3dSmrg	      hardcode_libdirs="$libdir"
8791428d7b3dSmrg	    else
8792428d7b3dSmrg	      # Just accumulate the unique libdirs.
8793428d7b3dSmrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
8794428d7b3dSmrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
8795428d7b3dSmrg		;;
8796428d7b3dSmrg	      *)
8797428d7b3dSmrg		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
8798428d7b3dSmrg		;;
8799428d7b3dSmrg	      esac
8800428d7b3dSmrg	    fi
8801428d7b3dSmrg	  else
8802428d7b3dSmrg	    eval flag=\"$hardcode_libdir_flag_spec\"
8803428d7b3dSmrg	    func_append rpath " $flag"
8804428d7b3dSmrg	  fi
8805428d7b3dSmrg	elif test -n "$runpath_var"; then
8806428d7b3dSmrg	  case "$perm_rpath " in
8807428d7b3dSmrg	  *" $libdir "*) ;;
8808428d7b3dSmrg	  *) func_append perm_rpath " $libdir" ;;
8809428d7b3dSmrg	  esac
8810428d7b3dSmrg	fi
8811428d7b3dSmrg	case $host in
8812428d7b3dSmrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
8813428d7b3dSmrg	  testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'`
8814428d7b3dSmrg	  case :$dllsearchpath: in
8815428d7b3dSmrg	  *":$libdir:"*) ;;
8816428d7b3dSmrg	  ::) dllsearchpath=$libdir;;
8817428d7b3dSmrg	  *) func_append dllsearchpath ":$libdir";;
8818428d7b3dSmrg	  esac
8819428d7b3dSmrg	  case :$dllsearchpath: in
8820428d7b3dSmrg	  *":$testbindir:"*) ;;
8821428d7b3dSmrg	  ::) dllsearchpath=$testbindir;;
8822428d7b3dSmrg	  *) func_append dllsearchpath ":$testbindir";;
8823428d7b3dSmrg	  esac
8824428d7b3dSmrg	  ;;
8825428d7b3dSmrg	esac
8826428d7b3dSmrg      done
8827428d7b3dSmrg      # Substitute the hardcoded libdirs into the rpath.
8828428d7b3dSmrg      if test -n "$hardcode_libdir_separator" &&
8829428d7b3dSmrg	 test -n "$hardcode_libdirs"; then
8830428d7b3dSmrg	libdir="$hardcode_libdirs"
8831428d7b3dSmrg	eval rpath=\" $hardcode_libdir_flag_spec\"
8832428d7b3dSmrg      fi
8833428d7b3dSmrg      compile_rpath="$rpath"
8834428d7b3dSmrg
8835428d7b3dSmrg      rpath=
8836428d7b3dSmrg      hardcode_libdirs=
8837428d7b3dSmrg      for libdir in $finalize_rpath; do
8838428d7b3dSmrg	if test -n "$hardcode_libdir_flag_spec"; then
8839428d7b3dSmrg	  if test -n "$hardcode_libdir_separator"; then
8840428d7b3dSmrg	    if test -z "$hardcode_libdirs"; then
8841428d7b3dSmrg	      hardcode_libdirs="$libdir"
8842428d7b3dSmrg	    else
8843428d7b3dSmrg	      # Just accumulate the unique libdirs.
8844428d7b3dSmrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
8845428d7b3dSmrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
8846428d7b3dSmrg		;;
8847428d7b3dSmrg	      *)
8848428d7b3dSmrg		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
8849428d7b3dSmrg		;;
8850428d7b3dSmrg	      esac
8851428d7b3dSmrg	    fi
8852428d7b3dSmrg	  else
8853428d7b3dSmrg	    eval flag=\"$hardcode_libdir_flag_spec\"
8854428d7b3dSmrg	    func_append rpath " $flag"
8855428d7b3dSmrg	  fi
8856428d7b3dSmrg	elif test -n "$runpath_var"; then
8857428d7b3dSmrg	  case "$finalize_perm_rpath " in
8858428d7b3dSmrg	  *" $libdir "*) ;;
8859428d7b3dSmrg	  *) func_append finalize_perm_rpath " $libdir" ;;
8860428d7b3dSmrg	  esac
8861428d7b3dSmrg	fi
8862428d7b3dSmrg      done
8863428d7b3dSmrg      # Substitute the hardcoded libdirs into the rpath.
8864428d7b3dSmrg      if test -n "$hardcode_libdir_separator" &&
8865428d7b3dSmrg	 test -n "$hardcode_libdirs"; then
8866428d7b3dSmrg	libdir="$hardcode_libdirs"
8867428d7b3dSmrg	eval rpath=\" $hardcode_libdir_flag_spec\"
8868428d7b3dSmrg      fi
8869428d7b3dSmrg      finalize_rpath="$rpath"
8870428d7b3dSmrg
8871428d7b3dSmrg      if test -n "$libobjs" && test "$build_old_libs" = yes; then
8872428d7b3dSmrg	# Transform all the library objects into standard objects.
8873428d7b3dSmrg	compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
8874428d7b3dSmrg	finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
8875428d7b3dSmrg      fi
8876428d7b3dSmrg
8877428d7b3dSmrg      func_generate_dlsyms "$outputname" "@PROGRAM@" "no"
8878428d7b3dSmrg
8879428d7b3dSmrg      # template prelinking step
8880428d7b3dSmrg      if test -n "$prelink_cmds"; then
8881428d7b3dSmrg	func_execute_cmds "$prelink_cmds" 'exit $?'
8882428d7b3dSmrg      fi
8883428d7b3dSmrg
8884428d7b3dSmrg      wrappers_required=yes
8885428d7b3dSmrg      case $host in
8886428d7b3dSmrg      *cegcc* | *mingw32ce*)
8887428d7b3dSmrg        # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
8888428d7b3dSmrg        wrappers_required=no
8889428d7b3dSmrg        ;;
8890428d7b3dSmrg      *cygwin* | *mingw* )
8891428d7b3dSmrg        if test "$build_libtool_libs" != yes; then
8892428d7b3dSmrg          wrappers_required=no
8893428d7b3dSmrg        fi
8894428d7b3dSmrg        ;;
8895428d7b3dSmrg      *)
8896428d7b3dSmrg        if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
8897428d7b3dSmrg          wrappers_required=no
8898428d7b3dSmrg        fi
8899428d7b3dSmrg        ;;
8900428d7b3dSmrg      esac
8901428d7b3dSmrg      if test "$wrappers_required" = no; then
8902428d7b3dSmrg	# Replace the output file specification.
8903428d7b3dSmrg	compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
8904428d7b3dSmrg	link_command="$compile_command$compile_rpath"
8905428d7b3dSmrg
8906428d7b3dSmrg	# We have no uninstalled library dependencies, so finalize right now.
8907428d7b3dSmrg	exit_status=0
8908428d7b3dSmrg	func_show_eval "$link_command" 'exit_status=$?'
8909428d7b3dSmrg
8910428d7b3dSmrg	if test -n "$postlink_cmds"; then
8911428d7b3dSmrg	  func_to_tool_file "$output"
8912428d7b3dSmrg	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
8913428d7b3dSmrg	  func_execute_cmds "$postlink_cmds" 'exit $?'
8914428d7b3dSmrg	fi
8915428d7b3dSmrg
8916428d7b3dSmrg	# Delete the generated files.
8917428d7b3dSmrg	if test -f "$output_objdir/${outputname}S.${objext}"; then
8918428d7b3dSmrg	  func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"'
8919428d7b3dSmrg	fi
8920428d7b3dSmrg
8921428d7b3dSmrg	exit $exit_status
8922428d7b3dSmrg      fi
8923428d7b3dSmrg
8924428d7b3dSmrg      if test -n "$compile_shlibpath$finalize_shlibpath"; then
8925428d7b3dSmrg	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
8926428d7b3dSmrg      fi
8927428d7b3dSmrg      if test -n "$finalize_shlibpath"; then
8928428d7b3dSmrg	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
8929428d7b3dSmrg      fi
8930428d7b3dSmrg
8931428d7b3dSmrg      compile_var=
8932428d7b3dSmrg      finalize_var=
8933428d7b3dSmrg      if test -n "$runpath_var"; then
8934428d7b3dSmrg	if test -n "$perm_rpath"; then
8935428d7b3dSmrg	  # We should set the runpath_var.
8936428d7b3dSmrg	  rpath=
8937428d7b3dSmrg	  for dir in $perm_rpath; do
8938428d7b3dSmrg	    func_append rpath "$dir:"
8939428d7b3dSmrg	  done
8940428d7b3dSmrg	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
8941428d7b3dSmrg	fi
8942428d7b3dSmrg	if test -n "$finalize_perm_rpath"; then
8943428d7b3dSmrg	  # We should set the runpath_var.
8944428d7b3dSmrg	  rpath=
8945428d7b3dSmrg	  for dir in $finalize_perm_rpath; do
8946428d7b3dSmrg	    func_append rpath "$dir:"
8947428d7b3dSmrg	  done
8948428d7b3dSmrg	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
8949428d7b3dSmrg	fi
8950428d7b3dSmrg      fi
8951428d7b3dSmrg
8952428d7b3dSmrg      if test "$no_install" = yes; then
8953428d7b3dSmrg	# We don't need to create a wrapper script.
8954428d7b3dSmrg	link_command="$compile_var$compile_command$compile_rpath"
8955428d7b3dSmrg	# Replace the output file specification.
8956428d7b3dSmrg	link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
8957428d7b3dSmrg	# Delete the old output file.
8958428d7b3dSmrg	$opt_dry_run || $RM $output
8959428d7b3dSmrg	# Link the executable and exit
8960428d7b3dSmrg	func_show_eval "$link_command" 'exit $?'
8961428d7b3dSmrg
8962428d7b3dSmrg	if test -n "$postlink_cmds"; then
8963428d7b3dSmrg	  func_to_tool_file "$output"
8964428d7b3dSmrg	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
8965428d7b3dSmrg	  func_execute_cmds "$postlink_cmds" 'exit $?'
8966428d7b3dSmrg	fi
8967428d7b3dSmrg
8968428d7b3dSmrg	exit $EXIT_SUCCESS
8969428d7b3dSmrg      fi
8970428d7b3dSmrg
8971428d7b3dSmrg      if test "$hardcode_action" = relink; then
8972428d7b3dSmrg	# Fast installation is not supported
8973428d7b3dSmrg	link_command="$compile_var$compile_command$compile_rpath"
8974428d7b3dSmrg	relink_command="$finalize_var$finalize_command$finalize_rpath"
8975428d7b3dSmrg
8976428d7b3dSmrg	func_warning "this platform does not like uninstalled shared libraries"
8977428d7b3dSmrg	func_warning "\`$output' will be relinked during installation"
8978428d7b3dSmrg      else
8979428d7b3dSmrg	if test "$fast_install" != no; then
8980428d7b3dSmrg	  link_command="$finalize_var$compile_command$finalize_rpath"
8981428d7b3dSmrg	  if test "$fast_install" = yes; then
8982428d7b3dSmrg	    relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
8983428d7b3dSmrg	  else
8984428d7b3dSmrg	    # fast_install is set to needless
8985428d7b3dSmrg	    relink_command=
8986428d7b3dSmrg	  fi
8987428d7b3dSmrg	else
8988428d7b3dSmrg	  link_command="$compile_var$compile_command$compile_rpath"
8989428d7b3dSmrg	  relink_command="$finalize_var$finalize_command$finalize_rpath"
8990428d7b3dSmrg	fi
8991428d7b3dSmrg      fi
8992428d7b3dSmrg
8993428d7b3dSmrg      # Replace the output file specification.
8994428d7b3dSmrg      link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
8995428d7b3dSmrg
8996428d7b3dSmrg      # Delete the old output files.
8997428d7b3dSmrg      $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
8998428d7b3dSmrg
8999428d7b3dSmrg      func_show_eval "$link_command" 'exit $?'
9000428d7b3dSmrg
9001428d7b3dSmrg      if test -n "$postlink_cmds"; then
9002428d7b3dSmrg	func_to_tool_file "$output_objdir/$outputname"
9003428d7b3dSmrg	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'`
9004428d7b3dSmrg	func_execute_cmds "$postlink_cmds" 'exit $?'
9005428d7b3dSmrg      fi
9006428d7b3dSmrg
9007428d7b3dSmrg      # Now create the wrapper script.
9008428d7b3dSmrg      func_verbose "creating $output"
9009428d7b3dSmrg
9010428d7b3dSmrg      # Quote the relink command for shipping.
9011428d7b3dSmrg      if test -n "$relink_command"; then
9012428d7b3dSmrg	# Preserve any variables that may affect compiler behavior
9013428d7b3dSmrg	for var in $variables_saved_for_relink; do
9014428d7b3dSmrg	  if eval test -z \"\${$var+set}\"; then
9015428d7b3dSmrg	    relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
9016428d7b3dSmrg	  elif eval var_value=\$$var; test -z "$var_value"; then
9017428d7b3dSmrg	    relink_command="$var=; export $var; $relink_command"
9018428d7b3dSmrg	  else
9019428d7b3dSmrg	    func_quote_for_eval "$var_value"
9020428d7b3dSmrg	    relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
9021428d7b3dSmrg	  fi
9022428d7b3dSmrg	done
9023428d7b3dSmrg	relink_command="(cd `pwd`; $relink_command)"
9024428d7b3dSmrg	relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
9025428d7b3dSmrg      fi
9026428d7b3dSmrg
9027428d7b3dSmrg      # Only actually do things if not in dry run mode.
9028428d7b3dSmrg      $opt_dry_run || {
9029428d7b3dSmrg	# win32 will think the script is a binary if it has
9030428d7b3dSmrg	# a .exe suffix, so we strip it off here.
9031428d7b3dSmrg	case $output in
9032428d7b3dSmrg	  *.exe) func_stripname '' '.exe' "$output"
9033428d7b3dSmrg	         output=$func_stripname_result ;;
9034428d7b3dSmrg	esac
9035428d7b3dSmrg	# test for cygwin because mv fails w/o .exe extensions
9036428d7b3dSmrg	case $host in
9037428d7b3dSmrg	  *cygwin*)
9038428d7b3dSmrg	    exeext=.exe
9039428d7b3dSmrg	    func_stripname '' '.exe' "$outputname"
9040428d7b3dSmrg	    outputname=$func_stripname_result ;;
9041428d7b3dSmrg	  *) exeext= ;;
9042428d7b3dSmrg	esac
9043428d7b3dSmrg	case $host in
9044428d7b3dSmrg	  *cygwin* | *mingw* )
9045428d7b3dSmrg	    func_dirname_and_basename "$output" "" "."
9046428d7b3dSmrg	    output_name=$func_basename_result
9047428d7b3dSmrg	    output_path=$func_dirname_result
9048428d7b3dSmrg	    cwrappersource="$output_path/$objdir/lt-$output_name.c"
9049428d7b3dSmrg	    cwrapper="$output_path/$output_name.exe"
9050428d7b3dSmrg	    $RM $cwrappersource $cwrapper
9051428d7b3dSmrg	    trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
9052428d7b3dSmrg
9053428d7b3dSmrg	    func_emit_cwrapperexe_src > $cwrappersource
9054428d7b3dSmrg
9055428d7b3dSmrg	    # The wrapper executable is built using the $host compiler,
9056428d7b3dSmrg	    # because it contains $host paths and files. If cross-
9057428d7b3dSmrg	    # compiling, it, like the target executable, must be
9058428d7b3dSmrg	    # executed on the $host or under an emulation environment.
9059428d7b3dSmrg	    $opt_dry_run || {
9060428d7b3dSmrg	      $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
9061428d7b3dSmrg	      $STRIP $cwrapper
9062428d7b3dSmrg	    }
9063428d7b3dSmrg
9064428d7b3dSmrg	    # Now, create the wrapper script for func_source use:
9065428d7b3dSmrg	    func_ltwrapper_scriptname $cwrapper
9066428d7b3dSmrg	    $RM $func_ltwrapper_scriptname_result
9067428d7b3dSmrg	    trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
9068428d7b3dSmrg	    $opt_dry_run || {
9069428d7b3dSmrg	      # note: this script will not be executed, so do not chmod.
9070428d7b3dSmrg	      if test "x$build" = "x$host" ; then
9071428d7b3dSmrg		$cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
9072428d7b3dSmrg	      else
9073428d7b3dSmrg		func_emit_wrapper no > $func_ltwrapper_scriptname_result
9074428d7b3dSmrg	      fi
9075428d7b3dSmrg	    }
9076428d7b3dSmrg	  ;;
9077428d7b3dSmrg	  * )
9078428d7b3dSmrg	    $RM $output
9079428d7b3dSmrg	    trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
9080428d7b3dSmrg
9081428d7b3dSmrg	    func_emit_wrapper no > $output
9082428d7b3dSmrg	    chmod +x $output
9083428d7b3dSmrg	  ;;
9084428d7b3dSmrg	esac
9085428d7b3dSmrg      }
9086428d7b3dSmrg      exit $EXIT_SUCCESS
9087428d7b3dSmrg      ;;
9088428d7b3dSmrg    esac
9089428d7b3dSmrg
9090428d7b3dSmrg    # See if we need to build an old-fashioned archive.
9091428d7b3dSmrg    for oldlib in $oldlibs; do
9092428d7b3dSmrg
9093428d7b3dSmrg      if test "$build_libtool_libs" = convenience; then
9094428d7b3dSmrg	oldobjs="$libobjs_save $symfileobj"
9095428d7b3dSmrg	addlibs="$convenience"
9096428d7b3dSmrg	build_libtool_libs=no
9097428d7b3dSmrg      else
9098428d7b3dSmrg	if test "$build_libtool_libs" = module; then
9099428d7b3dSmrg	  oldobjs="$libobjs_save"
9100428d7b3dSmrg	  build_libtool_libs=no
9101428d7b3dSmrg	else
9102428d7b3dSmrg	  oldobjs="$old_deplibs $non_pic_objects"
9103428d7b3dSmrg	  if test "$preload" = yes && test -f "$symfileobj"; then
9104428d7b3dSmrg	    func_append oldobjs " $symfileobj"
9105428d7b3dSmrg	  fi
9106428d7b3dSmrg	fi
9107428d7b3dSmrg	addlibs="$old_convenience"
9108428d7b3dSmrg      fi
9109428d7b3dSmrg
9110428d7b3dSmrg      if test -n "$addlibs"; then
9111428d7b3dSmrg	gentop="$output_objdir/${outputname}x"
9112428d7b3dSmrg	func_append generated " $gentop"
9113428d7b3dSmrg
9114428d7b3dSmrg	func_extract_archives $gentop $addlibs
9115428d7b3dSmrg	func_append oldobjs " $func_extract_archives_result"
9116428d7b3dSmrg      fi
9117428d7b3dSmrg
9118428d7b3dSmrg      # Do each command in the archive commands.
9119428d7b3dSmrg      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
9120428d7b3dSmrg	cmds=$old_archive_from_new_cmds
9121428d7b3dSmrg      else
9122428d7b3dSmrg
9123428d7b3dSmrg	# Add any objects from preloaded convenience libraries
9124428d7b3dSmrg	if test -n "$dlprefiles"; then
9125428d7b3dSmrg	  gentop="$output_objdir/${outputname}x"
9126428d7b3dSmrg	  func_append generated " $gentop"
9127428d7b3dSmrg
9128428d7b3dSmrg	  func_extract_archives $gentop $dlprefiles
9129428d7b3dSmrg	  func_append oldobjs " $func_extract_archives_result"
9130428d7b3dSmrg	fi
9131428d7b3dSmrg
9132428d7b3dSmrg	# POSIX demands no paths to be encoded in archives.  We have
9133428d7b3dSmrg	# to avoid creating archives with duplicate basenames if we
9134428d7b3dSmrg	# might have to extract them afterwards, e.g., when creating a
9135428d7b3dSmrg	# static archive out of a convenience library, or when linking
9136428d7b3dSmrg	# the entirety of a libtool archive into another (currently
9137428d7b3dSmrg	# not supported by libtool).
9138428d7b3dSmrg	if (for obj in $oldobjs
9139428d7b3dSmrg	    do
9140428d7b3dSmrg	      func_basename "$obj"
9141428d7b3dSmrg	      $ECHO "$func_basename_result"
9142428d7b3dSmrg	    done | sort | sort -uc >/dev/null 2>&1); then
9143428d7b3dSmrg	  :
9144428d7b3dSmrg	else
9145428d7b3dSmrg	  echo "copying selected object files to avoid basename conflicts..."
9146428d7b3dSmrg	  gentop="$output_objdir/${outputname}x"
9147428d7b3dSmrg	  func_append generated " $gentop"
9148428d7b3dSmrg	  func_mkdir_p "$gentop"
9149428d7b3dSmrg	  save_oldobjs=$oldobjs
9150428d7b3dSmrg	  oldobjs=
9151428d7b3dSmrg	  counter=1
9152428d7b3dSmrg	  for obj in $save_oldobjs
9153428d7b3dSmrg	  do
9154428d7b3dSmrg	    func_basename "$obj"
9155428d7b3dSmrg	    objbase="$func_basename_result"
9156428d7b3dSmrg	    case " $oldobjs " in
9157428d7b3dSmrg	    " ") oldobjs=$obj ;;
9158428d7b3dSmrg	    *[\ /]"$objbase "*)
9159428d7b3dSmrg	      while :; do
9160428d7b3dSmrg		# Make sure we don't pick an alternate name that also
9161428d7b3dSmrg		# overlaps.
9162428d7b3dSmrg		newobj=lt$counter-$objbase
9163428d7b3dSmrg		func_arith $counter + 1
9164428d7b3dSmrg		counter=$func_arith_result
9165428d7b3dSmrg		case " $oldobjs " in
9166428d7b3dSmrg		*[\ /]"$newobj "*) ;;
9167428d7b3dSmrg		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
9168428d7b3dSmrg		esac
9169428d7b3dSmrg	      done
9170428d7b3dSmrg	      func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
9171428d7b3dSmrg	      func_append oldobjs " $gentop/$newobj"
9172428d7b3dSmrg	      ;;
9173428d7b3dSmrg	    *) func_append oldobjs " $obj" ;;
9174428d7b3dSmrg	    esac
9175428d7b3dSmrg	  done
9176428d7b3dSmrg	fi
9177428d7b3dSmrg	func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
9178428d7b3dSmrg	tool_oldlib=$func_to_tool_file_result
9179428d7b3dSmrg	eval cmds=\"$old_archive_cmds\"
9180428d7b3dSmrg
9181428d7b3dSmrg	func_len " $cmds"
9182428d7b3dSmrg	len=$func_len_result
9183428d7b3dSmrg	if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
9184428d7b3dSmrg	  cmds=$old_archive_cmds
9185428d7b3dSmrg	elif test -n "$archiver_list_spec"; then
9186428d7b3dSmrg	  func_verbose "using command file archive linking..."
9187428d7b3dSmrg	  for obj in $oldobjs
9188428d7b3dSmrg	  do
9189428d7b3dSmrg	    func_to_tool_file "$obj"
9190428d7b3dSmrg	    $ECHO "$func_to_tool_file_result"
9191428d7b3dSmrg	  done > $output_objdir/$libname.libcmd
9192428d7b3dSmrg	  func_to_tool_file "$output_objdir/$libname.libcmd"
9193428d7b3dSmrg	  oldobjs=" $archiver_list_spec$func_to_tool_file_result"
9194428d7b3dSmrg	  cmds=$old_archive_cmds
9195428d7b3dSmrg	else
9196428d7b3dSmrg	  # the command line is too long to link in one step, link in parts
9197428d7b3dSmrg	  func_verbose "using piecewise archive linking..."
9198428d7b3dSmrg	  save_RANLIB=$RANLIB
9199428d7b3dSmrg	  RANLIB=:
9200428d7b3dSmrg	  objlist=
9201428d7b3dSmrg	  concat_cmds=
9202428d7b3dSmrg	  save_oldobjs=$oldobjs
9203428d7b3dSmrg	  oldobjs=
9204428d7b3dSmrg	  # Is there a better way of finding the last object in the list?
9205428d7b3dSmrg	  for obj in $save_oldobjs
9206428d7b3dSmrg	  do
9207428d7b3dSmrg	    last_oldobj=$obj
9208428d7b3dSmrg	  done
9209428d7b3dSmrg	  eval test_cmds=\"$old_archive_cmds\"
9210428d7b3dSmrg	  func_len " $test_cmds"
9211428d7b3dSmrg	  len0=$func_len_result
9212428d7b3dSmrg	  len=$len0
9213428d7b3dSmrg	  for obj in $save_oldobjs
9214428d7b3dSmrg	  do
9215428d7b3dSmrg	    func_len " $obj"
9216428d7b3dSmrg	    func_arith $len + $func_len_result
9217428d7b3dSmrg	    len=$func_arith_result
9218428d7b3dSmrg	    func_append objlist " $obj"
9219428d7b3dSmrg	    if test "$len" -lt "$max_cmd_len"; then
9220428d7b3dSmrg	      :
9221428d7b3dSmrg	    else
9222428d7b3dSmrg	      # the above command should be used before it gets too long
9223428d7b3dSmrg	      oldobjs=$objlist
9224428d7b3dSmrg	      if test "$obj" = "$last_oldobj" ; then
9225428d7b3dSmrg		RANLIB=$save_RANLIB
9226428d7b3dSmrg	      fi
9227428d7b3dSmrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
9228428d7b3dSmrg	      eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
9229428d7b3dSmrg	      objlist=
9230428d7b3dSmrg	      len=$len0
9231428d7b3dSmrg	    fi
9232428d7b3dSmrg	  done
9233428d7b3dSmrg	  RANLIB=$save_RANLIB
9234428d7b3dSmrg	  oldobjs=$objlist
9235428d7b3dSmrg	  if test "X$oldobjs" = "X" ; then
9236428d7b3dSmrg	    eval cmds=\"\$concat_cmds\"
9237428d7b3dSmrg	  else
9238428d7b3dSmrg	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
9239428d7b3dSmrg	  fi
9240428d7b3dSmrg	fi
9241428d7b3dSmrg      fi
9242428d7b3dSmrg      func_execute_cmds "$cmds" 'exit $?'
9243428d7b3dSmrg    done
9244428d7b3dSmrg
9245428d7b3dSmrg    test -n "$generated" && \
9246428d7b3dSmrg      func_show_eval "${RM}r$generated"
9247428d7b3dSmrg
9248428d7b3dSmrg    # Now create the libtool archive.
9249428d7b3dSmrg    case $output in
9250428d7b3dSmrg    *.la)
9251428d7b3dSmrg      old_library=
9252428d7b3dSmrg      test "$build_old_libs" = yes && old_library="$libname.$libext"
9253428d7b3dSmrg      func_verbose "creating $output"
9254428d7b3dSmrg
9255428d7b3dSmrg      # Preserve any variables that may affect compiler behavior
9256428d7b3dSmrg      for var in $variables_saved_for_relink; do
9257428d7b3dSmrg	if eval test -z \"\${$var+set}\"; then
9258428d7b3dSmrg	  relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
9259428d7b3dSmrg	elif eval var_value=\$$var; test -z "$var_value"; then
9260428d7b3dSmrg	  relink_command="$var=; export $var; $relink_command"
9261428d7b3dSmrg	else
9262428d7b3dSmrg	  func_quote_for_eval "$var_value"
9263428d7b3dSmrg	  relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
9264428d7b3dSmrg	fi
9265428d7b3dSmrg      done
9266428d7b3dSmrg      # Quote the link command for shipping.
9267428d7b3dSmrg      relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
9268428d7b3dSmrg      relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
9269428d7b3dSmrg      if test "$hardcode_automatic" = yes ; then
9270428d7b3dSmrg	relink_command=
9271428d7b3dSmrg      fi
9272428d7b3dSmrg
9273428d7b3dSmrg      # Only create the output if not a dry run.
9274428d7b3dSmrg      $opt_dry_run || {
9275428d7b3dSmrg	for installed in no yes; do
9276428d7b3dSmrg	  if test "$installed" = yes; then
9277428d7b3dSmrg	    if test -z "$install_libdir"; then
9278428d7b3dSmrg	      break
9279428d7b3dSmrg	    fi
9280428d7b3dSmrg	    output="$output_objdir/$outputname"i
9281428d7b3dSmrg	    # Replace all uninstalled libtool libraries with the installed ones
9282428d7b3dSmrg	    newdependency_libs=
9283428d7b3dSmrg	    for deplib in $dependency_libs; do
9284428d7b3dSmrg	      case $deplib in
9285428d7b3dSmrg	      *.la)
9286428d7b3dSmrg		func_basename "$deplib"
9287428d7b3dSmrg		name="$func_basename_result"
9288428d7b3dSmrg		func_resolve_sysroot "$deplib"
9289428d7b3dSmrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result`
9290428d7b3dSmrg		test -z "$libdir" && \
9291428d7b3dSmrg		  func_fatal_error "\`$deplib' is not a valid libtool archive"
9292428d7b3dSmrg		func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"
9293428d7b3dSmrg		;;
9294428d7b3dSmrg	      -L*)
9295428d7b3dSmrg		func_stripname -L '' "$deplib"
9296428d7b3dSmrg		func_replace_sysroot "$func_stripname_result"
9297428d7b3dSmrg		func_append newdependency_libs " -L$func_replace_sysroot_result"
9298428d7b3dSmrg		;;
9299428d7b3dSmrg	      -R*)
9300428d7b3dSmrg		func_stripname -R '' "$deplib"
9301428d7b3dSmrg		func_replace_sysroot "$func_stripname_result"
9302428d7b3dSmrg		func_append newdependency_libs " -R$func_replace_sysroot_result"
9303428d7b3dSmrg		;;
9304428d7b3dSmrg	      *) func_append newdependency_libs " $deplib" ;;
9305428d7b3dSmrg	      esac
9306428d7b3dSmrg	    done
9307428d7b3dSmrg	    dependency_libs="$newdependency_libs"
9308428d7b3dSmrg	    newdlfiles=
9309428d7b3dSmrg
9310428d7b3dSmrg	    for lib in $dlfiles; do
9311428d7b3dSmrg	      case $lib in
9312428d7b3dSmrg	      *.la)
9313428d7b3dSmrg	        func_basename "$lib"
9314428d7b3dSmrg		name="$func_basename_result"
9315428d7b3dSmrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
9316428d7b3dSmrg		test -z "$libdir" && \
9317428d7b3dSmrg		  func_fatal_error "\`$lib' is not a valid libtool archive"
9318428d7b3dSmrg		func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name"
9319428d7b3dSmrg		;;
9320428d7b3dSmrg	      *) func_append newdlfiles " $lib" ;;
9321428d7b3dSmrg	      esac
9322428d7b3dSmrg	    done
9323428d7b3dSmrg	    dlfiles="$newdlfiles"
9324428d7b3dSmrg	    newdlprefiles=
9325428d7b3dSmrg	    for lib in $dlprefiles; do
9326428d7b3dSmrg	      case $lib in
9327428d7b3dSmrg	      *.la)
9328428d7b3dSmrg		# Only pass preopened files to the pseudo-archive (for
9329428d7b3dSmrg		# eventual linking with the app. that links it) if we
9330428d7b3dSmrg		# didn't already link the preopened objects directly into
9331428d7b3dSmrg		# the library:
9332428d7b3dSmrg		func_basename "$lib"
9333428d7b3dSmrg		name="$func_basename_result"
9334428d7b3dSmrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
9335428d7b3dSmrg		test -z "$libdir" && \
9336428d7b3dSmrg		  func_fatal_error "\`$lib' is not a valid libtool archive"
9337428d7b3dSmrg		func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name"
9338428d7b3dSmrg		;;
9339428d7b3dSmrg	      esac
9340428d7b3dSmrg	    done
9341428d7b3dSmrg	    dlprefiles="$newdlprefiles"
9342428d7b3dSmrg	  else
9343428d7b3dSmrg	    newdlfiles=
9344428d7b3dSmrg	    for lib in $dlfiles; do
9345428d7b3dSmrg	      case $lib in
9346428d7b3dSmrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
9347428d7b3dSmrg		*) abs=`pwd`"/$lib" ;;
9348428d7b3dSmrg	      esac
9349428d7b3dSmrg	      func_append newdlfiles " $abs"
9350428d7b3dSmrg	    done
9351428d7b3dSmrg	    dlfiles="$newdlfiles"
9352428d7b3dSmrg	    newdlprefiles=
9353428d7b3dSmrg	    for lib in $dlprefiles; do
9354428d7b3dSmrg	      case $lib in
9355428d7b3dSmrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
9356428d7b3dSmrg		*) abs=`pwd`"/$lib" ;;
9357428d7b3dSmrg	      esac
9358428d7b3dSmrg	      func_append newdlprefiles " $abs"
9359428d7b3dSmrg	    done
9360428d7b3dSmrg	    dlprefiles="$newdlprefiles"
9361428d7b3dSmrg	  fi
9362428d7b3dSmrg	  $RM $output
9363428d7b3dSmrg	  # place dlname in correct position for cygwin
9364428d7b3dSmrg	  # In fact, it would be nice if we could use this code for all target
9365428d7b3dSmrg	  # systems that can't hard-code library paths into their executables
9366428d7b3dSmrg	  # and that have no shared library path variable independent of PATH,
9367428d7b3dSmrg	  # but it turns out we can't easily determine that from inspecting
9368428d7b3dSmrg	  # libtool variables, so we have to hard-code the OSs to which it
9369428d7b3dSmrg	  # applies here; at the moment, that means platforms that use the PE
9370428d7b3dSmrg	  # object format with DLL files.  See the long comment at the top of
9371428d7b3dSmrg	  # tests/bindir.at for full details.
9372428d7b3dSmrg	  tdlname=$dlname
9373428d7b3dSmrg	  case $host,$output,$installed,$module,$dlname in
9374428d7b3dSmrg	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
9375428d7b3dSmrg	      # If a -bindir argument was supplied, place the dll there.
9376428d7b3dSmrg	      if test "x$bindir" != x ;
9377428d7b3dSmrg	      then
9378428d7b3dSmrg		func_relative_path "$install_libdir" "$bindir"
9379428d7b3dSmrg		tdlname=$func_relative_path_result$dlname
9380428d7b3dSmrg	      else
9381428d7b3dSmrg		# Otherwise fall back on heuristic.
9382428d7b3dSmrg		tdlname=../bin/$dlname
9383428d7b3dSmrg	      fi
9384428d7b3dSmrg	      ;;
9385428d7b3dSmrg	  esac
9386428d7b3dSmrg	  $ECHO > $output "\
9387428d7b3dSmrg# $outputname - a libtool library file
9388428d7b3dSmrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
9389428d7b3dSmrg#
9390428d7b3dSmrg# Please DO NOT delete this file!
9391428d7b3dSmrg# It is necessary for linking the library.
9392428d7b3dSmrg
9393428d7b3dSmrg# The name that we can dlopen(3).
9394428d7b3dSmrgdlname='$tdlname'
9395428d7b3dSmrg
9396428d7b3dSmrg# Names of this library.
9397428d7b3dSmrglibrary_names='$library_names'
9398428d7b3dSmrg
9399428d7b3dSmrg# The name of the static archive.
9400428d7b3dSmrgold_library='$old_library'
9401428d7b3dSmrg
9402428d7b3dSmrg# Linker flags that can not go in dependency_libs.
9403428d7b3dSmrginherited_linker_flags='$new_inherited_linker_flags'
9404428d7b3dSmrg
9405428d7b3dSmrg# Libraries that this one depends upon.
9406428d7b3dSmrgdependency_libs='$dependency_libs'
9407428d7b3dSmrg
9408428d7b3dSmrg# Names of additional weak libraries provided by this library
9409428d7b3dSmrgweak_library_names='$weak_libs'
9410428d7b3dSmrg
9411428d7b3dSmrg# Version information for $libname.
9412428d7b3dSmrgcurrent=$current
9413428d7b3dSmrgage=$age
9414428d7b3dSmrgrevision=$revision
9415428d7b3dSmrg
9416428d7b3dSmrg# Is this an already installed library?
9417428d7b3dSmrginstalled=$installed
9418428d7b3dSmrg
9419428d7b3dSmrg# Should we warn about portability when linking against -modules?
9420428d7b3dSmrgshouldnotlink=$module
9421428d7b3dSmrg
9422428d7b3dSmrg# Files to dlopen/dlpreopen
9423428d7b3dSmrgdlopen='$dlfiles'
9424428d7b3dSmrgdlpreopen='$dlprefiles'
9425428d7b3dSmrg
9426428d7b3dSmrg# Directory that this library needs to be installed in:
9427428d7b3dSmrglibdir='$install_libdir'"
9428428d7b3dSmrg	  if test "$installed" = no && test "$need_relink" = yes; then
9429428d7b3dSmrg	    $ECHO >> $output "\
9430428d7b3dSmrgrelink_command=\"$relink_command\""
9431428d7b3dSmrg	  fi
9432428d7b3dSmrg	done
9433428d7b3dSmrg      }
9434428d7b3dSmrg
9435428d7b3dSmrg      # Do a symbolic link so that the libtool archive can be found in
9436428d7b3dSmrg      # LD_LIBRARY_PATH before the program is installed.
9437428d7b3dSmrg      func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
9438428d7b3dSmrg      ;;
9439428d7b3dSmrg    esac
9440428d7b3dSmrg    exit $EXIT_SUCCESS
9441428d7b3dSmrg}
9442428d7b3dSmrg
9443428d7b3dSmrg{ test "$opt_mode" = link || test "$opt_mode" = relink; } &&
9444428d7b3dSmrg    func_mode_link ${1+"$@"}
9445428d7b3dSmrg
9446428d7b3dSmrg
9447428d7b3dSmrg# func_mode_uninstall arg...
9448428d7b3dSmrgfunc_mode_uninstall ()
9449428d7b3dSmrg{
9450428d7b3dSmrg    $opt_debug
9451428d7b3dSmrg    RM="$nonopt"
9452428d7b3dSmrg    files=
9453428d7b3dSmrg    rmforce=
9454428d7b3dSmrg    exit_status=0
9455428d7b3dSmrg
9456428d7b3dSmrg    # This variable tells wrapper scripts just to set variables rather
9457428d7b3dSmrg    # than running their programs.
9458428d7b3dSmrg    libtool_install_magic="$magic"
9459428d7b3dSmrg
9460428d7b3dSmrg    for arg
9461428d7b3dSmrg    do
9462428d7b3dSmrg      case $arg in
9463428d7b3dSmrg      -f) func_append RM " $arg"; rmforce=yes ;;
9464428d7b3dSmrg      -*) func_append RM " $arg" ;;
9465428d7b3dSmrg      *) func_append files " $arg" ;;
9466428d7b3dSmrg      esac
9467428d7b3dSmrg    done
9468428d7b3dSmrg
9469428d7b3dSmrg    test -z "$RM" && \
9470428d7b3dSmrg      func_fatal_help "you must specify an RM program"
9471428d7b3dSmrg
9472428d7b3dSmrg    rmdirs=
9473428d7b3dSmrg
9474428d7b3dSmrg    for file in $files; do
9475428d7b3dSmrg      func_dirname "$file" "" "."
9476428d7b3dSmrg      dir="$func_dirname_result"
9477428d7b3dSmrg      if test "X$dir" = X.; then
9478428d7b3dSmrg	odir="$objdir"
9479428d7b3dSmrg      else
9480428d7b3dSmrg	odir="$dir/$objdir"
9481428d7b3dSmrg      fi
9482428d7b3dSmrg      func_basename "$file"
9483428d7b3dSmrg      name="$func_basename_result"
9484428d7b3dSmrg      test "$opt_mode" = uninstall && odir="$dir"
9485428d7b3dSmrg
9486428d7b3dSmrg      # Remember odir for removal later, being careful to avoid duplicates
9487428d7b3dSmrg      if test "$opt_mode" = clean; then
9488428d7b3dSmrg	case " $rmdirs " in
9489428d7b3dSmrg	  *" $odir "*) ;;
9490428d7b3dSmrg	  *) func_append rmdirs " $odir" ;;
9491428d7b3dSmrg	esac
9492428d7b3dSmrg      fi
9493428d7b3dSmrg
9494428d7b3dSmrg      # Don't error if the file doesn't exist and rm -f was used.
9495428d7b3dSmrg      if { test -L "$file"; } >/dev/null 2>&1 ||
9496428d7b3dSmrg	 { test -h "$file"; } >/dev/null 2>&1 ||
9497428d7b3dSmrg	 test -f "$file"; then
9498428d7b3dSmrg	:
9499428d7b3dSmrg      elif test -d "$file"; then
9500428d7b3dSmrg	exit_status=1
9501428d7b3dSmrg	continue
9502428d7b3dSmrg      elif test "$rmforce" = yes; then
9503428d7b3dSmrg	continue
9504428d7b3dSmrg      fi
9505428d7b3dSmrg
9506428d7b3dSmrg      rmfiles="$file"
9507428d7b3dSmrg
9508428d7b3dSmrg      case $name in
9509428d7b3dSmrg      *.la)
9510428d7b3dSmrg	# Possibly a libtool archive, so verify it.
9511428d7b3dSmrg	if func_lalib_p "$file"; then
9512428d7b3dSmrg	  func_source $dir/$name
9513428d7b3dSmrg
9514428d7b3dSmrg	  # Delete the libtool libraries and symlinks.
9515428d7b3dSmrg	  for n in $library_names; do
9516428d7b3dSmrg	    func_append rmfiles " $odir/$n"
9517428d7b3dSmrg	  done
9518428d7b3dSmrg	  test -n "$old_library" && func_append rmfiles " $odir/$old_library"
9519428d7b3dSmrg
9520428d7b3dSmrg	  case "$opt_mode" in
9521428d7b3dSmrg	  clean)
9522428d7b3dSmrg	    case " $library_names " in
9523428d7b3dSmrg	    *" $dlname "*) ;;
9524428d7b3dSmrg	    *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;;
9525428d7b3dSmrg	    esac
9526428d7b3dSmrg	    test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i"
9527428d7b3dSmrg	    ;;
9528428d7b3dSmrg	  uninstall)
9529428d7b3dSmrg	    if test -n "$library_names"; then
9530428d7b3dSmrg	      # Do each command in the postuninstall commands.
9531428d7b3dSmrg	      func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
9532428d7b3dSmrg	    fi
9533428d7b3dSmrg
9534428d7b3dSmrg	    if test -n "$old_library"; then
9535428d7b3dSmrg	      # Do each command in the old_postuninstall commands.
9536428d7b3dSmrg	      func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
9537428d7b3dSmrg	    fi
9538428d7b3dSmrg	    # FIXME: should reinstall the best remaining shared library.
9539428d7b3dSmrg	    ;;
9540428d7b3dSmrg	  esac
9541428d7b3dSmrg	fi
9542428d7b3dSmrg	;;
9543428d7b3dSmrg
9544428d7b3dSmrg      *.lo)
9545428d7b3dSmrg	# Possibly a libtool object, so verify it.
9546428d7b3dSmrg	if func_lalib_p "$file"; then
9547428d7b3dSmrg
9548428d7b3dSmrg	  # Read the .lo file
9549428d7b3dSmrg	  func_source $dir/$name
9550428d7b3dSmrg
9551428d7b3dSmrg	  # Add PIC object to the list of files to remove.
9552428d7b3dSmrg	  if test -n "$pic_object" &&
9553428d7b3dSmrg	     test "$pic_object" != none; then
9554428d7b3dSmrg	    func_append rmfiles " $dir/$pic_object"
9555428d7b3dSmrg	  fi
9556428d7b3dSmrg
9557428d7b3dSmrg	  # Add non-PIC object to the list of files to remove.
9558428d7b3dSmrg	  if test -n "$non_pic_object" &&
9559428d7b3dSmrg	     test "$non_pic_object" != none; then
9560428d7b3dSmrg	    func_append rmfiles " $dir/$non_pic_object"
9561428d7b3dSmrg	  fi
9562428d7b3dSmrg	fi
9563428d7b3dSmrg	;;
9564428d7b3dSmrg
9565428d7b3dSmrg      *)
9566428d7b3dSmrg	if test "$opt_mode" = clean ; then
9567428d7b3dSmrg	  noexename=$name
9568428d7b3dSmrg	  case $file in
9569428d7b3dSmrg	  *.exe)
9570428d7b3dSmrg	    func_stripname '' '.exe' "$file"
9571428d7b3dSmrg	    file=$func_stripname_result
9572428d7b3dSmrg	    func_stripname '' '.exe' "$name"
9573428d7b3dSmrg	    noexename=$func_stripname_result
9574428d7b3dSmrg	    # $file with .exe has already been added to rmfiles,
9575428d7b3dSmrg	    # add $file without .exe
9576428d7b3dSmrg	    func_append rmfiles " $file"
9577428d7b3dSmrg	    ;;
9578428d7b3dSmrg	  esac
9579428d7b3dSmrg	  # Do a test to see if this is a libtool program.
9580428d7b3dSmrg	  if func_ltwrapper_p "$file"; then
9581428d7b3dSmrg	    if func_ltwrapper_executable_p "$file"; then
9582428d7b3dSmrg	      func_ltwrapper_scriptname "$file"
9583428d7b3dSmrg	      relink_command=
9584428d7b3dSmrg	      func_source $func_ltwrapper_scriptname_result
9585428d7b3dSmrg	      func_append rmfiles " $func_ltwrapper_scriptname_result"
9586428d7b3dSmrg	    else
9587428d7b3dSmrg	      relink_command=
9588428d7b3dSmrg	      func_source $dir/$noexename
9589428d7b3dSmrg	    fi
9590428d7b3dSmrg
9591428d7b3dSmrg	    # note $name still contains .exe if it was in $file originally
9592428d7b3dSmrg	    # as does the version of $file that was added into $rmfiles
9593428d7b3dSmrg	    func_append rmfiles " $odir/$name $odir/${name}S.${objext}"
9594428d7b3dSmrg	    if test "$fast_install" = yes && test -n "$relink_command"; then
9595428d7b3dSmrg	      func_append rmfiles " $odir/lt-$name"
9596428d7b3dSmrg	    fi
9597428d7b3dSmrg	    if test "X$noexename" != "X$name" ; then
9598428d7b3dSmrg	      func_append rmfiles " $odir/lt-${noexename}.c"
9599428d7b3dSmrg	    fi
9600428d7b3dSmrg	  fi
9601428d7b3dSmrg	fi
9602428d7b3dSmrg	;;
9603428d7b3dSmrg      esac
9604428d7b3dSmrg      func_show_eval "$RM $rmfiles" 'exit_status=1'
9605428d7b3dSmrg    done
9606428d7b3dSmrg
9607428d7b3dSmrg    # Try to remove the ${objdir}s in the directories where we deleted files
9608428d7b3dSmrg    for dir in $rmdirs; do
9609428d7b3dSmrg      if test -d "$dir"; then
9610428d7b3dSmrg	func_show_eval "rmdir $dir >/dev/null 2>&1"
9611428d7b3dSmrg      fi
9612428d7b3dSmrg    done
9613428d7b3dSmrg
9614428d7b3dSmrg    exit $exit_status
9615428d7b3dSmrg}
9616428d7b3dSmrg
9617428d7b3dSmrg{ test "$opt_mode" = uninstall || test "$opt_mode" = clean; } &&
9618428d7b3dSmrg    func_mode_uninstall ${1+"$@"}
9619428d7b3dSmrg
9620428d7b3dSmrgtest -z "$opt_mode" && {
9621428d7b3dSmrg  help="$generic_help"
9622428d7b3dSmrg  func_fatal_help "you must specify a MODE"
9623428d7b3dSmrg}
9624428d7b3dSmrg
9625428d7b3dSmrgtest -z "$exec_cmd" && \
9626428d7b3dSmrg  func_fatal_help "invalid operation mode \`$opt_mode'"
9627428d7b3dSmrg
9628428d7b3dSmrgif test -n "$exec_cmd"; then
9629428d7b3dSmrg  eval exec "$exec_cmd"
9630428d7b3dSmrg  exit $EXIT_FAILURE
9631428d7b3dSmrgfi
9632428d7b3dSmrg
9633428d7b3dSmrgexit $exit_status
9634428d7b3dSmrg
9635428d7b3dSmrg
9636428d7b3dSmrg# The TAGs below are defined such that we never get into a situation
9637428d7b3dSmrg# in which we disable both kinds of libraries.  Given conflicting
9638428d7b3dSmrg# choices, we go for a static library, that is the most portable,
9639428d7b3dSmrg# since we can't tell whether shared libraries were disabled because
9640428d7b3dSmrg# the user asked for that or because the platform doesn't support
9641428d7b3dSmrg# them.  This is particularly important on AIX, because we don't
9642428d7b3dSmrg# support having both static and shared libraries enabled at the same
9643428d7b3dSmrg# time on that platform, so we default to a shared-only configuration.
9644428d7b3dSmrg# If a disable-shared tag is given, we'll fallback to a static-only
9645428d7b3dSmrg# configuration.  But we'll never go from static-only to shared-only.
9646428d7b3dSmrg
9647428d7b3dSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
9648428d7b3dSmrgbuild_libtool_libs=no
9649428d7b3dSmrgbuild_old_libs=yes
9650428d7b3dSmrg# ### END LIBTOOL TAG CONFIG: disable-shared
9651428d7b3dSmrg
9652428d7b3dSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static
9653428d7b3dSmrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
9654428d7b3dSmrg# ### END LIBTOOL TAG CONFIG: disable-static
9655428d7b3dSmrg
9656428d7b3dSmrg# Local Variables:
9657428d7b3dSmrg# mode:shell-script
9658428d7b3dSmrg# sh-indentation:2
9659428d7b3dSmrg# End:
9660428d7b3dSmrg# vi:sw=2
9661428d7b3dSmrg
9662