1267843Sdelphij
2267843Sdelphij# libtool (GNU libtool) 2.4.2
3267843Sdelphij# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
4267843Sdelphij
5267843Sdelphij# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006,
6267843Sdelphij# 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
7267843Sdelphij# This is free software; see the source for copying conditions.  There is NO
8267843Sdelphij# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9267843Sdelphij
10267843Sdelphij# GNU Libtool is free software; you can redistribute it and/or modify
11267843Sdelphij# it under the terms of the GNU General Public License as published by
12267843Sdelphij# the Free Software Foundation; either version 2 of the License, or
13267843Sdelphij# (at your option) any later version.
14267843Sdelphij#
15267843Sdelphij# As a special exception to the GNU General Public License,
16267843Sdelphij# if you distribute this file as part of a program or library that
17267843Sdelphij# is built using GNU Libtool, you may include this file under the
18267843Sdelphij# same distribution terms that you use for the rest of that program.
19267843Sdelphij#
20267843Sdelphij# GNU Libtool is distributed in the hope that it will be useful, but
21267843Sdelphij# WITHOUT ANY WARRANTY; without even the implied warranty of
22267843Sdelphij# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
23267843Sdelphij# General Public License for more details.
24267843Sdelphij#
25267843Sdelphij# You should have received a copy of the GNU General Public License
26267843Sdelphij# along with GNU Libtool; see the file COPYING.  If not, a copy
27267843Sdelphij# can be downloaded from http://www.gnu.org/licenses/gpl.html,
28267843Sdelphij# or obtained by writing to the Free Software Foundation, Inc.,
29267843Sdelphij# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
30267843Sdelphij
31267843Sdelphij# Usage: $progname [OPTION]... [MODE-ARG]...
32267843Sdelphij#
33267843Sdelphij# Provide generalized library-building support services.
34267843Sdelphij#
35267843Sdelphij#       --config             show all configuration variables
36267843Sdelphij#       --debug              enable verbose shell tracing
37267843Sdelphij#   -n, --dry-run            display commands without modifying any files
38267843Sdelphij#       --features           display basic configuration information and exit
39267843Sdelphij#       --mode=MODE          use operation mode MODE
40267843Sdelphij#       --preserve-dup-deps  don't remove duplicate dependency libraries
41267843Sdelphij#       --quiet, --silent    don't print informational messages
42267843Sdelphij#       --no-quiet, --no-silent
43267843Sdelphij#                            print informational messages (default)
44267843Sdelphij#       --no-warn            don't display warning messages
45267843Sdelphij#       --tag=TAG            use configuration variables from tag TAG
46267843Sdelphij#   -v, --verbose            print more informational messages than default
47267843Sdelphij#       --no-verbose         don't print the extra informational messages
48267843Sdelphij#       --version            print version information
49267843Sdelphij#   -h, --help, --help-all   print short, long, or detailed help message
50267843Sdelphij#
51267843Sdelphij# MODE must be one of the following:
52267843Sdelphij#
53267843Sdelphij#         clean              remove files from the build directory
54267843Sdelphij#         compile            compile a source file into a libtool object
55267843Sdelphij#         execute            automatically set library path, then run a program
56267843Sdelphij#         finish             complete the installation of libtool libraries
57267843Sdelphij#         install            install libraries or executables
58267843Sdelphij#         link               create a library or an executable
59267843Sdelphij#         uninstall          remove libraries from an installed directory
60267843Sdelphij#
61267843Sdelphij# MODE-ARGS vary depending on the MODE.  When passed as first option,
62267843Sdelphij# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that.
63267843Sdelphij# Try `$progname --help --mode=MODE' for a more detailed description of MODE.
64267843Sdelphij#
65267843Sdelphij# When reporting a bug, please describe a test case to reproduce it and
66267843Sdelphij# include the following information:
67267843Sdelphij#
68267843Sdelphij#         host-triplet:	$host
69267843Sdelphij#         shell:		$SHELL
70267843Sdelphij#         compiler:		$LTCC
71267843Sdelphij#         compiler flags:		$LTCFLAGS
72267843Sdelphij#         linker:		$LD (gnu? $with_gnu_ld)
73267843Sdelphij#         $progname:	(GNU libtool) 2.4.2
74267843Sdelphij#         automake:	$automake_version
75267843Sdelphij#         autoconf:	$autoconf_version
76267843Sdelphij#
77267843Sdelphij# Report bugs to <bug-libtool@gnu.org>.
78267843Sdelphij# GNU libtool home page: <http://www.gnu.org/software/libtool/>.
79267843Sdelphij# General help using GNU software: <http://www.gnu.org/gethelp/>.
80267843Sdelphij
81267843SdelphijPROGRAM=libtool
82267843SdelphijPACKAGE=libtool
83267843SdelphijVERSION=2.4.2
84267843SdelphijTIMESTAMP=""
85267843Sdelphijpackage_revision=1.3337
86267843Sdelphij
87267843Sdelphij# Be Bourne compatible
88267843Sdelphijif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
89267843Sdelphij  emulate sh
90267843Sdelphij  NULLCMD=:
91267843Sdelphij  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
92267843Sdelphij  # is contrary to our usage.  Disable this feature.
93267843Sdelphij  alias -g '${1+"$@"}'='"$@"'
94267843Sdelphij  setopt NO_GLOB_SUBST
95267843Sdelphijelse
96267843Sdelphij  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
97267843Sdelphijfi
98267843SdelphijBIN_SH=xpg4; export BIN_SH # for Tru64
99267843SdelphijDUALCASE=1; export DUALCASE # for MKS sh
100267843Sdelphij
101267843Sdelphij# A function that is used when there is no print builtin or printf.
102267843Sdelphijfunc_fallback_echo ()
103267843Sdelphij{
104267843Sdelphij  eval 'cat <<_LTECHO_EOF
105267843Sdelphij$1
106267843Sdelphij_LTECHO_EOF'
107267843Sdelphij}
108267843Sdelphij
109267843Sdelphij# NLS nuisances: We save the old values to restore during execute mode.
110267843Sdelphijlt_user_locale=
111267843Sdelphijlt_safe_locale=
112267843Sdelphijfor lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
113267843Sdelphijdo
114267843Sdelphij  eval "if test \"\${$lt_var+set}\" = set; then
115267843Sdelphij          save_$lt_var=\$$lt_var
116267843Sdelphij          $lt_var=C
117267843Sdelphij	  export $lt_var
118267843Sdelphij	  lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\"
119267843Sdelphij	  lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
120267843Sdelphij	fi"
121267843Sdelphijdone
122267843SdelphijLC_ALL=C
123267843SdelphijLANGUAGE=C
124267843Sdelphijexport LANGUAGE LC_ALL
125267843Sdelphij
126267843Sdelphij$lt_unset CDPATH
127267843Sdelphij
128267843Sdelphij
129267843Sdelphij# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
130267843Sdelphij# is ksh but when the shell is invoked as "sh" and the current value of
131267843Sdelphij# the _XPG environment variable is not equal to 1 (one), the special
132267843Sdelphij# positional parameter $0, within a function call, is the name of the
133267843Sdelphij# function.
134267843Sdelphijprogpath="$0"
135267843Sdelphij
136267843Sdelphijunset CP
137267843Sdelphijunset MV
138267843Sdelphijunset RM
139267843Sdelphij: ${CP="cp -f"}
140267843Sdelphijtest "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'}
141267843Sdelphij: ${MAKE="make"}
142267843Sdelphij: ${MKDIR="mkdir"}
143267843Sdelphij: ${MV="mv -f"}
144267843Sdelphij: ${RM="rm -f"}
145267843Sdelphij: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
146267843Sdelphij: ${Xsed="$SED -e 1s/^X//"}
147267843Sdelphij
148267843Sdelphij# Global variables:
149267843SdelphijEXIT_SUCCESS=0
150267843SdelphijEXIT_FAILURE=1
151267843SdelphijEXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
152267843SdelphijEXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
153267843Sdelphij
154267843Sdelphijexit_status=$EXIT_SUCCESS
155267843Sdelphij
156267843Sdelphij# Make sure IFS has a sensible default
157267843Sdelphijlt_nl='
158267843Sdelphij'
159267843SdelphijIFS=" 	$lt_nl"
160267843Sdelphij
161267843Sdelphijdirname="s,/[^/]*$,,"
162267843Sdelphijbasename="s,^.*/,,"
163267843Sdelphij
164267843Sdelphij# func_dirname file append nondir_replacement
165267843Sdelphij# Compute the dirname of FILE.  If nonempty, add APPEND to the result,
166267843Sdelphij# otherwise set result to NONDIR_REPLACEMENT.
167267843Sdelphijfunc_dirname ()
168267843Sdelphij{
169267843Sdelphij    func_dirname_result=`$ECHO "${1}" | $SED "$dirname"`
170267843Sdelphij    if test "X$func_dirname_result" = "X${1}"; then
171267843Sdelphij      func_dirname_result="${3}"
172267843Sdelphij    else
173267843Sdelphij      func_dirname_result="$func_dirname_result${2}"
174267843Sdelphij    fi
175267843Sdelphij} # func_dirname may be replaced by extended shell implementation
176267843Sdelphij
177267843Sdelphij
178267843Sdelphij# func_basename file
179267843Sdelphijfunc_basename ()
180267843Sdelphij{
181267843Sdelphij    func_basename_result=`$ECHO "${1}" | $SED "$basename"`
182267843Sdelphij} # func_basename may be replaced by extended shell implementation
183267843Sdelphij
184267843Sdelphij
185267843Sdelphij# func_dirname_and_basename file append nondir_replacement
186267843Sdelphij# perform func_basename and func_dirname in a single function
187267843Sdelphij# call:
188267843Sdelphij#   dirname:  Compute the dirname of FILE.  If nonempty,
189267843Sdelphij#             add APPEND to the result, otherwise set result
190267843Sdelphij#             to NONDIR_REPLACEMENT.
191267843Sdelphij#             value returned in "$func_dirname_result"
192267843Sdelphij#   basename: Compute filename of FILE.
193267843Sdelphij#             value retuned in "$func_basename_result"
194267843Sdelphij# Implementation must be kept synchronized with func_dirname
195267843Sdelphij# and func_basename. For efficiency, we do not delegate to
196267843Sdelphij# those functions but instead duplicate the functionality here.
197267843Sdelphijfunc_dirname_and_basename ()
198267843Sdelphij{
199267843Sdelphij    # Extract subdirectory from the argument.
200267843Sdelphij    func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"`
201267843Sdelphij    if test "X$func_dirname_result" = "X${1}"; then
202267843Sdelphij      func_dirname_result="${3}"
203267843Sdelphij    else
204267843Sdelphij      func_dirname_result="$func_dirname_result${2}"
205267843Sdelphij    fi
206267843Sdelphij    func_basename_result=`$ECHO "${1}" | $SED -e "$basename"`
207267843Sdelphij} # func_dirname_and_basename may be replaced by extended shell implementation
208267843Sdelphij
209267843Sdelphij
210267843Sdelphij# func_stripname prefix suffix name
211267843Sdelphij# strip PREFIX and SUFFIX off of NAME.
212267843Sdelphij# PREFIX and SUFFIX must not contain globbing or regex special
213267843Sdelphij# characters, hashes, percent signs, but SUFFIX may contain a leading
214267843Sdelphij# dot (in which case that matches only a dot).
215267843Sdelphij# func_strip_suffix prefix name
216267843Sdelphijfunc_stripname ()
217267843Sdelphij{
218267843Sdelphij    case ${2} in
219267843Sdelphij      .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;;
220267843Sdelphij      *)  func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;;
221267843Sdelphij    esac
222267843Sdelphij} # func_stripname may be replaced by extended shell implementation
223267843Sdelphij
224267843Sdelphij
225267843Sdelphij# These SED scripts presuppose an absolute path with a trailing slash.
226267843Sdelphijpathcar='s,^/\([^/]*\).*$,\1,'
227267843Sdelphijpathcdr='s,^/[^/]*,,'
228267843Sdelphijremovedotparts=':dotsl
229267843Sdelphij		s@/\./@/@g
230267843Sdelphij		t dotsl
231267843Sdelphij		s,/\.$,/,'
232267843Sdelphijcollapseslashes='s@/\{1,\}@/@g'
233267843Sdelphijfinalslash='s,/*$,/,'
234267843Sdelphij
235267843Sdelphij# func_normal_abspath PATH
236267843Sdelphij# Remove doubled-up and trailing slashes, "." path components,
237267843Sdelphij# and cancel out any ".." path components in PATH after making
238267843Sdelphij# it an absolute path.
239267843Sdelphij#             value returned in "$func_normal_abspath_result"
240267843Sdelphijfunc_normal_abspath ()
241267843Sdelphij{
242267843Sdelphij  # Start from root dir and reassemble the path.
243267843Sdelphij  func_normal_abspath_result=
244267843Sdelphij  func_normal_abspath_tpath=$1
245267843Sdelphij  func_normal_abspath_altnamespace=
246267843Sdelphij  case $func_normal_abspath_tpath in
247267843Sdelphij    "")
248267843Sdelphij      # Empty path, that just means $cwd.
249267843Sdelphij      func_stripname '' '/' "`pwd`"
250267843Sdelphij      func_normal_abspath_result=$func_stripname_result
251267843Sdelphij      return
252267843Sdelphij    ;;
253267843Sdelphij    # The next three entries are used to spot a run of precisely
254267843Sdelphij    # two leading slashes without using negated character classes;
255267843Sdelphij    # we take advantage of case's first-match behaviour.
256267843Sdelphij    ///*)
257267843Sdelphij      # Unusual form of absolute path, do nothing.
258267843Sdelphij    ;;
259267843Sdelphij    //*)
260267843Sdelphij      # Not necessarily an ordinary path; POSIX reserves leading '//'
261267843Sdelphij      # and for example Cygwin uses it to access remote file shares
262267843Sdelphij      # over CIFS/SMB, so we conserve a leading double slash if found.
263267843Sdelphij      func_normal_abspath_altnamespace=/
264267843Sdelphij    ;;
265267843Sdelphij    /*)
266267843Sdelphij      # Absolute path, do nothing.
267267843Sdelphij    ;;
268267843Sdelphij    *)
269267843Sdelphij      # Relative path, prepend $cwd.
270267843Sdelphij      func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
271267843Sdelphij    ;;
272267843Sdelphij  esac
273267843Sdelphij  # Cancel out all the simple stuff to save iterations.  We also want
274267843Sdelphij  # the path to end with a slash for ease of parsing, so make sure
275267843Sdelphij  # there is one (and only one) here.
276267843Sdelphij  func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
277267843Sdelphij        -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"`
278267843Sdelphij  while :; do
279267843Sdelphij    # Processed it all yet?
280267843Sdelphij    if test "$func_normal_abspath_tpath" = / ; then
281267843Sdelphij      # If we ascended to the root using ".." the result may be empty now.
282267843Sdelphij      if test -z "$func_normal_abspath_result" ; then
283267843Sdelphij        func_normal_abspath_result=/
284267843Sdelphij      fi
285267843Sdelphij      break
286267843Sdelphij    fi
287267843Sdelphij    func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
288267843Sdelphij        -e "$pathcar"`
289267843Sdelphij    func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
290267843Sdelphij        -e "$pathcdr"`
291267843Sdelphij    # Figure out what to do with it
292267843Sdelphij    case $func_normal_abspath_tcomponent in
293267843Sdelphij      "")
294267843Sdelphij        # Trailing empty path component, ignore it.
295267843Sdelphij      ;;
296267843Sdelphij      ..)
297267843Sdelphij        # Parent dir; strip last assembled component from result.
298267843Sdelphij        func_dirname "$func_normal_abspath_result"
299267843Sdelphij        func_normal_abspath_result=$func_dirname_result
300267843Sdelphij      ;;
301267843Sdelphij      *)
302267843Sdelphij        # Actual path component, append it.
303267843Sdelphij        func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent
304267843Sdelphij      ;;
305267843Sdelphij    esac
306267843Sdelphij  done
307267843Sdelphij  # Restore leading double-slash if one was found on entry.
308267843Sdelphij  func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
309267843Sdelphij}
310267843Sdelphij
311267843Sdelphij# func_relative_path SRCDIR DSTDIR
312267843Sdelphij# generates a relative path from SRCDIR to DSTDIR, with a trailing
313267843Sdelphij# slash if non-empty, suitable for immediately appending a filename
314267843Sdelphij# without needing to append a separator.
315267843Sdelphij#             value returned in "$func_relative_path_result"
316267843Sdelphijfunc_relative_path ()
317267843Sdelphij{
318267843Sdelphij  func_relative_path_result=
319267843Sdelphij  func_normal_abspath "$1"
320267843Sdelphij  func_relative_path_tlibdir=$func_normal_abspath_result
321267843Sdelphij  func_normal_abspath "$2"
322267843Sdelphij  func_relative_path_tbindir=$func_normal_abspath_result
323267843Sdelphij
324267843Sdelphij  # Ascend the tree starting from libdir
325267843Sdelphij  while :; do
326267843Sdelphij    # check if we have found a prefix of bindir
327267843Sdelphij    case $func_relative_path_tbindir in
328267843Sdelphij      $func_relative_path_tlibdir)
329267843Sdelphij        # found an exact match
330267843Sdelphij        func_relative_path_tcancelled=
331267843Sdelphij        break
332267843Sdelphij        ;;
333267843Sdelphij      $func_relative_path_tlibdir*)
334267843Sdelphij        # found a matching prefix
335267843Sdelphij        func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
336267843Sdelphij        func_relative_path_tcancelled=$func_stripname_result
337267843Sdelphij        if test -z "$func_relative_path_result"; then
338267843Sdelphij          func_relative_path_result=.
339267843Sdelphij        fi
340267843Sdelphij        break
341267843Sdelphij        ;;
342267843Sdelphij      *)
343267843Sdelphij        func_dirname $func_relative_path_tlibdir
344267843Sdelphij        func_relative_path_tlibdir=${func_dirname_result}
345267843Sdelphij        if test "x$func_relative_path_tlibdir" = x ; then
346267843Sdelphij          # Have to descend all the way to the root!
347267843Sdelphij          func_relative_path_result=../$func_relative_path_result
348267843Sdelphij          func_relative_path_tcancelled=$func_relative_path_tbindir
349267843Sdelphij          break
350267843Sdelphij        fi
351267843Sdelphij        func_relative_path_result=../$func_relative_path_result
352267843Sdelphij        ;;
353267843Sdelphij    esac
354267843Sdelphij  done
355267843Sdelphij
356267843Sdelphij  # Now calculate path; take care to avoid doubling-up slashes.
357267843Sdelphij  func_stripname '' '/' "$func_relative_path_result"
358267843Sdelphij  func_relative_path_result=$func_stripname_result
359267843Sdelphij  func_stripname '/' '/' "$func_relative_path_tcancelled"
360267843Sdelphij  if test "x$func_stripname_result" != x ; then
361267843Sdelphij    func_relative_path_result=${func_relative_path_result}/${func_stripname_result}
362267843Sdelphij  fi
363267843Sdelphij
364267843Sdelphij  # Normalisation. If bindir is libdir, return empty string,
365267843Sdelphij  # else relative path ending with a slash; either way, target
366267843Sdelphij  # file name can be directly appended.
367267843Sdelphij  if test ! -z "$func_relative_path_result"; then
368267843Sdelphij    func_stripname './' '' "$func_relative_path_result/"
369267843Sdelphij    func_relative_path_result=$func_stripname_result
370267843Sdelphij  fi
371267843Sdelphij}
372267843Sdelphij
373267843Sdelphij# The name of this program:
374267843Sdelphijfunc_dirname_and_basename "$progpath"
375267843Sdelphijprogname=$func_basename_result
376267843Sdelphij
377267843Sdelphij# Make sure we have an absolute path for reexecution:
378267843Sdelphijcase $progpath in
379267843Sdelphij  [\\/]*|[A-Za-z]:\\*) ;;
380267843Sdelphij  *[\\/]*)
381267843Sdelphij     progdir=$func_dirname_result
382267843Sdelphij     progdir=`cd "$progdir" && pwd`
383267843Sdelphij     progpath="$progdir/$progname"
384267843Sdelphij     ;;
385267843Sdelphij  *)
386267843Sdelphij     save_IFS="$IFS"
387267843Sdelphij     IFS=${PATH_SEPARATOR-:}
388267843Sdelphij     for progdir in $PATH; do
389267843Sdelphij       IFS="$save_IFS"
390267843Sdelphij       test -x "$progdir/$progname" && break
391267843Sdelphij     done
392267843Sdelphij     IFS="$save_IFS"
393267843Sdelphij     test -n "$progdir" || progdir=`pwd`
394267843Sdelphij     progpath="$progdir/$progname"
395267843Sdelphij     ;;
396267843Sdelphijesac
397267843Sdelphij
398267843Sdelphij# Sed substitution that helps us do robust quoting.  It backslashifies
399267843Sdelphij# metacharacters that are still active within double-quoted strings.
400267843SdelphijXsed="${SED}"' -e 1s/^X//'
401267843Sdelphijsed_quote_subst='s/\([`"$\\]\)/\\\1/g'
402267843Sdelphij
403267843Sdelphij# Same as above, but do not quote variable references.
404267843Sdelphijdouble_quote_subst='s/\(["`\\]\)/\\\1/g'
405267843Sdelphij
406267843Sdelphij# Sed substitution that turns a string into a regex matching for the
407267843Sdelphij# string literally.
408267843Sdelphijsed_make_literal_regex='s,[].[^$\\*\/],\\&,g'
409267843Sdelphij
410267843Sdelphij# Sed substitution that converts a w32 file name or path
411267843Sdelphij# which contains forward slashes, into one that contains
412267843Sdelphij# (escaped) backslashes.  A very naive implementation.
413267843Sdelphijlt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
414267843Sdelphij
415267843Sdelphij# Re-`\' parameter expansions in output of double_quote_subst that were
416267843Sdelphij# `\'-ed in input to the same.  If an odd number of `\' preceded a '$'
417267843Sdelphij# in input to double_quote_subst, that '$' was protected from expansion.
418267843Sdelphij# Since each input `\' is now two `\'s, look for any number of runs of
419267843Sdelphij# four `\'s followed by two `\'s and then a '$'.  `\' that '$'.
420267843Sdelphijbs='\\'
421267843Sdelphijbs2='\\\\'
422267843Sdelphijbs4='\\\\\\\\'
423267843Sdelphijdollar='\$'
424267843Sdelphijsed_double_backslash="\
425267843Sdelphij  s/$bs4/&\\
426267843Sdelphij/g
427267843Sdelphij  s/^$bs2$dollar/$bs&/
428267843Sdelphij  s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
429267843Sdelphij  s/\n//g"
430267843Sdelphij
431267843Sdelphij# Standard options:
432267843Sdelphijopt_dry_run=false
433267843Sdelphijopt_help=false
434267843Sdelphijopt_quiet=false
435267843Sdelphijopt_verbose=false
436267843Sdelphijopt_warning=:
437267843Sdelphij
438267843Sdelphij# func_echo arg...
439267843Sdelphij# Echo program name prefixed message, along with the current mode
440267843Sdelphij# name if it has been set yet.
441267843Sdelphijfunc_echo ()
442267843Sdelphij{
443267843Sdelphij    $ECHO "$progname: ${opt_mode+$opt_mode: }$*"
444267843Sdelphij}
445267843Sdelphij
446267843Sdelphij# func_verbose arg...
447267843Sdelphij# Echo program name prefixed message in verbose mode only.
448267843Sdelphijfunc_verbose ()
449267843Sdelphij{
450267843Sdelphij    $opt_verbose && func_echo ${1+"$@"}
451267843Sdelphij
452267843Sdelphij    # A bug in bash halts the script if the last line of a function
453267843Sdelphij    # fails when set -e is in force, so we need another command to
454267843Sdelphij    # work around that:
455267843Sdelphij    :
456267843Sdelphij}
457267843Sdelphij
458267843Sdelphij# func_echo_all arg...
459267843Sdelphij# Invoke $ECHO with all args, space-separated.
460267843Sdelphijfunc_echo_all ()
461267843Sdelphij{
462267843Sdelphij    $ECHO "$*"
463267843Sdelphij}
464267843Sdelphij
465267843Sdelphij# func_error arg...
466267843Sdelphij# Echo program name prefixed message to standard error.
467267843Sdelphijfunc_error ()
468267843Sdelphij{
469267843Sdelphij    $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2
470267843Sdelphij}
471267843Sdelphij
472267843Sdelphij# func_warning arg...
473267843Sdelphij# Echo program name prefixed warning message to standard error.
474267843Sdelphijfunc_warning ()
475267843Sdelphij{
476267843Sdelphij    $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2
477267843Sdelphij
478267843Sdelphij    # bash bug again:
479267843Sdelphij    :
480267843Sdelphij}
481267843Sdelphij
482267843Sdelphij# func_fatal_error arg...
483267843Sdelphij# Echo program name prefixed message to standard error, and exit.
484267843Sdelphijfunc_fatal_error ()
485267843Sdelphij{
486267843Sdelphij    func_error ${1+"$@"}
487267843Sdelphij    exit $EXIT_FAILURE
488267843Sdelphij}
489267843Sdelphij
490267843Sdelphij# func_fatal_help arg...
491267843Sdelphij# Echo program name prefixed message to standard error, followed by
492267843Sdelphij# a help hint, and exit.
493267843Sdelphijfunc_fatal_help ()
494267843Sdelphij{
495267843Sdelphij    func_error ${1+"$@"}
496267843Sdelphij    func_fatal_error "$help"
497267843Sdelphij}
498267843Sdelphijhelp="Try \`$progname --help' for more information."  ## default
499267843Sdelphij
500267843Sdelphij
501267843Sdelphij# func_grep expression filename
502267843Sdelphij# Check whether EXPRESSION matches any line of FILENAME, without output.
503267843Sdelphijfunc_grep ()
504267843Sdelphij{
505267843Sdelphij    $GREP "$1" "$2" >/dev/null 2>&1
506267843Sdelphij}
507267843Sdelphij
508267843Sdelphij
509267843Sdelphij# func_mkdir_p directory-path
510267843Sdelphij# Make sure the entire path to DIRECTORY-PATH is available.
511267843Sdelphijfunc_mkdir_p ()
512267843Sdelphij{
513267843Sdelphij    my_directory_path="$1"
514267843Sdelphij    my_dir_list=
515267843Sdelphij
516267843Sdelphij    if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
517267843Sdelphij
518267843Sdelphij      # Protect directory names starting with `-'
519267843Sdelphij      case $my_directory_path in
520267843Sdelphij        -*) my_directory_path="./$my_directory_path" ;;
521267843Sdelphij      esac
522267843Sdelphij
523267843Sdelphij      # While some portion of DIR does not yet exist...
524267843Sdelphij      while test ! -d "$my_directory_path"; do
525267843Sdelphij        # ...make a list in topmost first order.  Use a colon delimited
526267843Sdelphij	# list incase some portion of path contains whitespace.
527267843Sdelphij        my_dir_list="$my_directory_path:$my_dir_list"
528267843Sdelphij
529267843Sdelphij        # If the last portion added has no slash in it, the list is done
530267843Sdelphij        case $my_directory_path in */*) ;; *) break ;; esac
531267843Sdelphij
532267843Sdelphij        # ...otherwise throw away the child directory and loop
533267843Sdelphij        my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"`
534267843Sdelphij      done
535267843Sdelphij      my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'`
536267843Sdelphij
537267843Sdelphij      save_mkdir_p_IFS="$IFS"; IFS=':'
538267843Sdelphij      for my_dir in $my_dir_list; do
539267843Sdelphij	IFS="$save_mkdir_p_IFS"
540267843Sdelphij        # mkdir can fail with a `File exist' error if two processes
541267843Sdelphij        # try to create one of the directories concurrently.  Don't
542267843Sdelphij        # stop in that case!
543267843Sdelphij        $MKDIR "$my_dir" 2>/dev/null || :
544267843Sdelphij      done
545267843Sdelphij      IFS="$save_mkdir_p_IFS"
546267843Sdelphij
547267843Sdelphij      # Bail out if we (or some other process) failed to create a directory.
548267843Sdelphij      test -d "$my_directory_path" || \
549267843Sdelphij        func_fatal_error "Failed to create \`$1'"
550267843Sdelphij    fi
551267843Sdelphij}
552267843Sdelphij
553267843Sdelphij
554267843Sdelphij# func_mktempdir [string]
555267843Sdelphij# Make a temporary directory that won't clash with other running
556267843Sdelphij# libtool processes, and avoids race conditions if possible.  If
557267843Sdelphij# given, STRING is the basename for that directory.
558267843Sdelphijfunc_mktempdir ()
559267843Sdelphij{
560267843Sdelphij    my_template="${TMPDIR-/tmp}/${1-$progname}"
561267843Sdelphij
562267843Sdelphij    if test "$opt_dry_run" = ":"; then
563267843Sdelphij      # Return a directory name, but don't create it in dry-run mode
564267843Sdelphij      my_tmpdir="${my_template}-$$"
565267843Sdelphij    else
566267843Sdelphij
567267843Sdelphij      # If mktemp works, use that first and foremost
568267843Sdelphij      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
569267843Sdelphij
570267843Sdelphij      if test ! -d "$my_tmpdir"; then
571267843Sdelphij        # Failing that, at least try and use $RANDOM to avoid a race
572267843Sdelphij        my_tmpdir="${my_template}-${RANDOM-0}$$"
573267843Sdelphij
574267843Sdelphij        save_mktempdir_umask=`umask`
575267843Sdelphij        umask 0077
576267843Sdelphij        $MKDIR "$my_tmpdir"
577267843Sdelphij        umask $save_mktempdir_umask
578267843Sdelphij      fi
579267843Sdelphij
580267843Sdelphij      # If we're not in dry-run mode, bomb out on failure
581267843Sdelphij      test -d "$my_tmpdir" || \
582267843Sdelphij        func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
583267843Sdelphij    fi
584267843Sdelphij
585267843Sdelphij    $ECHO "$my_tmpdir"
586267843Sdelphij}
587267843Sdelphij
588267843Sdelphij
589267843Sdelphij# func_quote_for_eval arg
590267843Sdelphij# Aesthetically quote ARG to be evaled later.
591267843Sdelphij# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
592267843Sdelphij# is double-quoted, suitable for a subsequent eval, whereas
593267843Sdelphij# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
594267843Sdelphij# which are still active within double quotes backslashified.
595267843Sdelphijfunc_quote_for_eval ()
596267843Sdelphij{
597267843Sdelphij    case $1 in
598267843Sdelphij      *[\\\`\"\$]*)
599267843Sdelphij	func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;;
600267843Sdelphij      *)
601267843Sdelphij        func_quote_for_eval_unquoted_result="$1" ;;
602267843Sdelphij    esac
603267843Sdelphij
604267843Sdelphij    case $func_quote_for_eval_unquoted_result in
605267843Sdelphij      # Double-quote args containing shell metacharacters to delay
606267843Sdelphij      # word splitting, command substitution and and variable
607267843Sdelphij      # expansion for a subsequent eval.
608267843Sdelphij      # Many Bourne shells cannot handle close brackets correctly
609267843Sdelphij      # in scan sets, so we specify it separately.
610267843Sdelphij      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
611267843Sdelphij        func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
612267843Sdelphij        ;;
613267843Sdelphij      *)
614267843Sdelphij        func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
615267843Sdelphij    esac
616267843Sdelphij}
617267843Sdelphij
618267843Sdelphij
619267843Sdelphij# func_quote_for_expand arg
620267843Sdelphij# Aesthetically quote ARG to be evaled later; same as above,
621267843Sdelphij# but do not quote variable references.
622267843Sdelphijfunc_quote_for_expand ()
623267843Sdelphij{
624267843Sdelphij    case $1 in
625267843Sdelphij      *[\\\`\"]*)
626267843Sdelphij	my_arg=`$ECHO "$1" | $SED \
627267843Sdelphij	    -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
628267843Sdelphij      *)
629267843Sdelphij        my_arg="$1" ;;
630267843Sdelphij    esac
631267843Sdelphij
632267843Sdelphij    case $my_arg in
633267843Sdelphij      # Double-quote args containing shell metacharacters to delay
634267843Sdelphij      # word splitting and command substitution for a subsequent eval.
635267843Sdelphij      # Many Bourne shells cannot handle close brackets correctly
636267843Sdelphij      # in scan sets, so we specify it separately.
637267843Sdelphij      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
638267843Sdelphij        my_arg="\"$my_arg\""
639267843Sdelphij        ;;
640267843Sdelphij    esac
641267843Sdelphij
642267843Sdelphij    func_quote_for_expand_result="$my_arg"
643267843Sdelphij}
644267843Sdelphij
645267843Sdelphij
646267843Sdelphij# func_show_eval cmd [fail_exp]
647267843Sdelphij# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
648267843Sdelphij# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
649267843Sdelphij# is given, then evaluate it.
650267843Sdelphijfunc_show_eval ()
651267843Sdelphij{
652267843Sdelphij    my_cmd="$1"
653267843Sdelphij    my_fail_exp="${2-:}"
654267843Sdelphij
655267843Sdelphij    ${opt_silent-false} || {
656267843Sdelphij      func_quote_for_expand "$my_cmd"
657267843Sdelphij      eval "func_echo $func_quote_for_expand_result"
658267843Sdelphij    }
659267843Sdelphij
660267843Sdelphij    if ${opt_dry_run-false}; then :; else
661267843Sdelphij      eval "$my_cmd"
662267843Sdelphij      my_status=$?
663267843Sdelphij      if test "$my_status" -eq 0; then :; else
664267843Sdelphij	eval "(exit $my_status); $my_fail_exp"
665267843Sdelphij      fi
666267843Sdelphij    fi
667267843Sdelphij}
668267843Sdelphij
669267843Sdelphij
670267843Sdelphij# func_show_eval_locale cmd [fail_exp]
671267843Sdelphij# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
672267843Sdelphij# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
673267843Sdelphij# is given, then evaluate it.  Use the saved locale for evaluation.
674267843Sdelphijfunc_show_eval_locale ()
675267843Sdelphij{
676267843Sdelphij    my_cmd="$1"
677267843Sdelphij    my_fail_exp="${2-:}"
678267843Sdelphij
679267843Sdelphij    ${opt_silent-false} || {
680267843Sdelphij      func_quote_for_expand "$my_cmd"
681267843Sdelphij      eval "func_echo $func_quote_for_expand_result"
682267843Sdelphij    }
683267843Sdelphij
684267843Sdelphij    if ${opt_dry_run-false}; then :; else
685267843Sdelphij      eval "$lt_user_locale
686267843Sdelphij	    $my_cmd"
687267843Sdelphij      my_status=$?
688267843Sdelphij      eval "$lt_safe_locale"
689267843Sdelphij      if test "$my_status" -eq 0; then :; else
690267843Sdelphij	eval "(exit $my_status); $my_fail_exp"
691267843Sdelphij      fi
692267843Sdelphij    fi
693267843Sdelphij}
694267843Sdelphij
695267843Sdelphij# func_tr_sh
696267843Sdelphij# Turn $1 into a string suitable for a shell variable name.
697267843Sdelphij# Result is stored in $func_tr_sh_result.  All characters
698267843Sdelphij# not in the set a-zA-Z0-9_ are replaced with '_'. Further,
699267843Sdelphij# if $1 begins with a digit, a '_' is prepended as well.
700267843Sdelphijfunc_tr_sh ()
701267843Sdelphij{
702267843Sdelphij  case $1 in
703267843Sdelphij  [0-9]* | *[!a-zA-Z0-9_]*)
704267843Sdelphij    func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'`
705267843Sdelphij    ;;
706267843Sdelphij  * )
707267843Sdelphij    func_tr_sh_result=$1
708267843Sdelphij    ;;
709267843Sdelphij  esac
710267843Sdelphij}
711267843Sdelphij
712267843Sdelphij
713267843Sdelphij# func_version
714267843Sdelphij# Echo version message to standard output and exit.
715267843Sdelphijfunc_version ()
716267843Sdelphij{
717267843Sdelphij    $opt_debug
718267843Sdelphij
719267843Sdelphij    $SED -n '/(C)/!b go
720267843Sdelphij	:more
721267843Sdelphij	/\./!{
722267843Sdelphij	  N
723267843Sdelphij	  s/\n# / /
724267843Sdelphij	  b more
725267843Sdelphij	}
726267843Sdelphij	:go
727267843Sdelphij	/^# '$PROGRAM' (GNU /,/# warranty; / {
728267843Sdelphij        s/^# //
729267843Sdelphij	s/^# *$//
730267843Sdelphij        s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
731267843Sdelphij        p
732267843Sdelphij     }' < "$progpath"
733267843Sdelphij     exit $?
734267843Sdelphij}
735267843Sdelphij
736267843Sdelphij# func_usage
737267843Sdelphij# Echo short help message to standard output and exit.
738267843Sdelphijfunc_usage ()
739267843Sdelphij{
740267843Sdelphij    $opt_debug
741267843Sdelphij
742267843Sdelphij    $SED -n '/^# Usage:/,/^#  *.*--help/ {
743267843Sdelphij        s/^# //
744267843Sdelphij	s/^# *$//
745267843Sdelphij	s/\$progname/'$progname'/
746267843Sdelphij	p
747267843Sdelphij    }' < "$progpath"
748267843Sdelphij    echo
749267843Sdelphij    $ECHO "run \`$progname --help | more' for full usage"
750267843Sdelphij    exit $?
751267843Sdelphij}
752267843Sdelphij
753267843Sdelphij# func_help [NOEXIT]
754267843Sdelphij# Echo long help message to standard output and exit,
755267843Sdelphij# unless 'noexit' is passed as argument.
756267843Sdelphijfunc_help ()
757267843Sdelphij{
758267843Sdelphij    $opt_debug
759267843Sdelphij
760267843Sdelphij    $SED -n '/^# Usage:/,/# Report bugs to/ {
761267843Sdelphij	:print
762267843Sdelphij        s/^# //
763267843Sdelphij	s/^# *$//
764267843Sdelphij	s*\$progname*'$progname'*
765267843Sdelphij	s*\$host*'"$host"'*
766267843Sdelphij	s*\$SHELL*'"$SHELL"'*
767267843Sdelphij	s*\$LTCC*'"$LTCC"'*
768267843Sdelphij	s*\$LTCFLAGS*'"$LTCFLAGS"'*
769267843Sdelphij	s*\$LD*'"$LD"'*
770267843Sdelphij	s/\$with_gnu_ld/'"$with_gnu_ld"'/
771267843Sdelphij	s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/
772267843Sdelphij	s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/
773267843Sdelphij	p
774267843Sdelphij	d
775267843Sdelphij     }
776267843Sdelphij     /^# .* home page:/b print
777267843Sdelphij     /^# General help using/b print
778267843Sdelphij     ' < "$progpath"
779267843Sdelphij    ret=$?
780267843Sdelphij    if test -z "$1"; then
781267843Sdelphij      exit $ret
782267843Sdelphij    fi
783267843Sdelphij}
784267843Sdelphij
785267843Sdelphij# func_missing_arg argname
786267843Sdelphij# Echo program name prefixed message to standard error and set global
787267843Sdelphij# exit_cmd.
788267843Sdelphijfunc_missing_arg ()
789267843Sdelphij{
790267843Sdelphij    $opt_debug
791267843Sdelphij
792267843Sdelphij    func_error "missing argument for $1."
793267843Sdelphij    exit_cmd=exit
794267843Sdelphij}
795267843Sdelphij
796267843Sdelphij
797267843Sdelphij# func_split_short_opt shortopt
798267843Sdelphij# Set func_split_short_opt_name and func_split_short_opt_arg shell
799267843Sdelphij# variables after splitting SHORTOPT after the 2nd character.
800267843Sdelphijfunc_split_short_opt ()
801267843Sdelphij{
802267843Sdelphij    my_sed_short_opt='1s/^\(..\).*$/\1/;q'
803267843Sdelphij    my_sed_short_rest='1s/^..\(.*\)$/\1/;q'
804267843Sdelphij
805267843Sdelphij    func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"`
806267843Sdelphij    func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"`
807267843Sdelphij} # func_split_short_opt may be replaced by extended shell implementation
808267843Sdelphij
809267843Sdelphij
810267843Sdelphij# func_split_long_opt longopt
811267843Sdelphij# Set func_split_long_opt_name and func_split_long_opt_arg shell
812267843Sdelphij# variables after splitting LONGOPT at the `=' sign.
813267843Sdelphijfunc_split_long_opt ()
814267843Sdelphij{
815267843Sdelphij    my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q'
816267843Sdelphij    my_sed_long_arg='1s/^--[^=]*=//'
817267843Sdelphij
818267843Sdelphij    func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"`
819267843Sdelphij    func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"`
820267843Sdelphij} # func_split_long_opt may be replaced by extended shell implementation
821267843Sdelphij
822267843Sdelphijexit_cmd=:
823267843Sdelphij
824267843Sdelphij
825267843Sdelphij
826267843Sdelphij
827267843Sdelphij
828267843Sdelphijmagic="%%%MAGIC variable%%%"
829267843Sdelphijmagic_exe="%%%MAGIC EXE variable%%%"
830267843Sdelphij
831267843Sdelphij# Global variables.
832267843Sdelphijnonopt=
833267843Sdelphijpreserve_args=
834267843Sdelphijlo2o="s/\\.lo\$/.${objext}/"
835267843Sdelphijo2lo="s/\\.${objext}\$/.lo/"
836267843Sdelphijextracted_archives=
837267843Sdelphijextracted_serial=0
838267843Sdelphij
839267843Sdelphij# If this variable is set in any of the actions, the command in it
840267843Sdelphij# will be execed at the end.  This prevents here-documents from being
841267843Sdelphij# left over by shells.
842267843Sdelphijexec_cmd=
843267843Sdelphij
844267843Sdelphij# func_append var value
845267843Sdelphij# Append VALUE to the end of shell variable VAR.
846267843Sdelphijfunc_append ()
847267843Sdelphij{
848267843Sdelphij    eval "${1}=\$${1}\${2}"
849267843Sdelphij} # func_append may be replaced by extended shell implementation
850267843Sdelphij
851267843Sdelphij# func_append_quoted var value
852267843Sdelphij# Quote VALUE and append to the end of shell variable VAR, separated
853267843Sdelphij# by a space.
854267843Sdelphijfunc_append_quoted ()
855267843Sdelphij{
856267843Sdelphij    func_quote_for_eval "${2}"
857267843Sdelphij    eval "${1}=\$${1}\\ \$func_quote_for_eval_result"
858267843Sdelphij} # func_append_quoted may be replaced by extended shell implementation
859267843Sdelphij
860267843Sdelphij
861267843Sdelphij# func_arith arithmetic-term...
862267843Sdelphijfunc_arith ()
863267843Sdelphij{
864267843Sdelphij    func_arith_result=`expr "${@}"`
865267843Sdelphij} # func_arith may be replaced by extended shell implementation
866267843Sdelphij
867267843Sdelphij
868267843Sdelphij# func_len string
869267843Sdelphij# STRING may not start with a hyphen.
870267843Sdelphijfunc_len ()
871267843Sdelphij{
872267843Sdelphij    func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len`
873267843Sdelphij} # func_len may be replaced by extended shell implementation
874267843Sdelphij
875267843Sdelphij
876267843Sdelphij# func_lo2o object
877267843Sdelphijfunc_lo2o ()
878267843Sdelphij{
879267843Sdelphij    func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"`
880267843Sdelphij} # func_lo2o may be replaced by extended shell implementation
881267843Sdelphij
882267843Sdelphij
883267843Sdelphij# func_xform libobj-or-source
884267843Sdelphijfunc_xform ()
885267843Sdelphij{
886267843Sdelphij    func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'`
887267843Sdelphij} # func_xform may be replaced by extended shell implementation
888267843Sdelphij
889267843Sdelphij
890267843Sdelphij# func_fatal_configuration arg...
891267843Sdelphij# Echo program name prefixed message to standard error, followed by
892267843Sdelphij# a configuration failure hint, and exit.
893267843Sdelphijfunc_fatal_configuration ()
894267843Sdelphij{
895267843Sdelphij    func_error ${1+"$@"}
896267843Sdelphij    func_error "See the $PACKAGE documentation for more information."
897267843Sdelphij    func_fatal_error "Fatal configuration error."
898267843Sdelphij}
899267843Sdelphij
900267843Sdelphij
901267843Sdelphij# func_config
902267843Sdelphij# Display the configuration for all the tags in this script.
903267843Sdelphijfunc_config ()
904267843Sdelphij{
905267843Sdelphij    re_begincf='^# ### BEGIN LIBTOOL'
906267843Sdelphij    re_endcf='^# ### END LIBTOOL'
907267843Sdelphij
908267843Sdelphij    # Default configuration.
909267843Sdelphij    $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
910267843Sdelphij
911267843Sdelphij    # Now print the configurations for the tags.
912267843Sdelphij    for tagname in $taglist; do
913267843Sdelphij      $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
914267843Sdelphij    done
915267843Sdelphij
916267843Sdelphij    exit $?
917267843Sdelphij}
918267843Sdelphij
919267843Sdelphij# func_features
920267843Sdelphij# Display the features supported by this script.
921267843Sdelphijfunc_features ()
922267843Sdelphij{
923267843Sdelphij    echo "host: $host"
924267843Sdelphij    if test "$build_libtool_libs" = yes; then
925267843Sdelphij      echo "enable shared libraries"
926267843Sdelphij    else
927267843Sdelphij      echo "disable shared libraries"
928267843Sdelphij    fi
929267843Sdelphij    if test "$build_old_libs" = yes; then
930267843Sdelphij      echo "enable static libraries"
931267843Sdelphij    else
932267843Sdelphij      echo "disable static libraries"
933267843Sdelphij    fi
934267843Sdelphij
935267843Sdelphij    exit $?
936267843Sdelphij}
937267843Sdelphij
938267843Sdelphij# func_enable_tag tagname
939267843Sdelphij# Verify that TAGNAME is valid, and either flag an error and exit, or
940267843Sdelphij# enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
941267843Sdelphij# variable here.
942267843Sdelphijfunc_enable_tag ()
943267843Sdelphij{
944267843Sdelphij  # Global variable:
945267843Sdelphij  tagname="$1"
946267843Sdelphij
947267843Sdelphij  re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
948267843Sdelphij  re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
949267843Sdelphij  sed_extractcf="/$re_begincf/,/$re_endcf/p"
950267843Sdelphij
951267843Sdelphij  # Validate tagname.
952267843Sdelphij  case $tagname in
953267843Sdelphij    *[!-_A-Za-z0-9,/]*)
954267843Sdelphij      func_fatal_error "invalid tag name: $tagname"
955267843Sdelphij      ;;
956267843Sdelphij  esac
957267843Sdelphij
958267843Sdelphij  # Don't test for the "default" C tag, as we know it's
959267843Sdelphij  # there but not specially marked.
960267843Sdelphij  case $tagname in
961267843Sdelphij    CC) ;;
962267843Sdelphij    *)
963267843Sdelphij      if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
964267843Sdelphij	taglist="$taglist $tagname"
965267843Sdelphij
966267843Sdelphij	# Evaluate the configuration.  Be careful to quote the path
967267843Sdelphij	# and the sed script, to avoid splitting on whitespace, but
968267843Sdelphij	# also don't use non-portable quotes within backquotes within
969267843Sdelphij	# quotes we have to do it in 2 steps:
970267843Sdelphij	extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
971267843Sdelphij	eval "$extractedcf"
972267843Sdelphij      else
973267843Sdelphij	func_error "ignoring unknown tag $tagname"
974267843Sdelphij      fi
975267843Sdelphij      ;;
976267843Sdelphij  esac
977267843Sdelphij}
978267843Sdelphij
979267843Sdelphij# func_check_version_match
980267843Sdelphij# Ensure that we are using m4 macros, and libtool script from the same
981267843Sdelphij# release of libtool.
982267843Sdelphijfunc_check_version_match ()
983267843Sdelphij{
984267843Sdelphij  if test "$package_revision" != "$macro_revision"; then
985267843Sdelphij    if test "$VERSION" != "$macro_version"; then
986267843Sdelphij      if test -z "$macro_version"; then
987267843Sdelphij        cat >&2 <<_LT_EOF
988267843Sdelphij$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
989267843Sdelphij$progname: definition of this LT_INIT comes from an older release.
990267843Sdelphij$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
991267843Sdelphij$progname: and run autoconf again.
992267843Sdelphij_LT_EOF
993267843Sdelphij      else
994267843Sdelphij        cat >&2 <<_LT_EOF
995267843Sdelphij$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
996267843Sdelphij$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
997267843Sdelphij$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
998267843Sdelphij$progname: and run autoconf again.
999267843Sdelphij_LT_EOF
1000267843Sdelphij      fi
1001267843Sdelphij    else
1002267843Sdelphij      cat >&2 <<_LT_EOF
1003267843Sdelphij$progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
1004267843Sdelphij$progname: but the definition of this LT_INIT comes from revision $macro_revision.
1005267843Sdelphij$progname: You should recreate aclocal.m4 with macros from revision $package_revision
1006267843Sdelphij$progname: of $PACKAGE $VERSION and run autoconf again.
1007267843Sdelphij_LT_EOF
1008267843Sdelphij    fi
1009267843Sdelphij
1010267843Sdelphij    exit $EXIT_MISMATCH
1011267843Sdelphij  fi
1012267843Sdelphij}
1013267843Sdelphij
1014267843Sdelphij
1015267843Sdelphij# Shorthand for --mode=foo, only valid as the first argument
1016267843Sdelphijcase $1 in
1017267843Sdelphijclean|clea|cle|cl)
1018267843Sdelphij  shift; set dummy --mode clean ${1+"$@"}; shift
1019267843Sdelphij  ;;
1020267843Sdelphijcompile|compil|compi|comp|com|co|c)
1021267843Sdelphij  shift; set dummy --mode compile ${1+"$@"}; shift
1022267843Sdelphij  ;;
1023267843Sdelphijexecute|execut|execu|exec|exe|ex|e)
1024267843Sdelphij  shift; set dummy --mode execute ${1+"$@"}; shift
1025267843Sdelphij  ;;
1026267843Sdelphijfinish|finis|fini|fin|fi|f)
1027267843Sdelphij  shift; set dummy --mode finish ${1+"$@"}; shift
1028267843Sdelphij  ;;
1029267843Sdelphijinstall|instal|insta|inst|ins|in|i)
1030267843Sdelphij  shift; set dummy --mode install ${1+"$@"}; shift
1031267843Sdelphij  ;;
1032267843Sdelphijlink|lin|li|l)
1033267843Sdelphij  shift; set dummy --mode link ${1+"$@"}; shift
1034267843Sdelphij  ;;
1035267843Sdelphijuninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
1036267843Sdelphij  shift; set dummy --mode uninstall ${1+"$@"}; shift
1037267843Sdelphij  ;;
1038267843Sdelphijesac
1039267843Sdelphij
1040267843Sdelphij
1041267843Sdelphij
1042267843Sdelphij# Option defaults:
1043267843Sdelphijopt_debug=:
1044267843Sdelphijopt_dry_run=false
1045267843Sdelphijopt_config=false
1046267843Sdelphijopt_preserve_dup_deps=false
1047267843Sdelphijopt_features=false
1048267843Sdelphijopt_finish=false
1049267843Sdelphijopt_help=false
1050267843Sdelphijopt_help_all=false
1051267843Sdelphijopt_silent=:
1052267843Sdelphijopt_warning=:
1053267843Sdelphijopt_verbose=:
1054267843Sdelphijopt_silent=false
1055267843Sdelphijopt_verbose=false
1056267843Sdelphij
1057267843Sdelphij
1058267843Sdelphij# Parse options once, thoroughly.  This comes as soon as possible in the
1059267843Sdelphij# script to make things like `--version' happen as quickly as we can.
1060267843Sdelphij{
1061267843Sdelphij  # this just eases exit handling
1062267843Sdelphij  while test $# -gt 0; do
1063267843Sdelphij    opt="$1"
1064267843Sdelphij    shift
1065267843Sdelphij    case $opt in
1066267843Sdelphij      --debug|-x)	opt_debug='set -x'
1067267843Sdelphij			func_echo "enabling shell trace mode"
1068267843Sdelphij			$opt_debug
1069267843Sdelphij			;;
1070267843Sdelphij      --dry-run|--dryrun|-n)
1071267843Sdelphij			opt_dry_run=:
1072267843Sdelphij			;;
1073267843Sdelphij      --config)
1074267843Sdelphij			opt_config=:
1075267843Sdelphijfunc_config
1076267843Sdelphij			;;
1077267843Sdelphij      --dlopen|-dlopen)
1078267843Sdelphij			optarg="$1"
1079267843Sdelphij			opt_dlopen="${opt_dlopen+$opt_dlopen
1080267843Sdelphij}$optarg"
1081267843Sdelphij			shift
1082267843Sdelphij			;;
1083267843Sdelphij      --preserve-dup-deps)
1084267843Sdelphij			opt_preserve_dup_deps=:
1085267843Sdelphij			;;
1086267843Sdelphij      --features)
1087267843Sdelphij			opt_features=:
1088267843Sdelphijfunc_features
1089267843Sdelphij			;;
1090267843Sdelphij      --finish)
1091267843Sdelphij			opt_finish=:
1092267843Sdelphijset dummy --mode finish ${1+"$@"}; shift
1093267843Sdelphij			;;
1094267843Sdelphij      --help)
1095267843Sdelphij			opt_help=:
1096267843Sdelphij			;;
1097267843Sdelphij      --help-all)
1098267843Sdelphij			opt_help_all=:
1099267843Sdelphijopt_help=': help-all'
1100267843Sdelphij			;;
1101267843Sdelphij      --mode)
1102267843Sdelphij			test $# = 0 && func_missing_arg $opt && break
1103267843Sdelphij			optarg="$1"
1104267843Sdelphij			opt_mode="$optarg"
1105267843Sdelphijcase $optarg in
1106267843Sdelphij  # Valid mode arguments:
1107267843Sdelphij  clean|compile|execute|finish|install|link|relink|uninstall) ;;
1108267843Sdelphij
1109267843Sdelphij  # Catch anything else as an error
1110267843Sdelphij  *) func_error "invalid argument for $opt"
1111267843Sdelphij     exit_cmd=exit
1112267843Sdelphij     break
1113267843Sdelphij     ;;
1114267843Sdelphijesac
1115267843Sdelphij			shift
1116267843Sdelphij			;;
1117267843Sdelphij      --no-silent|--no-quiet)
1118267843Sdelphij			opt_silent=false
1119267843Sdelphijfunc_append preserve_args " $opt"
1120267843Sdelphij			;;
1121267843Sdelphij      --no-warning|--no-warn)
1122267843Sdelphij			opt_warning=false
1123267843Sdelphijfunc_append preserve_args " $opt"
1124267843Sdelphij			;;
1125267843Sdelphij      --no-verbose)
1126267843Sdelphij			opt_verbose=false
1127267843Sdelphijfunc_append preserve_args " $opt"
1128267843Sdelphij			;;
1129267843Sdelphij      --silent|--quiet)
1130267843Sdelphij			opt_silent=:
1131267843Sdelphijfunc_append preserve_args " $opt"
1132267843Sdelphij        opt_verbose=false
1133267843Sdelphij			;;
1134267843Sdelphij      --verbose|-v)
1135267843Sdelphij			opt_verbose=:
1136267843Sdelphijfunc_append preserve_args " $opt"
1137267843Sdelphijopt_silent=false
1138267843Sdelphij			;;
1139267843Sdelphij      --tag)
1140267843Sdelphij			test $# = 0 && func_missing_arg $opt && break
1141267843Sdelphij			optarg="$1"
1142267843Sdelphij			opt_tag="$optarg"
1143267843Sdelphijfunc_append preserve_args " $opt $optarg"
1144267843Sdelphijfunc_enable_tag "$optarg"
1145267843Sdelphij			shift
1146267843Sdelphij			;;
1147267843Sdelphij
1148267843Sdelphij      -\?|-h)		func_usage				;;
1149267843Sdelphij      --help)		func_help				;;
1150267843Sdelphij      --version)	func_version				;;
1151267843Sdelphij
1152267843Sdelphij      # Separate optargs to long options:
1153267843Sdelphij      --*=*)
1154267843Sdelphij			func_split_long_opt "$opt"
1155267843Sdelphij			set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"}
1156267843Sdelphij			shift
1157267843Sdelphij			;;
1158267843Sdelphij
1159267843Sdelphij      # Separate non-argument short options:
1160267843Sdelphij      -\?*|-h*|-n*|-v*)
1161267843Sdelphij			func_split_short_opt "$opt"
1162267843Sdelphij			set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"}
1163267843Sdelphij			shift
1164267843Sdelphij			;;
1165267843Sdelphij
1166267843Sdelphij      --)		break					;;
1167267843Sdelphij      -*)		func_fatal_help "unrecognized option \`$opt'" ;;
1168267843Sdelphij      *)		set dummy "$opt" ${1+"$@"};	shift; break  ;;
1169267843Sdelphij    esac
1170267843Sdelphij  done
1171267843Sdelphij
1172267843Sdelphij  # Validate options:
1173267843Sdelphij
1174267843Sdelphij  # save first non-option argument
1175267843Sdelphij  if test "$#" -gt 0; then
1176267843Sdelphij    nonopt="$opt"
1177267843Sdelphij    shift
1178267843Sdelphij  fi
1179267843Sdelphij
1180267843Sdelphij  # preserve --debug
1181267843Sdelphij  test "$opt_debug" = : || func_append preserve_args " --debug"
1182267843Sdelphij
1183267843Sdelphij  case $host in
1184267843Sdelphij    *cygwin* | *mingw* | *pw32* | *cegcc*)
1185267843Sdelphij      # don't eliminate duplications in $postdeps and $predeps
1186267843Sdelphij      opt_duplicate_compiler_generated_deps=:
1187267843Sdelphij      ;;
1188267843Sdelphij    *)
1189267843Sdelphij      opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
1190267843Sdelphij      ;;
1191267843Sdelphij  esac
1192267843Sdelphij
1193267843Sdelphij  $opt_help || {
1194267843Sdelphij    # Sanity checks first:
1195267843Sdelphij    func_check_version_match
1196267843Sdelphij
1197267843Sdelphij    if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
1198267843Sdelphij      func_fatal_configuration "not configured to build any kind of library"
1199267843Sdelphij    fi
1200267843Sdelphij
1201267843Sdelphij    # Darwin sucks
1202267843Sdelphij    eval std_shrext=\"$shrext_cmds\"
1203267843Sdelphij
1204267843Sdelphij    # Only execute mode is allowed to have -dlopen flags.
1205267843Sdelphij    if test -n "$opt_dlopen" && test "$opt_mode" != execute; then
1206267843Sdelphij      func_error "unrecognized option \`-dlopen'"
1207267843Sdelphij      $ECHO "$help" 1>&2
1208267843Sdelphij      exit $EXIT_FAILURE
1209267843Sdelphij    fi
1210267843Sdelphij
1211267843Sdelphij    # Change the help message to a mode-specific one.
1212267843Sdelphij    generic_help="$help"
1213267843Sdelphij    help="Try \`$progname --help --mode=$opt_mode' for more information."
1214267843Sdelphij  }
1215267843Sdelphij
1216267843Sdelphij
1217267843Sdelphij  # Bail if the options were screwed
1218267843Sdelphij  $exit_cmd $EXIT_FAILURE
1219267843Sdelphij}
1220267843Sdelphij
1221267843Sdelphij
1222267843Sdelphij
1223267843Sdelphij
1224267843Sdelphij## ----------- ##
1225267843Sdelphij##    Main.    ##
1226267843Sdelphij## ----------- ##
1227267843Sdelphij
1228267843Sdelphij# func_lalib_p file
1229267843Sdelphij# True iff FILE is a libtool `.la' library or `.lo' object file.
1230267843Sdelphij# This function is only a basic sanity check; it will hardly flush out
1231267843Sdelphij# determined imposters.
1232267843Sdelphijfunc_lalib_p ()
1233267843Sdelphij{
1234267843Sdelphij    test -f "$1" &&
1235267843Sdelphij      $SED -e 4q "$1" 2>/dev/null \
1236267843Sdelphij        | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
1237267843Sdelphij}
1238267843Sdelphij
1239267843Sdelphij# func_lalib_unsafe_p file
1240267843Sdelphij# True iff FILE is a libtool `.la' library or `.lo' object file.
1241267843Sdelphij# This function implements the same check as func_lalib_p without
1242267843Sdelphij# resorting to external programs.  To this end, it redirects stdin and
1243267843Sdelphij# closes it afterwards, without saving the original file descriptor.
1244267843Sdelphij# As a safety measure, use it only where a negative result would be
1245267843Sdelphij# fatal anyway.  Works if `file' does not exist.
1246267843Sdelphijfunc_lalib_unsafe_p ()
1247267843Sdelphij{
1248267843Sdelphij    lalib_p=no
1249267843Sdelphij    if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
1250267843Sdelphij	for lalib_p_l in 1 2 3 4
1251267843Sdelphij	do
1252267843Sdelphij	    read lalib_p_line
1253267843Sdelphij	    case "$lalib_p_line" in
1254267843Sdelphij		\#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
1255267843Sdelphij	    esac
1256267843Sdelphij	done
1257267843Sdelphij	exec 0<&5 5<&-
1258267843Sdelphij    fi
1259267843Sdelphij    test "$lalib_p" = yes
1260267843Sdelphij}
1261267843Sdelphij
1262267843Sdelphij# func_ltwrapper_script_p file
1263267843Sdelphij# True iff FILE is a libtool wrapper script
1264267843Sdelphij# This function is only a basic sanity check; it will hardly flush out
1265267843Sdelphij# determined imposters.
1266267843Sdelphijfunc_ltwrapper_script_p ()
1267267843Sdelphij{
1268267843Sdelphij    func_lalib_p "$1"
1269267843Sdelphij}
1270267843Sdelphij
1271267843Sdelphij# func_ltwrapper_executable_p file
1272267843Sdelphij# True iff FILE is a libtool wrapper executable
1273267843Sdelphij# This function is only a basic sanity check; it will hardly flush out
1274267843Sdelphij# determined imposters.
1275267843Sdelphijfunc_ltwrapper_executable_p ()
1276267843Sdelphij{
1277267843Sdelphij    func_ltwrapper_exec_suffix=
1278267843Sdelphij    case $1 in
1279267843Sdelphij    *.exe) ;;
1280267843Sdelphij    *) func_ltwrapper_exec_suffix=.exe ;;
1281267843Sdelphij    esac
1282267843Sdelphij    $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
1283267843Sdelphij}
1284267843Sdelphij
1285267843Sdelphij# func_ltwrapper_scriptname file
1286267843Sdelphij# Assumes file is an ltwrapper_executable
1287267843Sdelphij# uses $file to determine the appropriate filename for a
1288267843Sdelphij# temporary ltwrapper_script.
1289267843Sdelphijfunc_ltwrapper_scriptname ()
1290267843Sdelphij{
1291267843Sdelphij    func_dirname_and_basename "$1" "" "."
1292267843Sdelphij    func_stripname '' '.exe' "$func_basename_result"
1293267843Sdelphij    func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper"
1294267843Sdelphij}
1295267843Sdelphij
1296267843Sdelphij# func_ltwrapper_p file
1297267843Sdelphij# True iff FILE is a libtool wrapper script or wrapper executable
1298267843Sdelphij# This function is only a basic sanity check; it will hardly flush out
1299267843Sdelphij# determined imposters.
1300267843Sdelphijfunc_ltwrapper_p ()
1301267843Sdelphij{
1302267843Sdelphij    func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
1303267843Sdelphij}
1304267843Sdelphij
1305267843Sdelphij
1306267843Sdelphij# func_execute_cmds commands fail_cmd
1307267843Sdelphij# Execute tilde-delimited COMMANDS.
1308267843Sdelphij# If FAIL_CMD is given, eval that upon failure.
1309267843Sdelphij# FAIL_CMD may read-access the current command in variable CMD!
1310267843Sdelphijfunc_execute_cmds ()
1311267843Sdelphij{
1312267843Sdelphij    $opt_debug
1313267843Sdelphij    save_ifs=$IFS; IFS='~'
1314267843Sdelphij    for cmd in $1; do
1315267843Sdelphij      IFS=$save_ifs
1316267843Sdelphij      eval cmd=\"$cmd\"
1317267843Sdelphij      func_show_eval "$cmd" "${2-:}"
1318267843Sdelphij    done
1319267843Sdelphij    IFS=$save_ifs
1320267843Sdelphij}
1321267843Sdelphij
1322267843Sdelphij
1323267843Sdelphij# func_source file
1324267843Sdelphij# Source FILE, adding directory component if necessary.
1325267843Sdelphij# Note that it is not necessary on cygwin/mingw to append a dot to
1326267843Sdelphij# FILE even if both FILE and FILE.exe exist: automatic-append-.exe
1327267843Sdelphij# behavior happens only for exec(3), not for open(2)!  Also, sourcing
1328267843Sdelphij# `FILE.' does not work on cygwin managed mounts.
1329267843Sdelphijfunc_source ()
1330267843Sdelphij{
1331267843Sdelphij    $opt_debug
1332267843Sdelphij    case $1 in
1333267843Sdelphij    */* | *\\*)	. "$1" ;;
1334267843Sdelphij    *)		. "./$1" ;;
1335267843Sdelphij    esac
1336267843Sdelphij}
1337267843Sdelphij
1338267843Sdelphij
1339267843Sdelphij# func_resolve_sysroot PATH
1340267843Sdelphij# Replace a leading = in PATH with a sysroot.  Store the result into
1341267843Sdelphij# func_resolve_sysroot_result
1342267843Sdelphijfunc_resolve_sysroot ()
1343267843Sdelphij{
1344267843Sdelphij  func_resolve_sysroot_result=$1
1345267843Sdelphij  case $func_resolve_sysroot_result in
1346267843Sdelphij  =*)
1347267843Sdelphij    func_stripname '=' '' "$func_resolve_sysroot_result"
1348267843Sdelphij    func_resolve_sysroot_result=$lt_sysroot$func_stripname_result
1349267843Sdelphij    ;;
1350267843Sdelphij  esac
1351267843Sdelphij}
1352267843Sdelphij
1353267843Sdelphij# func_replace_sysroot PATH
1354267843Sdelphij# If PATH begins with the sysroot, replace it with = and
1355267843Sdelphij# store the result into func_replace_sysroot_result.
1356267843Sdelphijfunc_replace_sysroot ()
1357267843Sdelphij{
1358267843Sdelphij  case "$lt_sysroot:$1" in
1359267843Sdelphij  ?*:"$lt_sysroot"*)
1360267843Sdelphij    func_stripname "$lt_sysroot" '' "$1"
1361267843Sdelphij    func_replace_sysroot_result="=$func_stripname_result"
1362267843Sdelphij    ;;
1363267843Sdelphij  *)
1364267843Sdelphij    # Including no sysroot.
1365267843Sdelphij    func_replace_sysroot_result=$1
1366267843Sdelphij    ;;
1367267843Sdelphij  esac
1368267843Sdelphij}
1369267843Sdelphij
1370267843Sdelphij# func_infer_tag arg
1371267843Sdelphij# Infer tagged configuration to use if any are available and
1372267843Sdelphij# if one wasn't chosen via the "--tag" command line option.
1373267843Sdelphij# Only attempt this if the compiler in the base compile
1374267843Sdelphij# command doesn't match the default compiler.
1375267843Sdelphij# arg is usually of the form 'gcc ...'
1376267843Sdelphijfunc_infer_tag ()
1377267843Sdelphij{
1378267843Sdelphij    $opt_debug
1379267843Sdelphij    if test -n "$available_tags" && test -z "$tagname"; then
1380267843Sdelphij      CC_quoted=
1381267843Sdelphij      for arg in $CC; do
1382267843Sdelphij	func_append_quoted CC_quoted "$arg"
1383267843Sdelphij      done
1384267843Sdelphij      CC_expanded=`func_echo_all $CC`
1385267843Sdelphij      CC_quoted_expanded=`func_echo_all $CC_quoted`
1386267843Sdelphij      case $@ in
1387267843Sdelphij      # Blanks in the command may have been stripped by the calling shell,
1388267843Sdelphij      # but not from the CC environment variable when configure was run.
1389267843Sdelphij      " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
1390267843Sdelphij      " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
1391267843Sdelphij      # Blanks at the start of $base_compile will cause this to fail
1392267843Sdelphij      # if we don't check for them as well.
1393267843Sdelphij      *)
1394267843Sdelphij	for z in $available_tags; do
1395267843Sdelphij	  if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
1396267843Sdelphij	    # Evaluate the configuration.
1397267843Sdelphij	    eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
1398267843Sdelphij	    CC_quoted=
1399267843Sdelphij	    for arg in $CC; do
1400267843Sdelphij	      # Double-quote args containing other shell metacharacters.
1401267843Sdelphij	      func_append_quoted CC_quoted "$arg"
1402267843Sdelphij	    done
1403267843Sdelphij	    CC_expanded=`func_echo_all $CC`
1404267843Sdelphij	    CC_quoted_expanded=`func_echo_all $CC_quoted`
1405267843Sdelphij	    case "$@ " in
1406267843Sdelphij	    " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
1407267843Sdelphij	    " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
1408267843Sdelphij	      # The compiler in the base compile command matches
1409267843Sdelphij	      # the one in the tagged configuration.
1410267843Sdelphij	      # Assume this is the tagged configuration we want.
1411267843Sdelphij	      tagname=$z
1412267843Sdelphij	      break
1413267843Sdelphij	      ;;
1414267843Sdelphij	    esac
1415267843Sdelphij	  fi
1416267843Sdelphij	done
1417267843Sdelphij	# If $tagname still isn't set, then no tagged configuration
1418267843Sdelphij	# was found and let the user know that the "--tag" command
1419267843Sdelphij	# line option must be used.
1420267843Sdelphij	if test -z "$tagname"; then
1421267843Sdelphij	  func_echo "unable to infer tagged configuration"
1422267843Sdelphij	  func_fatal_error "specify a tag with \`--tag'"
1423267843Sdelphij#	else
1424267843Sdelphij#	  func_verbose "using $tagname tagged configuration"
1425267843Sdelphij	fi
1426267843Sdelphij	;;
1427267843Sdelphij      esac
1428267843Sdelphij    fi
1429267843Sdelphij}
1430267843Sdelphij
1431267843Sdelphij
1432267843Sdelphij
1433267843Sdelphij# func_write_libtool_object output_name pic_name nonpic_name
1434267843Sdelphij# Create a libtool object file (analogous to a ".la" file),
1435267843Sdelphij# but don't create it if we're doing a dry run.
1436267843Sdelphijfunc_write_libtool_object ()
1437267843Sdelphij{
1438267843Sdelphij    write_libobj=${1}
1439267843Sdelphij    if test "$build_libtool_libs" = yes; then
1440267843Sdelphij      write_lobj=\'${2}\'
1441267843Sdelphij    else
1442267843Sdelphij      write_lobj=none
1443267843Sdelphij    fi
1444267843Sdelphij
1445267843Sdelphij    if test "$build_old_libs" = yes; then
1446267843Sdelphij      write_oldobj=\'${3}\'
1447267843Sdelphij    else
1448267843Sdelphij      write_oldobj=none
1449267843Sdelphij    fi
1450267843Sdelphij
1451267843Sdelphij    $opt_dry_run || {
1452267843Sdelphij      cat >${write_libobj}T <<EOF
1453267843Sdelphij# $write_libobj - a libtool object file
1454267843Sdelphij# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
1455267843Sdelphij#
1456267843Sdelphij# Please DO NOT delete this file!
1457267843Sdelphij# It is necessary for linking the library.
1458267843Sdelphij
1459267843Sdelphij# Name of the PIC object.
1460267843Sdelphijpic_object=$write_lobj
1461267843Sdelphij
1462267843Sdelphij# Name of the non-PIC object
1463267843Sdelphijnon_pic_object=$write_oldobj
1464267843Sdelphij
1465267843SdelphijEOF
1466267843Sdelphij      $MV "${write_libobj}T" "${write_libobj}"
1467267843Sdelphij    }
1468267843Sdelphij}
1469267843Sdelphij
1470267843Sdelphij
1471267843Sdelphij##################################################
1472267843Sdelphij# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS #
1473267843Sdelphij##################################################
1474267843Sdelphij
1475267843Sdelphij# func_convert_core_file_wine_to_w32 ARG
1476267843Sdelphij# Helper function used by file name conversion functions when $build is *nix,
1477267843Sdelphij# and $host is mingw, cygwin, or some other w32 environment. Relies on a
1478267843Sdelphij# correctly configured wine environment available, with the winepath program
1479267843Sdelphij# in $build's $PATH.
1480267843Sdelphij#
1481267843Sdelphij# ARG is the $build file name to be converted to w32 format.
1482267843Sdelphij# Result is available in $func_convert_core_file_wine_to_w32_result, and will
1483267843Sdelphij# be empty on error (or when ARG is empty)
1484267843Sdelphijfunc_convert_core_file_wine_to_w32 ()
1485267843Sdelphij{
1486267843Sdelphij  $opt_debug
1487267843Sdelphij  func_convert_core_file_wine_to_w32_result="$1"
1488267843Sdelphij  if test -n "$1"; then
1489267843Sdelphij    # Unfortunately, winepath does not exit with a non-zero error code, so we
1490267843Sdelphij    # are forced to check the contents of stdout. On the other hand, if the
1491267843Sdelphij    # command is not found, the shell will set an exit code of 127 and print
1492267843Sdelphij    # *an error message* to stdout. So we must check for both error code of
1493267843Sdelphij    # zero AND non-empty stdout, which explains the odd construction:
1494267843Sdelphij    func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
1495267843Sdelphij    if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then
1496267843Sdelphij      func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
1497267843Sdelphij        $SED -e "$lt_sed_naive_backslashify"`
1498267843Sdelphij    else
1499267843Sdelphij      func_convert_core_file_wine_to_w32_result=
1500267843Sdelphij    fi
1501267843Sdelphij  fi
1502267843Sdelphij}
1503267843Sdelphij# end: func_convert_core_file_wine_to_w32
1504267843Sdelphij
1505267843Sdelphij
1506267843Sdelphij# func_convert_core_path_wine_to_w32 ARG
1507267843Sdelphij# Helper function used by path conversion functions when $build is *nix, and
1508267843Sdelphij# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly
1509267843Sdelphij# configured wine environment available, with the winepath program in $build's
1510267843Sdelphij# $PATH. Assumes ARG has no leading or trailing path separator characters.
1511267843Sdelphij#
1512267843Sdelphij# ARG is path to be converted from $build format to win32.
1513267843Sdelphij# Result is available in $func_convert_core_path_wine_to_w32_result.
1514267843Sdelphij# Unconvertible file (directory) names in ARG are skipped; if no directory names
1515267843Sdelphij# are convertible, then the result may be empty.
1516267843Sdelphijfunc_convert_core_path_wine_to_w32 ()
1517267843Sdelphij{
1518267843Sdelphij  $opt_debug
1519267843Sdelphij  # unfortunately, winepath doesn't convert paths, only file names
1520267843Sdelphij  func_convert_core_path_wine_to_w32_result=""
1521267843Sdelphij  if test -n "$1"; then
1522267843Sdelphij    oldIFS=$IFS
1523267843Sdelphij    IFS=:
1524267843Sdelphij    for func_convert_core_path_wine_to_w32_f in $1; do
1525267843Sdelphij      IFS=$oldIFS
1526267843Sdelphij      func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
1527267843Sdelphij      if test -n "$func_convert_core_file_wine_to_w32_result" ; then
1528267843Sdelphij        if test -z "$func_convert_core_path_wine_to_w32_result"; then
1529267843Sdelphij          func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result"
1530267843Sdelphij        else
1531267843Sdelphij          func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
1532267843Sdelphij        fi
1533267843Sdelphij      fi
1534267843Sdelphij    done
1535267843Sdelphij    IFS=$oldIFS
1536267843Sdelphij  fi
1537267843Sdelphij}
1538267843Sdelphij# end: func_convert_core_path_wine_to_w32
1539267843Sdelphij
1540267843Sdelphij
1541267843Sdelphij# func_cygpath ARGS...
1542267843Sdelphij# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when
1543267843Sdelphij# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2)
1544267843Sdelphij# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or
1545267843Sdelphij# (2), returns the Cygwin file name or path in func_cygpath_result (input
1546267843Sdelphij# file name or path is assumed to be in w32 format, as previously converted
1547267843Sdelphij# from $build's *nix or MSYS format). In case (3), returns the w32 file name
1548267843Sdelphij# or path in func_cygpath_result (input file name or path is assumed to be in
1549267843Sdelphij# Cygwin format). Returns an empty string on error.
1550267843Sdelphij#
1551267843Sdelphij# ARGS are passed to cygpath, with the last one being the file name or path to
1552267843Sdelphij# be converted.
1553267843Sdelphij#
1554267843Sdelphij# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH
1555267843Sdelphij# environment variable; do not put it in $PATH.
1556267843Sdelphijfunc_cygpath ()
1557267843Sdelphij{
1558267843Sdelphij  $opt_debug
1559267843Sdelphij  if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
1560267843Sdelphij    func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
1561267843Sdelphij    if test "$?" -ne 0; then
1562267843Sdelphij      # on failure, ensure result is empty
1563267843Sdelphij      func_cygpath_result=
1564267843Sdelphij    fi
1565267843Sdelphij  else
1566267843Sdelphij    func_cygpath_result=
1567267843Sdelphij    func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'"
1568267843Sdelphij  fi
1569267843Sdelphij}
1570267843Sdelphij#end: func_cygpath
1571267843Sdelphij
1572267843Sdelphij
1573267843Sdelphij# func_convert_core_msys_to_w32 ARG
1574267843Sdelphij# Convert file name or path ARG from MSYS format to w32 format.  Return
1575267843Sdelphij# result in func_convert_core_msys_to_w32_result.
1576267843Sdelphijfunc_convert_core_msys_to_w32 ()
1577267843Sdelphij{
1578267843Sdelphij  $opt_debug
1579267843Sdelphij  # awkward: cmd appends spaces to result
1580267843Sdelphij  func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
1581267843Sdelphij    $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"`
1582267843Sdelphij}
1583267843Sdelphij#end: func_convert_core_msys_to_w32
1584267843Sdelphij
1585267843Sdelphij
1586267843Sdelphij# func_convert_file_check ARG1 ARG2
1587267843Sdelphij# Verify that ARG1 (a file name in $build format) was converted to $host
1588267843Sdelphij# format in ARG2. Otherwise, emit an error message, but continue (resetting
1589267843Sdelphij# func_to_host_file_result to ARG1).
1590267843Sdelphijfunc_convert_file_check ()
1591267843Sdelphij{
1592267843Sdelphij  $opt_debug
1593267843Sdelphij  if test -z "$2" && test -n "$1" ; then
1594267843Sdelphij    func_error "Could not determine host file name corresponding to"
1595267843Sdelphij    func_error "  \`$1'"
1596267843Sdelphij    func_error "Continuing, but uninstalled executables may not work."
1597267843Sdelphij    # Fallback:
1598267843Sdelphij    func_to_host_file_result="$1"
1599267843Sdelphij  fi
1600267843Sdelphij}
1601267843Sdelphij# end func_convert_file_check
1602267843Sdelphij
1603267843Sdelphij
1604267843Sdelphij# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH
1605267843Sdelphij# Verify that FROM_PATH (a path in $build format) was converted to $host
1606267843Sdelphij# format in TO_PATH. Otherwise, emit an error message, but continue, resetting
1607267843Sdelphij# func_to_host_file_result to a simplistic fallback value (see below).
1608267843Sdelphijfunc_convert_path_check ()
1609267843Sdelphij{
1610267843Sdelphij  $opt_debug
1611267843Sdelphij  if test -z "$4" && test -n "$3"; then
1612267843Sdelphij    func_error "Could not determine the host path corresponding to"
1613267843Sdelphij    func_error "  \`$3'"
1614267843Sdelphij    func_error "Continuing, but uninstalled executables may not work."
1615267843Sdelphij    # Fallback.  This is a deliberately simplistic "conversion" and
1616267843Sdelphij    # should not be "improved".  See libtool.info.
1617267843Sdelphij    if test "x$1" != "x$2"; then
1618267843Sdelphij      lt_replace_pathsep_chars="s|$1|$2|g"
1619267843Sdelphij      func_to_host_path_result=`echo "$3" |
1620267843Sdelphij        $SED -e "$lt_replace_pathsep_chars"`
1621267843Sdelphij    else
1622267843Sdelphij      func_to_host_path_result="$3"
1623267843Sdelphij    fi
1624267843Sdelphij  fi
1625267843Sdelphij}
1626267843Sdelphij# end func_convert_path_check
1627267843Sdelphij
1628267843Sdelphij
1629267843Sdelphij# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG
1630267843Sdelphij# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT
1631267843Sdelphij# and appending REPL if ORIG matches BACKPAT.
1632267843Sdelphijfunc_convert_path_front_back_pathsep ()
1633267843Sdelphij{
1634267843Sdelphij  $opt_debug
1635267843Sdelphij  case $4 in
1636267843Sdelphij  $1 ) func_to_host_path_result="$3$func_to_host_path_result"
1637267843Sdelphij    ;;
1638267843Sdelphij  esac
1639267843Sdelphij  case $4 in
1640267843Sdelphij  $2 ) func_append func_to_host_path_result "$3"
1641267843Sdelphij    ;;
1642267843Sdelphij  esac
1643267843Sdelphij}
1644267843Sdelphij# end func_convert_path_front_back_pathsep
1645267843Sdelphij
1646267843Sdelphij
1647267843Sdelphij##################################################
1648267843Sdelphij# $build to $host FILE NAME CONVERSION FUNCTIONS #
1649267843Sdelphij##################################################
1650267843Sdelphij# invoked via `$to_host_file_cmd ARG'
1651267843Sdelphij#
1652267843Sdelphij# In each case, ARG is the path to be converted from $build to $host format.
1653267843Sdelphij# Result will be available in $func_to_host_file_result.
1654267843Sdelphij
1655267843Sdelphij
1656267843Sdelphij# func_to_host_file ARG
1657267843Sdelphij# Converts the file name ARG from $build format to $host format. Return result
1658267843Sdelphij# in func_to_host_file_result.
1659267843Sdelphijfunc_to_host_file ()
1660267843Sdelphij{
1661267843Sdelphij  $opt_debug
1662267843Sdelphij  $to_host_file_cmd "$1"
1663267843Sdelphij}
1664267843Sdelphij# end func_to_host_file
1665267843Sdelphij
1666267843Sdelphij
1667267843Sdelphij# func_to_tool_file ARG LAZY
1668267843Sdelphij# converts the file name ARG from $build format to toolchain format. Return
1669267843Sdelphij# result in func_to_tool_file_result.  If the conversion in use is listed
1670267843Sdelphij# in (the comma separated) LAZY, no conversion takes place.
1671267843Sdelphijfunc_to_tool_file ()
1672267843Sdelphij{
1673267843Sdelphij  $opt_debug
1674267843Sdelphij  case ,$2, in
1675267843Sdelphij    *,"$to_tool_file_cmd",*)
1676267843Sdelphij      func_to_tool_file_result=$1
1677267843Sdelphij      ;;
1678267843Sdelphij    *)
1679267843Sdelphij      $to_tool_file_cmd "$1"
1680267843Sdelphij      func_to_tool_file_result=$func_to_host_file_result
1681267843Sdelphij      ;;
1682267843Sdelphij  esac
1683267843Sdelphij}
1684267843Sdelphij# end func_to_tool_file
1685267843Sdelphij
1686267843Sdelphij
1687267843Sdelphij# func_convert_file_noop ARG
1688267843Sdelphij# Copy ARG to func_to_host_file_result.
1689267843Sdelphijfunc_convert_file_noop ()
1690267843Sdelphij{
1691267843Sdelphij  func_to_host_file_result="$1"
1692267843Sdelphij}
1693267843Sdelphij# end func_convert_file_noop
1694267843Sdelphij
1695267843Sdelphij
1696267843Sdelphij# func_convert_file_msys_to_w32 ARG
1697267843Sdelphij# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic
1698267843Sdelphij# conversion to w32 is not available inside the cwrapper.  Returns result in
1699267843Sdelphij# func_to_host_file_result.
1700267843Sdelphijfunc_convert_file_msys_to_w32 ()
1701267843Sdelphij{
1702267843Sdelphij  $opt_debug
1703267843Sdelphij  func_to_host_file_result="$1"
1704267843Sdelphij  if test -n "$1"; then
1705267843Sdelphij    func_convert_core_msys_to_w32 "$1"
1706267843Sdelphij    func_to_host_file_result="$func_convert_core_msys_to_w32_result"
1707267843Sdelphij  fi
1708267843Sdelphij  func_convert_file_check "$1" "$func_to_host_file_result"
1709267843Sdelphij}
1710267843Sdelphij# end func_convert_file_msys_to_w32
1711267843Sdelphij
1712267843Sdelphij
1713267843Sdelphij# func_convert_file_cygwin_to_w32 ARG
1714267843Sdelphij# Convert file name ARG from Cygwin to w32 format.  Returns result in
1715267843Sdelphij# func_to_host_file_result.
1716267843Sdelphijfunc_convert_file_cygwin_to_w32 ()
1717267843Sdelphij{
1718267843Sdelphij  $opt_debug
1719267843Sdelphij  func_to_host_file_result="$1"
1720267843Sdelphij  if test -n "$1"; then
1721267843Sdelphij    # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
1722267843Sdelphij    # LT_CYGPATH in this case.
1723267843Sdelphij    func_to_host_file_result=`cygpath -m "$1"`
1724267843Sdelphij  fi
1725267843Sdelphij  func_convert_file_check "$1" "$func_to_host_file_result"
1726267843Sdelphij}
1727267843Sdelphij# end func_convert_file_cygwin_to_w32
1728267843Sdelphij
1729267843Sdelphij
1730267843Sdelphij# func_convert_file_nix_to_w32 ARG
1731267843Sdelphij# Convert file name ARG from *nix to w32 format.  Requires a wine environment
1732267843Sdelphij# and a working winepath. Returns result in func_to_host_file_result.
1733267843Sdelphijfunc_convert_file_nix_to_w32 ()
1734267843Sdelphij{
1735267843Sdelphij  $opt_debug
1736267843Sdelphij  func_to_host_file_result="$1"
1737267843Sdelphij  if test -n "$1"; then
1738267843Sdelphij    func_convert_core_file_wine_to_w32 "$1"
1739267843Sdelphij    func_to_host_file_result="$func_convert_core_file_wine_to_w32_result"
1740267843Sdelphij  fi
1741267843Sdelphij  func_convert_file_check "$1" "$func_to_host_file_result"
1742267843Sdelphij}
1743267843Sdelphij# end func_convert_file_nix_to_w32
1744267843Sdelphij
1745267843Sdelphij
1746267843Sdelphij# func_convert_file_msys_to_cygwin ARG
1747267843Sdelphij# Convert file name ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
1748267843Sdelphij# Returns result in func_to_host_file_result.
1749267843Sdelphijfunc_convert_file_msys_to_cygwin ()
1750267843Sdelphij{
1751267843Sdelphij  $opt_debug
1752267843Sdelphij  func_to_host_file_result="$1"
1753267843Sdelphij  if test -n "$1"; then
1754267843Sdelphij    func_convert_core_msys_to_w32 "$1"
1755267843Sdelphij    func_cygpath -u "$func_convert_core_msys_to_w32_result"
1756267843Sdelphij    func_to_host_file_result="$func_cygpath_result"
1757267843Sdelphij  fi
1758267843Sdelphij  func_convert_file_check "$1" "$func_to_host_file_result"
1759267843Sdelphij}
1760267843Sdelphij# end func_convert_file_msys_to_cygwin
1761267843Sdelphij
1762267843Sdelphij
1763267843Sdelphij# func_convert_file_nix_to_cygwin ARG
1764267843Sdelphij# Convert file name ARG from *nix to Cygwin format.  Requires Cygwin installed
1765267843Sdelphij# in a wine environment, working winepath, and LT_CYGPATH set.  Returns result
1766267843Sdelphij# in func_to_host_file_result.
1767267843Sdelphijfunc_convert_file_nix_to_cygwin ()
1768267843Sdelphij{
1769267843Sdelphij  $opt_debug
1770267843Sdelphij  func_to_host_file_result="$1"
1771267843Sdelphij  if test -n "$1"; then
1772267843Sdelphij    # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
1773267843Sdelphij    func_convert_core_file_wine_to_w32 "$1"
1774267843Sdelphij    func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
1775267843Sdelphij    func_to_host_file_result="$func_cygpath_result"
1776267843Sdelphij  fi
1777267843Sdelphij  func_convert_file_check "$1" "$func_to_host_file_result"
1778267843Sdelphij}
1779267843Sdelphij# end func_convert_file_nix_to_cygwin
1780267843Sdelphij
1781267843Sdelphij
1782267843Sdelphij#############################################
1783267843Sdelphij# $build to $host PATH CONVERSION FUNCTIONS #
1784267843Sdelphij#############################################
1785267843Sdelphij# invoked via `$to_host_path_cmd ARG'
1786267843Sdelphij#
1787267843Sdelphij# In each case, ARG is the path to be converted from $build to $host format.
1788267843Sdelphij# The result will be available in $func_to_host_path_result.
1789267843Sdelphij#
1790267843Sdelphij# Path separators are also converted from $build format to $host format.  If
1791267843Sdelphij# ARG begins or ends with a path separator character, it is preserved (but
1792267843Sdelphij# converted to $host format) on output.
1793267843Sdelphij#
1794267843Sdelphij# All path conversion functions are named using the following convention:
1795267843Sdelphij#   file name conversion function    : func_convert_file_X_to_Y ()
1796267843Sdelphij#   path conversion function         : func_convert_path_X_to_Y ()
1797267843Sdelphij# where, for any given $build/$host combination the 'X_to_Y' value is the
1798267843Sdelphij# same.  If conversion functions are added for new $build/$host combinations,
1799267843Sdelphij# the two new functions must follow this pattern, or func_init_to_host_path_cmd
1800267843Sdelphij# will break.
1801267843Sdelphij
1802267843Sdelphij
1803267843Sdelphij# func_init_to_host_path_cmd
1804267843Sdelphij# Ensures that function "pointer" variable $to_host_path_cmd is set to the
1805267843Sdelphij# appropriate value, based on the value of $to_host_file_cmd.
1806267843Sdelphijto_host_path_cmd=
1807267843Sdelphijfunc_init_to_host_path_cmd ()
1808267843Sdelphij{
1809267843Sdelphij  $opt_debug
1810267843Sdelphij  if test -z "$to_host_path_cmd"; then
1811267843Sdelphij    func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
1812267843Sdelphij    to_host_path_cmd="func_convert_path_${func_stripname_result}"
1813267843Sdelphij  fi
1814267843Sdelphij}
1815267843Sdelphij
1816267843Sdelphij
1817267843Sdelphij# func_to_host_path ARG
1818267843Sdelphij# Converts the path ARG from $build format to $host format. Return result
1819267843Sdelphij# in func_to_host_path_result.
1820267843Sdelphijfunc_to_host_path ()
1821267843Sdelphij{
1822267843Sdelphij  $opt_debug
1823267843Sdelphij  func_init_to_host_path_cmd
1824267843Sdelphij  $to_host_path_cmd "$1"
1825267843Sdelphij}
1826267843Sdelphij# end func_to_host_path
1827267843Sdelphij
1828267843Sdelphij
1829267843Sdelphij# func_convert_path_noop ARG
1830267843Sdelphij# Copy ARG to func_to_host_path_result.
1831267843Sdelphijfunc_convert_path_noop ()
1832267843Sdelphij{
1833267843Sdelphij  func_to_host_path_result="$1"
1834267843Sdelphij}
1835267843Sdelphij# end func_convert_path_noop
1836267843Sdelphij
1837267843Sdelphij
1838267843Sdelphij# func_convert_path_msys_to_w32 ARG
1839267843Sdelphij# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic
1840267843Sdelphij# conversion to w32 is not available inside the cwrapper.  Returns result in
1841267843Sdelphij# func_to_host_path_result.
1842267843Sdelphijfunc_convert_path_msys_to_w32 ()
1843267843Sdelphij{
1844267843Sdelphij  $opt_debug
1845267843Sdelphij  func_to_host_path_result="$1"
1846267843Sdelphij  if test -n "$1"; then
1847267843Sdelphij    # Remove leading and trailing path separator characters from ARG.  MSYS
1848267843Sdelphij    # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
1849267843Sdelphij    # and winepath ignores them completely.
1850267843Sdelphij    func_stripname : : "$1"
1851267843Sdelphij    func_to_host_path_tmp1=$func_stripname_result
1852267843Sdelphij    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
1853267843Sdelphij    func_to_host_path_result="$func_convert_core_msys_to_w32_result"
1854267843Sdelphij    func_convert_path_check : ";" \
1855267843Sdelphij      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1856267843Sdelphij    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
1857267843Sdelphij  fi
1858267843Sdelphij}
1859267843Sdelphij# end func_convert_path_msys_to_w32
1860267843Sdelphij
1861267843Sdelphij
1862267843Sdelphij# func_convert_path_cygwin_to_w32 ARG
1863267843Sdelphij# Convert path ARG from Cygwin to w32 format.  Returns result in
1864267843Sdelphij# func_to_host_file_result.
1865267843Sdelphijfunc_convert_path_cygwin_to_w32 ()
1866267843Sdelphij{
1867267843Sdelphij  $opt_debug
1868267843Sdelphij  func_to_host_path_result="$1"
1869267843Sdelphij  if test -n "$1"; then
1870267843Sdelphij    # See func_convert_path_msys_to_w32:
1871267843Sdelphij    func_stripname : : "$1"
1872267843Sdelphij    func_to_host_path_tmp1=$func_stripname_result
1873267843Sdelphij    func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"`
1874267843Sdelphij    func_convert_path_check : ";" \
1875267843Sdelphij      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1876267843Sdelphij    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
1877267843Sdelphij  fi
1878267843Sdelphij}
1879267843Sdelphij# end func_convert_path_cygwin_to_w32
1880267843Sdelphij
1881267843Sdelphij
1882267843Sdelphij# func_convert_path_nix_to_w32 ARG
1883267843Sdelphij# Convert path ARG from *nix to w32 format.  Requires a wine environment and
1884267843Sdelphij# a working winepath.  Returns result in func_to_host_file_result.
1885267843Sdelphijfunc_convert_path_nix_to_w32 ()
1886267843Sdelphij{
1887267843Sdelphij  $opt_debug
1888267843Sdelphij  func_to_host_path_result="$1"
1889267843Sdelphij  if test -n "$1"; then
1890267843Sdelphij    # See func_convert_path_msys_to_w32:
1891267843Sdelphij    func_stripname : : "$1"
1892267843Sdelphij    func_to_host_path_tmp1=$func_stripname_result
1893267843Sdelphij    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
1894267843Sdelphij    func_to_host_path_result="$func_convert_core_path_wine_to_w32_result"
1895267843Sdelphij    func_convert_path_check : ";" \
1896267843Sdelphij      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1897267843Sdelphij    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
1898267843Sdelphij  fi
1899267843Sdelphij}
1900267843Sdelphij# end func_convert_path_nix_to_w32
1901267843Sdelphij
1902267843Sdelphij
1903267843Sdelphij# func_convert_path_msys_to_cygwin ARG
1904267843Sdelphij# Convert path ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
1905267843Sdelphij# Returns result in func_to_host_file_result.
1906267843Sdelphijfunc_convert_path_msys_to_cygwin ()
1907267843Sdelphij{
1908267843Sdelphij  $opt_debug
1909267843Sdelphij  func_to_host_path_result="$1"
1910267843Sdelphij  if test -n "$1"; then
1911267843Sdelphij    # See func_convert_path_msys_to_w32:
1912267843Sdelphij    func_stripname : : "$1"
1913267843Sdelphij    func_to_host_path_tmp1=$func_stripname_result
1914267843Sdelphij    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
1915267843Sdelphij    func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
1916267843Sdelphij    func_to_host_path_result="$func_cygpath_result"
1917267843Sdelphij    func_convert_path_check : : \
1918267843Sdelphij      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1919267843Sdelphij    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
1920267843Sdelphij  fi
1921267843Sdelphij}
1922267843Sdelphij# end func_convert_path_msys_to_cygwin
1923267843Sdelphij
1924267843Sdelphij
1925267843Sdelphij# func_convert_path_nix_to_cygwin ARG
1926267843Sdelphij# Convert path ARG from *nix to Cygwin format.  Requires Cygwin installed in a
1927267843Sdelphij# a wine environment, working winepath, and LT_CYGPATH set.  Returns result in
1928267843Sdelphij# func_to_host_file_result.
1929267843Sdelphijfunc_convert_path_nix_to_cygwin ()
1930267843Sdelphij{
1931267843Sdelphij  $opt_debug
1932267843Sdelphij  func_to_host_path_result="$1"
1933267843Sdelphij  if test -n "$1"; then
1934267843Sdelphij    # Remove leading and trailing path separator characters from
1935267843Sdelphij    # ARG. msys behavior is inconsistent here, cygpath turns them
1936267843Sdelphij    # into '.;' and ';.', and winepath ignores them completely.
1937267843Sdelphij    func_stripname : : "$1"
1938267843Sdelphij    func_to_host_path_tmp1=$func_stripname_result
1939267843Sdelphij    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
1940267843Sdelphij    func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
1941267843Sdelphij    func_to_host_path_result="$func_cygpath_result"
1942267843Sdelphij    func_convert_path_check : : \
1943267843Sdelphij      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1944267843Sdelphij    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
1945267843Sdelphij  fi
1946267843Sdelphij}
1947267843Sdelphij# end func_convert_path_nix_to_cygwin
1948267843Sdelphij
1949267843Sdelphij
1950267843Sdelphij# func_mode_compile arg...
1951267843Sdelphijfunc_mode_compile ()
1952267843Sdelphij{
1953267843Sdelphij    $opt_debug
1954267843Sdelphij    # Get the compilation command and the source file.
1955267843Sdelphij    base_compile=
1956267843Sdelphij    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
1957267843Sdelphij    suppress_opt=yes
1958267843Sdelphij    suppress_output=
1959267843Sdelphij    arg_mode=normal
1960267843Sdelphij    libobj=
1961267843Sdelphij    later=
1962267843Sdelphij    pie_flag=
1963267843Sdelphij
1964267843Sdelphij    for arg
1965267843Sdelphij    do
1966267843Sdelphij      case $arg_mode in
1967267843Sdelphij      arg  )
1968267843Sdelphij	# do not "continue".  Instead, add this to base_compile
1969267843Sdelphij	lastarg="$arg"
1970267843Sdelphij	arg_mode=normal
1971267843Sdelphij	;;
1972267843Sdelphij
1973267843Sdelphij      target )
1974267843Sdelphij	libobj="$arg"
1975267843Sdelphij	arg_mode=normal
1976267843Sdelphij	continue
1977267843Sdelphij	;;
1978267843Sdelphij
1979267843Sdelphij      normal )
1980267843Sdelphij	# Accept any command-line options.
1981267843Sdelphij	case $arg in
1982267843Sdelphij	-o)
1983267843Sdelphij	  test -n "$libobj" && \
1984267843Sdelphij	    func_fatal_error "you cannot specify \`-o' more than once"
1985267843Sdelphij	  arg_mode=target
1986267843Sdelphij	  continue
1987267843Sdelphij	  ;;
1988267843Sdelphij
1989267843Sdelphij	-pie | -fpie | -fPIE)
1990267843Sdelphij          func_append pie_flag " $arg"
1991267843Sdelphij	  continue
1992267843Sdelphij	  ;;
1993267843Sdelphij
1994267843Sdelphij	-shared | -static | -prefer-pic | -prefer-non-pic)
1995267843Sdelphij	  func_append later " $arg"
1996267843Sdelphij	  continue
1997267843Sdelphij	  ;;
1998267843Sdelphij
1999267843Sdelphij	-no-suppress)
2000267843Sdelphij	  suppress_opt=no
2001267843Sdelphij	  continue
2002267843Sdelphij	  ;;
2003267843Sdelphij
2004267843Sdelphij	-Xcompiler)
2005267843Sdelphij	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
2006267843Sdelphij	  continue      #  The current "srcfile" will either be retained or
2007267843Sdelphij	  ;;            #  replaced later.  I would guess that would be a bug.
2008267843Sdelphij
2009267843Sdelphij	-Wc,*)
2010267843Sdelphij	  func_stripname '-Wc,' '' "$arg"
2011267843Sdelphij	  args=$func_stripname_result
2012267843Sdelphij	  lastarg=
2013267843Sdelphij	  save_ifs="$IFS"; IFS=','
2014267843Sdelphij	  for arg in $args; do
2015267843Sdelphij	    IFS="$save_ifs"
2016267843Sdelphij	    func_append_quoted lastarg "$arg"
2017267843Sdelphij	  done
2018267843Sdelphij	  IFS="$save_ifs"
2019267843Sdelphij	  func_stripname ' ' '' "$lastarg"
2020267843Sdelphij	  lastarg=$func_stripname_result
2021267843Sdelphij
2022267843Sdelphij	  # Add the arguments to base_compile.
2023267843Sdelphij	  func_append base_compile " $lastarg"
2024267843Sdelphij	  continue
2025267843Sdelphij	  ;;
2026267843Sdelphij
2027267843Sdelphij	*)
2028267843Sdelphij	  # Accept the current argument as the source file.
2029267843Sdelphij	  # The previous "srcfile" becomes the current argument.
2030267843Sdelphij	  #
2031267843Sdelphij	  lastarg="$srcfile"
2032267843Sdelphij	  srcfile="$arg"
2033267843Sdelphij	  ;;
2034267843Sdelphij	esac  #  case $arg
2035267843Sdelphij	;;
2036267843Sdelphij      esac    #  case $arg_mode
2037267843Sdelphij
2038267843Sdelphij      # Aesthetically quote the previous argument.
2039267843Sdelphij      func_append_quoted base_compile "$lastarg"
2040267843Sdelphij    done # for arg
2041267843Sdelphij
2042267843Sdelphij    case $arg_mode in
2043267843Sdelphij    arg)
2044267843Sdelphij      func_fatal_error "you must specify an argument for -Xcompile"
2045267843Sdelphij      ;;
2046267843Sdelphij    target)
2047267843Sdelphij      func_fatal_error "you must specify a target with \`-o'"
2048267843Sdelphij      ;;
2049267843Sdelphij    *)
2050267843Sdelphij      # Get the name of the library object.
2051267843Sdelphij      test -z "$libobj" && {
2052267843Sdelphij	func_basename "$srcfile"
2053267843Sdelphij	libobj="$func_basename_result"
2054267843Sdelphij      }
2055267843Sdelphij      ;;
2056267843Sdelphij    esac
2057267843Sdelphij
2058267843Sdelphij    # Recognize several different file suffixes.
2059267843Sdelphij    # If the user specifies -o file.o, it is replaced with file.lo
2060267843Sdelphij    case $libobj in
2061267843Sdelphij    *.[cCFSifmso] | \
2062267843Sdelphij    *.ada | *.adb | *.ads | *.asm | \
2063267843Sdelphij    *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
2064267843Sdelphij    *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup)
2065267843Sdelphij      func_xform "$libobj"
2066267843Sdelphij      libobj=$func_xform_result
2067267843Sdelphij      ;;
2068267843Sdelphij    esac
2069267843Sdelphij
2070267843Sdelphij    case $libobj in
2071267843Sdelphij    *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
2072267843Sdelphij    *)
2073267843Sdelphij      func_fatal_error "cannot determine name of library object from \`$libobj'"
2074267843Sdelphij      ;;
2075267843Sdelphij    esac
2076267843Sdelphij
2077267843Sdelphij    func_infer_tag $base_compile
2078267843Sdelphij
2079267843Sdelphij    for arg in $later; do
2080267843Sdelphij      case $arg in
2081267843Sdelphij      -shared)
2082267843Sdelphij	test "$build_libtool_libs" != yes && \
2083267843Sdelphij	  func_fatal_configuration "can not build a shared library"
2084267843Sdelphij	build_old_libs=no
2085267843Sdelphij	continue
2086267843Sdelphij	;;
2087267843Sdelphij
2088267843Sdelphij      -static)
2089267843Sdelphij	build_libtool_libs=no
2090267843Sdelphij	build_old_libs=yes
2091267843Sdelphij	continue
2092267843Sdelphij	;;
2093267843Sdelphij
2094267843Sdelphij      -prefer-pic)
2095267843Sdelphij	pic_mode=yes
2096267843Sdelphij	continue
2097267843Sdelphij	;;
2098267843Sdelphij
2099267843Sdelphij      -prefer-non-pic)
2100267843Sdelphij	pic_mode=no
2101267843Sdelphij	continue
2102267843Sdelphij	;;
2103267843Sdelphij      esac
2104267843Sdelphij    done
2105267843Sdelphij
2106267843Sdelphij    func_quote_for_eval "$libobj"
2107267843Sdelphij    test "X$libobj" != "X$func_quote_for_eval_result" \
2108267843Sdelphij      && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'	 &()|`$[]' \
2109267843Sdelphij      && func_warning "libobj name \`$libobj' may not contain shell special characters."
2110267843Sdelphij    func_dirname_and_basename "$obj" "/" ""
2111267843Sdelphij    objname="$func_basename_result"
2112267843Sdelphij    xdir="$func_dirname_result"
2113267843Sdelphij    lobj=${xdir}$objdir/$objname
2114267843Sdelphij
2115267843Sdelphij    test -z "$base_compile" && \
2116267843Sdelphij      func_fatal_help "you must specify a compilation command"
2117267843Sdelphij
2118267843Sdelphij    # Delete any leftover library objects.
2119267843Sdelphij    if test "$build_old_libs" = yes; then
2120267843Sdelphij      removelist="$obj $lobj $libobj ${libobj}T"
2121267843Sdelphij    else
2122267843Sdelphij      removelist="$lobj $libobj ${libobj}T"
2123267843Sdelphij    fi
2124267843Sdelphij
2125267843Sdelphij    # On Cygwin there's no "real" PIC flag so we must build both object types
2126267843Sdelphij    case $host_os in
2127267843Sdelphij    cygwin* | mingw* | pw32* | os2* | cegcc*)
2128267843Sdelphij      pic_mode=default
2129267843Sdelphij      ;;
2130267843Sdelphij    esac
2131267843Sdelphij    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
2132267843Sdelphij      # non-PIC code in shared libraries is not supported
2133267843Sdelphij      pic_mode=default
2134267843Sdelphij    fi
2135267843Sdelphij
2136267843Sdelphij    # Calculate the filename of the output object if compiler does
2137267843Sdelphij    # not support -o with -c
2138267843Sdelphij    if test "$compiler_c_o" = no; then
2139267843Sdelphij      output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext}
2140267843Sdelphij      lockfile="$output_obj.lock"
2141267843Sdelphij    else
2142267843Sdelphij      output_obj=
2143267843Sdelphij      need_locks=no
2144267843Sdelphij      lockfile=
2145267843Sdelphij    fi
2146267843Sdelphij
2147267843Sdelphij    # Lock this critical section if it is needed
2148267843Sdelphij    # We use this script file to make the link, it avoids creating a new file
2149267843Sdelphij    if test "$need_locks" = yes; then
2150267843Sdelphij      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
2151267843Sdelphij	func_echo "Waiting for $lockfile to be removed"
2152267843Sdelphij	sleep 2
2153267843Sdelphij      done
2154267843Sdelphij    elif test "$need_locks" = warn; then
2155267843Sdelphij      if test -f "$lockfile"; then
2156267843Sdelphij	$ECHO "\
2157267843Sdelphij*** ERROR, $lockfile exists and contains:
2158267843Sdelphij`cat $lockfile 2>/dev/null`
2159267843Sdelphij
2160267843SdelphijThis indicates that another process is trying to use the same
2161267843Sdelphijtemporary object file, and libtool could not work around it because
2162267843Sdelphijyour compiler does not support \`-c' and \`-o' together.  If you
2163267843Sdelphijrepeat this compilation, it may succeed, by chance, but you had better
2164267843Sdelphijavoid parallel builds (make -j) in this platform, or get a better
2165267843Sdelphijcompiler."
2166267843Sdelphij
2167267843Sdelphij	$opt_dry_run || $RM $removelist
2168267843Sdelphij	exit $EXIT_FAILURE
2169267843Sdelphij      fi
2170267843Sdelphij      func_append removelist " $output_obj"
2171267843Sdelphij      $ECHO "$srcfile" > "$lockfile"
2172267843Sdelphij    fi
2173267843Sdelphij
2174267843Sdelphij    $opt_dry_run || $RM $removelist
2175267843Sdelphij    func_append removelist " $lockfile"
2176267843Sdelphij    trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
2177267843Sdelphij
2178267843Sdelphij    func_to_tool_file "$srcfile" func_convert_file_msys_to_w32
2179267843Sdelphij    srcfile=$func_to_tool_file_result
2180267843Sdelphij    func_quote_for_eval "$srcfile"
2181267843Sdelphij    qsrcfile=$func_quote_for_eval_result
2182267843Sdelphij
2183267843Sdelphij    # Only build a PIC object if we are building libtool libraries.
2184267843Sdelphij    if test "$build_libtool_libs" = yes; then
2185267843Sdelphij      # Without this assignment, base_compile gets emptied.
2186267843Sdelphij      fbsd_hideous_sh_bug=$base_compile
2187267843Sdelphij
2188267843Sdelphij      if test "$pic_mode" != no; then
2189267843Sdelphij	command="$base_compile $qsrcfile $pic_flag"
2190267843Sdelphij      else
2191267843Sdelphij	# Don't build PIC code
2192267843Sdelphij	command="$base_compile $qsrcfile"
2193267843Sdelphij      fi
2194267843Sdelphij
2195267843Sdelphij      func_mkdir_p "$xdir$objdir"
2196267843Sdelphij
2197267843Sdelphij      if test -z "$output_obj"; then
2198267843Sdelphij	# Place PIC objects in $objdir
2199267843Sdelphij	func_append command " -o $lobj"
2200267843Sdelphij      fi
2201267843Sdelphij
2202267843Sdelphij      func_show_eval_locale "$command"	\
2203267843Sdelphij          'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
2204267843Sdelphij
2205267843Sdelphij      if test "$need_locks" = warn &&
2206267843Sdelphij	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
2207267843Sdelphij	$ECHO "\
2208267843Sdelphij*** ERROR, $lockfile contains:
2209267843Sdelphij`cat $lockfile 2>/dev/null`
2210267843Sdelphij
2211267843Sdelphijbut it should contain:
2212267843Sdelphij$srcfile
2213267843Sdelphij
2214267843SdelphijThis indicates that another process is trying to use the same
2215267843Sdelphijtemporary object file, and libtool could not work around it because
2216267843Sdelphijyour compiler does not support \`-c' and \`-o' together.  If you
2217267843Sdelphijrepeat this compilation, it may succeed, by chance, but you had better
2218267843Sdelphijavoid parallel builds (make -j) in this platform, or get a better
2219267843Sdelphijcompiler."
2220267843Sdelphij
2221267843Sdelphij	$opt_dry_run || $RM $removelist
2222267843Sdelphij	exit $EXIT_FAILURE
2223267843Sdelphij      fi
2224267843Sdelphij
2225267843Sdelphij      # Just move the object if needed, then go on to compile the next one
2226267843Sdelphij      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
2227267843Sdelphij	func_show_eval '$MV "$output_obj" "$lobj"' \
2228267843Sdelphij	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
2229267843Sdelphij      fi
2230267843Sdelphij
2231267843Sdelphij      # Allow error messages only from the first compilation.
2232267843Sdelphij      if test "$suppress_opt" = yes; then
2233267843Sdelphij	suppress_output=' >/dev/null 2>&1'
2234267843Sdelphij      fi
2235267843Sdelphij    fi
2236267843Sdelphij
2237267843Sdelphij    # Only build a position-dependent object if we build old libraries.
2238267843Sdelphij    if test "$build_old_libs" = yes; then
2239267843Sdelphij      if test "$pic_mode" != yes; then
2240267843Sdelphij	# Don't build PIC code
2241267843Sdelphij	command="$base_compile $qsrcfile$pie_flag"
2242267843Sdelphij      else
2243267843Sdelphij	command="$base_compile $qsrcfile $pic_flag"
2244267843Sdelphij      fi
2245267843Sdelphij      if test "$compiler_c_o" = yes; then
2246267843Sdelphij	func_append command " -o $obj"
2247267843Sdelphij      fi
2248267843Sdelphij
2249267843Sdelphij      # Suppress compiler output if we already did a PIC compilation.
2250267843Sdelphij      func_append command "$suppress_output"
2251267843Sdelphij      func_show_eval_locale "$command" \
2252267843Sdelphij        '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
2253267843Sdelphij
2254267843Sdelphij      if test "$need_locks" = warn &&
2255267843Sdelphij	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
2256267843Sdelphij	$ECHO "\
2257267843Sdelphij*** ERROR, $lockfile contains:
2258267843Sdelphij`cat $lockfile 2>/dev/null`
2259267843Sdelphij
2260267843Sdelphijbut it should contain:
2261267843Sdelphij$srcfile
2262267843Sdelphij
2263267843SdelphijThis indicates that another process is trying to use the same
2264267843Sdelphijtemporary object file, and libtool could not work around it because
2265267843Sdelphijyour compiler does not support \`-c' and \`-o' together.  If you
2266267843Sdelphijrepeat this compilation, it may succeed, by chance, but you had better
2267267843Sdelphijavoid parallel builds (make -j) in this platform, or get a better
2268267843Sdelphijcompiler."
2269267843Sdelphij
2270267843Sdelphij	$opt_dry_run || $RM $removelist
2271267843Sdelphij	exit $EXIT_FAILURE
2272267843Sdelphij      fi
2273267843Sdelphij
2274267843Sdelphij      # Just move the object if needed
2275267843Sdelphij      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
2276267843Sdelphij	func_show_eval '$MV "$output_obj" "$obj"' \
2277267843Sdelphij	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
2278267843Sdelphij      fi
2279267843Sdelphij    fi
2280267843Sdelphij
2281267843Sdelphij    $opt_dry_run || {
2282267843Sdelphij      func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
2283267843Sdelphij
2284267843Sdelphij      # Unlock the critical section if it was locked
2285267843Sdelphij      if test "$need_locks" != no; then
2286267843Sdelphij	removelist=$lockfile
2287267843Sdelphij        $RM "$lockfile"
2288267843Sdelphij      fi
2289267843Sdelphij    }
2290267843Sdelphij
2291267843Sdelphij    exit $EXIT_SUCCESS
2292267843Sdelphij}
2293267843Sdelphij
2294267843Sdelphij$opt_help || {
2295267843Sdelphij  test "$opt_mode" = compile && func_mode_compile ${1+"$@"}
2296267843Sdelphij}
2297267843Sdelphij
2298267843Sdelphijfunc_mode_help ()
2299267843Sdelphij{
2300267843Sdelphij    # We need to display help for each of the modes.
2301267843Sdelphij    case $opt_mode in
2302267843Sdelphij      "")
2303267843Sdelphij        # Generic help is extracted from the usage comments
2304267843Sdelphij        # at the start of this file.
2305267843Sdelphij        func_help
2306267843Sdelphij        ;;
2307267843Sdelphij
2308267843Sdelphij      clean)
2309267843Sdelphij        $ECHO \
2310267843Sdelphij"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
2311267843Sdelphij
2312267843SdelphijRemove files from the build directory.
2313267843Sdelphij
2314267843SdelphijRM is the name of the program to use to delete files associated with each FILE
2315267843Sdelphij(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
2316267843Sdelphijto RM.
2317267843Sdelphij
2318267843SdelphijIf FILE is a libtool library, object or program, all the files associated
2319267843Sdelphijwith it are deleted. Otherwise, only FILE itself is deleted using RM."
2320267843Sdelphij        ;;
2321267843Sdelphij
2322267843Sdelphij      compile)
2323267843Sdelphij      $ECHO \
2324267843Sdelphij"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
2325267843Sdelphij
2326267843SdelphijCompile a source file into a libtool library object.
2327267843Sdelphij
2328267843SdelphijThis mode accepts the following additional options:
2329267843Sdelphij
2330267843Sdelphij  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
2331267843Sdelphij  -no-suppress      do not suppress compiler output for multiple passes
2332267843Sdelphij  -prefer-pic       try to build PIC objects only
2333267843Sdelphij  -prefer-non-pic   try to build non-PIC objects only
2334267843Sdelphij  -shared           do not build a \`.o' file suitable for static linking
2335267843Sdelphij  -static           only build a \`.o' file suitable for static linking
2336267843Sdelphij  -Wc,FLAG          pass FLAG directly to the compiler
2337267843Sdelphij
2338267843SdelphijCOMPILE-COMMAND is a command to be used in creating a \`standard' object file
2339267843Sdelphijfrom the given SOURCEFILE.
2340267843Sdelphij
2341267843SdelphijThe output file name is determined by removing the directory component from
2342267843SdelphijSOURCEFILE, then substituting the C source code suffix \`.c' with the
2343267843Sdelphijlibrary object suffix, \`.lo'."
2344267843Sdelphij        ;;
2345267843Sdelphij
2346267843Sdelphij      execute)
2347267843Sdelphij        $ECHO \
2348267843Sdelphij"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
2349267843Sdelphij
2350267843SdelphijAutomatically set library path, then run a program.
2351267843Sdelphij
2352267843SdelphijThis mode accepts the following additional options:
2353267843Sdelphij
2354267843Sdelphij  -dlopen FILE      add the directory containing FILE to the library path
2355267843Sdelphij
2356267843SdelphijThis mode sets the library path environment variable according to \`-dlopen'
2357267843Sdelphijflags.
2358267843Sdelphij
2359267843SdelphijIf any of the ARGS are libtool executable wrappers, then they are translated
2360267843Sdelphijinto their corresponding uninstalled binary, and any of their required library
2361267843Sdelphijdirectories are added to the library path.
2362267843Sdelphij
2363267843SdelphijThen, COMMAND is executed, with ARGS as arguments."
2364267843Sdelphij        ;;
2365267843Sdelphij
2366267843Sdelphij      finish)
2367267843Sdelphij        $ECHO \
2368267843Sdelphij"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
2369267843Sdelphij
2370267843SdelphijComplete the installation of libtool libraries.
2371267843Sdelphij
2372267843SdelphijEach LIBDIR is a directory that contains libtool libraries.
2373267843Sdelphij
2374267843SdelphijThe commands that this mode executes may require superuser privileges.  Use
2375267843Sdelphijthe \`--dry-run' option if you just want to see what would be executed."
2376267843Sdelphij        ;;
2377267843Sdelphij
2378267843Sdelphij      install)
2379267843Sdelphij        $ECHO \
2380267843Sdelphij"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
2381267843Sdelphij
2382267843SdelphijInstall executables or libraries.
2383267843Sdelphij
2384267843SdelphijINSTALL-COMMAND is the installation command.  The first component should be
2385267843Sdelphijeither the \`install' or \`cp' program.
2386267843Sdelphij
2387267843SdelphijThe following components of INSTALL-COMMAND are treated specially:
2388267843Sdelphij
2389267843Sdelphij  -inst-prefix-dir PREFIX-DIR  Use PREFIX-DIR as a staging area for installation
2390267843Sdelphij
2391267843SdelphijThe rest of the components are interpreted as arguments to that command (only
2392267843SdelphijBSD-compatible install options are recognized)."
2393267843Sdelphij        ;;
2394267843Sdelphij
2395267843Sdelphij      link)
2396267843Sdelphij        $ECHO \
2397267843Sdelphij"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
2398267843Sdelphij
2399267843SdelphijLink object files or libraries together to form another library, or to
2400267843Sdelphijcreate an executable program.
2401267843Sdelphij
2402267843SdelphijLINK-COMMAND is a command using the C compiler that you would use to create
2403267843Sdelphija program from several object files.
2404267843Sdelphij
2405267843SdelphijThe following components of LINK-COMMAND are treated specially:
2406267843Sdelphij
2407267843Sdelphij  -all-static       do not do any dynamic linking at all
2408267843Sdelphij  -avoid-version    do not add a version suffix if possible
2409267843Sdelphij  -bindir BINDIR    specify path to binaries directory (for systems where
2410267843Sdelphij                    libraries must be found in the PATH setting at runtime)
2411267843Sdelphij  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
2412267843Sdelphij  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
2413267843Sdelphij  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
2414267843Sdelphij  -export-symbols SYMFILE
2415267843Sdelphij                    try to export only the symbols listed in SYMFILE
2416267843Sdelphij  -export-symbols-regex REGEX
2417267843Sdelphij                    try to export only the symbols matching REGEX
2418267843Sdelphij  -LLIBDIR          search LIBDIR for required installed libraries
2419267843Sdelphij  -lNAME            OUTPUT-FILE requires the installed library libNAME
2420267843Sdelphij  -module           build a library that can dlopened
2421267843Sdelphij  -no-fast-install  disable the fast-install mode
2422267843Sdelphij  -no-install       link a not-installable executable
2423267843Sdelphij  -no-undefined     declare that a library does not refer to external symbols
2424267843Sdelphij  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
2425267843Sdelphij  -objectlist FILE  Use a list of object files found in FILE to specify objects
2426267843Sdelphij  -precious-files-regex REGEX
2427267843Sdelphij                    don't remove output files matching REGEX
2428267843Sdelphij  -release RELEASE  specify package release information
2429267843Sdelphij  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
2430267843Sdelphij  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
2431267843Sdelphij  -shared           only do dynamic linking of libtool libraries
2432267843Sdelphij  -shrext SUFFIX    override the standard shared library file extension
2433267843Sdelphij  -static           do not do any dynamic linking of uninstalled libtool libraries
2434267843Sdelphij  -static-libtool-libs
2435267843Sdelphij                    do not do any dynamic linking of libtool libraries
2436267843Sdelphij  -version-info CURRENT[:REVISION[:AGE]]
2437267843Sdelphij                    specify library version info [each variable defaults to 0]
2438267843Sdelphij  -weak LIBNAME     declare that the target provides the LIBNAME interface
2439267843Sdelphij  -Wc,FLAG
2440267843Sdelphij  -Xcompiler FLAG   pass linker-specific FLAG directly to the compiler
2441267843Sdelphij  -Wl,FLAG
2442267843Sdelphij  -Xlinker FLAG     pass linker-specific FLAG directly to the linker
2443267843Sdelphij  -XCClinker FLAG   pass link-specific FLAG to the compiler driver (CC)
2444267843Sdelphij
2445267843SdelphijAll other options (arguments beginning with \`-') are ignored.
2446267843Sdelphij
2447267843SdelphijEvery other argument is treated as a filename.  Files ending in \`.la' are
2448267843Sdelphijtreated as uninstalled libtool libraries, other files are standard or library
2449267843Sdelphijobject files.
2450267843Sdelphij
2451267843SdelphijIf the OUTPUT-FILE ends in \`.la', then a libtool library is created,
2452267843Sdelphijonly library objects (\`.lo' files) may be specified, and \`-rpath' is
2453267843Sdelphijrequired, except when creating a convenience library.
2454267843Sdelphij
2455267843SdelphijIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
2456267843Sdelphijusing \`ar' and \`ranlib', or on Windows using \`lib'.
2457267843Sdelphij
2458267843SdelphijIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
2459267843Sdelphijis created, otherwise an executable program is created."
2460267843Sdelphij        ;;
2461267843Sdelphij
2462267843Sdelphij      uninstall)
2463267843Sdelphij        $ECHO \
2464267843Sdelphij"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
2465267843Sdelphij
2466267843SdelphijRemove libraries from an installation directory.
2467267843Sdelphij
2468267843SdelphijRM is the name of the program to use to delete files associated with each FILE
2469267843Sdelphij(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
2470267843Sdelphijto RM.
2471267843Sdelphij
2472267843SdelphijIf FILE is a libtool library, all the files associated with it are deleted.
2473267843SdelphijOtherwise, only FILE itself is deleted using RM."
2474267843Sdelphij        ;;
2475267843Sdelphij
2476267843Sdelphij      *)
2477267843Sdelphij        func_fatal_help "invalid operation mode \`$opt_mode'"
2478267843Sdelphij        ;;
2479267843Sdelphij    esac
2480267843Sdelphij
2481267843Sdelphij    echo
2482267843Sdelphij    $ECHO "Try \`$progname --help' for more information about other modes."
2483267843Sdelphij}
2484267843Sdelphij
2485267843Sdelphij# Now that we've collected a possible --mode arg, show help if necessary
2486267843Sdelphijif $opt_help; then
2487267843Sdelphij  if test "$opt_help" = :; then
2488267843Sdelphij    func_mode_help
2489267843Sdelphij  else
2490267843Sdelphij    {
2491267843Sdelphij      func_help noexit
2492267843Sdelphij      for opt_mode in compile link execute install finish uninstall clean; do
2493267843Sdelphij	func_mode_help
2494267843Sdelphij      done
2495267843Sdelphij    } | sed -n '1p; 2,$s/^Usage:/  or: /p'
2496267843Sdelphij    {
2497267843Sdelphij      func_help noexit
2498267843Sdelphij      for opt_mode in compile link execute install finish uninstall clean; do
2499267843Sdelphij	echo
2500267843Sdelphij	func_mode_help
2501267843Sdelphij      done
2502267843Sdelphij    } |
2503267843Sdelphij    sed '1d
2504267843Sdelphij      /^When reporting/,/^Report/{
2505267843Sdelphij	H
2506267843Sdelphij	d
2507267843Sdelphij      }
2508267843Sdelphij      $x
2509267843Sdelphij      /information about other modes/d
2510267843Sdelphij      /more detailed .*MODE/d
2511267843Sdelphij      s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
2512267843Sdelphij  fi
2513267843Sdelphij  exit $?
2514267843Sdelphijfi
2515267843Sdelphij
2516267843Sdelphij
2517267843Sdelphij# func_mode_execute arg...
2518267843Sdelphijfunc_mode_execute ()
2519267843Sdelphij{
2520267843Sdelphij    $opt_debug
2521267843Sdelphij    # The first argument is the command name.
2522267843Sdelphij    cmd="$nonopt"
2523267843Sdelphij    test -z "$cmd" && \
2524267843Sdelphij      func_fatal_help "you must specify a COMMAND"
2525267843Sdelphij
2526267843Sdelphij    # Handle -dlopen flags immediately.
2527267843Sdelphij    for file in $opt_dlopen; do
2528267843Sdelphij      test -f "$file" \
2529267843Sdelphij	|| func_fatal_help "\`$file' is not a file"
2530267843Sdelphij
2531267843Sdelphij      dir=
2532267843Sdelphij      case $file in
2533267843Sdelphij      *.la)
2534267843Sdelphij	func_resolve_sysroot "$file"
2535267843Sdelphij	file=$func_resolve_sysroot_result
2536267843Sdelphij
2537267843Sdelphij	# Check to see that this really is a libtool archive.
2538267843Sdelphij	func_lalib_unsafe_p "$file" \
2539267843Sdelphij	  || func_fatal_help "\`$lib' is not a valid libtool archive"
2540267843Sdelphij
2541267843Sdelphij	# Read the libtool library.
2542267843Sdelphij	dlname=
2543267843Sdelphij	library_names=
2544267843Sdelphij	func_source "$file"
2545267843Sdelphij
2546267843Sdelphij	# Skip this library if it cannot be dlopened.
2547267843Sdelphij	if test -z "$dlname"; then
2548267843Sdelphij	  # Warn if it was a shared library.
2549267843Sdelphij	  test -n "$library_names" && \
2550267843Sdelphij	    func_warning "\`$file' was not linked with \`-export-dynamic'"
2551267843Sdelphij	  continue
2552267843Sdelphij	fi
2553267843Sdelphij
2554267843Sdelphij	func_dirname "$file" "" "."
2555267843Sdelphij	dir="$func_dirname_result"
2556267843Sdelphij
2557267843Sdelphij	if test -f "$dir/$objdir/$dlname"; then
2558267843Sdelphij	  func_append dir "/$objdir"
2559267843Sdelphij	else
2560267843Sdelphij	  if test ! -f "$dir/$dlname"; then
2561267843Sdelphij	    func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'"
2562267843Sdelphij	  fi
2563267843Sdelphij	fi
2564267843Sdelphij	;;
2565267843Sdelphij
2566267843Sdelphij      *.lo)
2567267843Sdelphij	# Just add the directory containing the .lo file.
2568267843Sdelphij	func_dirname "$file" "" "."
2569267843Sdelphij	dir="$func_dirname_result"
2570267843Sdelphij	;;
2571267843Sdelphij
2572267843Sdelphij      *)
2573267843Sdelphij	func_warning "\`-dlopen' is ignored for non-libtool libraries and objects"
2574267843Sdelphij	continue
2575267843Sdelphij	;;
2576267843Sdelphij      esac
2577267843Sdelphij
2578267843Sdelphij      # Get the absolute pathname.
2579267843Sdelphij      absdir=`cd "$dir" && pwd`
2580267843Sdelphij      test -n "$absdir" && dir="$absdir"
2581267843Sdelphij
2582267843Sdelphij      # Now add the directory to shlibpath_var.
2583267843Sdelphij      if eval "test -z \"\$$shlibpath_var\""; then
2584267843Sdelphij	eval "$shlibpath_var=\"\$dir\""
2585267843Sdelphij      else
2586267843Sdelphij	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
2587267843Sdelphij      fi
2588267843Sdelphij    done
2589267843Sdelphij
2590267843Sdelphij    # This variable tells wrapper scripts just to set shlibpath_var
2591267843Sdelphij    # rather than running their programs.
2592267843Sdelphij    libtool_execute_magic="$magic"
2593267843Sdelphij
2594267843Sdelphij    # Check if any of the arguments is a wrapper script.
2595267843Sdelphij    args=
2596267843Sdelphij    for file
2597267843Sdelphij    do
2598267843Sdelphij      case $file in
2599267843Sdelphij      -* | *.la | *.lo ) ;;
2600267843Sdelphij      *)
2601267843Sdelphij	# Do a test to see if this is really a libtool program.
2602267843Sdelphij	if func_ltwrapper_script_p "$file"; then
2603267843Sdelphij	  func_source "$file"
2604267843Sdelphij	  # Transform arg to wrapped name.
2605267843Sdelphij	  file="$progdir/$program"
2606267843Sdelphij	elif func_ltwrapper_executable_p "$file"; then
2607267843Sdelphij	  func_ltwrapper_scriptname "$file"
2608267843Sdelphij	  func_source "$func_ltwrapper_scriptname_result"
2609267843Sdelphij	  # Transform arg to wrapped name.
2610267843Sdelphij	  file="$progdir/$program"
2611267843Sdelphij	fi
2612267843Sdelphij	;;
2613267843Sdelphij      esac
2614267843Sdelphij      # Quote arguments (to preserve shell metacharacters).
2615267843Sdelphij      func_append_quoted args "$file"
2616267843Sdelphij    done
2617267843Sdelphij
2618267843Sdelphij    if test "X$opt_dry_run" = Xfalse; then
2619267843Sdelphij      if test -n "$shlibpath_var"; then
2620267843Sdelphij	# Export the shlibpath_var.
2621267843Sdelphij	eval "export $shlibpath_var"
2622267843Sdelphij      fi
2623267843Sdelphij
2624267843Sdelphij      # Restore saved environment variables
2625267843Sdelphij      for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
2626267843Sdelphij      do
2627267843Sdelphij	eval "if test \"\${save_$lt_var+set}\" = set; then
2628267843Sdelphij                $lt_var=\$save_$lt_var; export $lt_var
2629267843Sdelphij	      else
2630267843Sdelphij		$lt_unset $lt_var
2631267843Sdelphij	      fi"
2632267843Sdelphij      done
2633267843Sdelphij
2634267843Sdelphij      # Now prepare to actually exec the command.
2635267843Sdelphij      exec_cmd="\$cmd$args"
2636267843Sdelphij    else
2637267843Sdelphij      # Display what would be done.
2638267843Sdelphij      if test -n "$shlibpath_var"; then
2639267843Sdelphij	eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
2640267843Sdelphij	echo "export $shlibpath_var"
2641267843Sdelphij      fi
2642267843Sdelphij      $ECHO "$cmd$args"
2643267843Sdelphij      exit $EXIT_SUCCESS
2644267843Sdelphij    fi
2645267843Sdelphij}
2646267843Sdelphij
2647267843Sdelphijtest "$opt_mode" = execute && func_mode_execute ${1+"$@"}
2648267843Sdelphij
2649267843Sdelphij
2650267843Sdelphij# func_mode_finish arg...
2651267843Sdelphijfunc_mode_finish ()
2652267843Sdelphij{
2653267843Sdelphij    $opt_debug
2654267843Sdelphij    libs=
2655267843Sdelphij    libdirs=
2656267843Sdelphij    admincmds=
2657267843Sdelphij
2658267843Sdelphij    for opt in "$nonopt" ${1+"$@"}
2659267843Sdelphij    do
2660267843Sdelphij      if test -d "$opt"; then
2661267843Sdelphij	func_append libdirs " $opt"
2662267843Sdelphij
2663267843Sdelphij      elif test -f "$opt"; then
2664267843Sdelphij	if func_lalib_unsafe_p "$opt"; then
2665267843Sdelphij	  func_append libs " $opt"
2666267843Sdelphij	else
2667267843Sdelphij	  func_warning "\`$opt' is not a valid libtool archive"
2668267843Sdelphij	fi
2669267843Sdelphij
2670267843Sdelphij      else
2671267843Sdelphij	func_fatal_error "invalid argument \`$opt'"
2672267843Sdelphij      fi
2673267843Sdelphij    done
2674267843Sdelphij
2675267843Sdelphij    if test -n "$libs"; then
2676267843Sdelphij      if test -n "$lt_sysroot"; then
2677267843Sdelphij        sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"`
2678267843Sdelphij        sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;"
2679267843Sdelphij      else
2680267843Sdelphij        sysroot_cmd=
2681267843Sdelphij      fi
2682267843Sdelphij
2683267843Sdelphij      # Remove sysroot references
2684267843Sdelphij      if $opt_dry_run; then
2685267843Sdelphij        for lib in $libs; do
2686267843Sdelphij          echo "removing references to $lt_sysroot and \`=' prefixes from $lib"
2687267843Sdelphij        done
2688267843Sdelphij      else
2689267843Sdelphij        tmpdir=`func_mktempdir`
2690267843Sdelphij        for lib in $libs; do
2691267843Sdelphij	  sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
2692267843Sdelphij	    > $tmpdir/tmp-la
2693267843Sdelphij	  mv -f $tmpdir/tmp-la $lib
2694267843Sdelphij	done
2695267843Sdelphij        ${RM}r "$tmpdir"
2696267843Sdelphij      fi
2697267843Sdelphij    fi
2698267843Sdelphij
2699267843Sdelphij    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
2700267843Sdelphij      for libdir in $libdirs; do
2701267843Sdelphij	if test -n "$finish_cmds"; then
2702267843Sdelphij	  # Do each command in the finish commands.
2703267843Sdelphij	  func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
2704267843Sdelphij'"$cmd"'"'
2705267843Sdelphij	fi
2706267843Sdelphij	if test -n "$finish_eval"; then
2707267843Sdelphij	  # Do the single finish_eval.
2708267843Sdelphij	  eval cmds=\"$finish_eval\"
2709267843Sdelphij	  $opt_dry_run || eval "$cmds" || func_append admincmds "
2710267843Sdelphij       $cmds"
2711267843Sdelphij	fi
2712267843Sdelphij      done
2713267843Sdelphij    fi
2714267843Sdelphij
2715267843Sdelphij    # Exit here if they wanted silent mode.
2716267843Sdelphij    $opt_silent && exit $EXIT_SUCCESS
2717267843Sdelphij
2718267843Sdelphij    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
2719267843Sdelphij      echo "----------------------------------------------------------------------"
2720267843Sdelphij      echo "Libraries have been installed in:"
2721267843Sdelphij      for libdir in $libdirs; do
2722267843Sdelphij	$ECHO "   $libdir"
2723267843Sdelphij      done
2724267843Sdelphij      echo
2725267843Sdelphij      echo "If you ever happen to want to link against installed libraries"
2726267843Sdelphij      echo "in a given directory, LIBDIR, you must either use libtool, and"
2727267843Sdelphij      echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
2728267843Sdelphij      echo "flag during linking and do at least one of the following:"
2729267843Sdelphij      if test -n "$shlibpath_var"; then
2730267843Sdelphij	echo "   - add LIBDIR to the \`$shlibpath_var' environment variable"
2731267843Sdelphij	echo "     during execution"
2732267843Sdelphij      fi
2733267843Sdelphij      if test -n "$runpath_var"; then
2734267843Sdelphij	echo "   - add LIBDIR to the \`$runpath_var' environment variable"
2735267843Sdelphij	echo "     during linking"
2736267843Sdelphij      fi
2737267843Sdelphij      if test -n "$hardcode_libdir_flag_spec"; then
2738267843Sdelphij	libdir=LIBDIR
2739267843Sdelphij	eval flag=\"$hardcode_libdir_flag_spec\"
2740267843Sdelphij
2741267843Sdelphij	$ECHO "   - use the \`$flag' linker flag"
2742267843Sdelphij      fi
2743267843Sdelphij      if test -n "$admincmds"; then
2744267843Sdelphij	$ECHO "   - have your system administrator run these commands:$admincmds"
2745267843Sdelphij      fi
2746267843Sdelphij      if test -f /etc/ld.so.conf; then
2747267843Sdelphij	echo "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
2748267843Sdelphij      fi
2749267843Sdelphij      echo
2750267843Sdelphij
2751267843Sdelphij      echo "See any operating system documentation about shared libraries for"
2752267843Sdelphij      case $host in
2753267843Sdelphij	solaris2.[6789]|solaris2.1[0-9])
2754267843Sdelphij	  echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
2755267843Sdelphij	  echo "pages."
2756267843Sdelphij	  ;;
2757267843Sdelphij	*)
2758267843Sdelphij	  echo "more information, such as the ld(1) and ld.so(8) manual pages."
2759267843Sdelphij	  ;;
2760267843Sdelphij      esac
2761267843Sdelphij      echo "----------------------------------------------------------------------"
2762267843Sdelphij    fi
2763267843Sdelphij    exit $EXIT_SUCCESS
2764267843Sdelphij}
2765267843Sdelphij
2766267843Sdelphijtest "$opt_mode" = finish && func_mode_finish ${1+"$@"}
2767267843Sdelphij
2768267843Sdelphij
2769267843Sdelphij# func_mode_install arg...
2770267843Sdelphijfunc_mode_install ()
2771267843Sdelphij{
2772267843Sdelphij    $opt_debug
2773267843Sdelphij    # There may be an optional sh(1) argument at the beginning of
2774267843Sdelphij    # install_prog (especially on Windows NT).
2775267843Sdelphij    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
2776267843Sdelphij       # Allow the use of GNU shtool's install command.
2777267843Sdelphij       case $nonopt in *shtool*) :;; *) false;; esac; then
2778267843Sdelphij      # Aesthetically quote it.
2779267843Sdelphij      func_quote_for_eval "$nonopt"
2780267843Sdelphij      install_prog="$func_quote_for_eval_result "
2781267843Sdelphij      arg=$1
2782267843Sdelphij      shift
2783267843Sdelphij    else
2784267843Sdelphij      install_prog=
2785267843Sdelphij      arg=$nonopt
2786267843Sdelphij    fi
2787267843Sdelphij
2788267843Sdelphij    # The real first argument should be the name of the installation program.
2789267843Sdelphij    # Aesthetically quote it.
2790267843Sdelphij    func_quote_for_eval "$arg"
2791267843Sdelphij    func_append install_prog "$func_quote_for_eval_result"
2792267843Sdelphij    install_shared_prog=$install_prog
2793267843Sdelphij    case " $install_prog " in
2794267843Sdelphij      *[\\\ /]cp\ *) install_cp=: ;;
2795267843Sdelphij      *) install_cp=false ;;
2796267843Sdelphij    esac
2797267843Sdelphij
2798267843Sdelphij    # We need to accept at least all the BSD install flags.
2799267843Sdelphij    dest=
2800267843Sdelphij    files=
2801267843Sdelphij    opts=
2802267843Sdelphij    prev=
2803267843Sdelphij    install_type=
2804267843Sdelphij    isdir=no
2805267843Sdelphij    stripme=
2806267843Sdelphij    no_mode=:
2807267843Sdelphij    for arg
2808267843Sdelphij    do
2809267843Sdelphij      arg2=
2810267843Sdelphij      if test -n "$dest"; then
2811267843Sdelphij	func_append files " $dest"
2812267843Sdelphij	dest=$arg
2813267843Sdelphij	continue
2814267843Sdelphij      fi
2815267843Sdelphij
2816267843Sdelphij      case $arg in
2817267843Sdelphij      -d) isdir=yes ;;
2818267843Sdelphij      -f)
2819267843Sdelphij	if $install_cp; then :; else
2820267843Sdelphij	  prev=$arg
2821267843Sdelphij	fi
2822267843Sdelphij	;;
2823267843Sdelphij      -g | -m | -o)
2824267843Sdelphij	prev=$arg
2825267843Sdelphij	;;
2826267843Sdelphij      -s)
2827267843Sdelphij	stripme=" -s"
2828267843Sdelphij	continue
2829267843Sdelphij	;;
2830267843Sdelphij      -*)
2831267843Sdelphij	;;
2832267843Sdelphij      *)
2833267843Sdelphij	# If the previous option needed an argument, then skip it.
2834267843Sdelphij	if test -n "$prev"; then
2835267843Sdelphij	  if test "x$prev" = x-m && test -n "$install_override_mode"; then
2836267843Sdelphij	    arg2=$install_override_mode
2837267843Sdelphij	    no_mode=false
2838267843Sdelphij	  fi
2839267843Sdelphij	  prev=
2840267843Sdelphij	else
2841267843Sdelphij	  dest=$arg
2842267843Sdelphij	  continue
2843267843Sdelphij	fi
2844267843Sdelphij	;;
2845267843Sdelphij      esac
2846267843Sdelphij
2847267843Sdelphij      # Aesthetically quote the argument.
2848267843Sdelphij      func_quote_for_eval "$arg"
2849267843Sdelphij      func_append install_prog " $func_quote_for_eval_result"
2850267843Sdelphij      if test -n "$arg2"; then
2851267843Sdelphij	func_quote_for_eval "$arg2"
2852267843Sdelphij      fi
2853267843Sdelphij      func_append install_shared_prog " $func_quote_for_eval_result"
2854267843Sdelphij    done
2855267843Sdelphij
2856267843Sdelphij    test -z "$install_prog" && \
2857267843Sdelphij      func_fatal_help "you must specify an install program"
2858267843Sdelphij
2859267843Sdelphij    test -n "$prev" && \
2860267843Sdelphij      func_fatal_help "the \`$prev' option requires an argument"
2861267843Sdelphij
2862267843Sdelphij    if test -n "$install_override_mode" && $no_mode; then
2863267843Sdelphij      if $install_cp; then :; else
2864267843Sdelphij	func_quote_for_eval "$install_override_mode"
2865267843Sdelphij	func_append install_shared_prog " -m $func_quote_for_eval_result"
2866267843Sdelphij      fi
2867267843Sdelphij    fi
2868267843Sdelphij
2869267843Sdelphij    if test -z "$files"; then
2870267843Sdelphij      if test -z "$dest"; then
2871267843Sdelphij	func_fatal_help "no file or destination specified"
2872267843Sdelphij      else
2873267843Sdelphij	func_fatal_help "you must specify a destination"
2874267843Sdelphij      fi
2875267843Sdelphij    fi
2876267843Sdelphij
2877267843Sdelphij    # Strip any trailing slash from the destination.
2878267843Sdelphij    func_stripname '' '/' "$dest"
2879267843Sdelphij    dest=$func_stripname_result
2880267843Sdelphij
2881267843Sdelphij    # Check to see that the destination is a directory.
2882267843Sdelphij    test -d "$dest" && isdir=yes
2883267843Sdelphij    if test "$isdir" = yes; then
2884267843Sdelphij      destdir="$dest"
2885267843Sdelphij      destname=
2886267843Sdelphij    else
2887267843Sdelphij      func_dirname_and_basename "$dest" "" "."
2888267843Sdelphij      destdir="$func_dirname_result"
2889267843Sdelphij      destname="$func_basename_result"
2890267843Sdelphij
2891267843Sdelphij      # Not a directory, so check to see that there is only one file specified.
2892267843Sdelphij      set dummy $files; shift
2893267843Sdelphij      test "$#" -gt 1 && \
2894267843Sdelphij	func_fatal_help "\`$dest' is not a directory"
2895267843Sdelphij    fi
2896267843Sdelphij    case $destdir in
2897267843Sdelphij    [\\/]* | [A-Za-z]:[\\/]*) ;;
2898267843Sdelphij    *)
2899267843Sdelphij      for file in $files; do
2900267843Sdelphij	case $file in
2901267843Sdelphij	*.lo) ;;
2902267843Sdelphij	*)
2903267843Sdelphij	  func_fatal_help "\`$destdir' must be an absolute directory name"
2904267843Sdelphij	  ;;
2905267843Sdelphij	esac
2906267843Sdelphij      done
2907267843Sdelphij      ;;
2908267843Sdelphij    esac
2909267843Sdelphij
2910267843Sdelphij    # This variable tells wrapper scripts just to set variables rather
2911267843Sdelphij    # than running their programs.
2912267843Sdelphij    libtool_install_magic="$magic"
2913267843Sdelphij
2914267843Sdelphij    staticlibs=
2915267843Sdelphij    future_libdirs=
2916267843Sdelphij    current_libdirs=
2917267843Sdelphij    for file in $files; do
2918267843Sdelphij
2919267843Sdelphij      # Do each installation.
2920267843Sdelphij      case $file in
2921267843Sdelphij      *.$libext)
2922267843Sdelphij	# Do the static libraries later.
2923267843Sdelphij	func_append staticlibs " $file"
2924267843Sdelphij	;;
2925267843Sdelphij
2926267843Sdelphij      *.la)
2927267843Sdelphij	func_resolve_sysroot "$file"
2928267843Sdelphij	file=$func_resolve_sysroot_result
2929267843Sdelphij
2930267843Sdelphij	# Check to see that this really is a libtool archive.
2931267843Sdelphij	func_lalib_unsafe_p "$file" \
2932267843Sdelphij	  || func_fatal_help "\`$file' is not a valid libtool archive"
2933267843Sdelphij
2934267843Sdelphij	library_names=
2935267843Sdelphij	old_library=
2936267843Sdelphij	relink_command=
2937267843Sdelphij	func_source "$file"
2938267843Sdelphij
2939267843Sdelphij	# Add the libdir to current_libdirs if it is the destination.
2940267843Sdelphij	if test "X$destdir" = "X$libdir"; then
2941267843Sdelphij	  case "$current_libdirs " in
2942267843Sdelphij	  *" $libdir "*) ;;
2943267843Sdelphij	  *) func_append current_libdirs " $libdir" ;;
2944267843Sdelphij	  esac
2945267843Sdelphij	else
2946267843Sdelphij	  # Note the libdir as a future libdir.
2947267843Sdelphij	  case "$future_libdirs " in
2948267843Sdelphij	  *" $libdir "*) ;;
2949267843Sdelphij	  *) func_append future_libdirs " $libdir" ;;
2950267843Sdelphij	  esac
2951267843Sdelphij	fi
2952267843Sdelphij
2953267843Sdelphij	func_dirname "$file" "/" ""
2954267843Sdelphij	dir="$func_dirname_result"
2955267843Sdelphij	func_append dir "$objdir"
2956267843Sdelphij
2957267843Sdelphij	if test -n "$relink_command"; then
2958267843Sdelphij	  # Determine the prefix the user has applied to our future dir.
2959267843Sdelphij	  inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
2960267843Sdelphij
2961267843Sdelphij	  # Don't allow the user to place us outside of our expected
2962267843Sdelphij	  # location b/c this prevents finding dependent libraries that
2963267843Sdelphij	  # are installed to the same prefix.
2964267843Sdelphij	  # At present, this check doesn't affect windows .dll's that
2965267843Sdelphij	  # are installed into $libdir/../bin (currently, that works fine)
2966267843Sdelphij	  # but it's something to keep an eye on.
2967267843Sdelphij	  test "$inst_prefix_dir" = "$destdir" && \
2968267843Sdelphij	    func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
2969267843Sdelphij
2970267843Sdelphij	  if test -n "$inst_prefix_dir"; then
2971267843Sdelphij	    # Stick the inst_prefix_dir data into the link command.
2972267843Sdelphij	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
2973267843Sdelphij	  else
2974267843Sdelphij	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
2975267843Sdelphij	  fi
2976267843Sdelphij
2977267843Sdelphij	  func_warning "relinking \`$file'"
2978267843Sdelphij	  func_show_eval "$relink_command" \
2979267843Sdelphij	    'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
2980267843Sdelphij	fi
2981267843Sdelphij
2982267843Sdelphij	# See the names of the shared library.
2983267843Sdelphij	set dummy $library_names; shift
2984267843Sdelphij	if test -n "$1"; then
2985267843Sdelphij	  realname="$1"
2986267843Sdelphij	  shift
2987267843Sdelphij
2988267843Sdelphij	  srcname="$realname"
2989267843Sdelphij	  test -n "$relink_command" && srcname="$realname"T
2990267843Sdelphij
2991267843Sdelphij	  # Install the shared library and build the symlinks.
2992267843Sdelphij	  func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
2993267843Sdelphij	      'exit $?'
2994267843Sdelphij	  tstripme="$stripme"
2995267843Sdelphij	  case $host_os in
2996267843Sdelphij	  cygwin* | mingw* | pw32* | cegcc*)
2997267843Sdelphij	    case $realname in
2998267843Sdelphij	    *.dll.a)
2999267843Sdelphij	      tstripme=""
3000267843Sdelphij	      ;;
3001267843Sdelphij	    esac
3002267843Sdelphij	    ;;
3003267843Sdelphij	  esac
3004267843Sdelphij	  if test -n "$tstripme" && test -n "$striplib"; then
3005267843Sdelphij	    func_show_eval "$striplib $destdir/$realname" 'exit $?'
3006267843Sdelphij	  fi
3007267843Sdelphij
3008267843Sdelphij	  if test "$#" -gt 0; then
3009267843Sdelphij	    # Delete the old symlinks, and create new ones.
3010267843Sdelphij	    # Try `ln -sf' first, because the `ln' binary might depend on
3011267843Sdelphij	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
3012267843Sdelphij	    # so we also need to try rm && ln -s.
3013267843Sdelphij	    for linkname
3014267843Sdelphij	    do
3015267843Sdelphij	      test "$linkname" != "$realname" \
3016267843Sdelphij		&& func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
3017267843Sdelphij	    done
3018267843Sdelphij	  fi
3019267843Sdelphij
3020267843Sdelphij	  # Do each command in the postinstall commands.
3021267843Sdelphij	  lib="$destdir/$realname"
3022267843Sdelphij	  func_execute_cmds "$postinstall_cmds" 'exit $?'
3023267843Sdelphij	fi
3024267843Sdelphij
3025267843Sdelphij	# Install the pseudo-library for information purposes.
3026267843Sdelphij	func_basename "$file"
3027267843Sdelphij	name="$func_basename_result"
3028267843Sdelphij	instname="$dir/$name"i
3029267843Sdelphij	func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
3030267843Sdelphij
3031267843Sdelphij	# Maybe install the static library, too.
3032267843Sdelphij	test -n "$old_library" && func_append staticlibs " $dir/$old_library"
3033267843Sdelphij	;;
3034267843Sdelphij
3035267843Sdelphij      *.lo)
3036267843Sdelphij	# Install (i.e. copy) a libtool object.
3037267843Sdelphij
3038267843Sdelphij	# Figure out destination file name, if it wasn't already specified.
3039267843Sdelphij	if test -n "$destname"; then
3040267843Sdelphij	  destfile="$destdir/$destname"
3041267843Sdelphij	else
3042267843Sdelphij	  func_basename "$file"
3043267843Sdelphij	  destfile="$func_basename_result"
3044267843Sdelphij	  destfile="$destdir/$destfile"
3045267843Sdelphij	fi
3046267843Sdelphij
3047267843Sdelphij	# Deduce the name of the destination old-style object file.
3048267843Sdelphij	case $destfile in
3049267843Sdelphij	*.lo)
3050267843Sdelphij	  func_lo2o "$destfile"
3051267843Sdelphij	  staticdest=$func_lo2o_result
3052267843Sdelphij	  ;;
3053267843Sdelphij	*.$objext)
3054267843Sdelphij	  staticdest="$destfile"
3055267843Sdelphij	  destfile=
3056267843Sdelphij	  ;;
3057267843Sdelphij	*)
3058267843Sdelphij	  func_fatal_help "cannot copy a libtool object to \`$destfile'"
3059267843Sdelphij	  ;;
3060267843Sdelphij	esac
3061267843Sdelphij
3062267843Sdelphij	# Install the libtool object if requested.
3063267843Sdelphij	test -n "$destfile" && \
3064267843Sdelphij	  func_show_eval "$install_prog $file $destfile" 'exit $?'
3065267843Sdelphij
3066267843Sdelphij	# Install the old object if enabled.
3067267843Sdelphij	if test "$build_old_libs" = yes; then
3068267843Sdelphij	  # Deduce the name of the old-style object file.
3069267843Sdelphij	  func_lo2o "$file"
3070267843Sdelphij	  staticobj=$func_lo2o_result
3071267843Sdelphij	  func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
3072267843Sdelphij	fi
3073267843Sdelphij	exit $EXIT_SUCCESS
3074267843Sdelphij	;;
3075267843Sdelphij
3076267843Sdelphij      *)
3077267843Sdelphij	# Figure out destination file name, if it wasn't already specified.
3078267843Sdelphij	if test -n "$destname"; then
3079267843Sdelphij	  destfile="$destdir/$destname"
3080267843Sdelphij	else
3081267843Sdelphij	  func_basename "$file"
3082267843Sdelphij	  destfile="$func_basename_result"
3083267843Sdelphij	  destfile="$destdir/$destfile"
3084267843Sdelphij	fi
3085267843Sdelphij
3086267843Sdelphij	# If the file is missing, and there is a .exe on the end, strip it
3087267843Sdelphij	# because it is most likely a libtool script we actually want to
3088267843Sdelphij	# install
3089267843Sdelphij	stripped_ext=""
3090267843Sdelphij	case $file in
3091267843Sdelphij	  *.exe)
3092267843Sdelphij	    if test ! -f "$file"; then
3093267843Sdelphij	      func_stripname '' '.exe' "$file"
3094267843Sdelphij	      file=$func_stripname_result
3095267843Sdelphij	      stripped_ext=".exe"
3096267843Sdelphij	    fi
3097267843Sdelphij	    ;;
3098267843Sdelphij	esac
3099267843Sdelphij
3100267843Sdelphij	# Do a test to see if this is really a libtool program.
3101267843Sdelphij	case $host in
3102267843Sdelphij	*cygwin* | *mingw*)
3103267843Sdelphij	    if func_ltwrapper_executable_p "$file"; then
3104267843Sdelphij	      func_ltwrapper_scriptname "$file"
3105267843Sdelphij	      wrapper=$func_ltwrapper_scriptname_result
3106267843Sdelphij	    else
3107267843Sdelphij	      func_stripname '' '.exe' "$file"
3108267843Sdelphij	      wrapper=$func_stripname_result
3109267843Sdelphij	    fi
3110267843Sdelphij	    ;;
3111267843Sdelphij	*)
3112267843Sdelphij	    wrapper=$file
3113267843Sdelphij	    ;;
3114267843Sdelphij	esac
3115267843Sdelphij	if func_ltwrapper_script_p "$wrapper"; then
3116267843Sdelphij	  notinst_deplibs=
3117267843Sdelphij	  relink_command=
3118267843Sdelphij
3119267843Sdelphij	  func_source "$wrapper"
3120267843Sdelphij
3121267843Sdelphij	  # Check the variables that should have been set.
3122267843Sdelphij	  test -z "$generated_by_libtool_version" && \
3123267843Sdelphij	    func_fatal_error "invalid libtool wrapper script \`$wrapper'"
3124267843Sdelphij
3125267843Sdelphij	  finalize=yes
3126267843Sdelphij	  for lib in $notinst_deplibs; do
3127267843Sdelphij	    # Check to see that each library is installed.
3128267843Sdelphij	    libdir=
3129267843Sdelphij	    if test -f "$lib"; then
3130267843Sdelphij	      func_source "$lib"
3131267843Sdelphij	    fi
3132267843Sdelphij	    libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test
3133267843Sdelphij	    if test -n "$libdir" && test ! -f "$libfile"; then
3134267843Sdelphij	      func_warning "\`$lib' has not been installed in \`$libdir'"
3135267843Sdelphij	      finalize=no
3136267843Sdelphij	    fi
3137267843Sdelphij	  done
3138267843Sdelphij
3139267843Sdelphij	  relink_command=
3140267843Sdelphij	  func_source "$wrapper"
3141267843Sdelphij
3142267843Sdelphij	  outputname=
3143267843Sdelphij	  if test "$fast_install" = no && test -n "$relink_command"; then
3144267843Sdelphij	    $opt_dry_run || {
3145267843Sdelphij	      if test "$finalize" = yes; then
3146267843Sdelphij	        tmpdir=`func_mktempdir`
3147267843Sdelphij		func_basename "$file$stripped_ext"
3148267843Sdelphij		file="$func_basename_result"
3149267843Sdelphij	        outputname="$tmpdir/$file"
3150267843Sdelphij	        # Replace the output file specification.
3151267843Sdelphij	        relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
3152267843Sdelphij
3153267843Sdelphij	        $opt_silent || {
3154267843Sdelphij	          func_quote_for_expand "$relink_command"
3155267843Sdelphij		  eval "func_echo $func_quote_for_expand_result"
3156267843Sdelphij	        }
3157267843Sdelphij	        if eval "$relink_command"; then :
3158267843Sdelphij	          else
3159267843Sdelphij		  func_error "error: relink \`$file' with the above command before installing it"
3160267843Sdelphij		  $opt_dry_run || ${RM}r "$tmpdir"
3161267843Sdelphij		  continue
3162267843Sdelphij	        fi
3163267843Sdelphij	        file="$outputname"
3164267843Sdelphij	      else
3165267843Sdelphij	        func_warning "cannot relink \`$file'"
3166267843Sdelphij	      fi
3167267843Sdelphij	    }
3168267843Sdelphij	  else
3169267843Sdelphij	    # Install the binary that we compiled earlier.
3170267843Sdelphij	    file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
3171267843Sdelphij	  fi
3172267843Sdelphij	fi
3173267843Sdelphij
3174267843Sdelphij	# remove .exe since cygwin /usr/bin/install will append another
3175267843Sdelphij	# one anyway
3176267843Sdelphij	case $install_prog,$host in
3177267843Sdelphij	*/usr/bin/install*,*cygwin*)
3178267843Sdelphij	  case $file:$destfile in
3179267843Sdelphij	  *.exe:*.exe)
3180267843Sdelphij	    # this is ok
3181267843Sdelphij	    ;;
3182267843Sdelphij	  *.exe:*)
3183267843Sdelphij	    destfile=$destfile.exe
3184267843Sdelphij	    ;;
3185267843Sdelphij	  *:*.exe)
3186267843Sdelphij	    func_stripname '' '.exe' "$destfile"
3187267843Sdelphij	    destfile=$func_stripname_result
3188267843Sdelphij	    ;;
3189267843Sdelphij	  esac
3190267843Sdelphij	  ;;
3191267843Sdelphij	esac
3192267843Sdelphij	func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
3193267843Sdelphij	$opt_dry_run || if test -n "$outputname"; then
3194267843Sdelphij	  ${RM}r "$tmpdir"
3195267843Sdelphij	fi
3196267843Sdelphij	;;
3197267843Sdelphij      esac
3198267843Sdelphij    done
3199267843Sdelphij
3200267843Sdelphij    for file in $staticlibs; do
3201267843Sdelphij      func_basename "$file"
3202267843Sdelphij      name="$func_basename_result"
3203267843Sdelphij
3204267843Sdelphij      # Set up the ranlib parameters.
3205267843Sdelphij      oldlib="$destdir/$name"
3206267843Sdelphij      func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
3207267843Sdelphij      tool_oldlib=$func_to_tool_file_result
3208267843Sdelphij
3209267843Sdelphij      func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
3210267843Sdelphij
3211267843Sdelphij      if test -n "$stripme" && test -n "$old_striplib"; then
3212267843Sdelphij	func_show_eval "$old_striplib $tool_oldlib" 'exit $?'
3213267843Sdelphij      fi
3214267843Sdelphij
3215267843Sdelphij      # Do each command in the postinstall commands.
3216267843Sdelphij      func_execute_cmds "$old_postinstall_cmds" 'exit $?'
3217267843Sdelphij    done
3218267843Sdelphij
3219267843Sdelphij    test -n "$future_libdirs" && \
3220267843Sdelphij      func_warning "remember to run \`$progname --finish$future_libdirs'"
3221267843Sdelphij
3222267843Sdelphij    if test -n "$current_libdirs"; then
3223267843Sdelphij      # Maybe just do a dry run.
3224267843Sdelphij      $opt_dry_run && current_libdirs=" -n$current_libdirs"
3225267843Sdelphij      exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
3226267843Sdelphij    else
3227267843Sdelphij      exit $EXIT_SUCCESS
3228267843Sdelphij    fi
3229267843Sdelphij}
3230267843Sdelphij
3231267843Sdelphijtest "$opt_mode" = install && func_mode_install ${1+"$@"}
3232267843Sdelphij
3233267843Sdelphij
3234267843Sdelphij# func_generate_dlsyms outputname originator pic_p
3235267843Sdelphij# Extract symbols from dlprefiles and create ${outputname}S.o with
3236267843Sdelphij# a dlpreopen symbol table.
3237267843Sdelphijfunc_generate_dlsyms ()
3238267843Sdelphij{
3239267843Sdelphij    $opt_debug
3240267843Sdelphij    my_outputname="$1"
3241267843Sdelphij    my_originator="$2"
3242267843Sdelphij    my_pic_p="${3-no}"
3243267843Sdelphij    my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'`
3244267843Sdelphij    my_dlsyms=
3245267843Sdelphij
3246267843Sdelphij    if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
3247267843Sdelphij      if test -n "$NM" && test -n "$global_symbol_pipe"; then
3248267843Sdelphij	my_dlsyms="${my_outputname}S.c"
3249267843Sdelphij      else
3250267843Sdelphij	func_error "not configured to extract global symbols from dlpreopened files"
3251267843Sdelphij      fi
3252267843Sdelphij    fi
3253267843Sdelphij
3254267843Sdelphij    if test -n "$my_dlsyms"; then
3255267843Sdelphij      case $my_dlsyms in
3256267843Sdelphij      "") ;;
3257267843Sdelphij      *.c)
3258267843Sdelphij	# Discover the nlist of each of the dlfiles.
3259267843Sdelphij	nlist="$output_objdir/${my_outputname}.nm"
3260267843Sdelphij
3261267843Sdelphij	func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
3262267843Sdelphij
3263267843Sdelphij	# Parse the name list into a source file.
3264267843Sdelphij	func_verbose "creating $output_objdir/$my_dlsyms"
3265267843Sdelphij
3266267843Sdelphij	$opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
3267267843Sdelphij/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */
3268267843Sdelphij/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */
3269267843Sdelphij
3270267843Sdelphij#ifdef __cplusplus
3271267843Sdelphijextern \"C\" {
3272267843Sdelphij#endif
3273267843Sdelphij
3274267843Sdelphij#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
3275267843Sdelphij#pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
3276267843Sdelphij#endif
3277267843Sdelphij
3278267843Sdelphij/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
3279267843Sdelphij#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
3280267843Sdelphij/* DATA imports from DLLs on WIN32 con't be const, because runtime
3281267843Sdelphij   relocations are performed -- see ld's documentation on pseudo-relocs.  */
3282267843Sdelphij# define LT_DLSYM_CONST
3283267843Sdelphij#elif defined(__osf__)
3284267843Sdelphij/* This system does not cope well with relocations in const data.  */
3285267843Sdelphij# define LT_DLSYM_CONST
3286267843Sdelphij#else
3287267843Sdelphij# define LT_DLSYM_CONST const
3288267843Sdelphij#endif
3289267843Sdelphij
3290267843Sdelphij/* External symbol declarations for the compiler. */\
3291267843Sdelphij"
3292267843Sdelphij
3293267843Sdelphij	if test "$dlself" = yes; then
3294267843Sdelphij	  func_verbose "generating symbol list for \`$output'"
3295267843Sdelphij
3296267843Sdelphij	  $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
3297267843Sdelphij
3298267843Sdelphij	  # Add our own program objects to the symbol list.
3299267843Sdelphij	  progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
3300267843Sdelphij	  for progfile in $progfiles; do
3301267843Sdelphij	    func_to_tool_file "$progfile" func_convert_file_msys_to_w32
3302267843Sdelphij	    func_verbose "extracting global C symbols from \`$func_to_tool_file_result'"
3303267843Sdelphij	    $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
3304267843Sdelphij	  done
3305267843Sdelphij
3306267843Sdelphij	  if test -n "$exclude_expsyms"; then
3307267843Sdelphij	    $opt_dry_run || {
3308267843Sdelphij	      eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
3309267843Sdelphij	      eval '$MV "$nlist"T "$nlist"'
3310267843Sdelphij	    }
3311267843Sdelphij	  fi
3312267843Sdelphij
3313267843Sdelphij	  if test -n "$export_symbols_regex"; then
3314267843Sdelphij	    $opt_dry_run || {
3315267843Sdelphij	      eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
3316267843Sdelphij	      eval '$MV "$nlist"T "$nlist"'
3317267843Sdelphij	    }
3318267843Sdelphij	  fi
3319267843Sdelphij
3320267843Sdelphij	  # Prepare the list of exported symbols
3321267843Sdelphij	  if test -z "$export_symbols"; then
3322267843Sdelphij	    export_symbols="$output_objdir/$outputname.exp"
3323267843Sdelphij	    $opt_dry_run || {
3324267843Sdelphij	      $RM $export_symbols
3325267843Sdelphij	      eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
3326267843Sdelphij	      case $host in
3327267843Sdelphij	      *cygwin* | *mingw* | *cegcc* )
3328267843Sdelphij                eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
3329267843Sdelphij                eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
3330267843Sdelphij	        ;;
3331267843Sdelphij	      esac
3332267843Sdelphij	    }
3333267843Sdelphij	  else
3334267843Sdelphij	    $opt_dry_run || {
3335267843Sdelphij	      eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
3336267843Sdelphij	      eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
3337267843Sdelphij	      eval '$MV "$nlist"T "$nlist"'
3338267843Sdelphij	      case $host in
3339267843Sdelphij	        *cygwin* | *mingw* | *cegcc* )
3340267843Sdelphij	          eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
3341267843Sdelphij	          eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
3342267843Sdelphij	          ;;
3343267843Sdelphij	      esac
3344267843Sdelphij	    }
3345267843Sdelphij	  fi
3346267843Sdelphij	fi
3347267843Sdelphij
3348267843Sdelphij	for dlprefile in $dlprefiles; do
3349267843Sdelphij	  func_verbose "extracting global C symbols from \`$dlprefile'"
3350267843Sdelphij	  func_basename "$dlprefile"
3351267843Sdelphij	  name="$func_basename_result"
3352267843Sdelphij          case $host in
3353267843Sdelphij	    *cygwin* | *mingw* | *cegcc* )
3354267843Sdelphij	      # if an import library, we need to obtain dlname
3355267843Sdelphij	      if func_win32_import_lib_p "$dlprefile"; then
3356267843Sdelphij	        func_tr_sh "$dlprefile"
3357267843Sdelphij	        eval "curr_lafile=\$libfile_$func_tr_sh_result"
3358267843Sdelphij	        dlprefile_dlbasename=""
3359267843Sdelphij	        if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
3360267843Sdelphij	          # Use subshell, to avoid clobbering current variable values
3361267843Sdelphij	          dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
3362267843Sdelphij	          if test -n "$dlprefile_dlname" ; then
3363267843Sdelphij	            func_basename "$dlprefile_dlname"
3364267843Sdelphij	            dlprefile_dlbasename="$func_basename_result"
3365267843Sdelphij	          else
3366267843Sdelphij	            # no lafile. user explicitly requested -dlpreopen <import library>.
3367267843Sdelphij	            $sharedlib_from_linklib_cmd "$dlprefile"
3368267843Sdelphij	            dlprefile_dlbasename=$sharedlib_from_linklib_result
3369267843Sdelphij	          fi
3370267843Sdelphij	        fi
3371267843Sdelphij	        $opt_dry_run || {
3372267843Sdelphij	          if test -n "$dlprefile_dlbasename" ; then
3373267843Sdelphij	            eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
3374267843Sdelphij	          else
3375267843Sdelphij	            func_warning "Could not compute DLL name from $name"
3376267843Sdelphij	            eval '$ECHO ": $name " >> "$nlist"'
3377267843Sdelphij	          fi
3378267843Sdelphij	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
3379267843Sdelphij	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe |
3380267843Sdelphij	            $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'"
3381267843Sdelphij	        }
3382267843Sdelphij	      else # not an import lib
3383267843Sdelphij	        $opt_dry_run || {
3384267843Sdelphij	          eval '$ECHO ": $name " >> "$nlist"'
3385267843Sdelphij	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
3386267843Sdelphij	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
3387267843Sdelphij	        }
3388267843Sdelphij	      fi
3389267843Sdelphij	    ;;
3390267843Sdelphij	    *)
3391267843Sdelphij	      $opt_dry_run || {
3392267843Sdelphij	        eval '$ECHO ": $name " >> "$nlist"'
3393267843Sdelphij	        func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
3394267843Sdelphij	        eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
3395267843Sdelphij	      }
3396267843Sdelphij	    ;;
3397267843Sdelphij          esac
3398267843Sdelphij	done
3399267843Sdelphij
3400267843Sdelphij	$opt_dry_run || {
3401267843Sdelphij	  # Make sure we have at least an empty file.
3402267843Sdelphij	  test -f "$nlist" || : > "$nlist"
3403267843Sdelphij
3404267843Sdelphij	  if test -n "$exclude_expsyms"; then
3405267843Sdelphij	    $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
3406267843Sdelphij	    $MV "$nlist"T "$nlist"
3407267843Sdelphij	  fi
3408267843Sdelphij
3409267843Sdelphij	  # Try sorting and uniquifying the output.
3410267843Sdelphij	  if $GREP -v "^: " < "$nlist" |
3411267843Sdelphij	      if sort -k 3 </dev/null >/dev/null 2>&1; then
3412267843Sdelphij		sort -k 3
3413267843Sdelphij	      else
3414267843Sdelphij		sort +2
3415267843Sdelphij	      fi |
3416267843Sdelphij	      uniq > "$nlist"S; then
3417267843Sdelphij	    :
3418267843Sdelphij	  else
3419267843Sdelphij	    $GREP -v "^: " < "$nlist" > "$nlist"S
3420267843Sdelphij	  fi
3421267843Sdelphij
3422267843Sdelphij	  if test -f "$nlist"S; then
3423267843Sdelphij	    eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
3424267843Sdelphij	  else
3425267843Sdelphij	    echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
3426267843Sdelphij	  fi
3427267843Sdelphij
3428267843Sdelphij	  echo >> "$output_objdir/$my_dlsyms" "\
3429267843Sdelphij
3430267843Sdelphij/* The mapping between symbol names and symbols.  */
3431267843Sdelphijtypedef struct {
3432267843Sdelphij  const char *name;
3433267843Sdelphij  void *address;
3434267843Sdelphij} lt_dlsymlist;
3435267843Sdelphijextern LT_DLSYM_CONST lt_dlsymlist
3436267843Sdelphijlt_${my_prefix}_LTX_preloaded_symbols[];
3437267843SdelphijLT_DLSYM_CONST lt_dlsymlist
3438267843Sdelphijlt_${my_prefix}_LTX_preloaded_symbols[] =
3439267843Sdelphij{\
3440267843Sdelphij  { \"$my_originator\", (void *) 0 },"
3441267843Sdelphij
3442267843Sdelphij	  case $need_lib_prefix in
3443267843Sdelphij	  no)
3444267843Sdelphij	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
3445267843Sdelphij	    ;;
3446267843Sdelphij	  *)
3447267843Sdelphij	    eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
3448267843Sdelphij	    ;;
3449267843Sdelphij	  esac
3450267843Sdelphij	  echo >> "$output_objdir/$my_dlsyms" "\
3451267843Sdelphij  {0, (void *) 0}
3452267843Sdelphij};
3453267843Sdelphij
3454267843Sdelphij/* This works around a problem in FreeBSD linker */
3455267843Sdelphij#ifdef FREEBSD_WORKAROUND
3456267843Sdelphijstatic const void *lt_preloaded_setup() {
3457267843Sdelphij  return lt_${my_prefix}_LTX_preloaded_symbols;
3458267843Sdelphij}
3459267843Sdelphij#endif
3460267843Sdelphij
3461267843Sdelphij#ifdef __cplusplus
3462267843Sdelphij}
3463267843Sdelphij#endif\
3464267843Sdelphij"
3465267843Sdelphij	} # !$opt_dry_run
3466267843Sdelphij
3467267843Sdelphij	pic_flag_for_symtable=
3468267843Sdelphij	case "$compile_command " in
3469267843Sdelphij	*" -static "*) ;;
3470267843Sdelphij	*)
3471267843Sdelphij	  case $host in
3472267843Sdelphij	  # compiling the symbol table file with pic_flag works around
3473267843Sdelphij	  # a FreeBSD bug that causes programs to crash when -lm is
3474267843Sdelphij	  # linked before any other PIC object.  But we must not use
3475267843Sdelphij	  # pic_flag when linking with -static.  The problem exists in
3476267843Sdelphij	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
3477267843Sdelphij	  *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
3478267843Sdelphij	    pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
3479267843Sdelphij	  *-*-hpux*)
3480267843Sdelphij	    pic_flag_for_symtable=" $pic_flag"  ;;
3481267843Sdelphij	  *)
3482267843Sdelphij	    if test "X$my_pic_p" != Xno; then
3483267843Sdelphij	      pic_flag_for_symtable=" $pic_flag"
3484267843Sdelphij	    fi
3485267843Sdelphij	    ;;
3486267843Sdelphij	  esac
3487267843Sdelphij	  ;;
3488267843Sdelphij	esac
3489267843Sdelphij	symtab_cflags=
3490267843Sdelphij	for arg in $LTCFLAGS; do
3491267843Sdelphij	  case $arg in
3492267843Sdelphij	  -pie | -fpie | -fPIE) ;;
3493267843Sdelphij	  *) func_append symtab_cflags " $arg" ;;
3494267843Sdelphij	  esac
3495267843Sdelphij	done
3496267843Sdelphij
3497267843Sdelphij	# Now compile the dynamic symbol file.
3498267843Sdelphij	func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
3499267843Sdelphij
3500267843Sdelphij	# Clean up the generated files.
3501267843Sdelphij	func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"'
3502267843Sdelphij
3503267843Sdelphij	# Transform the symbol file into the correct name.
3504267843Sdelphij	symfileobj="$output_objdir/${my_outputname}S.$objext"
3505267843Sdelphij	case $host in
3506267843Sdelphij	*cygwin* | *mingw* | *cegcc* )
3507267843Sdelphij	  if test -f "$output_objdir/$my_outputname.def"; then
3508267843Sdelphij	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
3509267843Sdelphij	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
3510267843Sdelphij	  else
3511267843Sdelphij	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3512267843Sdelphij	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3513267843Sdelphij	  fi
3514267843Sdelphij	  ;;
3515267843Sdelphij	*)
3516267843Sdelphij	  compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3517267843Sdelphij	  finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3518267843Sdelphij	  ;;
3519267843Sdelphij	esac
3520267843Sdelphij	;;
3521267843Sdelphij      *)
3522267843Sdelphij	func_fatal_error "unknown suffix for \`$my_dlsyms'"
3523267843Sdelphij	;;
3524267843Sdelphij      esac
3525267843Sdelphij    else
3526267843Sdelphij      # We keep going just in case the user didn't refer to
3527267843Sdelphij      # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
3528267843Sdelphij      # really was required.
3529267843Sdelphij
3530267843Sdelphij      # Nullify the symbol file.
3531267843Sdelphij      compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
3532267843Sdelphij      finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
3533267843Sdelphij    fi
3534267843Sdelphij}
3535267843Sdelphij
3536267843Sdelphij# func_win32_libid arg
3537267843Sdelphij# return the library type of file 'arg'
3538267843Sdelphij#
3539267843Sdelphij# Need a lot of goo to handle *both* DLLs and import libs
3540267843Sdelphij# Has to be a shell function in order to 'eat' the argument
3541267843Sdelphij# that is supplied when $file_magic_command is called.
3542267843Sdelphij# Despite the name, also deal with 64 bit binaries.
3543267843Sdelphijfunc_win32_libid ()
3544267843Sdelphij{
3545267843Sdelphij  $opt_debug
3546267843Sdelphij  win32_libid_type="unknown"
3547267843Sdelphij  win32_fileres=`file -L $1 2>/dev/null`
3548267843Sdelphij  case $win32_fileres in
3549267843Sdelphij  *ar\ archive\ import\ library*) # definitely import
3550267843Sdelphij    win32_libid_type="x86 archive import"
3551267843Sdelphij    ;;
3552267843Sdelphij  *ar\ archive*) # could be an import, or static
3553267843Sdelphij    # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
3554267843Sdelphij    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
3555267843Sdelphij       $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
3556267843Sdelphij      func_to_tool_file "$1" func_convert_file_msys_to_w32
3557267843Sdelphij      win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
3558267843Sdelphij	$SED -n -e '
3559267843Sdelphij	    1,100{
3560267843Sdelphij		/ I /{
3561267843Sdelphij		    s,.*,import,
3562267843Sdelphij		    p
3563267843Sdelphij		    q
3564267843Sdelphij		}
3565267843Sdelphij	    }'`
3566267843Sdelphij      case $win32_nmres in
3567267843Sdelphij      import*)  win32_libid_type="x86 archive import";;
3568267843Sdelphij      *)        win32_libid_type="x86 archive static";;
3569267843Sdelphij      esac
3570267843Sdelphij    fi
3571267843Sdelphij    ;;
3572267843Sdelphij  *DLL*)
3573267843Sdelphij    win32_libid_type="x86 DLL"
3574267843Sdelphij    ;;
3575267843Sdelphij  *executable*) # but shell scripts are "executable" too...
3576267843Sdelphij    case $win32_fileres in
3577267843Sdelphij    *MS\ Windows\ PE\ Intel*)
3578267843Sdelphij      win32_libid_type="x86 DLL"
3579267843Sdelphij      ;;
3580267843Sdelphij    esac
3581267843Sdelphij    ;;
3582267843Sdelphij  esac
3583267843Sdelphij  $ECHO "$win32_libid_type"
3584267843Sdelphij}
3585267843Sdelphij
3586267843Sdelphij# func_cygming_dll_for_implib ARG
3587267843Sdelphij#
3588267843Sdelphij# Platform-specific function to extract the
3589267843Sdelphij# name of the DLL associated with the specified
3590267843Sdelphij# import library ARG.
3591267843Sdelphij# Invoked by eval'ing the libtool variable
3592267843Sdelphij#    $sharedlib_from_linklib_cmd
3593267843Sdelphij# Result is available in the variable
3594267843Sdelphij#    $sharedlib_from_linklib_result
3595267843Sdelphijfunc_cygming_dll_for_implib ()
3596267843Sdelphij{
3597267843Sdelphij  $opt_debug
3598267843Sdelphij  sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
3599267843Sdelphij}
3600267843Sdelphij
3601267843Sdelphij# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs
3602267843Sdelphij#
3603267843Sdelphij# The is the core of a fallback implementation of a
3604267843Sdelphij# platform-specific function to extract the name of the
3605267843Sdelphij# DLL associated with the specified import library LIBNAME.
3606267843Sdelphij#
3607267843Sdelphij# SECTION_NAME is either .idata$6 or .idata$7, depending
3608267843Sdelphij# on the platform and compiler that created the implib.
3609267843Sdelphij#
3610267843Sdelphij# Echos the name of the DLL associated with the
3611267843Sdelphij# specified import library.
3612267843Sdelphijfunc_cygming_dll_for_implib_fallback_core ()
3613267843Sdelphij{
3614267843Sdelphij  $opt_debug
3615267843Sdelphij  match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
3616267843Sdelphij  $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
3617267843Sdelphij    $SED '/^Contents of section '"$match_literal"':/{
3618267843Sdelphij      # Place marker at beginning of archive member dllname section
3619267843Sdelphij      s/.*/====MARK====/
3620267843Sdelphij      p
3621267843Sdelphij      d
3622267843Sdelphij    }
3623267843Sdelphij    # These lines can sometimes be longer than 43 characters, but
3624267843Sdelphij    # are always uninteresting
3625267843Sdelphij    /:[	 ]*file format pe[i]\{,1\}-/d
3626267843Sdelphij    /^In archive [^:]*:/d
3627267843Sdelphij    # Ensure marker is printed
3628267843Sdelphij    /^====MARK====/p
3629267843Sdelphij    # Remove all lines with less than 43 characters
3630267843Sdelphij    /^.\{43\}/!d
3631267843Sdelphij    # From remaining lines, remove first 43 characters
3632267843Sdelphij    s/^.\{43\}//' |
3633267843Sdelphij    $SED -n '
3634267843Sdelphij      # Join marker and all lines until next marker into a single line
3635267843Sdelphij      /^====MARK====/ b para
3636267843Sdelphij      H
3637267843Sdelphij      $ b para
3638267843Sdelphij      b
3639267843Sdelphij      :para
3640267843Sdelphij      x
3641267843Sdelphij      s/\n//g
3642267843Sdelphij      # Remove the marker
3643267843Sdelphij      s/^====MARK====//
3644267843Sdelphij      # Remove trailing dots and whitespace
3645267843Sdelphij      s/[\. \t]*$//
3646267843Sdelphij      # Print
3647267843Sdelphij      /./p' |
3648267843Sdelphij    # we now have a list, one entry per line, of the stringified
3649267843Sdelphij    # contents of the appropriate section of all members of the
3650267843Sdelphij    # archive which possess that section. Heuristic: eliminate
3651267843Sdelphij    # all those which have a first or second character that is
3652267843Sdelphij    # a '.' (that is, objdump's representation of an unprintable
3653267843Sdelphij    # character.) This should work for all archives with less than
3654267843Sdelphij    # 0x302f exports -- but will fail for DLLs whose name actually
3655267843Sdelphij    # begins with a literal '.' or a single character followed by
3656267843Sdelphij    # a '.'.
3657267843Sdelphij    #
3658267843Sdelphij    # Of those that remain, print the first one.
3659267843Sdelphij    $SED -e '/^\./d;/^.\./d;q'
3660267843Sdelphij}
3661267843Sdelphij
3662267843Sdelphij# func_cygming_gnu_implib_p ARG
3663267843Sdelphij# This predicate returns with zero status (TRUE) if
3664267843Sdelphij# ARG is a GNU/binutils-style import library. Returns
3665267843Sdelphij# with nonzero status (FALSE) otherwise.
3666267843Sdelphijfunc_cygming_gnu_implib_p ()
3667267843Sdelphij{
3668267843Sdelphij  $opt_debug
3669267843Sdelphij  func_to_tool_file "$1" func_convert_file_msys_to_w32
3670267843Sdelphij  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)$'`
3671267843Sdelphij  test -n "$func_cygming_gnu_implib_tmp"
3672267843Sdelphij}
3673267843Sdelphij
3674267843Sdelphij# func_cygming_ms_implib_p ARG
3675267843Sdelphij# This predicate returns with zero status (TRUE) if
3676267843Sdelphij# ARG is an MS-style import library. Returns
3677267843Sdelphij# with nonzero status (FALSE) otherwise.
3678267843Sdelphijfunc_cygming_ms_implib_p ()
3679267843Sdelphij{
3680267843Sdelphij  $opt_debug
3681267843Sdelphij  func_to_tool_file "$1" func_convert_file_msys_to_w32
3682267843Sdelphij  func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
3683267843Sdelphij  test -n "$func_cygming_ms_implib_tmp"
3684267843Sdelphij}
3685267843Sdelphij
3686267843Sdelphij# func_cygming_dll_for_implib_fallback ARG
3687267843Sdelphij# Platform-specific function to extract the
3688267843Sdelphij# name of the DLL associated with the specified
3689267843Sdelphij# import library ARG.
3690267843Sdelphij#
3691267843Sdelphij# This fallback implementation is for use when $DLLTOOL
3692267843Sdelphij# does not support the --identify-strict option.
3693267843Sdelphij# Invoked by eval'ing the libtool variable
3694267843Sdelphij#    $sharedlib_from_linklib_cmd
3695267843Sdelphij# Result is available in the variable
3696267843Sdelphij#    $sharedlib_from_linklib_result
3697267843Sdelphijfunc_cygming_dll_for_implib_fallback ()
3698267843Sdelphij{
3699267843Sdelphij  $opt_debug
3700267843Sdelphij  if func_cygming_gnu_implib_p "$1" ; then
3701267843Sdelphij    # binutils import library
3702267843Sdelphij    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
3703267843Sdelphij  elif func_cygming_ms_implib_p "$1" ; then
3704267843Sdelphij    # ms-generated import library
3705267843Sdelphij    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
3706267843Sdelphij  else
3707267843Sdelphij    # unknown
3708267843Sdelphij    sharedlib_from_linklib_result=""
3709267843Sdelphij  fi
3710267843Sdelphij}
3711267843Sdelphij
3712267843Sdelphij
3713267843Sdelphij# func_extract_an_archive dir oldlib
3714267843Sdelphijfunc_extract_an_archive ()
3715267843Sdelphij{
3716267843Sdelphij    $opt_debug
3717267843Sdelphij    f_ex_an_ar_dir="$1"; shift
3718267843Sdelphij    f_ex_an_ar_oldlib="$1"
3719267843Sdelphij    if test "$lock_old_archive_extraction" = yes; then
3720267843Sdelphij      lockfile=$f_ex_an_ar_oldlib.lock
3721267843Sdelphij      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
3722267843Sdelphij	func_echo "Waiting for $lockfile to be removed"
3723267843Sdelphij	sleep 2
3724267843Sdelphij      done
3725267843Sdelphij    fi
3726267843Sdelphij    func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
3727267843Sdelphij		   'stat=$?; rm -f "$lockfile"; exit $stat'
3728267843Sdelphij    if test "$lock_old_archive_extraction" = yes; then
3729267843Sdelphij      $opt_dry_run || rm -f "$lockfile"
3730267843Sdelphij    fi
3731267843Sdelphij    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
3732267843Sdelphij     :
3733267843Sdelphij    else
3734267843Sdelphij      func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
3735267843Sdelphij    fi
3736267843Sdelphij}
3737267843Sdelphij
3738267843Sdelphij
3739267843Sdelphij# func_extract_archives gentop oldlib ...
3740267843Sdelphijfunc_extract_archives ()
3741267843Sdelphij{
3742267843Sdelphij    $opt_debug
3743267843Sdelphij    my_gentop="$1"; shift
3744267843Sdelphij    my_oldlibs=${1+"$@"}
3745267843Sdelphij    my_oldobjs=""
3746267843Sdelphij    my_xlib=""
3747267843Sdelphij    my_xabs=""
3748267843Sdelphij    my_xdir=""
3749267843Sdelphij
3750267843Sdelphij    for my_xlib in $my_oldlibs; do
3751267843Sdelphij      # Extract the objects.
3752267843Sdelphij      case $my_xlib in
3753267843Sdelphij	[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
3754267843Sdelphij	*) my_xabs=`pwd`"/$my_xlib" ;;
3755267843Sdelphij      esac
3756267843Sdelphij      func_basename "$my_xlib"
3757267843Sdelphij      my_xlib="$func_basename_result"
3758267843Sdelphij      my_xlib_u=$my_xlib
3759267843Sdelphij      while :; do
3760267843Sdelphij        case " $extracted_archives " in
3761267843Sdelphij	*" $my_xlib_u "*)
3762267843Sdelphij	  func_arith $extracted_serial + 1
3763267843Sdelphij	  extracted_serial=$func_arith_result
3764267843Sdelphij	  my_xlib_u=lt$extracted_serial-$my_xlib ;;
3765267843Sdelphij	*) break ;;
3766267843Sdelphij	esac
3767267843Sdelphij      done
3768267843Sdelphij      extracted_archives="$extracted_archives $my_xlib_u"
3769267843Sdelphij      my_xdir="$my_gentop/$my_xlib_u"
3770267843Sdelphij
3771267843Sdelphij      func_mkdir_p "$my_xdir"
3772267843Sdelphij
3773267843Sdelphij      case $host in
3774267843Sdelphij      *-darwin*)
3775267843Sdelphij	func_verbose "Extracting $my_xabs"
3776267843Sdelphij	# Do not bother doing anything if just a dry run
3777267843Sdelphij	$opt_dry_run || {
3778267843Sdelphij	  darwin_orig_dir=`pwd`
3779267843Sdelphij	  cd $my_xdir || exit $?
3780267843Sdelphij	  darwin_archive=$my_xabs
3781267843Sdelphij	  darwin_curdir=`pwd`
3782267843Sdelphij	  darwin_base_archive=`basename "$darwin_archive"`
3783267843Sdelphij	  darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
3784267843Sdelphij	  if test -n "$darwin_arches"; then
3785267843Sdelphij	    darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
3786267843Sdelphij	    darwin_arch=
3787267843Sdelphij	    func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
3788267843Sdelphij	    for darwin_arch in  $darwin_arches ; do
3789267843Sdelphij	      func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
3790267843Sdelphij	      $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
3791267843Sdelphij	      cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
3792267843Sdelphij	      func_extract_an_archive "`pwd`" "${darwin_base_archive}"
3793267843Sdelphij	      cd "$darwin_curdir"
3794267843Sdelphij	      $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
3795267843Sdelphij	    done # $darwin_arches
3796267843Sdelphij            ## Okay now we've a bunch of thin objects, gotta fatten them up :)
3797267843Sdelphij	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u`
3798267843Sdelphij	    darwin_file=
3799267843Sdelphij	    darwin_files=
3800267843Sdelphij	    for darwin_file in $darwin_filelist; do
3801267843Sdelphij	      darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`
3802267843Sdelphij	      $LIPO -create -output "$darwin_file" $darwin_files
3803267843Sdelphij	    done # $darwin_filelist
3804267843Sdelphij	    $RM -rf unfat-$$
3805267843Sdelphij	    cd "$darwin_orig_dir"
3806267843Sdelphij	  else
3807267843Sdelphij	    cd $darwin_orig_dir
3808267843Sdelphij	    func_extract_an_archive "$my_xdir" "$my_xabs"
3809267843Sdelphij	  fi # $darwin_arches
3810267843Sdelphij	} # !$opt_dry_run
3811267843Sdelphij	;;
3812267843Sdelphij      *)
3813267843Sdelphij        func_extract_an_archive "$my_xdir" "$my_xabs"
3814267843Sdelphij	;;
3815267843Sdelphij      esac
3816267843Sdelphij      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
3817267843Sdelphij    done
3818267843Sdelphij
3819267843Sdelphij    func_extract_archives_result="$my_oldobjs"
3820267843Sdelphij}
3821267843Sdelphij
3822267843Sdelphij
3823267843Sdelphij# func_emit_wrapper [arg=no]
3824267843Sdelphij#
3825267843Sdelphij# Emit a libtool wrapper script on stdout.
3826267843Sdelphij# Don't directly open a file because we may want to
3827267843Sdelphij# incorporate the script contents within a cygwin/mingw
3828267843Sdelphij# wrapper executable.  Must ONLY be called from within
3829267843Sdelphij# func_mode_link because it depends on a number of variables
3830267843Sdelphij# set therein.
3831267843Sdelphij#
3832267843Sdelphij# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
3833267843Sdelphij# variable will take.  If 'yes', then the emitted script
3834267843Sdelphij# will assume that the directory in which it is stored is
3835267843Sdelphij# the $objdir directory.  This is a cygwin/mingw-specific
3836267843Sdelphij# behavior.
3837267843Sdelphijfunc_emit_wrapper ()
3838267843Sdelphij{
3839267843Sdelphij	func_emit_wrapper_arg1=${1-no}
3840267843Sdelphij
3841267843Sdelphij	$ECHO "\
3842267843Sdelphij#! $SHELL
3843267843Sdelphij
3844267843Sdelphij# $output - temporary wrapper script for $objdir/$outputname
3845267843Sdelphij# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
3846267843Sdelphij#
3847267843Sdelphij# The $output program cannot be directly executed until all the libtool
3848267843Sdelphij# libraries that it depends on are installed.
3849267843Sdelphij#
3850267843Sdelphij# This wrapper script should never be moved out of the build directory.
3851267843Sdelphij# If it is, it will not operate correctly.
3852267843Sdelphij
3853267843Sdelphij# Sed substitution that helps us do robust quoting.  It backslashifies
3854267843Sdelphij# metacharacters that are still active within double-quoted strings.
3855267843Sdelphijsed_quote_subst='$sed_quote_subst'
3856267843Sdelphij
3857267843Sdelphij# Be Bourne compatible
3858267843Sdelphijif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
3859267843Sdelphij  emulate sh
3860267843Sdelphij  NULLCMD=:
3861267843Sdelphij  # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
3862267843Sdelphij  # is contrary to our usage.  Disable this feature.
3863267843Sdelphij  alias -g '\${1+\"\$@\"}'='\"\$@\"'
3864267843Sdelphij  setopt NO_GLOB_SUBST
3865267843Sdelphijelse
3866267843Sdelphij  case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
3867267843Sdelphijfi
3868267843SdelphijBIN_SH=xpg4; export BIN_SH # for Tru64
3869267843SdelphijDUALCASE=1; export DUALCASE # for MKS sh
3870267843Sdelphij
3871267843Sdelphij# The HP-UX ksh and POSIX shell print the target directory to stdout
3872267843Sdelphij# if CDPATH is set.
3873267843Sdelphij(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
3874267843Sdelphij
3875267843Sdelphijrelink_command=\"$relink_command\"
3876267843Sdelphij
3877267843Sdelphij# This environment variable determines our operation mode.
3878267843Sdelphijif test \"\$libtool_install_magic\" = \"$magic\"; then
3879267843Sdelphij  # install mode needs the following variables:
3880267843Sdelphij  generated_by_libtool_version='$macro_version'
3881267843Sdelphij  notinst_deplibs='$notinst_deplibs'
3882267843Sdelphijelse
3883267843Sdelphij  # When we are sourced in execute mode, \$file and \$ECHO are already set.
3884267843Sdelphij  if test \"\$libtool_execute_magic\" != \"$magic\"; then
3885267843Sdelphij    file=\"\$0\""
3886267843Sdelphij
3887267843Sdelphij    qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"`
3888267843Sdelphij    $ECHO "\
3889267843Sdelphij
3890267843Sdelphij# A function that is used when there is no print builtin or printf.
3891267843Sdelphijfunc_fallback_echo ()
3892267843Sdelphij{
3893267843Sdelphij  eval 'cat <<_LTECHO_EOF
3894267843Sdelphij\$1
3895267843Sdelphij_LTECHO_EOF'
3896267843Sdelphij}
3897267843Sdelphij    ECHO=\"$qECHO\"
3898267843Sdelphij  fi
3899267843Sdelphij
3900267843Sdelphij# Very basic option parsing. These options are (a) specific to
3901267843Sdelphij# the libtool wrapper, (b) are identical between the wrapper
3902267843Sdelphij# /script/ and the wrapper /executable/ which is used only on
3903267843Sdelphij# windows platforms, and (c) all begin with the string "--lt-"
3904267843Sdelphij# (application programs are unlikely to have options which match
3905267843Sdelphij# this pattern).
3906267843Sdelphij#
3907267843Sdelphij# There are only two supported options: --lt-debug and
3908267843Sdelphij# --lt-dump-script. There is, deliberately, no --lt-help.
3909267843Sdelphij#
3910267843Sdelphij# The first argument to this parsing function should be the
3911267843Sdelphij# script's $0 value, followed by "$@".
3912267843Sdelphijlt_option_debug=
3913267843Sdelphijfunc_parse_lt_options ()
3914267843Sdelphij{
3915267843Sdelphij  lt_script_arg0=\$0
3916267843Sdelphij  shift
3917267843Sdelphij  for lt_opt
3918267843Sdelphij  do
3919267843Sdelphij    case \"\$lt_opt\" in
3920267843Sdelphij    --lt-debug) lt_option_debug=1 ;;
3921267843Sdelphij    --lt-dump-script)
3922267843Sdelphij        lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
3923267843Sdelphij        test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
3924267843Sdelphij        lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
3925267843Sdelphij        cat \"\$lt_dump_D/\$lt_dump_F\"
3926267843Sdelphij        exit 0
3927267843Sdelphij      ;;
3928267843Sdelphij    --lt-*)
3929267843Sdelphij        \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
3930267843Sdelphij        exit 1
3931267843Sdelphij      ;;
3932267843Sdelphij    esac
3933267843Sdelphij  done
3934267843Sdelphij
3935267843Sdelphij  # Print the debug banner immediately:
3936267843Sdelphij  if test -n \"\$lt_option_debug\"; then
3937267843Sdelphij    echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2
3938267843Sdelphij  fi
3939267843Sdelphij}
3940267843Sdelphij
3941267843Sdelphij# Used when --lt-debug. Prints its arguments to stdout
3942267843Sdelphij# (redirection is the responsibility of the caller)
3943267843Sdelphijfunc_lt_dump_args ()
3944267843Sdelphij{
3945267843Sdelphij  lt_dump_args_N=1;
3946267843Sdelphij  for lt_arg
3947267843Sdelphij  do
3948267843Sdelphij    \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\"
3949267843Sdelphij    lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
3950267843Sdelphij  done
3951267843Sdelphij}
3952267843Sdelphij
3953267843Sdelphij# Core function for launching the target application
3954267843Sdelphijfunc_exec_program_core ()
3955267843Sdelphij{
3956267843Sdelphij"
3957267843Sdelphij  case $host in
3958267843Sdelphij  # Backslashes separate directories on plain windows
3959267843Sdelphij  *-*-mingw | *-*-os2* | *-cegcc*)
3960267843Sdelphij    $ECHO "\
3961267843Sdelphij      if test -n \"\$lt_option_debug\"; then
3962267843Sdelphij        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2
3963267843Sdelphij        func_lt_dump_args \${1+\"\$@\"} 1>&2
3964267843Sdelphij      fi
3965267843Sdelphij      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
3966267843Sdelphij"
3967267843Sdelphij    ;;
3968267843Sdelphij
3969267843Sdelphij  *)
3970267843Sdelphij    $ECHO "\
3971267843Sdelphij      if test -n \"\$lt_option_debug\"; then
3972267843Sdelphij        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2
3973267843Sdelphij        func_lt_dump_args \${1+\"\$@\"} 1>&2
3974267843Sdelphij      fi
3975267843Sdelphij      exec \"\$progdir/\$program\" \${1+\"\$@\"}
3976267843Sdelphij"
3977267843Sdelphij    ;;
3978267843Sdelphij  esac
3979267843Sdelphij  $ECHO "\
3980267843Sdelphij      \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
3981267843Sdelphij      exit 1
3982267843Sdelphij}
3983267843Sdelphij
3984267843Sdelphij# A function to encapsulate launching the target application
3985267843Sdelphij# Strips options in the --lt-* namespace from \$@ and
3986267843Sdelphij# launches target application with the remaining arguments.
3987267843Sdelphijfunc_exec_program ()
3988267843Sdelphij{
3989267843Sdelphij  case \" \$* \" in
3990267843Sdelphij  *\\ --lt-*)
3991267843Sdelphij    for lt_wr_arg
3992267843Sdelphij    do
3993267843Sdelphij      case \$lt_wr_arg in
3994267843Sdelphij      --lt-*) ;;
3995267843Sdelphij      *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
3996267843Sdelphij      esac
3997267843Sdelphij      shift
3998267843Sdelphij    done ;;
3999267843Sdelphij  esac
4000267843Sdelphij  func_exec_program_core \${1+\"\$@\"}
4001267843Sdelphij}
4002267843Sdelphij
4003267843Sdelphij  # Parse options
4004267843Sdelphij  func_parse_lt_options \"\$0\" \${1+\"\$@\"}
4005267843Sdelphij
4006267843Sdelphij  # Find the directory that this script lives in.
4007267843Sdelphij  thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
4008267843Sdelphij  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
4009267843Sdelphij
4010267843Sdelphij  # Follow symbolic links until we get to the real thisdir.
4011267843Sdelphij  file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
4012267843Sdelphij  while test -n \"\$file\"; do
4013267843Sdelphij    destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
4014267843Sdelphij
4015267843Sdelphij    # If there was a directory component, then change thisdir.
4016267843Sdelphij    if test \"x\$destdir\" != \"x\$file\"; then
4017267843Sdelphij      case \"\$destdir\" in
4018267843Sdelphij      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
4019267843Sdelphij      *) thisdir=\"\$thisdir/\$destdir\" ;;
4020267843Sdelphij      esac
4021267843Sdelphij    fi
4022267843Sdelphij
4023267843Sdelphij    file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
4024267843Sdelphij    file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
4025267843Sdelphij  done
4026267843Sdelphij
4027267843Sdelphij  # Usually 'no', except on cygwin/mingw when embedded into
4028267843Sdelphij  # the cwrapper.
4029267843Sdelphij  WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
4030267843Sdelphij  if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
4031267843Sdelphij    # special case for '.'
4032267843Sdelphij    if test \"\$thisdir\" = \".\"; then
4033267843Sdelphij      thisdir=\`pwd\`
4034267843Sdelphij    fi
4035267843Sdelphij    # remove .libs from thisdir
4036267843Sdelphij    case \"\$thisdir\" in
4037267843Sdelphij    *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
4038267843Sdelphij    $objdir )   thisdir=. ;;
4039267843Sdelphij    esac
4040267843Sdelphij  fi
4041267843Sdelphij
4042267843Sdelphij  # Try to get the absolute directory name.
4043267843Sdelphij  absdir=\`cd \"\$thisdir\" && pwd\`
4044267843Sdelphij  test -n \"\$absdir\" && thisdir=\"\$absdir\"
4045267843Sdelphij"
4046267843Sdelphij
4047267843Sdelphij	if test "$fast_install" = yes; then
4048267843Sdelphij	  $ECHO "\
4049267843Sdelphij  program=lt-'$outputname'$exeext
4050267843Sdelphij  progdir=\"\$thisdir/$objdir\"
4051267843Sdelphij
4052267843Sdelphij  if test ! -f \"\$progdir/\$program\" ||
4053267843Sdelphij     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
4054267843Sdelphij       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
4055267843Sdelphij
4056267843Sdelphij    file=\"\$\$-\$program\"
4057267843Sdelphij
4058267843Sdelphij    if test ! -d \"\$progdir\"; then
4059267843Sdelphij      $MKDIR \"\$progdir\"
4060267843Sdelphij    else
4061267843Sdelphij      $RM \"\$progdir/\$file\"
4062267843Sdelphij    fi"
4063267843Sdelphij
4064267843Sdelphij	  $ECHO "\
4065267843Sdelphij
4066267843Sdelphij    # relink executable if necessary
4067267843Sdelphij    if test -n \"\$relink_command\"; then
4068267843Sdelphij      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
4069267843Sdelphij      else
4070267843Sdelphij	$ECHO \"\$relink_command_output\" >&2
4071267843Sdelphij	$RM \"\$progdir/\$file\"
4072267843Sdelphij	exit 1
4073267843Sdelphij      fi
4074267843Sdelphij    fi
4075267843Sdelphij
4076267843Sdelphij    $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
4077267843Sdelphij    { $RM \"\$progdir/\$program\";
4078267843Sdelphij      $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
4079267843Sdelphij    $RM \"\$progdir/\$file\"
4080267843Sdelphij  fi"
4081267843Sdelphij	else
4082267843Sdelphij	  $ECHO "\
4083267843Sdelphij  program='$outputname'
4084267843Sdelphij  progdir=\"\$thisdir/$objdir\"
4085267843Sdelphij"
4086267843Sdelphij	fi
4087267843Sdelphij
4088267843Sdelphij	$ECHO "\
4089267843Sdelphij
4090267843Sdelphij  if test -f \"\$progdir/\$program\"; then"
4091267843Sdelphij
4092267843Sdelphij	# fixup the dll searchpath if we need to.
4093267843Sdelphij	#
4094267843Sdelphij	# Fix the DLL searchpath if we need to.  Do this before prepending
4095267843Sdelphij	# to shlibpath, because on Windows, both are PATH and uninstalled
4096267843Sdelphij	# libraries must come first.
4097267843Sdelphij	if test -n "$dllsearchpath"; then
4098267843Sdelphij	  $ECHO "\
4099267843Sdelphij    # Add the dll search path components to the executable PATH
4100267843Sdelphij    PATH=$dllsearchpath:\$PATH
4101267843Sdelphij"
4102267843Sdelphij	fi
4103267843Sdelphij
4104267843Sdelphij	# Export our shlibpath_var if we have one.
4105267843Sdelphij	if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
4106267843Sdelphij	  $ECHO "\
4107267843Sdelphij    # Add our own library path to $shlibpath_var
4108267843Sdelphij    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
4109267843Sdelphij
4110267843Sdelphij    # Some systems cannot cope with colon-terminated $shlibpath_var
4111267843Sdelphij    # The second colon is a workaround for a bug in BeOS R4 sed
4112267843Sdelphij    $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
4113267843Sdelphij
4114267843Sdelphij    export $shlibpath_var
4115267843Sdelphij"
4116267843Sdelphij	fi
4117267843Sdelphij
4118267843Sdelphij	$ECHO "\
4119267843Sdelphij    if test \"\$libtool_execute_magic\" != \"$magic\"; then
4120267843Sdelphij      # Run the actual program with our arguments.
4121267843Sdelphij      func_exec_program \${1+\"\$@\"}
4122267843Sdelphij    fi
4123267843Sdelphij  else
4124267843Sdelphij    # The program doesn't exist.
4125267843Sdelphij    \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
4126267843Sdelphij    \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
4127267843Sdelphij    \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
4128267843Sdelphij    exit 1
4129267843Sdelphij  fi
4130267843Sdelphijfi\
4131267843Sdelphij"
4132267843Sdelphij}
4133267843Sdelphij
4134267843Sdelphij
4135267843Sdelphij# func_emit_cwrapperexe_src
4136267843Sdelphij# emit the source code for a wrapper executable on stdout
4137267843Sdelphij# Must ONLY be called from within func_mode_link because
4138267843Sdelphij# it depends on a number of variable set therein.
4139267843Sdelphijfunc_emit_cwrapperexe_src ()
4140267843Sdelphij{
4141267843Sdelphij	cat <<EOF
4142267843Sdelphij
4143267843Sdelphij/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
4144267843Sdelphij   Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
4145267843Sdelphij
4146267843Sdelphij   The $output program cannot be directly executed until all the libtool
4147267843Sdelphij   libraries that it depends on are installed.
4148267843Sdelphij
4149267843Sdelphij   This wrapper executable should never be moved out of the build directory.
4150267843Sdelphij   If it is, it will not operate correctly.
4151267843Sdelphij*/
4152267843SdelphijEOF
4153267843Sdelphij	    cat <<"EOF"
4154267843Sdelphij#ifdef _MSC_VER
4155267843Sdelphij# define _CRT_SECURE_NO_DEPRECATE 1
4156267843Sdelphij#endif
4157267843Sdelphij#include <stdio.h>
4158267843Sdelphij#include <stdlib.h>
4159267843Sdelphij#ifdef _MSC_VER
4160267843Sdelphij# include <direct.h>
4161267843Sdelphij# include <process.h>
4162267843Sdelphij# include <io.h>
4163267843Sdelphij#else
4164267843Sdelphij# include <unistd.h>
4165267843Sdelphij# include <stdint.h>
4166267843Sdelphij# ifdef __CYGWIN__
4167267843Sdelphij#  include <io.h>
4168267843Sdelphij# endif
4169267843Sdelphij#endif
4170267843Sdelphij#include <malloc.h>
4171267843Sdelphij#include <stdarg.h>
4172267843Sdelphij#include <assert.h>
4173267843Sdelphij#include <string.h>
4174267843Sdelphij#include <ctype.h>
4175267843Sdelphij#include <errno.h>
4176267843Sdelphij#include <fcntl.h>
4177267843Sdelphij#include <sys/stat.h>
4178267843Sdelphij
4179267843Sdelphij/* declarations of non-ANSI functions */
4180267843Sdelphij#if defined(__MINGW32__)
4181267843Sdelphij# ifdef __STRICT_ANSI__
4182267843Sdelphijint _putenv (const char *);
4183267843Sdelphij# endif
4184267843Sdelphij#elif defined(__CYGWIN__)
4185267843Sdelphij# ifdef __STRICT_ANSI__
4186267843Sdelphijchar *realpath (const char *, char *);
4187267843Sdelphijint putenv (char *);
4188267843Sdelphijint setenv (const char *, const char *, int);
4189267843Sdelphij# endif
4190267843Sdelphij/* #elif defined (other platforms) ... */
4191267843Sdelphij#endif
4192267843Sdelphij
4193267843Sdelphij/* portability defines, excluding path handling macros */
4194267843Sdelphij#if defined(_MSC_VER)
4195267843Sdelphij# define setmode _setmode
4196267843Sdelphij# define stat    _stat
4197267843Sdelphij# define chmod   _chmod
4198267843Sdelphij# define getcwd  _getcwd
4199267843Sdelphij# define putenv  _putenv
4200267843Sdelphij# define S_IXUSR _S_IEXEC
4201267843Sdelphij# ifndef _INTPTR_T_DEFINED
4202267843Sdelphij#  define _INTPTR_T_DEFINED
4203267843Sdelphij#  define intptr_t int
4204267843Sdelphij# endif
4205267843Sdelphij#elif defined(__MINGW32__)
4206267843Sdelphij# define setmode _setmode
4207267843Sdelphij# define stat    _stat
4208267843Sdelphij# define chmod   _chmod
4209267843Sdelphij# define getcwd  _getcwd
4210267843Sdelphij# define putenv  _putenv
4211267843Sdelphij#elif defined(__CYGWIN__)
4212267843Sdelphij# define HAVE_SETENV
4213267843Sdelphij# define FOPEN_WB "wb"
4214267843Sdelphij/* #elif defined (other platforms) ... */
4215267843Sdelphij#endif
4216267843Sdelphij
4217267843Sdelphij#if defined(PATH_MAX)
4218267843Sdelphij# define LT_PATHMAX PATH_MAX
4219267843Sdelphij#elif defined(MAXPATHLEN)
4220267843Sdelphij# define LT_PATHMAX MAXPATHLEN
4221267843Sdelphij#else
4222267843Sdelphij# define LT_PATHMAX 1024
4223267843Sdelphij#endif
4224267843Sdelphij
4225267843Sdelphij#ifndef S_IXOTH
4226267843Sdelphij# define S_IXOTH 0
4227267843Sdelphij#endif
4228267843Sdelphij#ifndef S_IXGRP
4229267843Sdelphij# define S_IXGRP 0
4230267843Sdelphij#endif
4231267843Sdelphij
4232267843Sdelphij/* path handling portability macros */
4233267843Sdelphij#ifndef DIR_SEPARATOR
4234267843Sdelphij# define DIR_SEPARATOR '/'
4235267843Sdelphij# define PATH_SEPARATOR ':'
4236267843Sdelphij#endif
4237267843Sdelphij
4238267843Sdelphij#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
4239267843Sdelphij  defined (__OS2__)
4240267843Sdelphij# define HAVE_DOS_BASED_FILE_SYSTEM
4241267843Sdelphij# define FOPEN_WB "wb"
4242267843Sdelphij# ifndef DIR_SEPARATOR_2
4243267843Sdelphij#  define DIR_SEPARATOR_2 '\\'
4244267843Sdelphij# endif
4245267843Sdelphij# ifndef PATH_SEPARATOR_2
4246267843Sdelphij#  define PATH_SEPARATOR_2 ';'
4247267843Sdelphij# endif
4248267843Sdelphij#endif
4249267843Sdelphij
4250267843Sdelphij#ifndef DIR_SEPARATOR_2
4251267843Sdelphij# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
4252267843Sdelphij#else /* DIR_SEPARATOR_2 */
4253267843Sdelphij# define IS_DIR_SEPARATOR(ch) \
4254267843Sdelphij	(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
4255267843Sdelphij#endif /* DIR_SEPARATOR_2 */
4256267843Sdelphij
4257267843Sdelphij#ifndef PATH_SEPARATOR_2
4258267843Sdelphij# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
4259267843Sdelphij#else /* PATH_SEPARATOR_2 */
4260267843Sdelphij# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
4261267843Sdelphij#endif /* PATH_SEPARATOR_2 */
4262267843Sdelphij
4263267843Sdelphij#ifndef FOPEN_WB
4264267843Sdelphij# define FOPEN_WB "w"
4265267843Sdelphij#endif
4266267843Sdelphij#ifndef _O_BINARY
4267267843Sdelphij# define _O_BINARY 0
4268267843Sdelphij#endif
4269267843Sdelphij
4270267843Sdelphij#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
4271267843Sdelphij#define XFREE(stale) do { \
4272267843Sdelphij  if (stale) { free ((void *) stale); stale = 0; } \
4273267843Sdelphij} while (0)
4274267843Sdelphij
4275267843Sdelphij#if defined(LT_DEBUGWRAPPER)
4276267843Sdelphijstatic int lt_debug = 1;
4277267843Sdelphij#else
4278267843Sdelphijstatic int lt_debug = 0;
4279267843Sdelphij#endif
4280267843Sdelphij
4281267843Sdelphijconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */
4282267843Sdelphij
4283267843Sdelphijvoid *xmalloc (size_t num);
4284267843Sdelphijchar *xstrdup (const char *string);
4285267843Sdelphijconst char *base_name (const char *name);
4286267843Sdelphijchar *find_executable (const char *wrapper);
4287267843Sdelphijchar *chase_symlinks (const char *pathspec);
4288267843Sdelphijint make_executable (const char *path);
4289267843Sdelphijint check_executable (const char *path);
4290267843Sdelphijchar *strendzap (char *str, const char *pat);
4291267843Sdelphijvoid lt_debugprintf (const char *file, int line, const char *fmt, ...);
4292267843Sdelphijvoid lt_fatal (const char *file, int line, const char *message, ...);
4293267843Sdelphijstatic const char *nonnull (const char *s);
4294267843Sdelphijstatic const char *nonempty (const char *s);
4295267843Sdelphijvoid lt_setenv (const char *name, const char *value);
4296267843Sdelphijchar *lt_extend_str (const char *orig_value, const char *add, int to_end);
4297267843Sdelphijvoid lt_update_exe_path (const char *name, const char *value);
4298267843Sdelphijvoid lt_update_lib_path (const char *name, const char *value);
4299267843Sdelphijchar **prepare_spawn (char **argv);
4300267843Sdelphijvoid lt_dump_script (FILE *f);
4301267843SdelphijEOF
4302267843Sdelphij
4303267843Sdelphij	    cat <<EOF
4304267843Sdelphijvolatile const char * MAGIC_EXE = "$magic_exe";
4305267843Sdelphijconst char * LIB_PATH_VARNAME = "$shlibpath_var";
4306267843SdelphijEOF
4307267843Sdelphij
4308267843Sdelphij	    if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
4309267843Sdelphij              func_to_host_path "$temp_rpath"
4310267843Sdelphij	      cat <<EOF
4311267843Sdelphijconst char * LIB_PATH_VALUE   = "$func_to_host_path_result";
4312267843SdelphijEOF
4313267843Sdelphij	    else
4314267843Sdelphij	      cat <<"EOF"
4315267843Sdelphijconst char * LIB_PATH_VALUE   = "";
4316267843SdelphijEOF
4317267843Sdelphij	    fi
4318267843Sdelphij
4319267843Sdelphij	    if test -n "$dllsearchpath"; then
4320267843Sdelphij              func_to_host_path "$dllsearchpath:"
4321267843Sdelphij	      cat <<EOF
4322267843Sdelphijconst char * EXE_PATH_VARNAME = "PATH";
4323267843Sdelphijconst char * EXE_PATH_VALUE   = "$func_to_host_path_result";
4324267843SdelphijEOF
4325267843Sdelphij	    else
4326267843Sdelphij	      cat <<"EOF"
4327267843Sdelphijconst char * EXE_PATH_VARNAME = "";
4328267843Sdelphijconst char * EXE_PATH_VALUE   = "";
4329267843SdelphijEOF
4330267843Sdelphij	    fi
4331267843Sdelphij
4332267843Sdelphij	    if test "$fast_install" = yes; then
4333267843Sdelphij	      cat <<EOF
4334267843Sdelphijconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
4335267843SdelphijEOF
4336267843Sdelphij	    else
4337267843Sdelphij	      cat <<EOF
4338267843Sdelphijconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
4339267843SdelphijEOF
4340267843Sdelphij	    fi
4341267843Sdelphij
4342267843Sdelphij
4343267843Sdelphij	    cat <<"EOF"
4344267843Sdelphij
4345267843Sdelphij#define LTWRAPPER_OPTION_PREFIX         "--lt-"
4346267843Sdelphij
4347267843Sdelphijstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
4348267843Sdelphijstatic const char *dumpscript_opt       = LTWRAPPER_OPTION_PREFIX "dump-script";
4349267843Sdelphijstatic const char *debug_opt            = LTWRAPPER_OPTION_PREFIX "debug";
4350267843Sdelphij
4351267843Sdelphijint
4352267843Sdelphijmain (int argc, char *argv[])
4353267843Sdelphij{
4354267843Sdelphij  char **newargz;
4355267843Sdelphij  int  newargc;
4356267843Sdelphij  char *tmp_pathspec;
4357267843Sdelphij  char *actual_cwrapper_path;
4358267843Sdelphij  char *actual_cwrapper_name;
4359267843Sdelphij  char *target_name;
4360267843Sdelphij  char *lt_argv_zero;
4361267843Sdelphij  intptr_t rval = 127;
4362267843Sdelphij
4363267843Sdelphij  int i;
4364267843Sdelphij
4365267843Sdelphij  program_name = (char *) xstrdup (base_name (argv[0]));
4366267843Sdelphij  newargz = XMALLOC (char *, argc + 1);
4367267843Sdelphij
4368267843Sdelphij  /* very simple arg parsing; don't want to rely on getopt
4369267843Sdelphij   * also, copy all non cwrapper options to newargz, except
4370267843Sdelphij   * argz[0], which is handled differently
4371267843Sdelphij   */
4372267843Sdelphij  newargc=0;
4373267843Sdelphij  for (i = 1; i < argc; i++)
4374267843Sdelphij    {
4375267843Sdelphij      if (strcmp (argv[i], dumpscript_opt) == 0)
4376267843Sdelphij	{
4377267843SdelphijEOF
4378267843Sdelphij	    case "$host" in
4379267843Sdelphij	      *mingw* | *cygwin* )
4380267843Sdelphij		# make stdout use "unix" line endings
4381267843Sdelphij		echo "          setmode(1,_O_BINARY);"
4382267843Sdelphij		;;
4383267843Sdelphij	      esac
4384267843Sdelphij
4385267843Sdelphij	    cat <<"EOF"
4386267843Sdelphij	  lt_dump_script (stdout);
4387267843Sdelphij	  return 0;
4388267843Sdelphij	}
4389267843Sdelphij      if (strcmp (argv[i], debug_opt) == 0)
4390267843Sdelphij	{
4391267843Sdelphij          lt_debug = 1;
4392267843Sdelphij          continue;
4393267843Sdelphij	}
4394267843Sdelphij      if (strcmp (argv[i], ltwrapper_option_prefix) == 0)
4395267843Sdelphij        {
4396267843Sdelphij          /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
4397267843Sdelphij             namespace, but it is not one of the ones we know about and
4398267843Sdelphij             have already dealt with, above (inluding dump-script), then
4399267843Sdelphij             report an error. Otherwise, targets might begin to believe
4400267843Sdelphij             they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
4401267843Sdelphij             namespace. The first time any user complains about this, we'll
4402267843Sdelphij             need to make LTWRAPPER_OPTION_PREFIX a configure-time option
4403267843Sdelphij             or a configure.ac-settable value.
4404267843Sdelphij           */
4405267843Sdelphij          lt_fatal (__FILE__, __LINE__,
4406267843Sdelphij		    "unrecognized %s option: '%s'",
4407267843Sdelphij                    ltwrapper_option_prefix, argv[i]);
4408267843Sdelphij        }
4409267843Sdelphij      /* otherwise ... */
4410267843Sdelphij      newargz[++newargc] = xstrdup (argv[i]);
4411267843Sdelphij    }
4412267843Sdelphij  newargz[++newargc] = NULL;
4413267843Sdelphij
4414267843SdelphijEOF
4415267843Sdelphij	    cat <<EOF
4416267843Sdelphij  /* The GNU banner must be the first non-error debug message */
4417267843Sdelphij  lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\n");
4418267843SdelphijEOF
4419267843Sdelphij	    cat <<"EOF"
4420267843Sdelphij  lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
4421267843Sdelphij  lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name);
4422267843Sdelphij
4423267843Sdelphij  tmp_pathspec = find_executable (argv[0]);
4424267843Sdelphij  if (tmp_pathspec == NULL)
4425267843Sdelphij    lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]);
4426267843Sdelphij  lt_debugprintf (__FILE__, __LINE__,
4427267843Sdelphij                  "(main) found exe (before symlink chase) at: %s\n",
4428267843Sdelphij		  tmp_pathspec);
4429267843Sdelphij
4430267843Sdelphij  actual_cwrapper_path = chase_symlinks (tmp_pathspec);
4431267843Sdelphij  lt_debugprintf (__FILE__, __LINE__,
4432267843Sdelphij                  "(main) found exe (after symlink chase) at: %s\n",
4433267843Sdelphij		  actual_cwrapper_path);
4434267843Sdelphij  XFREE (tmp_pathspec);
4435267843Sdelphij
4436267843Sdelphij  actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));
4437267843Sdelphij  strendzap (actual_cwrapper_path, actual_cwrapper_name);
4438267843Sdelphij
4439267843Sdelphij  /* wrapper name transforms */
4440267843Sdelphij  strendzap (actual_cwrapper_name, ".exe");
4441267843Sdelphij  tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
4442267843Sdelphij  XFREE (actual_cwrapper_name);
4443267843Sdelphij  actual_cwrapper_name = tmp_pathspec;
4444267843Sdelphij  tmp_pathspec = 0;
4445267843Sdelphij
4446267843Sdelphij  /* target_name transforms -- use actual target program name; might have lt- prefix */
4447267843Sdelphij  target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
4448267843Sdelphij  strendzap (target_name, ".exe");
4449267843Sdelphij  tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
4450267843Sdelphij  XFREE (target_name);
4451267843Sdelphij  target_name = tmp_pathspec;
4452267843Sdelphij  tmp_pathspec = 0;
4453267843Sdelphij
4454267843Sdelphij  lt_debugprintf (__FILE__, __LINE__,
4455267843Sdelphij		  "(main) libtool target name: %s\n",
4456267843Sdelphij		  target_name);
4457267843SdelphijEOF
4458267843Sdelphij
4459267843Sdelphij	    cat <<EOF
4460267843Sdelphij  newargz[0] =
4461267843Sdelphij    XMALLOC (char, (strlen (actual_cwrapper_path) +
4462267843Sdelphij		    strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
4463267843Sdelphij  strcpy (newargz[0], actual_cwrapper_path);
4464267843Sdelphij  strcat (newargz[0], "$objdir");
4465267843Sdelphij  strcat (newargz[0], "/");
4466267843SdelphijEOF
4467267843Sdelphij
4468267843Sdelphij	    cat <<"EOF"
4469267843Sdelphij  /* stop here, and copy so we don't have to do this twice */
4470267843Sdelphij  tmp_pathspec = xstrdup (newargz[0]);
4471267843Sdelphij
4472267843Sdelphij  /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
4473267843Sdelphij  strcat (newargz[0], actual_cwrapper_name);
4474267843Sdelphij
4475267843Sdelphij  /* DO want the lt- prefix here if it exists, so use target_name */
4476267843Sdelphij  lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
4477267843Sdelphij  XFREE (tmp_pathspec);
4478267843Sdelphij  tmp_pathspec = NULL;
4479267843SdelphijEOF
4480267843Sdelphij
4481267843Sdelphij	    case $host_os in
4482267843Sdelphij	      mingw*)
4483267843Sdelphij	    cat <<"EOF"
4484267843Sdelphij  {
4485267843Sdelphij    char* p;
4486267843Sdelphij    while ((p = strchr (newargz[0], '\\')) != NULL)
4487267843Sdelphij      {
4488267843Sdelphij	*p = '/';
4489267843Sdelphij      }
4490267843Sdelphij    while ((p = strchr (lt_argv_zero, '\\')) != NULL)
4491267843Sdelphij      {
4492267843Sdelphij	*p = '/';
4493267843Sdelphij      }
4494267843Sdelphij  }
4495267843SdelphijEOF
4496267843Sdelphij	    ;;
4497267843Sdelphij	    esac
4498267843Sdelphij
4499267843Sdelphij	    cat <<"EOF"
4500267843Sdelphij  XFREE (target_name);
4501267843Sdelphij  XFREE (actual_cwrapper_path);
4502267843Sdelphij  XFREE (actual_cwrapper_name);
4503267843Sdelphij
4504267843Sdelphij  lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
4505267843Sdelphij  lt_setenv ("DUALCASE", "1");  /* for MSK sh */
4506267843Sdelphij  /* Update the DLL searchpath.  EXE_PATH_VALUE ($dllsearchpath) must
4507267843Sdelphij     be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath)
4508267843Sdelphij     because on Windows, both *_VARNAMEs are PATH but uninstalled
4509267843Sdelphij     libraries must come first. */
4510267843Sdelphij  lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
4511267843Sdelphij  lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
4512267843Sdelphij
4513267843Sdelphij  lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",
4514267843Sdelphij		  nonnull (lt_argv_zero));
4515267843Sdelphij  for (i = 0; i < newargc; i++)
4516267843Sdelphij    {
4517267843Sdelphij      lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n",
4518267843Sdelphij		      i, nonnull (newargz[i]));
4519267843Sdelphij    }
4520267843Sdelphij
4521267843SdelphijEOF
4522267843Sdelphij
4523267843Sdelphij	    case $host_os in
4524267843Sdelphij	      mingw*)
4525267843Sdelphij		cat <<"EOF"
4526267843Sdelphij  /* execv doesn't actually work on mingw as expected on unix */
4527267843Sdelphij  newargz = prepare_spawn (newargz);
4528267843Sdelphij  rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
4529267843Sdelphij  if (rval == -1)
4530267843Sdelphij    {
4531267843Sdelphij      /* failed to start process */
4532267843Sdelphij      lt_debugprintf (__FILE__, __LINE__,
4533267843Sdelphij		      "(main) failed to launch target \"%s\": %s\n",
4534267843Sdelphij		      lt_argv_zero, nonnull (strerror (errno)));
4535267843Sdelphij      return 127;
4536267843Sdelphij    }
4537267843Sdelphij  return rval;
4538267843SdelphijEOF
4539267843Sdelphij		;;
4540267843Sdelphij	      *)
4541267843Sdelphij		cat <<"EOF"
4542267843Sdelphij  execv (lt_argv_zero, newargz);
4543267843Sdelphij  return rval; /* =127, but avoids unused variable warning */
4544267843SdelphijEOF
4545267843Sdelphij		;;
4546267843Sdelphij	    esac
4547267843Sdelphij
4548267843Sdelphij	    cat <<"EOF"
4549267843Sdelphij}
4550267843Sdelphij
4551267843Sdelphijvoid *
4552267843Sdelphijxmalloc (size_t num)
4553267843Sdelphij{
4554267843Sdelphij  void *p = (void *) malloc (num);
4555267843Sdelphij  if (!p)
4556267843Sdelphij    lt_fatal (__FILE__, __LINE__, "memory exhausted");
4557267843Sdelphij
4558267843Sdelphij  return p;
4559267843Sdelphij}
4560267843Sdelphij
4561267843Sdelphijchar *
4562267843Sdelphijxstrdup (const char *string)
4563267843Sdelphij{
4564267843Sdelphij  return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
4565267843Sdelphij			  string) : NULL;
4566267843Sdelphij}
4567267843Sdelphij
4568267843Sdelphijconst char *
4569267843Sdelphijbase_name (const char *name)
4570267843Sdelphij{
4571267843Sdelphij  const char *base;
4572267843Sdelphij
4573267843Sdelphij#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4574267843Sdelphij  /* Skip over the disk name in MSDOS pathnames. */
4575267843Sdelphij  if (isalpha ((unsigned char) name[0]) && name[1] == ':')
4576267843Sdelphij    name += 2;
4577267843Sdelphij#endif
4578267843Sdelphij
4579267843Sdelphij  for (base = name; *name; name++)
4580267843Sdelphij    if (IS_DIR_SEPARATOR (*name))
4581267843Sdelphij      base = name + 1;
4582267843Sdelphij  return base;
4583267843Sdelphij}
4584267843Sdelphij
4585267843Sdelphijint
4586267843Sdelphijcheck_executable (const char *path)
4587267843Sdelphij{
4588267843Sdelphij  struct stat st;
4589267843Sdelphij
4590267843Sdelphij  lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n",
4591267843Sdelphij                  nonempty (path));
4592267843Sdelphij  if ((!path) || (!*path))
4593267843Sdelphij    return 0;
4594267843Sdelphij
4595267843Sdelphij  if ((stat (path, &st) >= 0)
4596267843Sdelphij      && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
4597267843Sdelphij    return 1;
4598267843Sdelphij  else
4599267843Sdelphij    return 0;
4600267843Sdelphij}
4601267843Sdelphij
4602267843Sdelphijint
4603267843Sdelphijmake_executable (const char *path)
4604267843Sdelphij{
4605267843Sdelphij  int rval = 0;
4606267843Sdelphij  struct stat st;
4607267843Sdelphij
4608267843Sdelphij  lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n",
4609267843Sdelphij                  nonempty (path));
4610267843Sdelphij  if ((!path) || (!*path))
4611267843Sdelphij    return 0;
4612267843Sdelphij
4613267843Sdelphij  if (stat (path, &st) >= 0)
4614267843Sdelphij    {
4615267843Sdelphij      rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
4616267843Sdelphij    }
4617267843Sdelphij  return rval;
4618267843Sdelphij}
4619267843Sdelphij
4620267843Sdelphij/* Searches for the full path of the wrapper.  Returns
4621267843Sdelphij   newly allocated full path name if found, NULL otherwise
4622267843Sdelphij   Does not chase symlinks, even on platforms that support them.
4623267843Sdelphij*/
4624267843Sdelphijchar *
4625267843Sdelphijfind_executable (const char *wrapper)
4626267843Sdelphij{
4627267843Sdelphij  int has_slash = 0;
4628267843Sdelphij  const char *p;
4629267843Sdelphij  const char *p_next;
4630267843Sdelphij  /* static buffer for getcwd */
4631267843Sdelphij  char tmp[LT_PATHMAX + 1];
4632267843Sdelphij  int tmp_len;
4633267843Sdelphij  char *concat_name;
4634267843Sdelphij
4635267843Sdelphij  lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
4636267843Sdelphij                  nonempty (wrapper));
4637267843Sdelphij
4638267843Sdelphij  if ((wrapper == NULL) || (*wrapper == '\0'))
4639267843Sdelphij    return NULL;
4640267843Sdelphij
4641267843Sdelphij  /* Absolute path? */
4642267843Sdelphij#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4643267843Sdelphij  if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
4644267843Sdelphij    {
4645267843Sdelphij      concat_name = xstrdup (wrapper);
4646267843Sdelphij      if (check_executable (concat_name))
4647267843Sdelphij	return concat_name;
4648267843Sdelphij      XFREE (concat_name);
4649267843Sdelphij    }
4650267843Sdelphij  else
4651267843Sdelphij    {
4652267843Sdelphij#endif
4653267843Sdelphij      if (IS_DIR_SEPARATOR (wrapper[0]))
4654267843Sdelphij	{
4655267843Sdelphij	  concat_name = xstrdup (wrapper);
4656267843Sdelphij	  if (check_executable (concat_name))
4657267843Sdelphij	    return concat_name;
4658267843Sdelphij	  XFREE (concat_name);
4659267843Sdelphij	}
4660267843Sdelphij#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4661267843Sdelphij    }
4662267843Sdelphij#endif
4663267843Sdelphij
4664267843Sdelphij  for (p = wrapper; *p; p++)
4665267843Sdelphij    if (*p == '/')
4666267843Sdelphij      {
4667267843Sdelphij	has_slash = 1;
4668267843Sdelphij	break;
4669267843Sdelphij      }
4670267843Sdelphij  if (!has_slash)
4671267843Sdelphij    {
4672267843Sdelphij      /* no slashes; search PATH */
4673267843Sdelphij      const char *path = getenv ("PATH");
4674267843Sdelphij      if (path != NULL)
4675267843Sdelphij	{
4676267843Sdelphij	  for (p = path; *p; p = p_next)
4677267843Sdelphij	    {
4678267843Sdelphij	      const char *q;
4679267843Sdelphij	      size_t p_len;
4680267843Sdelphij	      for (q = p; *q; q++)
4681267843Sdelphij		if (IS_PATH_SEPARATOR (*q))
4682267843Sdelphij		  break;
4683267843Sdelphij	      p_len = q - p;
4684267843Sdelphij	      p_next = (*q == '\0' ? q : q + 1);
4685267843Sdelphij	      if (p_len == 0)
4686267843Sdelphij		{
4687267843Sdelphij		  /* empty path: current directory */
4688267843Sdelphij		  if (getcwd (tmp, LT_PATHMAX) == NULL)
4689267843Sdelphij		    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
4690267843Sdelphij                              nonnull (strerror (errno)));
4691267843Sdelphij		  tmp_len = strlen (tmp);
4692267843Sdelphij		  concat_name =
4693267843Sdelphij		    XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
4694267843Sdelphij		  memcpy (concat_name, tmp, tmp_len);
4695267843Sdelphij		  concat_name[tmp_len] = '/';
4696267843Sdelphij		  strcpy (concat_name + tmp_len + 1, wrapper);
4697267843Sdelphij		}
4698267843Sdelphij	      else
4699267843Sdelphij		{
4700267843Sdelphij		  concat_name =
4701267843Sdelphij		    XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
4702267843Sdelphij		  memcpy (concat_name, p, p_len);
4703267843Sdelphij		  concat_name[p_len] = '/';
4704267843Sdelphij		  strcpy (concat_name + p_len + 1, wrapper);
4705267843Sdelphij		}
4706267843Sdelphij	      if (check_executable (concat_name))
4707267843Sdelphij		return concat_name;
4708267843Sdelphij	      XFREE (concat_name);
4709267843Sdelphij	    }
4710267843Sdelphij	}
4711267843Sdelphij      /* not found in PATH; assume curdir */
4712267843Sdelphij    }
4713267843Sdelphij  /* Relative path | not found in path: prepend cwd */
4714267843Sdelphij  if (getcwd (tmp, LT_PATHMAX) == NULL)
4715267843Sdelphij    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
4716267843Sdelphij              nonnull (strerror (errno)));
4717267843Sdelphij  tmp_len = strlen (tmp);
4718267843Sdelphij  concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
4719267843Sdelphij  memcpy (concat_name, tmp, tmp_len);
4720267843Sdelphij  concat_name[tmp_len] = '/';
4721267843Sdelphij  strcpy (concat_name + tmp_len + 1, wrapper);
4722267843Sdelphij
4723267843Sdelphij  if (check_executable (concat_name))
4724267843Sdelphij    return concat_name;
4725267843Sdelphij  XFREE (concat_name);
4726267843Sdelphij  return NULL;
4727267843Sdelphij}
4728267843Sdelphij
4729267843Sdelphijchar *
4730267843Sdelphijchase_symlinks (const char *pathspec)
4731267843Sdelphij{
4732267843Sdelphij#ifndef S_ISLNK
4733267843Sdelphij  return xstrdup (pathspec);
4734267843Sdelphij#else
4735267843Sdelphij  char buf[LT_PATHMAX];
4736267843Sdelphij  struct stat s;
4737267843Sdelphij  char *tmp_pathspec = xstrdup (pathspec);
4738267843Sdelphij  char *p;
4739267843Sdelphij  int has_symlinks = 0;
4740267843Sdelphij  while (strlen (tmp_pathspec) && !has_symlinks)
4741267843Sdelphij    {
4742267843Sdelphij      lt_debugprintf (__FILE__, __LINE__,
4743267843Sdelphij		      "checking path component for symlinks: %s\n",
4744267843Sdelphij		      tmp_pathspec);
4745267843Sdelphij      if (lstat (tmp_pathspec, &s) == 0)
4746267843Sdelphij	{
4747267843Sdelphij	  if (S_ISLNK (s.st_mode) != 0)
4748267843Sdelphij	    {
4749267843Sdelphij	      has_symlinks = 1;
4750267843Sdelphij	      break;
4751267843Sdelphij	    }
4752267843Sdelphij
4753267843Sdelphij	  /* search backwards for last DIR_SEPARATOR */
4754267843Sdelphij	  p = tmp_pathspec + strlen (tmp_pathspec) - 1;
4755267843Sdelphij	  while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
4756267843Sdelphij	    p--;
4757267843Sdelphij	  if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
4758267843Sdelphij	    {
4759267843Sdelphij	      /* no more DIR_SEPARATORS left */
4760267843Sdelphij	      break;
4761267843Sdelphij	    }
4762267843Sdelphij	  *p = '\0';
4763267843Sdelphij	}
4764267843Sdelphij      else
4765267843Sdelphij	{
4766267843Sdelphij	  lt_fatal (__FILE__, __LINE__,
4767267843Sdelphij		    "error accessing file \"%s\": %s",
4768267843Sdelphij		    tmp_pathspec, nonnull (strerror (errno)));
4769267843Sdelphij	}
4770267843Sdelphij    }
4771267843Sdelphij  XFREE (tmp_pathspec);
4772267843Sdelphij
4773267843Sdelphij  if (!has_symlinks)
4774267843Sdelphij    {
4775267843Sdelphij      return xstrdup (pathspec);
4776267843Sdelphij    }
4777267843Sdelphij
4778267843Sdelphij  tmp_pathspec = realpath (pathspec, buf);
4779267843Sdelphij  if (tmp_pathspec == 0)
4780267843Sdelphij    {
4781267843Sdelphij      lt_fatal (__FILE__, __LINE__,
4782267843Sdelphij		"could not follow symlinks for %s", pathspec);
4783267843Sdelphij    }
4784267843Sdelphij  return xstrdup (tmp_pathspec);
4785267843Sdelphij#endif
4786267843Sdelphij}
4787267843Sdelphij
4788267843Sdelphijchar *
4789267843Sdelphijstrendzap (char *str, const char *pat)
4790267843Sdelphij{
4791267843Sdelphij  size_t len, patlen;
4792267843Sdelphij
4793267843Sdelphij  assert (str != NULL);
4794267843Sdelphij  assert (pat != NULL);
4795267843Sdelphij
4796267843Sdelphij  len = strlen (str);
4797267843Sdelphij  patlen = strlen (pat);
4798267843Sdelphij
4799267843Sdelphij  if (patlen <= len)
4800267843Sdelphij    {
4801267843Sdelphij      str += len - patlen;
4802267843Sdelphij      if (strcmp (str, pat) == 0)
4803267843Sdelphij	*str = '\0';
4804267843Sdelphij    }
4805267843Sdelphij  return str;
4806267843Sdelphij}
4807267843Sdelphij
4808267843Sdelphijvoid
4809267843Sdelphijlt_debugprintf (const char *file, int line, const char *fmt, ...)
4810267843Sdelphij{
4811267843Sdelphij  va_list args;
4812267843Sdelphij  if (lt_debug)
4813267843Sdelphij    {
4814267843Sdelphij      (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line);
4815267843Sdelphij      va_start (args, fmt);
4816267843Sdelphij      (void) vfprintf (stderr, fmt, args);
4817267843Sdelphij      va_end (args);
4818267843Sdelphij    }
4819267843Sdelphij}
4820267843Sdelphij
4821267843Sdelphijstatic void
4822267843Sdelphijlt_error_core (int exit_status, const char *file,
4823267843Sdelphij	       int line, const char *mode,
4824267843Sdelphij	       const char *message, va_list ap)
4825267843Sdelphij{
4826267843Sdelphij  fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode);
4827267843Sdelphij  vfprintf (stderr, message, ap);
4828267843Sdelphij  fprintf (stderr, ".\n");
4829267843Sdelphij
4830267843Sdelphij  if (exit_status >= 0)
4831267843Sdelphij    exit (exit_status);
4832267843Sdelphij}
4833267843Sdelphij
4834267843Sdelphijvoid
4835267843Sdelphijlt_fatal (const char *file, int line, const char *message, ...)
4836267843Sdelphij{
4837267843Sdelphij  va_list ap;
4838267843Sdelphij  va_start (ap, message);
4839267843Sdelphij  lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap);
4840267843Sdelphij  va_end (ap);
4841267843Sdelphij}
4842267843Sdelphij
4843267843Sdelphijstatic const char *
4844267843Sdelphijnonnull (const char *s)
4845267843Sdelphij{
4846267843Sdelphij  return s ? s : "(null)";
4847267843Sdelphij}
4848267843Sdelphij
4849267843Sdelphijstatic const char *
4850267843Sdelphijnonempty (const char *s)
4851267843Sdelphij{
4852267843Sdelphij  return (s && !*s) ? "(empty)" : nonnull (s);
4853267843Sdelphij}
4854267843Sdelphij
4855267843Sdelphijvoid
4856267843Sdelphijlt_setenv (const char *name, const char *value)
4857267843Sdelphij{
4858267843Sdelphij  lt_debugprintf (__FILE__, __LINE__,
4859267843Sdelphij		  "(lt_setenv) setting '%s' to '%s'\n",
4860267843Sdelphij                  nonnull (name), nonnull (value));
4861267843Sdelphij  {
4862267843Sdelphij#ifdef HAVE_SETENV
4863267843Sdelphij    /* always make a copy, for consistency with !HAVE_SETENV */
4864267843Sdelphij    char *str = xstrdup (value);
4865267843Sdelphij    setenv (name, str, 1);
4866267843Sdelphij#else
4867267843Sdelphij    int len = strlen (name) + 1 + strlen (value) + 1;
4868267843Sdelphij    char *str = XMALLOC (char, len);
4869267843Sdelphij    sprintf (str, "%s=%s", name, value);
4870267843Sdelphij    if (putenv (str) != EXIT_SUCCESS)
4871267843Sdelphij      {
4872267843Sdelphij        XFREE (str);
4873267843Sdelphij      }
4874267843Sdelphij#endif
4875267843Sdelphij  }
4876267843Sdelphij}
4877267843Sdelphij
4878267843Sdelphijchar *
4879267843Sdelphijlt_extend_str (const char *orig_value, const char *add, int to_end)
4880267843Sdelphij{
4881267843Sdelphij  char *new_value;
4882267843Sdelphij  if (orig_value && *orig_value)
4883267843Sdelphij    {
4884267843Sdelphij      int orig_value_len = strlen (orig_value);
4885267843Sdelphij      int add_len = strlen (add);
4886267843Sdelphij      new_value = XMALLOC (char, add_len + orig_value_len + 1);
4887267843Sdelphij      if (to_end)
4888267843Sdelphij        {
4889267843Sdelphij          strcpy (new_value, orig_value);
4890267843Sdelphij          strcpy (new_value + orig_value_len, add);
4891267843Sdelphij        }
4892267843Sdelphij      else
4893267843Sdelphij        {
4894267843Sdelphij          strcpy (new_value, add);
4895267843Sdelphij          strcpy (new_value + add_len, orig_value);
4896267843Sdelphij        }
4897267843Sdelphij    }
4898267843Sdelphij  else
4899267843Sdelphij    {
4900267843Sdelphij      new_value = xstrdup (add);
4901267843Sdelphij    }
4902267843Sdelphij  return new_value;
4903267843Sdelphij}
4904267843Sdelphij
4905267843Sdelphijvoid
4906267843Sdelphijlt_update_exe_path (const char *name, const char *value)
4907267843Sdelphij{
4908267843Sdelphij  lt_debugprintf (__FILE__, __LINE__,
4909267843Sdelphij		  "(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
4910267843Sdelphij                  nonnull (name), nonnull (value));
4911267843Sdelphij
4912267843Sdelphij  if (name && *name && value && *value)
4913267843Sdelphij    {
4914267843Sdelphij      char *new_value = lt_extend_str (getenv (name), value, 0);
4915267843Sdelphij      /* some systems can't cope with a ':'-terminated path #' */
4916267843Sdelphij      int len = strlen (new_value);
4917267843Sdelphij      while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
4918267843Sdelphij        {
4919267843Sdelphij          new_value[len-1] = '\0';
4920267843Sdelphij        }
4921267843Sdelphij      lt_setenv (name, new_value);
4922267843Sdelphij      XFREE (new_value);
4923267843Sdelphij    }
4924267843Sdelphij}
4925267843Sdelphij
4926267843Sdelphijvoid
4927267843Sdelphijlt_update_lib_path (const char *name, const char *value)
4928267843Sdelphij{
4929267843Sdelphij  lt_debugprintf (__FILE__, __LINE__,
4930267843Sdelphij		  "(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
4931267843Sdelphij                  nonnull (name), nonnull (value));
4932267843Sdelphij
4933267843Sdelphij  if (name && *name && value && *value)
4934267843Sdelphij    {
4935267843Sdelphij      char *new_value = lt_extend_str (getenv (name), value, 0);
4936267843Sdelphij      lt_setenv (name, new_value);
4937267843Sdelphij      XFREE (new_value);
4938267843Sdelphij    }
4939267843Sdelphij}
4940267843Sdelphij
4941267843SdelphijEOF
4942267843Sdelphij	    case $host_os in
4943267843Sdelphij	      mingw*)
4944267843Sdelphij		cat <<"EOF"
4945267843Sdelphij
4946267843Sdelphij/* Prepares an argument vector before calling spawn().
4947267843Sdelphij   Note that spawn() does not by itself call the command interpreter
4948267843Sdelphij     (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
4949267843Sdelphij      ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
4950267843Sdelphij         GetVersionEx(&v);
4951267843Sdelphij         v.dwPlatformId == VER_PLATFORM_WIN32_NT;
4952267843Sdelphij      }) ? "cmd.exe" : "command.com").
4953267843Sdelphij   Instead it simply concatenates the arguments, separated by ' ', and calls
4954267843Sdelphij   CreateProcess().  We must quote the arguments since Win32 CreateProcess()
4955267843Sdelphij   interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
4956267843Sdelphij   special way:
4957267843Sdelphij   - Space and tab are interpreted as delimiters. They are not treated as
4958267843Sdelphij     delimiters if they are surrounded by double quotes: "...".
4959267843Sdelphij   - Unescaped double quotes are removed from the input. Their only effect is
4960267843Sdelphij     that within double quotes, space and tab are treated like normal
4961267843Sdelphij     characters.
4962267843Sdelphij   - Backslashes not followed by double quotes are not special.
4963267843Sdelphij   - But 2*n+1 backslashes followed by a double quote become
4964267843Sdelphij     n backslashes followed by a double quote (n >= 0):
4965267843Sdelphij       \" -> "
4966267843Sdelphij       \\\" -> \"
4967267843Sdelphij       \\\\\" -> \\"
4968267843Sdelphij */
4969267843Sdelphij#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"
4970267843Sdelphij#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"
4971267843Sdelphijchar **
4972267843Sdelphijprepare_spawn (char **argv)
4973267843Sdelphij{
4974267843Sdelphij  size_t argc;
4975267843Sdelphij  char **new_argv;
4976267843Sdelphij  size_t i;
4977267843Sdelphij
4978267843Sdelphij  /* Count number of arguments.  */
4979267843Sdelphij  for (argc = 0; argv[argc] != NULL; argc++)
4980267843Sdelphij    ;
4981267843Sdelphij
4982267843Sdelphij  /* Allocate new argument vector.  */
4983267843Sdelphij  new_argv = XMALLOC (char *, argc + 1);
4984267843Sdelphij
4985267843Sdelphij  /* Put quoted arguments into the new argument vector.  */
4986267843Sdelphij  for (i = 0; i < argc; i++)
4987267843Sdelphij    {
4988267843Sdelphij      const char *string = argv[i];
4989267843Sdelphij
4990267843Sdelphij      if (string[0] == '\0')
4991267843Sdelphij	new_argv[i] = xstrdup ("\"\"");
4992267843Sdelphij      else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
4993267843Sdelphij	{
4994267843Sdelphij	  int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
4995267843Sdelphij	  size_t length;
4996267843Sdelphij	  unsigned int backslashes;
4997267843Sdelphij	  const char *s;
4998267843Sdelphij	  char *quoted_string;
4999267843Sdelphij	  char *p;
5000267843Sdelphij
5001267843Sdelphij	  length = 0;
5002267843Sdelphij	  backslashes = 0;
5003267843Sdelphij	  if (quote_around)
5004267843Sdelphij	    length++;
5005267843Sdelphij	  for (s = string; *s != '\0'; s++)
5006267843Sdelphij	    {
5007267843Sdelphij	      char c = *s;
5008267843Sdelphij	      if (c == '"')
5009267843Sdelphij		length += backslashes + 1;
5010267843Sdelphij	      length++;
5011267843Sdelphij	      if (c == '\\')
5012267843Sdelphij		backslashes++;
5013267843Sdelphij	      else
5014267843Sdelphij		backslashes = 0;
5015267843Sdelphij	    }
5016267843Sdelphij	  if (quote_around)
5017267843Sdelphij	    length += backslashes + 1;
5018267843Sdelphij
5019267843Sdelphij	  quoted_string = XMALLOC (char, length + 1);
5020267843Sdelphij
5021267843Sdelphij	  p = quoted_string;
5022267843Sdelphij	  backslashes = 0;
5023267843Sdelphij	  if (quote_around)
5024267843Sdelphij	    *p++ = '"';
5025267843Sdelphij	  for (s = string; *s != '\0'; s++)
5026267843Sdelphij	    {
5027267843Sdelphij	      char c = *s;
5028267843Sdelphij	      if (c == '"')
5029267843Sdelphij		{
5030267843Sdelphij		  unsigned int j;
5031267843Sdelphij		  for (j = backslashes + 1; j > 0; j--)
5032267843Sdelphij		    *p++ = '\\';
5033267843Sdelphij		}
5034267843Sdelphij	      *p++ = c;
5035267843Sdelphij	      if (c == '\\')
5036267843Sdelphij		backslashes++;
5037267843Sdelphij	      else
5038267843Sdelphij		backslashes = 0;
5039267843Sdelphij	    }
5040267843Sdelphij	  if (quote_around)
5041267843Sdelphij	    {
5042267843Sdelphij	      unsigned int j;
5043267843Sdelphij	      for (j = backslashes; j > 0; j--)
5044267843Sdelphij		*p++ = '\\';
5045267843Sdelphij	      *p++ = '"';
5046267843Sdelphij	    }
5047267843Sdelphij	  *p = '\0';
5048267843Sdelphij
5049267843Sdelphij	  new_argv[i] = quoted_string;
5050267843Sdelphij	}
5051267843Sdelphij      else
5052267843Sdelphij	new_argv[i] = (char *) string;
5053267843Sdelphij    }
5054267843Sdelphij  new_argv[argc] = NULL;
5055267843Sdelphij
5056267843Sdelphij  return new_argv;
5057267843Sdelphij}
5058267843SdelphijEOF
5059267843Sdelphij		;;
5060267843Sdelphij	    esac
5061267843Sdelphij
5062267843Sdelphij            cat <<"EOF"
5063267843Sdelphijvoid lt_dump_script (FILE* f)
5064267843Sdelphij{
5065267843SdelphijEOF
5066267843Sdelphij	    func_emit_wrapper yes |
5067267843Sdelphij	      $SED -n -e '
5068267843Sdelphijs/^\(.\{79\}\)\(..*\)/\1\
5069267843Sdelphij\2/
5070267843Sdelphijh
5071267843Sdelphijs/\([\\"]\)/\\\1/g
5072267843Sdelphijs/$/\\n/
5073267843Sdelphijs/\([^\n]*\).*/  fputs ("\1", f);/p
5074267843Sdelphijg
5075267843SdelphijD'
5076267843Sdelphij            cat <<"EOF"
5077267843Sdelphij}
5078267843SdelphijEOF
5079267843Sdelphij}
5080267843Sdelphij# end: func_emit_cwrapperexe_src
5081267843Sdelphij
5082267843Sdelphij# func_win32_import_lib_p ARG
5083267843Sdelphij# True if ARG is an import lib, as indicated by $file_magic_cmd
5084267843Sdelphijfunc_win32_import_lib_p ()
5085267843Sdelphij{
5086267843Sdelphij    $opt_debug
5087267843Sdelphij    case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
5088267843Sdelphij    *import*) : ;;
5089267843Sdelphij    *) false ;;
5090267843Sdelphij    esac
5091267843Sdelphij}
5092267843Sdelphij
5093267843Sdelphij# func_mode_link arg...
5094267843Sdelphijfunc_mode_link ()
5095267843Sdelphij{
5096267843Sdelphij    $opt_debug
5097267843Sdelphij    case $host in
5098267843Sdelphij    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
5099267843Sdelphij      # It is impossible to link a dll without this setting, and
5100267843Sdelphij      # we shouldn't force the makefile maintainer to figure out
5101267843Sdelphij      # which system we are compiling for in order to pass an extra
5102267843Sdelphij      # flag for every libtool invocation.
5103267843Sdelphij      # allow_undefined=no
5104267843Sdelphij
5105267843Sdelphij      # FIXME: Unfortunately, there are problems with the above when trying
5106267843Sdelphij      # to make a dll which has undefined symbols, in which case not
5107267843Sdelphij      # even a static library is built.  For now, we need to specify
5108267843Sdelphij      # -no-undefined on the libtool link line when we can be certain
5109267843Sdelphij      # that all symbols are satisfied, otherwise we get a static library.
5110267843Sdelphij      allow_undefined=yes
5111267843Sdelphij      ;;
5112267843Sdelphij    *)
5113267843Sdelphij      allow_undefined=yes
5114267843Sdelphij      ;;
5115267843Sdelphij    esac
5116267843Sdelphij    libtool_args=$nonopt
5117267843Sdelphij    base_compile="$nonopt $@"
5118267843Sdelphij    compile_command=$nonopt
5119267843Sdelphij    finalize_command=$nonopt
5120267843Sdelphij
5121267843Sdelphij    compile_rpath=
5122267843Sdelphij    finalize_rpath=
5123267843Sdelphij    compile_shlibpath=
5124267843Sdelphij    finalize_shlibpath=
5125267843Sdelphij    convenience=
5126267843Sdelphij    old_convenience=
5127267843Sdelphij    deplibs=
5128267843Sdelphij    old_deplibs=
5129267843Sdelphij    compiler_flags=
5130267843Sdelphij    linker_flags=
5131267843Sdelphij    dllsearchpath=
5132267843Sdelphij    lib_search_path=`pwd`
5133267843Sdelphij    inst_prefix_dir=
5134267843Sdelphij    new_inherited_linker_flags=
5135267843Sdelphij
5136267843Sdelphij    avoid_version=no
5137267843Sdelphij    bindir=
5138267843Sdelphij    dlfiles=
5139267843Sdelphij    dlprefiles=
5140267843Sdelphij    dlself=no
5141267843Sdelphij    export_dynamic=no
5142267843Sdelphij    export_symbols=
5143267843Sdelphij    export_symbols_regex=
5144267843Sdelphij    generated=
5145267843Sdelphij    libobjs=
5146267843Sdelphij    ltlibs=
5147267843Sdelphij    module=no
5148267843Sdelphij    no_install=no
5149267843Sdelphij    objs=
5150267843Sdelphij    non_pic_objects=
5151267843Sdelphij    precious_files_regex=
5152267843Sdelphij    prefer_static_libs=no
5153267843Sdelphij    preload=no
5154267843Sdelphij    prev=
5155267843Sdelphij    prevarg=
5156267843Sdelphij    release=
5157267843Sdelphij    rpath=
5158267843Sdelphij    xrpath=
5159267843Sdelphij    perm_rpath=
5160267843Sdelphij    temp_rpath=
5161267843Sdelphij    thread_safe=no
5162267843Sdelphij    vinfo=
5163267843Sdelphij    vinfo_number=no
5164267843Sdelphij    weak_libs=
5165267843Sdelphij    single_module="${wl}-single_module"
5166267843Sdelphij    func_infer_tag $base_compile
5167267843Sdelphij
5168267843Sdelphij    # We need to know -static, to get the right output filenames.
5169267843Sdelphij    for arg
5170267843Sdelphij    do
5171267843Sdelphij      case $arg in
5172267843Sdelphij      -shared)
5173267843Sdelphij	test "$build_libtool_libs" != yes && \
5174267843Sdelphij	  func_fatal_configuration "can not build a shared library"
5175267843Sdelphij	build_old_libs=no
5176267843Sdelphij	break
5177267843Sdelphij	;;
5178267843Sdelphij      -all-static | -static | -static-libtool-libs)
5179267843Sdelphij	case $arg in
5180267843Sdelphij	-all-static)
5181267843Sdelphij	  if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
5182267843Sdelphij	    func_warning "complete static linking is impossible in this configuration"
5183267843Sdelphij	  fi
5184267843Sdelphij	  if test -n "$link_static_flag"; then
5185267843Sdelphij	    dlopen_self=$dlopen_self_static
5186267843Sdelphij	  fi
5187267843Sdelphij	  prefer_static_libs=yes
5188267843Sdelphij	  ;;
5189267843Sdelphij	-static)
5190267843Sdelphij	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
5191267843Sdelphij	    dlopen_self=$dlopen_self_static
5192267843Sdelphij	  fi
5193267843Sdelphij	  prefer_static_libs=built
5194267843Sdelphij	  ;;
5195267843Sdelphij	-static-libtool-libs)
5196267843Sdelphij	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
5197267843Sdelphij	    dlopen_self=$dlopen_self_static
5198267843Sdelphij	  fi
5199267843Sdelphij	  prefer_static_libs=yes
5200267843Sdelphij	  ;;
5201267843Sdelphij	esac
5202267843Sdelphij	build_libtool_libs=no
5203267843Sdelphij	build_old_libs=yes
5204267843Sdelphij	break
5205267843Sdelphij	;;
5206267843Sdelphij      esac
5207267843Sdelphij    done
5208267843Sdelphij
5209267843Sdelphij    # See if our shared archives depend on static archives.
5210267843Sdelphij    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
5211267843Sdelphij
5212267843Sdelphij    # Go through the arguments, transforming them on the way.
5213267843Sdelphij    while test "$#" -gt 0; do
5214267843Sdelphij      arg="$1"
5215267843Sdelphij      shift
5216267843Sdelphij      func_quote_for_eval "$arg"
5217267843Sdelphij      qarg=$func_quote_for_eval_unquoted_result
5218267843Sdelphij      func_append libtool_args " $func_quote_for_eval_result"
5219267843Sdelphij
5220267843Sdelphij      # If the previous option needs an argument, assign it.
5221267843Sdelphij      if test -n "$prev"; then
5222267843Sdelphij	case $prev in
5223267843Sdelphij	output)
5224267843Sdelphij	  func_append compile_command " @OUTPUT@"
5225267843Sdelphij	  func_append finalize_command " @OUTPUT@"
5226267843Sdelphij	  ;;
5227267843Sdelphij	esac
5228267843Sdelphij
5229267843Sdelphij	case $prev in
5230267843Sdelphij	bindir)
5231267843Sdelphij	  bindir="$arg"
5232267843Sdelphij	  prev=
5233267843Sdelphij	  continue
5234267843Sdelphij	  ;;
5235267843Sdelphij	dlfiles|dlprefiles)
5236267843Sdelphij	  if test "$preload" = no; then
5237267843Sdelphij	    # Add the symbol object into the linking commands.
5238267843Sdelphij	    func_append compile_command " @SYMFILE@"
5239267843Sdelphij	    func_append finalize_command " @SYMFILE@"
5240267843Sdelphij	    preload=yes
5241267843Sdelphij	  fi
5242267843Sdelphij	  case $arg in
5243267843Sdelphij	  *.la | *.lo) ;;  # We handle these cases below.
5244267843Sdelphij	  force)
5245267843Sdelphij	    if test "$dlself" = no; then
5246267843Sdelphij	      dlself=needless
5247267843Sdelphij	      export_dynamic=yes
5248267843Sdelphij	    fi
5249267843Sdelphij	    prev=
5250267843Sdelphij	    continue
5251267843Sdelphij	    ;;
5252267843Sdelphij	  self)
5253267843Sdelphij	    if test "$prev" = dlprefiles; then
5254267843Sdelphij	      dlself=yes
5255267843Sdelphij	    elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
5256267843Sdelphij	      dlself=yes
5257267843Sdelphij	    else
5258267843Sdelphij	      dlself=needless
5259267843Sdelphij	      export_dynamic=yes
5260267843Sdelphij	    fi
5261267843Sdelphij	    prev=
5262267843Sdelphij	    continue
5263267843Sdelphij	    ;;
5264267843Sdelphij	  *)
5265267843Sdelphij	    if test "$prev" = dlfiles; then
5266267843Sdelphij	      func_append dlfiles " $arg"
5267267843Sdelphij	    else
5268267843Sdelphij	      func_append dlprefiles " $arg"
5269267843Sdelphij	    fi
5270267843Sdelphij	    prev=
5271267843Sdelphij	    continue
5272267843Sdelphij	    ;;
5273267843Sdelphij	  esac
5274267843Sdelphij	  ;;
5275267843Sdelphij	expsyms)
5276267843Sdelphij	  export_symbols="$arg"
5277267843Sdelphij	  test -f "$arg" \
5278267843Sdelphij	    || func_fatal_error "symbol file \`$arg' does not exist"
5279267843Sdelphij	  prev=
5280267843Sdelphij	  continue
5281267843Sdelphij	  ;;
5282267843Sdelphij	expsyms_regex)
5283267843Sdelphij	  export_symbols_regex="$arg"
5284267843Sdelphij	  prev=
5285267843Sdelphij	  continue
5286267843Sdelphij	  ;;
5287267843Sdelphij	framework)
5288267843Sdelphij	  case $host in
5289267843Sdelphij	    *-*-darwin*)
5290267843Sdelphij	      case "$deplibs " in
5291267843Sdelphij		*" $qarg.ltframework "*) ;;
5292267843Sdelphij		*) func_append deplibs " $qarg.ltframework" # this is fixed later
5293267843Sdelphij		   ;;
5294267843Sdelphij	      esac
5295267843Sdelphij	      ;;
5296267843Sdelphij	  esac
5297267843Sdelphij	  prev=
5298267843Sdelphij	  continue
5299267843Sdelphij	  ;;
5300267843Sdelphij	inst_prefix)
5301267843Sdelphij	  inst_prefix_dir="$arg"
5302267843Sdelphij	  prev=
5303267843Sdelphij	  continue
5304267843Sdelphij	  ;;
5305267843Sdelphij	objectlist)
5306267843Sdelphij	  if test -f "$arg"; then
5307267843Sdelphij	    save_arg=$arg
5308267843Sdelphij	    moreargs=
5309267843Sdelphij	    for fil in `cat "$save_arg"`
5310267843Sdelphij	    do
5311267843Sdelphij#	      func_append moreargs " $fil"
5312267843Sdelphij	      arg=$fil
5313267843Sdelphij	      # A libtool-controlled object.
5314267843Sdelphij
5315267843Sdelphij	      # Check to see that this really is a libtool object.
5316267843Sdelphij	      if func_lalib_unsafe_p "$arg"; then
5317267843Sdelphij		pic_object=
5318267843Sdelphij		non_pic_object=
5319267843Sdelphij
5320267843Sdelphij		# Read the .lo file
5321267843Sdelphij		func_source "$arg"
5322267843Sdelphij
5323267843Sdelphij		if test -z "$pic_object" ||
5324267843Sdelphij		   test -z "$non_pic_object" ||
5325267843Sdelphij		   test "$pic_object" = none &&
5326267843Sdelphij		   test "$non_pic_object" = none; then
5327267843Sdelphij		  func_fatal_error "cannot find name of object for \`$arg'"
5328267843Sdelphij		fi
5329267843Sdelphij
5330267843Sdelphij		# Extract subdirectory from the argument.
5331267843Sdelphij		func_dirname "$arg" "/" ""
5332267843Sdelphij		xdir="$func_dirname_result"
5333267843Sdelphij
5334267843Sdelphij		if test "$pic_object" != none; then
5335267843Sdelphij		  # Prepend the subdirectory the object is found in.
5336267843Sdelphij		  pic_object="$xdir$pic_object"
5337267843Sdelphij
5338267843Sdelphij		  if test "$prev" = dlfiles; then
5339267843Sdelphij		    if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
5340267843Sdelphij		      func_append dlfiles " $pic_object"
5341267843Sdelphij		      prev=
5342267843Sdelphij		      continue
5343267843Sdelphij		    else
5344267843Sdelphij		      # If libtool objects are unsupported, then we need to preload.
5345267843Sdelphij		      prev=dlprefiles
5346267843Sdelphij		    fi
5347267843Sdelphij		  fi
5348267843Sdelphij
5349267843Sdelphij		  # CHECK ME:  I think I busted this.  -Ossama
5350267843Sdelphij		  if test "$prev" = dlprefiles; then
5351267843Sdelphij		    # Preload the old-style object.
5352267843Sdelphij		    func_append dlprefiles " $pic_object"
5353267843Sdelphij		    prev=
5354267843Sdelphij		  fi
5355267843Sdelphij
5356267843Sdelphij		  # A PIC object.
5357267843Sdelphij		  func_append libobjs " $pic_object"
5358267843Sdelphij		  arg="$pic_object"
5359267843Sdelphij		fi
5360267843Sdelphij
5361267843Sdelphij		# Non-PIC object.
5362267843Sdelphij		if test "$non_pic_object" != none; then
5363267843Sdelphij		  # Prepend the subdirectory the object is found in.
5364267843Sdelphij		  non_pic_object="$xdir$non_pic_object"
5365267843Sdelphij
5366267843Sdelphij		  # A standard non-PIC object
5367267843Sdelphij		  func_append non_pic_objects " $non_pic_object"
5368267843Sdelphij		  if test -z "$pic_object" || test "$pic_object" = none ; then
5369267843Sdelphij		    arg="$non_pic_object"
5370267843Sdelphij		  fi
5371267843Sdelphij		else
5372267843Sdelphij		  # If the PIC object exists, use it instead.
5373267843Sdelphij		  # $xdir was prepended to $pic_object above.
5374267843Sdelphij		  non_pic_object="$pic_object"
5375267843Sdelphij		  func_append non_pic_objects " $non_pic_object"
5376267843Sdelphij		fi
5377267843Sdelphij	      else
5378267843Sdelphij		# Only an error if not doing a dry-run.
5379267843Sdelphij		if $opt_dry_run; then
5380267843Sdelphij		  # Extract subdirectory from the argument.
5381267843Sdelphij		  func_dirname "$arg" "/" ""
5382267843Sdelphij		  xdir="$func_dirname_result"
5383267843Sdelphij
5384267843Sdelphij		  func_lo2o "$arg"
5385267843Sdelphij		  pic_object=$xdir$objdir/$func_lo2o_result
5386267843Sdelphij		  non_pic_object=$xdir$func_lo2o_result
5387267843Sdelphij		  func_append libobjs " $pic_object"
5388267843Sdelphij		  func_append non_pic_objects " $non_pic_object"
5389267843Sdelphij	        else
5390267843Sdelphij		  func_fatal_error "\`$arg' is not a valid libtool object"
5391267843Sdelphij		fi
5392267843Sdelphij	      fi
5393267843Sdelphij	    done
5394267843Sdelphij	  else
5395267843Sdelphij	    func_fatal_error "link input file \`$arg' does not exist"
5396267843Sdelphij	  fi
5397267843Sdelphij	  arg=$save_arg
5398267843Sdelphij	  prev=
5399267843Sdelphij	  continue
5400267843Sdelphij	  ;;
5401267843Sdelphij	precious_regex)
5402267843Sdelphij	  precious_files_regex="$arg"
5403267843Sdelphij	  prev=
5404267843Sdelphij	  continue
5405267843Sdelphij	  ;;
5406267843Sdelphij	release)
5407267843Sdelphij	  release="-$arg"
5408267843Sdelphij	  prev=
5409267843Sdelphij	  continue
5410267843Sdelphij	  ;;
5411267843Sdelphij	rpath | xrpath)
5412267843Sdelphij	  # We need an absolute path.
5413267843Sdelphij	  case $arg in
5414267843Sdelphij	  [\\/]* | [A-Za-z]:[\\/]*) ;;
5415267843Sdelphij	  *)
5416267843Sdelphij	    func_fatal_error "only absolute run-paths are allowed"
5417267843Sdelphij	    ;;
5418267843Sdelphij	  esac
5419267843Sdelphij	  if test "$prev" = rpath; then
5420267843Sdelphij	    case "$rpath " in
5421267843Sdelphij	    *" $arg "*) ;;
5422267843Sdelphij	    *) func_append rpath " $arg" ;;
5423267843Sdelphij	    esac
5424267843Sdelphij	  else
5425267843Sdelphij	    case "$xrpath " in
5426267843Sdelphij	    *" $arg "*) ;;
5427267843Sdelphij	    *) func_append xrpath " $arg" ;;
5428267843Sdelphij	    esac
5429267843Sdelphij	  fi
5430267843Sdelphij	  prev=
5431267843Sdelphij	  continue
5432267843Sdelphij	  ;;
5433267843Sdelphij	shrext)
5434267843Sdelphij	  shrext_cmds="$arg"
5435267843Sdelphij	  prev=
5436267843Sdelphij	  continue
5437267843Sdelphij	  ;;
5438267843Sdelphij	weak)
5439267843Sdelphij	  func_append weak_libs " $arg"
5440267843Sdelphij	  prev=
5441267843Sdelphij	  continue
5442267843Sdelphij	  ;;
5443267843Sdelphij	xcclinker)
5444267843Sdelphij	  func_append linker_flags " $qarg"
5445267843Sdelphij	  func_append compiler_flags " $qarg"
5446267843Sdelphij	  prev=
5447267843Sdelphij	  func_append compile_command " $qarg"
5448267843Sdelphij	  func_append finalize_command " $qarg"
5449267843Sdelphij	  continue
5450267843Sdelphij	  ;;
5451267843Sdelphij	xcompiler)
5452267843Sdelphij	  func_append compiler_flags " $qarg"
5453267843Sdelphij	  prev=
5454267843Sdelphij	  func_append compile_command " $qarg"
5455267843Sdelphij	  func_append finalize_command " $qarg"
5456267843Sdelphij	  continue
5457267843Sdelphij	  ;;
5458267843Sdelphij	xlinker)
5459267843Sdelphij	  func_append linker_flags " $qarg"
5460267843Sdelphij	  func_append compiler_flags " $wl$qarg"
5461267843Sdelphij	  prev=
5462267843Sdelphij	  func_append compile_command " $wl$qarg"
5463267843Sdelphij	  func_append finalize_command " $wl$qarg"
5464267843Sdelphij	  continue
5465267843Sdelphij	  ;;
5466267843Sdelphij	*)
5467267843Sdelphij	  eval "$prev=\"\$arg\""
5468267843Sdelphij	  prev=
5469267843Sdelphij	  continue
5470267843Sdelphij	  ;;
5471267843Sdelphij	esac
5472267843Sdelphij      fi # test -n "$prev"
5473267843Sdelphij
5474267843Sdelphij      prevarg="$arg"
5475267843Sdelphij
5476267843Sdelphij      case $arg in
5477267843Sdelphij      -all-static)
5478267843Sdelphij	if test -n "$link_static_flag"; then
5479267843Sdelphij	  # See comment for -static flag below, for more details.
5480267843Sdelphij	  func_append compile_command " $link_static_flag"
5481267843Sdelphij	  func_append finalize_command " $link_static_flag"
5482267843Sdelphij	fi
5483267843Sdelphij	continue
5484267843Sdelphij	;;
5485267843Sdelphij
5486267843Sdelphij      -allow-undefined)
5487267843Sdelphij	# FIXME: remove this flag sometime in the future.
5488267843Sdelphij	func_fatal_error "\`-allow-undefined' must not be used because it is the default"
5489267843Sdelphij	;;
5490267843Sdelphij
5491267843Sdelphij      -avoid-version)
5492267843Sdelphij	avoid_version=yes
5493267843Sdelphij	continue
5494267843Sdelphij	;;
5495267843Sdelphij
5496267843Sdelphij      -bindir)
5497267843Sdelphij	prev=bindir
5498267843Sdelphij	continue
5499267843Sdelphij	;;
5500267843Sdelphij
5501267843Sdelphij      -dlopen)
5502267843Sdelphij	prev=dlfiles
5503267843Sdelphij	continue
5504267843Sdelphij	;;
5505267843Sdelphij
5506267843Sdelphij      -dlpreopen)
5507267843Sdelphij	prev=dlprefiles
5508267843Sdelphij	continue
5509267843Sdelphij	;;
5510267843Sdelphij
5511267843Sdelphij      -export-dynamic)
5512267843Sdelphij	export_dynamic=yes
5513267843Sdelphij	continue
5514267843Sdelphij	;;
5515267843Sdelphij
5516267843Sdelphij      -export-symbols | -export-symbols-regex)
5517267843Sdelphij	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
5518267843Sdelphij	  func_fatal_error "more than one -exported-symbols argument is not allowed"
5519267843Sdelphij	fi
5520267843Sdelphij	if test "X$arg" = "X-export-symbols"; then
5521267843Sdelphij	  prev=expsyms
5522267843Sdelphij	else
5523267843Sdelphij	  prev=expsyms_regex
5524267843Sdelphij	fi
5525267843Sdelphij	continue
5526267843Sdelphij	;;
5527267843Sdelphij
5528267843Sdelphij      -framework)
5529267843Sdelphij	prev=framework
5530267843Sdelphij	continue
5531267843Sdelphij	;;
5532267843Sdelphij
5533267843Sdelphij      -inst-prefix-dir)
5534267843Sdelphij	prev=inst_prefix
5535267843Sdelphij	continue
5536267843Sdelphij	;;
5537267843Sdelphij
5538267843Sdelphij      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
5539267843Sdelphij      # so, if we see these flags be careful not to treat them like -L
5540267843Sdelphij      -L[A-Z][A-Z]*:*)
5541267843Sdelphij	case $with_gcc/$host in
5542267843Sdelphij	no/*-*-irix* | /*-*-irix*)
5543267843Sdelphij	  func_append compile_command " $arg"
5544267843Sdelphij	  func_append finalize_command " $arg"
5545267843Sdelphij	  ;;
5546267843Sdelphij	esac
5547267843Sdelphij	continue
5548267843Sdelphij	;;
5549267843Sdelphij
5550267843Sdelphij      -L*)
5551267843Sdelphij	func_stripname "-L" '' "$arg"
5552267843Sdelphij	if test -z "$func_stripname_result"; then
5553267843Sdelphij	  if test "$#" -gt 0; then
5554267843Sdelphij	    func_fatal_error "require no space between \`-L' and \`$1'"
5555267843Sdelphij	  else
5556267843Sdelphij	    func_fatal_error "need path for \`-L' option"
5557267843Sdelphij	  fi
5558267843Sdelphij	fi
5559267843Sdelphij	func_resolve_sysroot "$func_stripname_result"
5560267843Sdelphij	dir=$func_resolve_sysroot_result
5561267843Sdelphij	# We need an absolute path.
5562267843Sdelphij	case $dir in
5563267843Sdelphij	[\\/]* | [A-Za-z]:[\\/]*) ;;
5564267843Sdelphij	*)
5565267843Sdelphij	  absdir=`cd "$dir" && pwd`
5566267843Sdelphij	  test -z "$absdir" && \
5567267843Sdelphij	    func_fatal_error "cannot determine absolute directory name of \`$dir'"
5568267843Sdelphij	  dir="$absdir"
5569267843Sdelphij	  ;;
5570267843Sdelphij	esac
5571267843Sdelphij	case "$deplibs " in
5572267843Sdelphij	*" -L$dir "* | *" $arg "*)
5573267843Sdelphij	  # Will only happen for absolute or sysroot arguments
5574267843Sdelphij	  ;;
5575267843Sdelphij	*)
5576267843Sdelphij	  # Preserve sysroot, but never include relative directories
5577267843Sdelphij	  case $dir in
5578267843Sdelphij	    [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;;
5579267843Sdelphij	    *) func_append deplibs " -L$dir" ;;
5580267843Sdelphij	  esac
5581267843Sdelphij	  func_append lib_search_path " $dir"
5582267843Sdelphij	  ;;
5583267843Sdelphij	esac
5584267843Sdelphij	case $host in
5585267843Sdelphij	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
5586267843Sdelphij	  testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
5587267843Sdelphij	  case :$dllsearchpath: in
5588267843Sdelphij	  *":$dir:"*) ;;
5589267843Sdelphij	  ::) dllsearchpath=$dir;;
5590267843Sdelphij	  *) func_append dllsearchpath ":$dir";;
5591267843Sdelphij	  esac
5592267843Sdelphij	  case :$dllsearchpath: in
5593267843Sdelphij	  *":$testbindir:"*) ;;
5594267843Sdelphij	  ::) dllsearchpath=$testbindir;;
5595267843Sdelphij	  *) func_append dllsearchpath ":$testbindir";;
5596267843Sdelphij	  esac
5597267843Sdelphij	  ;;
5598267843Sdelphij	esac
5599267843Sdelphij	continue
5600267843Sdelphij	;;
5601267843Sdelphij
5602267843Sdelphij      -l*)
5603267843Sdelphij	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
5604267843Sdelphij	  case $host in
5605267843Sdelphij	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
5606267843Sdelphij	    # These systems don't actually have a C or math library (as such)
5607267843Sdelphij	    continue
5608267843Sdelphij	    ;;
5609267843Sdelphij	  *-*-os2*)
5610267843Sdelphij	    # These systems don't actually have a C library (as such)
5611267843Sdelphij	    test "X$arg" = "X-lc" && continue
5612267843Sdelphij	    ;;
5613267843Sdelphij	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
5614267843Sdelphij	    # Do not include libc due to us having libc/libc_r.
5615267843Sdelphij	    test "X$arg" = "X-lc" && continue
5616267843Sdelphij	    ;;
5617267843Sdelphij	  *-*-rhapsody* | *-*-darwin1.[012])
5618267843Sdelphij	    # Rhapsody C and math libraries are in the System framework
5619267843Sdelphij	    func_append deplibs " System.ltframework"
5620267843Sdelphij	    continue
5621267843Sdelphij	    ;;
5622267843Sdelphij	  *-*-sco3.2v5* | *-*-sco5v6*)
5623267843Sdelphij	    # Causes problems with __ctype
5624267843Sdelphij	    test "X$arg" = "X-lc" && continue
5625267843Sdelphij	    ;;
5626267843Sdelphij	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
5627267843Sdelphij	    # Compiler inserts libc in the correct place for threads to work
5628267843Sdelphij	    test "X$arg" = "X-lc" && continue
5629267843Sdelphij	    ;;
5630267843Sdelphij	  esac
5631267843Sdelphij	elif test "X$arg" = "X-lc_r"; then
5632267843Sdelphij	 case $host in
5633267843Sdelphij	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
5634267843Sdelphij	   # Do not include libc_r directly, use -pthread flag.
5635267843Sdelphij	   continue
5636267843Sdelphij	   ;;
5637267843Sdelphij	 esac
5638267843Sdelphij	fi
5639267843Sdelphij	func_append deplibs " $arg"
5640267843Sdelphij	continue
5641267843Sdelphij	;;
5642267843Sdelphij
5643267843Sdelphij      -module)
5644267843Sdelphij	module=yes
5645267843Sdelphij	continue
5646267843Sdelphij	;;
5647267843Sdelphij
5648267843Sdelphij      # Tru64 UNIX uses -model [arg] to determine the layout of C++
5649267843Sdelphij      # classes, name mangling, and exception handling.
5650267843Sdelphij      # Darwin uses the -arch flag to determine output architecture.
5651267843Sdelphij      -model|-arch|-isysroot|--sysroot)
5652267843Sdelphij	func_append compiler_flags " $arg"
5653267843Sdelphij	func_append compile_command " $arg"
5654267843Sdelphij	func_append finalize_command " $arg"
5655267843Sdelphij	prev=xcompiler
5656267843Sdelphij	continue
5657267843Sdelphij	;;
5658267843Sdelphij
5659267843Sdelphij      -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
5660267843Sdelphij      |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
5661267843Sdelphij	func_append compiler_flags " $arg"
5662267843Sdelphij	func_append compile_command " $arg"
5663267843Sdelphij	func_append finalize_command " $arg"
5664267843Sdelphij	case "$new_inherited_linker_flags " in
5665267843Sdelphij	    *" $arg "*) ;;
5666267843Sdelphij	    * ) func_append new_inherited_linker_flags " $arg" ;;
5667267843Sdelphij	esac
5668267843Sdelphij	continue
5669267843Sdelphij	;;
5670267843Sdelphij
5671267843Sdelphij      -multi_module)
5672267843Sdelphij	single_module="${wl}-multi_module"
5673267843Sdelphij	continue
5674267843Sdelphij	;;
5675267843Sdelphij
5676267843Sdelphij      -no-fast-install)
5677267843Sdelphij	fast_install=no
5678267843Sdelphij	continue
5679267843Sdelphij	;;
5680267843Sdelphij
5681267843Sdelphij      -no-install)
5682267843Sdelphij	case $host in
5683267843Sdelphij	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
5684267843Sdelphij	  # The PATH hackery in wrapper scripts is required on Windows
5685267843Sdelphij	  # and Darwin in order for the loader to find any dlls it needs.
5686267843Sdelphij	  func_warning "\`-no-install' is ignored for $host"
5687267843Sdelphij	  func_warning "assuming \`-no-fast-install' instead"
5688267843Sdelphij	  fast_install=no
5689267843Sdelphij	  ;;
5690267843Sdelphij	*) no_install=yes ;;
5691267843Sdelphij	esac
5692267843Sdelphij	continue
5693267843Sdelphij	;;
5694267843Sdelphij
5695267843Sdelphij      -no-undefined)
5696267843Sdelphij	allow_undefined=no
5697267843Sdelphij	continue
5698267843Sdelphij	;;
5699267843Sdelphij
5700267843Sdelphij      -objectlist)
5701267843Sdelphij	prev=objectlist
5702267843Sdelphij	continue
5703267843Sdelphij	;;
5704267843Sdelphij
5705267843Sdelphij      -o) prev=output ;;
5706267843Sdelphij
5707267843Sdelphij      -precious-files-regex)
5708267843Sdelphij	prev=precious_regex
5709267843Sdelphij	continue
5710267843Sdelphij	;;
5711267843Sdelphij
5712267843Sdelphij      -release)
5713267843Sdelphij	prev=release
5714267843Sdelphij	continue
5715267843Sdelphij	;;
5716267843Sdelphij
5717267843Sdelphij      -rpath)
5718267843Sdelphij	prev=rpath
5719267843Sdelphij	continue
5720267843Sdelphij	;;
5721267843Sdelphij
5722267843Sdelphij      -R)
5723267843Sdelphij	prev=xrpath
5724267843Sdelphij	continue
5725267843Sdelphij	;;
5726267843Sdelphij
5727267843Sdelphij      -R*)
5728267843Sdelphij	func_stripname '-R' '' "$arg"
5729267843Sdelphij	dir=$func_stripname_result
5730267843Sdelphij	# We need an absolute path.
5731267843Sdelphij	case $dir in
5732267843Sdelphij	[\\/]* | [A-Za-z]:[\\/]*) ;;
5733267843Sdelphij	=*)
5734267843Sdelphij	  func_stripname '=' '' "$dir"
5735267843Sdelphij	  dir=$lt_sysroot$func_stripname_result
5736267843Sdelphij	  ;;
5737267843Sdelphij	*)
5738267843Sdelphij	  func_fatal_error "only absolute run-paths are allowed"
5739267843Sdelphij	  ;;
5740267843Sdelphij	esac
5741267843Sdelphij	case "$xrpath " in
5742267843Sdelphij	*" $dir "*) ;;
5743267843Sdelphij	*) func_append xrpath " $dir" ;;
5744267843Sdelphij	esac
5745267843Sdelphij	continue
5746267843Sdelphij	;;
5747267843Sdelphij
5748267843Sdelphij      -shared)
5749267843Sdelphij	# The effects of -shared are defined in a previous loop.
5750267843Sdelphij	continue
5751267843Sdelphij	;;
5752267843Sdelphij
5753267843Sdelphij      -shrext)
5754267843Sdelphij	prev=shrext
5755267843Sdelphij	continue
5756267843Sdelphij	;;
5757267843Sdelphij
5758267843Sdelphij      -static | -static-libtool-libs)
5759267843Sdelphij	# The effects of -static are defined in a previous loop.
5760267843Sdelphij	# We used to do the same as -all-static on platforms that
5761267843Sdelphij	# didn't have a PIC flag, but the assumption that the effects
5762267843Sdelphij	# would be equivalent was wrong.  It would break on at least
5763267843Sdelphij	# Digital Unix and AIX.
5764267843Sdelphij	continue
5765267843Sdelphij	;;
5766267843Sdelphij
5767267843Sdelphij      -thread-safe)
5768267843Sdelphij	thread_safe=yes
5769267843Sdelphij	continue
5770267843Sdelphij	;;
5771267843Sdelphij
5772267843Sdelphij      -version-info)
5773267843Sdelphij	prev=vinfo
5774267843Sdelphij	continue
5775267843Sdelphij	;;
5776267843Sdelphij
5777267843Sdelphij      -version-number)
5778267843Sdelphij	prev=vinfo
5779267843Sdelphij	vinfo_number=yes
5780267843Sdelphij	continue
5781267843Sdelphij	;;
5782267843Sdelphij
5783267843Sdelphij      -weak)
5784267843Sdelphij        prev=weak
5785267843Sdelphij	continue
5786267843Sdelphij	;;
5787267843Sdelphij
5788267843Sdelphij      -Wc,*)
5789267843Sdelphij	func_stripname '-Wc,' '' "$arg"
5790267843Sdelphij	args=$func_stripname_result
5791267843Sdelphij	arg=
5792267843Sdelphij	save_ifs="$IFS"; IFS=','
5793267843Sdelphij	for flag in $args; do
5794267843Sdelphij	  IFS="$save_ifs"
5795267843Sdelphij          func_quote_for_eval "$flag"
5796267843Sdelphij	  func_append arg " $func_quote_for_eval_result"
5797267843Sdelphij	  func_append compiler_flags " $func_quote_for_eval_result"
5798267843Sdelphij	done
5799267843Sdelphij	IFS="$save_ifs"
5800267843Sdelphij	func_stripname ' ' '' "$arg"
5801267843Sdelphij	arg=$func_stripname_result
5802267843Sdelphij	;;
5803267843Sdelphij
5804267843Sdelphij      -Wl,*)
5805267843Sdelphij	func_stripname '-Wl,' '' "$arg"
5806267843Sdelphij	args=$func_stripname_result
5807267843Sdelphij	arg=
5808267843Sdelphij	save_ifs="$IFS"; IFS=','
5809267843Sdelphij	for flag in $args; do
5810267843Sdelphij	  IFS="$save_ifs"
5811267843Sdelphij          func_quote_for_eval "$flag"
5812267843Sdelphij	  func_append arg " $wl$func_quote_for_eval_result"
5813267843Sdelphij	  func_append compiler_flags " $wl$func_quote_for_eval_result"
5814267843Sdelphij	  func_append linker_flags " $func_quote_for_eval_result"
5815267843Sdelphij	done
5816267843Sdelphij	IFS="$save_ifs"
5817267843Sdelphij	func_stripname ' ' '' "$arg"
5818267843Sdelphij	arg=$func_stripname_result
5819267843Sdelphij	;;
5820267843Sdelphij
5821267843Sdelphij      -Xcompiler)
5822267843Sdelphij	prev=xcompiler
5823267843Sdelphij	continue
5824267843Sdelphij	;;
5825267843Sdelphij
5826267843Sdelphij      -Xlinker)
5827267843Sdelphij	prev=xlinker
5828267843Sdelphij	continue
5829267843Sdelphij	;;
5830267843Sdelphij
5831267843Sdelphij      -XCClinker)
5832267843Sdelphij	prev=xcclinker
5833267843Sdelphij	continue
5834267843Sdelphij	;;
5835267843Sdelphij
5836267843Sdelphij      # -msg_* for osf cc
5837267843Sdelphij      -msg_*)
5838267843Sdelphij	func_quote_for_eval "$arg"
5839267843Sdelphij	arg="$func_quote_for_eval_result"
5840267843Sdelphij	;;
5841267843Sdelphij
5842267843Sdelphij      # Flags to be passed through unchanged, with rationale:
5843267843Sdelphij      # -64, -mips[0-9]      enable 64-bit mode for the SGI compiler
5844267843Sdelphij      # -r[0-9][0-9]*        specify processor for the SGI compiler
5845267843Sdelphij      # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler
5846267843Sdelphij      # +DA*, +DD*           enable 64-bit mode for the HP compiler
5847267843Sdelphij      # -q*                  compiler args for the IBM compiler
5848267843Sdelphij      # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
5849267843Sdelphij      # -F/path              path to uninstalled frameworks, gcc on darwin
5850267843Sdelphij      # -p, -pg, --coverage, -fprofile-*  profiling flags for GCC
5851267843Sdelphij      # @file                GCC response files
5852267843Sdelphij      # -tp=*                Portland pgcc target processor selection
5853267843Sdelphij      # --sysroot=*          for sysroot support
5854267843Sdelphij      # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
5855267843Sdelphij      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
5856267843Sdelphij      -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
5857267843Sdelphij      -O*|-flto*|-fwhopr*|-fuse-linker-plugin)
5858267843Sdelphij        func_quote_for_eval "$arg"
5859267843Sdelphij	arg="$func_quote_for_eval_result"
5860267843Sdelphij        func_append compile_command " $arg"
5861267843Sdelphij        func_append finalize_command " $arg"
5862267843Sdelphij        func_append compiler_flags " $arg"
5863267843Sdelphij        continue
5864267843Sdelphij        ;;
5865267843Sdelphij
5866267843Sdelphij      # Some other compiler flag.
5867267843Sdelphij      -* | +*)
5868267843Sdelphij        func_quote_for_eval "$arg"
5869267843Sdelphij	arg="$func_quote_for_eval_result"
5870267843Sdelphij	;;
5871267843Sdelphij
5872267843Sdelphij      *.$objext)
5873267843Sdelphij	# A standard object.
5874267843Sdelphij	func_append objs " $arg"
5875267843Sdelphij	;;
5876267843Sdelphij
5877267843Sdelphij      *.lo)
5878267843Sdelphij	# A libtool-controlled object.
5879267843Sdelphij
5880267843Sdelphij	# Check to see that this really is a libtool object.
5881267843Sdelphij	if func_lalib_unsafe_p "$arg"; then
5882267843Sdelphij	  pic_object=
5883267843Sdelphij	  non_pic_object=
5884267843Sdelphij
5885267843Sdelphij	  # Read the .lo file
5886267843Sdelphij	  func_source "$arg"
5887267843Sdelphij
5888267843Sdelphij	  if test -z "$pic_object" ||
5889267843Sdelphij	     test -z "$non_pic_object" ||
5890267843Sdelphij	     test "$pic_object" = none &&
5891267843Sdelphij	     test "$non_pic_object" = none; then
5892267843Sdelphij	    func_fatal_error "cannot find name of object for \`$arg'"
5893267843Sdelphij	  fi
5894267843Sdelphij
5895267843Sdelphij	  # Extract subdirectory from the argument.
5896267843Sdelphij	  func_dirname "$arg" "/" ""
5897267843Sdelphij	  xdir="$func_dirname_result"
5898267843Sdelphij
5899267843Sdelphij	  if test "$pic_object" != none; then
5900267843Sdelphij	    # Prepend the subdirectory the object is found in.
5901267843Sdelphij	    pic_object="$xdir$pic_object"
5902267843Sdelphij
5903267843Sdelphij	    if test "$prev" = dlfiles; then
5904267843Sdelphij	      if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
5905267843Sdelphij		func_append dlfiles " $pic_object"
5906267843Sdelphij		prev=
5907267843Sdelphij		continue
5908267843Sdelphij	      else
5909267843Sdelphij		# If libtool objects are unsupported, then we need to preload.
5910267843Sdelphij		prev=dlprefiles
5911267843Sdelphij	      fi
5912267843Sdelphij	    fi
5913267843Sdelphij
5914267843Sdelphij	    # CHECK ME:  I think I busted this.  -Ossama
5915267843Sdelphij	    if test "$prev" = dlprefiles; then
5916267843Sdelphij	      # Preload the old-style object.
5917267843Sdelphij	      func_append dlprefiles " $pic_object"
5918267843Sdelphij	      prev=
5919267843Sdelphij	    fi
5920267843Sdelphij
5921267843Sdelphij	    # A PIC object.
5922267843Sdelphij	    func_append libobjs " $pic_object"
5923267843Sdelphij	    arg="$pic_object"
5924267843Sdelphij	  fi
5925267843Sdelphij
5926267843Sdelphij	  # Non-PIC object.
5927267843Sdelphij	  if test "$non_pic_object" != none; then
5928267843Sdelphij	    # Prepend the subdirectory the object is found in.
5929267843Sdelphij	    non_pic_object="$xdir$non_pic_object"
5930267843Sdelphij
5931267843Sdelphij	    # A standard non-PIC object
5932267843Sdelphij	    func_append non_pic_objects " $non_pic_object"
5933267843Sdelphij	    if test -z "$pic_object" || test "$pic_object" = none ; then
5934267843Sdelphij	      arg="$non_pic_object"
5935267843Sdelphij	    fi
5936267843Sdelphij	  else
5937267843Sdelphij	    # If the PIC object exists, use it instead.
5938267843Sdelphij	    # $xdir was prepended to $pic_object above.
5939267843Sdelphij	    non_pic_object="$pic_object"
5940267843Sdelphij	    func_append non_pic_objects " $non_pic_object"
5941267843Sdelphij	  fi
5942267843Sdelphij	else
5943267843Sdelphij	  # Only an error if not doing a dry-run.
5944267843Sdelphij	  if $opt_dry_run; then
5945267843Sdelphij	    # Extract subdirectory from the argument.
5946267843Sdelphij	    func_dirname "$arg" "/" ""
5947267843Sdelphij	    xdir="$func_dirname_result"
5948267843Sdelphij
5949267843Sdelphij	    func_lo2o "$arg"
5950267843Sdelphij	    pic_object=$xdir$objdir/$func_lo2o_result
5951267843Sdelphij	    non_pic_object=$xdir$func_lo2o_result
5952267843Sdelphij	    func_append libobjs " $pic_object"
5953267843Sdelphij	    func_append non_pic_objects " $non_pic_object"
5954267843Sdelphij	  else
5955267843Sdelphij	    func_fatal_error "\`$arg' is not a valid libtool object"
5956267843Sdelphij	  fi
5957267843Sdelphij	fi
5958267843Sdelphij	;;
5959267843Sdelphij
5960267843Sdelphij      *.$libext)
5961267843Sdelphij	# An archive.
5962267843Sdelphij	func_append deplibs " $arg"
5963267843Sdelphij	func_append old_deplibs " $arg"
5964267843Sdelphij	continue
5965267843Sdelphij	;;
5966267843Sdelphij
5967267843Sdelphij      *.la)
5968267843Sdelphij	# A libtool-controlled library.
5969267843Sdelphij
5970267843Sdelphij	func_resolve_sysroot "$arg"
5971267843Sdelphij	if test "$prev" = dlfiles; then
5972267843Sdelphij	  # This library was specified with -dlopen.
5973267843Sdelphij	  func_append dlfiles " $func_resolve_sysroot_result"
5974267843Sdelphij	  prev=
5975267843Sdelphij	elif test "$prev" = dlprefiles; then
5976267843Sdelphij	  # The library was specified with -dlpreopen.
5977267843Sdelphij	  func_append dlprefiles " $func_resolve_sysroot_result"
5978267843Sdelphij	  prev=
5979267843Sdelphij	else
5980267843Sdelphij	  func_append deplibs " $func_resolve_sysroot_result"
5981267843Sdelphij	fi
5982267843Sdelphij	continue
5983267843Sdelphij	;;
5984267843Sdelphij
5985267843Sdelphij      # Some other compiler argument.
5986267843Sdelphij      *)
5987267843Sdelphij	# Unknown arguments in both finalize_command and compile_command need
5988267843Sdelphij	# to be aesthetically quoted because they are evaled later.
5989267843Sdelphij	func_quote_for_eval "$arg"
5990267843Sdelphij	arg="$func_quote_for_eval_result"
5991267843Sdelphij	;;
5992267843Sdelphij      esac # arg
5993267843Sdelphij
5994267843Sdelphij      # Now actually substitute the argument into the commands.
5995267843Sdelphij      if test -n "$arg"; then
5996267843Sdelphij	func_append compile_command " $arg"
5997267843Sdelphij	func_append finalize_command " $arg"
5998267843Sdelphij      fi
5999267843Sdelphij    done # argument parsing loop
6000267843Sdelphij
6001267843Sdelphij    test -n "$prev" && \
6002267843Sdelphij      func_fatal_help "the \`$prevarg' option requires an argument"
6003267843Sdelphij
6004267843Sdelphij    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
6005267843Sdelphij      eval arg=\"$export_dynamic_flag_spec\"
6006267843Sdelphij      func_append compile_command " $arg"
6007267843Sdelphij      func_append finalize_command " $arg"
6008267843Sdelphij    fi
6009267843Sdelphij
6010267843Sdelphij    oldlibs=
6011267843Sdelphij    # calculate the name of the file, without its directory
6012267843Sdelphij    func_basename "$output"
6013267843Sdelphij    outputname="$func_basename_result"
6014267843Sdelphij    libobjs_save="$libobjs"
6015267843Sdelphij
6016267843Sdelphij    if test -n "$shlibpath_var"; then
6017267843Sdelphij      # get the directories listed in $shlibpath_var
6018267843Sdelphij      eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\`
6019267843Sdelphij    else
6020267843Sdelphij      shlib_search_path=
6021267843Sdelphij    fi
6022267843Sdelphij    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
6023267843Sdelphij    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
6024267843Sdelphij
6025267843Sdelphij    func_dirname "$output" "/" ""
6026267843Sdelphij    output_objdir="$func_dirname_result$objdir"
6027267843Sdelphij    func_to_tool_file "$output_objdir/"
6028267843Sdelphij    tool_output_objdir=$func_to_tool_file_result
6029267843Sdelphij    # Create the object directory.
6030267843Sdelphij    func_mkdir_p "$output_objdir"
6031267843Sdelphij
6032267843Sdelphij    # Determine the type of output
6033267843Sdelphij    case $output in
6034267843Sdelphij    "")
6035267843Sdelphij      func_fatal_help "you must specify an output file"
6036267843Sdelphij      ;;
6037267843Sdelphij    *.$libext) linkmode=oldlib ;;
6038267843Sdelphij    *.lo | *.$objext) linkmode=obj ;;
6039267843Sdelphij    *.la) linkmode=lib ;;
6040267843Sdelphij    *) linkmode=prog ;; # Anything else should be a program.
6041267843Sdelphij    esac
6042267843Sdelphij
6043267843Sdelphij    specialdeplibs=
6044267843Sdelphij
6045267843Sdelphij    libs=
6046267843Sdelphij    # Find all interdependent deplibs by searching for libraries
6047267843Sdelphij    # that are linked more than once (e.g. -la -lb -la)
6048267843Sdelphij    for deplib in $deplibs; do
6049267843Sdelphij      if $opt_preserve_dup_deps ; then
6050267843Sdelphij	case "$libs " in
6051267843Sdelphij	*" $deplib "*) func_append specialdeplibs " $deplib" ;;
6052267843Sdelphij	esac
6053267843Sdelphij      fi
6054267843Sdelphij      func_append libs " $deplib"
6055267843Sdelphij    done
6056267843Sdelphij
6057267843Sdelphij    if test "$linkmode" = lib; then
6058267843Sdelphij      libs="$predeps $libs $compiler_lib_search_path $postdeps"
6059267843Sdelphij
6060267843Sdelphij      # Compute libraries that are listed more than once in $predeps
6061267843Sdelphij      # $postdeps and mark them as special (i.e., whose duplicates are
6062267843Sdelphij      # not to be eliminated).
6063267843Sdelphij      pre_post_deps=
6064267843Sdelphij      if $opt_duplicate_compiler_generated_deps; then
6065267843Sdelphij	for pre_post_dep in $predeps $postdeps; do
6066267843Sdelphij	  case "$pre_post_deps " in
6067267843Sdelphij	  *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;;
6068267843Sdelphij	  esac
6069267843Sdelphij	  func_append pre_post_deps " $pre_post_dep"
6070267843Sdelphij	done
6071267843Sdelphij      fi
6072267843Sdelphij      pre_post_deps=
6073267843Sdelphij    fi
6074267843Sdelphij
6075267843Sdelphij    deplibs=
6076267843Sdelphij    newdependency_libs=
6077267843Sdelphij    newlib_search_path=
6078267843Sdelphij    need_relink=no # whether we're linking any uninstalled libtool libraries
6079267843Sdelphij    notinst_deplibs= # not-installed libtool libraries
6080267843Sdelphij    notinst_path= # paths that contain not-installed libtool libraries
6081267843Sdelphij
6082267843Sdelphij    case $linkmode in
6083267843Sdelphij    lib)
6084267843Sdelphij	passes="conv dlpreopen link"
6085267843Sdelphij	for file in $dlfiles $dlprefiles; do
6086267843Sdelphij	  case $file in
6087267843Sdelphij	  *.la) ;;
6088267843Sdelphij	  *)
6089267843Sdelphij	    func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file"
6090267843Sdelphij	    ;;
6091267843Sdelphij	  esac
6092267843Sdelphij	done
6093267843Sdelphij	;;
6094267843Sdelphij    prog)
6095267843Sdelphij	compile_deplibs=
6096267843Sdelphij	finalize_deplibs=
6097267843Sdelphij	alldeplibs=no
6098267843Sdelphij	newdlfiles=
6099267843Sdelphij	newdlprefiles=
6100267843Sdelphij	passes="conv scan dlopen dlpreopen link"
6101267843Sdelphij	;;
6102267843Sdelphij    *)  passes="conv"
6103267843Sdelphij	;;
6104267843Sdelphij    esac
6105267843Sdelphij
6106267843Sdelphij    for pass in $passes; do
6107267843Sdelphij      # The preopen pass in lib mode reverses $deplibs; put it back here
6108267843Sdelphij      # so that -L comes before libs that need it for instance...
6109267843Sdelphij      if test "$linkmode,$pass" = "lib,link"; then
6110267843Sdelphij	## FIXME: Find the place where the list is rebuilt in the wrong
6111267843Sdelphij	##        order, and fix it there properly
6112267843Sdelphij        tmp_deplibs=
6113267843Sdelphij	for deplib in $deplibs; do
6114267843Sdelphij	  tmp_deplibs="$deplib $tmp_deplibs"
6115267843Sdelphij	done
6116267843Sdelphij	deplibs="$tmp_deplibs"
6117267843Sdelphij      fi
6118267843Sdelphij
6119267843Sdelphij      if test "$linkmode,$pass" = "lib,link" ||
6120267843Sdelphij	 test "$linkmode,$pass" = "prog,scan"; then
6121267843Sdelphij	libs="$deplibs"
6122267843Sdelphij	deplibs=
6123267843Sdelphij      fi
6124267843Sdelphij      if test "$linkmode" = prog; then
6125267843Sdelphij	case $pass in
6126267843Sdelphij	dlopen) libs="$dlfiles" ;;
6127267843Sdelphij	dlpreopen) libs="$dlprefiles" ;;
6128267843Sdelphij	link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
6129267843Sdelphij	esac
6130267843Sdelphij      fi
6131267843Sdelphij      if test "$linkmode,$pass" = "lib,dlpreopen"; then
6132267843Sdelphij	# Collect and forward deplibs of preopened libtool libs
6133267843Sdelphij	for lib in $dlprefiles; do
6134267843Sdelphij	  # Ignore non-libtool-libs
6135267843Sdelphij	  dependency_libs=
6136267843Sdelphij	  func_resolve_sysroot "$lib"
6137267843Sdelphij	  case $lib in
6138267843Sdelphij	  *.la)	func_source "$func_resolve_sysroot_result" ;;
6139267843Sdelphij	  esac
6140267843Sdelphij
6141267843Sdelphij	  # Collect preopened libtool deplibs, except any this library
6142267843Sdelphij	  # has declared as weak libs
6143267843Sdelphij	  for deplib in $dependency_libs; do
6144267843Sdelphij	    func_basename "$deplib"
6145267843Sdelphij            deplib_base=$func_basename_result
6146267843Sdelphij	    case " $weak_libs " in
6147267843Sdelphij	    *" $deplib_base "*) ;;
6148267843Sdelphij	    *) func_append deplibs " $deplib" ;;
6149267843Sdelphij	    esac
6150267843Sdelphij	  done
6151267843Sdelphij	done
6152267843Sdelphij	libs="$dlprefiles"
6153267843Sdelphij      fi
6154267843Sdelphij      if test "$pass" = dlopen; then
6155267843Sdelphij	# Collect dlpreopened libraries
6156267843Sdelphij	save_deplibs="$deplibs"
6157267843Sdelphij	deplibs=
6158267843Sdelphij      fi
6159267843Sdelphij
6160267843Sdelphij      for deplib in $libs; do
6161267843Sdelphij	lib=
6162267843Sdelphij	found=no
6163267843Sdelphij	case $deplib in
6164267843Sdelphij	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
6165267843Sdelphij        |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
6166267843Sdelphij	  if test "$linkmode,$pass" = "prog,link"; then
6167267843Sdelphij	    compile_deplibs="$deplib $compile_deplibs"
6168267843Sdelphij	    finalize_deplibs="$deplib $finalize_deplibs"
6169267843Sdelphij	  else
6170267843Sdelphij	    func_append compiler_flags " $deplib"
6171267843Sdelphij	    if test "$linkmode" = lib ; then
6172267843Sdelphij		case "$new_inherited_linker_flags " in
6173267843Sdelphij		    *" $deplib "*) ;;
6174267843Sdelphij		    * ) func_append new_inherited_linker_flags " $deplib" ;;
6175267843Sdelphij		esac
6176267843Sdelphij	    fi
6177267843Sdelphij	  fi
6178267843Sdelphij	  continue
6179267843Sdelphij	  ;;
6180267843Sdelphij	-l*)
6181267843Sdelphij	  if test "$linkmode" != lib && test "$linkmode" != prog; then
6182267843Sdelphij	    func_warning "\`-l' is ignored for archives/objects"
6183267843Sdelphij	    continue
6184267843Sdelphij	  fi
6185267843Sdelphij	  func_stripname '-l' '' "$deplib"
6186267843Sdelphij	  name=$func_stripname_result
6187267843Sdelphij	  if test "$linkmode" = lib; then
6188267843Sdelphij	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
6189267843Sdelphij	  else
6190267843Sdelphij	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
6191267843Sdelphij	  fi
6192267843Sdelphij	  for searchdir in $searchdirs; do
6193267843Sdelphij	    for search_ext in .la $std_shrext .so .a; do
6194267843Sdelphij	      # Search the libtool library
6195267843Sdelphij	      lib="$searchdir/lib${name}${search_ext}"
6196267843Sdelphij	      if test -f "$lib"; then
6197267843Sdelphij		if test "$search_ext" = ".la"; then
6198267843Sdelphij		  found=yes
6199267843Sdelphij		else
6200267843Sdelphij		  found=no
6201267843Sdelphij		fi
6202267843Sdelphij		break 2
6203267843Sdelphij	      fi
6204267843Sdelphij	    done
6205267843Sdelphij	  done
6206267843Sdelphij	  if test "$found" != yes; then
6207267843Sdelphij	    # deplib doesn't seem to be a libtool library
6208267843Sdelphij	    if test "$linkmode,$pass" = "prog,link"; then
6209267843Sdelphij	      compile_deplibs="$deplib $compile_deplibs"
6210267843Sdelphij	      finalize_deplibs="$deplib $finalize_deplibs"
6211267843Sdelphij	    else
6212267843Sdelphij	      deplibs="$deplib $deplibs"
6213267843Sdelphij	      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
6214267843Sdelphij	    fi
6215267843Sdelphij	    continue
6216267843Sdelphij	  else # deplib is a libtool library
6217267843Sdelphij	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
6218267843Sdelphij	    # We need to do some special things here, and not later.
6219267843Sdelphij	    if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6220267843Sdelphij	      case " $predeps $postdeps " in
6221267843Sdelphij	      *" $deplib "*)
6222267843Sdelphij		if func_lalib_p "$lib"; then
6223267843Sdelphij		  library_names=
6224267843Sdelphij		  old_library=
6225267843Sdelphij		  func_source "$lib"
6226267843Sdelphij		  for l in $old_library $library_names; do
6227267843Sdelphij		    ll="$l"
6228267843Sdelphij		  done
6229267843Sdelphij		  if test "X$ll" = "X$old_library" ; then # only static version available
6230267843Sdelphij		    found=no
6231267843Sdelphij		    func_dirname "$lib" "" "."
6232267843Sdelphij		    ladir="$func_dirname_result"
6233267843Sdelphij		    lib=$ladir/$old_library
6234267843Sdelphij		    if test "$linkmode,$pass" = "prog,link"; then
6235267843Sdelphij		      compile_deplibs="$deplib $compile_deplibs"
6236267843Sdelphij		      finalize_deplibs="$deplib $finalize_deplibs"
6237267843Sdelphij		    else
6238267843Sdelphij		      deplibs="$deplib $deplibs"
6239267843Sdelphij		      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
6240267843Sdelphij		    fi
6241267843Sdelphij		    continue
6242267843Sdelphij		  fi
6243267843Sdelphij		fi
6244267843Sdelphij		;;
6245267843Sdelphij	      *) ;;
6246267843Sdelphij	      esac
6247267843Sdelphij	    fi
6248267843Sdelphij	  fi
6249267843Sdelphij	  ;; # -l
6250267843Sdelphij	*.ltframework)
6251267843Sdelphij	  if test "$linkmode,$pass" = "prog,link"; then
6252267843Sdelphij	    compile_deplibs="$deplib $compile_deplibs"
6253267843Sdelphij	    finalize_deplibs="$deplib $finalize_deplibs"
6254267843Sdelphij	  else
6255267843Sdelphij	    deplibs="$deplib $deplibs"
6256267843Sdelphij	    if test "$linkmode" = lib ; then
6257267843Sdelphij		case "$new_inherited_linker_flags " in
6258267843Sdelphij		    *" $deplib "*) ;;
6259267843Sdelphij		    * ) func_append new_inherited_linker_flags " $deplib" ;;
6260267843Sdelphij		esac
6261267843Sdelphij	    fi
6262267843Sdelphij	  fi
6263267843Sdelphij	  continue
6264267843Sdelphij	  ;;
6265267843Sdelphij	-L*)
6266267843Sdelphij	  case $linkmode in
6267267843Sdelphij	  lib)
6268267843Sdelphij	    deplibs="$deplib $deplibs"
6269267843Sdelphij	    test "$pass" = conv && continue
6270267843Sdelphij	    newdependency_libs="$deplib $newdependency_libs"
6271267843Sdelphij	    func_stripname '-L' '' "$deplib"
6272267843Sdelphij	    func_resolve_sysroot "$func_stripname_result"
6273267843Sdelphij	    func_append newlib_search_path " $func_resolve_sysroot_result"
6274267843Sdelphij	    ;;
6275267843Sdelphij	  prog)
6276267843Sdelphij	    if test "$pass" = conv; then
6277267843Sdelphij	      deplibs="$deplib $deplibs"
6278267843Sdelphij	      continue
6279267843Sdelphij	    fi
6280267843Sdelphij	    if test "$pass" = scan; then
6281267843Sdelphij	      deplibs="$deplib $deplibs"
6282267843Sdelphij	    else
6283267843Sdelphij	      compile_deplibs="$deplib $compile_deplibs"
6284267843Sdelphij	      finalize_deplibs="$deplib $finalize_deplibs"
6285267843Sdelphij	    fi
6286267843Sdelphij	    func_stripname '-L' '' "$deplib"
6287267843Sdelphij	    func_resolve_sysroot "$func_stripname_result"
6288267843Sdelphij	    func_append newlib_search_path " $func_resolve_sysroot_result"
6289267843Sdelphij	    ;;
6290267843Sdelphij	  *)
6291267843Sdelphij	    func_warning "\`-L' is ignored for archives/objects"
6292267843Sdelphij	    ;;
6293267843Sdelphij	  esac # linkmode
6294267843Sdelphij	  continue
6295267843Sdelphij	  ;; # -L
6296267843Sdelphij	-R*)
6297267843Sdelphij	  if test "$pass" = link; then
6298267843Sdelphij	    func_stripname '-R' '' "$deplib"
6299267843Sdelphij	    func_resolve_sysroot "$func_stripname_result"
6300267843Sdelphij	    dir=$func_resolve_sysroot_result
6301267843Sdelphij	    # Make sure the xrpath contains only unique directories.
6302267843Sdelphij	    case "$xrpath " in
6303267843Sdelphij	    *" $dir "*) ;;
6304267843Sdelphij	    *) func_append xrpath " $dir" ;;
6305267843Sdelphij	    esac
6306267843Sdelphij	  fi
6307267843Sdelphij	  deplibs="$deplib $deplibs"
6308267843Sdelphij	  continue
6309267843Sdelphij	  ;;
6310267843Sdelphij	*.la)
6311267843Sdelphij	  func_resolve_sysroot "$deplib"
6312267843Sdelphij	  lib=$func_resolve_sysroot_result
6313267843Sdelphij	  ;;
6314267843Sdelphij	*.$libext)
6315267843Sdelphij	  if test "$pass" = conv; then
6316267843Sdelphij	    deplibs="$deplib $deplibs"
6317267843Sdelphij	    continue
6318267843Sdelphij	  fi
6319267843Sdelphij	  case $linkmode in
6320267843Sdelphij	  lib)
6321267843Sdelphij	    # Linking convenience modules into shared libraries is allowed,
6322267843Sdelphij	    # but linking other static libraries is non-portable.
6323267843Sdelphij	    case " $dlpreconveniencelibs " in
6324267843Sdelphij	    *" $deplib "*) ;;
6325267843Sdelphij	    *)
6326267843Sdelphij	      valid_a_lib=no
6327267843Sdelphij	      case $deplibs_check_method in
6328267843Sdelphij		match_pattern*)
6329267843Sdelphij		  set dummy $deplibs_check_method; shift
6330267843Sdelphij		  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
6331267843Sdelphij		  if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
6332267843Sdelphij		    | $EGREP "$match_pattern_regex" > /dev/null; then
6333267843Sdelphij		    valid_a_lib=yes
6334267843Sdelphij		  fi
6335267843Sdelphij		;;
6336267843Sdelphij		pass_all)
6337267843Sdelphij		  valid_a_lib=yes
6338267843Sdelphij		;;
6339267843Sdelphij	      esac
6340267843Sdelphij	      if test "$valid_a_lib" != yes; then
6341267843Sdelphij		echo
6342267843Sdelphij		$ECHO "*** Warning: Trying to link with static lib archive $deplib."
6343267843Sdelphij		echo "*** I have the capability to make that library automatically link in when"
6344267843Sdelphij		echo "*** you link to this library.  But I can only do this if you have a"
6345267843Sdelphij		echo "*** shared version of the library, which you do not appear to have"
6346267843Sdelphij		echo "*** because the file extensions .$libext of this argument makes me believe"
6347267843Sdelphij		echo "*** that it is just a static archive that I should not use here."
6348267843Sdelphij	      else
6349267843Sdelphij		echo
6350267843Sdelphij		$ECHO "*** Warning: Linking the shared library $output against the"
6351267843Sdelphij		$ECHO "*** static library $deplib is not portable!"
6352267843Sdelphij		deplibs="$deplib $deplibs"
6353267843Sdelphij	      fi
6354267843Sdelphij	      ;;
6355267843Sdelphij	    esac
6356267843Sdelphij	    continue
6357267843Sdelphij	    ;;
6358267843Sdelphij	  prog)
6359267843Sdelphij	    if test "$pass" != link; then
6360267843Sdelphij	      deplibs="$deplib $deplibs"
6361267843Sdelphij	    else
6362267843Sdelphij	      compile_deplibs="$deplib $compile_deplibs"
6363267843Sdelphij	      finalize_deplibs="$deplib $finalize_deplibs"
6364267843Sdelphij	    fi
6365267843Sdelphij	    continue
6366267843Sdelphij	    ;;
6367267843Sdelphij	  esac # linkmode
6368267843Sdelphij	  ;; # *.$libext
6369267843Sdelphij	*.lo | *.$objext)
6370267843Sdelphij	  if test "$pass" = conv; then
6371267843Sdelphij	    deplibs="$deplib $deplibs"
6372267843Sdelphij	  elif test "$linkmode" = prog; then
6373267843Sdelphij	    if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
6374267843Sdelphij	      # If there is no dlopen support or we're linking statically,
6375267843Sdelphij	      # we need to preload.
6376267843Sdelphij	      func_append newdlprefiles " $deplib"
6377267843Sdelphij	      compile_deplibs="$deplib $compile_deplibs"
6378267843Sdelphij	      finalize_deplibs="$deplib $finalize_deplibs"
6379267843Sdelphij	    else
6380267843Sdelphij	      func_append newdlfiles " $deplib"
6381267843Sdelphij	    fi
6382267843Sdelphij	  fi
6383267843Sdelphij	  continue
6384267843Sdelphij	  ;;
6385267843Sdelphij	%DEPLIBS%)
6386267843Sdelphij	  alldeplibs=yes
6387267843Sdelphij	  continue
6388267843Sdelphij	  ;;
6389267843Sdelphij	esac # case $deplib
6390267843Sdelphij
6391267843Sdelphij	if test "$found" = yes || test -f "$lib"; then :
6392267843Sdelphij	else
6393267843Sdelphij	  func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'"
6394267843Sdelphij	fi
6395267843Sdelphij
6396267843Sdelphij	# Check to see that this really is a libtool archive.
6397267843Sdelphij	func_lalib_unsafe_p "$lib" \
6398267843Sdelphij	  || func_fatal_error "\`$lib' is not a valid libtool archive"
6399267843Sdelphij
6400267843Sdelphij	func_dirname "$lib" "" "."
6401267843Sdelphij	ladir="$func_dirname_result"
6402267843Sdelphij
6403267843Sdelphij	dlname=
6404267843Sdelphij	dlopen=
6405267843Sdelphij	dlpreopen=
6406267843Sdelphij	libdir=
6407267843Sdelphij	library_names=
6408267843Sdelphij	old_library=
6409267843Sdelphij	inherited_linker_flags=
6410267843Sdelphij	# If the library was installed with an old release of libtool,
6411267843Sdelphij	# it will not redefine variables installed, or shouldnotlink
6412267843Sdelphij	installed=yes
6413267843Sdelphij	shouldnotlink=no
6414267843Sdelphij	avoidtemprpath=
6415267843Sdelphij
6416267843Sdelphij
6417267843Sdelphij	# Read the .la file
6418267843Sdelphij	func_source "$lib"
6419267843Sdelphij
6420267843Sdelphij	# Convert "-framework foo" to "foo.ltframework"
6421267843Sdelphij	if test -n "$inherited_linker_flags"; then
6422267843Sdelphij	  tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
6423267843Sdelphij	  for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
6424267843Sdelphij	    case " $new_inherited_linker_flags " in
6425267843Sdelphij	      *" $tmp_inherited_linker_flag "*) ;;
6426267843Sdelphij	      *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";;
6427267843Sdelphij	    esac
6428267843Sdelphij	  done
6429267843Sdelphij	fi
6430267843Sdelphij	dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
6431267843Sdelphij	if test "$linkmode,$pass" = "lib,link" ||
6432267843Sdelphij	   test "$linkmode,$pass" = "prog,scan" ||
6433267843Sdelphij	   { test "$linkmode" != prog && test "$linkmode" != lib; }; then
6434267843Sdelphij	  test -n "$dlopen" && func_append dlfiles " $dlopen"
6435267843Sdelphij	  test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen"
6436267843Sdelphij	fi
6437267843Sdelphij
6438267843Sdelphij	if test "$pass" = conv; then
6439267843Sdelphij	  # Only check for convenience libraries
6440267843Sdelphij	  deplibs="$lib $deplibs"
6441267843Sdelphij	  if test -z "$libdir"; then
6442267843Sdelphij	    if test -z "$old_library"; then
6443267843Sdelphij	      func_fatal_error "cannot find name of link library for \`$lib'"
6444267843Sdelphij	    fi
6445267843Sdelphij	    # It is a libtool convenience library, so add in its objects.
6446267843Sdelphij	    func_append convenience " $ladir/$objdir/$old_library"
6447267843Sdelphij	    func_append old_convenience " $ladir/$objdir/$old_library"
6448267843Sdelphij	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
6449267843Sdelphij	    func_fatal_error "\`$lib' is not a convenience library"
6450267843Sdelphij	  fi
6451267843Sdelphij	  tmp_libs=
6452267843Sdelphij	  for deplib in $dependency_libs; do
6453267843Sdelphij	    deplibs="$deplib $deplibs"
6454267843Sdelphij	    if $opt_preserve_dup_deps ; then
6455267843Sdelphij	      case "$tmp_libs " in
6456267843Sdelphij	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
6457267843Sdelphij	      esac
6458267843Sdelphij	    fi
6459267843Sdelphij	    func_append tmp_libs " $deplib"
6460267843Sdelphij	  done
6461267843Sdelphij	  continue
6462267843Sdelphij	fi # $pass = conv
6463267843Sdelphij
6464267843Sdelphij
6465267843Sdelphij	# Get the name of the library we link against.
6466267843Sdelphij	linklib=
6467267843Sdelphij	if test -n "$old_library" &&
6468267843Sdelphij	   { test "$prefer_static_libs" = yes ||
6469267843Sdelphij	     test "$prefer_static_libs,$installed" = "built,no"; }; then
6470267843Sdelphij	  linklib=$old_library
6471267843Sdelphij	else
6472267843Sdelphij	  for l in $old_library $library_names; do
6473267843Sdelphij	    linklib="$l"
6474267843Sdelphij	  done
6475267843Sdelphij	fi
6476267843Sdelphij	if test -z "$linklib"; then
6477267843Sdelphij	  func_fatal_error "cannot find name of link library for \`$lib'"
6478267843Sdelphij	fi
6479267843Sdelphij
6480267843Sdelphij	# This library was specified with -dlopen.
6481267843Sdelphij	if test "$pass" = dlopen; then
6482267843Sdelphij	  if test -z "$libdir"; then
6483267843Sdelphij	    func_fatal_error "cannot -dlopen a convenience library: \`$lib'"
6484267843Sdelphij	  fi
6485267843Sdelphij	  if test -z "$dlname" ||
6486267843Sdelphij	     test "$dlopen_support" != yes ||
6487267843Sdelphij	     test "$build_libtool_libs" = no; then
6488267843Sdelphij	    # If there is no dlname, no dlopen support or we're linking
6489267843Sdelphij	    # statically, we need to preload.  We also need to preload any
6490267843Sdelphij	    # dependent libraries so libltdl's deplib preloader doesn't
6491267843Sdelphij	    # bomb out in the load deplibs phase.
6492267843Sdelphij	    func_append dlprefiles " $lib $dependency_libs"
6493267843Sdelphij	  else
6494267843Sdelphij	    func_append newdlfiles " $lib"
6495267843Sdelphij	  fi
6496267843Sdelphij	  continue
6497267843Sdelphij	fi # $pass = dlopen
6498267843Sdelphij
6499267843Sdelphij	# We need an absolute path.
6500267843Sdelphij	case $ladir in
6501267843Sdelphij	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
6502267843Sdelphij	*)
6503267843Sdelphij	  abs_ladir=`cd "$ladir" && pwd`
6504267843Sdelphij	  if test -z "$abs_ladir"; then
6505267843Sdelphij	    func_warning "cannot determine absolute directory name of \`$ladir'"
6506267843Sdelphij	    func_warning "passing it literally to the linker, although it might fail"
6507267843Sdelphij	    abs_ladir="$ladir"
6508267843Sdelphij	  fi
6509267843Sdelphij	  ;;
6510267843Sdelphij	esac
6511267843Sdelphij	func_basename "$lib"
6512267843Sdelphij	laname="$func_basename_result"
6513267843Sdelphij
6514267843Sdelphij	# Find the relevant object directory and library name.
6515267843Sdelphij	if test "X$installed" = Xyes; then
6516267843Sdelphij	  if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
6517267843Sdelphij	    func_warning "library \`$lib' was moved."
6518267843Sdelphij	    dir="$ladir"
6519267843Sdelphij	    absdir="$abs_ladir"
6520267843Sdelphij	    libdir="$abs_ladir"
6521267843Sdelphij	  else
6522267843Sdelphij	    dir="$lt_sysroot$libdir"
6523267843Sdelphij	    absdir="$lt_sysroot$libdir"
6524267843Sdelphij	  fi
6525267843Sdelphij	  test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
6526267843Sdelphij	else
6527267843Sdelphij	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
6528267843Sdelphij	    dir="$ladir"
6529267843Sdelphij	    absdir="$abs_ladir"
6530267843Sdelphij	    # Remove this search path later
6531267843Sdelphij	    func_append notinst_path " $abs_ladir"
6532267843Sdelphij	  else
6533267843Sdelphij	    dir="$ladir/$objdir"
6534267843Sdelphij	    absdir="$abs_ladir/$objdir"
6535267843Sdelphij	    # Remove this search path later
6536267843Sdelphij	    func_append notinst_path " $abs_ladir"
6537267843Sdelphij	  fi
6538267843Sdelphij	fi # $installed = yes
6539267843Sdelphij	func_stripname 'lib' '.la' "$laname"
6540267843Sdelphij	name=$func_stripname_result
6541267843Sdelphij
6542267843Sdelphij	# This library was specified with -dlpreopen.
6543267843Sdelphij	if test "$pass" = dlpreopen; then
6544267843Sdelphij	  if test -z "$libdir" && test "$linkmode" = prog; then
6545267843Sdelphij	    func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'"
6546267843Sdelphij	  fi
6547267843Sdelphij	  case "$host" in
6548267843Sdelphij	    # special handling for platforms with PE-DLLs.
6549267843Sdelphij	    *cygwin* | *mingw* | *cegcc* )
6550267843Sdelphij	      # Linker will automatically link against shared library if both
6551267843Sdelphij	      # static and shared are present.  Therefore, ensure we extract
6552267843Sdelphij	      # symbols from the import library if a shared library is present
6553267843Sdelphij	      # (otherwise, the dlopen module name will be incorrect).  We do
6554267843Sdelphij	      # this by putting the import library name into $newdlprefiles.
6555267843Sdelphij	      # We recover the dlopen module name by 'saving' the la file
6556267843Sdelphij	      # name in a special purpose variable, and (later) extracting the
6557267843Sdelphij	      # dlname from the la file.
6558267843Sdelphij	      if test -n "$dlname"; then
6559267843Sdelphij	        func_tr_sh "$dir/$linklib"
6560267843Sdelphij	        eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname"
6561267843Sdelphij	        func_append newdlprefiles " $dir/$linklib"
6562267843Sdelphij	      else
6563267843Sdelphij	        func_append newdlprefiles " $dir/$old_library"
6564267843Sdelphij	        # Keep a list of preopened convenience libraries to check
6565267843Sdelphij	        # that they are being used correctly in the link pass.
6566267843Sdelphij	        test -z "$libdir" && \
6567267843Sdelphij	          func_append dlpreconveniencelibs " $dir/$old_library"
6568267843Sdelphij	      fi
6569267843Sdelphij	    ;;
6570267843Sdelphij	    * )
6571267843Sdelphij	      # Prefer using a static library (so that no silly _DYNAMIC symbols
6572267843Sdelphij	      # are required to link).
6573267843Sdelphij	      if test -n "$old_library"; then
6574267843Sdelphij	        func_append newdlprefiles " $dir/$old_library"
6575267843Sdelphij	        # Keep a list of preopened convenience libraries to check
6576267843Sdelphij	        # that they are being used correctly in the link pass.
6577267843Sdelphij	        test -z "$libdir" && \
6578267843Sdelphij	          func_append dlpreconveniencelibs " $dir/$old_library"
6579267843Sdelphij	      # Otherwise, use the dlname, so that lt_dlopen finds it.
6580267843Sdelphij	      elif test -n "$dlname"; then
6581267843Sdelphij	        func_append newdlprefiles " $dir/$dlname"
6582267843Sdelphij	      else
6583267843Sdelphij	        func_append newdlprefiles " $dir/$linklib"
6584267843Sdelphij	      fi
6585267843Sdelphij	    ;;
6586267843Sdelphij	  esac
6587267843Sdelphij	fi # $pass = dlpreopen
6588267843Sdelphij
6589267843Sdelphij	if test -z "$libdir"; then
6590267843Sdelphij	  # Link the convenience library
6591267843Sdelphij	  if test "$linkmode" = lib; then
6592267843Sdelphij	    deplibs="$dir/$old_library $deplibs"
6593267843Sdelphij	  elif test "$linkmode,$pass" = "prog,link"; then
6594267843Sdelphij	    compile_deplibs="$dir/$old_library $compile_deplibs"
6595267843Sdelphij	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
6596267843Sdelphij	  else
6597267843Sdelphij	    deplibs="$lib $deplibs" # used for prog,scan pass
6598267843Sdelphij	  fi
6599267843Sdelphij	  continue
6600267843Sdelphij	fi
6601267843Sdelphij
6602267843Sdelphij
6603267843Sdelphij	if test "$linkmode" = prog && test "$pass" != link; then
6604267843Sdelphij	  func_append newlib_search_path " $ladir"
6605267843Sdelphij	  deplibs="$lib $deplibs"
6606267843Sdelphij
6607267843Sdelphij	  linkalldeplibs=no
6608267843Sdelphij	  if test "$link_all_deplibs" != no || test -z "$library_names" ||
6609267843Sdelphij	     test "$build_libtool_libs" = no; then
6610267843Sdelphij	    linkalldeplibs=yes
6611267843Sdelphij	  fi
6612267843Sdelphij
6613267843Sdelphij	  tmp_libs=
6614267843Sdelphij	  for deplib in $dependency_libs; do
6615267843Sdelphij	    case $deplib in
6616267843Sdelphij	    -L*) func_stripname '-L' '' "$deplib"
6617267843Sdelphij	         func_resolve_sysroot "$func_stripname_result"
6618267843Sdelphij	         func_append newlib_search_path " $func_resolve_sysroot_result"
6619267843Sdelphij		 ;;
6620267843Sdelphij	    esac
6621267843Sdelphij	    # Need to link against all dependency_libs?
6622267843Sdelphij	    if test "$linkalldeplibs" = yes; then
6623267843Sdelphij	      deplibs="$deplib $deplibs"
6624267843Sdelphij	    else
6625267843Sdelphij	      # Need to hardcode shared library paths
6626267843Sdelphij	      # or/and link against static libraries
6627267843Sdelphij	      newdependency_libs="$deplib $newdependency_libs"
6628267843Sdelphij	    fi
6629267843Sdelphij	    if $opt_preserve_dup_deps ; then
6630267843Sdelphij	      case "$tmp_libs " in
6631267843Sdelphij	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
6632267843Sdelphij	      esac
6633267843Sdelphij	    fi
6634267843Sdelphij	    func_append tmp_libs " $deplib"
6635267843Sdelphij	  done # for deplib
6636267843Sdelphij	  continue
6637267843Sdelphij	fi # $linkmode = prog...
6638267843Sdelphij
6639267843Sdelphij	if test "$linkmode,$pass" = "prog,link"; then
6640267843Sdelphij	  if test -n "$library_names" &&
6641267843Sdelphij	     { { test "$prefer_static_libs" = no ||
6642267843Sdelphij	         test "$prefer_static_libs,$installed" = "built,yes"; } ||
6643267843Sdelphij	       test -z "$old_library"; }; then
6644267843Sdelphij	    # We need to hardcode the library path
6645267843Sdelphij	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
6646267843Sdelphij	      # Make sure the rpath contains only unique directories.
6647267843Sdelphij	      case "$temp_rpath:" in
6648267843Sdelphij	      *"$absdir:"*) ;;
6649267843Sdelphij	      *) func_append temp_rpath "$absdir:" ;;
6650267843Sdelphij	      esac
6651267843Sdelphij	    fi
6652267843Sdelphij
6653267843Sdelphij	    # Hardcode the library path.
6654267843Sdelphij	    # Skip directories that are in the system default run-time
6655267843Sdelphij	    # search path.
6656267843Sdelphij	    case " $sys_lib_dlsearch_path " in
6657267843Sdelphij	    *" $absdir "*) ;;
6658267843Sdelphij	    *)
6659267843Sdelphij	      case "$compile_rpath " in
6660267843Sdelphij	      *" $absdir "*) ;;
6661267843Sdelphij	      *) func_append compile_rpath " $absdir" ;;
6662267843Sdelphij	      esac
6663267843Sdelphij	      ;;
6664267843Sdelphij	    esac
6665267843Sdelphij	    case " $sys_lib_dlsearch_path " in
6666267843Sdelphij	    *" $libdir "*) ;;
6667267843Sdelphij	    *)
6668267843Sdelphij	      case "$finalize_rpath " in
6669267843Sdelphij	      *" $libdir "*) ;;
6670267843Sdelphij	      *) func_append finalize_rpath " $libdir" ;;
6671267843Sdelphij	      esac
6672267843Sdelphij	      ;;
6673267843Sdelphij	    esac
6674267843Sdelphij	  fi # $linkmode,$pass = prog,link...
6675267843Sdelphij
6676267843Sdelphij	  if test "$alldeplibs" = yes &&
6677267843Sdelphij	     { test "$deplibs_check_method" = pass_all ||
6678267843Sdelphij	       { test "$build_libtool_libs" = yes &&
6679267843Sdelphij		 test -n "$library_names"; }; }; then
6680267843Sdelphij	    # We only need to search for static libraries
6681267843Sdelphij	    continue
6682267843Sdelphij	  fi
6683267843Sdelphij	fi
6684267843Sdelphij
6685267843Sdelphij	link_static=no # Whether the deplib will be linked statically
6686267843Sdelphij	use_static_libs=$prefer_static_libs
6687267843Sdelphij	if test "$use_static_libs" = built && test "$installed" = yes; then
6688267843Sdelphij	  use_static_libs=no
6689267843Sdelphij	fi
6690267843Sdelphij	if test -n "$library_names" &&
6691267843Sdelphij	   { test "$use_static_libs" = no || test -z "$old_library"; }; then
6692267843Sdelphij	  case $host in
6693267843Sdelphij	  *cygwin* | *mingw* | *cegcc*)
6694267843Sdelphij	      # No point in relinking DLLs because paths are not encoded
6695267843Sdelphij	      func_append notinst_deplibs " $lib"
6696267843Sdelphij	      need_relink=no
6697267843Sdelphij	    ;;
6698267843Sdelphij	  *)
6699267843Sdelphij	    if test "$installed" = no; then
6700267843Sdelphij	      func_append notinst_deplibs " $lib"
6701267843Sdelphij	      need_relink=yes
6702267843Sdelphij	    fi
6703267843Sdelphij	    ;;
6704267843Sdelphij	  esac
6705267843Sdelphij	  # This is a shared library
6706267843Sdelphij
6707267843Sdelphij	  # Warn about portability, can't link against -module's on some
6708267843Sdelphij	  # systems (darwin).  Don't bleat about dlopened modules though!
6709267843Sdelphij	  dlopenmodule=""
6710267843Sdelphij	  for dlpremoduletest in $dlprefiles; do
6711267843Sdelphij	    if test "X$dlpremoduletest" = "X$lib"; then
6712267843Sdelphij	      dlopenmodule="$dlpremoduletest"
6713267843Sdelphij	      break
6714267843Sdelphij	    fi
6715267843Sdelphij	  done
6716267843Sdelphij	  if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then
6717267843Sdelphij	    echo
6718267843Sdelphij	    if test "$linkmode" = prog; then
6719267843Sdelphij	      $ECHO "*** Warning: Linking the executable $output against the loadable module"
6720267843Sdelphij	    else
6721267843Sdelphij	      $ECHO "*** Warning: Linking the shared library $output against the loadable module"
6722267843Sdelphij	    fi
6723267843Sdelphij	    $ECHO "*** $linklib is not portable!"
6724267843Sdelphij	  fi
6725267843Sdelphij	  if test "$linkmode" = lib &&
6726267843Sdelphij	     test "$hardcode_into_libs" = yes; then
6727267843Sdelphij	    # Hardcode the library path.
6728267843Sdelphij	    # Skip directories that are in the system default run-time
6729267843Sdelphij	    # search path.
6730267843Sdelphij	    case " $sys_lib_dlsearch_path " in
6731267843Sdelphij	    *" $absdir "*) ;;
6732267843Sdelphij	    *)
6733267843Sdelphij	      case "$compile_rpath " in
6734267843Sdelphij	      *" $absdir "*) ;;
6735267843Sdelphij	      *) func_append compile_rpath " $absdir" ;;
6736267843Sdelphij	      esac
6737267843Sdelphij	      ;;
6738267843Sdelphij	    esac
6739267843Sdelphij	    case " $sys_lib_dlsearch_path " in
6740267843Sdelphij	    *" $libdir "*) ;;
6741267843Sdelphij	    *)
6742267843Sdelphij	      case "$finalize_rpath " in
6743267843Sdelphij	      *" $libdir "*) ;;
6744267843Sdelphij	      *) func_append finalize_rpath " $libdir" ;;
6745267843Sdelphij	      esac
6746267843Sdelphij	      ;;
6747267843Sdelphij	    esac
6748267843Sdelphij	  fi
6749267843Sdelphij
6750267843Sdelphij	  if test -n "$old_archive_from_expsyms_cmds"; then
6751267843Sdelphij	    # figure out the soname
6752267843Sdelphij	    set dummy $library_names
6753267843Sdelphij	    shift
6754267843Sdelphij	    realname="$1"
6755267843Sdelphij	    shift
6756267843Sdelphij	    libname=`eval "\\$ECHO \"$libname_spec\""`
6757267843Sdelphij	    # use dlname if we got it. it's perfectly good, no?
6758267843Sdelphij	    if test -n "$dlname"; then
6759267843Sdelphij	      soname="$dlname"
6760267843Sdelphij	    elif test -n "$soname_spec"; then
6761267843Sdelphij	      # bleh windows
6762267843Sdelphij	      case $host in
6763267843Sdelphij	      *cygwin* | mingw* | *cegcc*)
6764267843Sdelphij	        func_arith $current - $age
6765267843Sdelphij		major=$func_arith_result
6766267843Sdelphij		versuffix="-$major"
6767267843Sdelphij		;;
6768267843Sdelphij	      esac
6769267843Sdelphij	      eval soname=\"$soname_spec\"
6770267843Sdelphij	    else
6771267843Sdelphij	      soname="$realname"
6772267843Sdelphij	    fi
6773267843Sdelphij
6774267843Sdelphij	    # Make a new name for the extract_expsyms_cmds to use
6775267843Sdelphij	    soroot="$soname"
6776267843Sdelphij	    func_basename "$soroot"
6777267843Sdelphij	    soname="$func_basename_result"
6778267843Sdelphij	    func_stripname 'lib' '.dll' "$soname"
6779267843Sdelphij	    newlib=libimp-$func_stripname_result.a
6780267843Sdelphij
6781267843Sdelphij	    # If the library has no export list, then create one now
6782267843Sdelphij	    if test -f "$output_objdir/$soname-def"; then :
6783267843Sdelphij	    else
6784267843Sdelphij	      func_verbose "extracting exported symbol list from \`$soname'"
6785267843Sdelphij	      func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
6786267843Sdelphij	    fi
6787267843Sdelphij
6788267843Sdelphij	    # Create $newlib
6789267843Sdelphij	    if test -f "$output_objdir/$newlib"; then :; else
6790267843Sdelphij	      func_verbose "generating import library for \`$soname'"
6791267843Sdelphij	      func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
6792267843Sdelphij	    fi
6793267843Sdelphij	    # make sure the library variables are pointing to the new library
6794267843Sdelphij	    dir=$output_objdir
6795267843Sdelphij	    linklib=$newlib
6796267843Sdelphij	  fi # test -n "$old_archive_from_expsyms_cmds"
6797267843Sdelphij
6798267843Sdelphij	  if test "$linkmode" = prog || test "$opt_mode" != relink; then
6799267843Sdelphij	    add_shlibpath=
6800267843Sdelphij	    add_dir=
6801267843Sdelphij	    add=
6802267843Sdelphij	    lib_linked=yes
6803267843Sdelphij	    case $hardcode_action in
6804267843Sdelphij	    immediate | unsupported)
6805267843Sdelphij	      if test "$hardcode_direct" = no; then
6806267843Sdelphij		add="$dir/$linklib"
6807267843Sdelphij		case $host in
6808267843Sdelphij		  *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
6809267843Sdelphij		  *-*-sysv4*uw2*) add_dir="-L$dir" ;;
6810267843Sdelphij		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
6811267843Sdelphij		    *-*-unixware7*) add_dir="-L$dir" ;;
6812267843Sdelphij		  *-*-darwin* )
6813267843Sdelphij		    # if the lib is a (non-dlopened) module then we can not
6814267843Sdelphij		    # link against it, someone is ignoring the earlier warnings
6815267843Sdelphij		    if /usr/bin/file -L $add 2> /dev/null |
6816267843Sdelphij			 $GREP ": [^:]* bundle" >/dev/null ; then
6817267843Sdelphij		      if test "X$dlopenmodule" != "X$lib"; then
6818267843Sdelphij			$ECHO "*** Warning: lib $linklib is a module, not a shared library"
6819267843Sdelphij			if test -z "$old_library" ; then
6820267843Sdelphij			  echo
6821267843Sdelphij			  echo "*** And there doesn't seem to be a static archive available"
6822267843Sdelphij			  echo "*** The link will probably fail, sorry"
6823267843Sdelphij			else
6824267843Sdelphij			  add="$dir/$old_library"
6825267843Sdelphij			fi
6826267843Sdelphij		      elif test -n "$old_library"; then
6827267843Sdelphij			add="$dir/$old_library"
6828267843Sdelphij		      fi
6829267843Sdelphij		    fi
6830267843Sdelphij		esac
6831267843Sdelphij	      elif test "$hardcode_minus_L" = no; then
6832267843Sdelphij		case $host in
6833267843Sdelphij		*-*-sunos*) add_shlibpath="$dir" ;;
6834267843Sdelphij		esac
6835267843Sdelphij		add_dir="-L$dir"
6836267843Sdelphij		add="-l$name"
6837267843Sdelphij	      elif test "$hardcode_shlibpath_var" = no; then
6838267843Sdelphij		add_shlibpath="$dir"
6839267843Sdelphij		add="-l$name"
6840267843Sdelphij	      else
6841267843Sdelphij		lib_linked=no
6842267843Sdelphij	      fi
6843267843Sdelphij	      ;;
6844267843Sdelphij	    relink)
6845267843Sdelphij	      if test "$hardcode_direct" = yes &&
6846267843Sdelphij	         test "$hardcode_direct_absolute" = no; then
6847267843Sdelphij		add="$dir/$linklib"
6848267843Sdelphij	      elif test "$hardcode_minus_L" = yes; then
6849267843Sdelphij		add_dir="-L$absdir"
6850267843Sdelphij		# Try looking first in the location we're being installed to.
6851267843Sdelphij		if test -n "$inst_prefix_dir"; then
6852267843Sdelphij		  case $libdir in
6853267843Sdelphij		    [\\/]*)
6854267843Sdelphij		      func_append add_dir " -L$inst_prefix_dir$libdir"
6855267843Sdelphij		      ;;
6856267843Sdelphij		  esac
6857267843Sdelphij		fi
6858267843Sdelphij		add="-l$name"
6859267843Sdelphij	      elif test "$hardcode_shlibpath_var" = yes; then
6860267843Sdelphij		add_shlibpath="$dir"
6861267843Sdelphij		add="-l$name"
6862267843Sdelphij	      else
6863267843Sdelphij		lib_linked=no
6864267843Sdelphij	      fi
6865267843Sdelphij	      ;;
6866267843Sdelphij	    *) lib_linked=no ;;
6867267843Sdelphij	    esac
6868267843Sdelphij
6869267843Sdelphij	    if test "$lib_linked" != yes; then
6870267843Sdelphij	      func_fatal_configuration "unsupported hardcode properties"
6871267843Sdelphij	    fi
6872267843Sdelphij
6873267843Sdelphij	    if test -n "$add_shlibpath"; then
6874267843Sdelphij	      case :$compile_shlibpath: in
6875267843Sdelphij	      *":$add_shlibpath:"*) ;;
6876267843Sdelphij	      *) func_append compile_shlibpath "$add_shlibpath:" ;;
6877267843Sdelphij	      esac
6878267843Sdelphij	    fi
6879267843Sdelphij	    if test "$linkmode" = prog; then
6880267843Sdelphij	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
6881267843Sdelphij	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
6882267843Sdelphij	    else
6883267843Sdelphij	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
6884267843Sdelphij	      test -n "$add" && deplibs="$add $deplibs"
6885267843Sdelphij	      if test "$hardcode_direct" != yes &&
6886267843Sdelphij		 test "$hardcode_minus_L" != yes &&
6887267843Sdelphij		 test "$hardcode_shlibpath_var" = yes; then
6888267843Sdelphij		case :$finalize_shlibpath: in
6889267843Sdelphij		*":$libdir:"*) ;;
6890267843Sdelphij		*) func_append finalize_shlibpath "$libdir:" ;;
6891267843Sdelphij		esac
6892267843Sdelphij	      fi
6893267843Sdelphij	    fi
6894267843Sdelphij	  fi
6895267843Sdelphij
6896267843Sdelphij	  if test "$linkmode" = prog || test "$opt_mode" = relink; then
6897267843Sdelphij	    add_shlibpath=
6898267843Sdelphij	    add_dir=
6899267843Sdelphij	    add=
6900267843Sdelphij	    # Finalize command for both is simple: just hardcode it.
6901267843Sdelphij	    if test "$hardcode_direct" = yes &&
6902267843Sdelphij	       test "$hardcode_direct_absolute" = no; then
6903284778Sdelphij	      if test -f "$inst_prefix_dir$libdir/$linklib"; then
6904284778Sdelphij	        add="$inst_prefix_dir$libdir/$linklib"
6905284778Sdelphij	      else
6906284778Sdelphij	        add="$libdir/$linklib"
6907284778Sdelphij	      fi
6908267843Sdelphij	    elif test "$hardcode_minus_L" = yes; then
6909267843Sdelphij	      add_dir="-L$libdir"
6910267843Sdelphij	      add="-l$name"
6911267843Sdelphij	    elif test "$hardcode_shlibpath_var" = yes; then
6912267843Sdelphij	      case :$finalize_shlibpath: in
6913267843Sdelphij	      *":$libdir:"*) ;;
6914267843Sdelphij	      *) func_append finalize_shlibpath "$libdir:" ;;
6915267843Sdelphij	      esac
6916267843Sdelphij	      add="-l$name"
6917267843Sdelphij	    elif test "$hardcode_automatic" = yes; then
6918267843Sdelphij	      if test -n "$inst_prefix_dir" &&
6919267843Sdelphij		 test -f "$inst_prefix_dir$libdir/$linklib" ; then
6920267843Sdelphij		add="$inst_prefix_dir$libdir/$linklib"
6921267843Sdelphij	      else
6922267843Sdelphij		add="$libdir/$linklib"
6923267843Sdelphij	      fi
6924267843Sdelphij	    else
6925267843Sdelphij	      # We cannot seem to hardcode it, guess we'll fake it.
6926267843Sdelphij	      add_dir="-L$libdir"
6927267843Sdelphij	      # Try looking first in the location we're being installed to.
6928267843Sdelphij	      if test -n "$inst_prefix_dir"; then
6929267843Sdelphij		case $libdir in
6930267843Sdelphij		  [\\/]*)
6931267843Sdelphij		    func_append add_dir " -L$inst_prefix_dir$libdir"
6932267843Sdelphij		    ;;
6933267843Sdelphij		esac
6934267843Sdelphij	      fi
6935267843Sdelphij	      add="-l$name"
6936267843Sdelphij	    fi
6937267843Sdelphij
6938267843Sdelphij	    if test "$linkmode" = prog; then
6939267843Sdelphij	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
6940267843Sdelphij	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
6941267843Sdelphij	    else
6942267843Sdelphij	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
6943267843Sdelphij	      test -n "$add" && deplibs="$add $deplibs"
6944267843Sdelphij	    fi
6945267843Sdelphij	  fi
6946267843Sdelphij	elif test "$linkmode" = prog; then
6947267843Sdelphij	  # Here we assume that one of hardcode_direct or hardcode_minus_L
6948267843Sdelphij	  # is not unsupported.  This is valid on all known static and
6949267843Sdelphij	  # shared platforms.
6950267843Sdelphij	  if test "$hardcode_direct" != unsupported; then
6951267843Sdelphij	    test -n "$old_library" && linklib="$old_library"
6952267843Sdelphij	    compile_deplibs="$dir/$linklib $compile_deplibs"
6953267843Sdelphij	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
6954267843Sdelphij	  else
6955267843Sdelphij	    compile_deplibs="-l$name -L$dir $compile_deplibs"
6956267843Sdelphij	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
6957267843Sdelphij	  fi
6958267843Sdelphij	elif test "$build_libtool_libs" = yes; then
6959267843Sdelphij	  # Not a shared library
6960267843Sdelphij	  if test "$deplibs_check_method" != pass_all; then
6961267843Sdelphij	    # We're trying link a shared library against a static one
6962267843Sdelphij	    # but the system doesn't support it.
6963267843Sdelphij
6964267843Sdelphij	    # Just print a warning and add the library to dependency_libs so
6965267843Sdelphij	    # that the program can be linked against the static library.
6966267843Sdelphij	    echo
6967267843Sdelphij	    $ECHO "*** Warning: This system can not link to static lib archive $lib."
6968267843Sdelphij	    echo "*** I have the capability to make that library automatically link in when"
6969267843Sdelphij	    echo "*** you link to this library.  But I can only do this if you have a"
6970267843Sdelphij	    echo "*** shared version of the library, which you do not appear to have."
6971267843Sdelphij	    if test "$module" = yes; then
6972267843Sdelphij	      echo "*** But as you try to build a module library, libtool will still create "
6973267843Sdelphij	      echo "*** a static module, that should work as long as the dlopening application"
6974267843Sdelphij	      echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
6975267843Sdelphij	      if test -z "$global_symbol_pipe"; then
6976267843Sdelphij		echo
6977267843Sdelphij		echo "*** However, this would only work if libtool was able to extract symbol"
6978267843Sdelphij		echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
6979267843Sdelphij		echo "*** not find such a program.  So, this module is probably useless."
6980267843Sdelphij		echo "*** \`nm' from GNU binutils and a full rebuild may help."
6981267843Sdelphij	      fi
6982267843Sdelphij	      if test "$build_old_libs" = no; then
6983267843Sdelphij		build_libtool_libs=module
6984267843Sdelphij		build_old_libs=yes
6985267843Sdelphij	      else
6986267843Sdelphij		build_libtool_libs=no
6987267843Sdelphij	      fi
6988267843Sdelphij	    fi
6989267843Sdelphij	  else
6990267843Sdelphij	    deplibs="$dir/$old_library $deplibs"
6991267843Sdelphij	    link_static=yes
6992267843Sdelphij	  fi
6993267843Sdelphij	fi # link shared/static library?
6994267843Sdelphij
6995267843Sdelphij	if test "$linkmode" = lib; then
6996267843Sdelphij	  if test -n "$dependency_libs" &&
6997267843Sdelphij	     { test "$hardcode_into_libs" != yes ||
6998267843Sdelphij	       test "$build_old_libs" = yes ||
6999267843Sdelphij	       test "$link_static" = yes; }; then
7000267843Sdelphij	    # Extract -R from dependency_libs
7001267843Sdelphij	    temp_deplibs=
7002267843Sdelphij	    for libdir in $dependency_libs; do
7003267843Sdelphij	      case $libdir in
7004267843Sdelphij	      -R*) func_stripname '-R' '' "$libdir"
7005267843Sdelphij	           temp_xrpath=$func_stripname_result
7006267843Sdelphij		   case " $xrpath " in
7007267843Sdelphij		   *" $temp_xrpath "*) ;;
7008267843Sdelphij		   *) func_append xrpath " $temp_xrpath";;
7009267843Sdelphij		   esac;;
7010267843Sdelphij	      *) func_append temp_deplibs " $libdir";;
7011267843Sdelphij	      esac
7012267843Sdelphij	    done
7013267843Sdelphij	    dependency_libs="$temp_deplibs"
7014267843Sdelphij	  fi
7015267843Sdelphij
7016267843Sdelphij	  func_append newlib_search_path " $absdir"
7017267843Sdelphij	  # Link against this library
7018267843Sdelphij	  test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
7019267843Sdelphij	  # ... and its dependency_libs
7020267843Sdelphij	  tmp_libs=
7021267843Sdelphij	  for deplib in $dependency_libs; do
7022267843Sdelphij	    newdependency_libs="$deplib $newdependency_libs"
7023267843Sdelphij	    case $deplib in
7024267843Sdelphij              -L*) func_stripname '-L' '' "$deplib"
7025267843Sdelphij                   func_resolve_sysroot "$func_stripname_result";;
7026267843Sdelphij              *) func_resolve_sysroot "$deplib" ;;
7027267843Sdelphij            esac
7028267843Sdelphij	    if $opt_preserve_dup_deps ; then
7029267843Sdelphij	      case "$tmp_libs " in
7030267843Sdelphij	      *" $func_resolve_sysroot_result "*)
7031267843Sdelphij                func_append specialdeplibs " $func_resolve_sysroot_result" ;;
7032267843Sdelphij	      esac
7033267843Sdelphij	    fi
7034267843Sdelphij	    func_append tmp_libs " $func_resolve_sysroot_result"
7035267843Sdelphij	  done
7036267843Sdelphij
7037267843Sdelphij	  if test "$link_all_deplibs" != no; then
7038267843Sdelphij	    # Add the search paths of all dependency libraries
7039267843Sdelphij	    for deplib in $dependency_libs; do
7040267843Sdelphij	      path=
7041267843Sdelphij	      case $deplib in
7042267843Sdelphij	      -L*) path="$deplib" ;;
7043267843Sdelphij	      *.la)
7044267843Sdelphij	        func_resolve_sysroot "$deplib"
7045267843Sdelphij	        deplib=$func_resolve_sysroot_result
7046267843Sdelphij	        func_dirname "$deplib" "" "."
7047267843Sdelphij		dir=$func_dirname_result
7048267843Sdelphij		# We need an absolute path.
7049267843Sdelphij		case $dir in
7050267843Sdelphij		[\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
7051267843Sdelphij		*)
7052267843Sdelphij		  absdir=`cd "$dir" && pwd`
7053267843Sdelphij		  if test -z "$absdir"; then
7054267843Sdelphij		    func_warning "cannot determine absolute directory name of \`$dir'"
7055267843Sdelphij		    absdir="$dir"
7056267843Sdelphij		  fi
7057267843Sdelphij		  ;;
7058267843Sdelphij		esac
7059267843Sdelphij		if $GREP "^installed=no" $deplib > /dev/null; then
7060267843Sdelphij		case $host in
7061267843Sdelphij		*-*-darwin*)
7062267843Sdelphij		  depdepl=
7063267843Sdelphij		  eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
7064267843Sdelphij		  if test -n "$deplibrary_names" ; then
7065267843Sdelphij		    for tmp in $deplibrary_names ; do
7066267843Sdelphij		      depdepl=$tmp
7067267843Sdelphij		    done
7068267843Sdelphij		    if test -f "$absdir/$objdir/$depdepl" ; then
7069267843Sdelphij		      depdepl="$absdir/$objdir/$depdepl"
7070267843Sdelphij		      darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
7071267843Sdelphij                      if test -z "$darwin_install_name"; then
7072267843Sdelphij                          darwin_install_name=`${OTOOL64} -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
7073267843Sdelphij                      fi
7074267843Sdelphij		      func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}"
7075267843Sdelphij		      func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}"
7076267843Sdelphij		      path=
7077267843Sdelphij		    fi
7078267843Sdelphij		  fi
7079267843Sdelphij		  ;;
7080267843Sdelphij		*)
7081267843Sdelphij		  path="-L$absdir/$objdir"
7082267843Sdelphij		  ;;
7083267843Sdelphij		esac
7084267843Sdelphij		else
7085267843Sdelphij		  eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
7086267843Sdelphij		  test -z "$libdir" && \
7087267843Sdelphij		    func_fatal_error "\`$deplib' is not a valid libtool archive"
7088267843Sdelphij		  test "$absdir" != "$libdir" && \
7089267843Sdelphij		    func_warning "\`$deplib' seems to be moved"
7090267843Sdelphij
7091267843Sdelphij		  path="-L$absdir"
7092267843Sdelphij		fi
7093267843Sdelphij		;;
7094267843Sdelphij	      esac
7095267843Sdelphij	      case " $deplibs " in
7096267843Sdelphij	      *" $path "*) ;;
7097267843Sdelphij	      *) deplibs="$path $deplibs" ;;
7098267843Sdelphij	      esac
7099267843Sdelphij	    done
7100267843Sdelphij	  fi # link_all_deplibs != no
7101267843Sdelphij	fi # linkmode = lib
7102267843Sdelphij      done # for deplib in $libs
7103267843Sdelphij      if test "$pass" = link; then
7104267843Sdelphij	if test "$linkmode" = "prog"; then
7105267843Sdelphij	  compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
7106267843Sdelphij	  finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
7107267843Sdelphij	else
7108267843Sdelphij	  compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
7109267843Sdelphij	fi
7110267843Sdelphij      fi
7111267843Sdelphij      dependency_libs="$newdependency_libs"
7112267843Sdelphij      if test "$pass" = dlpreopen; then
7113267843Sdelphij	# Link the dlpreopened libraries before other libraries
7114267843Sdelphij	for deplib in $save_deplibs; do
7115267843Sdelphij	  deplibs="$deplib $deplibs"
7116267843Sdelphij	done
7117267843Sdelphij      fi
7118267843Sdelphij      if test "$pass" != dlopen; then
7119267843Sdelphij	if test "$pass" != conv; then
7120267843Sdelphij	  # Make sure lib_search_path contains only unique directories.
7121267843Sdelphij	  lib_search_path=
7122267843Sdelphij	  for dir in $newlib_search_path; do
7123267843Sdelphij	    case "$lib_search_path " in
7124267843Sdelphij	    *" $dir "*) ;;
7125267843Sdelphij	    *) func_append lib_search_path " $dir" ;;
7126267843Sdelphij	    esac
7127267843Sdelphij	  done
7128267843Sdelphij	  newlib_search_path=
7129267843Sdelphij	fi
7130267843Sdelphij
7131267843Sdelphij	if test "$linkmode,$pass" != "prog,link"; then
7132267843Sdelphij	  vars="deplibs"
7133267843Sdelphij	else
7134267843Sdelphij	  vars="compile_deplibs finalize_deplibs"
7135267843Sdelphij	fi
7136267843Sdelphij	for var in $vars dependency_libs; do
7137267843Sdelphij	  # Add libraries to $var in reverse order
7138267843Sdelphij	  eval tmp_libs=\"\$$var\"
7139267843Sdelphij	  new_libs=
7140267843Sdelphij	  for deplib in $tmp_libs; do
7141267843Sdelphij	    # FIXME: Pedantically, this is the right thing to do, so
7142267843Sdelphij	    #        that some nasty dependency loop isn't accidentally
7143267843Sdelphij	    #        broken:
7144267843Sdelphij	    #new_libs="$deplib $new_libs"
7145267843Sdelphij	    # Pragmatically, this seems to cause very few problems in
7146267843Sdelphij	    # practice:
7147267843Sdelphij	    case $deplib in
7148267843Sdelphij	    -L*) new_libs="$deplib $new_libs" ;;
7149267843Sdelphij	    -R*) ;;
7150267843Sdelphij	    *)
7151267843Sdelphij	      # And here is the reason: when a library appears more
7152267843Sdelphij	      # than once as an explicit dependence of a library, or
7153267843Sdelphij	      # is implicitly linked in more than once by the
7154267843Sdelphij	      # compiler, it is considered special, and multiple
7155267843Sdelphij	      # occurrences thereof are not removed.  Compare this
7156267843Sdelphij	      # with having the same library being listed as a
7157267843Sdelphij	      # dependency of multiple other libraries: in this case,
7158267843Sdelphij	      # we know (pedantically, we assume) the library does not
7159267843Sdelphij	      # need to be listed more than once, so we keep only the
7160267843Sdelphij	      # last copy.  This is not always right, but it is rare
7161267843Sdelphij	      # enough that we require users that really mean to play
7162267843Sdelphij	      # such unportable linking tricks to link the library
7163267843Sdelphij	      # using -Wl,-lname, so that libtool does not consider it
7164267843Sdelphij	      # for duplicate removal.
7165267843Sdelphij	      case " $specialdeplibs " in
7166267843Sdelphij	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
7167267843Sdelphij	      *)
7168267843Sdelphij		case " $new_libs " in
7169267843Sdelphij		*" $deplib "*) ;;
7170267843Sdelphij		*) new_libs="$deplib $new_libs" ;;
7171267843Sdelphij		esac
7172267843Sdelphij		;;
7173267843Sdelphij	      esac
7174267843Sdelphij	      ;;
7175267843Sdelphij	    esac
7176267843Sdelphij	  done
7177267843Sdelphij	  tmp_libs=
7178267843Sdelphij	  for deplib in $new_libs; do
7179267843Sdelphij	    case $deplib in
7180267843Sdelphij	    -L*)
7181267843Sdelphij	      case " $tmp_libs " in
7182267843Sdelphij	      *" $deplib "*) ;;
7183267843Sdelphij	      *) func_append tmp_libs " $deplib" ;;
7184267843Sdelphij	      esac
7185267843Sdelphij	      ;;
7186267843Sdelphij	    *) func_append tmp_libs " $deplib" ;;
7187267843Sdelphij	    esac
7188267843Sdelphij	  done
7189267843Sdelphij	  eval $var=\"$tmp_libs\"
7190267843Sdelphij	done # for var
7191267843Sdelphij      fi
7192267843Sdelphij      # Last step: remove runtime libs from dependency_libs
7193267843Sdelphij      # (they stay in deplibs)
7194267843Sdelphij      tmp_libs=
7195267843Sdelphij      for i in $dependency_libs ; do
7196267843Sdelphij	case " $predeps $postdeps $compiler_lib_search_path " in
7197267843Sdelphij	*" $i "*)
7198267843Sdelphij	  i=""
7199267843Sdelphij	  ;;
7200267843Sdelphij	esac
7201267843Sdelphij	if test -n "$i" ; then
7202267843Sdelphij	  func_append tmp_libs " $i"
7203267843Sdelphij	fi
7204267843Sdelphij      done
7205267843Sdelphij      dependency_libs=$tmp_libs
7206267843Sdelphij    done # for pass
7207267843Sdelphij    if test "$linkmode" = prog; then
7208267843Sdelphij      dlfiles="$newdlfiles"
7209267843Sdelphij    fi
7210267843Sdelphij    if test "$linkmode" = prog || test "$linkmode" = lib; then
7211267843Sdelphij      dlprefiles="$newdlprefiles"
7212267843Sdelphij    fi
7213267843Sdelphij
7214267843Sdelphij    case $linkmode in
7215267843Sdelphij    oldlib)
7216267843Sdelphij      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
7217267843Sdelphij	func_warning "\`-dlopen' is ignored for archives"
7218267843Sdelphij      fi
7219267843Sdelphij
7220267843Sdelphij      case " $deplibs" in
7221267843Sdelphij      *\ -l* | *\ -L*)
7222267843Sdelphij	func_warning "\`-l' and \`-L' are ignored for archives" ;;
7223267843Sdelphij      esac
7224267843Sdelphij
7225267843Sdelphij      test -n "$rpath" && \
7226267843Sdelphij	func_warning "\`-rpath' is ignored for archives"
7227267843Sdelphij
7228267843Sdelphij      test -n "$xrpath" && \
7229267843Sdelphij	func_warning "\`-R' is ignored for archives"
7230267843Sdelphij
7231267843Sdelphij      test -n "$vinfo" && \
7232267843Sdelphij	func_warning "\`-version-info/-version-number' is ignored for archives"
7233267843Sdelphij
7234267843Sdelphij      test -n "$release" && \
7235267843Sdelphij	func_warning "\`-release' is ignored for archives"
7236267843Sdelphij
7237267843Sdelphij      test -n "$export_symbols$export_symbols_regex" && \
7238267843Sdelphij	func_warning "\`-export-symbols' is ignored for archives"
7239267843Sdelphij
7240267843Sdelphij      # Now set the variables for building old libraries.
7241267843Sdelphij      build_libtool_libs=no
7242267843Sdelphij      oldlibs="$output"
7243267843Sdelphij      func_append objs "$old_deplibs"
7244267843Sdelphij      ;;
7245267843Sdelphij
7246267843Sdelphij    lib)
7247267843Sdelphij      # Make sure we only generate libraries of the form `libNAME.la'.
7248267843Sdelphij      case $outputname in
7249267843Sdelphij      lib*)
7250267843Sdelphij	func_stripname 'lib' '.la' "$outputname"
7251267843Sdelphij	name=$func_stripname_result
7252267843Sdelphij	eval shared_ext=\"$shrext_cmds\"
7253267843Sdelphij	eval libname=\"$libname_spec\"
7254267843Sdelphij	;;
7255267843Sdelphij      *)
7256267843Sdelphij	test "$module" = no && \
7257267843Sdelphij	  func_fatal_help "libtool library \`$output' must begin with \`lib'"
7258267843Sdelphij
7259267843Sdelphij	if test "$need_lib_prefix" != no; then
7260267843Sdelphij	  # Add the "lib" prefix for modules if required
7261267843Sdelphij	  func_stripname '' '.la' "$outputname"
7262267843Sdelphij	  name=$func_stripname_result
7263267843Sdelphij	  eval shared_ext=\"$shrext_cmds\"
7264267843Sdelphij	  eval libname=\"$libname_spec\"
7265267843Sdelphij	else
7266267843Sdelphij	  func_stripname '' '.la' "$outputname"
7267267843Sdelphij	  libname=$func_stripname_result
7268267843Sdelphij	fi
7269267843Sdelphij	;;
7270267843Sdelphij      esac
7271267843Sdelphij
7272267843Sdelphij      if test -n "$objs"; then
7273267843Sdelphij	if test "$deplibs_check_method" != pass_all; then
7274267843Sdelphij	  func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs"
7275267843Sdelphij	else
7276267843Sdelphij	  echo
7277267843Sdelphij	  $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
7278267843Sdelphij	  $ECHO "*** objects $objs is not portable!"
7279267843Sdelphij	  func_append libobjs " $objs"
7280267843Sdelphij	fi
7281267843Sdelphij      fi
7282267843Sdelphij
7283267843Sdelphij      test "$dlself" != no && \
7284267843Sdelphij	func_warning "\`-dlopen self' is ignored for libtool libraries"
7285267843Sdelphij
7286267843Sdelphij      set dummy $rpath
7287267843Sdelphij      shift
7288267843Sdelphij      test "$#" -gt 1 && \
7289267843Sdelphij	func_warning "ignoring multiple \`-rpath's for a libtool library"
7290267843Sdelphij
7291267843Sdelphij      install_libdir="$1"
7292267843Sdelphij
7293267843Sdelphij      oldlibs=
7294267843Sdelphij      if test -z "$rpath"; then
7295267843Sdelphij	if test "$build_libtool_libs" = yes; then
7296267843Sdelphij	  # Building a libtool convenience library.
7297267843Sdelphij	  # Some compilers have problems with a `.al' extension so
7298267843Sdelphij	  # convenience libraries should have the same extension an
7299267843Sdelphij	  # archive normally would.
7300267843Sdelphij	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
7301267843Sdelphij	  build_libtool_libs=convenience
7302267843Sdelphij	  build_old_libs=yes
7303267843Sdelphij	fi
7304267843Sdelphij
7305267843Sdelphij	test -n "$vinfo" && \
7306267843Sdelphij	  func_warning "\`-version-info/-version-number' is ignored for convenience libraries"
7307267843Sdelphij
7308267843Sdelphij	test -n "$release" && \
7309267843Sdelphij	  func_warning "\`-release' is ignored for convenience libraries"
7310267843Sdelphij      else
7311267843Sdelphij
7312267843Sdelphij	# Parse the version information argument.
7313267843Sdelphij	save_ifs="$IFS"; IFS=':'
7314267843Sdelphij	set dummy $vinfo 0 0 0
7315267843Sdelphij	shift
7316267843Sdelphij	IFS="$save_ifs"
7317267843Sdelphij
7318267843Sdelphij	test -n "$7" && \
7319267843Sdelphij	  func_fatal_help "too many parameters to \`-version-info'"
7320267843Sdelphij
7321267843Sdelphij	# convert absolute version numbers to libtool ages
7322267843Sdelphij	# this retains compatibility with .la files and attempts
7323267843Sdelphij	# to make the code below a bit more comprehensible
7324267843Sdelphij
7325267843Sdelphij	case $vinfo_number in
7326267843Sdelphij	yes)
7327267843Sdelphij	  number_major="$1"
7328267843Sdelphij	  number_minor="$2"
7329267843Sdelphij	  number_revision="$3"
7330267843Sdelphij	  #
7331267843Sdelphij	  # There are really only two kinds -- those that
7332267843Sdelphij	  # use the current revision as the major version
7333267843Sdelphij	  # and those that subtract age and use age as
7334267843Sdelphij	  # a minor version.  But, then there is irix
7335267843Sdelphij	  # which has an extra 1 added just for fun
7336267843Sdelphij	  #
7337267843Sdelphij	  case $version_type in
7338267843Sdelphij	  # correct linux to gnu/linux during the next big refactor
7339267843Sdelphij	  darwin|linux|osf|windows|none)
7340267843Sdelphij	    func_arith $number_major + $number_minor
7341267843Sdelphij	    current=$func_arith_result
7342267843Sdelphij	    age="$number_minor"
7343267843Sdelphij	    revision="$number_revision"
7344267843Sdelphij	    ;;
7345267843Sdelphij	  freebsd-aout|freebsd-elf|qnx|sunos)
7346267843Sdelphij	    current="$number_major"
7347267843Sdelphij	    revision="$number_minor"
7348267843Sdelphij	    age="0"
7349267843Sdelphij	    ;;
7350267843Sdelphij	  irix|nonstopux)
7351267843Sdelphij	    func_arith $number_major + $number_minor
7352267843Sdelphij	    current=$func_arith_result
7353267843Sdelphij	    age="$number_minor"
7354267843Sdelphij	    revision="$number_minor"
7355267843Sdelphij	    lt_irix_increment=no
7356267843Sdelphij	    ;;
7357267843Sdelphij	  esac
7358267843Sdelphij	  ;;
7359267843Sdelphij	no)
7360267843Sdelphij	  current="$1"
7361267843Sdelphij	  revision="$2"
7362267843Sdelphij	  age="$3"
7363267843Sdelphij	  ;;
7364267843Sdelphij	esac
7365267843Sdelphij
7366267843Sdelphij	# Check that each of the things are valid numbers.
7367267843Sdelphij	case $current in
7368267843Sdelphij	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]) ;;
7369267843Sdelphij	*)
7370267843Sdelphij	  func_error "CURRENT \`$current' must be a nonnegative integer"
7371267843Sdelphij	  func_fatal_error "\`$vinfo' is not valid version information"
7372267843Sdelphij	  ;;
7373267843Sdelphij	esac
7374267843Sdelphij
7375267843Sdelphij	case $revision in
7376267843Sdelphij	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]) ;;
7377267843Sdelphij	*)
7378267843Sdelphij	  func_error "REVISION \`$revision' must be a nonnegative integer"
7379267843Sdelphij	  func_fatal_error "\`$vinfo' is not valid version information"
7380267843Sdelphij	  ;;
7381267843Sdelphij	esac
7382267843Sdelphij
7383267843Sdelphij	case $age in
7384267843Sdelphij	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]) ;;
7385267843Sdelphij	*)
7386267843Sdelphij	  func_error "AGE \`$age' must be a nonnegative integer"
7387267843Sdelphij	  func_fatal_error "\`$vinfo' is not valid version information"
7388267843Sdelphij	  ;;
7389267843Sdelphij	esac
7390267843Sdelphij
7391267843Sdelphij	if test "$age" -gt "$current"; then
7392267843Sdelphij	  func_error "AGE \`$age' is greater than the current interface number \`$current'"
7393267843Sdelphij	  func_fatal_error "\`$vinfo' is not valid version information"
7394267843Sdelphij	fi
7395267843Sdelphij
7396267843Sdelphij	# Calculate the version variables.
7397267843Sdelphij	major=
7398267843Sdelphij	versuffix=
7399267843Sdelphij	versuffix2=
7400267843Sdelphij	verstring=
7401267843Sdelphij	case $version_type in
7402267843Sdelphij	none) ;;
7403267843Sdelphij
7404267843Sdelphij	darwin)
7405267843Sdelphij	  # Like Linux, but with the current version available in
7406267843Sdelphij	  # verstring for coding it into the library header
7407267843Sdelphij	  func_arith $current - $age
7408267843Sdelphij	  major=.$func_arith_result
7409267843Sdelphij	  versuffix="$major.$age.$revision"
7410267843Sdelphij	  # Darwin ld doesn't like 0 for these options...
7411267843Sdelphij	  func_arith $current + 1
7412267843Sdelphij	  minor_current=$func_arith_result
7413267843Sdelphij	  xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
7414267843Sdelphij	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
7415267843Sdelphij	  ;;
7416267843Sdelphij
7417267843Sdelphij	freebsd-aout)
7418267843Sdelphij	  major=".$current"
7419267843Sdelphij	  versuffix=".$current.$revision";
7420267843Sdelphij	  ;;
7421267843Sdelphij
7422267843Sdelphij	freebsd-elf)
7423267843Sdelphij	  major=".$current"
7424267843Sdelphij	  versuffix=".$current"
7425267843Sdelphij	  ;;
7426267843Sdelphij
7427267843Sdelphij	irix | nonstopux)
7428267843Sdelphij	  if test "X$lt_irix_increment" = "Xno"; then
7429267843Sdelphij	    func_arith $current - $age
7430267843Sdelphij	  else
7431267843Sdelphij	    func_arith $current - $age + 1
7432267843Sdelphij	  fi
7433267843Sdelphij	  major=$func_arith_result
7434267843Sdelphij
7435267843Sdelphij	  case $version_type in
7436267843Sdelphij	    nonstopux) verstring_prefix=nonstopux ;;
7437267843Sdelphij	    *)         verstring_prefix=sgi ;;
7438267843Sdelphij	  esac
7439267843Sdelphij	  verstring="$verstring_prefix$major.$revision"
7440267843Sdelphij
7441267843Sdelphij	  # Add in all the interfaces that we are compatible with.
7442267843Sdelphij	  loop=$revision
7443267843Sdelphij	  while test "$loop" -ne 0; do
7444267843Sdelphij	    func_arith $revision - $loop
7445267843Sdelphij	    iface=$func_arith_result
7446267843Sdelphij	    func_arith $loop - 1
7447267843Sdelphij	    loop=$func_arith_result
7448267843Sdelphij	    verstring="$verstring_prefix$major.$iface:$verstring"
7449267843Sdelphij	  done
7450267843Sdelphij
7451267843Sdelphij	  # Before this point, $major must not contain `.'.
7452267843Sdelphij	  major=.$major
7453267843Sdelphij	  versuffix="$major.$revision"
7454267843Sdelphij	  ;;
7455267843Sdelphij
7456267843Sdelphij	linux) # correct to gnu/linux during the next big refactor
7457267843Sdelphij	  func_arith $current - $age
7458267843Sdelphij	  major=.$func_arith_result
7459267843Sdelphij	  versuffix="$major.$age.$revision"
7460267843Sdelphij	  versuffix2="$major.$age"
7461267843Sdelphij	  ;;
7462267843Sdelphij
7463267843Sdelphij	osf)
7464267843Sdelphij	  func_arith $current - $age
7465267843Sdelphij	  major=.$func_arith_result
7466267843Sdelphij	  versuffix=".$current.$age.$revision"
7467267843Sdelphij	  verstring="$current.$age.$revision"
7468267843Sdelphij
7469267843Sdelphij	  # Add in all the interfaces that we are compatible with.
7470267843Sdelphij	  loop=$age
7471267843Sdelphij	  while test "$loop" -ne 0; do
7472267843Sdelphij	    func_arith $current - $loop
7473267843Sdelphij	    iface=$func_arith_result
7474267843Sdelphij	    func_arith $loop - 1
7475267843Sdelphij	    loop=$func_arith_result
7476267843Sdelphij	    verstring="$verstring:${iface}.0"
7477267843Sdelphij	  done
7478267843Sdelphij
7479267843Sdelphij	  # Make executables depend on our current version.
7480267843Sdelphij	  func_append verstring ":${current}.0"
7481267843Sdelphij	  ;;
7482267843Sdelphij
7483267843Sdelphij	qnx)
7484267843Sdelphij	  major=".$current"
7485267843Sdelphij	  versuffix=".$current"
7486267843Sdelphij	  ;;
7487267843Sdelphij
7488267843Sdelphij	sunos)
7489267843Sdelphij	  major=".$current"
7490267843Sdelphij	  versuffix=".$current.$revision"
7491267843Sdelphij	  ;;
7492267843Sdelphij
7493267843Sdelphij	windows)
7494267843Sdelphij	  # Use '-' rather than '.', since we only want one
7495267843Sdelphij	  # extension on DOS 8.3 filesystems.
7496267843Sdelphij	  func_arith $current - $age
7497267843Sdelphij	  major=$func_arith_result
7498267843Sdelphij	  versuffix="-$major"
7499267843Sdelphij	  ;;
7500267843Sdelphij
7501267843Sdelphij	*)
7502267843Sdelphij	  func_fatal_configuration "unknown library version type \`$version_type'"
7503267843Sdelphij	  ;;
7504267843Sdelphij	esac
7505267843Sdelphij
7506267843Sdelphij	# Clear the version info if we defaulted, and they specified a release.
7507267843Sdelphij	if test -z "$vinfo" && test -n "$release"; then
7508267843Sdelphij	  major=
7509267843Sdelphij	  case $version_type in
7510267843Sdelphij	  darwin)
7511267843Sdelphij	    # we can't check for "0.0" in archive_cmds due to quoting
7512267843Sdelphij	    # problems, so we reset it completely
7513267843Sdelphij	    verstring=
7514267843Sdelphij	    ;;
7515267843Sdelphij	  *)
7516267843Sdelphij	    verstring="0.0"
7517267843Sdelphij	    ;;
7518267843Sdelphij	  esac
7519267843Sdelphij	  if test "$need_version" = no; then
7520267843Sdelphij	    versuffix=
7521267843Sdelphij	    versuffix2=
7522267843Sdelphij	  else
7523267843Sdelphij	    versuffix=".0.0"
7524267843Sdelphij	    versuffix2=".0.0"
7525267843Sdelphij	  fi
7526267843Sdelphij	fi
7527267843Sdelphij
7528267843Sdelphij	# Remove version info from name if versioning should be avoided
7529267843Sdelphij	if test "$avoid_version" = yes && test "$need_version" = no; then
7530267843Sdelphij	  major=
7531267843Sdelphij	  versuffix=
7532267843Sdelphij	  versuffix2=
7533267843Sdelphij	  verstring=""
7534267843Sdelphij	fi
7535267843Sdelphij
7536267843Sdelphij	# Check to see if the archive will have undefined symbols.
7537267843Sdelphij	if test "$allow_undefined" = yes; then
7538267843Sdelphij	  if test "$allow_undefined_flag" = unsupported; then
7539267843Sdelphij	    func_warning "undefined symbols not allowed in $host shared libraries"
7540267843Sdelphij	    build_libtool_libs=no
7541267843Sdelphij	    build_old_libs=yes
7542267843Sdelphij	  fi
7543267843Sdelphij	else
7544267843Sdelphij	  # Don't allow undefined symbols.
7545267843Sdelphij	  allow_undefined_flag="$no_undefined_flag"
7546267843Sdelphij	fi
7547267843Sdelphij
7548267843Sdelphij      fi
7549267843Sdelphij
7550267843Sdelphij      func_generate_dlsyms "$libname" "$libname" "yes"
7551267843Sdelphij      func_append libobjs " $symfileobj"
7552267843Sdelphij      test "X$libobjs" = "X " && libobjs=
7553267843Sdelphij
7554267843Sdelphij      if test "$opt_mode" != relink; then
7555267843Sdelphij	# Remove our outputs, but don't remove object files since they
7556267843Sdelphij	# may have been created when compiling PIC objects.
7557267843Sdelphij	removelist=
7558267843Sdelphij	tempremovelist=`$ECHO "$output_objdir/*"`
7559267843Sdelphij	for p in $tempremovelist; do
7560267843Sdelphij	  case $p in
7561267843Sdelphij	    *.$objext | *.gcno)
7562267843Sdelphij	       ;;
7563267843Sdelphij	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
7564267843Sdelphij	       if test "X$precious_files_regex" != "X"; then
7565267843Sdelphij		 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
7566267843Sdelphij		 then
7567267843Sdelphij		   continue
7568267843Sdelphij		 fi
7569267843Sdelphij	       fi
7570267843Sdelphij	       func_append removelist " $p"
7571267843Sdelphij	       ;;
7572267843Sdelphij	    *) ;;
7573267843Sdelphij	  esac
7574267843Sdelphij	done
7575267843Sdelphij	test -n "$removelist" && \
7576267843Sdelphij	  func_show_eval "${RM}r \$removelist"
7577267843Sdelphij      fi
7578267843Sdelphij
7579267843Sdelphij      # Now set the variables for building old libraries.
7580267843Sdelphij      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
7581267843Sdelphij	func_append oldlibs " $output_objdir/$libname.$libext"
7582267843Sdelphij
7583267843Sdelphij	# Transform .lo files to .o files.
7584267843Sdelphij	oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP`
7585267843Sdelphij      fi
7586267843Sdelphij
7587267843Sdelphij      # Eliminate all temporary directories.
7588267843Sdelphij      #for path in $notinst_path; do
7589267843Sdelphij      #	lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
7590267843Sdelphij      #	deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
7591267843Sdelphij      #	dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
7592267843Sdelphij      #done
7593267843Sdelphij
7594267843Sdelphij      if test -n "$xrpath"; then
7595267843Sdelphij	# If the user specified any rpath flags, then add them.
7596267843Sdelphij	temp_xrpath=
7597267843Sdelphij	for libdir in $xrpath; do
7598267843Sdelphij	  func_replace_sysroot "$libdir"
7599267843Sdelphij	  func_append temp_xrpath " -R$func_replace_sysroot_result"
7600267843Sdelphij	  case "$finalize_rpath " in
7601267843Sdelphij	  *" $libdir "*) ;;
7602267843Sdelphij	  *) func_append finalize_rpath " $libdir" ;;
7603267843Sdelphij	  esac
7604267843Sdelphij	done
7605267843Sdelphij	if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
7606267843Sdelphij	  dependency_libs="$temp_xrpath $dependency_libs"
7607267843Sdelphij	fi
7608267843Sdelphij      fi
7609267843Sdelphij
7610267843Sdelphij      # Make sure dlfiles contains only unique files that won't be dlpreopened
7611267843Sdelphij      old_dlfiles="$dlfiles"
7612267843Sdelphij      dlfiles=
7613267843Sdelphij      for lib in $old_dlfiles; do
7614267843Sdelphij	case " $dlprefiles $dlfiles " in
7615267843Sdelphij	*" $lib "*) ;;
7616267843Sdelphij	*) func_append dlfiles " $lib" ;;
7617267843Sdelphij	esac
7618267843Sdelphij      done
7619267843Sdelphij
7620267843Sdelphij      # Make sure dlprefiles contains only unique files
7621267843Sdelphij      old_dlprefiles="$dlprefiles"
7622267843Sdelphij      dlprefiles=
7623267843Sdelphij      for lib in $old_dlprefiles; do
7624267843Sdelphij	case "$dlprefiles " in
7625267843Sdelphij	*" $lib "*) ;;
7626267843Sdelphij	*) func_append dlprefiles " $lib" ;;
7627267843Sdelphij	esac
7628267843Sdelphij      done
7629267843Sdelphij
7630267843Sdelphij      if test "$build_libtool_libs" = yes; then
7631267843Sdelphij	if test -n "$rpath"; then
7632267843Sdelphij	  case $host in
7633267843Sdelphij	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
7634267843Sdelphij	    # these systems don't actually have a c library (as such)!
7635267843Sdelphij	    ;;
7636267843Sdelphij	  *-*-rhapsody* | *-*-darwin1.[012])
7637267843Sdelphij	    # Rhapsody C library is in the System framework
7638267843Sdelphij	    func_append deplibs " System.ltframework"
7639267843Sdelphij	    ;;
7640267843Sdelphij	  *-*-netbsd*)
7641267843Sdelphij	    # Don't link with libc until the a.out ld.so is fixed.
7642267843Sdelphij	    ;;
7643267843Sdelphij	  *-*-openbsd* | *-*-mirbsd* | *-*-freebsd* | *-*-dragonfly*)
7644267843Sdelphij	    # Do not include libc due to us having libc/libc_r.
7645267843Sdelphij	    ;;
7646267843Sdelphij	  *-*-sco3.2v5* | *-*-sco5v6*)
7647267843Sdelphij	    # Causes problems with __ctype
7648267843Sdelphij	    ;;
7649267843Sdelphij	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
7650267843Sdelphij	    # Compiler inserts libc in the correct place for threads to work
7651267843Sdelphij	    ;;
7652267843Sdelphij	  *)
7653267843Sdelphij	    # Add libc to deplibs on all other systems if necessary.
7654267843Sdelphij	    if test "$build_libtool_need_lc" = "yes"; then
7655267843Sdelphij	      func_append deplibs " -lc"
7656267843Sdelphij	    fi
7657267843Sdelphij	    ;;
7658267843Sdelphij	  esac
7659267843Sdelphij	fi
7660267843Sdelphij
7661267843Sdelphij	# Transform deplibs into only deplibs that can be linked in shared.
7662267843Sdelphij	name_save=$name
7663267843Sdelphij	libname_save=$libname
7664267843Sdelphij	release_save=$release
7665267843Sdelphij	versuffix_save=$versuffix
7666267843Sdelphij	versuffix2_save=$versuffix2
7667267843Sdelphij	major_save=$major
7668267843Sdelphij	# I'm not sure if I'm treating the release correctly.  I think
7669267843Sdelphij	# release should show up in the -l (ie -lgmp5) so we don't want to
7670267843Sdelphij	# add it in twice.  Is that correct?
7671267843Sdelphij	release=""
7672267843Sdelphij	versuffix=""
7673267843Sdelphij	versuffix2=""
7674267843Sdelphij	major=""
7675267843Sdelphij	newdeplibs=
7676267843Sdelphij	droppeddeps=no
7677267843Sdelphij	case $deplibs_check_method in
7678267843Sdelphij	pass_all)
7679267843Sdelphij	  # Don't check for shared/static.  Everything works.
7680267843Sdelphij	  # This might be a little naive.  We might want to check
7681267843Sdelphij	  # whether the library exists or not.  But this is on
7682267843Sdelphij	  # osf3 & osf4 and I'm not really sure... Just
7683267843Sdelphij	  # implementing what was already the behavior.
7684267843Sdelphij	  newdeplibs=$deplibs
7685267843Sdelphij	  ;;
7686267843Sdelphij	test_compile)
7687267843Sdelphij	  # This code stresses the "libraries are programs" paradigm to its
7688267843Sdelphij	  # limits. Maybe even breaks it.  We compile a program, linking it
7689267843Sdelphij	  # against the deplibs as a proxy for the library.  Then we can check
7690267843Sdelphij	  # whether they linked in statically or dynamically with ldd.
7691267843Sdelphij	  $opt_dry_run || $RM conftest.c
7692267843Sdelphij	  cat > conftest.c <<EOF
7693267843Sdelphij	  int main() { return 0; }
7694267843SdelphijEOF
7695267843Sdelphij	  $opt_dry_run || $RM conftest
7696267843Sdelphij	  if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
7697267843Sdelphij	    ldd_output=`ldd conftest`
7698267843Sdelphij	    for i in $deplibs; do
7699267843Sdelphij	      case $i in
7700267843Sdelphij	      -l*)
7701267843Sdelphij		func_stripname -l '' "$i"
7702267843Sdelphij		name=$func_stripname_result
7703267843Sdelphij		if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7704267843Sdelphij		  case " $predeps $postdeps " in
7705267843Sdelphij		  *" $i "*)
7706267843Sdelphij		    func_append newdeplibs " $i"
7707267843Sdelphij		    i=""
7708267843Sdelphij		    ;;
7709267843Sdelphij		  esac
7710267843Sdelphij		fi
7711267843Sdelphij		if test -n "$i" ; then
7712267843Sdelphij		  libname=`eval "\\$ECHO \"$libname_spec\""`
7713267843Sdelphij		  deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
7714267843Sdelphij		  set dummy $deplib_matches; shift
7715267843Sdelphij		  deplib_match=$1
7716267843Sdelphij		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
7717267843Sdelphij		    func_append newdeplibs " $i"
7718267843Sdelphij		  else
7719267843Sdelphij		    droppeddeps=yes
7720267843Sdelphij		    echo
7721267843Sdelphij		    $ECHO "*** Warning: dynamic linker does not accept needed library $i."
7722267843Sdelphij		    echo "*** I have the capability to make that library automatically link in when"
7723267843Sdelphij		    echo "*** you link to this library.  But I can only do this if you have a"
7724267843Sdelphij		    echo "*** shared version of the library, which I believe you do not have"
7725267843Sdelphij		    echo "*** because a test_compile did reveal that the linker did not use it for"
7726267843Sdelphij		    echo "*** its dynamic dependency list that programs get resolved with at runtime."
7727267843Sdelphij		  fi
7728267843Sdelphij		fi
7729267843Sdelphij		;;
7730267843Sdelphij	      *)
7731267843Sdelphij		func_append newdeplibs " $i"
7732267843Sdelphij		;;
7733267843Sdelphij	      esac
7734267843Sdelphij	    done
7735267843Sdelphij	  else
7736267843Sdelphij	    # Error occurred in the first compile.  Let's try to salvage
7737267843Sdelphij	    # the situation: Compile a separate program for each library.
7738267843Sdelphij	    for i in $deplibs; do
7739267843Sdelphij	      case $i in
7740267843Sdelphij	      -l*)
7741267843Sdelphij		func_stripname -l '' "$i"
7742267843Sdelphij		name=$func_stripname_result
7743267843Sdelphij		$opt_dry_run || $RM conftest
7744267843Sdelphij		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
7745267843Sdelphij		  ldd_output=`ldd conftest`
7746267843Sdelphij		  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7747267843Sdelphij		    case " $predeps $postdeps " in
7748267843Sdelphij		    *" $i "*)
7749267843Sdelphij		      func_append newdeplibs " $i"
7750267843Sdelphij		      i=""
7751267843Sdelphij		      ;;
7752267843Sdelphij		    esac
7753267843Sdelphij		  fi
7754267843Sdelphij		  if test -n "$i" ; then
7755267843Sdelphij		    libname=`eval "\\$ECHO \"$libname_spec\""`
7756267843Sdelphij		    deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
7757267843Sdelphij		    set dummy $deplib_matches; shift
7758267843Sdelphij		    deplib_match=$1
7759267843Sdelphij		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
7760267843Sdelphij		      func_append newdeplibs " $i"
7761267843Sdelphij		    else
7762267843Sdelphij		      droppeddeps=yes
7763267843Sdelphij		      echo
7764267843Sdelphij		      $ECHO "*** Warning: dynamic linker does not accept needed library $i."
7765267843Sdelphij		      echo "*** I have the capability to make that library automatically link in when"
7766267843Sdelphij		      echo "*** you link to this library.  But I can only do this if you have a"
7767267843Sdelphij		      echo "*** shared version of the library, which you do not appear to have"
7768267843Sdelphij		      echo "*** because a test_compile did reveal that the linker did not use this one"
7769267843Sdelphij		      echo "*** as a dynamic dependency that programs can get resolved with at runtime."
7770267843Sdelphij		    fi
7771267843Sdelphij		  fi
7772267843Sdelphij		else
7773267843Sdelphij		  droppeddeps=yes
7774267843Sdelphij		  echo
7775267843Sdelphij		  $ECHO "*** Warning!  Library $i is needed by this library but I was not able to"
7776267843Sdelphij		  echo "*** make it link in!  You will probably need to install it or some"
7777267843Sdelphij		  echo "*** library that it depends on before this library will be fully"
7778267843Sdelphij		  echo "*** functional.  Installing it before continuing would be even better."
7779267843Sdelphij		fi
7780267843Sdelphij		;;
7781267843Sdelphij	      *)
7782267843Sdelphij		func_append newdeplibs " $i"
7783267843Sdelphij		;;
7784267843Sdelphij	      esac
7785267843Sdelphij	    done
7786267843Sdelphij	  fi
7787267843Sdelphij	  ;;
7788267843Sdelphij	file_magic*)
7789267843Sdelphij	  set dummy $deplibs_check_method; shift
7790267843Sdelphij	  file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
7791267843Sdelphij	  for a_deplib in $deplibs; do
7792267843Sdelphij	    case $a_deplib in
7793267843Sdelphij	    -l*)
7794267843Sdelphij	      func_stripname -l '' "$a_deplib"
7795267843Sdelphij	      name=$func_stripname_result
7796267843Sdelphij	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7797267843Sdelphij		case " $predeps $postdeps " in
7798267843Sdelphij		*" $a_deplib "*)
7799267843Sdelphij		  func_append newdeplibs " $a_deplib"
7800267843Sdelphij		  a_deplib=""
7801267843Sdelphij		  ;;
7802267843Sdelphij		esac
7803267843Sdelphij	      fi
7804267843Sdelphij	      if test -n "$a_deplib" ; then
7805267843Sdelphij		libname=`eval "\\$ECHO \"$libname_spec\""`
7806267843Sdelphij		if test -n "$file_magic_glob"; then
7807267843Sdelphij		  libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob`
7808267843Sdelphij		else
7809267843Sdelphij		  libnameglob=$libname
7810267843Sdelphij		fi
7811267843Sdelphij		test "$want_nocaseglob" = yes && nocaseglob=`shopt -p nocaseglob`
7812267843Sdelphij		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
7813267843Sdelphij		  if test "$want_nocaseglob" = yes; then
7814267843Sdelphij		    shopt -s nocaseglob
7815267843Sdelphij		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
7816267843Sdelphij		    $nocaseglob
7817267843Sdelphij		  else
7818267843Sdelphij		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
7819267843Sdelphij		  fi
7820267843Sdelphij		  for potent_lib in $potential_libs; do
7821267843Sdelphij		      # Follow soft links.
7822267843Sdelphij		      if ls -lLd "$potent_lib" 2>/dev/null |
7823267843Sdelphij			 $GREP " -> " >/dev/null; then
7824267843Sdelphij			continue
7825267843Sdelphij		      fi
7826267843Sdelphij		      # The statement above tries to avoid entering an
7827267843Sdelphij		      # endless loop below, in case of cyclic links.
7828267843Sdelphij		      # We might still enter an endless loop, since a link
7829267843Sdelphij		      # loop can be closed while we follow links,
7830267843Sdelphij		      # but so what?
7831267843Sdelphij		      potlib="$potent_lib"
7832267843Sdelphij		      while test -h "$potlib" 2>/dev/null; do
7833267843Sdelphij			potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
7834267843Sdelphij			case $potliblink in
7835267843Sdelphij			[\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
7836267843Sdelphij			*) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";;
7837267843Sdelphij			esac
7838267843Sdelphij		      done
7839267843Sdelphij		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
7840267843Sdelphij			 $SED -e 10q |
7841267843Sdelphij			 $EGREP "$file_magic_regex" > /dev/null; then
7842267843Sdelphij			func_append newdeplibs " $a_deplib"
7843267843Sdelphij			a_deplib=""
7844267843Sdelphij			break 2
7845267843Sdelphij		      fi
7846267843Sdelphij		  done
7847267843Sdelphij		done
7848267843Sdelphij	      fi
7849267843Sdelphij	      if test -n "$a_deplib" ; then
7850267843Sdelphij		droppeddeps=yes
7851267843Sdelphij		echo
7852267843Sdelphij		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
7853267843Sdelphij		echo "*** I have the capability to make that library automatically link in when"
7854267843Sdelphij		echo "*** you link to this library.  But I can only do this if you have a"
7855267843Sdelphij		echo "*** shared version of the library, which you do not appear to have"
7856267843Sdelphij		echo "*** because I did check the linker path looking for a file starting"
7857267843Sdelphij		if test -z "$potlib" ; then
7858267843Sdelphij		  $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
7859267843Sdelphij		else
7860267843Sdelphij		  $ECHO "*** with $libname and none of the candidates passed a file format test"
7861267843Sdelphij		  $ECHO "*** using a file magic. Last file checked: $potlib"
7862267843Sdelphij		fi
7863267843Sdelphij	      fi
7864267843Sdelphij	      ;;
7865267843Sdelphij	    *)
7866267843Sdelphij	      # Add a -L argument.
7867267843Sdelphij	      func_append newdeplibs " $a_deplib"
7868267843Sdelphij	      ;;
7869267843Sdelphij	    esac
7870267843Sdelphij	  done # Gone through all deplibs.
7871267843Sdelphij	  ;;
7872267843Sdelphij	match_pattern*)
7873267843Sdelphij	  set dummy $deplibs_check_method; shift
7874267843Sdelphij	  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
7875267843Sdelphij	  for a_deplib in $deplibs; do
7876267843Sdelphij	    case $a_deplib in
7877267843Sdelphij	    -l*)
7878267843Sdelphij	      func_stripname -l '' "$a_deplib"
7879267843Sdelphij	      name=$func_stripname_result
7880267843Sdelphij	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7881267843Sdelphij		case " $predeps $postdeps " in
7882267843Sdelphij		*" $a_deplib "*)
7883267843Sdelphij		  func_append newdeplibs " $a_deplib"
7884267843Sdelphij		  a_deplib=""
7885267843Sdelphij		  ;;
7886267843Sdelphij		esac
7887267843Sdelphij	      fi
7888267843Sdelphij	      if test -n "$a_deplib" ; then
7889267843Sdelphij		libname=`eval "\\$ECHO \"$libname_spec\""`
7890267843Sdelphij		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
7891267843Sdelphij		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
7892267843Sdelphij		  for potent_lib in $potential_libs; do
7893267843Sdelphij		    potlib="$potent_lib" # see symlink-check above in file_magic test
7894267843Sdelphij		    if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
7895267843Sdelphij		       $EGREP "$match_pattern_regex" > /dev/null; then
7896267843Sdelphij		      func_append newdeplibs " $a_deplib"
7897267843Sdelphij		      a_deplib=""
7898267843Sdelphij		      break 2
7899267843Sdelphij		    fi
7900267843Sdelphij		  done
7901267843Sdelphij		done
7902267843Sdelphij	      fi
7903267843Sdelphij	      if test -n "$a_deplib" ; then
7904267843Sdelphij		droppeddeps=yes
7905267843Sdelphij		echo
7906267843Sdelphij		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
7907267843Sdelphij		echo "*** I have the capability to make that library automatically link in when"
7908267843Sdelphij		echo "*** you link to this library.  But I can only do this if you have a"
7909267843Sdelphij		echo "*** shared version of the library, which you do not appear to have"
7910267843Sdelphij		echo "*** because I did check the linker path looking for a file starting"
7911267843Sdelphij		if test -z "$potlib" ; then
7912267843Sdelphij		  $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
7913267843Sdelphij		else
7914267843Sdelphij		  $ECHO "*** with $libname and none of the candidates passed a file format test"
7915267843Sdelphij		  $ECHO "*** using a regex pattern. Last file checked: $potlib"
7916267843Sdelphij		fi
7917267843Sdelphij	      fi
7918267843Sdelphij	      ;;
7919267843Sdelphij	    *)
7920267843Sdelphij	      # Add a -L argument.
7921267843Sdelphij	      func_append newdeplibs " $a_deplib"
7922267843Sdelphij	      ;;
7923267843Sdelphij	    esac
7924267843Sdelphij	  done # Gone through all deplibs.
7925267843Sdelphij	  ;;
7926267843Sdelphij	none | unknown | *)
7927267843Sdelphij	  newdeplibs=""
7928267843Sdelphij	  tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
7929267843Sdelphij	  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7930267843Sdelphij	    for i in $predeps $postdeps ; do
7931267843Sdelphij	      # can't use Xsed below, because $i might contain '/'
7932267843Sdelphij	      tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"`
7933267843Sdelphij	    done
7934267843Sdelphij	  fi
7935267843Sdelphij	  case $tmp_deplibs in
7936267843Sdelphij	  *[!\	\ ]*)
7937267843Sdelphij	    echo
7938267843Sdelphij	    if test "X$deplibs_check_method" = "Xnone"; then
7939267843Sdelphij	      echo "*** Warning: inter-library dependencies are not supported in this platform."
7940267843Sdelphij	    else
7941267843Sdelphij	      echo "*** Warning: inter-library dependencies are not known to be supported."
7942267843Sdelphij	    fi
7943267843Sdelphij	    echo "*** All declared inter-library dependencies are being dropped."
7944267843Sdelphij	    droppeddeps=yes
7945267843Sdelphij	    ;;
7946267843Sdelphij	  esac
7947267843Sdelphij	  ;;
7948267843Sdelphij	esac
7949267843Sdelphij	versuffix=$versuffix_save
7950267843Sdelphij	versuffix2=$versuffix2_save
7951267843Sdelphij	major=$major_save
7952267843Sdelphij	release=$release_save
7953267843Sdelphij	libname=$libname_save
7954267843Sdelphij	name=$name_save
7955267843Sdelphij
7956267843Sdelphij	case $host in
7957267843Sdelphij	*-*-rhapsody* | *-*-darwin1.[012])
7958267843Sdelphij	  # On Rhapsody replace the C library with the System framework
7959267843Sdelphij	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
7960267843Sdelphij	  ;;
7961267843Sdelphij	esac
7962267843Sdelphij
7963267843Sdelphij	if test "$droppeddeps" = yes; then
7964267843Sdelphij	  if test "$module" = yes; then
7965267843Sdelphij	    echo
7966267843Sdelphij	    echo "*** Warning: libtool could not satisfy all declared inter-library"
7967267843Sdelphij	    $ECHO "*** dependencies of module $libname.  Therefore, libtool will create"
7968267843Sdelphij	    echo "*** a static module, that should work as long as the dlopening"
7969267843Sdelphij	    echo "*** application is linked with the -dlopen flag."
7970267843Sdelphij	    if test -z "$global_symbol_pipe"; then
7971267843Sdelphij	      echo
7972267843Sdelphij	      echo "*** However, this would only work if libtool was able to extract symbol"
7973267843Sdelphij	      echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
7974267843Sdelphij	      echo "*** not find such a program.  So, this module is probably useless."
7975267843Sdelphij	      echo "*** \`nm' from GNU binutils and a full rebuild may help."
7976267843Sdelphij	    fi
7977267843Sdelphij	    if test "$build_old_libs" = no; then
7978267843Sdelphij	      oldlibs="$output_objdir/$libname.$libext"
7979267843Sdelphij	      build_libtool_libs=module
7980267843Sdelphij	      build_old_libs=yes
7981267843Sdelphij	    else
7982267843Sdelphij	      build_libtool_libs=no
7983267843Sdelphij	    fi
7984267843Sdelphij	  else
7985267843Sdelphij	    echo "*** The inter-library dependencies that have been dropped here will be"
7986267843Sdelphij	    echo "*** automatically added whenever a program is linked with this library"
7987267843Sdelphij	    echo "*** or is declared to -dlopen it."
7988267843Sdelphij
7989267843Sdelphij	    if test "$allow_undefined" = no; then
7990267843Sdelphij	      echo
7991267843Sdelphij	      echo "*** Since this library must not contain undefined symbols,"
7992267843Sdelphij	      echo "*** because either the platform does not support them or"
7993267843Sdelphij	      echo "*** it was explicitly requested with -no-undefined,"
7994267843Sdelphij	      echo "*** libtool will only create a static version of it."
7995267843Sdelphij	      if test "$build_old_libs" = no; then
7996267843Sdelphij		oldlibs="$output_objdir/$libname.$libext"
7997267843Sdelphij		build_libtool_libs=module
7998267843Sdelphij		build_old_libs=yes
7999267843Sdelphij	      else
8000267843Sdelphij		build_libtool_libs=no
8001267843Sdelphij	      fi
8002267843Sdelphij	    fi
8003267843Sdelphij	  fi
8004267843Sdelphij	fi
8005267843Sdelphij	# Done checking deplibs!
8006267843Sdelphij	deplibs=$newdeplibs
8007267843Sdelphij      fi
8008267843Sdelphij      # Time to change all our "foo.ltframework" stuff back to "-framework foo"
8009267843Sdelphij      case $host in
8010267843Sdelphij	*-*-darwin*)
8011267843Sdelphij	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8012267843Sdelphij	  new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8013267843Sdelphij	  deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8014267843Sdelphij	  ;;
8015267843Sdelphij      esac
8016267843Sdelphij
8017267843Sdelphij      # move library search paths that coincide with paths to not yet
8018267843Sdelphij      # installed libraries to the beginning of the library search list
8019267843Sdelphij      new_libs=
8020267843Sdelphij      for path in $notinst_path; do
8021267843Sdelphij	case " $new_libs " in
8022267843Sdelphij	*" -L$path/$objdir "*) ;;
8023267843Sdelphij	*)
8024267843Sdelphij	  case " $deplibs " in
8025267843Sdelphij	  *" -L$path/$objdir "*)
8026267843Sdelphij	    func_append new_libs " -L$path/$objdir" ;;
8027267843Sdelphij	  esac
8028267843Sdelphij	  ;;
8029267843Sdelphij	esac
8030267843Sdelphij      done
8031267843Sdelphij      for deplib in $deplibs; do
8032267843Sdelphij	case $deplib in
8033267843Sdelphij	-L*)
8034267843Sdelphij	  case " $new_libs " in
8035267843Sdelphij	  *" $deplib "*) ;;
8036267843Sdelphij	  *) func_append new_libs " $deplib" ;;
8037267843Sdelphij	  esac
8038267843Sdelphij	  ;;
8039267843Sdelphij	*) func_append new_libs " $deplib" ;;
8040267843Sdelphij	esac
8041267843Sdelphij      done
8042267843Sdelphij      deplibs="$new_libs"
8043267843Sdelphij
8044267843Sdelphij      # All the library-specific variables (install_libdir is set above).
8045267843Sdelphij      library_names=
8046267843Sdelphij      old_library=
8047267843Sdelphij      dlname=
8048267843Sdelphij
8049267843Sdelphij      # Test again, we may have decided not to build it any more
8050267843Sdelphij      if test "$build_libtool_libs" = yes; then
8051267843Sdelphij	# Remove ${wl} instances when linking with ld.
8052267843Sdelphij	# FIXME: should test the right _cmds variable.
8053267843Sdelphij	case $archive_cmds in
8054267843Sdelphij	  *\$LD\ *) wl= ;;
8055267843Sdelphij        esac
8056267843Sdelphij	if test "$hardcode_into_libs" = yes; then
8057267843Sdelphij	  # Hardcode the library paths
8058267843Sdelphij	  hardcode_libdirs=
8059267843Sdelphij	  dep_rpath=
8060267843Sdelphij	  rpath="$finalize_rpath"
8061267843Sdelphij	  test "$opt_mode" != relink && rpath="$compile_rpath$rpath"
8062267843Sdelphij	  for libdir in $rpath; do
8063267843Sdelphij	    if test -n "$hardcode_libdir_flag_spec"; then
8064267843Sdelphij	      if test -n "$hardcode_libdir_separator"; then
8065267843Sdelphij		func_replace_sysroot "$libdir"
8066267843Sdelphij		libdir=$func_replace_sysroot_result
8067267843Sdelphij		if test -z "$hardcode_libdirs"; then
8068267843Sdelphij		  hardcode_libdirs="$libdir"
8069267843Sdelphij		else
8070267843Sdelphij		  # Just accumulate the unique libdirs.
8071267843Sdelphij		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
8072267843Sdelphij		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
8073267843Sdelphij		    ;;
8074267843Sdelphij		  *)
8075267843Sdelphij		    func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
8076267843Sdelphij		    ;;
8077267843Sdelphij		  esac
8078267843Sdelphij		fi
8079267843Sdelphij	      else
8080267843Sdelphij		eval flag=\"$hardcode_libdir_flag_spec\"
8081267843Sdelphij		func_append dep_rpath " $flag"
8082267843Sdelphij	      fi
8083267843Sdelphij	    elif test -n "$runpath_var"; then
8084267843Sdelphij	      case "$perm_rpath " in
8085267843Sdelphij	      *" $libdir "*) ;;
8086267843Sdelphij	      *) func_append perm_rpath " $libdir" ;;
8087267843Sdelphij	      esac
8088267843Sdelphij	    fi
8089267843Sdelphij	  done
8090267843Sdelphij	  # Substitute the hardcoded libdirs into the rpath.
8091267843Sdelphij	  if test -n "$hardcode_libdir_separator" &&
8092267843Sdelphij	     test -n "$hardcode_libdirs"; then
8093267843Sdelphij	    libdir="$hardcode_libdirs"
8094267843Sdelphij	    eval "dep_rpath=\"$hardcode_libdir_flag_spec\""
8095267843Sdelphij	  fi
8096267843Sdelphij	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
8097267843Sdelphij	    # We should set the runpath_var.
8098267843Sdelphij	    rpath=
8099267843Sdelphij	    for dir in $perm_rpath; do
8100267843Sdelphij	      func_append rpath "$dir:"
8101267843Sdelphij	    done
8102267843Sdelphij	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
8103267843Sdelphij	  fi
8104267843Sdelphij	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
8105267843Sdelphij	fi
8106267843Sdelphij
8107267843Sdelphij	shlibpath="$finalize_shlibpath"
8108267843Sdelphij	test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
8109267843Sdelphij	if test -n "$shlibpath"; then
8110267843Sdelphij	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
8111267843Sdelphij	fi
8112267843Sdelphij
8113267843Sdelphij	# Get the real and link names of the library.
8114267843Sdelphij	eval shared_ext=\"$shrext_cmds\"
8115267843Sdelphij	eval library_names=\"$library_names_spec\"
8116267843Sdelphij	set dummy $library_names
8117267843Sdelphij	shift
8118267843Sdelphij	realname="$1"
8119267843Sdelphij	shift
8120267843Sdelphij
8121267843Sdelphij	if test -n "$soname_spec"; then
8122267843Sdelphij	  eval soname=\"$soname_spec\"
8123267843Sdelphij	else
8124267843Sdelphij	  soname="$realname"
8125267843Sdelphij	fi
8126267843Sdelphij	if test -z "$dlname"; then
8127267843Sdelphij	  dlname=$soname
8128267843Sdelphij	fi
8129267843Sdelphij
8130267843Sdelphij	lib="$output_objdir/$realname"
8131267843Sdelphij	linknames=
8132267843Sdelphij	for link
8133267843Sdelphij	do
8134267843Sdelphij	  func_append linknames " $link"
8135267843Sdelphij	done
8136267843Sdelphij
8137267843Sdelphij	# Use standard objects if they are pic
8138267843Sdelphij	test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
8139267843Sdelphij	test "X$libobjs" = "X " && libobjs=
8140267843Sdelphij
8141267843Sdelphij	delfiles=
8142267843Sdelphij	if test -n "$export_symbols" && test -n "$include_expsyms"; then
8143267843Sdelphij	  $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
8144267843Sdelphij	  export_symbols="$output_objdir/$libname.uexp"
8145267843Sdelphij	  func_append delfiles " $export_symbols"
8146267843Sdelphij	fi
8147267843Sdelphij
8148267843Sdelphij	orig_export_symbols=
8149267843Sdelphij	case $host_os in
8150267843Sdelphij	cygwin* | mingw* | cegcc*)
8151267843Sdelphij	  if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
8152267843Sdelphij	    # exporting using user supplied symfile
8153267843Sdelphij	    if test "x`$SED 1q $export_symbols`" != xEXPORTS; then
8154267843Sdelphij	      # and it's NOT already a .def file. Must figure out
8155267843Sdelphij	      # which of the given symbols are data symbols and tag
8156267843Sdelphij	      # them as such. So, trigger use of export_symbols_cmds.
8157267843Sdelphij	      # export_symbols gets reassigned inside the "prepare
8158267843Sdelphij	      # the list of exported symbols" if statement, so the
8159267843Sdelphij	      # include_expsyms logic still works.
8160267843Sdelphij	      orig_export_symbols="$export_symbols"
8161267843Sdelphij	      export_symbols=
8162267843Sdelphij	      always_export_symbols=yes
8163267843Sdelphij	    fi
8164267843Sdelphij	  fi
8165267843Sdelphij	  ;;
8166267843Sdelphij	esac
8167267843Sdelphij
8168267843Sdelphij	# Prepare the list of exported symbols
8169267843Sdelphij	if test -z "$export_symbols"; then
8170267843Sdelphij	  if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
8171267843Sdelphij	    func_verbose "generating symbol list for \`$libname.la'"
8172267843Sdelphij	    export_symbols="$output_objdir/$libname.exp"
8173267843Sdelphij	    $opt_dry_run || $RM $export_symbols
8174267843Sdelphij	    cmds=$export_symbols_cmds
8175267843Sdelphij	    save_ifs="$IFS"; IFS='~'
8176267843Sdelphij	    for cmd1 in $cmds; do
8177267843Sdelphij	      IFS="$save_ifs"
8178267843Sdelphij	      # Take the normal branch if the nm_file_list_spec branch
8179267843Sdelphij	      # doesn't work or if tool conversion is not needed.
8180267843Sdelphij	      case $nm_file_list_spec~$to_tool_file_cmd in
8181267843Sdelphij		*~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*)
8182267843Sdelphij		  try_normal_branch=yes
8183267843Sdelphij		  eval cmd=\"$cmd1\"
8184267843Sdelphij		  func_len " $cmd"
8185267843Sdelphij		  len=$func_len_result
8186267843Sdelphij		  ;;
8187267843Sdelphij		*)
8188267843Sdelphij		  try_normal_branch=no
8189267843Sdelphij		  ;;
8190267843Sdelphij	      esac
8191267843Sdelphij	      if test "$try_normal_branch" = yes \
8192267843Sdelphij		 && { test "$len" -lt "$max_cmd_len" \
8193267843Sdelphij		      || test "$max_cmd_len" -le -1; }
8194267843Sdelphij	      then
8195267843Sdelphij		func_show_eval "$cmd" 'exit $?'
8196267843Sdelphij		skipped_export=false
8197267843Sdelphij	      elif test -n "$nm_file_list_spec"; then
8198267843Sdelphij		func_basename "$output"
8199267843Sdelphij		output_la=$func_basename_result
8200267843Sdelphij		save_libobjs=$libobjs
8201267843Sdelphij		save_output=$output
8202267843Sdelphij		output=${output_objdir}/${output_la}.nm
8203267843Sdelphij		func_to_tool_file "$output"
8204267843Sdelphij		libobjs=$nm_file_list_spec$func_to_tool_file_result
8205267843Sdelphij		func_append delfiles " $output"
8206267843Sdelphij		func_verbose "creating $NM input file list: $output"
8207267843Sdelphij		for obj in $save_libobjs; do
8208267843Sdelphij		  func_to_tool_file "$obj"
8209267843Sdelphij		  $ECHO "$func_to_tool_file_result"
8210267843Sdelphij		done > "$output"
8211267843Sdelphij		eval cmd=\"$cmd1\"
8212267843Sdelphij		func_show_eval "$cmd" 'exit $?'
8213267843Sdelphij		output=$save_output
8214267843Sdelphij		libobjs=$save_libobjs
8215267843Sdelphij		skipped_export=false
8216267843Sdelphij	      else
8217267843Sdelphij		# The command line is too long to execute in one step.
8218267843Sdelphij		func_verbose "using reloadable object file for export list..."
8219267843Sdelphij		skipped_export=:
8220267843Sdelphij		# Break out early, otherwise skipped_export may be
8221267843Sdelphij		# set to false by a later but shorter cmd.
8222267843Sdelphij		break
8223267843Sdelphij	      fi
8224267843Sdelphij	    done
8225267843Sdelphij	    IFS="$save_ifs"
8226267843Sdelphij	    if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then
8227267843Sdelphij	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
8228267843Sdelphij	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
8229267843Sdelphij	    fi
8230267843Sdelphij	  fi
8231267843Sdelphij	fi
8232267843Sdelphij
8233267843Sdelphij	if test -n "$export_symbols" && test -n "$include_expsyms"; then
8234267843Sdelphij	  tmp_export_symbols="$export_symbols"
8235267843Sdelphij	  test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
8236267843Sdelphij	  $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
8237267843Sdelphij	fi
8238267843Sdelphij
8239267843Sdelphij	if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then
8240267843Sdelphij	  # The given exports_symbols file has to be filtered, so filter it.
8241267843Sdelphij	  func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
8242267843Sdelphij	  # FIXME: $output_objdir/$libname.filter potentially contains lots of
8243267843Sdelphij	  # 's' commands which not all seds can handle. GNU sed should be fine
8244267843Sdelphij	  # though. Also, the filter scales superlinearly with the number of
8245267843Sdelphij	  # global variables. join(1) would be nice here, but unfortunately
8246267843Sdelphij	  # isn't a blessed tool.
8247267843Sdelphij	  $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
8248267843Sdelphij	  func_append delfiles " $export_symbols $output_objdir/$libname.filter"
8249267843Sdelphij	  export_symbols=$output_objdir/$libname.def
8250267843Sdelphij	  $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
8251267843Sdelphij	fi
8252267843Sdelphij
8253267843Sdelphij	tmp_deplibs=
8254267843Sdelphij	for test_deplib in $deplibs; do
8255267843Sdelphij	  case " $convenience " in
8256267843Sdelphij	  *" $test_deplib "*) ;;
8257267843Sdelphij	  *)
8258267843Sdelphij	    func_append tmp_deplibs " $test_deplib"
8259267843Sdelphij	    ;;
8260267843Sdelphij	  esac
8261267843Sdelphij	done
8262267843Sdelphij	deplibs="$tmp_deplibs"
8263267843Sdelphij
8264267843Sdelphij	if test -n "$convenience"; then
8265267843Sdelphij	  if test -n "$whole_archive_flag_spec" &&
8266267843Sdelphij	    test "$compiler_needs_object" = yes &&
8267267843Sdelphij	    test -z "$libobjs"; then
8268267843Sdelphij	    # extract the archives, so we have objects to list.
8269267843Sdelphij	    # TODO: could optimize this to just extract one archive.
8270267843Sdelphij	    whole_archive_flag_spec=
8271267843Sdelphij	  fi
8272267843Sdelphij	  if test -n "$whole_archive_flag_spec"; then
8273267843Sdelphij	    save_libobjs=$libobjs
8274267843Sdelphij	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
8275267843Sdelphij	    test "X$libobjs" = "X " && libobjs=
8276267843Sdelphij	  else
8277267843Sdelphij	    gentop="$output_objdir/${outputname}x"
8278267843Sdelphij	    func_append generated " $gentop"
8279267843Sdelphij
8280267843Sdelphij	    func_extract_archives $gentop $convenience
8281267843Sdelphij	    func_append libobjs " $func_extract_archives_result"
8282267843Sdelphij	    test "X$libobjs" = "X " && libobjs=
8283267843Sdelphij	  fi
8284267843Sdelphij	fi
8285267843Sdelphij
8286267843Sdelphij	if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
8287267843Sdelphij	  eval flag=\"$thread_safe_flag_spec\"
8288267843Sdelphij	  func_append linker_flags " $flag"
8289267843Sdelphij	fi
8290267843Sdelphij
8291267843Sdelphij	# Make a backup of the uninstalled library when relinking
8292267843Sdelphij	if test "$opt_mode" = relink; then
8293267843Sdelphij	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
8294267843Sdelphij	fi
8295267843Sdelphij
8296267843Sdelphij	# Do each of the archive commands.
8297267843Sdelphij	if test "$module" = yes && test -n "$module_cmds" ; then
8298267843Sdelphij	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
8299267843Sdelphij	    eval test_cmds=\"$module_expsym_cmds\"
8300267843Sdelphij	    cmds=$module_expsym_cmds
8301267843Sdelphij	  else
8302267843Sdelphij	    eval test_cmds=\"$module_cmds\"
8303267843Sdelphij	    cmds=$module_cmds
8304267843Sdelphij	  fi
8305267843Sdelphij	else
8306267843Sdelphij	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
8307267843Sdelphij	    eval test_cmds=\"$archive_expsym_cmds\"
8308267843Sdelphij	    cmds=$archive_expsym_cmds
8309267843Sdelphij	  else
8310267843Sdelphij	    eval test_cmds=\"$archive_cmds\"
8311267843Sdelphij	    cmds=$archive_cmds
8312267843Sdelphij	  fi
8313267843Sdelphij	fi
8314267843Sdelphij
8315267843Sdelphij	if test "X$skipped_export" != "X:" &&
8316267843Sdelphij	   func_len " $test_cmds" &&
8317267843Sdelphij	   len=$func_len_result &&
8318267843Sdelphij	   test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
8319267843Sdelphij	  :
8320267843Sdelphij	else
8321267843Sdelphij	  # The command line is too long to link in one step, link piecewise
8322267843Sdelphij	  # or, if using GNU ld and skipped_export is not :, use a linker
8323267843Sdelphij	  # script.
8324267843Sdelphij
8325267843Sdelphij	  # Save the value of $output and $libobjs because we want to
8326267843Sdelphij	  # use them later.  If we have whole_archive_flag_spec, we
8327267843Sdelphij	  # want to use save_libobjs as it was before
8328267843Sdelphij	  # whole_archive_flag_spec was expanded, because we can't
8329267843Sdelphij	  # assume the linker understands whole_archive_flag_spec.
8330267843Sdelphij	  # This may have to be revisited, in case too many
8331267843Sdelphij	  # convenience libraries get linked in and end up exceeding
8332267843Sdelphij	  # the spec.
8333267843Sdelphij	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
8334267843Sdelphij	    save_libobjs=$libobjs
8335267843Sdelphij	  fi
8336267843Sdelphij	  save_output=$output
8337267843Sdelphij	  func_basename "$output"
8338267843Sdelphij	  output_la=$func_basename_result
8339267843Sdelphij
8340267843Sdelphij	  # Clear the reloadable object creation command queue and
8341267843Sdelphij	  # initialize k to one.
8342267843Sdelphij	  test_cmds=
8343267843Sdelphij	  concat_cmds=
8344267843Sdelphij	  objlist=
8345267843Sdelphij	  last_robj=
8346267843Sdelphij	  k=1
8347267843Sdelphij
8348267843Sdelphij	  if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
8349267843Sdelphij	    output=${output_objdir}/${output_la}.lnkscript
8350267843Sdelphij	    func_verbose "creating GNU ld script: $output"
8351267843Sdelphij	    echo 'INPUT (' > $output
8352267843Sdelphij	    for obj in $save_libobjs
8353267843Sdelphij	    do
8354267843Sdelphij	      func_to_tool_file "$obj"
8355267843Sdelphij	      $ECHO "$func_to_tool_file_result" >> $output
8356267843Sdelphij	    done
8357267843Sdelphij	    echo ')' >> $output
8358267843Sdelphij	    func_append delfiles " $output"
8359267843Sdelphij	    func_to_tool_file "$output"
8360267843Sdelphij	    output=$func_to_tool_file_result
8361267843Sdelphij	  elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then
8362267843Sdelphij	    output=${output_objdir}/${output_la}.lnk
8363267843Sdelphij	    func_verbose "creating linker input file list: $output"
8364267843Sdelphij	    : > $output
8365267843Sdelphij	    set x $save_libobjs
8366267843Sdelphij	    shift
8367267843Sdelphij	    firstobj=
8368267843Sdelphij	    if test "$compiler_needs_object" = yes; then
8369267843Sdelphij	      firstobj="$1 "
8370267843Sdelphij	      shift
8371267843Sdelphij	    fi
8372267843Sdelphij	    for obj
8373267843Sdelphij	    do
8374267843Sdelphij	      func_to_tool_file "$obj"
8375267843Sdelphij	      $ECHO "$func_to_tool_file_result" >> $output
8376267843Sdelphij	    done
8377267843Sdelphij	    func_append delfiles " $output"
8378267843Sdelphij	    func_to_tool_file "$output"
8379267843Sdelphij	    output=$firstobj\"$file_list_spec$func_to_tool_file_result\"
8380267843Sdelphij	  else
8381267843Sdelphij	    if test -n "$save_libobjs"; then
8382267843Sdelphij	      func_verbose "creating reloadable object files..."
8383267843Sdelphij	      output=$output_objdir/$output_la-${k}.$objext
8384267843Sdelphij	      eval test_cmds=\"$reload_cmds\"
8385267843Sdelphij	      func_len " $test_cmds"
8386267843Sdelphij	      len0=$func_len_result
8387267843Sdelphij	      len=$len0
8388267843Sdelphij
8389267843Sdelphij	      # Loop over the list of objects to be linked.
8390267843Sdelphij	      for obj in $save_libobjs
8391267843Sdelphij	      do
8392267843Sdelphij		func_len " $obj"
8393267843Sdelphij		func_arith $len + $func_len_result
8394267843Sdelphij		len=$func_arith_result
8395267843Sdelphij		if test "X$objlist" = X ||
8396267843Sdelphij		   test "$len" -lt "$max_cmd_len"; then
8397267843Sdelphij		  func_append objlist " $obj"
8398267843Sdelphij		else
8399267843Sdelphij		  # The command $test_cmds is almost too long, add a
8400267843Sdelphij		  # command to the queue.
8401267843Sdelphij		  if test "$k" -eq 1 ; then
8402267843Sdelphij		    # The first file doesn't have a previous command to add.
8403267843Sdelphij		    reload_objs=$objlist
8404267843Sdelphij		    eval concat_cmds=\"$reload_cmds\"
8405267843Sdelphij		  else
8406267843Sdelphij		    # All subsequent reloadable object files will link in
8407267843Sdelphij		    # the last one created.
8408267843Sdelphij		    reload_objs="$objlist $last_robj"
8409267843Sdelphij		    eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
8410267843Sdelphij		  fi
8411267843Sdelphij		  last_robj=$output_objdir/$output_la-${k}.$objext
8412267843Sdelphij		  func_arith $k + 1
8413267843Sdelphij		  k=$func_arith_result
8414267843Sdelphij		  output=$output_objdir/$output_la-${k}.$objext
8415267843Sdelphij		  objlist=" $obj"
8416267843Sdelphij		  func_len " $last_robj"
8417267843Sdelphij		  func_arith $len0 + $func_len_result
8418267843Sdelphij		  len=$func_arith_result
8419267843Sdelphij		fi
8420267843Sdelphij	      done
8421267843Sdelphij	      # Handle the remaining objects by creating one last
8422267843Sdelphij	      # reloadable object file.  All subsequent reloadable object
8423267843Sdelphij	      # files will link in the last one created.
8424267843Sdelphij	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
8425267843Sdelphij	      reload_objs="$objlist $last_robj"
8426267843Sdelphij	      eval concat_cmds=\"\${concat_cmds}$reload_cmds\"
8427267843Sdelphij	      if test -n "$last_robj"; then
8428267843Sdelphij	        eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\"
8429267843Sdelphij	      fi
8430267843Sdelphij	      func_append delfiles " $output"
8431267843Sdelphij
8432267843Sdelphij	    else
8433267843Sdelphij	      output=
8434267843Sdelphij	    fi
8435267843Sdelphij
8436267843Sdelphij	    if ${skipped_export-false}; then
8437267843Sdelphij	      func_verbose "generating symbol list for \`$libname.la'"
8438267843Sdelphij	      export_symbols="$output_objdir/$libname.exp"
8439267843Sdelphij	      $opt_dry_run || $RM $export_symbols
8440267843Sdelphij	      libobjs=$output
8441267843Sdelphij	      # Append the command to create the export file.
8442267843Sdelphij	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
8443267843Sdelphij	      eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
8444267843Sdelphij	      if test -n "$last_robj"; then
8445267843Sdelphij		eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
8446267843Sdelphij	      fi
8447267843Sdelphij	    fi
8448267843Sdelphij
8449267843Sdelphij	    test -n "$save_libobjs" &&
8450267843Sdelphij	      func_verbose "creating a temporary reloadable object file: $output"
8451267843Sdelphij
8452267843Sdelphij	    # Loop through the commands generated above and execute them.
8453267843Sdelphij	    save_ifs="$IFS"; IFS='~'
8454267843Sdelphij	    for cmd in $concat_cmds; do
8455267843Sdelphij	      IFS="$save_ifs"
8456267843Sdelphij	      $opt_silent || {
8457267843Sdelphij		  func_quote_for_expand "$cmd"
8458267843Sdelphij		  eval "func_echo $func_quote_for_expand_result"
8459267843Sdelphij	      }
8460267843Sdelphij	      $opt_dry_run || eval "$cmd" || {
8461267843Sdelphij		lt_exit=$?
8462267843Sdelphij
8463267843Sdelphij		# Restore the uninstalled library and exit
8464267843Sdelphij		if test "$opt_mode" = relink; then
8465267843Sdelphij		  ( cd "$output_objdir" && \
8466267843Sdelphij		    $RM "${realname}T" && \
8467267843Sdelphij		    $MV "${realname}U" "$realname" )
8468267843Sdelphij		fi
8469267843Sdelphij
8470267843Sdelphij		exit $lt_exit
8471267843Sdelphij	      }
8472267843Sdelphij	    done
8473267843Sdelphij	    IFS="$save_ifs"
8474267843Sdelphij
8475267843Sdelphij	    if test -n "$export_symbols_regex" && ${skipped_export-false}; then
8476267843Sdelphij	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
8477267843Sdelphij	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
8478267843Sdelphij	    fi
8479267843Sdelphij	  fi
8480267843Sdelphij
8481267843Sdelphij          if ${skipped_export-false}; then
8482267843Sdelphij	    if test -n "$export_symbols" && test -n "$include_expsyms"; then
8483267843Sdelphij	      tmp_export_symbols="$export_symbols"
8484267843Sdelphij	      test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
8485267843Sdelphij	      $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
8486267843Sdelphij	    fi
8487267843Sdelphij
8488267843Sdelphij	    if test -n "$orig_export_symbols"; then
8489267843Sdelphij	      # The given exports_symbols file has to be filtered, so filter it.
8490267843Sdelphij	      func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
8491267843Sdelphij	      # FIXME: $output_objdir/$libname.filter potentially contains lots of
8492267843Sdelphij	      # 's' commands which not all seds can handle. GNU sed should be fine
8493267843Sdelphij	      # though. Also, the filter scales superlinearly with the number of
8494267843Sdelphij	      # global variables. join(1) would be nice here, but unfortunately
8495267843Sdelphij	      # isn't a blessed tool.
8496267843Sdelphij	      $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
8497267843Sdelphij	      func_append delfiles " $export_symbols $output_objdir/$libname.filter"
8498267843Sdelphij	      export_symbols=$output_objdir/$libname.def
8499267843Sdelphij	      $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
8500267843Sdelphij	    fi
8501267843Sdelphij	  fi
8502267843Sdelphij
8503267843Sdelphij	  libobjs=$output
8504267843Sdelphij	  # Restore the value of output.
8505267843Sdelphij	  output=$save_output
8506267843Sdelphij
8507267843Sdelphij	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
8508267843Sdelphij	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
8509267843Sdelphij	    test "X$libobjs" = "X " && libobjs=
8510267843Sdelphij	  fi
8511267843Sdelphij	  # Expand the library linking commands again to reset the
8512267843Sdelphij	  # value of $libobjs for piecewise linking.
8513267843Sdelphij
8514267843Sdelphij	  # Do each of the archive commands.
8515267843Sdelphij	  if test "$module" = yes && test -n "$module_cmds" ; then
8516267843Sdelphij	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
8517267843Sdelphij	      cmds=$module_expsym_cmds
8518267843Sdelphij	    else
8519267843Sdelphij	      cmds=$module_cmds
8520267843Sdelphij	    fi
8521267843Sdelphij	  else
8522267843Sdelphij	    if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
8523267843Sdelphij	      cmds=$archive_expsym_cmds
8524267843Sdelphij	    else
8525267843Sdelphij	      cmds=$archive_cmds
8526267843Sdelphij	    fi
8527267843Sdelphij	  fi
8528267843Sdelphij	fi
8529267843Sdelphij
8530267843Sdelphij	if test -n "$delfiles"; then
8531267843Sdelphij	  # Append the command to remove temporary files to $cmds.
8532267843Sdelphij	  eval cmds=\"\$cmds~\$RM $delfiles\"
8533267843Sdelphij	fi
8534267843Sdelphij
8535267843Sdelphij	# Add any objects from preloaded convenience libraries
8536267843Sdelphij	if test -n "$dlprefiles"; then
8537267843Sdelphij	  gentop="$output_objdir/${outputname}x"
8538267843Sdelphij	  func_append generated " $gentop"
8539267843Sdelphij
8540267843Sdelphij	  func_extract_archives $gentop $dlprefiles
8541267843Sdelphij	  func_append libobjs " $func_extract_archives_result"
8542267843Sdelphij	  test "X$libobjs" = "X " && libobjs=
8543267843Sdelphij	fi
8544267843Sdelphij
8545267843Sdelphij	save_ifs="$IFS"; IFS='~'
8546267843Sdelphij	for cmd in $cmds; do
8547267843Sdelphij	  IFS="$save_ifs"
8548267843Sdelphij	  eval cmd=\"$cmd\"
8549267843Sdelphij	  $opt_silent || {
8550267843Sdelphij	    func_quote_for_expand "$cmd"
8551267843Sdelphij	    eval "func_echo $func_quote_for_expand_result"
8552267843Sdelphij	  }
8553267843Sdelphij	  $opt_dry_run || eval "$cmd" || {
8554267843Sdelphij	    lt_exit=$?
8555267843Sdelphij
8556267843Sdelphij	    # Restore the uninstalled library and exit
8557267843Sdelphij	    if test "$opt_mode" = relink; then
8558267843Sdelphij	      ( cd "$output_objdir" && \
8559267843Sdelphij	        $RM "${realname}T" && \
8560267843Sdelphij		$MV "${realname}U" "$realname" )
8561267843Sdelphij	    fi
8562267843Sdelphij
8563267843Sdelphij	    exit $lt_exit
8564267843Sdelphij	  }
8565267843Sdelphij	done
8566267843Sdelphij	IFS="$save_ifs"
8567267843Sdelphij
8568267843Sdelphij	# Restore the uninstalled library and exit
8569267843Sdelphij	if test "$opt_mode" = relink; then
8570267843Sdelphij	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
8571267843Sdelphij
8572267843Sdelphij	  if test -n "$convenience"; then
8573267843Sdelphij	    if test -z "$whole_archive_flag_spec"; then
8574267843Sdelphij	      func_show_eval '${RM}r "$gentop"'
8575267843Sdelphij	    fi
8576267843Sdelphij	  fi
8577267843Sdelphij
8578267843Sdelphij	  exit $EXIT_SUCCESS
8579267843Sdelphij	fi
8580267843Sdelphij
8581267843Sdelphij	# Create links to the real library.
8582267843Sdelphij	for linkname in $linknames; do
8583267843Sdelphij	  if test "$realname" != "$linkname"; then
8584267843Sdelphij	    func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
8585267843Sdelphij	  fi
8586267843Sdelphij	done
8587267843Sdelphij
8588267843Sdelphij	# If -module or -export-dynamic was specified, set the dlname.
8589267843Sdelphij	if test "$module" = yes || test "$export_dynamic" = yes; then
8590267843Sdelphij	  # On all known operating systems, these are identical.
8591267843Sdelphij	  dlname="$soname"
8592267843Sdelphij	fi
8593267843Sdelphij      fi
8594267843Sdelphij      ;;
8595267843Sdelphij
8596267843Sdelphij    obj)
8597267843Sdelphij      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
8598267843Sdelphij	func_warning "\`-dlopen' is ignored for objects"
8599267843Sdelphij      fi
8600267843Sdelphij
8601267843Sdelphij      case " $deplibs" in
8602267843Sdelphij      *\ -l* | *\ -L*)
8603267843Sdelphij	func_warning "\`-l' and \`-L' are ignored for objects" ;;
8604267843Sdelphij      esac
8605267843Sdelphij
8606267843Sdelphij      test -n "$rpath" && \
8607267843Sdelphij	func_warning "\`-rpath' is ignored for objects"
8608267843Sdelphij
8609267843Sdelphij      test -n "$xrpath" && \
8610267843Sdelphij	func_warning "\`-R' is ignored for objects"
8611267843Sdelphij
8612267843Sdelphij      test -n "$vinfo" && \
8613267843Sdelphij	func_warning "\`-version-info' is ignored for objects"
8614267843Sdelphij
8615267843Sdelphij      test -n "$release" && \
8616267843Sdelphij	func_warning "\`-release' is ignored for objects"
8617267843Sdelphij
8618267843Sdelphij      case $output in
8619267843Sdelphij      *.lo)
8620267843Sdelphij	test -n "$objs$old_deplibs" && \
8621267843Sdelphij	  func_fatal_error "cannot build library object \`$output' from non-libtool objects"
8622267843Sdelphij
8623267843Sdelphij	libobj=$output
8624267843Sdelphij	func_lo2o "$libobj"
8625267843Sdelphij	obj=$func_lo2o_result
8626267843Sdelphij	;;
8627267843Sdelphij      *)
8628267843Sdelphij	libobj=
8629267843Sdelphij	obj="$output"
8630267843Sdelphij	;;
8631267843Sdelphij      esac
8632267843Sdelphij
8633267843Sdelphij      # Delete the old objects.
8634267843Sdelphij      $opt_dry_run || $RM $obj $libobj
8635267843Sdelphij
8636267843Sdelphij      # Objects from convenience libraries.  This assumes
8637267843Sdelphij      # single-version convenience libraries.  Whenever we create
8638267843Sdelphij      # different ones for PIC/non-PIC, this we'll have to duplicate
8639267843Sdelphij      # the extraction.
8640267843Sdelphij      reload_conv_objs=
8641267843Sdelphij      gentop=
8642267843Sdelphij      # reload_cmds runs $LD directly, so let us get rid of
8643267843Sdelphij      # -Wl from whole_archive_flag_spec and hope we can get by with
8644267843Sdelphij      # turning comma into space..
8645267843Sdelphij      wl=
8646267843Sdelphij
8647267843Sdelphij      if test -n "$convenience"; then
8648267843Sdelphij	if test -n "$whole_archive_flag_spec"; then
8649267843Sdelphij	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
8650267843Sdelphij	  reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
8651267843Sdelphij	else
8652267843Sdelphij	  gentop="$output_objdir/${obj}x"
8653267843Sdelphij	  func_append generated " $gentop"
8654267843Sdelphij
8655267843Sdelphij	  func_extract_archives $gentop $convenience
8656267843Sdelphij	  reload_conv_objs="$reload_objs $func_extract_archives_result"
8657267843Sdelphij	fi
8658267843Sdelphij      fi
8659267843Sdelphij
8660267843Sdelphij      # If we're not building shared, we need to use non_pic_objs
8661267843Sdelphij      test "$build_libtool_libs" != yes && libobjs="$non_pic_objects"
8662267843Sdelphij
8663267843Sdelphij      # Create the old-style object.
8664267843Sdelphij      reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
8665267843Sdelphij
8666267843Sdelphij      output="$obj"
8667267843Sdelphij      func_execute_cmds "$reload_cmds" 'exit $?'
8668267843Sdelphij
8669267843Sdelphij      # Exit if we aren't doing a library object file.
8670267843Sdelphij      if test -z "$libobj"; then
8671267843Sdelphij	if test -n "$gentop"; then
8672267843Sdelphij	  func_show_eval '${RM}r "$gentop"'
8673267843Sdelphij	fi
8674267843Sdelphij
8675267843Sdelphij	exit $EXIT_SUCCESS
8676267843Sdelphij      fi
8677267843Sdelphij
8678267843Sdelphij      if test "$build_libtool_libs" != yes; then
8679267843Sdelphij	if test -n "$gentop"; then
8680267843Sdelphij	  func_show_eval '${RM}r "$gentop"'
8681267843Sdelphij	fi
8682267843Sdelphij
8683267843Sdelphij	# Create an invalid libtool object if no PIC, so that we don't
8684267843Sdelphij	# accidentally link it into a program.
8685267843Sdelphij	# $show "echo timestamp > $libobj"
8686267843Sdelphij	# $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
8687267843Sdelphij	exit $EXIT_SUCCESS
8688267843Sdelphij      fi
8689267843Sdelphij
8690267843Sdelphij      if test -n "$pic_flag" || test "$pic_mode" != default; then
8691267843Sdelphij	# Only do commands if we really have different PIC objects.
8692267843Sdelphij	reload_objs="$libobjs $reload_conv_objs"
8693267843Sdelphij	output="$libobj"
8694267843Sdelphij	func_execute_cmds "$reload_cmds" 'exit $?'
8695267843Sdelphij      fi
8696267843Sdelphij
8697267843Sdelphij      if test -n "$gentop"; then
8698267843Sdelphij	func_show_eval '${RM}r "$gentop"'
8699267843Sdelphij      fi
8700267843Sdelphij
8701267843Sdelphij      exit $EXIT_SUCCESS
8702267843Sdelphij      ;;
8703267843Sdelphij
8704267843Sdelphij    prog)
8705267843Sdelphij      case $host in
8706267843Sdelphij	*cygwin*) func_stripname '' '.exe' "$output"
8707267843Sdelphij	          output=$func_stripname_result.exe;;
8708267843Sdelphij      esac
8709267843Sdelphij      test -n "$vinfo" && \
8710267843Sdelphij	func_warning "\`-version-info' is ignored for programs"
8711267843Sdelphij
8712267843Sdelphij      test -n "$release" && \
8713267843Sdelphij	func_warning "\`-release' is ignored for programs"
8714267843Sdelphij
8715267843Sdelphij      test "$preload" = yes \
8716267843Sdelphij        && test "$dlopen_support" = unknown \
8717267843Sdelphij	&& test "$dlopen_self" = unknown \
8718267843Sdelphij	&& test "$dlopen_self_static" = unknown && \
8719267843Sdelphij	  func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support."
8720267843Sdelphij
8721267843Sdelphij      case $host in
8722267843Sdelphij      *-*-rhapsody* | *-*-darwin1.[012])
8723267843Sdelphij	# On Rhapsody replace the C library is the System framework
8724267843Sdelphij	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
8725267843Sdelphij	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
8726267843Sdelphij	;;
8727267843Sdelphij      esac
8728267843Sdelphij
8729267843Sdelphij      case $host in
8730267843Sdelphij      *-*-darwin*)
8731267843Sdelphij	# Don't allow lazy linking, it breaks C++ global constructors
8732267843Sdelphij	# But is supposedly fixed on 10.4 or later (yay!).
8733267843Sdelphij	if test "$tagname" = CXX ; then
8734267843Sdelphij	  case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
8735267843Sdelphij	    10.[0123])
8736267843Sdelphij	      func_append compile_command " ${wl}-bind_at_load"
8737267843Sdelphij	      func_append finalize_command " ${wl}-bind_at_load"
8738267843Sdelphij	    ;;
8739267843Sdelphij	  esac
8740267843Sdelphij	fi
8741267843Sdelphij	# Time to change all our "foo.ltframework" stuff back to "-framework foo"
8742267843Sdelphij	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8743267843Sdelphij	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8744267843Sdelphij	;;
8745267843Sdelphij      esac
8746267843Sdelphij
8747267843Sdelphij
8748267843Sdelphij      # move library search paths that coincide with paths to not yet
8749267843Sdelphij      # installed libraries to the beginning of the library search list
8750267843Sdelphij      new_libs=
8751267843Sdelphij      for path in $notinst_path; do
8752267843Sdelphij	case " $new_libs " in
8753267843Sdelphij	*" -L$path/$objdir "*) ;;
8754267843Sdelphij	*)
8755267843Sdelphij	  case " $compile_deplibs " in
8756267843Sdelphij	  *" -L$path/$objdir "*)
8757267843Sdelphij	    func_append new_libs " -L$path/$objdir" ;;
8758267843Sdelphij	  esac
8759267843Sdelphij	  ;;
8760267843Sdelphij	esac
8761267843Sdelphij      done
8762267843Sdelphij      for deplib in $compile_deplibs; do
8763267843Sdelphij	case $deplib in
8764267843Sdelphij	-L*)
8765267843Sdelphij	  case " $new_libs " in
8766267843Sdelphij	  *" $deplib "*) ;;
8767267843Sdelphij	  *) func_append new_libs " $deplib" ;;
8768267843Sdelphij	  esac
8769267843Sdelphij	  ;;
8770267843Sdelphij	*) func_append new_libs " $deplib" ;;
8771267843Sdelphij	esac
8772267843Sdelphij      done
8773267843Sdelphij      compile_deplibs="$new_libs"
8774267843Sdelphij
8775267843Sdelphij
8776267843Sdelphij      func_append compile_command " $compile_deplibs"
8777267843Sdelphij      func_append finalize_command " $finalize_deplibs"
8778267843Sdelphij
8779267843Sdelphij      if test -n "$rpath$xrpath"; then
8780267843Sdelphij	# If the user specified any rpath flags, then add them.
8781267843Sdelphij	for libdir in $rpath $xrpath; do
8782267843Sdelphij	  # This is the magic to use -rpath.
8783267843Sdelphij	  case "$finalize_rpath " in
8784267843Sdelphij	  *" $libdir "*) ;;
8785267843Sdelphij	  *) func_append finalize_rpath " $libdir" ;;
8786267843Sdelphij	  esac
8787267843Sdelphij	done
8788267843Sdelphij      fi
8789267843Sdelphij
8790267843Sdelphij      # Now hardcode the library paths
8791267843Sdelphij      rpath=
8792267843Sdelphij      hardcode_libdirs=
8793267843Sdelphij      for libdir in $compile_rpath $finalize_rpath; do
8794267843Sdelphij	if test -n "$hardcode_libdir_flag_spec"; then
8795267843Sdelphij	  if test -n "$hardcode_libdir_separator"; then
8796267843Sdelphij	    if test -z "$hardcode_libdirs"; then
8797267843Sdelphij	      hardcode_libdirs="$libdir"
8798267843Sdelphij	    else
8799267843Sdelphij	      # Just accumulate the unique libdirs.
8800267843Sdelphij	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
8801267843Sdelphij	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
8802267843Sdelphij		;;
8803267843Sdelphij	      *)
8804267843Sdelphij		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
8805267843Sdelphij		;;
8806267843Sdelphij	      esac
8807267843Sdelphij	    fi
8808267843Sdelphij	  else
8809267843Sdelphij	    eval flag=\"$hardcode_libdir_flag_spec\"
8810267843Sdelphij	    func_append rpath " $flag"
8811267843Sdelphij	  fi
8812267843Sdelphij	elif test -n "$runpath_var"; then
8813267843Sdelphij	  case "$perm_rpath " in
8814267843Sdelphij	  *" $libdir "*) ;;
8815267843Sdelphij	  *) func_append perm_rpath " $libdir" ;;
8816267843Sdelphij	  esac
8817267843Sdelphij	fi
8818267843Sdelphij	case $host in
8819267843Sdelphij	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
8820267843Sdelphij	  testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'`
8821267843Sdelphij	  case :$dllsearchpath: in
8822267843Sdelphij	  *":$libdir:"*) ;;
8823267843Sdelphij	  ::) dllsearchpath=$libdir;;
8824267843Sdelphij	  *) func_append dllsearchpath ":$libdir";;
8825267843Sdelphij	  esac
8826267843Sdelphij	  case :$dllsearchpath: in
8827267843Sdelphij	  *":$testbindir:"*) ;;
8828267843Sdelphij	  ::) dllsearchpath=$testbindir;;
8829267843Sdelphij	  *) func_append dllsearchpath ":$testbindir";;
8830267843Sdelphij	  esac
8831267843Sdelphij	  ;;
8832267843Sdelphij	esac
8833267843Sdelphij      done
8834267843Sdelphij      # Substitute the hardcoded libdirs into the rpath.
8835267843Sdelphij      if test -n "$hardcode_libdir_separator" &&
8836267843Sdelphij	 test -n "$hardcode_libdirs"; then
8837267843Sdelphij	libdir="$hardcode_libdirs"
8838267843Sdelphij	eval rpath=\" $hardcode_libdir_flag_spec\"
8839267843Sdelphij      fi
8840267843Sdelphij      compile_rpath="$rpath"
8841267843Sdelphij
8842267843Sdelphij      rpath=
8843267843Sdelphij      hardcode_libdirs=
8844267843Sdelphij      for libdir in $finalize_rpath; do
8845267843Sdelphij	if test -n "$hardcode_libdir_flag_spec"; then
8846267843Sdelphij	  if test -n "$hardcode_libdir_separator"; then
8847267843Sdelphij	    if test -z "$hardcode_libdirs"; then
8848267843Sdelphij	      hardcode_libdirs="$libdir"
8849267843Sdelphij	    else
8850267843Sdelphij	      # Just accumulate the unique libdirs.
8851267843Sdelphij	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
8852267843Sdelphij	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
8853267843Sdelphij		;;
8854267843Sdelphij	      *)
8855267843Sdelphij		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
8856267843Sdelphij		;;
8857267843Sdelphij	      esac
8858267843Sdelphij	    fi
8859267843Sdelphij	  else
8860267843Sdelphij	    eval flag=\"$hardcode_libdir_flag_spec\"
8861267843Sdelphij	    func_append rpath " $flag"
8862267843Sdelphij	  fi
8863267843Sdelphij	elif test -n "$runpath_var"; then
8864267843Sdelphij	  case "$finalize_perm_rpath " in
8865267843Sdelphij	  *" $libdir "*) ;;
8866267843Sdelphij	  *) func_append finalize_perm_rpath " $libdir" ;;
8867267843Sdelphij	  esac
8868267843Sdelphij	fi
8869267843Sdelphij      done
8870267843Sdelphij      # Substitute the hardcoded libdirs into the rpath.
8871267843Sdelphij      if test -n "$hardcode_libdir_separator" &&
8872267843Sdelphij	 test -n "$hardcode_libdirs"; then
8873267843Sdelphij	libdir="$hardcode_libdirs"
8874267843Sdelphij	eval rpath=\" $hardcode_libdir_flag_spec\"
8875267843Sdelphij      fi
8876267843Sdelphij      finalize_rpath="$rpath"
8877267843Sdelphij
8878267843Sdelphij      if test -n "$libobjs" && test "$build_old_libs" = yes; then
8879267843Sdelphij	# Transform all the library objects into standard objects.
8880267843Sdelphij	compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
8881267843Sdelphij	finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
8882267843Sdelphij      fi
8883267843Sdelphij
8884267843Sdelphij      func_generate_dlsyms "$outputname" "@PROGRAM@" "no"
8885267843Sdelphij
8886267843Sdelphij      # template prelinking step
8887267843Sdelphij      if test -n "$prelink_cmds"; then
8888267843Sdelphij	func_execute_cmds "$prelink_cmds" 'exit $?'
8889267843Sdelphij      fi
8890267843Sdelphij
8891267843Sdelphij      wrappers_required=yes
8892267843Sdelphij      case $host in
8893267843Sdelphij      *cegcc* | *mingw32ce*)
8894267843Sdelphij        # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
8895267843Sdelphij        wrappers_required=no
8896267843Sdelphij        ;;
8897267843Sdelphij      *cygwin* | *mingw* )
8898267843Sdelphij        if test "$build_libtool_libs" != yes; then
8899267843Sdelphij          wrappers_required=no
8900267843Sdelphij        fi
8901267843Sdelphij        ;;
8902267843Sdelphij      *)
8903267843Sdelphij        if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
8904267843Sdelphij          wrappers_required=no
8905267843Sdelphij        fi
8906267843Sdelphij        ;;
8907267843Sdelphij      esac
8908267843Sdelphij      if test "$wrappers_required" = no; then
8909267843Sdelphij	# Replace the output file specification.
8910267843Sdelphij	compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
8911267843Sdelphij	link_command="$compile_command$compile_rpath"
8912267843Sdelphij
8913267843Sdelphij	# We have no uninstalled library dependencies, so finalize right now.
8914267843Sdelphij	exit_status=0
8915267843Sdelphij	func_show_eval "$link_command" 'exit_status=$?'
8916267843Sdelphij
8917267843Sdelphij	if test -n "$postlink_cmds"; then
8918267843Sdelphij	  func_to_tool_file "$output"
8919267843Sdelphij	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
8920267843Sdelphij	  func_execute_cmds "$postlink_cmds" 'exit $?'
8921267843Sdelphij	fi
8922267843Sdelphij
8923267843Sdelphij	# Delete the generated files.
8924267843Sdelphij	if test -f "$output_objdir/${outputname}S.${objext}"; then
8925267843Sdelphij	  func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"'
8926267843Sdelphij	fi
8927267843Sdelphij
8928267843Sdelphij	exit $exit_status
8929267843Sdelphij      fi
8930267843Sdelphij
8931267843Sdelphij      if test -n "$compile_shlibpath$finalize_shlibpath"; then
8932267843Sdelphij	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
8933267843Sdelphij      fi
8934267843Sdelphij      if test -n "$finalize_shlibpath"; then
8935267843Sdelphij	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
8936267843Sdelphij      fi
8937267843Sdelphij
8938267843Sdelphij      compile_var=
8939267843Sdelphij      finalize_var=
8940267843Sdelphij      if test -n "$runpath_var"; then
8941267843Sdelphij	if test -n "$perm_rpath"; then
8942267843Sdelphij	  # We should set the runpath_var.
8943267843Sdelphij	  rpath=
8944267843Sdelphij	  for dir in $perm_rpath; do
8945267843Sdelphij	    func_append rpath "$dir:"
8946267843Sdelphij	  done
8947267843Sdelphij	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
8948267843Sdelphij	fi
8949267843Sdelphij	if test -n "$finalize_perm_rpath"; then
8950267843Sdelphij	  # We should set the runpath_var.
8951267843Sdelphij	  rpath=
8952267843Sdelphij	  for dir in $finalize_perm_rpath; do
8953267843Sdelphij	    func_append rpath "$dir:"
8954267843Sdelphij	  done
8955267843Sdelphij	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
8956267843Sdelphij	fi
8957267843Sdelphij      fi
8958267843Sdelphij
8959267843Sdelphij      if test "$no_install" = yes; then
8960267843Sdelphij	# We don't need to create a wrapper script.
8961267843Sdelphij	link_command="$compile_var$compile_command$compile_rpath"
8962267843Sdelphij	# Replace the output file specification.
8963267843Sdelphij	link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
8964267843Sdelphij	# Delete the old output file.
8965267843Sdelphij	$opt_dry_run || $RM $output
8966267843Sdelphij	# Link the executable and exit
8967267843Sdelphij	func_show_eval "$link_command" 'exit $?'
8968267843Sdelphij
8969267843Sdelphij	if test -n "$postlink_cmds"; then
8970267843Sdelphij	  func_to_tool_file "$output"
8971267843Sdelphij	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
8972267843Sdelphij	  func_execute_cmds "$postlink_cmds" 'exit $?'
8973267843Sdelphij	fi
8974267843Sdelphij
8975267843Sdelphij	exit $EXIT_SUCCESS
8976267843Sdelphij      fi
8977267843Sdelphij
8978267843Sdelphij      if test "$hardcode_action" = relink; then
8979267843Sdelphij	# Fast installation is not supported
8980267843Sdelphij	link_command="$compile_var$compile_command$compile_rpath"
8981267843Sdelphij	relink_command="$finalize_var$finalize_command$finalize_rpath"
8982267843Sdelphij
8983267843Sdelphij	func_warning "this platform does not like uninstalled shared libraries"
8984267843Sdelphij	func_warning "\`$output' will be relinked during installation"
8985267843Sdelphij      else
8986267843Sdelphij	if test "$fast_install" != no; then
8987267843Sdelphij	  link_command="$finalize_var$compile_command$finalize_rpath"
8988267843Sdelphij	  if test "$fast_install" = yes; then
8989267843Sdelphij	    relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
8990267843Sdelphij	  else
8991267843Sdelphij	    # fast_install is set to needless
8992267843Sdelphij	    relink_command=
8993267843Sdelphij	  fi
8994267843Sdelphij	else
8995267843Sdelphij	  link_command="$compile_var$compile_command$compile_rpath"
8996267843Sdelphij	  relink_command="$finalize_var$finalize_command$finalize_rpath"
8997267843Sdelphij	fi
8998267843Sdelphij      fi
8999267843Sdelphij
9000267843Sdelphij      # Replace the output file specification.
9001267843Sdelphij      link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
9002267843Sdelphij
9003267843Sdelphij      # Delete the old output files.
9004267843Sdelphij      $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
9005267843Sdelphij
9006267843Sdelphij      func_show_eval "$link_command" 'exit $?'
9007267843Sdelphij
9008267843Sdelphij      if test -n "$postlink_cmds"; then
9009267843Sdelphij	func_to_tool_file "$output_objdir/$outputname"
9010267843Sdelphij	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'`
9011267843Sdelphij	func_execute_cmds "$postlink_cmds" 'exit $?'
9012267843Sdelphij      fi
9013267843Sdelphij
9014267843Sdelphij      # Now create the wrapper script.
9015267843Sdelphij      func_verbose "creating $output"
9016267843Sdelphij
9017267843Sdelphij      # Quote the relink command for shipping.
9018267843Sdelphij      if test -n "$relink_command"; then
9019267843Sdelphij	# Preserve any variables that may affect compiler behavior
9020267843Sdelphij	for var in $variables_saved_for_relink; do
9021267843Sdelphij	  if eval test -z \"\${$var+set}\"; then
9022267843Sdelphij	    relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
9023267843Sdelphij	  elif eval var_value=\$$var; test -z "$var_value"; then
9024267843Sdelphij	    relink_command="$var=; export $var; $relink_command"
9025267843Sdelphij	  else
9026267843Sdelphij	    func_quote_for_eval "$var_value"
9027267843Sdelphij	    relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
9028267843Sdelphij	  fi
9029267843Sdelphij	done
9030267843Sdelphij	relink_command="(cd `pwd`; $relink_command)"
9031267843Sdelphij	relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
9032267843Sdelphij      fi
9033267843Sdelphij
9034267843Sdelphij      # Only actually do things if not in dry run mode.
9035267843Sdelphij      $opt_dry_run || {
9036267843Sdelphij	# win32 will think the script is a binary if it has
9037267843Sdelphij	# a .exe suffix, so we strip it off here.
9038267843Sdelphij	case $output in
9039267843Sdelphij	  *.exe) func_stripname '' '.exe' "$output"
9040267843Sdelphij	         output=$func_stripname_result ;;
9041267843Sdelphij	esac
9042267843Sdelphij	# test for cygwin because mv fails w/o .exe extensions
9043267843Sdelphij	case $host in
9044267843Sdelphij	  *cygwin*)
9045267843Sdelphij	    exeext=.exe
9046267843Sdelphij	    func_stripname '' '.exe' "$outputname"
9047267843Sdelphij	    outputname=$func_stripname_result ;;
9048267843Sdelphij	  *) exeext= ;;
9049267843Sdelphij	esac
9050267843Sdelphij	case $host in
9051267843Sdelphij	  *cygwin* | *mingw* )
9052267843Sdelphij	    func_dirname_and_basename "$output" "" "."
9053267843Sdelphij	    output_name=$func_basename_result
9054267843Sdelphij	    output_path=$func_dirname_result
9055267843Sdelphij	    cwrappersource="$output_path/$objdir/lt-$output_name.c"
9056267843Sdelphij	    cwrapper="$output_path/$output_name.exe"
9057267843Sdelphij	    $RM $cwrappersource $cwrapper
9058267843Sdelphij	    trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
9059267843Sdelphij
9060267843Sdelphij	    func_emit_cwrapperexe_src > $cwrappersource
9061267843Sdelphij
9062267843Sdelphij	    # The wrapper executable is built using the $host compiler,
9063267843Sdelphij	    # because it contains $host paths and files. If cross-
9064267843Sdelphij	    # compiling, it, like the target executable, must be
9065267843Sdelphij	    # executed on the $host or under an emulation environment.
9066267843Sdelphij	    $opt_dry_run || {
9067267843Sdelphij	      $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
9068267843Sdelphij	      $STRIP $cwrapper
9069267843Sdelphij	    }
9070267843Sdelphij
9071267843Sdelphij	    # Now, create the wrapper script for func_source use:
9072267843Sdelphij	    func_ltwrapper_scriptname $cwrapper
9073267843Sdelphij	    $RM $func_ltwrapper_scriptname_result
9074267843Sdelphij	    trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
9075267843Sdelphij	    $opt_dry_run || {
9076267843Sdelphij	      # note: this script will not be executed, so do not chmod.
9077267843Sdelphij	      if test "x$build" = "x$host" ; then
9078267843Sdelphij		$cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
9079267843Sdelphij	      else
9080267843Sdelphij		func_emit_wrapper no > $func_ltwrapper_scriptname_result
9081267843Sdelphij	      fi
9082267843Sdelphij	    }
9083267843Sdelphij	  ;;
9084267843Sdelphij	  * )
9085267843Sdelphij	    $RM $output
9086267843Sdelphij	    trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
9087267843Sdelphij
9088267843Sdelphij	    func_emit_wrapper no > $output
9089267843Sdelphij	    chmod +x $output
9090267843Sdelphij	  ;;
9091267843Sdelphij	esac
9092267843Sdelphij      }
9093267843Sdelphij      exit $EXIT_SUCCESS
9094267843Sdelphij      ;;
9095267843Sdelphij    esac
9096267843Sdelphij
9097267843Sdelphij    # See if we need to build an old-fashioned archive.
9098267843Sdelphij    for oldlib in $oldlibs; do
9099267843Sdelphij
9100267843Sdelphij      if test "$build_libtool_libs" = convenience; then
9101267843Sdelphij	oldobjs="$libobjs_save $symfileobj"
9102267843Sdelphij	addlibs="$convenience"
9103267843Sdelphij	build_libtool_libs=no
9104267843Sdelphij      else
9105267843Sdelphij	if test "$build_libtool_libs" = module; then
9106267843Sdelphij	  oldobjs="$libobjs_save"
9107267843Sdelphij	  build_libtool_libs=no
9108267843Sdelphij	else
9109267843Sdelphij	  oldobjs="$old_deplibs $non_pic_objects"
9110267843Sdelphij	  if test "$preload" = yes && test -f "$symfileobj"; then
9111267843Sdelphij	    func_append oldobjs " $symfileobj"
9112267843Sdelphij	  fi
9113267843Sdelphij	fi
9114267843Sdelphij	addlibs="$old_convenience"
9115267843Sdelphij      fi
9116267843Sdelphij
9117267843Sdelphij      if test -n "$addlibs"; then
9118267843Sdelphij	gentop="$output_objdir/${outputname}x"
9119267843Sdelphij	func_append generated " $gentop"
9120267843Sdelphij
9121267843Sdelphij	func_extract_archives $gentop $addlibs
9122267843Sdelphij	func_append oldobjs " $func_extract_archives_result"
9123267843Sdelphij      fi
9124267843Sdelphij
9125267843Sdelphij      # Do each command in the archive commands.
9126267843Sdelphij      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
9127267843Sdelphij	cmds=$old_archive_from_new_cmds
9128267843Sdelphij      else
9129267843Sdelphij
9130267843Sdelphij	# Add any objects from preloaded convenience libraries
9131267843Sdelphij	if test -n "$dlprefiles"; then
9132267843Sdelphij	  gentop="$output_objdir/${outputname}x"
9133267843Sdelphij	  func_append generated " $gentop"
9134267843Sdelphij
9135267843Sdelphij	  func_extract_archives $gentop $dlprefiles
9136267843Sdelphij	  func_append oldobjs " $func_extract_archives_result"
9137267843Sdelphij	fi
9138267843Sdelphij
9139267843Sdelphij	# POSIX demands no paths to be encoded in archives.  We have
9140267843Sdelphij	# to avoid creating archives with duplicate basenames if we
9141267843Sdelphij	# might have to extract them afterwards, e.g., when creating a
9142267843Sdelphij	# static archive out of a convenience library, or when linking
9143267843Sdelphij	# the entirety of a libtool archive into another (currently
9144267843Sdelphij	# not supported by libtool).
9145267843Sdelphij	if (for obj in $oldobjs
9146267843Sdelphij	    do
9147267843Sdelphij	      func_basename "$obj"
9148267843Sdelphij	      $ECHO "$func_basename_result"
9149267843Sdelphij	    done | sort | sort -uc >/dev/null 2>&1); then
9150267843Sdelphij	  :
9151267843Sdelphij	else
9152267843Sdelphij	  echo "copying selected object files to avoid basename conflicts..."
9153267843Sdelphij	  gentop="$output_objdir/${outputname}x"
9154267843Sdelphij	  func_append generated " $gentop"
9155267843Sdelphij	  func_mkdir_p "$gentop"
9156267843Sdelphij	  save_oldobjs=$oldobjs
9157267843Sdelphij	  oldobjs=
9158267843Sdelphij	  counter=1
9159267843Sdelphij	  for obj in $save_oldobjs
9160267843Sdelphij	  do
9161267843Sdelphij	    func_basename "$obj"
9162267843Sdelphij	    objbase="$func_basename_result"
9163267843Sdelphij	    case " $oldobjs " in
9164267843Sdelphij	    " ") oldobjs=$obj ;;
9165267843Sdelphij	    *[\ /]"$objbase "*)
9166267843Sdelphij	      while :; do
9167267843Sdelphij		# Make sure we don't pick an alternate name that also
9168267843Sdelphij		# overlaps.
9169267843Sdelphij		newobj=lt$counter-$objbase
9170267843Sdelphij		func_arith $counter + 1
9171267843Sdelphij		counter=$func_arith_result
9172267843Sdelphij		case " $oldobjs " in
9173267843Sdelphij		*[\ /]"$newobj "*) ;;
9174267843Sdelphij		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
9175267843Sdelphij		esac
9176267843Sdelphij	      done
9177267843Sdelphij	      func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
9178267843Sdelphij	      func_append oldobjs " $gentop/$newobj"
9179267843Sdelphij	      ;;
9180267843Sdelphij	    *) func_append oldobjs " $obj" ;;
9181267843Sdelphij	    esac
9182267843Sdelphij	  done
9183267843Sdelphij	fi
9184267843Sdelphij	func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
9185267843Sdelphij	tool_oldlib=$func_to_tool_file_result
9186267843Sdelphij	eval cmds=\"$old_archive_cmds\"
9187267843Sdelphij
9188267843Sdelphij	func_len " $cmds"
9189267843Sdelphij	len=$func_len_result
9190267843Sdelphij	if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
9191267843Sdelphij	  cmds=$old_archive_cmds
9192267843Sdelphij	elif test -n "$archiver_list_spec"; then
9193267843Sdelphij	  func_verbose "using command file archive linking..."
9194267843Sdelphij	  for obj in $oldobjs
9195267843Sdelphij	  do
9196267843Sdelphij	    func_to_tool_file "$obj"
9197267843Sdelphij	    $ECHO "$func_to_tool_file_result"
9198267843Sdelphij	  done > $output_objdir/$libname.libcmd
9199267843Sdelphij	  func_to_tool_file "$output_objdir/$libname.libcmd"
9200267843Sdelphij	  oldobjs=" $archiver_list_spec$func_to_tool_file_result"
9201267843Sdelphij	  cmds=$old_archive_cmds
9202267843Sdelphij	else
9203267843Sdelphij	  # the command line is too long to link in one step, link in parts
9204267843Sdelphij	  func_verbose "using piecewise archive linking..."
9205267843Sdelphij	  save_RANLIB=$RANLIB
9206267843Sdelphij	  RANLIB=:
9207267843Sdelphij	  objlist=
9208267843Sdelphij	  concat_cmds=
9209267843Sdelphij	  save_oldobjs=$oldobjs
9210267843Sdelphij	  oldobjs=
9211267843Sdelphij	  # Is there a better way of finding the last object in the list?
9212267843Sdelphij	  for obj in $save_oldobjs
9213267843Sdelphij	  do
9214267843Sdelphij	    last_oldobj=$obj
9215267843Sdelphij	  done
9216267843Sdelphij	  eval test_cmds=\"$old_archive_cmds\"
9217267843Sdelphij	  func_len " $test_cmds"
9218267843Sdelphij	  len0=$func_len_result
9219267843Sdelphij	  len=$len0
9220267843Sdelphij	  for obj in $save_oldobjs
9221267843Sdelphij	  do
9222267843Sdelphij	    func_len " $obj"
9223267843Sdelphij	    func_arith $len + $func_len_result
9224267843Sdelphij	    len=$func_arith_result
9225267843Sdelphij	    func_append objlist " $obj"
9226267843Sdelphij	    if test "$len" -lt "$max_cmd_len"; then
9227267843Sdelphij	      :
9228267843Sdelphij	    else
9229267843Sdelphij	      # the above command should be used before it gets too long
9230267843Sdelphij	      oldobjs=$objlist
9231267843Sdelphij	      if test "$obj" = "$last_oldobj" ; then
9232267843Sdelphij		RANLIB=$save_RANLIB
9233267843Sdelphij	      fi
9234267843Sdelphij	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
9235267843Sdelphij	      eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
9236267843Sdelphij	      objlist=
9237267843Sdelphij	      len=$len0
9238267843Sdelphij	    fi
9239267843Sdelphij	  done
9240267843Sdelphij	  RANLIB=$save_RANLIB
9241267843Sdelphij	  oldobjs=$objlist
9242267843Sdelphij	  if test "X$oldobjs" = "X" ; then
9243267843Sdelphij	    eval cmds=\"\$concat_cmds\"
9244267843Sdelphij	  else
9245267843Sdelphij	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
9246267843Sdelphij	  fi
9247267843Sdelphij	fi
9248267843Sdelphij      fi
9249267843Sdelphij      func_execute_cmds "$cmds" 'exit $?'
9250267843Sdelphij    done
9251267843Sdelphij
9252267843Sdelphij    test -n "$generated" && \
9253267843Sdelphij      func_show_eval "${RM}r$generated"
9254267843Sdelphij
9255267843Sdelphij    # Now create the libtool archive.
9256267843Sdelphij    case $output in
9257267843Sdelphij    *.la)
9258267843Sdelphij      old_library=
9259267843Sdelphij      test "$build_old_libs" = yes && old_library="$libname.$libext"
9260267843Sdelphij      func_verbose "creating $output"
9261267843Sdelphij
9262267843Sdelphij      # Preserve any variables that may affect compiler behavior
9263267843Sdelphij      for var in $variables_saved_for_relink; do
9264267843Sdelphij	if eval test -z \"\${$var+set}\"; then
9265267843Sdelphij	  relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
9266267843Sdelphij	elif eval var_value=\$$var; test -z "$var_value"; then
9267267843Sdelphij	  relink_command="$var=; export $var; $relink_command"
9268267843Sdelphij	else
9269267843Sdelphij	  func_quote_for_eval "$var_value"
9270267843Sdelphij	  relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
9271267843Sdelphij	fi
9272267843Sdelphij      done
9273267843Sdelphij      # Quote the link command for shipping.
9274267843Sdelphij      relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
9275267843Sdelphij      relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
9276267843Sdelphij      if test "$hardcode_automatic" = yes ; then
9277267843Sdelphij	relink_command=
9278267843Sdelphij      fi
9279267843Sdelphij
9280267843Sdelphij      # Only create the output if not a dry run.
9281267843Sdelphij      $opt_dry_run || {
9282267843Sdelphij	for installed in no yes; do
9283267843Sdelphij	  if test "$installed" = yes; then
9284267843Sdelphij	    if test -z "$install_libdir"; then
9285267843Sdelphij	      break
9286267843Sdelphij	    fi
9287267843Sdelphij	    output="$output_objdir/$outputname"i
9288267843Sdelphij	    # Replace all uninstalled libtool libraries with the installed ones
9289267843Sdelphij	    newdependency_libs=
9290267843Sdelphij	    for deplib in $dependency_libs; do
9291267843Sdelphij	      case $deplib in
9292267843Sdelphij	      *.la)
9293267843Sdelphij		func_basename "$deplib"
9294267843Sdelphij		name="$func_basename_result"
9295267843Sdelphij		func_resolve_sysroot "$deplib"
9296267843Sdelphij		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result`
9297267843Sdelphij		test -z "$libdir" && \
9298267843Sdelphij		  func_fatal_error "\`$deplib' is not a valid libtool archive"
9299267843Sdelphij		func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"
9300267843Sdelphij		;;
9301267843Sdelphij	      -L*)
9302267843Sdelphij		func_stripname -L '' "$deplib"
9303267843Sdelphij		func_replace_sysroot "$func_stripname_result"
9304267843Sdelphij		func_append newdependency_libs " -L$func_replace_sysroot_result"
9305267843Sdelphij		;;
9306267843Sdelphij	      -R*)
9307267843Sdelphij		func_stripname -R '' "$deplib"
9308267843Sdelphij		func_replace_sysroot "$func_stripname_result"
9309267843Sdelphij		func_append newdependency_libs " -R$func_replace_sysroot_result"
9310267843Sdelphij		;;
9311267843Sdelphij	      *) func_append newdependency_libs " $deplib" ;;
9312267843Sdelphij	      esac
9313267843Sdelphij	    done
9314267843Sdelphij	    dependency_libs="$newdependency_libs"
9315267843Sdelphij	    newdlfiles=
9316267843Sdelphij
9317267843Sdelphij	    for lib in $dlfiles; do
9318267843Sdelphij	      case $lib in
9319267843Sdelphij	      *.la)
9320267843Sdelphij	        func_basename "$lib"
9321267843Sdelphij		name="$func_basename_result"
9322267843Sdelphij		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
9323267843Sdelphij		test -z "$libdir" && \
9324267843Sdelphij		  func_fatal_error "\`$lib' is not a valid libtool archive"
9325267843Sdelphij		func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name"
9326267843Sdelphij		;;
9327267843Sdelphij	      *) func_append newdlfiles " $lib" ;;
9328267843Sdelphij	      esac
9329267843Sdelphij	    done
9330267843Sdelphij	    dlfiles="$newdlfiles"
9331267843Sdelphij	    newdlprefiles=
9332267843Sdelphij	    for lib in $dlprefiles; do
9333267843Sdelphij	      case $lib in
9334267843Sdelphij	      *.la)
9335267843Sdelphij		# Only pass preopened files to the pseudo-archive (for
9336267843Sdelphij		# eventual linking with the app. that links it) if we
9337267843Sdelphij		# didn't already link the preopened objects directly into
9338267843Sdelphij		# the library:
9339267843Sdelphij		func_basename "$lib"
9340267843Sdelphij		name="$func_basename_result"
9341267843Sdelphij		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
9342267843Sdelphij		test -z "$libdir" && \
9343267843Sdelphij		  func_fatal_error "\`$lib' is not a valid libtool archive"
9344267843Sdelphij		func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name"
9345267843Sdelphij		;;
9346267843Sdelphij	      esac
9347267843Sdelphij	    done
9348267843Sdelphij	    dlprefiles="$newdlprefiles"
9349267843Sdelphij	  else
9350267843Sdelphij	    newdlfiles=
9351267843Sdelphij	    for lib in $dlfiles; do
9352267843Sdelphij	      case $lib in
9353267843Sdelphij		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
9354267843Sdelphij		*) abs=`pwd`"/$lib" ;;
9355267843Sdelphij	      esac
9356267843Sdelphij	      func_append newdlfiles " $abs"
9357267843Sdelphij	    done
9358267843Sdelphij	    dlfiles="$newdlfiles"
9359267843Sdelphij	    newdlprefiles=
9360267843Sdelphij	    for lib in $dlprefiles; do
9361267843Sdelphij	      case $lib in
9362267843Sdelphij		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
9363267843Sdelphij		*) abs=`pwd`"/$lib" ;;
9364267843Sdelphij	      esac
9365267843Sdelphij	      func_append newdlprefiles " $abs"
9366267843Sdelphij	    done
9367267843Sdelphij	    dlprefiles="$newdlprefiles"
9368267843Sdelphij	  fi
9369267843Sdelphij	  $RM $output
9370267843Sdelphij	  # place dlname in correct position for cygwin
9371267843Sdelphij	  # In fact, it would be nice if we could use this code for all target
9372267843Sdelphij	  # systems that can't hard-code library paths into their executables
9373267843Sdelphij	  # and that have no shared library path variable independent of PATH,
9374267843Sdelphij	  # but it turns out we can't easily determine that from inspecting
9375267843Sdelphij	  # libtool variables, so we have to hard-code the OSs to which it
9376267843Sdelphij	  # applies here; at the moment, that means platforms that use the PE
9377267843Sdelphij	  # object format with DLL files.  See the long comment at the top of
9378267843Sdelphij	  # tests/bindir.at for full details.
9379267843Sdelphij	  tdlname=$dlname
9380267843Sdelphij	  case $host,$output,$installed,$module,$dlname in
9381267843Sdelphij	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
9382267843Sdelphij	      # If a -bindir argument was supplied, place the dll there.
9383267843Sdelphij	      if test "x$bindir" != x ;
9384267843Sdelphij	      then
9385267843Sdelphij		func_relative_path "$install_libdir" "$bindir"
9386267843Sdelphij		tdlname=$func_relative_path_result$dlname
9387267843Sdelphij	      else
9388267843Sdelphij		# Otherwise fall back on heuristic.
9389267843Sdelphij		tdlname=../bin/$dlname
9390267843Sdelphij	      fi
9391267843Sdelphij	      ;;
9392267843Sdelphij	  esac
9393267843Sdelphij	  $ECHO > $output "\
9394267843Sdelphij# $outputname - a libtool library file
9395267843Sdelphij# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
9396267843Sdelphij#
9397267843Sdelphij# Please DO NOT delete this file!
9398267843Sdelphij# It is necessary for linking the library.
9399267843Sdelphij
9400267843Sdelphij# The name that we can dlopen(3).
9401267843Sdelphijdlname='$tdlname'
9402267843Sdelphij
9403267843Sdelphij# Names of this library.
9404267843Sdelphijlibrary_names='$library_names'
9405267843Sdelphij
9406267843Sdelphij# The name of the static archive.
9407267843Sdelphijold_library='$old_library'
9408267843Sdelphij
9409267843Sdelphij# Linker flags that can not go in dependency_libs.
9410267843Sdelphijinherited_linker_flags='$new_inherited_linker_flags'
9411267843Sdelphij
9412267843Sdelphij# Libraries that this one depends upon.
9413267843Sdelphijdependency_libs='$dependency_libs'
9414267843Sdelphij
9415267843Sdelphij# Names of additional weak libraries provided by this library
9416267843Sdelphijweak_library_names='$weak_libs'
9417267843Sdelphij
9418267843Sdelphij# Version information for $libname.
9419267843Sdelphijcurrent=$current
9420267843Sdelphijage=$age
9421267843Sdelphijrevision=$revision
9422267843Sdelphij
9423267843Sdelphij# Is this an already installed library?
9424267843Sdelphijinstalled=$installed
9425267843Sdelphij
9426267843Sdelphij# Should we warn about portability when linking against -modules?
9427267843Sdelphijshouldnotlink=$module
9428267843Sdelphij
9429267843Sdelphij# Files to dlopen/dlpreopen
9430267843Sdelphijdlopen='$dlfiles'
9431267843Sdelphijdlpreopen='$dlprefiles'
9432267843Sdelphij
9433267843Sdelphij# Directory that this library needs to be installed in:
9434267843Sdelphijlibdir='$install_libdir'"
9435309848Sdelphij	  if test "$installed" = no && test "$need_relink" = yes && \
9436309848Sdelphij	     test -n "$relink_command"; then
9437267843Sdelphij	    $ECHO >> $output "\
9438267843Sdelphijrelink_command=\"$relink_command\""
9439267843Sdelphij	  fi
9440267843Sdelphij	done
9441267843Sdelphij      }
9442267843Sdelphij
9443267843Sdelphij      # Do a symbolic link so that the libtool archive can be found in
9444267843Sdelphij      # LD_LIBRARY_PATH before the program is installed.
9445267843Sdelphij      func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
9446267843Sdelphij      ;;
9447267843Sdelphij    esac
9448267843Sdelphij    exit $EXIT_SUCCESS
9449267843Sdelphij}
9450267843Sdelphij
9451267843Sdelphij{ test "$opt_mode" = link || test "$opt_mode" = relink; } &&
9452267843Sdelphij    func_mode_link ${1+"$@"}
9453267843Sdelphij
9454267843Sdelphij
9455267843Sdelphij# func_mode_uninstall arg...
9456267843Sdelphijfunc_mode_uninstall ()
9457267843Sdelphij{
9458267843Sdelphij    $opt_debug
9459267843Sdelphij    RM="$nonopt"
9460267843Sdelphij    files=
9461267843Sdelphij    rmforce=
9462267843Sdelphij    exit_status=0
9463267843Sdelphij
9464267843Sdelphij    # This variable tells wrapper scripts just to set variables rather
9465267843Sdelphij    # than running their programs.
9466267843Sdelphij    libtool_install_magic="$magic"
9467267843Sdelphij
9468267843Sdelphij    for arg
9469267843Sdelphij    do
9470267843Sdelphij      case $arg in
9471267843Sdelphij      -f) func_append RM " $arg"; rmforce=yes ;;
9472267843Sdelphij      -*) func_append RM " $arg" ;;
9473267843Sdelphij      *) func_append files " $arg" ;;
9474267843Sdelphij      esac
9475267843Sdelphij    done
9476267843Sdelphij
9477267843Sdelphij    test -z "$RM" && \
9478267843Sdelphij      func_fatal_help "you must specify an RM program"
9479267843Sdelphij
9480267843Sdelphij    rmdirs=
9481267843Sdelphij
9482267843Sdelphij    for file in $files; do
9483267843Sdelphij      func_dirname "$file" "" "."
9484267843Sdelphij      dir="$func_dirname_result"
9485267843Sdelphij      if test "X$dir" = X.; then
9486267843Sdelphij	odir="$objdir"
9487267843Sdelphij      else
9488267843Sdelphij	odir="$dir/$objdir"
9489267843Sdelphij      fi
9490267843Sdelphij      func_basename "$file"
9491267843Sdelphij      name="$func_basename_result"
9492267843Sdelphij      test "$opt_mode" = uninstall && odir="$dir"
9493267843Sdelphij
9494267843Sdelphij      # Remember odir for removal later, being careful to avoid duplicates
9495267843Sdelphij      if test "$opt_mode" = clean; then
9496267843Sdelphij	case " $rmdirs " in
9497267843Sdelphij	  *" $odir "*) ;;
9498267843Sdelphij	  *) func_append rmdirs " $odir" ;;
9499267843Sdelphij	esac
9500267843Sdelphij      fi
9501267843Sdelphij
9502267843Sdelphij      # Don't error if the file doesn't exist and rm -f was used.
9503267843Sdelphij      if { test -L "$file"; } >/dev/null 2>&1 ||
9504267843Sdelphij	 { test -h "$file"; } >/dev/null 2>&1 ||
9505267843Sdelphij	 test -f "$file"; then
9506267843Sdelphij	:
9507267843Sdelphij      elif test -d "$file"; then
9508267843Sdelphij	exit_status=1
9509267843Sdelphij	continue
9510267843Sdelphij      elif test "$rmforce" = yes; then
9511267843Sdelphij	continue
9512267843Sdelphij      fi
9513267843Sdelphij
9514267843Sdelphij      rmfiles="$file"
9515267843Sdelphij
9516267843Sdelphij      case $name in
9517267843Sdelphij      *.la)
9518267843Sdelphij	# Possibly a libtool archive, so verify it.
9519267843Sdelphij	if func_lalib_p "$file"; then
9520267843Sdelphij	  func_source $dir/$name
9521267843Sdelphij
9522267843Sdelphij	  # Delete the libtool libraries and symlinks.
9523267843Sdelphij	  for n in $library_names; do
9524267843Sdelphij	    func_append rmfiles " $odir/$n"
9525267843Sdelphij	  done
9526267843Sdelphij	  test -n "$old_library" && func_append rmfiles " $odir/$old_library"
9527267843Sdelphij
9528267843Sdelphij	  case "$opt_mode" in
9529267843Sdelphij	  clean)
9530267843Sdelphij	    case " $library_names " in
9531267843Sdelphij	    *" $dlname "*) ;;
9532267843Sdelphij	    *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;;
9533267843Sdelphij	    esac
9534267843Sdelphij	    test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i"
9535267843Sdelphij	    ;;
9536267843Sdelphij	  uninstall)
9537267843Sdelphij	    if test -n "$library_names"; then
9538267843Sdelphij	      # Do each command in the postuninstall commands.
9539267843Sdelphij	      func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
9540267843Sdelphij	    fi
9541267843Sdelphij
9542267843Sdelphij	    if test -n "$old_library"; then
9543267843Sdelphij	      # Do each command in the old_postuninstall commands.
9544267843Sdelphij	      func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
9545267843Sdelphij	    fi
9546267843Sdelphij	    # FIXME: should reinstall the best remaining shared library.
9547267843Sdelphij	    ;;
9548267843Sdelphij	  esac
9549267843Sdelphij	fi
9550267843Sdelphij	;;
9551267843Sdelphij
9552267843Sdelphij      *.lo)
9553267843Sdelphij	# Possibly a libtool object, so verify it.
9554267843Sdelphij	if func_lalib_p "$file"; then
9555267843Sdelphij
9556267843Sdelphij	  # Read the .lo file
9557267843Sdelphij	  func_source $dir/$name
9558267843Sdelphij
9559267843Sdelphij	  # Add PIC object to the list of files to remove.
9560267843Sdelphij	  if test -n "$pic_object" &&
9561267843Sdelphij	     test "$pic_object" != none; then
9562267843Sdelphij	    func_append rmfiles " $dir/$pic_object"
9563267843Sdelphij	  fi
9564267843Sdelphij
9565267843Sdelphij	  # Add non-PIC object to the list of files to remove.
9566267843Sdelphij	  if test -n "$non_pic_object" &&
9567267843Sdelphij	     test "$non_pic_object" != none; then
9568267843Sdelphij	    func_append rmfiles " $dir/$non_pic_object"
9569267843Sdelphij	  fi
9570267843Sdelphij	fi
9571267843Sdelphij	;;
9572267843Sdelphij
9573267843Sdelphij      *)
9574267843Sdelphij	if test "$opt_mode" = clean ; then
9575267843Sdelphij	  noexename=$name
9576267843Sdelphij	  case $file in
9577267843Sdelphij	  *.exe)
9578267843Sdelphij	    func_stripname '' '.exe' "$file"
9579267843Sdelphij	    file=$func_stripname_result
9580267843Sdelphij	    func_stripname '' '.exe' "$name"
9581267843Sdelphij	    noexename=$func_stripname_result
9582267843Sdelphij	    # $file with .exe has already been added to rmfiles,
9583267843Sdelphij	    # add $file without .exe
9584267843Sdelphij	    func_append rmfiles " $file"
9585267843Sdelphij	    ;;
9586267843Sdelphij	  esac
9587267843Sdelphij	  # Do a test to see if this is a libtool program.
9588267843Sdelphij	  if func_ltwrapper_p "$file"; then
9589267843Sdelphij	    if func_ltwrapper_executable_p "$file"; then
9590267843Sdelphij	      func_ltwrapper_scriptname "$file"
9591267843Sdelphij	      relink_command=
9592267843Sdelphij	      func_source $func_ltwrapper_scriptname_result
9593267843Sdelphij	      func_append rmfiles " $func_ltwrapper_scriptname_result"
9594267843Sdelphij	    else
9595267843Sdelphij	      relink_command=
9596267843Sdelphij	      func_source $dir/$noexename
9597267843Sdelphij	    fi
9598267843Sdelphij
9599267843Sdelphij	    # note $name still contains .exe if it was in $file originally
9600267843Sdelphij	    # as does the version of $file that was added into $rmfiles
9601267843Sdelphij	    func_append rmfiles " $odir/$name $odir/${name}S.${objext}"
9602267843Sdelphij	    if test "$fast_install" = yes && test -n "$relink_command"; then
9603267843Sdelphij	      func_append rmfiles " $odir/lt-$name"
9604267843Sdelphij	    fi
9605267843Sdelphij	    if test "X$noexename" != "X$name" ; then
9606267843Sdelphij	      func_append rmfiles " $odir/lt-${noexename}.c"
9607267843Sdelphij	    fi
9608267843Sdelphij	  fi
9609267843Sdelphij	fi
9610267843Sdelphij	;;
9611267843Sdelphij      esac
9612267843Sdelphij      func_show_eval "$RM $rmfiles" 'exit_status=1'
9613267843Sdelphij    done
9614267843Sdelphij
9615267843Sdelphij    # Try to remove the ${objdir}s in the directories where we deleted files
9616267843Sdelphij    for dir in $rmdirs; do
9617267843Sdelphij      if test -d "$dir"; then
9618267843Sdelphij	func_show_eval "rmdir $dir >/dev/null 2>&1"
9619267843Sdelphij      fi
9620267843Sdelphij    done
9621267843Sdelphij
9622267843Sdelphij    exit $exit_status
9623267843Sdelphij}
9624267843Sdelphij
9625267843Sdelphij{ test "$opt_mode" = uninstall || test "$opt_mode" = clean; } &&
9626267843Sdelphij    func_mode_uninstall ${1+"$@"}
9627267843Sdelphij
9628267843Sdelphijtest -z "$opt_mode" && {
9629267843Sdelphij  help="$generic_help"
9630267843Sdelphij  func_fatal_help "you must specify a MODE"
9631267843Sdelphij}
9632267843Sdelphij
9633267843Sdelphijtest -z "$exec_cmd" && \
9634267843Sdelphij  func_fatal_help "invalid operation mode \`$opt_mode'"
9635267843Sdelphij
9636267843Sdelphijif test -n "$exec_cmd"; then
9637267843Sdelphij  eval exec "$exec_cmd"
9638267843Sdelphij  exit $EXIT_FAILURE
9639267843Sdelphijfi
9640267843Sdelphij
9641267843Sdelphijexit $exit_status
9642267843Sdelphij
9643267843Sdelphij
9644267843Sdelphij# The TAGs below are defined such that we never get into a situation
9645267843Sdelphij# in which we disable both kinds of libraries.  Given conflicting
9646267843Sdelphij# choices, we go for a static library, that is the most portable,
9647267843Sdelphij# since we can't tell whether shared libraries were disabled because
9648267843Sdelphij# the user asked for that or because the platform doesn't support
9649267843Sdelphij# them.  This is particularly important on AIX, because we don't
9650267843Sdelphij# support having both static and shared libraries enabled at the same
9651267843Sdelphij# time on that platform, so we default to a shared-only configuration.
9652267843Sdelphij# If a disable-shared tag is given, we'll fallback to a static-only
9653267843Sdelphij# configuration.  But we'll never go from static-only to shared-only.
9654267843Sdelphij
9655267843Sdelphij# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
9656267843Sdelphijbuild_libtool_libs=no
9657267843Sdelphijbuild_old_libs=yes
9658267843Sdelphij# ### END LIBTOOL TAG CONFIG: disable-shared
9659267843Sdelphij
9660267843Sdelphij# ### BEGIN LIBTOOL TAG CONFIG: disable-static
9661267843Sdelphijbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
9662267843Sdelphij# ### END LIBTOOL TAG CONFIG: disable-static
9663267843Sdelphij
9664267843Sdelphij# Local Variables:
9665267843Sdelphij# mode:shell-script
9666267843Sdelphij# sh-indentation:2
9667267843Sdelphij# End:
9668267843Sdelphij# vi:sw=2
9669267843Sdelphij
9670