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