1238104Sdes
2238104Sdes# libtool (GNU libtool) 2.4.2
3238104Sdes# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
4238104Sdes
5238104Sdes# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006,
6238104Sdes# 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
7238104Sdes# This is free software; see the source for copying conditions.  There is NO
8238104Sdes# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9238104Sdes
10238104Sdes# GNU Libtool is free software; you can redistribute it and/or modify
11238104Sdes# it under the terms of the GNU General Public License as published by
12238104Sdes# the Free Software Foundation; either version 2 of the License, or
13238104Sdes# (at your option) any later version.
14238104Sdes#
15238104Sdes# As a special exception to the GNU General Public License,
16238104Sdes# if you distribute this file as part of a program or library that
17238104Sdes# is built using GNU Libtool, you may include this file under the
18238104Sdes# same distribution terms that you use for the rest of that program.
19238104Sdes#
20238104Sdes# GNU Libtool is distributed in the hope that it will be useful, but
21238104Sdes# WITHOUT ANY WARRANTY; without even the implied warranty of
22238104Sdes# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
23238104Sdes# General Public License for more details.
24238104Sdes#
25238104Sdes# You should have received a copy of the GNU General Public License
26238104Sdes# along with GNU Libtool; see the file COPYING.  If not, a copy
27238104Sdes# can be downloaded from http://www.gnu.org/licenses/gpl.html,
28238104Sdes# or obtained by writing to the Free Software Foundation, Inc.,
29238104Sdes# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
30238104Sdes
31238104Sdes# Usage: $progname [OPTION]... [MODE-ARG]...
32238104Sdes#
33238104Sdes# Provide generalized library-building support services.
34238104Sdes#
35238104Sdes#       --config             show all configuration variables
36238104Sdes#       --debug              enable verbose shell tracing
37238104Sdes#   -n, --dry-run            display commands without modifying any files
38238104Sdes#       --features           display basic configuration information and exit
39238104Sdes#       --mode=MODE          use operation mode MODE
40238104Sdes#       --preserve-dup-deps  don't remove duplicate dependency libraries
41238104Sdes#       --quiet, --silent    don't print informational messages
42238104Sdes#       --no-quiet, --no-silent
43238104Sdes#                            print informational messages (default)
44238104Sdes#       --no-warn            don't display warning messages
45238104Sdes#       --tag=TAG            use configuration variables from tag TAG
46238104Sdes#   -v, --verbose            print more informational messages than default
47238104Sdes#       --no-verbose         don't print the extra informational messages
48238104Sdes#       --version            print version information
49238104Sdes#   -h, --help, --help-all   print short, long, or detailed help message
50238104Sdes#
51238104Sdes# MODE must be one of the following:
52238104Sdes#
53238104Sdes#         clean              remove files from the build directory
54238104Sdes#         compile            compile a source file into a libtool object
55238104Sdes#         execute            automatically set library path, then run a program
56238104Sdes#         finish             complete the installation of libtool libraries
57238104Sdes#         install            install libraries or executables
58238104Sdes#         link               create a library or an executable
59238104Sdes#         uninstall          remove libraries from an installed directory
60238104Sdes#
61238104Sdes# MODE-ARGS vary depending on the MODE.  When passed as first option,
62238104Sdes# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that.
63238104Sdes# Try `$progname --help --mode=MODE' for a more detailed description of MODE.
64238104Sdes#
65238104Sdes# When reporting a bug, please describe a test case to reproduce it and
66238104Sdes# include the following information:
67238104Sdes#
68238104Sdes#         host-triplet:	$host
69238104Sdes#         shell:		$SHELL
70238104Sdes#         compiler:		$LTCC
71238104Sdes#         compiler flags:		$LTCFLAGS
72238104Sdes#         linker:		$LD (gnu? $with_gnu_ld)
73238104Sdes#         $progname:	(GNU libtool) 2.4.2 Debian-2.4.2-1ubuntu1
74238104Sdes#         automake:	$automake_version
75238104Sdes#         autoconf:	$autoconf_version
76238104Sdes#
77238104Sdes# Report bugs to <bug-libtool@gnu.org>.
78238104Sdes# GNU libtool home page: <http://www.gnu.org/software/libtool/>.
79238104Sdes# General help using GNU software: <http://www.gnu.org/gethelp/>.
80238104Sdes
81238104SdesPROGRAM=libtool
82238104SdesPACKAGE=libtool
83238104SdesVERSION="2.4.2 Debian-2.4.2-1ubuntu1"
84238104SdesTIMESTAMP=""
85238104Sdespackage_revision=1.3337
86238104Sdes
87238104Sdes# Be Bourne compatible
88238104Sdesif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
89238104Sdes  emulate sh
90238104Sdes  NULLCMD=:
91238104Sdes  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
92238104Sdes  # is contrary to our usage.  Disable this feature.
93238104Sdes  alias -g '${1+"$@"}'='"$@"'
94238104Sdes  setopt NO_GLOB_SUBST
95238104Sdeselse
96238104Sdes  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
97238104Sdesfi
98238104SdesBIN_SH=xpg4; export BIN_SH # for Tru64
99238104SdesDUALCASE=1; export DUALCASE # for MKS sh
100238104Sdes
101238104Sdes# A function that is used when there is no print builtin or printf.
102238104Sdesfunc_fallback_echo ()
103238104Sdes{
104238104Sdes  eval 'cat <<_LTECHO_EOF
105238104Sdes$1
106238104Sdes_LTECHO_EOF'
107238104Sdes}
108238104Sdes
109238104Sdes# NLS nuisances: We save the old values to restore during execute mode.
110238104Sdeslt_user_locale=
111238104Sdeslt_safe_locale=
112238104Sdesfor lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
113238104Sdesdo
114238104Sdes  eval "if test \"\${$lt_var+set}\" = set; then
115238104Sdes          save_$lt_var=\$$lt_var
116238104Sdes          $lt_var=C
117238104Sdes	  export $lt_var
118238104Sdes	  lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\"
119238104Sdes	  lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
120238104Sdes	fi"
121238104Sdesdone
122238104SdesLC_ALL=C
123238104SdesLANGUAGE=C
124238104Sdesexport LANGUAGE LC_ALL
125238104Sdes
126238104Sdes$lt_unset CDPATH
127238104Sdes
128238104Sdes
129238104Sdes# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
130238104Sdes# is ksh but when the shell is invoked as "sh" and the current value of
131238104Sdes# the _XPG environment variable is not equal to 1 (one), the special
132238104Sdes# positional parameter $0, within a function call, is the name of the
133238104Sdes# function.
134238104Sdesprogpath="$0"
135238104Sdes
136238104Sdes
137238104Sdes
138238104Sdes: ${CP="cp -f"}
139238104Sdestest "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'}
140238104Sdes: ${MAKE="make"}
141238104Sdes: ${MKDIR="mkdir"}
142238104Sdes: ${MV="mv -f"}
143238104Sdes: ${RM="rm -f"}
144238104Sdes: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
145238104Sdes: ${Xsed="$SED -e 1s/^X//"}
146238104Sdes
147238104Sdes# Global variables:
148238104SdesEXIT_SUCCESS=0
149238104SdesEXIT_FAILURE=1
150238104SdesEXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
151238104SdesEXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
152238104Sdes
153238104Sdesexit_status=$EXIT_SUCCESS
154238104Sdes
155238104Sdes# Make sure IFS has a sensible default
156238104Sdeslt_nl='
157238104Sdes'
158238104SdesIFS=" 	$lt_nl"
159238104Sdes
160238104Sdesdirname="s,/[^/]*$,,"
161238104Sdesbasename="s,^.*/,,"
162238104Sdes
163238104Sdes# func_dirname file append nondir_replacement
164238104Sdes# Compute the dirname of FILE.  If nonempty, add APPEND to the result,
165238104Sdes# otherwise set result to NONDIR_REPLACEMENT.
166238104Sdesfunc_dirname ()
167238104Sdes{
168238104Sdes    func_dirname_result=`$ECHO "${1}" | $SED "$dirname"`
169238104Sdes    if test "X$func_dirname_result" = "X${1}"; then
170238104Sdes      func_dirname_result="${3}"
171238104Sdes    else
172238104Sdes      func_dirname_result="$func_dirname_result${2}"
173238104Sdes    fi
174238104Sdes} # func_dirname may be replaced by extended shell implementation
175238104Sdes
176238104Sdes
177238104Sdes# func_basename file
178238104Sdesfunc_basename ()
179238104Sdes{
180238104Sdes    func_basename_result=`$ECHO "${1}" | $SED "$basename"`
181238104Sdes} # func_basename may be replaced by extended shell implementation
182238104Sdes
183238104Sdes
184238104Sdes# func_dirname_and_basename file append nondir_replacement
185238104Sdes# perform func_basename and func_dirname in a single function
186238104Sdes# call:
187238104Sdes#   dirname:  Compute the dirname of FILE.  If nonempty,
188238104Sdes#             add APPEND to the result, otherwise set result
189238104Sdes#             to NONDIR_REPLACEMENT.
190238104Sdes#             value returned in "$func_dirname_result"
191238104Sdes#   basename: Compute filename of FILE.
192238104Sdes#             value retuned in "$func_basename_result"
193238104Sdes# Implementation must be kept synchronized with func_dirname
194238104Sdes# and func_basename. For efficiency, we do not delegate to
195238104Sdes# those functions but instead duplicate the functionality here.
196238104Sdesfunc_dirname_and_basename ()
197238104Sdes{
198238104Sdes    # Extract subdirectory from the argument.
199238104Sdes    func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"`
200238104Sdes    if test "X$func_dirname_result" = "X${1}"; then
201238104Sdes      func_dirname_result="${3}"
202238104Sdes    else
203238104Sdes      func_dirname_result="$func_dirname_result${2}"
204238104Sdes    fi
205238104Sdes    func_basename_result=`$ECHO "${1}" | $SED -e "$basename"`
206238104Sdes} # func_dirname_and_basename may be replaced by extended shell implementation
207238104Sdes
208238104Sdes
209238104Sdes# func_stripname prefix suffix name
210238104Sdes# strip PREFIX and SUFFIX off of NAME.
211238104Sdes# PREFIX and SUFFIX must not contain globbing or regex special
212238104Sdes# characters, hashes, percent signs, but SUFFIX may contain a leading
213238104Sdes# dot (in which case that matches only a dot).
214238104Sdes# func_strip_suffix prefix name
215238104Sdesfunc_stripname ()
216238104Sdes{
217238104Sdes    case ${2} in
218238104Sdes      .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;;
219238104Sdes      *)  func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;;
220238104Sdes    esac
221238104Sdes} # func_stripname may be replaced by extended shell implementation
222238104Sdes
223238104Sdes
224238104Sdes# These SED scripts presuppose an absolute path with a trailing slash.
225238104Sdespathcar='s,^/\([^/]*\).*$,\1,'
226238104Sdespathcdr='s,^/[^/]*,,'
227238104Sdesremovedotparts=':dotsl
228238104Sdes		s@/\./@/@g
229238104Sdes		t dotsl
230238104Sdes		s,/\.$,/,'
231238104Sdescollapseslashes='s@/\{1,\}@/@g'
232238104Sdesfinalslash='s,/*$,/,'
233238104Sdes
234238104Sdes# func_normal_abspath PATH
235238104Sdes# Remove doubled-up and trailing slashes, "." path components,
236238104Sdes# and cancel out any ".." path components in PATH after making
237238104Sdes# it an absolute path.
238238104Sdes#             value returned in "$func_normal_abspath_result"
239238104Sdesfunc_normal_abspath ()
240238104Sdes{
241238104Sdes  # Start from root dir and reassemble the path.
242238104Sdes  func_normal_abspath_result=
243238104Sdes  func_normal_abspath_tpath=$1
244238104Sdes  func_normal_abspath_altnamespace=
245238104Sdes  case $func_normal_abspath_tpath in
246238104Sdes    "")
247238104Sdes      # Empty path, that just means $cwd.
248238104Sdes      func_stripname '' '/' "`pwd`"
249238104Sdes      func_normal_abspath_result=$func_stripname_result
250238104Sdes      return
251238104Sdes    ;;
252238104Sdes    # The next three entries are used to spot a run of precisely
253238104Sdes    # two leading slashes without using negated character classes;
254238104Sdes    # we take advantage of case's first-match behaviour.
255238104Sdes    ///*)
256238104Sdes      # Unusual form of absolute path, do nothing.
257238104Sdes    ;;
258238104Sdes    //*)
259238104Sdes      # Not necessarily an ordinary path; POSIX reserves leading '//'
260238104Sdes      # and for example Cygwin uses it to access remote file shares
261238104Sdes      # over CIFS/SMB, so we conserve a leading double slash if found.
262238104Sdes      func_normal_abspath_altnamespace=/
263238104Sdes    ;;
264238104Sdes    /*)
265238104Sdes      # Absolute path, do nothing.
266238104Sdes    ;;
267238104Sdes    *)
268238104Sdes      # Relative path, prepend $cwd.
269238104Sdes      func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
270238104Sdes    ;;
271238104Sdes  esac
272238104Sdes  # Cancel out all the simple stuff to save iterations.  We also want
273238104Sdes  # the path to end with a slash for ease of parsing, so make sure
274238104Sdes  # there is one (and only one) here.
275238104Sdes  func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
276238104Sdes        -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"`
277238104Sdes  while :; do
278238104Sdes    # Processed it all yet?
279238104Sdes    if test "$func_normal_abspath_tpath" = / ; then
280238104Sdes      # If we ascended to the root using ".." the result may be empty now.
281238104Sdes      if test -z "$func_normal_abspath_result" ; then
282238104Sdes        func_normal_abspath_result=/
283238104Sdes      fi
284238104Sdes      break
285238104Sdes    fi
286238104Sdes    func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
287238104Sdes        -e "$pathcar"`
288238104Sdes    func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
289238104Sdes        -e "$pathcdr"`
290238104Sdes    # Figure out what to do with it
291238104Sdes    case $func_normal_abspath_tcomponent in
292238104Sdes      "")
293238104Sdes        # Trailing empty path component, ignore it.
294238104Sdes      ;;
295238104Sdes      ..)
296238104Sdes        # Parent dir; strip last assembled component from result.
297238104Sdes        func_dirname "$func_normal_abspath_result"
298238104Sdes        func_normal_abspath_result=$func_dirname_result
299238104Sdes      ;;
300238104Sdes      *)
301238104Sdes        # Actual path component, append it.
302238104Sdes        func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent
303238104Sdes      ;;
304238104Sdes    esac
305238104Sdes  done
306238104Sdes  # Restore leading double-slash if one was found on entry.
307238104Sdes  func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
308238104Sdes}
309238104Sdes
310238104Sdes# func_relative_path SRCDIR DSTDIR
311238104Sdes# generates a relative path from SRCDIR to DSTDIR, with a trailing
312238104Sdes# slash if non-empty, suitable for immediately appending a filename
313238104Sdes# without needing to append a separator.
314238104Sdes#             value returned in "$func_relative_path_result"
315238104Sdesfunc_relative_path ()
316238104Sdes{
317238104Sdes  func_relative_path_result=
318238104Sdes  func_normal_abspath "$1"
319238104Sdes  func_relative_path_tlibdir=$func_normal_abspath_result
320238104Sdes  func_normal_abspath "$2"
321238104Sdes  func_relative_path_tbindir=$func_normal_abspath_result
322238104Sdes
323238104Sdes  # Ascend the tree starting from libdir
324238104Sdes  while :; do
325238104Sdes    # check if we have found a prefix of bindir
326238104Sdes    case $func_relative_path_tbindir in
327238104Sdes      $func_relative_path_tlibdir)
328238104Sdes        # found an exact match
329238104Sdes        func_relative_path_tcancelled=
330238104Sdes        break
331238104Sdes        ;;
332238104Sdes      $func_relative_path_tlibdir*)
333238104Sdes        # found a matching prefix
334238104Sdes        func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
335238104Sdes        func_relative_path_tcancelled=$func_stripname_result
336238104Sdes        if test -z "$func_relative_path_result"; then
337238104Sdes          func_relative_path_result=.
338238104Sdes        fi
339238104Sdes        break
340238104Sdes        ;;
341238104Sdes      *)
342238104Sdes        func_dirname $func_relative_path_tlibdir
343238104Sdes        func_relative_path_tlibdir=${func_dirname_result}
344238104Sdes        if test "x$func_relative_path_tlibdir" = x ; then
345238104Sdes          # Have to descend all the way to the root!
346238104Sdes          func_relative_path_result=../$func_relative_path_result
347238104Sdes          func_relative_path_tcancelled=$func_relative_path_tbindir
348238104Sdes          break
349238104Sdes        fi
350238104Sdes        func_relative_path_result=../$func_relative_path_result
351238104Sdes        ;;
352238104Sdes    esac
353238104Sdes  done
354238104Sdes
355238104Sdes  # Now calculate path; take care to avoid doubling-up slashes.
356238104Sdes  func_stripname '' '/' "$func_relative_path_result"
357238104Sdes  func_relative_path_result=$func_stripname_result
358238104Sdes  func_stripname '/' '/' "$func_relative_path_tcancelled"
359238104Sdes  if test "x$func_stripname_result" != x ; then
360238104Sdes    func_relative_path_result=${func_relative_path_result}/${func_stripname_result}
361238104Sdes  fi
362238104Sdes
363238104Sdes  # Normalisation. If bindir is libdir, return empty string,
364238104Sdes  # else relative path ending with a slash; either way, target
365238104Sdes  # file name can be directly appended.
366238104Sdes  if test ! -z "$func_relative_path_result"; then
367238104Sdes    func_stripname './' '' "$func_relative_path_result/"
368238104Sdes    func_relative_path_result=$func_stripname_result
369238104Sdes  fi
370238104Sdes}
371238104Sdes
372238104Sdes# The name of this program:
373238104Sdesfunc_dirname_and_basename "$progpath"
374238104Sdesprogname=$func_basename_result
375238104Sdes
376238104Sdes# Make sure we have an absolute path for reexecution:
377238104Sdescase $progpath in
378238104Sdes  [\\/]*|[A-Za-z]:\\*) ;;
379238104Sdes  *[\\/]*)
380238104Sdes     progdir=$func_dirname_result
381238104Sdes     progdir=`cd "$progdir" && pwd`
382238104Sdes     progpath="$progdir/$progname"
383238104Sdes     ;;
384238104Sdes  *)
385238104Sdes     save_IFS="$IFS"
386238104Sdes     IFS=${PATH_SEPARATOR-:}
387238104Sdes     for progdir in $PATH; do
388238104Sdes       IFS="$save_IFS"
389238104Sdes       test -x "$progdir/$progname" && break
390238104Sdes     done
391238104Sdes     IFS="$save_IFS"
392238104Sdes     test -n "$progdir" || progdir=`pwd`
393238104Sdes     progpath="$progdir/$progname"
394238104Sdes     ;;
395238104Sdesesac
396238104Sdes
397238104Sdes# Sed substitution that helps us do robust quoting.  It backslashifies
398238104Sdes# metacharacters that are still active within double-quoted strings.
399238104SdesXsed="${SED}"' -e 1s/^X//'
400238104Sdessed_quote_subst='s/\([`"$\\]\)/\\\1/g'
401238104Sdes
402238104Sdes# Same as above, but do not quote variable references.
403238104Sdesdouble_quote_subst='s/\(["`\\]\)/\\\1/g'
404238104Sdes
405238104Sdes# Sed substitution that turns a string into a regex matching for the
406238104Sdes# string literally.
407238104Sdessed_make_literal_regex='s,[].[^$\\*\/],\\&,g'
408238104Sdes
409238104Sdes# Sed substitution that converts a w32 file name or path
410238104Sdes# which contains forward slashes, into one that contains
411238104Sdes# (escaped) backslashes.  A very naive implementation.
412238104Sdeslt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
413238104Sdes
414238104Sdes# Re-`\' parameter expansions in output of double_quote_subst that were
415238104Sdes# `\'-ed in input to the same.  If an odd number of `\' preceded a '$'
416238104Sdes# in input to double_quote_subst, that '$' was protected from expansion.
417238104Sdes# Since each input `\' is now two `\'s, look for any number of runs of
418238104Sdes# four `\'s followed by two `\'s and then a '$'.  `\' that '$'.
419238104Sdesbs='\\'
420238104Sdesbs2='\\\\'
421238104Sdesbs4='\\\\\\\\'
422238104Sdesdollar='\$'
423238104Sdessed_double_backslash="\
424238104Sdes  s/$bs4/&\\
425238104Sdes/g
426238104Sdes  s/^$bs2$dollar/$bs&/
427238104Sdes  s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
428238104Sdes  s/\n//g"
429238104Sdes
430238104Sdes# Standard options:
431238104Sdesopt_dry_run=false
432238104Sdesopt_help=false
433238104Sdesopt_quiet=false
434238104Sdesopt_verbose=false
435238104Sdesopt_warning=:
436238104Sdes
437238104Sdes# func_echo arg...
438238104Sdes# Echo program name prefixed message, along with the current mode
439238104Sdes# name if it has been set yet.
440238104Sdesfunc_echo ()
441238104Sdes{
442238104Sdes    $ECHO "$progname: ${opt_mode+$opt_mode: }$*"
443238104Sdes}
444238104Sdes
445238104Sdes# func_verbose arg...
446238104Sdes# Echo program name prefixed message in verbose mode only.
447238104Sdesfunc_verbose ()
448238104Sdes{
449238104Sdes    $opt_verbose && func_echo ${1+"$@"}
450238104Sdes
451238104Sdes    # A bug in bash halts the script if the last line of a function
452238104Sdes    # fails when set -e is in force, so we need another command to
453238104Sdes    # work around that:
454238104Sdes    :
455238104Sdes}
456238104Sdes
457238104Sdes# func_echo_all arg...
458238104Sdes# Invoke $ECHO with all args, space-separated.
459238104Sdesfunc_echo_all ()
460238104Sdes{
461238104Sdes    $ECHO "$*"
462238104Sdes}
463238104Sdes
464238104Sdes# func_error arg...
465238104Sdes# Echo program name prefixed message to standard error.
466238104Sdesfunc_error ()
467238104Sdes{
468238104Sdes    $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2
469238104Sdes}
470238104Sdes
471238104Sdes# func_warning arg...
472238104Sdes# Echo program name prefixed warning message to standard error.
473238104Sdesfunc_warning ()
474238104Sdes{
475238104Sdes    $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2
476238104Sdes
477238104Sdes    # bash bug again:
478238104Sdes    :
479238104Sdes}
480238104Sdes
481238104Sdes# func_fatal_error arg...
482238104Sdes# Echo program name prefixed message to standard error, and exit.
483238104Sdesfunc_fatal_error ()
484238104Sdes{
485238104Sdes    func_error ${1+"$@"}
486238104Sdes    exit $EXIT_FAILURE
487238104Sdes}
488238104Sdes
489238104Sdes# func_fatal_help arg...
490238104Sdes# Echo program name prefixed message to standard error, followed by
491238104Sdes# a help hint, and exit.
492238104Sdesfunc_fatal_help ()
493238104Sdes{
494238104Sdes    func_error ${1+"$@"}
495238104Sdes    func_fatal_error "$help"
496238104Sdes}
497238104Sdeshelp="Try \`$progname --help' for more information."  ## default
498238104Sdes
499238104Sdes
500238104Sdes# func_grep expression filename
501238104Sdes# Check whether EXPRESSION matches any line of FILENAME, without output.
502238104Sdesfunc_grep ()
503238104Sdes{
504238104Sdes    $GREP "$1" "$2" >/dev/null 2>&1
505238104Sdes}
506238104Sdes
507238104Sdes
508238104Sdes# func_mkdir_p directory-path
509238104Sdes# Make sure the entire path to DIRECTORY-PATH is available.
510238104Sdesfunc_mkdir_p ()
511238104Sdes{
512238104Sdes    my_directory_path="$1"
513238104Sdes    my_dir_list=
514238104Sdes
515238104Sdes    if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
516238104Sdes
517238104Sdes      # Protect directory names starting with `-'
518238104Sdes      case $my_directory_path in
519238104Sdes        -*) my_directory_path="./$my_directory_path" ;;
520238104Sdes      esac
521238104Sdes
522238104Sdes      # While some portion of DIR does not yet exist...
523238104Sdes      while test ! -d "$my_directory_path"; do
524238104Sdes        # ...make a list in topmost first order.  Use a colon delimited
525238104Sdes	# list incase some portion of path contains whitespace.
526238104Sdes        my_dir_list="$my_directory_path:$my_dir_list"
527238104Sdes
528238104Sdes        # If the last portion added has no slash in it, the list is done
529238104Sdes        case $my_directory_path in */*) ;; *) break ;; esac
530238104Sdes
531238104Sdes        # ...otherwise throw away the child directory and loop
532238104Sdes        my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"`
533238104Sdes      done
534238104Sdes      my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'`
535238104Sdes
536238104Sdes      save_mkdir_p_IFS="$IFS"; IFS=':'
537238104Sdes      for my_dir in $my_dir_list; do
538238104Sdes	IFS="$save_mkdir_p_IFS"
539238104Sdes        # mkdir can fail with a `File exist' error if two processes
540238104Sdes        # try to create one of the directories concurrently.  Don't
541238104Sdes        # stop in that case!
542238104Sdes        $MKDIR "$my_dir" 2>/dev/null || :
543238104Sdes      done
544238104Sdes      IFS="$save_mkdir_p_IFS"
545238104Sdes
546238104Sdes      # Bail out if we (or some other process) failed to create a directory.
547238104Sdes      test -d "$my_directory_path" || \
548238104Sdes        func_fatal_error "Failed to create \`$1'"
549238104Sdes    fi
550238104Sdes}
551238104Sdes
552238104Sdes
553238104Sdes# func_mktempdir [string]
554238104Sdes# Make a temporary directory that won't clash with other running
555238104Sdes# libtool processes, and avoids race conditions if possible.  If
556238104Sdes# given, STRING is the basename for that directory.
557238104Sdesfunc_mktempdir ()
558238104Sdes{
559238104Sdes    my_template="${TMPDIR-/tmp}/${1-$progname}"
560238104Sdes
561238104Sdes    if test "$opt_dry_run" = ":"; then
562238104Sdes      # Return a directory name, but don't create it in dry-run mode
563238104Sdes      my_tmpdir="${my_template}-$$"
564238104Sdes    else
565238104Sdes
566238104Sdes      # If mktemp works, use that first and foremost
567238104Sdes      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
568238104Sdes
569238104Sdes      if test ! -d "$my_tmpdir"; then
570238104Sdes        # Failing that, at least try and use $RANDOM to avoid a race
571238104Sdes        my_tmpdir="${my_template}-${RANDOM-0}$$"
572238104Sdes
573238104Sdes        save_mktempdir_umask=`umask`
574238104Sdes        umask 0077
575238104Sdes        $MKDIR "$my_tmpdir"
576238104Sdes        umask $save_mktempdir_umask
577238104Sdes      fi
578238104Sdes
579238104Sdes      # If we're not in dry-run mode, bomb out on failure
580238104Sdes      test -d "$my_tmpdir" || \
581238104Sdes        func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
582238104Sdes    fi
583238104Sdes
584238104Sdes    $ECHO "$my_tmpdir"
585238104Sdes}
586238104Sdes
587238104Sdes
588238104Sdes# func_quote_for_eval arg
589238104Sdes# Aesthetically quote ARG to be evaled later.
590238104Sdes# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
591238104Sdes# is double-quoted, suitable for a subsequent eval, whereas
592238104Sdes# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
593238104Sdes# which are still active within double quotes backslashified.
594238104Sdesfunc_quote_for_eval ()
595238104Sdes{
596238104Sdes    case $1 in
597238104Sdes      *[\\\`\"\$]*)
598238104Sdes	func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;;
599238104Sdes      *)
600238104Sdes        func_quote_for_eval_unquoted_result="$1" ;;
601238104Sdes    esac
602238104Sdes
603238104Sdes    case $func_quote_for_eval_unquoted_result in
604238104Sdes      # Double-quote args containing shell metacharacters to delay
605238104Sdes      # word splitting, command substitution and and variable
606238104Sdes      # expansion for a subsequent eval.
607238104Sdes      # Many Bourne shells cannot handle close brackets correctly
608238104Sdes      # in scan sets, so we specify it separately.
609238104Sdes      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
610238104Sdes        func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
611238104Sdes        ;;
612238104Sdes      *)
613238104Sdes        func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
614238104Sdes    esac
615238104Sdes}
616238104Sdes
617238104Sdes
618238104Sdes# func_quote_for_expand arg
619238104Sdes# Aesthetically quote ARG to be evaled later; same as above,
620238104Sdes# but do not quote variable references.
621238104Sdesfunc_quote_for_expand ()
622238104Sdes{
623238104Sdes    case $1 in
624238104Sdes      *[\\\`\"]*)
625238104Sdes	my_arg=`$ECHO "$1" | $SED \
626238104Sdes	    -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
627238104Sdes      *)
628238104Sdes        my_arg="$1" ;;
629238104Sdes    esac
630238104Sdes
631238104Sdes    case $my_arg in
632238104Sdes      # Double-quote args containing shell metacharacters to delay
633238104Sdes      # word splitting and command substitution for a subsequent eval.
634238104Sdes      # Many Bourne shells cannot handle close brackets correctly
635238104Sdes      # in scan sets, so we specify it separately.
636238104Sdes      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
637238104Sdes        my_arg="\"$my_arg\""
638238104Sdes        ;;
639238104Sdes    esac
640238104Sdes
641238104Sdes    func_quote_for_expand_result="$my_arg"
642238104Sdes}
643238104Sdes
644238104Sdes
645238104Sdes# func_show_eval cmd [fail_exp]
646238104Sdes# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
647238104Sdes# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
648238104Sdes# is given, then evaluate it.
649238104Sdesfunc_show_eval ()
650238104Sdes{
651238104Sdes    my_cmd="$1"
652238104Sdes    my_fail_exp="${2-:}"
653238104Sdes
654238104Sdes    ${opt_silent-false} || {
655238104Sdes      func_quote_for_expand "$my_cmd"
656238104Sdes      eval "func_echo $func_quote_for_expand_result"
657238104Sdes    }
658238104Sdes
659238104Sdes    if ${opt_dry_run-false}; then :; else
660238104Sdes      eval "$my_cmd"
661238104Sdes      my_status=$?
662238104Sdes      if test "$my_status" -eq 0; then :; else
663238104Sdes	eval "(exit $my_status); $my_fail_exp"
664238104Sdes      fi
665238104Sdes    fi
666238104Sdes}
667238104Sdes
668238104Sdes
669238104Sdes# func_show_eval_locale cmd [fail_exp]
670238104Sdes# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
671238104Sdes# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
672238104Sdes# is given, then evaluate it.  Use the saved locale for evaluation.
673238104Sdesfunc_show_eval_locale ()
674238104Sdes{
675238104Sdes    my_cmd="$1"
676238104Sdes    my_fail_exp="${2-:}"
677238104Sdes
678238104Sdes    ${opt_silent-false} || {
679238104Sdes      func_quote_for_expand "$my_cmd"
680238104Sdes      eval "func_echo $func_quote_for_expand_result"
681238104Sdes    }
682238104Sdes
683238104Sdes    if ${opt_dry_run-false}; then :; else
684238104Sdes      eval "$lt_user_locale
685238104Sdes	    $my_cmd"
686238104Sdes      my_status=$?
687238104Sdes      eval "$lt_safe_locale"
688238104Sdes      if test "$my_status" -eq 0; then :; else
689238104Sdes	eval "(exit $my_status); $my_fail_exp"
690238104Sdes      fi
691238104Sdes    fi
692238104Sdes}
693238104Sdes
694238104Sdes# func_tr_sh
695238104Sdes# Turn $1 into a string suitable for a shell variable name.
696238104Sdes# Result is stored in $func_tr_sh_result.  All characters
697238104Sdes# not in the set a-zA-Z0-9_ are replaced with '_'. Further,
698238104Sdes# if $1 begins with a digit, a '_' is prepended as well.
699238104Sdesfunc_tr_sh ()
700238104Sdes{
701238104Sdes  case $1 in
702238104Sdes  [0-9]* | *[!a-zA-Z0-9_]*)
703238104Sdes    func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'`
704238104Sdes    ;;
705238104Sdes  * )
706238104Sdes    func_tr_sh_result=$1
707238104Sdes    ;;
708238104Sdes  esac
709238104Sdes}
710238104Sdes
711238104Sdes
712238104Sdes# func_version
713238104Sdes# Echo version message to standard output and exit.
714238104Sdesfunc_version ()
715238104Sdes{
716238104Sdes    $opt_debug
717238104Sdes
718238104Sdes    $SED -n '/(C)/!b go
719238104Sdes	:more
720238104Sdes	/\./!{
721238104Sdes	  N
722238104Sdes	  s/\n# / /
723238104Sdes	  b more
724238104Sdes	}
725238104Sdes	:go
726238104Sdes	/^# '$PROGRAM' (GNU /,/# warranty; / {
727238104Sdes        s/^# //
728238104Sdes	s/^# *$//
729238104Sdes        s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
730238104Sdes        p
731238104Sdes     }' < "$progpath"
732238104Sdes     exit $?
733238104Sdes}
734238104Sdes
735238104Sdes# func_usage
736238104Sdes# Echo short help message to standard output and exit.
737238104Sdesfunc_usage ()
738238104Sdes{
739238104Sdes    $opt_debug
740238104Sdes
741238104Sdes    $SED -n '/^# Usage:/,/^#  *.*--help/ {
742238104Sdes        s/^# //
743238104Sdes	s/^# *$//
744238104Sdes	s/\$progname/'$progname'/
745238104Sdes	p
746238104Sdes    }' < "$progpath"
747238104Sdes    echo
748238104Sdes    $ECHO "run \`$progname --help | more' for full usage"
749238104Sdes    exit $?
750238104Sdes}
751238104Sdes
752238104Sdes# func_help [NOEXIT]
753238104Sdes# Echo long help message to standard output and exit,
754238104Sdes# unless 'noexit' is passed as argument.
755238104Sdesfunc_help ()
756238104Sdes{
757238104Sdes    $opt_debug
758238104Sdes
759238104Sdes    $SED -n '/^# Usage:/,/# Report bugs to/ {
760238104Sdes	:print
761238104Sdes        s/^# //
762238104Sdes	s/^# *$//
763238104Sdes	s*\$progname*'$progname'*
764238104Sdes	s*\$host*'"$host"'*
765238104Sdes	s*\$SHELL*'"$SHELL"'*
766238104Sdes	s*\$LTCC*'"$LTCC"'*
767238104Sdes	s*\$LTCFLAGS*'"$LTCFLAGS"'*
768238104Sdes	s*\$LD*'"$LD"'*
769238104Sdes	s/\$with_gnu_ld/'"$with_gnu_ld"'/
770238104Sdes	s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/
771238104Sdes	s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/
772238104Sdes	p
773238104Sdes	d
774238104Sdes     }
775238104Sdes     /^# .* home page:/b print
776238104Sdes     /^# General help using/b print
777238104Sdes     ' < "$progpath"
778238104Sdes    ret=$?
779238104Sdes    if test -z "$1"; then
780238104Sdes      exit $ret
781238104Sdes    fi
782238104Sdes}
783238104Sdes
784238104Sdes# func_missing_arg argname
785238104Sdes# Echo program name prefixed message to standard error and set global
786238104Sdes# exit_cmd.
787238104Sdesfunc_missing_arg ()
788238104Sdes{
789238104Sdes    $opt_debug
790238104Sdes
791238104Sdes    func_error "missing argument for $1."
792238104Sdes    exit_cmd=exit
793238104Sdes}
794238104Sdes
795238104Sdes
796238104Sdes# func_split_short_opt shortopt
797238104Sdes# Set func_split_short_opt_name and func_split_short_opt_arg shell
798238104Sdes# variables after splitting SHORTOPT after the 2nd character.
799238104Sdesfunc_split_short_opt ()
800238104Sdes{
801238104Sdes    my_sed_short_opt='1s/^\(..\).*$/\1/;q'
802238104Sdes    my_sed_short_rest='1s/^..\(.*\)$/\1/;q'
803238104Sdes
804238104Sdes    func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"`
805238104Sdes    func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"`
806238104Sdes} # func_split_short_opt may be replaced by extended shell implementation
807238104Sdes
808238104Sdes
809238104Sdes# func_split_long_opt longopt
810238104Sdes# Set func_split_long_opt_name and func_split_long_opt_arg shell
811238104Sdes# variables after splitting LONGOPT at the `=' sign.
812238104Sdesfunc_split_long_opt ()
813238104Sdes{
814238104Sdes    my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q'
815238104Sdes    my_sed_long_arg='1s/^--[^=]*=//'
816238104Sdes
817238104Sdes    func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"`
818238104Sdes    func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"`
819238104Sdes} # func_split_long_opt may be replaced by extended shell implementation
820238104Sdes
821238104Sdesexit_cmd=:
822238104Sdes
823238104Sdes
824238104Sdes
825238104Sdes
826238104Sdes
827238104Sdesmagic="%%%MAGIC variable%%%"
828238104Sdesmagic_exe="%%%MAGIC EXE variable%%%"
829238104Sdes
830238104Sdes# Global variables.
831238104Sdesnonopt=
832238104Sdespreserve_args=
833238104Sdeslo2o="s/\\.lo\$/.${objext}/"
834238104Sdeso2lo="s/\\.${objext}\$/.lo/"
835238104Sdesextracted_archives=
836238104Sdesextracted_serial=0
837238104Sdes
838238104Sdes# If this variable is set in any of the actions, the command in it
839238104Sdes# will be execed at the end.  This prevents here-documents from being
840238104Sdes# left over by shells.
841238104Sdesexec_cmd=
842238104Sdes
843238104Sdes# func_append var value
844238104Sdes# Append VALUE to the end of shell variable VAR.
845238104Sdesfunc_append ()
846238104Sdes{
847238104Sdes    eval "${1}=\$${1}\${2}"
848238104Sdes} # func_append may be replaced by extended shell implementation
849238104Sdes
850238104Sdes# func_append_quoted var value
851238104Sdes# Quote VALUE and append to the end of shell variable VAR, separated
852238104Sdes# by a space.
853238104Sdesfunc_append_quoted ()
854238104Sdes{
855238104Sdes    func_quote_for_eval "${2}"
856238104Sdes    eval "${1}=\$${1}\\ \$func_quote_for_eval_result"
857238104Sdes} # func_append_quoted may be replaced by extended shell implementation
858238104Sdes
859238104Sdes
860238104Sdes# func_arith arithmetic-term...
861238104Sdesfunc_arith ()
862238104Sdes{
863238104Sdes    func_arith_result=`expr "${@}"`
864238104Sdes} # func_arith may be replaced by extended shell implementation
865238104Sdes
866238104Sdes
867238104Sdes# func_len string
868238104Sdes# STRING may not start with a hyphen.
869238104Sdesfunc_len ()
870238104Sdes{
871238104Sdes    func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len`
872238104Sdes} # func_len may be replaced by extended shell implementation
873238104Sdes
874238104Sdes
875238104Sdes# func_lo2o object
876238104Sdesfunc_lo2o ()
877238104Sdes{
878238104Sdes    func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"`
879238104Sdes} # func_lo2o may be replaced by extended shell implementation
880238104Sdes
881238104Sdes
882238104Sdes# func_xform libobj-or-source
883238104Sdesfunc_xform ()
884238104Sdes{
885238104Sdes    func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'`
886238104Sdes} # func_xform may be replaced by extended shell implementation
887238104Sdes
888238104Sdes
889238104Sdes# func_fatal_configuration arg...
890238104Sdes# Echo program name prefixed message to standard error, followed by
891238104Sdes# a configuration failure hint, and exit.
892238104Sdesfunc_fatal_configuration ()
893238104Sdes{
894238104Sdes    func_error ${1+"$@"}
895238104Sdes    func_error "See the $PACKAGE documentation for more information."
896238104Sdes    func_fatal_error "Fatal configuration error."
897238104Sdes}
898238104Sdes
899238104Sdes
900238104Sdes# func_config
901238104Sdes# Display the configuration for all the tags in this script.
902238104Sdesfunc_config ()
903238104Sdes{
904238104Sdes    re_begincf='^# ### BEGIN LIBTOOL'
905238104Sdes    re_endcf='^# ### END LIBTOOL'
906238104Sdes
907238104Sdes    # Default configuration.
908238104Sdes    $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
909238104Sdes
910238104Sdes    # Now print the configurations for the tags.
911238104Sdes    for tagname in $taglist; do
912238104Sdes      $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
913238104Sdes    done
914238104Sdes
915238104Sdes    exit $?
916238104Sdes}
917238104Sdes
918238104Sdes# func_features
919238104Sdes# Display the features supported by this script.
920238104Sdesfunc_features ()
921238104Sdes{
922238104Sdes    echo "host: $host"
923238104Sdes    if test "$build_libtool_libs" = yes; then
924238104Sdes      echo "enable shared libraries"
925238104Sdes    else
926238104Sdes      echo "disable shared libraries"
927238104Sdes    fi
928238104Sdes    if test "$build_old_libs" = yes; then
929238104Sdes      echo "enable static libraries"
930238104Sdes    else
931238104Sdes      echo "disable static libraries"
932238104Sdes    fi
933238104Sdes
934238104Sdes    exit $?
935238104Sdes}
936238104Sdes
937238104Sdes# func_enable_tag tagname
938238104Sdes# Verify that TAGNAME is valid, and either flag an error and exit, or
939238104Sdes# enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
940238104Sdes# variable here.
941238104Sdesfunc_enable_tag ()
942238104Sdes{
943238104Sdes  # Global variable:
944238104Sdes  tagname="$1"
945238104Sdes
946238104Sdes  re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
947238104Sdes  re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
948238104Sdes  sed_extractcf="/$re_begincf/,/$re_endcf/p"
949238104Sdes
950238104Sdes  # Validate tagname.
951238104Sdes  case $tagname in
952238104Sdes    *[!-_A-Za-z0-9,/]*)
953238104Sdes      func_fatal_error "invalid tag name: $tagname"
954238104Sdes      ;;
955238104Sdes  esac
956238104Sdes
957238104Sdes  # Don't test for the "default" C tag, as we know it's
958238104Sdes  # there but not specially marked.
959238104Sdes  case $tagname in
960238104Sdes    CC) ;;
961238104Sdes    *)
962238104Sdes      if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
963238104Sdes	taglist="$taglist $tagname"
964238104Sdes
965238104Sdes	# Evaluate the configuration.  Be careful to quote the path
966238104Sdes	# and the sed script, to avoid splitting on whitespace, but
967238104Sdes	# also don't use non-portable quotes within backquotes within
968238104Sdes	# quotes we have to do it in 2 steps:
969238104Sdes	extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
970238104Sdes	eval "$extractedcf"
971238104Sdes      else
972238104Sdes	func_error "ignoring unknown tag $tagname"
973238104Sdes      fi
974238104Sdes      ;;
975238104Sdes  esac
976238104Sdes}
977238104Sdes
978238104Sdes# func_check_version_match
979238104Sdes# Ensure that we are using m4 macros, and libtool script from the same
980238104Sdes# release of libtool.
981238104Sdesfunc_check_version_match ()
982238104Sdes{
983238104Sdes  if test "$package_revision" != "$macro_revision"; then
984238104Sdes    if test "$VERSION" != "$macro_version"; then
985238104Sdes      if test -z "$macro_version"; then
986238104Sdes        cat >&2 <<_LT_EOF
987238104Sdes$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
988238104Sdes$progname: definition of this LT_INIT comes from an older release.
989238104Sdes$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
990238104Sdes$progname: and run autoconf again.
991238104Sdes_LT_EOF
992238104Sdes      else
993238104Sdes        cat >&2 <<_LT_EOF
994238104Sdes$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
995238104Sdes$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
996238104Sdes$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
997238104Sdes$progname: and run autoconf again.
998238104Sdes_LT_EOF
999238104Sdes      fi
1000238104Sdes    else
1001238104Sdes      cat >&2 <<_LT_EOF
1002238104Sdes$progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
1003238104Sdes$progname: but the definition of this LT_INIT comes from revision $macro_revision.
1004238104Sdes$progname: You should recreate aclocal.m4 with macros from revision $package_revision
1005238104Sdes$progname: of $PACKAGE $VERSION and run autoconf again.
1006238104Sdes_LT_EOF
1007238104Sdes    fi
1008238104Sdes
1009238104Sdes    exit $EXIT_MISMATCH
1010238104Sdes  fi
1011238104Sdes}
1012238104Sdes
1013238104Sdes
1014238104Sdes# Shorthand for --mode=foo, only valid as the first argument
1015238104Sdescase $1 in
1016238104Sdesclean|clea|cle|cl)
1017238104Sdes  shift; set dummy --mode clean ${1+"$@"}; shift
1018238104Sdes  ;;
1019238104Sdescompile|compil|compi|comp|com|co|c)
1020238104Sdes  shift; set dummy --mode compile ${1+"$@"}; shift
1021238104Sdes  ;;
1022238104Sdesexecute|execut|execu|exec|exe|ex|e)
1023238104Sdes  shift; set dummy --mode execute ${1+"$@"}; shift
1024238104Sdes  ;;
1025238104Sdesfinish|finis|fini|fin|fi|f)
1026238104Sdes  shift; set dummy --mode finish ${1+"$@"}; shift
1027238104Sdes  ;;
1028238104Sdesinstall|instal|insta|inst|ins|in|i)
1029238104Sdes  shift; set dummy --mode install ${1+"$@"}; shift
1030238104Sdes  ;;
1031238104Sdeslink|lin|li|l)
1032238104Sdes  shift; set dummy --mode link ${1+"$@"}; shift
1033238104Sdes  ;;
1034238104Sdesuninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
1035238104Sdes  shift; set dummy --mode uninstall ${1+"$@"}; shift
1036238104Sdes  ;;
1037238104Sdesesac
1038238104Sdes
1039238104Sdes
1040238104Sdes
1041238104Sdes# Option defaults:
1042238104Sdesopt_debug=:
1043238104Sdesopt_dry_run=false
1044238104Sdesopt_config=false
1045238104Sdesopt_preserve_dup_deps=false
1046238104Sdesopt_features=false
1047238104Sdesopt_finish=false
1048238104Sdesopt_help=false
1049238104Sdesopt_help_all=false
1050238104Sdesopt_silent=:
1051238104Sdesopt_warning=:
1052238104Sdesopt_verbose=:
1053238104Sdesopt_silent=false
1054238104Sdesopt_verbose=false
1055238104Sdes
1056238104Sdes
1057238104Sdes# Parse options once, thoroughly.  This comes as soon as possible in the
1058238104Sdes# script to make things like `--version' happen as quickly as we can.
1059238104Sdes{
1060238104Sdes  # this just eases exit handling
1061238104Sdes  while test $# -gt 0; do
1062238104Sdes    opt="$1"
1063238104Sdes    shift
1064238104Sdes    case $opt in
1065238104Sdes      --debug|-x)	opt_debug='set -x'
1066238104Sdes			func_echo "enabling shell trace mode"
1067238104Sdes			$opt_debug
1068238104Sdes			;;
1069238104Sdes      --dry-run|--dryrun|-n)
1070238104Sdes			opt_dry_run=:
1071238104Sdes			;;
1072238104Sdes      --config)
1073238104Sdes			opt_config=:
1074238104Sdesfunc_config
1075238104Sdes			;;
1076238104Sdes      --dlopen|-dlopen)
1077238104Sdes			optarg="$1"
1078238104Sdes			opt_dlopen="${opt_dlopen+$opt_dlopen
1079238104Sdes}$optarg"
1080238104Sdes			shift
1081238104Sdes			;;
1082238104Sdes      --preserve-dup-deps)
1083238104Sdes			opt_preserve_dup_deps=:
1084238104Sdes			;;
1085238104Sdes      --features)
1086238104Sdes			opt_features=:
1087238104Sdesfunc_features
1088238104Sdes			;;
1089238104Sdes      --finish)
1090238104Sdes			opt_finish=:
1091238104Sdesset dummy --mode finish ${1+"$@"}; shift
1092238104Sdes			;;
1093238104Sdes      --help)
1094238104Sdes			opt_help=:
1095238104Sdes			;;
1096238104Sdes      --help-all)
1097238104Sdes			opt_help_all=:
1098238104Sdesopt_help=': help-all'
1099238104Sdes			;;
1100238104Sdes      --mode)
1101238104Sdes			test $# = 0 && func_missing_arg $opt && break
1102238104Sdes			optarg="$1"
1103238104Sdes			opt_mode="$optarg"
1104238104Sdescase $optarg in
1105238104Sdes  # Valid mode arguments:
1106238104Sdes  clean|compile|execute|finish|install|link|relink|uninstall) ;;
1107238104Sdes
1108238104Sdes  # Catch anything else as an error
1109238104Sdes  *) func_error "invalid argument for $opt"
1110238104Sdes     exit_cmd=exit
1111238104Sdes     break
1112238104Sdes     ;;
1113238104Sdesesac
1114238104Sdes			shift
1115238104Sdes			;;
1116238104Sdes      --no-silent|--no-quiet)
1117238104Sdes			opt_silent=false
1118238104Sdesfunc_append preserve_args " $opt"
1119238104Sdes			;;
1120238104Sdes      --no-warning|--no-warn)
1121238104Sdes			opt_warning=false
1122238104Sdesfunc_append preserve_args " $opt"
1123238104Sdes			;;
1124238104Sdes      --no-verbose)
1125238104Sdes			opt_verbose=false
1126238104Sdesfunc_append preserve_args " $opt"
1127238104Sdes			;;
1128238104Sdes      --silent|--quiet)
1129238104Sdes			opt_silent=:
1130238104Sdesfunc_append preserve_args " $opt"
1131238104Sdes        opt_verbose=false
1132238104Sdes			;;
1133238104Sdes      --verbose|-v)
1134238104Sdes			opt_verbose=:
1135238104Sdesfunc_append preserve_args " $opt"
1136238104Sdesopt_silent=false
1137238104Sdes			;;
1138238104Sdes      --tag)
1139238104Sdes			test $# = 0 && func_missing_arg $opt && break
1140238104Sdes			optarg="$1"
1141238104Sdes			opt_tag="$optarg"
1142238104Sdesfunc_append preserve_args " $opt $optarg"
1143238104Sdesfunc_enable_tag "$optarg"
1144238104Sdes			shift
1145238104Sdes			;;
1146238104Sdes
1147238104Sdes      -\?|-h)		func_usage				;;
1148238104Sdes      --help)		func_help				;;
1149238104Sdes      --version)	func_version				;;
1150238104Sdes
1151238104Sdes      # Separate optargs to long options:
1152238104Sdes      --*=*)
1153238104Sdes			func_split_long_opt "$opt"
1154238104Sdes			set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"}
1155238104Sdes			shift
1156238104Sdes			;;
1157238104Sdes
1158238104Sdes      # Separate non-argument short options:
1159238104Sdes      -\?*|-h*|-n*|-v*)
1160238104Sdes			func_split_short_opt "$opt"
1161238104Sdes			set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"}
1162238104Sdes			shift
1163238104Sdes			;;
1164238104Sdes
1165238104Sdes      --)		break					;;
1166238104Sdes      -*)		func_fatal_help "unrecognized option \`$opt'" ;;
1167238104Sdes      *)		set dummy "$opt" ${1+"$@"};	shift; break  ;;
1168238104Sdes    esac
1169238104Sdes  done
1170238104Sdes
1171238104Sdes  # Validate options:
1172238104Sdes
1173238104Sdes  # save first non-option argument
1174238104Sdes  if test "$#" -gt 0; then
1175238104Sdes    nonopt="$opt"
1176238104Sdes    shift
1177238104Sdes  fi
1178238104Sdes
1179238104Sdes  # preserve --debug
1180238104Sdes  test "$opt_debug" = : || func_append preserve_args " --debug"
1181238104Sdes
1182238104Sdes  case $host in
1183238104Sdes    *cygwin* | *mingw* | *pw32* | *cegcc*)
1184238104Sdes      # don't eliminate duplications in $postdeps and $predeps
1185238104Sdes      opt_duplicate_compiler_generated_deps=:
1186238104Sdes      ;;
1187238104Sdes    *)
1188238104Sdes      opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
1189238104Sdes      ;;
1190238104Sdes  esac
1191238104Sdes
1192238104Sdes  $opt_help || {
1193238104Sdes    # Sanity checks first:
1194238104Sdes    func_check_version_match
1195238104Sdes
1196238104Sdes    if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
1197238104Sdes      func_fatal_configuration "not configured to build any kind of library"
1198238104Sdes    fi
1199238104Sdes
1200238104Sdes    # Darwin sucks
1201238104Sdes    eval std_shrext=\"$shrext_cmds\"
1202238104Sdes
1203238104Sdes    # Only execute mode is allowed to have -dlopen flags.
1204238104Sdes    if test -n "$opt_dlopen" && test "$opt_mode" != execute; then
1205238104Sdes      func_error "unrecognized option \`-dlopen'"
1206238104Sdes      $ECHO "$help" 1>&2
1207238104Sdes      exit $EXIT_FAILURE
1208238104Sdes    fi
1209238104Sdes
1210238104Sdes    # Change the help message to a mode-specific one.
1211238104Sdes    generic_help="$help"
1212238104Sdes    help="Try \`$progname --help --mode=$opt_mode' for more information."
1213238104Sdes  }
1214238104Sdes
1215238104Sdes
1216238104Sdes  # Bail if the options were screwed
1217238104Sdes  $exit_cmd $EXIT_FAILURE
1218238104Sdes}
1219238104Sdes
1220238104Sdes
1221238104Sdes
1222238104Sdes
1223238104Sdes## ----------- ##
1224238104Sdes##    Main.    ##
1225238104Sdes## ----------- ##
1226238104Sdes
1227238104Sdes# func_lalib_p file
1228238104Sdes# True iff FILE is a libtool `.la' library or `.lo' object file.
1229238104Sdes# This function is only a basic sanity check; it will hardly flush out
1230238104Sdes# determined imposters.
1231238104Sdesfunc_lalib_p ()
1232238104Sdes{
1233238104Sdes    test -f "$1" &&
1234238104Sdes      $SED -e 4q "$1" 2>/dev/null \
1235238104Sdes        | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
1236238104Sdes}
1237238104Sdes
1238238104Sdes# func_lalib_unsafe_p file
1239238104Sdes# True iff FILE is a libtool `.la' library or `.lo' object file.
1240238104Sdes# This function implements the same check as func_lalib_p without
1241238104Sdes# resorting to external programs.  To this end, it redirects stdin and
1242238104Sdes# closes it afterwards, without saving the original file descriptor.
1243238104Sdes# As a safety measure, use it only where a negative result would be
1244238104Sdes# fatal anyway.  Works if `file' does not exist.
1245238104Sdesfunc_lalib_unsafe_p ()
1246238104Sdes{
1247238104Sdes    lalib_p=no
1248238104Sdes    if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
1249238104Sdes	for lalib_p_l in 1 2 3 4
1250238104Sdes	do
1251238104Sdes	    read lalib_p_line
1252238104Sdes	    case "$lalib_p_line" in
1253238104Sdes		\#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
1254238104Sdes	    esac
1255238104Sdes	done
1256238104Sdes	exec 0<&5 5<&-
1257238104Sdes    fi
1258238104Sdes    test "$lalib_p" = yes
1259238104Sdes}
1260238104Sdes
1261238104Sdes# func_ltwrapper_script_p file
1262238104Sdes# True iff FILE is a libtool wrapper script
1263238104Sdes# This function is only a basic sanity check; it will hardly flush out
1264238104Sdes# determined imposters.
1265238104Sdesfunc_ltwrapper_script_p ()
1266238104Sdes{
1267238104Sdes    func_lalib_p "$1"
1268238104Sdes}
1269238104Sdes
1270238104Sdes# func_ltwrapper_executable_p file
1271238104Sdes# True iff FILE is a libtool wrapper executable
1272238104Sdes# This function is only a basic sanity check; it will hardly flush out
1273238104Sdes# determined imposters.
1274238104Sdesfunc_ltwrapper_executable_p ()
1275238104Sdes{
1276238104Sdes    func_ltwrapper_exec_suffix=
1277238104Sdes    case $1 in
1278238104Sdes    *.exe) ;;
1279238104Sdes    *) func_ltwrapper_exec_suffix=.exe ;;
1280238104Sdes    esac
1281238104Sdes    $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
1282238104Sdes}
1283238104Sdes
1284238104Sdes# func_ltwrapper_scriptname file
1285238104Sdes# Assumes file is an ltwrapper_executable
1286238104Sdes# uses $file to determine the appropriate filename for a
1287238104Sdes# temporary ltwrapper_script.
1288238104Sdesfunc_ltwrapper_scriptname ()
1289238104Sdes{
1290238104Sdes    func_dirname_and_basename "$1" "" "."
1291238104Sdes    func_stripname '' '.exe' "$func_basename_result"
1292238104Sdes    func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper"
1293238104Sdes}
1294238104Sdes
1295238104Sdes# func_ltwrapper_p file
1296238104Sdes# True iff FILE is a libtool wrapper script or wrapper executable
1297238104Sdes# This function is only a basic sanity check; it will hardly flush out
1298238104Sdes# determined imposters.
1299238104Sdesfunc_ltwrapper_p ()
1300238104Sdes{
1301238104Sdes    func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
1302238104Sdes}
1303238104Sdes
1304238104Sdes
1305238104Sdes# func_execute_cmds commands fail_cmd
1306238104Sdes# Execute tilde-delimited COMMANDS.
1307238104Sdes# If FAIL_CMD is given, eval that upon failure.
1308238104Sdes# FAIL_CMD may read-access the current command in variable CMD!
1309238104Sdesfunc_execute_cmds ()
1310238104Sdes{
1311238104Sdes    $opt_debug
1312238104Sdes    save_ifs=$IFS; IFS='~'
1313238104Sdes    for cmd in $1; do
1314238104Sdes      IFS=$save_ifs
1315238104Sdes      eval cmd=\"$cmd\"
1316238104Sdes      func_show_eval "$cmd" "${2-:}"
1317238104Sdes    done
1318238104Sdes    IFS=$save_ifs
1319238104Sdes}
1320238104Sdes
1321238104Sdes
1322238104Sdes# func_source file
1323238104Sdes# Source FILE, adding directory component if necessary.
1324238104Sdes# Note that it is not necessary on cygwin/mingw to append a dot to
1325238104Sdes# FILE even if both FILE and FILE.exe exist: automatic-append-.exe
1326238104Sdes# behavior happens only for exec(3), not for open(2)!  Also, sourcing
1327238104Sdes# `FILE.' does not work on cygwin managed mounts.
1328238104Sdesfunc_source ()
1329238104Sdes{
1330238104Sdes    $opt_debug
1331238104Sdes    case $1 in
1332238104Sdes    */* | *\\*)	. "$1" ;;
1333238104Sdes    *)		. "./$1" ;;
1334238104Sdes    esac
1335238104Sdes}
1336238104Sdes
1337238104Sdes
1338238104Sdes# func_resolve_sysroot PATH
1339238104Sdes# Replace a leading = in PATH with a sysroot.  Store the result into
1340238104Sdes# func_resolve_sysroot_result
1341238104Sdesfunc_resolve_sysroot ()
1342238104Sdes{
1343238104Sdes  func_resolve_sysroot_result=$1
1344238104Sdes  case $func_resolve_sysroot_result in
1345238104Sdes  =*)
1346238104Sdes    func_stripname '=' '' "$func_resolve_sysroot_result"
1347238104Sdes    func_resolve_sysroot_result=$lt_sysroot$func_stripname_result
1348238104Sdes    ;;
1349238104Sdes  esac
1350238104Sdes}
1351238104Sdes
1352238104Sdes# func_replace_sysroot PATH
1353238104Sdes# If PATH begins with the sysroot, replace it with = and
1354238104Sdes# store the result into func_replace_sysroot_result.
1355238104Sdesfunc_replace_sysroot ()
1356238104Sdes{
1357238104Sdes  case "$lt_sysroot:$1" in
1358238104Sdes  ?*:"$lt_sysroot"*)
1359238104Sdes    func_stripname "$lt_sysroot" '' "$1"
1360238104Sdes    func_replace_sysroot_result="=$func_stripname_result"
1361238104Sdes    ;;
1362238104Sdes  *)
1363238104Sdes    # Including no sysroot.
1364238104Sdes    func_replace_sysroot_result=$1
1365238104Sdes    ;;
1366238104Sdes  esac
1367238104Sdes}
1368238104Sdes
1369238104Sdes# func_infer_tag arg
1370238104Sdes# Infer tagged configuration to use if any are available and
1371238104Sdes# if one wasn't chosen via the "--tag" command line option.
1372238104Sdes# Only attempt this if the compiler in the base compile
1373238104Sdes# command doesn't match the default compiler.
1374238104Sdes# arg is usually of the form 'gcc ...'
1375238104Sdesfunc_infer_tag ()
1376238104Sdes{
1377238104Sdes    $opt_debug
1378238104Sdes    if test -n "$available_tags" && test -z "$tagname"; then
1379238104Sdes      CC_quoted=
1380238104Sdes      for arg in $CC; do
1381238104Sdes	func_append_quoted CC_quoted "$arg"
1382238104Sdes      done
1383238104Sdes      CC_expanded=`func_echo_all $CC`
1384238104Sdes      CC_quoted_expanded=`func_echo_all $CC_quoted`
1385238104Sdes      case $@ in
1386238104Sdes      # Blanks in the command may have been stripped by the calling shell,
1387238104Sdes      # but not from the CC environment variable when configure was run.
1388238104Sdes      " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
1389238104Sdes      " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
1390238104Sdes      # Blanks at the start of $base_compile will cause this to fail
1391238104Sdes      # if we don't check for them as well.
1392238104Sdes      *)
1393238104Sdes	for z in $available_tags; do
1394238104Sdes	  if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
1395238104Sdes	    # Evaluate the configuration.
1396238104Sdes	    eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
1397238104Sdes	    CC_quoted=
1398238104Sdes	    for arg in $CC; do
1399238104Sdes	      # Double-quote args containing other shell metacharacters.
1400238104Sdes	      func_append_quoted CC_quoted "$arg"
1401238104Sdes	    done
1402238104Sdes	    CC_expanded=`func_echo_all $CC`
1403238104Sdes	    CC_quoted_expanded=`func_echo_all $CC_quoted`
1404238104Sdes	    case "$@ " in
1405238104Sdes	    " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
1406238104Sdes	    " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
1407238104Sdes	      # The compiler in the base compile command matches
1408238104Sdes	      # the one in the tagged configuration.
1409238104Sdes	      # Assume this is the tagged configuration we want.
1410238104Sdes	      tagname=$z
1411238104Sdes	      break
1412238104Sdes	      ;;
1413238104Sdes	    esac
1414238104Sdes	  fi
1415238104Sdes	done
1416238104Sdes	# If $tagname still isn't set, then no tagged configuration
1417238104Sdes	# was found and let the user know that the "--tag" command
1418238104Sdes	# line option must be used.
1419238104Sdes	if test -z "$tagname"; then
1420238104Sdes	  func_echo "unable to infer tagged configuration"
1421238104Sdes	  func_fatal_error "specify a tag with \`--tag'"
1422238104Sdes#	else
1423238104Sdes#	  func_verbose "using $tagname tagged configuration"
1424238104Sdes	fi
1425238104Sdes	;;
1426238104Sdes      esac
1427238104Sdes    fi
1428238104Sdes}
1429238104Sdes
1430238104Sdes
1431238104Sdes
1432238104Sdes# func_write_libtool_object output_name pic_name nonpic_name
1433238104Sdes# Create a libtool object file (analogous to a ".la" file),
1434238104Sdes# but don't create it if we're doing a dry run.
1435238104Sdesfunc_write_libtool_object ()
1436238104Sdes{
1437238104Sdes    write_libobj=${1}
1438238104Sdes    if test "$build_libtool_libs" = yes; then
1439238104Sdes      write_lobj=\'${2}\'
1440238104Sdes    else
1441238104Sdes      write_lobj=none
1442238104Sdes    fi
1443238104Sdes
1444238104Sdes    if test "$build_old_libs" = yes; then
1445238104Sdes      write_oldobj=\'${3}\'
1446238104Sdes    else
1447238104Sdes      write_oldobj=none
1448238104Sdes    fi
1449238104Sdes
1450238104Sdes    $opt_dry_run || {
1451238104Sdes      cat >${write_libobj}T <<EOF
1452238104Sdes# $write_libobj - a libtool object file
1453238104Sdes# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
1454238104Sdes#
1455238104Sdes# Please DO NOT delete this file!
1456238104Sdes# It is necessary for linking the library.
1457238104Sdes
1458238104Sdes# Name of the PIC object.
1459238104Sdespic_object=$write_lobj
1460238104Sdes
1461238104Sdes# Name of the non-PIC object
1462238104Sdesnon_pic_object=$write_oldobj
1463238104Sdes
1464238104SdesEOF
1465238104Sdes      $MV "${write_libobj}T" "${write_libobj}"
1466238104Sdes    }
1467238104Sdes}
1468238104Sdes
1469238104Sdes
1470238104Sdes##################################################
1471238104Sdes# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS #
1472238104Sdes##################################################
1473238104Sdes
1474238104Sdes# func_convert_core_file_wine_to_w32 ARG
1475238104Sdes# Helper function used by file name conversion functions when $build is *nix,
1476238104Sdes# and $host is mingw, cygwin, or some other w32 environment. Relies on a
1477238104Sdes# correctly configured wine environment available, with the winepath program
1478238104Sdes# in $build's $PATH.
1479238104Sdes#
1480238104Sdes# ARG is the $build file name to be converted to w32 format.
1481238104Sdes# Result is available in $func_convert_core_file_wine_to_w32_result, and will
1482238104Sdes# be empty on error (or when ARG is empty)
1483238104Sdesfunc_convert_core_file_wine_to_w32 ()
1484238104Sdes{
1485238104Sdes  $opt_debug
1486238104Sdes  func_convert_core_file_wine_to_w32_result="$1"
1487238104Sdes  if test -n "$1"; then
1488238104Sdes    # Unfortunately, winepath does not exit with a non-zero error code, so we
1489238104Sdes    # are forced to check the contents of stdout. On the other hand, if the
1490238104Sdes    # command is not found, the shell will set an exit code of 127 and print
1491238104Sdes    # *an error message* to stdout. So we must check for both error code of
1492238104Sdes    # zero AND non-empty stdout, which explains the odd construction:
1493238104Sdes    func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
1494238104Sdes    if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then
1495238104Sdes      func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
1496238104Sdes        $SED -e "$lt_sed_naive_backslashify"`
1497238104Sdes    else
1498238104Sdes      func_convert_core_file_wine_to_w32_result=
1499238104Sdes    fi
1500238104Sdes  fi
1501238104Sdes}
1502238104Sdes# end: func_convert_core_file_wine_to_w32
1503238104Sdes
1504238104Sdes
1505238104Sdes# func_convert_core_path_wine_to_w32 ARG
1506238104Sdes# Helper function used by path conversion functions when $build is *nix, and
1507238104Sdes# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly
1508238104Sdes# configured wine environment available, with the winepath program in $build's
1509238104Sdes# $PATH. Assumes ARG has no leading or trailing path separator characters.
1510238104Sdes#
1511238104Sdes# ARG is path to be converted from $build format to win32.
1512238104Sdes# Result is available in $func_convert_core_path_wine_to_w32_result.
1513238104Sdes# Unconvertible file (directory) names in ARG are skipped; if no directory names
1514238104Sdes# are convertible, then the result may be empty.
1515238104Sdesfunc_convert_core_path_wine_to_w32 ()
1516238104Sdes{
1517238104Sdes  $opt_debug
1518238104Sdes  # unfortunately, winepath doesn't convert paths, only file names
1519238104Sdes  func_convert_core_path_wine_to_w32_result=""
1520238104Sdes  if test -n "$1"; then
1521238104Sdes    oldIFS=$IFS
1522238104Sdes    IFS=:
1523238104Sdes    for func_convert_core_path_wine_to_w32_f in $1; do
1524238104Sdes      IFS=$oldIFS
1525238104Sdes      func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
1526238104Sdes      if test -n "$func_convert_core_file_wine_to_w32_result" ; then
1527238104Sdes        if test -z "$func_convert_core_path_wine_to_w32_result"; then
1528238104Sdes          func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result"
1529238104Sdes        else
1530238104Sdes          func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
1531238104Sdes        fi
1532238104Sdes      fi
1533238104Sdes    done
1534238104Sdes    IFS=$oldIFS
1535238104Sdes  fi
1536238104Sdes}
1537238104Sdes# end: func_convert_core_path_wine_to_w32
1538238104Sdes
1539238104Sdes
1540238104Sdes# func_cygpath ARGS...
1541238104Sdes# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when
1542238104Sdes# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2)
1543238104Sdes# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or
1544238104Sdes# (2), returns the Cygwin file name or path in func_cygpath_result (input
1545238104Sdes# file name or path is assumed to be in w32 format, as previously converted
1546238104Sdes# from $build's *nix or MSYS format). In case (3), returns the w32 file name
1547238104Sdes# or path in func_cygpath_result (input file name or path is assumed to be in
1548238104Sdes# Cygwin format). Returns an empty string on error.
1549238104Sdes#
1550238104Sdes# ARGS are passed to cygpath, with the last one being the file name or path to
1551238104Sdes# be converted.
1552238104Sdes#
1553238104Sdes# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH
1554238104Sdes# environment variable; do not put it in $PATH.
1555238104Sdesfunc_cygpath ()
1556238104Sdes{
1557238104Sdes  $opt_debug
1558238104Sdes  if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
1559238104Sdes    func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
1560238104Sdes    if test "$?" -ne 0; then
1561238104Sdes      # on failure, ensure result is empty
1562238104Sdes      func_cygpath_result=
1563238104Sdes    fi
1564238104Sdes  else
1565238104Sdes    func_cygpath_result=
1566238104Sdes    func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'"
1567238104Sdes  fi
1568238104Sdes}
1569238104Sdes#end: func_cygpath
1570238104Sdes
1571238104Sdes
1572238104Sdes# func_convert_core_msys_to_w32 ARG
1573238104Sdes# Convert file name or path ARG from MSYS format to w32 format.  Return
1574238104Sdes# result in func_convert_core_msys_to_w32_result.
1575238104Sdesfunc_convert_core_msys_to_w32 ()
1576238104Sdes{
1577238104Sdes  $opt_debug
1578238104Sdes  # awkward: cmd appends spaces to result
1579238104Sdes  func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
1580238104Sdes    $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"`
1581238104Sdes}
1582238104Sdes#end: func_convert_core_msys_to_w32
1583238104Sdes
1584238104Sdes
1585238104Sdes# func_convert_file_check ARG1 ARG2
1586238104Sdes# Verify that ARG1 (a file name in $build format) was converted to $host
1587238104Sdes# format in ARG2. Otherwise, emit an error message, but continue (resetting
1588238104Sdes# func_to_host_file_result to ARG1).
1589238104Sdesfunc_convert_file_check ()
1590238104Sdes{
1591238104Sdes  $opt_debug
1592238104Sdes  if test -z "$2" && test -n "$1" ; then
1593238104Sdes    func_error "Could not determine host file name corresponding to"
1594238104Sdes    func_error "  \`$1'"
1595238104Sdes    func_error "Continuing, but uninstalled executables may not work."
1596238104Sdes    # Fallback:
1597238104Sdes    func_to_host_file_result="$1"
1598238104Sdes  fi
1599238104Sdes}
1600238104Sdes# end func_convert_file_check
1601238104Sdes
1602238104Sdes
1603238104Sdes# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH
1604238104Sdes# Verify that FROM_PATH (a path in $build format) was converted to $host
1605238104Sdes# format in TO_PATH. Otherwise, emit an error message, but continue, resetting
1606238104Sdes# func_to_host_file_result to a simplistic fallback value (see below).
1607238104Sdesfunc_convert_path_check ()
1608238104Sdes{
1609238104Sdes  $opt_debug
1610238104Sdes  if test -z "$4" && test -n "$3"; then
1611238104Sdes    func_error "Could not determine the host path corresponding to"
1612238104Sdes    func_error "  \`$3'"
1613238104Sdes    func_error "Continuing, but uninstalled executables may not work."
1614238104Sdes    # Fallback.  This is a deliberately simplistic "conversion" and
1615238104Sdes    # should not be "improved".  See libtool.info.
1616238104Sdes    if test "x$1" != "x$2"; then
1617238104Sdes      lt_replace_pathsep_chars="s|$1|$2|g"
1618238104Sdes      func_to_host_path_result=`echo "$3" |
1619238104Sdes        $SED -e "$lt_replace_pathsep_chars"`
1620238104Sdes    else
1621238104Sdes      func_to_host_path_result="$3"
1622238104Sdes    fi
1623238104Sdes  fi
1624238104Sdes}
1625238104Sdes# end func_convert_path_check
1626238104Sdes
1627238104Sdes
1628238104Sdes# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG
1629238104Sdes# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT
1630238104Sdes# and appending REPL if ORIG matches BACKPAT.
1631238104Sdesfunc_convert_path_front_back_pathsep ()
1632238104Sdes{
1633238104Sdes  $opt_debug
1634238104Sdes  case $4 in
1635238104Sdes  $1 ) func_to_host_path_result="$3$func_to_host_path_result"
1636238104Sdes    ;;
1637238104Sdes  esac
1638238104Sdes  case $4 in
1639238104Sdes  $2 ) func_append func_to_host_path_result "$3"
1640238104Sdes    ;;
1641238104Sdes  esac
1642238104Sdes}
1643238104Sdes# end func_convert_path_front_back_pathsep
1644238104Sdes
1645238104Sdes
1646238104Sdes##################################################
1647238104Sdes# $build to $host FILE NAME CONVERSION FUNCTIONS #
1648238104Sdes##################################################
1649238104Sdes# invoked via `$to_host_file_cmd ARG'
1650238104Sdes#
1651238104Sdes# In each case, ARG is the path to be converted from $build to $host format.
1652238104Sdes# Result will be available in $func_to_host_file_result.
1653238104Sdes
1654238104Sdes
1655238104Sdes# func_to_host_file ARG
1656238104Sdes# Converts the file name ARG from $build format to $host format. Return result
1657238104Sdes# in func_to_host_file_result.
1658238104Sdesfunc_to_host_file ()
1659238104Sdes{
1660238104Sdes  $opt_debug
1661238104Sdes  $to_host_file_cmd "$1"
1662238104Sdes}
1663238104Sdes# end func_to_host_file
1664238104Sdes
1665238104Sdes
1666238104Sdes# func_to_tool_file ARG LAZY
1667238104Sdes# converts the file name ARG from $build format to toolchain format. Return
1668238104Sdes# result in func_to_tool_file_result.  If the conversion in use is listed
1669238104Sdes# in (the comma separated) LAZY, no conversion takes place.
1670238104Sdesfunc_to_tool_file ()
1671238104Sdes{
1672238104Sdes  $opt_debug
1673238104Sdes  case ,$2, in
1674238104Sdes    *,"$to_tool_file_cmd",*)
1675238104Sdes      func_to_tool_file_result=$1
1676238104Sdes      ;;
1677238104Sdes    *)
1678238104Sdes      $to_tool_file_cmd "$1"
1679238104Sdes      func_to_tool_file_result=$func_to_host_file_result
1680238104Sdes      ;;
1681238104Sdes  esac
1682238104Sdes}
1683238104Sdes# end func_to_tool_file
1684238104Sdes
1685238104Sdes
1686238104Sdes# func_convert_file_noop ARG
1687238104Sdes# Copy ARG to func_to_host_file_result.
1688238104Sdesfunc_convert_file_noop ()
1689238104Sdes{
1690238104Sdes  func_to_host_file_result="$1"
1691238104Sdes}
1692238104Sdes# end func_convert_file_noop
1693238104Sdes
1694238104Sdes
1695238104Sdes# func_convert_file_msys_to_w32 ARG
1696238104Sdes# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic
1697238104Sdes# conversion to w32 is not available inside the cwrapper.  Returns result in
1698238104Sdes# func_to_host_file_result.
1699238104Sdesfunc_convert_file_msys_to_w32 ()
1700238104Sdes{
1701238104Sdes  $opt_debug
1702238104Sdes  func_to_host_file_result="$1"
1703238104Sdes  if test -n "$1"; then
1704238104Sdes    func_convert_core_msys_to_w32 "$1"
1705238104Sdes    func_to_host_file_result="$func_convert_core_msys_to_w32_result"
1706238104Sdes  fi
1707238104Sdes  func_convert_file_check "$1" "$func_to_host_file_result"
1708238104Sdes}
1709238104Sdes# end func_convert_file_msys_to_w32
1710238104Sdes
1711238104Sdes
1712238104Sdes# func_convert_file_cygwin_to_w32 ARG
1713238104Sdes# Convert file name ARG from Cygwin to w32 format.  Returns result in
1714238104Sdes# func_to_host_file_result.
1715238104Sdesfunc_convert_file_cygwin_to_w32 ()
1716238104Sdes{
1717238104Sdes  $opt_debug
1718238104Sdes  func_to_host_file_result="$1"
1719238104Sdes  if test -n "$1"; then
1720238104Sdes    # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
1721238104Sdes    # LT_CYGPATH in this case.
1722238104Sdes    func_to_host_file_result=`cygpath -m "$1"`
1723238104Sdes  fi
1724238104Sdes  func_convert_file_check "$1" "$func_to_host_file_result"
1725238104Sdes}
1726238104Sdes# end func_convert_file_cygwin_to_w32
1727238104Sdes
1728238104Sdes
1729238104Sdes# func_convert_file_nix_to_w32 ARG
1730238104Sdes# Convert file name ARG from *nix to w32 format.  Requires a wine environment
1731238104Sdes# and a working winepath. Returns result in func_to_host_file_result.
1732238104Sdesfunc_convert_file_nix_to_w32 ()
1733238104Sdes{
1734238104Sdes  $opt_debug
1735238104Sdes  func_to_host_file_result="$1"
1736238104Sdes  if test -n "$1"; then
1737238104Sdes    func_convert_core_file_wine_to_w32 "$1"
1738238104Sdes    func_to_host_file_result="$func_convert_core_file_wine_to_w32_result"
1739238104Sdes  fi
1740238104Sdes  func_convert_file_check "$1" "$func_to_host_file_result"
1741238104Sdes}
1742238104Sdes# end func_convert_file_nix_to_w32
1743238104Sdes
1744238104Sdes
1745238104Sdes# func_convert_file_msys_to_cygwin ARG
1746238104Sdes# Convert file name ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
1747238104Sdes# Returns result in func_to_host_file_result.
1748238104Sdesfunc_convert_file_msys_to_cygwin ()
1749238104Sdes{
1750238104Sdes  $opt_debug
1751238104Sdes  func_to_host_file_result="$1"
1752238104Sdes  if test -n "$1"; then
1753238104Sdes    func_convert_core_msys_to_w32 "$1"
1754238104Sdes    func_cygpath -u "$func_convert_core_msys_to_w32_result"
1755238104Sdes    func_to_host_file_result="$func_cygpath_result"
1756238104Sdes  fi
1757238104Sdes  func_convert_file_check "$1" "$func_to_host_file_result"
1758238104Sdes}
1759238104Sdes# end func_convert_file_msys_to_cygwin
1760238104Sdes
1761238104Sdes
1762238104Sdes# func_convert_file_nix_to_cygwin ARG
1763238104Sdes# Convert file name ARG from *nix to Cygwin format.  Requires Cygwin installed
1764238104Sdes# in a wine environment, working winepath, and LT_CYGPATH set.  Returns result
1765238104Sdes# in func_to_host_file_result.
1766238104Sdesfunc_convert_file_nix_to_cygwin ()
1767238104Sdes{
1768238104Sdes  $opt_debug
1769238104Sdes  func_to_host_file_result="$1"
1770238104Sdes  if test -n "$1"; then
1771238104Sdes    # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
1772238104Sdes    func_convert_core_file_wine_to_w32 "$1"
1773238104Sdes    func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
1774238104Sdes    func_to_host_file_result="$func_cygpath_result"
1775238104Sdes  fi
1776238104Sdes  func_convert_file_check "$1" "$func_to_host_file_result"
1777238104Sdes}
1778238104Sdes# end func_convert_file_nix_to_cygwin
1779238104Sdes
1780238104Sdes
1781238104Sdes#############################################
1782238104Sdes# $build to $host PATH CONVERSION FUNCTIONS #
1783238104Sdes#############################################
1784238104Sdes# invoked via `$to_host_path_cmd ARG'
1785238104Sdes#
1786238104Sdes# In each case, ARG is the path to be converted from $build to $host format.
1787238104Sdes# The result will be available in $func_to_host_path_result.
1788238104Sdes#
1789238104Sdes# Path separators are also converted from $build format to $host format.  If
1790238104Sdes# ARG begins or ends with a path separator character, it is preserved (but
1791238104Sdes# converted to $host format) on output.
1792238104Sdes#
1793238104Sdes# All path conversion functions are named using the following convention:
1794238104Sdes#   file name conversion function    : func_convert_file_X_to_Y ()
1795238104Sdes#   path conversion function         : func_convert_path_X_to_Y ()
1796238104Sdes# where, for any given $build/$host combination the 'X_to_Y' value is the
1797238104Sdes# same.  If conversion functions are added for new $build/$host combinations,
1798238104Sdes# the two new functions must follow this pattern, or func_init_to_host_path_cmd
1799238104Sdes# will break.
1800238104Sdes
1801238104Sdes
1802238104Sdes# func_init_to_host_path_cmd
1803238104Sdes# Ensures that function "pointer" variable $to_host_path_cmd is set to the
1804238104Sdes# appropriate value, based on the value of $to_host_file_cmd.
1805238104Sdesto_host_path_cmd=
1806238104Sdesfunc_init_to_host_path_cmd ()
1807238104Sdes{
1808238104Sdes  $opt_debug
1809238104Sdes  if test -z "$to_host_path_cmd"; then
1810238104Sdes    func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
1811238104Sdes    to_host_path_cmd="func_convert_path_${func_stripname_result}"
1812238104Sdes  fi
1813238104Sdes}
1814238104Sdes
1815238104Sdes
1816238104Sdes# func_to_host_path ARG
1817238104Sdes# Converts the path ARG from $build format to $host format. Return result
1818238104Sdes# in func_to_host_path_result.
1819238104Sdesfunc_to_host_path ()
1820238104Sdes{
1821238104Sdes  $opt_debug
1822238104Sdes  func_init_to_host_path_cmd
1823238104Sdes  $to_host_path_cmd "$1"
1824238104Sdes}
1825238104Sdes# end func_to_host_path
1826238104Sdes
1827238104Sdes
1828238104Sdes# func_convert_path_noop ARG
1829238104Sdes# Copy ARG to func_to_host_path_result.
1830238104Sdesfunc_convert_path_noop ()
1831238104Sdes{
1832238104Sdes  func_to_host_path_result="$1"
1833238104Sdes}
1834238104Sdes# end func_convert_path_noop
1835238104Sdes
1836238104Sdes
1837238104Sdes# func_convert_path_msys_to_w32 ARG
1838238104Sdes# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic
1839238104Sdes# conversion to w32 is not available inside the cwrapper.  Returns result in
1840238104Sdes# func_to_host_path_result.
1841238104Sdesfunc_convert_path_msys_to_w32 ()
1842238104Sdes{
1843238104Sdes  $opt_debug
1844238104Sdes  func_to_host_path_result="$1"
1845238104Sdes  if test -n "$1"; then
1846238104Sdes    # Remove leading and trailing path separator characters from ARG.  MSYS
1847238104Sdes    # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
1848238104Sdes    # and winepath ignores them completely.
1849238104Sdes    func_stripname : : "$1"
1850238104Sdes    func_to_host_path_tmp1=$func_stripname_result
1851238104Sdes    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
1852238104Sdes    func_to_host_path_result="$func_convert_core_msys_to_w32_result"
1853238104Sdes    func_convert_path_check : ";" \
1854238104Sdes      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1855238104Sdes    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
1856238104Sdes  fi
1857238104Sdes}
1858238104Sdes# end func_convert_path_msys_to_w32
1859238104Sdes
1860238104Sdes
1861238104Sdes# func_convert_path_cygwin_to_w32 ARG
1862238104Sdes# Convert path ARG from Cygwin to w32 format.  Returns result in
1863238104Sdes# func_to_host_file_result.
1864238104Sdesfunc_convert_path_cygwin_to_w32 ()
1865238104Sdes{
1866238104Sdes  $opt_debug
1867238104Sdes  func_to_host_path_result="$1"
1868238104Sdes  if test -n "$1"; then
1869238104Sdes    # See func_convert_path_msys_to_w32:
1870238104Sdes    func_stripname : : "$1"
1871238104Sdes    func_to_host_path_tmp1=$func_stripname_result
1872238104Sdes    func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"`
1873238104Sdes    func_convert_path_check : ";" \
1874238104Sdes      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1875238104Sdes    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
1876238104Sdes  fi
1877238104Sdes}
1878238104Sdes# end func_convert_path_cygwin_to_w32
1879238104Sdes
1880238104Sdes
1881238104Sdes# func_convert_path_nix_to_w32 ARG
1882238104Sdes# Convert path ARG from *nix to w32 format.  Requires a wine environment and
1883238104Sdes# a working winepath.  Returns result in func_to_host_file_result.
1884238104Sdesfunc_convert_path_nix_to_w32 ()
1885238104Sdes{
1886238104Sdes  $opt_debug
1887238104Sdes  func_to_host_path_result="$1"
1888238104Sdes  if test -n "$1"; then
1889238104Sdes    # See func_convert_path_msys_to_w32:
1890238104Sdes    func_stripname : : "$1"
1891238104Sdes    func_to_host_path_tmp1=$func_stripname_result
1892238104Sdes    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
1893238104Sdes    func_to_host_path_result="$func_convert_core_path_wine_to_w32_result"
1894238104Sdes    func_convert_path_check : ";" \
1895238104Sdes      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1896238104Sdes    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
1897238104Sdes  fi
1898238104Sdes}
1899238104Sdes# end func_convert_path_nix_to_w32
1900238104Sdes
1901238104Sdes
1902238104Sdes# func_convert_path_msys_to_cygwin ARG
1903238104Sdes# Convert path ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
1904238104Sdes# Returns result in func_to_host_file_result.
1905238104Sdesfunc_convert_path_msys_to_cygwin ()
1906238104Sdes{
1907238104Sdes  $opt_debug
1908238104Sdes  func_to_host_path_result="$1"
1909238104Sdes  if test -n "$1"; then
1910238104Sdes    # See func_convert_path_msys_to_w32:
1911238104Sdes    func_stripname : : "$1"
1912238104Sdes    func_to_host_path_tmp1=$func_stripname_result
1913238104Sdes    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
1914238104Sdes    func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
1915238104Sdes    func_to_host_path_result="$func_cygpath_result"
1916238104Sdes    func_convert_path_check : : \
1917238104Sdes      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1918238104Sdes    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
1919238104Sdes  fi
1920238104Sdes}
1921238104Sdes# end func_convert_path_msys_to_cygwin
1922238104Sdes
1923238104Sdes
1924238104Sdes# func_convert_path_nix_to_cygwin ARG
1925238104Sdes# Convert path ARG from *nix to Cygwin format.  Requires Cygwin installed in a
1926238104Sdes# a wine environment, working winepath, and LT_CYGPATH set.  Returns result in
1927238104Sdes# func_to_host_file_result.
1928238104Sdesfunc_convert_path_nix_to_cygwin ()
1929238104Sdes{
1930238104Sdes  $opt_debug
1931238104Sdes  func_to_host_path_result="$1"
1932238104Sdes  if test -n "$1"; then
1933238104Sdes    # Remove leading and trailing path separator characters from
1934238104Sdes    # ARG. msys behavior is inconsistent here, cygpath turns them
1935238104Sdes    # into '.;' and ';.', and winepath ignores them completely.
1936238104Sdes    func_stripname : : "$1"
1937238104Sdes    func_to_host_path_tmp1=$func_stripname_result
1938238104Sdes    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
1939238104Sdes    func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
1940238104Sdes    func_to_host_path_result="$func_cygpath_result"
1941238104Sdes    func_convert_path_check : : \
1942238104Sdes      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1943238104Sdes    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
1944238104Sdes  fi
1945238104Sdes}
1946238104Sdes# end func_convert_path_nix_to_cygwin
1947238104Sdes
1948238104Sdes
1949238104Sdes# func_mode_compile arg...
1950238104Sdesfunc_mode_compile ()
1951238104Sdes{
1952238104Sdes    $opt_debug
1953238104Sdes    # Get the compilation command and the source file.
1954238104Sdes    base_compile=
1955238104Sdes    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
1956238104Sdes    suppress_opt=yes
1957238104Sdes    suppress_output=
1958238104Sdes    arg_mode=normal
1959238104Sdes    libobj=
1960238104Sdes    later=
1961238104Sdes    pie_flag=
1962238104Sdes
1963238104Sdes    for arg
1964238104Sdes    do
1965238104Sdes      case $arg_mode in
1966238104Sdes      arg  )
1967238104Sdes	# do not "continue".  Instead, add this to base_compile
1968238104Sdes	lastarg="$arg"
1969238104Sdes	arg_mode=normal
1970238104Sdes	;;
1971238104Sdes
1972238104Sdes      target )
1973238104Sdes	libobj="$arg"
1974238104Sdes	arg_mode=normal
1975238104Sdes	continue
1976238104Sdes	;;
1977238104Sdes
1978238104Sdes      normal )
1979238104Sdes	# Accept any command-line options.
1980238104Sdes	case $arg in
1981238104Sdes	-o)
1982238104Sdes	  test -n "$libobj" && \
1983238104Sdes	    func_fatal_error "you cannot specify \`-o' more than once"
1984238104Sdes	  arg_mode=target
1985238104Sdes	  continue
1986238104Sdes	  ;;
1987238104Sdes
1988238104Sdes	-pie | -fpie | -fPIE)
1989238104Sdes          func_append pie_flag " $arg"
1990238104Sdes	  continue
1991238104Sdes	  ;;
1992238104Sdes
1993238104Sdes	-shared | -static | -prefer-pic | -prefer-non-pic)
1994238104Sdes	  func_append later " $arg"
1995238104Sdes	  continue
1996238104Sdes	  ;;
1997238104Sdes
1998238104Sdes	-no-suppress)
1999238104Sdes	  suppress_opt=no
2000238104Sdes	  continue
2001238104Sdes	  ;;
2002238104Sdes
2003238104Sdes	-Xcompiler)
2004238104Sdes	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
2005238104Sdes	  continue      #  The current "srcfile" will either be retained or
2006238104Sdes	  ;;            #  replaced later.  I would guess that would be a bug.
2007238104Sdes
2008238104Sdes	-Wc,*)
2009238104Sdes	  func_stripname '-Wc,' '' "$arg"
2010238104Sdes	  args=$func_stripname_result
2011238104Sdes	  lastarg=
2012238104Sdes	  save_ifs="$IFS"; IFS=','
2013238104Sdes	  for arg in $args; do
2014238104Sdes	    IFS="$save_ifs"
2015238104Sdes	    func_append_quoted lastarg "$arg"
2016238104Sdes	  done
2017238104Sdes	  IFS="$save_ifs"
2018238104Sdes	  func_stripname ' ' '' "$lastarg"
2019238104Sdes	  lastarg=$func_stripname_result
2020238104Sdes
2021238104Sdes	  # Add the arguments to base_compile.
2022238104Sdes	  func_append base_compile " $lastarg"
2023238104Sdes	  continue
2024238104Sdes	  ;;
2025238104Sdes
2026238104Sdes	*)
2027238104Sdes	  # Accept the current argument as the source file.
2028238104Sdes	  # The previous "srcfile" becomes the current argument.
2029238104Sdes	  #
2030238104Sdes	  lastarg="$srcfile"
2031238104Sdes	  srcfile="$arg"
2032238104Sdes	  ;;
2033238104Sdes	esac  #  case $arg
2034238104Sdes	;;
2035238104Sdes      esac    #  case $arg_mode
2036238104Sdes
2037238104Sdes      # Aesthetically quote the previous argument.
2038238104Sdes      func_append_quoted base_compile "$lastarg"
2039238104Sdes    done # for arg
2040238104Sdes
2041238104Sdes    case $arg_mode in
2042238104Sdes    arg)
2043238104Sdes      func_fatal_error "you must specify an argument for -Xcompile"
2044238104Sdes      ;;
2045238104Sdes    target)
2046238104Sdes      func_fatal_error "you must specify a target with \`-o'"
2047238104Sdes      ;;
2048238104Sdes    *)
2049238104Sdes      # Get the name of the library object.
2050238104Sdes      test -z "$libobj" && {
2051238104Sdes	func_basename "$srcfile"
2052238104Sdes	libobj="$func_basename_result"
2053238104Sdes      }
2054238104Sdes      ;;
2055238104Sdes    esac
2056238104Sdes
2057238104Sdes    # Recognize several different file suffixes.
2058238104Sdes    # If the user specifies -o file.o, it is replaced with file.lo
2059238104Sdes    case $libobj in
2060238104Sdes    *.[cCFSifmso] | \
2061238104Sdes    *.ada | *.adb | *.ads | *.asm | \
2062238104Sdes    *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
2063238104Sdes    *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup)
2064238104Sdes      func_xform "$libobj"
2065238104Sdes      libobj=$func_xform_result
2066238104Sdes      ;;
2067238104Sdes    esac
2068238104Sdes
2069238104Sdes    case $libobj in
2070238104Sdes    *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
2071238104Sdes    *)
2072238104Sdes      func_fatal_error "cannot determine name of library object from \`$libobj'"
2073238104Sdes      ;;
2074238104Sdes    esac
2075238104Sdes
2076238104Sdes    func_infer_tag $base_compile
2077238104Sdes
2078238104Sdes    for arg in $later; do
2079238104Sdes      case $arg in
2080238104Sdes      -shared)
2081238104Sdes	test "$build_libtool_libs" != yes && \
2082238104Sdes	  func_fatal_configuration "can not build a shared library"
2083238104Sdes	build_old_libs=no
2084238104Sdes	continue
2085238104Sdes	;;
2086238104Sdes
2087238104Sdes      -static)
2088238104Sdes	build_libtool_libs=no
2089238104Sdes	build_old_libs=yes
2090238104Sdes	continue
2091238104Sdes	;;
2092238104Sdes
2093238104Sdes      -prefer-pic)
2094238104Sdes	pic_mode=yes
2095238104Sdes	continue
2096238104Sdes	;;
2097238104Sdes
2098238104Sdes      -prefer-non-pic)
2099238104Sdes	pic_mode=no
2100238104Sdes	continue
2101238104Sdes	;;
2102238104Sdes      esac
2103238104Sdes    done
2104238104Sdes
2105238104Sdes    func_quote_for_eval "$libobj"
2106238104Sdes    test "X$libobj" != "X$func_quote_for_eval_result" \
2107238104Sdes      && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'	 &()|`$[]' \
2108238104Sdes      && func_warning "libobj name \`$libobj' may not contain shell special characters."
2109238104Sdes    func_dirname_and_basename "$obj" "/" ""
2110238104Sdes    objname="$func_basename_result"
2111238104Sdes    xdir="$func_dirname_result"
2112238104Sdes    lobj=${xdir}$objdir/$objname
2113238104Sdes
2114238104Sdes    test -z "$base_compile" && \
2115238104Sdes      func_fatal_help "you must specify a compilation command"
2116238104Sdes
2117238104Sdes    # Delete any leftover library objects.
2118238104Sdes    if test "$build_old_libs" = yes; then
2119238104Sdes      removelist="$obj $lobj $libobj ${libobj}T"
2120238104Sdes    else
2121238104Sdes      removelist="$lobj $libobj ${libobj}T"
2122238104Sdes    fi
2123238104Sdes
2124238104Sdes    # On Cygwin there's no "real" PIC flag so we must build both object types
2125238104Sdes    case $host_os in
2126238104Sdes    cygwin* | mingw* | pw32* | os2* | cegcc*)
2127238104Sdes      pic_mode=default
2128238104Sdes      ;;
2129238104Sdes    esac
2130238104Sdes    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
2131238104Sdes      # non-PIC code in shared libraries is not supported
2132238104Sdes      pic_mode=default
2133238104Sdes    fi
2134238104Sdes
2135238104Sdes    # Calculate the filename of the output object if compiler does
2136238104Sdes    # not support -o with -c
2137238104Sdes    if test "$compiler_c_o" = no; then
2138238104Sdes      output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext}
2139238104Sdes      lockfile="$output_obj.lock"
2140238104Sdes    else
2141238104Sdes      output_obj=
2142238104Sdes      need_locks=no
2143238104Sdes      lockfile=
2144238104Sdes    fi
2145238104Sdes
2146238104Sdes    # Lock this critical section if it is needed
2147238104Sdes    # We use this script file to make the link, it avoids creating a new file
2148238104Sdes    if test "$need_locks" = yes; then
2149238104Sdes      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
2150238104Sdes	func_echo "Waiting for $lockfile to be removed"
2151238104Sdes	sleep 2
2152238104Sdes      done
2153238104Sdes    elif test "$need_locks" = warn; then
2154238104Sdes      if test -f "$lockfile"; then
2155238104Sdes	$ECHO "\
2156238104Sdes*** ERROR, $lockfile exists and contains:
2157238104Sdes`cat $lockfile 2>/dev/null`
2158238104Sdes
2159238104SdesThis indicates that another process is trying to use the same
2160238104Sdestemporary object file, and libtool could not work around it because
2161238104Sdesyour compiler does not support \`-c' and \`-o' together.  If you
2162238104Sdesrepeat this compilation, it may succeed, by chance, but you had better
2163238104Sdesavoid parallel builds (make -j) in this platform, or get a better
2164238104Sdescompiler."
2165238104Sdes
2166238104Sdes	$opt_dry_run || $RM $removelist
2167238104Sdes	exit $EXIT_FAILURE
2168238104Sdes      fi
2169238104Sdes      func_append removelist " $output_obj"
2170238104Sdes      $ECHO "$srcfile" > "$lockfile"
2171238104Sdes    fi
2172238104Sdes
2173238104Sdes    $opt_dry_run || $RM $removelist
2174238104Sdes    func_append removelist " $lockfile"
2175238104Sdes    trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
2176238104Sdes
2177238104Sdes    func_to_tool_file "$srcfile" func_convert_file_msys_to_w32
2178238104Sdes    srcfile=$func_to_tool_file_result
2179238104Sdes    func_quote_for_eval "$srcfile"
2180238104Sdes    qsrcfile=$func_quote_for_eval_result
2181238104Sdes
2182238104Sdes    # Only build a PIC object if we are building libtool libraries.
2183238104Sdes    if test "$build_libtool_libs" = yes; then
2184238104Sdes      # Without this assignment, base_compile gets emptied.
2185238104Sdes      fbsd_hideous_sh_bug=$base_compile
2186238104Sdes
2187238104Sdes      if test "$pic_mode" != no; then
2188238104Sdes	command="$base_compile $qsrcfile $pic_flag"
2189238104Sdes      else
2190238104Sdes	# Don't build PIC code
2191238104Sdes	command="$base_compile $qsrcfile"
2192238104Sdes      fi
2193238104Sdes
2194238104Sdes      func_mkdir_p "$xdir$objdir"
2195238104Sdes
2196238104Sdes      if test -z "$output_obj"; then
2197238104Sdes	# Place PIC objects in $objdir
2198238104Sdes	func_append command " -o $lobj"
2199238104Sdes      fi
2200238104Sdes
2201238104Sdes      func_show_eval_locale "$command"	\
2202238104Sdes          'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
2203238104Sdes
2204238104Sdes      if test "$need_locks" = warn &&
2205238104Sdes	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
2206238104Sdes	$ECHO "\
2207238104Sdes*** ERROR, $lockfile contains:
2208238104Sdes`cat $lockfile 2>/dev/null`
2209238104Sdes
2210238104Sdesbut it should contain:
2211238104Sdes$srcfile
2212238104Sdes
2213238104SdesThis indicates that another process is trying to use the same
2214238104Sdestemporary object file, and libtool could not work around it because
2215238104Sdesyour compiler does not support \`-c' and \`-o' together.  If you
2216238104Sdesrepeat this compilation, it may succeed, by chance, but you had better
2217238104Sdesavoid parallel builds (make -j) in this platform, or get a better
2218238104Sdescompiler."
2219238104Sdes
2220238104Sdes	$opt_dry_run || $RM $removelist
2221238104Sdes	exit $EXIT_FAILURE
2222238104Sdes      fi
2223238104Sdes
2224238104Sdes      # Just move the object if needed, then go on to compile the next one
2225238104Sdes      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
2226238104Sdes	func_show_eval '$MV "$output_obj" "$lobj"' \
2227238104Sdes	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
2228238104Sdes      fi
2229238104Sdes
2230238104Sdes      # Allow error messages only from the first compilation.
2231238104Sdes      if test "$suppress_opt" = yes; then
2232238104Sdes	suppress_output=' >/dev/null 2>&1'
2233238104Sdes      fi
2234238104Sdes    fi
2235238104Sdes
2236238104Sdes    # Only build a position-dependent object if we build old libraries.
2237238104Sdes    if test "$build_old_libs" = yes; then
2238238104Sdes      if test "$pic_mode" != yes; then
2239238104Sdes	# Don't build PIC code
2240238104Sdes	command="$base_compile $qsrcfile$pie_flag"
2241238104Sdes      else
2242238104Sdes	command="$base_compile $qsrcfile $pic_flag"
2243238104Sdes      fi
2244238104Sdes      if test "$compiler_c_o" = yes; then
2245238104Sdes	func_append command " -o $obj"
2246238104Sdes      fi
2247238104Sdes
2248238104Sdes      # Suppress compiler output if we already did a PIC compilation.
2249238104Sdes      func_append command "$suppress_output"
2250238104Sdes      func_show_eval_locale "$command" \
2251238104Sdes        '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
2252238104Sdes
2253238104Sdes      if test "$need_locks" = warn &&
2254238104Sdes	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
2255238104Sdes	$ECHO "\
2256238104Sdes*** ERROR, $lockfile contains:
2257238104Sdes`cat $lockfile 2>/dev/null`
2258238104Sdes
2259238104Sdesbut it should contain:
2260238104Sdes$srcfile
2261238104Sdes
2262238104SdesThis indicates that another process is trying to use the same
2263238104Sdestemporary object file, and libtool could not work around it because
2264238104Sdesyour compiler does not support \`-c' and \`-o' together.  If you
2265238104Sdesrepeat this compilation, it may succeed, by chance, but you had better
2266238104Sdesavoid parallel builds (make -j) in this platform, or get a better
2267238104Sdescompiler."
2268238104Sdes
2269238104Sdes	$opt_dry_run || $RM $removelist
2270238104Sdes	exit $EXIT_FAILURE
2271238104Sdes      fi
2272238104Sdes
2273238104Sdes      # Just move the object if needed
2274238104Sdes      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
2275238104Sdes	func_show_eval '$MV "$output_obj" "$obj"' \
2276238104Sdes	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
2277238104Sdes      fi
2278238104Sdes    fi
2279238104Sdes
2280238104Sdes    $opt_dry_run || {
2281238104Sdes      func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
2282238104Sdes
2283238104Sdes      # Unlock the critical section if it was locked
2284238104Sdes      if test "$need_locks" != no; then
2285238104Sdes	removelist=$lockfile
2286238104Sdes        $RM "$lockfile"
2287238104Sdes      fi
2288238104Sdes    }
2289238104Sdes
2290238104Sdes    exit $EXIT_SUCCESS
2291238104Sdes}
2292238104Sdes
2293238104Sdes$opt_help || {
2294238104Sdes  test "$opt_mode" = compile && func_mode_compile ${1+"$@"}
2295238104Sdes}
2296238104Sdes
2297238104Sdesfunc_mode_help ()
2298238104Sdes{
2299238104Sdes    # We need to display help for each of the modes.
2300238104Sdes    case $opt_mode in
2301238104Sdes      "")
2302238104Sdes        # Generic help is extracted from the usage comments
2303238104Sdes        # at the start of this file.
2304238104Sdes        func_help
2305238104Sdes        ;;
2306238104Sdes
2307238104Sdes      clean)
2308238104Sdes        $ECHO \
2309238104Sdes"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
2310238104Sdes
2311238104SdesRemove files from the build directory.
2312238104Sdes
2313238104SdesRM is the name of the program to use to delete files associated with each FILE
2314238104Sdes(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
2315238104Sdesto RM.
2316238104Sdes
2317238104SdesIf FILE is a libtool library, object or program, all the files associated
2318238104Sdeswith it are deleted. Otherwise, only FILE itself is deleted using RM."
2319238104Sdes        ;;
2320238104Sdes
2321238104Sdes      compile)
2322238104Sdes      $ECHO \
2323238104Sdes"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
2324238104Sdes
2325238104SdesCompile a source file into a libtool library object.
2326238104Sdes
2327238104SdesThis mode accepts the following additional options:
2328238104Sdes
2329238104Sdes  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
2330238104Sdes  -no-suppress      do not suppress compiler output for multiple passes
2331238104Sdes  -prefer-pic       try to build PIC objects only
2332238104Sdes  -prefer-non-pic   try to build non-PIC objects only
2333238104Sdes  -shared           do not build a \`.o' file suitable for static linking
2334238104Sdes  -static           only build a \`.o' file suitable for static linking
2335238104Sdes  -Wc,FLAG          pass FLAG directly to the compiler
2336238104Sdes
2337238104SdesCOMPILE-COMMAND is a command to be used in creating a \`standard' object file
2338238104Sdesfrom the given SOURCEFILE.
2339238104Sdes
2340238104SdesThe output file name is determined by removing the directory component from
2341238104SdesSOURCEFILE, then substituting the C source code suffix \`.c' with the
2342238104Sdeslibrary object suffix, \`.lo'."
2343238104Sdes        ;;
2344238104Sdes
2345238104Sdes      execute)
2346238104Sdes        $ECHO \
2347238104Sdes"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
2348238104Sdes
2349238104SdesAutomatically set library path, then run a program.
2350238104Sdes
2351238104SdesThis mode accepts the following additional options:
2352238104Sdes
2353238104Sdes  -dlopen FILE      add the directory containing FILE to the library path
2354238104Sdes
2355238104SdesThis mode sets the library path environment variable according to \`-dlopen'
2356238104Sdesflags.
2357238104Sdes
2358238104SdesIf any of the ARGS are libtool executable wrappers, then they are translated
2359238104Sdesinto their corresponding uninstalled binary, and any of their required library
2360238104Sdesdirectories are added to the library path.
2361238104Sdes
2362238104SdesThen, COMMAND is executed, with ARGS as arguments."
2363238104Sdes        ;;
2364238104Sdes
2365238104Sdes      finish)
2366238104Sdes        $ECHO \
2367238104Sdes"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
2368238104Sdes
2369238104SdesComplete the installation of libtool libraries.
2370238104Sdes
2371238104SdesEach LIBDIR is a directory that contains libtool libraries.
2372238104Sdes
2373238104SdesThe commands that this mode executes may require superuser privileges.  Use
2374238104Sdesthe \`--dry-run' option if you just want to see what would be executed."
2375238104Sdes        ;;
2376238104Sdes
2377238104Sdes      install)
2378238104Sdes        $ECHO \
2379238104Sdes"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
2380238104Sdes
2381238104SdesInstall executables or libraries.
2382238104Sdes
2383238104SdesINSTALL-COMMAND is the installation command.  The first component should be
2384238104Sdeseither the \`install' or \`cp' program.
2385238104Sdes
2386238104SdesThe following components of INSTALL-COMMAND are treated specially:
2387238104Sdes
2388238104Sdes  -inst-prefix-dir PREFIX-DIR  Use PREFIX-DIR as a staging area for installation
2389238104Sdes
2390238104SdesThe rest of the components are interpreted as arguments to that command (only
2391238104SdesBSD-compatible install options are recognized)."
2392238104Sdes        ;;
2393238104Sdes
2394238104Sdes      link)
2395238104Sdes        $ECHO \
2396238104Sdes"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
2397238104Sdes
2398238104SdesLink object files or libraries together to form another library, or to
2399238104Sdescreate an executable program.
2400238104Sdes
2401238104SdesLINK-COMMAND is a command using the C compiler that you would use to create
2402238104Sdesa program from several object files.
2403238104Sdes
2404238104SdesThe following components of LINK-COMMAND are treated specially:
2405238104Sdes
2406238104Sdes  -all-static       do not do any dynamic linking at all
2407238104Sdes  -avoid-version    do not add a version suffix if possible
2408238104Sdes  -bindir BINDIR    specify path to binaries directory (for systems where
2409238104Sdes                    libraries must be found in the PATH setting at runtime)
2410238104Sdes  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
2411238104Sdes  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
2412238104Sdes  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
2413238104Sdes  -export-symbols SYMFILE
2414238104Sdes                    try to export only the symbols listed in SYMFILE
2415238104Sdes  -export-symbols-regex REGEX
2416238104Sdes                    try to export only the symbols matching REGEX
2417238104Sdes  -LLIBDIR          search LIBDIR for required installed libraries
2418238104Sdes  -lNAME            OUTPUT-FILE requires the installed library libNAME
2419238104Sdes  -module           build a library that can dlopened
2420238104Sdes  -no-fast-install  disable the fast-install mode
2421238104Sdes  -no-install       link a not-installable executable
2422238104Sdes  -no-undefined     declare that a library does not refer to external symbols
2423238104Sdes  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
2424238104Sdes  -objectlist FILE  Use a list of object files found in FILE to specify objects
2425238104Sdes  -precious-files-regex REGEX
2426238104Sdes                    don't remove output files matching REGEX
2427238104Sdes  -release RELEASE  specify package release information
2428238104Sdes  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
2429238104Sdes  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
2430238104Sdes  -shared           only do dynamic linking of libtool libraries
2431238104Sdes  -shrext SUFFIX    override the standard shared library file extension
2432238104Sdes  -static           do not do any dynamic linking of uninstalled libtool libraries
2433238104Sdes  -static-libtool-libs
2434238104Sdes                    do not do any dynamic linking of libtool libraries
2435238104Sdes  -version-info CURRENT[:REVISION[:AGE]]
2436238104Sdes                    specify library version info [each variable defaults to 0]
2437238104Sdes  -weak LIBNAME     declare that the target provides the LIBNAME interface
2438238104Sdes  -Wc,FLAG
2439238104Sdes  -Xcompiler FLAG   pass linker-specific FLAG directly to the compiler
2440238104Sdes  -Wl,FLAG
2441238104Sdes  -Xlinker FLAG     pass linker-specific FLAG directly to the linker
2442238104Sdes  -XCClinker FLAG   pass link-specific FLAG to the compiler driver (CC)
2443238104Sdes
2444238104SdesAll other options (arguments beginning with \`-') are ignored.
2445238104Sdes
2446238104SdesEvery other argument is treated as a filename.  Files ending in \`.la' are
2447238104Sdestreated as uninstalled libtool libraries, other files are standard or library
2448238104Sdesobject files.
2449238104Sdes
2450238104SdesIf the OUTPUT-FILE ends in \`.la', then a libtool library is created,
2451238104Sdesonly library objects (\`.lo' files) may be specified, and \`-rpath' is
2452238104Sdesrequired, except when creating a convenience library.
2453238104Sdes
2454238104SdesIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
2455238104Sdesusing \`ar' and \`ranlib', or on Windows using \`lib'.
2456238104Sdes
2457238104SdesIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
2458238104Sdesis created, otherwise an executable program is created."
2459238104Sdes        ;;
2460238104Sdes
2461238104Sdes      uninstall)
2462238104Sdes        $ECHO \
2463238104Sdes"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
2464238104Sdes
2465238104SdesRemove libraries from an installation directory.
2466238104Sdes
2467238104SdesRM is the name of the program to use to delete files associated with each FILE
2468238104Sdes(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
2469238104Sdesto RM.
2470238104Sdes
2471238104SdesIf FILE is a libtool library, all the files associated with it are deleted.
2472238104SdesOtherwise, only FILE itself is deleted using RM."
2473238104Sdes        ;;
2474238104Sdes
2475238104Sdes      *)
2476238104Sdes        func_fatal_help "invalid operation mode \`$opt_mode'"
2477238104Sdes        ;;
2478238104Sdes    esac
2479238104Sdes
2480238104Sdes    echo
2481238104Sdes    $ECHO "Try \`$progname --help' for more information about other modes."
2482238104Sdes}
2483238104Sdes
2484238104Sdes# Now that we've collected a possible --mode arg, show help if necessary
2485238104Sdesif $opt_help; then
2486238104Sdes  if test "$opt_help" = :; then
2487238104Sdes    func_mode_help
2488238104Sdes  else
2489238104Sdes    {
2490238104Sdes      func_help noexit
2491238104Sdes      for opt_mode in compile link execute install finish uninstall clean; do
2492238104Sdes	func_mode_help
2493238104Sdes      done
2494238104Sdes    } | sed -n '1p; 2,$s/^Usage:/  or: /p'
2495238104Sdes    {
2496238104Sdes      func_help noexit
2497238104Sdes      for opt_mode in compile link execute install finish uninstall clean; do
2498238104Sdes	echo
2499238104Sdes	func_mode_help
2500238104Sdes      done
2501238104Sdes    } |
2502238104Sdes    sed '1d
2503238104Sdes      /^When reporting/,/^Report/{
2504238104Sdes	H
2505238104Sdes	d
2506238104Sdes      }
2507238104Sdes      $x
2508238104Sdes      /information about other modes/d
2509238104Sdes      /more detailed .*MODE/d
2510238104Sdes      s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
2511238104Sdes  fi
2512238104Sdes  exit $?
2513238104Sdesfi
2514238104Sdes
2515238104Sdes
2516238104Sdes# func_mode_execute arg...
2517238104Sdesfunc_mode_execute ()
2518238104Sdes{
2519238104Sdes    $opt_debug
2520238104Sdes    # The first argument is the command name.
2521238104Sdes    cmd="$nonopt"
2522238104Sdes    test -z "$cmd" && \
2523238104Sdes      func_fatal_help "you must specify a COMMAND"
2524238104Sdes
2525238104Sdes    # Handle -dlopen flags immediately.
2526238104Sdes    for file in $opt_dlopen; do
2527238104Sdes      test -f "$file" \
2528238104Sdes	|| func_fatal_help "\`$file' is not a file"
2529238104Sdes
2530238104Sdes      dir=
2531238104Sdes      case $file in
2532238104Sdes      *.la)
2533238104Sdes	func_resolve_sysroot "$file"
2534238104Sdes	file=$func_resolve_sysroot_result
2535238104Sdes
2536238104Sdes	# Check to see that this really is a libtool archive.
2537238104Sdes	func_lalib_unsafe_p "$file" \
2538238104Sdes	  || func_fatal_help "\`$lib' is not a valid libtool archive"
2539238104Sdes
2540238104Sdes	# Read the libtool library.
2541238104Sdes	dlname=
2542238104Sdes	library_names=
2543238104Sdes	func_source "$file"
2544238104Sdes
2545238104Sdes	# Skip this library if it cannot be dlopened.
2546238104Sdes	if test -z "$dlname"; then
2547238104Sdes	  # Warn if it was a shared library.
2548238104Sdes	  test -n "$library_names" && \
2549238104Sdes	    func_warning "\`$file' was not linked with \`-export-dynamic'"
2550238104Sdes	  continue
2551238104Sdes	fi
2552238104Sdes
2553238104Sdes	func_dirname "$file" "" "."
2554238104Sdes	dir="$func_dirname_result"
2555238104Sdes
2556238104Sdes	if test -f "$dir/$objdir/$dlname"; then
2557238104Sdes	  func_append dir "/$objdir"
2558238104Sdes	else
2559238104Sdes	  if test ! -f "$dir/$dlname"; then
2560238104Sdes	    func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'"
2561238104Sdes	  fi
2562238104Sdes	fi
2563238104Sdes	;;
2564238104Sdes
2565238104Sdes      *.lo)
2566238104Sdes	# Just add the directory containing the .lo file.
2567238104Sdes	func_dirname "$file" "" "."
2568238104Sdes	dir="$func_dirname_result"
2569238104Sdes	;;
2570238104Sdes
2571238104Sdes      *)
2572238104Sdes	func_warning "\`-dlopen' is ignored for non-libtool libraries and objects"
2573238104Sdes	continue
2574238104Sdes	;;
2575238104Sdes      esac
2576238104Sdes
2577238104Sdes      # Get the absolute pathname.
2578238104Sdes      absdir=`cd "$dir" && pwd`
2579238104Sdes      test -n "$absdir" && dir="$absdir"
2580238104Sdes
2581238104Sdes      # Now add the directory to shlibpath_var.
2582238104Sdes      if eval "test -z \"\$$shlibpath_var\""; then
2583238104Sdes	eval "$shlibpath_var=\"\$dir\""
2584238104Sdes      else
2585238104Sdes	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
2586238104Sdes      fi
2587238104Sdes    done
2588238104Sdes
2589238104Sdes    # This variable tells wrapper scripts just to set shlibpath_var
2590238104Sdes    # rather than running their programs.
2591238104Sdes    libtool_execute_magic="$magic"
2592238104Sdes
2593238104Sdes    # Check if any of the arguments is a wrapper script.
2594238104Sdes    args=
2595238104Sdes    for file
2596238104Sdes    do
2597238104Sdes      case $file in
2598238104Sdes      -* | *.la | *.lo ) ;;
2599238104Sdes      *)
2600238104Sdes	# Do a test to see if this is really a libtool program.
2601238104Sdes	if func_ltwrapper_script_p "$file"; then
2602238104Sdes	  func_source "$file"
2603238104Sdes	  # Transform arg to wrapped name.
2604238104Sdes	  file="$progdir/$program"
2605238104Sdes	elif func_ltwrapper_executable_p "$file"; then
2606238104Sdes	  func_ltwrapper_scriptname "$file"
2607238104Sdes	  func_source "$func_ltwrapper_scriptname_result"
2608238104Sdes	  # Transform arg to wrapped name.
2609238104Sdes	  file="$progdir/$program"
2610238104Sdes	fi
2611238104Sdes	;;
2612238104Sdes      esac
2613238104Sdes      # Quote arguments (to preserve shell metacharacters).
2614238104Sdes      func_append_quoted args "$file"
2615238104Sdes    done
2616238104Sdes
2617238104Sdes    if test "X$opt_dry_run" = Xfalse; then
2618238104Sdes      if test -n "$shlibpath_var"; then
2619238104Sdes	# Export the shlibpath_var.
2620238104Sdes	eval "export $shlibpath_var"
2621238104Sdes      fi
2622238104Sdes
2623238104Sdes      # Restore saved environment variables
2624238104Sdes      for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
2625238104Sdes      do
2626238104Sdes	eval "if test \"\${save_$lt_var+set}\" = set; then
2627238104Sdes                $lt_var=\$save_$lt_var; export $lt_var
2628238104Sdes	      else
2629238104Sdes		$lt_unset $lt_var
2630238104Sdes	      fi"
2631238104Sdes      done
2632238104Sdes
2633238104Sdes      # Now prepare to actually exec the command.
2634238104Sdes      exec_cmd="\$cmd$args"
2635238104Sdes    else
2636238104Sdes      # Display what would be done.
2637238104Sdes      if test -n "$shlibpath_var"; then
2638238104Sdes	eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
2639238104Sdes	echo "export $shlibpath_var"
2640238104Sdes      fi
2641238104Sdes      $ECHO "$cmd$args"
2642238104Sdes      exit $EXIT_SUCCESS
2643238104Sdes    fi
2644238104Sdes}
2645238104Sdes
2646238104Sdestest "$opt_mode" = execute && func_mode_execute ${1+"$@"}
2647238104Sdes
2648238104Sdes
2649238104Sdes# func_mode_finish arg...
2650238104Sdesfunc_mode_finish ()
2651238104Sdes{
2652238104Sdes    $opt_debug
2653238104Sdes    libs=
2654238104Sdes    libdirs=
2655238104Sdes    admincmds=
2656238104Sdes
2657238104Sdes    for opt in "$nonopt" ${1+"$@"}
2658238104Sdes    do
2659238104Sdes      if test -d "$opt"; then
2660238104Sdes	func_append libdirs " $opt"
2661238104Sdes
2662238104Sdes      elif test -f "$opt"; then
2663238104Sdes	if func_lalib_unsafe_p "$opt"; then
2664238104Sdes	  func_append libs " $opt"
2665238104Sdes	else
2666238104Sdes	  func_warning "\`$opt' is not a valid libtool archive"
2667238104Sdes	fi
2668238104Sdes
2669238104Sdes      else
2670238104Sdes	func_fatal_error "invalid argument \`$opt'"
2671238104Sdes      fi
2672238104Sdes    done
2673238104Sdes
2674238104Sdes    if test -n "$libs"; then
2675238104Sdes      if test -n "$lt_sysroot"; then
2676238104Sdes        sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"`
2677238104Sdes        sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;"
2678238104Sdes      else
2679238104Sdes        sysroot_cmd=
2680238104Sdes      fi
2681238104Sdes
2682238104Sdes      # Remove sysroot references
2683238104Sdes      if $opt_dry_run; then
2684238104Sdes        for lib in $libs; do
2685238104Sdes          echo "removing references to $lt_sysroot and \`=' prefixes from $lib"
2686238104Sdes        done
2687238104Sdes      else
2688238104Sdes        tmpdir=`func_mktempdir`
2689238104Sdes        for lib in $libs; do
2690238104Sdes	  sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
2691238104Sdes	    > $tmpdir/tmp-la
2692238104Sdes	  mv -f $tmpdir/tmp-la $lib
2693238104Sdes	done
2694238104Sdes        ${RM}r "$tmpdir"
2695238104Sdes      fi
2696238104Sdes    fi
2697238104Sdes
2698238104Sdes    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
2699238104Sdes      for libdir in $libdirs; do
2700238104Sdes	if test -n "$finish_cmds"; then
2701238104Sdes	  # Do each command in the finish commands.
2702238104Sdes	  func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
2703238104Sdes'"$cmd"'"'
2704238104Sdes	fi
2705238104Sdes	if test -n "$finish_eval"; then
2706238104Sdes	  # Do the single finish_eval.
2707238104Sdes	  eval cmds=\"$finish_eval\"
2708238104Sdes	  $opt_dry_run || eval "$cmds" || func_append admincmds "
2709238104Sdes       $cmds"
2710238104Sdes	fi
2711238104Sdes      done
2712238104Sdes    fi
2713238104Sdes
2714238104Sdes    # Exit here if they wanted silent mode.
2715238104Sdes    $opt_silent && exit $EXIT_SUCCESS
2716238104Sdes
2717238104Sdes    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
2718238104Sdes      echo "----------------------------------------------------------------------"
2719238104Sdes      echo "Libraries have been installed in:"
2720238104Sdes      for libdir in $libdirs; do
2721238104Sdes	$ECHO "   $libdir"
2722238104Sdes      done
2723238104Sdes      echo
2724238104Sdes      echo "If you ever happen to want to link against installed libraries"
2725238104Sdes      echo "in a given directory, LIBDIR, you must either use libtool, and"
2726238104Sdes      echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
2727238104Sdes      echo "flag during linking and do at least one of the following:"
2728238104Sdes      if test -n "$shlibpath_var"; then
2729238104Sdes	echo "   - add LIBDIR to the \`$shlibpath_var' environment variable"
2730238104Sdes	echo "     during execution"
2731238104Sdes      fi
2732238104Sdes      if test -n "$runpath_var"; then
2733238104Sdes	echo "   - add LIBDIR to the \`$runpath_var' environment variable"
2734238104Sdes	echo "     during linking"
2735238104Sdes      fi
2736238104Sdes      if test -n "$hardcode_libdir_flag_spec"; then
2737238104Sdes	libdir=LIBDIR
2738238104Sdes	eval flag=\"$hardcode_libdir_flag_spec\"
2739238104Sdes
2740238104Sdes	$ECHO "   - use the \`$flag' linker flag"
2741238104Sdes      fi
2742238104Sdes      if test -n "$admincmds"; then
2743238104Sdes	$ECHO "   - have your system administrator run these commands:$admincmds"
2744238104Sdes      fi
2745238104Sdes      if test -f /etc/ld.so.conf; then
2746238104Sdes	echo "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
2747238104Sdes      fi
2748238104Sdes      echo
2749238104Sdes
2750238104Sdes      echo "See any operating system documentation about shared libraries for"
2751238104Sdes      case $host in
2752238104Sdes	solaris2.[6789]|solaris2.1[0-9])
2753238104Sdes	  echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
2754238104Sdes	  echo "pages."
2755238104Sdes	  ;;
2756238104Sdes	*)
2757238104Sdes	  echo "more information, such as the ld(1) and ld.so(8) manual pages."
2758238104Sdes	  ;;
2759238104Sdes      esac
2760238104Sdes      echo "----------------------------------------------------------------------"
2761238104Sdes    fi
2762238104Sdes    exit $EXIT_SUCCESS
2763238104Sdes}
2764238104Sdes
2765238104Sdestest "$opt_mode" = finish && func_mode_finish ${1+"$@"}
2766238104Sdes
2767238104Sdes
2768238104Sdes# func_mode_install arg...
2769238104Sdesfunc_mode_install ()
2770238104Sdes{
2771238104Sdes    $opt_debug
2772238104Sdes    # There may be an optional sh(1) argument at the beginning of
2773238104Sdes    # install_prog (especially on Windows NT).
2774238104Sdes    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
2775238104Sdes       # Allow the use of GNU shtool's install command.
2776238104Sdes       case $nonopt in *shtool*) :;; *) false;; esac; then
2777238104Sdes      # Aesthetically quote it.
2778238104Sdes      func_quote_for_eval "$nonopt"
2779238104Sdes      install_prog="$func_quote_for_eval_result "
2780238104Sdes      arg=$1
2781238104Sdes      shift
2782238104Sdes    else
2783238104Sdes      install_prog=
2784238104Sdes      arg=$nonopt
2785238104Sdes    fi
2786238104Sdes
2787238104Sdes    # The real first argument should be the name of the installation program.
2788238104Sdes    # Aesthetically quote it.
2789238104Sdes    func_quote_for_eval "$arg"
2790238104Sdes    func_append install_prog "$func_quote_for_eval_result"
2791238104Sdes    install_shared_prog=$install_prog
2792238104Sdes    case " $install_prog " in
2793238104Sdes      *[\\\ /]cp\ *) install_cp=: ;;
2794238104Sdes      *) install_cp=false ;;
2795238104Sdes    esac
2796238104Sdes
2797238104Sdes    # We need to accept at least all the BSD install flags.
2798238104Sdes    dest=
2799238104Sdes    files=
2800238104Sdes    opts=
2801238104Sdes    prev=
2802238104Sdes    install_type=
2803238104Sdes    isdir=no
2804238104Sdes    stripme=
2805238104Sdes    no_mode=:
2806238104Sdes    for arg
2807238104Sdes    do
2808238104Sdes      arg2=
2809238104Sdes      if test -n "$dest"; then
2810238104Sdes	func_append files " $dest"
2811238104Sdes	dest=$arg
2812238104Sdes	continue
2813238104Sdes      fi
2814238104Sdes
2815238104Sdes      case $arg in
2816238104Sdes      -d) isdir=yes ;;
2817238104Sdes      -f)
2818238104Sdes	if $install_cp; then :; else
2819238104Sdes	  prev=$arg
2820238104Sdes	fi
2821238104Sdes	;;
2822238104Sdes      -g | -m | -o)
2823238104Sdes	prev=$arg
2824238104Sdes	;;
2825238104Sdes      -s)
2826238104Sdes	stripme=" -s"
2827238104Sdes	continue
2828238104Sdes	;;
2829238104Sdes      -*)
2830238104Sdes	;;
2831238104Sdes      *)
2832238104Sdes	# If the previous option needed an argument, then skip it.
2833238104Sdes	if test -n "$prev"; then
2834238104Sdes	  if test "x$prev" = x-m && test -n "$install_override_mode"; then
2835238104Sdes	    arg2=$install_override_mode
2836238104Sdes	    no_mode=false
2837238104Sdes	  fi
2838238104Sdes	  prev=
2839238104Sdes	else
2840238104Sdes	  dest=$arg
2841238104Sdes	  continue
2842238104Sdes	fi
2843238104Sdes	;;
2844238104Sdes      esac
2845238104Sdes
2846238104Sdes      # Aesthetically quote the argument.
2847238104Sdes      func_quote_for_eval "$arg"
2848238104Sdes      func_append install_prog " $func_quote_for_eval_result"
2849238104Sdes      if test -n "$arg2"; then
2850238104Sdes	func_quote_for_eval "$arg2"
2851238104Sdes      fi
2852238104Sdes      func_append install_shared_prog " $func_quote_for_eval_result"
2853238104Sdes    done
2854238104Sdes
2855238104Sdes    test -z "$install_prog" && \
2856238104Sdes      func_fatal_help "you must specify an install program"
2857238104Sdes
2858238104Sdes    test -n "$prev" && \
2859238104Sdes      func_fatal_help "the \`$prev' option requires an argument"
2860238104Sdes
2861238104Sdes    if test -n "$install_override_mode" && $no_mode; then
2862238104Sdes      if $install_cp; then :; else
2863238104Sdes	func_quote_for_eval "$install_override_mode"
2864238104Sdes	func_append install_shared_prog " -m $func_quote_for_eval_result"
2865238104Sdes      fi
2866238104Sdes    fi
2867238104Sdes
2868238104Sdes    if test -z "$files"; then
2869238104Sdes      if test -z "$dest"; then
2870238104Sdes	func_fatal_help "no file or destination specified"
2871238104Sdes      else
2872238104Sdes	func_fatal_help "you must specify a destination"
2873238104Sdes      fi
2874238104Sdes    fi
2875238104Sdes
2876238104Sdes    # Strip any trailing slash from the destination.
2877238104Sdes    func_stripname '' '/' "$dest"
2878238104Sdes    dest=$func_stripname_result
2879238104Sdes
2880238104Sdes    # Check to see that the destination is a directory.
2881238104Sdes    test -d "$dest" && isdir=yes
2882238104Sdes    if test "$isdir" = yes; then
2883238104Sdes      destdir="$dest"
2884238104Sdes      destname=
2885238104Sdes    else
2886238104Sdes      func_dirname_and_basename "$dest" "" "."
2887238104Sdes      destdir="$func_dirname_result"
2888238104Sdes      destname="$func_basename_result"
2889238104Sdes
2890238104Sdes      # Not a directory, so check to see that there is only one file specified.
2891238104Sdes      set dummy $files; shift
2892238104Sdes      test "$#" -gt 1 && \
2893238104Sdes	func_fatal_help "\`$dest' is not a directory"
2894238104Sdes    fi
2895238104Sdes    case $destdir in
2896238104Sdes    [\\/]* | [A-Za-z]:[\\/]*) ;;
2897238104Sdes    *)
2898238104Sdes      for file in $files; do
2899238104Sdes	case $file in
2900238104Sdes	*.lo) ;;
2901238104Sdes	*)
2902238104Sdes	  func_fatal_help "\`$destdir' must be an absolute directory name"
2903238104Sdes	  ;;
2904238104Sdes	esac
2905238104Sdes      done
2906238104Sdes      ;;
2907238104Sdes    esac
2908238104Sdes
2909238104Sdes    # This variable tells wrapper scripts just to set variables rather
2910238104Sdes    # than running their programs.
2911238104Sdes    libtool_install_magic="$magic"
2912238104Sdes
2913238104Sdes    staticlibs=
2914238104Sdes    future_libdirs=
2915238104Sdes    current_libdirs=
2916238104Sdes    for file in $files; do
2917238104Sdes
2918238104Sdes      # Do each installation.
2919238104Sdes      case $file in
2920238104Sdes      *.$libext)
2921238104Sdes	# Do the static libraries later.
2922238104Sdes	func_append staticlibs " $file"
2923238104Sdes	;;
2924238104Sdes
2925238104Sdes      *.la)
2926238104Sdes	func_resolve_sysroot "$file"
2927238104Sdes	file=$func_resolve_sysroot_result
2928238104Sdes
2929238104Sdes	# Check to see that this really is a libtool archive.
2930238104Sdes	func_lalib_unsafe_p "$file" \
2931238104Sdes	  || func_fatal_help "\`$file' is not a valid libtool archive"
2932238104Sdes
2933238104Sdes	library_names=
2934238104Sdes	old_library=
2935238104Sdes	relink_command=
2936238104Sdes	func_source "$file"
2937238104Sdes
2938238104Sdes	# Add the libdir to current_libdirs if it is the destination.
2939238104Sdes	if test "X$destdir" = "X$libdir"; then
2940238104Sdes	  case "$current_libdirs " in
2941238104Sdes	  *" $libdir "*) ;;
2942238104Sdes	  *) func_append current_libdirs " $libdir" ;;
2943238104Sdes	  esac
2944238104Sdes	else
2945238104Sdes	  # Note the libdir as a future libdir.
2946238104Sdes	  case "$future_libdirs " in
2947238104Sdes	  *" $libdir "*) ;;
2948238104Sdes	  *) func_append future_libdirs " $libdir" ;;
2949238104Sdes	  esac
2950238104Sdes	fi
2951238104Sdes
2952238104Sdes	func_dirname "$file" "/" ""
2953238104Sdes	dir="$func_dirname_result"
2954238104Sdes	func_append dir "$objdir"
2955238104Sdes
2956238104Sdes	if test -n "$relink_command"; then
2957238104Sdes	  # Determine the prefix the user has applied to our future dir.
2958238104Sdes	  inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
2959238104Sdes
2960238104Sdes	  # Don't allow the user to place us outside of our expected
2961238104Sdes	  # location b/c this prevents finding dependent libraries that
2962238104Sdes	  # are installed to the same prefix.
2963238104Sdes	  # At present, this check doesn't affect windows .dll's that
2964238104Sdes	  # are installed into $libdir/../bin (currently, that works fine)
2965238104Sdes	  # but it's something to keep an eye on.
2966238104Sdes	  test "$inst_prefix_dir" = "$destdir" && \
2967238104Sdes	    func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
2968238104Sdes
2969238104Sdes	  if test -n "$inst_prefix_dir"; then
2970238104Sdes	    # Stick the inst_prefix_dir data into the link command.
2971238104Sdes	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
2972238104Sdes	  else
2973238104Sdes	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
2974238104Sdes	  fi
2975238104Sdes
2976238104Sdes	  func_warning "relinking \`$file'"
2977238104Sdes	  func_show_eval "$relink_command" \
2978238104Sdes	    'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
2979238104Sdes	fi
2980238104Sdes
2981238104Sdes	# See the names of the shared library.
2982238104Sdes	set dummy $library_names; shift
2983238104Sdes	if test -n "$1"; then
2984238104Sdes	  realname="$1"
2985238104Sdes	  shift
2986238104Sdes
2987238104Sdes	  srcname="$realname"
2988238104Sdes	  test -n "$relink_command" && srcname="$realname"T
2989238104Sdes
2990238104Sdes	  # Install the shared library and build the symlinks.
2991238104Sdes	  func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
2992238104Sdes	      'exit $?'
2993238104Sdes	  tstripme="$stripme"
2994238104Sdes	  case $host_os in
2995238104Sdes	  cygwin* | mingw* | pw32* | cegcc*)
2996238104Sdes	    case $realname in
2997238104Sdes	    *.dll.a)
2998238104Sdes	      tstripme=""
2999238104Sdes	      ;;
3000238104Sdes	    esac
3001238104Sdes	    ;;
3002238104Sdes	  esac
3003238104Sdes	  if test -n "$tstripme" && test -n "$striplib"; then
3004238104Sdes	    func_show_eval "$striplib $destdir/$realname" 'exit $?'
3005238104Sdes	  fi
3006238104Sdes
3007238104Sdes	  if test "$#" -gt 0; then
3008238104Sdes	    # Delete the old symlinks, and create new ones.
3009238104Sdes	    # Try `ln -sf' first, because the `ln' binary might depend on
3010238104Sdes	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
3011238104Sdes	    # so we also need to try rm && ln -s.
3012238104Sdes	    for linkname
3013238104Sdes	    do
3014238104Sdes	      test "$linkname" != "$realname" \
3015238104Sdes		&& func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
3016238104Sdes	    done
3017238104Sdes	  fi
3018238104Sdes
3019238104Sdes	  # Do each command in the postinstall commands.
3020238104Sdes	  lib="$destdir/$realname"
3021238104Sdes	  func_execute_cmds "$postinstall_cmds" 'exit $?'
3022238104Sdes	fi
3023238104Sdes
3024238104Sdes	# Install the pseudo-library for information purposes.
3025238104Sdes	func_basename "$file"
3026238104Sdes	name="$func_basename_result"
3027238104Sdes	instname="$dir/$name"i
3028238104Sdes	func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
3029238104Sdes
3030238104Sdes	# Maybe install the static library, too.
3031238104Sdes	test -n "$old_library" && func_append staticlibs " $dir/$old_library"
3032238104Sdes	;;
3033238104Sdes
3034238104Sdes      *.lo)
3035238104Sdes	# Install (i.e. copy) a libtool object.
3036238104Sdes
3037238104Sdes	# Figure out destination file name, if it wasn't already specified.
3038238104Sdes	if test -n "$destname"; then
3039238104Sdes	  destfile="$destdir/$destname"
3040238104Sdes	else
3041238104Sdes	  func_basename "$file"
3042238104Sdes	  destfile="$func_basename_result"
3043238104Sdes	  destfile="$destdir/$destfile"
3044238104Sdes	fi
3045238104Sdes
3046238104Sdes	# Deduce the name of the destination old-style object file.
3047238104Sdes	case $destfile in
3048238104Sdes	*.lo)
3049238104Sdes	  func_lo2o "$destfile"
3050238104Sdes	  staticdest=$func_lo2o_result
3051238104Sdes	  ;;
3052238104Sdes	*.$objext)
3053238104Sdes	  staticdest="$destfile"
3054238104Sdes	  destfile=
3055238104Sdes	  ;;
3056238104Sdes	*)
3057238104Sdes	  func_fatal_help "cannot copy a libtool object to \`$destfile'"
3058238104Sdes	  ;;
3059238104Sdes	esac
3060238104Sdes
3061238104Sdes	# Install the libtool object if requested.
3062238104Sdes	test -n "$destfile" && \
3063238104Sdes	  func_show_eval "$install_prog $file $destfile" 'exit $?'
3064238104Sdes
3065238104Sdes	# Install the old object if enabled.
3066238104Sdes	if test "$build_old_libs" = yes; then
3067238104Sdes	  # Deduce the name of the old-style object file.
3068238104Sdes	  func_lo2o "$file"
3069238104Sdes	  staticobj=$func_lo2o_result
3070238104Sdes	  func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
3071238104Sdes	fi
3072238104Sdes	exit $EXIT_SUCCESS
3073238104Sdes	;;
3074238104Sdes
3075238104Sdes      *)
3076238104Sdes	# Figure out destination file name, if it wasn't already specified.
3077238104Sdes	if test -n "$destname"; then
3078238104Sdes	  destfile="$destdir/$destname"
3079238104Sdes	else
3080238104Sdes	  func_basename "$file"
3081238104Sdes	  destfile="$func_basename_result"
3082238104Sdes	  destfile="$destdir/$destfile"
3083238104Sdes	fi
3084238104Sdes
3085238104Sdes	# If the file is missing, and there is a .exe on the end, strip it
3086238104Sdes	# because it is most likely a libtool script we actually want to
3087238104Sdes	# install
3088238104Sdes	stripped_ext=""
3089238104Sdes	case $file in
3090238104Sdes	  *.exe)
3091238104Sdes	    if test ! -f "$file"; then
3092238104Sdes	      func_stripname '' '.exe' "$file"
3093238104Sdes	      file=$func_stripname_result
3094238104Sdes	      stripped_ext=".exe"
3095238104Sdes	    fi
3096238104Sdes	    ;;
3097238104Sdes	esac
3098238104Sdes
3099238104Sdes	# Do a test to see if this is really a libtool program.
3100238104Sdes	case $host in
3101238104Sdes	*cygwin* | *mingw*)
3102238104Sdes	    if func_ltwrapper_executable_p "$file"; then
3103238104Sdes	      func_ltwrapper_scriptname "$file"
3104238104Sdes	      wrapper=$func_ltwrapper_scriptname_result
3105238104Sdes	    else
3106238104Sdes	      func_stripname '' '.exe' "$file"
3107238104Sdes	      wrapper=$func_stripname_result
3108238104Sdes	    fi
3109238104Sdes	    ;;
3110238104Sdes	*)
3111238104Sdes	    wrapper=$file
3112238104Sdes	    ;;
3113238104Sdes	esac
3114238104Sdes	if func_ltwrapper_script_p "$wrapper"; then
3115238104Sdes	  notinst_deplibs=
3116238104Sdes	  relink_command=
3117238104Sdes
3118238104Sdes	  func_source "$wrapper"
3119238104Sdes
3120238104Sdes	  # Check the variables that should have been set.
3121238104Sdes	  test -z "$generated_by_libtool_version" && \
3122238104Sdes	    func_fatal_error "invalid libtool wrapper script \`$wrapper'"
3123238104Sdes
3124238104Sdes	  finalize=yes
3125238104Sdes	  for lib in $notinst_deplibs; do
3126238104Sdes	    # Check to see that each library is installed.
3127238104Sdes	    libdir=
3128238104Sdes	    if test -f "$lib"; then
3129238104Sdes	      func_source "$lib"
3130238104Sdes	    fi
3131238104Sdes	    libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test
3132238104Sdes	    if test -n "$libdir" && test ! -f "$libfile"; then
3133238104Sdes	      func_warning "\`$lib' has not been installed in \`$libdir'"
3134238104Sdes	      finalize=no
3135238104Sdes	    fi
3136238104Sdes	  done
3137238104Sdes
3138238104Sdes	  relink_command=
3139238104Sdes	  func_source "$wrapper"
3140238104Sdes
3141238104Sdes	  outputname=
3142238104Sdes	  if test "$fast_install" = no && test -n "$relink_command"; then
3143238104Sdes	    $opt_dry_run || {
3144238104Sdes	      if test "$finalize" = yes; then
3145238104Sdes	        tmpdir=`func_mktempdir`
3146238104Sdes		func_basename "$file$stripped_ext"
3147238104Sdes		file="$func_basename_result"
3148238104Sdes	        outputname="$tmpdir/$file"
3149238104Sdes	        # Replace the output file specification.
3150238104Sdes	        relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
3151238104Sdes
3152238104Sdes	        $opt_silent || {
3153238104Sdes	          func_quote_for_expand "$relink_command"
3154238104Sdes		  eval "func_echo $func_quote_for_expand_result"
3155238104Sdes	        }
3156238104Sdes	        if eval "$relink_command"; then :
3157238104Sdes	          else
3158238104Sdes		  func_error "error: relink \`$file' with the above command before installing it"
3159238104Sdes		  $opt_dry_run || ${RM}r "$tmpdir"
3160238104Sdes		  continue
3161238104Sdes	        fi
3162238104Sdes	        file="$outputname"
3163238104Sdes	      else
3164238104Sdes	        func_warning "cannot relink \`$file'"
3165238104Sdes	      fi
3166238104Sdes	    }
3167238104Sdes	  else
3168238104Sdes	    # Install the binary that we compiled earlier.
3169238104Sdes	    file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
3170238104Sdes	  fi
3171238104Sdes	fi
3172238104Sdes
3173238104Sdes	# remove .exe since cygwin /usr/bin/install will append another
3174238104Sdes	# one anyway
3175238104Sdes	case $install_prog,$host in
3176238104Sdes	*/usr/bin/install*,*cygwin*)
3177238104Sdes	  case $file:$destfile in
3178238104Sdes	  *.exe:*.exe)
3179238104Sdes	    # this is ok
3180238104Sdes	    ;;
3181238104Sdes	  *.exe:*)
3182238104Sdes	    destfile=$destfile.exe
3183238104Sdes	    ;;
3184238104Sdes	  *:*.exe)
3185238104Sdes	    func_stripname '' '.exe' "$destfile"
3186238104Sdes	    destfile=$func_stripname_result
3187238104Sdes	    ;;
3188238104Sdes	  esac
3189238104Sdes	  ;;
3190238104Sdes	esac
3191238104Sdes	func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
3192238104Sdes	$opt_dry_run || if test -n "$outputname"; then
3193238104Sdes	  ${RM}r "$tmpdir"
3194238104Sdes	fi
3195238104Sdes	;;
3196238104Sdes      esac
3197238104Sdes    done
3198238104Sdes
3199238104Sdes    for file in $staticlibs; do
3200238104Sdes      func_basename "$file"
3201238104Sdes      name="$func_basename_result"
3202238104Sdes
3203238104Sdes      # Set up the ranlib parameters.
3204238104Sdes      oldlib="$destdir/$name"
3205238104Sdes      func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
3206238104Sdes      tool_oldlib=$func_to_tool_file_result
3207238104Sdes
3208238104Sdes      func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
3209238104Sdes
3210238104Sdes      if test -n "$stripme" && test -n "$old_striplib"; then
3211238104Sdes	func_show_eval "$old_striplib $tool_oldlib" 'exit $?'
3212238104Sdes      fi
3213238104Sdes
3214238104Sdes      # Do each command in the postinstall commands.
3215238104Sdes      func_execute_cmds "$old_postinstall_cmds" 'exit $?'
3216238104Sdes    done
3217238104Sdes
3218238104Sdes    test -n "$future_libdirs" && \
3219238104Sdes      func_warning "remember to run \`$progname --finish$future_libdirs'"
3220238104Sdes
3221238104Sdes    if test -n "$current_libdirs"; then
3222238104Sdes      # Maybe just do a dry run.
3223238104Sdes      $opt_dry_run && current_libdirs=" -n$current_libdirs"
3224238104Sdes      exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
3225238104Sdes    else
3226238104Sdes      exit $EXIT_SUCCESS
3227238104Sdes    fi
3228238104Sdes}
3229238104Sdes
3230238104Sdestest "$opt_mode" = install && func_mode_install ${1+"$@"}
3231238104Sdes
3232238104Sdes
3233238104Sdes# func_generate_dlsyms outputname originator pic_p
3234238104Sdes# Extract symbols from dlprefiles and create ${outputname}S.o with
3235238104Sdes# a dlpreopen symbol table.
3236238104Sdesfunc_generate_dlsyms ()
3237238104Sdes{
3238238104Sdes    $opt_debug
3239238104Sdes    my_outputname="$1"
3240238104Sdes    my_originator="$2"
3241238104Sdes    my_pic_p="${3-no}"
3242238104Sdes    my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'`
3243238104Sdes    my_dlsyms=
3244238104Sdes
3245238104Sdes    if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
3246238104Sdes      if test -n "$NM" && test -n "$global_symbol_pipe"; then
3247238104Sdes	my_dlsyms="${my_outputname}S.c"
3248238104Sdes      else
3249238104Sdes	func_error "not configured to extract global symbols from dlpreopened files"
3250238104Sdes      fi
3251238104Sdes    fi
3252238104Sdes
3253238104Sdes    if test -n "$my_dlsyms"; then
3254238104Sdes      case $my_dlsyms in
3255238104Sdes      "") ;;
3256238104Sdes      *.c)
3257238104Sdes	# Discover the nlist of each of the dlfiles.
3258238104Sdes	nlist="$output_objdir/${my_outputname}.nm"
3259238104Sdes
3260238104Sdes	func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
3261238104Sdes
3262238104Sdes	# Parse the name list into a source file.
3263238104Sdes	func_verbose "creating $output_objdir/$my_dlsyms"
3264238104Sdes
3265238104Sdes	$opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
3266238104Sdes/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */
3267238104Sdes/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */
3268238104Sdes
3269238104Sdes#ifdef __cplusplus
3270238104Sdesextern \"C\" {
3271238104Sdes#endif
3272238104Sdes
3273238104Sdes#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
3274238104Sdes#pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
3275238104Sdes#endif
3276238104Sdes
3277238104Sdes/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
3278238104Sdes#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
3279238104Sdes/* DATA imports from DLLs on WIN32 con't be const, because runtime
3280238104Sdes   relocations are performed -- see ld's documentation on pseudo-relocs.  */
3281238104Sdes# define LT_DLSYM_CONST
3282238104Sdes#elif defined(__osf__)
3283238104Sdes/* This system does not cope well with relocations in const data.  */
3284238104Sdes# define LT_DLSYM_CONST
3285238104Sdes#else
3286238104Sdes# define LT_DLSYM_CONST const
3287238104Sdes#endif
3288238104Sdes
3289238104Sdes/* External symbol declarations for the compiler. */\
3290238104Sdes"
3291238104Sdes
3292238104Sdes	if test "$dlself" = yes; then
3293238104Sdes	  func_verbose "generating symbol list for \`$output'"
3294238104Sdes
3295238104Sdes	  $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
3296238104Sdes
3297238104Sdes	  # Add our own program objects to the symbol list.
3298238104Sdes	  progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
3299238104Sdes	  for progfile in $progfiles; do
3300238104Sdes	    func_to_tool_file "$progfile" func_convert_file_msys_to_w32
3301238104Sdes	    func_verbose "extracting global C symbols from \`$func_to_tool_file_result'"
3302238104Sdes	    $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
3303238104Sdes	  done
3304238104Sdes
3305238104Sdes	  if test -n "$exclude_expsyms"; then
3306238104Sdes	    $opt_dry_run || {
3307238104Sdes	      eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
3308238104Sdes	      eval '$MV "$nlist"T "$nlist"'
3309238104Sdes	    }
3310238104Sdes	  fi
3311238104Sdes
3312238104Sdes	  if test -n "$export_symbols_regex"; then
3313238104Sdes	    $opt_dry_run || {
3314238104Sdes	      eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
3315238104Sdes	      eval '$MV "$nlist"T "$nlist"'
3316238104Sdes	    }
3317238104Sdes	  fi
3318238104Sdes
3319238104Sdes	  # Prepare the list of exported symbols
3320238104Sdes	  if test -z "$export_symbols"; then
3321238104Sdes	    export_symbols="$output_objdir/$outputname.exp"
3322238104Sdes	    $opt_dry_run || {
3323238104Sdes	      $RM $export_symbols
3324238104Sdes	      eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
3325238104Sdes	      case $host in
3326238104Sdes	      *cygwin* | *mingw* | *cegcc* )
3327238104Sdes                eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
3328238104Sdes                eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
3329238104Sdes	        ;;
3330238104Sdes	      esac
3331238104Sdes	    }
3332238104Sdes	  else
3333238104Sdes	    $opt_dry_run || {
3334238104Sdes	      eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
3335238104Sdes	      eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
3336238104Sdes	      eval '$MV "$nlist"T "$nlist"'
3337238104Sdes	      case $host in
3338238104Sdes	        *cygwin* | *mingw* | *cegcc* )
3339238104Sdes	          eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
3340238104Sdes	          eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
3341238104Sdes	          ;;
3342238104Sdes	      esac
3343238104Sdes	    }
3344238104Sdes	  fi
3345238104Sdes	fi
3346238104Sdes
3347238104Sdes	for dlprefile in $dlprefiles; do
3348238104Sdes	  func_verbose "extracting global C symbols from \`$dlprefile'"
3349238104Sdes	  func_basename "$dlprefile"
3350238104Sdes	  name="$func_basename_result"
3351238104Sdes          case $host in
3352238104Sdes	    *cygwin* | *mingw* | *cegcc* )
3353238104Sdes	      # if an import library, we need to obtain dlname
3354238104Sdes	      if func_win32_import_lib_p "$dlprefile"; then
3355238104Sdes	        func_tr_sh "$dlprefile"
3356238104Sdes	        eval "curr_lafile=\$libfile_$func_tr_sh_result"
3357238104Sdes	        dlprefile_dlbasename=""
3358238104Sdes	        if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
3359238104Sdes	          # Use subshell, to avoid clobbering current variable values
3360238104Sdes	          dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
3361238104Sdes	          if test -n "$dlprefile_dlname" ; then
3362238104Sdes	            func_basename "$dlprefile_dlname"
3363238104Sdes	            dlprefile_dlbasename="$func_basename_result"
3364238104Sdes	          else
3365238104Sdes	            # no lafile. user explicitly requested -dlpreopen <import library>.
3366238104Sdes	            $sharedlib_from_linklib_cmd "$dlprefile"
3367238104Sdes	            dlprefile_dlbasename=$sharedlib_from_linklib_result
3368238104Sdes	          fi
3369238104Sdes	        fi
3370238104Sdes	        $opt_dry_run || {
3371238104Sdes	          if test -n "$dlprefile_dlbasename" ; then
3372238104Sdes	            eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
3373238104Sdes	          else
3374238104Sdes	            func_warning "Could not compute DLL name from $name"
3375238104Sdes	            eval '$ECHO ": $name " >> "$nlist"'
3376238104Sdes	          fi
3377238104Sdes	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
3378238104Sdes	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe |
3379238104Sdes	            $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'"
3380238104Sdes	        }
3381238104Sdes	      else # not an import lib
3382238104Sdes	        $opt_dry_run || {
3383238104Sdes	          eval '$ECHO ": $name " >> "$nlist"'
3384238104Sdes	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
3385238104Sdes	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
3386238104Sdes	        }
3387238104Sdes	      fi
3388238104Sdes	    ;;
3389238104Sdes	    *)
3390238104Sdes	      $opt_dry_run || {
3391238104Sdes	        eval '$ECHO ": $name " >> "$nlist"'
3392238104Sdes	        func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
3393238104Sdes	        eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
3394238104Sdes	      }
3395238104Sdes	    ;;
3396238104Sdes          esac
3397238104Sdes	done
3398238104Sdes
3399238104Sdes	$opt_dry_run || {
3400238104Sdes	  # Make sure we have at least an empty file.
3401238104Sdes	  test -f "$nlist" || : > "$nlist"
3402238104Sdes
3403238104Sdes	  if test -n "$exclude_expsyms"; then
3404238104Sdes	    $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
3405238104Sdes	    $MV "$nlist"T "$nlist"
3406238104Sdes	  fi
3407238104Sdes
3408238104Sdes	  # Try sorting and uniquifying the output.
3409238104Sdes	  if $GREP -v "^: " < "$nlist" |
3410238104Sdes	      if sort -k 3 </dev/null >/dev/null 2>&1; then
3411238104Sdes		sort -k 3
3412238104Sdes	      else
3413238104Sdes		sort +2
3414238104Sdes	      fi |
3415238104Sdes	      uniq > "$nlist"S; then
3416238104Sdes	    :
3417238104Sdes	  else
3418238104Sdes	    $GREP -v "^: " < "$nlist" > "$nlist"S
3419238104Sdes	  fi
3420238104Sdes
3421238104Sdes	  if test -f "$nlist"S; then
3422238104Sdes	    eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
3423238104Sdes	  else
3424238104Sdes	    echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
3425238104Sdes	  fi
3426238104Sdes
3427238104Sdes	  echo >> "$output_objdir/$my_dlsyms" "\
3428238104Sdes
3429238104Sdes/* The mapping between symbol names and symbols.  */
3430238104Sdestypedef struct {
3431238104Sdes  const char *name;
3432238104Sdes  void *address;
3433238104Sdes} lt_dlsymlist;
3434238104Sdesextern LT_DLSYM_CONST lt_dlsymlist
3435238104Sdeslt_${my_prefix}_LTX_preloaded_symbols[];
3436238104SdesLT_DLSYM_CONST lt_dlsymlist
3437238104Sdeslt_${my_prefix}_LTX_preloaded_symbols[] =
3438238104Sdes{\
3439238104Sdes  { \"$my_originator\", (void *) 0 },"
3440238104Sdes
3441238104Sdes	  case $need_lib_prefix in
3442238104Sdes	  no)
3443238104Sdes	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
3444238104Sdes	    ;;
3445238104Sdes	  *)
3446238104Sdes	    eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
3447238104Sdes	    ;;
3448238104Sdes	  esac
3449238104Sdes	  echo >> "$output_objdir/$my_dlsyms" "\
3450238104Sdes  {0, (void *) 0}
3451238104Sdes};
3452238104Sdes
3453238104Sdes/* This works around a problem in FreeBSD linker */
3454238104Sdes#ifdef FREEBSD_WORKAROUND
3455238104Sdesstatic const void *lt_preloaded_setup() {
3456238104Sdes  return lt_${my_prefix}_LTX_preloaded_symbols;
3457238104Sdes}
3458238104Sdes#endif
3459238104Sdes
3460238104Sdes#ifdef __cplusplus
3461238104Sdes}
3462238104Sdes#endif\
3463238104Sdes"
3464238104Sdes	} # !$opt_dry_run
3465238104Sdes
3466238104Sdes	pic_flag_for_symtable=
3467238104Sdes	case "$compile_command " in
3468238104Sdes	*" -static "*) ;;
3469238104Sdes	*)
3470238104Sdes	  case $host in
3471238104Sdes	  # compiling the symbol table file with pic_flag works around
3472238104Sdes	  # a FreeBSD bug that causes programs to crash when -lm is
3473238104Sdes	  # linked before any other PIC object.  But we must not use
3474238104Sdes	  # pic_flag when linking with -static.  The problem exists in
3475238104Sdes	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
3476238104Sdes	  *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
3477238104Sdes	    pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
3478238104Sdes	  *-*-hpux*)
3479238104Sdes	    pic_flag_for_symtable=" $pic_flag"  ;;
3480238104Sdes	  *)
3481238104Sdes	    if test "X$my_pic_p" != Xno; then
3482238104Sdes	      pic_flag_for_symtable=" $pic_flag"
3483238104Sdes	    fi
3484238104Sdes	    ;;
3485238104Sdes	  esac
3486238104Sdes	  ;;
3487238104Sdes	esac
3488238104Sdes	symtab_cflags=
3489238104Sdes	for arg in $LTCFLAGS; do
3490238104Sdes	  case $arg in
3491238104Sdes	  -pie | -fpie | -fPIE) ;;
3492238104Sdes	  *) func_append symtab_cflags " $arg" ;;
3493238104Sdes	  esac
3494238104Sdes	done
3495238104Sdes
3496238104Sdes	# Now compile the dynamic symbol file.
3497238104Sdes	func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
3498238104Sdes
3499238104Sdes	# Clean up the generated files.
3500238104Sdes	func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"'
3501238104Sdes
3502238104Sdes	# Transform the symbol file into the correct name.
3503238104Sdes	symfileobj="$output_objdir/${my_outputname}S.$objext"
3504238104Sdes	case $host in
3505238104Sdes	*cygwin* | *mingw* | *cegcc* )
3506238104Sdes	  if test -f "$output_objdir/$my_outputname.def"; then
3507238104Sdes	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
3508238104Sdes	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
3509238104Sdes	  else
3510238104Sdes	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3511238104Sdes	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3512238104Sdes	  fi
3513238104Sdes	  ;;
3514238104Sdes	*)
3515238104Sdes	  compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3516238104Sdes	  finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3517238104Sdes	  ;;
3518238104Sdes	esac
3519238104Sdes	;;
3520238104Sdes      *)
3521238104Sdes	func_fatal_error "unknown suffix for \`$my_dlsyms'"
3522238104Sdes	;;
3523238104Sdes      esac
3524238104Sdes    else
3525238104Sdes      # We keep going just in case the user didn't refer to
3526238104Sdes      # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
3527238104Sdes      # really was required.
3528238104Sdes
3529238104Sdes      # Nullify the symbol file.
3530238104Sdes      compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
3531238104Sdes      finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
3532238104Sdes    fi
3533238104Sdes}
3534238104Sdes
3535238104Sdes# func_win32_libid arg
3536238104Sdes# return the library type of file 'arg'
3537238104Sdes#
3538238104Sdes# Need a lot of goo to handle *both* DLLs and import libs
3539238104Sdes# Has to be a shell function in order to 'eat' the argument
3540238104Sdes# that is supplied when $file_magic_command is called.
3541238104Sdes# Despite the name, also deal with 64 bit binaries.
3542238104Sdesfunc_win32_libid ()
3543238104Sdes{
3544238104Sdes  $opt_debug
3545238104Sdes  win32_libid_type="unknown"
3546238104Sdes  win32_fileres=`file -L $1 2>/dev/null`
3547238104Sdes  case $win32_fileres in
3548238104Sdes  *ar\ archive\ import\ library*) # definitely import
3549238104Sdes    win32_libid_type="x86 archive import"
3550238104Sdes    ;;
3551238104Sdes  *ar\ archive*) # could be an import, or static
3552238104Sdes    # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
3553238104Sdes    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
3554238104Sdes       $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
3555238104Sdes      func_to_tool_file "$1" func_convert_file_msys_to_w32
3556238104Sdes      win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
3557238104Sdes	$SED -n -e '
3558238104Sdes	    1,100{
3559238104Sdes		/ I /{
3560238104Sdes		    s,.*,import,
3561238104Sdes		    p
3562238104Sdes		    q
3563238104Sdes		}
3564238104Sdes	    }'`
3565238104Sdes      case $win32_nmres in
3566238104Sdes      import*)  win32_libid_type="x86 archive import";;
3567238104Sdes      *)        win32_libid_type="x86 archive static";;
3568238104Sdes      esac
3569238104Sdes    fi
3570238104Sdes    ;;
3571238104Sdes  *DLL*)
3572238104Sdes    win32_libid_type="x86 DLL"
3573238104Sdes    ;;
3574238104Sdes  *executable*) # but shell scripts are "executable" too...
3575238104Sdes    case $win32_fileres in
3576238104Sdes    *MS\ Windows\ PE\ Intel*)
3577238104Sdes      win32_libid_type="x86 DLL"
3578238104Sdes      ;;
3579238104Sdes    esac
3580238104Sdes    ;;
3581238104Sdes  esac
3582238104Sdes  $ECHO "$win32_libid_type"
3583238104Sdes}
3584238104Sdes
3585238104Sdes# func_cygming_dll_for_implib ARG
3586238104Sdes#
3587238104Sdes# Platform-specific function to extract the
3588238104Sdes# name of the DLL associated with the specified
3589238104Sdes# import library ARG.
3590238104Sdes# Invoked by eval'ing the libtool variable
3591238104Sdes#    $sharedlib_from_linklib_cmd
3592238104Sdes# Result is available in the variable
3593238104Sdes#    $sharedlib_from_linklib_result
3594238104Sdesfunc_cygming_dll_for_implib ()
3595238104Sdes{
3596238104Sdes  $opt_debug
3597238104Sdes  sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
3598238104Sdes}
3599238104Sdes
3600238104Sdes# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs
3601238104Sdes#
3602238104Sdes# The is the core of a fallback implementation of a
3603238104Sdes# platform-specific function to extract the name of the
3604238104Sdes# DLL associated with the specified import library LIBNAME.
3605238104Sdes#
3606238104Sdes# SECTION_NAME is either .idata$6 or .idata$7, depending
3607238104Sdes# on the platform and compiler that created the implib.
3608238104Sdes#
3609238104Sdes# Echos the name of the DLL associated with the
3610238104Sdes# specified import library.
3611238104Sdesfunc_cygming_dll_for_implib_fallback_core ()
3612238104Sdes{
3613238104Sdes  $opt_debug
3614238104Sdes  match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
3615238104Sdes  $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
3616238104Sdes    $SED '/^Contents of section '"$match_literal"':/{
3617238104Sdes      # Place marker at beginning of archive member dllname section
3618238104Sdes      s/.*/====MARK====/
3619238104Sdes      p
3620238104Sdes      d
3621238104Sdes    }
3622238104Sdes    # These lines can sometimes be longer than 43 characters, but
3623238104Sdes    # are always uninteresting
3624238104Sdes    /:[	 ]*file format pe[i]\{,1\}-/d
3625238104Sdes    /^In archive [^:]*:/d
3626238104Sdes    # Ensure marker is printed
3627238104Sdes    /^====MARK====/p
3628238104Sdes    # Remove all lines with less than 43 characters
3629238104Sdes    /^.\{43\}/!d
3630238104Sdes    # From remaining lines, remove first 43 characters
3631238104Sdes    s/^.\{43\}//' |
3632238104Sdes    $SED -n '
3633238104Sdes      # Join marker and all lines until next marker into a single line
3634238104Sdes      /^====MARK====/ b para
3635238104Sdes      H
3636238104Sdes      $ b para
3637238104Sdes      b
3638238104Sdes      :para
3639238104Sdes      x
3640238104Sdes      s/\n//g
3641238104Sdes      # Remove the marker
3642238104Sdes      s/^====MARK====//
3643238104Sdes      # Remove trailing dots and whitespace
3644238104Sdes      s/[\. \t]*$//
3645238104Sdes      # Print
3646238104Sdes      /./p' |
3647238104Sdes    # we now have a list, one entry per line, of the stringified
3648238104Sdes    # contents of the appropriate section of all members of the
3649238104Sdes    # archive which possess that section. Heuristic: eliminate
3650238104Sdes    # all those which have a first or second character that is
3651238104Sdes    # a '.' (that is, objdump's representation of an unprintable
3652238104Sdes    # character.) This should work for all archives with less than
3653238104Sdes    # 0x302f exports -- but will fail for DLLs whose name actually
3654238104Sdes    # begins with a literal '.' or a single character followed by
3655238104Sdes    # a '.'.
3656238104Sdes    #
3657238104Sdes    # Of those that remain, print the first one.
3658238104Sdes    $SED -e '/^\./d;/^.\./d;q'
3659238104Sdes}
3660238104Sdes
3661238104Sdes# func_cygming_gnu_implib_p ARG
3662238104Sdes# This predicate returns with zero status (TRUE) if
3663238104Sdes# ARG is a GNU/binutils-style import library. Returns
3664238104Sdes# with nonzero status (FALSE) otherwise.
3665238104Sdesfunc_cygming_gnu_implib_p ()
3666238104Sdes{
3667238104Sdes  $opt_debug
3668238104Sdes  func_to_tool_file "$1" func_convert_file_msys_to_w32
3669238104Sdes  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)$'`
3670238104Sdes  test -n "$func_cygming_gnu_implib_tmp"
3671238104Sdes}
3672238104Sdes
3673238104Sdes# func_cygming_ms_implib_p ARG
3674238104Sdes# This predicate returns with zero status (TRUE) if
3675238104Sdes# ARG is an MS-style import library. Returns
3676238104Sdes# with nonzero status (FALSE) otherwise.
3677238104Sdesfunc_cygming_ms_implib_p ()
3678238104Sdes{
3679238104Sdes  $opt_debug
3680238104Sdes  func_to_tool_file "$1" func_convert_file_msys_to_w32
3681238104Sdes  func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
3682238104Sdes  test -n "$func_cygming_ms_implib_tmp"
3683238104Sdes}
3684238104Sdes
3685238104Sdes# func_cygming_dll_for_implib_fallback ARG
3686238104Sdes# Platform-specific function to extract the
3687238104Sdes# name of the DLL associated with the specified
3688238104Sdes# import library ARG.
3689238104Sdes#
3690238104Sdes# This fallback implementation is for use when $DLLTOOL
3691238104Sdes# does not support the --identify-strict option.
3692238104Sdes# Invoked by eval'ing the libtool variable
3693238104Sdes#    $sharedlib_from_linklib_cmd
3694238104Sdes# Result is available in the variable
3695238104Sdes#    $sharedlib_from_linklib_result
3696238104Sdesfunc_cygming_dll_for_implib_fallback ()
3697238104Sdes{
3698238104Sdes  $opt_debug
3699238104Sdes  if func_cygming_gnu_implib_p "$1" ; then
3700238104Sdes    # binutils import library
3701238104Sdes    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
3702238104Sdes  elif func_cygming_ms_implib_p "$1" ; then
3703238104Sdes    # ms-generated import library
3704238104Sdes    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
3705238104Sdes  else
3706238104Sdes    # unknown
3707238104Sdes    sharedlib_from_linklib_result=""
3708238104Sdes  fi
3709238104Sdes}
3710238104Sdes
3711238104Sdes
3712238104Sdes# func_extract_an_archive dir oldlib
3713238104Sdesfunc_extract_an_archive ()
3714238104Sdes{
3715238104Sdes    $opt_debug
3716238104Sdes    f_ex_an_ar_dir="$1"; shift
3717238104Sdes    f_ex_an_ar_oldlib="$1"
3718238104Sdes    if test "$lock_old_archive_extraction" = yes; then
3719238104Sdes      lockfile=$f_ex_an_ar_oldlib.lock
3720238104Sdes      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
3721238104Sdes	func_echo "Waiting for $lockfile to be removed"
3722238104Sdes	sleep 2
3723238104Sdes      done
3724238104Sdes    fi
3725238104Sdes    func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
3726238104Sdes		   'stat=$?; rm -f "$lockfile"; exit $stat'
3727238104Sdes    if test "$lock_old_archive_extraction" = yes; then
3728238104Sdes      $opt_dry_run || rm -f "$lockfile"
3729238104Sdes    fi
3730238104Sdes    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
3731238104Sdes     :
3732238104Sdes    else
3733238104Sdes      func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
3734238104Sdes    fi
3735238104Sdes}
3736238104Sdes
3737238104Sdes
3738238104Sdes# func_extract_archives gentop oldlib ...
3739238104Sdesfunc_extract_archives ()
3740238104Sdes{
3741238104Sdes    $opt_debug
3742238104Sdes    my_gentop="$1"; shift
3743238104Sdes    my_oldlibs=${1+"$@"}
3744238104Sdes    my_oldobjs=""
3745238104Sdes    my_xlib=""
3746238104Sdes    my_xabs=""
3747238104Sdes    my_xdir=""
3748238104Sdes
3749238104Sdes    for my_xlib in $my_oldlibs; do
3750238104Sdes      # Extract the objects.
3751238104Sdes      case $my_xlib in
3752238104Sdes	[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
3753238104Sdes	*) my_xabs=`pwd`"/$my_xlib" ;;
3754238104Sdes      esac
3755238104Sdes      func_basename "$my_xlib"
3756238104Sdes      my_xlib="$func_basename_result"
3757238104Sdes      my_xlib_u=$my_xlib
3758238104Sdes      while :; do
3759238104Sdes        case " $extracted_archives " in
3760238104Sdes	*" $my_xlib_u "*)
3761238104Sdes	  func_arith $extracted_serial + 1
3762238104Sdes	  extracted_serial=$func_arith_result
3763238104Sdes	  my_xlib_u=lt$extracted_serial-$my_xlib ;;
3764238104Sdes	*) break ;;
3765238104Sdes	esac
3766238104Sdes      done
3767238104Sdes      extracted_archives="$extracted_archives $my_xlib_u"
3768238104Sdes      my_xdir="$my_gentop/$my_xlib_u"
3769238104Sdes
3770238104Sdes      func_mkdir_p "$my_xdir"
3771238104Sdes
3772238104Sdes      case $host in
3773238104Sdes      *-darwin*)
3774238104Sdes	func_verbose "Extracting $my_xabs"
3775238104Sdes	# Do not bother doing anything if just a dry run
3776238104Sdes	$opt_dry_run || {
3777238104Sdes	  darwin_orig_dir=`pwd`
3778238104Sdes	  cd $my_xdir || exit $?
3779238104Sdes	  darwin_archive=$my_xabs
3780238104Sdes	  darwin_curdir=`pwd`
3781238104Sdes	  darwin_base_archive=`basename "$darwin_archive"`
3782238104Sdes	  darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
3783238104Sdes	  if test -n "$darwin_arches"; then
3784238104Sdes	    darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
3785238104Sdes	    darwin_arch=
3786238104Sdes	    func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
3787238104Sdes	    for darwin_arch in  $darwin_arches ; do
3788238104Sdes	      func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
3789238104Sdes	      $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
3790238104Sdes	      cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
3791238104Sdes	      func_extract_an_archive "`pwd`" "${darwin_base_archive}"
3792238104Sdes	      cd "$darwin_curdir"
3793238104Sdes	      $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
3794238104Sdes	    done # $darwin_arches
3795238104Sdes            ## Okay now we've a bunch of thin objects, gotta fatten them up :)
3796238104Sdes	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u`
3797238104Sdes	    darwin_file=
3798238104Sdes	    darwin_files=
3799238104Sdes	    for darwin_file in $darwin_filelist; do
3800238104Sdes	      darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`
3801238104Sdes	      $LIPO -create -output "$darwin_file" $darwin_files
3802238104Sdes	    done # $darwin_filelist
3803238104Sdes	    $RM -rf unfat-$$
3804238104Sdes	    cd "$darwin_orig_dir"
3805238104Sdes	  else
3806238104Sdes	    cd $darwin_orig_dir
3807238104Sdes	    func_extract_an_archive "$my_xdir" "$my_xabs"
3808238104Sdes	  fi # $darwin_arches
3809238104Sdes	} # !$opt_dry_run
3810238104Sdes	;;
3811238104Sdes      *)
3812238104Sdes        func_extract_an_archive "$my_xdir" "$my_xabs"
3813238104Sdes	;;
3814238104Sdes      esac
3815238104Sdes      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
3816238104Sdes    done
3817238104Sdes
3818238104Sdes    func_extract_archives_result="$my_oldobjs"
3819238104Sdes}
3820238104Sdes
3821238104Sdes
3822238104Sdes# func_emit_wrapper [arg=no]
3823238104Sdes#
3824238104Sdes# Emit a libtool wrapper script on stdout.
3825238104Sdes# Don't directly open a file because we may want to
3826238104Sdes# incorporate the script contents within a cygwin/mingw
3827238104Sdes# wrapper executable.  Must ONLY be called from within
3828238104Sdes# func_mode_link because it depends on a number of variables
3829238104Sdes# set therein.
3830238104Sdes#
3831238104Sdes# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
3832238104Sdes# variable will take.  If 'yes', then the emitted script
3833238104Sdes# will assume that the directory in which it is stored is
3834238104Sdes# the $objdir directory.  This is a cygwin/mingw-specific
3835238104Sdes# behavior.
3836238104Sdesfunc_emit_wrapper ()
3837238104Sdes{
3838238104Sdes	func_emit_wrapper_arg1=${1-no}
3839238104Sdes
3840238104Sdes	$ECHO "\
3841238104Sdes#! $SHELL
3842238104Sdes
3843238104Sdes# $output - temporary wrapper script for $objdir/$outputname
3844238104Sdes# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
3845238104Sdes#
3846238104Sdes# The $output program cannot be directly executed until all the libtool
3847238104Sdes# libraries that it depends on are installed.
3848238104Sdes#
3849238104Sdes# This wrapper script should never be moved out of the build directory.
3850238104Sdes# If it is, it will not operate correctly.
3851238104Sdes
3852238104Sdes# Sed substitution that helps us do robust quoting.  It backslashifies
3853238104Sdes# metacharacters that are still active within double-quoted strings.
3854238104Sdessed_quote_subst='$sed_quote_subst'
3855238104Sdes
3856238104Sdes# Be Bourne compatible
3857238104Sdesif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
3858238104Sdes  emulate sh
3859238104Sdes  NULLCMD=:
3860238104Sdes  # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
3861238104Sdes  # is contrary to our usage.  Disable this feature.
3862238104Sdes  alias -g '\${1+\"\$@\"}'='\"\$@\"'
3863238104Sdes  setopt NO_GLOB_SUBST
3864238104Sdeselse
3865238104Sdes  case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
3866238104Sdesfi
3867238104SdesBIN_SH=xpg4; export BIN_SH # for Tru64
3868238104SdesDUALCASE=1; export DUALCASE # for MKS sh
3869238104Sdes
3870238104Sdes# The HP-UX ksh and POSIX shell print the target directory to stdout
3871238104Sdes# if CDPATH is set.
3872238104Sdes(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
3873238104Sdes
3874238104Sdesrelink_command=\"$relink_command\"
3875238104Sdes
3876238104Sdes# This environment variable determines our operation mode.
3877238104Sdesif test \"\$libtool_install_magic\" = \"$magic\"; then
3878238104Sdes  # install mode needs the following variables:
3879238104Sdes  generated_by_libtool_version='$macro_version'
3880238104Sdes  notinst_deplibs='$notinst_deplibs'
3881238104Sdeselse
3882238104Sdes  # When we are sourced in execute mode, \$file and \$ECHO are already set.
3883238104Sdes  if test \"\$libtool_execute_magic\" != \"$magic\"; then
3884238104Sdes    file=\"\$0\""
3885238104Sdes
3886238104Sdes    qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"`
3887238104Sdes    $ECHO "\
3888238104Sdes
3889238104Sdes# A function that is used when there is no print builtin or printf.
3890238104Sdesfunc_fallback_echo ()
3891238104Sdes{
3892238104Sdes  eval 'cat <<_LTECHO_EOF
3893238104Sdes\$1
3894238104Sdes_LTECHO_EOF'
3895238104Sdes}
3896238104Sdes    ECHO=\"$qECHO\"
3897238104Sdes  fi
3898238104Sdes
3899238104Sdes# Very basic option parsing. These options are (a) specific to
3900238104Sdes# the libtool wrapper, (b) are identical between the wrapper
3901238104Sdes# /script/ and the wrapper /executable/ which is used only on
3902238104Sdes# windows platforms, and (c) all begin with the string "--lt-"
3903238104Sdes# (application programs are unlikely to have options which match
3904238104Sdes# this pattern).
3905238104Sdes#
3906238104Sdes# There are only two supported options: --lt-debug and
3907238104Sdes# --lt-dump-script. There is, deliberately, no --lt-help.
3908238104Sdes#
3909238104Sdes# The first argument to this parsing function should be the
3910238104Sdes# script's $0 value, followed by "$@".
3911238104Sdeslt_option_debug=
3912238104Sdesfunc_parse_lt_options ()
3913238104Sdes{
3914238104Sdes  lt_script_arg0=\$0
3915238104Sdes  shift
3916238104Sdes  for lt_opt
3917238104Sdes  do
3918238104Sdes    case \"\$lt_opt\" in
3919238104Sdes    --lt-debug) lt_option_debug=1 ;;
3920238104Sdes    --lt-dump-script)
3921238104Sdes        lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
3922238104Sdes        test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
3923238104Sdes        lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
3924238104Sdes        cat \"\$lt_dump_D/\$lt_dump_F\"
3925238104Sdes        exit 0
3926238104Sdes      ;;
3927238104Sdes    --lt-*)
3928238104Sdes        \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
3929238104Sdes        exit 1
3930238104Sdes      ;;
3931238104Sdes    esac
3932238104Sdes  done
3933238104Sdes
3934238104Sdes  # Print the debug banner immediately:
3935238104Sdes  if test -n \"\$lt_option_debug\"; then
3936238104Sdes    echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2
3937238104Sdes  fi
3938238104Sdes}
3939238104Sdes
3940238104Sdes# Used when --lt-debug. Prints its arguments to stdout
3941238104Sdes# (redirection is the responsibility of the caller)
3942238104Sdesfunc_lt_dump_args ()
3943238104Sdes{
3944238104Sdes  lt_dump_args_N=1;
3945238104Sdes  for lt_arg
3946238104Sdes  do
3947238104Sdes    \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\"
3948238104Sdes    lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
3949238104Sdes  done
3950238104Sdes}
3951238104Sdes
3952238104Sdes# Core function for launching the target application
3953238104Sdesfunc_exec_program_core ()
3954238104Sdes{
3955238104Sdes"
3956238104Sdes  case $host in
3957238104Sdes  # Backslashes separate directories on plain windows
3958238104Sdes  *-*-mingw | *-*-os2* | *-cegcc*)
3959238104Sdes    $ECHO "\
3960238104Sdes      if test -n \"\$lt_option_debug\"; then
3961238104Sdes        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2
3962238104Sdes        func_lt_dump_args \${1+\"\$@\"} 1>&2
3963238104Sdes      fi
3964238104Sdes      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
3965238104Sdes"
3966238104Sdes    ;;
3967238104Sdes
3968238104Sdes  *)
3969238104Sdes    $ECHO "\
3970238104Sdes      if test -n \"\$lt_option_debug\"; then
3971238104Sdes        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2
3972238104Sdes        func_lt_dump_args \${1+\"\$@\"} 1>&2
3973238104Sdes      fi
3974238104Sdes      exec \"\$progdir/\$program\" \${1+\"\$@\"}
3975238104Sdes"
3976238104Sdes    ;;
3977238104Sdes  esac
3978238104Sdes  $ECHO "\
3979238104Sdes      \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
3980238104Sdes      exit 1
3981238104Sdes}
3982238104Sdes
3983238104Sdes# A function to encapsulate launching the target application
3984238104Sdes# Strips options in the --lt-* namespace from \$@ and
3985238104Sdes# launches target application with the remaining arguments.
3986238104Sdesfunc_exec_program ()
3987238104Sdes{
3988238104Sdes  case \" \$* \" in
3989238104Sdes  *\\ --lt-*)
3990238104Sdes    for lt_wr_arg
3991238104Sdes    do
3992238104Sdes      case \$lt_wr_arg in
3993238104Sdes      --lt-*) ;;
3994238104Sdes      *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
3995238104Sdes      esac
3996238104Sdes      shift
3997238104Sdes    done ;;
3998238104Sdes  esac
3999238104Sdes  func_exec_program_core \${1+\"\$@\"}
4000238104Sdes}
4001238104Sdes
4002238104Sdes  # Parse options
4003238104Sdes  func_parse_lt_options \"\$0\" \${1+\"\$@\"}
4004238104Sdes
4005238104Sdes  # Find the directory that this script lives in.
4006238104Sdes  thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
4007238104Sdes  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
4008238104Sdes
4009238104Sdes  # Follow symbolic links until we get to the real thisdir.
4010238104Sdes  file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
4011238104Sdes  while test -n \"\$file\"; do
4012238104Sdes    destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
4013238104Sdes
4014238104Sdes    # If there was a directory component, then change thisdir.
4015238104Sdes    if test \"x\$destdir\" != \"x\$file\"; then
4016238104Sdes      case \"\$destdir\" in
4017238104Sdes      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
4018238104Sdes      *) thisdir=\"\$thisdir/\$destdir\" ;;
4019238104Sdes      esac
4020238104Sdes    fi
4021238104Sdes
4022238104Sdes    file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
4023238104Sdes    file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
4024238104Sdes  done
4025238104Sdes
4026238104Sdes  # Usually 'no', except on cygwin/mingw when embedded into
4027238104Sdes  # the cwrapper.
4028238104Sdes  WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
4029238104Sdes  if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
4030238104Sdes    # special case for '.'
4031238104Sdes    if test \"\$thisdir\" = \".\"; then
4032238104Sdes      thisdir=\`pwd\`
4033238104Sdes    fi
4034238104Sdes    # remove .libs from thisdir
4035238104Sdes    case \"\$thisdir\" in
4036238104Sdes    *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
4037238104Sdes    $objdir )   thisdir=. ;;
4038238104Sdes    esac
4039238104Sdes  fi
4040238104Sdes
4041238104Sdes  # Try to get the absolute directory name.
4042238104Sdes  absdir=\`cd \"\$thisdir\" && pwd\`
4043238104Sdes  test -n \"\$absdir\" && thisdir=\"\$absdir\"
4044238104Sdes"
4045238104Sdes
4046238104Sdes	if test "$fast_install" = yes; then
4047238104Sdes	  $ECHO "\
4048238104Sdes  program=lt-'$outputname'$exeext
4049238104Sdes  progdir=\"\$thisdir/$objdir\"
4050238104Sdes
4051238104Sdes  if test ! -f \"\$progdir/\$program\" ||
4052238104Sdes     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
4053238104Sdes       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
4054238104Sdes
4055238104Sdes    file=\"\$\$-\$program\"
4056238104Sdes
4057238104Sdes    if test ! -d \"\$progdir\"; then
4058238104Sdes      $MKDIR \"\$progdir\"
4059238104Sdes    else
4060238104Sdes      $RM \"\$progdir/\$file\"
4061238104Sdes    fi"
4062238104Sdes
4063238104Sdes	  $ECHO "\
4064238104Sdes
4065238104Sdes    # relink executable if necessary
4066238104Sdes    if test -n \"\$relink_command\"; then
4067238104Sdes      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
4068238104Sdes      else
4069238104Sdes	$ECHO \"\$relink_command_output\" >&2
4070238104Sdes	$RM \"\$progdir/\$file\"
4071238104Sdes	exit 1
4072238104Sdes      fi
4073238104Sdes    fi
4074238104Sdes
4075238104Sdes    $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
4076238104Sdes    { $RM \"\$progdir/\$program\";
4077238104Sdes      $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
4078238104Sdes    $RM \"\$progdir/\$file\"
4079238104Sdes  fi"
4080238104Sdes	else
4081238104Sdes	  $ECHO "\
4082238104Sdes  program='$outputname'
4083238104Sdes  progdir=\"\$thisdir/$objdir\"
4084238104Sdes"
4085238104Sdes	fi
4086238104Sdes
4087238104Sdes	$ECHO "\
4088238104Sdes
4089238104Sdes  if test -f \"\$progdir/\$program\"; then"
4090238104Sdes
4091238104Sdes	# fixup the dll searchpath if we need to.
4092238104Sdes	#
4093238104Sdes	# Fix the DLL searchpath if we need to.  Do this before prepending
4094238104Sdes	# to shlibpath, because on Windows, both are PATH and uninstalled
4095238104Sdes	# libraries must come first.
4096238104Sdes	if test -n "$dllsearchpath"; then
4097238104Sdes	  $ECHO "\
4098238104Sdes    # Add the dll search path components to the executable PATH
4099238104Sdes    PATH=$dllsearchpath:\$PATH
4100238104Sdes"
4101238104Sdes	fi
4102238104Sdes
4103238104Sdes	# Export our shlibpath_var if we have one.
4104238104Sdes	if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
4105238104Sdes	  $ECHO "\
4106238104Sdes    # Add our own library path to $shlibpath_var
4107238104Sdes    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
4108238104Sdes
4109238104Sdes    # Some systems cannot cope with colon-terminated $shlibpath_var
4110238104Sdes    # The second colon is a workaround for a bug in BeOS R4 sed
4111238104Sdes    $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
4112238104Sdes
4113238104Sdes    export $shlibpath_var
4114238104Sdes"
4115238104Sdes	fi
4116238104Sdes
4117238104Sdes	$ECHO "\
4118238104Sdes    if test \"\$libtool_execute_magic\" != \"$magic\"; then
4119238104Sdes      # Run the actual program with our arguments.
4120238104Sdes      func_exec_program \${1+\"\$@\"}
4121238104Sdes    fi
4122238104Sdes  else
4123238104Sdes    # The program doesn't exist.
4124238104Sdes    \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
4125238104Sdes    \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
4126238104Sdes    \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
4127238104Sdes    exit 1
4128238104Sdes  fi
4129238104Sdesfi\
4130238104Sdes"
4131238104Sdes}
4132238104Sdes
4133238104Sdes
4134238104Sdes# func_emit_cwrapperexe_src
4135238104Sdes# emit the source code for a wrapper executable on stdout
4136238104Sdes# Must ONLY be called from within func_mode_link because
4137238104Sdes# it depends on a number of variable set therein.
4138238104Sdesfunc_emit_cwrapperexe_src ()
4139238104Sdes{
4140238104Sdes	cat <<EOF
4141238104Sdes
4142238104Sdes/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
4143238104Sdes   Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
4144238104Sdes
4145238104Sdes   The $output program cannot be directly executed until all the libtool
4146238104Sdes   libraries that it depends on are installed.
4147238104Sdes
4148238104Sdes   This wrapper executable should never be moved out of the build directory.
4149238104Sdes   If it is, it will not operate correctly.
4150238104Sdes*/
4151238104SdesEOF
4152238104Sdes	    cat <<"EOF"
4153238104Sdes#ifdef _MSC_VER
4154238104Sdes# define _CRT_SECURE_NO_DEPRECATE 1
4155238104Sdes#endif
4156238104Sdes#include <stdio.h>
4157238104Sdes#include <stdlib.h>
4158238104Sdes#ifdef _MSC_VER
4159238104Sdes# include <direct.h>
4160238104Sdes# include <process.h>
4161238104Sdes# include <io.h>
4162238104Sdes#else
4163238104Sdes# include <unistd.h>
4164238104Sdes# include <stdint.h>
4165238104Sdes# ifdef __CYGWIN__
4166238104Sdes#  include <io.h>
4167238104Sdes# endif
4168238104Sdes#endif
4169238104Sdes#include <malloc.h>
4170238104Sdes#include <stdarg.h>
4171238104Sdes#include <assert.h>
4172238104Sdes#include <string.h>
4173238104Sdes#include <ctype.h>
4174238104Sdes#include <errno.h>
4175238104Sdes#include <fcntl.h>
4176238104Sdes#include <sys/stat.h>
4177238104Sdes
4178238104Sdes/* declarations of non-ANSI functions */
4179238104Sdes#if defined(__MINGW32__)
4180238104Sdes# ifdef __STRICT_ANSI__
4181238104Sdesint _putenv (const char *);
4182238104Sdes# endif
4183238104Sdes#elif defined(__CYGWIN__)
4184238104Sdes# ifdef __STRICT_ANSI__
4185238104Sdeschar *realpath (const char *, char *);
4186238104Sdesint putenv (char *);
4187238104Sdesint setenv (const char *, const char *, int);
4188238104Sdes# endif
4189238104Sdes/* #elif defined (other platforms) ... */
4190238104Sdes#endif
4191238104Sdes
4192238104Sdes/* portability defines, excluding path handling macros */
4193238104Sdes#if defined(_MSC_VER)
4194238104Sdes# define setmode _setmode
4195238104Sdes# define stat    _stat
4196238104Sdes# define chmod   _chmod
4197238104Sdes# define getcwd  _getcwd
4198238104Sdes# define putenv  _putenv
4199238104Sdes# define S_IXUSR _S_IEXEC
4200238104Sdes# ifndef _INTPTR_T_DEFINED
4201238104Sdes#  define _INTPTR_T_DEFINED
4202238104Sdes#  define intptr_t int
4203238104Sdes# endif
4204238104Sdes#elif defined(__MINGW32__)
4205238104Sdes# define setmode _setmode
4206238104Sdes# define stat    _stat
4207238104Sdes# define chmod   _chmod
4208238104Sdes# define getcwd  _getcwd
4209238104Sdes# define putenv  _putenv
4210238104Sdes#elif defined(__CYGWIN__)
4211238104Sdes# define HAVE_SETENV
4212238104Sdes# define FOPEN_WB "wb"
4213238104Sdes/* #elif defined (other platforms) ... */
4214238104Sdes#endif
4215238104Sdes
4216238104Sdes#if defined(PATH_MAX)
4217238104Sdes# define LT_PATHMAX PATH_MAX
4218238104Sdes#elif defined(MAXPATHLEN)
4219238104Sdes# define LT_PATHMAX MAXPATHLEN
4220238104Sdes#else
4221238104Sdes# define LT_PATHMAX 1024
4222238104Sdes#endif
4223238104Sdes
4224238104Sdes#ifndef S_IXOTH
4225238104Sdes# define S_IXOTH 0
4226238104Sdes#endif
4227238104Sdes#ifndef S_IXGRP
4228238104Sdes# define S_IXGRP 0
4229238104Sdes#endif
4230238104Sdes
4231238104Sdes/* path handling portability macros */
4232238104Sdes#ifndef DIR_SEPARATOR
4233238104Sdes# define DIR_SEPARATOR '/'
4234238104Sdes# define PATH_SEPARATOR ':'
4235238104Sdes#endif
4236238104Sdes
4237238104Sdes#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
4238238104Sdes  defined (__OS2__)
4239238104Sdes# define HAVE_DOS_BASED_FILE_SYSTEM
4240238104Sdes# define FOPEN_WB "wb"
4241238104Sdes# ifndef DIR_SEPARATOR_2
4242238104Sdes#  define DIR_SEPARATOR_2 '\\'
4243238104Sdes# endif
4244238104Sdes# ifndef PATH_SEPARATOR_2
4245238104Sdes#  define PATH_SEPARATOR_2 ';'
4246238104Sdes# endif
4247238104Sdes#endif
4248238104Sdes
4249238104Sdes#ifndef DIR_SEPARATOR_2
4250238104Sdes# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
4251238104Sdes#else /* DIR_SEPARATOR_2 */
4252238104Sdes# define IS_DIR_SEPARATOR(ch) \
4253238104Sdes	(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
4254238104Sdes#endif /* DIR_SEPARATOR_2 */
4255238104Sdes
4256238104Sdes#ifndef PATH_SEPARATOR_2
4257238104Sdes# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
4258238104Sdes#else /* PATH_SEPARATOR_2 */
4259238104Sdes# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
4260238104Sdes#endif /* PATH_SEPARATOR_2 */
4261238104Sdes
4262238104Sdes#ifndef FOPEN_WB
4263238104Sdes# define FOPEN_WB "w"
4264238104Sdes#endif
4265238104Sdes#ifndef _O_BINARY
4266238104Sdes# define _O_BINARY 0
4267238104Sdes#endif
4268238104Sdes
4269238104Sdes#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
4270238104Sdes#define XFREE(stale) do { \
4271238104Sdes  if (stale) { free ((void *) stale); stale = 0; } \
4272238104Sdes} while (0)
4273238104Sdes
4274238104Sdes#if defined(LT_DEBUGWRAPPER)
4275238104Sdesstatic int lt_debug = 1;
4276238104Sdes#else
4277238104Sdesstatic int lt_debug = 0;
4278238104Sdes#endif
4279238104Sdes
4280238104Sdesconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */
4281238104Sdes
4282238104Sdesvoid *xmalloc (size_t num);
4283238104Sdeschar *xstrdup (const char *string);
4284238104Sdesconst char *base_name (const char *name);
4285238104Sdeschar *find_executable (const char *wrapper);
4286238104Sdeschar *chase_symlinks (const char *pathspec);
4287238104Sdesint make_executable (const char *path);
4288238104Sdesint check_executable (const char *path);
4289238104Sdeschar *strendzap (char *str, const char *pat);
4290238104Sdesvoid lt_debugprintf (const char *file, int line, const char *fmt, ...);
4291238104Sdesvoid lt_fatal (const char *file, int line, const char *message, ...);
4292238104Sdesstatic const char *nonnull (const char *s);
4293238104Sdesstatic const char *nonempty (const char *s);
4294238104Sdesvoid lt_setenv (const char *name, const char *value);
4295238104Sdeschar *lt_extend_str (const char *orig_value, const char *add, int to_end);
4296238104Sdesvoid lt_update_exe_path (const char *name, const char *value);
4297238104Sdesvoid lt_update_lib_path (const char *name, const char *value);
4298238104Sdeschar **prepare_spawn (char **argv);
4299238104Sdesvoid lt_dump_script (FILE *f);
4300238104SdesEOF
4301238104Sdes
4302238104Sdes	    cat <<EOF
4303238104Sdesvolatile const char * MAGIC_EXE = "$magic_exe";
4304238104Sdesconst char * LIB_PATH_VARNAME = "$shlibpath_var";
4305238104SdesEOF
4306238104Sdes
4307238104Sdes	    if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
4308238104Sdes              func_to_host_path "$temp_rpath"
4309238104Sdes	      cat <<EOF
4310238104Sdesconst char * LIB_PATH_VALUE   = "$func_to_host_path_result";
4311238104SdesEOF
4312238104Sdes	    else
4313238104Sdes	      cat <<"EOF"
4314238104Sdesconst char * LIB_PATH_VALUE   = "";
4315238104SdesEOF
4316238104Sdes	    fi
4317238104Sdes
4318238104Sdes	    if test -n "$dllsearchpath"; then
4319238104Sdes              func_to_host_path "$dllsearchpath:"
4320238104Sdes	      cat <<EOF
4321238104Sdesconst char * EXE_PATH_VARNAME = "PATH";
4322238104Sdesconst char * EXE_PATH_VALUE   = "$func_to_host_path_result";
4323238104SdesEOF
4324238104Sdes	    else
4325238104Sdes	      cat <<"EOF"
4326238104Sdesconst char * EXE_PATH_VARNAME = "";
4327238104Sdesconst char * EXE_PATH_VALUE   = "";
4328238104SdesEOF
4329238104Sdes	    fi
4330238104Sdes
4331238104Sdes	    if test "$fast_install" = yes; then
4332238104Sdes	      cat <<EOF
4333238104Sdesconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
4334238104SdesEOF
4335238104Sdes	    else
4336238104Sdes	      cat <<EOF
4337238104Sdesconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
4338238104SdesEOF
4339238104Sdes	    fi
4340238104Sdes
4341238104Sdes
4342238104Sdes	    cat <<"EOF"
4343238104Sdes
4344238104Sdes#define LTWRAPPER_OPTION_PREFIX         "--lt-"
4345238104Sdes
4346238104Sdesstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
4347238104Sdesstatic const char *dumpscript_opt       = LTWRAPPER_OPTION_PREFIX "dump-script";
4348238104Sdesstatic const char *debug_opt            = LTWRAPPER_OPTION_PREFIX "debug";
4349238104Sdes
4350238104Sdesint
4351238104Sdesmain (int argc, char *argv[])
4352238104Sdes{
4353238104Sdes  char **newargz;
4354238104Sdes  int  newargc;
4355238104Sdes  char *tmp_pathspec;
4356238104Sdes  char *actual_cwrapper_path;
4357238104Sdes  char *actual_cwrapper_name;
4358238104Sdes  char *target_name;
4359238104Sdes  char *lt_argv_zero;
4360238104Sdes  intptr_t rval = 127;
4361238104Sdes
4362238104Sdes  int i;
4363238104Sdes
4364238104Sdes  program_name = (char *) xstrdup (base_name (argv[0]));
4365238104Sdes  newargz = XMALLOC (char *, argc + 1);
4366238104Sdes
4367238104Sdes  /* very simple arg parsing; don't want to rely on getopt
4368238104Sdes   * also, copy all non cwrapper options to newargz, except
4369238104Sdes   * argz[0], which is handled differently
4370238104Sdes   */
4371238104Sdes  newargc=0;
4372238104Sdes  for (i = 1; i < argc; i++)
4373238104Sdes    {
4374238104Sdes      if (strcmp (argv[i], dumpscript_opt) == 0)
4375238104Sdes	{
4376238104SdesEOF
4377238104Sdes	    case "$host" in
4378238104Sdes	      *mingw* | *cygwin* )
4379238104Sdes		# make stdout use "unix" line endings
4380238104Sdes		echo "          setmode(1,_O_BINARY);"
4381238104Sdes		;;
4382238104Sdes	      esac
4383238104Sdes
4384238104Sdes	    cat <<"EOF"
4385238104Sdes	  lt_dump_script (stdout);
4386238104Sdes	  return 0;
4387238104Sdes	}
4388238104Sdes      if (strcmp (argv[i], debug_opt) == 0)
4389238104Sdes	{
4390238104Sdes          lt_debug = 1;
4391238104Sdes          continue;
4392238104Sdes	}
4393238104Sdes      if (strcmp (argv[i], ltwrapper_option_prefix) == 0)
4394238104Sdes        {
4395238104Sdes          /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
4396238104Sdes             namespace, but it is not one of the ones we know about and
4397238104Sdes             have already dealt with, above (inluding dump-script), then
4398238104Sdes             report an error. Otherwise, targets might begin to believe
4399238104Sdes             they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
4400238104Sdes             namespace. The first time any user complains about this, we'll
4401238104Sdes             need to make LTWRAPPER_OPTION_PREFIX a configure-time option
4402238104Sdes             or a configure.ac-settable value.
4403238104Sdes           */
4404238104Sdes          lt_fatal (__FILE__, __LINE__,
4405238104Sdes		    "unrecognized %s option: '%s'",
4406238104Sdes                    ltwrapper_option_prefix, argv[i]);
4407238104Sdes        }
4408238104Sdes      /* otherwise ... */
4409238104Sdes      newargz[++newargc] = xstrdup (argv[i]);
4410238104Sdes    }
4411238104Sdes  newargz[++newargc] = NULL;
4412238104Sdes
4413238104SdesEOF
4414238104Sdes	    cat <<EOF
4415238104Sdes  /* The GNU banner must be the first non-error debug message */
4416238104Sdes  lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\n");
4417238104SdesEOF
4418238104Sdes	    cat <<"EOF"
4419238104Sdes  lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
4420238104Sdes  lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name);
4421238104Sdes
4422238104Sdes  tmp_pathspec = find_executable (argv[0]);
4423238104Sdes  if (tmp_pathspec == NULL)
4424238104Sdes    lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]);
4425238104Sdes  lt_debugprintf (__FILE__, __LINE__,
4426238104Sdes                  "(main) found exe (before symlink chase) at: %s\n",
4427238104Sdes		  tmp_pathspec);
4428238104Sdes
4429238104Sdes  actual_cwrapper_path = chase_symlinks (tmp_pathspec);
4430238104Sdes  lt_debugprintf (__FILE__, __LINE__,
4431238104Sdes                  "(main) found exe (after symlink chase) at: %s\n",
4432238104Sdes		  actual_cwrapper_path);
4433238104Sdes  XFREE (tmp_pathspec);
4434238104Sdes
4435238104Sdes  actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));
4436238104Sdes  strendzap (actual_cwrapper_path, actual_cwrapper_name);
4437238104Sdes
4438238104Sdes  /* wrapper name transforms */
4439238104Sdes  strendzap (actual_cwrapper_name, ".exe");
4440238104Sdes  tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
4441238104Sdes  XFREE (actual_cwrapper_name);
4442238104Sdes  actual_cwrapper_name = tmp_pathspec;
4443238104Sdes  tmp_pathspec = 0;
4444238104Sdes
4445238104Sdes  /* target_name transforms -- use actual target program name; might have lt- prefix */
4446238104Sdes  target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
4447238104Sdes  strendzap (target_name, ".exe");
4448238104Sdes  tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
4449238104Sdes  XFREE (target_name);
4450238104Sdes  target_name = tmp_pathspec;
4451238104Sdes  tmp_pathspec = 0;
4452238104Sdes
4453238104Sdes  lt_debugprintf (__FILE__, __LINE__,
4454238104Sdes		  "(main) libtool target name: %s\n",
4455238104Sdes		  target_name);
4456238104SdesEOF
4457238104Sdes
4458238104Sdes	    cat <<EOF
4459238104Sdes  newargz[0] =
4460238104Sdes    XMALLOC (char, (strlen (actual_cwrapper_path) +
4461238104Sdes		    strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
4462238104Sdes  strcpy (newargz[0], actual_cwrapper_path);
4463238104Sdes  strcat (newargz[0], "$objdir");
4464238104Sdes  strcat (newargz[0], "/");
4465238104SdesEOF
4466238104Sdes
4467238104Sdes	    cat <<"EOF"
4468238104Sdes  /* stop here, and copy so we don't have to do this twice */
4469238104Sdes  tmp_pathspec = xstrdup (newargz[0]);
4470238104Sdes
4471238104Sdes  /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
4472238104Sdes  strcat (newargz[0], actual_cwrapper_name);
4473238104Sdes
4474238104Sdes  /* DO want the lt- prefix here if it exists, so use target_name */
4475238104Sdes  lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
4476238104Sdes  XFREE (tmp_pathspec);
4477238104Sdes  tmp_pathspec = NULL;
4478238104SdesEOF
4479238104Sdes
4480238104Sdes	    case $host_os in
4481238104Sdes	      mingw*)
4482238104Sdes	    cat <<"EOF"
4483238104Sdes  {
4484238104Sdes    char* p;
4485238104Sdes    while ((p = strchr (newargz[0], '\\')) != NULL)
4486238104Sdes      {
4487238104Sdes	*p = '/';
4488238104Sdes      }
4489238104Sdes    while ((p = strchr (lt_argv_zero, '\\')) != NULL)
4490238104Sdes      {
4491238104Sdes	*p = '/';
4492238104Sdes      }
4493238104Sdes  }
4494238104SdesEOF
4495238104Sdes	    ;;
4496238104Sdes	    esac
4497238104Sdes
4498238104Sdes	    cat <<"EOF"
4499238104Sdes  XFREE (target_name);
4500238104Sdes  XFREE (actual_cwrapper_path);
4501238104Sdes  XFREE (actual_cwrapper_name);
4502238104Sdes
4503238104Sdes  lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
4504238104Sdes  lt_setenv ("DUALCASE", "1");  /* for MSK sh */
4505238104Sdes  /* Update the DLL searchpath.  EXE_PATH_VALUE ($dllsearchpath) must
4506238104Sdes     be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath)
4507238104Sdes     because on Windows, both *_VARNAMEs are PATH but uninstalled
4508238104Sdes     libraries must come first. */
4509238104Sdes  lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
4510238104Sdes  lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
4511238104Sdes
4512238104Sdes  lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",
4513238104Sdes		  nonnull (lt_argv_zero));
4514238104Sdes  for (i = 0; i < newargc; i++)
4515238104Sdes    {
4516238104Sdes      lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n",
4517238104Sdes		      i, nonnull (newargz[i]));
4518238104Sdes    }
4519238104Sdes
4520238104SdesEOF
4521238104Sdes
4522238104Sdes	    case $host_os in
4523238104Sdes	      mingw*)
4524238104Sdes		cat <<"EOF"
4525238104Sdes  /* execv doesn't actually work on mingw as expected on unix */
4526238104Sdes  newargz = prepare_spawn (newargz);
4527238104Sdes  rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
4528238104Sdes  if (rval == -1)
4529238104Sdes    {
4530238104Sdes      /* failed to start process */
4531238104Sdes      lt_debugprintf (__FILE__, __LINE__,
4532238104Sdes		      "(main) failed to launch target \"%s\": %s\n",
4533238104Sdes		      lt_argv_zero, nonnull (strerror (errno)));
4534238104Sdes      return 127;
4535238104Sdes    }
4536238104Sdes  return rval;
4537238104SdesEOF
4538238104Sdes		;;
4539238104Sdes	      *)
4540238104Sdes		cat <<"EOF"
4541238104Sdes  execv (lt_argv_zero, newargz);
4542238104Sdes  return rval; /* =127, but avoids unused variable warning */
4543238104SdesEOF
4544238104Sdes		;;
4545238104Sdes	    esac
4546238104Sdes
4547238104Sdes	    cat <<"EOF"
4548238104Sdes}
4549238104Sdes
4550238104Sdesvoid *
4551238104Sdesxmalloc (size_t num)
4552238104Sdes{
4553238104Sdes  void *p = (void *) malloc (num);
4554238104Sdes  if (!p)
4555238104Sdes    lt_fatal (__FILE__, __LINE__, "memory exhausted");
4556238104Sdes
4557238104Sdes  return p;
4558238104Sdes}
4559238104Sdes
4560238104Sdeschar *
4561238104Sdesxstrdup (const char *string)
4562238104Sdes{
4563238104Sdes  return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
4564238104Sdes			  string) : NULL;
4565238104Sdes}
4566238104Sdes
4567238104Sdesconst char *
4568238104Sdesbase_name (const char *name)
4569238104Sdes{
4570238104Sdes  const char *base;
4571238104Sdes
4572238104Sdes#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4573238104Sdes  /* Skip over the disk name in MSDOS pathnames. */
4574238104Sdes  if (isalpha ((unsigned char) name[0]) && name[1] == ':')
4575238104Sdes    name += 2;
4576238104Sdes#endif
4577238104Sdes
4578238104Sdes  for (base = name; *name; name++)
4579238104Sdes    if (IS_DIR_SEPARATOR (*name))
4580238104Sdes      base = name + 1;
4581238104Sdes  return base;
4582238104Sdes}
4583238104Sdes
4584238104Sdesint
4585238104Sdescheck_executable (const char *path)
4586238104Sdes{
4587238104Sdes  struct stat st;
4588238104Sdes
4589238104Sdes  lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n",
4590238104Sdes                  nonempty (path));
4591238104Sdes  if ((!path) || (!*path))
4592238104Sdes    return 0;
4593238104Sdes
4594238104Sdes  if ((stat (path, &st) >= 0)
4595238104Sdes      && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
4596238104Sdes    return 1;
4597238104Sdes  else
4598238104Sdes    return 0;
4599238104Sdes}
4600238104Sdes
4601238104Sdesint
4602238104Sdesmake_executable (const char *path)
4603238104Sdes{
4604238104Sdes  int rval = 0;
4605238104Sdes  struct stat st;
4606238104Sdes
4607238104Sdes  lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n",
4608238104Sdes                  nonempty (path));
4609238104Sdes  if ((!path) || (!*path))
4610238104Sdes    return 0;
4611238104Sdes
4612238104Sdes  if (stat (path, &st) >= 0)
4613238104Sdes    {
4614238104Sdes      rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
4615238104Sdes    }
4616238104Sdes  return rval;
4617238104Sdes}
4618238104Sdes
4619238104Sdes/* Searches for the full path of the wrapper.  Returns
4620238104Sdes   newly allocated full path name if found, NULL otherwise
4621238104Sdes   Does not chase symlinks, even on platforms that support them.
4622238104Sdes*/
4623238104Sdeschar *
4624238104Sdesfind_executable (const char *wrapper)
4625238104Sdes{
4626238104Sdes  int has_slash = 0;
4627238104Sdes  const char *p;
4628238104Sdes  const char *p_next;
4629238104Sdes  /* static buffer for getcwd */
4630238104Sdes  char tmp[LT_PATHMAX + 1];
4631238104Sdes  int tmp_len;
4632238104Sdes  char *concat_name;
4633238104Sdes
4634238104Sdes  lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
4635238104Sdes                  nonempty (wrapper));
4636238104Sdes
4637238104Sdes  if ((wrapper == NULL) || (*wrapper == '\0'))
4638238104Sdes    return NULL;
4639238104Sdes
4640238104Sdes  /* Absolute path? */
4641238104Sdes#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4642238104Sdes  if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
4643238104Sdes    {
4644238104Sdes      concat_name = xstrdup (wrapper);
4645238104Sdes      if (check_executable (concat_name))
4646238104Sdes	return concat_name;
4647238104Sdes      XFREE (concat_name);
4648238104Sdes    }
4649238104Sdes  else
4650238104Sdes    {
4651238104Sdes#endif
4652238104Sdes      if (IS_DIR_SEPARATOR (wrapper[0]))
4653238104Sdes	{
4654238104Sdes	  concat_name = xstrdup (wrapper);
4655238104Sdes	  if (check_executable (concat_name))
4656238104Sdes	    return concat_name;
4657238104Sdes	  XFREE (concat_name);
4658238104Sdes	}
4659238104Sdes#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4660238104Sdes    }
4661238104Sdes#endif
4662238104Sdes
4663238104Sdes  for (p = wrapper; *p; p++)
4664238104Sdes    if (*p == '/')
4665238104Sdes      {
4666238104Sdes	has_slash = 1;
4667238104Sdes	break;
4668238104Sdes      }
4669238104Sdes  if (!has_slash)
4670238104Sdes    {
4671238104Sdes      /* no slashes; search PATH */
4672238104Sdes      const char *path = getenv ("PATH");
4673238104Sdes      if (path != NULL)
4674238104Sdes	{
4675238104Sdes	  for (p = path; *p; p = p_next)
4676238104Sdes	    {
4677238104Sdes	      const char *q;
4678238104Sdes	      size_t p_len;
4679238104Sdes	      for (q = p; *q; q++)
4680238104Sdes		if (IS_PATH_SEPARATOR (*q))
4681238104Sdes		  break;
4682238104Sdes	      p_len = q - p;
4683238104Sdes	      p_next = (*q == '\0' ? q : q + 1);
4684238104Sdes	      if (p_len == 0)
4685238104Sdes		{
4686238104Sdes		  /* empty path: current directory */
4687238104Sdes		  if (getcwd (tmp, LT_PATHMAX) == NULL)
4688238104Sdes		    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
4689238104Sdes                              nonnull (strerror (errno)));
4690238104Sdes		  tmp_len = strlen (tmp);
4691238104Sdes		  concat_name =
4692238104Sdes		    XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
4693238104Sdes		  memcpy (concat_name, tmp, tmp_len);
4694238104Sdes		  concat_name[tmp_len] = '/';
4695238104Sdes		  strcpy (concat_name + tmp_len + 1, wrapper);
4696238104Sdes		}
4697238104Sdes	      else
4698238104Sdes		{
4699238104Sdes		  concat_name =
4700238104Sdes		    XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
4701238104Sdes		  memcpy (concat_name, p, p_len);
4702238104Sdes		  concat_name[p_len] = '/';
4703238104Sdes		  strcpy (concat_name + p_len + 1, wrapper);
4704238104Sdes		}
4705238104Sdes	      if (check_executable (concat_name))
4706238104Sdes		return concat_name;
4707238104Sdes	      XFREE (concat_name);
4708238104Sdes	    }
4709238104Sdes	}
4710238104Sdes      /* not found in PATH; assume curdir */
4711238104Sdes    }
4712238104Sdes  /* Relative path | not found in path: prepend cwd */
4713238104Sdes  if (getcwd (tmp, LT_PATHMAX) == NULL)
4714238104Sdes    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
4715238104Sdes              nonnull (strerror (errno)));
4716238104Sdes  tmp_len = strlen (tmp);
4717238104Sdes  concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
4718238104Sdes  memcpy (concat_name, tmp, tmp_len);
4719238104Sdes  concat_name[tmp_len] = '/';
4720238104Sdes  strcpy (concat_name + tmp_len + 1, wrapper);
4721238104Sdes
4722238104Sdes  if (check_executable (concat_name))
4723238104Sdes    return concat_name;
4724238104Sdes  XFREE (concat_name);
4725238104Sdes  return NULL;
4726238104Sdes}
4727238104Sdes
4728238104Sdeschar *
4729238104Sdeschase_symlinks (const char *pathspec)
4730238104Sdes{
4731238104Sdes#ifndef S_ISLNK
4732238104Sdes  return xstrdup (pathspec);
4733238104Sdes#else
4734238104Sdes  char buf[LT_PATHMAX];
4735238104Sdes  struct stat s;
4736238104Sdes  char *tmp_pathspec = xstrdup (pathspec);
4737238104Sdes  char *p;
4738238104Sdes  int has_symlinks = 0;
4739238104Sdes  while (strlen (tmp_pathspec) && !has_symlinks)
4740238104Sdes    {
4741238104Sdes      lt_debugprintf (__FILE__, __LINE__,
4742238104Sdes		      "checking path component for symlinks: %s\n",
4743238104Sdes		      tmp_pathspec);
4744238104Sdes      if (lstat (tmp_pathspec, &s) == 0)
4745238104Sdes	{
4746238104Sdes	  if (S_ISLNK (s.st_mode) != 0)
4747238104Sdes	    {
4748238104Sdes	      has_symlinks = 1;
4749238104Sdes	      break;
4750238104Sdes	    }
4751238104Sdes
4752238104Sdes	  /* search backwards for last DIR_SEPARATOR */
4753238104Sdes	  p = tmp_pathspec + strlen (tmp_pathspec) - 1;
4754238104Sdes	  while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
4755238104Sdes	    p--;
4756238104Sdes	  if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
4757238104Sdes	    {
4758238104Sdes	      /* no more DIR_SEPARATORS left */
4759238104Sdes	      break;
4760238104Sdes	    }
4761238104Sdes	  *p = '\0';
4762238104Sdes	}
4763238104Sdes      else
4764238104Sdes	{
4765238104Sdes	  lt_fatal (__FILE__, __LINE__,
4766238104Sdes		    "error accessing file \"%s\": %s",
4767238104Sdes		    tmp_pathspec, nonnull (strerror (errno)));
4768238104Sdes	}
4769238104Sdes    }
4770238104Sdes  XFREE (tmp_pathspec);
4771238104Sdes
4772238104Sdes  if (!has_symlinks)
4773238104Sdes    {
4774238104Sdes      return xstrdup (pathspec);
4775238104Sdes    }
4776238104Sdes
4777238104Sdes  tmp_pathspec = realpath (pathspec, buf);
4778238104Sdes  if (tmp_pathspec == 0)
4779238104Sdes    {
4780238104Sdes      lt_fatal (__FILE__, __LINE__,
4781238104Sdes		"could not follow symlinks for %s", pathspec);
4782238104Sdes    }
4783238104Sdes  return xstrdup (tmp_pathspec);
4784238104Sdes#endif
4785238104Sdes}
4786238104Sdes
4787238104Sdeschar *
4788238104Sdesstrendzap (char *str, const char *pat)
4789238104Sdes{
4790238104Sdes  size_t len, patlen;
4791238104Sdes
4792238104Sdes  assert (str != NULL);
4793238104Sdes  assert (pat != NULL);
4794238104Sdes
4795238104Sdes  len = strlen (str);
4796238104Sdes  patlen = strlen (pat);
4797238104Sdes
4798238104Sdes  if (patlen <= len)
4799238104Sdes    {
4800238104Sdes      str += len - patlen;
4801238104Sdes      if (strcmp (str, pat) == 0)
4802238104Sdes	*str = '\0';
4803238104Sdes    }
4804238104Sdes  return str;
4805238104Sdes}
4806238104Sdes
4807238104Sdesvoid
4808238104Sdeslt_debugprintf (const char *file, int line, const char *fmt, ...)
4809238104Sdes{
4810238104Sdes  va_list args;
4811238104Sdes  if (lt_debug)
4812238104Sdes    {
4813238104Sdes      (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line);
4814238104Sdes      va_start (args, fmt);
4815238104Sdes      (void) vfprintf (stderr, fmt, args);
4816238104Sdes      va_end (args);
4817238104Sdes    }
4818238104Sdes}
4819238104Sdes
4820238104Sdesstatic void
4821238104Sdeslt_error_core (int exit_status, const char *file,
4822238104Sdes	       int line, const char *mode,
4823238104Sdes	       const char *message, va_list ap)
4824238104Sdes{
4825238104Sdes  fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode);
4826238104Sdes  vfprintf (stderr, message, ap);
4827238104Sdes  fprintf (stderr, ".\n");
4828238104Sdes
4829238104Sdes  if (exit_status >= 0)
4830238104Sdes    exit (exit_status);
4831238104Sdes}
4832238104Sdes
4833238104Sdesvoid
4834238104Sdeslt_fatal (const char *file, int line, const char *message, ...)
4835238104Sdes{
4836238104Sdes  va_list ap;
4837238104Sdes  va_start (ap, message);
4838238104Sdes  lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap);
4839238104Sdes  va_end (ap);
4840238104Sdes}
4841238104Sdes
4842238104Sdesstatic const char *
4843238104Sdesnonnull (const char *s)
4844238104Sdes{
4845238104Sdes  return s ? s : "(null)";
4846238104Sdes}
4847238104Sdes
4848238104Sdesstatic const char *
4849238104Sdesnonempty (const char *s)
4850238104Sdes{
4851238104Sdes  return (s && !*s) ? "(empty)" : nonnull (s);
4852238104Sdes}
4853238104Sdes
4854238104Sdesvoid
4855238104Sdeslt_setenv (const char *name, const char *value)
4856238104Sdes{
4857238104Sdes  lt_debugprintf (__FILE__, __LINE__,
4858238104Sdes		  "(lt_setenv) setting '%s' to '%s'\n",
4859238104Sdes                  nonnull (name), nonnull (value));
4860238104Sdes  {
4861238104Sdes#ifdef HAVE_SETENV
4862238104Sdes    /* always make a copy, for consistency with !HAVE_SETENV */
4863238104Sdes    char *str = xstrdup (value);
4864238104Sdes    setenv (name, str, 1);
4865238104Sdes#else
4866238104Sdes    int len = strlen (name) + 1 + strlen (value) + 1;
4867238104Sdes    char *str = XMALLOC (char, len);
4868238104Sdes    sprintf (str, "%s=%s", name, value);
4869238104Sdes    if (putenv (str) != EXIT_SUCCESS)
4870238104Sdes      {
4871238104Sdes        XFREE (str);
4872238104Sdes      }
4873238104Sdes#endif
4874238104Sdes  }
4875238104Sdes}
4876238104Sdes
4877238104Sdeschar *
4878238104Sdeslt_extend_str (const char *orig_value, const char *add, int to_end)
4879238104Sdes{
4880238104Sdes  char *new_value;
4881238104Sdes  if (orig_value && *orig_value)
4882238104Sdes    {
4883238104Sdes      int orig_value_len = strlen (orig_value);
4884238104Sdes      int add_len = strlen (add);
4885238104Sdes      new_value = XMALLOC (char, add_len + orig_value_len + 1);
4886238104Sdes      if (to_end)
4887238104Sdes        {
4888238104Sdes          strcpy (new_value, orig_value);
4889238104Sdes          strcpy (new_value + orig_value_len, add);
4890238104Sdes        }
4891238104Sdes      else
4892238104Sdes        {
4893238104Sdes          strcpy (new_value, add);
4894238104Sdes          strcpy (new_value + add_len, orig_value);
4895238104Sdes        }
4896238104Sdes    }
4897238104Sdes  else
4898238104Sdes    {
4899238104Sdes      new_value = xstrdup (add);
4900238104Sdes    }
4901238104Sdes  return new_value;
4902238104Sdes}
4903238104Sdes
4904238104Sdesvoid
4905238104Sdeslt_update_exe_path (const char *name, const char *value)
4906238104Sdes{
4907238104Sdes  lt_debugprintf (__FILE__, __LINE__,
4908238104Sdes		  "(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
4909238104Sdes                  nonnull (name), nonnull (value));
4910238104Sdes
4911238104Sdes  if (name && *name && value && *value)
4912238104Sdes    {
4913238104Sdes      char *new_value = lt_extend_str (getenv (name), value, 0);
4914238104Sdes      /* some systems can't cope with a ':'-terminated path #' */
4915238104Sdes      int len = strlen (new_value);
4916238104Sdes      while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
4917238104Sdes        {
4918238104Sdes          new_value[len-1] = '\0';
4919238104Sdes        }
4920238104Sdes      lt_setenv (name, new_value);
4921238104Sdes      XFREE (new_value);
4922238104Sdes    }
4923238104Sdes}
4924238104Sdes
4925238104Sdesvoid
4926238104Sdeslt_update_lib_path (const char *name, const char *value)
4927238104Sdes{
4928238104Sdes  lt_debugprintf (__FILE__, __LINE__,
4929238104Sdes		  "(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
4930238104Sdes                  nonnull (name), nonnull (value));
4931238104Sdes
4932238104Sdes  if (name && *name && value && *value)
4933238104Sdes    {
4934238104Sdes      char *new_value = lt_extend_str (getenv (name), value, 0);
4935238104Sdes      lt_setenv (name, new_value);
4936238104Sdes      XFREE (new_value);
4937238104Sdes    }
4938238104Sdes}
4939238104Sdes
4940238104SdesEOF
4941238104Sdes	    case $host_os in
4942238104Sdes	      mingw*)
4943238104Sdes		cat <<"EOF"
4944238104Sdes
4945238104Sdes/* Prepares an argument vector before calling spawn().
4946238104Sdes   Note that spawn() does not by itself call the command interpreter
4947238104Sdes     (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
4948238104Sdes      ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
4949238104Sdes         GetVersionEx(&v);
4950238104Sdes         v.dwPlatformId == VER_PLATFORM_WIN32_NT;
4951238104Sdes      }) ? "cmd.exe" : "command.com").
4952238104Sdes   Instead it simply concatenates the arguments, separated by ' ', and calls
4953238104Sdes   CreateProcess().  We must quote the arguments since Win32 CreateProcess()
4954238104Sdes   interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
4955238104Sdes   special way:
4956238104Sdes   - Space and tab are interpreted as delimiters. They are not treated as
4957238104Sdes     delimiters if they are surrounded by double quotes: "...".
4958238104Sdes   - Unescaped double quotes are removed from the input. Their only effect is
4959238104Sdes     that within double quotes, space and tab are treated like normal
4960238104Sdes     characters.
4961238104Sdes   - Backslashes not followed by double quotes are not special.
4962238104Sdes   - But 2*n+1 backslashes followed by a double quote become
4963238104Sdes     n backslashes followed by a double quote (n >= 0):
4964238104Sdes       \" -> "
4965238104Sdes       \\\" -> \"
4966238104Sdes       \\\\\" -> \\"
4967238104Sdes */
4968238104Sdes#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"
4969238104Sdes#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"
4970238104Sdeschar **
4971238104Sdesprepare_spawn (char **argv)
4972238104Sdes{
4973238104Sdes  size_t argc;
4974238104Sdes  char **new_argv;
4975238104Sdes  size_t i;
4976238104Sdes
4977238104Sdes  /* Count number of arguments.  */
4978238104Sdes  for (argc = 0; argv[argc] != NULL; argc++)
4979238104Sdes    ;
4980238104Sdes
4981238104Sdes  /* Allocate new argument vector.  */
4982238104Sdes  new_argv = XMALLOC (char *, argc + 1);
4983238104Sdes
4984238104Sdes  /* Put quoted arguments into the new argument vector.  */
4985238104Sdes  for (i = 0; i < argc; i++)
4986238104Sdes    {
4987238104Sdes      const char *string = argv[i];
4988238104Sdes
4989238104Sdes      if (string[0] == '\0')
4990238104Sdes	new_argv[i] = xstrdup ("\"\"");
4991238104Sdes      else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
4992238104Sdes	{
4993238104Sdes	  int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
4994238104Sdes	  size_t length;
4995238104Sdes	  unsigned int backslashes;
4996238104Sdes	  const char *s;
4997238104Sdes	  char *quoted_string;
4998238104Sdes	  char *p;
4999238104Sdes
5000238104Sdes	  length = 0;
5001238104Sdes	  backslashes = 0;
5002238104Sdes	  if (quote_around)
5003238104Sdes	    length++;
5004238104Sdes	  for (s = string; *s != '\0'; s++)
5005238104Sdes	    {
5006238104Sdes	      char c = *s;
5007238104Sdes	      if (c == '"')
5008238104Sdes		length += backslashes + 1;
5009238104Sdes	      length++;
5010238104Sdes	      if (c == '\\')
5011238104Sdes		backslashes++;
5012238104Sdes	      else
5013238104Sdes		backslashes = 0;
5014238104Sdes	    }
5015238104Sdes	  if (quote_around)
5016238104Sdes	    length += backslashes + 1;
5017238104Sdes
5018238104Sdes	  quoted_string = XMALLOC (char, length + 1);
5019238104Sdes
5020238104Sdes	  p = quoted_string;
5021238104Sdes	  backslashes = 0;
5022238104Sdes	  if (quote_around)
5023238104Sdes	    *p++ = '"';
5024238104Sdes	  for (s = string; *s != '\0'; s++)
5025238104Sdes	    {
5026238104Sdes	      char c = *s;
5027238104Sdes	      if (c == '"')
5028238104Sdes		{
5029238104Sdes		  unsigned int j;
5030238104Sdes		  for (j = backslashes + 1; j > 0; j--)
5031238104Sdes		    *p++ = '\\';
5032238104Sdes		}
5033238104Sdes	      *p++ = c;
5034238104Sdes	      if (c == '\\')
5035238104Sdes		backslashes++;
5036238104Sdes	      else
5037238104Sdes		backslashes = 0;
5038238104Sdes	    }
5039238104Sdes	  if (quote_around)
5040238104Sdes	    {
5041238104Sdes	      unsigned int j;
5042238104Sdes	      for (j = backslashes; j > 0; j--)
5043238104Sdes		*p++ = '\\';
5044238104Sdes	      *p++ = '"';
5045238104Sdes	    }
5046238104Sdes	  *p = '\0';
5047238104Sdes
5048238104Sdes	  new_argv[i] = quoted_string;
5049238104Sdes	}
5050238104Sdes      else
5051238104Sdes	new_argv[i] = (char *) string;
5052238104Sdes    }
5053238104Sdes  new_argv[argc] = NULL;
5054238104Sdes
5055238104Sdes  return new_argv;
5056238104Sdes}
5057238104SdesEOF
5058238104Sdes		;;
5059238104Sdes	    esac
5060238104Sdes
5061238104Sdes            cat <<"EOF"
5062238104Sdesvoid lt_dump_script (FILE* f)
5063238104Sdes{
5064238104SdesEOF
5065238104Sdes	    func_emit_wrapper yes |
5066238104Sdes	      $SED -n -e '
5067238104Sdess/^\(.\{79\}\)\(..*\)/\1\
5068238104Sdes\2/
5069238104Sdesh
5070238104Sdess/\([\\"]\)/\\\1/g
5071238104Sdess/$/\\n/
5072238104Sdess/\([^\n]*\).*/  fputs ("\1", f);/p
5073238104Sdesg
5074238104SdesD'
5075238104Sdes            cat <<"EOF"
5076238104Sdes}
5077238104SdesEOF
5078238104Sdes}
5079238104Sdes# end: func_emit_cwrapperexe_src
5080238104Sdes
5081238104Sdes# func_win32_import_lib_p ARG
5082238104Sdes# True if ARG is an import lib, as indicated by $file_magic_cmd
5083238104Sdesfunc_win32_import_lib_p ()
5084238104Sdes{
5085238104Sdes    $opt_debug
5086238104Sdes    case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
5087238104Sdes    *import*) : ;;
5088238104Sdes    *) false ;;
5089238104Sdes    esac
5090238104Sdes}
5091238104Sdes
5092238104Sdes# func_mode_link arg...
5093238104Sdesfunc_mode_link ()
5094238104Sdes{
5095238104Sdes    $opt_debug
5096238104Sdes    case $host in
5097238104Sdes    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
5098238104Sdes      # It is impossible to link a dll without this setting, and
5099238104Sdes      # we shouldn't force the makefile maintainer to figure out
5100238104Sdes      # which system we are compiling for in order to pass an extra
5101238104Sdes      # flag for every libtool invocation.
5102238104Sdes      # allow_undefined=no
5103238104Sdes
5104238104Sdes      # FIXME: Unfortunately, there are problems with the above when trying
5105238104Sdes      # to make a dll which has undefined symbols, in which case not
5106238104Sdes      # even a static library is built.  For now, we need to specify
5107238104Sdes      # -no-undefined on the libtool link line when we can be certain
5108238104Sdes      # that all symbols are satisfied, otherwise we get a static library.
5109238104Sdes      allow_undefined=yes
5110238104Sdes      ;;
5111238104Sdes    *)
5112238104Sdes      allow_undefined=yes
5113238104Sdes      ;;
5114238104Sdes    esac
5115238104Sdes    libtool_args=$nonopt
5116238104Sdes    base_compile="$nonopt $@"
5117238104Sdes    compile_command=$nonopt
5118238104Sdes    finalize_command=$nonopt
5119238104Sdes
5120238104Sdes    compile_rpath=
5121238104Sdes    finalize_rpath=
5122238104Sdes    compile_shlibpath=
5123238104Sdes    finalize_shlibpath=
5124238104Sdes    convenience=
5125238104Sdes    old_convenience=
5126238104Sdes    deplibs=
5127238104Sdes    old_deplibs=
5128238104Sdes    compiler_flags=
5129238104Sdes    linker_flags=
5130238104Sdes    dllsearchpath=
5131238104Sdes    lib_search_path=`pwd`
5132238104Sdes    inst_prefix_dir=
5133238104Sdes    new_inherited_linker_flags=
5134238104Sdes
5135238104Sdes    avoid_version=no
5136238104Sdes    bindir=
5137238104Sdes    dlfiles=
5138238104Sdes    dlprefiles=
5139238104Sdes    dlself=no
5140238104Sdes    export_dynamic=no
5141238104Sdes    export_symbols=
5142238104Sdes    export_symbols_regex=
5143238104Sdes    generated=
5144238104Sdes    libobjs=
5145238104Sdes    ltlibs=
5146238104Sdes    module=no
5147238104Sdes    no_install=no
5148238104Sdes    objs=
5149238104Sdes    non_pic_objects=
5150238104Sdes    precious_files_regex=
5151238104Sdes    prefer_static_libs=no
5152238104Sdes    preload=no
5153238104Sdes    prev=
5154238104Sdes    prevarg=
5155238104Sdes    release=
5156238104Sdes    rpath=
5157238104Sdes    xrpath=
5158238104Sdes    perm_rpath=
5159238104Sdes    temp_rpath=
5160238104Sdes    thread_safe=no
5161238104Sdes    vinfo=
5162238104Sdes    vinfo_number=no
5163238104Sdes    weak_libs=
5164238104Sdes    single_module="${wl}-single_module"
5165238104Sdes    func_infer_tag $base_compile
5166238104Sdes
5167238104Sdes    # We need to know -static, to get the right output filenames.
5168238104Sdes    for arg
5169238104Sdes    do
5170238104Sdes      case $arg in
5171238104Sdes      -shared)
5172238104Sdes	test "$build_libtool_libs" != yes && \
5173238104Sdes	  func_fatal_configuration "can not build a shared library"
5174238104Sdes	build_old_libs=no
5175238104Sdes	break
5176238104Sdes	;;
5177238104Sdes      -all-static | -static | -static-libtool-libs)
5178238104Sdes	case $arg in
5179238104Sdes	-all-static)
5180238104Sdes	  if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
5181238104Sdes	    func_warning "complete static linking is impossible in this configuration"
5182238104Sdes	  fi
5183238104Sdes	  if test -n "$link_static_flag"; then
5184238104Sdes	    dlopen_self=$dlopen_self_static
5185238104Sdes	  fi
5186238104Sdes	  prefer_static_libs=yes
5187238104Sdes	  ;;
5188238104Sdes	-static)
5189238104Sdes	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
5190238104Sdes	    dlopen_self=$dlopen_self_static
5191238104Sdes	  fi
5192238104Sdes	  prefer_static_libs=built
5193238104Sdes	  ;;
5194238104Sdes	-static-libtool-libs)
5195238104Sdes	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
5196238104Sdes	    dlopen_self=$dlopen_self_static
5197238104Sdes	  fi
5198238104Sdes	  prefer_static_libs=yes
5199238104Sdes	  ;;
5200238104Sdes	esac
5201238104Sdes	build_libtool_libs=no
5202238104Sdes	build_old_libs=yes
5203238104Sdes	break
5204238104Sdes	;;
5205238104Sdes      esac
5206238104Sdes    done
5207238104Sdes
5208238104Sdes    # See if our shared archives depend on static archives.
5209238104Sdes    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
5210238104Sdes
5211238104Sdes    # Go through the arguments, transforming them on the way.
5212238104Sdes    while test "$#" -gt 0; do
5213238104Sdes      arg="$1"
5214238104Sdes      shift
5215238104Sdes      func_quote_for_eval "$arg"
5216238104Sdes      qarg=$func_quote_for_eval_unquoted_result
5217238104Sdes      func_append libtool_args " $func_quote_for_eval_result"
5218238104Sdes
5219238104Sdes      # If the previous option needs an argument, assign it.
5220238104Sdes      if test -n "$prev"; then
5221238104Sdes	case $prev in
5222238104Sdes	output)
5223238104Sdes	  func_append compile_command " @OUTPUT@"
5224238104Sdes	  func_append finalize_command " @OUTPUT@"
5225238104Sdes	  ;;
5226238104Sdes	esac
5227238104Sdes
5228238104Sdes	case $prev in
5229238104Sdes	bindir)
5230238104Sdes	  bindir="$arg"
5231238104Sdes	  prev=
5232238104Sdes	  continue
5233238104Sdes	  ;;
5234238104Sdes	dlfiles|dlprefiles)
5235238104Sdes	  if test "$preload" = no; then
5236238104Sdes	    # Add the symbol object into the linking commands.
5237238104Sdes	    func_append compile_command " @SYMFILE@"
5238238104Sdes	    func_append finalize_command " @SYMFILE@"
5239238104Sdes	    preload=yes
5240238104Sdes	  fi
5241238104Sdes	  case $arg in
5242238104Sdes	  *.la | *.lo) ;;  # We handle these cases below.
5243238104Sdes	  force)
5244238104Sdes	    if test "$dlself" = no; then
5245238104Sdes	      dlself=needless
5246238104Sdes	      export_dynamic=yes
5247238104Sdes	    fi
5248238104Sdes	    prev=
5249238104Sdes	    continue
5250238104Sdes	    ;;
5251238104Sdes	  self)
5252238104Sdes	    if test "$prev" = dlprefiles; then
5253238104Sdes	      dlself=yes
5254238104Sdes	    elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
5255238104Sdes	      dlself=yes
5256238104Sdes	    else
5257238104Sdes	      dlself=needless
5258238104Sdes	      export_dynamic=yes
5259238104Sdes	    fi
5260238104Sdes	    prev=
5261238104Sdes	    continue
5262238104Sdes	    ;;
5263238104Sdes	  *)
5264238104Sdes	    if test "$prev" = dlfiles; then
5265238104Sdes	      func_append dlfiles " $arg"
5266238104Sdes	    else
5267238104Sdes	      func_append dlprefiles " $arg"
5268238104Sdes	    fi
5269238104Sdes	    prev=
5270238104Sdes	    continue
5271238104Sdes	    ;;
5272238104Sdes	  esac
5273238104Sdes	  ;;
5274238104Sdes	expsyms)
5275238104Sdes	  export_symbols="$arg"
5276238104Sdes	  test -f "$arg" \
5277238104Sdes	    || func_fatal_error "symbol file \`$arg' does not exist"
5278238104Sdes	  prev=
5279238104Sdes	  continue
5280238104Sdes	  ;;
5281238104Sdes	expsyms_regex)
5282238104Sdes	  export_symbols_regex="$arg"
5283238104Sdes	  prev=
5284238104Sdes	  continue
5285238104Sdes	  ;;
5286238104Sdes	framework)
5287238104Sdes	  case $host in
5288238104Sdes	    *-*-darwin*)
5289238104Sdes	      case "$deplibs " in
5290238104Sdes		*" $qarg.ltframework "*) ;;
5291238104Sdes		*) func_append deplibs " $qarg.ltframework" # this is fixed later
5292238104Sdes		   ;;
5293238104Sdes	      esac
5294238104Sdes	      ;;
5295238104Sdes	  esac
5296238104Sdes	  prev=
5297238104Sdes	  continue
5298238104Sdes	  ;;
5299238104Sdes	inst_prefix)
5300238104Sdes	  inst_prefix_dir="$arg"
5301238104Sdes	  prev=
5302238104Sdes	  continue
5303238104Sdes	  ;;
5304238104Sdes	objectlist)
5305238104Sdes	  if test -f "$arg"; then
5306238104Sdes	    save_arg=$arg
5307238104Sdes	    moreargs=
5308238104Sdes	    for fil in `cat "$save_arg"`
5309238104Sdes	    do
5310238104Sdes#	      func_append moreargs " $fil"
5311238104Sdes	      arg=$fil
5312238104Sdes	      # A libtool-controlled object.
5313238104Sdes
5314238104Sdes	      # Check to see that this really is a libtool object.
5315238104Sdes	      if func_lalib_unsafe_p "$arg"; then
5316238104Sdes		pic_object=
5317238104Sdes		non_pic_object=
5318238104Sdes
5319238104Sdes		# Read the .lo file
5320238104Sdes		func_source "$arg"
5321238104Sdes
5322238104Sdes		if test -z "$pic_object" ||
5323238104Sdes		   test -z "$non_pic_object" ||
5324238104Sdes		   test "$pic_object" = none &&
5325238104Sdes		   test "$non_pic_object" = none; then
5326238104Sdes		  func_fatal_error "cannot find name of object for \`$arg'"
5327238104Sdes		fi
5328238104Sdes
5329238104Sdes		# Extract subdirectory from the argument.
5330238104Sdes		func_dirname "$arg" "/" ""
5331238104Sdes		xdir="$func_dirname_result"
5332238104Sdes
5333238104Sdes		if test "$pic_object" != none; then
5334238104Sdes		  # Prepend the subdirectory the object is found in.
5335238104Sdes		  pic_object="$xdir$pic_object"
5336238104Sdes
5337238104Sdes		  if test "$prev" = dlfiles; then
5338238104Sdes		    if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
5339238104Sdes		      func_append dlfiles " $pic_object"
5340238104Sdes		      prev=
5341238104Sdes		      continue
5342238104Sdes		    else
5343238104Sdes		      # If libtool objects are unsupported, then we need to preload.
5344238104Sdes		      prev=dlprefiles
5345238104Sdes		    fi
5346238104Sdes		  fi
5347238104Sdes
5348238104Sdes		  # CHECK ME:  I think I busted this.  -Ossama
5349238104Sdes		  if test "$prev" = dlprefiles; then
5350238104Sdes		    # Preload the old-style object.
5351238104Sdes		    func_append dlprefiles " $pic_object"
5352238104Sdes		    prev=
5353238104Sdes		  fi
5354238104Sdes
5355238104Sdes		  # A PIC object.
5356238104Sdes		  func_append libobjs " $pic_object"
5357238104Sdes		  arg="$pic_object"
5358238104Sdes		fi
5359238104Sdes
5360238104Sdes		# Non-PIC object.
5361238104Sdes		if test "$non_pic_object" != none; then
5362238104Sdes		  # Prepend the subdirectory the object is found in.
5363238104Sdes		  non_pic_object="$xdir$non_pic_object"
5364238104Sdes
5365238104Sdes		  # A standard non-PIC object
5366238104Sdes		  func_append non_pic_objects " $non_pic_object"
5367238104Sdes		  if test -z "$pic_object" || test "$pic_object" = none ; then
5368238104Sdes		    arg="$non_pic_object"
5369238104Sdes		  fi
5370238104Sdes		else
5371238104Sdes		  # If the PIC object exists, use it instead.
5372238104Sdes		  # $xdir was prepended to $pic_object above.
5373238104Sdes		  non_pic_object="$pic_object"
5374238104Sdes		  func_append non_pic_objects " $non_pic_object"
5375238104Sdes		fi
5376238104Sdes	      else
5377238104Sdes		# Only an error if not doing a dry-run.
5378238104Sdes		if $opt_dry_run; then
5379238104Sdes		  # Extract subdirectory from the argument.
5380238104Sdes		  func_dirname "$arg" "/" ""
5381238104Sdes		  xdir="$func_dirname_result"
5382238104Sdes
5383238104Sdes		  func_lo2o "$arg"
5384238104Sdes		  pic_object=$xdir$objdir/$func_lo2o_result
5385238104Sdes		  non_pic_object=$xdir$func_lo2o_result
5386238104Sdes		  func_append libobjs " $pic_object"
5387238104Sdes		  func_append non_pic_objects " $non_pic_object"
5388238104Sdes	        else
5389238104Sdes		  func_fatal_error "\`$arg' is not a valid libtool object"
5390238104Sdes		fi
5391238104Sdes	      fi
5392238104Sdes	    done
5393238104Sdes	  else
5394238104Sdes	    func_fatal_error "link input file \`$arg' does not exist"
5395238104Sdes	  fi
5396238104Sdes	  arg=$save_arg
5397238104Sdes	  prev=
5398238104Sdes	  continue
5399238104Sdes	  ;;
5400238104Sdes	precious_regex)
5401238104Sdes	  precious_files_regex="$arg"
5402238104Sdes	  prev=
5403238104Sdes	  continue
5404238104Sdes	  ;;
5405238104Sdes	release)
5406238104Sdes	  release="-$arg"
5407238104Sdes	  prev=
5408238104Sdes	  continue
5409238104Sdes	  ;;
5410238104Sdes	rpath | xrpath)
5411238104Sdes	  # We need an absolute path.
5412238104Sdes	  case $arg in
5413238104Sdes	  [\\/]* | [A-Za-z]:[\\/]*) ;;
5414238104Sdes	  *)
5415238104Sdes	    func_fatal_error "only absolute run-paths are allowed"
5416238104Sdes	    ;;
5417238104Sdes	  esac
5418238104Sdes	  if test "$prev" = rpath; then
5419238104Sdes	    case "$rpath " in
5420238104Sdes	    *" $arg "*) ;;
5421238104Sdes	    *) func_append rpath " $arg" ;;
5422238104Sdes	    esac
5423238104Sdes	  else
5424238104Sdes	    case "$xrpath " in
5425238104Sdes	    *" $arg "*) ;;
5426238104Sdes	    *) func_append xrpath " $arg" ;;
5427238104Sdes	    esac
5428238104Sdes	  fi
5429238104Sdes	  prev=
5430238104Sdes	  continue
5431238104Sdes	  ;;
5432238104Sdes	shrext)
5433238104Sdes	  shrext_cmds="$arg"
5434238104Sdes	  prev=
5435238104Sdes	  continue
5436238104Sdes	  ;;
5437238104Sdes	weak)
5438238104Sdes	  func_append weak_libs " $arg"
5439238104Sdes	  prev=
5440238104Sdes	  continue
5441238104Sdes	  ;;
5442238104Sdes	xcclinker)
5443238104Sdes	  func_append linker_flags " $qarg"
5444238104Sdes	  func_append compiler_flags " $qarg"
5445238104Sdes	  prev=
5446238104Sdes	  func_append compile_command " $qarg"
5447238104Sdes	  func_append finalize_command " $qarg"
5448238104Sdes	  continue
5449238104Sdes	  ;;
5450238104Sdes	xcompiler)
5451238104Sdes	  func_append compiler_flags " $qarg"
5452238104Sdes	  prev=
5453238104Sdes	  func_append compile_command " $qarg"
5454238104Sdes	  func_append finalize_command " $qarg"
5455238104Sdes	  continue
5456238104Sdes	  ;;
5457238104Sdes	xlinker)
5458238104Sdes	  func_append linker_flags " $qarg"
5459238104Sdes	  func_append compiler_flags " $wl$qarg"
5460238104Sdes	  prev=
5461238104Sdes	  func_append compile_command " $wl$qarg"
5462238104Sdes	  func_append finalize_command " $wl$qarg"
5463238104Sdes	  continue
5464238104Sdes	  ;;
5465238104Sdes	*)
5466238104Sdes	  eval "$prev=\"\$arg\""
5467238104Sdes	  prev=
5468238104Sdes	  continue
5469238104Sdes	  ;;
5470238104Sdes	esac
5471238104Sdes      fi # test -n "$prev"
5472238104Sdes
5473238104Sdes      prevarg="$arg"
5474238104Sdes
5475238104Sdes      case $arg in
5476238104Sdes      -all-static)
5477238104Sdes	if test -n "$link_static_flag"; then
5478238104Sdes	  # See comment for -static flag below, for more details.
5479238104Sdes	  func_append compile_command " $link_static_flag"
5480238104Sdes	  func_append finalize_command " $link_static_flag"
5481238104Sdes	fi
5482238104Sdes	continue
5483238104Sdes	;;
5484238104Sdes
5485238104Sdes      -allow-undefined)
5486238104Sdes	# FIXME: remove this flag sometime in the future.
5487238104Sdes	func_fatal_error "\`-allow-undefined' must not be used because it is the default"
5488238104Sdes	;;
5489238104Sdes
5490238104Sdes      -avoid-version)
5491238104Sdes	avoid_version=yes
5492238104Sdes	continue
5493238104Sdes	;;
5494238104Sdes
5495238104Sdes      -bindir)
5496238104Sdes	prev=bindir
5497238104Sdes	continue
5498238104Sdes	;;
5499238104Sdes
5500238104Sdes      -dlopen)
5501238104Sdes	prev=dlfiles
5502238104Sdes	continue
5503238104Sdes	;;
5504238104Sdes
5505238104Sdes      -dlpreopen)
5506238104Sdes	prev=dlprefiles
5507238104Sdes	continue
5508238104Sdes	;;
5509238104Sdes
5510238104Sdes      -export-dynamic)
5511238104Sdes	export_dynamic=yes
5512238104Sdes	continue
5513238104Sdes	;;
5514238104Sdes
5515238104Sdes      -export-symbols | -export-symbols-regex)
5516238104Sdes	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
5517238104Sdes	  func_fatal_error "more than one -exported-symbols argument is not allowed"
5518238104Sdes	fi
5519238104Sdes	if test "X$arg" = "X-export-symbols"; then
5520238104Sdes	  prev=expsyms
5521238104Sdes	else
5522238104Sdes	  prev=expsyms_regex
5523238104Sdes	fi
5524238104Sdes	continue
5525238104Sdes	;;
5526238104Sdes
5527238104Sdes      -framework)
5528238104Sdes	prev=framework
5529238104Sdes	continue
5530238104Sdes	;;
5531238104Sdes
5532238104Sdes      -inst-prefix-dir)
5533238104Sdes	prev=inst_prefix
5534238104Sdes	continue
5535238104Sdes	;;
5536238104Sdes
5537238104Sdes      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
5538238104Sdes      # so, if we see these flags be careful not to treat them like -L
5539238104Sdes      -L[A-Z][A-Z]*:*)
5540238104Sdes	case $with_gcc/$host in
5541238104Sdes	no/*-*-irix* | /*-*-irix*)
5542238104Sdes	  func_append compile_command " $arg"
5543238104Sdes	  func_append finalize_command " $arg"
5544238104Sdes	  ;;
5545238104Sdes	esac
5546238104Sdes	continue
5547238104Sdes	;;
5548238104Sdes
5549238104Sdes      -L*)
5550238104Sdes	func_stripname "-L" '' "$arg"
5551238104Sdes	if test -z "$func_stripname_result"; then
5552238104Sdes	  if test "$#" -gt 0; then
5553238104Sdes	    func_fatal_error "require no space between \`-L' and \`$1'"
5554238104Sdes	  else
5555238104Sdes	    func_fatal_error "need path for \`-L' option"
5556238104Sdes	  fi
5557238104Sdes	fi
5558238104Sdes	func_resolve_sysroot "$func_stripname_result"
5559238104Sdes	dir=$func_resolve_sysroot_result
5560238104Sdes	# We need an absolute path.
5561238104Sdes	case $dir in
5562238104Sdes	[\\/]* | [A-Za-z]:[\\/]*) ;;
5563238104Sdes	*)
5564238104Sdes	  absdir=`cd "$dir" && pwd`
5565238104Sdes	  test -z "$absdir" && \
5566238104Sdes	    func_fatal_error "cannot determine absolute directory name of \`$dir'"
5567238104Sdes	  dir="$absdir"
5568238104Sdes	  ;;
5569238104Sdes	esac
5570238104Sdes	case "$deplibs " in
5571238104Sdes	*" -L$dir "* | *" $arg "*)
5572238104Sdes	  # Will only happen for absolute or sysroot arguments
5573238104Sdes	  ;;
5574238104Sdes	*)
5575238104Sdes	  # Preserve sysroot, but never include relative directories
5576238104Sdes	  case $dir in
5577238104Sdes	    [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;;
5578238104Sdes	    *) func_append deplibs " -L$dir" ;;
5579238104Sdes	  esac
5580238104Sdes	  func_append lib_search_path " $dir"
5581238104Sdes	  ;;
5582238104Sdes	esac
5583238104Sdes	case $host in
5584238104Sdes	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
5585238104Sdes	  testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
5586238104Sdes	  case :$dllsearchpath: in
5587238104Sdes	  *":$dir:"*) ;;
5588238104Sdes	  ::) dllsearchpath=$dir;;
5589238104Sdes	  *) func_append dllsearchpath ":$dir";;
5590238104Sdes	  esac
5591238104Sdes	  case :$dllsearchpath: in
5592238104Sdes	  *":$testbindir:"*) ;;
5593238104Sdes	  ::) dllsearchpath=$testbindir;;
5594238104Sdes	  *) func_append dllsearchpath ":$testbindir";;
5595238104Sdes	  esac
5596238104Sdes	  ;;
5597238104Sdes	esac
5598238104Sdes	continue
5599238104Sdes	;;
5600238104Sdes
5601238104Sdes      -l*)
5602238104Sdes	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
5603238104Sdes	  case $host in
5604238104Sdes	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
5605238104Sdes	    # These systems don't actually have a C or math library (as such)
5606238104Sdes	    continue
5607238104Sdes	    ;;
5608238104Sdes	  *-*-os2*)
5609238104Sdes	    # These systems don't actually have a C library (as such)
5610238104Sdes	    test "X$arg" = "X-lc" && continue
5611238104Sdes	    ;;
5612238104Sdes	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
5613238104Sdes	    # Do not include libc due to us having libc/libc_r.
5614238104Sdes	    test "X$arg" = "X-lc" && continue
5615238104Sdes	    ;;
5616238104Sdes	  *-*-rhapsody* | *-*-darwin1.[012])
5617238104Sdes	    # Rhapsody C and math libraries are in the System framework
5618238104Sdes	    func_append deplibs " System.ltframework"
5619238104Sdes	    continue
5620238104Sdes	    ;;
5621238104Sdes	  *-*-sco3.2v5* | *-*-sco5v6*)
5622238104Sdes	    # Causes problems with __ctype
5623238104Sdes	    test "X$arg" = "X-lc" && continue
5624238104Sdes	    ;;
5625238104Sdes	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
5626238104Sdes	    # Compiler inserts libc in the correct place for threads to work
5627238104Sdes	    test "X$arg" = "X-lc" && continue
5628238104Sdes	    ;;
5629238104Sdes	  esac
5630238104Sdes	elif test "X$arg" = "X-lc_r"; then
5631238104Sdes	 case $host in
5632238104Sdes	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
5633238104Sdes	   # Do not include libc_r directly, use -pthread flag.
5634238104Sdes	   continue
5635238104Sdes	   ;;
5636238104Sdes	 esac
5637238104Sdes	fi
5638238104Sdes	func_append deplibs " $arg"
5639238104Sdes	continue
5640238104Sdes	;;
5641238104Sdes
5642238104Sdes      -module)
5643238104Sdes	module=yes
5644238104Sdes	continue
5645238104Sdes	;;
5646238104Sdes
5647238104Sdes      # Tru64 UNIX uses -model [arg] to determine the layout of C++
5648238104Sdes      # classes, name mangling, and exception handling.
5649238104Sdes      # Darwin uses the -arch flag to determine output architecture.
5650238104Sdes      -model|-arch|-isysroot|--sysroot)
5651238104Sdes	func_append compiler_flags " $arg"
5652238104Sdes	func_append compile_command " $arg"
5653238104Sdes	func_append finalize_command " $arg"
5654238104Sdes	prev=xcompiler
5655238104Sdes	continue
5656238104Sdes	;;
5657238104Sdes
5658238104Sdes      -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
5659238104Sdes      |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
5660238104Sdes	func_append compiler_flags " $arg"
5661238104Sdes	func_append compile_command " $arg"
5662238104Sdes	func_append finalize_command " $arg"
5663238104Sdes	case "$new_inherited_linker_flags " in
5664238104Sdes	    *" $arg "*) ;;
5665238104Sdes	    * ) func_append new_inherited_linker_flags " $arg" ;;
5666238104Sdes	esac
5667238104Sdes	continue
5668238104Sdes	;;
5669238104Sdes
5670238104Sdes      -multi_module)
5671238104Sdes	single_module="${wl}-multi_module"
5672238104Sdes	continue
5673238104Sdes	;;
5674238104Sdes
5675238104Sdes      -no-fast-install)
5676238104Sdes	fast_install=no
5677238104Sdes	continue
5678238104Sdes	;;
5679238104Sdes
5680238104Sdes      -no-install)
5681238104Sdes	case $host in
5682238104Sdes	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
5683238104Sdes	  # The PATH hackery in wrapper scripts is required on Windows
5684238104Sdes	  # and Darwin in order for the loader to find any dlls it needs.
5685238104Sdes	  func_warning "\`-no-install' is ignored for $host"
5686238104Sdes	  func_warning "assuming \`-no-fast-install' instead"
5687238104Sdes	  fast_install=no
5688238104Sdes	  ;;
5689238104Sdes	*) no_install=yes ;;
5690238104Sdes	esac
5691238104Sdes	continue
5692238104Sdes	;;
5693238104Sdes
5694238104Sdes      -no-undefined)
5695238104Sdes	allow_undefined=no
5696238104Sdes	continue
5697238104Sdes	;;
5698238104Sdes
5699238104Sdes      -objectlist)
5700238104Sdes	prev=objectlist
5701238104Sdes	continue
5702238104Sdes	;;
5703238104Sdes
5704238104Sdes      -o) prev=output ;;
5705238104Sdes
5706238104Sdes      -precious-files-regex)
5707238104Sdes	prev=precious_regex
5708238104Sdes	continue
5709238104Sdes	;;
5710238104Sdes
5711238104Sdes      -release)
5712238104Sdes	prev=release
5713238104Sdes	continue
5714238104Sdes	;;
5715238104Sdes
5716238104Sdes      -rpath)
5717238104Sdes	prev=rpath
5718238104Sdes	continue
5719238104Sdes	;;
5720238104Sdes
5721238104Sdes      -R)
5722238104Sdes	prev=xrpath
5723238104Sdes	continue
5724238104Sdes	;;
5725238104Sdes
5726238104Sdes      -R*)
5727238104Sdes	func_stripname '-R' '' "$arg"
5728238104Sdes	dir=$func_stripname_result
5729238104Sdes	# We need an absolute path.
5730238104Sdes	case $dir in
5731238104Sdes	[\\/]* | [A-Za-z]:[\\/]*) ;;
5732238104Sdes	=*)
5733238104Sdes	  func_stripname '=' '' "$dir"
5734238104Sdes	  dir=$lt_sysroot$func_stripname_result
5735238104Sdes	  ;;
5736238104Sdes	*)
5737238104Sdes	  func_fatal_error "only absolute run-paths are allowed"
5738238104Sdes	  ;;
5739238104Sdes	esac
5740238104Sdes	case "$xrpath " in
5741238104Sdes	*" $dir "*) ;;
5742238104Sdes	*) func_append xrpath " $dir" ;;
5743238104Sdes	esac
5744238104Sdes	continue
5745238104Sdes	;;
5746238104Sdes
5747238104Sdes      -shared)
5748238104Sdes	# The effects of -shared are defined in a previous loop.
5749238104Sdes	continue
5750238104Sdes	;;
5751238104Sdes
5752238104Sdes      -shrext)
5753238104Sdes	prev=shrext
5754238104Sdes	continue
5755238104Sdes	;;
5756238104Sdes
5757238104Sdes      -static | -static-libtool-libs)
5758238104Sdes	# The effects of -static are defined in a previous loop.
5759238104Sdes	# We used to do the same as -all-static on platforms that
5760238104Sdes	# didn't have a PIC flag, but the assumption that the effects
5761238104Sdes	# would be equivalent was wrong.  It would break on at least
5762238104Sdes	# Digital Unix and AIX.
5763238104Sdes	continue
5764238104Sdes	;;
5765238104Sdes
5766238104Sdes      -thread-safe)
5767238104Sdes	thread_safe=yes
5768238104Sdes	continue
5769238104Sdes	;;
5770238104Sdes
5771238104Sdes      -version-info)
5772238104Sdes	prev=vinfo
5773238104Sdes	continue
5774238104Sdes	;;
5775238104Sdes
5776238104Sdes      -version-number)
5777238104Sdes	prev=vinfo
5778238104Sdes	vinfo_number=yes
5779238104Sdes	continue
5780238104Sdes	;;
5781238104Sdes
5782238104Sdes      -weak)
5783238104Sdes        prev=weak
5784238104Sdes	continue
5785238104Sdes	;;
5786238104Sdes
5787238104Sdes      -Wc,*)
5788238104Sdes	func_stripname '-Wc,' '' "$arg"
5789238104Sdes	args=$func_stripname_result
5790238104Sdes	arg=
5791238104Sdes	save_ifs="$IFS"; IFS=','
5792238104Sdes	for flag in $args; do
5793238104Sdes	  IFS="$save_ifs"
5794238104Sdes          func_quote_for_eval "$flag"
5795238104Sdes	  func_append arg " $func_quote_for_eval_result"
5796238104Sdes	  func_append compiler_flags " $func_quote_for_eval_result"
5797238104Sdes	done
5798238104Sdes	IFS="$save_ifs"
5799238104Sdes	func_stripname ' ' '' "$arg"
5800238104Sdes	arg=$func_stripname_result
5801238104Sdes	;;
5802238104Sdes
5803238104Sdes      -Wl,*)
5804238104Sdes	func_stripname '-Wl,' '' "$arg"
5805238104Sdes	args=$func_stripname_result
5806238104Sdes	arg=
5807238104Sdes	save_ifs="$IFS"; IFS=','
5808238104Sdes	for flag in $args; do
5809238104Sdes	  IFS="$save_ifs"
5810238104Sdes          func_quote_for_eval "$flag"
5811238104Sdes	  func_append arg " $wl$func_quote_for_eval_result"
5812238104Sdes	  func_append compiler_flags " $wl$func_quote_for_eval_result"
5813238104Sdes	  func_append linker_flags " $func_quote_for_eval_result"
5814238104Sdes	done
5815238104Sdes	IFS="$save_ifs"
5816238104Sdes	func_stripname ' ' '' "$arg"
5817238104Sdes	arg=$func_stripname_result
5818238104Sdes	;;
5819238104Sdes
5820238104Sdes      -Xcompiler)
5821238104Sdes	prev=xcompiler
5822238104Sdes	continue
5823238104Sdes	;;
5824238104Sdes
5825238104Sdes      -Xlinker)
5826238104Sdes	prev=xlinker
5827238104Sdes	continue
5828238104Sdes	;;
5829238104Sdes
5830238104Sdes      -XCClinker)
5831238104Sdes	prev=xcclinker
5832238104Sdes	continue
5833238104Sdes	;;
5834238104Sdes
5835238104Sdes      # -msg_* for osf cc
5836238104Sdes      -msg_*)
5837238104Sdes	func_quote_for_eval "$arg"
5838238104Sdes	arg="$func_quote_for_eval_result"
5839238104Sdes	;;
5840238104Sdes
5841238104Sdes      # Flags to be passed through unchanged, with rationale:
5842238104Sdes      # -64, -mips[0-9]      enable 64-bit mode for the SGI compiler
5843238104Sdes      # -r[0-9][0-9]*        specify processor for the SGI compiler
5844238104Sdes      # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler
5845238104Sdes      # +DA*, +DD*           enable 64-bit mode for the HP compiler
5846238104Sdes      # -q*                  compiler args for the IBM compiler
5847238104Sdes      # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
5848238104Sdes      # -F/path              path to uninstalled frameworks, gcc on darwin
5849238104Sdes      # -p, -pg, --coverage, -fprofile-*  profiling flags for GCC
5850238104Sdes      # @file                GCC response files
5851238104Sdes      # -tp=*                Portland pgcc target processor selection
5852238104Sdes      # --sysroot=*          for sysroot support
5853238104Sdes      # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
5854238104Sdes      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
5855238104Sdes      -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
5856238104Sdes      -O*|-flto*|-fwhopr*|-fuse-linker-plugin)
5857238104Sdes        func_quote_for_eval "$arg"
5858238104Sdes	arg="$func_quote_for_eval_result"
5859238104Sdes        func_append compile_command " $arg"
5860238104Sdes        func_append finalize_command " $arg"
5861238104Sdes        func_append compiler_flags " $arg"
5862238104Sdes        continue
5863238104Sdes        ;;
5864238104Sdes
5865238104Sdes      # Some other compiler flag.
5866238104Sdes      -* | +*)
5867238104Sdes        func_quote_for_eval "$arg"
5868238104Sdes	arg="$func_quote_for_eval_result"
5869238104Sdes	;;
5870238104Sdes
5871238104Sdes      *.$objext)
5872238104Sdes	# A standard object.
5873238104Sdes	func_append objs " $arg"
5874238104Sdes	;;
5875238104Sdes
5876238104Sdes      *.lo)
5877238104Sdes	# A libtool-controlled object.
5878238104Sdes
5879238104Sdes	# Check to see that this really is a libtool object.
5880238104Sdes	if func_lalib_unsafe_p "$arg"; then
5881238104Sdes	  pic_object=
5882238104Sdes	  non_pic_object=
5883238104Sdes
5884238104Sdes	  # Read the .lo file
5885238104Sdes	  func_source "$arg"
5886238104Sdes
5887238104Sdes	  if test -z "$pic_object" ||
5888238104Sdes	     test -z "$non_pic_object" ||
5889238104Sdes	     test "$pic_object" = none &&
5890238104Sdes	     test "$non_pic_object" = none; then
5891238104Sdes	    func_fatal_error "cannot find name of object for \`$arg'"
5892238104Sdes	  fi
5893238104Sdes
5894238104Sdes	  # Extract subdirectory from the argument.
5895238104Sdes	  func_dirname "$arg" "/" ""
5896238104Sdes	  xdir="$func_dirname_result"
5897238104Sdes
5898238104Sdes	  if test "$pic_object" != none; then
5899238104Sdes	    # Prepend the subdirectory the object is found in.
5900238104Sdes	    pic_object="$xdir$pic_object"
5901238104Sdes
5902238104Sdes	    if test "$prev" = dlfiles; then
5903238104Sdes	      if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
5904238104Sdes		func_append dlfiles " $pic_object"
5905238104Sdes		prev=
5906238104Sdes		continue
5907238104Sdes	      else
5908238104Sdes		# If libtool objects are unsupported, then we need to preload.
5909238104Sdes		prev=dlprefiles
5910238104Sdes	      fi
5911238104Sdes	    fi
5912238104Sdes
5913238104Sdes	    # CHECK ME:  I think I busted this.  -Ossama
5914238104Sdes	    if test "$prev" = dlprefiles; then
5915238104Sdes	      # Preload the old-style object.
5916238104Sdes	      func_append dlprefiles " $pic_object"
5917238104Sdes	      prev=
5918238104Sdes	    fi
5919238104Sdes
5920238104Sdes	    # A PIC object.
5921238104Sdes	    func_append libobjs " $pic_object"
5922238104Sdes	    arg="$pic_object"
5923238104Sdes	  fi
5924238104Sdes
5925238104Sdes	  # Non-PIC object.
5926238104Sdes	  if test "$non_pic_object" != none; then
5927238104Sdes	    # Prepend the subdirectory the object is found in.
5928238104Sdes	    non_pic_object="$xdir$non_pic_object"
5929238104Sdes
5930238104Sdes	    # A standard non-PIC object
5931238104Sdes	    func_append non_pic_objects " $non_pic_object"
5932238104Sdes	    if test -z "$pic_object" || test "$pic_object" = none ; then
5933238104Sdes	      arg="$non_pic_object"
5934238104Sdes	    fi
5935238104Sdes	  else
5936238104Sdes	    # If the PIC object exists, use it instead.
5937238104Sdes	    # $xdir was prepended to $pic_object above.
5938238104Sdes	    non_pic_object="$pic_object"
5939238104Sdes	    func_append non_pic_objects " $non_pic_object"
5940238104Sdes	  fi
5941238104Sdes	else
5942238104Sdes	  # Only an error if not doing a dry-run.
5943238104Sdes	  if $opt_dry_run; then
5944238104Sdes	    # Extract subdirectory from the argument.
5945238104Sdes	    func_dirname "$arg" "/" ""
5946238104Sdes	    xdir="$func_dirname_result"
5947238104Sdes
5948238104Sdes	    func_lo2o "$arg"
5949238104Sdes	    pic_object=$xdir$objdir/$func_lo2o_result
5950238104Sdes	    non_pic_object=$xdir$func_lo2o_result
5951238104Sdes	    func_append libobjs " $pic_object"
5952238104Sdes	    func_append non_pic_objects " $non_pic_object"
5953238104Sdes	  else
5954238104Sdes	    func_fatal_error "\`$arg' is not a valid libtool object"
5955238104Sdes	  fi
5956238104Sdes	fi
5957238104Sdes	;;
5958238104Sdes
5959238104Sdes      *.$libext)
5960238104Sdes	# An archive.
5961238104Sdes	func_append deplibs " $arg"
5962238104Sdes	func_append old_deplibs " $arg"
5963238104Sdes	continue
5964238104Sdes	;;
5965238104Sdes
5966238104Sdes      *.la)
5967238104Sdes	# A libtool-controlled library.
5968238104Sdes
5969238104Sdes	func_resolve_sysroot "$arg"
5970238104Sdes	if test "$prev" = dlfiles; then
5971238104Sdes	  # This library was specified with -dlopen.
5972238104Sdes	  func_append dlfiles " $func_resolve_sysroot_result"
5973238104Sdes	  prev=
5974238104Sdes	elif test "$prev" = dlprefiles; then
5975238104Sdes	  # The library was specified with -dlpreopen.
5976238104Sdes	  func_append dlprefiles " $func_resolve_sysroot_result"
5977238104Sdes	  prev=
5978238104Sdes	else
5979238104Sdes	  func_append deplibs " $func_resolve_sysroot_result"
5980238104Sdes	fi
5981238104Sdes	continue
5982238104Sdes	;;
5983238104Sdes
5984238104Sdes      # Some other compiler argument.
5985238104Sdes      *)
5986238104Sdes	# Unknown arguments in both finalize_command and compile_command need
5987238104Sdes	# to be aesthetically quoted because they are evaled later.
5988238104Sdes	func_quote_for_eval "$arg"
5989238104Sdes	arg="$func_quote_for_eval_result"
5990238104Sdes	;;
5991238104Sdes      esac # arg
5992238104Sdes
5993238104Sdes      # Now actually substitute the argument into the commands.
5994238104Sdes      if test -n "$arg"; then
5995238104Sdes	func_append compile_command " $arg"
5996238104Sdes	func_append finalize_command " $arg"
5997238104Sdes      fi
5998238104Sdes    done # argument parsing loop
5999238104Sdes
6000238104Sdes    test -n "$prev" && \
6001238104Sdes      func_fatal_help "the \`$prevarg' option requires an argument"
6002238104Sdes
6003238104Sdes    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
6004238104Sdes      eval arg=\"$export_dynamic_flag_spec\"
6005238104Sdes      func_append compile_command " $arg"
6006238104Sdes      func_append finalize_command " $arg"
6007238104Sdes    fi
6008238104Sdes
6009238104Sdes    oldlibs=
6010238104Sdes    # calculate the name of the file, without its directory
6011238104Sdes    func_basename "$output"
6012238104Sdes    outputname="$func_basename_result"
6013238104Sdes    libobjs_save="$libobjs"
6014238104Sdes
6015238104Sdes    if test -n "$shlibpath_var"; then
6016238104Sdes      # get the directories listed in $shlibpath_var
6017238104Sdes      eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\`
6018238104Sdes    else
6019238104Sdes      shlib_search_path=
6020238104Sdes    fi
6021238104Sdes    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
6022238104Sdes    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
6023238104Sdes
6024238104Sdes    func_dirname "$output" "/" ""
6025238104Sdes    output_objdir="$func_dirname_result$objdir"
6026238104Sdes    func_to_tool_file "$output_objdir/"
6027238104Sdes    tool_output_objdir=$func_to_tool_file_result
6028238104Sdes    # Create the object directory.
6029238104Sdes    func_mkdir_p "$output_objdir"
6030238104Sdes
6031238104Sdes    # Determine the type of output
6032238104Sdes    case $output in
6033238104Sdes    "")
6034238104Sdes      func_fatal_help "you must specify an output file"
6035238104Sdes      ;;
6036238104Sdes    *.$libext) linkmode=oldlib ;;
6037238104Sdes    *.lo | *.$objext) linkmode=obj ;;
6038238104Sdes    *.la) linkmode=lib ;;
6039238104Sdes    *) linkmode=prog ;; # Anything else should be a program.
6040238104Sdes    esac
6041238104Sdes
6042238104Sdes    specialdeplibs=
6043238104Sdes
6044238104Sdes    libs=
6045238104Sdes    # Find all interdependent deplibs by searching for libraries
6046238104Sdes    # that are linked more than once (e.g. -la -lb -la)
6047238104Sdes    for deplib in $deplibs; do
6048238104Sdes      if $opt_preserve_dup_deps ; then
6049238104Sdes	case "$libs " in
6050238104Sdes	*" $deplib "*) func_append specialdeplibs " $deplib" ;;
6051238104Sdes	esac
6052238104Sdes      fi
6053238104Sdes      func_append libs " $deplib"
6054238104Sdes    done
6055238104Sdes
6056238104Sdes    if test "$linkmode" = lib; then
6057238104Sdes      libs="$predeps $libs $compiler_lib_search_path $postdeps"
6058238104Sdes
6059238104Sdes      # Compute libraries that are listed more than once in $predeps
6060238104Sdes      # $postdeps and mark them as special (i.e., whose duplicates are
6061238104Sdes      # not to be eliminated).
6062238104Sdes      pre_post_deps=
6063238104Sdes      if $opt_duplicate_compiler_generated_deps; then
6064238104Sdes	for pre_post_dep in $predeps $postdeps; do
6065238104Sdes	  case "$pre_post_deps " in
6066238104Sdes	  *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;;
6067238104Sdes	  esac
6068238104Sdes	  func_append pre_post_deps " $pre_post_dep"
6069238104Sdes	done
6070238104Sdes      fi
6071238104Sdes      pre_post_deps=
6072238104Sdes    fi
6073238104Sdes
6074238104Sdes    deplibs=
6075238104Sdes    newdependency_libs=
6076238104Sdes    newlib_search_path=
6077238104Sdes    need_relink=no # whether we're linking any uninstalled libtool libraries
6078238104Sdes    notinst_deplibs= # not-installed libtool libraries
6079238104Sdes    notinst_path= # paths that contain not-installed libtool libraries
6080238104Sdes
6081238104Sdes    case $linkmode in
6082238104Sdes    lib)
6083238104Sdes	passes="conv dlpreopen link"
6084238104Sdes	for file in $dlfiles $dlprefiles; do
6085238104Sdes	  case $file in
6086238104Sdes	  *.la) ;;
6087238104Sdes	  *)
6088238104Sdes	    func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file"
6089238104Sdes	    ;;
6090238104Sdes	  esac
6091238104Sdes	done
6092238104Sdes	;;
6093238104Sdes    prog)
6094238104Sdes	compile_deplibs=
6095238104Sdes	finalize_deplibs=
6096238104Sdes	alldeplibs=no
6097238104Sdes	newdlfiles=
6098238104Sdes	newdlprefiles=
6099238104Sdes	passes="conv scan dlopen dlpreopen link"
6100238104Sdes	;;
6101238104Sdes    *)  passes="conv"
6102238104Sdes	;;
6103238104Sdes    esac
6104238104Sdes
6105238104Sdes    for pass in $passes; do
6106238104Sdes      # The preopen pass in lib mode reverses $deplibs; put it back here
6107238104Sdes      # so that -L comes before libs that need it for instance...
6108238104Sdes      if test "$linkmode,$pass" = "lib,link"; then
6109238104Sdes	## FIXME: Find the place where the list is rebuilt in the wrong
6110238104Sdes	##        order, and fix it there properly
6111238104Sdes        tmp_deplibs=
6112238104Sdes	for deplib in $deplibs; do
6113238104Sdes	  tmp_deplibs="$deplib $tmp_deplibs"
6114238104Sdes	done
6115238104Sdes	deplibs="$tmp_deplibs"
6116238104Sdes      fi
6117238104Sdes
6118238104Sdes      if test "$linkmode,$pass" = "lib,link" ||
6119238104Sdes	 test "$linkmode,$pass" = "prog,scan"; then
6120238104Sdes	libs="$deplibs"
6121238104Sdes	deplibs=
6122238104Sdes      fi
6123238104Sdes      if test "$linkmode" = prog; then
6124238104Sdes	case $pass in
6125238104Sdes	dlopen) libs="$dlfiles" ;;
6126238104Sdes	dlpreopen) libs="$dlprefiles" ;;
6127238104Sdes	link)
6128238104Sdes	  libs="$deplibs %DEPLIBS%"
6129238104Sdes	  test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs"
6130238104Sdes	  ;;
6131238104Sdes	esac
6132238104Sdes      fi
6133238104Sdes      if test "$linkmode,$pass" = "lib,dlpreopen"; then
6134238104Sdes	# Collect and forward deplibs of preopened libtool libs
6135238104Sdes	for lib in $dlprefiles; do
6136238104Sdes	  # Ignore non-libtool-libs
6137238104Sdes	  dependency_libs=
6138238104Sdes	  func_resolve_sysroot "$lib"
6139238104Sdes	  case $lib in
6140238104Sdes	  *.la)	func_source "$func_resolve_sysroot_result" ;;
6141238104Sdes	  esac
6142238104Sdes
6143238104Sdes	  # Collect preopened libtool deplibs, except any this library
6144238104Sdes	  # has declared as weak libs
6145238104Sdes	  for deplib in $dependency_libs; do
6146238104Sdes	    func_basename "$deplib"
6147238104Sdes            deplib_base=$func_basename_result
6148238104Sdes	    case " $weak_libs " in
6149238104Sdes	    *" $deplib_base "*) ;;
6150238104Sdes	    *) func_append deplibs " $deplib" ;;
6151238104Sdes	    esac
6152238104Sdes	  done
6153238104Sdes	done
6154238104Sdes	libs="$dlprefiles"
6155238104Sdes      fi
6156238104Sdes      if test "$pass" = dlopen; then
6157238104Sdes	# Collect dlpreopened libraries
6158238104Sdes	save_deplibs="$deplibs"
6159238104Sdes	deplibs=
6160238104Sdes      fi
6161238104Sdes
6162238104Sdes      for deplib in $libs; do
6163238104Sdes	lib=
6164238104Sdes	found=no
6165238104Sdes	case $deplib in
6166238104Sdes	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
6167238104Sdes        |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
6168238104Sdes	  if test "$linkmode,$pass" = "prog,link"; then
6169238104Sdes	    compile_deplibs="$deplib $compile_deplibs"
6170238104Sdes	    finalize_deplibs="$deplib $finalize_deplibs"
6171238104Sdes	  else
6172238104Sdes	    func_append compiler_flags " $deplib"
6173238104Sdes	    if test "$linkmode" = lib ; then
6174238104Sdes		case "$new_inherited_linker_flags " in
6175238104Sdes		    *" $deplib "*) ;;
6176238104Sdes		    * ) func_append new_inherited_linker_flags " $deplib" ;;
6177238104Sdes		esac
6178238104Sdes	    fi
6179238104Sdes	  fi
6180238104Sdes	  continue
6181238104Sdes	  ;;
6182238104Sdes	-l*)
6183238104Sdes	  if test "$linkmode" != lib && test "$linkmode" != prog; then
6184238104Sdes	    func_warning "\`-l' is ignored for archives/objects"
6185238104Sdes	    continue
6186238104Sdes	  fi
6187238104Sdes	  func_stripname '-l' '' "$deplib"
6188238104Sdes	  name=$func_stripname_result
6189238104Sdes	  if test "$linkmode" = lib; then
6190238104Sdes	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
6191238104Sdes	  else
6192238104Sdes	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
6193238104Sdes	  fi
6194238104Sdes	  for searchdir in $searchdirs; do
6195238104Sdes	    for search_ext in .la $std_shrext .so .a; do
6196238104Sdes	      # Search the libtool library
6197238104Sdes	      lib="$searchdir/lib${name}${search_ext}"
6198238104Sdes	      if test -f "$lib"; then
6199238104Sdes		if test "$search_ext" = ".la"; then
6200238104Sdes		  found=yes
6201238104Sdes		else
6202238104Sdes		  found=no
6203238104Sdes		fi
6204238104Sdes		break 2
6205238104Sdes	      fi
6206238104Sdes	    done
6207238104Sdes	  done
6208238104Sdes	  if test "$found" != yes; then
6209238104Sdes	    # deplib doesn't seem to be a libtool library
6210238104Sdes	    if test "$linkmode,$pass" = "prog,link"; then
6211238104Sdes	      compile_deplibs="$deplib $compile_deplibs"
6212238104Sdes	      finalize_deplibs="$deplib $finalize_deplibs"
6213238104Sdes	    else
6214238104Sdes	      deplibs="$deplib $deplibs"
6215238104Sdes	      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
6216238104Sdes	    fi
6217238104Sdes	    continue
6218238104Sdes	  else # deplib is a libtool library
6219238104Sdes	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
6220238104Sdes	    # We need to do some special things here, and not later.
6221238104Sdes	    if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6222238104Sdes	      case " $predeps $postdeps " in
6223238104Sdes	      *" $deplib "*)
6224238104Sdes		if func_lalib_p "$lib"; then
6225238104Sdes		  library_names=
6226238104Sdes		  old_library=
6227238104Sdes		  func_source "$lib"
6228238104Sdes		  for l in $old_library $library_names; do
6229238104Sdes		    ll="$l"
6230238104Sdes		  done
6231238104Sdes		  if test "X$ll" = "X$old_library" ; then # only static version available
6232238104Sdes		    found=no
6233238104Sdes		    func_dirname "$lib" "" "."
6234238104Sdes		    ladir="$func_dirname_result"
6235238104Sdes		    lib=$ladir/$old_library
6236238104Sdes		    if test "$linkmode,$pass" = "prog,link"; then
6237238104Sdes		      compile_deplibs="$deplib $compile_deplibs"
6238238104Sdes		      finalize_deplibs="$deplib $finalize_deplibs"
6239238104Sdes		    else
6240238104Sdes		      deplibs="$deplib $deplibs"
6241238104Sdes		      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
6242238104Sdes		    fi
6243238104Sdes		    continue
6244238104Sdes		  fi
6245238104Sdes		fi
6246238104Sdes		;;
6247238104Sdes	      *) ;;
6248238104Sdes	      esac
6249238104Sdes	    fi
6250238104Sdes	  fi
6251238104Sdes	  ;; # -l
6252238104Sdes	*.ltframework)
6253238104Sdes	  if test "$linkmode,$pass" = "prog,link"; then
6254238104Sdes	    compile_deplibs="$deplib $compile_deplibs"
6255238104Sdes	    finalize_deplibs="$deplib $finalize_deplibs"
6256238104Sdes	  else
6257238104Sdes	    deplibs="$deplib $deplibs"
6258238104Sdes	    if test "$linkmode" = lib ; then
6259238104Sdes		case "$new_inherited_linker_flags " in
6260238104Sdes		    *" $deplib "*) ;;
6261238104Sdes		    * ) func_append new_inherited_linker_flags " $deplib" ;;
6262238104Sdes		esac
6263238104Sdes	    fi
6264238104Sdes	  fi
6265238104Sdes	  continue
6266238104Sdes	  ;;
6267238104Sdes	-L*)
6268238104Sdes	  case $linkmode in
6269238104Sdes	  lib)
6270238104Sdes	    deplibs="$deplib $deplibs"
6271238104Sdes	    test "$pass" = conv && continue
6272238104Sdes	    newdependency_libs="$deplib $newdependency_libs"
6273238104Sdes	    func_stripname '-L' '' "$deplib"
6274238104Sdes	    func_resolve_sysroot "$func_stripname_result"
6275238104Sdes	    func_append newlib_search_path " $func_resolve_sysroot_result"
6276238104Sdes	    ;;
6277238104Sdes	  prog)
6278238104Sdes	    if test "$pass" = conv; then
6279238104Sdes	      deplibs="$deplib $deplibs"
6280238104Sdes	      continue
6281238104Sdes	    fi
6282238104Sdes	    if test "$pass" = scan; then
6283238104Sdes	      deplibs="$deplib $deplibs"
6284238104Sdes	    else
6285238104Sdes	      compile_deplibs="$deplib $compile_deplibs"
6286238104Sdes	      finalize_deplibs="$deplib $finalize_deplibs"
6287238104Sdes	    fi
6288238104Sdes	    func_stripname '-L' '' "$deplib"
6289238104Sdes	    func_resolve_sysroot "$func_stripname_result"
6290238104Sdes	    func_append newlib_search_path " $func_resolve_sysroot_result"
6291238104Sdes	    ;;
6292238104Sdes	  *)
6293238104Sdes	    func_warning "\`-L' is ignored for archives/objects"
6294238104Sdes	    ;;
6295238104Sdes	  esac # linkmode
6296238104Sdes	  continue
6297238104Sdes	  ;; # -L
6298238104Sdes	-R*)
6299238104Sdes	  if test "$pass" = link; then
6300238104Sdes	    func_stripname '-R' '' "$deplib"
6301238104Sdes	    func_resolve_sysroot "$func_stripname_result"
6302238104Sdes	    dir=$func_resolve_sysroot_result
6303238104Sdes	    # Make sure the xrpath contains only unique directories.
6304238104Sdes	    case "$xrpath " in
6305238104Sdes	    *" $dir "*) ;;
6306238104Sdes	    *) func_append xrpath " $dir" ;;
6307238104Sdes	    esac
6308238104Sdes	  fi
6309238104Sdes	  deplibs="$deplib $deplibs"
6310238104Sdes	  continue
6311238104Sdes	  ;;
6312238104Sdes	*.la)
6313238104Sdes	  func_resolve_sysroot "$deplib"
6314238104Sdes	  lib=$func_resolve_sysroot_result
6315238104Sdes	  ;;
6316238104Sdes	*.$libext)
6317238104Sdes	  if test "$pass" = conv; then
6318238104Sdes	    deplibs="$deplib $deplibs"
6319238104Sdes	    continue
6320238104Sdes	  fi
6321238104Sdes	  case $linkmode in
6322238104Sdes	  lib)
6323238104Sdes	    # Linking convenience modules into shared libraries is allowed,
6324238104Sdes	    # but linking other static libraries is non-portable.
6325238104Sdes	    case " $dlpreconveniencelibs " in
6326238104Sdes	    *" $deplib "*) ;;
6327238104Sdes	    *)
6328238104Sdes	      valid_a_lib=no
6329238104Sdes	      case $deplibs_check_method in
6330238104Sdes		match_pattern*)
6331238104Sdes		  set dummy $deplibs_check_method; shift
6332238104Sdes		  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
6333238104Sdes		  if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
6334238104Sdes		    | $EGREP "$match_pattern_regex" > /dev/null; then
6335238104Sdes		    valid_a_lib=yes
6336238104Sdes		  fi
6337238104Sdes		;;
6338238104Sdes		pass_all)
6339238104Sdes		  valid_a_lib=yes
6340238104Sdes		;;
6341238104Sdes	      esac
6342238104Sdes	      if test "$valid_a_lib" != yes; then
6343238104Sdes		echo
6344238104Sdes		$ECHO "*** Warning: Trying to link with static lib archive $deplib."
6345238104Sdes		echo "*** I have the capability to make that library automatically link in when"
6346238104Sdes		echo "*** you link to this library.  But I can only do this if you have a"
6347238104Sdes		echo "*** shared version of the library, which you do not appear to have"
6348238104Sdes		echo "*** because the file extensions .$libext of this argument makes me believe"
6349238104Sdes		echo "*** that it is just a static archive that I should not use here."
6350238104Sdes	      else
6351238104Sdes		echo
6352238104Sdes		$ECHO "*** Warning: Linking the shared library $output against the"
6353238104Sdes		$ECHO "*** static library $deplib is not portable!"
6354238104Sdes		deplibs="$deplib $deplibs"
6355238104Sdes	      fi
6356238104Sdes	      ;;
6357238104Sdes	    esac
6358238104Sdes	    continue
6359238104Sdes	    ;;
6360238104Sdes	  prog)
6361238104Sdes	    if test "$pass" != link; then
6362238104Sdes	      deplibs="$deplib $deplibs"
6363238104Sdes	    else
6364238104Sdes	      compile_deplibs="$deplib $compile_deplibs"
6365238104Sdes	      finalize_deplibs="$deplib $finalize_deplibs"
6366238104Sdes	    fi
6367238104Sdes	    continue
6368238104Sdes	    ;;
6369238104Sdes	  esac # linkmode
6370238104Sdes	  ;; # *.$libext
6371238104Sdes	*.lo | *.$objext)
6372238104Sdes	  if test "$pass" = conv; then
6373238104Sdes	    deplibs="$deplib $deplibs"
6374238104Sdes	  elif test "$linkmode" = prog; then
6375238104Sdes	    if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
6376238104Sdes	      # If there is no dlopen support or we're linking statically,
6377238104Sdes	      # we need to preload.
6378238104Sdes	      func_append newdlprefiles " $deplib"
6379238104Sdes	      compile_deplibs="$deplib $compile_deplibs"
6380238104Sdes	      finalize_deplibs="$deplib $finalize_deplibs"
6381238104Sdes	    else
6382238104Sdes	      func_append newdlfiles " $deplib"
6383238104Sdes	    fi
6384238104Sdes	  fi
6385238104Sdes	  continue
6386238104Sdes	  ;;
6387238104Sdes	%DEPLIBS%)
6388238104Sdes	  alldeplibs=yes
6389238104Sdes	  continue
6390238104Sdes	  ;;
6391238104Sdes	esac # case $deplib
6392238104Sdes
6393238104Sdes	if test "$found" = yes || test -f "$lib"; then :
6394238104Sdes	else
6395238104Sdes	  func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'"
6396238104Sdes	fi
6397238104Sdes
6398238104Sdes	# Check to see that this really is a libtool archive.
6399238104Sdes	func_lalib_unsafe_p "$lib" \
6400238104Sdes	  || func_fatal_error "\`$lib' is not a valid libtool archive"
6401238104Sdes
6402238104Sdes	func_dirname "$lib" "" "."
6403238104Sdes	ladir="$func_dirname_result"
6404238104Sdes
6405238104Sdes	dlname=
6406238104Sdes	dlopen=
6407238104Sdes	dlpreopen=
6408238104Sdes	libdir=
6409238104Sdes	library_names=
6410238104Sdes	old_library=
6411238104Sdes	inherited_linker_flags=
6412238104Sdes	# If the library was installed with an old release of libtool,
6413238104Sdes	# it will not redefine variables installed, or shouldnotlink
6414238104Sdes	installed=yes
6415238104Sdes	shouldnotlink=no
6416238104Sdes	avoidtemprpath=
6417238104Sdes
6418238104Sdes
6419238104Sdes	# Read the .la file
6420238104Sdes	func_source "$lib"
6421238104Sdes
6422238104Sdes	# Convert "-framework foo" to "foo.ltframework"
6423238104Sdes	if test -n "$inherited_linker_flags"; then
6424238104Sdes	  tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
6425238104Sdes	  for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
6426238104Sdes	    case " $new_inherited_linker_flags " in
6427238104Sdes	      *" $tmp_inherited_linker_flag "*) ;;
6428238104Sdes	      *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";;
6429238104Sdes	    esac
6430238104Sdes	  done
6431238104Sdes	fi
6432238104Sdes	dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
6433238104Sdes	if test "$linkmode,$pass" = "lib,link" ||
6434238104Sdes	   test "$linkmode,$pass" = "prog,scan" ||
6435238104Sdes	   { test "$linkmode" != prog && test "$linkmode" != lib; }; then
6436238104Sdes	  test -n "$dlopen" && func_append dlfiles " $dlopen"
6437238104Sdes	  test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen"
6438238104Sdes	fi
6439238104Sdes
6440238104Sdes	if test "$pass" = conv; then
6441238104Sdes	  # Only check for convenience libraries
6442238104Sdes	  deplibs="$lib $deplibs"
6443238104Sdes	  if test -z "$libdir"; then
6444238104Sdes	    if test -z "$old_library"; then
6445238104Sdes	      func_fatal_error "cannot find name of link library for \`$lib'"
6446238104Sdes	    fi
6447238104Sdes	    # It is a libtool convenience library, so add in its objects.
6448238104Sdes	    func_append convenience " $ladir/$objdir/$old_library"
6449238104Sdes	    func_append old_convenience " $ladir/$objdir/$old_library"
6450238104Sdes	    tmp_libs=
6451238104Sdes	    for deplib in $dependency_libs; do
6452238104Sdes	      deplibs="$deplib $deplibs"
6453238104Sdes	      if $opt_preserve_dup_deps ; then
6454238104Sdes		case "$tmp_libs " in
6455238104Sdes		*" $deplib "*) func_append specialdeplibs " $deplib" ;;
6456238104Sdes		esac
6457238104Sdes	      fi
6458238104Sdes	      func_append tmp_libs " $deplib"
6459238104Sdes	    done
6460238104Sdes	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
6461238104Sdes	    func_fatal_error "\`$lib' is not a convenience library"
6462238104Sdes	  fi
6463238104Sdes	  continue
6464238104Sdes	fi # $pass = conv
6465238104Sdes
6466238104Sdes
6467238104Sdes	# Get the name of the library we link against.
6468238104Sdes	linklib=
6469238104Sdes	if test -n "$old_library" &&
6470238104Sdes	   { test "$prefer_static_libs" = yes ||
6471238104Sdes	     test "$prefer_static_libs,$installed" = "built,no"; }; then
6472238104Sdes	  linklib=$old_library
6473238104Sdes	else
6474238104Sdes	  for l in $old_library $library_names; do
6475238104Sdes	    linklib="$l"
6476238104Sdes	  done
6477238104Sdes	fi
6478238104Sdes	if test -z "$linklib"; then
6479238104Sdes	  func_fatal_error "cannot find name of link library for \`$lib'"
6480238104Sdes	fi
6481238104Sdes
6482238104Sdes	# This library was specified with -dlopen.
6483238104Sdes	if test "$pass" = dlopen; then
6484238104Sdes	  if test -z "$libdir"; then
6485238104Sdes	    func_fatal_error "cannot -dlopen a convenience library: \`$lib'"
6486238104Sdes	  fi
6487238104Sdes	  if test -z "$dlname" ||
6488238104Sdes	     test "$dlopen_support" != yes ||
6489238104Sdes	     test "$build_libtool_libs" = no; then
6490238104Sdes	    # If there is no dlname, no dlopen support or we're linking
6491238104Sdes	    # statically, we need to preload.  We also need to preload any
6492238104Sdes	    # dependent libraries so libltdl's deplib preloader doesn't
6493238104Sdes	    # bomb out in the load deplibs phase.
6494238104Sdes	    func_append dlprefiles " $lib $dependency_libs"
6495238104Sdes	  else
6496238104Sdes	    func_append newdlfiles " $lib"
6497238104Sdes	  fi
6498238104Sdes	  continue
6499238104Sdes	fi # $pass = dlopen
6500238104Sdes
6501238104Sdes	# We need an absolute path.
6502238104Sdes	case $ladir in
6503238104Sdes	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
6504238104Sdes	*)
6505238104Sdes	  abs_ladir=`cd "$ladir" && pwd`
6506238104Sdes	  if test -z "$abs_ladir"; then
6507238104Sdes	    func_warning "cannot determine absolute directory name of \`$ladir'"
6508238104Sdes	    func_warning "passing it literally to the linker, although it might fail"
6509238104Sdes	    abs_ladir="$ladir"
6510238104Sdes	  fi
6511238104Sdes	  ;;
6512238104Sdes	esac
6513238104Sdes	func_basename "$lib"
6514238104Sdes	laname="$func_basename_result"
6515238104Sdes
6516238104Sdes	# Find the relevant object directory and library name.
6517238104Sdes	if test "X$installed" = Xyes; then
6518238104Sdes	  if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
6519238104Sdes	    func_warning "library \`$lib' was moved."
6520238104Sdes	    dir="$ladir"
6521238104Sdes	    absdir="$abs_ladir"
6522238104Sdes	    libdir="$abs_ladir"
6523238104Sdes	  else
6524238104Sdes	    dir="$lt_sysroot$libdir"
6525238104Sdes	    absdir="$lt_sysroot$libdir"
6526238104Sdes	  fi
6527238104Sdes	  test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
6528238104Sdes	else
6529238104Sdes	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
6530238104Sdes	    dir="$ladir"
6531238104Sdes	    absdir="$abs_ladir"
6532238104Sdes	    # Remove this search path later
6533238104Sdes	    func_append notinst_path " $abs_ladir"
6534238104Sdes	  else
6535238104Sdes	    dir="$ladir/$objdir"
6536238104Sdes	    absdir="$abs_ladir/$objdir"
6537238104Sdes	    # Remove this search path later
6538238104Sdes	    func_append notinst_path " $abs_ladir"
6539238104Sdes	  fi
6540238104Sdes	fi # $installed = yes
6541238104Sdes	func_stripname 'lib' '.la' "$laname"
6542238104Sdes	name=$func_stripname_result
6543238104Sdes
6544238104Sdes	# This library was specified with -dlpreopen.
6545238104Sdes	if test "$pass" = dlpreopen; then
6546238104Sdes	  if test -z "$libdir" && test "$linkmode" = prog; then
6547238104Sdes	    func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'"
6548238104Sdes	  fi
6549238104Sdes	  case "$host" in
6550238104Sdes	    # special handling for platforms with PE-DLLs.
6551238104Sdes	    *cygwin* | *mingw* | *cegcc* )
6552238104Sdes	      # Linker will automatically link against shared library if both
6553238104Sdes	      # static and shared are present.  Therefore, ensure we extract
6554238104Sdes	      # symbols from the import library if a shared library is present
6555238104Sdes	      # (otherwise, the dlopen module name will be incorrect).  We do
6556238104Sdes	      # this by putting the import library name into $newdlprefiles.
6557238104Sdes	      # We recover the dlopen module name by 'saving' the la file
6558238104Sdes	      # name in a special purpose variable, and (later) extracting the
6559238104Sdes	      # dlname from the la file.
6560238104Sdes	      if test -n "$dlname"; then
6561238104Sdes	        func_tr_sh "$dir/$linklib"
6562238104Sdes	        eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname"
6563238104Sdes	        func_append newdlprefiles " $dir/$linklib"
6564238104Sdes	      else
6565238104Sdes	        func_append newdlprefiles " $dir/$old_library"
6566238104Sdes	        # Keep a list of preopened convenience libraries to check
6567238104Sdes	        # that they are being used correctly in the link pass.
6568238104Sdes	        test -z "$libdir" && \
6569238104Sdes	          func_append dlpreconveniencelibs " $dir/$old_library"
6570238104Sdes	      fi
6571238104Sdes	    ;;
6572238104Sdes	    * )
6573238104Sdes	      # Prefer using a static library (so that no silly _DYNAMIC symbols
6574238104Sdes	      # are required to link).
6575238104Sdes	      if test -n "$old_library"; then
6576238104Sdes	        func_append newdlprefiles " $dir/$old_library"
6577238104Sdes	        # Keep a list of preopened convenience libraries to check
6578238104Sdes	        # that they are being used correctly in the link pass.
6579238104Sdes	        test -z "$libdir" && \
6580238104Sdes	          func_append dlpreconveniencelibs " $dir/$old_library"
6581238104Sdes	      # Otherwise, use the dlname, so that lt_dlopen finds it.
6582238104Sdes	      elif test -n "$dlname"; then
6583238104Sdes	        func_append newdlprefiles " $dir/$dlname"
6584238104Sdes	      else
6585238104Sdes	        func_append newdlprefiles " $dir/$linklib"
6586238104Sdes	      fi
6587238104Sdes	    ;;
6588238104Sdes	  esac
6589238104Sdes	fi # $pass = dlpreopen
6590238104Sdes
6591238104Sdes	if test -z "$libdir"; then
6592238104Sdes	  # Link the convenience library
6593238104Sdes	  if test "$linkmode" = lib; then
6594238104Sdes	    deplibs="$dir/$old_library $deplibs"
6595238104Sdes	  elif test "$linkmode,$pass" = "prog,link"; then
6596238104Sdes	    compile_deplibs="$dir/$old_library $compile_deplibs"
6597238104Sdes	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
6598238104Sdes	  else
6599238104Sdes	    deplibs="$lib $deplibs" # used for prog,scan pass
6600238104Sdes	  fi
6601238104Sdes	  continue
6602238104Sdes	fi
6603238104Sdes
6604238104Sdes
6605238104Sdes	if test "$linkmode" = prog && test "$pass" != link; then
6606238104Sdes	  func_append newlib_search_path " $ladir"
6607238104Sdes	  deplibs="$lib $deplibs"
6608238104Sdes
6609238104Sdes	  linkalldeplibs=no
6610238104Sdes	  if test "$link_all_deplibs" != no || test -z "$library_names" ||
6611238104Sdes	     test "$build_libtool_libs" = no; then
6612238104Sdes	    linkalldeplibs=yes
6613238104Sdes	  fi
6614238104Sdes
6615238104Sdes	  tmp_libs=
6616238104Sdes	  for deplib in $dependency_libs; do
6617238104Sdes	    case $deplib in
6618238104Sdes	    -L*) func_stripname '-L' '' "$deplib"
6619238104Sdes	         func_resolve_sysroot "$func_stripname_result"
6620238104Sdes	         func_append newlib_search_path " $func_resolve_sysroot_result"
6621238104Sdes		 ;;
6622238104Sdes	    esac
6623238104Sdes	    # Need to link against all dependency_libs?
6624238104Sdes	    if test "$linkalldeplibs" = yes; then
6625238104Sdes	      deplibs="$deplib $deplibs"
6626238104Sdes	    else
6627238104Sdes	      # Need to hardcode shared library paths
6628238104Sdes	      # or/and link against static libraries
6629238104Sdes	      newdependency_libs="$deplib $newdependency_libs"
6630238104Sdes	    fi
6631238104Sdes	    if $opt_preserve_dup_deps ; then
6632238104Sdes	      case "$tmp_libs " in
6633238104Sdes	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
6634238104Sdes	      esac
6635238104Sdes	    fi
6636238104Sdes	    func_append tmp_libs " $deplib"
6637238104Sdes	  done # for deplib
6638238104Sdes	  continue
6639238104Sdes	fi # $linkmode = prog...
6640238104Sdes
6641238104Sdes	if test "$linkmode,$pass" = "prog,link"; then
6642238104Sdes	  if test -n "$library_names" &&
6643238104Sdes	     { { test "$prefer_static_libs" = no ||
6644238104Sdes	         test "$prefer_static_libs,$installed" = "built,yes"; } ||
6645238104Sdes	       test -z "$old_library"; }; then
6646238104Sdes	    # We need to hardcode the library path
6647238104Sdes	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
6648238104Sdes	      # Make sure the rpath contains only unique directories.
6649238104Sdes	      case "$temp_rpath:" in
6650238104Sdes	      *"$absdir:"*) ;;
6651238104Sdes	      *) func_append temp_rpath "$absdir:" ;;
6652238104Sdes	      esac
6653238104Sdes	    fi
6654238104Sdes
6655238104Sdes	    # Hardcode the library path.
6656238104Sdes	    # Skip directories that are in the system default run-time
6657238104Sdes	    # search path.
6658238104Sdes	    case " $sys_lib_dlsearch_path " in
6659238104Sdes	    *" $absdir "*) ;;
6660238104Sdes	    *)
6661238104Sdes	      case "$compile_rpath " in
6662238104Sdes	      *" $absdir "*) ;;
6663238104Sdes	      *) func_append compile_rpath " $absdir" ;;
6664238104Sdes	      esac
6665238104Sdes	      ;;
6666238104Sdes	    esac
6667238104Sdes	    case " $sys_lib_dlsearch_path " in
6668238104Sdes	    *" $libdir "*) ;;
6669238104Sdes	    *)
6670238104Sdes	      case "$finalize_rpath " in
6671238104Sdes	      *" $libdir "*) ;;
6672238104Sdes	      *) func_append finalize_rpath " $libdir" ;;
6673238104Sdes	      esac
6674238104Sdes	      ;;
6675238104Sdes	    esac
6676238104Sdes	  fi # $linkmode,$pass = prog,link...
6677238104Sdes
6678238104Sdes	  if test "$alldeplibs" = yes &&
6679238104Sdes	     { test "$deplibs_check_method" = pass_all ||
6680238104Sdes	       { test "$build_libtool_libs" = yes &&
6681238104Sdes		 test -n "$library_names"; }; }; then
6682238104Sdes	    # We only need to search for static libraries
6683238104Sdes	    continue
6684238104Sdes	  fi
6685238104Sdes	fi
6686238104Sdes
6687238104Sdes	link_static=no # Whether the deplib will be linked statically
6688238104Sdes	use_static_libs=$prefer_static_libs
6689238104Sdes	if test "$use_static_libs" = built && test "$installed" = yes; then
6690238104Sdes	  use_static_libs=no
6691238104Sdes	fi
6692238104Sdes	if test -n "$library_names" &&
6693238104Sdes	   { test "$use_static_libs" = no || test -z "$old_library"; }; then
6694238104Sdes	  case $host in
6695238104Sdes	  *cygwin* | *mingw* | *cegcc*)
6696238104Sdes	      # No point in relinking DLLs because paths are not encoded
6697238104Sdes	      func_append notinst_deplibs " $lib"
6698238104Sdes	      need_relink=no
6699238104Sdes	    ;;
6700238104Sdes	  *)
6701238104Sdes	    if test "$installed" = no; then
6702238104Sdes	      func_append notinst_deplibs " $lib"
6703238104Sdes	      need_relink=yes
6704238104Sdes	    fi
6705238104Sdes	    ;;
6706238104Sdes	  esac
6707238104Sdes	  # This is a shared library
6708238104Sdes
6709238104Sdes	  # Warn about portability, can't link against -module's on some
6710238104Sdes	  # systems (darwin).  Don't bleat about dlopened modules though!
6711238104Sdes	  dlopenmodule=""
6712238104Sdes	  for dlpremoduletest in $dlprefiles; do
6713238104Sdes	    if test "X$dlpremoduletest" = "X$lib"; then
6714238104Sdes	      dlopenmodule="$dlpremoduletest"
6715238104Sdes	      break
6716238104Sdes	    fi
6717238104Sdes	  done
6718238104Sdes	  if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then
6719238104Sdes	    echo
6720238104Sdes	    if test "$linkmode" = prog; then
6721238104Sdes	      $ECHO "*** Warning: Linking the executable $output against the loadable module"
6722238104Sdes	    else
6723238104Sdes	      $ECHO "*** Warning: Linking the shared library $output against the loadable module"
6724238104Sdes	    fi
6725238104Sdes	    $ECHO "*** $linklib is not portable!"
6726238104Sdes	  fi
6727238104Sdes	  if test "$linkmode" = lib &&
6728238104Sdes	     test "$hardcode_into_libs" = yes; then
6729238104Sdes	    # Hardcode the library path.
6730238104Sdes	    # Skip directories that are in the system default run-time
6731238104Sdes	    # search path.
6732238104Sdes	    case " $sys_lib_dlsearch_path " in
6733238104Sdes	    *" $absdir "*) ;;
6734238104Sdes	    *)
6735238104Sdes	      case "$compile_rpath " in
6736238104Sdes	      *" $absdir "*) ;;
6737238104Sdes	      *) func_append compile_rpath " $absdir" ;;
6738238104Sdes	      esac
6739238104Sdes	      ;;
6740238104Sdes	    esac
6741238104Sdes	    case " $sys_lib_dlsearch_path " in
6742238104Sdes	    *" $libdir "*) ;;
6743238104Sdes	    *)
6744238104Sdes	      case "$finalize_rpath " in
6745238104Sdes	      *" $libdir "*) ;;
6746238104Sdes	      *) func_append finalize_rpath " $libdir" ;;
6747238104Sdes	      esac
6748238104Sdes	      ;;
6749238104Sdes	    esac
6750238104Sdes	  fi
6751238104Sdes
6752238104Sdes	  if test -n "$old_archive_from_expsyms_cmds"; then
6753238104Sdes	    # figure out the soname
6754238104Sdes	    set dummy $library_names
6755238104Sdes	    shift
6756238104Sdes	    realname="$1"
6757238104Sdes	    shift
6758238104Sdes	    libname=`eval "\\$ECHO \"$libname_spec\""`
6759238104Sdes	    # use dlname if we got it. it's perfectly good, no?
6760238104Sdes	    if test -n "$dlname"; then
6761238104Sdes	      soname="$dlname"
6762238104Sdes	    elif test -n "$soname_spec"; then
6763238104Sdes	      # bleh windows
6764238104Sdes	      case $host in
6765238104Sdes	      *cygwin* | mingw* | *cegcc*)
6766238104Sdes	        func_arith $current - $age
6767238104Sdes		major=$func_arith_result
6768238104Sdes		versuffix="-$major"
6769238104Sdes		;;
6770238104Sdes	      esac
6771238104Sdes	      eval soname=\"$soname_spec\"
6772238104Sdes	    else
6773238104Sdes	      soname="$realname"
6774238104Sdes	    fi
6775238104Sdes
6776238104Sdes	    # Make a new name for the extract_expsyms_cmds to use
6777238104Sdes	    soroot="$soname"
6778238104Sdes	    func_basename "$soroot"
6779238104Sdes	    soname="$func_basename_result"
6780238104Sdes	    func_stripname 'lib' '.dll' "$soname"
6781238104Sdes	    newlib=libimp-$func_stripname_result.a
6782238104Sdes
6783238104Sdes	    # If the library has no export list, then create one now
6784238104Sdes	    if test -f "$output_objdir/$soname-def"; then :
6785238104Sdes	    else
6786238104Sdes	      func_verbose "extracting exported symbol list from \`$soname'"
6787238104Sdes	      func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
6788238104Sdes	    fi
6789238104Sdes
6790238104Sdes	    # Create $newlib
6791238104Sdes	    if test -f "$output_objdir/$newlib"; then :; else
6792238104Sdes	      func_verbose "generating import library for \`$soname'"
6793238104Sdes	      func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
6794238104Sdes	    fi
6795238104Sdes	    # make sure the library variables are pointing to the new library
6796238104Sdes	    dir=$output_objdir
6797238104Sdes	    linklib=$newlib
6798238104Sdes	  fi # test -n "$old_archive_from_expsyms_cmds"
6799238104Sdes
6800238104Sdes	  if test "$linkmode" = prog || test "$opt_mode" != relink; then
6801238104Sdes	    add_shlibpath=
6802238104Sdes	    add_dir=
6803238104Sdes	    add=
6804238104Sdes	    lib_linked=yes
6805238104Sdes	    case $hardcode_action in
6806238104Sdes	    immediate | unsupported)
6807238104Sdes	      if test "$hardcode_direct" = no; then
6808238104Sdes		add="$dir/$linklib"
6809238104Sdes		case $host in
6810238104Sdes		  *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
6811238104Sdes		  *-*-sysv4*uw2*) add_dir="-L$dir" ;;
6812238104Sdes		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
6813238104Sdes		    *-*-unixware7*) add_dir="-L$dir" ;;
6814238104Sdes		  *-*-darwin* )
6815238104Sdes		    # if the lib is a (non-dlopened) module then we can not
6816238104Sdes		    # link against it, someone is ignoring the earlier warnings
6817238104Sdes		    if /usr/bin/file -L $add 2> /dev/null |
6818238104Sdes			 $GREP ": [^:]* bundle" >/dev/null ; then
6819238104Sdes		      if test "X$dlopenmodule" != "X$lib"; then
6820238104Sdes			$ECHO "*** Warning: lib $linklib is a module, not a shared library"
6821238104Sdes			if test -z "$old_library" ; then
6822238104Sdes			  echo
6823238104Sdes			  echo "*** And there doesn't seem to be a static archive available"
6824238104Sdes			  echo "*** The link will probably fail, sorry"
6825238104Sdes			else
6826238104Sdes			  add="$dir/$old_library"
6827238104Sdes			fi
6828238104Sdes		      elif test -n "$old_library"; then
6829238104Sdes			add="$dir/$old_library"
6830238104Sdes		      fi
6831238104Sdes		    fi
6832238104Sdes		esac
6833238104Sdes	      elif test "$hardcode_minus_L" = no; then
6834238104Sdes		case $host in
6835238104Sdes		*-*-sunos*) add_shlibpath="$dir" ;;
6836238104Sdes		esac
6837238104Sdes		add_dir="-L$dir"
6838238104Sdes		add="-l$name"
6839238104Sdes	      elif test "$hardcode_shlibpath_var" = no; then
6840238104Sdes		add_shlibpath="$dir"
6841238104Sdes		add="-l$name"
6842238104Sdes	      else
6843238104Sdes		lib_linked=no
6844238104Sdes	      fi
6845238104Sdes	      ;;
6846238104Sdes	    relink)
6847238104Sdes	      if test "$hardcode_direct" = yes &&
6848238104Sdes	         test "$hardcode_direct_absolute" = no; then
6849238104Sdes		add="$dir/$linklib"
6850238104Sdes	      elif test "$hardcode_minus_L" = yes; then
6851238104Sdes		add_dir="-L$absdir"
6852238104Sdes		# Try looking first in the location we're being installed to.
6853238104Sdes		if test -n "$inst_prefix_dir"; then
6854238104Sdes		  case $libdir in
6855238104Sdes		    [\\/]*)
6856238104Sdes		      func_append add_dir " -L$inst_prefix_dir$libdir"
6857238104Sdes		      ;;
6858238104Sdes		  esac
6859238104Sdes		fi
6860238104Sdes		add="-l$name"
6861238104Sdes	      elif test "$hardcode_shlibpath_var" = yes; then
6862238104Sdes		add_shlibpath="$dir"
6863238104Sdes		add="-l$name"
6864238104Sdes	      else
6865238104Sdes		lib_linked=no
6866238104Sdes	      fi
6867238104Sdes	      ;;
6868238104Sdes	    *) lib_linked=no ;;
6869238104Sdes	    esac
6870238104Sdes
6871238104Sdes	    if test "$lib_linked" != yes; then
6872238104Sdes	      func_fatal_configuration "unsupported hardcode properties"
6873238104Sdes	    fi
6874238104Sdes
6875238104Sdes	    if test -n "$add_shlibpath"; then
6876238104Sdes	      case :$compile_shlibpath: in
6877238104Sdes	      *":$add_shlibpath:"*) ;;
6878238104Sdes	      *) func_append compile_shlibpath "$add_shlibpath:" ;;
6879238104Sdes	      esac
6880238104Sdes	    fi
6881238104Sdes	    if test "$linkmode" = prog; then
6882238104Sdes	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
6883238104Sdes	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
6884238104Sdes	    else
6885238104Sdes	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
6886238104Sdes	      test -n "$add" && deplibs="$add $deplibs"
6887238104Sdes	      if test "$hardcode_direct" != yes &&
6888238104Sdes		 test "$hardcode_minus_L" != yes &&
6889238104Sdes		 test "$hardcode_shlibpath_var" = yes; then
6890238104Sdes		case :$finalize_shlibpath: in
6891238104Sdes		*":$libdir:"*) ;;
6892238104Sdes		*) func_append finalize_shlibpath "$libdir:" ;;
6893238104Sdes		esac
6894238104Sdes	      fi
6895238104Sdes	    fi
6896238104Sdes	  fi
6897238104Sdes
6898238104Sdes	  if test "$linkmode" = prog || test "$opt_mode" = relink; then
6899238104Sdes	    add_shlibpath=
6900238104Sdes	    add_dir=
6901238104Sdes	    add=
6902238104Sdes	    # Finalize command for both is simple: just hardcode it.
6903238104Sdes	    if test "$hardcode_direct" = yes &&
6904238104Sdes	       test "$hardcode_direct_absolute" = no; then
6905238104Sdes	      add="$libdir/$linklib"
6906238104Sdes	    elif test "$hardcode_minus_L" = yes; then
6907238104Sdes	      add_dir="-L$libdir"
6908238104Sdes	      add="-l$name"
6909238104Sdes	    elif test "$hardcode_shlibpath_var" = yes; then
6910238104Sdes	      case :$finalize_shlibpath: in
6911238104Sdes	      *":$libdir:"*) ;;
6912238104Sdes	      *) func_append finalize_shlibpath "$libdir:" ;;
6913238104Sdes	      esac
6914238104Sdes	      add="-l$name"
6915238104Sdes	    elif test "$hardcode_automatic" = yes; then
6916238104Sdes	      if test -n "$inst_prefix_dir" &&
6917238104Sdes		 test -f "$inst_prefix_dir$libdir/$linklib" ; then
6918238104Sdes		add="$inst_prefix_dir$libdir/$linklib"
6919238104Sdes	      else
6920238104Sdes		add="$libdir/$linklib"
6921238104Sdes	      fi
6922238104Sdes	    else
6923238104Sdes	      # We cannot seem to hardcode it, guess we'll fake it.
6924238104Sdes	      add_dir="-L$libdir"
6925238104Sdes	      # Try looking first in the location we're being installed to.
6926238104Sdes	      if test -n "$inst_prefix_dir"; then
6927238104Sdes		case $libdir in
6928238104Sdes		  [\\/]*)
6929238104Sdes		    func_append add_dir " -L$inst_prefix_dir$libdir"
6930238104Sdes		    ;;
6931238104Sdes		esac
6932238104Sdes	      fi
6933238104Sdes	      add="-l$name"
6934238104Sdes	    fi
6935238104Sdes
6936238104Sdes	    if test "$linkmode" = prog; then
6937238104Sdes	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
6938238104Sdes	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
6939238104Sdes	    else
6940238104Sdes	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
6941238104Sdes	      test -n "$add" && deplibs="$add $deplibs"
6942238104Sdes	    fi
6943238104Sdes	  fi
6944238104Sdes	elif test "$linkmode" = prog; then
6945238104Sdes	  # Here we assume that one of hardcode_direct or hardcode_minus_L
6946238104Sdes	  # is not unsupported.  This is valid on all known static and
6947238104Sdes	  # shared platforms.
6948238104Sdes	  if test "$hardcode_direct" != unsupported; then
6949238104Sdes	    test -n "$old_library" && linklib="$old_library"
6950238104Sdes	    compile_deplibs="$dir/$linklib $compile_deplibs"
6951238104Sdes	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
6952238104Sdes	  else
6953238104Sdes	    compile_deplibs="-l$name -L$dir $compile_deplibs"
6954238104Sdes	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
6955238104Sdes	  fi
6956238104Sdes	elif test "$build_libtool_libs" = yes; then
6957238104Sdes	  # Not a shared library
6958238104Sdes	  if test "$deplibs_check_method" != pass_all; then
6959238104Sdes	    # We're trying link a shared library against a static one
6960238104Sdes	    # but the system doesn't support it.
6961238104Sdes
6962238104Sdes	    # Just print a warning and add the library to dependency_libs so
6963238104Sdes	    # that the program can be linked against the static library.
6964238104Sdes	    echo
6965238104Sdes	    $ECHO "*** Warning: This system can not link to static lib archive $lib."
6966238104Sdes	    echo "*** I have the capability to make that library automatically link in when"
6967238104Sdes	    echo "*** you link to this library.  But I can only do this if you have a"
6968238104Sdes	    echo "*** shared version of the library, which you do not appear to have."
6969238104Sdes	    if test "$module" = yes; then
6970238104Sdes	      echo "*** But as you try to build a module library, libtool will still create "
6971238104Sdes	      echo "*** a static module, that should work as long as the dlopening application"
6972238104Sdes	      echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
6973238104Sdes	      if test -z "$global_symbol_pipe"; then
6974238104Sdes		echo
6975238104Sdes		echo "*** However, this would only work if libtool was able to extract symbol"
6976238104Sdes		echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
6977238104Sdes		echo "*** not find such a program.  So, this module is probably useless."
6978238104Sdes		echo "*** \`nm' from GNU binutils and a full rebuild may help."
6979238104Sdes	      fi
6980238104Sdes	      if test "$build_old_libs" = no; then
6981238104Sdes		build_libtool_libs=module
6982238104Sdes		build_old_libs=yes
6983238104Sdes	      else
6984238104Sdes		build_libtool_libs=no
6985238104Sdes	      fi
6986238104Sdes	    fi
6987238104Sdes	  else
6988238104Sdes	    deplibs="$dir/$old_library $deplibs"
6989238104Sdes	    link_static=yes
6990238104Sdes	  fi
6991238104Sdes	fi # link shared/static library?
6992238104Sdes
6993238104Sdes	if test "$linkmode" = lib; then
6994238104Sdes	  if test -n "$dependency_libs" &&
6995238104Sdes	     { test "$hardcode_into_libs" != yes ||
6996238104Sdes	       test "$build_old_libs" = yes ||
6997238104Sdes	       test "$link_static" = yes; }; then
6998238104Sdes	    # Extract -R from dependency_libs
6999238104Sdes	    temp_deplibs=
7000238104Sdes	    for libdir in $dependency_libs; do
7001238104Sdes	      case $libdir in
7002238104Sdes	      -R*) func_stripname '-R' '' "$libdir"
7003238104Sdes	           temp_xrpath=$func_stripname_result
7004238104Sdes		   case " $xrpath " in
7005238104Sdes		   *" $temp_xrpath "*) ;;
7006238104Sdes		   *) func_append xrpath " $temp_xrpath";;
7007238104Sdes		   esac;;
7008238104Sdes	      *) func_append temp_deplibs " $libdir";;
7009238104Sdes	      esac
7010238104Sdes	    done
7011238104Sdes	    dependency_libs="$temp_deplibs"
7012238104Sdes	  fi
7013238104Sdes
7014238104Sdes	  func_append newlib_search_path " $absdir"
7015238104Sdes	  # Link against this library
7016238104Sdes	  test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
7017238104Sdes	  # ... and its dependency_libs
7018238104Sdes	  tmp_libs=
7019238104Sdes	  for deplib in $dependency_libs; do
7020238104Sdes	    newdependency_libs="$deplib $newdependency_libs"
7021238104Sdes	    case $deplib in
7022238104Sdes              -L*) func_stripname '-L' '' "$deplib"
7023238104Sdes                   func_resolve_sysroot "$func_stripname_result";;
7024238104Sdes              *) func_resolve_sysroot "$deplib" ;;
7025238104Sdes            esac
7026238104Sdes	    if $opt_preserve_dup_deps ; then
7027238104Sdes	      case "$tmp_libs " in
7028238104Sdes	      *" $func_resolve_sysroot_result "*)
7029238104Sdes                func_append specialdeplibs " $func_resolve_sysroot_result" ;;
7030238104Sdes	      esac
7031238104Sdes	    fi
7032238104Sdes	    func_append tmp_libs " $func_resolve_sysroot_result"
7033238104Sdes	  done
7034238104Sdes
7035238104Sdes	  if test "$link_all_deplibs" != no; then
7036238104Sdes	    # Add the search paths of all dependency libraries
7037238104Sdes	    for deplib in $dependency_libs; do
7038238104Sdes	      path=
7039238104Sdes	      case $deplib in
7040238104Sdes	      -L*) path="$deplib" ;;
7041238104Sdes	      *.la)
7042238104Sdes	        func_resolve_sysroot "$deplib"
7043238104Sdes	        deplib=$func_resolve_sysroot_result
7044238104Sdes	        func_dirname "$deplib" "" "."
7045238104Sdes		dir=$func_dirname_result
7046238104Sdes		# We need an absolute path.
7047238104Sdes		case $dir in
7048238104Sdes		[\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
7049238104Sdes		*)
7050238104Sdes		  absdir=`cd "$dir" && pwd`
7051238104Sdes		  if test -z "$absdir"; then
7052238104Sdes		    func_warning "cannot determine absolute directory name of \`$dir'"
7053238104Sdes		    absdir="$dir"
7054238104Sdes		  fi
7055238104Sdes		  ;;
7056238104Sdes		esac
7057238104Sdes		if $GREP "^installed=no" $deplib > /dev/null; then
7058238104Sdes		case $host in
7059238104Sdes		*-*-darwin*)
7060238104Sdes		  depdepl=
7061238104Sdes		  eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
7062238104Sdes		  if test -n "$deplibrary_names" ; then
7063238104Sdes		    for tmp in $deplibrary_names ; do
7064238104Sdes		      depdepl=$tmp
7065238104Sdes		    done
7066238104Sdes		    if test -f "$absdir/$objdir/$depdepl" ; then
7067238104Sdes		      depdepl="$absdir/$objdir/$depdepl"
7068238104Sdes		      darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
7069238104Sdes                      if test -z "$darwin_install_name"; then
7070238104Sdes                          darwin_install_name=`${OTOOL64} -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
7071238104Sdes                      fi
7072238104Sdes		      func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}"
7073238104Sdes		      func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}"
7074238104Sdes		      path=
7075238104Sdes		    fi
7076238104Sdes		  fi
7077238104Sdes		  ;;
7078238104Sdes		*)
7079238104Sdes		  path="-L$absdir/$objdir"
7080238104Sdes		  ;;
7081238104Sdes		esac
7082238104Sdes		else
7083238104Sdes		  eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
7084238104Sdes		  test -z "$libdir" && \
7085238104Sdes		    func_fatal_error "\`$deplib' is not a valid libtool archive"
7086238104Sdes		  test "$absdir" != "$libdir" && \
7087238104Sdes		    func_warning "\`$deplib' seems to be moved"
7088238104Sdes
7089238104Sdes		  path="-L$absdir"
7090238104Sdes		fi
7091238104Sdes		;;
7092238104Sdes	      esac
7093238104Sdes	      case " $deplibs " in
7094238104Sdes	      *" $path "*) ;;
7095238104Sdes	      *) deplibs="$path $deplibs" ;;
7096238104Sdes	      esac
7097238104Sdes	    done
7098238104Sdes	  fi # link_all_deplibs != no
7099238104Sdes	fi # linkmode = lib
7100238104Sdes      done # for deplib in $libs
7101238104Sdes      if test "$pass" = link; then
7102238104Sdes	if test "$linkmode" = "prog"; then
7103238104Sdes	  compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
7104238104Sdes	  finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
7105238104Sdes	else
7106238104Sdes	  compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
7107238104Sdes	fi
7108238104Sdes      fi
7109238104Sdes      dependency_libs="$newdependency_libs"
7110238104Sdes      if test "$pass" = dlpreopen; then
7111238104Sdes	# Link the dlpreopened libraries before other libraries
7112238104Sdes	for deplib in $save_deplibs; do
7113238104Sdes	  deplibs="$deplib $deplibs"
7114238104Sdes	done
7115238104Sdes      fi
7116238104Sdes      if test "$pass" != dlopen; then
7117238104Sdes	if test "$pass" != conv; then
7118238104Sdes	  # Make sure lib_search_path contains only unique directories.
7119238104Sdes	  lib_search_path=
7120238104Sdes	  for dir in $newlib_search_path; do
7121238104Sdes	    case "$lib_search_path " in
7122238104Sdes	    *" $dir "*) ;;
7123238104Sdes	    *) func_append lib_search_path " $dir" ;;
7124238104Sdes	    esac
7125238104Sdes	  done
7126238104Sdes	  newlib_search_path=
7127238104Sdes	fi
7128238104Sdes
7129238104Sdes	if test "$linkmode,$pass" != "prog,link"; then
7130238104Sdes	  vars="deplibs"
7131238104Sdes	else
7132238104Sdes	  vars="compile_deplibs finalize_deplibs"
7133238104Sdes	fi
7134238104Sdes	for var in $vars dependency_libs; do
7135238104Sdes	  # Add libraries to $var in reverse order
7136238104Sdes	  eval tmp_libs=\"\$$var\"
7137238104Sdes	  new_libs=
7138238104Sdes	  for deplib in $tmp_libs; do
7139238104Sdes	    # FIXME: Pedantically, this is the right thing to do, so
7140238104Sdes	    #        that some nasty dependency loop isn't accidentally
7141238104Sdes	    #        broken:
7142238104Sdes	    #new_libs="$deplib $new_libs"
7143238104Sdes	    # Pragmatically, this seems to cause very few problems in
7144238104Sdes	    # practice:
7145238104Sdes	    case $deplib in
7146238104Sdes	    -L*) new_libs="$deplib $new_libs" ;;
7147238104Sdes	    -R*) ;;
7148238104Sdes	    *)
7149238104Sdes	      # And here is the reason: when a library appears more
7150238104Sdes	      # than once as an explicit dependence of a library, or
7151238104Sdes	      # is implicitly linked in more than once by the
7152238104Sdes	      # compiler, it is considered special, and multiple
7153238104Sdes	      # occurrences thereof are not removed.  Compare this
7154238104Sdes	      # with having the same library being listed as a
7155238104Sdes	      # dependency of multiple other libraries: in this case,
7156238104Sdes	      # we know (pedantically, we assume) the library does not
7157238104Sdes	      # need to be listed more than once, so we keep only the
7158238104Sdes	      # last copy.  This is not always right, but it is rare
7159238104Sdes	      # enough that we require users that really mean to play
7160238104Sdes	      # such unportable linking tricks to link the library
7161238104Sdes	      # using -Wl,-lname, so that libtool does not consider it
7162238104Sdes	      # for duplicate removal.
7163238104Sdes	      case " $specialdeplibs " in
7164238104Sdes	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
7165238104Sdes	      *)
7166238104Sdes		case " $new_libs " in
7167238104Sdes		*" $deplib "*) ;;
7168238104Sdes		*) new_libs="$deplib $new_libs" ;;
7169238104Sdes		esac
7170238104Sdes		;;
7171238104Sdes	      esac
7172238104Sdes	      ;;
7173238104Sdes	    esac
7174238104Sdes	  done
7175238104Sdes	  tmp_libs=
7176238104Sdes	  for deplib in $new_libs; do
7177238104Sdes	    case $deplib in
7178238104Sdes	    -L*)
7179238104Sdes	      case " $tmp_libs " in
7180238104Sdes	      *" $deplib "*) ;;
7181238104Sdes	      *) func_append tmp_libs " $deplib" ;;
7182238104Sdes	      esac
7183238104Sdes	      ;;
7184238104Sdes	    *) func_append tmp_libs " $deplib" ;;
7185238104Sdes	    esac
7186238104Sdes	  done
7187238104Sdes	  eval $var=\"$tmp_libs\"
7188238104Sdes	done # for var
7189238104Sdes      fi
7190238104Sdes      # Last step: remove runtime libs from dependency_libs
7191238104Sdes      # (they stay in deplibs)
7192238104Sdes      tmp_libs=
7193238104Sdes      for i in $dependency_libs ; do
7194238104Sdes	case " $predeps $postdeps $compiler_lib_search_path " in
7195238104Sdes	*" $i "*)
7196238104Sdes	  i=""
7197238104Sdes	  ;;
7198238104Sdes	esac
7199238104Sdes	if test -n "$i" ; then
7200238104Sdes	  func_append tmp_libs " $i"
7201238104Sdes	fi
7202238104Sdes      done
7203238104Sdes      dependency_libs=$tmp_libs
7204238104Sdes    done # for pass
7205238104Sdes    if test "$linkmode" = prog; then
7206238104Sdes      dlfiles="$newdlfiles"
7207238104Sdes    fi
7208238104Sdes    if test "$linkmode" = prog || test "$linkmode" = lib; then
7209238104Sdes      dlprefiles="$newdlprefiles"
7210238104Sdes    fi
7211238104Sdes
7212238104Sdes    case $linkmode in
7213238104Sdes    oldlib)
7214238104Sdes      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
7215238104Sdes	func_warning "\`-dlopen' is ignored for archives"
7216238104Sdes      fi
7217238104Sdes
7218238104Sdes      case " $deplibs" in
7219238104Sdes      *\ -l* | *\ -L*)
7220238104Sdes	func_warning "\`-l' and \`-L' are ignored for archives" ;;
7221238104Sdes      esac
7222238104Sdes
7223238104Sdes      test -n "$rpath" && \
7224238104Sdes	func_warning "\`-rpath' is ignored for archives"
7225238104Sdes
7226238104Sdes      test -n "$xrpath" && \
7227238104Sdes	func_warning "\`-R' is ignored for archives"
7228238104Sdes
7229238104Sdes      test -n "$vinfo" && \
7230238104Sdes	func_warning "\`-version-info/-version-number' is ignored for archives"
7231238104Sdes
7232238104Sdes      test -n "$release" && \
7233238104Sdes	func_warning "\`-release' is ignored for archives"
7234238104Sdes
7235238104Sdes      test -n "$export_symbols$export_symbols_regex" && \
7236238104Sdes	func_warning "\`-export-symbols' is ignored for archives"
7237238104Sdes
7238238104Sdes      # Now set the variables for building old libraries.
7239238104Sdes      build_libtool_libs=no
7240238104Sdes      oldlibs="$output"
7241238104Sdes      func_append objs "$old_deplibs"
7242238104Sdes      ;;
7243238104Sdes
7244238104Sdes    lib)
7245238104Sdes      # Make sure we only generate libraries of the form `libNAME.la'.
7246238104Sdes      case $outputname in
7247238104Sdes      lib*)
7248238104Sdes	func_stripname 'lib' '.la' "$outputname"
7249238104Sdes	name=$func_stripname_result
7250238104Sdes	eval shared_ext=\"$shrext_cmds\"
7251238104Sdes	eval libname=\"$libname_spec\"
7252238104Sdes	;;
7253238104Sdes      *)
7254238104Sdes	test "$module" = no && \
7255238104Sdes	  func_fatal_help "libtool library \`$output' must begin with \`lib'"
7256238104Sdes
7257238104Sdes	if test "$need_lib_prefix" != no; then
7258238104Sdes	  # Add the "lib" prefix for modules if required
7259238104Sdes	  func_stripname '' '.la' "$outputname"
7260238104Sdes	  name=$func_stripname_result
7261238104Sdes	  eval shared_ext=\"$shrext_cmds\"
7262238104Sdes	  eval libname=\"$libname_spec\"
7263238104Sdes	else
7264238104Sdes	  func_stripname '' '.la' "$outputname"
7265238104Sdes	  libname=$func_stripname_result
7266238104Sdes	fi
7267238104Sdes	;;
7268238104Sdes      esac
7269238104Sdes
7270238104Sdes      if test -n "$objs"; then
7271238104Sdes	if test "$deplibs_check_method" != pass_all; then
7272238104Sdes	  func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs"
7273238104Sdes	else
7274238104Sdes	  echo
7275238104Sdes	  $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
7276238104Sdes	  $ECHO "*** objects $objs is not portable!"
7277238104Sdes	  func_append libobjs " $objs"
7278238104Sdes	fi
7279238104Sdes      fi
7280238104Sdes
7281238104Sdes      test "$dlself" != no && \
7282238104Sdes	func_warning "\`-dlopen self' is ignored for libtool libraries"
7283238104Sdes
7284238104Sdes      set dummy $rpath
7285238104Sdes      shift
7286238104Sdes      test "$#" -gt 1 && \
7287238104Sdes	func_warning "ignoring multiple \`-rpath's for a libtool library"
7288238104Sdes
7289238104Sdes      install_libdir="$1"
7290238104Sdes
7291238104Sdes      oldlibs=
7292238104Sdes      if test -z "$rpath"; then
7293238104Sdes	if test "$build_libtool_libs" = yes; then
7294238104Sdes	  # Building a libtool convenience library.
7295238104Sdes	  # Some compilers have problems with a `.al' extension so
7296238104Sdes	  # convenience libraries should have the same extension an
7297238104Sdes	  # archive normally would.
7298238104Sdes	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
7299238104Sdes	  build_libtool_libs=convenience
7300238104Sdes	  build_old_libs=yes
7301238104Sdes	fi
7302238104Sdes
7303238104Sdes	test -n "$vinfo" && \
7304238104Sdes	  func_warning "\`-version-info/-version-number' is ignored for convenience libraries"
7305238104Sdes
7306238104Sdes	test -n "$release" && \
7307238104Sdes	  func_warning "\`-release' is ignored for convenience libraries"
7308238104Sdes      else
7309238104Sdes
7310238104Sdes	# Parse the version information argument.
7311238104Sdes	save_ifs="$IFS"; IFS=':'
7312238104Sdes	set dummy $vinfo 0 0 0
7313238104Sdes	shift
7314238104Sdes	IFS="$save_ifs"
7315238104Sdes
7316238104Sdes	test -n "$7" && \
7317238104Sdes	  func_fatal_help "too many parameters to \`-version-info'"
7318238104Sdes
7319238104Sdes	# convert absolute version numbers to libtool ages
7320238104Sdes	# this retains compatibility with .la files and attempts
7321238104Sdes	# to make the code below a bit more comprehensible
7322238104Sdes
7323238104Sdes	case $vinfo_number in
7324238104Sdes	yes)
7325238104Sdes	  number_major="$1"
7326238104Sdes	  number_minor="$2"
7327238104Sdes	  number_revision="$3"
7328238104Sdes	  #
7329238104Sdes	  # There are really only two kinds -- those that
7330238104Sdes	  # use the current revision as the major version
7331238104Sdes	  # and those that subtract age and use age as
7332238104Sdes	  # a minor version.  But, then there is irix
7333238104Sdes	  # which has an extra 1 added just for fun
7334238104Sdes	  #
7335238104Sdes	  case $version_type in
7336238104Sdes	  # correct linux to gnu/linux during the next big refactor
7337238104Sdes	  darwin|linux|osf|windows|none)
7338238104Sdes	    func_arith $number_major + $number_minor
7339238104Sdes	    current=$func_arith_result
7340238104Sdes	    age="$number_minor"
7341238104Sdes	    revision="$number_revision"
7342238104Sdes	    ;;
7343238104Sdes	  freebsd-aout|freebsd-elf|qnx|sunos)
7344238104Sdes	    current="$number_major"
7345238104Sdes	    revision="$number_minor"
7346238104Sdes	    age="0"
7347238104Sdes	    ;;
7348238104Sdes	  irix|nonstopux)
7349238104Sdes	    func_arith $number_major + $number_minor
7350238104Sdes	    current=$func_arith_result
7351238104Sdes	    age="$number_minor"
7352238104Sdes	    revision="$number_minor"
7353238104Sdes	    lt_irix_increment=no
7354238104Sdes	    ;;
7355238104Sdes	  *)
7356238104Sdes	    func_fatal_configuration "$modename: unknown library version type \`$version_type'"
7357238104Sdes	    ;;
7358238104Sdes	  esac
7359238104Sdes	  ;;
7360238104Sdes	no)
7361238104Sdes	  current="$1"
7362238104Sdes	  revision="$2"
7363238104Sdes	  age="$3"
7364238104Sdes	  ;;
7365238104Sdes	esac
7366238104Sdes
7367238104Sdes	# Check that each of the things are valid numbers.
7368238104Sdes	case $current in
7369238104Sdes	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]) ;;
7370238104Sdes	*)
7371238104Sdes	  func_error "CURRENT \`$current' must be a nonnegative integer"
7372238104Sdes	  func_fatal_error "\`$vinfo' is not valid version information"
7373238104Sdes	  ;;
7374238104Sdes	esac
7375238104Sdes
7376238104Sdes	case $revision in
7377238104Sdes	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]) ;;
7378238104Sdes	*)
7379238104Sdes	  func_error "REVISION \`$revision' must be a nonnegative integer"
7380238104Sdes	  func_fatal_error "\`$vinfo' is not valid version information"
7381238104Sdes	  ;;
7382238104Sdes	esac
7383238104Sdes
7384238104Sdes	case $age in
7385238104Sdes	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]) ;;
7386238104Sdes	*)
7387238104Sdes	  func_error "AGE \`$age' must be a nonnegative integer"
7388238104Sdes	  func_fatal_error "\`$vinfo' is not valid version information"
7389238104Sdes	  ;;
7390238104Sdes	esac
7391238104Sdes
7392238104Sdes	if test "$age" -gt "$current"; then
7393238104Sdes	  func_error "AGE \`$age' is greater than the current interface number \`$current'"
7394238104Sdes	  func_fatal_error "\`$vinfo' is not valid version information"
7395238104Sdes	fi
7396238104Sdes
7397238104Sdes	# Calculate the version variables.
7398238104Sdes	major=
7399238104Sdes	versuffix=
7400238104Sdes	verstring=
7401238104Sdes	case $version_type in
7402238104Sdes	none) ;;
7403238104Sdes
7404238104Sdes	darwin)
7405238104Sdes	  # Like Linux, but with the current version available in
7406238104Sdes	  # verstring for coding it into the library header
7407238104Sdes	  func_arith $current - $age
7408238104Sdes	  major=.$func_arith_result
7409238104Sdes	  versuffix="$major.$age.$revision"
7410238104Sdes	  # Darwin ld doesn't like 0 for these options...
7411238104Sdes	  func_arith $current + 1
7412238104Sdes	  minor_current=$func_arith_result
7413238104Sdes	  xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
7414238104Sdes	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
7415238104Sdes	  ;;
7416238104Sdes
7417238104Sdes	freebsd-aout)
7418238104Sdes	  major=".$current"
7419238104Sdes	  versuffix=".$current.$revision";
7420238104Sdes	  ;;
7421238104Sdes
7422238104Sdes	freebsd-elf)
7423238104Sdes	  major=".$current"
7424238104Sdes	  versuffix=".$current"
7425238104Sdes	  ;;
7426238104Sdes
7427238104Sdes	irix | nonstopux)
7428238104Sdes	  if test "X$lt_irix_increment" = "Xno"; then
7429238104Sdes	    func_arith $current - $age
7430238104Sdes	  else
7431238104Sdes	    func_arith $current - $age + 1
7432238104Sdes	  fi
7433238104Sdes	  major=$func_arith_result
7434238104Sdes
7435238104Sdes	  case $version_type in
7436238104Sdes	    nonstopux) verstring_prefix=nonstopux ;;
7437238104Sdes	    *)         verstring_prefix=sgi ;;
7438238104Sdes	  esac
7439238104Sdes	  verstring="$verstring_prefix$major.$revision"
7440238104Sdes
7441238104Sdes	  # Add in all the interfaces that we are compatible with.
7442238104Sdes	  loop=$revision
7443238104Sdes	  while test "$loop" -ne 0; do
7444238104Sdes	    func_arith $revision - $loop
7445238104Sdes	    iface=$func_arith_result
7446238104Sdes	    func_arith $loop - 1
7447238104Sdes	    loop=$func_arith_result
7448238104Sdes	    verstring="$verstring_prefix$major.$iface:$verstring"
7449238104Sdes	  done
7450238104Sdes
7451238104Sdes	  # Before this point, $major must not contain `.'.
7452238104Sdes	  major=.$major
7453238104Sdes	  versuffix="$major.$revision"
7454238104Sdes	  ;;
7455238104Sdes
7456238104Sdes	linux) # correct to gnu/linux during the next big refactor
7457238104Sdes	  func_arith $current - $age
7458238104Sdes	  major=.$func_arith_result
7459238104Sdes	  versuffix="$major.$age.$revision"
7460238104Sdes	  ;;
7461238104Sdes
7462238104Sdes	osf)
7463238104Sdes	  func_arith $current - $age
7464238104Sdes	  major=.$func_arith_result
7465238104Sdes	  versuffix=".$current.$age.$revision"
7466238104Sdes	  verstring="$current.$age.$revision"
7467238104Sdes
7468238104Sdes	  # Add in all the interfaces that we are compatible with.
7469238104Sdes	  loop=$age
7470238104Sdes	  while test "$loop" -ne 0; do
7471238104Sdes	    func_arith $current - $loop
7472238104Sdes	    iface=$func_arith_result
7473238104Sdes	    func_arith $loop - 1
7474238104Sdes	    loop=$func_arith_result
7475238104Sdes	    verstring="$verstring:${iface}.0"
7476238104Sdes	  done
7477238104Sdes
7478238104Sdes	  # Make executables depend on our current version.
7479238104Sdes	  func_append verstring ":${current}.0"
7480238104Sdes	  ;;
7481238104Sdes
7482238104Sdes	qnx)
7483238104Sdes	  major=".$current"
7484238104Sdes	  versuffix=".$current"
7485238104Sdes	  ;;
7486238104Sdes
7487238104Sdes	sunos)
7488238104Sdes	  major=".$current"
7489238104Sdes	  versuffix=".$current.$revision"
7490238104Sdes	  ;;
7491238104Sdes
7492238104Sdes	windows)
7493238104Sdes	  # Use '-' rather than '.', since we only want one
7494238104Sdes	  # extension on DOS 8.3 filesystems.
7495238104Sdes	  func_arith $current - $age
7496238104Sdes	  major=$func_arith_result
7497238104Sdes	  versuffix="-$major"
7498238104Sdes	  ;;
7499238104Sdes
7500238104Sdes	*)
7501238104Sdes	  func_fatal_configuration "unknown library version type \`$version_type'"
7502238104Sdes	  ;;
7503238104Sdes	esac
7504238104Sdes
7505238104Sdes	# Clear the version info if we defaulted, and they specified a release.
7506238104Sdes	if test -z "$vinfo" && test -n "$release"; then
7507238104Sdes	  major=
7508238104Sdes	  case $version_type in
7509238104Sdes	  darwin)
7510238104Sdes	    # we can't check for "0.0" in archive_cmds due to quoting
7511238104Sdes	    # problems, so we reset it completely
7512238104Sdes	    verstring=
7513238104Sdes	    ;;
7514238104Sdes	  *)
7515238104Sdes	    verstring="0.0"
7516238104Sdes	    ;;
7517238104Sdes	  esac
7518238104Sdes	  if test "$need_version" = no; then
7519238104Sdes	    versuffix=
7520238104Sdes	  else
7521238104Sdes	    versuffix=".0.0"
7522238104Sdes	  fi
7523238104Sdes	fi
7524238104Sdes
7525238104Sdes	# Remove version info from name if versioning should be avoided
7526238104Sdes	if test "$avoid_version" = yes && test "$need_version" = no; then
7527238104Sdes	  major=
7528238104Sdes	  versuffix=
7529238104Sdes	  verstring=""
7530238104Sdes	fi
7531238104Sdes
7532238104Sdes	# Check to see if the archive will have undefined symbols.
7533238104Sdes	if test "$allow_undefined" = yes; then
7534238104Sdes	  if test "$allow_undefined_flag" = unsupported; then
7535238104Sdes	    func_warning "undefined symbols not allowed in $host shared libraries"
7536238104Sdes	    build_libtool_libs=no
7537238104Sdes	    build_old_libs=yes
7538238104Sdes	  fi
7539238104Sdes	else
7540238104Sdes	  # Don't allow undefined symbols.
7541238104Sdes	  allow_undefined_flag="$no_undefined_flag"
7542238104Sdes	fi
7543238104Sdes
7544238104Sdes      fi
7545238104Sdes
7546238104Sdes      func_generate_dlsyms "$libname" "$libname" "yes"
7547238104Sdes      func_append libobjs " $symfileobj"
7548238104Sdes      test "X$libobjs" = "X " && libobjs=
7549238104Sdes
7550238104Sdes      if test "$opt_mode" != relink; then
7551238104Sdes	# Remove our outputs, but don't remove object files since they
7552238104Sdes	# may have been created when compiling PIC objects.
7553238104Sdes	removelist=
7554238104Sdes	tempremovelist=`$ECHO "$output_objdir/*"`
7555238104Sdes	for p in $tempremovelist; do
7556238104Sdes	  case $p in
7557238104Sdes	    *.$objext | *.gcno)
7558238104Sdes	       ;;
7559238104Sdes	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
7560238104Sdes	       if test "X$precious_files_regex" != "X"; then
7561238104Sdes		 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
7562238104Sdes		 then
7563238104Sdes		   continue
7564238104Sdes		 fi
7565238104Sdes	       fi
7566238104Sdes	       func_append removelist " $p"
7567238104Sdes	       ;;
7568238104Sdes	    *) ;;
7569238104Sdes	  esac
7570238104Sdes	done
7571238104Sdes	test -n "$removelist" && \
7572238104Sdes	  func_show_eval "${RM}r \$removelist"
7573238104Sdes      fi
7574238104Sdes
7575238104Sdes      # Now set the variables for building old libraries.
7576238104Sdes      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
7577238104Sdes	func_append oldlibs " $output_objdir/$libname.$libext"
7578238104Sdes
7579238104Sdes	# Transform .lo files to .o files.
7580238104Sdes	oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP`
7581238104Sdes      fi
7582238104Sdes
7583238104Sdes      # Eliminate all temporary directories.
7584238104Sdes      #for path in $notinst_path; do
7585238104Sdes      #	lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
7586238104Sdes      #	deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
7587238104Sdes      #	dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
7588238104Sdes      #done
7589238104Sdes
7590238104Sdes      if test -n "$xrpath"; then
7591238104Sdes	# If the user specified any rpath flags, then add them.
7592238104Sdes	temp_xrpath=
7593238104Sdes	for libdir in $xrpath; do
7594238104Sdes	  func_replace_sysroot "$libdir"
7595238104Sdes	  func_append temp_xrpath " -R$func_replace_sysroot_result"
7596238104Sdes	  case "$finalize_rpath " in
7597238104Sdes	  *" $libdir "*) ;;
7598238104Sdes	  *) func_append finalize_rpath " $libdir" ;;
7599238104Sdes	  esac
7600238104Sdes	done
7601238104Sdes	if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
7602238104Sdes	  dependency_libs="$temp_xrpath $dependency_libs"
7603238104Sdes	fi
7604238104Sdes      fi
7605238104Sdes
7606238104Sdes      # Make sure dlfiles contains only unique files that won't be dlpreopened
7607238104Sdes      old_dlfiles="$dlfiles"
7608238104Sdes      dlfiles=
7609238104Sdes      for lib in $old_dlfiles; do
7610238104Sdes	case " $dlprefiles $dlfiles " in
7611238104Sdes	*" $lib "*) ;;
7612238104Sdes	*) func_append dlfiles " $lib" ;;
7613238104Sdes	esac
7614238104Sdes      done
7615238104Sdes
7616238104Sdes      # Make sure dlprefiles contains only unique files
7617238104Sdes      old_dlprefiles="$dlprefiles"
7618238104Sdes      dlprefiles=
7619238104Sdes      for lib in $old_dlprefiles; do
7620238104Sdes	case "$dlprefiles " in
7621238104Sdes	*" $lib "*) ;;
7622238104Sdes	*) func_append dlprefiles " $lib" ;;
7623238104Sdes	esac
7624238104Sdes      done
7625238104Sdes
7626238104Sdes      if test "$build_libtool_libs" = yes; then
7627238104Sdes	if test -n "$rpath"; then
7628238104Sdes	  case $host in
7629238104Sdes	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
7630238104Sdes	    # these systems don't actually have a c library (as such)!
7631238104Sdes	    ;;
7632238104Sdes	  *-*-rhapsody* | *-*-darwin1.[012])
7633238104Sdes	    # Rhapsody C library is in the System framework
7634238104Sdes	    func_append deplibs " System.ltframework"
7635238104Sdes	    ;;
7636238104Sdes	  *-*-netbsd*)
7637238104Sdes	    # Don't link with libc until the a.out ld.so is fixed.
7638238104Sdes	    ;;
7639238104Sdes	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
7640238104Sdes	    # Do not include libc due to us having libc/libc_r.
7641238104Sdes	    ;;
7642238104Sdes	  *-*-sco3.2v5* | *-*-sco5v6*)
7643238104Sdes	    # Causes problems with __ctype
7644238104Sdes	    ;;
7645238104Sdes	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
7646238104Sdes	    # Compiler inserts libc in the correct place for threads to work
7647238104Sdes	    ;;
7648238104Sdes	  *)
7649238104Sdes	    # Add libc to deplibs on all other systems if necessary.
7650238104Sdes	    if test "$build_libtool_need_lc" = "yes"; then
7651238104Sdes	      func_append deplibs " -lc"
7652238104Sdes	    fi
7653238104Sdes	    ;;
7654238104Sdes	  esac
7655238104Sdes	fi
7656238104Sdes
7657238104Sdes	# Transform deplibs into only deplibs that can be linked in shared.
7658238104Sdes	name_save=$name
7659238104Sdes	libname_save=$libname
7660238104Sdes	release_save=$release
7661238104Sdes	versuffix_save=$versuffix
7662238104Sdes	major_save=$major
7663238104Sdes	# I'm not sure if I'm treating the release correctly.  I think
7664238104Sdes	# release should show up in the -l (ie -lgmp5) so we don't want to
7665238104Sdes	# add it in twice.  Is that correct?
7666238104Sdes	release=""
7667238104Sdes	versuffix=""
7668238104Sdes	major=""
7669238104Sdes	newdeplibs=
7670238104Sdes	droppeddeps=no
7671238104Sdes	case $deplibs_check_method in
7672238104Sdes	pass_all)
7673238104Sdes	  # Don't check for shared/static.  Everything works.
7674238104Sdes	  # This might be a little naive.  We might want to check
7675238104Sdes	  # whether the library exists or not.  But this is on
7676238104Sdes	  # osf3 & osf4 and I'm not really sure... Just
7677238104Sdes	  # implementing what was already the behavior.
7678238104Sdes	  newdeplibs=$deplibs
7679238104Sdes	  ;;
7680238104Sdes	test_compile)
7681238104Sdes	  # This code stresses the "libraries are programs" paradigm to its
7682238104Sdes	  # limits. Maybe even breaks it.  We compile a program, linking it
7683238104Sdes	  # against the deplibs as a proxy for the library.  Then we can check
7684238104Sdes	  # whether they linked in statically or dynamically with ldd.
7685238104Sdes	  $opt_dry_run || $RM conftest.c
7686238104Sdes	  cat > conftest.c <<EOF
7687238104Sdes	  int main() { return 0; }
7688238104SdesEOF
7689238104Sdes	  $opt_dry_run || $RM conftest
7690238104Sdes	  if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
7691238104Sdes	    ldd_output=`ldd conftest`
7692238104Sdes	    for i in $deplibs; do
7693238104Sdes	      case $i in
7694238104Sdes	      -l*)
7695238104Sdes		func_stripname -l '' "$i"
7696238104Sdes		name=$func_stripname_result
7697238104Sdes		if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7698238104Sdes		  case " $predeps $postdeps " in
7699238104Sdes		  *" $i "*)
7700238104Sdes		    func_append newdeplibs " $i"
7701238104Sdes		    i=""
7702238104Sdes		    ;;
7703238104Sdes		  esac
7704238104Sdes		fi
7705238104Sdes		if test -n "$i" ; then
7706238104Sdes		  libname=`eval "\\$ECHO \"$libname_spec\""`
7707238104Sdes		  deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
7708238104Sdes		  set dummy $deplib_matches; shift
7709238104Sdes		  deplib_match=$1
7710238104Sdes		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
7711238104Sdes		    func_append newdeplibs " $i"
7712238104Sdes		  else
7713238104Sdes		    droppeddeps=yes
7714238104Sdes		    echo
7715238104Sdes		    $ECHO "*** Warning: dynamic linker does not accept needed library $i."
7716238104Sdes		    echo "*** I have the capability to make that library automatically link in when"
7717238104Sdes		    echo "*** you link to this library.  But I can only do this if you have a"
7718238104Sdes		    echo "*** shared version of the library, which I believe you do not have"
7719238104Sdes		    echo "*** because a test_compile did reveal that the linker did not use it for"
7720238104Sdes		    echo "*** its dynamic dependency list that programs get resolved with at runtime."
7721238104Sdes		  fi
7722238104Sdes		fi
7723238104Sdes		;;
7724238104Sdes	      *)
7725238104Sdes		func_append newdeplibs " $i"
7726238104Sdes		;;
7727238104Sdes	      esac
7728238104Sdes	    done
7729238104Sdes	  else
7730238104Sdes	    # Error occurred in the first compile.  Let's try to salvage
7731238104Sdes	    # the situation: Compile a separate program for each library.
7732238104Sdes	    for i in $deplibs; do
7733238104Sdes	      case $i in
7734238104Sdes	      -l*)
7735238104Sdes		func_stripname -l '' "$i"
7736238104Sdes		name=$func_stripname_result
7737238104Sdes		$opt_dry_run || $RM conftest
7738238104Sdes		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
7739238104Sdes		  ldd_output=`ldd conftest`
7740238104Sdes		  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7741238104Sdes		    case " $predeps $postdeps " in
7742238104Sdes		    *" $i "*)
7743238104Sdes		      func_append newdeplibs " $i"
7744238104Sdes		      i=""
7745238104Sdes		      ;;
7746238104Sdes		    esac
7747238104Sdes		  fi
7748238104Sdes		  if test -n "$i" ; then
7749238104Sdes		    libname=`eval "\\$ECHO \"$libname_spec\""`
7750238104Sdes		    deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
7751238104Sdes		    set dummy $deplib_matches; shift
7752238104Sdes		    deplib_match=$1
7753238104Sdes		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
7754238104Sdes		      func_append newdeplibs " $i"
7755238104Sdes		    else
7756238104Sdes		      droppeddeps=yes
7757238104Sdes		      echo
7758238104Sdes		      $ECHO "*** Warning: dynamic linker does not accept needed library $i."
7759238104Sdes		      echo "*** I have the capability to make that library automatically link in when"
7760238104Sdes		      echo "*** you link to this library.  But I can only do this if you have a"
7761238104Sdes		      echo "*** shared version of the library, which you do not appear to have"
7762238104Sdes		      echo "*** because a test_compile did reveal that the linker did not use this one"
7763238104Sdes		      echo "*** as a dynamic dependency that programs can get resolved with at runtime."
7764238104Sdes		    fi
7765238104Sdes		  fi
7766238104Sdes		else
7767238104Sdes		  droppeddeps=yes
7768238104Sdes		  echo
7769238104Sdes		  $ECHO "*** Warning!  Library $i is needed by this library but I was not able to"
7770238104Sdes		  echo "*** make it link in!  You will probably need to install it or some"
7771238104Sdes		  echo "*** library that it depends on before this library will be fully"
7772238104Sdes		  echo "*** functional.  Installing it before continuing would be even better."
7773238104Sdes		fi
7774238104Sdes		;;
7775238104Sdes	      *)
7776238104Sdes		func_append newdeplibs " $i"
7777238104Sdes		;;
7778238104Sdes	      esac
7779238104Sdes	    done
7780238104Sdes	  fi
7781238104Sdes	  ;;
7782238104Sdes	file_magic*)
7783238104Sdes	  set dummy $deplibs_check_method; shift
7784238104Sdes	  file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
7785238104Sdes	  for a_deplib in $deplibs; do
7786238104Sdes	    case $a_deplib in
7787238104Sdes	    -l*)
7788238104Sdes	      func_stripname -l '' "$a_deplib"
7789238104Sdes	      name=$func_stripname_result
7790238104Sdes	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7791238104Sdes		case " $predeps $postdeps " in
7792238104Sdes		*" $a_deplib "*)
7793238104Sdes		  func_append newdeplibs " $a_deplib"
7794238104Sdes		  a_deplib=""
7795238104Sdes		  ;;
7796238104Sdes		esac
7797238104Sdes	      fi
7798238104Sdes	      if test -n "$a_deplib" ; then
7799238104Sdes		libname=`eval "\\$ECHO \"$libname_spec\""`
7800238104Sdes		if test -n "$file_magic_glob"; then
7801238104Sdes		  libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob`
7802238104Sdes		else
7803238104Sdes		  libnameglob=$libname
7804238104Sdes		fi
7805238104Sdes		test "$want_nocaseglob" = yes && nocaseglob=`shopt -p nocaseglob`
7806238104Sdes		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
7807238104Sdes		  if test "$want_nocaseglob" = yes; then
7808238104Sdes		    shopt -s nocaseglob
7809238104Sdes		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
7810238104Sdes		    $nocaseglob
7811238104Sdes		  else
7812238104Sdes		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
7813238104Sdes		  fi
7814238104Sdes		  for potent_lib in $potential_libs; do
7815238104Sdes		      # Follow soft links.
7816238104Sdes		      if ls -lLd "$potent_lib" 2>/dev/null |
7817238104Sdes			 $GREP " -> " >/dev/null; then
7818238104Sdes			continue
7819238104Sdes		      fi
7820238104Sdes		      # The statement above tries to avoid entering an
7821238104Sdes		      # endless loop below, in case of cyclic links.
7822238104Sdes		      # We might still enter an endless loop, since a link
7823238104Sdes		      # loop can be closed while we follow links,
7824238104Sdes		      # but so what?
7825238104Sdes		      potlib="$potent_lib"
7826238104Sdes		      while test -h "$potlib" 2>/dev/null; do
7827238104Sdes			potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
7828238104Sdes			case $potliblink in
7829238104Sdes			[\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
7830238104Sdes			*) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";;
7831238104Sdes			esac
7832238104Sdes		      done
7833238104Sdes		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
7834238104Sdes			 $SED -e 10q |
7835238104Sdes			 $EGREP "$file_magic_regex" > /dev/null; then
7836238104Sdes			func_append newdeplibs " $a_deplib"
7837238104Sdes			a_deplib=""
7838238104Sdes			break 2
7839238104Sdes		      fi
7840238104Sdes		  done
7841238104Sdes		done
7842238104Sdes	      fi
7843238104Sdes	      if test -n "$a_deplib" ; then
7844238104Sdes		droppeddeps=yes
7845238104Sdes		echo
7846238104Sdes		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
7847238104Sdes		echo "*** I have the capability to make that library automatically link in when"
7848238104Sdes		echo "*** you link to this library.  But I can only do this if you have a"
7849238104Sdes		echo "*** shared version of the library, which you do not appear to have"
7850238104Sdes		echo "*** because I did check the linker path looking for a file starting"
7851238104Sdes		if test -z "$potlib" ; then
7852238104Sdes		  $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
7853238104Sdes		else
7854238104Sdes		  $ECHO "*** with $libname and none of the candidates passed a file format test"
7855238104Sdes		  $ECHO "*** using a file magic. Last file checked: $potlib"
7856238104Sdes		fi
7857238104Sdes	      fi
7858238104Sdes	      ;;
7859238104Sdes	    *)
7860238104Sdes	      # Add a -L argument.
7861238104Sdes	      func_append newdeplibs " $a_deplib"
7862238104Sdes	      ;;
7863238104Sdes	    esac
7864238104Sdes	  done # Gone through all deplibs.
7865238104Sdes	  ;;
7866238104Sdes	match_pattern*)
7867238104Sdes	  set dummy $deplibs_check_method; shift
7868238104Sdes	  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
7869238104Sdes	  for a_deplib in $deplibs; do
7870238104Sdes	    case $a_deplib in
7871238104Sdes	    -l*)
7872238104Sdes	      func_stripname -l '' "$a_deplib"
7873238104Sdes	      name=$func_stripname_result
7874238104Sdes	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7875238104Sdes		case " $predeps $postdeps " in
7876238104Sdes		*" $a_deplib "*)
7877238104Sdes		  func_append newdeplibs " $a_deplib"
7878238104Sdes		  a_deplib=""
7879238104Sdes		  ;;
7880238104Sdes		esac
7881238104Sdes	      fi
7882238104Sdes	      if test -n "$a_deplib" ; then
7883238104Sdes		libname=`eval "\\$ECHO \"$libname_spec\""`
7884238104Sdes		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
7885238104Sdes		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
7886238104Sdes		  for potent_lib in $potential_libs; do
7887238104Sdes		    potlib="$potent_lib" # see symlink-check above in file_magic test
7888238104Sdes		    if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
7889238104Sdes		       $EGREP "$match_pattern_regex" > /dev/null; then
7890238104Sdes		      func_append newdeplibs " $a_deplib"
7891238104Sdes		      a_deplib=""
7892238104Sdes		      break 2
7893238104Sdes		    fi
7894238104Sdes		  done
7895238104Sdes		done
7896238104Sdes	      fi
7897238104Sdes	      if test -n "$a_deplib" ; then
7898238104Sdes		droppeddeps=yes
7899238104Sdes		echo
7900238104Sdes		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
7901238104Sdes		echo "*** I have the capability to make that library automatically link in when"
7902238104Sdes		echo "*** you link to this library.  But I can only do this if you have a"
7903238104Sdes		echo "*** shared version of the library, which you do not appear to have"
7904238104Sdes		echo "*** because I did check the linker path looking for a file starting"
7905238104Sdes		if test -z "$potlib" ; then
7906238104Sdes		  $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
7907238104Sdes		else
7908238104Sdes		  $ECHO "*** with $libname and none of the candidates passed a file format test"
7909238104Sdes		  $ECHO "*** using a regex pattern. Last file checked: $potlib"
7910238104Sdes		fi
7911238104Sdes	      fi
7912238104Sdes	      ;;
7913238104Sdes	    *)
7914238104Sdes	      # Add a -L argument.
7915238104Sdes	      func_append newdeplibs " $a_deplib"
7916238104Sdes	      ;;
7917238104Sdes	    esac
7918238104Sdes	  done # Gone through all deplibs.
7919238104Sdes	  ;;
7920238104Sdes	none | unknown | *)
7921238104Sdes	  newdeplibs=""
7922238104Sdes	  tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
7923238104Sdes	  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7924238104Sdes	    for i in $predeps $postdeps ; do
7925238104Sdes	      # can't use Xsed below, because $i might contain '/'
7926238104Sdes	      tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"`
7927238104Sdes	    done
7928238104Sdes	  fi
7929238104Sdes	  case $tmp_deplibs in
7930238104Sdes	  *[!\	\ ]*)
7931238104Sdes	    echo
7932238104Sdes	    if test "X$deplibs_check_method" = "Xnone"; then
7933238104Sdes	      echo "*** Warning: inter-library dependencies are not supported in this platform."
7934238104Sdes	    else
7935238104Sdes	      echo "*** Warning: inter-library dependencies are not known to be supported."
7936238104Sdes	    fi
7937238104Sdes	    echo "*** All declared inter-library dependencies are being dropped."
7938238104Sdes	    droppeddeps=yes
7939238104Sdes	    ;;
7940238104Sdes	  esac
7941238104Sdes	  ;;
7942238104Sdes	esac
7943238104Sdes	versuffix=$versuffix_save
7944238104Sdes	major=$major_save
7945238104Sdes	release=$release_save
7946238104Sdes	libname=$libname_save
7947238104Sdes	name=$name_save
7948238104Sdes
7949238104Sdes	case $host in
7950238104Sdes	*-*-rhapsody* | *-*-darwin1.[012])
7951238104Sdes	  # On Rhapsody replace the C library with the System framework
7952238104Sdes	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
7953238104Sdes	  ;;
7954238104Sdes	esac
7955238104Sdes
7956238104Sdes	if test "$droppeddeps" = yes; then
7957238104Sdes	  if test "$module" = yes; then
7958238104Sdes	    echo
7959238104Sdes	    echo "*** Warning: libtool could not satisfy all declared inter-library"
7960238104Sdes	    $ECHO "*** dependencies of module $libname.  Therefore, libtool will create"
7961238104Sdes	    echo "*** a static module, that should work as long as the dlopening"
7962238104Sdes	    echo "*** application is linked with the -dlopen flag."
7963238104Sdes	    if test -z "$global_symbol_pipe"; then
7964238104Sdes	      echo
7965238104Sdes	      echo "*** However, this would only work if libtool was able to extract symbol"
7966238104Sdes	      echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
7967238104Sdes	      echo "*** not find such a program.  So, this module is probably useless."
7968238104Sdes	      echo "*** \`nm' from GNU binutils and a full rebuild may help."
7969238104Sdes	    fi
7970238104Sdes	    if test "$build_old_libs" = no; then
7971238104Sdes	      oldlibs="$output_objdir/$libname.$libext"
7972238104Sdes	      build_libtool_libs=module
7973238104Sdes	      build_old_libs=yes
7974238104Sdes	    else
7975238104Sdes	      build_libtool_libs=no
7976238104Sdes	    fi
7977238104Sdes	  else
7978238104Sdes	    echo "*** The inter-library dependencies that have been dropped here will be"
7979238104Sdes	    echo "*** automatically added whenever a program is linked with this library"
7980238104Sdes	    echo "*** or is declared to -dlopen it."
7981238104Sdes
7982238104Sdes	    if test "$allow_undefined" = no; then
7983238104Sdes	      echo
7984238104Sdes	      echo "*** Since this library must not contain undefined symbols,"
7985238104Sdes	      echo "*** because either the platform does not support them or"
7986238104Sdes	      echo "*** it was explicitly requested with -no-undefined,"
7987238104Sdes	      echo "*** libtool will only create a static version of it."
7988238104Sdes	      if test "$build_old_libs" = no; then
7989238104Sdes		oldlibs="$output_objdir/$libname.$libext"
7990238104Sdes		build_libtool_libs=module
7991238104Sdes		build_old_libs=yes
7992238104Sdes	      else
7993238104Sdes		build_libtool_libs=no
7994238104Sdes	      fi
7995238104Sdes	    fi
7996238104Sdes	  fi
7997238104Sdes	fi
7998238104Sdes	# Done checking deplibs!
7999238104Sdes	deplibs=$newdeplibs
8000238104Sdes      fi
8001238104Sdes      # Time to change all our "foo.ltframework" stuff back to "-framework foo"
8002238104Sdes      case $host in
8003238104Sdes	*-*-darwin*)
8004238104Sdes	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8005238104Sdes	  new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8006238104Sdes	  deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8007238104Sdes	  ;;
8008238104Sdes      esac
8009238104Sdes
8010238104Sdes      # move library search paths that coincide with paths to not yet
8011238104Sdes      # installed libraries to the beginning of the library search list
8012238104Sdes      new_libs=
8013238104Sdes      for path in $notinst_path; do
8014238104Sdes	case " $new_libs " in
8015238104Sdes	*" -L$path/$objdir "*) ;;
8016238104Sdes	*)
8017238104Sdes	  case " $deplibs " in
8018238104Sdes	  *" -L$path/$objdir "*)
8019238104Sdes	    func_append new_libs " -L$path/$objdir" ;;
8020238104Sdes	  esac
8021238104Sdes	  ;;
8022238104Sdes	esac
8023238104Sdes      done
8024238104Sdes      for deplib in $deplibs; do
8025238104Sdes	case $deplib in
8026238104Sdes	-L*)
8027238104Sdes	  case " $new_libs " in
8028238104Sdes	  *" $deplib "*) ;;
8029238104Sdes	  *) func_append new_libs " $deplib" ;;
8030238104Sdes	  esac
8031238104Sdes	  ;;
8032238104Sdes	*) func_append new_libs " $deplib" ;;
8033238104Sdes	esac
8034238104Sdes      done
8035238104Sdes      deplibs="$new_libs"
8036238104Sdes
8037238104Sdes      # All the library-specific variables (install_libdir is set above).
8038238104Sdes      library_names=
8039238104Sdes      old_library=
8040238104Sdes      dlname=
8041238104Sdes
8042238104Sdes      # Test again, we may have decided not to build it any more
8043238104Sdes      if test "$build_libtool_libs" = yes; then
8044238104Sdes	# Remove ${wl} instances when linking with ld.
8045238104Sdes	# FIXME: should test the right _cmds variable.
8046238104Sdes	case $archive_cmds in
8047238104Sdes	  *\$LD\ *) wl= ;;
8048238104Sdes        esac
8049238104Sdes	if test "$hardcode_into_libs" = yes; then
8050238104Sdes	  # Hardcode the library paths
8051238104Sdes	  hardcode_libdirs=
8052238104Sdes	  dep_rpath=
8053238104Sdes	  rpath="$finalize_rpath"
8054238104Sdes	  test "$opt_mode" != relink && rpath="$compile_rpath$rpath"
8055238104Sdes	  for libdir in $rpath; do
8056238104Sdes	    if test -n "$hardcode_libdir_flag_spec"; then
8057238104Sdes	      if test -n "$hardcode_libdir_separator"; then
8058238104Sdes		func_replace_sysroot "$libdir"
8059238104Sdes		libdir=$func_replace_sysroot_result
8060238104Sdes		if test -z "$hardcode_libdirs"; then
8061238104Sdes		  hardcode_libdirs="$libdir"
8062238104Sdes		else
8063238104Sdes		  # Just accumulate the unique libdirs.
8064238104Sdes		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
8065238104Sdes		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
8066238104Sdes		    ;;
8067238104Sdes		  *)
8068238104Sdes		    func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
8069238104Sdes		    ;;
8070238104Sdes		  esac
8071238104Sdes		fi
8072238104Sdes	      else
8073238104Sdes		eval flag=\"$hardcode_libdir_flag_spec\"
8074238104Sdes		func_append dep_rpath " $flag"
8075238104Sdes	      fi
8076238104Sdes	    elif test -n "$runpath_var"; then
8077238104Sdes	      case "$perm_rpath " in
8078238104Sdes	      *" $libdir "*) ;;
8079238104Sdes	      *) func_append perm_rpath " $libdir" ;;
8080238104Sdes	      esac
8081238104Sdes	    fi
8082238104Sdes	  done
8083238104Sdes	  # Substitute the hardcoded libdirs into the rpath.
8084238104Sdes	  if test -n "$hardcode_libdir_separator" &&
8085238104Sdes	     test -n "$hardcode_libdirs"; then
8086238104Sdes	    libdir="$hardcode_libdirs"
8087238104Sdes	    eval "dep_rpath=\"$hardcode_libdir_flag_spec\""
8088238104Sdes	  fi
8089238104Sdes	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
8090238104Sdes	    # We should set the runpath_var.
8091238104Sdes	    rpath=
8092238104Sdes	    for dir in $perm_rpath; do
8093238104Sdes	      func_append rpath "$dir:"
8094238104Sdes	    done
8095238104Sdes	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
8096238104Sdes	  fi
8097238104Sdes	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
8098238104Sdes	fi
8099238104Sdes
8100238104Sdes	shlibpath="$finalize_shlibpath"
8101238104Sdes	test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
8102238104Sdes	if test -n "$shlibpath"; then
8103238104Sdes	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
8104238104Sdes	fi
8105238104Sdes
8106238104Sdes	# Get the real and link names of the library.
8107238104Sdes	eval shared_ext=\"$shrext_cmds\"
8108238104Sdes	eval library_names=\"$library_names_spec\"
8109238104Sdes	set dummy $library_names
8110238104Sdes	shift
8111238104Sdes	realname="$1"
8112238104Sdes	shift
8113238104Sdes
8114238104Sdes	if test -n "$soname_spec"; then
8115238104Sdes	  eval soname=\"$soname_spec\"
8116238104Sdes	else
8117238104Sdes	  soname="$realname"
8118238104Sdes	fi
8119238104Sdes	if test -z "$dlname"; then
8120238104Sdes	  dlname=$soname
8121238104Sdes	fi
8122238104Sdes
8123238104Sdes	lib="$output_objdir/$realname"
8124238104Sdes	linknames=
8125238104Sdes	for link
8126238104Sdes	do
8127238104Sdes	  func_append linknames " $link"
8128238104Sdes	done
8129238104Sdes
8130238104Sdes	# Use standard objects if they are pic
8131238104Sdes	test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
8132238104Sdes	test "X$libobjs" = "X " && libobjs=
8133238104Sdes
8134238104Sdes	delfiles=
8135238104Sdes	if test -n "$export_symbols" && test -n "$include_expsyms"; then
8136238104Sdes	  $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
8137238104Sdes	  export_symbols="$output_objdir/$libname.uexp"
8138238104Sdes	  func_append delfiles " $export_symbols"
8139238104Sdes	fi
8140238104Sdes
8141238104Sdes	orig_export_symbols=
8142238104Sdes	case $host_os in
8143238104Sdes	cygwin* | mingw* | cegcc*)
8144238104Sdes	  if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
8145238104Sdes	    # exporting using user supplied symfile
8146238104Sdes	    if test "x`$SED 1q $export_symbols`" != xEXPORTS; then
8147238104Sdes	      # and it's NOT already a .def file. Must figure out
8148238104Sdes	      # which of the given symbols are data symbols and tag
8149238104Sdes	      # them as such. So, trigger use of export_symbols_cmds.
8150238104Sdes	      # export_symbols gets reassigned inside the "prepare
8151238104Sdes	      # the list of exported symbols" if statement, so the
8152238104Sdes	      # include_expsyms logic still works.
8153238104Sdes	      orig_export_symbols="$export_symbols"
8154238104Sdes	      export_symbols=
8155238104Sdes	      always_export_symbols=yes
8156238104Sdes	    fi
8157238104Sdes	  fi
8158238104Sdes	  ;;
8159238104Sdes	esac
8160238104Sdes
8161238104Sdes	# Prepare the list of exported symbols
8162238104Sdes	if test -z "$export_symbols"; then
8163238104Sdes	  if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
8164238104Sdes	    func_verbose "generating symbol list for \`$libname.la'"
8165238104Sdes	    export_symbols="$output_objdir/$libname.exp"
8166238104Sdes	    $opt_dry_run || $RM $export_symbols
8167238104Sdes	    cmds=$export_symbols_cmds
8168238104Sdes	    save_ifs="$IFS"; IFS='~'
8169238104Sdes	    for cmd1 in $cmds; do
8170238104Sdes	      IFS="$save_ifs"
8171238104Sdes	      # Take the normal branch if the nm_file_list_spec branch
8172238104Sdes	      # doesn't work or if tool conversion is not needed.
8173238104Sdes	      case $nm_file_list_spec~$to_tool_file_cmd in
8174238104Sdes		*~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*)
8175238104Sdes		  try_normal_branch=yes
8176238104Sdes		  eval cmd=\"$cmd1\"
8177238104Sdes		  func_len " $cmd"
8178238104Sdes		  len=$func_len_result
8179238104Sdes		  ;;
8180238104Sdes		*)
8181238104Sdes		  try_normal_branch=no
8182238104Sdes		  ;;
8183238104Sdes	      esac
8184238104Sdes	      if test "$try_normal_branch" = yes \
8185238104Sdes		 && { test "$len" -lt "$max_cmd_len" \
8186238104Sdes		      || test "$max_cmd_len" -le -1; }
8187238104Sdes	      then
8188238104Sdes		func_show_eval "$cmd" 'exit $?'
8189238104Sdes		skipped_export=false
8190238104Sdes	      elif test -n "$nm_file_list_spec"; then
8191238104Sdes		func_basename "$output"
8192238104Sdes		output_la=$func_basename_result
8193238104Sdes		save_libobjs=$libobjs
8194238104Sdes		save_output=$output
8195238104Sdes		output=${output_objdir}/${output_la}.nm
8196238104Sdes		func_to_tool_file "$output"
8197238104Sdes		libobjs=$nm_file_list_spec$func_to_tool_file_result
8198238104Sdes		func_append delfiles " $output"
8199238104Sdes		func_verbose "creating $NM input file list: $output"
8200238104Sdes		for obj in $save_libobjs; do
8201238104Sdes		  func_to_tool_file "$obj"
8202238104Sdes		  $ECHO "$func_to_tool_file_result"
8203238104Sdes		done > "$output"
8204238104Sdes		eval cmd=\"$cmd1\"
8205238104Sdes		func_show_eval "$cmd" 'exit $?'
8206238104Sdes		output=$save_output
8207238104Sdes		libobjs=$save_libobjs
8208238104Sdes		skipped_export=false
8209238104Sdes	      else
8210238104Sdes		# The command line is too long to execute in one step.
8211238104Sdes		func_verbose "using reloadable object file for export list..."
8212238104Sdes		skipped_export=:
8213238104Sdes		# Break out early, otherwise skipped_export may be
8214238104Sdes		# set to false by a later but shorter cmd.
8215238104Sdes		break
8216238104Sdes	      fi
8217238104Sdes	    done
8218238104Sdes	    IFS="$save_ifs"
8219238104Sdes	    if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then
8220238104Sdes	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
8221238104Sdes	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
8222238104Sdes	    fi
8223238104Sdes	  fi
8224238104Sdes	fi
8225238104Sdes
8226238104Sdes	if test -n "$export_symbols" && test -n "$include_expsyms"; then
8227238104Sdes	  tmp_export_symbols="$export_symbols"
8228238104Sdes	  test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
8229238104Sdes	  $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
8230238104Sdes	fi
8231238104Sdes
8232238104Sdes	if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then
8233238104Sdes	  # The given exports_symbols file has to be filtered, so filter it.
8234238104Sdes	  func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
8235238104Sdes	  # FIXME: $output_objdir/$libname.filter potentially contains lots of
8236238104Sdes	  # 's' commands which not all seds can handle. GNU sed should be fine
8237238104Sdes	  # though. Also, the filter scales superlinearly with the number of
8238238104Sdes	  # global variables. join(1) would be nice here, but unfortunately
8239238104Sdes	  # isn't a blessed tool.
8240238104Sdes	  $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
8241238104Sdes	  func_append delfiles " $export_symbols $output_objdir/$libname.filter"
8242238104Sdes	  export_symbols=$output_objdir/$libname.def
8243238104Sdes	  $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
8244238104Sdes	fi
8245238104Sdes
8246238104Sdes	tmp_deplibs=
8247238104Sdes	for test_deplib in $deplibs; do
8248238104Sdes	  case " $convenience " in
8249238104Sdes	  *" $test_deplib "*) ;;
8250238104Sdes	  *)
8251238104Sdes	    func_append tmp_deplibs " $test_deplib"
8252238104Sdes	    ;;
8253238104Sdes	  esac
8254238104Sdes	done
8255238104Sdes	deplibs="$tmp_deplibs"
8256238104Sdes
8257238104Sdes	if test -n "$convenience"; then
8258238104Sdes	  if test -n "$whole_archive_flag_spec" &&
8259238104Sdes	    test "$compiler_needs_object" = yes &&
8260238104Sdes	    test -z "$libobjs"; then
8261238104Sdes	    # extract the archives, so we have objects to list.
8262238104Sdes	    # TODO: could optimize this to just extract one archive.
8263238104Sdes	    whole_archive_flag_spec=
8264238104Sdes	  fi
8265238104Sdes	  if test -n "$whole_archive_flag_spec"; then
8266238104Sdes	    save_libobjs=$libobjs
8267238104Sdes	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
8268238104Sdes	    test "X$libobjs" = "X " && libobjs=
8269238104Sdes	  else
8270238104Sdes	    gentop="$output_objdir/${outputname}x"
8271238104Sdes	    func_append generated " $gentop"
8272238104Sdes
8273238104Sdes	    func_extract_archives $gentop $convenience
8274238104Sdes	    func_append libobjs " $func_extract_archives_result"
8275238104Sdes	    test "X$libobjs" = "X " && libobjs=
8276238104Sdes	  fi
8277238104Sdes	fi
8278238104Sdes
8279238104Sdes	if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
8280238104Sdes	  eval flag=\"$thread_safe_flag_spec\"
8281238104Sdes	  func_append linker_flags " $flag"
8282238104Sdes	fi
8283238104Sdes
8284238104Sdes	# Make a backup of the uninstalled library when relinking
8285238104Sdes	if test "$opt_mode" = relink; then
8286238104Sdes	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
8287238104Sdes	fi
8288238104Sdes
8289238104Sdes	# Do each of the archive commands.
8290238104Sdes	if test "$module" = yes && test -n "$module_cmds" ; then
8291238104Sdes	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
8292238104Sdes	    eval test_cmds=\"$module_expsym_cmds\"
8293238104Sdes	    cmds=$module_expsym_cmds
8294238104Sdes	  else
8295238104Sdes	    eval test_cmds=\"$module_cmds\"
8296238104Sdes	    cmds=$module_cmds
8297238104Sdes	  fi
8298238104Sdes	else
8299238104Sdes	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
8300238104Sdes	    eval test_cmds=\"$archive_expsym_cmds\"
8301238104Sdes	    cmds=$archive_expsym_cmds
8302238104Sdes	  else
8303238104Sdes	    eval test_cmds=\"$archive_cmds\"
8304238104Sdes	    cmds=$archive_cmds
8305238104Sdes	  fi
8306238104Sdes	fi
8307238104Sdes
8308238104Sdes	if test "X$skipped_export" != "X:" &&
8309238104Sdes	   func_len " $test_cmds" &&
8310238104Sdes	   len=$func_len_result &&
8311238104Sdes	   test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
8312238104Sdes	  :
8313238104Sdes	else
8314238104Sdes	  # The command line is too long to link in one step, link piecewise
8315238104Sdes	  # or, if using GNU ld and skipped_export is not :, use a linker
8316238104Sdes	  # script.
8317238104Sdes
8318238104Sdes	  # Save the value of $output and $libobjs because we want to
8319238104Sdes	  # use them later.  If we have whole_archive_flag_spec, we
8320238104Sdes	  # want to use save_libobjs as it was before
8321238104Sdes	  # whole_archive_flag_spec was expanded, because we can't
8322238104Sdes	  # assume the linker understands whole_archive_flag_spec.
8323238104Sdes	  # This may have to be revisited, in case too many
8324238104Sdes	  # convenience libraries get linked in and end up exceeding
8325238104Sdes	  # the spec.
8326238104Sdes	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
8327238104Sdes	    save_libobjs=$libobjs
8328238104Sdes	  fi
8329238104Sdes	  save_output=$output
8330238104Sdes	  func_basename "$output"
8331238104Sdes	  output_la=$func_basename_result
8332238104Sdes
8333238104Sdes	  # Clear the reloadable object creation command queue and
8334238104Sdes	  # initialize k to one.
8335238104Sdes	  test_cmds=
8336238104Sdes	  concat_cmds=
8337238104Sdes	  objlist=
8338238104Sdes	  last_robj=
8339238104Sdes	  k=1
8340238104Sdes
8341238104Sdes	  if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
8342238104Sdes	    output=${output_objdir}/${output_la}.lnkscript
8343238104Sdes	    func_verbose "creating GNU ld script: $output"
8344238104Sdes	    echo 'INPUT (' > $output
8345238104Sdes	    for obj in $save_libobjs
8346238104Sdes	    do
8347238104Sdes	      func_to_tool_file "$obj"
8348238104Sdes	      $ECHO "$func_to_tool_file_result" >> $output
8349238104Sdes	    done
8350238104Sdes	    echo ')' >> $output
8351238104Sdes	    func_append delfiles " $output"
8352238104Sdes	    func_to_tool_file "$output"
8353238104Sdes	    output=$func_to_tool_file_result
8354238104Sdes	  elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then
8355238104Sdes	    output=${output_objdir}/${output_la}.lnk
8356238104Sdes	    func_verbose "creating linker input file list: $output"
8357238104Sdes	    : > $output
8358238104Sdes	    set x $save_libobjs
8359238104Sdes	    shift
8360238104Sdes	    firstobj=
8361238104Sdes	    if test "$compiler_needs_object" = yes; then
8362238104Sdes	      firstobj="$1 "
8363238104Sdes	      shift
8364238104Sdes	    fi
8365238104Sdes	    for obj
8366238104Sdes	    do
8367238104Sdes	      func_to_tool_file "$obj"
8368238104Sdes	      $ECHO "$func_to_tool_file_result" >> $output
8369238104Sdes	    done
8370238104Sdes	    func_append delfiles " $output"
8371238104Sdes	    func_to_tool_file "$output"
8372238104Sdes	    output=$firstobj\"$file_list_spec$func_to_tool_file_result\"
8373238104Sdes	  else
8374238104Sdes	    if test -n "$save_libobjs"; then
8375238104Sdes	      func_verbose "creating reloadable object files..."
8376238104Sdes	      output=$output_objdir/$output_la-${k}.$objext
8377238104Sdes	      eval test_cmds=\"$reload_cmds\"
8378238104Sdes	      func_len " $test_cmds"
8379238104Sdes	      len0=$func_len_result
8380238104Sdes	      len=$len0
8381238104Sdes
8382238104Sdes	      # Loop over the list of objects to be linked.
8383238104Sdes	      for obj in $save_libobjs
8384238104Sdes	      do
8385238104Sdes		func_len " $obj"
8386238104Sdes		func_arith $len + $func_len_result
8387238104Sdes		len=$func_arith_result
8388238104Sdes		if test "X$objlist" = X ||
8389238104Sdes		   test "$len" -lt "$max_cmd_len"; then
8390238104Sdes		  func_append objlist " $obj"
8391238104Sdes		else
8392238104Sdes		  # The command $test_cmds is almost too long, add a
8393238104Sdes		  # command to the queue.
8394238104Sdes		  if test "$k" -eq 1 ; then
8395238104Sdes		    # The first file doesn't have a previous command to add.
8396238104Sdes		    reload_objs=$objlist
8397238104Sdes		    eval concat_cmds=\"$reload_cmds\"
8398238104Sdes		  else
8399238104Sdes		    # All subsequent reloadable object files will link in
8400238104Sdes		    # the last one created.
8401238104Sdes		    reload_objs="$objlist $last_robj"
8402238104Sdes		    eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
8403238104Sdes		  fi
8404238104Sdes		  last_robj=$output_objdir/$output_la-${k}.$objext
8405238104Sdes		  func_arith $k + 1
8406238104Sdes		  k=$func_arith_result
8407238104Sdes		  output=$output_objdir/$output_la-${k}.$objext
8408238104Sdes		  objlist=" $obj"
8409238104Sdes		  func_len " $last_robj"
8410238104Sdes		  func_arith $len0 + $func_len_result
8411238104Sdes		  len=$func_arith_result
8412238104Sdes		fi
8413238104Sdes	      done
8414238104Sdes	      # Handle the remaining objects by creating one last
8415238104Sdes	      # reloadable object file.  All subsequent reloadable object
8416238104Sdes	      # files will link in the last one created.
8417238104Sdes	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
8418238104Sdes	      reload_objs="$objlist $last_robj"
8419238104Sdes	      eval concat_cmds=\"\${concat_cmds}$reload_cmds\"
8420238104Sdes	      if test -n "$last_robj"; then
8421238104Sdes	        eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\"
8422238104Sdes	      fi
8423238104Sdes	      func_append delfiles " $output"
8424238104Sdes
8425238104Sdes	    else
8426238104Sdes	      output=
8427238104Sdes	    fi
8428238104Sdes
8429238104Sdes	    if ${skipped_export-false}; then
8430238104Sdes	      func_verbose "generating symbol list for \`$libname.la'"
8431238104Sdes	      export_symbols="$output_objdir/$libname.exp"
8432238104Sdes	      $opt_dry_run || $RM $export_symbols
8433238104Sdes	      libobjs=$output
8434238104Sdes	      # Append the command to create the export file.
8435238104Sdes	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
8436238104Sdes	      eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
8437238104Sdes	      if test -n "$last_robj"; then
8438238104Sdes		eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
8439238104Sdes	      fi
8440238104Sdes	    fi
8441238104Sdes
8442238104Sdes	    test -n "$save_libobjs" &&
8443238104Sdes	      func_verbose "creating a temporary reloadable object file: $output"
8444238104Sdes
8445238104Sdes	    # Loop through the commands generated above and execute them.
8446238104Sdes	    save_ifs="$IFS"; IFS='~'
8447238104Sdes	    for cmd in $concat_cmds; do
8448238104Sdes	      IFS="$save_ifs"
8449238104Sdes	      $opt_silent || {
8450238104Sdes		  func_quote_for_expand "$cmd"
8451238104Sdes		  eval "func_echo $func_quote_for_expand_result"
8452238104Sdes	      }
8453238104Sdes	      $opt_dry_run || eval "$cmd" || {
8454238104Sdes		lt_exit=$?
8455238104Sdes
8456238104Sdes		# Restore the uninstalled library and exit
8457238104Sdes		if test "$opt_mode" = relink; then
8458238104Sdes		  ( cd "$output_objdir" && \
8459238104Sdes		    $RM "${realname}T" && \
8460238104Sdes		    $MV "${realname}U" "$realname" )
8461238104Sdes		fi
8462238104Sdes
8463238104Sdes		exit $lt_exit
8464238104Sdes	      }
8465238104Sdes	    done
8466238104Sdes	    IFS="$save_ifs"
8467238104Sdes
8468238104Sdes	    if test -n "$export_symbols_regex" && ${skipped_export-false}; then
8469238104Sdes	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
8470238104Sdes	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
8471238104Sdes	    fi
8472238104Sdes	  fi
8473238104Sdes
8474238104Sdes          if ${skipped_export-false}; then
8475238104Sdes	    if test -n "$export_symbols" && test -n "$include_expsyms"; then
8476238104Sdes	      tmp_export_symbols="$export_symbols"
8477238104Sdes	      test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
8478238104Sdes	      $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
8479238104Sdes	    fi
8480238104Sdes
8481238104Sdes	    if test -n "$orig_export_symbols"; then
8482238104Sdes	      # The given exports_symbols file has to be filtered, so filter it.
8483238104Sdes	      func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
8484238104Sdes	      # FIXME: $output_objdir/$libname.filter potentially contains lots of
8485238104Sdes	      # 's' commands which not all seds can handle. GNU sed should be fine
8486238104Sdes	      # though. Also, the filter scales superlinearly with the number of
8487238104Sdes	      # global variables. join(1) would be nice here, but unfortunately
8488238104Sdes	      # isn't a blessed tool.
8489238104Sdes	      $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
8490238104Sdes	      func_append delfiles " $export_symbols $output_objdir/$libname.filter"
8491238104Sdes	      export_symbols=$output_objdir/$libname.def
8492238104Sdes	      $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
8493238104Sdes	    fi
8494238104Sdes	  fi
8495238104Sdes
8496238104Sdes	  libobjs=$output
8497238104Sdes	  # Restore the value of output.
8498238104Sdes	  output=$save_output
8499238104Sdes
8500238104Sdes	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
8501238104Sdes	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
8502238104Sdes	    test "X$libobjs" = "X " && libobjs=
8503238104Sdes	  fi
8504238104Sdes	  # Expand the library linking commands again to reset the
8505238104Sdes	  # value of $libobjs for piecewise linking.
8506238104Sdes
8507238104Sdes	  # Do each of the archive commands.
8508238104Sdes	  if test "$module" = yes && test -n "$module_cmds" ; then
8509238104Sdes	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
8510238104Sdes	      cmds=$module_expsym_cmds
8511238104Sdes	    else
8512238104Sdes	      cmds=$module_cmds
8513238104Sdes	    fi
8514238104Sdes	  else
8515238104Sdes	    if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
8516238104Sdes	      cmds=$archive_expsym_cmds
8517238104Sdes	    else
8518238104Sdes	      cmds=$archive_cmds
8519238104Sdes	    fi
8520238104Sdes	  fi
8521238104Sdes	fi
8522238104Sdes
8523238104Sdes	if test -n "$delfiles"; then
8524238104Sdes	  # Append the command to remove temporary files to $cmds.
8525238104Sdes	  eval cmds=\"\$cmds~\$RM $delfiles\"
8526238104Sdes	fi
8527238104Sdes
8528238104Sdes	# Add any objects from preloaded convenience libraries
8529238104Sdes	if test -n "$dlprefiles"; then
8530238104Sdes	  gentop="$output_objdir/${outputname}x"
8531238104Sdes	  func_append generated " $gentop"
8532238104Sdes
8533238104Sdes	  func_extract_archives $gentop $dlprefiles
8534238104Sdes	  func_append libobjs " $func_extract_archives_result"
8535238104Sdes	  test "X$libobjs" = "X " && libobjs=
8536238104Sdes	fi
8537238104Sdes
8538238104Sdes	save_ifs="$IFS"; IFS='~'
8539238104Sdes	for cmd in $cmds; do
8540238104Sdes	  IFS="$save_ifs"
8541238104Sdes	  eval cmd=\"$cmd\"
8542238104Sdes	  $opt_silent || {
8543238104Sdes	    func_quote_for_expand "$cmd"
8544238104Sdes	    eval "func_echo $func_quote_for_expand_result"
8545238104Sdes	  }
8546238104Sdes	  $opt_dry_run || eval "$cmd" || {
8547238104Sdes	    lt_exit=$?
8548238104Sdes
8549238104Sdes	    # Restore the uninstalled library and exit
8550238104Sdes	    if test "$opt_mode" = relink; then
8551238104Sdes	      ( cd "$output_objdir" && \
8552238104Sdes	        $RM "${realname}T" && \
8553238104Sdes		$MV "${realname}U" "$realname" )
8554238104Sdes	    fi
8555238104Sdes
8556238104Sdes	    exit $lt_exit
8557238104Sdes	  }
8558238104Sdes	done
8559238104Sdes	IFS="$save_ifs"
8560238104Sdes
8561238104Sdes	# Restore the uninstalled library and exit
8562238104Sdes	if test "$opt_mode" = relink; then
8563238104Sdes	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
8564238104Sdes
8565238104Sdes	  if test -n "$convenience"; then
8566238104Sdes	    if test -z "$whole_archive_flag_spec"; then
8567238104Sdes	      func_show_eval '${RM}r "$gentop"'
8568238104Sdes	    fi
8569238104Sdes	  fi
8570238104Sdes
8571238104Sdes	  exit $EXIT_SUCCESS
8572238104Sdes	fi
8573238104Sdes
8574238104Sdes	# Create links to the real library.
8575238104Sdes	for linkname in $linknames; do
8576238104Sdes	  if test "$realname" != "$linkname"; then
8577238104Sdes	    func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
8578238104Sdes	  fi
8579238104Sdes	done
8580238104Sdes
8581238104Sdes	# If -module or -export-dynamic was specified, set the dlname.
8582238104Sdes	if test "$module" = yes || test "$export_dynamic" = yes; then
8583238104Sdes	  # On all known operating systems, these are identical.
8584238104Sdes	  dlname="$soname"
8585238104Sdes	fi
8586238104Sdes      fi
8587238104Sdes      ;;
8588238104Sdes
8589238104Sdes    obj)
8590238104Sdes      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
8591238104Sdes	func_warning "\`-dlopen' is ignored for objects"
8592238104Sdes      fi
8593238104Sdes
8594238104Sdes      case " $deplibs" in
8595238104Sdes      *\ -l* | *\ -L*)
8596238104Sdes	func_warning "\`-l' and \`-L' are ignored for objects" ;;
8597238104Sdes      esac
8598238104Sdes
8599238104Sdes      test -n "$rpath" && \
8600238104Sdes	func_warning "\`-rpath' is ignored for objects"
8601238104Sdes
8602238104Sdes      test -n "$xrpath" && \
8603238104Sdes	func_warning "\`-R' is ignored for objects"
8604238104Sdes
8605238104Sdes      test -n "$vinfo" && \
8606238104Sdes	func_warning "\`-version-info' is ignored for objects"
8607238104Sdes
8608238104Sdes      test -n "$release" && \
8609238104Sdes	func_warning "\`-release' is ignored for objects"
8610238104Sdes
8611238104Sdes      case $output in
8612238104Sdes      *.lo)
8613238104Sdes	test -n "$objs$old_deplibs" && \
8614238104Sdes	  func_fatal_error "cannot build library object \`$output' from non-libtool objects"
8615238104Sdes
8616238104Sdes	libobj=$output
8617238104Sdes	func_lo2o "$libobj"
8618238104Sdes	obj=$func_lo2o_result
8619238104Sdes	;;
8620238104Sdes      *)
8621238104Sdes	libobj=
8622238104Sdes	obj="$output"
8623238104Sdes	;;
8624238104Sdes      esac
8625238104Sdes
8626238104Sdes      # Delete the old objects.
8627238104Sdes      $opt_dry_run || $RM $obj $libobj
8628238104Sdes
8629238104Sdes      # Objects from convenience libraries.  This assumes
8630238104Sdes      # single-version convenience libraries.  Whenever we create
8631238104Sdes      # different ones for PIC/non-PIC, this we'll have to duplicate
8632238104Sdes      # the extraction.
8633238104Sdes      reload_conv_objs=
8634238104Sdes      gentop=
8635238104Sdes      # reload_cmds runs $LD directly, so let us get rid of
8636238104Sdes      # -Wl from whole_archive_flag_spec and hope we can get by with
8637238104Sdes      # turning comma into space..
8638238104Sdes      wl=
8639238104Sdes
8640238104Sdes      if test -n "$convenience"; then
8641238104Sdes	if test -n "$whole_archive_flag_spec"; then
8642238104Sdes	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
8643238104Sdes	  reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
8644238104Sdes	else
8645238104Sdes	  gentop="$output_objdir/${obj}x"
8646238104Sdes	  func_append generated " $gentop"
8647238104Sdes
8648238104Sdes	  func_extract_archives $gentop $convenience
8649238104Sdes	  reload_conv_objs="$reload_objs $func_extract_archives_result"
8650238104Sdes	fi
8651238104Sdes      fi
8652238104Sdes
8653238104Sdes      # If we're not building shared, we need to use non_pic_objs
8654238104Sdes      test "$build_libtool_libs" != yes && libobjs="$non_pic_objects"
8655238104Sdes
8656238104Sdes      # Create the old-style object.
8657238104Sdes      reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
8658238104Sdes
8659238104Sdes      output="$obj"
8660238104Sdes      func_execute_cmds "$reload_cmds" 'exit $?'
8661238104Sdes
8662238104Sdes      # Exit if we aren't doing a library object file.
8663238104Sdes      if test -z "$libobj"; then
8664238104Sdes	if test -n "$gentop"; then
8665238104Sdes	  func_show_eval '${RM}r "$gentop"'
8666238104Sdes	fi
8667238104Sdes
8668238104Sdes	exit $EXIT_SUCCESS
8669238104Sdes      fi
8670238104Sdes
8671238104Sdes      if test "$build_libtool_libs" != yes; then
8672238104Sdes	if test -n "$gentop"; then
8673238104Sdes	  func_show_eval '${RM}r "$gentop"'
8674238104Sdes	fi
8675238104Sdes
8676238104Sdes	# Create an invalid libtool object if no PIC, so that we don't
8677238104Sdes	# accidentally link it into a program.
8678238104Sdes	# $show "echo timestamp > $libobj"
8679238104Sdes	# $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
8680238104Sdes	exit $EXIT_SUCCESS
8681238104Sdes      fi
8682238104Sdes
8683238104Sdes      if test -n "$pic_flag" || test "$pic_mode" != default; then
8684238104Sdes	# Only do commands if we really have different PIC objects.
8685238104Sdes	reload_objs="$libobjs $reload_conv_objs"
8686238104Sdes	output="$libobj"
8687238104Sdes	func_execute_cmds "$reload_cmds" 'exit $?'
8688238104Sdes      fi
8689238104Sdes
8690238104Sdes      if test -n "$gentop"; then
8691238104Sdes	func_show_eval '${RM}r "$gentop"'
8692238104Sdes      fi
8693238104Sdes
8694238104Sdes      exit $EXIT_SUCCESS
8695238104Sdes      ;;
8696238104Sdes
8697238104Sdes    prog)
8698238104Sdes      case $host in
8699238104Sdes	*cygwin*) func_stripname '' '.exe' "$output"
8700238104Sdes	          output=$func_stripname_result.exe;;
8701238104Sdes      esac
8702238104Sdes      test -n "$vinfo" && \
8703238104Sdes	func_warning "\`-version-info' is ignored for programs"
8704238104Sdes
8705238104Sdes      test -n "$release" && \
8706238104Sdes	func_warning "\`-release' is ignored for programs"
8707238104Sdes
8708238104Sdes      test "$preload" = yes \
8709238104Sdes        && test "$dlopen_support" = unknown \
8710238104Sdes	&& test "$dlopen_self" = unknown \
8711238104Sdes	&& test "$dlopen_self_static" = unknown && \
8712238104Sdes	  func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support."
8713238104Sdes
8714238104Sdes      case $host in
8715238104Sdes      *-*-rhapsody* | *-*-darwin1.[012])
8716238104Sdes	# On Rhapsody replace the C library is the System framework
8717238104Sdes	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
8718238104Sdes	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
8719238104Sdes	;;
8720238104Sdes      esac
8721238104Sdes
8722238104Sdes      case $host in
8723238104Sdes      *-*-darwin*)
8724238104Sdes	# Don't allow lazy linking, it breaks C++ global constructors
8725238104Sdes	# But is supposedly fixed on 10.4 or later (yay!).
8726238104Sdes	if test "$tagname" = CXX ; then
8727238104Sdes	  case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
8728238104Sdes	    10.[0123])
8729238104Sdes	      func_append compile_command " ${wl}-bind_at_load"
8730238104Sdes	      func_append finalize_command " ${wl}-bind_at_load"
8731238104Sdes	    ;;
8732238104Sdes	  esac
8733238104Sdes	fi
8734238104Sdes	# Time to change all our "foo.ltframework" stuff back to "-framework foo"
8735238104Sdes	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8736238104Sdes	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8737238104Sdes	;;
8738238104Sdes      esac
8739238104Sdes
8740238104Sdes
8741238104Sdes      # move library search paths that coincide with paths to not yet
8742238104Sdes      # installed libraries to the beginning of the library search list
8743238104Sdes      new_libs=
8744238104Sdes      for path in $notinst_path; do
8745238104Sdes	case " $new_libs " in
8746238104Sdes	*" -L$path/$objdir "*) ;;
8747238104Sdes	*)
8748238104Sdes	  case " $compile_deplibs " in
8749238104Sdes	  *" -L$path/$objdir "*)
8750238104Sdes	    func_append new_libs " -L$path/$objdir" ;;
8751238104Sdes	  esac
8752238104Sdes	  ;;
8753238104Sdes	esac
8754238104Sdes      done
8755238104Sdes      for deplib in $compile_deplibs; do
8756238104Sdes	case $deplib in
8757238104Sdes	-L*)
8758238104Sdes	  case " $new_libs " in
8759238104Sdes	  *" $deplib "*) ;;
8760238104Sdes	  *) func_append new_libs " $deplib" ;;
8761238104Sdes	  esac
8762238104Sdes	  ;;
8763238104Sdes	*) func_append new_libs " $deplib" ;;
8764238104Sdes	esac
8765238104Sdes      done
8766238104Sdes      compile_deplibs="$new_libs"
8767238104Sdes
8768238104Sdes
8769238104Sdes      func_append compile_command " $compile_deplibs"
8770238104Sdes      func_append finalize_command " $finalize_deplibs"
8771238104Sdes
8772238104Sdes      if test -n "$rpath$xrpath"; then
8773238104Sdes	# If the user specified any rpath flags, then add them.
8774238104Sdes	for libdir in $rpath $xrpath; do
8775238104Sdes	  # This is the magic to use -rpath.
8776238104Sdes	  case "$finalize_rpath " in
8777238104Sdes	  *" $libdir "*) ;;
8778238104Sdes	  *) func_append finalize_rpath " $libdir" ;;
8779238104Sdes	  esac
8780238104Sdes	done
8781238104Sdes      fi
8782238104Sdes
8783238104Sdes      # Now hardcode the library paths
8784238104Sdes      rpath=
8785238104Sdes      hardcode_libdirs=
8786238104Sdes      for libdir in $compile_rpath $finalize_rpath; do
8787238104Sdes	if test -n "$hardcode_libdir_flag_spec"; then
8788238104Sdes	  if test -n "$hardcode_libdir_separator"; then
8789238104Sdes	    if test -z "$hardcode_libdirs"; then
8790238104Sdes	      hardcode_libdirs="$libdir"
8791238104Sdes	    else
8792238104Sdes	      # Just accumulate the unique libdirs.
8793238104Sdes	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
8794238104Sdes	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
8795238104Sdes		;;
8796238104Sdes	      *)
8797238104Sdes		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
8798238104Sdes		;;
8799238104Sdes	      esac
8800238104Sdes	    fi
8801238104Sdes	  else
8802238104Sdes	    eval flag=\"$hardcode_libdir_flag_spec\"
8803238104Sdes	    func_append rpath " $flag"
8804238104Sdes	  fi
8805238104Sdes	elif test -n "$runpath_var"; then
8806238104Sdes	  case "$perm_rpath " in
8807238104Sdes	  *" $libdir "*) ;;
8808238104Sdes	  *) func_append perm_rpath " $libdir" ;;
8809238104Sdes	  esac
8810238104Sdes	fi
8811238104Sdes	case $host in
8812238104Sdes	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
8813238104Sdes	  testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'`
8814238104Sdes	  case :$dllsearchpath: in
8815238104Sdes	  *":$libdir:"*) ;;
8816238104Sdes	  ::) dllsearchpath=$libdir;;
8817238104Sdes	  *) func_append dllsearchpath ":$libdir";;
8818238104Sdes	  esac
8819238104Sdes	  case :$dllsearchpath: in
8820238104Sdes	  *":$testbindir:"*) ;;
8821238104Sdes	  ::) dllsearchpath=$testbindir;;
8822238104Sdes	  *) func_append dllsearchpath ":$testbindir";;
8823238104Sdes	  esac
8824238104Sdes	  ;;
8825238104Sdes	esac
8826238104Sdes      done
8827238104Sdes      # Substitute the hardcoded libdirs into the rpath.
8828238104Sdes      if test -n "$hardcode_libdir_separator" &&
8829238104Sdes	 test -n "$hardcode_libdirs"; then
8830238104Sdes	libdir="$hardcode_libdirs"
8831238104Sdes	eval rpath=\" $hardcode_libdir_flag_spec\"
8832238104Sdes      fi
8833238104Sdes      compile_rpath="$rpath"
8834238104Sdes
8835238104Sdes      rpath=
8836238104Sdes      hardcode_libdirs=
8837238104Sdes      for libdir in $finalize_rpath; do
8838238104Sdes	if test -n "$hardcode_libdir_flag_spec"; then
8839238104Sdes	  if test -n "$hardcode_libdir_separator"; then
8840238104Sdes	    if test -z "$hardcode_libdirs"; then
8841238104Sdes	      hardcode_libdirs="$libdir"
8842238104Sdes	    else
8843238104Sdes	      # Just accumulate the unique libdirs.
8844238104Sdes	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
8845238104Sdes	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
8846238104Sdes		;;
8847238104Sdes	      *)
8848238104Sdes		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
8849238104Sdes		;;
8850238104Sdes	      esac
8851238104Sdes	    fi
8852238104Sdes	  else
8853238104Sdes	    eval flag=\"$hardcode_libdir_flag_spec\"
8854238104Sdes	    func_append rpath " $flag"
8855238104Sdes	  fi
8856238104Sdes	elif test -n "$runpath_var"; then
8857238104Sdes	  case "$finalize_perm_rpath " in
8858238104Sdes	  *" $libdir "*) ;;
8859238104Sdes	  *) func_append finalize_perm_rpath " $libdir" ;;
8860238104Sdes	  esac
8861238104Sdes	fi
8862238104Sdes      done
8863238104Sdes      # Substitute the hardcoded libdirs into the rpath.
8864238104Sdes      if test -n "$hardcode_libdir_separator" &&
8865238104Sdes	 test -n "$hardcode_libdirs"; then
8866238104Sdes	libdir="$hardcode_libdirs"
8867238104Sdes	eval rpath=\" $hardcode_libdir_flag_spec\"
8868238104Sdes      fi
8869238104Sdes      finalize_rpath="$rpath"
8870238104Sdes
8871238104Sdes      if test -n "$libobjs" && test "$build_old_libs" = yes; then
8872238104Sdes	# Transform all the library objects into standard objects.
8873238104Sdes	compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
8874238104Sdes	finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
8875238104Sdes      fi
8876238104Sdes
8877238104Sdes      func_generate_dlsyms "$outputname" "@PROGRAM@" "no"
8878238104Sdes
8879238104Sdes      # template prelinking step
8880238104Sdes      if test -n "$prelink_cmds"; then
8881238104Sdes	func_execute_cmds "$prelink_cmds" 'exit $?'
8882238104Sdes      fi
8883238104Sdes
8884238104Sdes      wrappers_required=yes
8885238104Sdes      case $host in
8886238104Sdes      *cegcc* | *mingw32ce*)
8887238104Sdes        # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
8888238104Sdes        wrappers_required=no
8889238104Sdes        ;;
8890238104Sdes      *cygwin* | *mingw* )
8891238104Sdes        if test "$build_libtool_libs" != yes; then
8892238104Sdes          wrappers_required=no
8893238104Sdes        fi
8894238104Sdes        ;;
8895238104Sdes      *)
8896238104Sdes        if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
8897238104Sdes          wrappers_required=no
8898238104Sdes        fi
8899238104Sdes        ;;
8900238104Sdes      esac
8901238104Sdes      if test "$wrappers_required" = no; then
8902238104Sdes	# Replace the output file specification.
8903238104Sdes	compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
8904238104Sdes	link_command="$compile_command$compile_rpath"
8905238104Sdes
8906238104Sdes	# We have no uninstalled library dependencies, so finalize right now.
8907238104Sdes	exit_status=0
8908238104Sdes	func_show_eval "$link_command" 'exit_status=$?'
8909238104Sdes
8910238104Sdes	if test -n "$postlink_cmds"; then
8911238104Sdes	  func_to_tool_file "$output"
8912238104Sdes	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
8913238104Sdes	  func_execute_cmds "$postlink_cmds" 'exit $?'
8914238104Sdes	fi
8915238104Sdes
8916238104Sdes	# Delete the generated files.
8917238104Sdes	if test -f "$output_objdir/${outputname}S.${objext}"; then
8918238104Sdes	  func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"'
8919238104Sdes	fi
8920238104Sdes
8921238104Sdes	exit $exit_status
8922238104Sdes      fi
8923238104Sdes
8924238104Sdes      if test -n "$compile_shlibpath$finalize_shlibpath"; then
8925238104Sdes	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
8926238104Sdes      fi
8927238104Sdes      if test -n "$finalize_shlibpath"; then
8928238104Sdes	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
8929238104Sdes      fi
8930238104Sdes
8931238104Sdes      compile_var=
8932238104Sdes      finalize_var=
8933238104Sdes      if test -n "$runpath_var"; then
8934238104Sdes	if test -n "$perm_rpath"; then
8935238104Sdes	  # We should set the runpath_var.
8936238104Sdes	  rpath=
8937238104Sdes	  for dir in $perm_rpath; do
8938238104Sdes	    func_append rpath "$dir:"
8939238104Sdes	  done
8940238104Sdes	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
8941238104Sdes	fi
8942238104Sdes	if test -n "$finalize_perm_rpath"; then
8943238104Sdes	  # We should set the runpath_var.
8944238104Sdes	  rpath=
8945238104Sdes	  for dir in $finalize_perm_rpath; do
8946238104Sdes	    func_append rpath "$dir:"
8947238104Sdes	  done
8948238104Sdes	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
8949238104Sdes	fi
8950238104Sdes      fi
8951238104Sdes
8952238104Sdes      if test "$no_install" = yes; then
8953238104Sdes	# We don't need to create a wrapper script.
8954238104Sdes	link_command="$compile_var$compile_command$compile_rpath"
8955238104Sdes	# Replace the output file specification.
8956238104Sdes	link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
8957238104Sdes	# Delete the old output file.
8958238104Sdes	$opt_dry_run || $RM $output
8959238104Sdes	# Link the executable and exit
8960238104Sdes	func_show_eval "$link_command" 'exit $?'
8961238104Sdes
8962238104Sdes	if test -n "$postlink_cmds"; then
8963238104Sdes	  func_to_tool_file "$output"
8964238104Sdes	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
8965238104Sdes	  func_execute_cmds "$postlink_cmds" 'exit $?'
8966238104Sdes	fi
8967238104Sdes
8968238104Sdes	exit $EXIT_SUCCESS
8969238104Sdes      fi
8970238104Sdes
8971238104Sdes      if test "$hardcode_action" = relink; then
8972238104Sdes	# Fast installation is not supported
8973238104Sdes	link_command="$compile_var$compile_command$compile_rpath"
8974238104Sdes	relink_command="$finalize_var$finalize_command$finalize_rpath"
8975238104Sdes
8976238104Sdes	func_warning "this platform does not like uninstalled shared libraries"
8977238104Sdes	func_warning "\`$output' will be relinked during installation"
8978238104Sdes      else
8979238104Sdes	if test "$fast_install" != no; then
8980238104Sdes	  link_command="$finalize_var$compile_command$finalize_rpath"
8981238104Sdes	  if test "$fast_install" = yes; then
8982238104Sdes	    relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
8983238104Sdes	  else
8984238104Sdes	    # fast_install is set to needless
8985238104Sdes	    relink_command=
8986238104Sdes	  fi
8987238104Sdes	else
8988238104Sdes	  link_command="$compile_var$compile_command$compile_rpath"
8989238104Sdes	  relink_command="$finalize_var$finalize_command$finalize_rpath"
8990238104Sdes	fi
8991238104Sdes      fi
8992238104Sdes
8993238104Sdes      # Replace the output file specification.
8994238104Sdes      link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
8995238104Sdes
8996238104Sdes      # Delete the old output files.
8997238104Sdes      $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
8998238104Sdes
8999238104Sdes      func_show_eval "$link_command" 'exit $?'
9000238104Sdes
9001238104Sdes      if test -n "$postlink_cmds"; then
9002238104Sdes	func_to_tool_file "$output_objdir/$outputname"
9003238104Sdes	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'`
9004238104Sdes	func_execute_cmds "$postlink_cmds" 'exit $?'
9005238104Sdes      fi
9006238104Sdes
9007238104Sdes      # Now create the wrapper script.
9008238104Sdes      func_verbose "creating $output"
9009238104Sdes
9010238104Sdes      # Quote the relink command for shipping.
9011238104Sdes      if test -n "$relink_command"; then
9012238104Sdes	# Preserve any variables that may affect compiler behavior
9013238104Sdes	for var in $variables_saved_for_relink; do
9014238104Sdes	  if eval test -z \"\${$var+set}\"; then
9015238104Sdes	    relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
9016238104Sdes	  elif eval var_value=\$$var; test -z "$var_value"; then
9017238104Sdes	    relink_command="$var=; export $var; $relink_command"
9018238104Sdes	  else
9019238104Sdes	    func_quote_for_eval "$var_value"
9020238104Sdes	    relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
9021238104Sdes	  fi
9022238104Sdes	done
9023238104Sdes	relink_command="(cd `pwd`; $relink_command)"
9024238104Sdes	relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
9025238104Sdes      fi
9026238104Sdes
9027238104Sdes      # Only actually do things if not in dry run mode.
9028238104Sdes      $opt_dry_run || {
9029238104Sdes	# win32 will think the script is a binary if it has
9030238104Sdes	# a .exe suffix, so we strip it off here.
9031238104Sdes	case $output in
9032238104Sdes	  *.exe) func_stripname '' '.exe' "$output"
9033238104Sdes	         output=$func_stripname_result ;;
9034238104Sdes	esac
9035238104Sdes	# test for cygwin because mv fails w/o .exe extensions
9036238104Sdes	case $host in
9037238104Sdes	  *cygwin*)
9038238104Sdes	    exeext=.exe
9039238104Sdes	    func_stripname '' '.exe' "$outputname"
9040238104Sdes	    outputname=$func_stripname_result ;;
9041238104Sdes	  *) exeext= ;;
9042238104Sdes	esac
9043238104Sdes	case $host in
9044238104Sdes	  *cygwin* | *mingw* )
9045238104Sdes	    func_dirname_and_basename "$output" "" "."
9046238104Sdes	    output_name=$func_basename_result
9047238104Sdes	    output_path=$func_dirname_result
9048238104Sdes	    cwrappersource="$output_path/$objdir/lt-$output_name.c"
9049238104Sdes	    cwrapper="$output_path/$output_name.exe"
9050238104Sdes	    $RM $cwrappersource $cwrapper
9051238104Sdes	    trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
9052238104Sdes
9053238104Sdes	    func_emit_cwrapperexe_src > $cwrappersource
9054238104Sdes
9055238104Sdes	    # The wrapper executable is built using the $host compiler,
9056238104Sdes	    # because it contains $host paths and files. If cross-
9057238104Sdes	    # compiling, it, like the target executable, must be
9058238104Sdes	    # executed on the $host or under an emulation environment.
9059238104Sdes	    $opt_dry_run || {
9060238104Sdes	      $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
9061238104Sdes	      $STRIP $cwrapper
9062238104Sdes	    }
9063238104Sdes
9064238104Sdes	    # Now, create the wrapper script for func_source use:
9065238104Sdes	    func_ltwrapper_scriptname $cwrapper
9066238104Sdes	    $RM $func_ltwrapper_scriptname_result
9067238104Sdes	    trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
9068238104Sdes	    $opt_dry_run || {
9069238104Sdes	      # note: this script will not be executed, so do not chmod.
9070238104Sdes	      if test "x$build" = "x$host" ; then
9071238104Sdes		$cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
9072238104Sdes	      else
9073238104Sdes		func_emit_wrapper no > $func_ltwrapper_scriptname_result
9074238104Sdes	      fi
9075238104Sdes	    }
9076238104Sdes	  ;;
9077238104Sdes	  * )
9078238104Sdes	    $RM $output
9079238104Sdes	    trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
9080238104Sdes
9081238104Sdes	    func_emit_wrapper no > $output
9082238104Sdes	    chmod +x $output
9083238104Sdes	  ;;
9084238104Sdes	esac
9085238104Sdes      }
9086238104Sdes      exit $EXIT_SUCCESS
9087238104Sdes      ;;
9088238104Sdes    esac
9089238104Sdes
9090238104Sdes    # See if we need to build an old-fashioned archive.
9091238104Sdes    for oldlib in $oldlibs; do
9092238104Sdes
9093238104Sdes      if test "$build_libtool_libs" = convenience; then
9094238104Sdes	oldobjs="$libobjs_save $symfileobj"
9095238104Sdes	addlibs="$convenience"
9096238104Sdes	build_libtool_libs=no
9097238104Sdes      else
9098238104Sdes	if test "$build_libtool_libs" = module; then
9099238104Sdes	  oldobjs="$libobjs_save"
9100238104Sdes	  build_libtool_libs=no
9101238104Sdes	else
9102238104Sdes	  oldobjs="$old_deplibs $non_pic_objects"
9103238104Sdes	  if test "$preload" = yes && test -f "$symfileobj"; then
9104238104Sdes	    func_append oldobjs " $symfileobj"
9105238104Sdes	  fi
9106238104Sdes	fi
9107238104Sdes	addlibs="$old_convenience"
9108238104Sdes      fi
9109238104Sdes
9110238104Sdes      if test -n "$addlibs"; then
9111238104Sdes	gentop="$output_objdir/${outputname}x"
9112238104Sdes	func_append generated " $gentop"
9113238104Sdes
9114238104Sdes	func_extract_archives $gentop $addlibs
9115238104Sdes	func_append oldobjs " $func_extract_archives_result"
9116238104Sdes      fi
9117238104Sdes
9118238104Sdes      # Do each command in the archive commands.
9119238104Sdes      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
9120238104Sdes	cmds=$old_archive_from_new_cmds
9121238104Sdes      else
9122238104Sdes
9123238104Sdes	# Add any objects from preloaded convenience libraries
9124238104Sdes	if test -n "$dlprefiles"; then
9125238104Sdes	  gentop="$output_objdir/${outputname}x"
9126238104Sdes	  func_append generated " $gentop"
9127238104Sdes
9128238104Sdes	  func_extract_archives $gentop $dlprefiles
9129238104Sdes	  func_append oldobjs " $func_extract_archives_result"
9130238104Sdes	fi
9131238104Sdes
9132238104Sdes	# POSIX demands no paths to be encoded in archives.  We have
9133238104Sdes	# to avoid creating archives with duplicate basenames if we
9134238104Sdes	# might have to extract them afterwards, e.g., when creating a
9135238104Sdes	# static archive out of a convenience library, or when linking
9136238104Sdes	# the entirety of a libtool archive into another (currently
9137238104Sdes	# not supported by libtool).
9138238104Sdes	if (for obj in $oldobjs
9139238104Sdes	    do
9140238104Sdes	      func_basename "$obj"
9141238104Sdes	      $ECHO "$func_basename_result"
9142238104Sdes	    done | sort | sort -uc >/dev/null 2>&1); then
9143238104Sdes	  :
9144238104Sdes	else
9145238104Sdes	  echo "copying selected object files to avoid basename conflicts..."
9146238104Sdes	  gentop="$output_objdir/${outputname}x"
9147238104Sdes	  func_append generated " $gentop"
9148238104Sdes	  func_mkdir_p "$gentop"
9149238104Sdes	  save_oldobjs=$oldobjs
9150238104Sdes	  oldobjs=
9151238104Sdes	  counter=1
9152238104Sdes	  for obj in $save_oldobjs
9153238104Sdes	  do
9154238104Sdes	    func_basename "$obj"
9155238104Sdes	    objbase="$func_basename_result"
9156238104Sdes	    case " $oldobjs " in
9157238104Sdes	    " ") oldobjs=$obj ;;
9158238104Sdes	    *[\ /]"$objbase "*)
9159238104Sdes	      while :; do
9160238104Sdes		# Make sure we don't pick an alternate name that also
9161238104Sdes		# overlaps.
9162238104Sdes		newobj=lt$counter-$objbase
9163238104Sdes		func_arith $counter + 1
9164238104Sdes		counter=$func_arith_result
9165238104Sdes		case " $oldobjs " in
9166238104Sdes		*[\ /]"$newobj "*) ;;
9167238104Sdes		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
9168238104Sdes		esac
9169238104Sdes	      done
9170238104Sdes	      func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
9171238104Sdes	      func_append oldobjs " $gentop/$newobj"
9172238104Sdes	      ;;
9173238104Sdes	    *) func_append oldobjs " $obj" ;;
9174238104Sdes	    esac
9175238104Sdes	  done
9176238104Sdes	fi
9177238104Sdes	func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
9178238104Sdes	tool_oldlib=$func_to_tool_file_result
9179238104Sdes	eval cmds=\"$old_archive_cmds\"
9180238104Sdes
9181238104Sdes	func_len " $cmds"
9182238104Sdes	len=$func_len_result
9183238104Sdes	if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
9184238104Sdes	  cmds=$old_archive_cmds
9185238104Sdes	elif test -n "$archiver_list_spec"; then
9186238104Sdes	  func_verbose "using command file archive linking..."
9187238104Sdes	  for obj in $oldobjs
9188238104Sdes	  do
9189238104Sdes	    func_to_tool_file "$obj"
9190238104Sdes	    $ECHO "$func_to_tool_file_result"
9191238104Sdes	  done > $output_objdir/$libname.libcmd
9192238104Sdes	  func_to_tool_file "$output_objdir/$libname.libcmd"
9193238104Sdes	  oldobjs=" $archiver_list_spec$func_to_tool_file_result"
9194238104Sdes	  cmds=$old_archive_cmds
9195238104Sdes	else
9196238104Sdes	  # the command line is too long to link in one step, link in parts
9197238104Sdes	  func_verbose "using piecewise archive linking..."
9198238104Sdes	  save_RANLIB=$RANLIB
9199238104Sdes	  RANLIB=:
9200238104Sdes	  objlist=
9201238104Sdes	  concat_cmds=
9202238104Sdes	  save_oldobjs=$oldobjs
9203238104Sdes	  oldobjs=
9204238104Sdes	  # Is there a better way of finding the last object in the list?
9205238104Sdes	  for obj in $save_oldobjs
9206238104Sdes	  do
9207238104Sdes	    last_oldobj=$obj
9208238104Sdes	  done
9209238104Sdes	  eval test_cmds=\"$old_archive_cmds\"
9210238104Sdes	  func_len " $test_cmds"
9211238104Sdes	  len0=$func_len_result
9212238104Sdes	  len=$len0
9213238104Sdes	  for obj in $save_oldobjs
9214238104Sdes	  do
9215238104Sdes	    func_len " $obj"
9216238104Sdes	    func_arith $len + $func_len_result
9217238104Sdes	    len=$func_arith_result
9218238104Sdes	    func_append objlist " $obj"
9219238104Sdes	    if test "$len" -lt "$max_cmd_len"; then
9220238104Sdes	      :
9221238104Sdes	    else
9222238104Sdes	      # the above command should be used before it gets too long
9223238104Sdes	      oldobjs=$objlist
9224238104Sdes	      if test "$obj" = "$last_oldobj" ; then
9225238104Sdes		RANLIB=$save_RANLIB
9226238104Sdes	      fi
9227238104Sdes	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
9228238104Sdes	      eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
9229238104Sdes	      objlist=
9230238104Sdes	      len=$len0
9231238104Sdes	    fi
9232238104Sdes	  done
9233238104Sdes	  RANLIB=$save_RANLIB
9234238104Sdes	  oldobjs=$objlist
9235238104Sdes	  if test "X$oldobjs" = "X" ; then
9236238104Sdes	    eval cmds=\"\$concat_cmds\"
9237238104Sdes	  else
9238238104Sdes	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
9239238104Sdes	  fi
9240238104Sdes	fi
9241238104Sdes      fi
9242238104Sdes      func_execute_cmds "$cmds" 'exit $?'
9243238104Sdes    done
9244238104Sdes
9245238104Sdes    test -n "$generated" && \
9246238104Sdes      func_show_eval "${RM}r$generated"
9247238104Sdes
9248238104Sdes    # Now create the libtool archive.
9249238104Sdes    case $output in
9250238104Sdes    *.la)
9251238104Sdes      old_library=
9252238104Sdes      test "$build_old_libs" = yes && old_library="$libname.$libext"
9253238104Sdes      func_verbose "creating $output"
9254238104Sdes
9255238104Sdes      # Preserve any variables that may affect compiler behavior
9256238104Sdes      for var in $variables_saved_for_relink; do
9257238104Sdes	if eval test -z \"\${$var+set}\"; then
9258238104Sdes	  relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
9259238104Sdes	elif eval var_value=\$$var; test -z "$var_value"; then
9260238104Sdes	  relink_command="$var=; export $var; $relink_command"
9261238104Sdes	else
9262238104Sdes	  func_quote_for_eval "$var_value"
9263238104Sdes	  relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
9264238104Sdes	fi
9265238104Sdes      done
9266238104Sdes      # Quote the link command for shipping.
9267238104Sdes      relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
9268238104Sdes      relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
9269238104Sdes      if test "$hardcode_automatic" = yes ; then
9270238104Sdes	relink_command=
9271238104Sdes      fi
9272238104Sdes
9273238104Sdes      # Only create the output if not a dry run.
9274238104Sdes      $opt_dry_run || {
9275238104Sdes	for installed in no yes; do
9276238104Sdes	  if test "$installed" = yes; then
9277238104Sdes	    if test -z "$install_libdir"; then
9278238104Sdes	      break
9279238104Sdes	    fi
9280238104Sdes	    output="$output_objdir/$outputname"i
9281238104Sdes	    # Replace all uninstalled libtool libraries with the installed ones
9282238104Sdes	    newdependency_libs=
9283238104Sdes	    for deplib in $dependency_libs; do
9284238104Sdes	      case $deplib in
9285238104Sdes	      *.la)
9286238104Sdes		func_basename "$deplib"
9287238104Sdes		name="$func_basename_result"
9288238104Sdes		func_resolve_sysroot "$deplib"
9289238104Sdes		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result`
9290238104Sdes		test -z "$libdir" && \
9291238104Sdes		  func_fatal_error "\`$deplib' is not a valid libtool archive"
9292238104Sdes		func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"
9293238104Sdes		;;
9294238104Sdes	      -L*)
9295238104Sdes		func_stripname -L '' "$deplib"
9296238104Sdes		func_replace_sysroot "$func_stripname_result"
9297238104Sdes		func_append newdependency_libs " -L$func_replace_sysroot_result"
9298238104Sdes		;;
9299238104Sdes	      -R*)
9300238104Sdes		func_stripname -R '' "$deplib"
9301238104Sdes		func_replace_sysroot "$func_stripname_result"
9302238104Sdes		func_append newdependency_libs " -R$func_replace_sysroot_result"
9303238104Sdes		;;
9304238104Sdes	      *) func_append newdependency_libs " $deplib" ;;
9305238104Sdes	      esac
9306238104Sdes	    done
9307238104Sdes	    dependency_libs="$newdependency_libs"
9308238104Sdes	    newdlfiles=
9309238104Sdes
9310238104Sdes	    for lib in $dlfiles; do
9311238104Sdes	      case $lib in
9312238104Sdes	      *.la)
9313238104Sdes	        func_basename "$lib"
9314238104Sdes		name="$func_basename_result"
9315238104Sdes		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
9316238104Sdes		test -z "$libdir" && \
9317238104Sdes		  func_fatal_error "\`$lib' is not a valid libtool archive"
9318238104Sdes		func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name"
9319238104Sdes		;;
9320238104Sdes	      *) func_append newdlfiles " $lib" ;;
9321238104Sdes	      esac
9322238104Sdes	    done
9323238104Sdes	    dlfiles="$newdlfiles"
9324238104Sdes	    newdlprefiles=
9325238104Sdes	    for lib in $dlprefiles; do
9326238104Sdes	      case $lib in
9327238104Sdes	      *.la)
9328238104Sdes		# Only pass preopened files to the pseudo-archive (for
9329238104Sdes		# eventual linking with the app. that links it) if we
9330238104Sdes		# didn't already link the preopened objects directly into
9331238104Sdes		# the library:
9332238104Sdes		func_basename "$lib"
9333238104Sdes		name="$func_basename_result"
9334238104Sdes		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
9335238104Sdes		test -z "$libdir" && \
9336238104Sdes		  func_fatal_error "\`$lib' is not a valid libtool archive"
9337238104Sdes		func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name"
9338238104Sdes		;;
9339238104Sdes	      esac
9340238104Sdes	    done
9341238104Sdes	    dlprefiles="$newdlprefiles"
9342238104Sdes	  else
9343238104Sdes	    newdlfiles=
9344238104Sdes	    for lib in $dlfiles; do
9345238104Sdes	      case $lib in
9346238104Sdes		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
9347238104Sdes		*) abs=`pwd`"/$lib" ;;
9348238104Sdes	      esac
9349238104Sdes	      func_append newdlfiles " $abs"
9350238104Sdes	    done
9351238104Sdes	    dlfiles="$newdlfiles"
9352238104Sdes	    newdlprefiles=
9353238104Sdes	    for lib in $dlprefiles; do
9354238104Sdes	      case $lib in
9355238104Sdes		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
9356238104Sdes		*) abs=`pwd`"/$lib" ;;
9357238104Sdes	      esac
9358238104Sdes	      func_append newdlprefiles " $abs"
9359238104Sdes	    done
9360238104Sdes	    dlprefiles="$newdlprefiles"
9361238104Sdes	  fi
9362238104Sdes	  $RM $output
9363238104Sdes	  # place dlname in correct position for cygwin
9364238104Sdes	  # In fact, it would be nice if we could use this code for all target
9365238104Sdes	  # systems that can't hard-code library paths into their executables
9366238104Sdes	  # and that have no shared library path variable independent of PATH,
9367238104Sdes	  # but it turns out we can't easily determine that from inspecting
9368238104Sdes	  # libtool variables, so we have to hard-code the OSs to which it
9369238104Sdes	  # applies here; at the moment, that means platforms that use the PE
9370238104Sdes	  # object format with DLL files.  See the long comment at the top of
9371238104Sdes	  # tests/bindir.at for full details.
9372238104Sdes	  tdlname=$dlname
9373238104Sdes	  case $host,$output,$installed,$module,$dlname in
9374238104Sdes	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
9375238104Sdes	      # If a -bindir argument was supplied, place the dll there.
9376238104Sdes	      if test "x$bindir" != x ;
9377238104Sdes	      then
9378238104Sdes		func_relative_path "$install_libdir" "$bindir"
9379238104Sdes		tdlname=$func_relative_path_result$dlname
9380238104Sdes	      else
9381238104Sdes		# Otherwise fall back on heuristic.
9382238104Sdes		tdlname=../bin/$dlname
9383238104Sdes	      fi
9384238104Sdes	      ;;
9385238104Sdes	  esac
9386238104Sdes	  $ECHO > $output "\
9387238104Sdes# $outputname - a libtool library file
9388238104Sdes# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
9389238104Sdes#
9390238104Sdes# Please DO NOT delete this file!
9391238104Sdes# It is necessary for linking the library.
9392238104Sdes
9393238104Sdes# The name that we can dlopen(3).
9394238104Sdesdlname='$tdlname'
9395238104Sdes
9396238104Sdes# Names of this library.
9397238104Sdeslibrary_names='$library_names'
9398238104Sdes
9399238104Sdes# The name of the static archive.
9400238104Sdesold_library='$old_library'
9401238104Sdes
9402238104Sdes# Linker flags that can not go in dependency_libs.
9403238104Sdesinherited_linker_flags='$new_inherited_linker_flags'
9404238104Sdes
9405238104Sdes# Libraries that this one depends upon.
9406238104Sdesdependency_libs='$dependency_libs'
9407238104Sdes
9408238104Sdes# Names of additional weak libraries provided by this library
9409238104Sdesweak_library_names='$weak_libs'
9410238104Sdes
9411238104Sdes# Version information for $libname.
9412238104Sdescurrent=$current
9413238104Sdesage=$age
9414238104Sdesrevision=$revision
9415238104Sdes
9416238104Sdes# Is this an already installed library?
9417238104Sdesinstalled=$installed
9418238104Sdes
9419238104Sdes# Should we warn about portability when linking against -modules?
9420238104Sdesshouldnotlink=$module
9421238104Sdes
9422238104Sdes# Files to dlopen/dlpreopen
9423238104Sdesdlopen='$dlfiles'
9424238104Sdesdlpreopen='$dlprefiles'
9425238104Sdes
9426238104Sdes# Directory that this library needs to be installed in:
9427238104Sdeslibdir='$install_libdir'"
9428238104Sdes	  if test "$installed" = no && test "$need_relink" = yes; then
9429238104Sdes	    $ECHO >> $output "\
9430238104Sdesrelink_command=\"$relink_command\""
9431238104Sdes	  fi
9432238104Sdes	done
9433238104Sdes      }
9434238104Sdes
9435238104Sdes      # Do a symbolic link so that the libtool archive can be found in
9436238104Sdes      # LD_LIBRARY_PATH before the program is installed.
9437238104Sdes      func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
9438238104Sdes      ;;
9439238104Sdes    esac
9440238104Sdes    exit $EXIT_SUCCESS
9441238104Sdes}
9442238104Sdes
9443238104Sdes{ test "$opt_mode" = link || test "$opt_mode" = relink; } &&
9444238104Sdes    func_mode_link ${1+"$@"}
9445238104Sdes
9446238104Sdes
9447238104Sdes# func_mode_uninstall arg...
9448238104Sdesfunc_mode_uninstall ()
9449238104Sdes{
9450238104Sdes    $opt_debug
9451238104Sdes    RM="$nonopt"
9452238104Sdes    files=
9453238104Sdes    rmforce=
9454238104Sdes    exit_status=0
9455238104Sdes
9456238104Sdes    # This variable tells wrapper scripts just to set variables rather
9457238104Sdes    # than running their programs.
9458238104Sdes    libtool_install_magic="$magic"
9459238104Sdes
9460238104Sdes    for arg
9461238104Sdes    do
9462238104Sdes      case $arg in
9463238104Sdes      -f) func_append RM " $arg"; rmforce=yes ;;
9464238104Sdes      -*) func_append RM " $arg" ;;
9465238104Sdes      *) func_append files " $arg" ;;
9466238104Sdes      esac
9467238104Sdes    done
9468238104Sdes
9469238104Sdes    test -z "$RM" && \
9470238104Sdes      func_fatal_help "you must specify an RM program"
9471238104Sdes
9472238104Sdes    rmdirs=
9473238104Sdes
9474238104Sdes    for file in $files; do
9475238104Sdes      func_dirname "$file" "" "."
9476238104Sdes      dir="$func_dirname_result"
9477238104Sdes      if test "X$dir" = X.; then
9478238104Sdes	odir="$objdir"
9479238104Sdes      else
9480238104Sdes	odir="$dir/$objdir"
9481238104Sdes      fi
9482238104Sdes      func_basename "$file"
9483238104Sdes      name="$func_basename_result"
9484238104Sdes      test "$opt_mode" = uninstall && odir="$dir"
9485238104Sdes
9486238104Sdes      # Remember odir for removal later, being careful to avoid duplicates
9487238104Sdes      if test "$opt_mode" = clean; then
9488238104Sdes	case " $rmdirs " in
9489238104Sdes	  *" $odir "*) ;;
9490238104Sdes	  *) func_append rmdirs " $odir" ;;
9491238104Sdes	esac
9492238104Sdes      fi
9493238104Sdes
9494238104Sdes      # Don't error if the file doesn't exist and rm -f was used.
9495238104Sdes      if { test -L "$file"; } >/dev/null 2>&1 ||
9496238104Sdes	 { test -h "$file"; } >/dev/null 2>&1 ||
9497238104Sdes	 test -f "$file"; then
9498238104Sdes	:
9499238104Sdes      elif test -d "$file"; then
9500238104Sdes	exit_status=1
9501238104Sdes	continue
9502238104Sdes      elif test "$rmforce" = yes; then
9503238104Sdes	continue
9504238104Sdes      fi
9505238104Sdes
9506238104Sdes      rmfiles="$file"
9507238104Sdes
9508238104Sdes      case $name in
9509238104Sdes      *.la)
9510238104Sdes	# Possibly a libtool archive, so verify it.
9511238104Sdes	if func_lalib_p "$file"; then
9512238104Sdes	  func_source $dir/$name
9513238104Sdes
9514238104Sdes	  # Delete the libtool libraries and symlinks.
9515238104Sdes	  for n in $library_names; do
9516238104Sdes	    func_append rmfiles " $odir/$n"
9517238104Sdes	  done
9518238104Sdes	  test -n "$old_library" && func_append rmfiles " $odir/$old_library"
9519238104Sdes
9520238104Sdes	  case "$opt_mode" in
9521238104Sdes	  clean)
9522238104Sdes	    case " $library_names " in
9523238104Sdes	    *" $dlname "*) ;;
9524238104Sdes	    *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;;
9525238104Sdes	    esac
9526238104Sdes	    test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i"
9527238104Sdes	    ;;
9528238104Sdes	  uninstall)
9529238104Sdes	    if test -n "$library_names"; then
9530238104Sdes	      # Do each command in the postuninstall commands.
9531238104Sdes	      func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
9532238104Sdes	    fi
9533238104Sdes
9534238104Sdes	    if test -n "$old_library"; then
9535238104Sdes	      # Do each command in the old_postuninstall commands.
9536238104Sdes	      func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
9537238104Sdes	    fi
9538238104Sdes	    # FIXME: should reinstall the best remaining shared library.
9539238104Sdes	    ;;
9540238104Sdes	  esac
9541238104Sdes	fi
9542238104Sdes	;;
9543238104Sdes
9544238104Sdes      *.lo)
9545238104Sdes	# Possibly a libtool object, so verify it.
9546238104Sdes	if func_lalib_p "$file"; then
9547238104Sdes
9548238104Sdes	  # Read the .lo file
9549238104Sdes	  func_source $dir/$name
9550238104Sdes
9551238104Sdes	  # Add PIC object to the list of files to remove.
9552238104Sdes	  if test -n "$pic_object" &&
9553238104Sdes	     test "$pic_object" != none; then
9554238104Sdes	    func_append rmfiles " $dir/$pic_object"
9555238104Sdes	  fi
9556238104Sdes
9557238104Sdes	  # Add non-PIC object to the list of files to remove.
9558238104Sdes	  if test -n "$non_pic_object" &&
9559238104Sdes	     test "$non_pic_object" != none; then
9560238104Sdes	    func_append rmfiles " $dir/$non_pic_object"
9561238104Sdes	  fi
9562238104Sdes	fi
9563238104Sdes	;;
9564238104Sdes
9565238104Sdes      *)
9566238104Sdes	if test "$opt_mode" = clean ; then
9567238104Sdes	  noexename=$name
9568238104Sdes	  case $file in
9569238104Sdes	  *.exe)
9570238104Sdes	    func_stripname '' '.exe' "$file"
9571238104Sdes	    file=$func_stripname_result
9572238104Sdes	    func_stripname '' '.exe' "$name"
9573238104Sdes	    noexename=$func_stripname_result
9574238104Sdes	    # $file with .exe has already been added to rmfiles,
9575238104Sdes	    # add $file without .exe
9576238104Sdes	    func_append rmfiles " $file"
9577238104Sdes	    ;;
9578238104Sdes	  esac
9579238104Sdes	  # Do a test to see if this is a libtool program.
9580238104Sdes	  if func_ltwrapper_p "$file"; then
9581238104Sdes	    if func_ltwrapper_executable_p "$file"; then
9582238104Sdes	      func_ltwrapper_scriptname "$file"
9583238104Sdes	      relink_command=
9584238104Sdes	      func_source $func_ltwrapper_scriptname_result
9585238104Sdes	      func_append rmfiles " $func_ltwrapper_scriptname_result"
9586238104Sdes	    else
9587238104Sdes	      relink_command=
9588238104Sdes	      func_source $dir/$noexename
9589238104Sdes	    fi
9590238104Sdes
9591238104Sdes	    # note $name still contains .exe if it was in $file originally
9592238104Sdes	    # as does the version of $file that was added into $rmfiles
9593238104Sdes	    func_append rmfiles " $odir/$name $odir/${name}S.${objext}"
9594238104Sdes	    if test "$fast_install" = yes && test -n "$relink_command"; then
9595238104Sdes	      func_append rmfiles " $odir/lt-$name"
9596238104Sdes	    fi
9597238104Sdes	    if test "X$noexename" != "X$name" ; then
9598238104Sdes	      func_append rmfiles " $odir/lt-${noexename}.c"
9599238104Sdes	    fi
9600238104Sdes	  fi
9601238104Sdes	fi
9602238104Sdes	;;
9603238104Sdes      esac
9604238104Sdes      func_show_eval "$RM $rmfiles" 'exit_status=1'
9605238104Sdes    done
9606238104Sdes
9607238104Sdes    # Try to remove the ${objdir}s in the directories where we deleted files
9608238104Sdes    for dir in $rmdirs; do
9609238104Sdes      if test -d "$dir"; then
9610238104Sdes	func_show_eval "rmdir $dir >/dev/null 2>&1"
9611238104Sdes      fi
9612238104Sdes    done
9613238104Sdes
9614238104Sdes    exit $exit_status
9615238104Sdes}
9616238104Sdes
9617238104Sdes{ test "$opt_mode" = uninstall || test "$opt_mode" = clean; } &&
9618238104Sdes    func_mode_uninstall ${1+"$@"}
9619238104Sdes
9620238104Sdestest -z "$opt_mode" && {
9621238104Sdes  help="$generic_help"
9622238104Sdes  func_fatal_help "you must specify a MODE"
9623238104Sdes}
9624238104Sdes
9625238104Sdestest -z "$exec_cmd" && \
9626238104Sdes  func_fatal_help "invalid operation mode \`$opt_mode'"
9627238104Sdes
9628238104Sdesif test -n "$exec_cmd"; then
9629238104Sdes  eval exec "$exec_cmd"
9630238104Sdes  exit $EXIT_FAILURE
9631238104Sdesfi
9632238104Sdes
9633238104Sdesexit $exit_status
9634238104Sdes
9635238104Sdes
9636238104Sdes# The TAGs below are defined such that we never get into a situation
9637238104Sdes# in which we disable both kinds of libraries.  Given conflicting
9638238104Sdes# choices, we go for a static library, that is the most portable,
9639238104Sdes# since we can't tell whether shared libraries were disabled because
9640238104Sdes# the user asked for that or because the platform doesn't support
9641238104Sdes# them.  This is particularly important on AIX, because we don't
9642238104Sdes# support having both static and shared libraries enabled at the same
9643238104Sdes# time on that platform, so we default to a shared-only configuration.
9644238104Sdes# If a disable-shared tag is given, we'll fallback to a static-only
9645238104Sdes# configuration.  But we'll never go from static-only to shared-only.
9646238104Sdes
9647238104Sdes# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
9648238104Sdesbuild_libtool_libs=no
9649238104Sdesbuild_old_libs=yes
9650238104Sdes# ### END LIBTOOL TAG CONFIG: disable-shared
9651238104Sdes
9652238104Sdes# ### BEGIN LIBTOOL TAG CONFIG: disable-static
9653238104Sdesbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
9654238104Sdes# ### END LIBTOOL TAG CONFIG: disable-static
9655238104Sdes
9656238104Sdes# Local Variables:
9657238104Sdes# mode:shell-script
9658238104Sdes# sh-indentation:2
9659238104Sdes# End:
9660238104Sdes# vi:sw=2
9661238104Sdes
9662