1247568Sdes
2247568Sdes# libtool (GNU libtool) 2.4.2
3247568Sdes# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
4247568Sdes
5174832Sdes# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006,
6247568Sdes# 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
7247568Sdes# This is free software; see the source for copying conditions.  There is NO
8247568Sdes# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9247568Sdes
10247568Sdes# GNU Libtool is free software; you can redistribute it and/or modify
11117610Sdes# it under the terms of the GNU General Public License as published by
12117610Sdes# the Free Software Foundation; either version 2 of the License, or
13117610Sdes# (at your option) any later version.
14117610Sdes#
15247568Sdes# As a special exception to the GNU General Public License,
16247568Sdes# if you distribute this file as part of a program or library that
17247568Sdes# is built using GNU Libtool, you may include this file under the
18247568Sdes# same distribution terms that you use for the rest of that program.
19247568Sdes#
20247568Sdes# GNU Libtool is distributed in the hope that it will be useful, but
21117610Sdes# WITHOUT ANY WARRANTY; without even the implied warranty of
22117610Sdes# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
23117610Sdes# General Public License for more details.
24117610Sdes#
25117610Sdes# You should have received a copy of the GNU General Public License
26247568Sdes# along with GNU Libtool; see the file COPYING.  If not, a copy
27247568Sdes# can be downloaded from http://www.gnu.org/licenses/gpl.html,
28247568Sdes# or obtained by writing to the Free Software Foundation, Inc.,
29247568Sdes# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
30247568Sdes
31247568Sdes# Usage: $progname [OPTION]... [MODE-ARG]...
32117610Sdes#
33247568Sdes# Provide generalized library-building support services.
34247568Sdes#
35247568Sdes#       --config             show all configuration variables
36247568Sdes#       --debug              enable verbose shell tracing
37247568Sdes#   -n, --dry-run            display commands without modifying any files
38247568Sdes#       --features           display basic configuration information and exit
39247568Sdes#       --mode=MODE          use operation mode MODE
40247568Sdes#       --preserve-dup-deps  don't remove duplicate dependency libraries
41247568Sdes#       --quiet, --silent    don't print informational messages
42247568Sdes#       --no-quiet, --no-silent
43247568Sdes#                            print informational messages (default)
44247568Sdes#       --no-warn            don't display warning messages
45247568Sdes#       --tag=TAG            use configuration variables from tag TAG
46247568Sdes#   -v, --verbose            print more informational messages than default
47247568Sdes#       --no-verbose         don't print the extra informational messages
48247568Sdes#       --version            print version information
49247568Sdes#   -h, --help, --help-all   print short, long, or detailed help message
50247568Sdes#
51247568Sdes# MODE must be one of the following:
52247568Sdes#
53247568Sdes#         clean              remove files from the build directory
54247568Sdes#         compile            compile a source file into a libtool object
55247568Sdes#         execute            automatically set library path, then run a program
56247568Sdes#         finish             complete the installation of libtool libraries
57247568Sdes#         install            install libraries or executables
58247568Sdes#         link               create a library or an executable
59247568Sdes#         uninstall          remove libraries from an installed directory
60247568Sdes#
61247568Sdes# MODE-ARGS vary depending on the MODE.  When passed as first option,
62247568Sdes# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that.
63247568Sdes# Try `$progname --help --mode=MODE' for a more detailed description of MODE.
64247568Sdes#
65247568Sdes# When reporting a bug, please describe a test case to reproduce it and
66247568Sdes# include the following information:
67247568Sdes#
68247568Sdes#         host-triplet:	$host
69247568Sdes#         shell:		$SHELL
70247568Sdes#         compiler:		$LTCC
71247568Sdes#         compiler flags:		$LTCFLAGS
72247568Sdes#         linker:		$LD (gnu? $with_gnu_ld)
73247568Sdes#         $progname:	(GNU libtool) 2.4.2
74247568Sdes#         automake:	$automake_version
75247568Sdes#         autoconf:	$autoconf_version
76247568Sdes#
77247568Sdes# Report bugs to <bug-libtool@gnu.org>.
78247568Sdes# GNU libtool home page: <http://www.gnu.org/software/libtool/>.
79247568Sdes# General help using GNU software: <http://www.gnu.org/gethelp/>.
80117610Sdes
81247568SdesPROGRAM=libtool
82141098SdesPACKAGE=libtool
83247568SdesVERSION=2.4.2
84247568SdesTIMESTAMP=""
85247568Sdespackage_revision=1.3337
86141098Sdes
87247568Sdes# Be Bourne compatible
88174832Sdesif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
89174832Sdes  emulate sh
90174832Sdes  NULLCMD=:
91174832Sdes  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
92174832Sdes  # is contrary to our usage.  Disable this feature.
93174832Sdes  alias -g '${1+"$@"}'='"$@"'
94141098Sdes  setopt NO_GLOB_SUBST
95174832Sdeselse
96174832Sdes  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
97141098Sdesfi
98174832SdesBIN_SH=xpg4; export BIN_SH # for Tru64
99174832SdesDUALCASE=1; export DUALCASE # for MKS sh
100141098Sdes
101247568Sdes# A function that is used when there is no print builtin or printf.
102247568Sdesfunc_fallback_echo ()
103247568Sdes{
104247568Sdes  eval 'cat <<_LTECHO_EOF
105247568Sdes$1
106247568Sdes_LTECHO_EOF'
107247568Sdes}
108117610Sdes
109247568Sdes# NLS nuisances: We save the old values to restore during execute mode.
110247568Sdeslt_user_locale=
111247568Sdeslt_safe_locale=
112247568Sdesfor lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
113174832Sdesdo
114174832Sdes  eval "if test \"\${$lt_var+set}\" = set; then
115247568Sdes          save_$lt_var=\$$lt_var
116247568Sdes          $lt_var=C
117174832Sdes	  export $lt_var
118247568Sdes	  lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\"
119247568Sdes	  lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
120174832Sdes	fi"
121174832Sdesdone
122247568SdesLC_ALL=C
123247568SdesLANGUAGE=C
124247568Sdesexport LANGUAGE LC_ALL
125117610Sdes
126247568Sdes$lt_unset CDPATH
127247568Sdes
128247568Sdes
129247568Sdes# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
130247568Sdes# is ksh but when the shell is invoked as "sh" and the current value of
131247568Sdes# the _XPG environment variable is not equal to 1 (one), the special
132247568Sdes# positional parameter $0, within a function call, is the name of the
133247568Sdes# function.
134247568Sdesprogpath="$0"
135247568Sdes
136247568Sdes
137247568Sdes
138247568Sdes: ${CP="cp -f"}
139247568Sdestest "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'}
140247568Sdes: ${MAKE="make"}
141247568Sdes: ${MKDIR="mkdir"}
142247568Sdes: ${MV="mv -f"}
143247568Sdes: ${RM="rm -f"}
144247568Sdes: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
145247568Sdes: ${Xsed="$SED -e 1s/^X//"}
146247568Sdes
147247568Sdes# Global variables:
148247568SdesEXIT_SUCCESS=0
149247568SdesEXIT_FAILURE=1
150247568SdesEXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
151247568SdesEXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
152247568Sdes
153247568Sdesexit_status=$EXIT_SUCCESS
154247568Sdes
155125647Sdes# Make sure IFS has a sensible default
156174832Sdeslt_nl='
157174832Sdes'
158174832SdesIFS=" 	$lt_nl"
159117610Sdes
160247568Sdesdirname="s,/[^/]*$,,"
161247568Sdesbasename="s,^.*/,,"
162117610Sdes
163247568Sdes# func_dirname file append nondir_replacement
164247568Sdes# Compute the dirname of FILE.  If nonempty, add APPEND to the result,
165247568Sdes# otherwise set result to NONDIR_REPLACEMENT.
166247568Sdesfunc_dirname ()
167247568Sdes{
168247568Sdes    func_dirname_result=`$ECHO "${1}" | $SED "$dirname"`
169247568Sdes    if test "X$func_dirname_result" = "X${1}"; then
170247568Sdes      func_dirname_result="${3}"
171247568Sdes    else
172247568Sdes      func_dirname_result="$func_dirname_result${2}"
173247568Sdes    fi
174247568Sdes} # func_dirname may be replaced by extended shell implementation
175117610Sdes
176141098Sdes
177247568Sdes# func_basename file
178247568Sdesfunc_basename ()
179247568Sdes{
180247568Sdes    func_basename_result=`$ECHO "${1}" | $SED "$basename"`
181247568Sdes} # func_basename may be replaced by extended shell implementation
182247568Sdes
183247568Sdes
184247568Sdes# func_dirname_and_basename file append nondir_replacement
185247568Sdes# perform func_basename and func_dirname in a single function
186247568Sdes# call:
187247568Sdes#   dirname:  Compute the dirname of FILE.  If nonempty,
188247568Sdes#             add APPEND to the result, otherwise set result
189247568Sdes#             to NONDIR_REPLACEMENT.
190247568Sdes#             value returned in "$func_dirname_result"
191247568Sdes#   basename: Compute filename of FILE.
192247568Sdes#             value retuned in "$func_basename_result"
193247568Sdes# Implementation must be kept synchronized with func_dirname
194247568Sdes# and func_basename. For efficiency, we do not delegate to
195247568Sdes# those functions but instead duplicate the functionality here.
196247568Sdesfunc_dirname_and_basename ()
197247568Sdes{
198247568Sdes    # Extract subdirectory from the argument.
199247568Sdes    func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"`
200247568Sdes    if test "X$func_dirname_result" = "X${1}"; then
201247568Sdes      func_dirname_result="${3}"
202247568Sdes    else
203247568Sdes      func_dirname_result="$func_dirname_result${2}"
204247568Sdes    fi
205247568Sdes    func_basename_result=`$ECHO "${1}" | $SED -e "$basename"`
206247568Sdes} # func_dirname_and_basename may be replaced by extended shell implementation
207247568Sdes
208247568Sdes
209247568Sdes# func_stripname prefix suffix name
210247568Sdes# strip PREFIX and SUFFIX off of NAME.
211247568Sdes# PREFIX and SUFFIX must not contain globbing or regex special
212247568Sdes# characters, hashes, percent signs, but SUFFIX may contain a leading
213247568Sdes# dot (in which case that matches only a dot).
214247568Sdes# func_strip_suffix prefix name
215247568Sdesfunc_stripname ()
216247568Sdes{
217247568Sdes    case ${2} in
218247568Sdes      .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;;
219247568Sdes      *)  func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;;
220247568Sdes    esac
221247568Sdes} # func_stripname may be replaced by extended shell implementation
222247568Sdes
223247568Sdes
224247568Sdes# These SED scripts presuppose an absolute path with a trailing slash.
225247568Sdespathcar='s,^/\([^/]*\).*$,\1,'
226247568Sdespathcdr='s,^/[^/]*,,'
227247568Sdesremovedotparts=':dotsl
228247568Sdes		s@/\./@/@g
229247568Sdes		t dotsl
230247568Sdes		s,/\.$,/,'
231247568Sdescollapseslashes='s@/\{1,\}@/@g'
232247568Sdesfinalslash='s,/*$,/,'
233247568Sdes
234247568Sdes# func_normal_abspath PATH
235247568Sdes# Remove doubled-up and trailing slashes, "." path components,
236247568Sdes# and cancel out any ".." path components in PATH after making
237247568Sdes# it an absolute path.
238247568Sdes#             value returned in "$func_normal_abspath_result"
239247568Sdesfunc_normal_abspath ()
240247568Sdes{
241247568Sdes  # Start from root dir and reassemble the path.
242247568Sdes  func_normal_abspath_result=
243247568Sdes  func_normal_abspath_tpath=$1
244247568Sdes  func_normal_abspath_altnamespace=
245247568Sdes  case $func_normal_abspath_tpath in
246247568Sdes    "")
247247568Sdes      # Empty path, that just means $cwd.
248247568Sdes      func_stripname '' '/' "`pwd`"
249247568Sdes      func_normal_abspath_result=$func_stripname_result
250247568Sdes      return
251247568Sdes    ;;
252247568Sdes    # The next three entries are used to spot a run of precisely
253247568Sdes    # two leading slashes without using negated character classes;
254247568Sdes    # we take advantage of case's first-match behaviour.
255247568Sdes    ///*)
256247568Sdes      # Unusual form of absolute path, do nothing.
257247568Sdes    ;;
258247568Sdes    //*)
259247568Sdes      # Not necessarily an ordinary path; POSIX reserves leading '//'
260247568Sdes      # and for example Cygwin uses it to access remote file shares
261247568Sdes      # over CIFS/SMB, so we conserve a leading double slash if found.
262247568Sdes      func_normal_abspath_altnamespace=/
263247568Sdes    ;;
264247568Sdes    /*)
265247568Sdes      # Absolute path, do nothing.
266247568Sdes    ;;
267247568Sdes    *)
268247568Sdes      # Relative path, prepend $cwd.
269247568Sdes      func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
270247568Sdes    ;;
271247568Sdes  esac
272247568Sdes  # Cancel out all the simple stuff to save iterations.  We also want
273247568Sdes  # the path to end with a slash for ease of parsing, so make sure
274247568Sdes  # there is one (and only one) here.
275247568Sdes  func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
276247568Sdes        -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"`
277247568Sdes  while :; do
278247568Sdes    # Processed it all yet?
279247568Sdes    if test "$func_normal_abspath_tpath" = / ; then
280247568Sdes      # If we ascended to the root using ".." the result may be empty now.
281247568Sdes      if test -z "$func_normal_abspath_result" ; then
282247568Sdes        func_normal_abspath_result=/
283247568Sdes      fi
284247568Sdes      break
285247568Sdes    fi
286247568Sdes    func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
287247568Sdes        -e "$pathcar"`
288247568Sdes    func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
289247568Sdes        -e "$pathcdr"`
290247568Sdes    # Figure out what to do with it
291247568Sdes    case $func_normal_abspath_tcomponent in
292247568Sdes      "")
293247568Sdes        # Trailing empty path component, ignore it.
294247568Sdes      ;;
295247568Sdes      ..)
296247568Sdes        # Parent dir; strip last assembled component from result.
297247568Sdes        func_dirname "$func_normal_abspath_result"
298247568Sdes        func_normal_abspath_result=$func_dirname_result
299247568Sdes      ;;
300247568Sdes      *)
301247568Sdes        # Actual path component, append it.
302247568Sdes        func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent
303247568Sdes      ;;
304247568Sdes    esac
305247568Sdes  done
306247568Sdes  # Restore leading double-slash if one was found on entry.
307247568Sdes  func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
308247568Sdes}
309247568Sdes
310247568Sdes# func_relative_path SRCDIR DSTDIR
311247568Sdes# generates a relative path from SRCDIR to DSTDIR, with a trailing
312247568Sdes# slash if non-empty, suitable for immediately appending a filename
313247568Sdes# without needing to append a separator.
314247568Sdes#             value returned in "$func_relative_path_result"
315247568Sdesfunc_relative_path ()
316247568Sdes{
317247568Sdes  func_relative_path_result=
318247568Sdes  func_normal_abspath "$1"
319247568Sdes  func_relative_path_tlibdir=$func_normal_abspath_result
320247568Sdes  func_normal_abspath "$2"
321247568Sdes  func_relative_path_tbindir=$func_normal_abspath_result
322247568Sdes
323247568Sdes  # Ascend the tree starting from libdir
324247568Sdes  while :; do
325247568Sdes    # check if we have found a prefix of bindir
326247568Sdes    case $func_relative_path_tbindir in
327247568Sdes      $func_relative_path_tlibdir)
328247568Sdes        # found an exact match
329247568Sdes        func_relative_path_tcancelled=
330247568Sdes        break
331247568Sdes        ;;
332247568Sdes      $func_relative_path_tlibdir*)
333247568Sdes        # found a matching prefix
334247568Sdes        func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
335247568Sdes        func_relative_path_tcancelled=$func_stripname_result
336247568Sdes        if test -z "$func_relative_path_result"; then
337247568Sdes          func_relative_path_result=.
338247568Sdes        fi
339247568Sdes        break
340247568Sdes        ;;
341247568Sdes      *)
342247568Sdes        func_dirname $func_relative_path_tlibdir
343247568Sdes        func_relative_path_tlibdir=${func_dirname_result}
344247568Sdes        if test "x$func_relative_path_tlibdir" = x ; then
345247568Sdes          # Have to descend all the way to the root!
346247568Sdes          func_relative_path_result=../$func_relative_path_result
347247568Sdes          func_relative_path_tcancelled=$func_relative_path_tbindir
348247568Sdes          break
349247568Sdes        fi
350247568Sdes        func_relative_path_result=../$func_relative_path_result
351247568Sdes        ;;
352247568Sdes    esac
353247568Sdes  done
354247568Sdes
355247568Sdes  # Now calculate path; take care to avoid doubling-up slashes.
356247568Sdes  func_stripname '' '/' "$func_relative_path_result"
357247568Sdes  func_relative_path_result=$func_stripname_result
358247568Sdes  func_stripname '/' '/' "$func_relative_path_tcancelled"
359247568Sdes  if test "x$func_stripname_result" != x ; then
360247568Sdes    func_relative_path_result=${func_relative_path_result}/${func_stripname_result}
361247568Sdes  fi
362247568Sdes
363247568Sdes  # Normalisation. If bindir is libdir, return empty string,
364247568Sdes  # else relative path ending with a slash; either way, target
365247568Sdes  # file name can be directly appended.
366247568Sdes  if test ! -z "$func_relative_path_result"; then
367247568Sdes    func_stripname './' '' "$func_relative_path_result/"
368247568Sdes    func_relative_path_result=$func_stripname_result
369247568Sdes  fi
370247568Sdes}
371247568Sdes
372247568Sdes# The name of this program:
373247568Sdesfunc_dirname_and_basename "$progpath"
374247568Sdesprogname=$func_basename_result
375247568Sdes
376247568Sdes# Make sure we have an absolute path for reexecution:
377247568Sdescase $progpath in
378247568Sdes  [\\/]*|[A-Za-z]:\\*) ;;
379247568Sdes  *[\\/]*)
380247568Sdes     progdir=$func_dirname_result
381247568Sdes     progdir=`cd "$progdir" && pwd`
382247568Sdes     progpath="$progdir/$progname"
383247568Sdes     ;;
384247568Sdes  *)
385247568Sdes     save_IFS="$IFS"
386247568Sdes     IFS=${PATH_SEPARATOR-:}
387247568Sdes     for progdir in $PATH; do
388247568Sdes       IFS="$save_IFS"
389247568Sdes       test -x "$progdir/$progname" && break
390247568Sdes     done
391247568Sdes     IFS="$save_IFS"
392247568Sdes     test -n "$progdir" || progdir=`pwd`
393247568Sdes     progpath="$progdir/$progname"
394247568Sdes     ;;
395247568Sdesesac
396247568Sdes
397247568Sdes# Sed substitution that helps us do robust quoting.  It backslashifies
398247568Sdes# metacharacters that are still active within double-quoted strings.
399247568SdesXsed="${SED}"' -e 1s/^X//'
400247568Sdessed_quote_subst='s/\([`"$\\]\)/\\\1/g'
401247568Sdes
402247568Sdes# Same as above, but do not quote variable references.
403247568Sdesdouble_quote_subst='s/\(["`\\]\)/\\\1/g'
404247568Sdes
405247568Sdes# Sed substitution that turns a string into a regex matching for the
406247568Sdes# string literally.
407247568Sdessed_make_literal_regex='s,[].[^$\\*\/],\\&,g'
408247568Sdes
409247568Sdes# Sed substitution that converts a w32 file name or path
410247568Sdes# which contains forward slashes, into one that contains
411247568Sdes# (escaped) backslashes.  A very naive implementation.
412247568Sdeslt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
413247568Sdes
414247568Sdes# Re-`\' parameter expansions in output of double_quote_subst that were
415247568Sdes# `\'-ed in input to the same.  If an odd number of `\' preceded a '$'
416247568Sdes# in input to double_quote_subst, that '$' was protected from expansion.
417247568Sdes# Since each input `\' is now two `\'s, look for any number of runs of
418247568Sdes# four `\'s followed by two `\'s and then a '$'.  `\' that '$'.
419247568Sdesbs='\\'
420247568Sdesbs2='\\\\'
421247568Sdesbs4='\\\\\\\\'
422247568Sdesdollar='\$'
423247568Sdessed_double_backslash="\
424247568Sdes  s/$bs4/&\\
425247568Sdes/g
426247568Sdes  s/^$bs2$dollar/$bs&/
427247568Sdes  s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
428247568Sdes  s/\n//g"
429247568Sdes
430247568Sdes# Standard options:
431247568Sdesopt_dry_run=false
432247568Sdesopt_help=false
433247568Sdesopt_quiet=false
434247568Sdesopt_verbose=false
435247568Sdesopt_warning=:
436247568Sdes
437247568Sdes# func_echo arg...
438247568Sdes# Echo program name prefixed message, along with the current mode
439247568Sdes# name if it has been set yet.
440247568Sdesfunc_echo ()
441247568Sdes{
442247568Sdes    $ECHO "$progname: ${opt_mode+$opt_mode: }$*"
443247568Sdes}
444247568Sdes
445247568Sdes# func_verbose arg...
446247568Sdes# Echo program name prefixed message in verbose mode only.
447247568Sdesfunc_verbose ()
448247568Sdes{
449247568Sdes    $opt_verbose && func_echo ${1+"$@"}
450247568Sdes
451247568Sdes    # A bug in bash halts the script if the last line of a function
452247568Sdes    # fails when set -e is in force, so we need another command to
453247568Sdes    # work around that:
454247568Sdes    :
455247568Sdes}
456247568Sdes
457247568Sdes# func_echo_all arg...
458247568Sdes# Invoke $ECHO with all args, space-separated.
459247568Sdesfunc_echo_all ()
460247568Sdes{
461247568Sdes    $ECHO "$*"
462247568Sdes}
463247568Sdes
464247568Sdes# func_error arg...
465247568Sdes# Echo program name prefixed message to standard error.
466247568Sdesfunc_error ()
467247568Sdes{
468247568Sdes    $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2
469247568Sdes}
470247568Sdes
471247568Sdes# func_warning arg...
472247568Sdes# Echo program name prefixed warning message to standard error.
473247568Sdesfunc_warning ()
474247568Sdes{
475247568Sdes    $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2
476247568Sdes
477247568Sdes    # bash bug again:
478247568Sdes    :
479247568Sdes}
480247568Sdes
481247568Sdes# func_fatal_error arg...
482247568Sdes# Echo program name prefixed message to standard error, and exit.
483247568Sdesfunc_fatal_error ()
484247568Sdes{
485247568Sdes    func_error ${1+"$@"}
486247568Sdes    exit $EXIT_FAILURE
487247568Sdes}
488247568Sdes
489247568Sdes# func_fatal_help arg...
490247568Sdes# Echo program name prefixed message to standard error, followed by
491247568Sdes# a help hint, and exit.
492247568Sdesfunc_fatal_help ()
493247568Sdes{
494247568Sdes    func_error ${1+"$@"}
495247568Sdes    func_fatal_error "$help"
496247568Sdes}
497247568Sdeshelp="Try \`$progname --help' for more information."  ## default
498247568Sdes
499247568Sdes
500247568Sdes# func_grep expression filename
501247568Sdes# Check whether EXPRESSION matches any line of FILENAME, without output.
502247568Sdesfunc_grep ()
503247568Sdes{
504247568Sdes    $GREP "$1" "$2" >/dev/null 2>&1
505247568Sdes}
506247568Sdes
507247568Sdes
508247568Sdes# func_mkdir_p directory-path
509247568Sdes# Make sure the entire path to DIRECTORY-PATH is available.
510247568Sdesfunc_mkdir_p ()
511247568Sdes{
512247568Sdes    my_directory_path="$1"
513247568Sdes    my_dir_list=
514247568Sdes
515247568Sdes    if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
516247568Sdes
517247568Sdes      # Protect directory names starting with `-'
518247568Sdes      case $my_directory_path in
519247568Sdes        -*) my_directory_path="./$my_directory_path" ;;
520247568Sdes      esac
521247568Sdes
522247568Sdes      # While some portion of DIR does not yet exist...
523247568Sdes      while test ! -d "$my_directory_path"; do
524247568Sdes        # ...make a list in topmost first order.  Use a colon delimited
525247568Sdes	# list incase some portion of path contains whitespace.
526247568Sdes        my_dir_list="$my_directory_path:$my_dir_list"
527247568Sdes
528247568Sdes        # If the last portion added has no slash in it, the list is done
529247568Sdes        case $my_directory_path in */*) ;; *) break ;; esac
530247568Sdes
531247568Sdes        # ...otherwise throw away the child directory and loop
532247568Sdes        my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"`
533247568Sdes      done
534247568Sdes      my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'`
535247568Sdes
536247568Sdes      save_mkdir_p_IFS="$IFS"; IFS=':'
537247568Sdes      for my_dir in $my_dir_list; do
538247568Sdes	IFS="$save_mkdir_p_IFS"
539247568Sdes        # mkdir can fail with a `File exist' error if two processes
540247568Sdes        # try to create one of the directories concurrently.  Don't
541247568Sdes        # stop in that case!
542247568Sdes        $MKDIR "$my_dir" 2>/dev/null || :
543247568Sdes      done
544247568Sdes      IFS="$save_mkdir_p_IFS"
545247568Sdes
546247568Sdes      # Bail out if we (or some other process) failed to create a directory.
547247568Sdes      test -d "$my_directory_path" || \
548247568Sdes        func_fatal_error "Failed to create \`$1'"
549247568Sdes    fi
550247568Sdes}
551247568Sdes
552247568Sdes
553174832Sdes# func_mktempdir [string]
554174832Sdes# Make a temporary directory that won't clash with other running
555174832Sdes# libtool processes, and avoids race conditions if possible.  If
556174832Sdes# given, STRING is the basename for that directory.
557174832Sdesfunc_mktempdir ()
558174832Sdes{
559174832Sdes    my_template="${TMPDIR-/tmp}/${1-$progname}"
560174832Sdes
561247568Sdes    if test "$opt_dry_run" = ":"; then
562174832Sdes      # Return a directory name, but don't create it in dry-run mode
563174832Sdes      my_tmpdir="${my_template}-$$"
564174832Sdes    else
565174832Sdes
566174832Sdes      # If mktemp works, use that first and foremost
567174832Sdes      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
568174832Sdes
569174832Sdes      if test ! -d "$my_tmpdir"; then
570247568Sdes        # Failing that, at least try and use $RANDOM to avoid a race
571247568Sdes        my_tmpdir="${my_template}-${RANDOM-0}$$"
572174832Sdes
573247568Sdes        save_mktempdir_umask=`umask`
574247568Sdes        umask 0077
575247568Sdes        $MKDIR "$my_tmpdir"
576247568Sdes        umask $save_mktempdir_umask
577174832Sdes      fi
578174832Sdes
579174832Sdes      # If we're not in dry-run mode, bomb out on failure
580247568Sdes      test -d "$my_tmpdir" || \
581247568Sdes        func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
582174832Sdes    fi
583174832Sdes
584247568Sdes    $ECHO "$my_tmpdir"
585174832Sdes}
586174832Sdes
587174832Sdes
588247568Sdes# func_quote_for_eval arg
589247568Sdes# Aesthetically quote ARG to be evaled later.
590247568Sdes# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
591247568Sdes# is double-quoted, suitable for a subsequent eval, whereas
592247568Sdes# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
593247568Sdes# which are still active within double quotes backslashified.
594247568Sdesfunc_quote_for_eval ()
595147455Sdes{
596247568Sdes    case $1 in
597247568Sdes      *[\\\`\"\$]*)
598247568Sdes	func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;;
599247568Sdes      *)
600247568Sdes        func_quote_for_eval_unquoted_result="$1" ;;
601247568Sdes    esac
602247568Sdes
603247568Sdes    case $func_quote_for_eval_unquoted_result in
604247568Sdes      # Double-quote args containing shell metacharacters to delay
605247568Sdes      # word splitting, command substitution and and variable
606247568Sdes      # expansion for a subsequent eval.
607247568Sdes      # Many Bourne shells cannot handle close brackets correctly
608247568Sdes      # in scan sets, so we specify it separately.
609247568Sdes      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
610247568Sdes        func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
611247568Sdes        ;;
612247568Sdes      *)
613247568Sdes        func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
614247568Sdes    esac
615247568Sdes}
616247568Sdes
617247568Sdes
618247568Sdes# func_quote_for_expand arg
619247568Sdes# Aesthetically quote ARG to be evaled later; same as above,
620247568Sdes# but do not quote variable references.
621247568Sdesfunc_quote_for_expand ()
622247568Sdes{
623247568Sdes    case $1 in
624247568Sdes      *[\\\`\"]*)
625247568Sdes	my_arg=`$ECHO "$1" | $SED \
626247568Sdes	    -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
627247568Sdes      *)
628247568Sdes        my_arg="$1" ;;
629247568Sdes    esac
630247568Sdes
631247568Sdes    case $my_arg in
632247568Sdes      # Double-quote args containing shell metacharacters to delay
633247568Sdes      # word splitting and command substitution for a subsequent eval.
634247568Sdes      # Many Bourne shells cannot handle close brackets correctly
635247568Sdes      # in scan sets, so we specify it separately.
636247568Sdes      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
637247568Sdes        my_arg="\"$my_arg\""
638247568Sdes        ;;
639247568Sdes    esac
640247568Sdes
641247568Sdes    func_quote_for_expand_result="$my_arg"
642247568Sdes}
643247568Sdes
644247568Sdes
645247568Sdes# func_show_eval cmd [fail_exp]
646247568Sdes# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
647247568Sdes# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
648247568Sdes# is given, then evaluate it.
649247568Sdesfunc_show_eval ()
650247568Sdes{
651247568Sdes    my_cmd="$1"
652247568Sdes    my_fail_exp="${2-:}"
653247568Sdes
654247568Sdes    ${opt_silent-false} || {
655247568Sdes      func_quote_for_expand "$my_cmd"
656247568Sdes      eval "func_echo $func_quote_for_expand_result"
657247568Sdes    }
658247568Sdes
659247568Sdes    if ${opt_dry_run-false}; then :; else
660247568Sdes      eval "$my_cmd"
661247568Sdes      my_status=$?
662247568Sdes      if test "$my_status" -eq 0; then :; else
663247568Sdes	eval "(exit $my_status); $my_fail_exp"
664247568Sdes      fi
665141098Sdes    fi
666247568Sdes}
667247568Sdes
668247568Sdes
669247568Sdes# func_show_eval_locale cmd [fail_exp]
670247568Sdes# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
671247568Sdes# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
672247568Sdes# is given, then evaluate it.  Use the saved locale for evaluation.
673247568Sdesfunc_show_eval_locale ()
674247568Sdes{
675247568Sdes    my_cmd="$1"
676247568Sdes    my_fail_exp="${2-:}"
677247568Sdes
678247568Sdes    ${opt_silent-false} || {
679247568Sdes      func_quote_for_expand "$my_cmd"
680247568Sdes      eval "func_echo $func_quote_for_expand_result"
681247568Sdes    }
682247568Sdes
683247568Sdes    if ${opt_dry_run-false}; then :; else
684247568Sdes      eval "$lt_user_locale
685247568Sdes	    $my_cmd"
686247568Sdes      my_status=$?
687247568Sdes      eval "$lt_safe_locale"
688247568Sdes      if test "$my_status" -eq 0; then :; else
689247568Sdes	eval "(exit $my_status); $my_fail_exp"
690247568Sdes      fi
691247568Sdes    fi
692247568Sdes}
693247568Sdes
694247568Sdes# func_tr_sh
695247568Sdes# Turn $1 into a string suitable for a shell variable name.
696247568Sdes# Result is stored in $func_tr_sh_result.  All characters
697247568Sdes# not in the set a-zA-Z0-9_ are replaced with '_'. Further,
698247568Sdes# if $1 begins with a digit, a '_' is prepended as well.
699247568Sdesfunc_tr_sh ()
700247568Sdes{
701247568Sdes  case $1 in
702247568Sdes  [0-9]* | *[!a-zA-Z0-9_]*)
703247568Sdes    func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'`
704141098Sdes    ;;
705247568Sdes  * )
706247568Sdes    func_tr_sh_result=$1
707141098Sdes    ;;
708247568Sdes  esac
709247568Sdes}
710247568Sdes
711247568Sdes
712247568Sdes# func_version
713247568Sdes# Echo version message to standard output and exit.
714247568Sdesfunc_version ()
715247568Sdes{
716247568Sdes    $opt_debug
717247568Sdes
718247568Sdes    $SED -n '/(C)/!b go
719247568Sdes	:more
720247568Sdes	/\./!{
721247568Sdes	  N
722247568Sdes	  s/\n# / /
723247568Sdes	  b more
724247568Sdes	}
725247568Sdes	:go
726247568Sdes	/^# '$PROGRAM' (GNU /,/# warranty; / {
727247568Sdes        s/^# //
728247568Sdes	s/^# *$//
729247568Sdes        s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
730247568Sdes        p
731247568Sdes     }' < "$progpath"
732247568Sdes     exit $?
733247568Sdes}
734247568Sdes
735247568Sdes# func_usage
736247568Sdes# Echo short help message to standard output and exit.
737247568Sdesfunc_usage ()
738247568Sdes{
739247568Sdes    $opt_debug
740247568Sdes
741247568Sdes    $SED -n '/^# Usage:/,/^#  *.*--help/ {
742247568Sdes        s/^# //
743247568Sdes	s/^# *$//
744247568Sdes	s/\$progname/'$progname'/
745247568Sdes	p
746247568Sdes    }' < "$progpath"
747247568Sdes    echo
748247568Sdes    $ECHO "run \`$progname --help | more' for full usage"
749247568Sdes    exit $?
750247568Sdes}
751247568Sdes
752247568Sdes# func_help [NOEXIT]
753247568Sdes# Echo long help message to standard output and exit,
754247568Sdes# unless 'noexit' is passed as argument.
755247568Sdesfunc_help ()
756247568Sdes{
757247568Sdes    $opt_debug
758247568Sdes
759247568Sdes    $SED -n '/^# Usage:/,/# Report bugs to/ {
760247568Sdes	:print
761247568Sdes        s/^# //
762247568Sdes	s/^# *$//
763247568Sdes	s*\$progname*'$progname'*
764247568Sdes	s*\$host*'"$host"'*
765247568Sdes	s*\$SHELL*'"$SHELL"'*
766247568Sdes	s*\$LTCC*'"$LTCC"'*
767247568Sdes	s*\$LTCFLAGS*'"$LTCFLAGS"'*
768247568Sdes	s*\$LD*'"$LD"'*
769247568Sdes	s/\$with_gnu_ld/'"$with_gnu_ld"'/
770247568Sdes	s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/
771247568Sdes	s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/
772247568Sdes	p
773247568Sdes	d
774247568Sdes     }
775247568Sdes     /^# .* home page:/b print
776247568Sdes     /^# General help using/b print
777247568Sdes     ' < "$progpath"
778247568Sdes    ret=$?
779247568Sdes    if test -z "$1"; then
780247568Sdes      exit $ret
781247568Sdes    fi
782247568Sdes}
783247568Sdes
784247568Sdes# func_missing_arg argname
785247568Sdes# Echo program name prefixed message to standard error and set global
786247568Sdes# exit_cmd.
787247568Sdesfunc_missing_arg ()
788247568Sdes{
789247568Sdes    $opt_debug
790247568Sdes
791247568Sdes    func_error "missing argument for $1."
792247568Sdes    exit_cmd=exit
793247568Sdes}
794247568Sdes
795247568Sdes
796247568Sdes# func_split_short_opt shortopt
797247568Sdes# Set func_split_short_opt_name and func_split_short_opt_arg shell
798247568Sdes# variables after splitting SHORTOPT after the 2nd character.
799247568Sdesfunc_split_short_opt ()
800247568Sdes{
801247568Sdes    my_sed_short_opt='1s/^\(..\).*$/\1/;q'
802247568Sdes    my_sed_short_rest='1s/^..\(.*\)$/\1/;q'
803247568Sdes
804247568Sdes    func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"`
805247568Sdes    func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"`
806247568Sdes} # func_split_short_opt may be replaced by extended shell implementation
807247568Sdes
808247568Sdes
809247568Sdes# func_split_long_opt longopt
810247568Sdes# Set func_split_long_opt_name and func_split_long_opt_arg shell
811247568Sdes# variables after splitting LONGOPT at the `=' sign.
812247568Sdesfunc_split_long_opt ()
813247568Sdes{
814247568Sdes    my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q'
815247568Sdes    my_sed_long_arg='1s/^--[^=]*=//'
816247568Sdes
817247568Sdes    func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"`
818247568Sdes    func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"`
819247568Sdes} # func_split_long_opt may be replaced by extended shell implementation
820247568Sdes
821247568Sdesexit_cmd=:
822247568Sdes
823247568Sdes
824247568Sdes
825247568Sdes
826247568Sdes
827247568Sdesmagic="%%%MAGIC variable%%%"
828247568Sdesmagic_exe="%%%MAGIC EXE variable%%%"
829247568Sdes
830247568Sdes# Global variables.
831247568Sdesnonopt=
832247568Sdespreserve_args=
833247568Sdeslo2o="s/\\.lo\$/.${objext}/"
834247568Sdeso2lo="s/\\.${objext}\$/.lo/"
835247568Sdesextracted_archives=
836247568Sdesextracted_serial=0
837247568Sdes
838247568Sdes# If this variable is set in any of the actions, the command in it
839247568Sdes# will be execed at the end.  This prevents here-documents from being
840247568Sdes# left over by shells.
841247568Sdesexec_cmd=
842247568Sdes
843247568Sdes# func_append var value
844247568Sdes# Append VALUE to the end of shell variable VAR.
845247568Sdesfunc_append ()
846247568Sdes{
847247568Sdes    eval "${1}=\$${1}\${2}"
848247568Sdes} # func_append may be replaced by extended shell implementation
849247568Sdes
850247568Sdes# func_append_quoted var value
851247568Sdes# Quote VALUE and append to the end of shell variable VAR, separated
852247568Sdes# by a space.
853247568Sdesfunc_append_quoted ()
854247568Sdes{
855247568Sdes    func_quote_for_eval "${2}"
856247568Sdes    eval "${1}=\$${1}\\ \$func_quote_for_eval_result"
857247568Sdes} # func_append_quoted may be replaced by extended shell implementation
858247568Sdes
859247568Sdes
860247568Sdes# func_arith arithmetic-term...
861247568Sdesfunc_arith ()
862247568Sdes{
863247568Sdes    func_arith_result=`expr "${@}"`
864247568Sdes} # func_arith may be replaced by extended shell implementation
865247568Sdes
866247568Sdes
867247568Sdes# func_len string
868247568Sdes# STRING may not start with a hyphen.
869247568Sdesfunc_len ()
870247568Sdes{
871247568Sdes    func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len`
872247568Sdes} # func_len may be replaced by extended shell implementation
873247568Sdes
874247568Sdes
875247568Sdes# func_lo2o object
876247568Sdesfunc_lo2o ()
877247568Sdes{
878247568Sdes    func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"`
879247568Sdes} # func_lo2o may be replaced by extended shell implementation
880247568Sdes
881247568Sdes
882247568Sdes# func_xform libobj-or-source
883247568Sdesfunc_xform ()
884247568Sdes{
885247568Sdes    func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'`
886247568Sdes} # func_xform may be replaced by extended shell implementation
887247568Sdes
888247568Sdes
889247568Sdes# func_fatal_configuration arg...
890247568Sdes# Echo program name prefixed message to standard error, followed by
891247568Sdes# a configuration failure hint, and exit.
892247568Sdesfunc_fatal_configuration ()
893247568Sdes{
894247568Sdes    func_error ${1+"$@"}
895247568Sdes    func_error "See the $PACKAGE documentation for more information."
896247568Sdes    func_fatal_error "Fatal configuration error."
897247568Sdes}
898247568Sdes
899247568Sdes
900247568Sdes# func_config
901247568Sdes# Display the configuration for all the tags in this script.
902247568Sdesfunc_config ()
903247568Sdes{
904247568Sdes    re_begincf='^# ### BEGIN LIBTOOL'
905247568Sdes    re_endcf='^# ### END LIBTOOL'
906247568Sdes
907247568Sdes    # Default configuration.
908247568Sdes    $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
909247568Sdes
910247568Sdes    # Now print the configurations for the tags.
911247568Sdes    for tagname in $taglist; do
912247568Sdes      $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
913247568Sdes    done
914247568Sdes
915247568Sdes    exit $?
916247568Sdes}
917247568Sdes
918247568Sdes# func_features
919247568Sdes# Display the features supported by this script.
920247568Sdesfunc_features ()
921247568Sdes{
922247568Sdes    echo "host: $host"
923247568Sdes    if test "$build_libtool_libs" = yes; then
924247568Sdes      echo "enable shared libraries"
925247568Sdes    else
926247568Sdes      echo "disable shared libraries"
927247568Sdes    fi
928247568Sdes    if test "$build_old_libs" = yes; then
929247568Sdes      echo "enable static libraries"
930247568Sdes    else
931247568Sdes      echo "disable static libraries"
932247568Sdes    fi
933247568Sdes
934247568Sdes    exit $?
935247568Sdes}
936247568Sdes
937247568Sdes# func_enable_tag tagname
938247568Sdes# Verify that TAGNAME is valid, and either flag an error and exit, or
939247568Sdes# enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
940247568Sdes# variable here.
941247568Sdesfunc_enable_tag ()
942247568Sdes{
943247568Sdes  # Global variable:
944247568Sdes  tagname="$1"
945247568Sdes
946247568Sdes  re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
947247568Sdes  re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
948247568Sdes  sed_extractcf="/$re_begincf/,/$re_endcf/p"
949247568Sdes
950247568Sdes  # Validate tagname.
951247568Sdes  case $tagname in
952247568Sdes    *[!-_A-Za-z0-9,/]*)
953247568Sdes      func_fatal_error "invalid tag name: $tagname"
954141098Sdes      ;;
955247568Sdes  esac
956247568Sdes
957247568Sdes  # Don't test for the "default" C tag, as we know it's
958247568Sdes  # there but not specially marked.
959247568Sdes  case $tagname in
960247568Sdes    CC) ;;
961247568Sdes    *)
962247568Sdes      if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
963247568Sdes	taglist="$taglist $tagname"
964247568Sdes
965247568Sdes	# Evaluate the configuration.  Be careful to quote the path
966247568Sdes	# and the sed script, to avoid splitting on whitespace, but
967247568Sdes	# also don't use non-portable quotes within backquotes within
968247568Sdes	# quotes we have to do it in 2 steps:
969247568Sdes	extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
970247568Sdes	eval "$extractedcf"
971247568Sdes      else
972247568Sdes	func_error "ignoring unknown tag $tagname"
973247568Sdes      fi
974247568Sdes      ;;
975247568Sdes  esac
976247568Sdes}
977247568Sdes
978247568Sdes# func_check_version_match
979247568Sdes# Ensure that we are using m4 macros, and libtool script from the same
980247568Sdes# release of libtool.
981247568Sdesfunc_check_version_match ()
982247568Sdes{
983247568Sdes  if test "$package_revision" != "$macro_revision"; then
984247568Sdes    if test "$VERSION" != "$macro_version"; then
985247568Sdes      if test -z "$macro_version"; then
986247568Sdes        cat >&2 <<_LT_EOF
987247568Sdes$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
988247568Sdes$progname: definition of this LT_INIT comes from an older release.
989247568Sdes$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
990247568Sdes$progname: and run autoconf again.
991247568Sdes_LT_EOF
992247568Sdes      else
993247568Sdes        cat >&2 <<_LT_EOF
994247568Sdes$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
995247568Sdes$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
996247568Sdes$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
997247568Sdes$progname: and run autoconf again.
998247568Sdes_LT_EOF
999247568Sdes      fi
1000247568Sdes    else
1001247568Sdes      cat >&2 <<_LT_EOF
1002247568Sdes$progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
1003247568Sdes$progname: but the definition of this LT_INIT comes from revision $macro_revision.
1004247568Sdes$progname: You should recreate aclocal.m4 with macros from revision $package_revision
1005247568Sdes$progname: of $PACKAGE $VERSION and run autoconf again.
1006247568Sdes_LT_EOF
1007247568Sdes    fi
1008247568Sdes
1009247568Sdes    exit $EXIT_MISMATCH
1010247568Sdes  fi
1011247568Sdes}
1012247568Sdes
1013247568Sdes
1014247568Sdes# Shorthand for --mode=foo, only valid as the first argument
1015247568Sdescase $1 in
1016247568Sdesclean|clea|cle|cl)
1017247568Sdes  shift; set dummy --mode clean ${1+"$@"}; shift
1018247568Sdes  ;;
1019247568Sdescompile|compil|compi|comp|com|co|c)
1020247568Sdes  shift; set dummy --mode compile ${1+"$@"}; shift
1021247568Sdes  ;;
1022247568Sdesexecute|execut|execu|exec|exe|ex|e)
1023247568Sdes  shift; set dummy --mode execute ${1+"$@"}; shift
1024247568Sdes  ;;
1025247568Sdesfinish|finis|fini|fin|fi|f)
1026247568Sdes  shift; set dummy --mode finish ${1+"$@"}; shift
1027247568Sdes  ;;
1028247568Sdesinstall|instal|insta|inst|ins|in|i)
1029247568Sdes  shift; set dummy --mode install ${1+"$@"}; shift
1030247568Sdes  ;;
1031247568Sdeslink|lin|li|l)
1032247568Sdes  shift; set dummy --mode link ${1+"$@"}; shift
1033247568Sdes  ;;
1034247568Sdesuninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
1035247568Sdes  shift; set dummy --mode uninstall ${1+"$@"}; shift
1036247568Sdes  ;;
1037247568Sdesesac
1038247568Sdes
1039247568Sdes
1040247568Sdes
1041247568Sdes# Option defaults:
1042247568Sdesopt_debug=:
1043247568Sdesopt_dry_run=false
1044247568Sdesopt_config=false
1045247568Sdesopt_preserve_dup_deps=false
1046247568Sdesopt_features=false
1047247568Sdesopt_finish=false
1048247568Sdesopt_help=false
1049247568Sdesopt_help_all=false
1050247568Sdesopt_silent=:
1051247568Sdesopt_warning=:
1052247568Sdesopt_verbose=:
1053247568Sdesopt_silent=false
1054247568Sdesopt_verbose=false
1055247568Sdes
1056247568Sdes
1057247568Sdes# Parse options once, thoroughly.  This comes as soon as possible in the
1058247568Sdes# script to make things like `--version' happen as quickly as we can.
1059247568Sdes{
1060247568Sdes  # this just eases exit handling
1061247568Sdes  while test $# -gt 0; do
1062247568Sdes    opt="$1"
1063247568Sdes    shift
1064247568Sdes    case $opt in
1065247568Sdes      --debug|-x)	opt_debug='set -x'
1066247568Sdes			func_echo "enabling shell trace mode"
1067247568Sdes			$opt_debug
1068247568Sdes			;;
1069247568Sdes      --dry-run|--dryrun|-n)
1070247568Sdes			opt_dry_run=:
1071247568Sdes			;;
1072247568Sdes      --config)
1073247568Sdes			opt_config=:
1074247568Sdesfunc_config
1075247568Sdes			;;
1076247568Sdes      --dlopen|-dlopen)
1077247568Sdes			optarg="$1"
1078247568Sdes			opt_dlopen="${opt_dlopen+$opt_dlopen
1079247568Sdes}$optarg"
1080247568Sdes			shift
1081247568Sdes			;;
1082247568Sdes      --preserve-dup-deps)
1083247568Sdes			opt_preserve_dup_deps=:
1084247568Sdes			;;
1085247568Sdes      --features)
1086247568Sdes			opt_features=:
1087247568Sdesfunc_features
1088247568Sdes			;;
1089247568Sdes      --finish)
1090247568Sdes			opt_finish=:
1091247568Sdesset dummy --mode finish ${1+"$@"}; shift
1092247568Sdes			;;
1093247568Sdes      --help)
1094247568Sdes			opt_help=:
1095247568Sdes			;;
1096247568Sdes      --help-all)
1097247568Sdes			opt_help_all=:
1098247568Sdesopt_help=': help-all'
1099247568Sdes			;;
1100247568Sdes      --mode)
1101247568Sdes			test $# = 0 && func_missing_arg $opt && break
1102247568Sdes			optarg="$1"
1103247568Sdes			opt_mode="$optarg"
1104247568Sdescase $optarg in
1105247568Sdes  # Valid mode arguments:
1106247568Sdes  clean|compile|execute|finish|install|link|relink|uninstall) ;;
1107247568Sdes
1108247568Sdes  # Catch anything else as an error
1109247568Sdes  *) func_error "invalid argument for $opt"
1110247568Sdes     exit_cmd=exit
1111247568Sdes     break
1112247568Sdes     ;;
1113247568Sdesesac
1114247568Sdes			shift
1115247568Sdes			;;
1116247568Sdes      --no-silent|--no-quiet)
1117247568Sdes			opt_silent=false
1118247568Sdesfunc_append preserve_args " $opt"
1119247568Sdes			;;
1120247568Sdes      --no-warning|--no-warn)
1121247568Sdes			opt_warning=false
1122247568Sdesfunc_append preserve_args " $opt"
1123247568Sdes			;;
1124247568Sdes      --no-verbose)
1125247568Sdes			opt_verbose=false
1126247568Sdesfunc_append preserve_args " $opt"
1127247568Sdes			;;
1128247568Sdes      --silent|--quiet)
1129247568Sdes			opt_silent=:
1130247568Sdesfunc_append preserve_args " $opt"
1131247568Sdes        opt_verbose=false
1132247568Sdes			;;
1133247568Sdes      --verbose|-v)
1134247568Sdes			opt_verbose=:
1135247568Sdesfunc_append preserve_args " $opt"
1136247568Sdesopt_silent=false
1137247568Sdes			;;
1138247568Sdes      --tag)
1139247568Sdes			test $# = 0 && func_missing_arg $opt && break
1140247568Sdes			optarg="$1"
1141247568Sdes			opt_tag="$optarg"
1142247568Sdesfunc_append preserve_args " $opt $optarg"
1143247568Sdesfunc_enable_tag "$optarg"
1144247568Sdes			shift
1145247568Sdes			;;
1146247568Sdes
1147247568Sdes      -\?|-h)		func_usage				;;
1148247568Sdes      --help)		func_help				;;
1149247568Sdes      --version)	func_version				;;
1150247568Sdes
1151247568Sdes      # Separate optargs to long options:
1152247568Sdes      --*=*)
1153247568Sdes			func_split_long_opt "$opt"
1154247568Sdes			set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"}
1155247568Sdes			shift
1156247568Sdes			;;
1157247568Sdes
1158247568Sdes      # Separate non-argument short options:
1159247568Sdes      -\?*|-h*|-n*|-v*)
1160247568Sdes			func_split_short_opt "$opt"
1161247568Sdes			set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"}
1162247568Sdes			shift
1163247568Sdes			;;
1164247568Sdes
1165247568Sdes      --)		break					;;
1166247568Sdes      -*)		func_fatal_help "unrecognized option \`$opt'" ;;
1167247568Sdes      *)		set dummy "$opt" ${1+"$@"};	shift; break  ;;
1168141098Sdes    esac
1169247568Sdes  done
1170247568Sdes
1171247568Sdes  # Validate options:
1172247568Sdes
1173247568Sdes  # save first non-option argument
1174247568Sdes  if test "$#" -gt 0; then
1175247568Sdes    nonopt="$opt"
1176247568Sdes    shift
1177247568Sdes  fi
1178247568Sdes
1179247568Sdes  # preserve --debug
1180247568Sdes  test "$opt_debug" = : || func_append preserve_args " --debug"
1181247568Sdes
1182247568Sdes  case $host in
1183247568Sdes    *cygwin* | *mingw* | *pw32* | *cegcc*)
1184247568Sdes      # don't eliminate duplications in $postdeps and $predeps
1185247568Sdes      opt_duplicate_compiler_generated_deps=:
1186247568Sdes      ;;
1187247568Sdes    *)
1188247568Sdes      opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
1189247568Sdes      ;;
1190247568Sdes  esac
1191247568Sdes
1192247568Sdes  $opt_help || {
1193247568Sdes    # Sanity checks first:
1194247568Sdes    func_check_version_match
1195247568Sdes
1196247568Sdes    if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
1197247568Sdes      func_fatal_configuration "not configured to build any kind of library"
1198247568Sdes    fi
1199247568Sdes
1200247568Sdes    # Darwin sucks
1201247568Sdes    eval std_shrext=\"$shrext_cmds\"
1202247568Sdes
1203247568Sdes    # Only execute mode is allowed to have -dlopen flags.
1204247568Sdes    if test -n "$opt_dlopen" && test "$opt_mode" != execute; then
1205247568Sdes      func_error "unrecognized option \`-dlopen'"
1206247568Sdes      $ECHO "$help" 1>&2
1207247568Sdes      exit $EXIT_FAILURE
1208247568Sdes    fi
1209247568Sdes
1210247568Sdes    # Change the help message to a mode-specific one.
1211247568Sdes    generic_help="$help"
1212247568Sdes    help="Try \`$progname --help --mode=$opt_mode' for more information."
1213247568Sdes  }
1214247568Sdes
1215247568Sdes
1216247568Sdes  # Bail if the options were screwed
1217247568Sdes  $exit_cmd $EXIT_FAILURE
1218247568Sdes}
1219247568Sdes
1220247568Sdes
1221247568Sdes
1222247568Sdes
1223247568Sdes## ----------- ##
1224247568Sdes##    Main.    ##
1225247568Sdes## ----------- ##
1226247568Sdes
1227247568Sdes# func_lalib_p file
1228247568Sdes# True iff FILE is a libtool `.la' library or `.lo' object file.
1229247568Sdes# This function is only a basic sanity check; it will hardly flush out
1230247568Sdes# determined imposters.
1231247568Sdesfunc_lalib_p ()
1232247568Sdes{
1233247568Sdes    test -f "$1" &&
1234247568Sdes      $SED -e 4q "$1" 2>/dev/null \
1235247568Sdes        | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
1236247568Sdes}
1237247568Sdes
1238247568Sdes# func_lalib_unsafe_p file
1239247568Sdes# True iff FILE is a libtool `.la' library or `.lo' object file.
1240247568Sdes# This function implements the same check as func_lalib_p without
1241247568Sdes# resorting to external programs.  To this end, it redirects stdin and
1242247568Sdes# closes it afterwards, without saving the original file descriptor.
1243247568Sdes# As a safety measure, use it only where a negative result would be
1244247568Sdes# fatal anyway.  Works if `file' does not exist.
1245247568Sdesfunc_lalib_unsafe_p ()
1246247568Sdes{
1247247568Sdes    lalib_p=no
1248247568Sdes    if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
1249247568Sdes	for lalib_p_l in 1 2 3 4
1250247568Sdes	do
1251247568Sdes	    read lalib_p_line
1252247568Sdes	    case "$lalib_p_line" in
1253247568Sdes		\#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
1254247568Sdes	    esac
1255247568Sdes	done
1256247568Sdes	exec 0<&5 5<&-
1257247568Sdes    fi
1258247568Sdes    test "$lalib_p" = yes
1259247568Sdes}
1260247568Sdes
1261247568Sdes# func_ltwrapper_script_p file
1262247568Sdes# True iff FILE is a libtool wrapper script
1263247568Sdes# This function is only a basic sanity check; it will hardly flush out
1264247568Sdes# determined imposters.
1265247568Sdesfunc_ltwrapper_script_p ()
1266247568Sdes{
1267247568Sdes    func_lalib_p "$1"
1268247568Sdes}
1269247568Sdes
1270247568Sdes# func_ltwrapper_executable_p file
1271247568Sdes# True iff FILE is a libtool wrapper executable
1272247568Sdes# This function is only a basic sanity check; it will hardly flush out
1273247568Sdes# determined imposters.
1274247568Sdesfunc_ltwrapper_executable_p ()
1275247568Sdes{
1276247568Sdes    func_ltwrapper_exec_suffix=
1277247568Sdes    case $1 in
1278247568Sdes    *.exe) ;;
1279247568Sdes    *) func_ltwrapper_exec_suffix=.exe ;;
1280247568Sdes    esac
1281247568Sdes    $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
1282247568Sdes}
1283247568Sdes
1284247568Sdes# func_ltwrapper_scriptname file
1285247568Sdes# Assumes file is an ltwrapper_executable
1286247568Sdes# uses $file to determine the appropriate filename for a
1287247568Sdes# temporary ltwrapper_script.
1288247568Sdesfunc_ltwrapper_scriptname ()
1289247568Sdes{
1290247568Sdes    func_dirname_and_basename "$1" "" "."
1291247568Sdes    func_stripname '' '.exe' "$func_basename_result"
1292247568Sdes    func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper"
1293247568Sdes}
1294247568Sdes
1295247568Sdes# func_ltwrapper_p file
1296247568Sdes# True iff FILE is a libtool wrapper script or wrapper executable
1297247568Sdes# This function is only a basic sanity check; it will hardly flush out
1298247568Sdes# determined imposters.
1299247568Sdesfunc_ltwrapper_p ()
1300247568Sdes{
1301247568Sdes    func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
1302247568Sdes}
1303247568Sdes
1304247568Sdes
1305247568Sdes# func_execute_cmds commands fail_cmd
1306247568Sdes# Execute tilde-delimited COMMANDS.
1307247568Sdes# If FAIL_CMD is given, eval that upon failure.
1308247568Sdes# FAIL_CMD may read-access the current command in variable CMD!
1309247568Sdesfunc_execute_cmds ()
1310247568Sdes{
1311247568Sdes    $opt_debug
1312247568Sdes    save_ifs=$IFS; IFS='~'
1313247568Sdes    for cmd in $1; do
1314247568Sdes      IFS=$save_ifs
1315247568Sdes      eval cmd=\"$cmd\"
1316247568Sdes      func_show_eval "$cmd" "${2-:}"
1317247568Sdes    done
1318247568Sdes    IFS=$save_ifs
1319247568Sdes}
1320247568Sdes
1321247568Sdes
1322247568Sdes# func_source file
1323247568Sdes# Source FILE, adding directory component if necessary.
1324247568Sdes# Note that it is not necessary on cygwin/mingw to append a dot to
1325247568Sdes# FILE even if both FILE and FILE.exe exist: automatic-append-.exe
1326247568Sdes# behavior happens only for exec(3), not for open(2)!  Also, sourcing
1327247568Sdes# `FILE.' does not work on cygwin managed mounts.
1328247568Sdesfunc_source ()
1329247568Sdes{
1330247568Sdes    $opt_debug
1331247568Sdes    case $1 in
1332247568Sdes    */* | *\\*)	. "$1" ;;
1333247568Sdes    *)		. "./$1" ;;
1334247568Sdes    esac
1335247568Sdes}
1336247568Sdes
1337247568Sdes
1338247568Sdes# func_resolve_sysroot PATH
1339247568Sdes# Replace a leading = in PATH with a sysroot.  Store the result into
1340247568Sdes# func_resolve_sysroot_result
1341247568Sdesfunc_resolve_sysroot ()
1342247568Sdes{
1343247568Sdes  func_resolve_sysroot_result=$1
1344247568Sdes  case $func_resolve_sysroot_result in
1345247568Sdes  =*)
1346247568Sdes    func_stripname '=' '' "$func_resolve_sysroot_result"
1347247568Sdes    func_resolve_sysroot_result=$lt_sysroot$func_stripname_result
1348141098Sdes    ;;
1349141098Sdes  esac
1350141098Sdes}
1351141098Sdes
1352247568Sdes# func_replace_sysroot PATH
1353247568Sdes# If PATH begins with the sysroot, replace it with = and
1354247568Sdes# store the result into func_replace_sysroot_result.
1355247568Sdesfunc_replace_sysroot ()
1356247568Sdes{
1357247568Sdes  case "$lt_sysroot:$1" in
1358247568Sdes  ?*:"$lt_sysroot"*)
1359247568Sdes    func_stripname "$lt_sysroot" '' "$1"
1360247568Sdes    func_replace_sysroot_result="=$func_stripname_result"
1361247568Sdes    ;;
1362247568Sdes  *)
1363247568Sdes    # Including no sysroot.
1364247568Sdes    func_replace_sysroot_result=$1
1365247568Sdes    ;;
1366247568Sdes  esac
1367247568Sdes}
1368141098Sdes
1369141098Sdes# func_infer_tag arg
1370141098Sdes# Infer tagged configuration to use if any are available and
1371141098Sdes# if one wasn't chosen via the "--tag" command line option.
1372141098Sdes# Only attempt this if the compiler in the base compile
1373141098Sdes# command doesn't match the default compiler.
1374141098Sdes# arg is usually of the form 'gcc ...'
1375147455Sdesfunc_infer_tag ()
1376147455Sdes{
1377247568Sdes    $opt_debug
1378247568Sdes
1379174832Sdes    # FreeBSD-specific: where we install compilers with non-standard names
1380247568Sdes    tag_compilers_CC="*cc cc* *gcc gcc* clang"
1381247568Sdes    tag_compilers_CXX="*c++ c++* *g++ g++* clang++"
1382174832Sdes    base_compiler=`set -- "$@"; echo $1`
1383174832Sdes
1384174832Sdes    # If $tagname isn't set, then try to infer if the default "CC" tag applies
1385174832Sdes    if test -z "$tagname"; then
1386174832Sdes      for zp in $tag_compilers_CC; do
1387174832Sdes        case $base_compiler in
1388174832Sdes	 $zp) tagname="CC"; break;;
1389174832Sdes	esac
1390174832Sdes      done
1391174832Sdes    fi
1392174832Sdes
1393141098Sdes    if test -n "$available_tags" && test -z "$tagname"; then
1394141098Sdes      CC_quoted=
1395141098Sdes      for arg in $CC; do
1396247568Sdes	func_append_quoted CC_quoted "$arg"
1397141098Sdes      done
1398247568Sdes      CC_expanded=`func_echo_all $CC`
1399247568Sdes      CC_quoted_expanded=`func_echo_all $CC_quoted`
1400141098Sdes      case $@ in
1401141098Sdes      # Blanks in the command may have been stripped by the calling shell,
1402141098Sdes      # but not from the CC environment variable when configure was run.
1403247568Sdes      " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
1404247568Sdes      " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
1405141098Sdes      # Blanks at the start of $base_compile will cause this to fail
1406141098Sdes      # if we don't check for them as well.
1407141098Sdes      *)
1408141098Sdes	for z in $available_tags; do
1409247568Sdes	  if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
1410141098Sdes	    # Evaluate the configuration.
1411141098Sdes	    eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
1412141098Sdes	    CC_quoted=
1413141098Sdes	    for arg in $CC; do
1414247568Sdes	      # Double-quote args containing other shell metacharacters.
1415247568Sdes	      func_append_quoted CC_quoted "$arg"
1416247568Sdes	    done
1417247568Sdes	    CC_expanded=`func_echo_all $CC`
1418247568Sdes	    CC_quoted_expanded=`func_echo_all $CC_quoted`
1419141098Sdes	    case "$@ " in
1420247568Sdes	    " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
1421247568Sdes	    " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
1422141098Sdes	      # The compiler in the base compile command matches
1423141098Sdes	      # the one in the tagged configuration.
1424141098Sdes	      # Assume this is the tagged configuration we want.
1425141098Sdes	      tagname=$z
1426141098Sdes	      break
1427141098Sdes	      ;;
1428141098Sdes	    esac
1429174832Sdes
1430174832Sdes	    # FreeBSD-specific: try compilers based on inferred tag
1431174832Sdes	    if test -z "$tagname"; then
1432174832Sdes	      eval "tag_compilers=\$tag_compilers_${z}"
1433174832Sdes	      if test -n "$tag_compilers"; then
1434174832Sdes		for zp in $tag_compilers; do
1435174832Sdes		  case $base_compiler in   
1436174832Sdes		    $zp) tagname=$z; break;;
1437174832Sdes		  esac
1438174832Sdes		done
1439174832Sdes		if test -n "$tagname"; then
1440174832Sdes		  break
1441174832Sdes		fi
1442174832Sdes	      fi
1443174832Sdes            fi
1444174832Sdes          fi
1445141098Sdes	done
1446141098Sdes	# If $tagname still isn't set, then no tagged configuration
1447141098Sdes	# was found and let the user know that the "--tag" command
1448141098Sdes	# line option must be used.
1449141098Sdes	if test -z "$tagname"; then
1450247568Sdes	  func_echo "unable to infer tagged configuration"
1451247568Sdes	  func_fatal_error "specify a tag with \`--tag'"
1452247568Sdes#	else
1453247568Sdes#	  func_verbose "using $tagname tagged configuration"
1454141098Sdes	fi
1455141098Sdes	;;
1456141098Sdes      esac
1457141098Sdes    fi
1458141098Sdes}
1459141098Sdes
1460141098Sdes
1461247568Sdes
1462247568Sdes# func_write_libtool_object output_name pic_name nonpic_name
1463247568Sdes# Create a libtool object file (analogous to a ".la" file),
1464247568Sdes# but don't create it if we're doing a dry run.
1465247568Sdesfunc_write_libtool_object ()
1466147455Sdes{
1467247568Sdes    write_libobj=${1}
1468247568Sdes    if test "$build_libtool_libs" = yes; then
1469247568Sdes      write_lobj=\'${2}\'
1470247568Sdes    else
1471247568Sdes      write_lobj=none
1472247568Sdes    fi
1473147455Sdes
1474247568Sdes    if test "$build_old_libs" = yes; then
1475247568Sdes      write_oldobj=\'${3}\'
1476147455Sdes    else
1477247568Sdes      write_oldobj=none
1478147455Sdes    fi
1479247568Sdes
1480247568Sdes    $opt_dry_run || {
1481247568Sdes      cat >${write_libobj}T <<EOF
1482247568Sdes# $write_libobj - a libtool object file
1483247568Sdes# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
1484247568Sdes#
1485247568Sdes# Please DO NOT delete this file!
1486247568Sdes# It is necessary for linking the library.
1487247568Sdes
1488247568Sdes# Name of the PIC object.
1489247568Sdespic_object=$write_lobj
1490247568Sdes
1491247568Sdes# Name of the non-PIC object
1492247568Sdesnon_pic_object=$write_oldobj
1493247568Sdes
1494247568SdesEOF
1495247568Sdes      $MV "${write_libobj}T" "${write_libobj}"
1496247568Sdes    }
1497147455Sdes}
1498147455Sdes
1499247568Sdes
1500247568Sdes##################################################
1501247568Sdes# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS #
1502247568Sdes##################################################
1503247568Sdes
1504247568Sdes# func_convert_core_file_wine_to_w32 ARG
1505247568Sdes# Helper function used by file name conversion functions when $build is *nix,
1506247568Sdes# and $host is mingw, cygwin, or some other w32 environment. Relies on a
1507247568Sdes# correctly configured wine environment available, with the winepath program
1508247568Sdes# in $build's $PATH.
1509247568Sdes#
1510247568Sdes# ARG is the $build file name to be converted to w32 format.
1511247568Sdes# Result is available in $func_convert_core_file_wine_to_w32_result, and will
1512247568Sdes# be empty on error (or when ARG is empty)
1513247568Sdesfunc_convert_core_file_wine_to_w32 ()
1514147455Sdes{
1515247568Sdes  $opt_debug
1516247568Sdes  func_convert_core_file_wine_to_w32_result="$1"
1517247568Sdes  if test -n "$1"; then
1518247568Sdes    # Unfortunately, winepath does not exit with a non-zero error code, so we
1519247568Sdes    # are forced to check the contents of stdout. On the other hand, if the
1520247568Sdes    # command is not found, the shell will set an exit code of 127 and print
1521247568Sdes    # *an error message* to stdout. So we must check for both error code of
1522247568Sdes    # zero AND non-empty stdout, which explains the odd construction:
1523247568Sdes    func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
1524247568Sdes    if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then
1525247568Sdes      func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
1526247568Sdes        $SED -e "$lt_sed_naive_backslashify"`
1527247568Sdes    else
1528247568Sdes      func_convert_core_file_wine_to_w32_result=
1529141098Sdes    fi
1530247568Sdes  fi
1531247568Sdes}
1532247568Sdes# end: func_convert_core_file_wine_to_w32
1533141098Sdes
1534141098Sdes
1535247568Sdes# func_convert_core_path_wine_to_w32 ARG
1536247568Sdes# Helper function used by path conversion functions when $build is *nix, and
1537247568Sdes# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly
1538247568Sdes# configured wine environment available, with the winepath program in $build's
1539247568Sdes# $PATH. Assumes ARG has no leading or trailing path separator characters.
1540247568Sdes#
1541247568Sdes# ARG is path to be converted from $build format to win32.
1542247568Sdes# Result is available in $func_convert_core_path_wine_to_w32_result.
1543247568Sdes# Unconvertible file (directory) names in ARG are skipped; if no directory names
1544247568Sdes# are convertible, then the result may be empty.
1545247568Sdesfunc_convert_core_path_wine_to_w32 ()
1546247568Sdes{
1547247568Sdes  $opt_debug
1548247568Sdes  # unfortunately, winepath doesn't convert paths, only file names
1549247568Sdes  func_convert_core_path_wine_to_w32_result=""
1550247568Sdes  if test -n "$1"; then
1551247568Sdes    oldIFS=$IFS
1552247568Sdes    IFS=:
1553247568Sdes    for func_convert_core_path_wine_to_w32_f in $1; do
1554247568Sdes      IFS=$oldIFS
1555247568Sdes      func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
1556247568Sdes      if test -n "$func_convert_core_file_wine_to_w32_result" ; then
1557247568Sdes        if test -z "$func_convert_core_path_wine_to_w32_result"; then
1558247568Sdes          func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result"
1559247568Sdes        else
1560247568Sdes          func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
1561247568Sdes        fi
1562141098Sdes      fi
1563141098Sdes    done
1564247568Sdes    IFS=$oldIFS
1565247568Sdes  fi
1566141098Sdes}
1567247568Sdes# end: func_convert_core_path_wine_to_w32
1568141098Sdes
1569141098Sdes
1570247568Sdes# func_cygpath ARGS...
1571247568Sdes# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when
1572247568Sdes# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2)
1573247568Sdes# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or
1574247568Sdes# (2), returns the Cygwin file name or path in func_cygpath_result (input
1575247568Sdes# file name or path is assumed to be in w32 format, as previously converted
1576247568Sdes# from $build's *nix or MSYS format). In case (3), returns the w32 file name
1577247568Sdes# or path in func_cygpath_result (input file name or path is assumed to be in
1578247568Sdes# Cygwin format). Returns an empty string on error.
1579247568Sdes#
1580247568Sdes# ARGS are passed to cygpath, with the last one being the file name or path to
1581247568Sdes# be converted.
1582247568Sdes#
1583247568Sdes# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH
1584247568Sdes# environment variable; do not put it in $PATH.
1585247568Sdesfunc_cygpath ()
1586247568Sdes{
1587247568Sdes  $opt_debug
1588247568Sdes  if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
1589247568Sdes    func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
1590247568Sdes    if test "$?" -ne 0; then
1591247568Sdes      # on failure, ensure result is empty
1592247568Sdes      func_cygpath_result=
1593247568Sdes    fi
1594247568Sdes  else
1595247568Sdes    func_cygpath_result=
1596247568Sdes    func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'"
1597247568Sdes  fi
1598247568Sdes}
1599247568Sdes#end: func_cygpath
1600174832Sdes
1601117610Sdes
1602247568Sdes# func_convert_core_msys_to_w32 ARG
1603247568Sdes# Convert file name or path ARG from MSYS format to w32 format.  Return
1604247568Sdes# result in func_convert_core_msys_to_w32_result.
1605247568Sdesfunc_convert_core_msys_to_w32 ()
1606247568Sdes{
1607247568Sdes  $opt_debug
1608247568Sdes  # awkward: cmd appends spaces to result
1609247568Sdes  func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
1610247568Sdes    $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"`
1611247568Sdes}
1612247568Sdes#end: func_convert_core_msys_to_w32
1613247568Sdes
1614247568Sdes
1615247568Sdes# func_convert_file_check ARG1 ARG2
1616247568Sdes# Verify that ARG1 (a file name in $build format) was converted to $host
1617247568Sdes# format in ARG2. Otherwise, emit an error message, but continue (resetting
1618247568Sdes# func_to_host_file_result to ARG1).
1619247568Sdesfunc_convert_file_check ()
1620247568Sdes{
1621247568Sdes  $opt_debug
1622247568Sdes  if test -z "$2" && test -n "$1" ; then
1623247568Sdes    func_error "Could not determine host file name corresponding to"
1624247568Sdes    func_error "  \`$1'"
1625247568Sdes    func_error "Continuing, but uninstalled executables may not work."
1626247568Sdes    # Fallback:
1627247568Sdes    func_to_host_file_result="$1"
1628247568Sdes  fi
1629247568Sdes}
1630247568Sdes# end func_convert_file_check
1631247568Sdes
1632247568Sdes
1633247568Sdes# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH
1634247568Sdes# Verify that FROM_PATH (a path in $build format) was converted to $host
1635247568Sdes# format in TO_PATH. Otherwise, emit an error message, but continue, resetting
1636247568Sdes# func_to_host_file_result to a simplistic fallback value (see below).
1637247568Sdesfunc_convert_path_check ()
1638247568Sdes{
1639247568Sdes  $opt_debug
1640247568Sdes  if test -z "$4" && test -n "$3"; then
1641247568Sdes    func_error "Could not determine the host path corresponding to"
1642247568Sdes    func_error "  \`$3'"
1643247568Sdes    func_error "Continuing, but uninstalled executables may not work."
1644247568Sdes    # Fallback.  This is a deliberately simplistic "conversion" and
1645247568Sdes    # should not be "improved".  See libtool.info.
1646247568Sdes    if test "x$1" != "x$2"; then
1647247568Sdes      lt_replace_pathsep_chars="s|$1|$2|g"
1648247568Sdes      func_to_host_path_result=`echo "$3" |
1649247568Sdes        $SED -e "$lt_replace_pathsep_chars"`
1650247568Sdes    else
1651247568Sdes      func_to_host_path_result="$3"
1652247568Sdes    fi
1653247568Sdes  fi
1654247568Sdes}
1655247568Sdes# end func_convert_path_check
1656247568Sdes
1657247568Sdes
1658247568Sdes# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG
1659247568Sdes# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT
1660247568Sdes# and appending REPL if ORIG matches BACKPAT.
1661247568Sdesfunc_convert_path_front_back_pathsep ()
1662247568Sdes{
1663247568Sdes  $opt_debug
1664247568Sdes  case $4 in
1665247568Sdes  $1 ) func_to_host_path_result="$3$func_to_host_path_result"
1666247568Sdes    ;;
1667117610Sdes  esac
1668247568Sdes  case $4 in
1669247568Sdes  $2 ) func_append func_to_host_path_result "$3"
1670247568Sdes    ;;
1671247568Sdes  esac
1672247568Sdes}
1673247568Sdes# end func_convert_path_front_back_pathsep
1674117610Sdes
1675141098Sdes
1676247568Sdes##################################################
1677247568Sdes# $build to $host FILE NAME CONVERSION FUNCTIONS #
1678247568Sdes##################################################
1679247568Sdes# invoked via `$to_host_file_cmd ARG'
1680247568Sdes#
1681247568Sdes# In each case, ARG is the path to be converted from $build to $host format.
1682247568Sdes# Result will be available in $func_to_host_file_result.
1683141098Sdes
1684247568Sdes
1685247568Sdes# func_to_host_file ARG
1686247568Sdes# Converts the file name ARG from $build format to $host format. Return result
1687247568Sdes# in func_to_host_file_result.
1688247568Sdesfunc_to_host_file ()
1689247568Sdes{
1690247568Sdes  $opt_debug
1691247568Sdes  $to_host_file_cmd "$1"
1692247568Sdes}
1693247568Sdes# end func_to_host_file
1694247568Sdes
1695247568Sdes
1696247568Sdes# func_to_tool_file ARG LAZY
1697247568Sdes# converts the file name ARG from $build format to toolchain format. Return
1698247568Sdes# result in func_to_tool_file_result.  If the conversion in use is listed
1699247568Sdes# in (the comma separated) LAZY, no conversion takes place.
1700247568Sdesfunc_to_tool_file ()
1701247568Sdes{
1702247568Sdes  $opt_debug
1703247568Sdes  case ,$2, in
1704247568Sdes    *,"$to_tool_file_cmd",*)
1705247568Sdes      func_to_tool_file_result=$1
1706141098Sdes      ;;
1707117610Sdes    *)
1708247568Sdes      $to_tool_file_cmd "$1"
1709247568Sdes      func_to_tool_file_result=$func_to_host_file_result
1710117610Sdes      ;;
1711247568Sdes  esac
1712247568Sdes}
1713247568Sdes# end func_to_tool_file
1714117610Sdes
1715247568Sdes
1716247568Sdes# func_convert_file_noop ARG
1717247568Sdes# Copy ARG to func_to_host_file_result.
1718247568Sdesfunc_convert_file_noop ()
1719247568Sdes{
1720247568Sdes  func_to_host_file_result="$1"
1721247568Sdes}
1722247568Sdes# end func_convert_file_noop
1723247568Sdes
1724247568Sdes
1725247568Sdes# func_convert_file_msys_to_w32 ARG
1726247568Sdes# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic
1727247568Sdes# conversion to w32 is not available inside the cwrapper.  Returns result in
1728247568Sdes# func_to_host_file_result.
1729247568Sdesfunc_convert_file_msys_to_w32 ()
1730247568Sdes{
1731247568Sdes  $opt_debug
1732247568Sdes  func_to_host_file_result="$1"
1733247568Sdes  if test -n "$1"; then
1734247568Sdes    func_convert_core_msys_to_w32 "$1"
1735247568Sdes    func_to_host_file_result="$func_convert_core_msys_to_w32_result"
1736117610Sdes  fi
1737247568Sdes  func_convert_file_check "$1" "$func_to_host_file_result"
1738247568Sdes}
1739247568Sdes# end func_convert_file_msys_to_w32
1740117610Sdes
1741117610Sdes
1742247568Sdes# func_convert_file_cygwin_to_w32 ARG
1743247568Sdes# Convert file name ARG from Cygwin to w32 format.  Returns result in
1744247568Sdes# func_to_host_file_result.
1745247568Sdesfunc_convert_file_cygwin_to_w32 ()
1746247568Sdes{
1747247568Sdes  $opt_debug
1748247568Sdes  func_to_host_file_result="$1"
1749247568Sdes  if test -n "$1"; then
1750247568Sdes    # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
1751247568Sdes    # LT_CYGPATH in this case.
1752247568Sdes    func_to_host_file_result=`cygpath -m "$1"`
1753247568Sdes  fi
1754247568Sdes  func_convert_file_check "$1" "$func_to_host_file_result"
1755247568Sdes}
1756247568Sdes# end func_convert_file_cygwin_to_w32
1757174832Sdes
1758117610Sdes
1759247568Sdes# func_convert_file_nix_to_w32 ARG
1760247568Sdes# Convert file name ARG from *nix to w32 format.  Requires a wine environment
1761247568Sdes# and a working winepath. Returns result in func_to_host_file_result.
1762247568Sdesfunc_convert_file_nix_to_w32 ()
1763247568Sdes{
1764247568Sdes  $opt_debug
1765247568Sdes  func_to_host_file_result="$1"
1766247568Sdes  if test -n "$1"; then
1767247568Sdes    func_convert_core_file_wine_to_w32 "$1"
1768247568Sdes    func_to_host_file_result="$func_convert_core_file_wine_to_w32_result"
1769247568Sdes  fi
1770247568Sdes  func_convert_file_check "$1" "$func_to_host_file_result"
1771247568Sdes}
1772247568Sdes# end func_convert_file_nix_to_w32
1773117610Sdes
1774117610Sdes
1775247568Sdes# func_convert_file_msys_to_cygwin ARG
1776247568Sdes# Convert file name ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
1777247568Sdes# Returns result in func_to_host_file_result.
1778247568Sdesfunc_convert_file_msys_to_cygwin ()
1779247568Sdes{
1780247568Sdes  $opt_debug
1781247568Sdes  func_to_host_file_result="$1"
1782247568Sdes  if test -n "$1"; then
1783247568Sdes    func_convert_core_msys_to_w32 "$1"
1784247568Sdes    func_cygpath -u "$func_convert_core_msys_to_w32_result"
1785247568Sdes    func_to_host_file_result="$func_cygpath_result"
1786247568Sdes  fi
1787247568Sdes  func_convert_file_check "$1" "$func_to_host_file_result"
1788247568Sdes}
1789247568Sdes# end func_convert_file_msys_to_cygwin
1790117610Sdes
1791117610Sdes
1792247568Sdes# func_convert_file_nix_to_cygwin ARG
1793247568Sdes# Convert file name ARG from *nix to Cygwin format.  Requires Cygwin installed
1794247568Sdes# in a wine environment, working winepath, and LT_CYGPATH set.  Returns result
1795247568Sdes# in func_to_host_file_result.
1796247568Sdesfunc_convert_file_nix_to_cygwin ()
1797247568Sdes{
1798247568Sdes  $opt_debug
1799247568Sdes  func_to_host_file_result="$1"
1800247568Sdes  if test -n "$1"; then
1801247568Sdes    # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
1802247568Sdes    func_convert_core_file_wine_to_w32 "$1"
1803247568Sdes    func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
1804247568Sdes    func_to_host_file_result="$func_cygpath_result"
1805247568Sdes  fi
1806247568Sdes  func_convert_file_check "$1" "$func_to_host_file_result"
1807247568Sdes}
1808247568Sdes# end func_convert_file_nix_to_cygwin
1809117610Sdes
1810117610Sdes
1811247568Sdes#############################################
1812247568Sdes# $build to $host PATH CONVERSION FUNCTIONS #
1813247568Sdes#############################################
1814247568Sdes# invoked via `$to_host_path_cmd ARG'
1815247568Sdes#
1816247568Sdes# In each case, ARG is the path to be converted from $build to $host format.
1817247568Sdes# The result will be available in $func_to_host_path_result.
1818247568Sdes#
1819247568Sdes# Path separators are also converted from $build format to $host format.  If
1820247568Sdes# ARG begins or ends with a path separator character, it is preserved (but
1821247568Sdes# converted to $host format) on output.
1822247568Sdes#
1823247568Sdes# All path conversion functions are named using the following convention:
1824247568Sdes#   file name conversion function    : func_convert_file_X_to_Y ()
1825247568Sdes#   path conversion function         : func_convert_path_X_to_Y ()
1826247568Sdes# where, for any given $build/$host combination the 'X_to_Y' value is the
1827247568Sdes# same.  If conversion functions are added for new $build/$host combinations,
1828247568Sdes# the two new functions must follow this pattern, or func_init_to_host_path_cmd
1829247568Sdes# will break.
1830125647Sdes
1831117610Sdes
1832247568Sdes# func_init_to_host_path_cmd
1833247568Sdes# Ensures that function "pointer" variable $to_host_path_cmd is set to the
1834247568Sdes# appropriate value, based on the value of $to_host_file_cmd.
1835247568Sdesto_host_path_cmd=
1836247568Sdesfunc_init_to_host_path_cmd ()
1837247568Sdes{
1838247568Sdes  $opt_debug
1839247568Sdes  if test -z "$to_host_path_cmd"; then
1840247568Sdes    func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
1841247568Sdes    to_host_path_cmd="func_convert_path_${func_stripname_result}"
1842247568Sdes  fi
1843247568Sdes}
1844141098Sdes
1845117610Sdes
1846247568Sdes# func_to_host_path ARG
1847247568Sdes# Converts the path ARG from $build format to $host format. Return result
1848247568Sdes# in func_to_host_path_result.
1849247568Sdesfunc_to_host_path ()
1850247568Sdes{
1851247568Sdes  $opt_debug
1852247568Sdes  func_init_to_host_path_cmd
1853247568Sdes  $to_host_path_cmd "$1"
1854247568Sdes}
1855247568Sdes# end func_to_host_path
1856117610Sdes
1857117610Sdes
1858247568Sdes# func_convert_path_noop ARG
1859247568Sdes# Copy ARG to func_to_host_path_result.
1860247568Sdesfunc_convert_path_noop ()
1861247568Sdes{
1862247568Sdes  func_to_host_path_result="$1"
1863247568Sdes}
1864247568Sdes# end func_convert_path_noop
1865117610Sdes
1866174832Sdes
1867247568Sdes# func_convert_path_msys_to_w32 ARG
1868247568Sdes# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic
1869247568Sdes# conversion to w32 is not available inside the cwrapper.  Returns result in
1870247568Sdes# func_to_host_path_result.
1871247568Sdesfunc_convert_path_msys_to_w32 ()
1872247568Sdes{
1873247568Sdes  $opt_debug
1874247568Sdes  func_to_host_path_result="$1"
1875247568Sdes  if test -n "$1"; then
1876247568Sdes    # Remove leading and trailing path separator characters from ARG.  MSYS
1877247568Sdes    # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
1878247568Sdes    # and winepath ignores them completely.
1879247568Sdes    func_stripname : : "$1"
1880247568Sdes    func_to_host_path_tmp1=$func_stripname_result
1881247568Sdes    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
1882247568Sdes    func_to_host_path_result="$func_convert_core_msys_to_w32_result"
1883247568Sdes    func_convert_path_check : ";" \
1884247568Sdes      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1885247568Sdes    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
1886247568Sdes  fi
1887247568Sdes}
1888247568Sdes# end func_convert_path_msys_to_w32
1889125647Sdes
1890117610Sdes
1891247568Sdes# func_convert_path_cygwin_to_w32 ARG
1892247568Sdes# Convert path ARG from Cygwin to w32 format.  Returns result in
1893247568Sdes# func_to_host_file_result.
1894247568Sdesfunc_convert_path_cygwin_to_w32 ()
1895247568Sdes{
1896247568Sdes  $opt_debug
1897247568Sdes  func_to_host_path_result="$1"
1898247568Sdes  if test -n "$1"; then
1899247568Sdes    # See func_convert_path_msys_to_w32:
1900247568Sdes    func_stripname : : "$1"
1901247568Sdes    func_to_host_path_tmp1=$func_stripname_result
1902247568Sdes    func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"`
1903247568Sdes    func_convert_path_check : ";" \
1904247568Sdes      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1905247568Sdes    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
1906247568Sdes  fi
1907247568Sdes}
1908247568Sdes# end func_convert_path_cygwin_to_w32
1909117610Sdes
1910247568Sdes
1911247568Sdes# func_convert_path_nix_to_w32 ARG
1912247568Sdes# Convert path ARG from *nix to w32 format.  Requires a wine environment and
1913247568Sdes# a working winepath.  Returns result in func_to_host_file_result.
1914247568Sdesfunc_convert_path_nix_to_w32 ()
1915247568Sdes{
1916247568Sdes  $opt_debug
1917247568Sdes  func_to_host_path_result="$1"
1918247568Sdes  if test -n "$1"; then
1919247568Sdes    # See func_convert_path_msys_to_w32:
1920247568Sdes    func_stripname : : "$1"
1921247568Sdes    func_to_host_path_tmp1=$func_stripname_result
1922247568Sdes    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
1923247568Sdes    func_to_host_path_result="$func_convert_core_path_wine_to_w32_result"
1924247568Sdes    func_convert_path_check : ";" \
1925247568Sdes      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1926247568Sdes    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
1927117610Sdes  fi
1928247568Sdes}
1929247568Sdes# end func_convert_path_nix_to_w32
1930117610Sdes
1931247568Sdes
1932247568Sdes# func_convert_path_msys_to_cygwin ARG
1933247568Sdes# Convert path ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
1934247568Sdes# Returns result in func_to_host_file_result.
1935247568Sdesfunc_convert_path_msys_to_cygwin ()
1936247568Sdes{
1937247568Sdes  $opt_debug
1938247568Sdes  func_to_host_path_result="$1"
1939247568Sdes  if test -n "$1"; then
1940247568Sdes    # See func_convert_path_msys_to_w32:
1941247568Sdes    func_stripname : : "$1"
1942247568Sdes    func_to_host_path_tmp1=$func_stripname_result
1943247568Sdes    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
1944247568Sdes    func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
1945247568Sdes    func_to_host_path_result="$func_cygpath_result"
1946247568Sdes    func_convert_path_check : : \
1947247568Sdes      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1948247568Sdes    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
1949117610Sdes  fi
1950247568Sdes}
1951247568Sdes# end func_convert_path_msys_to_cygwin
1952117610Sdes
1953117610Sdes
1954247568Sdes# func_convert_path_nix_to_cygwin ARG
1955247568Sdes# Convert path ARG from *nix to Cygwin format.  Requires Cygwin installed in a
1956247568Sdes# a wine environment, working winepath, and LT_CYGPATH set.  Returns result in
1957247568Sdes# func_to_host_file_result.
1958247568Sdesfunc_convert_path_nix_to_cygwin ()
1959247568Sdes{
1960247568Sdes  $opt_debug
1961247568Sdes  func_to_host_path_result="$1"
1962247568Sdes  if test -n "$1"; then
1963247568Sdes    # Remove leading and trailing path separator characters from
1964247568Sdes    # ARG. msys behavior is inconsistent here, cygpath turns them
1965247568Sdes    # into '.;' and ';.', and winepath ignores them completely.
1966247568Sdes    func_stripname : : "$1"
1967247568Sdes    func_to_host_path_tmp1=$func_stripname_result
1968247568Sdes    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
1969247568Sdes    func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
1970247568Sdes    func_to_host_path_result="$func_cygpath_result"
1971247568Sdes    func_convert_path_check : : \
1972247568Sdes      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1973247568Sdes    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
1974247568Sdes  fi
1975247568Sdes}
1976247568Sdes# end func_convert_path_nix_to_cygwin
1977247568Sdes
1978247568Sdes
1979247568Sdes# func_mode_compile arg...
1980247568Sdesfunc_mode_compile ()
1981247568Sdes{
1982247568Sdes    $opt_debug
1983117610Sdes    # Get the compilation command and the source file.
1984117610Sdes    base_compile=
1985141098Sdes    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
1986141098Sdes    suppress_opt=yes
1987117610Sdes    suppress_output=
1988141098Sdes    arg_mode=normal
1989141098Sdes    libobj=
1990141098Sdes    later=
1991247568Sdes    pie_flag=
1992117610Sdes
1993117610Sdes    for arg
1994117610Sdes    do
1995174832Sdes      case $arg_mode in
1996141098Sdes      arg  )
1997141098Sdes	# do not "continue".  Instead, add this to base_compile
1998141098Sdes	lastarg="$arg"
1999141098Sdes	arg_mode=normal
2000141098Sdes	;;
2001125647Sdes
2002141098Sdes      target )
2003141098Sdes	libobj="$arg"
2004141098Sdes	arg_mode=normal
2005125647Sdes	continue
2006125647Sdes	;;
2007125647Sdes
2008141098Sdes      normal )
2009141098Sdes	# Accept any command-line options.
2010141098Sdes	case $arg in
2011141098Sdes	-o)
2012247568Sdes	  test -n "$libobj" && \
2013247568Sdes	    func_fatal_error "you cannot specify \`-o' more than once"
2014141098Sdes	  arg_mode=target
2015141098Sdes	  continue
2016141098Sdes	  ;;
2017117610Sdes
2018247568Sdes	-pie | -fpie | -fPIE)
2019247568Sdes          func_append pie_flag " $arg"
2020141098Sdes	  continue
2021141098Sdes	  ;;
2022125647Sdes
2023247568Sdes	-shared | -static | -prefer-pic | -prefer-non-pic)
2024247568Sdes	  func_append later " $arg"
2025247568Sdes	  continue
2026247568Sdes	  ;;
2027247568Sdes
2028141098Sdes	-no-suppress)
2029141098Sdes	  suppress_opt=no
2030141098Sdes	  continue
2031141098Sdes	  ;;
2032125647Sdes
2033141098Sdes	-Xcompiler)
2034141098Sdes	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
2035141098Sdes	  continue      #  The current "srcfile" will either be retained or
2036141098Sdes	  ;;            #  replaced later.  I would guess that would be a bug.
2037125647Sdes
2038141098Sdes	-Wc,*)
2039247568Sdes	  func_stripname '-Wc,' '' "$arg"
2040247568Sdes	  args=$func_stripname_result
2041141098Sdes	  lastarg=
2042141098Sdes	  save_ifs="$IFS"; IFS=','
2043247568Sdes	  for arg in $args; do
2044141098Sdes	    IFS="$save_ifs"
2045247568Sdes	    func_append_quoted lastarg "$arg"
2046141098Sdes	  done
2047125647Sdes	  IFS="$save_ifs"
2048247568Sdes	  func_stripname ' ' '' "$lastarg"
2049247568Sdes	  lastarg=$func_stripname_result
2050125647Sdes
2051141098Sdes	  # Add the arguments to base_compile.
2052247568Sdes	  func_append base_compile " $lastarg"
2053141098Sdes	  continue
2054141098Sdes	  ;;
2055117610Sdes
2056247568Sdes	*)
2057141098Sdes	  # Accept the current argument as the source file.
2058141098Sdes	  # The previous "srcfile" becomes the current argument.
2059141098Sdes	  #
2060141098Sdes	  lastarg="$srcfile"
2061141098Sdes	  srcfile="$arg"
2062141098Sdes	  ;;
2063141098Sdes	esac  #  case $arg
2064117610Sdes	;;
2065141098Sdes      esac    #  case $arg_mode
2066117610Sdes
2067117610Sdes      # Aesthetically quote the previous argument.
2068247568Sdes      func_append_quoted base_compile "$lastarg"
2069141098Sdes    done # for arg
2070117610Sdes
2071141098Sdes    case $arg_mode in
2072141098Sdes    arg)
2073247568Sdes      func_fatal_error "you must specify an argument for -Xcompile"
2074117610Sdes      ;;
2075141098Sdes    target)
2076247568Sdes      func_fatal_error "you must specify a target with \`-o'"
2077117610Sdes      ;;
2078117610Sdes    *)
2079141098Sdes      # Get the name of the library object.
2080247568Sdes      test -z "$libobj" && {
2081247568Sdes	func_basename "$srcfile"
2082247568Sdes	libobj="$func_basename_result"
2083247568Sdes      }
2084117610Sdes      ;;
2085117610Sdes    esac
2086117610Sdes
2087117610Sdes    # Recognize several different file suffixes.
2088117610Sdes    # If the user specifies -o file.o, it is replaced with file.lo
2089125647Sdes    case $libobj in
2090247568Sdes    *.[cCFSifmso] | \
2091247568Sdes    *.ada | *.adb | *.ads | *.asm | \
2092247568Sdes    *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
2093247568Sdes    *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup)
2094247568Sdes      func_xform "$libobj"
2095247568Sdes      libobj=$func_xform_result
2096247568Sdes      ;;
2097117610Sdes    esac
2098117610Sdes
2099125647Sdes    case $libobj in
2100247568Sdes    *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
2101117610Sdes    *)
2102247568Sdes      func_fatal_error "cannot determine name of library object from \`$libobj'"
2103117610Sdes      ;;
2104117610Sdes    esac
2105117610Sdes
2106141098Sdes    func_infer_tag $base_compile
2107141098Sdes
2108141098Sdes    for arg in $later; do
2109141098Sdes      case $arg in
2110247568Sdes      -shared)
2111247568Sdes	test "$build_libtool_libs" != yes && \
2112247568Sdes	  func_fatal_configuration "can not build a shared library"
2113247568Sdes	build_old_libs=no
2114247568Sdes	continue
2115247568Sdes	;;
2116247568Sdes
2117141098Sdes      -static)
2118247568Sdes	build_libtool_libs=no
2119141098Sdes	build_old_libs=yes
2120141098Sdes	continue
2121141098Sdes	;;
2122141098Sdes
2123141098Sdes      -prefer-pic)
2124141098Sdes	pic_mode=yes
2125141098Sdes	continue
2126141098Sdes	;;
2127141098Sdes
2128141098Sdes      -prefer-non-pic)
2129141098Sdes	pic_mode=no
2130141098Sdes	continue
2131141098Sdes	;;
2132141098Sdes      esac
2133141098Sdes    done
2134141098Sdes
2135247568Sdes    func_quote_for_eval "$libobj"
2136247568Sdes    test "X$libobj" != "X$func_quote_for_eval_result" \
2137247568Sdes      && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'	 &()|`$[]' \
2138247568Sdes      && func_warning "libobj name \`$libobj' may not contain shell special characters."
2139247568Sdes    func_dirname_and_basename "$obj" "/" ""
2140247568Sdes    objname="$func_basename_result"
2141247568Sdes    xdir="$func_dirname_result"
2142141098Sdes    lobj=${xdir}$objdir/$objname
2143141098Sdes
2144247568Sdes    test -z "$base_compile" && \
2145247568Sdes      func_fatal_help "you must specify a compilation command"
2146117610Sdes
2147117610Sdes    # Delete any leftover library objects.
2148117610Sdes    if test "$build_old_libs" = yes; then
2149141098Sdes      removelist="$obj $lobj $libobj ${libobj}T"
2150117610Sdes    else
2151141098Sdes      removelist="$lobj $libobj ${libobj}T"
2152117610Sdes    fi
2153117610Sdes
2154125647Sdes    # On Cygwin there's no "real" PIC flag so we must build both object types
2155125647Sdes    case $host_os in
2156247568Sdes    cygwin* | mingw* | pw32* | os2* | cegcc*)
2157125647Sdes      pic_mode=default
2158125647Sdes      ;;
2159125647Sdes    esac
2160125647Sdes    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
2161125647Sdes      # non-PIC code in shared libraries is not supported
2162125647Sdes      pic_mode=default
2163125647Sdes    fi
2164125647Sdes
2165117610Sdes    # Calculate the filename of the output object if compiler does
2166117610Sdes    # not support -o with -c
2167117610Sdes    if test "$compiler_c_o" = no; then
2168247568Sdes      output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext}
2169117610Sdes      lockfile="$output_obj.lock"
2170117610Sdes    else
2171141098Sdes      output_obj=
2172117610Sdes      need_locks=no
2173117610Sdes      lockfile=
2174117610Sdes    fi
2175117610Sdes
2176117610Sdes    # Lock this critical section if it is needed
2177117610Sdes    # We use this script file to make the link, it avoids creating a new file
2178117610Sdes    if test "$need_locks" = yes; then
2179247568Sdes      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
2180247568Sdes	func_echo "Waiting for $lockfile to be removed"
2181117610Sdes	sleep 2
2182117610Sdes      done
2183117610Sdes    elif test "$need_locks" = warn; then
2184117610Sdes      if test -f "$lockfile"; then
2185247568Sdes	$ECHO "\
2186117610Sdes*** ERROR, $lockfile exists and contains:
2187117610Sdes`cat $lockfile 2>/dev/null`
2188117610Sdes
2189117610SdesThis indicates that another process is trying to use the same
2190117610Sdestemporary object file, and libtool could not work around it because
2191117610Sdesyour compiler does not support \`-c' and \`-o' together.  If you
2192117610Sdesrepeat this compilation, it may succeed, by chance, but you had better
2193117610Sdesavoid parallel builds (make -j) in this platform, or get a better
2194117610Sdescompiler."
2195117610Sdes
2196247568Sdes	$opt_dry_run || $RM $removelist
2197141098Sdes	exit $EXIT_FAILURE
2198117610Sdes      fi
2199247568Sdes      func_append removelist " $output_obj"
2200247568Sdes      $ECHO "$srcfile" > "$lockfile"
2201117610Sdes    fi
2202117610Sdes
2203247568Sdes    $opt_dry_run || $RM $removelist
2204247568Sdes    func_append removelist " $lockfile"
2205247568Sdes    trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
2206117610Sdes
2207247568Sdes    func_to_tool_file "$srcfile" func_convert_file_msys_to_w32
2208247568Sdes    srcfile=$func_to_tool_file_result
2209247568Sdes    func_quote_for_eval "$srcfile"
2210247568Sdes    qsrcfile=$func_quote_for_eval_result
2211141098Sdes
2212117610Sdes    # Only build a PIC object if we are building libtool libraries.
2213117610Sdes    if test "$build_libtool_libs" = yes; then
2214117610Sdes      # Without this assignment, base_compile gets emptied.
2215117610Sdes      fbsd_hideous_sh_bug=$base_compile
2216117610Sdes
2217125647Sdes      if test "$pic_mode" != no; then
2218174832Sdes	command="$base_compile $qsrcfile $pic_flag"
2219125647Sdes      else
2220125647Sdes	# Don't build PIC code
2221174832Sdes	command="$base_compile $qsrcfile"
2222125647Sdes      fi
2223117610Sdes
2224247568Sdes      func_mkdir_p "$xdir$objdir"
2225141098Sdes
2226141098Sdes      if test -z "$output_obj"; then
2227141098Sdes	# Place PIC objects in $objdir
2228247568Sdes	func_append command " -o $lobj"
2229117610Sdes      fi
2230117610Sdes
2231247568Sdes      func_show_eval_locale "$command"	\
2232247568Sdes          'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
2233141098Sdes
2234117610Sdes      if test "$need_locks" = warn &&
2235141098Sdes	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
2236247568Sdes	$ECHO "\
2237117610Sdes*** ERROR, $lockfile contains:
2238117610Sdes`cat $lockfile 2>/dev/null`
2239117610Sdes
2240117610Sdesbut it should contain:
2241117610Sdes$srcfile
2242117610Sdes
2243117610SdesThis indicates that another process is trying to use the same
2244117610Sdestemporary object file, and libtool could not work around it because
2245117610Sdesyour compiler does not support \`-c' and \`-o' together.  If you
2246117610Sdesrepeat this compilation, it may succeed, by chance, but you had better
2247117610Sdesavoid parallel builds (make -j) in this platform, or get a better
2248117610Sdescompiler."
2249117610Sdes
2250247568Sdes	$opt_dry_run || $RM $removelist
2251141098Sdes	exit $EXIT_FAILURE
2252117610Sdes      fi
2253117610Sdes
2254117610Sdes      # Just move the object if needed, then go on to compile the next one
2255141098Sdes      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
2256247568Sdes	func_show_eval '$MV "$output_obj" "$lobj"' \
2257247568Sdes	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
2258117610Sdes      fi
2259117610Sdes
2260141098Sdes      # Allow error messages only from the first compilation.
2261141098Sdes      if test "$suppress_opt" = yes; then
2262247568Sdes	suppress_output=' >/dev/null 2>&1'
2263117610Sdes      fi
2264117610Sdes    fi
2265117610Sdes
2266117610Sdes    # Only build a position-dependent object if we build old libraries.
2267117610Sdes    if test "$build_old_libs" = yes; then
2268125647Sdes      if test "$pic_mode" != yes; then
2269125647Sdes	# Don't build PIC code
2270247568Sdes	command="$base_compile $qsrcfile$pie_flag"
2271125647Sdes      else
2272174832Sdes	command="$base_compile $qsrcfile $pic_flag"
2273125647Sdes      fi
2274117610Sdes      if test "$compiler_c_o" = yes; then
2275247568Sdes	func_append command " -o $obj"
2276117610Sdes      fi
2277117610Sdes
2278117610Sdes      # Suppress compiler output if we already did a PIC compilation.
2279247568Sdes      func_append command "$suppress_output"
2280247568Sdes      func_show_eval_locale "$command" \
2281247568Sdes        '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
2282117610Sdes
2283117610Sdes      if test "$need_locks" = warn &&
2284141098Sdes	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
2285247568Sdes	$ECHO "\
2286117610Sdes*** ERROR, $lockfile contains:
2287117610Sdes`cat $lockfile 2>/dev/null`
2288117610Sdes
2289117610Sdesbut it should contain:
2290117610Sdes$srcfile
2291117610Sdes
2292117610SdesThis indicates that another process is trying to use the same
2293117610Sdestemporary object file, and libtool could not work around it because
2294117610Sdesyour compiler does not support \`-c' and \`-o' together.  If you
2295117610Sdesrepeat this compilation, it may succeed, by chance, but you had better
2296117610Sdesavoid parallel builds (make -j) in this platform, or get a better
2297117610Sdescompiler."
2298117610Sdes
2299247568Sdes	$opt_dry_run || $RM $removelist
2300141098Sdes	exit $EXIT_FAILURE
2301117610Sdes      fi
2302117610Sdes
2303117610Sdes      # Just move the object if needed
2304141098Sdes      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
2305247568Sdes	func_show_eval '$MV "$output_obj" "$obj"' \
2306247568Sdes	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
2307247568Sdes      fi
2308247568Sdes    fi
2309247568Sdes
2310247568Sdes    $opt_dry_run || {
2311247568Sdes      func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
2312247568Sdes
2313247568Sdes      # Unlock the critical section if it was locked
2314247568Sdes      if test "$need_locks" != no; then
2315247568Sdes	removelist=$lockfile
2316247568Sdes        $RM "$lockfile"
2317247568Sdes      fi
2318247568Sdes    }
2319247568Sdes
2320247568Sdes    exit $EXIT_SUCCESS
2321247568Sdes}
2322247568Sdes
2323247568Sdes$opt_help || {
2324247568Sdes  test "$opt_mode" = compile && func_mode_compile ${1+"$@"}
2325247568Sdes}
2326247568Sdes
2327247568Sdesfunc_mode_help ()
2328247568Sdes{
2329247568Sdes    # We need to display help for each of the modes.
2330247568Sdes    case $opt_mode in
2331247568Sdes      "")
2332247568Sdes        # Generic help is extracted from the usage comments
2333247568Sdes        # at the start of this file.
2334247568Sdes        func_help
2335247568Sdes        ;;
2336247568Sdes
2337247568Sdes      clean)
2338247568Sdes        $ECHO \
2339247568Sdes"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
2340247568Sdes
2341247568SdesRemove files from the build directory.
2342247568Sdes
2343247568SdesRM is the name of the program to use to delete files associated with each FILE
2344247568Sdes(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
2345247568Sdesto RM.
2346247568Sdes
2347247568SdesIf FILE is a libtool library, object or program, all the files associated
2348247568Sdeswith it are deleted. Otherwise, only FILE itself is deleted using RM."
2349247568Sdes        ;;
2350247568Sdes
2351247568Sdes      compile)
2352247568Sdes      $ECHO \
2353247568Sdes"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
2354247568Sdes
2355247568SdesCompile a source file into a libtool library object.
2356247568Sdes
2357247568SdesThis mode accepts the following additional options:
2358247568Sdes
2359247568Sdes  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
2360247568Sdes  -no-suppress      do not suppress compiler output for multiple passes
2361247568Sdes  -prefer-pic       try to build PIC objects only
2362247568Sdes  -prefer-non-pic   try to build non-PIC objects only
2363247568Sdes  -shared           do not build a \`.o' file suitable for static linking
2364247568Sdes  -static           only build a \`.o' file suitable for static linking
2365247568Sdes  -Wc,FLAG          pass FLAG directly to the compiler
2366247568Sdes
2367247568SdesCOMPILE-COMMAND is a command to be used in creating a \`standard' object file
2368247568Sdesfrom the given SOURCEFILE.
2369247568Sdes
2370247568SdesThe output file name is determined by removing the directory component from
2371247568SdesSOURCEFILE, then substituting the C source code suffix \`.c' with the
2372247568Sdeslibrary object suffix, \`.lo'."
2373247568Sdes        ;;
2374247568Sdes
2375247568Sdes      execute)
2376247568Sdes        $ECHO \
2377247568Sdes"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
2378247568Sdes
2379247568SdesAutomatically set library path, then run a program.
2380247568Sdes
2381247568SdesThis mode accepts the following additional options:
2382247568Sdes
2383247568Sdes  -dlopen FILE      add the directory containing FILE to the library path
2384247568Sdes
2385247568SdesThis mode sets the library path environment variable according to \`-dlopen'
2386247568Sdesflags.
2387247568Sdes
2388247568SdesIf any of the ARGS are libtool executable wrappers, then they are translated
2389247568Sdesinto their corresponding uninstalled binary, and any of their required library
2390247568Sdesdirectories are added to the library path.
2391247568Sdes
2392247568SdesThen, COMMAND is executed, with ARGS as arguments."
2393247568Sdes        ;;
2394247568Sdes
2395247568Sdes      finish)
2396247568Sdes        $ECHO \
2397247568Sdes"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
2398247568Sdes
2399247568SdesComplete the installation of libtool libraries.
2400247568Sdes
2401247568SdesEach LIBDIR is a directory that contains libtool libraries.
2402247568Sdes
2403247568SdesThe commands that this mode executes may require superuser privileges.  Use
2404247568Sdesthe \`--dry-run' option if you just want to see what would be executed."
2405247568Sdes        ;;
2406247568Sdes
2407247568Sdes      install)
2408247568Sdes        $ECHO \
2409247568Sdes"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
2410247568Sdes
2411247568SdesInstall executables or libraries.
2412247568Sdes
2413247568SdesINSTALL-COMMAND is the installation command.  The first component should be
2414247568Sdeseither the \`install' or \`cp' program.
2415247568Sdes
2416247568SdesThe following components of INSTALL-COMMAND are treated specially:
2417247568Sdes
2418247568Sdes  -inst-prefix-dir PREFIX-DIR  Use PREFIX-DIR as a staging area for installation
2419247568Sdes
2420247568SdesThe rest of the components are interpreted as arguments to that command (only
2421247568SdesBSD-compatible install options are recognized)."
2422247568Sdes        ;;
2423247568Sdes
2424247568Sdes      link)
2425247568Sdes        $ECHO \
2426247568Sdes"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
2427247568Sdes
2428247568SdesLink object files or libraries together to form another library, or to
2429247568Sdescreate an executable program.
2430247568Sdes
2431247568SdesLINK-COMMAND is a command using the C compiler that you would use to create
2432247568Sdesa program from several object files.
2433247568Sdes
2434247568SdesThe following components of LINK-COMMAND are treated specially:
2435247568Sdes
2436247568Sdes  -all-static       do not do any dynamic linking at all
2437247568Sdes  -avoid-version    do not add a version suffix if possible
2438247568Sdes  -bindir BINDIR    specify path to binaries directory (for systems where
2439247568Sdes                    libraries must be found in the PATH setting at runtime)
2440247568Sdes  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
2441247568Sdes  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
2442247568Sdes  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
2443247568Sdes  -export-symbols SYMFILE
2444247568Sdes                    try to export only the symbols listed in SYMFILE
2445247568Sdes  -export-symbols-regex REGEX
2446247568Sdes                    try to export only the symbols matching REGEX
2447247568Sdes  -LLIBDIR          search LIBDIR for required installed libraries
2448247568Sdes  -lNAME            OUTPUT-FILE requires the installed library libNAME
2449247568Sdes  -module           build a library that can dlopened
2450247568Sdes  -no-fast-install  disable the fast-install mode
2451247568Sdes  -no-install       link a not-installable executable
2452247568Sdes  -no-undefined     declare that a library does not refer to external symbols
2453247568Sdes  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
2454247568Sdes  -objectlist FILE  Use a list of object files found in FILE to specify objects
2455247568Sdes  -precious-files-regex REGEX
2456247568Sdes                    don't remove output files matching REGEX
2457247568Sdes  -release RELEASE  specify package release information
2458247568Sdes  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
2459247568Sdes  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
2460247568Sdes  -shared           only do dynamic linking of libtool libraries
2461247568Sdes  -shrext SUFFIX    override the standard shared library file extension
2462247568Sdes  -static           do not do any dynamic linking of uninstalled libtool libraries
2463247568Sdes  -static-libtool-libs
2464247568Sdes                    do not do any dynamic linking of libtool libraries
2465247568Sdes  -version-info CURRENT[:REVISION[:AGE]]
2466247568Sdes                    specify library version info [each variable defaults to 0]
2467247568Sdes  -weak LIBNAME     declare that the target provides the LIBNAME interface
2468247568Sdes  -Wc,FLAG
2469247568Sdes  -Xcompiler FLAG   pass linker-specific FLAG directly to the compiler
2470247568Sdes  -Wl,FLAG
2471247568Sdes  -Xlinker FLAG     pass linker-specific FLAG directly to the linker
2472247568Sdes  -XCClinker FLAG   pass link-specific FLAG to the compiler driver (CC)
2473247568Sdes
2474247568SdesAll other options (arguments beginning with \`-') are ignored.
2475247568Sdes
2476247568SdesEvery other argument is treated as a filename.  Files ending in \`.la' are
2477247568Sdestreated as uninstalled libtool libraries, other files are standard or library
2478247568Sdesobject files.
2479247568Sdes
2480247568SdesIf the OUTPUT-FILE ends in \`.la', then a libtool library is created,
2481247568Sdesonly library objects (\`.lo' files) may be specified, and \`-rpath' is
2482247568Sdesrequired, except when creating a convenience library.
2483247568Sdes
2484247568SdesIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
2485247568Sdesusing \`ar' and \`ranlib', or on Windows using \`lib'.
2486247568Sdes
2487247568SdesIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
2488247568Sdesis created, otherwise an executable program is created."
2489247568Sdes        ;;
2490247568Sdes
2491247568Sdes      uninstall)
2492247568Sdes        $ECHO \
2493247568Sdes"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
2494247568Sdes
2495247568SdesRemove libraries from an installation directory.
2496247568Sdes
2497247568SdesRM is the name of the program to use to delete files associated with each FILE
2498247568Sdes(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
2499247568Sdesto RM.
2500247568Sdes
2501247568SdesIf FILE is a libtool library, all the files associated with it are deleted.
2502247568SdesOtherwise, only FILE itself is deleted using RM."
2503247568Sdes        ;;
2504247568Sdes
2505247568Sdes      *)
2506247568Sdes        func_fatal_help "invalid operation mode \`$opt_mode'"
2507247568Sdes        ;;
2508247568Sdes    esac
2509247568Sdes
2510247568Sdes    echo
2511247568Sdes    $ECHO "Try \`$progname --help' for more information about other modes."
2512247568Sdes}
2513247568Sdes
2514247568Sdes# Now that we've collected a possible --mode arg, show help if necessary
2515247568Sdesif $opt_help; then
2516247568Sdes  if test "$opt_help" = :; then
2517247568Sdes    func_mode_help
2518247568Sdes  else
2519247568Sdes    {
2520247568Sdes      func_help noexit
2521247568Sdes      for opt_mode in compile link execute install finish uninstall clean; do
2522247568Sdes	func_mode_help
2523247568Sdes      done
2524247568Sdes    } | sed -n '1p; 2,$s/^Usage:/  or: /p'
2525247568Sdes    {
2526247568Sdes      func_help noexit
2527247568Sdes      for opt_mode in compile link execute install finish uninstall clean; do
2528247568Sdes	echo
2529247568Sdes	func_mode_help
2530247568Sdes      done
2531247568Sdes    } |
2532247568Sdes    sed '1d
2533247568Sdes      /^When reporting/,/^Report/{
2534247568Sdes	H
2535247568Sdes	d
2536247568Sdes      }
2537247568Sdes      $x
2538247568Sdes      /information about other modes/d
2539247568Sdes      /more detailed .*MODE/d
2540247568Sdes      s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
2541247568Sdes  fi
2542247568Sdes  exit $?
2543247568Sdesfi
2544247568Sdes
2545247568Sdes
2546247568Sdes# func_mode_execute arg...
2547247568Sdesfunc_mode_execute ()
2548247568Sdes{
2549247568Sdes    $opt_debug
2550247568Sdes    # The first argument is the command name.
2551247568Sdes    cmd="$nonopt"
2552247568Sdes    test -z "$cmd" && \
2553247568Sdes      func_fatal_help "you must specify a COMMAND"
2554247568Sdes
2555247568Sdes    # Handle -dlopen flags immediately.
2556247568Sdes    for file in $opt_dlopen; do
2557247568Sdes      test -f "$file" \
2558247568Sdes	|| func_fatal_help "\`$file' is not a file"
2559247568Sdes
2560247568Sdes      dir=
2561247568Sdes      case $file in
2562247568Sdes      *.la)
2563247568Sdes	func_resolve_sysroot "$file"
2564247568Sdes	file=$func_resolve_sysroot_result
2565247568Sdes
2566247568Sdes	# Check to see that this really is a libtool archive.
2567247568Sdes	func_lalib_unsafe_p "$file" \
2568247568Sdes	  || func_fatal_help "\`$lib' is not a valid libtool archive"
2569247568Sdes
2570247568Sdes	# Read the libtool library.
2571247568Sdes	dlname=
2572247568Sdes	library_names=
2573247568Sdes	func_source "$file"
2574247568Sdes
2575247568Sdes	# Skip this library if it cannot be dlopened.
2576247568Sdes	if test -z "$dlname"; then
2577247568Sdes	  # Warn if it was a shared library.
2578247568Sdes	  test -n "$library_names" && \
2579247568Sdes	    func_warning "\`$file' was not linked with \`-export-dynamic'"
2580247568Sdes	  continue
2581247568Sdes	fi
2582247568Sdes
2583247568Sdes	func_dirname "$file" "" "."
2584247568Sdes	dir="$func_dirname_result"
2585247568Sdes
2586247568Sdes	if test -f "$dir/$objdir/$dlname"; then
2587247568Sdes	  func_append dir "/$objdir"
2588117610Sdes	else
2589247568Sdes	  if test ! -f "$dir/$dlname"; then
2590247568Sdes	    func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'"
2591247568Sdes	  fi
2592117610Sdes	fi
2593247568Sdes	;;
2594247568Sdes
2595247568Sdes      *.lo)
2596247568Sdes	# Just add the directory containing the .lo file.
2597247568Sdes	func_dirname "$file" "" "."
2598247568Sdes	dir="$func_dirname_result"
2599247568Sdes	;;
2600247568Sdes
2601247568Sdes      *)
2602247568Sdes	func_warning "\`-dlopen' is ignored for non-libtool libraries and objects"
2603247568Sdes	continue
2604247568Sdes	;;
2605247568Sdes      esac
2606247568Sdes
2607247568Sdes      # Get the absolute pathname.
2608247568Sdes      absdir=`cd "$dir" && pwd`
2609247568Sdes      test -n "$absdir" && dir="$absdir"
2610247568Sdes
2611247568Sdes      # Now add the directory to shlibpath_var.
2612247568Sdes      if eval "test -z \"\$$shlibpath_var\""; then
2613247568Sdes	eval "$shlibpath_var=\"\$dir\""
2614247568Sdes      else
2615247568Sdes	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
2616117610Sdes      fi
2617247568Sdes    done
2618117610Sdes
2619247568Sdes    # This variable tells wrapper scripts just to set shlibpath_var
2620247568Sdes    # rather than running their programs.
2621247568Sdes    libtool_execute_magic="$magic"
2622141098Sdes
2623247568Sdes    # Check if any of the arguments is a wrapper script.
2624247568Sdes    args=
2625247568Sdes    for file
2626247568Sdes    do
2627247568Sdes      case $file in
2628247568Sdes      -* | *.la | *.lo ) ;;
2629247568Sdes      *)
2630247568Sdes	# Do a test to see if this is really a libtool program.
2631247568Sdes	if func_ltwrapper_script_p "$file"; then
2632247568Sdes	  func_source "$file"
2633247568Sdes	  # Transform arg to wrapped name.
2634247568Sdes	  file="$progdir/$program"
2635247568Sdes	elif func_ltwrapper_executable_p "$file"; then
2636247568Sdes	  func_ltwrapper_scriptname "$file"
2637247568Sdes	  func_source "$func_ltwrapper_scriptname_result"
2638247568Sdes	  # Transform arg to wrapped name.
2639247568Sdes	  file="$progdir/$program"
2640247568Sdes	fi
2641247568Sdes	;;
2642247568Sdes      esac
2643247568Sdes      # Quote arguments (to preserve shell metacharacters).
2644247568Sdes      func_append_quoted args "$file"
2645247568Sdes    done
2646247568Sdes
2647247568Sdes    if test "X$opt_dry_run" = Xfalse; then
2648247568Sdes      if test -n "$shlibpath_var"; then
2649247568Sdes	# Export the shlibpath_var.
2650247568Sdes	eval "export $shlibpath_var"
2651247568Sdes      fi
2652247568Sdes
2653247568Sdes      # Restore saved environment variables
2654247568Sdes      for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
2655247568Sdes      do
2656247568Sdes	eval "if test \"\${save_$lt_var+set}\" = set; then
2657247568Sdes                $lt_var=\$save_$lt_var; export $lt_var
2658247568Sdes	      else
2659247568Sdes		$lt_unset $lt_var
2660247568Sdes	      fi"
2661247568Sdes      done
2662247568Sdes
2663247568Sdes      # Now prepare to actually exec the command.
2664247568Sdes      exec_cmd="\$cmd$args"
2665141098Sdes    else
2666247568Sdes      # Display what would be done.
2667247568Sdes      if test -n "$shlibpath_var"; then
2668247568Sdes	eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
2669247568Sdes	echo "export $shlibpath_var"
2670247568Sdes      fi
2671247568Sdes      $ECHO "$cmd$args"
2672247568Sdes      exit $EXIT_SUCCESS
2673247568Sdes    fi
2674247568Sdes}
2675141098Sdes
2676247568Sdestest "$opt_mode" = execute && func_mode_execute ${1+"$@"}
2677247568Sdes
2678247568Sdes
2679247568Sdes# func_mode_finish arg...
2680247568Sdesfunc_mode_finish ()
2681247568Sdes{
2682247568Sdes    $opt_debug
2683247568Sdes    libs=
2684247568Sdes    libdirs=
2685247568Sdes    admincmds=
2686247568Sdes
2687247568Sdes    for opt in "$nonopt" ${1+"$@"}
2688247568Sdes    do
2689247568Sdes      if test -d "$opt"; then
2690247568Sdes	func_append libdirs " $opt"
2691247568Sdes
2692247568Sdes      elif test -f "$opt"; then
2693247568Sdes	if func_lalib_unsafe_p "$opt"; then
2694247568Sdes	  func_append libs " $opt"
2695247568Sdes	else
2696247568Sdes	  func_warning "\`$opt' is not a valid libtool archive"
2697247568Sdes	fi
2698247568Sdes
2699247568Sdes      else
2700247568Sdes	func_fatal_error "invalid argument \`$opt'"
2701247568Sdes      fi
2702247568Sdes    done
2703247568Sdes
2704247568Sdes    if test -n "$libs"; then
2705247568Sdes      if test -n "$lt_sysroot"; then
2706247568Sdes        sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"`
2707247568Sdes        sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;"
2708247568Sdes      else
2709247568Sdes        sysroot_cmd=
2710247568Sdes      fi
2711247568Sdes
2712247568Sdes      # Remove sysroot references
2713247568Sdes      if $opt_dry_run; then
2714247568Sdes        for lib in $libs; do
2715247568Sdes          echo "removing references to $lt_sysroot and \`=' prefixes from $lib"
2716247568Sdes        done
2717247568Sdes      else
2718247568Sdes        tmpdir=`func_mktempdir`
2719247568Sdes        for lib in $libs; do
2720247568Sdes	  sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
2721247568Sdes	    > $tmpdir/tmp-la
2722247568Sdes	  mv -f $tmpdir/tmp-la $lib
2723247568Sdes	done
2724247568Sdes        ${RM}r "$tmpdir"
2725247568Sdes      fi
2726117610Sdes    fi
2727117610Sdes
2728247568Sdes    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
2729247568Sdes      for libdir in $libdirs; do
2730247568Sdes	if test -n "$finish_cmds"; then
2731247568Sdes	  # Do each command in the finish commands.
2732247568Sdes	  func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
2733247568Sdes'"$cmd"'"'
2734247568Sdes	fi
2735247568Sdes	if test -n "$finish_eval"; then
2736247568Sdes	  # Do the single finish_eval.
2737247568Sdes	  eval cmds=\"$finish_eval\"
2738247568Sdes	  $opt_dry_run || eval "$cmds" || func_append admincmds "
2739247568Sdes       $cmds"
2740247568Sdes	fi
2741247568Sdes      done
2742247568Sdes    fi
2743141098Sdes
2744247568Sdes    # Exit here if they wanted silent mode.
2745247568Sdes    $opt_silent && exit $EXIT_SUCCESS
2746247568Sdes
2747247568Sdes    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
2748247568Sdes      echo "----------------------------------------------------------------------"
2749247568Sdes      echo "Libraries have been installed in:"
2750247568Sdes      for libdir in $libdirs; do
2751247568Sdes	$ECHO "   $libdir"
2752247568Sdes      done
2753247568Sdes      echo
2754247568Sdes      echo "If you ever happen to want to link against installed libraries"
2755247568Sdes      echo "in a given directory, LIBDIR, you must either use libtool, and"
2756247568Sdes      echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
2757247568Sdes      echo "flag during linking and do at least one of the following:"
2758247568Sdes      if test -n "$shlibpath_var"; then
2759247568Sdes	echo "   - add LIBDIR to the \`$shlibpath_var' environment variable"
2760247568Sdes	echo "     during execution"
2761247568Sdes      fi
2762247568Sdes      if test -n "$runpath_var"; then
2763247568Sdes	echo "   - add LIBDIR to the \`$runpath_var' environment variable"
2764247568Sdes	echo "     during linking"
2765247568Sdes      fi
2766247568Sdes      if test -n "$hardcode_libdir_flag_spec"; then
2767247568Sdes	libdir=LIBDIR
2768247568Sdes	eval flag=\"$hardcode_libdir_flag_spec\"
2769247568Sdes
2770247568Sdes	$ECHO "   - use the \`$flag' linker flag"
2771247568Sdes      fi
2772247568Sdes      if test -n "$admincmds"; then
2773247568Sdes	$ECHO "   - have your system administrator run these commands:$admincmds"
2774247568Sdes      fi
2775247568Sdes      if test -f /etc/ld.so.conf; then
2776247568Sdes	echo "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
2777247568Sdes      fi
2778247568Sdes      echo
2779247568Sdes
2780247568Sdes      echo "See any operating system documentation about shared libraries for"
2781247568Sdes      case $host in
2782247568Sdes	solaris2.[6789]|solaris2.1[0-9])
2783247568Sdes	  echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
2784247568Sdes	  echo "pages."
2785247568Sdes	  ;;
2786247568Sdes	*)
2787247568Sdes	  echo "more information, such as the ld(1) and ld.so(8) manual pages."
2788247568Sdes	  ;;
2789247568Sdes      esac
2790247568Sdes      echo "----------------------------------------------------------------------"
2791117610Sdes    fi
2792247568Sdes    exit $EXIT_SUCCESS
2793247568Sdes}
2794117610Sdes
2795247568Sdestest "$opt_mode" = finish && func_mode_finish ${1+"$@"}
2796247568Sdes
2797247568Sdes
2798247568Sdes# func_mode_install arg...
2799247568Sdesfunc_mode_install ()
2800247568Sdes{
2801247568Sdes    $opt_debug
2802247568Sdes    # There may be an optional sh(1) argument at the beginning of
2803247568Sdes    # install_prog (especially on Windows NT).
2804247568Sdes    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
2805247568Sdes       # Allow the use of GNU shtool's install command.
2806247568Sdes       case $nonopt in *shtool*) :;; *) false;; esac; then
2807247568Sdes      # Aesthetically quote it.
2808247568Sdes      func_quote_for_eval "$nonopt"
2809247568Sdes      install_prog="$func_quote_for_eval_result "
2810247568Sdes      arg=$1
2811247568Sdes      shift
2812247568Sdes    else
2813247568Sdes      install_prog=
2814247568Sdes      arg=$nonopt
2815247568Sdes    fi
2816247568Sdes
2817247568Sdes    # The real first argument should be the name of the installation program.
2818247568Sdes    # Aesthetically quote it.
2819247568Sdes    func_quote_for_eval "$arg"
2820247568Sdes    func_append install_prog "$func_quote_for_eval_result"
2821247568Sdes    install_shared_prog=$install_prog
2822247568Sdes    case " $install_prog " in
2823247568Sdes      *[\\\ /]cp\ *) install_cp=: ;;
2824247568Sdes      *) install_cp=false ;;
2825247568Sdes    esac
2826247568Sdes
2827247568Sdes    # We need to accept at least all the BSD install flags.
2828247568Sdes    dest=
2829247568Sdes    files=
2830247568Sdes    opts=
2831247568Sdes    prev=
2832247568Sdes    install_type=
2833247568Sdes    isdir=no
2834247568Sdes    stripme=
2835247568Sdes    no_mode=:
2836247568Sdes    for arg
2837247568Sdes    do
2838247568Sdes      arg2=
2839247568Sdes      if test -n "$dest"; then
2840247568Sdes	func_append files " $dest"
2841247568Sdes	dest=$arg
2842247568Sdes	continue
2843247568Sdes      fi
2844247568Sdes
2845247568Sdes      case $arg in
2846247568Sdes      -d) isdir=yes ;;
2847247568Sdes      -f)
2848247568Sdes	if $install_cp; then :; else
2849247568Sdes	  prev=$arg
2850247568Sdes	fi
2851247568Sdes	;;
2852247568Sdes      -g | -m | -o)
2853247568Sdes	prev=$arg
2854247568Sdes	;;
2855247568Sdes      -s)
2856247568Sdes	stripme=" -s"
2857247568Sdes	continue
2858247568Sdes	;;
2859247568Sdes      -*)
2860247568Sdes	;;
2861247568Sdes      *)
2862247568Sdes	# If the previous option needed an argument, then skip it.
2863247568Sdes	if test -n "$prev"; then
2864247568Sdes	  if test "x$prev" = x-m && test -n "$install_override_mode"; then
2865247568Sdes	    arg2=$install_override_mode
2866247568Sdes	    no_mode=false
2867247568Sdes	  fi
2868247568Sdes	  prev=
2869247568Sdes	else
2870247568Sdes	  dest=$arg
2871247568Sdes	  continue
2872247568Sdes	fi
2873247568Sdes	;;
2874247568Sdes      esac
2875247568Sdes
2876247568Sdes      # Aesthetically quote the argument.
2877247568Sdes      func_quote_for_eval "$arg"
2878247568Sdes      func_append install_prog " $func_quote_for_eval_result"
2879247568Sdes      if test -n "$arg2"; then
2880247568Sdes	func_quote_for_eval "$arg2"
2881247568Sdes      fi
2882247568Sdes      func_append install_shared_prog " $func_quote_for_eval_result"
2883247568Sdes    done
2884247568Sdes
2885247568Sdes    test -z "$install_prog" && \
2886247568Sdes      func_fatal_help "you must specify an install program"
2887247568Sdes
2888247568Sdes    test -n "$prev" && \
2889247568Sdes      func_fatal_help "the \`$prev' option requires an argument"
2890247568Sdes
2891247568Sdes    if test -n "$install_override_mode" && $no_mode; then
2892247568Sdes      if $install_cp; then :; else
2893247568Sdes	func_quote_for_eval "$install_override_mode"
2894247568Sdes	func_append install_shared_prog " -m $func_quote_for_eval_result"
2895247568Sdes      fi
2896247568Sdes    fi
2897247568Sdes
2898247568Sdes    if test -z "$files"; then
2899247568Sdes      if test -z "$dest"; then
2900247568Sdes	func_fatal_help "no file or destination specified"
2901247568Sdes      else
2902247568Sdes	func_fatal_help "you must specify a destination"
2903247568Sdes      fi
2904247568Sdes    fi
2905247568Sdes
2906247568Sdes    # Strip any trailing slash from the destination.
2907247568Sdes    func_stripname '' '/' "$dest"
2908247568Sdes    dest=$func_stripname_result
2909247568Sdes
2910247568Sdes    # Check to see that the destination is a directory.
2911247568Sdes    test -d "$dest" && isdir=yes
2912247568Sdes    if test "$isdir" = yes; then
2913247568Sdes      destdir="$dest"
2914247568Sdes      destname=
2915247568Sdes    else
2916247568Sdes      func_dirname_and_basename "$dest" "" "."
2917247568Sdes      destdir="$func_dirname_result"
2918247568Sdes      destname="$func_basename_result"
2919247568Sdes
2920247568Sdes      # Not a directory, so check to see that there is only one file specified.
2921247568Sdes      set dummy $files; shift
2922247568Sdes      test "$#" -gt 1 && \
2923247568Sdes	func_fatal_help "\`$dest' is not a directory"
2924247568Sdes    fi
2925247568Sdes    case $destdir in
2926247568Sdes    [\\/]* | [A-Za-z]:[\\/]*) ;;
2927247568Sdes    *)
2928247568Sdes      for file in $files; do
2929247568Sdes	case $file in
2930247568Sdes	*.lo) ;;
2931247568Sdes	*)
2932247568Sdes	  func_fatal_help "\`$destdir' must be an absolute directory name"
2933247568Sdes	  ;;
2934247568Sdes	esac
2935247568Sdes      done
2936247568Sdes      ;;
2937247568Sdes    esac
2938247568Sdes
2939247568Sdes    # This variable tells wrapper scripts just to set variables rather
2940247568Sdes    # than running their programs.
2941247568Sdes    libtool_install_magic="$magic"
2942247568Sdes
2943247568Sdes    staticlibs=
2944247568Sdes    future_libdirs=
2945247568Sdes    current_libdirs=
2946247568Sdes    for file in $files; do
2947247568Sdes
2948247568Sdes      # Do each installation.
2949247568Sdes      case $file in
2950247568Sdes      *.$libext)
2951247568Sdes	# Do the static libraries later.
2952247568Sdes	func_append staticlibs " $file"
2953247568Sdes	;;
2954247568Sdes
2955247568Sdes      *.la)
2956247568Sdes	func_resolve_sysroot "$file"
2957247568Sdes	file=$func_resolve_sysroot_result
2958247568Sdes
2959247568Sdes	# Check to see that this really is a libtool archive.
2960247568Sdes	func_lalib_unsafe_p "$file" \
2961247568Sdes	  || func_fatal_help "\`$file' is not a valid libtool archive"
2962247568Sdes
2963247568Sdes	library_names=
2964247568Sdes	old_library=
2965247568Sdes	relink_command=
2966247568Sdes	func_source "$file"
2967247568Sdes
2968247568Sdes	# Add the libdir to current_libdirs if it is the destination.
2969247568Sdes	if test "X$destdir" = "X$libdir"; then
2970247568Sdes	  case "$current_libdirs " in
2971247568Sdes	  *" $libdir "*) ;;
2972247568Sdes	  *) func_append current_libdirs " $libdir" ;;
2973247568Sdes	  esac
2974247568Sdes	else
2975247568Sdes	  # Note the libdir as a future libdir.
2976247568Sdes	  case "$future_libdirs " in
2977247568Sdes	  *" $libdir "*) ;;
2978247568Sdes	  *) func_append future_libdirs " $libdir" ;;
2979247568Sdes	  esac
2980247568Sdes	fi
2981247568Sdes
2982247568Sdes	func_dirname "$file" "/" ""
2983247568Sdes	dir="$func_dirname_result"
2984247568Sdes	func_append dir "$objdir"
2985247568Sdes
2986247568Sdes	if test -n "$relink_command"; then
2987247568Sdes	  # Determine the prefix the user has applied to our future dir.
2988247568Sdes	  inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
2989247568Sdes
2990247568Sdes	  # Don't allow the user to place us outside of our expected
2991247568Sdes	  # location b/c this prevents finding dependent libraries that
2992247568Sdes	  # are installed to the same prefix.
2993247568Sdes	  # At present, this check doesn't affect windows .dll's that
2994247568Sdes	  # are installed into $libdir/../bin (currently, that works fine)
2995247568Sdes	  # but it's something to keep an eye on.
2996247568Sdes	  test "$inst_prefix_dir" = "$destdir" && \
2997247568Sdes	    func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
2998247568Sdes
2999247568Sdes	  if test -n "$inst_prefix_dir"; then
3000247568Sdes	    # Stick the inst_prefix_dir data into the link command.
3001247568Sdes	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
3002247568Sdes	  else
3003247568Sdes	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
3004247568Sdes	  fi
3005247568Sdes
3006247568Sdes	  func_warning "relinking \`$file'"
3007247568Sdes	  func_show_eval "$relink_command" \
3008247568Sdes	    'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
3009247568Sdes	fi
3010247568Sdes
3011247568Sdes	# See the names of the shared library.
3012247568Sdes	set dummy $library_names; shift
3013247568Sdes	if test -n "$1"; then
3014247568Sdes	  realname="$1"
3015247568Sdes	  shift
3016247568Sdes
3017247568Sdes	  srcname="$realname"
3018247568Sdes	  test -n "$relink_command" && srcname="$realname"T
3019247568Sdes
3020247568Sdes	  # Install the shared library and build the symlinks.
3021247568Sdes	  func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
3022247568Sdes	      'exit $?'
3023247568Sdes	  tstripme="$stripme"
3024247568Sdes	  case $host_os in
3025247568Sdes	  cygwin* | mingw* | pw32* | cegcc*)
3026247568Sdes	    case $realname in
3027247568Sdes	    *.dll.a)
3028247568Sdes	      tstripme=""
3029247568Sdes	      ;;
3030247568Sdes	    esac
3031247568Sdes	    ;;
3032247568Sdes	  esac
3033247568Sdes	  if test -n "$tstripme" && test -n "$striplib"; then
3034247568Sdes	    func_show_eval "$striplib $destdir/$realname" 'exit $?'
3035247568Sdes	  fi
3036247568Sdes
3037247568Sdes	  if test "$#" -gt 0; then
3038247568Sdes	    # Delete the old symlinks, and create new ones.
3039247568Sdes	    # Try `ln -sf' first, because the `ln' binary might depend on
3040247568Sdes	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
3041247568Sdes	    # so we also need to try rm && ln -s.
3042247568Sdes	    for linkname
3043247568Sdes	    do
3044247568Sdes	      test "$linkname" != "$realname" \
3045247568Sdes		&& func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
3046247568Sdes	    done
3047247568Sdes	  fi
3048247568Sdes
3049247568Sdes	  # Do each command in the postinstall commands.
3050247568Sdes	  lib="$destdir/$realname"
3051247568Sdes	  func_execute_cmds "$postinstall_cmds" 'exit $?'
3052247568Sdes	fi
3053247568Sdes
3054247568Sdes	# Install the pseudo-library for information purposes.
3055247568Sdes	func_basename "$file"
3056247568Sdes	name="$func_basename_result"
3057247568Sdes	instname="$dir/$name"i
3058247568Sdes	func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
3059247568Sdes
3060247568Sdes	# Maybe install the static library, too.
3061247568Sdes	test -n "$old_library" && func_append staticlibs " $dir/$old_library"
3062247568Sdes	;;
3063247568Sdes
3064247568Sdes      *.lo)
3065247568Sdes	# Install (i.e. copy) a libtool object.
3066247568Sdes
3067247568Sdes	# Figure out destination file name, if it wasn't already specified.
3068247568Sdes	if test -n "$destname"; then
3069247568Sdes	  destfile="$destdir/$destname"
3070247568Sdes	else
3071247568Sdes	  func_basename "$file"
3072247568Sdes	  destfile="$func_basename_result"
3073247568Sdes	  destfile="$destdir/$destfile"
3074247568Sdes	fi
3075247568Sdes
3076247568Sdes	# Deduce the name of the destination old-style object file.
3077247568Sdes	case $destfile in
3078247568Sdes	*.lo)
3079247568Sdes	  func_lo2o "$destfile"
3080247568Sdes	  staticdest=$func_lo2o_result
3081247568Sdes	  ;;
3082247568Sdes	*.$objext)
3083247568Sdes	  staticdest="$destfile"
3084247568Sdes	  destfile=
3085247568Sdes	  ;;
3086247568Sdes	*)
3087247568Sdes	  func_fatal_help "cannot copy a libtool object to \`$destfile'"
3088247568Sdes	  ;;
3089247568Sdes	esac
3090247568Sdes
3091247568Sdes	# Install the libtool object if requested.
3092247568Sdes	test -n "$destfile" && \
3093247568Sdes	  func_show_eval "$install_prog $file $destfile" 'exit $?'
3094247568Sdes
3095247568Sdes	# Install the old object if enabled.
3096247568Sdes	if test "$build_old_libs" = yes; then
3097247568Sdes	  # Deduce the name of the old-style object file.
3098247568Sdes	  func_lo2o "$file"
3099247568Sdes	  staticobj=$func_lo2o_result
3100247568Sdes	  func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
3101247568Sdes	fi
3102247568Sdes	exit $EXIT_SUCCESS
3103247568Sdes	;;
3104247568Sdes
3105247568Sdes      *)
3106247568Sdes	# Figure out destination file name, if it wasn't already specified.
3107247568Sdes	if test -n "$destname"; then
3108247568Sdes	  destfile="$destdir/$destname"
3109247568Sdes	else
3110247568Sdes	  func_basename "$file"
3111247568Sdes	  destfile="$func_basename_result"
3112247568Sdes	  destfile="$destdir/$destfile"
3113247568Sdes	fi
3114247568Sdes
3115247568Sdes	# If the file is missing, and there is a .exe on the end, strip it
3116247568Sdes	# because it is most likely a libtool script we actually want to
3117247568Sdes	# install
3118247568Sdes	stripped_ext=""
3119247568Sdes	case $file in
3120247568Sdes	  *.exe)
3121247568Sdes	    if test ! -f "$file"; then
3122247568Sdes	      func_stripname '' '.exe' "$file"
3123247568Sdes	      file=$func_stripname_result
3124247568Sdes	      stripped_ext=".exe"
3125247568Sdes	    fi
3126247568Sdes	    ;;
3127247568Sdes	esac
3128247568Sdes
3129247568Sdes	# Do a test to see if this is really a libtool program.
3130247568Sdes	case $host in
3131247568Sdes	*cygwin* | *mingw*)
3132247568Sdes	    if func_ltwrapper_executable_p "$file"; then
3133247568Sdes	      func_ltwrapper_scriptname "$file"
3134247568Sdes	      wrapper=$func_ltwrapper_scriptname_result
3135247568Sdes	    else
3136247568Sdes	      func_stripname '' '.exe' "$file"
3137247568Sdes	      wrapper=$func_stripname_result
3138247568Sdes	    fi
3139247568Sdes	    ;;
3140247568Sdes	*)
3141247568Sdes	    wrapper=$file
3142247568Sdes	    ;;
3143247568Sdes	esac
3144247568Sdes	if func_ltwrapper_script_p "$wrapper"; then
3145247568Sdes	  notinst_deplibs=
3146247568Sdes	  relink_command=
3147247568Sdes
3148247568Sdes	  func_source "$wrapper"
3149247568Sdes
3150247568Sdes	  # Check the variables that should have been set.
3151247568Sdes	  test -z "$generated_by_libtool_version" && \
3152247568Sdes	    func_fatal_error "invalid libtool wrapper script \`$wrapper'"
3153247568Sdes
3154247568Sdes	  finalize=yes
3155247568Sdes	  for lib in $notinst_deplibs; do
3156247568Sdes	    # Check to see that each library is installed.
3157247568Sdes	    libdir=
3158247568Sdes	    if test -f "$lib"; then
3159247568Sdes	      func_source "$lib"
3160247568Sdes	    fi
3161247568Sdes	    libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test
3162247568Sdes	    if test -n "$libdir" && test ! -f "$libfile"; then
3163247568Sdes	      func_warning "\`$lib' has not been installed in \`$libdir'"
3164247568Sdes	      finalize=no
3165247568Sdes	    fi
3166247568Sdes	  done
3167247568Sdes
3168247568Sdes	  relink_command=
3169247568Sdes	  func_source "$wrapper"
3170247568Sdes
3171247568Sdes	  outputname=
3172247568Sdes	  if test "$fast_install" = no && test -n "$relink_command"; then
3173247568Sdes	    $opt_dry_run || {
3174247568Sdes	      if test "$finalize" = yes; then
3175247568Sdes	        tmpdir=`func_mktempdir`
3176247568Sdes		func_basename "$file$stripped_ext"
3177247568Sdes		file="$func_basename_result"
3178247568Sdes	        outputname="$tmpdir/$file"
3179247568Sdes	        # Replace the output file specification.
3180247568Sdes	        relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
3181247568Sdes
3182247568Sdes	        $opt_silent || {
3183247568Sdes	          func_quote_for_expand "$relink_command"
3184247568Sdes		  eval "func_echo $func_quote_for_expand_result"
3185247568Sdes	        }
3186247568Sdes	        if eval "$relink_command"; then :
3187247568Sdes	          else
3188247568Sdes		  func_error "error: relink \`$file' with the above command before installing it"
3189247568Sdes		  $opt_dry_run || ${RM}r "$tmpdir"
3190247568Sdes		  continue
3191247568Sdes	        fi
3192247568Sdes	        file="$outputname"
3193247568Sdes	      else
3194247568Sdes	        func_warning "cannot relink \`$file'"
3195247568Sdes	      fi
3196247568Sdes	    }
3197247568Sdes	  else
3198247568Sdes	    # Install the binary that we compiled earlier.
3199247568Sdes	    file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
3200247568Sdes	  fi
3201247568Sdes	fi
3202247568Sdes
3203247568Sdes	# remove .exe since cygwin /usr/bin/install will append another
3204247568Sdes	# one anyway
3205247568Sdes	case $install_prog,$host in
3206247568Sdes	*/usr/bin/install*,*cygwin*)
3207247568Sdes	  case $file:$destfile in
3208247568Sdes	  *.exe:*.exe)
3209247568Sdes	    # this is ok
3210247568Sdes	    ;;
3211247568Sdes	  *.exe:*)
3212247568Sdes	    destfile=$destfile.exe
3213247568Sdes	    ;;
3214247568Sdes	  *:*.exe)
3215247568Sdes	    func_stripname '' '.exe' "$destfile"
3216247568Sdes	    destfile=$func_stripname_result
3217247568Sdes	    ;;
3218247568Sdes	  esac
3219247568Sdes	  ;;
3220247568Sdes	esac
3221247568Sdes	func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
3222247568Sdes	$opt_dry_run || if test -n "$outputname"; then
3223247568Sdes	  ${RM}r "$tmpdir"
3224247568Sdes	fi
3225247568Sdes	;;
3226247568Sdes      esac
3227247568Sdes    done
3228247568Sdes
3229247568Sdes    for file in $staticlibs; do
3230247568Sdes      func_basename "$file"
3231247568Sdes      name="$func_basename_result"
3232247568Sdes
3233247568Sdes      # Set up the ranlib parameters.
3234247568Sdes      oldlib="$destdir/$name"
3235247568Sdes      func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
3236247568Sdes      tool_oldlib=$func_to_tool_file_result
3237247568Sdes
3238247568Sdes      func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
3239247568Sdes
3240247568Sdes      if test -n "$stripme" && test -n "$old_striplib"; then
3241247568Sdes	func_show_eval "$old_striplib $tool_oldlib" 'exit $?'
3242247568Sdes      fi
3243247568Sdes
3244247568Sdes      # Do each command in the postinstall commands.
3245247568Sdes      func_execute_cmds "$old_postinstall_cmds" 'exit $?'
3246247568Sdes    done
3247247568Sdes
3248247568Sdes    test -n "$future_libdirs" && \
3249247568Sdes      func_warning "remember to run \`$progname --finish$future_libdirs'"
3250247568Sdes
3251247568Sdes    if test -n "$current_libdirs"; then
3252247568Sdes      # Maybe just do a dry run.
3253247568Sdes      $opt_dry_run && current_libdirs=" -n$current_libdirs"
3254247568Sdes      exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
3255247568Sdes    else
3256247568Sdes      exit $EXIT_SUCCESS
3257247568Sdes    fi
3258247568Sdes}
3259247568Sdes
3260247568Sdestest "$opt_mode" = install && func_mode_install ${1+"$@"}
3261247568Sdes
3262247568Sdes
3263247568Sdes# func_generate_dlsyms outputname originator pic_p
3264247568Sdes# Extract symbols from dlprefiles and create ${outputname}S.o with
3265247568Sdes# a dlpreopen symbol table.
3266247568Sdesfunc_generate_dlsyms ()
3267247568Sdes{
3268247568Sdes    $opt_debug
3269247568Sdes    my_outputname="$1"
3270247568Sdes    my_originator="$2"
3271247568Sdes    my_pic_p="${3-no}"
3272247568Sdes    my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'`
3273247568Sdes    my_dlsyms=
3274247568Sdes
3275247568Sdes    if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
3276247568Sdes      if test -n "$NM" && test -n "$global_symbol_pipe"; then
3277247568Sdes	my_dlsyms="${my_outputname}S.c"
3278247568Sdes      else
3279247568Sdes	func_error "not configured to extract global symbols from dlpreopened files"
3280247568Sdes      fi
3281247568Sdes    fi
3282247568Sdes
3283247568Sdes    if test -n "$my_dlsyms"; then
3284247568Sdes      case $my_dlsyms in
3285247568Sdes      "") ;;
3286247568Sdes      *.c)
3287247568Sdes	# Discover the nlist of each of the dlfiles.
3288247568Sdes	nlist="$output_objdir/${my_outputname}.nm"
3289247568Sdes
3290247568Sdes	func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
3291247568Sdes
3292247568Sdes	# Parse the name list into a source file.
3293247568Sdes	func_verbose "creating $output_objdir/$my_dlsyms"
3294247568Sdes
3295247568Sdes	$opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
3296247568Sdes/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */
3297247568Sdes/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */
3298247568Sdes
3299247568Sdes#ifdef __cplusplus
3300247568Sdesextern \"C\" {
3301247568Sdes#endif
3302247568Sdes
3303247568Sdes#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
3304247568Sdes#pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
3305247568Sdes#endif
3306247568Sdes
3307247568Sdes/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
3308247568Sdes#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
3309247568Sdes/* DATA imports from DLLs on WIN32 con't be const, because runtime
3310247568Sdes   relocations are performed -- see ld's documentation on pseudo-relocs.  */
3311247568Sdes# define LT_DLSYM_CONST
3312247568Sdes#elif defined(__osf__)
3313247568Sdes/* This system does not cope well with relocations in const data.  */
3314247568Sdes# define LT_DLSYM_CONST
3315247568Sdes#else
3316247568Sdes# define LT_DLSYM_CONST const
3317247568Sdes#endif
3318247568Sdes
3319247568Sdes/* External symbol declarations for the compiler. */\
3320247568Sdes"
3321247568Sdes
3322247568Sdes	if test "$dlself" = yes; then
3323247568Sdes	  func_verbose "generating symbol list for \`$output'"
3324247568Sdes
3325247568Sdes	  $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
3326247568Sdes
3327247568Sdes	  # Add our own program objects to the symbol list.
3328247568Sdes	  progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
3329247568Sdes	  for progfile in $progfiles; do
3330247568Sdes	    func_to_tool_file "$progfile" func_convert_file_msys_to_w32
3331247568Sdes	    func_verbose "extracting global C symbols from \`$func_to_tool_file_result'"
3332247568Sdes	    $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
3333247568Sdes	  done
3334247568Sdes
3335247568Sdes	  if test -n "$exclude_expsyms"; then
3336247568Sdes	    $opt_dry_run || {
3337247568Sdes	      eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
3338247568Sdes	      eval '$MV "$nlist"T "$nlist"'
3339247568Sdes	    }
3340247568Sdes	  fi
3341247568Sdes
3342247568Sdes	  if test -n "$export_symbols_regex"; then
3343247568Sdes	    $opt_dry_run || {
3344247568Sdes	      eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
3345247568Sdes	      eval '$MV "$nlist"T "$nlist"'
3346247568Sdes	    }
3347247568Sdes	  fi
3348247568Sdes
3349247568Sdes	  # Prepare the list of exported symbols
3350247568Sdes	  if test -z "$export_symbols"; then
3351247568Sdes	    export_symbols="$output_objdir/$outputname.exp"
3352247568Sdes	    $opt_dry_run || {
3353247568Sdes	      $RM $export_symbols
3354247568Sdes	      eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
3355247568Sdes	      case $host in
3356247568Sdes	      *cygwin* | *mingw* | *cegcc* )
3357247568Sdes                eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
3358247568Sdes                eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
3359247568Sdes	        ;;
3360247568Sdes	      esac
3361247568Sdes	    }
3362247568Sdes	  else
3363247568Sdes	    $opt_dry_run || {
3364247568Sdes	      eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
3365247568Sdes	      eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
3366247568Sdes	      eval '$MV "$nlist"T "$nlist"'
3367247568Sdes	      case $host in
3368247568Sdes	        *cygwin* | *mingw* | *cegcc* )
3369247568Sdes	          eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
3370247568Sdes	          eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
3371247568Sdes	          ;;
3372247568Sdes	      esac
3373247568Sdes	    }
3374247568Sdes	  fi
3375247568Sdes	fi
3376247568Sdes
3377247568Sdes	for dlprefile in $dlprefiles; do
3378247568Sdes	  func_verbose "extracting global C symbols from \`$dlprefile'"
3379247568Sdes	  func_basename "$dlprefile"
3380247568Sdes	  name="$func_basename_result"
3381247568Sdes          case $host in
3382247568Sdes	    *cygwin* | *mingw* | *cegcc* )
3383247568Sdes	      # if an import library, we need to obtain dlname
3384247568Sdes	      if func_win32_import_lib_p "$dlprefile"; then
3385247568Sdes	        func_tr_sh "$dlprefile"
3386247568Sdes	        eval "curr_lafile=\$libfile_$func_tr_sh_result"
3387247568Sdes	        dlprefile_dlbasename=""
3388247568Sdes	        if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
3389247568Sdes	          # Use subshell, to avoid clobbering current variable values
3390247568Sdes	          dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
3391247568Sdes	          if test -n "$dlprefile_dlname" ; then
3392247568Sdes	            func_basename "$dlprefile_dlname"
3393247568Sdes	            dlprefile_dlbasename="$func_basename_result"
3394247568Sdes	          else
3395247568Sdes	            # no lafile. user explicitly requested -dlpreopen <import library>.
3396247568Sdes	            $sharedlib_from_linklib_cmd "$dlprefile"
3397247568Sdes	            dlprefile_dlbasename=$sharedlib_from_linklib_result
3398247568Sdes	          fi
3399247568Sdes	        fi
3400247568Sdes	        $opt_dry_run || {
3401247568Sdes	          if test -n "$dlprefile_dlbasename" ; then
3402247568Sdes	            eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
3403247568Sdes	          else
3404247568Sdes	            func_warning "Could not compute DLL name from $name"
3405247568Sdes	            eval '$ECHO ": $name " >> "$nlist"'
3406247568Sdes	          fi
3407247568Sdes	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
3408247568Sdes	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe |
3409247568Sdes	            $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'"
3410247568Sdes	        }
3411247568Sdes	      else # not an import lib
3412247568Sdes	        $opt_dry_run || {
3413247568Sdes	          eval '$ECHO ": $name " >> "$nlist"'
3414247568Sdes	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
3415247568Sdes	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
3416247568Sdes	        }
3417247568Sdes	      fi
3418247568Sdes	    ;;
3419247568Sdes	    *)
3420247568Sdes	      $opt_dry_run || {
3421247568Sdes	        eval '$ECHO ": $name " >> "$nlist"'
3422247568Sdes	        func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
3423247568Sdes	        eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
3424247568Sdes	      }
3425247568Sdes	    ;;
3426247568Sdes          esac
3427247568Sdes	done
3428247568Sdes
3429247568Sdes	$opt_dry_run || {
3430247568Sdes	  # Make sure we have at least an empty file.
3431247568Sdes	  test -f "$nlist" || : > "$nlist"
3432247568Sdes
3433247568Sdes	  if test -n "$exclude_expsyms"; then
3434247568Sdes	    $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
3435247568Sdes	    $MV "$nlist"T "$nlist"
3436247568Sdes	  fi
3437247568Sdes
3438247568Sdes	  # Try sorting and uniquifying the output.
3439247568Sdes	  if $GREP -v "^: " < "$nlist" |
3440247568Sdes	      if sort -k 3 </dev/null >/dev/null 2>&1; then
3441247568Sdes		sort -k 3
3442247568Sdes	      else
3443247568Sdes		sort +2
3444247568Sdes	      fi |
3445247568Sdes	      uniq > "$nlist"S; then
3446247568Sdes	    :
3447247568Sdes	  else
3448247568Sdes	    $GREP -v "^: " < "$nlist" > "$nlist"S
3449247568Sdes	  fi
3450247568Sdes
3451247568Sdes	  if test -f "$nlist"S; then
3452247568Sdes	    eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
3453247568Sdes	  else
3454247568Sdes	    echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
3455247568Sdes	  fi
3456247568Sdes
3457247568Sdes	  echo >> "$output_objdir/$my_dlsyms" "\
3458247568Sdes
3459247568Sdes/* The mapping between symbol names and symbols.  */
3460247568Sdestypedef struct {
3461247568Sdes  const char *name;
3462247568Sdes  void *address;
3463247568Sdes} lt_dlsymlist;
3464247568Sdesextern LT_DLSYM_CONST lt_dlsymlist
3465247568Sdeslt_${my_prefix}_LTX_preloaded_symbols[];
3466247568SdesLT_DLSYM_CONST lt_dlsymlist
3467247568Sdeslt_${my_prefix}_LTX_preloaded_symbols[] =
3468247568Sdes{\
3469247568Sdes  { \"$my_originator\", (void *) 0 },"
3470247568Sdes
3471247568Sdes	  case $need_lib_prefix in
3472247568Sdes	  no)
3473247568Sdes	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
3474247568Sdes	    ;;
3475247568Sdes	  *)
3476247568Sdes	    eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
3477247568Sdes	    ;;
3478247568Sdes	  esac
3479247568Sdes	  echo >> "$output_objdir/$my_dlsyms" "\
3480247568Sdes  {0, (void *) 0}
3481247568Sdes};
3482247568Sdes
3483247568Sdes/* This works around a problem in FreeBSD linker */
3484247568Sdes#ifdef FREEBSD_WORKAROUND
3485247568Sdesstatic const void *lt_preloaded_setup() {
3486247568Sdes  return lt_${my_prefix}_LTX_preloaded_symbols;
3487247568Sdes}
3488247568Sdes#endif
3489247568Sdes
3490247568Sdes#ifdef __cplusplus
3491247568Sdes}
3492247568Sdes#endif\
3493247568Sdes"
3494247568Sdes	} # !$opt_dry_run
3495247568Sdes
3496247568Sdes	pic_flag_for_symtable=
3497247568Sdes	case "$compile_command " in
3498247568Sdes	*" -static "*) ;;
3499247568Sdes	*)
3500247568Sdes	  case $host in
3501247568Sdes	  # compiling the symbol table file with pic_flag works around
3502247568Sdes	  # a FreeBSD bug that causes programs to crash when -lm is
3503247568Sdes	  # linked before any other PIC object.  But we must not use
3504247568Sdes	  # pic_flag when linking with -static.  The problem exists in
3505247568Sdes	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
3506247568Sdes	  *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
3507247568Sdes	    pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
3508247568Sdes	  *-*-hpux*)
3509247568Sdes	    pic_flag_for_symtable=" $pic_flag"  ;;
3510247568Sdes	  *)
3511247568Sdes	    if test "X$my_pic_p" != Xno; then
3512247568Sdes	      pic_flag_for_symtable=" $pic_flag"
3513247568Sdes	    fi
3514247568Sdes	    ;;
3515247568Sdes	  esac
3516247568Sdes	  ;;
3517247568Sdes	esac
3518247568Sdes	symtab_cflags=
3519247568Sdes	for arg in $LTCFLAGS; do
3520247568Sdes	  case $arg in
3521247568Sdes	  -pie | -fpie | -fPIE) ;;
3522247568Sdes	  *) func_append symtab_cflags " $arg" ;;
3523247568Sdes	  esac
3524247568Sdes	done
3525247568Sdes
3526247568Sdes	# Now compile the dynamic symbol file.
3527247568Sdes	func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
3528247568Sdes
3529247568Sdes	# Clean up the generated files.
3530247568Sdes	func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"'
3531247568Sdes
3532247568Sdes	# Transform the symbol file into the correct name.
3533247568Sdes	symfileobj="$output_objdir/${my_outputname}S.$objext"
3534247568Sdes	case $host in
3535247568Sdes	*cygwin* | *mingw* | *cegcc* )
3536247568Sdes	  if test -f "$output_objdir/$my_outputname.def"; then
3537247568Sdes	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
3538247568Sdes	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
3539247568Sdes	  else
3540247568Sdes	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3541247568Sdes	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3542247568Sdes	  fi
3543247568Sdes	  ;;
3544247568Sdes	*)
3545247568Sdes	  compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3546247568Sdes	  finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3547247568Sdes	  ;;
3548247568Sdes	esac
3549247568Sdes	;;
3550247568Sdes      *-*-freebsd*)
3551247568Sdes	# FreeBSD doesn't need this...
3552247568Sdes	;;
3553247568Sdes      *)
3554247568Sdes	func_fatal_error "unknown suffix for \`$my_dlsyms'"
3555247568Sdes	;;
3556247568Sdes      esac
3557247568Sdes    else
3558247568Sdes      # We keep going just in case the user didn't refer to
3559247568Sdes      # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
3560247568Sdes      # really was required.
3561247568Sdes
3562247568Sdes      # Nullify the symbol file.
3563247568Sdes      compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
3564247568Sdes      finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
3565247568Sdes    fi
3566247568Sdes}
3567247568Sdes
3568247568Sdes# func_win32_libid arg
3569247568Sdes# return the library type of file 'arg'
3570247568Sdes#
3571247568Sdes# Need a lot of goo to handle *both* DLLs and import libs
3572247568Sdes# Has to be a shell function in order to 'eat' the argument
3573247568Sdes# that is supplied when $file_magic_command is called.
3574247568Sdes# Despite the name, also deal with 64 bit binaries.
3575247568Sdesfunc_win32_libid ()
3576247568Sdes{
3577247568Sdes  $opt_debug
3578247568Sdes  win32_libid_type="unknown"
3579247568Sdes  win32_fileres=`file -L $1 2>/dev/null`
3580247568Sdes  case $win32_fileres in
3581247568Sdes  *ar\ archive\ import\ library*) # definitely import
3582247568Sdes    win32_libid_type="x86 archive import"
3583117610Sdes    ;;
3584247568Sdes  *ar\ archive*) # could be an import, or static
3585247568Sdes    # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
3586247568Sdes    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
3587247568Sdes       $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
3588247568Sdes      func_to_tool_file "$1" func_convert_file_msys_to_w32
3589247568Sdes      win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
3590247568Sdes	$SED -n -e '
3591247568Sdes	    1,100{
3592247568Sdes		/ I /{
3593247568Sdes		    s,.*,import,
3594247568Sdes		    p
3595247568Sdes		    q
3596247568Sdes		}
3597247568Sdes	    }'`
3598247568Sdes      case $win32_nmres in
3599247568Sdes      import*)  win32_libid_type="x86 archive import";;
3600247568Sdes      *)        win32_libid_type="x86 archive static";;
3601247568Sdes      esac
3602247568Sdes    fi
3603247568Sdes    ;;
3604247568Sdes  *DLL*)
3605247568Sdes    win32_libid_type="x86 DLL"
3606247568Sdes    ;;
3607247568Sdes  *executable*) # but shell scripts are "executable" too...
3608247568Sdes    case $win32_fileres in
3609247568Sdes    *MS\ Windows\ PE\ Intel*)
3610247568Sdes      win32_libid_type="x86 DLL"
3611247568Sdes      ;;
3612247568Sdes    esac
3613247568Sdes    ;;
3614247568Sdes  esac
3615247568Sdes  $ECHO "$win32_libid_type"
3616247568Sdes}
3617117610Sdes
3618247568Sdes# func_cygming_dll_for_implib ARG
3619247568Sdes#
3620247568Sdes# Platform-specific function to extract the
3621247568Sdes# name of the DLL associated with the specified
3622247568Sdes# import library ARG.
3623247568Sdes# Invoked by eval'ing the libtool variable
3624247568Sdes#    $sharedlib_from_linklib_cmd
3625247568Sdes# Result is available in the variable
3626247568Sdes#    $sharedlib_from_linklib_result
3627247568Sdesfunc_cygming_dll_for_implib ()
3628247568Sdes{
3629247568Sdes  $opt_debug
3630247568Sdes  sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
3631247568Sdes}
3632247568Sdes
3633247568Sdes# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs
3634247568Sdes#
3635247568Sdes# The is the core of a fallback implementation of a
3636247568Sdes# platform-specific function to extract the name of the
3637247568Sdes# DLL associated with the specified import library LIBNAME.
3638247568Sdes#
3639247568Sdes# SECTION_NAME is either .idata$6 or .idata$7, depending
3640247568Sdes# on the platform and compiler that created the implib.
3641247568Sdes#
3642247568Sdes# Echos the name of the DLL associated with the
3643247568Sdes# specified import library.
3644247568Sdesfunc_cygming_dll_for_implib_fallback_core ()
3645247568Sdes{
3646247568Sdes  $opt_debug
3647247568Sdes  match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
3648247568Sdes  $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
3649247568Sdes    $SED '/^Contents of section '"$match_literal"':/{
3650247568Sdes      # Place marker at beginning of archive member dllname section
3651247568Sdes      s/.*/====MARK====/
3652247568Sdes      p
3653247568Sdes      d
3654247568Sdes    }
3655247568Sdes    # These lines can sometimes be longer than 43 characters, but
3656247568Sdes    # are always uninteresting
3657247568Sdes    /:[	 ]*file format pe[i]\{,1\}-/d
3658247568Sdes    /^In archive [^:]*:/d
3659247568Sdes    # Ensure marker is printed
3660247568Sdes    /^====MARK====/p
3661247568Sdes    # Remove all lines with less than 43 characters
3662247568Sdes    /^.\{43\}/!d
3663247568Sdes    # From remaining lines, remove first 43 characters
3664247568Sdes    s/^.\{43\}//' |
3665247568Sdes    $SED -n '
3666247568Sdes      # Join marker and all lines until next marker into a single line
3667247568Sdes      /^====MARK====/ b para
3668247568Sdes      H
3669247568Sdes      $ b para
3670247568Sdes      b
3671247568Sdes      :para
3672247568Sdes      x
3673247568Sdes      s/\n//g
3674247568Sdes      # Remove the marker
3675247568Sdes      s/^====MARK====//
3676247568Sdes      # Remove trailing dots and whitespace
3677247568Sdes      s/[\. \t]*$//
3678247568Sdes      # Print
3679247568Sdes      /./p' |
3680247568Sdes    # we now have a list, one entry per line, of the stringified
3681247568Sdes    # contents of the appropriate section of all members of the
3682247568Sdes    # archive which possess that section. Heuristic: eliminate
3683247568Sdes    # all those which have a first or second character that is
3684247568Sdes    # a '.' (that is, objdump's representation of an unprintable
3685247568Sdes    # character.) This should work for all archives with less than
3686247568Sdes    # 0x302f exports -- but will fail for DLLs whose name actually
3687247568Sdes    # begins with a literal '.' or a single character followed by
3688247568Sdes    # a '.'.
3689247568Sdes    #
3690247568Sdes    # Of those that remain, print the first one.
3691247568Sdes    $SED -e '/^\./d;/^.\./d;q'
3692247568Sdes}
3693247568Sdes
3694247568Sdes# func_cygming_gnu_implib_p ARG
3695247568Sdes# This predicate returns with zero status (TRUE) if
3696247568Sdes# ARG is a GNU/binutils-style import library. Returns
3697247568Sdes# with nonzero status (FALSE) otherwise.
3698247568Sdesfunc_cygming_gnu_implib_p ()
3699247568Sdes{
3700247568Sdes  $opt_debug
3701247568Sdes  func_to_tool_file "$1" func_convert_file_msys_to_w32
3702247568Sdes  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)$'`
3703247568Sdes  test -n "$func_cygming_gnu_implib_tmp"
3704247568Sdes}
3705247568Sdes
3706247568Sdes# func_cygming_ms_implib_p ARG
3707247568Sdes# This predicate returns with zero status (TRUE) if
3708247568Sdes# ARG is an MS-style import library. Returns
3709247568Sdes# with nonzero status (FALSE) otherwise.
3710247568Sdesfunc_cygming_ms_implib_p ()
3711247568Sdes{
3712247568Sdes  $opt_debug
3713247568Sdes  func_to_tool_file "$1" func_convert_file_msys_to_w32
3714247568Sdes  func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
3715247568Sdes  test -n "$func_cygming_ms_implib_tmp"
3716247568Sdes}
3717247568Sdes
3718247568Sdes# func_cygming_dll_for_implib_fallback ARG
3719247568Sdes# Platform-specific function to extract the
3720247568Sdes# name of the DLL associated with the specified
3721247568Sdes# import library ARG.
3722247568Sdes#
3723247568Sdes# This fallback implementation is for use when $DLLTOOL
3724247568Sdes# does not support the --identify-strict option.
3725247568Sdes# Invoked by eval'ing the libtool variable
3726247568Sdes#    $sharedlib_from_linklib_cmd
3727247568Sdes# Result is available in the variable
3728247568Sdes#    $sharedlib_from_linklib_result
3729247568Sdesfunc_cygming_dll_for_implib_fallback ()
3730247568Sdes{
3731247568Sdes  $opt_debug
3732247568Sdes  if func_cygming_gnu_implib_p "$1" ; then
3733247568Sdes    # binutils import library
3734247568Sdes    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
3735247568Sdes  elif func_cygming_ms_implib_p "$1" ; then
3736247568Sdes    # ms-generated import library
3737247568Sdes    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
3738247568Sdes  else
3739247568Sdes    # unknown
3740247568Sdes    sharedlib_from_linklib_result=""
3741247568Sdes  fi
3742247568Sdes}
3743247568Sdes
3744247568Sdes
3745247568Sdes# func_extract_an_archive dir oldlib
3746247568Sdesfunc_extract_an_archive ()
3747247568Sdes{
3748247568Sdes    $opt_debug
3749247568Sdes    f_ex_an_ar_dir="$1"; shift
3750247568Sdes    f_ex_an_ar_oldlib="$1"
3751247568Sdes    if test "$lock_old_archive_extraction" = yes; then
3752247568Sdes      lockfile=$f_ex_an_ar_oldlib.lock
3753247568Sdes      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
3754247568Sdes	func_echo "Waiting for $lockfile to be removed"
3755247568Sdes	sleep 2
3756247568Sdes      done
3757247568Sdes    fi
3758247568Sdes    func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
3759247568Sdes		   'stat=$?; rm -f "$lockfile"; exit $stat'
3760247568Sdes    if test "$lock_old_archive_extraction" = yes; then
3761247568Sdes      $opt_dry_run || rm -f "$lockfile"
3762247568Sdes    fi
3763247568Sdes    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
3764247568Sdes     :
3765247568Sdes    else
3766247568Sdes      func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
3767247568Sdes    fi
3768247568Sdes}
3769247568Sdes
3770247568Sdes
3771247568Sdes# func_extract_archives gentop oldlib ...
3772247568Sdesfunc_extract_archives ()
3773247568Sdes{
3774247568Sdes    $opt_debug
3775247568Sdes    my_gentop="$1"; shift
3776247568Sdes    my_oldlibs=${1+"$@"}
3777247568Sdes    my_oldobjs=""
3778247568Sdes    my_xlib=""
3779247568Sdes    my_xabs=""
3780247568Sdes    my_xdir=""
3781247568Sdes
3782247568Sdes    for my_xlib in $my_oldlibs; do
3783247568Sdes      # Extract the objects.
3784247568Sdes      case $my_xlib in
3785247568Sdes	[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
3786247568Sdes	*) my_xabs=`pwd`"/$my_xlib" ;;
3787247568Sdes      esac
3788247568Sdes      func_basename "$my_xlib"
3789247568Sdes      my_xlib="$func_basename_result"
3790247568Sdes      my_xlib_u=$my_xlib
3791247568Sdes      while :; do
3792247568Sdes        case " $extracted_archives " in
3793247568Sdes	*" $my_xlib_u "*)
3794247568Sdes	  func_arith $extracted_serial + 1
3795247568Sdes	  extracted_serial=$func_arith_result
3796247568Sdes	  my_xlib_u=lt$extracted_serial-$my_xlib ;;
3797247568Sdes	*) break ;;
3798247568Sdes	esac
3799247568Sdes      done
3800247568Sdes      extracted_archives="$extracted_archives $my_xlib_u"
3801247568Sdes      my_xdir="$my_gentop/$my_xlib_u"
3802247568Sdes
3803247568Sdes      func_mkdir_p "$my_xdir"
3804247568Sdes
3805247568Sdes      case $host in
3806247568Sdes      *-darwin*)
3807247568Sdes	func_verbose "Extracting $my_xabs"
3808247568Sdes	# Do not bother doing anything if just a dry run
3809247568Sdes	$opt_dry_run || {
3810247568Sdes	  darwin_orig_dir=`pwd`
3811247568Sdes	  cd $my_xdir || exit $?
3812247568Sdes	  darwin_archive=$my_xabs
3813247568Sdes	  darwin_curdir=`pwd`
3814247568Sdes	  darwin_base_archive=`basename "$darwin_archive"`
3815247568Sdes	  darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
3816247568Sdes	  if test -n "$darwin_arches"; then
3817247568Sdes	    darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
3818247568Sdes	    darwin_arch=
3819247568Sdes	    func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
3820247568Sdes	    for darwin_arch in  $darwin_arches ; do
3821247568Sdes	      func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
3822247568Sdes	      $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
3823247568Sdes	      cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
3824247568Sdes	      func_extract_an_archive "`pwd`" "${darwin_base_archive}"
3825247568Sdes	      cd "$darwin_curdir"
3826247568Sdes	      $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
3827247568Sdes	    done # $darwin_arches
3828247568Sdes            ## Okay now we've a bunch of thin objects, gotta fatten them up :)
3829247568Sdes	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u`
3830247568Sdes	    darwin_file=
3831247568Sdes	    darwin_files=
3832247568Sdes	    for darwin_file in $darwin_filelist; do
3833247568Sdes	      darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`
3834247568Sdes	      $LIPO -create -output "$darwin_file" $darwin_files
3835247568Sdes	    done # $darwin_filelist
3836247568Sdes	    $RM -rf unfat-$$
3837247568Sdes	    cd "$darwin_orig_dir"
3838247568Sdes	  else
3839247568Sdes	    cd $darwin_orig_dir
3840247568Sdes	    func_extract_an_archive "$my_xdir" "$my_xabs"
3841247568Sdes	  fi # $darwin_arches
3842247568Sdes	} # !$opt_dry_run
3843247568Sdes	;;
3844247568Sdes      *)
3845247568Sdes        func_extract_an_archive "$my_xdir" "$my_xabs"
3846247568Sdes	;;
3847247568Sdes      esac
3848247568Sdes      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
3849247568Sdes    done
3850247568Sdes
3851247568Sdes    func_extract_archives_result="$my_oldobjs"
3852247568Sdes}
3853247568Sdes
3854247568Sdes
3855247568Sdes# func_emit_wrapper [arg=no]
3856247568Sdes#
3857247568Sdes# Emit a libtool wrapper script on stdout.
3858247568Sdes# Don't directly open a file because we may want to
3859247568Sdes# incorporate the script contents within a cygwin/mingw
3860247568Sdes# wrapper executable.  Must ONLY be called from within
3861247568Sdes# func_mode_link because it depends on a number of variables
3862247568Sdes# set therein.
3863247568Sdes#
3864247568Sdes# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
3865247568Sdes# variable will take.  If 'yes', then the emitted script
3866247568Sdes# will assume that the directory in which it is stored is
3867247568Sdes# the $objdir directory.  This is a cygwin/mingw-specific
3868247568Sdes# behavior.
3869247568Sdesfunc_emit_wrapper ()
3870247568Sdes{
3871247568Sdes	func_emit_wrapper_arg1=${1-no}
3872247568Sdes
3873247568Sdes	$ECHO "\
3874247568Sdes#! $SHELL
3875247568Sdes
3876247568Sdes# $output - temporary wrapper script for $objdir/$outputname
3877247568Sdes# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
3878247568Sdes#
3879247568Sdes# The $output program cannot be directly executed until all the libtool
3880247568Sdes# libraries that it depends on are installed.
3881247568Sdes#
3882247568Sdes# This wrapper script should never be moved out of the build directory.
3883247568Sdes# If it is, it will not operate correctly.
3884247568Sdes
3885247568Sdes# Sed substitution that helps us do robust quoting.  It backslashifies
3886247568Sdes# metacharacters that are still active within double-quoted strings.
3887247568Sdessed_quote_subst='$sed_quote_subst'
3888247568Sdes
3889247568Sdes# Be Bourne compatible
3890247568Sdesif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
3891247568Sdes  emulate sh
3892247568Sdes  NULLCMD=:
3893247568Sdes  # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
3894247568Sdes  # is contrary to our usage.  Disable this feature.
3895247568Sdes  alias -g '\${1+\"\$@\"}'='\"\$@\"'
3896247568Sdes  setopt NO_GLOB_SUBST
3897247568Sdeselse
3898247568Sdes  case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
3899247568Sdesfi
3900247568SdesBIN_SH=xpg4; export BIN_SH # for Tru64
3901247568SdesDUALCASE=1; export DUALCASE # for MKS sh
3902247568Sdes
3903247568Sdes# The HP-UX ksh and POSIX shell print the target directory to stdout
3904247568Sdes# if CDPATH is set.
3905247568Sdes(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
3906247568Sdes
3907247568Sdesrelink_command=\"$relink_command\"
3908247568Sdes
3909247568Sdes# This environment variable determines our operation mode.
3910247568Sdesif test \"\$libtool_install_magic\" = \"$magic\"; then
3911247568Sdes  # install mode needs the following variables:
3912247568Sdes  generated_by_libtool_version='$macro_version'
3913247568Sdes  notinst_deplibs='$notinst_deplibs'
3914247568Sdeselse
3915247568Sdes  # When we are sourced in execute mode, \$file and \$ECHO are already set.
3916247568Sdes  if test \"\$libtool_execute_magic\" != \"$magic\"; then
3917247568Sdes    file=\"\$0\""
3918247568Sdes
3919247568Sdes    qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"`
3920247568Sdes    $ECHO "\
3921247568Sdes
3922247568Sdes# A function that is used when there is no print builtin or printf.
3923247568Sdesfunc_fallback_echo ()
3924247568Sdes{
3925247568Sdes  eval 'cat <<_LTECHO_EOF
3926247568Sdes\$1
3927247568Sdes_LTECHO_EOF'
3928247568Sdes}
3929247568Sdes    ECHO=\"$qECHO\"
3930247568Sdes  fi
3931247568Sdes
3932247568Sdes# Very basic option parsing. These options are (a) specific to
3933247568Sdes# the libtool wrapper, (b) are identical between the wrapper
3934247568Sdes# /script/ and the wrapper /executable/ which is used only on
3935247568Sdes# windows platforms, and (c) all begin with the string "--lt-"
3936247568Sdes# (application programs are unlikely to have options which match
3937247568Sdes# this pattern).
3938247568Sdes#
3939247568Sdes# There are only two supported options: --lt-debug and
3940247568Sdes# --lt-dump-script. There is, deliberately, no --lt-help.
3941247568Sdes#
3942247568Sdes# The first argument to this parsing function should be the
3943247568Sdes# script's $0 value, followed by "$@".
3944247568Sdeslt_option_debug=
3945247568Sdesfunc_parse_lt_options ()
3946247568Sdes{
3947247568Sdes  lt_script_arg0=\$0
3948247568Sdes  shift
3949247568Sdes  for lt_opt
3950247568Sdes  do
3951247568Sdes    case \"\$lt_opt\" in
3952247568Sdes    --lt-debug) lt_option_debug=1 ;;
3953247568Sdes    --lt-dump-script)
3954247568Sdes        lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
3955247568Sdes        test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
3956247568Sdes        lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
3957247568Sdes        cat \"\$lt_dump_D/\$lt_dump_F\"
3958247568Sdes        exit 0
3959247568Sdes      ;;
3960247568Sdes    --lt-*)
3961247568Sdes        \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
3962247568Sdes        exit 1
3963247568Sdes      ;;
3964247568Sdes    esac
3965247568Sdes  done
3966247568Sdes
3967247568Sdes  # Print the debug banner immediately:
3968247568Sdes  if test -n \"\$lt_option_debug\"; then
3969247568Sdes    echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2
3970247568Sdes  fi
3971247568Sdes}
3972247568Sdes
3973247568Sdes# Used when --lt-debug. Prints its arguments to stdout
3974247568Sdes# (redirection is the responsibility of the caller)
3975247568Sdesfunc_lt_dump_args ()
3976247568Sdes{
3977247568Sdes  lt_dump_args_N=1;
3978247568Sdes  for lt_arg
3979247568Sdes  do
3980247568Sdes    \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\"
3981247568Sdes    lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
3982247568Sdes  done
3983247568Sdes}
3984247568Sdes
3985247568Sdes# Core function for launching the target application
3986247568Sdesfunc_exec_program_core ()
3987247568Sdes{
3988247568Sdes"
3989247568Sdes  case $host in
3990247568Sdes  # Backslashes separate directories on plain windows
3991247568Sdes  *-*-mingw | *-*-os2* | *-cegcc*)
3992247568Sdes    $ECHO "\
3993247568Sdes      if test -n \"\$lt_option_debug\"; then
3994247568Sdes        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2
3995247568Sdes        func_lt_dump_args \${1+\"\$@\"} 1>&2
3996247568Sdes      fi
3997247568Sdes      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
3998247568Sdes"
3999247568Sdes    ;;
4000247568Sdes
4001247568Sdes  *)
4002247568Sdes    $ECHO "\
4003247568Sdes      if test -n \"\$lt_option_debug\"; then
4004247568Sdes        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2
4005247568Sdes        func_lt_dump_args \${1+\"\$@\"} 1>&2
4006247568Sdes      fi
4007247568Sdes      exec \"\$progdir/\$program\" \${1+\"\$@\"}
4008247568Sdes"
4009247568Sdes    ;;
4010247568Sdes  esac
4011247568Sdes  $ECHO "\
4012247568Sdes      \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
4013247568Sdes      exit 1
4014247568Sdes}
4015247568Sdes
4016247568Sdes# A function to encapsulate launching the target application
4017247568Sdes# Strips options in the --lt-* namespace from \$@ and
4018247568Sdes# launches target application with the remaining arguments.
4019247568Sdesfunc_exec_program ()
4020247568Sdes{
4021247568Sdes  case \" \$* \" in
4022247568Sdes  *\\ --lt-*)
4023247568Sdes    for lt_wr_arg
4024247568Sdes    do
4025247568Sdes      case \$lt_wr_arg in
4026247568Sdes      --lt-*) ;;
4027247568Sdes      *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
4028247568Sdes      esac
4029247568Sdes      shift
4030247568Sdes    done ;;
4031247568Sdes  esac
4032247568Sdes  func_exec_program_core \${1+\"\$@\"}
4033247568Sdes}
4034247568Sdes
4035247568Sdes  # Parse options
4036247568Sdes  func_parse_lt_options \"\$0\" \${1+\"\$@\"}
4037247568Sdes
4038247568Sdes  # Find the directory that this script lives in.
4039247568Sdes  thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
4040247568Sdes  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
4041247568Sdes
4042247568Sdes  # Follow symbolic links until we get to the real thisdir.
4043247568Sdes  file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
4044247568Sdes  while test -n \"\$file\"; do
4045247568Sdes    destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
4046247568Sdes
4047247568Sdes    # If there was a directory component, then change thisdir.
4048247568Sdes    if test \"x\$destdir\" != \"x\$file\"; then
4049247568Sdes      case \"\$destdir\" in
4050247568Sdes      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
4051247568Sdes      *) thisdir=\"\$thisdir/\$destdir\" ;;
4052247568Sdes      esac
4053247568Sdes    fi
4054247568Sdes
4055247568Sdes    file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
4056247568Sdes    file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
4057247568Sdes  done
4058247568Sdes
4059247568Sdes  # Usually 'no', except on cygwin/mingw when embedded into
4060247568Sdes  # the cwrapper.
4061247568Sdes  WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
4062247568Sdes  if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
4063247568Sdes    # special case for '.'
4064247568Sdes    if test \"\$thisdir\" = \".\"; then
4065247568Sdes      thisdir=\`pwd\`
4066247568Sdes    fi
4067247568Sdes    # remove .libs from thisdir
4068247568Sdes    case \"\$thisdir\" in
4069247568Sdes    *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
4070247568Sdes    $objdir )   thisdir=. ;;
4071247568Sdes    esac
4072247568Sdes  fi
4073247568Sdes
4074247568Sdes  # Try to get the absolute directory name.
4075247568Sdes  absdir=\`cd \"\$thisdir\" && pwd\`
4076247568Sdes  test -n \"\$absdir\" && thisdir=\"\$absdir\"
4077247568Sdes"
4078247568Sdes
4079247568Sdes	if test "$fast_install" = yes; then
4080247568Sdes	  $ECHO "\
4081247568Sdes  program=lt-'$outputname'$exeext
4082247568Sdes  progdir=\"\$thisdir/$objdir\"
4083247568Sdes
4084247568Sdes  if test ! -f \"\$progdir/\$program\" ||
4085247568Sdes     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
4086247568Sdes       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
4087247568Sdes
4088247568Sdes    file=\"\$\$-\$program\"
4089247568Sdes
4090247568Sdes    if test ! -d \"\$progdir\"; then
4091247568Sdes      $MKDIR \"\$progdir\"
4092247568Sdes    else
4093247568Sdes      $RM \"\$progdir/\$file\"
4094247568Sdes    fi"
4095247568Sdes
4096247568Sdes	  $ECHO "\
4097247568Sdes
4098247568Sdes    # relink executable if necessary
4099247568Sdes    if test -n \"\$relink_command\"; then
4100247568Sdes      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
4101247568Sdes      else
4102247568Sdes	$ECHO \"\$relink_command_output\" >&2
4103247568Sdes	$RM \"\$progdir/\$file\"
4104247568Sdes	exit 1
4105247568Sdes      fi
4106247568Sdes    fi
4107247568Sdes
4108247568Sdes    $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
4109247568Sdes    { $RM \"\$progdir/\$program\";
4110247568Sdes      $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
4111247568Sdes    $RM \"\$progdir/\$file\"
4112247568Sdes  fi"
4113247568Sdes	else
4114247568Sdes	  $ECHO "\
4115247568Sdes  program='$outputname'
4116247568Sdes  progdir=\"\$thisdir/$objdir\"
4117247568Sdes"
4118247568Sdes	fi
4119247568Sdes
4120247568Sdes	$ECHO "\
4121247568Sdes
4122247568Sdes  if test -f \"\$progdir/\$program\"; then"
4123247568Sdes
4124247568Sdes	# fixup the dll searchpath if we need to.
4125247568Sdes	#
4126247568Sdes	# Fix the DLL searchpath if we need to.  Do this before prepending
4127247568Sdes	# to shlibpath, because on Windows, both are PATH and uninstalled
4128247568Sdes	# libraries must come first.
4129247568Sdes	if test -n "$dllsearchpath"; then
4130247568Sdes	  $ECHO "\
4131247568Sdes    # Add the dll search path components to the executable PATH
4132247568Sdes    PATH=$dllsearchpath:\$PATH
4133247568Sdes"
4134247568Sdes	fi
4135247568Sdes
4136247568Sdes	# Export our shlibpath_var if we have one.
4137247568Sdes	if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
4138247568Sdes	  $ECHO "\
4139247568Sdes    # Add our own library path to $shlibpath_var
4140247568Sdes    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
4141247568Sdes
4142247568Sdes    # Some systems cannot cope with colon-terminated $shlibpath_var
4143247568Sdes    # The second colon is a workaround for a bug in BeOS R4 sed
4144247568Sdes    $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
4145247568Sdes
4146247568Sdes    export $shlibpath_var
4147247568Sdes"
4148247568Sdes	fi
4149247568Sdes
4150247568Sdes	$ECHO "\
4151247568Sdes    if test \"\$libtool_execute_magic\" != \"$magic\"; then
4152247568Sdes      # Run the actual program with our arguments.
4153247568Sdes      func_exec_program \${1+\"\$@\"}
4154247568Sdes    fi
4155247568Sdes  else
4156247568Sdes    # The program doesn't exist.
4157247568Sdes    \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
4158247568Sdes    \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
4159247568Sdes    \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
4160247568Sdes    exit 1
4161247568Sdes  fi
4162247568Sdesfi\
4163247568Sdes"
4164247568Sdes}
4165247568Sdes
4166247568Sdes
4167247568Sdes# func_emit_cwrapperexe_src
4168247568Sdes# emit the source code for a wrapper executable on stdout
4169247568Sdes# Must ONLY be called from within func_mode_link because
4170247568Sdes# it depends on a number of variable set therein.
4171247568Sdesfunc_emit_cwrapperexe_src ()
4172247568Sdes{
4173247568Sdes	cat <<EOF
4174247568Sdes
4175247568Sdes/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
4176247568Sdes   Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
4177247568Sdes
4178247568Sdes   The $output program cannot be directly executed until all the libtool
4179247568Sdes   libraries that it depends on are installed.
4180247568Sdes
4181247568Sdes   This wrapper executable should never be moved out of the build directory.
4182247568Sdes   If it is, it will not operate correctly.
4183247568Sdes*/
4184247568SdesEOF
4185247568Sdes	    cat <<"EOF"
4186247568Sdes#ifdef _MSC_VER
4187247568Sdes# define _CRT_SECURE_NO_DEPRECATE 1
4188247568Sdes#endif
4189247568Sdes#include <stdio.h>
4190247568Sdes#include <stdlib.h>
4191247568Sdes#ifdef _MSC_VER
4192247568Sdes# include <direct.h>
4193247568Sdes# include <process.h>
4194247568Sdes# include <io.h>
4195247568Sdes#else
4196247568Sdes# include <unistd.h>
4197247568Sdes# include <stdint.h>
4198247568Sdes# ifdef __CYGWIN__
4199247568Sdes#  include <io.h>
4200247568Sdes# endif
4201247568Sdes#endif
4202247568Sdes#include <malloc.h>
4203247568Sdes#include <stdarg.h>
4204247568Sdes#include <assert.h>
4205247568Sdes#include <string.h>
4206247568Sdes#include <ctype.h>
4207247568Sdes#include <errno.h>
4208247568Sdes#include <fcntl.h>
4209247568Sdes#include <sys/stat.h>
4210247568Sdes
4211247568Sdes/* declarations of non-ANSI functions */
4212247568Sdes#if defined(__MINGW32__)
4213247568Sdes# ifdef __STRICT_ANSI__
4214247568Sdesint _putenv (const char *);
4215247568Sdes# endif
4216247568Sdes#elif defined(__CYGWIN__)
4217247568Sdes# ifdef __STRICT_ANSI__
4218247568Sdeschar *realpath (const char *, char *);
4219247568Sdesint putenv (char *);
4220247568Sdesint setenv (const char *, const char *, int);
4221247568Sdes# endif
4222247568Sdes/* #elif defined (other platforms) ... */
4223247568Sdes#endif
4224247568Sdes
4225247568Sdes/* portability defines, excluding path handling macros */
4226247568Sdes#if defined(_MSC_VER)
4227247568Sdes# define setmode _setmode
4228247568Sdes# define stat    _stat
4229247568Sdes# define chmod   _chmod
4230247568Sdes# define getcwd  _getcwd
4231247568Sdes# define putenv  _putenv
4232247568Sdes# define S_IXUSR _S_IEXEC
4233247568Sdes# ifndef _INTPTR_T_DEFINED
4234247568Sdes#  define _INTPTR_T_DEFINED
4235247568Sdes#  define intptr_t int
4236247568Sdes# endif
4237247568Sdes#elif defined(__MINGW32__)
4238247568Sdes# define setmode _setmode
4239247568Sdes# define stat    _stat
4240247568Sdes# define chmod   _chmod
4241247568Sdes# define getcwd  _getcwd
4242247568Sdes# define putenv  _putenv
4243247568Sdes#elif defined(__CYGWIN__)
4244247568Sdes# define HAVE_SETENV
4245247568Sdes# define FOPEN_WB "wb"
4246247568Sdes/* #elif defined (other platforms) ... */
4247247568Sdes#endif
4248247568Sdes
4249247568Sdes#if defined(PATH_MAX)
4250247568Sdes# define LT_PATHMAX PATH_MAX
4251247568Sdes#elif defined(MAXPATHLEN)
4252247568Sdes# define LT_PATHMAX MAXPATHLEN
4253247568Sdes#else
4254247568Sdes# define LT_PATHMAX 1024
4255247568Sdes#endif
4256247568Sdes
4257247568Sdes#ifndef S_IXOTH
4258247568Sdes# define S_IXOTH 0
4259247568Sdes#endif
4260247568Sdes#ifndef S_IXGRP
4261247568Sdes# define S_IXGRP 0
4262247568Sdes#endif
4263247568Sdes
4264247568Sdes/* path handling portability macros */
4265247568Sdes#ifndef DIR_SEPARATOR
4266247568Sdes# define DIR_SEPARATOR '/'
4267247568Sdes# define PATH_SEPARATOR ':'
4268247568Sdes#endif
4269247568Sdes
4270247568Sdes#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
4271247568Sdes  defined (__OS2__)
4272247568Sdes# define HAVE_DOS_BASED_FILE_SYSTEM
4273247568Sdes# define FOPEN_WB "wb"
4274247568Sdes# ifndef DIR_SEPARATOR_2
4275247568Sdes#  define DIR_SEPARATOR_2 '\\'
4276247568Sdes# endif
4277247568Sdes# ifndef PATH_SEPARATOR_2
4278247568Sdes#  define PATH_SEPARATOR_2 ';'
4279247568Sdes# endif
4280247568Sdes#endif
4281247568Sdes
4282247568Sdes#ifndef DIR_SEPARATOR_2
4283247568Sdes# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
4284247568Sdes#else /* DIR_SEPARATOR_2 */
4285247568Sdes# define IS_DIR_SEPARATOR(ch) \
4286247568Sdes	(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
4287247568Sdes#endif /* DIR_SEPARATOR_2 */
4288247568Sdes
4289247568Sdes#ifndef PATH_SEPARATOR_2
4290247568Sdes# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
4291247568Sdes#else /* PATH_SEPARATOR_2 */
4292247568Sdes# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
4293247568Sdes#endif /* PATH_SEPARATOR_2 */
4294247568Sdes
4295247568Sdes#ifndef FOPEN_WB
4296247568Sdes# define FOPEN_WB "w"
4297247568Sdes#endif
4298247568Sdes#ifndef _O_BINARY
4299247568Sdes# define _O_BINARY 0
4300247568Sdes#endif
4301247568Sdes
4302247568Sdes#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
4303247568Sdes#define XFREE(stale) do { \
4304247568Sdes  if (stale) { free ((void *) stale); stale = 0; } \
4305247568Sdes} while (0)
4306247568Sdes
4307247568Sdes#if defined(LT_DEBUGWRAPPER)
4308247568Sdesstatic int lt_debug = 1;
4309247568Sdes#else
4310247568Sdesstatic int lt_debug = 0;
4311247568Sdes#endif
4312247568Sdes
4313247568Sdesconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */
4314247568Sdes
4315247568Sdesvoid *xmalloc (size_t num);
4316247568Sdeschar *xstrdup (const char *string);
4317247568Sdesconst char *base_name (const char *name);
4318247568Sdeschar *find_executable (const char *wrapper);
4319247568Sdeschar *chase_symlinks (const char *pathspec);
4320247568Sdesint make_executable (const char *path);
4321247568Sdesint check_executable (const char *path);
4322247568Sdeschar *strendzap (char *str, const char *pat);
4323247568Sdesvoid lt_debugprintf (const char *file, int line, const char *fmt, ...);
4324247568Sdesvoid lt_fatal (const char *file, int line, const char *message, ...);
4325247568Sdesstatic const char *nonnull (const char *s);
4326247568Sdesstatic const char *nonempty (const char *s);
4327247568Sdesvoid lt_setenv (const char *name, const char *value);
4328247568Sdeschar *lt_extend_str (const char *orig_value, const char *add, int to_end);
4329247568Sdesvoid lt_update_exe_path (const char *name, const char *value);
4330247568Sdesvoid lt_update_lib_path (const char *name, const char *value);
4331247568Sdeschar **prepare_spawn (char **argv);
4332247568Sdesvoid lt_dump_script (FILE *f);
4333247568SdesEOF
4334247568Sdes
4335247568Sdes	    cat <<EOF
4336247568Sdesvolatile const char * MAGIC_EXE = "$magic_exe";
4337247568Sdesconst char * LIB_PATH_VARNAME = "$shlibpath_var";
4338247568SdesEOF
4339247568Sdes
4340247568Sdes	    if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
4341247568Sdes              func_to_host_path "$temp_rpath"
4342247568Sdes	      cat <<EOF
4343247568Sdesconst char * LIB_PATH_VALUE   = "$func_to_host_path_result";
4344247568SdesEOF
4345247568Sdes	    else
4346247568Sdes	      cat <<"EOF"
4347247568Sdesconst char * LIB_PATH_VALUE   = "";
4348247568SdesEOF
4349247568Sdes	    fi
4350247568Sdes
4351247568Sdes	    if test -n "$dllsearchpath"; then
4352247568Sdes              func_to_host_path "$dllsearchpath:"
4353247568Sdes	      cat <<EOF
4354247568Sdesconst char * EXE_PATH_VARNAME = "PATH";
4355247568Sdesconst char * EXE_PATH_VALUE   = "$func_to_host_path_result";
4356247568SdesEOF
4357247568Sdes	    else
4358247568Sdes	      cat <<"EOF"
4359247568Sdesconst char * EXE_PATH_VARNAME = "";
4360247568Sdesconst char * EXE_PATH_VALUE   = "";
4361247568SdesEOF
4362247568Sdes	    fi
4363247568Sdes
4364247568Sdes	    if test "$fast_install" = yes; then
4365247568Sdes	      cat <<EOF
4366247568Sdesconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
4367247568SdesEOF
4368247568Sdes	    else
4369247568Sdes	      cat <<EOF
4370247568Sdesconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
4371247568SdesEOF
4372247568Sdes	    fi
4373247568Sdes
4374247568Sdes
4375247568Sdes	    cat <<"EOF"
4376247568Sdes
4377247568Sdes#define LTWRAPPER_OPTION_PREFIX         "--lt-"
4378247568Sdes
4379247568Sdesstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
4380247568Sdesstatic const char *dumpscript_opt       = LTWRAPPER_OPTION_PREFIX "dump-script";
4381247568Sdesstatic const char *debug_opt            = LTWRAPPER_OPTION_PREFIX "debug";
4382247568Sdes
4383247568Sdesint
4384247568Sdesmain (int argc, char *argv[])
4385247568Sdes{
4386247568Sdes  char **newargz;
4387247568Sdes  int  newargc;
4388247568Sdes  char *tmp_pathspec;
4389247568Sdes  char *actual_cwrapper_path;
4390247568Sdes  char *actual_cwrapper_name;
4391247568Sdes  char *target_name;
4392247568Sdes  char *lt_argv_zero;
4393247568Sdes  intptr_t rval = 127;
4394247568Sdes
4395247568Sdes  int i;
4396247568Sdes
4397247568Sdes  program_name = (char *) xstrdup (base_name (argv[0]));
4398247568Sdes  newargz = XMALLOC (char *, argc + 1);
4399247568Sdes
4400247568Sdes  /* very simple arg parsing; don't want to rely on getopt
4401247568Sdes   * also, copy all non cwrapper options to newargz, except
4402247568Sdes   * argz[0], which is handled differently
4403247568Sdes   */
4404247568Sdes  newargc=0;
4405247568Sdes  for (i = 1; i < argc; i++)
4406247568Sdes    {
4407247568Sdes      if (strcmp (argv[i], dumpscript_opt) == 0)
4408247568Sdes	{
4409247568SdesEOF
4410247568Sdes	    case "$host" in
4411247568Sdes	      *mingw* | *cygwin* )
4412247568Sdes		# make stdout use "unix" line endings
4413247568Sdes		echo "          setmode(1,_O_BINARY);"
4414247568Sdes		;;
4415247568Sdes	      esac
4416247568Sdes
4417247568Sdes	    cat <<"EOF"
4418247568Sdes	  lt_dump_script (stdout);
4419247568Sdes	  return 0;
4420247568Sdes	}
4421247568Sdes      if (strcmp (argv[i], debug_opt) == 0)
4422247568Sdes	{
4423247568Sdes          lt_debug = 1;
4424247568Sdes          continue;
4425247568Sdes	}
4426247568Sdes      if (strcmp (argv[i], ltwrapper_option_prefix) == 0)
4427247568Sdes        {
4428247568Sdes          /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
4429247568Sdes             namespace, but it is not one of the ones we know about and
4430247568Sdes             have already dealt with, above (inluding dump-script), then
4431247568Sdes             report an error. Otherwise, targets might begin to believe
4432247568Sdes             they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
4433247568Sdes             namespace. The first time any user complains about this, we'll
4434247568Sdes             need to make LTWRAPPER_OPTION_PREFIX a configure-time option
4435247568Sdes             or a configure.ac-settable value.
4436247568Sdes           */
4437247568Sdes          lt_fatal (__FILE__, __LINE__,
4438247568Sdes		    "unrecognized %s option: '%s'",
4439247568Sdes                    ltwrapper_option_prefix, argv[i]);
4440247568Sdes        }
4441247568Sdes      /* otherwise ... */
4442247568Sdes      newargz[++newargc] = xstrdup (argv[i]);
4443247568Sdes    }
4444247568Sdes  newargz[++newargc] = NULL;
4445247568Sdes
4446247568SdesEOF
4447247568Sdes	    cat <<EOF
4448247568Sdes  /* The GNU banner must be the first non-error debug message */
4449247568Sdes  lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\n");
4450247568SdesEOF
4451247568Sdes	    cat <<"EOF"
4452247568Sdes  lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
4453247568Sdes  lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name);
4454247568Sdes
4455247568Sdes  tmp_pathspec = find_executable (argv[0]);
4456247568Sdes  if (tmp_pathspec == NULL)
4457247568Sdes    lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]);
4458247568Sdes  lt_debugprintf (__FILE__, __LINE__,
4459247568Sdes                  "(main) found exe (before symlink chase) at: %s\n",
4460247568Sdes		  tmp_pathspec);
4461247568Sdes
4462247568Sdes  actual_cwrapper_path = chase_symlinks (tmp_pathspec);
4463247568Sdes  lt_debugprintf (__FILE__, __LINE__,
4464247568Sdes                  "(main) found exe (after symlink chase) at: %s\n",
4465247568Sdes		  actual_cwrapper_path);
4466247568Sdes  XFREE (tmp_pathspec);
4467247568Sdes
4468247568Sdes  actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));
4469247568Sdes  strendzap (actual_cwrapper_path, actual_cwrapper_name);
4470247568Sdes
4471247568Sdes  /* wrapper name transforms */
4472247568Sdes  strendzap (actual_cwrapper_name, ".exe");
4473247568Sdes  tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
4474247568Sdes  XFREE (actual_cwrapper_name);
4475247568Sdes  actual_cwrapper_name = tmp_pathspec;
4476247568Sdes  tmp_pathspec = 0;
4477247568Sdes
4478247568Sdes  /* target_name transforms -- use actual target program name; might have lt- prefix */
4479247568Sdes  target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
4480247568Sdes  strendzap (target_name, ".exe");
4481247568Sdes  tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
4482247568Sdes  XFREE (target_name);
4483247568Sdes  target_name = tmp_pathspec;
4484247568Sdes  tmp_pathspec = 0;
4485247568Sdes
4486247568Sdes  lt_debugprintf (__FILE__, __LINE__,
4487247568Sdes		  "(main) libtool target name: %s\n",
4488247568Sdes		  target_name);
4489247568SdesEOF
4490247568Sdes
4491247568Sdes	    cat <<EOF
4492247568Sdes  newargz[0] =
4493247568Sdes    XMALLOC (char, (strlen (actual_cwrapper_path) +
4494247568Sdes		    strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
4495247568Sdes  strcpy (newargz[0], actual_cwrapper_path);
4496247568Sdes  strcat (newargz[0], "$objdir");
4497247568Sdes  strcat (newargz[0], "/");
4498247568SdesEOF
4499247568Sdes
4500247568Sdes	    cat <<"EOF"
4501247568Sdes  /* stop here, and copy so we don't have to do this twice */
4502247568Sdes  tmp_pathspec = xstrdup (newargz[0]);
4503247568Sdes
4504247568Sdes  /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
4505247568Sdes  strcat (newargz[0], actual_cwrapper_name);
4506247568Sdes
4507247568Sdes  /* DO want the lt- prefix here if it exists, so use target_name */
4508247568Sdes  lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
4509247568Sdes  XFREE (tmp_pathspec);
4510247568Sdes  tmp_pathspec = NULL;
4511247568SdesEOF
4512247568Sdes
4513247568Sdes	    case $host_os in
4514247568Sdes	      mingw*)
4515247568Sdes	    cat <<"EOF"
4516247568Sdes  {
4517247568Sdes    char* p;
4518247568Sdes    while ((p = strchr (newargz[0], '\\')) != NULL)
4519247568Sdes      {
4520247568Sdes	*p = '/';
4521247568Sdes      }
4522247568Sdes    while ((p = strchr (lt_argv_zero, '\\')) != NULL)
4523247568Sdes      {
4524247568Sdes	*p = '/';
4525247568Sdes      }
4526247568Sdes  }
4527247568SdesEOF
4528247568Sdes	    ;;
4529247568Sdes	    esac
4530247568Sdes
4531247568Sdes	    cat <<"EOF"
4532247568Sdes  XFREE (target_name);
4533247568Sdes  XFREE (actual_cwrapper_path);
4534247568Sdes  XFREE (actual_cwrapper_name);
4535247568Sdes
4536247568Sdes  lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
4537247568Sdes  lt_setenv ("DUALCASE", "1");  /* for MSK sh */
4538247568Sdes  /* Update the DLL searchpath.  EXE_PATH_VALUE ($dllsearchpath) must
4539247568Sdes     be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath)
4540247568Sdes     because on Windows, both *_VARNAMEs are PATH but uninstalled
4541247568Sdes     libraries must come first. */
4542247568Sdes  lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
4543247568Sdes  lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
4544247568Sdes
4545247568Sdes  lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",
4546247568Sdes		  nonnull (lt_argv_zero));
4547247568Sdes  for (i = 0; i < newargc; i++)
4548247568Sdes    {
4549247568Sdes      lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n",
4550247568Sdes		      i, nonnull (newargz[i]));
4551247568Sdes    }
4552247568Sdes
4553247568SdesEOF
4554247568Sdes
4555247568Sdes	    case $host_os in
4556247568Sdes	      mingw*)
4557247568Sdes		cat <<"EOF"
4558247568Sdes  /* execv doesn't actually work on mingw as expected on unix */
4559247568Sdes  newargz = prepare_spawn (newargz);
4560247568Sdes  rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
4561247568Sdes  if (rval == -1)
4562247568Sdes    {
4563247568Sdes      /* failed to start process */
4564247568Sdes      lt_debugprintf (__FILE__, __LINE__,
4565247568Sdes		      "(main) failed to launch target \"%s\": %s\n",
4566247568Sdes		      lt_argv_zero, nonnull (strerror (errno)));
4567247568Sdes      return 127;
4568247568Sdes    }
4569247568Sdes  return rval;
4570247568SdesEOF
4571247568Sdes		;;
4572247568Sdes	      *)
4573247568Sdes		cat <<"EOF"
4574247568Sdes  execv (lt_argv_zero, newargz);
4575247568Sdes  return rval; /* =127, but avoids unused variable warning */
4576247568SdesEOF
4577247568Sdes		;;
4578247568Sdes	    esac
4579247568Sdes
4580247568Sdes	    cat <<"EOF"
4581247568Sdes}
4582247568Sdes
4583247568Sdesvoid *
4584247568Sdesxmalloc (size_t num)
4585247568Sdes{
4586247568Sdes  void *p = (void *) malloc (num);
4587247568Sdes  if (!p)
4588247568Sdes    lt_fatal (__FILE__, __LINE__, "memory exhausted");
4589247568Sdes
4590247568Sdes  return p;
4591247568Sdes}
4592247568Sdes
4593247568Sdeschar *
4594247568Sdesxstrdup (const char *string)
4595247568Sdes{
4596247568Sdes  return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
4597247568Sdes			  string) : NULL;
4598247568Sdes}
4599247568Sdes
4600247568Sdesconst char *
4601247568Sdesbase_name (const char *name)
4602247568Sdes{
4603247568Sdes  const char *base;
4604247568Sdes
4605247568Sdes#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4606247568Sdes  /* Skip over the disk name in MSDOS pathnames. */
4607247568Sdes  if (isalpha ((unsigned char) name[0]) && name[1] == ':')
4608247568Sdes    name += 2;
4609247568Sdes#endif
4610247568Sdes
4611247568Sdes  for (base = name; *name; name++)
4612247568Sdes    if (IS_DIR_SEPARATOR (*name))
4613247568Sdes      base = name + 1;
4614247568Sdes  return base;
4615247568Sdes}
4616247568Sdes
4617247568Sdesint
4618247568Sdescheck_executable (const char *path)
4619247568Sdes{
4620247568Sdes  struct stat st;
4621247568Sdes
4622247568Sdes  lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n",
4623247568Sdes                  nonempty (path));
4624247568Sdes  if ((!path) || (!*path))
4625247568Sdes    return 0;
4626247568Sdes
4627247568Sdes  if ((stat (path, &st) >= 0)
4628247568Sdes      && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
4629247568Sdes    return 1;
4630247568Sdes  else
4631247568Sdes    return 0;
4632247568Sdes}
4633247568Sdes
4634247568Sdesint
4635247568Sdesmake_executable (const char *path)
4636247568Sdes{
4637247568Sdes  int rval = 0;
4638247568Sdes  struct stat st;
4639247568Sdes
4640247568Sdes  lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n",
4641247568Sdes                  nonempty (path));
4642247568Sdes  if ((!path) || (!*path))
4643247568Sdes    return 0;
4644247568Sdes
4645247568Sdes  if (stat (path, &st) >= 0)
4646247568Sdes    {
4647247568Sdes      rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
4648247568Sdes    }
4649247568Sdes  return rval;
4650247568Sdes}
4651247568Sdes
4652247568Sdes/* Searches for the full path of the wrapper.  Returns
4653247568Sdes   newly allocated full path name if found, NULL otherwise
4654247568Sdes   Does not chase symlinks, even on platforms that support them.
4655247568Sdes*/
4656247568Sdeschar *
4657247568Sdesfind_executable (const char *wrapper)
4658247568Sdes{
4659247568Sdes  int has_slash = 0;
4660247568Sdes  const char *p;
4661247568Sdes  const char *p_next;
4662247568Sdes  /* static buffer for getcwd */
4663247568Sdes  char tmp[LT_PATHMAX + 1];
4664247568Sdes  int tmp_len;
4665247568Sdes  char *concat_name;
4666247568Sdes
4667247568Sdes  lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
4668247568Sdes                  nonempty (wrapper));
4669247568Sdes
4670247568Sdes  if ((wrapper == NULL) || (*wrapper == '\0'))
4671247568Sdes    return NULL;
4672247568Sdes
4673247568Sdes  /* Absolute path? */
4674247568Sdes#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4675247568Sdes  if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
4676247568Sdes    {
4677247568Sdes      concat_name = xstrdup (wrapper);
4678247568Sdes      if (check_executable (concat_name))
4679247568Sdes	return concat_name;
4680247568Sdes      XFREE (concat_name);
4681247568Sdes    }
4682247568Sdes  else
4683247568Sdes    {
4684247568Sdes#endif
4685247568Sdes      if (IS_DIR_SEPARATOR (wrapper[0]))
4686247568Sdes	{
4687247568Sdes	  concat_name = xstrdup (wrapper);
4688247568Sdes	  if (check_executable (concat_name))
4689247568Sdes	    return concat_name;
4690247568Sdes	  XFREE (concat_name);
4691247568Sdes	}
4692247568Sdes#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4693247568Sdes    }
4694247568Sdes#endif
4695247568Sdes
4696247568Sdes  for (p = wrapper; *p; p++)
4697247568Sdes    if (*p == '/')
4698247568Sdes      {
4699247568Sdes	has_slash = 1;
4700247568Sdes	break;
4701247568Sdes      }
4702247568Sdes  if (!has_slash)
4703247568Sdes    {
4704247568Sdes      /* no slashes; search PATH */
4705247568Sdes      const char *path = getenv ("PATH");
4706247568Sdes      if (path != NULL)
4707247568Sdes	{
4708247568Sdes	  for (p = path; *p; p = p_next)
4709247568Sdes	    {
4710247568Sdes	      const char *q;
4711247568Sdes	      size_t p_len;
4712247568Sdes	      for (q = p; *q; q++)
4713247568Sdes		if (IS_PATH_SEPARATOR (*q))
4714247568Sdes		  break;
4715247568Sdes	      p_len = q - p;
4716247568Sdes	      p_next = (*q == '\0' ? q : q + 1);
4717247568Sdes	      if (p_len == 0)
4718247568Sdes		{
4719247568Sdes		  /* empty path: current directory */
4720247568Sdes		  if (getcwd (tmp, LT_PATHMAX) == NULL)
4721247568Sdes		    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
4722247568Sdes                              nonnull (strerror (errno)));
4723247568Sdes		  tmp_len = strlen (tmp);
4724247568Sdes		  concat_name =
4725247568Sdes		    XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
4726247568Sdes		  memcpy (concat_name, tmp, tmp_len);
4727247568Sdes		  concat_name[tmp_len] = '/';
4728247568Sdes		  strcpy (concat_name + tmp_len + 1, wrapper);
4729247568Sdes		}
4730247568Sdes	      else
4731247568Sdes		{
4732247568Sdes		  concat_name =
4733247568Sdes		    XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
4734247568Sdes		  memcpy (concat_name, p, p_len);
4735247568Sdes		  concat_name[p_len] = '/';
4736247568Sdes		  strcpy (concat_name + p_len + 1, wrapper);
4737247568Sdes		}
4738247568Sdes	      if (check_executable (concat_name))
4739247568Sdes		return concat_name;
4740247568Sdes	      XFREE (concat_name);
4741247568Sdes	    }
4742247568Sdes	}
4743247568Sdes      /* not found in PATH; assume curdir */
4744247568Sdes    }
4745247568Sdes  /* Relative path | not found in path: prepend cwd */
4746247568Sdes  if (getcwd (tmp, LT_PATHMAX) == NULL)
4747247568Sdes    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
4748247568Sdes              nonnull (strerror (errno)));
4749247568Sdes  tmp_len = strlen (tmp);
4750247568Sdes  concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
4751247568Sdes  memcpy (concat_name, tmp, tmp_len);
4752247568Sdes  concat_name[tmp_len] = '/';
4753247568Sdes  strcpy (concat_name + tmp_len + 1, wrapper);
4754247568Sdes
4755247568Sdes  if (check_executable (concat_name))
4756247568Sdes    return concat_name;
4757247568Sdes  XFREE (concat_name);
4758247568Sdes  return NULL;
4759247568Sdes}
4760247568Sdes
4761247568Sdeschar *
4762247568Sdeschase_symlinks (const char *pathspec)
4763247568Sdes{
4764247568Sdes#ifndef S_ISLNK
4765247568Sdes  return xstrdup (pathspec);
4766247568Sdes#else
4767247568Sdes  char buf[LT_PATHMAX];
4768247568Sdes  struct stat s;
4769247568Sdes  char *tmp_pathspec = xstrdup (pathspec);
4770247568Sdes  char *p;
4771247568Sdes  int has_symlinks = 0;
4772247568Sdes  while (strlen (tmp_pathspec) && !has_symlinks)
4773247568Sdes    {
4774247568Sdes      lt_debugprintf (__FILE__, __LINE__,
4775247568Sdes		      "checking path component for symlinks: %s\n",
4776247568Sdes		      tmp_pathspec);
4777247568Sdes      if (lstat (tmp_pathspec, &s) == 0)
4778247568Sdes	{
4779247568Sdes	  if (S_ISLNK (s.st_mode) != 0)
4780247568Sdes	    {
4781247568Sdes	      has_symlinks = 1;
4782247568Sdes	      break;
4783247568Sdes	    }
4784247568Sdes
4785247568Sdes	  /* search backwards for last DIR_SEPARATOR */
4786247568Sdes	  p = tmp_pathspec + strlen (tmp_pathspec) - 1;
4787247568Sdes	  while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
4788247568Sdes	    p--;
4789247568Sdes	  if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
4790247568Sdes	    {
4791247568Sdes	      /* no more DIR_SEPARATORS left */
4792247568Sdes	      break;
4793247568Sdes	    }
4794247568Sdes	  *p = '\0';
4795247568Sdes	}
4796247568Sdes      else
4797247568Sdes	{
4798247568Sdes	  lt_fatal (__FILE__, __LINE__,
4799247568Sdes		    "error accessing file \"%s\": %s",
4800247568Sdes		    tmp_pathspec, nonnull (strerror (errno)));
4801247568Sdes	}
4802247568Sdes    }
4803247568Sdes  XFREE (tmp_pathspec);
4804247568Sdes
4805247568Sdes  if (!has_symlinks)
4806247568Sdes    {
4807247568Sdes      return xstrdup (pathspec);
4808247568Sdes    }
4809247568Sdes
4810247568Sdes  tmp_pathspec = realpath (pathspec, buf);
4811247568Sdes  if (tmp_pathspec == 0)
4812247568Sdes    {
4813247568Sdes      lt_fatal (__FILE__, __LINE__,
4814247568Sdes		"could not follow symlinks for %s", pathspec);
4815247568Sdes    }
4816247568Sdes  return xstrdup (tmp_pathspec);
4817247568Sdes#endif
4818247568Sdes}
4819247568Sdes
4820247568Sdeschar *
4821247568Sdesstrendzap (char *str, const char *pat)
4822247568Sdes{
4823247568Sdes  size_t len, patlen;
4824247568Sdes
4825247568Sdes  assert (str != NULL);
4826247568Sdes  assert (pat != NULL);
4827247568Sdes
4828247568Sdes  len = strlen (str);
4829247568Sdes  patlen = strlen (pat);
4830247568Sdes
4831247568Sdes  if (patlen <= len)
4832247568Sdes    {
4833247568Sdes      str += len - patlen;
4834247568Sdes      if (strcmp (str, pat) == 0)
4835247568Sdes	*str = '\0';
4836247568Sdes    }
4837247568Sdes  return str;
4838247568Sdes}
4839247568Sdes
4840247568Sdesvoid
4841247568Sdeslt_debugprintf (const char *file, int line, const char *fmt, ...)
4842247568Sdes{
4843247568Sdes  va_list args;
4844247568Sdes  if (lt_debug)
4845247568Sdes    {
4846247568Sdes      (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line);
4847247568Sdes      va_start (args, fmt);
4848247568Sdes      (void) vfprintf (stderr, fmt, args);
4849247568Sdes      va_end (args);
4850247568Sdes    }
4851247568Sdes}
4852247568Sdes
4853247568Sdesstatic void
4854247568Sdeslt_error_core (int exit_status, const char *file,
4855247568Sdes	       int line, const char *mode,
4856247568Sdes	       const char *message, va_list ap)
4857247568Sdes{
4858247568Sdes  fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode);
4859247568Sdes  vfprintf (stderr, message, ap);
4860247568Sdes  fprintf (stderr, ".\n");
4861247568Sdes
4862247568Sdes  if (exit_status >= 0)
4863247568Sdes    exit (exit_status);
4864247568Sdes}
4865247568Sdes
4866247568Sdesvoid
4867247568Sdeslt_fatal (const char *file, int line, const char *message, ...)
4868247568Sdes{
4869247568Sdes  va_list ap;
4870247568Sdes  va_start (ap, message);
4871247568Sdes  lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap);
4872247568Sdes  va_end (ap);
4873247568Sdes}
4874247568Sdes
4875247568Sdesstatic const char *
4876247568Sdesnonnull (const char *s)
4877247568Sdes{
4878247568Sdes  return s ? s : "(null)";
4879247568Sdes}
4880247568Sdes
4881247568Sdesstatic const char *
4882247568Sdesnonempty (const char *s)
4883247568Sdes{
4884247568Sdes  return (s && !*s) ? "(empty)" : nonnull (s);
4885247568Sdes}
4886247568Sdes
4887247568Sdesvoid
4888247568Sdeslt_setenv (const char *name, const char *value)
4889247568Sdes{
4890247568Sdes  lt_debugprintf (__FILE__, __LINE__,
4891247568Sdes		  "(lt_setenv) setting '%s' to '%s'\n",
4892247568Sdes                  nonnull (name), nonnull (value));
4893247568Sdes  {
4894247568Sdes#ifdef HAVE_SETENV
4895247568Sdes    /* always make a copy, for consistency with !HAVE_SETENV */
4896247568Sdes    char *str = xstrdup (value);
4897247568Sdes    setenv (name, str, 1);
4898247568Sdes#else
4899247568Sdes    int len = strlen (name) + 1 + strlen (value) + 1;
4900247568Sdes    char *str = XMALLOC (char, len);
4901247568Sdes    sprintf (str, "%s=%s", name, value);
4902247568Sdes    if (putenv (str) != EXIT_SUCCESS)
4903247568Sdes      {
4904247568Sdes        XFREE (str);
4905247568Sdes      }
4906247568Sdes#endif
4907247568Sdes  }
4908247568Sdes}
4909247568Sdes
4910247568Sdeschar *
4911247568Sdeslt_extend_str (const char *orig_value, const char *add, int to_end)
4912247568Sdes{
4913247568Sdes  char *new_value;
4914247568Sdes  if (orig_value && *orig_value)
4915247568Sdes    {
4916247568Sdes      int orig_value_len = strlen (orig_value);
4917247568Sdes      int add_len = strlen (add);
4918247568Sdes      new_value = XMALLOC (char, add_len + orig_value_len + 1);
4919247568Sdes      if (to_end)
4920247568Sdes        {
4921247568Sdes          strcpy (new_value, orig_value);
4922247568Sdes          strcpy (new_value + orig_value_len, add);
4923247568Sdes        }
4924247568Sdes      else
4925247568Sdes        {
4926247568Sdes          strcpy (new_value, add);
4927247568Sdes          strcpy (new_value + add_len, orig_value);
4928247568Sdes        }
4929247568Sdes    }
4930247568Sdes  else
4931247568Sdes    {
4932247568Sdes      new_value = xstrdup (add);
4933247568Sdes    }
4934247568Sdes  return new_value;
4935247568Sdes}
4936247568Sdes
4937247568Sdesvoid
4938247568Sdeslt_update_exe_path (const char *name, const char *value)
4939247568Sdes{
4940247568Sdes  lt_debugprintf (__FILE__, __LINE__,
4941247568Sdes		  "(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
4942247568Sdes                  nonnull (name), nonnull (value));
4943247568Sdes
4944247568Sdes  if (name && *name && value && *value)
4945247568Sdes    {
4946247568Sdes      char *new_value = lt_extend_str (getenv (name), value, 0);
4947247568Sdes      /* some systems can't cope with a ':'-terminated path #' */
4948247568Sdes      int len = strlen (new_value);
4949247568Sdes      while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
4950247568Sdes        {
4951247568Sdes          new_value[len-1] = '\0';
4952247568Sdes        }
4953247568Sdes      lt_setenv (name, new_value);
4954247568Sdes      XFREE (new_value);
4955247568Sdes    }
4956247568Sdes}
4957247568Sdes
4958247568Sdesvoid
4959247568Sdeslt_update_lib_path (const char *name, const char *value)
4960247568Sdes{
4961247568Sdes  lt_debugprintf (__FILE__, __LINE__,
4962247568Sdes		  "(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
4963247568Sdes                  nonnull (name), nonnull (value));
4964247568Sdes
4965247568Sdes  if (name && *name && value && *value)
4966247568Sdes    {
4967247568Sdes      char *new_value = lt_extend_str (getenv (name), value, 0);
4968247568Sdes      lt_setenv (name, new_value);
4969247568Sdes      XFREE (new_value);
4970247568Sdes    }
4971247568Sdes}
4972247568Sdes
4973247568SdesEOF
4974247568Sdes	    case $host_os in
4975247568Sdes	      mingw*)
4976247568Sdes		cat <<"EOF"
4977247568Sdes
4978247568Sdes/* Prepares an argument vector before calling spawn().
4979247568Sdes   Note that spawn() does not by itself call the command interpreter
4980247568Sdes     (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
4981247568Sdes      ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
4982247568Sdes         GetVersionEx(&v);
4983247568Sdes         v.dwPlatformId == VER_PLATFORM_WIN32_NT;
4984247568Sdes      }) ? "cmd.exe" : "command.com").
4985247568Sdes   Instead it simply concatenates the arguments, separated by ' ', and calls
4986247568Sdes   CreateProcess().  We must quote the arguments since Win32 CreateProcess()
4987247568Sdes   interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
4988247568Sdes   special way:
4989247568Sdes   - Space and tab are interpreted as delimiters. They are not treated as
4990247568Sdes     delimiters if they are surrounded by double quotes: "...".
4991247568Sdes   - Unescaped double quotes are removed from the input. Their only effect is
4992247568Sdes     that within double quotes, space and tab are treated like normal
4993247568Sdes     characters.
4994247568Sdes   - Backslashes not followed by double quotes are not special.
4995247568Sdes   - But 2*n+1 backslashes followed by a double quote become
4996247568Sdes     n backslashes followed by a double quote (n >= 0):
4997247568Sdes       \" -> "
4998247568Sdes       \\\" -> \"
4999247568Sdes       \\\\\" -> \\"
5000247568Sdes */
5001247568Sdes#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"
5002247568Sdes#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"
5003247568Sdeschar **
5004247568Sdesprepare_spawn (char **argv)
5005247568Sdes{
5006247568Sdes  size_t argc;
5007247568Sdes  char **new_argv;
5008247568Sdes  size_t i;
5009247568Sdes
5010247568Sdes  /* Count number of arguments.  */
5011247568Sdes  for (argc = 0; argv[argc] != NULL; argc++)
5012247568Sdes    ;
5013247568Sdes
5014247568Sdes  /* Allocate new argument vector.  */
5015247568Sdes  new_argv = XMALLOC (char *, argc + 1);
5016247568Sdes
5017247568Sdes  /* Put quoted arguments into the new argument vector.  */
5018247568Sdes  for (i = 0; i < argc; i++)
5019247568Sdes    {
5020247568Sdes      const char *string = argv[i];
5021247568Sdes
5022247568Sdes      if (string[0] == '\0')
5023247568Sdes	new_argv[i] = xstrdup ("\"\"");
5024247568Sdes      else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
5025247568Sdes	{
5026247568Sdes	  int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
5027247568Sdes	  size_t length;
5028247568Sdes	  unsigned int backslashes;
5029247568Sdes	  const char *s;
5030247568Sdes	  char *quoted_string;
5031247568Sdes	  char *p;
5032247568Sdes
5033247568Sdes	  length = 0;
5034247568Sdes	  backslashes = 0;
5035247568Sdes	  if (quote_around)
5036247568Sdes	    length++;
5037247568Sdes	  for (s = string; *s != '\0'; s++)
5038247568Sdes	    {
5039247568Sdes	      char c = *s;
5040247568Sdes	      if (c == '"')
5041247568Sdes		length += backslashes + 1;
5042247568Sdes	      length++;
5043247568Sdes	      if (c == '\\')
5044247568Sdes		backslashes++;
5045247568Sdes	      else
5046247568Sdes		backslashes = 0;
5047247568Sdes	    }
5048247568Sdes	  if (quote_around)
5049247568Sdes	    length += backslashes + 1;
5050247568Sdes
5051247568Sdes	  quoted_string = XMALLOC (char, length + 1);
5052247568Sdes
5053247568Sdes	  p = quoted_string;
5054247568Sdes	  backslashes = 0;
5055247568Sdes	  if (quote_around)
5056247568Sdes	    *p++ = '"';
5057247568Sdes	  for (s = string; *s != '\0'; s++)
5058247568Sdes	    {
5059247568Sdes	      char c = *s;
5060247568Sdes	      if (c == '"')
5061247568Sdes		{
5062247568Sdes		  unsigned int j;
5063247568Sdes		  for (j = backslashes + 1; j > 0; j--)
5064247568Sdes		    *p++ = '\\';
5065247568Sdes		}
5066247568Sdes	      *p++ = c;
5067247568Sdes	      if (c == '\\')
5068247568Sdes		backslashes++;
5069247568Sdes	      else
5070247568Sdes		backslashes = 0;
5071247568Sdes	    }
5072247568Sdes	  if (quote_around)
5073247568Sdes	    {
5074247568Sdes	      unsigned int j;
5075247568Sdes	      for (j = backslashes; j > 0; j--)
5076247568Sdes		*p++ = '\\';
5077247568Sdes	      *p++ = '"';
5078247568Sdes	    }
5079247568Sdes	  *p = '\0';
5080247568Sdes
5081247568Sdes	  new_argv[i] = quoted_string;
5082247568Sdes	}
5083247568Sdes      else
5084247568Sdes	new_argv[i] = (char *) string;
5085247568Sdes    }
5086247568Sdes  new_argv[argc] = NULL;
5087247568Sdes
5088247568Sdes  return new_argv;
5089247568Sdes}
5090247568SdesEOF
5091247568Sdes		;;
5092247568Sdes	    esac
5093247568Sdes
5094247568Sdes            cat <<"EOF"
5095247568Sdesvoid lt_dump_script (FILE* f)
5096247568Sdes{
5097247568SdesEOF
5098247568Sdes	    func_emit_wrapper yes |
5099247568Sdes	      $SED -n -e '
5100247568Sdess/^\(.\{79\}\)\(..*\)/\1\
5101247568Sdes\2/
5102247568Sdesh
5103247568Sdess/\([\\"]\)/\\\1/g
5104247568Sdess/$/\\n/
5105247568Sdess/\([^\n]*\).*/  fputs ("\1", f);/p
5106247568Sdesg
5107247568SdesD'
5108247568Sdes            cat <<"EOF"
5109247568Sdes}
5110247568SdesEOF
5111247568Sdes}
5112247568Sdes# end: func_emit_cwrapperexe_src
5113247568Sdes
5114247568Sdes# func_win32_import_lib_p ARG
5115247568Sdes# True if ARG is an import lib, as indicated by $file_magic_cmd
5116247568Sdesfunc_win32_import_lib_p ()
5117247568Sdes{
5118247568Sdes    $opt_debug
5119247568Sdes    case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
5120247568Sdes    *import*) : ;;
5121247568Sdes    *) false ;;
5122247568Sdes    esac
5123247568Sdes}
5124247568Sdes
5125247568Sdes# func_mode_link arg...
5126247568Sdesfunc_mode_link ()
5127247568Sdes{
5128247568Sdes    $opt_debug
5129125647Sdes    case $host in
5130247568Sdes    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
5131117610Sdes      # It is impossible to link a dll without this setting, and
5132117610Sdes      # we shouldn't force the makefile maintainer to figure out
5133117610Sdes      # which system we are compiling for in order to pass an extra
5134141098Sdes      # flag for every libtool invocation.
5135117610Sdes      # allow_undefined=no
5136117610Sdes
5137117610Sdes      # FIXME: Unfortunately, there are problems with the above when trying
5138117610Sdes      # to make a dll which has undefined symbols, in which case not
5139117610Sdes      # even a static library is built.  For now, we need to specify
5140117610Sdes      # -no-undefined on the libtool link line when we can be certain
5141117610Sdes      # that all symbols are satisfied, otherwise we get a static library.
5142117610Sdes      allow_undefined=yes
5143117610Sdes      ;;
5144117610Sdes    *)
5145117610Sdes      allow_undefined=yes
5146117610Sdes      ;;
5147117610Sdes    esac
5148247568Sdes    libtool_args=$nonopt
5149141098Sdes    base_compile="$nonopt $@"
5150247568Sdes    compile_command=$nonopt
5151247568Sdes    finalize_command=$nonopt
5152117610Sdes
5153117610Sdes    compile_rpath=
5154117610Sdes    finalize_rpath=
5155117610Sdes    compile_shlibpath=
5156117610Sdes    finalize_shlibpath=
5157117610Sdes    convenience=
5158117610Sdes    old_convenience=
5159117610Sdes    deplibs=
5160125647Sdes    old_deplibs=
5161125647Sdes    compiler_flags=
5162125647Sdes    linker_flags=
5163125647Sdes    dllsearchpath=
5164125647Sdes    lib_search_path=`pwd`
5165141098Sdes    inst_prefix_dir=
5166247568Sdes    new_inherited_linker_flags=
5167117610Sdes
5168117610Sdes    avoid_version=no
5169247568Sdes    bindir=
5170117610Sdes    dlfiles=
5171117610Sdes    dlprefiles=
5172117610Sdes    dlself=no
5173117610Sdes    export_dynamic=no
5174117610Sdes    export_symbols=
5175117610Sdes    export_symbols_regex=
5176117610Sdes    generated=
5177117610Sdes    libobjs=
5178117610Sdes    ltlibs=
5179117610Sdes    module=no
5180125647Sdes    no_install=no
5181117610Sdes    objs=
5182141098Sdes    non_pic_objects=
5183141098Sdes    precious_files_regex=
5184117610Sdes    prefer_static_libs=no
5185117610Sdes    preload=no
5186117610Sdes    prev=
5187117610Sdes    prevarg=
5188117610Sdes    release=
5189117610Sdes    rpath=
5190117610Sdes    xrpath=
5191117610Sdes    perm_rpath=
5192117610Sdes    temp_rpath=
5193117610Sdes    thread_safe=no
5194117610Sdes    vinfo=
5195141098Sdes    vinfo_number=no
5196247568Sdes    weak_libs=
5197247568Sdes    single_module="${wl}-single_module"
5198141098Sdes    func_infer_tag $base_compile
5199141098Sdes
5200117610Sdes    # We need to know -static, to get the right output filenames.
5201117610Sdes    for arg
5202117610Sdes    do
5203125647Sdes      case $arg in
5204247568Sdes      -shared)
5205247568Sdes	test "$build_libtool_libs" != yes && \
5206247568Sdes	  func_fatal_configuration "can not build a shared library"
5207247568Sdes	build_old_libs=no
5208247568Sdes	break
5209247568Sdes	;;
5210174832Sdes      -all-static | -static | -static-libtool-libs)
5211174832Sdes	case $arg in
5212174832Sdes	-all-static)
5213117610Sdes	  if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
5214247568Sdes	    func_warning "complete static linking is impossible in this configuration"
5215117610Sdes	  fi
5216117610Sdes	  if test -n "$link_static_flag"; then
5217117610Sdes	    dlopen_self=$dlopen_self_static
5218117610Sdes	  fi
5219174832Sdes	  prefer_static_libs=yes
5220174832Sdes	  ;;
5221174832Sdes	-static)
5222117610Sdes	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
5223117610Sdes	    dlopen_self=$dlopen_self_static
5224117610Sdes	  fi
5225174832Sdes	  prefer_static_libs=built
5226174832Sdes	  ;;
5227174832Sdes	-static-libtool-libs)
5228174832Sdes	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
5229174832Sdes	    dlopen_self=$dlopen_self_static
5230174832Sdes	  fi
5231174832Sdes	  prefer_static_libs=yes
5232174832Sdes	  ;;
5233174832Sdes	esac
5234117610Sdes	build_libtool_libs=no
5235117610Sdes	build_old_libs=yes
5236117610Sdes	break
5237117610Sdes	;;
5238117610Sdes      esac
5239117610Sdes    done
5240117610Sdes
5241117610Sdes    # See if our shared archives depend on static archives.
5242117610Sdes    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
5243117610Sdes
5244117610Sdes    # Go through the arguments, transforming them on the way.
5245141098Sdes    while test "$#" -gt 0; do
5246117610Sdes      arg="$1"
5247117610Sdes      shift
5248247568Sdes      func_quote_for_eval "$arg"
5249247568Sdes      qarg=$func_quote_for_eval_unquoted_result
5250247568Sdes      func_append libtool_args " $func_quote_for_eval_result"
5251117610Sdes
5252117610Sdes      # If the previous option needs an argument, assign it.
5253117610Sdes      if test -n "$prev"; then
5254125647Sdes	case $prev in
5255117610Sdes	output)
5256247568Sdes	  func_append compile_command " @OUTPUT@"
5257247568Sdes	  func_append finalize_command " @OUTPUT@"
5258117610Sdes	  ;;
5259117610Sdes	esac
5260117610Sdes
5261125647Sdes	case $prev in
5262247568Sdes	bindir)
5263247568Sdes	  bindir="$arg"
5264247568Sdes	  prev=
5265247568Sdes	  continue
5266247568Sdes	  ;;
5267117610Sdes	dlfiles|dlprefiles)
5268117610Sdes	  if test "$preload" = no; then
5269117610Sdes	    # Add the symbol object into the linking commands.
5270247568Sdes	    func_append compile_command " @SYMFILE@"
5271247568Sdes	    func_append finalize_command " @SYMFILE@"
5272117610Sdes	    preload=yes
5273117610Sdes	  fi
5274125647Sdes	  case $arg in
5275117610Sdes	  *.la | *.lo) ;;  # We handle these cases below.
5276117610Sdes	  force)
5277117610Sdes	    if test "$dlself" = no; then
5278117610Sdes	      dlself=needless
5279117610Sdes	      export_dynamic=yes
5280117610Sdes	    fi
5281117610Sdes	    prev=
5282117610Sdes	    continue
5283117610Sdes	    ;;
5284117610Sdes	  self)
5285117610Sdes	    if test "$prev" = dlprefiles; then
5286117610Sdes	      dlself=yes
5287117610Sdes	    elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
5288117610Sdes	      dlself=yes
5289117610Sdes	    else
5290117610Sdes	      dlself=needless
5291117610Sdes	      export_dynamic=yes
5292117610Sdes	    fi
5293117610Sdes	    prev=
5294117610Sdes	    continue
5295117610Sdes	    ;;
5296117610Sdes	  *)
5297117610Sdes	    if test "$prev" = dlfiles; then
5298247568Sdes	      func_append dlfiles " $arg"
5299117610Sdes	    else
5300247568Sdes	      func_append dlprefiles " $arg"
5301117610Sdes	    fi
5302117610Sdes	    prev=
5303125647Sdes	    continue
5304117610Sdes	    ;;
5305117610Sdes	  esac
5306117610Sdes	  ;;
5307117610Sdes	expsyms)
5308117610Sdes	  export_symbols="$arg"
5309247568Sdes	  test -f "$arg" \
5310247568Sdes	    || func_fatal_error "symbol file \`$arg' does not exist"
5311117610Sdes	  prev=
5312117610Sdes	  continue
5313117610Sdes	  ;;
5314117610Sdes	expsyms_regex)
5315117610Sdes	  export_symbols_regex="$arg"
5316117610Sdes	  prev=
5317117610Sdes	  continue
5318117610Sdes	  ;;
5319247568Sdes	framework)
5320247568Sdes	  case $host in
5321247568Sdes	    *-*-darwin*)
5322247568Sdes	      case "$deplibs " in
5323247568Sdes		*" $qarg.ltframework "*) ;;
5324247568Sdes		*) func_append deplibs " $qarg.ltframework" # this is fixed later
5325247568Sdes		   ;;
5326247568Sdes	      esac
5327247568Sdes	      ;;
5328247568Sdes	  esac
5329141098Sdes	  prev=
5330141098Sdes	  continue
5331141098Sdes	  ;;
5332247568Sdes	inst_prefix)
5333247568Sdes	  inst_prefix_dir="$arg"
5334141098Sdes	  prev=
5335141098Sdes	  continue
5336141098Sdes	  ;;
5337141098Sdes	objectlist)
5338141098Sdes	  if test -f "$arg"; then
5339141098Sdes	    save_arg=$arg
5340141098Sdes	    moreargs=
5341247568Sdes	    for fil in `cat "$save_arg"`
5342141098Sdes	    do
5343247568Sdes#	      func_append moreargs " $fil"
5344141098Sdes	      arg=$fil
5345141098Sdes	      # A libtool-controlled object.
5346141098Sdes
5347141098Sdes	      # Check to see that this really is a libtool object.
5348247568Sdes	      if func_lalib_unsafe_p "$arg"; then
5349141098Sdes		pic_object=
5350141098Sdes		non_pic_object=
5351141098Sdes
5352141098Sdes		# Read the .lo file
5353247568Sdes		func_source "$arg"
5354141098Sdes
5355247568Sdes		if test -z "$pic_object" ||
5356141098Sdes		   test -z "$non_pic_object" ||
5357247568Sdes		   test "$pic_object" = none &&
5358141098Sdes		   test "$non_pic_object" = none; then
5359247568Sdes		  func_fatal_error "cannot find name of object for \`$arg'"
5360141098Sdes		fi
5361141098Sdes
5362141098Sdes		# Extract subdirectory from the argument.
5363247568Sdes		func_dirname "$arg" "/" ""
5364247568Sdes		xdir="$func_dirname_result"
5365141098Sdes
5366141098Sdes		if test "$pic_object" != none; then
5367141098Sdes		  # Prepend the subdirectory the object is found in.
5368141098Sdes		  pic_object="$xdir$pic_object"
5369141098Sdes
5370141098Sdes		  if test "$prev" = dlfiles; then
5371141098Sdes		    if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
5372247568Sdes		      func_append dlfiles " $pic_object"
5373141098Sdes		      prev=
5374141098Sdes		      continue
5375141098Sdes		    else
5376141098Sdes		      # If libtool objects are unsupported, then we need to preload.
5377141098Sdes		      prev=dlprefiles
5378141098Sdes		    fi
5379141098Sdes		  fi
5380141098Sdes
5381141098Sdes		  # CHECK ME:  I think I busted this.  -Ossama
5382141098Sdes		  if test "$prev" = dlprefiles; then
5383141098Sdes		    # Preload the old-style object.
5384247568Sdes		    func_append dlprefiles " $pic_object"
5385141098Sdes		    prev=
5386141098Sdes		  fi
5387141098Sdes
5388141098Sdes		  # A PIC object.
5389247568Sdes		  func_append libobjs " $pic_object"
5390141098Sdes		  arg="$pic_object"
5391141098Sdes		fi
5392141098Sdes
5393141098Sdes		# Non-PIC object.
5394141098Sdes		if test "$non_pic_object" != none; then
5395141098Sdes		  # Prepend the subdirectory the object is found in.
5396141098Sdes		  non_pic_object="$xdir$non_pic_object"
5397141098Sdes
5398141098Sdes		  # A standard non-PIC object
5399247568Sdes		  func_append non_pic_objects " $non_pic_object"
5400141098Sdes		  if test -z "$pic_object" || test "$pic_object" = none ; then
5401141098Sdes		    arg="$non_pic_object"
5402141098Sdes		  fi
5403174832Sdes		else
5404174832Sdes		  # If the PIC object exists, use it instead.
5405174832Sdes		  # $xdir was prepended to $pic_object above.
5406174832Sdes		  non_pic_object="$pic_object"
5407247568Sdes		  func_append non_pic_objects " $non_pic_object"
5408141098Sdes		fi
5409141098Sdes	      else
5410141098Sdes		# Only an error if not doing a dry-run.
5411247568Sdes		if $opt_dry_run; then
5412141098Sdes		  # Extract subdirectory from the argument.
5413247568Sdes		  func_dirname "$arg" "/" ""
5414247568Sdes		  xdir="$func_dirname_result"
5415141098Sdes
5416247568Sdes		  func_lo2o "$arg"
5417247568Sdes		  pic_object=$xdir$objdir/$func_lo2o_result
5418247568Sdes		  non_pic_object=$xdir$func_lo2o_result
5419247568Sdes		  func_append libobjs " $pic_object"
5420247568Sdes		  func_append non_pic_objects " $non_pic_object"
5421247568Sdes	        else
5422247568Sdes		  func_fatal_error "\`$arg' is not a valid libtool object"
5423141098Sdes		fi
5424141098Sdes	      fi
5425141098Sdes	    done
5426141098Sdes	  else
5427247568Sdes	    func_fatal_error "link input file \`$arg' does not exist"
5428141098Sdes	  fi
5429141098Sdes	  arg=$save_arg
5430141098Sdes	  prev=
5431141098Sdes	  continue
5432141098Sdes	  ;;
5433247568Sdes	precious_regex)
5434247568Sdes	  precious_files_regex="$arg"
5435247568Sdes	  prev=
5436247568Sdes	  continue
5437247568Sdes	  ;;
5438247568Sdes	release)
5439247568Sdes	  release="-$arg"
5440247568Sdes	  prev=
5441247568Sdes	  continue
5442247568Sdes	  ;;
5443117610Sdes	rpath | xrpath)
5444117610Sdes	  # We need an absolute path.
5445125647Sdes	  case $arg in
5446117610Sdes	  [\\/]* | [A-Za-z]:[\\/]*) ;;
5447117610Sdes	  *)
5448247568Sdes	    func_fatal_error "only absolute run-paths are allowed"
5449117610Sdes	    ;;
5450117610Sdes	  esac
5451117610Sdes	  if test "$prev" = rpath; then
5452117610Sdes	    case "$rpath " in
5453117610Sdes	    *" $arg "*) ;;
5454247568Sdes	    *) func_append rpath " $arg" ;;
5455117610Sdes	    esac
5456117610Sdes	  else
5457117610Sdes	    case "$xrpath " in
5458117610Sdes	    *" $arg "*) ;;
5459247568Sdes	    *) func_append xrpath " $arg" ;;
5460117610Sdes	    esac
5461117610Sdes	  fi
5462117610Sdes	  prev=
5463117610Sdes	  continue
5464117610Sdes	  ;;
5465247568Sdes	shrext)
5466247568Sdes	  shrext_cmds="$arg"
5467125647Sdes	  prev=
5468125647Sdes	  continue
5469125647Sdes	  ;;
5470247568Sdes	weak)
5471247568Sdes	  func_append weak_libs " $arg"
5472125647Sdes	  prev=
5473125647Sdes	  continue
5474125647Sdes	  ;;
5475141098Sdes	xcclinker)
5476247568Sdes	  func_append linker_flags " $qarg"
5477247568Sdes	  func_append compiler_flags " $qarg"
5478141098Sdes	  prev=
5479247568Sdes	  func_append compile_command " $qarg"
5480247568Sdes	  func_append finalize_command " $qarg"
5481141098Sdes	  continue
5482141098Sdes	  ;;
5483247568Sdes	xcompiler)
5484247568Sdes	  func_append compiler_flags " $qarg"
5485141098Sdes	  prev=
5486247568Sdes	  func_append compile_command " $qarg"
5487247568Sdes	  func_append finalize_command " $qarg"
5488141098Sdes	  continue
5489141098Sdes	  ;;
5490247568Sdes	xlinker)
5491247568Sdes	  func_append linker_flags " $qarg"
5492247568Sdes	  func_append compiler_flags " $wl$qarg"
5493147455Sdes	  prev=
5494247568Sdes	  func_append compile_command " $wl$qarg"
5495247568Sdes	  func_append finalize_command " $wl$qarg"
5496147455Sdes	  continue
5497147455Sdes	  ;;
5498117610Sdes	*)
5499117610Sdes	  eval "$prev=\"\$arg\""
5500117610Sdes	  prev=
5501117610Sdes	  continue
5502117610Sdes	  ;;
5503117610Sdes	esac
5504141098Sdes      fi # test -n "$prev"
5505117610Sdes
5506117610Sdes      prevarg="$arg"
5507117610Sdes
5508125647Sdes      case $arg in
5509117610Sdes      -all-static)
5510117610Sdes	if test -n "$link_static_flag"; then
5511247568Sdes	  # See comment for -static flag below, for more details.
5512247568Sdes	  func_append compile_command " $link_static_flag"
5513247568Sdes	  func_append finalize_command " $link_static_flag"
5514117610Sdes	fi
5515117610Sdes	continue
5516117610Sdes	;;
5517117610Sdes
5518117610Sdes      -allow-undefined)
5519117610Sdes	# FIXME: remove this flag sometime in the future.
5520247568Sdes	func_fatal_error "\`-allow-undefined' must not be used because it is the default"
5521117610Sdes	;;
5522117610Sdes
5523117610Sdes      -avoid-version)
5524117610Sdes	avoid_version=yes
5525117610Sdes	continue
5526117610Sdes	;;
5527117610Sdes
5528247568Sdes      -bindir)
5529247568Sdes	prev=bindir
5530247568Sdes	continue
5531247568Sdes	;;
5532247568Sdes
5533117610Sdes      -dlopen)
5534117610Sdes	prev=dlfiles
5535117610Sdes	continue
5536117610Sdes	;;
5537117610Sdes
5538117610Sdes      -dlpreopen)
5539117610Sdes	prev=dlprefiles
5540117610Sdes	continue
5541117610Sdes	;;
5542117610Sdes
5543117610Sdes      -export-dynamic)
5544117610Sdes	export_dynamic=yes
5545117610Sdes	continue
5546117610Sdes	;;
5547117610Sdes
5548117610Sdes      -export-symbols | -export-symbols-regex)
5549117610Sdes	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
5550247568Sdes	  func_fatal_error "more than one -exported-symbols argument is not allowed"
5551117610Sdes	fi
5552117610Sdes	if test "X$arg" = "X-export-symbols"; then
5553117610Sdes	  prev=expsyms
5554117610Sdes	else
5555117610Sdes	  prev=expsyms_regex
5556117610Sdes	fi
5557117610Sdes	continue
5558117610Sdes	;;
5559117610Sdes
5560247568Sdes      -framework)
5561247568Sdes	prev=framework
5562174832Sdes	continue
5563174832Sdes	;;
5564147455Sdes
5565141098Sdes      -inst-prefix-dir)
5566141098Sdes	prev=inst_prefix
5567141098Sdes	continue
5568141098Sdes	;;
5569141098Sdes
5570125647Sdes      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
5571125647Sdes      # so, if we see these flags be careful not to treat them like -L
5572125647Sdes      -L[A-Z][A-Z]*:*)
5573125647Sdes	case $with_gcc/$host in
5574141098Sdes	no/*-*-irix* | /*-*-irix*)
5575247568Sdes	  func_append compile_command " $arg"
5576247568Sdes	  func_append finalize_command " $arg"
5577125647Sdes	  ;;
5578125647Sdes	esac
5579125647Sdes	continue
5580125647Sdes	;;
5581125647Sdes
5582117610Sdes      -L*)
5583247568Sdes	func_stripname "-L" '' "$arg"
5584247568Sdes	if test -z "$func_stripname_result"; then
5585247568Sdes	  if test "$#" -gt 0; then
5586247568Sdes	    func_fatal_error "require no space between \`-L' and \`$1'"
5587247568Sdes	  else
5588247568Sdes	    func_fatal_error "need path for \`-L' option"
5589247568Sdes	  fi
5590247568Sdes	fi
5591247568Sdes	func_resolve_sysroot "$func_stripname_result"
5592247568Sdes	dir=$func_resolve_sysroot_result
5593117610Sdes	# We need an absolute path.
5594125647Sdes	case $dir in
5595117610Sdes	[\\/]* | [A-Za-z]:[\\/]*) ;;
5596117610Sdes	*)
5597117610Sdes	  absdir=`cd "$dir" && pwd`
5598247568Sdes	  test -z "$absdir" && \
5599247568Sdes	    func_fatal_error "cannot determine absolute directory name of \`$dir'"
5600117610Sdes	  dir="$absdir"
5601117610Sdes	  ;;
5602117610Sdes	esac
5603125647Sdes	case "$deplibs " in
5604247568Sdes	*" -L$dir "* | *" $arg "*)
5605247568Sdes	  # Will only happen for absolute or sysroot arguments
5606247568Sdes	  ;;
5607125647Sdes	*)
5608247568Sdes	  # Preserve sysroot, but never include relative directories
5609247568Sdes	  case $dir in
5610247568Sdes	    [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;;
5611247568Sdes	    *) func_append deplibs " -L$dir" ;;
5612247568Sdes	  esac
5613247568Sdes	  func_append lib_search_path " $dir"
5614125647Sdes	  ;;
5615117610Sdes	esac
5616125647Sdes	case $host in
5617247568Sdes	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
5618247568Sdes	  testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
5619125647Sdes	  case :$dllsearchpath: in
5620125647Sdes	  *":$dir:"*) ;;
5621247568Sdes	  ::) dllsearchpath=$dir;;
5622247568Sdes	  *) func_append dllsearchpath ":$dir";;
5623117610Sdes	  esac
5624174832Sdes	  case :$dllsearchpath: in
5625174832Sdes	  *":$testbindir:"*) ;;
5626247568Sdes	  ::) dllsearchpath=$testbindir;;
5627247568Sdes	  *) func_append dllsearchpath ":$testbindir";;
5628174832Sdes	  esac
5629117610Sdes	  ;;
5630117610Sdes	esac
5631247568Sdes	deplibs="$deplibs $arg"
5632125647Sdes	continue
5633117610Sdes	;;
5634117610Sdes
5635117610Sdes      -l*)
5636125647Sdes	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
5637125647Sdes	  case $host in
5638247568Sdes	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
5639125647Sdes	    # These systems don't actually have a C or math library (as such)
5640117610Sdes	    continue
5641117610Sdes	    ;;
5642174832Sdes	  *-*-os2*)
5643125647Sdes	    # These systems don't actually have a C library (as such)
5644125647Sdes	    test "X$arg" = "X-lc" && continue
5645125647Sdes	    ;;
5646147455Sdes	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
5647125647Sdes	    # Do not include libc due to us having libc/libc_r.
5648125647Sdes	    test "X$arg" = "X-lc" && continue
5649125647Sdes	    ;;
5650141098Sdes	  *-*-rhapsody* | *-*-darwin1.[012])
5651141098Sdes	    # Rhapsody C and math libraries are in the System framework
5652247568Sdes	    func_append deplibs " System.ltframework"
5653117610Sdes	    continue
5654174832Sdes	    ;;
5655174832Sdes	  *-*-sco3.2v5* | *-*-sco5v6*)
5656174832Sdes	    # Causes problems with __ctype
5657174832Sdes	    test "X$arg" = "X-lc" && continue
5658174832Sdes	    ;;
5659174832Sdes	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
5660174832Sdes	    # Compiler inserts libc in the correct place for threads to work
5661174832Sdes	    test "X$arg" = "X-lc" && continue
5662174832Sdes	    ;;
5663117610Sdes	  esac
5664141098Sdes	elif test "X$arg" = "X-lc_r"; then
5665141098Sdes	 case $host in
5666147455Sdes	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
5667141098Sdes	   # Do not include libc_r directly, use -pthread flag.
5668141098Sdes	   continue
5669141098Sdes	   ;;
5670141098Sdes	 esac
5671117610Sdes	fi
5672247568Sdes	func_append deplibs " $arg"
5673125647Sdes	continue
5674117610Sdes	;;
5675117610Sdes
5676247568Sdes      -module)
5677247568Sdes	module=yes
5678247568Sdes	continue
5679247568Sdes	;;
5680247568Sdes
5681147455Sdes      # Tru64 UNIX uses -model [arg] to determine the layout of C++
5682147455Sdes      # classes, name mangling, and exception handling.
5683247568Sdes      # Darwin uses the -arch flag to determine output architecture.
5684247568Sdes      -model|-arch|-isysroot|--sysroot)
5685247568Sdes	func_append compiler_flags " $arg"
5686247568Sdes	func_append compile_command " $arg"
5687247568Sdes	func_append finalize_command " $arg"
5688147455Sdes	prev=xcompiler
5689147455Sdes	continue
5690147455Sdes	;;
5691147455Sdes
5692247568Sdes      -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
5693247568Sdes      |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
5694247568Sdes	func_append compiler_flags " $arg"
5695247568Sdes	func_append compile_command " $arg"
5696247568Sdes	func_append finalize_command " $arg"
5697247568Sdes	case "$new_inherited_linker_flags " in
5698247568Sdes	    *" $arg "*) ;;
5699247568Sdes	    * ) func_append new_inherited_linker_flags " $arg" ;;
5700247568Sdes	esac
5701141098Sdes	continue
5702141098Sdes	;;
5703141098Sdes
5704247568Sdes      -multi_module)
5705247568Sdes	single_module="${wl}-multi_module"
5706141098Sdes	continue
5707141098Sdes	;;
5708141098Sdes
5709125647Sdes      -no-fast-install)
5710125647Sdes	fast_install=no
5711125647Sdes	continue
5712125647Sdes	;;
5713125647Sdes
5714125647Sdes      -no-install)
5715125647Sdes	case $host in
5716247568Sdes	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
5717125647Sdes	  # The PATH hackery in wrapper scripts is required on Windows
5718174832Sdes	  # and Darwin in order for the loader to find any dlls it needs.
5719247568Sdes	  func_warning "\`-no-install' is ignored for $host"
5720247568Sdes	  func_warning "assuming \`-no-fast-install' instead"
5721125647Sdes	  fast_install=no
5722125647Sdes	  ;;
5723125647Sdes	*) no_install=yes ;;
5724125647Sdes	esac
5725125647Sdes	continue
5726125647Sdes	;;
5727125647Sdes
5728117610Sdes      -no-undefined)
5729117610Sdes	allow_undefined=no
5730117610Sdes	continue
5731117610Sdes	;;
5732117610Sdes
5733141098Sdes      -objectlist)
5734141098Sdes	prev=objectlist
5735141098Sdes	continue
5736141098Sdes	;;
5737141098Sdes
5738117610Sdes      -o) prev=output ;;
5739117610Sdes
5740141098Sdes      -precious-files-regex)
5741141098Sdes	prev=precious_regex
5742141098Sdes	continue
5743141098Sdes	;;
5744141098Sdes
5745117610Sdes      -release)
5746117610Sdes	prev=release
5747117610Sdes	continue
5748117610Sdes	;;
5749117610Sdes
5750117610Sdes      -rpath)
5751117610Sdes	prev=rpath
5752117610Sdes	continue
5753117610Sdes	;;
5754117610Sdes
5755117610Sdes      -R)
5756117610Sdes	prev=xrpath
5757117610Sdes	continue
5758117610Sdes	;;
5759117610Sdes
5760117610Sdes      -R*)
5761247568Sdes	func_stripname '-R' '' "$arg"
5762247568Sdes	dir=$func_stripname_result
5763117610Sdes	# We need an absolute path.
5764125647Sdes	case $dir in
5765117610Sdes	[\\/]* | [A-Za-z]:[\\/]*) ;;
5766247568Sdes	=*)
5767247568Sdes	  func_stripname '=' '' "$dir"
5768247568Sdes	  dir=$lt_sysroot$func_stripname_result
5769247568Sdes	  ;;
5770117610Sdes	*)
5771247568Sdes	  func_fatal_error "only absolute run-paths are allowed"
5772117610Sdes	  ;;
5773117610Sdes	esac
5774117610Sdes	case "$xrpath " in
5775117610Sdes	*" $dir "*) ;;
5776247568Sdes	*) func_append xrpath " $dir" ;;
5777117610Sdes	esac
5778117610Sdes	continue
5779117610Sdes	;;
5780117610Sdes
5781247568Sdes      -shared)
5782247568Sdes	# The effects of -shared are defined in a previous loop.
5783247568Sdes	continue
5784247568Sdes	;;
5785247568Sdes
5786247568Sdes      -shrext)
5787247568Sdes	prev=shrext
5788247568Sdes	continue
5789247568Sdes	;;
5790247568Sdes
5791174832Sdes      -static | -static-libtool-libs)
5792125647Sdes	# The effects of -static are defined in a previous loop.
5793125647Sdes	# We used to do the same as -all-static on platforms that
5794125647Sdes	# didn't have a PIC flag, but the assumption that the effects
5795125647Sdes	# would be equivalent was wrong.  It would break on at least
5796125647Sdes	# Digital Unix and AIX.
5797117610Sdes	continue
5798117610Sdes	;;
5799117610Sdes
5800117610Sdes      -thread-safe)
5801117610Sdes	thread_safe=yes
5802117610Sdes	continue
5803117610Sdes	;;
5804117610Sdes
5805117610Sdes      -version-info)
5806117610Sdes	prev=vinfo
5807117610Sdes	continue
5808117610Sdes	;;
5809247568Sdes
5810141098Sdes      -version-number)
5811141098Sdes	prev=vinfo
5812141098Sdes	vinfo_number=yes
5813141098Sdes	continue
5814141098Sdes	;;
5815117610Sdes
5816247568Sdes      -weak)
5817247568Sdes        prev=weak
5818247568Sdes	continue
5819247568Sdes	;;
5820247568Sdes
5821125647Sdes      -Wc,*)
5822247568Sdes	func_stripname '-Wc,' '' "$arg"
5823247568Sdes	args=$func_stripname_result
5824125647Sdes	arg=
5825125647Sdes	save_ifs="$IFS"; IFS=','
5826125647Sdes	for flag in $args; do
5827125647Sdes	  IFS="$save_ifs"
5828247568Sdes          func_quote_for_eval "$flag"
5829247568Sdes	  func_append arg " $func_quote_for_eval_result"
5830247568Sdes	  func_append compiler_flags " $func_quote_for_eval_result"
5831125647Sdes	done
5832125647Sdes	IFS="$save_ifs"
5833247568Sdes	func_stripname ' ' '' "$arg"
5834247568Sdes	arg=$func_stripname_result
5835125647Sdes	;;
5836125647Sdes
5837125647Sdes      -Wl,*)
5838247568Sdes	func_stripname '-Wl,' '' "$arg"
5839247568Sdes	args=$func_stripname_result
5840125647Sdes	arg=
5841125647Sdes	save_ifs="$IFS"; IFS=','
5842125647Sdes	for flag in $args; do
5843125647Sdes	  IFS="$save_ifs"
5844247568Sdes          func_quote_for_eval "$flag"
5845247568Sdes	  func_append arg " $wl$func_quote_for_eval_result"
5846247568Sdes	  func_append compiler_flags " $wl$func_quote_for_eval_result"
5847247568Sdes	  func_append linker_flags " $func_quote_for_eval_result"
5848125647Sdes	done
5849125647Sdes	IFS="$save_ifs"
5850247568Sdes	func_stripname ' ' '' "$arg"
5851247568Sdes	arg=$func_stripname_result
5852125647Sdes	;;
5853125647Sdes
5854125647Sdes      -Xcompiler)
5855125647Sdes	prev=xcompiler
5856125647Sdes	continue
5857125647Sdes	;;
5858125647Sdes
5859125647Sdes      -Xlinker)
5860125647Sdes	prev=xlinker
5861125647Sdes	continue
5862125647Sdes	;;
5863125647Sdes
5864141098Sdes      -XCClinker)
5865141098Sdes	prev=xcclinker
5866141098Sdes	continue
5867141098Sdes	;;
5868141098Sdes
5869247568Sdes      # -msg_* for osf cc
5870247568Sdes      -msg_*)
5871247568Sdes	func_quote_for_eval "$arg"
5872247568Sdes	arg="$func_quote_for_eval_result"
5873247568Sdes	;;
5874247568Sdes
5875247568Sdes      # Flags to be passed through unchanged, with rationale:
5876247568Sdes      # -64, -mips[0-9]      enable 64-bit mode for the SGI compiler
5877247568Sdes      # -r[0-9][0-9]*        specify processor for the SGI compiler
5878247568Sdes      # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler
5879247568Sdes      # +DA*, +DD*           enable 64-bit mode for the HP compiler
5880247568Sdes      # -q*                  compiler args for the IBM compiler
5881247568Sdes      # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
5882247568Sdes      # -F/path              path to uninstalled frameworks, gcc on darwin
5883247568Sdes      # -p, -pg, --coverage, -fprofile-*  profiling flags for GCC
5884247568Sdes      # @file                GCC response files
5885247568Sdes      # -tp=*                Portland pgcc target processor selection
5886247568Sdes      # --sysroot=*          for sysroot support
5887247568Sdes      # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
5888247568Sdes      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
5889247568Sdes      -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
5890247568Sdes      -O*|-flto*|-fwhopr*|-fuse-linker-plugin)
5891247568Sdes        func_quote_for_eval "$arg"
5892247568Sdes	arg="$func_quote_for_eval_result"
5893247568Sdes        func_append compile_command " $arg"
5894247568Sdes        func_append finalize_command " $arg"
5895247568Sdes        func_append compiler_flags " $arg"
5896247568Sdes        continue
5897247568Sdes        ;;
5898247568Sdes
5899117610Sdes      # Some other compiler flag.
5900117610Sdes      -* | +*)
5901247568Sdes        func_quote_for_eval "$arg"
5902247568Sdes	arg="$func_quote_for_eval_result"
5903117610Sdes	;;
5904117610Sdes
5905141098Sdes      *.$objext)
5906141098Sdes	# A standard object.
5907247568Sdes	func_append objs " $arg"
5908141098Sdes	;;
5909141098Sdes
5910141098Sdes      *.lo)
5911141098Sdes	# A libtool-controlled object.
5912141098Sdes
5913141098Sdes	# Check to see that this really is a libtool object.
5914247568Sdes	if func_lalib_unsafe_p "$arg"; then
5915141098Sdes	  pic_object=
5916141098Sdes	  non_pic_object=
5917141098Sdes
5918141098Sdes	  # Read the .lo file
5919247568Sdes	  func_source "$arg"
5920141098Sdes
5921247568Sdes	  if test -z "$pic_object" ||
5922141098Sdes	     test -z "$non_pic_object" ||
5923247568Sdes	     test "$pic_object" = none &&
5924141098Sdes	     test "$non_pic_object" = none; then
5925247568Sdes	    func_fatal_error "cannot find name of object for \`$arg'"
5926117610Sdes	  fi
5927117610Sdes
5928141098Sdes	  # Extract subdirectory from the argument.
5929247568Sdes	  func_dirname "$arg" "/" ""
5930247568Sdes	  xdir="$func_dirname_result"
5931141098Sdes
5932141098Sdes	  if test "$pic_object" != none; then
5933141098Sdes	    # Prepend the subdirectory the object is found in.
5934141098Sdes	    pic_object="$xdir$pic_object"
5935141098Sdes
5936141098Sdes	    if test "$prev" = dlfiles; then
5937141098Sdes	      if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
5938247568Sdes		func_append dlfiles " $pic_object"
5939141098Sdes		prev=
5940141098Sdes		continue
5941141098Sdes	      else
5942141098Sdes		# If libtool objects are unsupported, then we need to preload.
5943141098Sdes		prev=dlprefiles
5944141098Sdes	      fi
5945141098Sdes	    fi
5946141098Sdes
5947141098Sdes	    # CHECK ME:  I think I busted this.  -Ossama
5948141098Sdes	    if test "$prev" = dlprefiles; then
5949141098Sdes	      # Preload the old-style object.
5950247568Sdes	      func_append dlprefiles " $pic_object"
5951141098Sdes	      prev=
5952141098Sdes	    fi
5953141098Sdes
5954141098Sdes	    # A PIC object.
5955247568Sdes	    func_append libobjs " $pic_object"
5956141098Sdes	    arg="$pic_object"
5957141098Sdes	  fi
5958141098Sdes
5959141098Sdes	  # Non-PIC object.
5960141098Sdes	  if test "$non_pic_object" != none; then
5961141098Sdes	    # Prepend the subdirectory the object is found in.
5962141098Sdes	    non_pic_object="$xdir$non_pic_object"
5963141098Sdes
5964141098Sdes	    # A standard non-PIC object
5965247568Sdes	    func_append non_pic_objects " $non_pic_object"
5966141098Sdes	    if test -z "$pic_object" || test "$pic_object" = none ; then
5967141098Sdes	      arg="$non_pic_object"
5968141098Sdes	    fi
5969174832Sdes	  else
5970174832Sdes	    # If the PIC object exists, use it instead.
5971174832Sdes	    # $xdir was prepended to $pic_object above.
5972174832Sdes	    non_pic_object="$pic_object"
5973247568Sdes	    func_append non_pic_objects " $non_pic_object"
5974141098Sdes	  fi
5975125647Sdes	else
5976141098Sdes	  # Only an error if not doing a dry-run.
5977247568Sdes	  if $opt_dry_run; then
5978141098Sdes	    # Extract subdirectory from the argument.
5979247568Sdes	    func_dirname "$arg" "/" ""
5980247568Sdes	    xdir="$func_dirname_result"
5981141098Sdes
5982247568Sdes	    func_lo2o "$arg"
5983247568Sdes	    pic_object=$xdir$objdir/$func_lo2o_result
5984247568Sdes	    non_pic_object=$xdir$func_lo2o_result
5985247568Sdes	    func_append libobjs " $pic_object"
5986247568Sdes	    func_append non_pic_objects " $non_pic_object"
5987247568Sdes	  else
5988247568Sdes	    func_fatal_error "\`$arg' is not a valid libtool object"
5989141098Sdes	  fi
5990117610Sdes	fi
5991117610Sdes	;;
5992117610Sdes
5993125647Sdes      *.$libext)
5994125647Sdes	# An archive.
5995247568Sdes	func_append deplibs " $arg"
5996247568Sdes	func_append old_deplibs " $arg"
5997125647Sdes	continue
5998125647Sdes	;;
5999125647Sdes
6000117610Sdes      *.la)
6001117610Sdes	# A libtool-controlled library.
6002117610Sdes
6003247568Sdes	func_resolve_sysroot "$arg"
6004125647Sdes	if test "$prev" = dlfiles; then
6005125647Sdes	  # This library was specified with -dlopen.
6006247568Sdes	  func_append dlfiles " $func_resolve_sysroot_result"
6007125647Sdes	  prev=
6008125647Sdes	elif test "$prev" = dlprefiles; then
6009125647Sdes	  # The library was specified with -dlpreopen.
6010247568Sdes	  func_append dlprefiles " $func_resolve_sysroot_result"
6011125647Sdes	  prev=
6012125647Sdes	else
6013247568Sdes	  func_append deplibs " $func_resolve_sysroot_result"
6014125647Sdes	fi
6015125647Sdes	continue
6016125647Sdes	;;
6017117610Sdes
6018125647Sdes      # Some other compiler argument.
6019125647Sdes      *)
6020125647Sdes	# Unknown arguments in both finalize_command and compile_command need
6021125647Sdes	# to be aesthetically quoted because they are evaled later.
6022247568Sdes	func_quote_for_eval "$arg"
6023247568Sdes	arg="$func_quote_for_eval_result"
6024125647Sdes	;;
6025125647Sdes      esac # arg
6026125647Sdes
6027125647Sdes      # Now actually substitute the argument into the commands.
6028125647Sdes      if test -n "$arg"; then
6029247568Sdes	func_append compile_command " $arg"
6030247568Sdes	func_append finalize_command " $arg"
6031125647Sdes      fi
6032125647Sdes    done # argument parsing loop
6033125647Sdes
6034247568Sdes    test -n "$prev" && \
6035247568Sdes      func_fatal_help "the \`$prevarg' option requires an argument"
6036125647Sdes
6037125647Sdes    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
6038125647Sdes      eval arg=\"$export_dynamic_flag_spec\"
6039247568Sdes      func_append compile_command " $arg"
6040247568Sdes      func_append finalize_command " $arg"
6041125647Sdes    fi
6042125647Sdes
6043141098Sdes    oldlibs=
6044125647Sdes    # calculate the name of the file, without its directory
6045247568Sdes    func_basename "$output"
6046247568Sdes    outputname="$func_basename_result"
6047125647Sdes    libobjs_save="$libobjs"
6048125647Sdes
6049125647Sdes    if test -n "$shlibpath_var"; then
6050125647Sdes      # get the directories listed in $shlibpath_var
6051247568Sdes      eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\`
6052125647Sdes    else
6053125647Sdes      shlib_search_path=
6054125647Sdes    fi
6055125647Sdes    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
6056125647Sdes    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
6057125647Sdes
6058247568Sdes    func_dirname "$output" "/" ""
6059247568Sdes    output_objdir="$func_dirname_result$objdir"
6060247568Sdes    func_to_tool_file "$output_objdir/"
6061247568Sdes    tool_output_objdir=$func_to_tool_file_result
6062125647Sdes    # Create the object directory.
6063247568Sdes    func_mkdir_p "$output_objdir"
6064125647Sdes
6065125647Sdes    # Determine the type of output
6066125647Sdes    case $output in
6067125647Sdes    "")
6068247568Sdes      func_fatal_help "you must specify an output file"
6069125647Sdes      ;;
6070125647Sdes    *.$libext) linkmode=oldlib ;;
6071125647Sdes    *.lo | *.$objext) linkmode=obj ;;
6072125647Sdes    *.la) linkmode=lib ;;
6073125647Sdes    *) linkmode=prog ;; # Anything else should be a program.
6074125647Sdes    esac
6075125647Sdes
6076125647Sdes    specialdeplibs=
6077141098Sdes
6078125647Sdes    libs=
6079125647Sdes    # Find all interdependent deplibs by searching for libraries
6080125647Sdes    # that are linked more than once (e.g. -la -lb -la)
6081125647Sdes    for deplib in $deplibs; do
6082247568Sdes      if $opt_preserve_dup_deps ; then
6083125647Sdes	case "$libs " in
6084247568Sdes	*" $deplib "*) func_append specialdeplibs " $deplib" ;;
6085125647Sdes	esac
6086125647Sdes      fi
6087247568Sdes      func_append libs " $deplib"
6088125647Sdes    done
6089141098Sdes
6090141098Sdes    if test "$linkmode" = lib; then
6091141098Sdes      libs="$predeps $libs $compiler_lib_search_path $postdeps"
6092141098Sdes
6093141098Sdes      # Compute libraries that are listed more than once in $predeps
6094141098Sdes      # $postdeps and mark them as special (i.e., whose duplicates are
6095141098Sdes      # not to be eliminated).
6096141098Sdes      pre_post_deps=
6097247568Sdes      if $opt_duplicate_compiler_generated_deps; then
6098141098Sdes	for pre_post_dep in $predeps $postdeps; do
6099141098Sdes	  case "$pre_post_deps " in
6100247568Sdes	  *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;;
6101141098Sdes	  esac
6102247568Sdes	  func_append pre_post_deps " $pre_post_dep"
6103141098Sdes	done
6104141098Sdes      fi
6105141098Sdes      pre_post_deps=
6106141098Sdes    fi
6107141098Sdes
6108125647Sdes    deplibs=
6109125647Sdes    newdependency_libs=
6110125647Sdes    newlib_search_path=
6111125647Sdes    need_relink=no # whether we're linking any uninstalled libtool libraries
6112125647Sdes    notinst_deplibs= # not-installed libtool libraries
6113247568Sdes    notinst_path= # paths that contain not-installed libtool libraries
6114247568Sdes
6115125647Sdes    case $linkmode in
6116125647Sdes    lib)
6117247568Sdes	passes="conv dlpreopen link"
6118125647Sdes	for file in $dlfiles $dlprefiles; do
6119125647Sdes	  case $file in
6120125647Sdes	  *.la) ;;
6121125647Sdes	  *)
6122247568Sdes	    func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file"
6123125647Sdes	    ;;
6124125647Sdes	  esac
6125125647Sdes	done
6126125647Sdes	;;
6127125647Sdes    prog)
6128125647Sdes	compile_deplibs=
6129125647Sdes	finalize_deplibs=
6130125647Sdes	alldeplibs=no
6131125647Sdes	newdlfiles=
6132125647Sdes	newdlprefiles=
6133125647Sdes	passes="conv scan dlopen dlpreopen link"
6134125647Sdes	;;
6135125647Sdes    *)  passes="conv"
6136125647Sdes	;;
6137125647Sdes    esac
6138247568Sdes
6139125647Sdes    for pass in $passes; do
6140247568Sdes      # The preopen pass in lib mode reverses $deplibs; put it back here
6141247568Sdes      # so that -L comes before libs that need it for instance...
6142247568Sdes      if test "$linkmode,$pass" = "lib,link"; then
6143247568Sdes	## FIXME: Find the place where the list is rebuilt in the wrong
6144247568Sdes	##        order, and fix it there properly
6145247568Sdes        tmp_deplibs=
6146247568Sdes	for deplib in $deplibs; do
6147247568Sdes	  tmp_deplibs="$deplib $tmp_deplibs"
6148247568Sdes	done
6149247568Sdes	deplibs="$tmp_deplibs"
6150247568Sdes      fi
6151247568Sdes
6152141098Sdes      if test "$linkmode,$pass" = "lib,link" ||
6153141098Sdes	 test "$linkmode,$pass" = "prog,scan"; then
6154141098Sdes	libs="$deplibs"
6155141098Sdes	deplibs=
6156141098Sdes      fi
6157141098Sdes      if test "$linkmode" = prog; then
6158125647Sdes	case $pass in
6159141098Sdes	dlopen) libs="$dlfiles" ;;
6160125647Sdes	dlpreopen) libs="$dlprefiles" ;;
6161125647Sdes	link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
6162125647Sdes	esac
6163125647Sdes      fi
6164247568Sdes      if test "$linkmode,$pass" = "lib,dlpreopen"; then
6165247568Sdes	# Collect and forward deplibs of preopened libtool libs
6166247568Sdes	for lib in $dlprefiles; do
6167247568Sdes	  # Ignore non-libtool-libs
6168247568Sdes	  dependency_libs=
6169247568Sdes	  func_resolve_sysroot "$lib"
6170247568Sdes	  case $lib in
6171247568Sdes	  *.la)	func_source "$func_resolve_sysroot_result" ;;
6172247568Sdes	  esac
6173247568Sdes
6174247568Sdes	  # Collect preopened libtool deplibs, except any this library
6175247568Sdes	  # has declared as weak libs
6176247568Sdes	  for deplib in $dependency_libs; do
6177247568Sdes	    func_basename "$deplib"
6178247568Sdes            deplib_base=$func_basename_result
6179247568Sdes	    case " $weak_libs " in
6180247568Sdes	    *" $deplib_base "*) ;;
6181247568Sdes	    *) func_append deplibs " $deplib" ;;
6182247568Sdes	    esac
6183247568Sdes	  done
6184247568Sdes	done
6185247568Sdes	libs="$dlprefiles"
6186247568Sdes      fi
6187141098Sdes      if test "$pass" = dlopen; then
6188141098Sdes	# Collect dlpreopened libraries
6189141098Sdes	save_deplibs="$deplibs"
6190141098Sdes	deplibs=
6191141098Sdes      fi
6192247568Sdes
6193125647Sdes      for deplib in $libs; do
6194125647Sdes	lib=
6195125647Sdes	found=no
6196125647Sdes	case $deplib in
6197247568Sdes	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
6198247568Sdes        |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
6199141098Sdes	  if test "$linkmode,$pass" = "prog,link"; then
6200141098Sdes	    compile_deplibs="$deplib $compile_deplibs"
6201141098Sdes	    finalize_deplibs="$deplib $finalize_deplibs"
6202141098Sdes	  else
6203247568Sdes	    func_append compiler_flags " $deplib"
6204141098Sdes	  fi
6205174832Sdes
6206174832Sdes	  case $linkmode in
6207174832Sdes	  lib)
6208174832Sdes	    deplibs="$deplib $deplibs"
6209174832Sdes	    test "$pass" = conv && continue
6210174832Sdes	    newdependency_libs="$deplib $newdependency_libs"
6211174832Sdes	    ;;
6212174832Sdes	  prog)
6213174832Sdes	    if test "$pass" = conv; then
6214174832Sdes	      deplibs="$deplib $deplibs"
6215174832Sdes	      continue
6216174832Sdes	    fi
6217174832Sdes	    if test "$pass" = scan; then
6218174832Sdes	      deplibs="$deplib $deplibs"
6219174832Sdes	    else
6220174832Sdes	      compile_deplibs="$deplib $compile_deplibs"
6221174832Sdes	      finalize_deplibs="$deplib $finalize_deplibs"
6222174832Sdes	    fi
6223174832Sdes	    ;;
6224174832Sdes	  *)
6225174832Sdes	    ;;
6226174832Sdes	  esac # linkmode
6227174832Sdes
6228141098Sdes	  continue
6229141098Sdes	  ;;
6230125647Sdes	-l*)
6231141098Sdes	  if test "$linkmode" != lib && test "$linkmode" != prog; then
6232247568Sdes	    func_warning "\`-l' is ignored for archives/objects"
6233125647Sdes	    continue
6234125647Sdes	  fi
6235247568Sdes	  func_stripname '-l' '' "$deplib"
6236247568Sdes	  name=$func_stripname_result
6237247568Sdes	  if test "$linkmode" = lib; then
6238247568Sdes	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
6239247568Sdes	  else
6240247568Sdes	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
6241247568Sdes	  fi
6242247568Sdes	  for searchdir in $searchdirs; do
6243141098Sdes	    for search_ext in .la $std_shrext .so .a; do
6244141098Sdes	      # Search the libtool library
6245141098Sdes	      lib="$searchdir/lib${name}${search_ext}"
6246141098Sdes	      if test -f "$lib"; then
6247141098Sdes		if test "$search_ext" = ".la"; then
6248141098Sdes		  found=yes
6249141098Sdes		else
6250141098Sdes		  found=no
6251141098Sdes		fi
6252141098Sdes		break 2
6253141098Sdes	      fi
6254141098Sdes	    done
6255125647Sdes	  done
6256125647Sdes	  if test "$found" != yes; then
6257125647Sdes	    # deplib doesn't seem to be a libtool library
6258125647Sdes	    if test "$linkmode,$pass" = "prog,link"; then
6259125647Sdes	      compile_deplibs="$deplib $compile_deplibs"
6260125647Sdes	      finalize_deplibs="$deplib $finalize_deplibs"
6261125647Sdes	    else
6262125647Sdes	      deplibs="$deplib $deplibs"
6263141098Sdes	      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
6264125647Sdes	    fi
6265125647Sdes	    continue
6266141098Sdes	  else # deplib is a libtool library
6267141098Sdes	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
6268141098Sdes	    # We need to do some special things here, and not later.
6269141098Sdes	    if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6270141098Sdes	      case " $predeps $postdeps " in
6271141098Sdes	      *" $deplib "*)
6272247568Sdes		if func_lalib_p "$lib"; then
6273141098Sdes		  library_names=
6274141098Sdes		  old_library=
6275247568Sdes		  func_source "$lib"
6276141098Sdes		  for l in $old_library $library_names; do
6277141098Sdes		    ll="$l"
6278141098Sdes		  done
6279141098Sdes		  if test "X$ll" = "X$old_library" ; then # only static version available
6280141098Sdes		    found=no
6281247568Sdes		    func_dirname "$lib" "" "."
6282247568Sdes		    ladir="$func_dirname_result"
6283141098Sdes		    lib=$ladir/$old_library
6284141098Sdes		    if test "$linkmode,$pass" = "prog,link"; then
6285141098Sdes		      compile_deplibs="$deplib $compile_deplibs"
6286141098Sdes		      finalize_deplibs="$deplib $finalize_deplibs"
6287141098Sdes		    else
6288141098Sdes		      deplibs="$deplib $deplibs"
6289141098Sdes		      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
6290141098Sdes		    fi
6291141098Sdes		    continue
6292141098Sdes		  fi
6293141098Sdes		fi
6294247568Sdes		;;
6295141098Sdes	      *) ;;
6296141098Sdes	      esac
6297141098Sdes	    fi
6298125647Sdes	  fi
6299125647Sdes	  ;; # -l
6300247568Sdes	*.ltframework)
6301247568Sdes	  if test "$linkmode,$pass" = "prog,link"; then
6302247568Sdes	    compile_deplibs="$deplib $compile_deplibs"
6303247568Sdes	    finalize_deplibs="$deplib $finalize_deplibs"
6304247568Sdes	  else
6305247568Sdes	    deplibs="$deplib $deplibs"
6306247568Sdes	    if test "$linkmode" = lib ; then
6307247568Sdes		case "$new_inherited_linker_flags " in
6308247568Sdes		    *" $deplib "*) ;;
6309247568Sdes		    * ) func_append new_inherited_linker_flags " $deplib" ;;
6310247568Sdes		esac
6311247568Sdes	    fi
6312247568Sdes	  fi
6313247568Sdes	  continue
6314247568Sdes	  ;;
6315125647Sdes	-L*)
6316125647Sdes	  case $linkmode in
6317125647Sdes	  lib)
6318125647Sdes	    deplibs="$deplib $deplibs"
6319141098Sdes	    test "$pass" = conv && continue
6320125647Sdes	    newdependency_libs="$deplib $newdependency_libs"
6321247568Sdes	    func_stripname '-L' '' "$deplib"
6322247568Sdes	    func_resolve_sysroot "$func_stripname_result"
6323247568Sdes	    func_append newlib_search_path " $func_resolve_sysroot_result"
6324125647Sdes	    ;;
6325125647Sdes	  prog)
6326141098Sdes	    if test "$pass" = conv; then
6327125647Sdes	      deplibs="$deplib $deplibs"
6328125647Sdes	      continue
6329125647Sdes	    fi
6330141098Sdes	    if test "$pass" = scan; then
6331125647Sdes	      deplibs="$deplib $deplibs"
6332125647Sdes	    else
6333125647Sdes	      compile_deplibs="$deplib $compile_deplibs"
6334125647Sdes	      finalize_deplibs="$deplib $finalize_deplibs"
6335125647Sdes	    fi
6336247568Sdes	    func_stripname '-L' '' "$deplib"
6337247568Sdes	    func_resolve_sysroot "$func_stripname_result"
6338247568Sdes	    func_append newlib_search_path " $func_resolve_sysroot_result"
6339125647Sdes	    ;;
6340125647Sdes	  *)
6341247568Sdes	    func_warning "\`-L' is ignored for archives/objects"
6342125647Sdes	    ;;
6343125647Sdes	  esac # linkmode
6344125647Sdes	  continue
6345125647Sdes	  ;; # -L
6346125647Sdes	-R*)
6347141098Sdes	  if test "$pass" = link; then
6348247568Sdes	    func_stripname '-R' '' "$deplib"
6349247568Sdes	    func_resolve_sysroot "$func_stripname_result"
6350247568Sdes	    dir=$func_resolve_sysroot_result
6351125647Sdes	    # Make sure the xrpath contains only unique directories.
6352125647Sdes	    case "$xrpath " in
6353125647Sdes	    *" $dir "*) ;;
6354247568Sdes	    *) func_append xrpath " $dir" ;;
6355125647Sdes	    esac
6356125647Sdes	  fi
6357125647Sdes	  deplibs="$deplib $deplibs"
6358125647Sdes	  continue
6359125647Sdes	  ;;
6360247568Sdes	*.la)
6361247568Sdes	  func_resolve_sysroot "$deplib"
6362247568Sdes	  lib=$func_resolve_sysroot_result
6363247568Sdes	  ;;
6364125647Sdes	*.$libext)
6365141098Sdes	  if test "$pass" = conv; then
6366125647Sdes	    deplibs="$deplib $deplibs"
6367125647Sdes	    continue
6368125647Sdes	  fi
6369125647Sdes	  case $linkmode in
6370125647Sdes	  lib)
6371247568Sdes	    # Linking convenience modules into shared libraries is allowed,
6372247568Sdes	    # but linking other static libraries is non-portable.
6373247568Sdes	    case " $dlpreconveniencelibs " in
6374247568Sdes	    *" $deplib "*) ;;
6375247568Sdes	    *)
6376247568Sdes	      valid_a_lib=no
6377247568Sdes	      case $deplibs_check_method in
6378247568Sdes		match_pattern*)
6379247568Sdes		  set dummy $deplibs_check_method; shift
6380247568Sdes		  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
6381247568Sdes		  if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
6382141098Sdes		    | $EGREP "$match_pattern_regex" > /dev/null; then
6383247568Sdes		    valid_a_lib=yes
6384247568Sdes		  fi
6385247568Sdes		;;
6386247568Sdes		pass_all)
6387141098Sdes		  valid_a_lib=yes
6388141098Sdes		;;
6389247568Sdes	      esac
6390247568Sdes	      if test "$valid_a_lib" != yes; then
6391247568Sdes		echo
6392247568Sdes		$ECHO "*** Warning: Trying to link with static lib archive $deplib."
6393247568Sdes		echo "*** I have the capability to make that library automatically link in when"
6394247568Sdes		echo "*** you link to this library.  But I can only do this if you have a"
6395247568Sdes		echo "*** shared version of the library, which you do not appear to have"
6396247568Sdes		echo "*** because the file extensions .$libext of this argument makes me believe"
6397247568Sdes		echo "*** that it is just a static archive that I should not use here."
6398247568Sdes	      else
6399247568Sdes		echo
6400247568Sdes		$ECHO "*** Warning: Linking the shared library $output against the"
6401247568Sdes		$ECHO "*** static library $deplib is not portable!"
6402247568Sdes		deplibs="$deplib $deplibs"
6403247568Sdes	      fi
6404247568Sdes	      ;;
6405247568Sdes	    esac
6406125647Sdes	    continue
6407125647Sdes	    ;;
6408125647Sdes	  prog)
6409141098Sdes	    if test "$pass" != link; then
6410125647Sdes	      deplibs="$deplib $deplibs"
6411125647Sdes	    else
6412125647Sdes	      compile_deplibs="$deplib $compile_deplibs"
6413125647Sdes	      finalize_deplibs="$deplib $finalize_deplibs"
6414125647Sdes	    fi
6415125647Sdes	    continue
6416125647Sdes	    ;;
6417125647Sdes	  esac # linkmode
6418125647Sdes	  ;; # *.$libext
6419125647Sdes	*.lo | *.$objext)
6420141098Sdes	  if test "$pass" = conv; then
6421141098Sdes	    deplibs="$deplib $deplibs"
6422141098Sdes	  elif test "$linkmode" = prog; then
6423141098Sdes	    if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
6424141098Sdes	      # If there is no dlopen support or we're linking statically,
6425141098Sdes	      # we need to preload.
6426247568Sdes	      func_append newdlprefiles " $deplib"
6427141098Sdes	      compile_deplibs="$deplib $compile_deplibs"
6428141098Sdes	      finalize_deplibs="$deplib $finalize_deplibs"
6429141098Sdes	    else
6430247568Sdes	      func_append newdlfiles " $deplib"
6431141098Sdes	    fi
6432125647Sdes	  fi
6433125647Sdes	  continue
6434125647Sdes	  ;;
6435125647Sdes	%DEPLIBS%)
6436125647Sdes	  alldeplibs=yes
6437125647Sdes	  continue
6438125647Sdes	  ;;
6439125647Sdes	esac # case $deplib
6440247568Sdes
6441141098Sdes	if test "$found" = yes || test -f "$lib"; then :
6442125647Sdes	else
6443247568Sdes	  func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'"
6444125647Sdes	fi
6445125647Sdes
6446117610Sdes	# Check to see that this really is a libtool archive.
6447247568Sdes	func_lalib_unsafe_p "$lib" \
6448247568Sdes	  || func_fatal_error "\`$lib' is not a valid libtool archive"
6449117610Sdes
6450247568Sdes	func_dirname "$lib" "" "."
6451247568Sdes	ladir="$func_dirname_result"
6452125647Sdes
6453125647Sdes	dlname=
6454125647Sdes	dlopen=
6455125647Sdes	dlpreopen=
6456125647Sdes	libdir=
6457125647Sdes	library_names=
6458125647Sdes	old_library=
6459247568Sdes	inherited_linker_flags=
6460117610Sdes	# If the library was installed with an old release of libtool,
6461141098Sdes	# it will not redefine variables installed, or shouldnotlink
6462117610Sdes	installed=yes
6463141098Sdes	shouldnotlink=no
6464147455Sdes	avoidtemprpath=
6465117610Sdes
6466147455Sdes
6467117610Sdes	# Read the .la file
6468247568Sdes	func_source "$lib"
6469117610Sdes
6470247568Sdes	# Convert "-framework foo" to "foo.ltframework"
6471247568Sdes	if test -n "$inherited_linker_flags"; then
6472247568Sdes	  tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
6473247568Sdes	  for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
6474247568Sdes	    case " $new_inherited_linker_flags " in
6475247568Sdes	      *" $tmp_inherited_linker_flag "*) ;;
6476247568Sdes	      *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";;
6477247568Sdes	    esac
6478247568Sdes	  done
6479247568Sdes	fi
6480247568Sdes	dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
6481125647Sdes	if test "$linkmode,$pass" = "lib,link" ||
6482125647Sdes	   test "$linkmode,$pass" = "prog,scan" ||
6483141098Sdes	   { test "$linkmode" != prog && test "$linkmode" != lib; }; then
6484247568Sdes	  test -n "$dlopen" && func_append dlfiles " $dlopen"
6485247568Sdes	  test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen"
6486125647Sdes	fi
6487125647Sdes
6488141098Sdes	if test "$pass" = conv; then
6489125647Sdes	  # Only check for convenience libraries
6490125647Sdes	  deplibs="$lib $deplibs"
6491125647Sdes	  if test -z "$libdir"; then
6492125647Sdes	    if test -z "$old_library"; then
6493247568Sdes	      func_fatal_error "cannot find name of link library for \`$lib'"
6494125647Sdes	    fi
6495125647Sdes	    # It is a libtool convenience library, so add in its objects.
6496247568Sdes	    func_append convenience " $ladir/$objdir/$old_library"
6497247568Sdes	    func_append old_convenience " $ladir/$objdir/$old_library"
6498141098Sdes	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
6499247568Sdes	    func_fatal_error "\`$lib' is not a convenience library"
6500125647Sdes	  fi
6501247568Sdes	  tmp_libs=
6502247568Sdes	  for deplib in $dependency_libs; do
6503247568Sdes	    deplibs="$deplib $deplibs"
6504247568Sdes	    if $opt_preserve_dup_deps ; then
6505247568Sdes	      case "$tmp_libs " in
6506247568Sdes	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
6507247568Sdes	      esac
6508247568Sdes	    fi
6509247568Sdes	    func_append tmp_libs " $deplib"
6510247568Sdes	  done
6511125647Sdes	  continue
6512125647Sdes	fi # $pass = conv
6513125647Sdes
6514141098Sdes
6515117610Sdes	# Get the name of the library we link against.
6516117610Sdes	linklib=
6517247568Sdes	if test -n "$old_library" &&
6518247568Sdes	   { test "$prefer_static_libs" = yes ||
6519247568Sdes	     test "$prefer_static_libs,$installed" = "built,no"; }; then
6520247568Sdes	  linklib=$old_library
6521247568Sdes	else
6522247568Sdes	  for l in $old_library $library_names; do
6523247568Sdes	    linklib="$l"
6524247568Sdes	  done
6525247568Sdes	fi
6526117610Sdes	if test -z "$linklib"; then
6527247568Sdes	  func_fatal_error "cannot find name of link library for \`$lib'"
6528117610Sdes	fi
6529117610Sdes
6530125647Sdes	# This library was specified with -dlopen.
6531141098Sdes	if test "$pass" = dlopen; then
6532125647Sdes	  if test -z "$libdir"; then
6533247568Sdes	    func_fatal_error "cannot -dlopen a convenience library: \`$lib'"
6534125647Sdes	  fi
6535141098Sdes	  if test -z "$dlname" ||
6536141098Sdes	     test "$dlopen_support" != yes ||
6537141098Sdes	     test "$build_libtool_libs" = no; then
6538125647Sdes	    # If there is no dlname, no dlopen support or we're linking
6539141098Sdes	    # statically, we need to preload.  We also need to preload any
6540141098Sdes	    # dependent libraries so libltdl's deplib preloader doesn't
6541141098Sdes	    # bomb out in the load deplibs phase.
6542247568Sdes	    func_append dlprefiles " $lib $dependency_libs"
6543117610Sdes	  else
6544247568Sdes	    func_append newdlfiles " $lib"
6545117610Sdes	  fi
6546125647Sdes	  continue
6547125647Sdes	fi # $pass = dlopen
6548117610Sdes
6549125647Sdes	# We need an absolute path.
6550125647Sdes	case $ladir in
6551125647Sdes	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
6552125647Sdes	*)
6553125647Sdes	  abs_ladir=`cd "$ladir" && pwd`
6554125647Sdes	  if test -z "$abs_ladir"; then
6555247568Sdes	    func_warning "cannot determine absolute directory name of \`$ladir'"
6556247568Sdes	    func_warning "passing it literally to the linker, although it might fail"
6557125647Sdes	    abs_ladir="$ladir"
6558125647Sdes	  fi
6559125647Sdes	  ;;
6560125647Sdes	esac
6561247568Sdes	func_basename "$lib"
6562247568Sdes	laname="$func_basename_result"
6563117610Sdes
6564125647Sdes	# Find the relevant object directory and library name.
6565125647Sdes	if test "X$installed" = Xyes; then
6566247568Sdes	  if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
6567247568Sdes	    func_warning "library \`$lib' was moved."
6568125647Sdes	    dir="$ladir"
6569125647Sdes	    absdir="$abs_ladir"
6570125647Sdes	    libdir="$abs_ladir"
6571117610Sdes	  else
6572247568Sdes	    dir="$lt_sysroot$libdir"
6573247568Sdes	    absdir="$lt_sysroot$libdir"
6574117610Sdes	  fi
6575147455Sdes	  test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
6576125647Sdes	else
6577141098Sdes	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
6578141098Sdes	    dir="$ladir"
6579141098Sdes	    absdir="$abs_ladir"
6580141098Sdes	    # Remove this search path later
6581247568Sdes	    func_append notinst_path " $abs_ladir"
6582141098Sdes	  else
6583141098Sdes	    dir="$ladir/$objdir"
6584141098Sdes	    absdir="$abs_ladir/$objdir"
6585141098Sdes	    # Remove this search path later
6586247568Sdes	    func_append notinst_path " $abs_ladir"
6587141098Sdes	  fi
6588125647Sdes	fi # $installed = yes
6589247568Sdes	func_stripname 'lib' '.la' "$laname"
6590247568Sdes	name=$func_stripname_result
6591117610Sdes
6592125647Sdes	# This library was specified with -dlpreopen.
6593141098Sdes	if test "$pass" = dlpreopen; then
6594247568Sdes	  if test -z "$libdir" && test "$linkmode" = prog; then
6595247568Sdes	    func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'"
6596125647Sdes	  fi
6597247568Sdes	  case "$host" in
6598247568Sdes	    # special handling for platforms with PE-DLLs.
6599247568Sdes	    *cygwin* | *mingw* | *cegcc* )
6600247568Sdes	      # Linker will automatically link against shared library if both
6601247568Sdes	      # static and shared are present.  Therefore, ensure we extract
6602247568Sdes	      # symbols from the import library if a shared library is present
6603247568Sdes	      # (otherwise, the dlopen module name will be incorrect).  We do
6604247568Sdes	      # this by putting the import library name into $newdlprefiles.
6605247568Sdes	      # We recover the dlopen module name by 'saving' the la file
6606247568Sdes	      # name in a special purpose variable, and (later) extracting the
6607247568Sdes	      # dlname from the la file.
6608247568Sdes	      if test -n "$dlname"; then
6609247568Sdes	        func_tr_sh "$dir/$linklib"
6610247568Sdes	        eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname"
6611247568Sdes	        func_append newdlprefiles " $dir/$linklib"
6612247568Sdes	      else
6613247568Sdes	        func_append newdlprefiles " $dir/$old_library"
6614247568Sdes	        # Keep a list of preopened convenience libraries to check
6615247568Sdes	        # that they are being used correctly in the link pass.
6616247568Sdes	        test -z "$libdir" && \
6617247568Sdes	          func_append dlpreconveniencelibs " $dir/$old_library"
6618247568Sdes	      fi
6619247568Sdes	    ;;
6620247568Sdes	    * )
6621247568Sdes	      # Prefer using a static library (so that no silly _DYNAMIC symbols
6622247568Sdes	      # are required to link).
6623247568Sdes	      if test -n "$old_library"; then
6624247568Sdes	        func_append newdlprefiles " $dir/$old_library"
6625247568Sdes	        # Keep a list of preopened convenience libraries to check
6626247568Sdes	        # that they are being used correctly in the link pass.
6627247568Sdes	        test -z "$libdir" && \
6628247568Sdes	          func_append dlpreconveniencelibs " $dir/$old_library"
6629247568Sdes	      # Otherwise, use the dlname, so that lt_dlopen finds it.
6630247568Sdes	      elif test -n "$dlname"; then
6631247568Sdes	        func_append newdlprefiles " $dir/$dlname"
6632247568Sdes	      else
6633247568Sdes	        func_append newdlprefiles " $dir/$linklib"
6634247568Sdes	      fi
6635247568Sdes	    ;;
6636247568Sdes	  esac
6637125647Sdes	fi # $pass = dlpreopen
6638125647Sdes
6639125647Sdes	if test -z "$libdir"; then
6640125647Sdes	  # Link the convenience library
6641141098Sdes	  if test "$linkmode" = lib; then
6642125647Sdes	    deplibs="$dir/$old_library $deplibs"
6643125647Sdes	  elif test "$linkmode,$pass" = "prog,link"; then
6644125647Sdes	    compile_deplibs="$dir/$old_library $compile_deplibs"
6645125647Sdes	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
6646125647Sdes	  else
6647141098Sdes	    deplibs="$lib $deplibs" # used for prog,scan pass
6648125647Sdes	  fi
6649125647Sdes	  continue
6650117610Sdes	fi
6651117610Sdes
6652141098Sdes
6653141098Sdes	if test "$linkmode" = prog && test "$pass" != link; then
6654247568Sdes	  func_append newlib_search_path " $ladir"
6655125647Sdes	  deplibs="$lib $deplibs"
6656125647Sdes
6657125647Sdes	  linkalldeplibs=no
6658125647Sdes	  if test "$link_all_deplibs" != no || test -z "$library_names" ||
6659125647Sdes	     test "$build_libtool_libs" = no; then
6660125647Sdes	    linkalldeplibs=yes
6661125647Sdes	  fi
6662125647Sdes
6663125647Sdes	  tmp_libs=
6664125647Sdes	  for deplib in $dependency_libs; do
6665125647Sdes	    case $deplib in
6666247568Sdes	    -L*) func_stripname '-L' '' "$deplib"
6667247568Sdes	         func_resolve_sysroot "$func_stripname_result"
6668247568Sdes	         func_append newlib_search_path " $func_resolve_sysroot_result"
6669247568Sdes		 ;;
6670125647Sdes	    esac
6671125647Sdes	    # Need to link against all dependency_libs?
6672141098Sdes	    if test "$linkalldeplibs" = yes; then
6673125647Sdes	      deplibs="$deplib $deplibs"
6674125647Sdes	    else
6675125647Sdes	      # Need to hardcode shared library paths
6676125647Sdes	      # or/and link against static libraries
6677125647Sdes	      newdependency_libs="$deplib $newdependency_libs"
6678125647Sdes	    fi
6679247568Sdes	    if $opt_preserve_dup_deps ; then
6680125647Sdes	      case "$tmp_libs " in
6681247568Sdes	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
6682125647Sdes	      esac
6683125647Sdes	    fi
6684247568Sdes	    func_append tmp_libs " $deplib"
6685125647Sdes	  done # for deplib
6686125647Sdes	  continue
6687125647Sdes	fi # $linkmode = prog...
6688125647Sdes
6689141098Sdes	if test "$linkmode,$pass" = "prog,link"; then
6690141098Sdes	  if test -n "$library_names" &&
6691174832Sdes	     { { test "$prefer_static_libs" = no ||
6692247568Sdes	         test "$prefer_static_libs,$installed" = "built,yes"; } ||
6693174832Sdes	       test -z "$old_library"; }; then
6694141098Sdes	    # We need to hardcode the library path
6695147455Sdes	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
6696141098Sdes	      # Make sure the rpath contains only unique directories.
6697247568Sdes	      case "$temp_rpath:" in
6698247568Sdes	      *"$absdir:"*) ;;
6699247568Sdes	      *) func_append temp_rpath "$absdir:" ;;
6700141098Sdes	      esac
6701141098Sdes	    fi
6702117610Sdes
6703125647Sdes	    # Hardcode the library path.
6704125647Sdes	    # Skip directories that are in the system default run-time
6705125647Sdes	    # search path.
6706125647Sdes	    case " $sys_lib_dlsearch_path " in
6707117610Sdes	    *" $absdir "*) ;;
6708125647Sdes	    *)
6709125647Sdes	      case "$compile_rpath " in
6710125647Sdes	      *" $absdir "*) ;;
6711247568Sdes	      *) func_append compile_rpath " $absdir" ;;
6712125647Sdes	      esac
6713125647Sdes	      ;;
6714117610Sdes	    esac
6715125647Sdes	    case " $sys_lib_dlsearch_path " in
6716117610Sdes	    *" $libdir "*) ;;
6717125647Sdes	    *)
6718125647Sdes	      case "$finalize_rpath " in
6719125647Sdes	      *" $libdir "*) ;;
6720247568Sdes	      *) func_append finalize_rpath " $libdir" ;;
6721125647Sdes	      esac
6722125647Sdes	      ;;
6723117610Sdes	    esac
6724125647Sdes	  fi # $linkmode,$pass = prog,link...
6725117610Sdes
6726125647Sdes	  if test "$alldeplibs" = yes &&
6727125647Sdes	     { test "$deplibs_check_method" = pass_all ||
6728125647Sdes	       { test "$build_libtool_libs" = yes &&
6729125647Sdes		 test -n "$library_names"; }; }; then
6730125647Sdes	    # We only need to search for static libraries
6731125647Sdes	    continue
6732125647Sdes	  fi
6733141098Sdes	fi
6734125647Sdes
6735141098Sdes	link_static=no # Whether the deplib will be linked statically
6736174832Sdes	use_static_libs=$prefer_static_libs
6737247568Sdes	if test "$use_static_libs" = built && test "$installed" = yes; then
6738174832Sdes	  use_static_libs=no
6739174832Sdes	fi
6740141098Sdes	if test -n "$library_names" &&
6741174832Sdes	   { test "$use_static_libs" = no || test -z "$old_library"; }; then
6742247568Sdes	  case $host in
6743247568Sdes	  *cygwin* | *mingw* | *cegcc*)
6744247568Sdes	      # No point in relinking DLLs because paths are not encoded
6745247568Sdes	      func_append notinst_deplibs " $lib"
6746247568Sdes	      need_relink=no
6747247568Sdes	    ;;
6748247568Sdes	  *)
6749247568Sdes	    if test "$installed" = no; then
6750247568Sdes	      func_append notinst_deplibs " $lib"
6751247568Sdes	      need_relink=yes
6752247568Sdes	    fi
6753247568Sdes	    ;;
6754247568Sdes	  esac
6755141098Sdes	  # This is a shared library
6756125647Sdes
6757247568Sdes	  # Warn about portability, can't link against -module's on some
6758247568Sdes	  # systems (darwin).  Don't bleat about dlopened modules though!
6759247568Sdes	  dlopenmodule=""
6760247568Sdes	  for dlpremoduletest in $dlprefiles; do
6761247568Sdes	    if test "X$dlpremoduletest" = "X$lib"; then
6762247568Sdes	      dlopenmodule="$dlpremoduletest"
6763247568Sdes	      break
6764247568Sdes	    fi
6765247568Sdes	  done
6766247568Sdes	  if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then
6767247568Sdes	    echo
6768141098Sdes	    if test "$linkmode" = prog; then
6769247568Sdes	      $ECHO "*** Warning: Linking the executable $output against the loadable module"
6770141098Sdes	    else
6771247568Sdes	      $ECHO "*** Warning: Linking the shared library $output against the loadable module"
6772141098Sdes	    fi
6773247568Sdes	    $ECHO "*** $linklib is not portable!"
6774141098Sdes	  fi
6775141098Sdes	  if test "$linkmode" = lib &&
6776141098Sdes	     test "$hardcode_into_libs" = yes; then
6777141098Sdes	    # Hardcode the library path.
6778141098Sdes	    # Skip directories that are in the system default run-time
6779141098Sdes	    # search path.
6780141098Sdes	    case " $sys_lib_dlsearch_path " in
6781141098Sdes	    *" $absdir "*) ;;
6782141098Sdes	    *)
6783141098Sdes	      case "$compile_rpath " in
6784141098Sdes	      *" $absdir "*) ;;
6785247568Sdes	      *) func_append compile_rpath " $absdir" ;;
6786141098Sdes	      esac
6787141098Sdes	      ;;
6788141098Sdes	    esac
6789141098Sdes	    case " $sys_lib_dlsearch_path " in
6790141098Sdes	    *" $libdir "*) ;;
6791141098Sdes	    *)
6792141098Sdes	      case "$finalize_rpath " in
6793141098Sdes	      *" $libdir "*) ;;
6794247568Sdes	      *) func_append finalize_rpath " $libdir" ;;
6795141098Sdes	      esac
6796141098Sdes	      ;;
6797141098Sdes	    esac
6798141098Sdes	  fi
6799141098Sdes
6800125647Sdes	  if test -n "$old_archive_from_expsyms_cmds"; then
6801125647Sdes	    # figure out the soname
6802125647Sdes	    set dummy $library_names
6803247568Sdes	    shift
6804247568Sdes	    realname="$1"
6805247568Sdes	    shift
6806247568Sdes	    libname=`eval "\\$ECHO \"$libname_spec\""`
6807125647Sdes	    # use dlname if we got it. it's perfectly good, no?
6808125647Sdes	    if test -n "$dlname"; then
6809125647Sdes	      soname="$dlname"
6810125647Sdes	    elif test -n "$soname_spec"; then
6811125647Sdes	      # bleh windows
6812125647Sdes	      case $host in
6813247568Sdes	      *cygwin* | mingw* | *cegcc*)
6814247568Sdes	        func_arith $current - $age
6815247568Sdes		major=$func_arith_result
6816125647Sdes		versuffix="-$major"
6817117610Sdes		;;
6818117610Sdes	      esac
6819125647Sdes	      eval soname=\"$soname_spec\"
6820125647Sdes	    else
6821125647Sdes	      soname="$realname"
6822125647Sdes	    fi
6823125647Sdes
6824125647Sdes	    # Make a new name for the extract_expsyms_cmds to use
6825125647Sdes	    soroot="$soname"
6826247568Sdes	    func_basename "$soroot"
6827247568Sdes	    soname="$func_basename_result"
6828247568Sdes	    func_stripname 'lib' '.dll' "$soname"
6829247568Sdes	    newlib=libimp-$func_stripname_result.a
6830125647Sdes
6831125647Sdes	    # If the library has no export list, then create one now
6832125647Sdes	    if test -f "$output_objdir/$soname-def"; then :
6833125647Sdes	    else
6834247568Sdes	      func_verbose "extracting exported symbol list from \`$soname'"
6835247568Sdes	      func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
6836125647Sdes	    fi
6837125647Sdes
6838125647Sdes	    # Create $newlib
6839125647Sdes	    if test -f "$output_objdir/$newlib"; then :; else
6840247568Sdes	      func_verbose "generating import library for \`$soname'"
6841247568Sdes	      func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
6842125647Sdes	    fi
6843125647Sdes	    # make sure the library variables are pointing to the new library
6844125647Sdes	    dir=$output_objdir
6845125647Sdes	    linklib=$newlib
6846141098Sdes	  fi # test -n "$old_archive_from_expsyms_cmds"
6847125647Sdes
6848247568Sdes	  if test "$linkmode" = prog || test "$opt_mode" != relink; then
6849125647Sdes	    add_shlibpath=
6850125647Sdes	    add_dir=
6851125647Sdes	    add=
6852125647Sdes	    lib_linked=yes
6853125647Sdes	    case $hardcode_action in
6854125647Sdes	    immediate | unsupported)
6855125647Sdes	      if test "$hardcode_direct" = no; then
6856125647Sdes		add="$dir/$linklib"
6857141098Sdes		case $host in
6858174832Sdes		  *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
6859174832Sdes		  *-*-sysv4*uw2*) add_dir="-L$dir" ;;
6860174832Sdes		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
6861174832Sdes		    *-*-unixware7*) add_dir="-L$dir" ;;
6862141098Sdes		  *-*-darwin* )
6863247568Sdes		    # if the lib is a (non-dlopened) module then we can not
6864247568Sdes		    # link against it, someone is ignoring the earlier warnings
6865174832Sdes		    if /usr/bin/file -L $add 2> /dev/null |
6866247568Sdes			 $GREP ": [^:]* bundle" >/dev/null ; then
6867247568Sdes		      if test "X$dlopenmodule" != "X$lib"; then
6868247568Sdes			$ECHO "*** Warning: lib $linklib is a module, not a shared library"
6869247568Sdes			if test -z "$old_library" ; then
6870247568Sdes			  echo
6871247568Sdes			  echo "*** And there doesn't seem to be a static archive available"
6872247568Sdes			  echo "*** The link will probably fail, sorry"
6873247568Sdes			else
6874247568Sdes			  add="$dir/$old_library"
6875247568Sdes			fi
6876247568Sdes		      elif test -n "$old_library"; then
6877247568Sdes			add="$dir/$old_library"
6878141098Sdes		      fi
6879141098Sdes		    fi
6880141098Sdes		esac
6881125647Sdes	      elif test "$hardcode_minus_L" = no; then
6882125647Sdes		case $host in
6883125647Sdes		*-*-sunos*) add_shlibpath="$dir" ;;
6884125647Sdes		esac
6885125647Sdes		add_dir="-L$dir"
6886125647Sdes		add="-l$name"
6887125647Sdes	      elif test "$hardcode_shlibpath_var" = no; then
6888125647Sdes		add_shlibpath="$dir"
6889125647Sdes		add="-l$name"
6890125647Sdes	      else
6891125647Sdes		lib_linked=no
6892125647Sdes	      fi
6893125647Sdes	      ;;
6894125647Sdes	    relink)
6895247568Sdes	      if test "$hardcode_direct" = yes &&
6896247568Sdes	         test "$hardcode_direct_absolute" = no; then
6897125647Sdes		add="$dir/$linklib"
6898125647Sdes	      elif test "$hardcode_minus_L" = yes; then
6899247568Sdes		add_dir="-L$absdir"
6900141098Sdes		# Try looking first in the location we're being installed to.
6901141098Sdes		if test -n "$inst_prefix_dir"; then
6902174832Sdes		  case $libdir in
6903141098Sdes		    [\\/]*)
6904247568Sdes		      func_append add_dir " -L$inst_prefix_dir$libdir"
6905141098Sdes		      ;;
6906141098Sdes		  esac
6907141098Sdes		fi
6908125647Sdes		add="-l$name"
6909125647Sdes	      elif test "$hardcode_shlibpath_var" = yes; then
6910125647Sdes		add_shlibpath="$dir"
6911125647Sdes		add="-l$name"
6912125647Sdes	      else
6913125647Sdes		lib_linked=no
6914125647Sdes	      fi
6915125647Sdes	      ;;
6916125647Sdes	    *) lib_linked=no ;;
6917125647Sdes	    esac
6918125647Sdes
6919125647Sdes	    if test "$lib_linked" != yes; then
6920247568Sdes	      func_fatal_configuration "unsupported hardcode properties"
6921125647Sdes	    fi
6922125647Sdes
6923125647Sdes	    if test -n "$add_shlibpath"; then
6924125647Sdes	      case :$compile_shlibpath: in
6925125647Sdes	      *":$add_shlibpath:"*) ;;
6926247568Sdes	      *) func_append compile_shlibpath "$add_shlibpath:" ;;
6927117610Sdes	      esac
6928125647Sdes	    fi
6929141098Sdes	    if test "$linkmode" = prog; then
6930125647Sdes	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
6931125647Sdes	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
6932117610Sdes	    else
6933125647Sdes	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
6934125647Sdes	      test -n "$add" && deplibs="$add $deplibs"
6935247568Sdes	      if test "$hardcode_direct" != yes &&
6936247568Sdes		 test "$hardcode_minus_L" != yes &&
6937125647Sdes		 test "$hardcode_shlibpath_var" = yes; then
6938125647Sdes		case :$finalize_shlibpath: in
6939125647Sdes		*":$libdir:"*) ;;
6940247568Sdes		*) func_append finalize_shlibpath "$libdir:" ;;
6941125647Sdes		esac
6942125647Sdes	      fi
6943117610Sdes	    fi
6944125647Sdes	  fi
6945117610Sdes
6946247568Sdes	  if test "$linkmode" = prog || test "$opt_mode" = relink; then
6947125647Sdes	    add_shlibpath=
6948125647Sdes	    add_dir=
6949125647Sdes	    add=
6950125647Sdes	    # Finalize command for both is simple: just hardcode it.
6951247568Sdes	    if test "$hardcode_direct" = yes &&
6952247568Sdes	       test "$hardcode_direct_absolute" = no; then
6953125647Sdes	      add="$libdir/$linklib"
6954117610Sdes	    elif test "$hardcode_minus_L" = yes; then
6955125647Sdes	      add_dir="-L$libdir"
6956125647Sdes	      add="-l$name"
6957117610Sdes	    elif test "$hardcode_shlibpath_var" = yes; then
6958125647Sdes	      case :$finalize_shlibpath: in
6959125647Sdes	      *":$libdir:"*) ;;
6960247568Sdes	      *) func_append finalize_shlibpath "$libdir:" ;;
6961117610Sdes	      esac
6962125647Sdes	      add="-l$name"
6963141098Sdes	    elif test "$hardcode_automatic" = yes; then
6964141098Sdes	      if test -n "$inst_prefix_dir" &&
6965141098Sdes		 test -f "$inst_prefix_dir$libdir/$linklib" ; then
6966247568Sdes		add="$inst_prefix_dir$libdir/$linklib"
6967141098Sdes	      else
6968247568Sdes		add="$libdir/$linklib"
6969141098Sdes	      fi
6970117610Sdes	    else
6971125647Sdes	      # We cannot seem to hardcode it, guess we'll fake it.
6972125647Sdes	      add_dir="-L$libdir"
6973141098Sdes	      # Try looking first in the location we're being installed to.
6974141098Sdes	      if test -n "$inst_prefix_dir"; then
6975174832Sdes		case $libdir in
6976141098Sdes		  [\\/]*)
6977247568Sdes		    func_append add_dir " -L$inst_prefix_dir$libdir"
6978141098Sdes		    ;;
6979141098Sdes		esac
6980141098Sdes	      fi
6981125647Sdes	      add="-l$name"
6982117610Sdes	    fi
6983117610Sdes
6984141098Sdes	    if test "$linkmode" = prog; then
6985125647Sdes	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
6986125647Sdes	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
6987125647Sdes	    else
6988125647Sdes	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
6989125647Sdes	      test -n "$add" && deplibs="$add $deplibs"
6990125647Sdes	    fi
6991117610Sdes	  fi
6992141098Sdes	elif test "$linkmode" = prog; then
6993117610Sdes	  # Here we assume that one of hardcode_direct or hardcode_minus_L
6994117610Sdes	  # is not unsupported.  This is valid on all known static and
6995117610Sdes	  # shared platforms.
6996117610Sdes	  if test "$hardcode_direct" != unsupported; then
6997117610Sdes	    test -n "$old_library" && linklib="$old_library"
6998125647Sdes	    compile_deplibs="$dir/$linklib $compile_deplibs"
6999125647Sdes	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
7000117610Sdes	  else
7001125647Sdes	    compile_deplibs="-l$name -L$dir $compile_deplibs"
7002125647Sdes	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
7003117610Sdes	  fi
7004125647Sdes	elif test "$build_libtool_libs" = yes; then
7005125647Sdes	  # Not a shared library
7006125647Sdes	  if test "$deplibs_check_method" != pass_all; then
7007125647Sdes	    # We're trying link a shared library against a static one
7008125647Sdes	    # but the system doesn't support it.
7009117610Sdes
7010125647Sdes	    # Just print a warning and add the library to dependency_libs so
7011125647Sdes	    # that the program can be linked against the static library.
7012247568Sdes	    echo
7013247568Sdes	    $ECHO "*** Warning: This system can not link to static lib archive $lib."
7014247568Sdes	    echo "*** I have the capability to make that library automatically link in when"
7015247568Sdes	    echo "*** you link to this library.  But I can only do this if you have a"
7016247568Sdes	    echo "*** shared version of the library, which you do not appear to have."
7017125647Sdes	    if test "$module" = yes; then
7018247568Sdes	      echo "*** But as you try to build a module library, libtool will still create "
7019247568Sdes	      echo "*** a static module, that should work as long as the dlopening application"
7020247568Sdes	      echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
7021125647Sdes	      if test -z "$global_symbol_pipe"; then
7022247568Sdes		echo
7023247568Sdes		echo "*** However, this would only work if libtool was able to extract symbol"
7024247568Sdes		echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
7025247568Sdes		echo "*** not find such a program.  So, this module is probably useless."
7026247568Sdes		echo "*** \`nm' from GNU binutils and a full rebuild may help."
7027125647Sdes	      fi
7028125647Sdes	      if test "$build_old_libs" = no; then
7029125647Sdes		build_libtool_libs=module
7030125647Sdes		build_old_libs=yes
7031125647Sdes	      else
7032125647Sdes		build_libtool_libs=no
7033125647Sdes	      fi
7034125647Sdes	    fi
7035125647Sdes	  else
7036125647Sdes	    deplibs="$dir/$old_library $deplibs"
7037125647Sdes	    link_static=yes
7038125647Sdes	  fi
7039125647Sdes	fi # link shared/static library?
7040117610Sdes
7041141098Sdes	if test "$linkmode" = lib; then
7042125647Sdes	  if test -n "$dependency_libs" &&
7043141098Sdes	     { test "$hardcode_into_libs" != yes ||
7044141098Sdes	       test "$build_old_libs" = yes ||
7045141098Sdes	       test "$link_static" = yes; }; then
7046125647Sdes	    # Extract -R from dependency_libs
7047125647Sdes	    temp_deplibs=
7048125647Sdes	    for libdir in $dependency_libs; do
7049125647Sdes	      case $libdir in
7050247568Sdes	      -R*) func_stripname '-R' '' "$libdir"
7051247568Sdes	           temp_xrpath=$func_stripname_result
7052125647Sdes		   case " $xrpath " in
7053125647Sdes		   *" $temp_xrpath "*) ;;
7054247568Sdes		   *) func_append xrpath " $temp_xrpath";;
7055125647Sdes		   esac;;
7056247568Sdes	      *) func_append temp_deplibs " $libdir";;
7057125647Sdes	      esac
7058125647Sdes	    done
7059125647Sdes	    dependency_libs="$temp_deplibs"
7060125647Sdes	  fi
7061117610Sdes
7062247568Sdes	  func_append newlib_search_path " $absdir"
7063125647Sdes	  # Link against this library
7064125647Sdes	  test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
7065125647Sdes	  # ... and its dependency_libs
7066125647Sdes	  tmp_libs=
7067125647Sdes	  for deplib in $dependency_libs; do
7068125647Sdes	    newdependency_libs="$deplib $newdependency_libs"
7069247568Sdes	    case $deplib in
7070247568Sdes              -L*) func_stripname '-L' '' "$deplib"
7071247568Sdes                   func_resolve_sysroot "$func_stripname_result";;
7072247568Sdes              *) func_resolve_sysroot "$deplib" ;;
7073247568Sdes            esac
7074247568Sdes	    if $opt_preserve_dup_deps ; then
7075125647Sdes	      case "$tmp_libs " in
7076247568Sdes	      *" $func_resolve_sysroot_result "*)
7077247568Sdes                func_append specialdeplibs " $func_resolve_sysroot_result" ;;
7078125647Sdes	      esac
7079125647Sdes	    fi
7080247568Sdes	    func_append tmp_libs " $func_resolve_sysroot_result"
7081125647Sdes	  done
7082117610Sdes
7083141098Sdes	  if test "$link_all_deplibs" != no; then
7084125647Sdes	    # Add the search paths of all dependency libraries
7085125647Sdes	    for deplib in $dependency_libs; do
7086247568Sdes	      path=
7087125647Sdes	      case $deplib in
7088125647Sdes	      -L*) path="$deplib" ;;
7089125647Sdes	      *.la)
7090247568Sdes	        func_resolve_sysroot "$deplib"
7091247568Sdes	        deplib=$func_resolve_sysroot_result
7092247568Sdes	        func_dirname "$deplib" "" "."
7093247568Sdes		dir=$func_dirname_result
7094125647Sdes		# We need an absolute path.
7095125647Sdes		case $dir in
7096125647Sdes		[\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
7097125647Sdes		*)
7098125647Sdes		  absdir=`cd "$dir" && pwd`
7099125647Sdes		  if test -z "$absdir"; then
7100247568Sdes		    func_warning "cannot determine absolute directory name of \`$dir'"
7101125647Sdes		    absdir="$dir"
7102125647Sdes		  fi
7103125647Sdes		  ;;
7104125647Sdes		esac
7105247568Sdes		if $GREP "^installed=no" $deplib > /dev/null; then
7106141098Sdes		case $host in
7107141098Sdes		*-*-darwin*)
7108247568Sdes		  depdepl=
7109141098Sdes		  eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
7110141098Sdes		  if test -n "$deplibrary_names" ; then
7111141098Sdes		    for tmp in $deplibrary_names ; do
7112141098Sdes		      depdepl=$tmp
7113141098Sdes		    done
7114247568Sdes		    if test -f "$absdir/$objdir/$depdepl" ; then
7115247568Sdes		      depdepl="$absdir/$objdir/$depdepl"
7116247568Sdes		      darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
7117247568Sdes                      if test -z "$darwin_install_name"; then
7118247568Sdes                          darwin_install_name=`${OTOOL64} -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
7119247568Sdes                      fi
7120247568Sdes		      func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}"
7121247568Sdes		      func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}"
7122247568Sdes		      path=
7123141098Sdes		    fi
7124141098Sdes		  fi
7125141098Sdes		  ;;
7126141098Sdes		*)
7127247568Sdes		  path="-L$absdir/$objdir"
7128141098Sdes		  ;;
7129141098Sdes		esac
7130247568Sdes		else
7131247568Sdes		  eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
7132247568Sdes		  test -z "$libdir" && \
7133247568Sdes		    func_fatal_error "\`$deplib' is not a valid libtool archive"
7134247568Sdes		  test "$absdir" != "$libdir" && \
7135247568Sdes		    func_warning "\`$deplib' seems to be moved"
7136247568Sdes
7137247568Sdes		  path="-L$absdir"
7138247568Sdes		fi
7139125647Sdes		;;
7140125647Sdes	      esac
7141125647Sdes	      case " $deplibs " in
7142174832Sdes	      *" $path "*) ;;
7143174832Sdes	      *) deplibs="$path $deplibs" ;;
7144174832Sdes	      esac
7145125647Sdes	    done
7146125647Sdes	  fi # link_all_deplibs != no
7147125647Sdes	fi # linkmode = lib
7148125647Sdes      done # for deplib in $libs
7149247568Sdes      if test "$pass" = link; then
7150247568Sdes	if test "$linkmode" = "prog"; then
7151247568Sdes	  compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
7152247568Sdes	  finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
7153247568Sdes	else
7154247568Sdes	  compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
7155247568Sdes	fi
7156247568Sdes      fi
7157141098Sdes      dependency_libs="$newdependency_libs"
7158141098Sdes      if test "$pass" = dlpreopen; then
7159125647Sdes	# Link the dlpreopened libraries before other libraries
7160125647Sdes	for deplib in $save_deplibs; do
7161125647Sdes	  deplibs="$deplib $deplibs"
7162125647Sdes	done
7163117610Sdes      fi
7164141098Sdes      if test "$pass" != dlopen; then
7165141098Sdes	if test "$pass" != conv; then
7166125647Sdes	  # Make sure lib_search_path contains only unique directories.
7167125647Sdes	  lib_search_path=
7168125647Sdes	  for dir in $newlib_search_path; do
7169125647Sdes	    case "$lib_search_path " in
7170125647Sdes	    *" $dir "*) ;;
7171247568Sdes	    *) func_append lib_search_path " $dir" ;;
7172125647Sdes	    esac
7173125647Sdes	  done
7174125647Sdes	  newlib_search_path=
7175125647Sdes	fi
7176117610Sdes
7177125647Sdes	if test "$linkmode,$pass" != "prog,link"; then
7178125647Sdes	  vars="deplibs"
7179125647Sdes	else
7180125647Sdes	  vars="compile_deplibs finalize_deplibs"
7181125647Sdes	fi
7182125647Sdes	for var in $vars dependency_libs; do
7183125647Sdes	  # Add libraries to $var in reverse order
7184125647Sdes	  eval tmp_libs=\"\$$var\"
7185125647Sdes	  new_libs=
7186125647Sdes	  for deplib in $tmp_libs; do
7187141098Sdes	    # FIXME: Pedantically, this is the right thing to do, so
7188141098Sdes	    #        that some nasty dependency loop isn't accidentally
7189141098Sdes	    #        broken:
7190141098Sdes	    #new_libs="$deplib $new_libs"
7191141098Sdes	    # Pragmatically, this seems to cause very few problems in
7192141098Sdes	    # practice:
7193125647Sdes	    case $deplib in
7194125647Sdes	    -L*) new_libs="$deplib $new_libs" ;;
7195141098Sdes	    -R*) ;;
7196125647Sdes	    *)
7197141098Sdes	      # And here is the reason: when a library appears more
7198141098Sdes	      # than once as an explicit dependence of a library, or
7199141098Sdes	      # is implicitly linked in more than once by the
7200141098Sdes	      # compiler, it is considered special, and multiple
7201141098Sdes	      # occurrences thereof are not removed.  Compare this
7202141098Sdes	      # with having the same library being listed as a
7203141098Sdes	      # dependency of multiple other libraries: in this case,
7204141098Sdes	      # we know (pedantically, we assume) the library does not
7205141098Sdes	      # need to be listed more than once, so we keep only the
7206141098Sdes	      # last copy.  This is not always right, but it is rare
7207141098Sdes	      # enough that we require users that really mean to play
7208141098Sdes	      # such unportable linking tricks to link the library
7209141098Sdes	      # using -Wl,-lname, so that libtool does not consider it
7210141098Sdes	      # for duplicate removal.
7211125647Sdes	      case " $specialdeplibs " in
7212125647Sdes	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
7213125647Sdes	      *)
7214125647Sdes		case " $new_libs " in
7215125647Sdes		*" $deplib "*) ;;
7216125647Sdes		*) new_libs="$deplib $new_libs" ;;
7217125647Sdes		esac
7218125647Sdes		;;
7219125647Sdes	      esac
7220125647Sdes	      ;;
7221125647Sdes	    esac
7222125647Sdes	  done
7223125647Sdes	  tmp_libs=
7224125647Sdes	  for deplib in $new_libs; do
7225125647Sdes	    case $deplib in
7226125647Sdes	    -L*)
7227125647Sdes	      case " $tmp_libs " in
7228125647Sdes	      *" $deplib "*) ;;
7229247568Sdes	      *) func_append tmp_libs " $deplib" ;;
7230125647Sdes	      esac
7231125647Sdes	      ;;
7232247568Sdes	    *) func_append tmp_libs " $deplib" ;;
7233125647Sdes	    esac
7234125647Sdes	  done
7235125647Sdes	  eval $var=\"$tmp_libs\"
7236125647Sdes	done # for var
7237117610Sdes      fi
7238141098Sdes      # Last step: remove runtime libs from dependency_libs
7239141098Sdes      # (they stay in deplibs)
7240141098Sdes      tmp_libs=
7241141098Sdes      for i in $dependency_libs ; do
7242141098Sdes	case " $predeps $postdeps $compiler_lib_search_path " in
7243141098Sdes	*" $i "*)
7244141098Sdes	  i=""
7245141098Sdes	  ;;
7246141098Sdes	esac
7247141098Sdes	if test -n "$i" ; then
7248247568Sdes	  func_append tmp_libs " $i"
7249141098Sdes	fi
7250141098Sdes      done
7251141098Sdes      dependency_libs=$tmp_libs
7252125647Sdes    done # for pass
7253141098Sdes    if test "$linkmode" = prog; then
7254125647Sdes      dlfiles="$newdlfiles"
7255247568Sdes    fi
7256247568Sdes    if test "$linkmode" = prog || test "$linkmode" = lib; then
7257125647Sdes      dlprefiles="$newdlprefiles"
7258125647Sdes    fi
7259117610Sdes
7260125647Sdes    case $linkmode in
7261125647Sdes    oldlib)
7262117610Sdes      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
7263247568Sdes	func_warning "\`-dlopen' is ignored for archives"
7264117610Sdes      fi
7265117610Sdes
7266247568Sdes      case " $deplibs" in
7267247568Sdes      *\ -l* | *\ -L*)
7268247568Sdes	func_warning "\`-l' and \`-L' are ignored for archives" ;;
7269247568Sdes      esac
7270117610Sdes
7271247568Sdes      test -n "$rpath" && \
7272247568Sdes	func_warning "\`-rpath' is ignored for archives"
7273117610Sdes
7274247568Sdes      test -n "$xrpath" && \
7275247568Sdes	func_warning "\`-R' is ignored for archives"
7276117610Sdes
7277247568Sdes      test -n "$vinfo" && \
7278247568Sdes	func_warning "\`-version-info/-version-number' is ignored for archives"
7279117610Sdes
7280247568Sdes      test -n "$release" && \
7281247568Sdes	func_warning "\`-release' is ignored for archives"
7282117610Sdes
7283247568Sdes      test -n "$export_symbols$export_symbols_regex" && \
7284247568Sdes	func_warning "\`-export-symbols' is ignored for archives"
7285247568Sdes
7286117610Sdes      # Now set the variables for building old libraries.
7287117610Sdes      build_libtool_libs=no
7288117610Sdes      oldlibs="$output"
7289247568Sdes      func_append objs "$old_deplibs"
7290117610Sdes      ;;
7291117610Sdes
7292125647Sdes    lib)
7293117610Sdes      # Make sure we only generate libraries of the form `libNAME.la'.
7294125647Sdes      case $outputname in
7295117610Sdes      lib*)
7296247568Sdes	func_stripname 'lib' '.la' "$outputname"
7297247568Sdes	name=$func_stripname_result
7298141098Sdes	eval shared_ext=\"$shrext_cmds\"
7299117610Sdes	eval libname=\"$libname_spec\"
7300117610Sdes	;;
7301117610Sdes      *)
7302247568Sdes	test "$module" = no && \
7303247568Sdes	  func_fatal_help "libtool library \`$output' must begin with \`lib'"
7304247568Sdes
7305117610Sdes	if test "$need_lib_prefix" != no; then
7306117610Sdes	  # Add the "lib" prefix for modules if required
7307247568Sdes	  func_stripname '' '.la' "$outputname"
7308247568Sdes	  name=$func_stripname_result
7309141098Sdes	  eval shared_ext=\"$shrext_cmds\"
7310117610Sdes	  eval libname=\"$libname_spec\"
7311117610Sdes	else
7312247568Sdes	  func_stripname '' '.la' "$outputname"
7313247568Sdes	  libname=$func_stripname_result
7314117610Sdes	fi
7315117610Sdes	;;
7316117610Sdes      esac
7317117610Sdes
7318117610Sdes      if test -n "$objs"; then
7319125647Sdes	if test "$deplibs_check_method" != pass_all; then
7320247568Sdes	  func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs"
7321125647Sdes	else
7322247568Sdes	  echo
7323247568Sdes	  $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
7324247568Sdes	  $ECHO "*** objects $objs is not portable!"
7325247568Sdes	  func_append libobjs " $objs"
7326125647Sdes	fi
7327117610Sdes      fi
7328117610Sdes
7329247568Sdes      test "$dlself" != no && \
7330247568Sdes	func_warning "\`-dlopen self' is ignored for libtool libraries"
7331117610Sdes
7332117610Sdes      set dummy $rpath
7333247568Sdes      shift
7334247568Sdes      test "$#" -gt 1 && \
7335247568Sdes	func_warning "ignoring multiple \`-rpath's for a libtool library"
7336117610Sdes
7337247568Sdes      install_libdir="$1"
7338247568Sdes
7339117610Sdes      oldlibs=
7340117610Sdes      if test -z "$rpath"; then
7341117610Sdes	if test "$build_libtool_libs" = yes; then
7342117610Sdes	  # Building a libtool convenience library.
7343141098Sdes	  # Some compilers have problems with a `.al' extension so
7344141098Sdes	  # convenience libraries should have the same extension an
7345141098Sdes	  # archive normally would.
7346117610Sdes	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
7347117610Sdes	  build_libtool_libs=convenience
7348117610Sdes	  build_old_libs=yes
7349117610Sdes	fi
7350117610Sdes
7351247568Sdes	test -n "$vinfo" && \
7352247568Sdes	  func_warning "\`-version-info/-version-number' is ignored for convenience libraries"
7353117610Sdes
7354247568Sdes	test -n "$release" && \
7355247568Sdes	  func_warning "\`-release' is ignored for convenience libraries"
7356117610Sdes      else
7357117610Sdes
7358117610Sdes	# Parse the version information argument.
7359125647Sdes	save_ifs="$IFS"; IFS=':'
7360117610Sdes	set dummy $vinfo 0 0 0
7361247568Sdes	shift
7362117610Sdes	IFS="$save_ifs"
7363117610Sdes
7364247568Sdes	test -n "$7" && \
7365247568Sdes	  func_fatal_help "too many parameters to \`-version-info'"
7366117610Sdes
7367141098Sdes	# convert absolute version numbers to libtool ages
7368141098Sdes	# this retains compatibility with .la files and attempts
7369141098Sdes	# to make the code below a bit more comprehensible
7370117610Sdes
7371141098Sdes	case $vinfo_number in
7372141098Sdes	yes)
7373247568Sdes	  number_major="$1"
7374247568Sdes	  number_minor="$2"
7375247568Sdes	  number_revision="$3"
7376141098Sdes	  #
7377141098Sdes	  # There are really only two kinds -- those that
7378141098Sdes	  # use the current revision as the major version
7379141098Sdes	  # and those that subtract age and use age as
7380141098Sdes	  # a minor version.  But, then there is irix
7381141098Sdes	  # which has an extra 1 added just for fun
7382141098Sdes	  #
7383141098Sdes	  case $version_type in
7384247568Sdes	  # correct linux to gnu/linux during the next big refactor
7385174832Sdes	  darwin|linux|osf|windows|none)
7386247568Sdes	    func_arith $number_major + $number_minor
7387247568Sdes	    current=$func_arith_result
7388141098Sdes	    age="$number_minor"
7389141098Sdes	    revision="$number_revision"
7390141098Sdes	    ;;
7391247568Sdes	  freebsd-aout|freebsd-elf|qnx|sunos)
7392141098Sdes	    current="$number_major"
7393141098Sdes	    revision="$number_minor"
7394141098Sdes	    age="0"
7395141098Sdes	    ;;
7396141098Sdes	  irix|nonstopux)
7397247568Sdes	    func_arith $number_major + $number_minor
7398247568Sdes	    current=$func_arith_result
7399141098Sdes	    age="$number_minor"
7400141098Sdes	    revision="$number_minor"
7401174832Sdes	    lt_irix_increment=no
7402141098Sdes	    ;;
7403141098Sdes	  esac
7404141098Sdes	  ;;
7405141098Sdes	no)
7406247568Sdes	  current="$1"
7407247568Sdes	  revision="$2"
7408247568Sdes	  age="$3"
7409141098Sdes	  ;;
7410141098Sdes	esac
7411141098Sdes
7412117610Sdes	# Check that each of the things are valid numbers.
7413125647Sdes	case $current in
7414147455Sdes	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]) ;;
7415117610Sdes	*)
7416247568Sdes	  func_error "CURRENT \`$current' must be a nonnegative integer"
7417247568Sdes	  func_fatal_error "\`$vinfo' is not valid version information"
7418117610Sdes	  ;;
7419117610Sdes	esac
7420117610Sdes
7421125647Sdes	case $revision in
7422147455Sdes	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]) ;;
7423117610Sdes	*)
7424247568Sdes	  func_error "REVISION \`$revision' must be a nonnegative integer"
7425247568Sdes	  func_fatal_error "\`$vinfo' is not valid version information"
7426117610Sdes	  ;;
7427117610Sdes	esac
7428117610Sdes
7429125647Sdes	case $age in
7430147455Sdes	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]) ;;
7431117610Sdes	*)
7432247568Sdes	  func_error "AGE \`$age' must be a nonnegative integer"
7433247568Sdes	  func_fatal_error "\`$vinfo' is not valid version information"
7434117610Sdes	  ;;
7435117610Sdes	esac
7436117610Sdes
7437141098Sdes	if test "$age" -gt "$current"; then
7438247568Sdes	  func_error "AGE \`$age' is greater than the current interface number \`$current'"
7439247568Sdes	  func_fatal_error "\`$vinfo' is not valid version information"
7440117610Sdes	fi
7441117610Sdes
7442117610Sdes	# Calculate the version variables.
7443117610Sdes	major=
7444117610Sdes	versuffix=
7445117610Sdes	verstring=
7446125647Sdes	case $version_type in
7447117610Sdes	none) ;;
7448117610Sdes
7449125647Sdes	darwin)
7450125647Sdes	  # Like Linux, but with the current version available in
7451125647Sdes	  # verstring for coding it into the library header
7452247568Sdes	  func_arith $current - $age
7453247568Sdes	  major=.$func_arith_result
7454125647Sdes	  versuffix="$major.$age.$revision"
7455125647Sdes	  # Darwin ld doesn't like 0 for these options...
7456247568Sdes	  func_arith $current + 1
7457247568Sdes	  minor_current=$func_arith_result
7458174832Sdes	  xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
7459174832Sdes	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
7460125647Sdes	  ;;
7461125647Sdes
7462125647Sdes	freebsd-aout)
7463125647Sdes	  major=".$current"
7464125647Sdes	  versuffix=".$current.$revision";
7465125647Sdes	  ;;
7466125647Sdes
7467125647Sdes	freebsd-elf)
7468125647Sdes	  major=".$current"
7469247568Sdes	  versuffix=".$current"
7470125647Sdes	  ;;
7471125647Sdes
7472125647Sdes	irix | nonstopux)
7473174832Sdes	  if test "X$lt_irix_increment" = "Xno"; then
7474247568Sdes	    func_arith $current - $age
7475174832Sdes	  else
7476247568Sdes	    func_arith $current - $age + 1
7477174832Sdes	  fi
7478247568Sdes	  major=$func_arith_result
7479247568Sdes
7480125647Sdes	  case $version_type in
7481125647Sdes	    nonstopux) verstring_prefix=nonstopux ;;
7482125647Sdes	    *)         verstring_prefix=sgi ;;
7483125647Sdes	  esac
7484125647Sdes	  verstring="$verstring_prefix$major.$revision"
7485125647Sdes
7486117610Sdes	  # Add in all the interfaces that we are compatible with.
7487117610Sdes	  loop=$revision
7488141098Sdes	  while test "$loop" -ne 0; do
7489247568Sdes	    func_arith $revision - $loop
7490247568Sdes	    iface=$func_arith_result
7491247568Sdes	    func_arith $loop - 1
7492247568Sdes	    loop=$func_arith_result
7493125647Sdes	    verstring="$verstring_prefix$major.$iface:$verstring"
7494117610Sdes	  done
7495125647Sdes
7496125647Sdes	  # Before this point, $major must not contain `.'.
7497125647Sdes	  major=.$major
7498125647Sdes	  versuffix="$major.$revision"
7499117610Sdes	  ;;
7500117610Sdes
7501247568Sdes	linux) # correct to gnu/linux during the next big refactor
7502247568Sdes	  func_arith $current - $age
7503247568Sdes	  major=.$func_arith_result
7504117610Sdes	  versuffix="$major.$age.$revision"
7505117610Sdes	  ;;
7506117610Sdes
7507117610Sdes	osf)
7508247568Sdes	  func_arith $current - $age
7509247568Sdes	  major=.$func_arith_result
7510117610Sdes	  versuffix=".$current.$age.$revision"
7511117610Sdes	  verstring="$current.$age.$revision"
7512117610Sdes
7513117610Sdes	  # Add in all the interfaces that we are compatible with.
7514117610Sdes	  loop=$age
7515141098Sdes	  while test "$loop" -ne 0; do
7516247568Sdes	    func_arith $current - $loop
7517247568Sdes	    iface=$func_arith_result
7518247568Sdes	    func_arith $loop - 1
7519247568Sdes	    loop=$func_arith_result
7520117610Sdes	    verstring="$verstring:${iface}.0"
7521117610Sdes	  done
7522117610Sdes
7523117610Sdes	  # Make executables depend on our current version.
7524247568Sdes	  func_append verstring ":${current}.0"
7525117610Sdes	  ;;
7526117610Sdes
7527247568Sdes	qnx)
7528247568Sdes	  major=".$current"
7529247568Sdes	  versuffix=".$current"
7530247568Sdes	  ;;
7531247568Sdes
7532117610Sdes	sunos)
7533117610Sdes	  major=".$current"
7534117610Sdes	  versuffix=".$current.$revision"
7535117610Sdes	  ;;
7536117610Sdes
7537117610Sdes	windows)
7538125647Sdes	  # Use '-' rather than '.', since we only want one
7539125647Sdes	  # extension on DOS 8.3 filesystems.
7540247568Sdes	  func_arith $current - $age
7541247568Sdes	  major=$func_arith_result
7542125647Sdes	  versuffix="-$major"
7543117610Sdes	  ;;
7544117610Sdes
7545117610Sdes	*)
7546247568Sdes	  func_fatal_configuration "unknown library version type \`$version_type'"
7547117610Sdes	  ;;
7548117610Sdes	esac
7549117610Sdes
7550117610Sdes	# Clear the version info if we defaulted, and they specified a release.
7551117610Sdes	if test -z "$vinfo" && test -n "$release"; then
7552117610Sdes	  major=
7553125647Sdes	  case $version_type in
7554125647Sdes	  darwin)
7555125647Sdes	    # we can't check for "0.0" in archive_cmds due to quoting
7556125647Sdes	    # problems, so we reset it completely
7557141098Sdes	    verstring=
7558125647Sdes	    ;;
7559125647Sdes	  *)
7560125647Sdes	    verstring="0.0"
7561125647Sdes	    ;;
7562125647Sdes	  esac
7563117610Sdes	  if test "$need_version" = no; then
7564117610Sdes	    versuffix=
7565117610Sdes	  else
7566117610Sdes	    versuffix=".0.0"
7567117610Sdes	  fi
7568117610Sdes	fi
7569117610Sdes
7570117610Sdes	# Remove version info from name if versioning should be avoided
7571117610Sdes	if test "$avoid_version" = yes && test "$need_version" = no; then
7572117610Sdes	  major=
7573117610Sdes	  versuffix=
7574117610Sdes	  verstring=""
7575117610Sdes	fi
7576125647Sdes
7577117610Sdes	# Check to see if the archive will have undefined symbols.
7578117610Sdes	if test "$allow_undefined" = yes; then
7579117610Sdes	  if test "$allow_undefined_flag" = unsupported; then
7580247568Sdes	    func_warning "undefined symbols not allowed in $host shared libraries"
7581117610Sdes	    build_libtool_libs=no
7582117610Sdes	    build_old_libs=yes
7583117610Sdes	  fi
7584117610Sdes	else
7585117610Sdes	  # Don't allow undefined symbols.
7586117610Sdes	  allow_undefined_flag="$no_undefined_flag"
7587117610Sdes	fi
7588247568Sdes
7589125647Sdes      fi
7590117610Sdes
7591247568Sdes      func_generate_dlsyms "$libname" "$libname" "yes"
7592247568Sdes      func_append libobjs " $symfileobj"
7593247568Sdes      test "X$libobjs" = "X " && libobjs=
7594247568Sdes
7595247568Sdes      if test "$opt_mode" != relink; then
7596141098Sdes	# Remove our outputs, but don't remove object files since they
7597141098Sdes	# may have been created when compiling PIC objects.
7598141098Sdes	removelist=
7599247568Sdes	tempremovelist=`$ECHO "$output_objdir/*"`
7600141098Sdes	for p in $tempremovelist; do
7601141098Sdes	  case $p in
7602247568Sdes	    *.$objext | *.gcno)
7603141098Sdes	       ;;
7604141098Sdes	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
7605141098Sdes	       if test "X$precious_files_regex" != "X"; then
7606247568Sdes		 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
7607247568Sdes		 then
7608141098Sdes		   continue
7609141098Sdes		 fi
7610141098Sdes	       fi
7611247568Sdes	       func_append removelist " $p"
7612141098Sdes	       ;;
7613141098Sdes	    *) ;;
7614141098Sdes	  esac
7615141098Sdes	done
7616247568Sdes	test -n "$removelist" && \
7617247568Sdes	  func_show_eval "${RM}r \$removelist"
7618117610Sdes      fi
7619117610Sdes
7620125647Sdes      # Now set the variables for building old libraries.
7621125647Sdes      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
7622247568Sdes	func_append oldlibs " $output_objdir/$libname.$libext"
7623125647Sdes
7624125647Sdes	# Transform .lo files to .o files.
7625247568Sdes	oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP`
7626125647Sdes      fi
7627125647Sdes
7628125647Sdes      # Eliminate all temporary directories.
7629174832Sdes      #for path in $notinst_path; do
7630247568Sdes      #	lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
7631247568Sdes      #	deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
7632247568Sdes      #	dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
7633174832Sdes      #done
7634125647Sdes
7635125647Sdes      if test -n "$xrpath"; then
7636117610Sdes	# If the user specified any rpath flags, then add them.
7637125647Sdes	temp_xrpath=
7638125647Sdes	for libdir in $xrpath; do
7639247568Sdes	  func_replace_sysroot "$libdir"
7640247568Sdes	  func_append temp_xrpath " -R$func_replace_sysroot_result"
7641117610Sdes	  case "$finalize_rpath " in
7642117610Sdes	  *" $libdir "*) ;;
7643247568Sdes	  *) func_append finalize_rpath " $libdir" ;;
7644117610Sdes	  esac
7645117610Sdes	done
7646141098Sdes	if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
7647125647Sdes	  dependency_libs="$temp_xrpath $dependency_libs"
7648125647Sdes	fi
7649117610Sdes      fi
7650117610Sdes
7651125647Sdes      # Make sure dlfiles contains only unique files that won't be dlpreopened
7652125647Sdes      old_dlfiles="$dlfiles"
7653125647Sdes      dlfiles=
7654125647Sdes      for lib in $old_dlfiles; do
7655125647Sdes	case " $dlprefiles $dlfiles " in
7656125647Sdes	*" $lib "*) ;;
7657247568Sdes	*) func_append dlfiles " $lib" ;;
7658125647Sdes	esac
7659117610Sdes      done
7660117610Sdes
7661125647Sdes      # Make sure dlprefiles contains only unique files
7662125647Sdes      old_dlprefiles="$dlprefiles"
7663125647Sdes      dlprefiles=
7664125647Sdes      for lib in $old_dlprefiles; do
7665125647Sdes	case "$dlprefiles " in
7666125647Sdes	*" $lib "*) ;;
7667247568Sdes	*) func_append dlprefiles " $lib" ;;
7668125647Sdes	esac
7669125647Sdes      done
7670125647Sdes
7671125647Sdes      if test "$build_libtool_libs" = yes; then
7672125647Sdes	if test -n "$rpath"; then
7673125647Sdes	  case $host in
7674247568Sdes	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
7675125647Sdes	    # these systems don't actually have a c library (as such)!
7676125647Sdes	    ;;
7677125647Sdes	  *-*-rhapsody* | *-*-darwin1.[012])
7678125647Sdes	    # Rhapsody C library is in the System framework
7679247568Sdes	    func_append deplibs " System.ltframework"
7680125647Sdes	    ;;
7681125647Sdes	  *-*-netbsd*)
7682125647Sdes	    # Don't link with libc until the a.out ld.so is fixed.
7683125647Sdes	    ;;
7684147455Sdes	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
7685125647Sdes	    # Do not include libc due to us having libc/libc_r.
7686125647Sdes	    ;;
7687174832Sdes	  *-*-sco3.2v5* | *-*-sco5v6*)
7688174832Sdes	    # Causes problems with __ctype
7689174832Sdes	    ;;
7690174832Sdes	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
7691174832Sdes	    # Compiler inserts libc in the correct place for threads to work
7692174832Sdes	    ;;
7693247568Sdes	  *)
7694125647Sdes	    # Add libc to deplibs on all other systems if necessary.
7695141098Sdes	    if test "$build_libtool_need_lc" = "yes"; then
7696247568Sdes	      func_append deplibs " -lc"
7697117610Sdes	    fi
7698125647Sdes	    ;;
7699117610Sdes	  esac
7700117610Sdes	fi
7701117610Sdes
7702117610Sdes	# Transform deplibs into only deplibs that can be linked in shared.
7703117610Sdes	name_save=$name
7704117610Sdes	libname_save=$libname
7705117610Sdes	release_save=$release
7706117610Sdes	versuffix_save=$versuffix
7707117610Sdes	major_save=$major
7708117610Sdes	# I'm not sure if I'm treating the release correctly.  I think
7709117610Sdes	# release should show up in the -l (ie -lgmp5) so we don't want to
7710117610Sdes	# add it in twice.  Is that correct?
7711117610Sdes	release=""
7712117610Sdes	versuffix=""
7713117610Sdes	major=""
7714117610Sdes	newdeplibs=
7715117610Sdes	droppeddeps=no
7716125647Sdes	case $deplibs_check_method in
7717117610Sdes	pass_all)
7718117610Sdes	  # Don't check for shared/static.  Everything works.
7719117610Sdes	  # This might be a little naive.  We might want to check
7720117610Sdes	  # whether the library exists or not.  But this is on
7721117610Sdes	  # osf3 & osf4 and I'm not really sure... Just
7722141098Sdes	  # implementing what was already the behavior.
7723117610Sdes	  newdeplibs=$deplibs
7724117610Sdes	  ;;
7725117610Sdes	test_compile)
7726117610Sdes	  # This code stresses the "libraries are programs" paradigm to its
7727117610Sdes	  # limits. Maybe even breaks it.  We compile a program, linking it
7728117610Sdes	  # against the deplibs as a proxy for the library.  Then we can check
7729117610Sdes	  # whether they linked in statically or dynamically with ldd.
7730247568Sdes	  $opt_dry_run || $RM conftest.c
7731117610Sdes	  cat > conftest.c <<EOF
7732117610Sdes	  int main() { return 0; }
7733117610SdesEOF
7734247568Sdes	  $opt_dry_run || $RM conftest
7735174832Sdes	  if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
7736117610Sdes	    ldd_output=`ldd conftest`
7737117610Sdes	    for i in $deplibs; do
7738247568Sdes	      case $i in
7739247568Sdes	      -l*)
7740247568Sdes		func_stripname -l '' "$i"
7741247568Sdes		name=$func_stripname_result
7742141098Sdes		if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7743141098Sdes		  case " $predeps $postdeps " in
7744141098Sdes		  *" $i "*)
7745247568Sdes		    func_append newdeplibs " $i"
7746141098Sdes		    i=""
7747141098Sdes		    ;;
7748141098Sdes		  esac
7749247568Sdes		fi
7750141098Sdes		if test -n "$i" ; then
7751247568Sdes		  libname=`eval "\\$ECHO \"$libname_spec\""`
7752247568Sdes		  deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
7753247568Sdes		  set dummy $deplib_matches; shift
7754247568Sdes		  deplib_match=$1
7755141098Sdes		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
7756247568Sdes		    func_append newdeplibs " $i"
7757141098Sdes		  else
7758141098Sdes		    droppeddeps=yes
7759247568Sdes		    echo
7760247568Sdes		    $ECHO "*** Warning: dynamic linker does not accept needed library $i."
7761247568Sdes		    echo "*** I have the capability to make that library automatically link in when"
7762247568Sdes		    echo "*** you link to this library.  But I can only do this if you have a"
7763247568Sdes		    echo "*** shared version of the library, which I believe you do not have"
7764247568Sdes		    echo "*** because a test_compile did reveal that the linker did not use it for"
7765247568Sdes		    echo "*** its dynamic dependency list that programs get resolved with at runtime."
7766141098Sdes		  fi
7767117610Sdes		fi
7768247568Sdes		;;
7769247568Sdes	      *)
7770247568Sdes		func_append newdeplibs " $i"
7771247568Sdes		;;
7772247568Sdes	      esac
7773117610Sdes	    done
7774117610Sdes	  else
7775141098Sdes	    # Error occurred in the first compile.  Let's try to salvage
7776125647Sdes	    # the situation: Compile a separate program for each library.
7777117610Sdes	    for i in $deplibs; do
7778247568Sdes	      case $i in
7779247568Sdes	      -l*)
7780247568Sdes		func_stripname -l '' "$i"
7781247568Sdes		name=$func_stripname_result
7782247568Sdes		$opt_dry_run || $RM conftest
7783174832Sdes		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
7784117610Sdes		  ldd_output=`ldd conftest`
7785141098Sdes		  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7786141098Sdes		    case " $predeps $postdeps " in
7787141098Sdes		    *" $i "*)
7788247568Sdes		      func_append newdeplibs " $i"
7789141098Sdes		      i=""
7790141098Sdes		      ;;
7791141098Sdes		    esac
7792117610Sdes		  fi
7793141098Sdes		  if test -n "$i" ; then
7794247568Sdes		    libname=`eval "\\$ECHO \"$libname_spec\""`
7795247568Sdes		    deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
7796247568Sdes		    set dummy $deplib_matches; shift
7797247568Sdes		    deplib_match=$1
7798141098Sdes		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
7799247568Sdes		      func_append newdeplibs " $i"
7800141098Sdes		    else
7801141098Sdes		      droppeddeps=yes
7802247568Sdes		      echo
7803247568Sdes		      $ECHO "*** Warning: dynamic linker does not accept needed library $i."
7804247568Sdes		      echo "*** I have the capability to make that library automatically link in when"
7805247568Sdes		      echo "*** you link to this library.  But I can only do this if you have a"
7806247568Sdes		      echo "*** shared version of the library, which you do not appear to have"
7807247568Sdes		      echo "*** because a test_compile did reveal that the linker did not use this one"
7808247568Sdes		      echo "*** as a dynamic dependency that programs can get resolved with at runtime."
7809141098Sdes		    fi
7810141098Sdes		  fi
7811117610Sdes		else
7812117610Sdes		  droppeddeps=yes
7813247568Sdes		  echo
7814247568Sdes		  $ECHO "*** Warning!  Library $i is needed by this library but I was not able to"
7815247568Sdes		  echo "*** make it link in!  You will probably need to install it or some"
7816247568Sdes		  echo "*** library that it depends on before this library will be fully"
7817247568Sdes		  echo "*** functional.  Installing it before continuing would be even better."
7818117610Sdes		fi
7819247568Sdes		;;
7820247568Sdes	      *)
7821247568Sdes		func_append newdeplibs " $i"
7822247568Sdes		;;
7823247568Sdes	      esac
7824117610Sdes	    done
7825117610Sdes	  fi
7826117610Sdes	  ;;
7827117610Sdes	file_magic*)
7828247568Sdes	  set dummy $deplibs_check_method; shift
7829247568Sdes	  file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
7830117610Sdes	  for a_deplib in $deplibs; do
7831247568Sdes	    case $a_deplib in
7832247568Sdes	    -l*)
7833247568Sdes	      func_stripname -l '' "$a_deplib"
7834247568Sdes	      name=$func_stripname_result
7835141098Sdes	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7836141098Sdes		case " $predeps $postdeps " in
7837141098Sdes		*" $a_deplib "*)
7838247568Sdes		  func_append newdeplibs " $a_deplib"
7839141098Sdes		  a_deplib=""
7840141098Sdes		  ;;
7841141098Sdes		esac
7842141098Sdes	      fi
7843141098Sdes	      if test -n "$a_deplib" ; then
7844247568Sdes		libname=`eval "\\$ECHO \"$libname_spec\""`
7845247568Sdes		if test -n "$file_magic_glob"; then
7846247568Sdes		  libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob`
7847247568Sdes		else
7848247568Sdes		  libnameglob=$libname
7849247568Sdes		fi
7850247568Sdes		test "$want_nocaseglob" = yes && nocaseglob=`shopt -p nocaseglob`
7851141098Sdes		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
7852247568Sdes		  if test "$want_nocaseglob" = yes; then
7853247568Sdes		    shopt -s nocaseglob
7854247568Sdes		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
7855247568Sdes		    $nocaseglob
7856247568Sdes		  else
7857247568Sdes		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
7858247568Sdes		  fi
7859141098Sdes		  for potent_lib in $potential_libs; do
7860117610Sdes		      # Follow soft links.
7861247568Sdes		      if ls -lLd "$potent_lib" 2>/dev/null |
7862247568Sdes			 $GREP " -> " >/dev/null; then
7863125647Sdes			continue
7864117610Sdes		      fi
7865117610Sdes		      # The statement above tries to avoid entering an
7866117610Sdes		      # endless loop below, in case of cyclic links.
7867117610Sdes		      # We might still enter an endless loop, since a link
7868117610Sdes		      # loop can be closed while we follow links,
7869117610Sdes		      # but so what?
7870117610Sdes		      potlib="$potent_lib"
7871117610Sdes		      while test -h "$potlib" 2>/dev/null; do
7872125647Sdes			potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
7873125647Sdes			case $potliblink in
7874117610Sdes			[\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
7875247568Sdes			*) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";;
7876117610Sdes			esac
7877117610Sdes		      done
7878247568Sdes		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
7879247568Sdes			 $SED -e 10q |
7880247568Sdes			 $EGREP "$file_magic_regex" > /dev/null; then
7881247568Sdes			func_append newdeplibs " $a_deplib"
7882117610Sdes			a_deplib=""
7883117610Sdes			break 2
7884117610Sdes		      fi
7885141098Sdes		  done
7886141098Sdes		done
7887141098Sdes	      fi
7888117610Sdes	      if test -n "$a_deplib" ; then
7889117610Sdes		droppeddeps=yes
7890247568Sdes		echo
7891247568Sdes		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
7892247568Sdes		echo "*** I have the capability to make that library automatically link in when"
7893247568Sdes		echo "*** you link to this library.  But I can only do this if you have a"
7894247568Sdes		echo "*** shared version of the library, which you do not appear to have"
7895247568Sdes		echo "*** because I did check the linker path looking for a file starting"
7896125647Sdes		if test -z "$potlib" ; then
7897247568Sdes		  $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
7898125647Sdes		else
7899247568Sdes		  $ECHO "*** with $libname and none of the candidates passed a file format test"
7900247568Sdes		  $ECHO "*** using a file magic. Last file checked: $potlib"
7901125647Sdes		fi
7902117610Sdes	      fi
7903247568Sdes	      ;;
7904247568Sdes	    *)
7905117610Sdes	      # Add a -L argument.
7906247568Sdes	      func_append newdeplibs " $a_deplib"
7907247568Sdes	      ;;
7908247568Sdes	    esac
7909117610Sdes	  done # Gone through all deplibs.
7910117610Sdes	  ;;
7911125647Sdes	match_pattern*)
7912247568Sdes	  set dummy $deplibs_check_method; shift
7913247568Sdes	  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
7914125647Sdes	  for a_deplib in $deplibs; do
7915247568Sdes	    case $a_deplib in
7916247568Sdes	    -l*)
7917247568Sdes	      func_stripname -l '' "$a_deplib"
7918247568Sdes	      name=$func_stripname_result
7919141098Sdes	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7920141098Sdes		case " $predeps $postdeps " in
7921141098Sdes		*" $a_deplib "*)
7922247568Sdes		  func_append newdeplibs " $a_deplib"
7923141098Sdes		  a_deplib=""
7924141098Sdes		  ;;
7925141098Sdes		esac
7926141098Sdes	      fi
7927141098Sdes	      if test -n "$a_deplib" ; then
7928247568Sdes		libname=`eval "\\$ECHO \"$libname_spec\""`
7929141098Sdes		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
7930141098Sdes		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
7931141098Sdes		  for potent_lib in $potential_libs; do
7932141098Sdes		    potlib="$potent_lib" # see symlink-check above in file_magic test
7933247568Sdes		    if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
7934247568Sdes		       $EGREP "$match_pattern_regex" > /dev/null; then
7935247568Sdes		      func_append newdeplibs " $a_deplib"
7936141098Sdes		      a_deplib=""
7937141098Sdes		      break 2
7938141098Sdes		    fi
7939141098Sdes		  done
7940125647Sdes		done
7941141098Sdes	      fi
7942125647Sdes	      if test -n "$a_deplib" ; then
7943125647Sdes		droppeddeps=yes
7944247568Sdes		echo
7945247568Sdes		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
7946247568Sdes		echo "*** I have the capability to make that library automatically link in when"
7947247568Sdes		echo "*** you link to this library.  But I can only do this if you have a"
7948247568Sdes		echo "*** shared version of the library, which you do not appear to have"
7949247568Sdes		echo "*** because I did check the linker path looking for a file starting"
7950125647Sdes		if test -z "$potlib" ; then
7951247568Sdes		  $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
7952125647Sdes		else
7953247568Sdes		  $ECHO "*** with $libname and none of the candidates passed a file format test"
7954247568Sdes		  $ECHO "*** using a regex pattern. Last file checked: $potlib"
7955125647Sdes		fi
7956125647Sdes	      fi
7957247568Sdes	      ;;
7958247568Sdes	    *)
7959125647Sdes	      # Add a -L argument.
7960247568Sdes	      func_append newdeplibs " $a_deplib"
7961247568Sdes	      ;;
7962247568Sdes	    esac
7963125647Sdes	  done # Gone through all deplibs.
7964125647Sdes	  ;;
7965117610Sdes	none | unknown | *)
7966117610Sdes	  newdeplibs=""
7967247568Sdes	  tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
7968141098Sdes	  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7969141098Sdes	    for i in $predeps $postdeps ; do
7970141098Sdes	      # can't use Xsed below, because $i might contain '/'
7971247568Sdes	      tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"`
7972141098Sdes	    done
7973141098Sdes	  fi
7974247568Sdes	  case $tmp_deplibs in
7975247568Sdes	  *[!\	\ ]*)
7976247568Sdes	    echo
7977117610Sdes	    if test "X$deplibs_check_method" = "Xnone"; then
7978247568Sdes	      echo "*** Warning: inter-library dependencies are not supported in this platform."
7979117610Sdes	    else
7980247568Sdes	      echo "*** Warning: inter-library dependencies are not known to be supported."
7981117610Sdes	    fi
7982247568Sdes	    echo "*** All declared inter-library dependencies are being dropped."
7983117610Sdes	    droppeddeps=yes
7984247568Sdes	    ;;
7985247568Sdes	  esac
7986117610Sdes	  ;;
7987117610Sdes	esac
7988117610Sdes	versuffix=$versuffix_save
7989117610Sdes	major=$major_save
7990117610Sdes	release=$release_save
7991117610Sdes	libname=$libname_save
7992117610Sdes	name=$name_save
7993117610Sdes
7994125647Sdes	case $host in
7995125647Sdes	*-*-rhapsody* | *-*-darwin1.[012])
7996247568Sdes	  # On Rhapsody replace the C library with the System framework
7997247568Sdes	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
7998125647Sdes	  ;;
7999125647Sdes	esac
8000125647Sdes
8001117610Sdes	if test "$droppeddeps" = yes; then
8002117610Sdes	  if test "$module" = yes; then
8003247568Sdes	    echo
8004247568Sdes	    echo "*** Warning: libtool could not satisfy all declared inter-library"
8005247568Sdes	    $ECHO "*** dependencies of module $libname.  Therefore, libtool will create"
8006247568Sdes	    echo "*** a static module, that should work as long as the dlopening"
8007247568Sdes	    echo "*** application is linked with the -dlopen flag."
8008117610Sdes	    if test -z "$global_symbol_pipe"; then
8009247568Sdes	      echo
8010247568Sdes	      echo "*** However, this would only work if libtool was able to extract symbol"
8011247568Sdes	      echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
8012247568Sdes	      echo "*** not find such a program.  So, this module is probably useless."
8013247568Sdes	      echo "*** \`nm' from GNU binutils and a full rebuild may help."
8014117610Sdes	    fi
8015117610Sdes	    if test "$build_old_libs" = no; then
8016117610Sdes	      oldlibs="$output_objdir/$libname.$libext"
8017117610Sdes	      build_libtool_libs=module
8018117610Sdes	      build_old_libs=yes
8019117610Sdes	    else
8020117610Sdes	      build_libtool_libs=no
8021117610Sdes	    fi
8022117610Sdes	  else
8023247568Sdes	    echo "*** The inter-library dependencies that have been dropped here will be"
8024247568Sdes	    echo "*** automatically added whenever a program is linked with this library"
8025247568Sdes	    echo "*** or is declared to -dlopen it."
8026125647Sdes
8027141098Sdes	    if test "$allow_undefined" = no; then
8028247568Sdes	      echo
8029247568Sdes	      echo "*** Since this library must not contain undefined symbols,"
8030247568Sdes	      echo "*** because either the platform does not support them or"
8031247568Sdes	      echo "*** it was explicitly requested with -no-undefined,"
8032247568Sdes	      echo "*** libtool will only create a static version of it."
8033125647Sdes	      if test "$build_old_libs" = no; then
8034125647Sdes		oldlibs="$output_objdir/$libname.$libext"
8035125647Sdes		build_libtool_libs=module
8036125647Sdes		build_old_libs=yes
8037125647Sdes	      else
8038125647Sdes		build_libtool_libs=no
8039125647Sdes	      fi
8040125647Sdes	    fi
8041117610Sdes	  fi
8042117610Sdes	fi
8043117610Sdes	# Done checking deplibs!
8044117610Sdes	deplibs=$newdeplibs
8045117610Sdes      fi
8046247568Sdes      # Time to change all our "foo.ltframework" stuff back to "-framework foo"
8047247568Sdes      case $host in
8048247568Sdes	*-*-darwin*)
8049247568Sdes	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8050247568Sdes	  new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8051247568Sdes	  deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8052247568Sdes	  ;;
8053247568Sdes      esac
8054117610Sdes
8055174832Sdes      # move library search paths that coincide with paths to not yet
8056174832Sdes      # installed libraries to the beginning of the library search list
8057174832Sdes      new_libs=
8058174832Sdes      for path in $notinst_path; do
8059174832Sdes	case " $new_libs " in
8060174832Sdes	*" -L$path/$objdir "*) ;;
8061174832Sdes	*)
8062174832Sdes	  case " $deplibs " in
8063174832Sdes	  *" -L$path/$objdir "*)
8064247568Sdes	    func_append new_libs " -L$path/$objdir" ;;
8065174832Sdes	  esac
8066174832Sdes	  ;;
8067174832Sdes	esac
8068174832Sdes      done
8069174832Sdes      for deplib in $deplibs; do
8070174832Sdes	case $deplib in
8071174832Sdes	-L*)
8072174832Sdes	  case " $new_libs " in
8073174832Sdes	  *" $deplib "*) ;;
8074247568Sdes	  *) func_append new_libs " $deplib" ;;
8075174832Sdes	  esac
8076174832Sdes	  ;;
8077247568Sdes	*) func_append new_libs " $deplib" ;;
8078174832Sdes	esac
8079174832Sdes      done
8080174832Sdes      deplibs="$new_libs"
8081174832Sdes
8082117610Sdes      # All the library-specific variables (install_libdir is set above).
8083117610Sdes      library_names=
8084117610Sdes      old_library=
8085117610Sdes      dlname=
8086125647Sdes
8087117610Sdes      # Test again, we may have decided not to build it any more
8088117610Sdes      if test "$build_libtool_libs" = yes; then
8089247568Sdes	# Remove ${wl} instances when linking with ld.
8090247568Sdes	# FIXME: should test the right _cmds variable.
8091247568Sdes	case $archive_cmds in
8092247568Sdes	  *\$LD\ *) wl= ;;
8093247568Sdes        esac
8094141098Sdes	if test "$hardcode_into_libs" = yes; then
8095125647Sdes	  # Hardcode the library paths
8096125647Sdes	  hardcode_libdirs=
8097125647Sdes	  dep_rpath=
8098125647Sdes	  rpath="$finalize_rpath"
8099247568Sdes	  test "$opt_mode" != relink && rpath="$compile_rpath$rpath"
8100125647Sdes	  for libdir in $rpath; do
8101125647Sdes	    if test -n "$hardcode_libdir_flag_spec"; then
8102125647Sdes	      if test -n "$hardcode_libdir_separator"; then
8103247568Sdes		func_replace_sysroot "$libdir"
8104247568Sdes		libdir=$func_replace_sysroot_result
8105125647Sdes		if test -z "$hardcode_libdirs"; then
8106125647Sdes		  hardcode_libdirs="$libdir"
8107125647Sdes		else
8108125647Sdes		  # Just accumulate the unique libdirs.
8109125647Sdes		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
8110125647Sdes		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
8111125647Sdes		    ;;
8112125647Sdes		  *)
8113247568Sdes		    func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
8114125647Sdes		    ;;
8115125647Sdes		  esac
8116125647Sdes		fi
8117125647Sdes	      else
8118125647Sdes		eval flag=\"$hardcode_libdir_flag_spec\"
8119247568Sdes		func_append dep_rpath " $flag"
8120125647Sdes	      fi
8121125647Sdes	    elif test -n "$runpath_var"; then
8122125647Sdes	      case "$perm_rpath " in
8123125647Sdes	      *" $libdir "*) ;;
8124247568Sdes	      *) func_append perm_rpath " $libdir" ;;
8125125647Sdes	      esac
8126125647Sdes	    fi
8127125647Sdes	  done
8128125647Sdes	  # Substitute the hardcoded libdirs into the rpath.
8129125647Sdes	  if test -n "$hardcode_libdir_separator" &&
8130125647Sdes	     test -n "$hardcode_libdirs"; then
8131125647Sdes	    libdir="$hardcode_libdirs"
8132247568Sdes	    eval "dep_rpath=\"$hardcode_libdir_flag_spec\""
8133125647Sdes	  fi
8134125647Sdes	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
8135125647Sdes	    # We should set the runpath_var.
8136125647Sdes	    rpath=
8137125647Sdes	    for dir in $perm_rpath; do
8138247568Sdes	      func_append rpath "$dir:"
8139125647Sdes	    done
8140125647Sdes	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
8141125647Sdes	  fi
8142125647Sdes	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
8143125647Sdes	fi
8144125647Sdes
8145125647Sdes	shlibpath="$finalize_shlibpath"
8146247568Sdes	test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
8147125647Sdes	if test -n "$shlibpath"; then
8148125647Sdes	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
8149125647Sdes	fi
8150125647Sdes
8151117610Sdes	# Get the real and link names of the library.
8152141098Sdes	eval shared_ext=\"$shrext_cmds\"
8153117610Sdes	eval library_names=\"$library_names_spec\"
8154117610Sdes	set dummy $library_names
8155247568Sdes	shift
8156247568Sdes	realname="$1"
8157247568Sdes	shift
8158117610Sdes
8159117610Sdes	if test -n "$soname_spec"; then
8160117610Sdes	  eval soname=\"$soname_spec\"
8161117610Sdes	else
8162117610Sdes	  soname="$realname"
8163117610Sdes	fi
8164141098Sdes	if test -z "$dlname"; then
8165141098Sdes	  dlname=$soname
8166141098Sdes	fi
8167117610Sdes
8168117610Sdes	lib="$output_objdir/$realname"
8169174832Sdes	linknames=
8170117610Sdes	for link
8171117610Sdes	do
8172247568Sdes	  func_append linknames " $link"
8173117610Sdes	done
8174117610Sdes
8175117610Sdes	# Use standard objects if they are pic
8176247568Sdes	test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
8177247568Sdes	test "X$libobjs" = "X " && libobjs=
8178117610Sdes
8179247568Sdes	delfiles=
8180247568Sdes	if test -n "$export_symbols" && test -n "$include_expsyms"; then
8181247568Sdes	  $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
8182247568Sdes	  export_symbols="$output_objdir/$libname.uexp"
8183247568Sdes	  func_append delfiles " $export_symbols"
8184247568Sdes	fi
8185247568Sdes
8186247568Sdes	orig_export_symbols=
8187247568Sdes	case $host_os in
8188247568Sdes	cygwin* | mingw* | cegcc*)
8189247568Sdes	  if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
8190247568Sdes	    # exporting using user supplied symfile
8191247568Sdes	    if test "x`$SED 1q $export_symbols`" != xEXPORTS; then
8192247568Sdes	      # and it's NOT already a .def file. Must figure out
8193247568Sdes	      # which of the given symbols are data symbols and tag
8194247568Sdes	      # them as such. So, trigger use of export_symbols_cmds.
8195247568Sdes	      # export_symbols gets reassigned inside the "prepare
8196247568Sdes	      # the list of exported symbols" if statement, so the
8197247568Sdes	      # include_expsyms logic still works.
8198247568Sdes	      orig_export_symbols="$export_symbols"
8199247568Sdes	      export_symbols=
8200247568Sdes	      always_export_symbols=yes
8201247568Sdes	    fi
8202247568Sdes	  fi
8203247568Sdes	  ;;
8204247568Sdes	esac
8205247568Sdes
8206117610Sdes	# Prepare the list of exported symbols
8207117610Sdes	if test -z "$export_symbols"; then
8208117610Sdes	  if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
8209247568Sdes	    func_verbose "generating symbol list for \`$libname.la'"
8210117610Sdes	    export_symbols="$output_objdir/$libname.exp"
8211247568Sdes	    $opt_dry_run || $RM $export_symbols
8212141098Sdes	    cmds=$export_symbols_cmds
8213125647Sdes	    save_ifs="$IFS"; IFS='~'
8214247568Sdes	    for cmd1 in $cmds; do
8215117610Sdes	      IFS="$save_ifs"
8216247568Sdes	      # Take the normal branch if the nm_file_list_spec branch
8217247568Sdes	      # doesn't work or if tool conversion is not needed.
8218247568Sdes	      case $nm_file_list_spec~$to_tool_file_cmd in
8219247568Sdes		*~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*)
8220247568Sdes		  try_normal_branch=yes
8221247568Sdes		  eval cmd=\"$cmd1\"
8222247568Sdes		  func_len " $cmd"
8223247568Sdes		  len=$func_len_result
8224247568Sdes		  ;;
8225247568Sdes		*)
8226247568Sdes		  try_normal_branch=no
8227247568Sdes		  ;;
8228247568Sdes	      esac
8229247568Sdes	      if test "$try_normal_branch" = yes \
8230247568Sdes		 && { test "$len" -lt "$max_cmd_len" \
8231247568Sdes		      || test "$max_cmd_len" -le -1; }
8232247568Sdes	      then
8233247568Sdes		func_show_eval "$cmd" 'exit $?'
8234247568Sdes		skipped_export=false
8235247568Sdes	      elif test -n "$nm_file_list_spec"; then
8236247568Sdes		func_basename "$output"
8237247568Sdes		output_la=$func_basename_result
8238247568Sdes		save_libobjs=$libobjs
8239247568Sdes		save_output=$output
8240247568Sdes		output=${output_objdir}/${output_la}.nm
8241247568Sdes		func_to_tool_file "$output"
8242247568Sdes		libobjs=$nm_file_list_spec$func_to_tool_file_result
8243247568Sdes		func_append delfiles " $output"
8244247568Sdes		func_verbose "creating $NM input file list: $output"
8245247568Sdes		for obj in $save_libobjs; do
8246247568Sdes		  func_to_tool_file "$obj"
8247247568Sdes		  $ECHO "$func_to_tool_file_result"
8248247568Sdes		done > "$output"
8249247568Sdes		eval cmd=\"$cmd1\"
8250247568Sdes		func_show_eval "$cmd" 'exit $?'
8251247568Sdes		output=$save_output
8252247568Sdes		libobjs=$save_libobjs
8253247568Sdes		skipped_export=false
8254141098Sdes	      else
8255247568Sdes		# The command line is too long to execute in one step.
8256247568Sdes		func_verbose "using reloadable object file for export list..."
8257247568Sdes		skipped_export=:
8258174832Sdes		# Break out early, otherwise skipped_export may be
8259174832Sdes		# set to false by a later but shorter cmd.
8260174832Sdes		break
8261141098Sdes	      fi
8262117610Sdes	    done
8263117610Sdes	    IFS="$save_ifs"
8264247568Sdes	    if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then
8265247568Sdes	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
8266247568Sdes	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
8267117610Sdes	    fi
8268117610Sdes	  fi
8269117610Sdes	fi
8270117610Sdes
8271117610Sdes	if test -n "$export_symbols" && test -n "$include_expsyms"; then
8272247568Sdes	  tmp_export_symbols="$export_symbols"
8273247568Sdes	  test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
8274247568Sdes	  $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
8275117610Sdes	fi
8276117610Sdes
8277247568Sdes	if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then
8278247568Sdes	  # The given exports_symbols file has to be filtered, so filter it.
8279247568Sdes	  func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
8280247568Sdes	  # FIXME: $output_objdir/$libname.filter potentially contains lots of
8281247568Sdes	  # 's' commands which not all seds can handle. GNU sed should be fine
8282247568Sdes	  # though. Also, the filter scales superlinearly with the number of
8283247568Sdes	  # global variables. join(1) would be nice here, but unfortunately
8284247568Sdes	  # isn't a blessed tool.
8285247568Sdes	  $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
8286247568Sdes	  func_append delfiles " $export_symbols $output_objdir/$libname.filter"
8287247568Sdes	  export_symbols=$output_objdir/$libname.def
8288247568Sdes	  $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
8289247568Sdes	fi
8290247568Sdes
8291141098Sdes	tmp_deplibs=
8292141098Sdes	for test_deplib in $deplibs; do
8293247568Sdes	  case " $convenience " in
8294247568Sdes	  *" $test_deplib "*) ;;
8295247568Sdes	  *)
8296247568Sdes	    func_append tmp_deplibs " $test_deplib"
8297247568Sdes	    ;;
8298247568Sdes	  esac
8299141098Sdes	done
8300141098Sdes	deplibs="$tmp_deplibs"
8301141098Sdes
8302117610Sdes	if test -n "$convenience"; then
8303247568Sdes	  if test -n "$whole_archive_flag_spec" &&
8304247568Sdes	    test "$compiler_needs_object" = yes &&
8305247568Sdes	    test -z "$libobjs"; then
8306247568Sdes	    # extract the archives, so we have objects to list.
8307247568Sdes	    # TODO: could optimize this to just extract one archive.
8308247568Sdes	    whole_archive_flag_spec=
8309247568Sdes	  fi
8310117610Sdes	  if test -n "$whole_archive_flag_spec"; then
8311141098Sdes	    save_libobjs=$libobjs
8312117610Sdes	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
8313247568Sdes	    test "X$libobjs" = "X " && libobjs=
8314117610Sdes	  else
8315117610Sdes	    gentop="$output_objdir/${outputname}x"
8316247568Sdes	    func_append generated " $gentop"
8317117610Sdes
8318141098Sdes	    func_extract_archives $gentop $convenience
8319247568Sdes	    func_append libobjs " $func_extract_archives_result"
8320247568Sdes	    test "X$libobjs" = "X " && libobjs=
8321117610Sdes	  fi
8322117610Sdes	fi
8323247568Sdes
8324117610Sdes	if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
8325117610Sdes	  eval flag=\"$thread_safe_flag_spec\"
8326247568Sdes	  func_append linker_flags " $flag"
8327117610Sdes	fi
8328117610Sdes
8329125647Sdes	# Make a backup of the uninstalled library when relinking
8330247568Sdes	if test "$opt_mode" = relink; then
8331247568Sdes	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
8332125647Sdes	fi
8333125647Sdes
8334117610Sdes	# Do each of the archive commands.
8335141098Sdes	if test "$module" = yes && test -n "$module_cmds" ; then
8336141098Sdes	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
8337141098Sdes	    eval test_cmds=\"$module_expsym_cmds\"
8338141098Sdes	    cmds=$module_expsym_cmds
8339141098Sdes	  else
8340141098Sdes	    eval test_cmds=\"$module_cmds\"
8341141098Sdes	    cmds=$module_cmds
8342141098Sdes	  fi
8343141098Sdes	else
8344247568Sdes	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
8345247568Sdes	    eval test_cmds=\"$archive_expsym_cmds\"
8346247568Sdes	    cmds=$archive_expsym_cmds
8347247568Sdes	  else
8348247568Sdes	    eval test_cmds=\"$archive_cmds\"
8349247568Sdes	    cmds=$archive_cmds
8350141098Sdes	  fi
8351141098Sdes	fi
8352141098Sdes
8353174832Sdes	if test "X$skipped_export" != "X:" &&
8354247568Sdes	   func_len " $test_cmds" &&
8355247568Sdes	   len=$func_len_result &&
8356247568Sdes	   test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
8357141098Sdes	  :
8358141098Sdes	else
8359247568Sdes	  # The command line is too long to link in one step, link piecewise
8360247568Sdes	  # or, if using GNU ld and skipped_export is not :, use a linker
8361247568Sdes	  # script.
8362141098Sdes
8363141098Sdes	  # Save the value of $output and $libobjs because we want to
8364141098Sdes	  # use them later.  If we have whole_archive_flag_spec, we
8365141098Sdes	  # want to use save_libobjs as it was before
8366141098Sdes	  # whole_archive_flag_spec was expanded, because we can't
8367141098Sdes	  # assume the linker understands whole_archive_flag_spec.
8368141098Sdes	  # This may have to be revisited, in case too many
8369141098Sdes	  # convenience libraries get linked in and end up exceeding
8370141098Sdes	  # the spec.
8371141098Sdes	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
8372141098Sdes	    save_libobjs=$libobjs
8373141098Sdes	  fi
8374141098Sdes	  save_output=$output
8375247568Sdes	  func_basename "$output"
8376247568Sdes	  output_la=$func_basename_result
8377141098Sdes
8378141098Sdes	  # Clear the reloadable object creation command queue and
8379141098Sdes	  # initialize k to one.
8380141098Sdes	  test_cmds=
8381141098Sdes	  concat_cmds=
8382141098Sdes	  objlist=
8383141098Sdes	  last_robj=
8384141098Sdes	  k=1
8385247568Sdes
8386247568Sdes	  if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
8387247568Sdes	    output=${output_objdir}/${output_la}.lnkscript
8388247568Sdes	    func_verbose "creating GNU ld script: $output"
8389247568Sdes	    echo 'INPUT (' > $output
8390247568Sdes	    for obj in $save_libobjs
8391247568Sdes	    do
8392247568Sdes	      func_to_tool_file "$obj"
8393247568Sdes	      $ECHO "$func_to_tool_file_result" >> $output
8394247568Sdes	    done
8395247568Sdes	    echo ')' >> $output
8396247568Sdes	    func_append delfiles " $output"
8397247568Sdes	    func_to_tool_file "$output"
8398247568Sdes	    output=$func_to_tool_file_result
8399247568Sdes	  elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then
8400247568Sdes	    output=${output_objdir}/${output_la}.lnk
8401247568Sdes	    func_verbose "creating linker input file list: $output"
8402247568Sdes	    : > $output
8403247568Sdes	    set x $save_libobjs
8404247568Sdes	    shift
8405247568Sdes	    firstobj=
8406247568Sdes	    if test "$compiler_needs_object" = yes; then
8407247568Sdes	      firstobj="$1 "
8408247568Sdes	      shift
8409247568Sdes	    fi
8410247568Sdes	    for obj
8411247568Sdes	    do
8412247568Sdes	      func_to_tool_file "$obj"
8413247568Sdes	      $ECHO "$func_to_tool_file_result" >> $output
8414247568Sdes	    done
8415247568Sdes	    func_append delfiles " $output"
8416247568Sdes	    func_to_tool_file "$output"
8417247568Sdes	    output=$firstobj\"$file_list_spec$func_to_tool_file_result\"
8418247568Sdes	  else
8419247568Sdes	    if test -n "$save_libobjs"; then
8420247568Sdes	      func_verbose "creating reloadable object files..."
8421247568Sdes	      output=$output_objdir/$output_la-${k}.$objext
8422247568Sdes	      eval test_cmds=\"$reload_cmds\"
8423247568Sdes	      func_len " $test_cmds"
8424247568Sdes	      len0=$func_len_result
8425247568Sdes	      len=$len0
8426247568Sdes
8427247568Sdes	      # Loop over the list of objects to be linked.
8428247568Sdes	      for obj in $save_libobjs
8429247568Sdes	      do
8430247568Sdes		func_len " $obj"
8431247568Sdes		func_arith $len + $func_len_result
8432247568Sdes		len=$func_arith_result
8433247568Sdes		if test "X$objlist" = X ||
8434247568Sdes		   test "$len" -lt "$max_cmd_len"; then
8435247568Sdes		  func_append objlist " $obj"
8436247568Sdes		else
8437247568Sdes		  # The command $test_cmds is almost too long, add a
8438247568Sdes		  # command to the queue.
8439247568Sdes		  if test "$k" -eq 1 ; then
8440247568Sdes		    # The first file doesn't have a previous command to add.
8441247568Sdes		    reload_objs=$objlist
8442247568Sdes		    eval concat_cmds=\"$reload_cmds\"
8443247568Sdes		  else
8444247568Sdes		    # All subsequent reloadable object files will link in
8445247568Sdes		    # the last one created.
8446247568Sdes		    reload_objs="$objlist $last_robj"
8447247568Sdes		    eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
8448247568Sdes		  fi
8449247568Sdes		  last_robj=$output_objdir/$output_la-${k}.$objext
8450247568Sdes		  func_arith $k + 1
8451247568Sdes		  k=$func_arith_result
8452247568Sdes		  output=$output_objdir/$output_la-${k}.$objext
8453247568Sdes		  objlist=" $obj"
8454247568Sdes		  func_len " $last_robj"
8455247568Sdes		  func_arith $len0 + $func_len_result
8456247568Sdes		  len=$func_arith_result
8457247568Sdes		fi
8458247568Sdes	      done
8459247568Sdes	      # Handle the remaining objects by creating one last
8460247568Sdes	      # reloadable object file.  All subsequent reloadable object
8461247568Sdes	      # files will link in the last one created.
8462247568Sdes	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
8463247568Sdes	      reload_objs="$objlist $last_robj"
8464247568Sdes	      eval concat_cmds=\"\${concat_cmds}$reload_cmds\"
8465247568Sdes	      if test -n "$last_robj"; then
8466247568Sdes	        eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\"
8467247568Sdes	      fi
8468247568Sdes	      func_append delfiles " $output"
8469247568Sdes
8470141098Sdes	    else
8471247568Sdes	      output=
8472247568Sdes	    fi
8473247568Sdes
8474247568Sdes	    if ${skipped_export-false}; then
8475247568Sdes	      func_verbose "generating symbol list for \`$libname.la'"
8476247568Sdes	      export_symbols="$output_objdir/$libname.exp"
8477247568Sdes	      $opt_dry_run || $RM $export_symbols
8478247568Sdes	      libobjs=$output
8479247568Sdes	      # Append the command to create the export file.
8480247568Sdes	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
8481247568Sdes	      eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
8482247568Sdes	      if test -n "$last_robj"; then
8483247568Sdes		eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
8484125647Sdes	      fi
8485141098Sdes	    fi
8486141098Sdes
8487247568Sdes	    test -n "$save_libobjs" &&
8488247568Sdes	      func_verbose "creating a temporary reloadable object file: $output"
8489141098Sdes
8490247568Sdes	    # Loop through the commands generated above and execute them.
8491247568Sdes	    save_ifs="$IFS"; IFS='~'
8492247568Sdes	    for cmd in $concat_cmds; do
8493247568Sdes	      IFS="$save_ifs"
8494247568Sdes	      $opt_silent || {
8495247568Sdes		  func_quote_for_expand "$cmd"
8496247568Sdes		  eval "func_echo $func_quote_for_expand_result"
8497247568Sdes	      }
8498247568Sdes	      $opt_dry_run || eval "$cmd" || {
8499247568Sdes		lt_exit=$?
8500141098Sdes
8501247568Sdes		# Restore the uninstalled library and exit
8502247568Sdes		if test "$opt_mode" = relink; then
8503247568Sdes		  ( cd "$output_objdir" && \
8504247568Sdes		    $RM "${realname}T" && \
8505247568Sdes		    $MV "${realname}U" "$realname" )
8506247568Sdes		fi
8507141098Sdes
8508247568Sdes		exit $lt_exit
8509247568Sdes	      }
8510247568Sdes	    done
8511141098Sdes	    IFS="$save_ifs"
8512141098Sdes
8513247568Sdes	    if test -n "$export_symbols_regex" && ${skipped_export-false}; then
8514247568Sdes	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
8515247568Sdes	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
8516247568Sdes	    fi
8517247568Sdes	  fi
8518247568Sdes
8519247568Sdes          if ${skipped_export-false}; then
8520247568Sdes	    if test -n "$export_symbols" && test -n "$include_expsyms"; then
8521247568Sdes	      tmp_export_symbols="$export_symbols"
8522247568Sdes	      test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
8523247568Sdes	      $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
8524247568Sdes	    fi
8525247568Sdes
8526247568Sdes	    if test -n "$orig_export_symbols"; then
8527247568Sdes	      # The given exports_symbols file has to be filtered, so filter it.
8528247568Sdes	      func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
8529247568Sdes	      # FIXME: $output_objdir/$libname.filter potentially contains lots of
8530247568Sdes	      # 's' commands which not all seds can handle. GNU sed should be fine
8531247568Sdes	      # though. Also, the filter scales superlinearly with the number of
8532247568Sdes	      # global variables. join(1) would be nice here, but unfortunately
8533247568Sdes	      # isn't a blessed tool.
8534247568Sdes	      $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
8535247568Sdes	      func_append delfiles " $export_symbols $output_objdir/$libname.filter"
8536247568Sdes	      export_symbols=$output_objdir/$libname.def
8537247568Sdes	      $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
8538247568Sdes	    fi
8539247568Sdes	  fi
8540247568Sdes
8541141098Sdes	  libobjs=$output
8542141098Sdes	  # Restore the value of output.
8543141098Sdes	  output=$save_output
8544141098Sdes
8545141098Sdes	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
8546141098Sdes	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
8547247568Sdes	    test "X$libobjs" = "X " && libobjs=
8548141098Sdes	  fi
8549141098Sdes	  # Expand the library linking commands again to reset the
8550141098Sdes	  # value of $libobjs for piecewise linking.
8551141098Sdes
8552141098Sdes	  # Do each of the archive commands.
8553141098Sdes	  if test "$module" = yes && test -n "$module_cmds" ; then
8554141098Sdes	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
8555141098Sdes	      cmds=$module_expsym_cmds
8556141098Sdes	    else
8557141098Sdes	      cmds=$module_cmds
8558141098Sdes	    fi
8559141098Sdes	  else
8560247568Sdes	    if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
8561247568Sdes	      cmds=$archive_expsym_cmds
8562247568Sdes	    else
8563247568Sdes	      cmds=$archive_cmds
8564141098Sdes	    fi
8565141098Sdes	  fi
8566247568Sdes	fi
8567141098Sdes
8568247568Sdes	if test -n "$delfiles"; then
8569247568Sdes	  # Append the command to remove temporary files to $cmds.
8570247568Sdes	  eval cmds=\"\$cmds~\$RM $delfiles\"
8571117610Sdes	fi
8572247568Sdes
8573247568Sdes	# Add any objects from preloaded convenience libraries
8574247568Sdes	if test -n "$dlprefiles"; then
8575247568Sdes	  gentop="$output_objdir/${outputname}x"
8576247568Sdes	  func_append generated " $gentop"
8577247568Sdes
8578247568Sdes	  func_extract_archives $gentop $dlprefiles
8579247568Sdes	  func_append libobjs " $func_extract_archives_result"
8580247568Sdes	  test "X$libobjs" = "X " && libobjs=
8581247568Sdes	fi
8582247568Sdes
8583125647Sdes	save_ifs="$IFS"; IFS='~'
8584117610Sdes	for cmd in $cmds; do
8585117610Sdes	  IFS="$save_ifs"
8586141098Sdes	  eval cmd=\"$cmd\"
8587247568Sdes	  $opt_silent || {
8588247568Sdes	    func_quote_for_expand "$cmd"
8589247568Sdes	    eval "func_echo $func_quote_for_expand_result"
8590247568Sdes	  }
8591247568Sdes	  $opt_dry_run || eval "$cmd" || {
8592174832Sdes	    lt_exit=$?
8593174832Sdes
8594174832Sdes	    # Restore the uninstalled library and exit
8595247568Sdes	    if test "$opt_mode" = relink; then
8596247568Sdes	      ( cd "$output_objdir" && \
8597247568Sdes	        $RM "${realname}T" && \
8598247568Sdes		$MV "${realname}U" "$realname" )
8599174832Sdes	    fi
8600174832Sdes
8601174832Sdes	    exit $lt_exit
8602174832Sdes	  }
8603117610Sdes	done
8604117610Sdes	IFS="$save_ifs"
8605117610Sdes
8606125647Sdes	# Restore the uninstalled library and exit
8607247568Sdes	if test "$opt_mode" = relink; then
8608247568Sdes	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
8609174832Sdes
8610174832Sdes	  if test -n "$convenience"; then
8611174832Sdes	    if test -z "$whole_archive_flag_spec"; then
8612247568Sdes	      func_show_eval '${RM}r "$gentop"'
8613174832Sdes	    fi
8614174832Sdes	  fi
8615174832Sdes
8616141098Sdes	  exit $EXIT_SUCCESS
8617125647Sdes	fi
8618125647Sdes
8619117610Sdes	# Create links to the real library.
8620117610Sdes	for linkname in $linknames; do
8621117610Sdes	  if test "$realname" != "$linkname"; then
8622247568Sdes	    func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
8623117610Sdes	  fi
8624117610Sdes	done
8625117610Sdes
8626117610Sdes	# If -module or -export-dynamic was specified, set the dlname.
8627117610Sdes	if test "$module" = yes || test "$export_dynamic" = yes; then
8628117610Sdes	  # On all known operating systems, these are identical.
8629117610Sdes	  dlname="$soname"
8630117610Sdes	fi
8631117610Sdes      fi
8632117610Sdes      ;;
8633117610Sdes
8634125647Sdes    obj)
8635117610Sdes      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
8636247568Sdes	func_warning "\`-dlopen' is ignored for objects"
8637117610Sdes      fi
8638117610Sdes
8639247568Sdes      case " $deplibs" in
8640247568Sdes      *\ -l* | *\ -L*)
8641247568Sdes	func_warning "\`-l' and \`-L' are ignored for objects" ;;
8642247568Sdes      esac
8643117610Sdes
8644247568Sdes      test -n "$rpath" && \
8645247568Sdes	func_warning "\`-rpath' is ignored for objects"
8646117610Sdes
8647247568Sdes      test -n "$xrpath" && \
8648247568Sdes	func_warning "\`-R' is ignored for objects"
8649117610Sdes
8650247568Sdes      test -n "$vinfo" && \
8651247568Sdes	func_warning "\`-version-info' is ignored for objects"
8652117610Sdes
8653247568Sdes      test -n "$release" && \
8654247568Sdes	func_warning "\`-release' is ignored for objects"
8655247568Sdes
8656125647Sdes      case $output in
8657117610Sdes      *.lo)
8658247568Sdes	test -n "$objs$old_deplibs" && \
8659247568Sdes	  func_fatal_error "cannot build library object \`$output' from non-libtool objects"
8660247568Sdes
8661247568Sdes	libobj=$output
8662247568Sdes	func_lo2o "$libobj"
8663247568Sdes	obj=$func_lo2o_result
8664117610Sdes	;;
8665117610Sdes      *)
8666117610Sdes	libobj=
8667117610Sdes	obj="$output"
8668117610Sdes	;;
8669117610Sdes      esac
8670117610Sdes
8671117610Sdes      # Delete the old objects.
8672247568Sdes      $opt_dry_run || $RM $obj $libobj
8673117610Sdes
8674117610Sdes      # Objects from convenience libraries.  This assumes
8675117610Sdes      # single-version convenience libraries.  Whenever we create
8676117610Sdes      # different ones for PIC/non-PIC, this we'll have to duplicate
8677117610Sdes      # the extraction.
8678117610Sdes      reload_conv_objs=
8679117610Sdes      gentop=
8680117610Sdes      # reload_cmds runs $LD directly, so let us get rid of
8681174832Sdes      # -Wl from whole_archive_flag_spec and hope we can get by with
8682174832Sdes      # turning comma into space..
8683125647Sdes      wl=
8684117610Sdes
8685117610Sdes      if test -n "$convenience"; then
8686117610Sdes	if test -n "$whole_archive_flag_spec"; then
8687174832Sdes	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
8688247568Sdes	  reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
8689117610Sdes	else
8690117610Sdes	  gentop="$output_objdir/${obj}x"
8691247568Sdes	  func_append generated " $gentop"
8692117610Sdes
8693141098Sdes	  func_extract_archives $gentop $convenience
8694141098Sdes	  reload_conv_objs="$reload_objs $func_extract_archives_result"
8695117610Sdes	fi
8696117610Sdes      fi
8697117610Sdes
8698247568Sdes      # If we're not building shared, we need to use non_pic_objs
8699247568Sdes      test "$build_libtool_libs" != yes && libobjs="$non_pic_objects"
8700247568Sdes
8701117610Sdes      # Create the old-style object.
8702247568Sdes      reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
8703117610Sdes
8704117610Sdes      output="$obj"
8705247568Sdes      func_execute_cmds "$reload_cmds" 'exit $?'
8706117610Sdes
8707117610Sdes      # Exit if we aren't doing a library object file.
8708117610Sdes      if test -z "$libobj"; then
8709117610Sdes	if test -n "$gentop"; then
8710247568Sdes	  func_show_eval '${RM}r "$gentop"'
8711117610Sdes	fi
8712117610Sdes
8713141098Sdes	exit $EXIT_SUCCESS
8714117610Sdes      fi
8715117610Sdes
8716117610Sdes      if test "$build_libtool_libs" != yes; then
8717117610Sdes	if test -n "$gentop"; then
8718247568Sdes	  func_show_eval '${RM}r "$gentop"'
8719117610Sdes	fi
8720117610Sdes
8721117610Sdes	# Create an invalid libtool object if no PIC, so that we don't
8722117610Sdes	# accidentally link it into a program.
8723141098Sdes	# $show "echo timestamp > $libobj"
8724247568Sdes	# $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
8725141098Sdes	exit $EXIT_SUCCESS
8726117610Sdes      fi
8727117610Sdes
8728125647Sdes      if test -n "$pic_flag" || test "$pic_mode" != default; then
8729117610Sdes	# Only do commands if we really have different PIC objects.
8730117610Sdes	reload_objs="$libobjs $reload_conv_objs"
8731117610Sdes	output="$libobj"
8732247568Sdes	func_execute_cmds "$reload_cmds" 'exit $?'
8733117610Sdes      fi
8734117610Sdes
8735117610Sdes      if test -n "$gentop"; then
8736247568Sdes	func_show_eval '${RM}r "$gentop"'
8737117610Sdes      fi
8738117610Sdes
8739141098Sdes      exit $EXIT_SUCCESS
8740117610Sdes      ;;
8741117610Sdes
8742125647Sdes    prog)
8743125647Sdes      case $host in
8744247568Sdes	*cygwin*) func_stripname '' '.exe' "$output"
8745247568Sdes	          output=$func_stripname_result.exe;;
8746125647Sdes      esac
8747247568Sdes      test -n "$vinfo" && \
8748247568Sdes	func_warning "\`-version-info' is ignored for programs"
8749117610Sdes
8750247568Sdes      test -n "$release" && \
8751247568Sdes	func_warning "\`-release' is ignored for programs"
8752117610Sdes
8753247568Sdes      test "$preload" = yes \
8754247568Sdes        && test "$dlopen_support" = unknown \
8755247568Sdes	&& test "$dlopen_self" = unknown \
8756247568Sdes	&& test "$dlopen_self_static" = unknown && \
8757247568Sdes	  func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support."
8758125647Sdes
8759125647Sdes      case $host in
8760125647Sdes      *-*-rhapsody* | *-*-darwin1.[012])
8761125647Sdes	# On Rhapsody replace the C library is the System framework
8762247568Sdes	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
8763247568Sdes	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
8764125647Sdes	;;
8765125647Sdes      esac
8766125647Sdes
8767141098Sdes      case $host in
8768247568Sdes      *-*-darwin*)
8769247568Sdes	# Don't allow lazy linking, it breaks C++ global constructors
8770247568Sdes	# But is supposedly fixed on 10.4 or later (yay!).
8771247568Sdes	if test "$tagname" = CXX ; then
8772247568Sdes	  case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
8773247568Sdes	    10.[0123])
8774247568Sdes	      func_append compile_command " ${wl}-bind_at_load"
8775247568Sdes	      func_append finalize_command " ${wl}-bind_at_load"
8776247568Sdes	    ;;
8777247568Sdes	  esac
8778247568Sdes	fi
8779247568Sdes	# Time to change all our "foo.ltframework" stuff back to "-framework foo"
8780247568Sdes	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8781247568Sdes	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8782247568Sdes	;;
8783141098Sdes      esac
8784141098Sdes
8785174832Sdes
8786174832Sdes      # move library search paths that coincide with paths to not yet
8787174832Sdes      # installed libraries to the beginning of the library search list
8788174832Sdes      new_libs=
8789174832Sdes      for path in $notinst_path; do
8790174832Sdes	case " $new_libs " in
8791174832Sdes	*" -L$path/$objdir "*) ;;
8792174832Sdes	*)
8793174832Sdes	  case " $compile_deplibs " in
8794174832Sdes	  *" -L$path/$objdir "*)
8795247568Sdes	    func_append new_libs " -L$path/$objdir" ;;
8796174832Sdes	  esac
8797174832Sdes	  ;;
8798174832Sdes	esac
8799174832Sdes      done
8800174832Sdes      for deplib in $compile_deplibs; do
8801174832Sdes	case $deplib in
8802174832Sdes	-L*)
8803174832Sdes	  case " $new_libs " in
8804174832Sdes	  *" $deplib "*) ;;
8805247568Sdes	  *) func_append new_libs " $deplib" ;;
8806174832Sdes	  esac
8807174832Sdes	  ;;
8808247568Sdes	*) func_append new_libs " $deplib" ;;
8809174832Sdes	esac
8810174832Sdes      done
8811174832Sdes      compile_deplibs="$new_libs"
8812174832Sdes
8813174832Sdes
8814247568Sdes      func_append compile_command " $compile_deplibs"
8815247568Sdes      func_append finalize_command " $finalize_deplibs"
8816125647Sdes
8817117610Sdes      if test -n "$rpath$xrpath"; then
8818117610Sdes	# If the user specified any rpath flags, then add them.
8819117610Sdes	for libdir in $rpath $xrpath; do
8820117610Sdes	  # This is the magic to use -rpath.
8821117610Sdes	  case "$finalize_rpath " in
8822117610Sdes	  *" $libdir "*) ;;
8823247568Sdes	  *) func_append finalize_rpath " $libdir" ;;
8824117610Sdes	  esac
8825117610Sdes	done
8826117610Sdes      fi
8827117610Sdes
8828117610Sdes      # Now hardcode the library paths
8829117610Sdes      rpath=
8830117610Sdes      hardcode_libdirs=
8831117610Sdes      for libdir in $compile_rpath $finalize_rpath; do
8832117610Sdes	if test -n "$hardcode_libdir_flag_spec"; then
8833117610Sdes	  if test -n "$hardcode_libdir_separator"; then
8834117610Sdes	    if test -z "$hardcode_libdirs"; then
8835117610Sdes	      hardcode_libdirs="$libdir"
8836117610Sdes	    else
8837117610Sdes	      # Just accumulate the unique libdirs.
8838125647Sdes	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
8839117610Sdes	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
8840117610Sdes		;;
8841117610Sdes	      *)
8842247568Sdes		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
8843117610Sdes		;;
8844117610Sdes	      esac
8845117610Sdes	    fi
8846117610Sdes	  else
8847117610Sdes	    eval flag=\"$hardcode_libdir_flag_spec\"
8848247568Sdes	    func_append rpath " $flag"
8849117610Sdes	  fi
8850117610Sdes	elif test -n "$runpath_var"; then
8851117610Sdes	  case "$perm_rpath " in
8852117610Sdes	  *" $libdir "*) ;;
8853247568Sdes	  *) func_append perm_rpath " $libdir" ;;
8854117610Sdes	  esac
8855117610Sdes	fi
8856125647Sdes	case $host in
8857247568Sdes	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
8858247568Sdes	  testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'`
8859125647Sdes	  case :$dllsearchpath: in
8860125647Sdes	  *":$libdir:"*) ;;
8861247568Sdes	  ::) dllsearchpath=$libdir;;
8862247568Sdes	  *) func_append dllsearchpath ":$libdir";;
8863125647Sdes	  esac
8864174832Sdes	  case :$dllsearchpath: in
8865174832Sdes	  *":$testbindir:"*) ;;
8866247568Sdes	  ::) dllsearchpath=$testbindir;;
8867247568Sdes	  *) func_append dllsearchpath ":$testbindir";;
8868174832Sdes	  esac
8869125647Sdes	  ;;
8870125647Sdes	esac
8871117610Sdes      done
8872117610Sdes      # Substitute the hardcoded libdirs into the rpath.
8873117610Sdes      if test -n "$hardcode_libdir_separator" &&
8874117610Sdes	 test -n "$hardcode_libdirs"; then
8875117610Sdes	libdir="$hardcode_libdirs"
8876117610Sdes	eval rpath=\" $hardcode_libdir_flag_spec\"
8877117610Sdes      fi
8878117610Sdes      compile_rpath="$rpath"
8879117610Sdes
8880117610Sdes      rpath=
8881117610Sdes      hardcode_libdirs=
8882117610Sdes      for libdir in $finalize_rpath; do
8883117610Sdes	if test -n "$hardcode_libdir_flag_spec"; then
8884117610Sdes	  if test -n "$hardcode_libdir_separator"; then
8885117610Sdes	    if test -z "$hardcode_libdirs"; then
8886117610Sdes	      hardcode_libdirs="$libdir"
8887117610Sdes	    else
8888117610Sdes	      # Just accumulate the unique libdirs.
8889125647Sdes	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
8890117610Sdes	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
8891117610Sdes		;;
8892117610Sdes	      *)
8893247568Sdes		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
8894117610Sdes		;;
8895117610Sdes	      esac
8896117610Sdes	    fi
8897117610Sdes	  else
8898117610Sdes	    eval flag=\"$hardcode_libdir_flag_spec\"
8899247568Sdes	    func_append rpath " $flag"
8900117610Sdes	  fi
8901117610Sdes	elif test -n "$runpath_var"; then
8902117610Sdes	  case "$finalize_perm_rpath " in
8903117610Sdes	  *" $libdir "*) ;;
8904247568Sdes	  *) func_append finalize_perm_rpath " $libdir" ;;
8905117610Sdes	  esac
8906117610Sdes	fi
8907117610Sdes      done
8908117610Sdes      # Substitute the hardcoded libdirs into the rpath.
8909117610Sdes      if test -n "$hardcode_libdir_separator" &&
8910117610Sdes	 test -n "$hardcode_libdirs"; then
8911117610Sdes	libdir="$hardcode_libdirs"
8912117610Sdes	eval rpath=\" $hardcode_libdir_flag_spec\"
8913117610Sdes      fi
8914117610Sdes      finalize_rpath="$rpath"
8915117610Sdes
8916117610Sdes      if test -n "$libobjs" && test "$build_old_libs" = yes; then
8917117610Sdes	# Transform all the library objects into standard objects.
8918247568Sdes	compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
8919247568Sdes	finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
8920117610Sdes      fi
8921117610Sdes
8922247568Sdes      func_generate_dlsyms "$outputname" "@PROGRAM@" "no"
8923117610Sdes
8924247568Sdes      # template prelinking step
8925247568Sdes      if test -n "$prelink_cmds"; then
8926247568Sdes	func_execute_cmds "$prelink_cmds" 'exit $?'
8927117610Sdes      fi
8928117610Sdes
8929247568Sdes      wrappers_required=yes
8930247568Sdes      case $host in
8931247568Sdes      *cegcc* | *mingw32ce*)
8932247568Sdes        # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
8933247568Sdes        wrappers_required=no
8934247568Sdes        ;;
8935247568Sdes      *cygwin* | *mingw* )
8936247568Sdes        if test "$build_libtool_libs" != yes; then
8937247568Sdes          wrappers_required=no
8938247568Sdes        fi
8939247568Sdes        ;;
8940247568Sdes      *)
8941247568Sdes        if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
8942247568Sdes          wrappers_required=no
8943247568Sdes        fi
8944247568Sdes        ;;
8945247568Sdes      esac
8946247568Sdes      if test "$wrappers_required" = no; then
8947117610Sdes	# Replace the output file specification.
8948247568Sdes	compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
8949117610Sdes	link_command="$compile_command$compile_rpath"
8950117610Sdes
8951117610Sdes	# We have no uninstalled library dependencies, so finalize right now.
8952247568Sdes	exit_status=0
8953247568Sdes	func_show_eval "$link_command" 'exit_status=$?'
8954125647Sdes
8955247568Sdes	if test -n "$postlink_cmds"; then
8956247568Sdes	  func_to_tool_file "$output"
8957247568Sdes	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
8958247568Sdes	  func_execute_cmds "$postlink_cmds" 'exit $?'
8959247568Sdes	fi
8960247568Sdes
8961117610Sdes	# Delete the generated files.
8962247568Sdes	if test -f "$output_objdir/${outputname}S.${objext}"; then
8963247568Sdes	  func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"'
8964117610Sdes	fi
8965117610Sdes
8966174832Sdes	exit $exit_status
8967117610Sdes      fi
8968117610Sdes
8969117610Sdes      if test -n "$compile_shlibpath$finalize_shlibpath"; then
8970117610Sdes	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
8971117610Sdes      fi
8972117610Sdes      if test -n "$finalize_shlibpath"; then
8973117610Sdes	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
8974117610Sdes      fi
8975117610Sdes
8976117610Sdes      compile_var=
8977117610Sdes      finalize_var=
8978117610Sdes      if test -n "$runpath_var"; then
8979117610Sdes	if test -n "$perm_rpath"; then
8980117610Sdes	  # We should set the runpath_var.
8981117610Sdes	  rpath=
8982117610Sdes	  for dir in $perm_rpath; do
8983247568Sdes	    func_append rpath "$dir:"
8984117610Sdes	  done
8985117610Sdes	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
8986117610Sdes	fi
8987117610Sdes	if test -n "$finalize_perm_rpath"; then
8988117610Sdes	  # We should set the runpath_var.
8989117610Sdes	  rpath=
8990117610Sdes	  for dir in $finalize_perm_rpath; do
8991247568Sdes	    func_append rpath "$dir:"
8992117610Sdes	  done
8993117610Sdes	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
8994117610Sdes	fi
8995117610Sdes      fi
8996117610Sdes
8997125647Sdes      if test "$no_install" = yes; then
8998125647Sdes	# We don't need to create a wrapper script.
8999125647Sdes	link_command="$compile_var$compile_command$compile_rpath"
9000125647Sdes	# Replace the output file specification.
9001247568Sdes	link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
9002125647Sdes	# Delete the old output file.
9003247568Sdes	$opt_dry_run || $RM $output
9004125647Sdes	# Link the executable and exit
9005247568Sdes	func_show_eval "$link_command" 'exit $?'
9006247568Sdes
9007247568Sdes	if test -n "$postlink_cmds"; then
9008247568Sdes	  func_to_tool_file "$output"
9009247568Sdes	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
9010247568Sdes	  func_execute_cmds "$postlink_cmds" 'exit $?'
9011247568Sdes	fi
9012247568Sdes
9013141098Sdes	exit $EXIT_SUCCESS
9014125647Sdes      fi
9015125647Sdes
9016117610Sdes      if test "$hardcode_action" = relink; then
9017117610Sdes	# Fast installation is not supported
9018117610Sdes	link_command="$compile_var$compile_command$compile_rpath"
9019117610Sdes	relink_command="$finalize_var$finalize_command$finalize_rpath"
9020125647Sdes
9021247568Sdes	func_warning "this platform does not like uninstalled shared libraries"
9022247568Sdes	func_warning "\`$output' will be relinked during installation"
9023117610Sdes      else
9024117610Sdes	if test "$fast_install" != no; then
9025117610Sdes	  link_command="$finalize_var$compile_command$finalize_rpath"
9026117610Sdes	  if test "$fast_install" = yes; then
9027247568Sdes	    relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
9028117610Sdes	  else
9029117610Sdes	    # fast_install is set to needless
9030117610Sdes	    relink_command=
9031117610Sdes	  fi
9032117610Sdes	else
9033117610Sdes	  link_command="$compile_var$compile_command$compile_rpath"
9034117610Sdes	  relink_command="$finalize_var$finalize_command$finalize_rpath"
9035117610Sdes	fi
9036117610Sdes      fi
9037117610Sdes
9038117610Sdes      # Replace the output file specification.
9039247568Sdes      link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
9040125647Sdes
9041117610Sdes      # Delete the old output files.
9042247568Sdes      $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
9043117610Sdes
9044247568Sdes      func_show_eval "$link_command" 'exit $?'
9045117610Sdes
9046247568Sdes      if test -n "$postlink_cmds"; then
9047247568Sdes	func_to_tool_file "$output_objdir/$outputname"
9048247568Sdes	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'`
9049247568Sdes	func_execute_cmds "$postlink_cmds" 'exit $?'
9050247568Sdes      fi
9051247568Sdes
9052117610Sdes      # Now create the wrapper script.
9053247568Sdes      func_verbose "creating $output"
9054117610Sdes
9055117610Sdes      # Quote the relink command for shipping.
9056117610Sdes      if test -n "$relink_command"; then
9057125647Sdes	# Preserve any variables that may affect compiler behavior
9058125647Sdes	for var in $variables_saved_for_relink; do
9059125647Sdes	  if eval test -z \"\${$var+set}\"; then
9060247568Sdes	    relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
9061125647Sdes	  elif eval var_value=\$$var; test -z "$var_value"; then
9062125647Sdes	    relink_command="$var=; export $var; $relink_command"
9063125647Sdes	  else
9064247568Sdes	    func_quote_for_eval "$var_value"
9065247568Sdes	    relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
9066125647Sdes	  fi
9067125647Sdes	done
9068125647Sdes	relink_command="(cd `pwd`; $relink_command)"
9069247568Sdes	relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
9070117610Sdes      fi
9071117610Sdes
9072247568Sdes      # Only actually do things if not in dry run mode.
9073247568Sdes      $opt_dry_run || {
9074117610Sdes	# win32 will think the script is a binary if it has
9075117610Sdes	# a .exe suffix, so we strip it off here.
9076117610Sdes	case $output in
9077247568Sdes	  *.exe) func_stripname '' '.exe' "$output"
9078247568Sdes	         output=$func_stripname_result ;;
9079117610Sdes	esac
9080125647Sdes	# test for cygwin because mv fails w/o .exe extensions
9081125647Sdes	case $host in
9082141098Sdes	  *cygwin*)
9083141098Sdes	    exeext=.exe
9084247568Sdes	    func_stripname '' '.exe' "$outputname"
9085247568Sdes	    outputname=$func_stripname_result ;;
9086125647Sdes	  *) exeext= ;;
9087125647Sdes	esac
9088141098Sdes	case $host in
9089141098Sdes	  *cygwin* | *mingw* )
9090247568Sdes	    func_dirname_and_basename "$output" "" "."
9091247568Sdes	    output_name=$func_basename_result
9092247568Sdes	    output_path=$func_dirname_result
9093247568Sdes	    cwrappersource="$output_path/$objdir/lt-$output_name.c"
9094247568Sdes	    cwrapper="$output_path/$output_name.exe"
9095247568Sdes	    $RM $cwrappersource $cwrapper
9096247568Sdes	    trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
9097141098Sdes
9098247568Sdes	    func_emit_cwrapperexe_src > $cwrappersource
9099141098Sdes
9100247568Sdes	    # The wrapper executable is built using the $host compiler,
9101247568Sdes	    # because it contains $host paths and files. If cross-
9102247568Sdes	    # compiling, it, like the target executable, must be
9103247568Sdes	    # executed on the $host or under an emulation environment.
9104247568Sdes	    $opt_dry_run || {
9105247568Sdes	      $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
9106247568Sdes	      $STRIP $cwrapper
9107247568Sdes	    }
9108141098Sdes
9109247568Sdes	    # Now, create the wrapper script for func_source use:
9110247568Sdes	    func_ltwrapper_scriptname $cwrapper
9111247568Sdes	    $RM $func_ltwrapper_scriptname_result
9112247568Sdes	    trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
9113247568Sdes	    $opt_dry_run || {
9114247568Sdes	      # note: this script will not be executed, so do not chmod.
9115247568Sdes	      if test "x$build" = "x$host" ; then
9116247568Sdes		$cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
9117247568Sdes	      else
9118247568Sdes		func_emit_wrapper no > $func_ltwrapper_scriptname_result
9119247568Sdes	      fi
9120247568Sdes	    }
9121117610Sdes	  ;;
9122247568Sdes	  * )
9123247568Sdes	    $RM $output
9124247568Sdes	    trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
9125117610Sdes
9126247568Sdes	    func_emit_wrapper no > $output
9127247568Sdes	    chmod +x $output
9128117610Sdes	  ;;
9129117610Sdes	esac
9130247568Sdes      }
9131141098Sdes      exit $EXIT_SUCCESS
9132117610Sdes      ;;
9133117610Sdes    esac
9134117610Sdes
9135117610Sdes    # See if we need to build an old-fashioned archive.
9136117610Sdes    for oldlib in $oldlibs; do
9137117610Sdes
9138117610Sdes      if test "$build_libtool_libs" = convenience; then
9139247568Sdes	oldobjs="$libobjs_save $symfileobj"
9140117610Sdes	addlibs="$convenience"
9141117610Sdes	build_libtool_libs=no
9142117610Sdes      else
9143117610Sdes	if test "$build_libtool_libs" = module; then
9144117610Sdes	  oldobjs="$libobjs_save"
9145117610Sdes	  build_libtool_libs=no
9146117610Sdes	else
9147141098Sdes	  oldobjs="$old_deplibs $non_pic_objects"
9148247568Sdes	  if test "$preload" = yes && test -f "$symfileobj"; then
9149247568Sdes	    func_append oldobjs " $symfileobj"
9150247568Sdes	  fi
9151117610Sdes	fi
9152117610Sdes	addlibs="$old_convenience"
9153117610Sdes      fi
9154117610Sdes
9155117610Sdes      if test -n "$addlibs"; then
9156117610Sdes	gentop="$output_objdir/${outputname}x"
9157247568Sdes	func_append generated " $gentop"
9158125647Sdes
9159141098Sdes	func_extract_archives $gentop $addlibs
9160247568Sdes	func_append oldobjs " $func_extract_archives_result"
9161117610Sdes      fi
9162117610Sdes
9163117610Sdes      # Do each command in the archive commands.
9164117610Sdes      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
9165247568Sdes	cmds=$old_archive_from_new_cmds
9166117610Sdes      else
9167247568Sdes
9168247568Sdes	# Add any objects from preloaded convenience libraries
9169247568Sdes	if test -n "$dlprefiles"; then
9170247568Sdes	  gentop="$output_objdir/${outputname}x"
9171247568Sdes	  func_append generated " $gentop"
9172247568Sdes
9173247568Sdes	  func_extract_archives $gentop $dlprefiles
9174247568Sdes	  func_append oldobjs " $func_extract_archives_result"
9175247568Sdes	fi
9176247568Sdes
9177174832Sdes	# POSIX demands no paths to be encoded in archives.  We have
9178174832Sdes	# to avoid creating archives with duplicate basenames if we
9179174832Sdes	# might have to extract them afterwards, e.g., when creating a
9180174832Sdes	# static archive out of a convenience library, or when linking
9181174832Sdes	# the entirety of a libtool archive into another (currently
9182174832Sdes	# not supported by libtool).
9183174832Sdes	if (for obj in $oldobjs
9184174832Sdes	    do
9185247568Sdes	      func_basename "$obj"
9186247568Sdes	      $ECHO "$func_basename_result"
9187174832Sdes	    done | sort | sort -uc >/dev/null 2>&1); then
9188174832Sdes	  :
9189174832Sdes	else
9190247568Sdes	  echo "copying selected object files to avoid basename conflicts..."
9191247568Sdes	  gentop="$output_objdir/${outputname}x"
9192247568Sdes	  func_append generated " $gentop"
9193247568Sdes	  func_mkdir_p "$gentop"
9194174832Sdes	  save_oldobjs=$oldobjs
9195174832Sdes	  oldobjs=
9196174832Sdes	  counter=1
9197174832Sdes	  for obj in $save_oldobjs
9198174832Sdes	  do
9199247568Sdes	    func_basename "$obj"
9200247568Sdes	    objbase="$func_basename_result"
9201174832Sdes	    case " $oldobjs " in
9202174832Sdes	    " ") oldobjs=$obj ;;
9203174832Sdes	    *[\ /]"$objbase "*)
9204174832Sdes	      while :; do
9205174832Sdes		# Make sure we don't pick an alternate name that also
9206174832Sdes		# overlaps.
9207174832Sdes		newobj=lt$counter-$objbase
9208247568Sdes		func_arith $counter + 1
9209247568Sdes		counter=$func_arith_result
9210174832Sdes		case " $oldobjs " in
9211174832Sdes		*[\ /]"$newobj "*) ;;
9212174832Sdes		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
9213174832Sdes		esac
9214174832Sdes	      done
9215247568Sdes	      func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
9216247568Sdes	      func_append oldobjs " $gentop/$newobj"
9217174832Sdes	      ;;
9218247568Sdes	    *) func_append oldobjs " $obj" ;;
9219174832Sdes	    esac
9220174832Sdes	  done
9221174832Sdes	fi
9222247568Sdes	func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
9223247568Sdes	tool_oldlib=$func_to_tool_file_result
9224141098Sdes	eval cmds=\"$old_archive_cmds\"
9225141098Sdes
9226247568Sdes	func_len " $cmds"
9227247568Sdes	len=$func_len_result
9228247568Sdes	if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
9229141098Sdes	  cmds=$old_archive_cmds
9230247568Sdes	elif test -n "$archiver_list_spec"; then
9231247568Sdes	  func_verbose "using command file archive linking..."
9232247568Sdes	  for obj in $oldobjs
9233247568Sdes	  do
9234247568Sdes	    func_to_tool_file "$obj"
9235247568Sdes	    $ECHO "$func_to_tool_file_result"
9236247568Sdes	  done > $output_objdir/$libname.libcmd
9237247568Sdes	  func_to_tool_file "$output_objdir/$libname.libcmd"
9238247568Sdes	  oldobjs=" $archiver_list_spec$func_to_tool_file_result"
9239247568Sdes	  cmds=$old_archive_cmds
9240141098Sdes	else
9241141098Sdes	  # the command line is too long to link in one step, link in parts
9242247568Sdes	  func_verbose "using piecewise archive linking..."
9243141098Sdes	  save_RANLIB=$RANLIB
9244141098Sdes	  RANLIB=:
9245141098Sdes	  objlist=
9246141098Sdes	  concat_cmds=
9247141098Sdes	  save_oldobjs=$oldobjs
9248247568Sdes	  oldobjs=
9249141098Sdes	  # Is there a better way of finding the last object in the list?
9250141098Sdes	  for obj in $save_oldobjs
9251141098Sdes	  do
9252141098Sdes	    last_oldobj=$obj
9253141098Sdes	  done
9254247568Sdes	  eval test_cmds=\"$old_archive_cmds\"
9255247568Sdes	  func_len " $test_cmds"
9256247568Sdes	  len0=$func_len_result
9257247568Sdes	  len=$len0
9258141098Sdes	  for obj in $save_oldobjs
9259141098Sdes	  do
9260247568Sdes	    func_len " $obj"
9261247568Sdes	    func_arith $len + $func_len_result
9262247568Sdes	    len=$func_arith_result
9263247568Sdes	    func_append objlist " $obj"
9264247568Sdes	    if test "$len" -lt "$max_cmd_len"; then
9265141098Sdes	      :
9266117610Sdes	    else
9267141098Sdes	      # the above command should be used before it gets too long
9268141098Sdes	      oldobjs=$objlist
9269141098Sdes	      if test "$obj" = "$last_oldobj" ; then
9270247568Sdes		RANLIB=$save_RANLIB
9271141098Sdes	      fi
9272141098Sdes	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
9273141098Sdes	      eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
9274141098Sdes	      objlist=
9275247568Sdes	      len=$len0
9276117610Sdes	    fi
9277141098Sdes	  done
9278141098Sdes	  RANLIB=$save_RANLIB
9279141098Sdes	  oldobjs=$objlist
9280141098Sdes	  if test "X$oldobjs" = "X" ; then
9281141098Sdes	    eval cmds=\"\$concat_cmds\"
9282141098Sdes	  else
9283141098Sdes	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
9284117610Sdes	  fi
9285141098Sdes	fi
9286117610Sdes      fi
9287247568Sdes      func_execute_cmds "$cmds" 'exit $?'
9288117610Sdes    done
9289117610Sdes
9290247568Sdes    test -n "$generated" && \
9291247568Sdes      func_show_eval "${RM}r$generated"
9292117610Sdes
9293117610Sdes    # Now create the libtool archive.
9294125647Sdes    case $output in
9295117610Sdes    *.la)
9296117610Sdes      old_library=
9297117610Sdes      test "$build_old_libs" = yes && old_library="$libname.$libext"
9298247568Sdes      func_verbose "creating $output"
9299117610Sdes
9300125647Sdes      # Preserve any variables that may affect compiler behavior
9301125647Sdes      for var in $variables_saved_for_relink; do
9302125647Sdes	if eval test -z \"\${$var+set}\"; then
9303247568Sdes	  relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
9304125647Sdes	elif eval var_value=\$$var; test -z "$var_value"; then
9305125647Sdes	  relink_command="$var=; export $var; $relink_command"
9306125647Sdes	else
9307247568Sdes	  func_quote_for_eval "$var_value"
9308247568Sdes	  relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
9309125647Sdes	fi
9310125647Sdes      done
9311125647Sdes      # Quote the link command for shipping.
9312141098Sdes      relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
9313247568Sdes      relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
9314141098Sdes      if test "$hardcode_automatic" = yes ; then
9315141098Sdes	relink_command=
9316141098Sdes      fi
9317117610Sdes
9318117610Sdes      # Only create the output if not a dry run.
9319247568Sdes      $opt_dry_run || {
9320117610Sdes	for installed in no yes; do
9321117610Sdes	  if test "$installed" = yes; then
9322117610Sdes	    if test -z "$install_libdir"; then
9323117610Sdes	      break
9324117610Sdes	    fi
9325117610Sdes	    output="$output_objdir/$outputname"i
9326125647Sdes	    # Replace all uninstalled libtool libraries with the installed ones
9327125647Sdes	    newdependency_libs=
9328125647Sdes	    for deplib in $dependency_libs; do
9329125647Sdes	      case $deplib in
9330125647Sdes	      *.la)
9331247568Sdes		func_basename "$deplib"
9332247568Sdes		name="$func_basename_result"
9333247568Sdes		func_resolve_sysroot "$deplib"
9334247568Sdes		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result`
9335247568Sdes		test -z "$libdir" && \
9336247568Sdes		  func_fatal_error "\`$deplib' is not a valid libtool archive"
9337247568Sdes		func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"
9338125647Sdes		;;
9339247568Sdes	      -L*)
9340247568Sdes		func_stripname -L '' "$deplib"
9341247568Sdes		func_replace_sysroot "$func_stripname_result"
9342247568Sdes		func_append newdependency_libs " -L$func_replace_sysroot_result"
9343247568Sdes		;;
9344247568Sdes	      -R*)
9345247568Sdes		func_stripname -R '' "$deplib"
9346247568Sdes		func_replace_sysroot "$func_stripname_result"
9347247568Sdes		func_append newdependency_libs " -R$func_replace_sysroot_result"
9348247568Sdes		;;
9349247568Sdes	      *) func_append newdependency_libs " $deplib" ;;
9350125647Sdes	      esac
9351125647Sdes	    done
9352125647Sdes	    dependency_libs="$newdependency_libs"
9353125647Sdes	    newdlfiles=
9354247568Sdes
9355125647Sdes	    for lib in $dlfiles; do
9356247568Sdes	      case $lib in
9357247568Sdes	      *.la)
9358247568Sdes	        func_basename "$lib"
9359247568Sdes		name="$func_basename_result"
9360247568Sdes		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
9361247568Sdes		test -z "$libdir" && \
9362247568Sdes		  func_fatal_error "\`$lib' is not a valid libtool archive"
9363247568Sdes		func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name"
9364247568Sdes		;;
9365247568Sdes	      *) func_append newdlfiles " $lib" ;;
9366247568Sdes	      esac
9367125647Sdes	    done
9368125647Sdes	    dlfiles="$newdlfiles"
9369125647Sdes	    newdlprefiles=
9370125647Sdes	    for lib in $dlprefiles; do
9371247568Sdes	      case $lib in
9372247568Sdes	      *.la)
9373247568Sdes		# Only pass preopened files to the pseudo-archive (for
9374247568Sdes		# eventual linking with the app. that links it) if we
9375247568Sdes		# didn't already link the preopened objects directly into
9376247568Sdes		# the library:
9377247568Sdes		func_basename "$lib"
9378247568Sdes		name="$func_basename_result"
9379247568Sdes		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
9380247568Sdes		test -z "$libdir" && \
9381247568Sdes		  func_fatal_error "\`$lib' is not a valid libtool archive"
9382247568Sdes		func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name"
9383247568Sdes		;;
9384247568Sdes	      esac
9385125647Sdes	    done
9386125647Sdes	    dlprefiles="$newdlprefiles"
9387141098Sdes	  else
9388141098Sdes	    newdlfiles=
9389141098Sdes	    for lib in $dlfiles; do
9390141098Sdes	      case $lib in
9391141098Sdes		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
9392141098Sdes		*) abs=`pwd`"/$lib" ;;
9393141098Sdes	      esac
9394247568Sdes	      func_append newdlfiles " $abs"
9395141098Sdes	    done
9396141098Sdes	    dlfiles="$newdlfiles"
9397141098Sdes	    newdlprefiles=
9398141098Sdes	    for lib in $dlprefiles; do
9399141098Sdes	      case $lib in
9400141098Sdes		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
9401141098Sdes		*) abs=`pwd`"/$lib" ;;
9402141098Sdes	      esac
9403247568Sdes	      func_append newdlprefiles " $abs"
9404141098Sdes	    done
9405141098Sdes	    dlprefiles="$newdlprefiles"
9406117610Sdes	  fi
9407247568Sdes	  $RM $output
9408125647Sdes	  # place dlname in correct position for cygwin
9409247568Sdes	  # In fact, it would be nice if we could use this code for all target
9410247568Sdes	  # systems that can't hard-code library paths into their executables
9411247568Sdes	  # and that have no shared library path variable independent of PATH,
9412247568Sdes	  # but it turns out we can't easily determine that from inspecting
9413247568Sdes	  # libtool variables, so we have to hard-code the OSs to which it
9414247568Sdes	  # applies here; at the moment, that means platforms that use the PE
9415247568Sdes	  # object format with DLL files.  See the long comment at the top of
9416247568Sdes	  # tests/bindir.at for full details.
9417125647Sdes	  tdlname=$dlname
9418125647Sdes	  case $host,$output,$installed,$module,$dlname in
9419247568Sdes	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
9420247568Sdes	      # If a -bindir argument was supplied, place the dll there.
9421247568Sdes	      if test "x$bindir" != x ;
9422247568Sdes	      then
9423247568Sdes		func_relative_path "$install_libdir" "$bindir"
9424247568Sdes		tdlname=$func_relative_path_result$dlname
9425247568Sdes	      else
9426247568Sdes		# Otherwise fall back on heuristic.
9427247568Sdes		tdlname=../bin/$dlname
9428247568Sdes	      fi
9429247568Sdes	      ;;
9430125647Sdes	  esac
9431247568Sdes	  $ECHO > $output "\
9432117610Sdes# $outputname - a libtool library file
9433247568Sdes# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
9434117610Sdes#
9435117610Sdes# Please DO NOT delete this file!
9436117610Sdes# It is necessary for linking the library.
9437117610Sdes
9438117610Sdes# The name that we can dlopen(3).
9439125647Sdesdlname='$tdlname'
9440117610Sdes
9441117610Sdes# Names of this library.
9442117610Sdeslibrary_names='$library_names'
9443117610Sdes
9444117610Sdes# The name of the static archive.
9445117610Sdesold_library='$old_library'
9446117610Sdes
9447247568Sdes# Linker flags that can not go in dependency_libs.
9448247568Sdesinherited_linker_flags='$new_inherited_linker_flags'
9449247568Sdes
9450117610Sdes# Libraries that this one depends upon.
9451117610Sdesdependency_libs='$dependency_libs'
9452117610Sdes
9453247568Sdes# Names of additional weak libraries provided by this library
9454247568Sdesweak_library_names='$weak_libs'
9455247568Sdes
9456117610Sdes# Version information for $libname.
9457117610Sdescurrent=$current
9458117610Sdesage=$age
9459117610Sdesrevision=$revision
9460117610Sdes
9461117610Sdes# Is this an already installed library?
9462117610Sdesinstalled=$installed
9463117610Sdes
9464141098Sdes# Should we warn about portability when linking against -modules?
9465141098Sdesshouldnotlink=$module
9466141098Sdes
9467125647Sdes# Files to dlopen/dlpreopen
9468125647Sdesdlopen='$dlfiles'
9469125647Sdesdlpreopen='$dlprefiles'
9470125647Sdes
9471117610Sdes# Directory that this library needs to be installed in:
9472125647Sdeslibdir='$install_libdir'"
9473141098Sdes	  if test "$installed" = no && test "$need_relink" = yes; then
9474247568Sdes	    $ECHO >> $output "\
9475125647Sdesrelink_command=\"$relink_command\""
9476125647Sdes	  fi
9477117610Sdes	done
9478247568Sdes      }
9479117610Sdes
9480117610Sdes      # Do a symbolic link so that the libtool archive can be found in
9481117610Sdes      # LD_LIBRARY_PATH before the program is installed.
9482247568Sdes      func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
9483117610Sdes      ;;
9484117610Sdes    esac
9485141098Sdes    exit $EXIT_SUCCESS
9486247568Sdes}
9487117610Sdes
9488247568Sdes{ test "$opt_mode" = link || test "$opt_mode" = relink; } &&
9489247568Sdes    func_mode_link ${1+"$@"}
9490117610Sdes
9491117610Sdes
9492247568Sdes# func_mode_uninstall arg...
9493247568Sdesfunc_mode_uninstall ()
9494247568Sdes{
9495247568Sdes    $opt_debug
9496247568Sdes    RM="$nonopt"
9497117610Sdes    files=
9498125647Sdes    rmforce=
9499125647Sdes    exit_status=0
9500117610Sdes
9501125647Sdes    # This variable tells wrapper scripts just to set variables rather
9502125647Sdes    # than running their programs.
9503125647Sdes    libtool_install_magic="$magic"
9504125647Sdes
9505117610Sdes    for arg
9506117610Sdes    do
9507125647Sdes      case $arg in
9508247568Sdes      -f) func_append RM " $arg"; rmforce=yes ;;
9509247568Sdes      -*) func_append RM " $arg" ;;
9510247568Sdes      *) func_append files " $arg" ;;
9511117610Sdes      esac
9512117610Sdes    done
9513117610Sdes
9514247568Sdes    test -z "$RM" && \
9515247568Sdes      func_fatal_help "you must specify an RM program"
9516117610Sdes
9517125647Sdes    rmdirs=
9518125647Sdes
9519117610Sdes    for file in $files; do
9520247568Sdes      func_dirname "$file" "" "."
9521247568Sdes      dir="$func_dirname_result"
9522247568Sdes      if test "X$dir" = X.; then
9523247568Sdes	odir="$objdir"
9524125647Sdes      else
9525247568Sdes	odir="$dir/$objdir"
9526125647Sdes      fi
9527247568Sdes      func_basename "$file"
9528247568Sdes      name="$func_basename_result"
9529247568Sdes      test "$opt_mode" = uninstall && odir="$dir"
9530117610Sdes
9531247568Sdes      # Remember odir for removal later, being careful to avoid duplicates
9532247568Sdes      if test "$opt_mode" = clean; then
9533125647Sdes	case " $rmdirs " in
9534247568Sdes	  *" $odir "*) ;;
9535247568Sdes	  *) func_append rmdirs " $odir" ;;
9536125647Sdes	esac
9537125647Sdes      fi
9538125647Sdes
9539125647Sdes      # Don't error if the file doesn't exist and rm -f was used.
9540247568Sdes      if { test -L "$file"; } >/dev/null 2>&1 ||
9541247568Sdes	 { test -h "$file"; } >/dev/null 2>&1 ||
9542247568Sdes	 test -f "$file"; then
9543125647Sdes	:
9544125647Sdes      elif test -d "$file"; then
9545125647Sdes	exit_status=1
9546125647Sdes	continue
9547125647Sdes      elif test "$rmforce" = yes; then
9548125647Sdes	continue
9549125647Sdes      fi
9550125647Sdes
9551117610Sdes      rmfiles="$file"
9552117610Sdes
9553125647Sdes      case $name in
9554117610Sdes      *.la)
9555117610Sdes	# Possibly a libtool archive, so verify it.
9556247568Sdes	if func_lalib_p "$file"; then
9557247568Sdes	  func_source $dir/$name
9558117610Sdes
9559117610Sdes	  # Delete the libtool libraries and symlinks.
9560117610Sdes	  for n in $library_names; do
9561247568Sdes	    func_append rmfiles " $odir/$n"
9562117610Sdes	  done
9563247568Sdes	  test -n "$old_library" && func_append rmfiles " $odir/$old_library"
9564117610Sdes
9565247568Sdes	  case "$opt_mode" in
9566174832Sdes	  clean)
9567247568Sdes	    case " $library_names " in
9568174832Sdes	    *" $dlname "*) ;;
9569247568Sdes	    *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;;
9570174832Sdes	    esac
9571247568Sdes	    test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i"
9572174832Sdes	    ;;
9573174832Sdes	  uninstall)
9574125647Sdes	    if test -n "$library_names"; then
9575125647Sdes	      # Do each command in the postuninstall commands.
9576247568Sdes	      func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
9577125647Sdes	    fi
9578117610Sdes
9579125647Sdes	    if test -n "$old_library"; then
9580125647Sdes	      # Do each command in the old_postuninstall commands.
9581247568Sdes	      func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
9582125647Sdes	    fi
9583125647Sdes	    # FIXME: should reinstall the best remaining shared library.
9584174832Sdes	    ;;
9585174832Sdes	  esac
9586117610Sdes	fi
9587117610Sdes	;;
9588117610Sdes
9589117610Sdes      *.lo)
9590141098Sdes	# Possibly a libtool object, so verify it.
9591247568Sdes	if func_lalib_p "$file"; then
9592141098Sdes
9593141098Sdes	  # Read the .lo file
9594247568Sdes	  func_source $dir/$name
9595141098Sdes
9596141098Sdes	  # Add PIC object to the list of files to remove.
9597247568Sdes	  if test -n "$pic_object" &&
9598247568Sdes	     test "$pic_object" != none; then
9599247568Sdes	    func_append rmfiles " $dir/$pic_object"
9600141098Sdes	  fi
9601141098Sdes
9602141098Sdes	  # Add non-PIC object to the list of files to remove.
9603247568Sdes	  if test -n "$non_pic_object" &&
9604247568Sdes	     test "$non_pic_object" != none; then
9605247568Sdes	    func_append rmfiles " $dir/$non_pic_object"
9606141098Sdes	  fi
9607117610Sdes	fi
9608117610Sdes	;;
9609117610Sdes
9610117610Sdes      *)
9611247568Sdes	if test "$opt_mode" = clean ; then
9612141098Sdes	  noexename=$name
9613141098Sdes	  case $file in
9614141098Sdes	  *.exe)
9615247568Sdes	    func_stripname '' '.exe' "$file"
9616247568Sdes	    file=$func_stripname_result
9617247568Sdes	    func_stripname '' '.exe' "$name"
9618247568Sdes	    noexename=$func_stripname_result
9619141098Sdes	    # $file with .exe has already been added to rmfiles,
9620141098Sdes	    # add $file without .exe
9621247568Sdes	    func_append rmfiles " $file"
9622141098Sdes	    ;;
9623141098Sdes	  esac
9624141098Sdes	  # Do a test to see if this is a libtool program.
9625247568Sdes	  if func_ltwrapper_p "$file"; then
9626247568Sdes	    if func_ltwrapper_executable_p "$file"; then
9627247568Sdes	      func_ltwrapper_scriptname "$file"
9628247568Sdes	      relink_command=
9629247568Sdes	      func_source $func_ltwrapper_scriptname_result
9630247568Sdes	      func_append rmfiles " $func_ltwrapper_scriptname_result"
9631247568Sdes	    else
9632247568Sdes	      relink_command=
9633247568Sdes	      func_source $dir/$noexename
9634247568Sdes	    fi
9635125647Sdes
9636141098Sdes	    # note $name still contains .exe if it was in $file originally
9637141098Sdes	    # as does the version of $file that was added into $rmfiles
9638247568Sdes	    func_append rmfiles " $odir/$name $odir/${name}S.${objext}"
9639141098Sdes	    if test "$fast_install" = yes && test -n "$relink_command"; then
9640247568Sdes	      func_append rmfiles " $odir/lt-$name"
9641141098Sdes	    fi
9642141098Sdes	    if test "X$noexename" != "X$name" ; then
9643247568Sdes	      func_append rmfiles " $odir/lt-${noexename}.c"
9644141098Sdes	    fi
9645125647Sdes	  fi
9646125647Sdes	fi
9647117610Sdes	;;
9648117610Sdes      esac
9649247568Sdes      func_show_eval "$RM $rmfiles" 'exit_status=1'
9650117610Sdes    done
9651125647Sdes
9652125647Sdes    # Try to remove the ${objdir}s in the directories where we deleted files
9653125647Sdes    for dir in $rmdirs; do
9654125647Sdes      if test -d "$dir"; then
9655247568Sdes	func_show_eval "rmdir $dir >/dev/null 2>&1"
9656125647Sdes      fi
9657125647Sdes    done
9658125647Sdes
9659125647Sdes    exit $exit_status
9660247568Sdes}
9661117610Sdes
9662247568Sdes{ test "$opt_mode" = uninstall || test "$opt_mode" = clean; } &&
9663247568Sdes    func_mode_uninstall ${1+"$@"}
9664117610Sdes
9665247568Sdestest -z "$opt_mode" && {
9666247568Sdes  help="$generic_help"
9667247568Sdes  func_fatal_help "you must specify a MODE"
9668247568Sdes}
9669117610Sdes
9670247568Sdestest -z "$exec_cmd" && \
9671247568Sdes  func_fatal_help "invalid operation mode \`$opt_mode'"
9672247568Sdes
9673125647Sdesif test -n "$exec_cmd"; then
9674247568Sdes  eval exec "$exec_cmd"
9675141098Sdes  exit $EXIT_FAILURE
9676125647Sdesfi
9677125647Sdes
9678247568Sdesexit $exit_status
9679117610Sdes
9680117610Sdes
9681141098Sdes# The TAGs below are defined such that we never get into a situation
9682141098Sdes# in which we disable both kinds of libraries.  Given conflicting
9683141098Sdes# choices, we go for a static library, that is the most portable,
9684141098Sdes# since we can't tell whether shared libraries were disabled because
9685141098Sdes# the user asked for that or because the platform doesn't support
9686141098Sdes# them.  This is particularly important on AIX, because we don't
9687141098Sdes# support having both static and shared libraries enabled at the same
9688141098Sdes# time on that platform, so we default to a shared-only configuration.
9689141098Sdes# If a disable-shared tag is given, we'll fallback to a static-only
9690141098Sdes# configuration.  But we'll never go from static-only to shared-only.
9691141098Sdes
9692141098Sdes# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
9693247568Sdesbuild_libtool_libs=no
9694247568Sdesbuild_old_libs=yes
9695141098Sdes# ### END LIBTOOL TAG CONFIG: disable-shared
9696141098Sdes
9697141098Sdes# ### BEGIN LIBTOOL TAG CONFIG: disable-static
9698247568Sdesbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
9699141098Sdes# ### END LIBTOOL TAG CONFIG: disable-static
9700141098Sdes
9701117610Sdes# Local Variables:
9702117610Sdes# mode:shell-script
9703117610Sdes# sh-indentation:2
9704117610Sdes# End:
9705247568Sdes# vi:sw=2
9706247568Sdes
9707