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