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