ltmain.sh revision af1a9c97
1af1a9c97Smrg# Generated from ltmain.m4sh.
2af1a9c97Smrg
3af1a9c97Smrg# ltmain.sh (GNU libtool) 2.2.6
4af1a9c97Smrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
5af1a9c97Smrg
6af1a9c97Smrg# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007 2008 Free Software Foundation, Inc.
7af1a9c97Smrg# This is free software; see the source for copying conditions.  There is NO
8af1a9c97Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9af1a9c97Smrg
10af1a9c97Smrg# GNU Libtool is free software; you can redistribute it and/or modify
1150806d53Smrg# it under the terms of the GNU General Public License as published by
1250806d53Smrg# the Free Software Foundation; either version 2 of the License, or
1350806d53Smrg# (at your option) any later version.
1450806d53Smrg#
15af1a9c97Smrg# As a special exception to the GNU General Public License,
16af1a9c97Smrg# if you distribute this file as part of a program or library that
17af1a9c97Smrg# is built using GNU Libtool, you may include this file under the
18af1a9c97Smrg# same distribution terms that you use for the rest of that program.
19af1a9c97Smrg#
20af1a9c97Smrg# GNU Libtool is distributed in the hope that it will be useful, but
2150806d53Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of
2250806d53Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
2350806d53Smrg# General Public License for more details.
2450806d53Smrg#
2550806d53Smrg# You should have received a copy of the GNU General Public License
26af1a9c97Smrg# along with GNU Libtool; see the file COPYING.  If not, a copy
27af1a9c97Smrg# can be downloaded from http://www.gnu.org/licenses/gpl.html,
28af1a9c97Smrg# or obtained by writing to the Free Software Foundation, Inc.,
29af1a9c97Smrg# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
3050806d53Smrg
31af1a9c97Smrg# Usage: $progname [OPTION]... [MODE-ARG]...
32af1a9c97Smrg#
33af1a9c97Smrg# Provide generalized library-building support services.
34af1a9c97Smrg#
35af1a9c97Smrg#     --config             show all configuration variables
36af1a9c97Smrg#     --debug              enable verbose shell tracing
37af1a9c97Smrg# -n, --dry-run            display commands without modifying any files
38af1a9c97Smrg#     --features           display basic configuration information and exit
39af1a9c97Smrg#     --mode=MODE          use operation mode MODE
40af1a9c97Smrg#     --preserve-dup-deps  don't remove duplicate dependency libraries
41af1a9c97Smrg#     --quiet, --silent    don't print informational messages
42af1a9c97Smrg#     --tag=TAG            use configuration variables from tag TAG
43af1a9c97Smrg# -v, --verbose            print informational messages (default)
44af1a9c97Smrg#     --version            print version information
45af1a9c97Smrg# -h, --help               print short or long help message
46af1a9c97Smrg#
47af1a9c97Smrg# MODE must be one of the following:
48af1a9c97Smrg#
49af1a9c97Smrg#       clean              remove files from the build directory
50af1a9c97Smrg#       compile            compile a source file into a libtool object
51af1a9c97Smrg#       execute            automatically set library path, then run a program
52af1a9c97Smrg#       finish             complete the installation of libtool libraries
53af1a9c97Smrg#       install            install libraries or executables
54af1a9c97Smrg#       link               create a library or an executable
55af1a9c97Smrg#       uninstall          remove libraries from an installed directory
56af1a9c97Smrg#
57af1a9c97Smrg# MODE-ARGS vary depending on the MODE.
58af1a9c97Smrg# Try `$progname --help --mode=MODE' for a more detailed description of MODE.
59af1a9c97Smrg#
60af1a9c97Smrg# When reporting a bug, please describe a test case to reproduce it and
61af1a9c97Smrg# include the following information:
62af1a9c97Smrg#
63af1a9c97Smrg#       host-triplet:	$host
64af1a9c97Smrg#       shell:		$SHELL
65af1a9c97Smrg#       compiler:		$LTCC
66af1a9c97Smrg#       compiler flags:		$LTCFLAGS
67af1a9c97Smrg#       linker:		$LD (gnu? $with_gnu_ld)
68af1a9c97Smrg#       $progname:		(GNU libtool) 2.2.6
69af1a9c97Smrg#       automake:		$automake_version
70af1a9c97Smrg#       autoconf:		$autoconf_version
71af1a9c97Smrg#
72af1a9c97Smrg# Report bugs to <bug-libtool@gnu.org>.
7350806d53Smrg
7450806d53SmrgPROGRAM=ltmain.sh
7550806d53SmrgPACKAGE=libtool
76af1a9c97SmrgVERSION=2.2.6
77af1a9c97SmrgTIMESTAMP=""
78af1a9c97Smrgpackage_revision=1.3012
7950806d53Smrg
80af1a9c97Smrg# Be Bourne compatible
8150806d53Smrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
8250806d53Smrg  emulate sh
8350806d53Smrg  NULLCMD=:
8450806d53Smrg  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
8550806d53Smrg  # is contrary to our usage.  Disable this feature.
8650806d53Smrg  alias -g '${1+"$@"}'='"$@"'
8750806d53Smrg  setopt NO_GLOB_SUBST
8850806d53Smrgelse
8950806d53Smrg  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
9050806d53Smrgfi
917965d9acSmrgBIN_SH=xpg4; export BIN_SH # for Tru64
927965d9acSmrgDUALCASE=1; export DUALCASE # for MKS sh
9350806d53Smrg
94af1a9c97Smrg# NLS nuisances: We save the old values to restore during execute mode.
9550806d53Smrg# Only set LANG and LC_ALL to C if already set.
9650806d53Smrg# These must not be set unconditionally because not all systems understand
9750806d53Smrg# e.g. LANG=C (notably SCO).
98af1a9c97Smrglt_user_locale=
99af1a9c97Smrglt_safe_locale=
1007965d9acSmrgfor lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
10150806d53Smrgdo
10250806d53Smrg  eval "if test \"\${$lt_var+set}\" = set; then
103af1a9c97Smrg          save_$lt_var=\$$lt_var
104af1a9c97Smrg          $lt_var=C
1057965d9acSmrg	  export $lt_var
106af1a9c97Smrg	  lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\"
107af1a9c97Smrg	  lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
1087965d9acSmrg	fi"
10950806d53Smrgdone
11050806d53Smrg
111af1a9c97Smrg$lt_unset CDPATH
112af1a9c97Smrg
113af1a9c97Smrg
114af1a9c97Smrg
115af1a9c97Smrg
116af1a9c97Smrg
117af1a9c97Smrg: ${CP="cp -f"}
118af1a9c97Smrg: ${ECHO="echo"}
119af1a9c97Smrg: ${EGREP="/bin/grep -E"}
120af1a9c97Smrg: ${FGREP="/bin/grep -F"}
121af1a9c97Smrg: ${GREP="/bin/grep"}
122af1a9c97Smrg: ${LN_S="ln -s"}
123af1a9c97Smrg: ${MAKE="make"}
124af1a9c97Smrg: ${MKDIR="mkdir"}
125af1a9c97Smrg: ${MV="mv -f"}
126af1a9c97Smrg: ${RM="rm -f"}
127af1a9c97Smrg: ${SED="/bin/sed"}
128af1a9c97Smrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
129af1a9c97Smrg: ${Xsed="$SED -e 1s/^X//"}
130af1a9c97Smrg
131af1a9c97Smrg# Global variables:
132af1a9c97SmrgEXIT_SUCCESS=0
133af1a9c97SmrgEXIT_FAILURE=1
134af1a9c97SmrgEXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
135af1a9c97SmrgEXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
136af1a9c97Smrg
137af1a9c97Smrgexit_status=$EXIT_SUCCESS
1387965d9acSmrg
13950806d53Smrg# Make sure IFS has a sensible default
14050806d53Smrglt_nl='
14150806d53Smrg'
14250806d53SmrgIFS=" 	$lt_nl"
14350806d53Smrg
144af1a9c97Smrgdirname="s,/[^/]*$,,"
145af1a9c97Smrgbasename="s,^.*/,,"
146af1a9c97Smrg
147af1a9c97Smrg# func_dirname_and_basename file append nondir_replacement
148af1a9c97Smrg# perform func_basename and func_dirname in a single function
149af1a9c97Smrg# call:
150af1a9c97Smrg#   dirname:  Compute the dirname of FILE.  If nonempty,
151af1a9c97Smrg#             add APPEND to the result, otherwise set result
152af1a9c97Smrg#             to NONDIR_REPLACEMENT.
153af1a9c97Smrg#             value returned in "$func_dirname_result"
154af1a9c97Smrg#   basename: Compute filename of FILE.
155af1a9c97Smrg#             value retuned in "$func_basename_result"
156af1a9c97Smrg# Implementation must be kept synchronized with func_dirname
157af1a9c97Smrg# and func_basename. For efficiency, we do not delegate to
158af1a9c97Smrg# those functions but instead duplicate the functionality here.
159af1a9c97Smrgfunc_dirname_and_basename ()
160af1a9c97Smrg{
161af1a9c97Smrg  # Extract subdirectory from the argument.
162af1a9c97Smrg  func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"`
163af1a9c97Smrg  if test "X$func_dirname_result" = "X${1}"; then
164af1a9c97Smrg    func_dirname_result="${3}"
165af1a9c97Smrg  else
166af1a9c97Smrg    func_dirname_result="$func_dirname_result${2}"
167af1a9c97Smrg  fi
168af1a9c97Smrg  func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"`
169af1a9c97Smrg}
17050806d53Smrg
171af1a9c97Smrg# Generated shell functions inserted here.
172af1a9c97Smrg
173af1a9c97Smrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
174af1a9c97Smrg# is ksh but when the shell is invoked as "sh" and the current value of
175af1a9c97Smrg# the _XPG environment variable is not equal to 1 (one), the special
176af1a9c97Smrg# positional parameter $0, within a function call, is the name of the
177af1a9c97Smrg# function.
178af1a9c97Smrgprogpath="$0"
179af1a9c97Smrg
180af1a9c97Smrg# The name of this program:
181af1a9c97Smrg# In the unlikely event $progname began with a '-', it would play havoc with
182af1a9c97Smrg# func_echo (imagine progname=-n), so we prepend ./ in that case:
183af1a9c97Smrgfunc_dirname_and_basename "$progpath"
184af1a9c97Smrgprogname=$func_basename_result
185af1a9c97Smrgcase $progname in
186af1a9c97Smrg  -*) progname=./$progname ;;
187af1a9c97Smrgesac
188af1a9c97Smrg
189af1a9c97Smrg# Make sure we have an absolute path for reexecution:
190af1a9c97Smrgcase $progpath in
191af1a9c97Smrg  [\\/]*|[A-Za-z]:\\*) ;;
192af1a9c97Smrg  *[\\/]*)
193af1a9c97Smrg     progdir=$func_dirname_result
194af1a9c97Smrg     progdir=`cd "$progdir" && pwd`
195af1a9c97Smrg     progpath="$progdir/$progname"
196af1a9c97Smrg     ;;
197af1a9c97Smrg  *)
198af1a9c97Smrg     save_IFS="$IFS"
199af1a9c97Smrg     IFS=:
200af1a9c97Smrg     for progdir in $PATH; do
201af1a9c97Smrg       IFS="$save_IFS"
202af1a9c97Smrg       test -x "$progdir/$progname" && break
203af1a9c97Smrg     done
204af1a9c97Smrg     IFS="$save_IFS"
205af1a9c97Smrg     test -n "$progdir" || progdir=`pwd`
206af1a9c97Smrg     progpath="$progdir/$progname"
207af1a9c97Smrg     ;;
208af1a9c97Smrgesac
209af1a9c97Smrg
210af1a9c97Smrg# Sed substitution that helps us do robust quoting.  It backslashifies
211af1a9c97Smrg# metacharacters that are still active within double-quoted strings.
212af1a9c97SmrgXsed="${SED}"' -e 1s/^X//'
213af1a9c97Smrgsed_quote_subst='s/\([`"$\\]\)/\\\1/g'
214af1a9c97Smrg
215af1a9c97Smrg# Same as above, but do not quote variable references.
216af1a9c97Smrgdouble_quote_subst='s/\(["`\\]\)/\\\1/g'
217af1a9c97Smrg
218af1a9c97Smrg# Re-`\' parameter expansions in output of double_quote_subst that were
219af1a9c97Smrg# `\'-ed in input to the same.  If an odd number of `\' preceded a '$'
220af1a9c97Smrg# in input to double_quote_subst, that '$' was protected from expansion.
221af1a9c97Smrg# Since each input `\' is now two `\'s, look for any number of runs of
222af1a9c97Smrg# four `\'s followed by two `\'s and then a '$'.  `\' that '$'.
223af1a9c97Smrgbs='\\'
224af1a9c97Smrgbs2='\\\\'
225af1a9c97Smrgbs4='\\\\\\\\'
226af1a9c97Smrgdollar='\$'
227af1a9c97Smrgsed_double_backslash="\
228af1a9c97Smrg  s/$bs4/&\\
229af1a9c97Smrg/g
230af1a9c97Smrg  s/^$bs2$dollar/$bs&/
231af1a9c97Smrg  s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
232af1a9c97Smrg  s/\n//g"
233af1a9c97Smrg
234af1a9c97Smrg# Standard options:
235af1a9c97Smrgopt_dry_run=false
236af1a9c97Smrgopt_help=false
237af1a9c97Smrgopt_quiet=false
238af1a9c97Smrgopt_verbose=false
239af1a9c97Smrgopt_warning=:
240af1a9c97Smrg
241af1a9c97Smrg# func_echo arg...
242af1a9c97Smrg# Echo program name prefixed message, along with the current mode
243af1a9c97Smrg# name if it has been set yet.
244af1a9c97Smrgfunc_echo ()
245af1a9c97Smrg{
246af1a9c97Smrg    $ECHO "$progname${mode+: }$mode: $*"
247af1a9c97Smrg}
248af1a9c97Smrg
249af1a9c97Smrg# func_verbose arg...
250af1a9c97Smrg# Echo program name prefixed message in verbose mode only.
251af1a9c97Smrgfunc_verbose ()
252af1a9c97Smrg{
253af1a9c97Smrg    $opt_verbose && func_echo ${1+"$@"}
254af1a9c97Smrg
255af1a9c97Smrg    # A bug in bash halts the script if the last line of a function
256af1a9c97Smrg    # fails when set -e is in force, so we need another command to
257af1a9c97Smrg    # work around that:
258af1a9c97Smrg    :
259af1a9c97Smrg}
260af1a9c97Smrg
261af1a9c97Smrg# func_error arg...
262af1a9c97Smrg# Echo program name prefixed message to standard error.
263af1a9c97Smrgfunc_error ()
264af1a9c97Smrg{
265af1a9c97Smrg    $ECHO "$progname${mode+: }$mode: "${1+"$@"} 1>&2
266af1a9c97Smrg}
267af1a9c97Smrg
268af1a9c97Smrg# func_warning arg...
269af1a9c97Smrg# Echo program name prefixed warning message to standard error.
270af1a9c97Smrgfunc_warning ()
271af1a9c97Smrg{
272af1a9c97Smrg    $opt_warning && $ECHO "$progname${mode+: }$mode: warning: "${1+"$@"} 1>&2
273af1a9c97Smrg
274af1a9c97Smrg    # bash bug again:
275af1a9c97Smrg    :
276af1a9c97Smrg}
277af1a9c97Smrg
278af1a9c97Smrg# func_fatal_error arg...
279af1a9c97Smrg# Echo program name prefixed message to standard error, and exit.
280af1a9c97Smrgfunc_fatal_error ()
281af1a9c97Smrg{
282af1a9c97Smrg    func_error ${1+"$@"}
283af1a9c97Smrg    exit $EXIT_FAILURE
284af1a9c97Smrg}
285af1a9c97Smrg
286af1a9c97Smrg# func_fatal_help arg...
287af1a9c97Smrg# Echo program name prefixed message to standard error, followed by
288af1a9c97Smrg# a help hint, and exit.
289af1a9c97Smrgfunc_fatal_help ()
290af1a9c97Smrg{
291af1a9c97Smrg    func_error ${1+"$@"}
292af1a9c97Smrg    func_fatal_error "$help"
293af1a9c97Smrg}
294af1a9c97Smrghelp="Try \`$progname --help' for more information."  ## default
295af1a9c97Smrg
296af1a9c97Smrg
297af1a9c97Smrg# func_grep expression filename
298af1a9c97Smrg# Check whether EXPRESSION matches any line of FILENAME, without output.
299af1a9c97Smrgfunc_grep ()
300af1a9c97Smrg{
301af1a9c97Smrg    $GREP "$1" "$2" >/dev/null 2>&1
302af1a9c97Smrg}
303af1a9c97Smrg
304af1a9c97Smrg
305af1a9c97Smrg# func_mkdir_p directory-path
306af1a9c97Smrg# Make sure the entire path to DIRECTORY-PATH is available.
307af1a9c97Smrgfunc_mkdir_p ()
308af1a9c97Smrg{
309af1a9c97Smrg    my_directory_path="$1"
310af1a9c97Smrg    my_dir_list=
311af1a9c97Smrg
312af1a9c97Smrg    if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
313af1a9c97Smrg
314af1a9c97Smrg      # Protect directory names starting with `-'
315af1a9c97Smrg      case $my_directory_path in
316af1a9c97Smrg        -*) my_directory_path="./$my_directory_path" ;;
317af1a9c97Smrg      esac
318af1a9c97Smrg
319af1a9c97Smrg      # While some portion of DIR does not yet exist...
320af1a9c97Smrg      while test ! -d "$my_directory_path"; do
321af1a9c97Smrg        # ...make a list in topmost first order.  Use a colon delimited
322af1a9c97Smrg	# list incase some portion of path contains whitespace.
323af1a9c97Smrg        my_dir_list="$my_directory_path:$my_dir_list"
324af1a9c97Smrg
325af1a9c97Smrg        # If the last portion added has no slash in it, the list is done
326af1a9c97Smrg        case $my_directory_path in */*) ;; *) break ;; esac
327af1a9c97Smrg
328af1a9c97Smrg        # ...otherwise throw away the child directory and loop
329af1a9c97Smrg        my_directory_path=`$ECHO "X$my_directory_path" | $Xsed -e "$dirname"`
330af1a9c97Smrg      done
331af1a9c97Smrg      my_dir_list=`$ECHO "X$my_dir_list" | $Xsed -e 's,:*$,,'`
332af1a9c97Smrg
333af1a9c97Smrg      save_mkdir_p_IFS="$IFS"; IFS=':'
334af1a9c97Smrg      for my_dir in $my_dir_list; do
335af1a9c97Smrg	IFS="$save_mkdir_p_IFS"
336af1a9c97Smrg        # mkdir can fail with a `File exist' error if two processes
337af1a9c97Smrg        # try to create one of the directories concurrently.  Don't
338af1a9c97Smrg        # stop in that case!
339af1a9c97Smrg        $MKDIR "$my_dir" 2>/dev/null || :
340af1a9c97Smrg      done
341af1a9c97Smrg      IFS="$save_mkdir_p_IFS"
342af1a9c97Smrg
343af1a9c97Smrg      # Bail out if we (or some other process) failed to create a directory.
344af1a9c97Smrg      test -d "$my_directory_path" || \
345af1a9c97Smrg        func_fatal_error "Failed to create \`$1'"
346af1a9c97Smrg    fi
347af1a9c97Smrg}
34850806d53Smrg
34950806d53Smrg
35050806d53Smrg# func_mktempdir [string]
35150806d53Smrg# Make a temporary directory that won't clash with other running
35250806d53Smrg# libtool processes, and avoids race conditions if possible.  If
35350806d53Smrg# given, STRING is the basename for that directory.
35450806d53Smrgfunc_mktempdir ()
35550806d53Smrg{
35650806d53Smrg    my_template="${TMPDIR-/tmp}/${1-$progname}"
35750806d53Smrg
358af1a9c97Smrg    if test "$opt_dry_run" = ":"; then
35950806d53Smrg      # Return a directory name, but don't create it in dry-run mode
36050806d53Smrg      my_tmpdir="${my_template}-$$"
36150806d53Smrg    else
36250806d53Smrg
36350806d53Smrg      # If mktemp works, use that first and foremost
36450806d53Smrg      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
36550806d53Smrg
36650806d53Smrg      if test ! -d "$my_tmpdir"; then
367af1a9c97Smrg        # Failing that, at least try and use $RANDOM to avoid a race
368af1a9c97Smrg        my_tmpdir="${my_template}-${RANDOM-0}$$"
36950806d53Smrg
370af1a9c97Smrg        save_mktempdir_umask=`umask`
371af1a9c97Smrg        umask 0077
372af1a9c97Smrg        $MKDIR "$my_tmpdir"
373af1a9c97Smrg        umask $save_mktempdir_umask
37450806d53Smrg      fi
37550806d53Smrg
37650806d53Smrg      # If we're not in dry-run mode, bomb out on failure
377af1a9c97Smrg      test -d "$my_tmpdir" || \
378af1a9c97Smrg        func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
37950806d53Smrg    fi
38050806d53Smrg
381af1a9c97Smrg    $ECHO "X$my_tmpdir" | $Xsed
38250806d53Smrg}
38350806d53Smrg
38450806d53Smrg
385af1a9c97Smrg# func_quote_for_eval arg
386af1a9c97Smrg# Aesthetically quote ARG to be evaled later.
387af1a9c97Smrg# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
388af1a9c97Smrg# is double-quoted, suitable for a subsequent eval, whereas
389af1a9c97Smrg# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
390af1a9c97Smrg# which are still active within double quotes backslashified.
391af1a9c97Smrgfunc_quote_for_eval ()
39250806d53Smrg{
393af1a9c97Smrg    case $1 in
394af1a9c97Smrg      *[\\\`\"\$]*)
395af1a9c97Smrg	func_quote_for_eval_unquoted_result=`$ECHO "X$1" | $Xsed -e "$sed_quote_subst"` ;;
396af1a9c97Smrg      *)
397af1a9c97Smrg        func_quote_for_eval_unquoted_result="$1" ;;
398af1a9c97Smrg    esac
399af1a9c97Smrg
400af1a9c97Smrg    case $func_quote_for_eval_unquoted_result in
401af1a9c97Smrg      # Double-quote args containing shell metacharacters to delay
402af1a9c97Smrg      # word splitting, command substitution and and variable
403af1a9c97Smrg      # expansion for a subsequent eval.
404af1a9c97Smrg      # Many Bourne shells cannot handle close brackets correctly
405af1a9c97Smrg      # in scan sets, so we specify it separately.
406af1a9c97Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
407af1a9c97Smrg        func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
408af1a9c97Smrg        ;;
409af1a9c97Smrg      *)
410af1a9c97Smrg        func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
41150806d53Smrg    esac
41250806d53Smrg}
41350806d53Smrg
41450806d53Smrg
415af1a9c97Smrg# func_quote_for_expand arg
416af1a9c97Smrg# Aesthetically quote ARG to be evaled later; same as above,
417af1a9c97Smrg# but do not quote variable references.
418af1a9c97Smrgfunc_quote_for_expand ()
41950806d53Smrg{
420af1a9c97Smrg    case $1 in
421af1a9c97Smrg      *[\\\`\"]*)
422af1a9c97Smrg	my_arg=`$ECHO "X$1" | $Xsed \
423af1a9c97Smrg	    -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
42450806d53Smrg      *)
425af1a9c97Smrg        my_arg="$1" ;;
426af1a9c97Smrg    esac
427af1a9c97Smrg
428af1a9c97Smrg    case $my_arg in
429af1a9c97Smrg      # Double-quote args containing shell metacharacters to delay
430af1a9c97Smrg      # word splitting and command substitution for a subsequent eval.
431af1a9c97Smrg      # Many Bourne shells cannot handle close brackets correctly
432af1a9c97Smrg      # in scan sets, so we specify it separately.
433af1a9c97Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
434af1a9c97Smrg        my_arg="\"$my_arg\""
435af1a9c97Smrg        ;;
436af1a9c97Smrg    esac
437af1a9c97Smrg
438af1a9c97Smrg    func_quote_for_expand_result="$my_arg"
43950806d53Smrg}
44050806d53Smrg
44150806d53Smrg
442af1a9c97Smrg# func_show_eval cmd [fail_exp]
443af1a9c97Smrg# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
444af1a9c97Smrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
445af1a9c97Smrg# is given, then evaluate it.
446af1a9c97Smrgfunc_show_eval ()
44750806d53Smrg{
448af1a9c97Smrg    my_cmd="$1"
449af1a9c97Smrg    my_fail_exp="${2-:}"
45050806d53Smrg
451af1a9c97Smrg    ${opt_silent-false} || {
452af1a9c97Smrg      func_quote_for_expand "$my_cmd"
453af1a9c97Smrg      eval "func_echo $func_quote_for_expand_result"
454af1a9c97Smrg    }
455af1a9c97Smrg
456af1a9c97Smrg    if ${opt_dry_run-false}; then :; else
457af1a9c97Smrg      eval "$my_cmd"
458af1a9c97Smrg      my_status=$?
459af1a9c97Smrg      if test "$my_status" -eq 0; then :; else
460af1a9c97Smrg	eval "(exit $my_status); $my_fail_exp"
461af1a9c97Smrg      fi
46250806d53Smrg    fi
46350806d53Smrg}
46450806d53Smrg
465af1a9c97Smrg
466af1a9c97Smrg# func_show_eval_locale cmd [fail_exp]
467af1a9c97Smrg# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
468af1a9c97Smrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
469af1a9c97Smrg# is given, then evaluate it.  Use the saved locale for evaluation.
470af1a9c97Smrgfunc_show_eval_locale ()
47150806d53Smrg{
472af1a9c97Smrg    my_cmd="$1"
473af1a9c97Smrg    my_fail_exp="${2-:}"
474af1a9c97Smrg
475af1a9c97Smrg    ${opt_silent-false} || {
476af1a9c97Smrg      func_quote_for_expand "$my_cmd"
477af1a9c97Smrg      eval "func_echo $func_quote_for_expand_result"
478af1a9c97Smrg    }
479af1a9c97Smrg
480af1a9c97Smrg    if ${opt_dry_run-false}; then :; else
481af1a9c97Smrg      eval "$lt_user_locale
482af1a9c97Smrg	    $my_cmd"
483af1a9c97Smrg      my_status=$?
484af1a9c97Smrg      eval "$lt_safe_locale"
485af1a9c97Smrg      if test "$my_status" -eq 0; then :; else
486af1a9c97Smrg	eval "(exit $my_status); $my_fail_exp"
487af1a9c97Smrg      fi
48850806d53Smrg    fi
489af1a9c97Smrg}
49050806d53Smrg
49150806d53Smrg
492af1a9c97Smrg
493af1a9c97Smrg
494af1a9c97Smrg
495af1a9c97Smrg# func_version
496af1a9c97Smrg# Echo version message to standard output and exit.
497af1a9c97Smrgfunc_version ()
498af1a9c97Smrg{
499af1a9c97Smrg    $SED -n '/^# '$PROGRAM' (GNU /,/# warranty; / {
500af1a9c97Smrg        s/^# //
501af1a9c97Smrg	s/^# *$//
502af1a9c97Smrg        s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
503af1a9c97Smrg        p
504af1a9c97Smrg     }' < "$progpath"
505af1a9c97Smrg     exit $?
506af1a9c97Smrg}
507af1a9c97Smrg
508af1a9c97Smrg# func_usage
509af1a9c97Smrg# Echo short help message to standard output and exit.
510af1a9c97Smrgfunc_usage ()
511af1a9c97Smrg{
512af1a9c97Smrg    $SED -n '/^# Usage:/,/# -h/ {
513af1a9c97Smrg        s/^# //
514af1a9c97Smrg	s/^# *$//
515af1a9c97Smrg	s/\$progname/'$progname'/
516af1a9c97Smrg	p
517af1a9c97Smrg    }' < "$progpath"
518af1a9c97Smrg    $ECHO
519af1a9c97Smrg    $ECHO "run \`$progname --help | more' for full usage"
520af1a9c97Smrg    exit $?
521af1a9c97Smrg}
522af1a9c97Smrg
523af1a9c97Smrg# func_help
524af1a9c97Smrg# Echo long help message to standard output and exit.
525af1a9c97Smrgfunc_help ()
526af1a9c97Smrg{
527af1a9c97Smrg    $SED -n '/^# Usage:/,/# Report bugs to/ {
528af1a9c97Smrg        s/^# //
529af1a9c97Smrg	s/^# *$//
530af1a9c97Smrg	s*\$progname*'$progname'*
531af1a9c97Smrg	s*\$host*'"$host"'*
532af1a9c97Smrg	s*\$SHELL*'"$SHELL"'*
533af1a9c97Smrg	s*\$LTCC*'"$LTCC"'*
534af1a9c97Smrg	s*\$LTCFLAGS*'"$LTCFLAGS"'*
535af1a9c97Smrg	s*\$LD*'"$LD"'*
536af1a9c97Smrg	s/\$with_gnu_ld/'"$with_gnu_ld"'/
537af1a9c97Smrg	s/\$automake_version/'"`(automake --version) 2>/dev/null |$SED 1q`"'/
538af1a9c97Smrg	s/\$autoconf_version/'"`(autoconf --version) 2>/dev/null |$SED 1q`"'/
539af1a9c97Smrg	p
540af1a9c97Smrg     }' < "$progpath"
541af1a9c97Smrg    exit $?
542af1a9c97Smrg}
543af1a9c97Smrg
544af1a9c97Smrg# func_missing_arg argname
545af1a9c97Smrg# Echo program name prefixed message to standard error and set global
546af1a9c97Smrg# exit_cmd.
547af1a9c97Smrgfunc_missing_arg ()
548af1a9c97Smrg{
549af1a9c97Smrg    func_error "missing argument for $1"
550af1a9c97Smrg    exit_cmd=exit
55150806d53Smrg}
55250806d53Smrg
553af1a9c97Smrgexit_cmd=:
55450806d53Smrg
55550806d53Smrg
556af1a9c97Smrg
557af1a9c97Smrg
558af1a9c97Smrg
559af1a9c97Smrg# Check that we have a working $ECHO.
560af1a9c97Smrgif test "X$1" = X--no-reexec; then
561af1a9c97Smrg  # Discard the --no-reexec flag, and continue.
56250806d53Smrg  shift
563af1a9c97Smrgelif test "X$1" = X--fallback-echo; then
564af1a9c97Smrg  # Avoid inline document here, it may be left over
565af1a9c97Smrg  :
566af1a9c97Smrgelif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t'; then
567af1a9c97Smrg  # Yippee, $ECHO works!
568af1a9c97Smrg  :
569af1a9c97Smrgelse
570af1a9c97Smrg  # Restart under the correct shell, and then maybe $ECHO will work.
571af1a9c97Smrg  exec $SHELL "$progpath" --no-reexec ${1+"$@"}
572af1a9c97Smrgfi
57350806d53Smrg
574af1a9c97Smrgif test "X$1" = X--fallback-echo; then
575af1a9c97Smrg  # used as fallback echo
576af1a9c97Smrg  shift
577af1a9c97Smrg  cat <<EOF
578af1a9c97Smrg$*
579af1a9c97SmrgEOF
580af1a9c97Smrg  exit $EXIT_SUCCESS
581af1a9c97Smrgfi
58250806d53Smrg
583af1a9c97Smrgmagic="%%%MAGIC variable%%%"
584af1a9c97Smrgmagic_exe="%%%MAGIC EXE variable%%%"
58550806d53Smrg
586af1a9c97Smrg# Global variables.
587af1a9c97Smrg# $mode is unset
588af1a9c97Smrgnonopt=
589af1a9c97Smrgexecute_dlfiles=
590af1a9c97Smrgpreserve_args=
591af1a9c97Smrglo2o="s/\\.lo\$/.${objext}/"
592af1a9c97Smrgo2lo="s/\\.${objext}\$/.lo/"
593af1a9c97Smrgextracted_archives=
594af1a9c97Smrgextracted_serial=0
59550806d53Smrg
596af1a9c97Smrgopt_dry_run=false
597af1a9c97Smrgopt_duplicate_deps=false
598af1a9c97Smrgopt_silent=false
599af1a9c97Smrgopt_debug=:
60050806d53Smrg
601af1a9c97Smrg# If this variable is set in any of the actions, the command in it
602af1a9c97Smrg# will be execed at the end.  This prevents here-documents from being
603af1a9c97Smrg# left over by shells.
604af1a9c97Smrgexec_cmd=
605af1a9c97Smrg
606af1a9c97Smrg# func_fatal_configuration arg...
607af1a9c97Smrg# Echo program name prefixed message to standard error, followed by
608af1a9c97Smrg# a configuration failure hint, and exit.
609af1a9c97Smrgfunc_fatal_configuration ()
610af1a9c97Smrg{
611af1a9c97Smrg    func_error ${1+"$@"}
612af1a9c97Smrg    func_error "See the $PACKAGE documentation for more information."
613af1a9c97Smrg    func_fatal_error "Fatal configuration error."
614af1a9c97Smrg}
61550806d53Smrg
6167965d9acSmrg
617af1a9c97Smrg# func_config
618af1a9c97Smrg# Display the configuration for all the tags in this script.
619af1a9c97Smrgfunc_config ()
620af1a9c97Smrg{
621af1a9c97Smrg    re_begincf='^# ### BEGIN LIBTOOL'
622af1a9c97Smrg    re_endcf='^# ### END LIBTOOL'
623af1a9c97Smrg
624af1a9c97Smrg    # Default configuration.
625af1a9c97Smrg    $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
62650806d53Smrg
62750806d53Smrg    # Now print the configurations for the tags.
62850806d53Smrg    for tagname in $taglist; do
629af1a9c97Smrg      $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
63050806d53Smrg    done
63150806d53Smrg
632af1a9c97Smrg    exit $?
633af1a9c97Smrg}
63450806d53Smrg
635af1a9c97Smrg# func_features
636af1a9c97Smrg# Display the features supported by this script.
637af1a9c97Smrgfunc_features ()
638af1a9c97Smrg{
639af1a9c97Smrg    $ECHO "host: $host"
64050806d53Smrg    if test "$build_libtool_libs" = yes; then
641af1a9c97Smrg      $ECHO "enable shared libraries"
64250806d53Smrg    else
643af1a9c97Smrg      $ECHO "disable shared libraries"
64450806d53Smrg    fi
64550806d53Smrg    if test "$build_old_libs" = yes; then
646af1a9c97Smrg      $ECHO "enable static libraries"
64750806d53Smrg    else
648af1a9c97Smrg      $ECHO "disable static libraries"
64950806d53Smrg    fi
650af1a9c97Smrg
65150806d53Smrg    exit $?
652af1a9c97Smrg}
65350806d53Smrg
654af1a9c97Smrg# func_enable_tag tagname
655af1a9c97Smrg# Verify that TAGNAME is valid, and either flag an error and exit, or
656af1a9c97Smrg# enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
657af1a9c97Smrg# variable here.
658af1a9c97Smrgfunc_enable_tag ()
659af1a9c97Smrg{
660af1a9c97Smrg  # Global variable:
661af1a9c97Smrg  tagname="$1"
66250806d53Smrg
663af1a9c97Smrg  re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
664af1a9c97Smrg  re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
665af1a9c97Smrg  sed_extractcf="/$re_begincf/,/$re_endcf/p"
66650806d53Smrg
667af1a9c97Smrg  # Validate tagname.
668af1a9c97Smrg  case $tagname in
669af1a9c97Smrg    *[!-_A-Za-z0-9,/]*)
670af1a9c97Smrg      func_fatal_error "invalid tag name: $tagname"
671af1a9c97Smrg      ;;
672af1a9c97Smrg  esac
67350806d53Smrg
674af1a9c97Smrg  # Don't test for the "default" C tag, as we know it's
675af1a9c97Smrg  # there but not specially marked.
676af1a9c97Smrg  case $tagname in
677af1a9c97Smrg    CC) ;;
678af1a9c97Smrg    *)
679af1a9c97Smrg      if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
680af1a9c97Smrg	taglist="$taglist $tagname"
681af1a9c97Smrg
682af1a9c97Smrg	# Evaluate the configuration.  Be careful to quote the path
683af1a9c97Smrg	# and the sed script, to avoid splitting on whitespace, but
684af1a9c97Smrg	# also don't use non-portable quotes within backquotes within
685af1a9c97Smrg	# quotes we have to do it in 2 steps:
686af1a9c97Smrg	extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
687af1a9c97Smrg	eval "$extractedcf"
688af1a9c97Smrg      else
689af1a9c97Smrg	func_error "ignoring unknown tag $tagname"
690af1a9c97Smrg      fi
691af1a9c97Smrg      ;;
692af1a9c97Smrg  esac
693af1a9c97Smrg}
694af1a9c97Smrg
695af1a9c97Smrg# Parse options once, thoroughly.  This comes as soon as possible in
696af1a9c97Smrg# the script to make things like `libtool --version' happen quickly.
697af1a9c97Smrg{
69850806d53Smrg
699af1a9c97Smrg  # Shorthand for --mode=foo, only valid as the first argument
700af1a9c97Smrg  case $1 in
701af1a9c97Smrg  clean|clea|cle|cl)
702af1a9c97Smrg    shift; set dummy --mode clean ${1+"$@"}; shift
70350806d53Smrg    ;;
704af1a9c97Smrg  compile|compil|compi|comp|com|co|c)
705af1a9c97Smrg    shift; set dummy --mode compile ${1+"$@"}; shift
70650806d53Smrg    ;;
707af1a9c97Smrg  execute|execut|execu|exec|exe|ex|e)
708af1a9c97Smrg    shift; set dummy --mode execute ${1+"$@"}; shift
70950806d53Smrg    ;;
710af1a9c97Smrg  finish|finis|fini|fin|fi|f)
711af1a9c97Smrg    shift; set dummy --mode finish ${1+"$@"}; shift
71250806d53Smrg    ;;
713af1a9c97Smrg  install|instal|insta|inst|ins|in|i)
714af1a9c97Smrg    shift; set dummy --mode install ${1+"$@"}; shift
715af1a9c97Smrg    ;;
716af1a9c97Smrg  link|lin|li|l)
717af1a9c97Smrg    shift; set dummy --mode link ${1+"$@"}; shift
718af1a9c97Smrg    ;;
719af1a9c97Smrg  uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
720af1a9c97Smrg    shift; set dummy --mode uninstall ${1+"$@"}; shift
72150806d53Smrg    ;;
72250806d53Smrg  esac
72350806d53Smrg
724af1a9c97Smrg  # Parse non-mode specific arguments:
725af1a9c97Smrg  while test "$#" -gt 0; do
726af1a9c97Smrg    opt="$1"
727af1a9c97Smrg    shift
72850806d53Smrg
729af1a9c97Smrg    case $opt in
730af1a9c97Smrg      --config)		func_config					;;
73150806d53Smrg
732af1a9c97Smrg      --debug)		preserve_args="$preserve_args $opt"
733af1a9c97Smrg			func_echo "enabling shell trace mode"
734af1a9c97Smrg			opt_debug='set -x'
735af1a9c97Smrg			$opt_debug
736af1a9c97Smrg			;;
73750806d53Smrg
738af1a9c97Smrg      -dlopen)		test "$#" -eq 0 && func_missing_arg "$opt" && break
739af1a9c97Smrg			execute_dlfiles="$execute_dlfiles $1"
740af1a9c97Smrg			shift
741af1a9c97Smrg			;;
74250806d53Smrg
743af1a9c97Smrg      --dry-run | -n)	opt_dry_run=:					;;
744af1a9c97Smrg      --features)       func_features					;;
745af1a9c97Smrg      --finish)		mode="finish"					;;
746af1a9c97Smrg
747af1a9c97Smrg      --mode)		test "$#" -eq 0 && func_missing_arg "$opt" && break
748af1a9c97Smrg			case $1 in
749af1a9c97Smrg			  # Valid mode arguments:
750af1a9c97Smrg			  clean)	;;
751af1a9c97Smrg			  compile)	;;
752af1a9c97Smrg			  execute)	;;
753af1a9c97Smrg			  finish)	;;
754af1a9c97Smrg			  install)	;;
755af1a9c97Smrg			  link)		;;
756af1a9c97Smrg			  relink)	;;
757af1a9c97Smrg			  uninstall)	;;
758af1a9c97Smrg
759af1a9c97Smrg			  # Catch anything else as an error
760af1a9c97Smrg			  *) func_error "invalid argument for $opt"
761af1a9c97Smrg			     exit_cmd=exit
762af1a9c97Smrg			     break
763af1a9c97Smrg			     ;;
764af1a9c97Smrg		        esac
765af1a9c97Smrg
766af1a9c97Smrg			mode="$1"
767af1a9c97Smrg			shift
768af1a9c97Smrg			;;
769af1a9c97Smrg
770af1a9c97Smrg      --preserve-dup-deps)
771af1a9c97Smrg			opt_duplicate_deps=:				;;
772af1a9c97Smrg
773af1a9c97Smrg      --quiet|--silent)	preserve_args="$preserve_args $opt"
774af1a9c97Smrg			opt_silent=:
775af1a9c97Smrg			;;
776af1a9c97Smrg
777af1a9c97Smrg      --verbose| -v)	preserve_args="$preserve_args $opt"
778af1a9c97Smrg			opt_silent=false
779af1a9c97Smrg			;;
780af1a9c97Smrg
781af1a9c97Smrg      --tag)		test "$#" -eq 0 && func_missing_arg "$opt" && break
782af1a9c97Smrg			preserve_args="$preserve_args $opt $1"
783af1a9c97Smrg			func_enable_tag "$1"	# tagname is set here
784af1a9c97Smrg			shift
785af1a9c97Smrg			;;
786af1a9c97Smrg
787af1a9c97Smrg      # Separate optargs to long options:
788af1a9c97Smrg      -dlopen=*|--mode=*|--tag=*)
789af1a9c97Smrg			func_opt_split "$opt"
790af1a9c97Smrg			set dummy "$func_opt_split_opt" "$func_opt_split_arg" ${1+"$@"}
791af1a9c97Smrg			shift
792af1a9c97Smrg			;;
793af1a9c97Smrg
794af1a9c97Smrg      -\?|-h)		func_usage					;;
795af1a9c97Smrg      --help)		opt_help=:					;;
796af1a9c97Smrg      --version)	func_version					;;
797af1a9c97Smrg
798af1a9c97Smrg      -*)		func_fatal_help "unrecognized option \`$opt'"	;;
799af1a9c97Smrg
800af1a9c97Smrg      *)		nonopt="$opt"
801af1a9c97Smrg			break
802af1a9c97Smrg			;;
803af1a9c97Smrg    esac
804af1a9c97Smrg  done
805af1a9c97Smrg
806af1a9c97Smrg
807af1a9c97Smrg  case $host in
808af1a9c97Smrg    *cygwin* | *mingw* | *pw32* | *cegcc*)
809af1a9c97Smrg      # don't eliminate duplications in $postdeps and $predeps
810af1a9c97Smrg      opt_duplicate_compiler_generated_deps=:
81150806d53Smrg      ;;
81250806d53Smrg    *)
813af1a9c97Smrg      opt_duplicate_compiler_generated_deps=$opt_duplicate_deps
814af1a9c97Smrg      ;;
815af1a9c97Smrg  esac
81650806d53Smrg
817af1a9c97Smrg  # Having warned about all mis-specified options, bail out if
818af1a9c97Smrg  # anything was wrong.
819af1a9c97Smrg  $exit_cmd $EXIT_FAILURE
820af1a9c97Smrg}
821af1a9c97Smrg
822af1a9c97Smrg# func_check_version_match
823af1a9c97Smrg# Ensure that we are using m4 macros, and libtool script from the same
824af1a9c97Smrg# release of libtool.
825af1a9c97Smrgfunc_check_version_match ()
826af1a9c97Smrg{
827af1a9c97Smrg  if test "$package_revision" != "$macro_revision"; then
828af1a9c97Smrg    if test "$VERSION" != "$macro_version"; then
829af1a9c97Smrg      if test -z "$macro_version"; then
830af1a9c97Smrg        cat >&2 <<_LT_EOF
831af1a9c97Smrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
832af1a9c97Smrg$progname: definition of this LT_INIT comes from an older release.
833af1a9c97Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
834af1a9c97Smrg$progname: and run autoconf again.
835af1a9c97Smrg_LT_EOF
836af1a9c97Smrg      else
837af1a9c97Smrg        cat >&2 <<_LT_EOF
838af1a9c97Smrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
839af1a9c97Smrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
840af1a9c97Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
841af1a9c97Smrg$progname: and run autoconf again.
842af1a9c97Smrg_LT_EOF
84350806d53Smrg      fi
844af1a9c97Smrg    else
845af1a9c97Smrg      cat >&2 <<_LT_EOF
846af1a9c97Smrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
847af1a9c97Smrg$progname: but the definition of this LT_INIT comes from revision $macro_revision.
848af1a9c97Smrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision
849af1a9c97Smrg$progname: of $PACKAGE $VERSION and run autoconf again.
850af1a9c97Smrg_LT_EOF
851af1a9c97Smrg    fi
852af1a9c97Smrg
853af1a9c97Smrg    exit $EXIT_MISMATCH
854af1a9c97Smrg  fi
855af1a9c97Smrg}
856af1a9c97Smrg
857af1a9c97Smrg
858af1a9c97Smrg## ----------- ##
859af1a9c97Smrg##    Main.    ##
860af1a9c97Smrg## ----------- ##
861af1a9c97Smrg
862af1a9c97Smrg$opt_help || {
863af1a9c97Smrg  # Sanity checks first:
864af1a9c97Smrg  func_check_version_match
865af1a9c97Smrg
866af1a9c97Smrg  if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
867af1a9c97Smrg    func_fatal_configuration "not configured to build any kind of library"
86850806d53Smrg  fi
86950806d53Smrg
870af1a9c97Smrg  test -z "$mode" && func_fatal_error "error: you must specify a MODE."
871af1a9c97Smrg
872af1a9c97Smrg
873af1a9c97Smrg  # Darwin sucks
874af1a9c97Smrg  eval std_shrext=\"$shrext_cmds\"
875af1a9c97Smrg
876af1a9c97Smrg
87750806d53Smrg  # Only execute mode is allowed to have -dlopen flags.
87850806d53Smrg  if test -n "$execute_dlfiles" && test "$mode" != execute; then
879af1a9c97Smrg    func_error "unrecognized option \`-dlopen'"
880af1a9c97Smrg    $ECHO "$help" 1>&2
88150806d53Smrg    exit $EXIT_FAILURE
88250806d53Smrg  fi
88350806d53Smrg
88450806d53Smrg  # Change the help message to a mode-specific one.
88550806d53Smrg  generic_help="$help"
886af1a9c97Smrg  help="Try \`$progname --help --mode=$mode' for more information."
887af1a9c97Smrg}
88850806d53Smrg
88950806d53Smrg
890af1a9c97Smrg# func_lalib_p file
891af1a9c97Smrg# True iff FILE is a libtool `.la' library or `.lo' object file.
892af1a9c97Smrg# This function is only a basic sanity check; it will hardly flush out
893af1a9c97Smrg# determined imposters.
894af1a9c97Smrgfunc_lalib_p ()
895af1a9c97Smrg{
896af1a9c97Smrg    test -f "$1" &&
897af1a9c97Smrg      $SED -e 4q "$1" 2>/dev/null \
898af1a9c97Smrg        | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
899af1a9c97Smrg}
90050806d53Smrg
901af1a9c97Smrg# func_lalib_unsafe_p file
902af1a9c97Smrg# True iff FILE is a libtool `.la' library or `.lo' object file.
903af1a9c97Smrg# This function implements the same check as func_lalib_p without
904af1a9c97Smrg# resorting to external programs.  To this end, it redirects stdin and
905af1a9c97Smrg# closes it afterwards, without saving the original file descriptor.
906af1a9c97Smrg# As a safety measure, use it only where a negative result would be
907af1a9c97Smrg# fatal anyway.  Works if `file' does not exist.
908af1a9c97Smrgfunc_lalib_unsafe_p ()
909af1a9c97Smrg{
910af1a9c97Smrg    lalib_p=no
911af1a9c97Smrg    if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
912af1a9c97Smrg	for lalib_p_l in 1 2 3 4
913af1a9c97Smrg	do
914af1a9c97Smrg	    read lalib_p_line
915af1a9c97Smrg	    case "$lalib_p_line" in
916af1a9c97Smrg		\#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
917af1a9c97Smrg	    esac
918af1a9c97Smrg	done
919af1a9c97Smrg	exec 0<&5 5<&-
920af1a9c97Smrg    fi
921af1a9c97Smrg    test "$lalib_p" = yes
922af1a9c97Smrg}
92350806d53Smrg
924af1a9c97Smrg# func_ltwrapper_script_p file
925af1a9c97Smrg# True iff FILE is a libtool wrapper script
926af1a9c97Smrg# This function is only a basic sanity check; it will hardly flush out
927af1a9c97Smrg# determined imposters.
928af1a9c97Smrgfunc_ltwrapper_script_p ()
929af1a9c97Smrg{
930af1a9c97Smrg    func_lalib_p "$1"
931af1a9c97Smrg}
93250806d53Smrg
933af1a9c97Smrg# func_ltwrapper_executable_p file
934af1a9c97Smrg# True iff FILE is a libtool wrapper executable
935af1a9c97Smrg# This function is only a basic sanity check; it will hardly flush out
936af1a9c97Smrg# determined imposters.
937af1a9c97Smrgfunc_ltwrapper_executable_p ()
938af1a9c97Smrg{
939af1a9c97Smrg    func_ltwrapper_exec_suffix=
940af1a9c97Smrg    case $1 in
941af1a9c97Smrg    *.exe) ;;
942af1a9c97Smrg    *) func_ltwrapper_exec_suffix=.exe ;;
943af1a9c97Smrg    esac
944af1a9c97Smrg    $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
945af1a9c97Smrg}
94650806d53Smrg
947af1a9c97Smrg# func_ltwrapper_scriptname file
948af1a9c97Smrg# Assumes file is an ltwrapper_executable
949af1a9c97Smrg# uses $file to determine the appropriate filename for a
950af1a9c97Smrg# temporary ltwrapper_script.
951af1a9c97Smrgfunc_ltwrapper_scriptname ()
952af1a9c97Smrg{
953af1a9c97Smrg    func_ltwrapper_scriptname_result=""
954af1a9c97Smrg    if func_ltwrapper_executable_p "$1"; then
955af1a9c97Smrg	func_dirname_and_basename "$1" "" "."
956af1a9c97Smrg	func_stripname '' '.exe' "$func_basename_result"
957af1a9c97Smrg	func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper"
958af1a9c97Smrg    fi
959af1a9c97Smrg}
960af1a9c97Smrg
961af1a9c97Smrg# func_ltwrapper_p file
962af1a9c97Smrg# True iff FILE is a libtool wrapper script or wrapper executable
963af1a9c97Smrg# This function is only a basic sanity check; it will hardly flush out
964af1a9c97Smrg# determined imposters.
965af1a9c97Smrgfunc_ltwrapper_p ()
966af1a9c97Smrg{
967af1a9c97Smrg    func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
968af1a9c97Smrg}
969af1a9c97Smrg
970af1a9c97Smrg
971af1a9c97Smrg# func_execute_cmds commands fail_cmd
972af1a9c97Smrg# Execute tilde-delimited COMMANDS.
973af1a9c97Smrg# If FAIL_CMD is given, eval that upon failure.
974af1a9c97Smrg# FAIL_CMD may read-access the current command in variable CMD!
975af1a9c97Smrgfunc_execute_cmds ()
976af1a9c97Smrg{
977af1a9c97Smrg    $opt_debug
978af1a9c97Smrg    save_ifs=$IFS; IFS='~'
979af1a9c97Smrg    for cmd in $1; do
980af1a9c97Smrg      IFS=$save_ifs
981af1a9c97Smrg      eval cmd=\"$cmd\"
982af1a9c97Smrg      func_show_eval "$cmd" "${2-:}"
983af1a9c97Smrg    done
984af1a9c97Smrg    IFS=$save_ifs
985af1a9c97Smrg}
986af1a9c97Smrg
987af1a9c97Smrg
988af1a9c97Smrg# func_source file
989af1a9c97Smrg# Source FILE, adding directory component if necessary.
990af1a9c97Smrg# Note that it is not necessary on cygwin/mingw to append a dot to
991af1a9c97Smrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe
992af1a9c97Smrg# behavior happens only for exec(3), not for open(2)!  Also, sourcing
993af1a9c97Smrg# `FILE.' does not work on cygwin managed mounts.
994af1a9c97Smrgfunc_source ()
995af1a9c97Smrg{
996af1a9c97Smrg    $opt_debug
997af1a9c97Smrg    case $1 in
998af1a9c97Smrg    */* | *\\*)	. "$1" ;;
999af1a9c97Smrg    *)		. "./$1" ;;
1000af1a9c97Smrg    esac
1001af1a9c97Smrg}
1002af1a9c97Smrg
1003af1a9c97Smrg
1004af1a9c97Smrg# func_infer_tag arg
1005af1a9c97Smrg# Infer tagged configuration to use if any are available and
1006af1a9c97Smrg# if one wasn't chosen via the "--tag" command line option.
1007af1a9c97Smrg# Only attempt this if the compiler in the base compile
1008af1a9c97Smrg# command doesn't match the default compiler.
1009af1a9c97Smrg# arg is usually of the form 'gcc ...'
1010af1a9c97Smrgfunc_infer_tag ()
1011af1a9c97Smrg{
1012af1a9c97Smrg    $opt_debug
1013af1a9c97Smrg    if test -n "$available_tags" && test -z "$tagname"; then
1014af1a9c97Smrg      CC_quoted=
1015af1a9c97Smrg      for arg in $CC; do
1016af1a9c97Smrg        func_quote_for_eval "$arg"
1017af1a9c97Smrg	CC_quoted="$CC_quoted $func_quote_for_eval_result"
1018af1a9c97Smrg      done
1019af1a9c97Smrg      case $@ in
1020af1a9c97Smrg      # Blanks in the command may have been stripped by the calling shell,
1021af1a9c97Smrg      # but not from the CC environment variable when configure was run.
1022af1a9c97Smrg      " $CC "* | "$CC "* | " `$ECHO $CC` "* | "`$ECHO $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$ECHO $CC_quoted` "* | "`$ECHO $CC_quoted` "*) ;;
1023af1a9c97Smrg      # Blanks at the start of $base_compile will cause this to fail
1024af1a9c97Smrg      # if we don't check for them as well.
1025af1a9c97Smrg      *)
1026af1a9c97Smrg	for z in $available_tags; do
1027af1a9c97Smrg	  if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
1028af1a9c97Smrg	    # Evaluate the configuration.
1029af1a9c97Smrg	    eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
1030af1a9c97Smrg	    CC_quoted=
1031af1a9c97Smrg	    for arg in $CC; do
1032af1a9c97Smrg	      # Double-quote args containing other shell metacharacters.
1033af1a9c97Smrg	      func_quote_for_eval "$arg"
1034af1a9c97Smrg	      CC_quoted="$CC_quoted $func_quote_for_eval_result"
1035af1a9c97Smrg	    done
1036af1a9c97Smrg	    case "$@ " in
1037af1a9c97Smrg	      " $CC "* | "$CC "* | " `$ECHO $CC` "* | "`$ECHO $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$ECHO $CC_quoted` "* | "`$ECHO $CC_quoted` "*)
1038af1a9c97Smrg	      # The compiler in the base compile command matches
1039af1a9c97Smrg	      # the one in the tagged configuration.
1040af1a9c97Smrg	      # Assume this is the tagged configuration we want.
1041af1a9c97Smrg	      tagname=$z
1042af1a9c97Smrg	      break
1043af1a9c97Smrg	      ;;
1044af1a9c97Smrg	    esac
1045af1a9c97Smrg	  fi
1046af1a9c97Smrg	done
1047af1a9c97Smrg	# If $tagname still isn't set, then no tagged configuration
1048af1a9c97Smrg	# was found and let the user know that the "--tag" command
1049af1a9c97Smrg	# line option must be used.
1050af1a9c97Smrg	if test -z "$tagname"; then
1051af1a9c97Smrg	  func_echo "unable to infer tagged configuration"
1052af1a9c97Smrg	  func_fatal_error "specify a tag with \`--tag'"
1053af1a9c97Smrg#	else
1054af1a9c97Smrg#	  func_verbose "using $tagname tagged configuration"
1055af1a9c97Smrg	fi
1056af1a9c97Smrg	;;
1057af1a9c97Smrg      esac
1058af1a9c97Smrg    fi
1059af1a9c97Smrg}
1060af1a9c97Smrg
1061af1a9c97Smrg
1062af1a9c97Smrg
1063af1a9c97Smrg# func_write_libtool_object output_name pic_name nonpic_name
1064af1a9c97Smrg# Create a libtool object file (analogous to a ".la" file),
1065af1a9c97Smrg# but don't create it if we're doing a dry run.
1066af1a9c97Smrgfunc_write_libtool_object ()
1067af1a9c97Smrg{
1068af1a9c97Smrg    write_libobj=${1}
1069af1a9c97Smrg    if test "$build_libtool_libs" = yes; then
1070af1a9c97Smrg      write_lobj=\'${2}\'
1071af1a9c97Smrg    else
1072af1a9c97Smrg      write_lobj=none
1073af1a9c97Smrg    fi
1074af1a9c97Smrg
1075af1a9c97Smrg    if test "$build_old_libs" = yes; then
1076af1a9c97Smrg      write_oldobj=\'${3}\'
1077af1a9c97Smrg    else
1078af1a9c97Smrg      write_oldobj=none
1079af1a9c97Smrg    fi
1080af1a9c97Smrg
1081af1a9c97Smrg    $opt_dry_run || {
1082af1a9c97Smrg      cat >${write_libobj}T <<EOF
1083af1a9c97Smrg# $write_libobj - a libtool object file
1084af1a9c97Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
1085af1a9c97Smrg#
1086af1a9c97Smrg# Please DO NOT delete this file!
1087af1a9c97Smrg# It is necessary for linking the library.
1088af1a9c97Smrg
1089af1a9c97Smrg# Name of the PIC object.
1090af1a9c97Smrgpic_object=$write_lobj
1091af1a9c97Smrg
1092af1a9c97Smrg# Name of the non-PIC object
1093af1a9c97Smrgnon_pic_object=$write_oldobj
1094af1a9c97Smrg
1095af1a9c97SmrgEOF
1096af1a9c97Smrg      $MV "${write_libobj}T" "${write_libobj}"
1097af1a9c97Smrg    }
1098af1a9c97Smrg}
1099af1a9c97Smrg
1100af1a9c97Smrg# func_mode_compile arg...
1101af1a9c97Smrgfunc_mode_compile ()
1102af1a9c97Smrg{
1103af1a9c97Smrg    $opt_debug
1104af1a9c97Smrg    # Get the compilation command and the source file.
1105af1a9c97Smrg    base_compile=
1106af1a9c97Smrg    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
1107af1a9c97Smrg    suppress_opt=yes
1108af1a9c97Smrg    suppress_output=
1109af1a9c97Smrg    arg_mode=normal
1110af1a9c97Smrg    libobj=
1111af1a9c97Smrg    later=
1112af1a9c97Smrg    pie_flag=
1113af1a9c97Smrg
1114af1a9c97Smrg    for arg
1115af1a9c97Smrg    do
1116af1a9c97Smrg      case $arg_mode in
1117af1a9c97Smrg      arg  )
1118af1a9c97Smrg	# do not "continue".  Instead, add this to base_compile
1119af1a9c97Smrg	lastarg="$arg"
1120af1a9c97Smrg	arg_mode=normal
1121af1a9c97Smrg	;;
1122af1a9c97Smrg
1123af1a9c97Smrg      target )
1124af1a9c97Smrg	libobj="$arg"
1125af1a9c97Smrg	arg_mode=normal
1126af1a9c97Smrg	continue
1127af1a9c97Smrg	;;
1128af1a9c97Smrg
1129af1a9c97Smrg      normal )
1130af1a9c97Smrg	# Accept any command-line options.
1131af1a9c97Smrg	case $arg in
1132af1a9c97Smrg	-o)
1133af1a9c97Smrg	  test -n "$libobj" && \
1134af1a9c97Smrg	    func_fatal_error "you cannot specify \`-o' more than once"
1135af1a9c97Smrg	  arg_mode=target
1136af1a9c97Smrg	  continue
1137af1a9c97Smrg	  ;;
1138af1a9c97Smrg
1139af1a9c97Smrg	-pie | -fpie | -fPIE)
1140af1a9c97Smrg          pie_flag="$pie_flag $arg"
1141af1a9c97Smrg	  continue
1142af1a9c97Smrg	  ;;
1143af1a9c97Smrg
1144af1a9c97Smrg	-shared | -static | -prefer-pic | -prefer-non-pic)
1145af1a9c97Smrg	  later="$later $arg"
1146af1a9c97Smrg	  continue
1147af1a9c97Smrg	  ;;
1148af1a9c97Smrg
1149af1a9c97Smrg	-no-suppress)
115050806d53Smrg	  suppress_opt=no
115150806d53Smrg	  continue
115250806d53Smrg	  ;;
115350806d53Smrg
115450806d53Smrg	-Xcompiler)
115550806d53Smrg	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
115650806d53Smrg	  continue      #  The current "srcfile" will either be retained or
115750806d53Smrg	  ;;            #  replaced later.  I would guess that would be a bug.
115850806d53Smrg
115950806d53Smrg	-Wc,*)
1160af1a9c97Smrg	  func_stripname '-Wc,' '' "$arg"
1161af1a9c97Smrg	  args=$func_stripname_result
116250806d53Smrg	  lastarg=
116350806d53Smrg	  save_ifs="$IFS"; IFS=','
1164af1a9c97Smrg	  for arg in $args; do
116550806d53Smrg	    IFS="$save_ifs"
1166af1a9c97Smrg	    func_quote_for_eval "$arg"
1167af1a9c97Smrg	    lastarg="$lastarg $func_quote_for_eval_result"
116850806d53Smrg	  done
116950806d53Smrg	  IFS="$save_ifs"
1170af1a9c97Smrg	  func_stripname ' ' '' "$lastarg"
1171af1a9c97Smrg	  lastarg=$func_stripname_result
117250806d53Smrg
117350806d53Smrg	  # Add the arguments to base_compile.
117450806d53Smrg	  base_compile="$base_compile $lastarg"
117550806d53Smrg	  continue
117650806d53Smrg	  ;;
117750806d53Smrg
1178af1a9c97Smrg	*)
117950806d53Smrg	  # Accept the current argument as the source file.
118050806d53Smrg	  # The previous "srcfile" becomes the current argument.
118150806d53Smrg	  #
118250806d53Smrg	  lastarg="$srcfile"
118350806d53Smrg	  srcfile="$arg"
118450806d53Smrg	  ;;
118550806d53Smrg	esac  #  case $arg
118650806d53Smrg	;;
118750806d53Smrg      esac    #  case $arg_mode
118850806d53Smrg
118950806d53Smrg      # Aesthetically quote the previous argument.
1190af1a9c97Smrg      func_quote_for_eval "$lastarg"
1191af1a9c97Smrg      base_compile="$base_compile $func_quote_for_eval_result"
119250806d53Smrg    done # for arg
119350806d53Smrg
119450806d53Smrg    case $arg_mode in
119550806d53Smrg    arg)
1196af1a9c97Smrg      func_fatal_error "you must specify an argument for -Xcompile"
119750806d53Smrg      ;;
119850806d53Smrg    target)
1199af1a9c97Smrg      func_fatal_error "you must specify a target with \`-o'"
120050806d53Smrg      ;;
120150806d53Smrg    *)
120250806d53Smrg      # Get the name of the library object.
1203af1a9c97Smrg      test -z "$libobj" && {
1204af1a9c97Smrg	func_basename "$srcfile"
1205af1a9c97Smrg	libobj="$func_basename_result"
1206af1a9c97Smrg      }
120750806d53Smrg      ;;
120850806d53Smrg    esac
120950806d53Smrg
121050806d53Smrg    # Recognize several different file suffixes.
121150806d53Smrg    # If the user specifies -o file.o, it is replaced with file.lo
121250806d53Smrg    case $libobj in
1213af1a9c97Smrg    *.[cCFSifmso] | \
1214af1a9c97Smrg    *.ada | *.adb | *.ads | *.asm | \
1215af1a9c97Smrg    *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
1216af1a9c97Smrg    *.[fF][09]? | *.for | *.java | *.obj | *.sx)
1217af1a9c97Smrg      func_xform "$libobj"
1218af1a9c97Smrg      libobj=$func_xform_result
1219af1a9c97Smrg      ;;
122050806d53Smrg    esac
122150806d53Smrg
122250806d53Smrg    case $libobj in
1223af1a9c97Smrg    *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
122450806d53Smrg    *)
1225af1a9c97Smrg      func_fatal_error "cannot determine name of library object from \`$libobj'"
122650806d53Smrg      ;;
122750806d53Smrg    esac
122850806d53Smrg
122950806d53Smrg    func_infer_tag $base_compile
123050806d53Smrg
123150806d53Smrg    for arg in $later; do
123250806d53Smrg      case $arg in
1233af1a9c97Smrg      -shared)
1234af1a9c97Smrg	test "$build_libtool_libs" != yes && \
1235af1a9c97Smrg	  func_fatal_configuration "can not build a shared library"
1236af1a9c97Smrg	build_old_libs=no
1237af1a9c97Smrg	continue
1238af1a9c97Smrg	;;
1239af1a9c97Smrg
124050806d53Smrg      -static)
1241af1a9c97Smrg	build_libtool_libs=no
124250806d53Smrg	build_old_libs=yes
124350806d53Smrg	continue
124450806d53Smrg	;;
124550806d53Smrg
124650806d53Smrg      -prefer-pic)
124750806d53Smrg	pic_mode=yes
124850806d53Smrg	continue
124950806d53Smrg	;;
125050806d53Smrg
125150806d53Smrg      -prefer-non-pic)
125250806d53Smrg	pic_mode=no
125350806d53Smrg	continue
125450806d53Smrg	;;
125550806d53Smrg      esac
125650806d53Smrg    done
125750806d53Smrg
1258af1a9c97Smrg    func_quote_for_eval "$libobj"
1259af1a9c97Smrg    test "X$libobj" != "X$func_quote_for_eval_result" \
1260af1a9c97Smrg      && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'	 &()|`$[]' \
1261af1a9c97Smrg      && func_warning "libobj name \`$libobj' may not contain shell special characters."
1262af1a9c97Smrg    func_dirname_and_basename "$obj" "/" ""
1263af1a9c97Smrg    objname="$func_basename_result"
1264af1a9c97Smrg    xdir="$func_dirname_result"
126550806d53Smrg    lobj=${xdir}$objdir/$objname
126650806d53Smrg
1267af1a9c97Smrg    test -z "$base_compile" && \
1268af1a9c97Smrg      func_fatal_help "you must specify a compilation command"
126950806d53Smrg
127050806d53Smrg    # Delete any leftover library objects.
127150806d53Smrg    if test "$build_old_libs" = yes; then
127250806d53Smrg      removelist="$obj $lobj $libobj ${libobj}T"
127350806d53Smrg    else
127450806d53Smrg      removelist="$lobj $libobj ${libobj}T"
127550806d53Smrg    fi
127650806d53Smrg
127750806d53Smrg    # On Cygwin there's no "real" PIC flag so we must build both object types
127850806d53Smrg    case $host_os in
1279af1a9c97Smrg    cygwin* | mingw* | pw32* | os2* | cegcc*)
128050806d53Smrg      pic_mode=default
128150806d53Smrg      ;;
128250806d53Smrg    esac
128350806d53Smrg    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
128450806d53Smrg      # non-PIC code in shared libraries is not supported
128550806d53Smrg      pic_mode=default
128650806d53Smrg    fi
128750806d53Smrg
128850806d53Smrg    # Calculate the filename of the output object if compiler does
128950806d53Smrg    # not support -o with -c
129050806d53Smrg    if test "$compiler_c_o" = no; then
1291af1a9c97Smrg      output_obj=`$ECHO "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext}
129250806d53Smrg      lockfile="$output_obj.lock"
129350806d53Smrg    else
129450806d53Smrg      output_obj=
129550806d53Smrg      need_locks=no
129650806d53Smrg      lockfile=
129750806d53Smrg    fi
129850806d53Smrg
129950806d53Smrg    # Lock this critical section if it is needed
130050806d53Smrg    # We use this script file to make the link, it avoids creating a new file
130150806d53Smrg    if test "$need_locks" = yes; then
1302af1a9c97Smrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
1303af1a9c97Smrg	func_echo "Waiting for $lockfile to be removed"
130450806d53Smrg	sleep 2
130550806d53Smrg      done
130650806d53Smrg    elif test "$need_locks" = warn; then
130750806d53Smrg      if test -f "$lockfile"; then
1308af1a9c97Smrg	$ECHO "\
130950806d53Smrg*** ERROR, $lockfile exists and contains:
131050806d53Smrg`cat $lockfile 2>/dev/null`
131150806d53Smrg
131250806d53SmrgThis indicates that another process is trying to use the same
131350806d53Smrgtemporary object file, and libtool could not work around it because
131450806d53Smrgyour compiler does not support \`-c' and \`-o' together.  If you
131550806d53Smrgrepeat this compilation, it may succeed, by chance, but you had better
131650806d53Smrgavoid parallel builds (make -j) in this platform, or get a better
131750806d53Smrgcompiler."
131850806d53Smrg
1319af1a9c97Smrg	$opt_dry_run || $RM $removelist
132050806d53Smrg	exit $EXIT_FAILURE
132150806d53Smrg      fi
1322af1a9c97Smrg      removelist="$removelist $output_obj"
1323af1a9c97Smrg      $ECHO "$srcfile" > "$lockfile"
132450806d53Smrg    fi
132550806d53Smrg
1326af1a9c97Smrg    $opt_dry_run || $RM $removelist
1327af1a9c97Smrg    removelist="$removelist $lockfile"
1328af1a9c97Smrg    trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
1329af1a9c97Smrg
133050806d53Smrg    if test -n "$fix_srcfile_path"; then
133150806d53Smrg      eval srcfile=\"$fix_srcfile_path\"
133250806d53Smrg    fi
1333af1a9c97Smrg    func_quote_for_eval "$srcfile"
1334af1a9c97Smrg    qsrcfile=$func_quote_for_eval_result
133550806d53Smrg
133650806d53Smrg    # Only build a PIC object if we are building libtool libraries.
133750806d53Smrg    if test "$build_libtool_libs" = yes; then
133850806d53Smrg      # Without this assignment, base_compile gets emptied.
133950806d53Smrg      fbsd_hideous_sh_bug=$base_compile
134050806d53Smrg
134150806d53Smrg      if test "$pic_mode" != no; then
134250806d53Smrg	command="$base_compile $qsrcfile $pic_flag"
134350806d53Smrg      else
134450806d53Smrg	# Don't build PIC code
134550806d53Smrg	command="$base_compile $qsrcfile"
134650806d53Smrg      fi
134750806d53Smrg
1348af1a9c97Smrg      func_mkdir_p "$xdir$objdir"
134950806d53Smrg
135050806d53Smrg      if test -z "$output_obj"; then
135150806d53Smrg	# Place PIC objects in $objdir
135250806d53Smrg	command="$command -o $lobj"
135350806d53Smrg      fi
135450806d53Smrg
1355af1a9c97Smrg      func_show_eval_locale "$command"	\
1356af1a9c97Smrg          'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
135750806d53Smrg
135850806d53Smrg      if test "$need_locks" = warn &&
135950806d53Smrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
1360af1a9c97Smrg	$ECHO "\
136150806d53Smrg*** ERROR, $lockfile contains:
136250806d53Smrg`cat $lockfile 2>/dev/null`
136350806d53Smrg
136450806d53Smrgbut it should contain:
136550806d53Smrg$srcfile
136650806d53Smrg
136750806d53SmrgThis indicates that another process is trying to use the same
136850806d53Smrgtemporary object file, and libtool could not work around it because
136950806d53Smrgyour compiler does not support \`-c' and \`-o' together.  If you
137050806d53Smrgrepeat this compilation, it may succeed, by chance, but you had better
137150806d53Smrgavoid parallel builds (make -j) in this platform, or get a better
137250806d53Smrgcompiler."
137350806d53Smrg
1374af1a9c97Smrg	$opt_dry_run || $RM $removelist
137550806d53Smrg	exit $EXIT_FAILURE
137650806d53Smrg      fi
137750806d53Smrg
137850806d53Smrg      # Just move the object if needed, then go on to compile the next one
137950806d53Smrg      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
1380af1a9c97Smrg	func_show_eval '$MV "$output_obj" "$lobj"' \
1381af1a9c97Smrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
138250806d53Smrg      fi
138350806d53Smrg
138450806d53Smrg      # Allow error messages only from the first compilation.
138550806d53Smrg      if test "$suppress_opt" = yes; then
1386af1a9c97Smrg	suppress_output=' >/dev/null 2>&1'
138750806d53Smrg      fi
138850806d53Smrg    fi
138950806d53Smrg
139050806d53Smrg    # Only build a position-dependent object if we build old libraries.
139150806d53Smrg    if test "$build_old_libs" = yes; then
139250806d53Smrg      if test "$pic_mode" != yes; then
139350806d53Smrg	# Don't build PIC code
1394af1a9c97Smrg	command="$base_compile $qsrcfile$pie_flag"
139550806d53Smrg      else
139650806d53Smrg	command="$base_compile $qsrcfile $pic_flag"
139750806d53Smrg      fi
139850806d53Smrg      if test "$compiler_c_o" = yes; then
139950806d53Smrg	command="$command -o $obj"
140050806d53Smrg      fi
140150806d53Smrg
140250806d53Smrg      # Suppress compiler output if we already did a PIC compilation.
140350806d53Smrg      command="$command$suppress_output"
1404af1a9c97Smrg      func_show_eval_locale "$command" \
1405af1a9c97Smrg        '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
140650806d53Smrg
140750806d53Smrg      if test "$need_locks" = warn &&
140850806d53Smrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
1409af1a9c97Smrg	$ECHO "\
141050806d53Smrg*** ERROR, $lockfile contains:
141150806d53Smrg`cat $lockfile 2>/dev/null`
141250806d53Smrg
141350806d53Smrgbut it should contain:
141450806d53Smrg$srcfile
141550806d53Smrg
141650806d53SmrgThis indicates that another process is trying to use the same
141750806d53Smrgtemporary object file, and libtool could not work around it because
141850806d53Smrgyour compiler does not support \`-c' and \`-o' together.  If you
141950806d53Smrgrepeat this compilation, it may succeed, by chance, but you had better
142050806d53Smrgavoid parallel builds (make -j) in this platform, or get a better
142150806d53Smrgcompiler."
142250806d53Smrg
1423af1a9c97Smrg	$opt_dry_run || $RM $removelist
142450806d53Smrg	exit $EXIT_FAILURE
142550806d53Smrg      fi
142650806d53Smrg
142750806d53Smrg      # Just move the object if needed
142850806d53Smrg      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
1429af1a9c97Smrg	func_show_eval '$MV "$output_obj" "$obj"' \
1430af1a9c97Smrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
143150806d53Smrg      fi
143250806d53Smrg    fi
143350806d53Smrg
1434af1a9c97Smrg    $opt_dry_run || {
1435af1a9c97Smrg      func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
143650806d53Smrg
1437af1a9c97Smrg      # Unlock the critical section if it was locked
1438af1a9c97Smrg      if test "$need_locks" != no; then
1439af1a9c97Smrg	removelist=$lockfile
1440af1a9c97Smrg        $RM "$lockfile"
1441af1a9c97Smrg      fi
1442af1a9c97Smrg    }
144350806d53Smrg
144450806d53Smrg    exit $EXIT_SUCCESS
1445af1a9c97Smrg}
144650806d53Smrg
1447af1a9c97Smrg$opt_help || {
1448af1a9c97Smrgtest "$mode" = compile && func_mode_compile ${1+"$@"}
1449af1a9c97Smrg}
145050806d53Smrg
1451af1a9c97Smrgfunc_mode_help ()
1452af1a9c97Smrg{
1453af1a9c97Smrg    # We need to display help for each of the modes.
1454af1a9c97Smrg    case $mode in
1455af1a9c97Smrg      "")
1456af1a9c97Smrg        # Generic help is extracted from the usage comments
1457af1a9c97Smrg        # at the start of this file.
1458af1a9c97Smrg        func_help
1459af1a9c97Smrg        ;;
146050806d53Smrg
1461af1a9c97Smrg      clean)
1462af1a9c97Smrg        $ECHO \
1463af1a9c97Smrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
146450806d53Smrg
1465af1a9c97SmrgRemove files from the build directory.
146650806d53Smrg
1467af1a9c97SmrgRM is the name of the program to use to delete files associated with each FILE
1468af1a9c97Smrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
1469af1a9c97Smrgto RM.
147050806d53Smrg
1471af1a9c97SmrgIf FILE is a libtool library, object or program, all the files associated
1472af1a9c97Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM."
1473af1a9c97Smrg        ;;
147450806d53Smrg
1475af1a9c97Smrg      compile)
1476af1a9c97Smrg      $ECHO \
1477af1a9c97Smrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
147850806d53Smrg
1479af1a9c97SmrgCompile a source file into a libtool library object.
148050806d53Smrg
1481af1a9c97SmrgThis mode accepts the following additional options:
148250806d53Smrg
1483af1a9c97Smrg  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
1484af1a9c97Smrg  -no-suppress      do not suppress compiler output for multiple passes
1485af1a9c97Smrg  -prefer-pic       try to building PIC objects only
1486af1a9c97Smrg  -prefer-non-pic   try to building non-PIC objects only
1487af1a9c97Smrg  -shared           do not build a \`.o' file suitable for static linking
1488af1a9c97Smrg  -static           only build a \`.o' file suitable for static linking
148950806d53Smrg
1490af1a9c97SmrgCOMPILE-COMMAND is a command to be used in creating a \`standard' object file
1491af1a9c97Smrgfrom the given SOURCEFILE.
149250806d53Smrg
1493af1a9c97SmrgThe output file name is determined by removing the directory component from
1494af1a9c97SmrgSOURCEFILE, then substituting the C source code suffix \`.c' with the
1495af1a9c97Smrglibrary object suffix, \`.lo'."
1496af1a9c97Smrg        ;;
149750806d53Smrg
1498af1a9c97Smrg      execute)
1499af1a9c97Smrg        $ECHO \
1500af1a9c97Smrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
150150806d53Smrg
1502af1a9c97SmrgAutomatically set library path, then run a program.
150350806d53Smrg
1504af1a9c97SmrgThis mode accepts the following additional options:
150550806d53Smrg
1506af1a9c97Smrg  -dlopen FILE      add the directory containing FILE to the library path
150750806d53Smrg
1508af1a9c97SmrgThis mode sets the library path environment variable according to \`-dlopen'
1509af1a9c97Smrgflags.
151050806d53Smrg
1511af1a9c97SmrgIf any of the ARGS are libtool executable wrappers, then they are translated
1512af1a9c97Smrginto their corresponding uninstalled binary, and any of their required library
1513af1a9c97Smrgdirectories are added to the library path.
151450806d53Smrg
1515af1a9c97SmrgThen, COMMAND is executed, with ARGS as arguments."
1516af1a9c97Smrg        ;;
151750806d53Smrg
1518af1a9c97Smrg      finish)
1519af1a9c97Smrg        $ECHO \
1520af1a9c97Smrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
152150806d53Smrg
1522af1a9c97SmrgComplete the installation of libtool libraries.
152350806d53Smrg
1524af1a9c97SmrgEach LIBDIR is a directory that contains libtool libraries.
152550806d53Smrg
1526af1a9c97SmrgThe commands that this mode executes may require superuser privileges.  Use
1527af1a9c97Smrgthe \`--dry-run' option if you just want to see what would be executed."
1528af1a9c97Smrg        ;;
152950806d53Smrg
1530af1a9c97Smrg      install)
1531af1a9c97Smrg        $ECHO \
1532af1a9c97Smrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
153350806d53Smrg
1534af1a9c97SmrgInstall executables or libraries.
153550806d53Smrg
1536af1a9c97SmrgINSTALL-COMMAND is the installation command.  The first component should be
1537af1a9c97Smrgeither the \`install' or \`cp' program.
153850806d53Smrg
1539af1a9c97SmrgThe following components of INSTALL-COMMAND are treated specially:
154050806d53Smrg
1541af1a9c97Smrg  -inst-prefix PREFIX-DIR  Use PREFIX-DIR as a staging area for installation
154250806d53Smrg
1543af1a9c97SmrgThe rest of the components are interpreted as arguments to that command (only
1544af1a9c97SmrgBSD-compatible install options are recognized)."
1545af1a9c97Smrg        ;;
154650806d53Smrg
1547af1a9c97Smrg      link)
1548af1a9c97Smrg        $ECHO \
1549af1a9c97Smrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
155050806d53Smrg
1551af1a9c97SmrgLink object files or libraries together to form another library, or to
1552af1a9c97Smrgcreate an executable program.
155350806d53Smrg
1554af1a9c97SmrgLINK-COMMAND is a command using the C compiler that you would use to create
1555af1a9c97Smrga program from several object files.
155650806d53Smrg
1557af1a9c97SmrgThe following components of LINK-COMMAND are treated specially:
155850806d53Smrg
1559af1a9c97Smrg  -all-static       do not do any dynamic linking at all
1560af1a9c97Smrg  -avoid-version    do not add a version suffix if possible
1561af1a9c97Smrg  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
1562af1a9c97Smrg  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
1563af1a9c97Smrg  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
1564af1a9c97Smrg  -export-symbols SYMFILE
1565af1a9c97Smrg                    try to export only the symbols listed in SYMFILE
1566af1a9c97Smrg  -export-symbols-regex REGEX
1567af1a9c97Smrg                    try to export only the symbols matching REGEX
1568af1a9c97Smrg  -LLIBDIR          search LIBDIR for required installed libraries
1569af1a9c97Smrg  -lNAME            OUTPUT-FILE requires the installed library libNAME
1570af1a9c97Smrg  -module           build a library that can dlopened
1571af1a9c97Smrg  -no-fast-install  disable the fast-install mode
1572af1a9c97Smrg  -no-install       link a not-installable executable
1573af1a9c97Smrg  -no-undefined     declare that a library does not refer to external symbols
1574af1a9c97Smrg  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
1575af1a9c97Smrg  -objectlist FILE  Use a list of object files found in FILE to specify objects
1576af1a9c97Smrg  -precious-files-regex REGEX
1577af1a9c97Smrg                    don't remove output files matching REGEX
1578af1a9c97Smrg  -release RELEASE  specify package release information
1579af1a9c97Smrg  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
1580af1a9c97Smrg  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
1581af1a9c97Smrg  -shared           only do dynamic linking of libtool libraries
1582af1a9c97Smrg  -shrext SUFFIX    override the standard shared library file extension
1583af1a9c97Smrg  -static           do not do any dynamic linking of uninstalled libtool libraries
1584af1a9c97Smrg  -static-libtool-libs
1585af1a9c97Smrg                    do not do any dynamic linking of libtool libraries
1586af1a9c97Smrg  -version-info CURRENT[:REVISION[:AGE]]
1587af1a9c97Smrg                    specify library version info [each variable defaults to 0]
1588af1a9c97Smrg  -weak LIBNAME     declare that the target provides the LIBNAME interface
158950806d53Smrg
1590af1a9c97SmrgAll other options (arguments beginning with \`-') are ignored.
159150806d53Smrg
1592af1a9c97SmrgEvery other argument is treated as a filename.  Files ending in \`.la' are
1593af1a9c97Smrgtreated as uninstalled libtool libraries, other files are standard or library
1594af1a9c97Smrgobject files.
15957965d9acSmrg
1596af1a9c97SmrgIf the OUTPUT-FILE ends in \`.la', then a libtool library is created,
1597af1a9c97Smrgonly library objects (\`.lo' files) may be specified, and \`-rpath' is
1598af1a9c97Smrgrequired, except when creating a convenience library.
159950806d53Smrg
1600af1a9c97SmrgIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
1601af1a9c97Smrgusing \`ar' and \`ranlib', or on Windows using \`lib'.
160250806d53Smrg
1603af1a9c97SmrgIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
1604af1a9c97Smrgis created, otherwise an executable program is created."
160550806d53Smrg        ;;
160650806d53Smrg
1607af1a9c97Smrg      uninstall)
1608af1a9c97Smrg        $ECHO \
1609af1a9c97Smrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
161050806d53Smrg
1611af1a9c97SmrgRemove libraries from an installation directory.
161250806d53Smrg
1613af1a9c97SmrgRM is the name of the program to use to delete files associated with each FILE
1614af1a9c97Smrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
1615af1a9c97Smrgto RM.
161650806d53Smrg
1617af1a9c97SmrgIf FILE is a libtool library, all the files associated with it are deleted.
1618af1a9c97SmrgOtherwise, only FILE itself is deleted using RM."
1619af1a9c97Smrg        ;;
162050806d53Smrg
1621af1a9c97Smrg      *)
1622af1a9c97Smrg        func_fatal_help "invalid operation mode \`$mode'"
1623af1a9c97Smrg        ;;
1624af1a9c97Smrg    esac
162550806d53Smrg
1626af1a9c97Smrg    $ECHO
1627af1a9c97Smrg    $ECHO "Try \`$progname --help' for more information about other modes."
162850806d53Smrg
1629af1a9c97Smrg    exit $?
1630af1a9c97Smrg}
163150806d53Smrg
1632af1a9c97Smrg  # Now that we've collected a possible --mode arg, show help if necessary
1633af1a9c97Smrg  $opt_help && func_mode_help
163450806d53Smrg
163550806d53Smrg
1636af1a9c97Smrg# func_mode_execute arg...
1637af1a9c97Smrgfunc_mode_execute ()
1638af1a9c97Smrg{
1639af1a9c97Smrg    $opt_debug
1640af1a9c97Smrg    # The first argument is the command name.
1641af1a9c97Smrg    cmd="$nonopt"
1642af1a9c97Smrg    test -z "$cmd" && \
1643af1a9c97Smrg      func_fatal_help "you must specify a COMMAND"
164450806d53Smrg
1645af1a9c97Smrg    # Handle -dlopen flags immediately.
1646af1a9c97Smrg    for file in $execute_dlfiles; do
1647af1a9c97Smrg      test -f "$file" \
1648af1a9c97Smrg	|| func_fatal_help "\`$file' is not a file"
164950806d53Smrg
1650af1a9c97Smrg      dir=
1651af1a9c97Smrg      case $file in
1652af1a9c97Smrg      *.la)
1653af1a9c97Smrg	# Check to see that this really is a libtool archive.
1654af1a9c97Smrg	func_lalib_unsafe_p "$file" \
1655af1a9c97Smrg	  || func_fatal_help "\`$lib' is not a valid libtool archive"
165650806d53Smrg
1657af1a9c97Smrg	# Read the libtool library.
1658af1a9c97Smrg	dlname=
1659af1a9c97Smrg	library_names=
1660af1a9c97Smrg	func_source "$file"
166150806d53Smrg
1662af1a9c97Smrg	# Skip this library if it cannot be dlopened.
1663af1a9c97Smrg	if test -z "$dlname"; then
1664af1a9c97Smrg	  # Warn if it was a shared library.
1665af1a9c97Smrg	  test -n "$library_names" && \
1666af1a9c97Smrg	    func_warning "\`$file' was not linked with \`-export-dynamic'"
1667af1a9c97Smrg	  continue
1668af1a9c97Smrg	fi
166950806d53Smrg
1670af1a9c97Smrg	func_dirname "$file" "" "."
1671af1a9c97Smrg	dir="$func_dirname_result"
167250806d53Smrg
1673af1a9c97Smrg	if test -f "$dir/$objdir/$dlname"; then
1674af1a9c97Smrg	  dir="$dir/$objdir"
1675af1a9c97Smrg	else
1676af1a9c97Smrg	  if test ! -f "$dir/$dlname"; then
1677af1a9c97Smrg	    func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'"
1678af1a9c97Smrg	  fi
1679af1a9c97Smrg	fi
168050806d53Smrg	;;
168150806d53Smrg
1682af1a9c97Smrg      *.lo)
1683af1a9c97Smrg	# Just add the directory containing the .lo file.
1684af1a9c97Smrg	func_dirname "$file" "" "."
1685af1a9c97Smrg	dir="$func_dirname_result"
168650806d53Smrg	;;
168750806d53Smrg
1688af1a9c97Smrg      *)
1689af1a9c97Smrg	func_warning "\`-dlopen' is ignored for non-libtool libraries and objects"
169050806d53Smrg	continue
169150806d53Smrg	;;
1692af1a9c97Smrg      esac
169350806d53Smrg
1694af1a9c97Smrg      # Get the absolute pathname.
1695af1a9c97Smrg      absdir=`cd "$dir" && pwd`
1696af1a9c97Smrg      test -n "$absdir" && dir="$absdir"
169750806d53Smrg
1698af1a9c97Smrg      # Now add the directory to shlibpath_var.
1699af1a9c97Smrg      if eval "test -z \"\$$shlibpath_var\""; then
1700af1a9c97Smrg	eval "$shlibpath_var=\"\$dir\""
1701af1a9c97Smrg      else
1702af1a9c97Smrg	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
1703af1a9c97Smrg      fi
1704af1a9c97Smrg    done
170550806d53Smrg
1706af1a9c97Smrg    # This variable tells wrapper scripts just to set shlibpath_var
1707af1a9c97Smrg    # rather than running their programs.
1708af1a9c97Smrg    libtool_execute_magic="$magic"
170950806d53Smrg
1710af1a9c97Smrg    # Check if any of the arguments is a wrapper script.
1711af1a9c97Smrg    args=
1712af1a9c97Smrg    for file
1713af1a9c97Smrg    do
1714af1a9c97Smrg      case $file in
1715af1a9c97Smrg      -*) ;;
1716af1a9c97Smrg      *)
1717af1a9c97Smrg	# Do a test to see if this is really a libtool program.
1718af1a9c97Smrg	if func_ltwrapper_script_p "$file"; then
1719af1a9c97Smrg	  func_source "$file"
1720af1a9c97Smrg	  # Transform arg to wrapped name.
1721af1a9c97Smrg	  file="$progdir/$program"
1722af1a9c97Smrg	elif func_ltwrapper_executable_p "$file"; then
1723af1a9c97Smrg	  func_ltwrapper_scriptname "$file"
1724af1a9c97Smrg	  func_source "$func_ltwrapper_scriptname_result"
1725af1a9c97Smrg	  # Transform arg to wrapped name.
1726af1a9c97Smrg	  file="$progdir/$program"
1727af1a9c97Smrg	fi
1728af1a9c97Smrg	;;
1729af1a9c97Smrg      esac
1730af1a9c97Smrg      # Quote arguments (to preserve shell metacharacters).
1731af1a9c97Smrg      func_quote_for_eval "$file"
1732af1a9c97Smrg      args="$args $func_quote_for_eval_result"
1733af1a9c97Smrg    done
173450806d53Smrg
1735af1a9c97Smrg    if test "X$opt_dry_run" = Xfalse; then
1736af1a9c97Smrg      if test -n "$shlibpath_var"; then
1737af1a9c97Smrg	# Export the shlibpath_var.
1738af1a9c97Smrg	eval "export $shlibpath_var"
1739af1a9c97Smrg      fi
174050806d53Smrg
1741af1a9c97Smrg      # Restore saved environment variables
1742af1a9c97Smrg      for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
1743af1a9c97Smrg      do
1744af1a9c97Smrg	eval "if test \"\${save_$lt_var+set}\" = set; then
1745af1a9c97Smrg                $lt_var=\$save_$lt_var; export $lt_var
174650806d53Smrg	      else
1747af1a9c97Smrg		$lt_unset $lt_var
1748af1a9c97Smrg	      fi"
1749af1a9c97Smrg      done
175050806d53Smrg
1751af1a9c97Smrg      # Now prepare to actually exec the command.
1752af1a9c97Smrg      exec_cmd="\$cmd$args"
1753af1a9c97Smrg    else
1754af1a9c97Smrg      # Display what would be done.
1755af1a9c97Smrg      if test -n "$shlibpath_var"; then
1756af1a9c97Smrg	eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
1757af1a9c97Smrg	$ECHO "export $shlibpath_var"
1758af1a9c97Smrg      fi
1759af1a9c97Smrg      $ECHO "$cmd$args"
1760af1a9c97Smrg      exit $EXIT_SUCCESS
1761af1a9c97Smrg    fi
1762af1a9c97Smrg}
176350806d53Smrg
1764af1a9c97Smrgtest "$mode" = execute && func_mode_execute ${1+"$@"}
176550806d53Smrg
176650806d53Smrg
1767af1a9c97Smrg# func_mode_finish arg...
1768af1a9c97Smrgfunc_mode_finish ()
1769af1a9c97Smrg{
1770af1a9c97Smrg    $opt_debug
1771af1a9c97Smrg    libdirs="$nonopt"
1772af1a9c97Smrg    admincmds=
177350806d53Smrg
1774af1a9c97Smrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
1775af1a9c97Smrg      for dir
1776af1a9c97Smrg      do
1777af1a9c97Smrg	libdirs="$libdirs $dir"
1778af1a9c97Smrg      done
177950806d53Smrg
1780af1a9c97Smrg      for libdir in $libdirs; do
1781af1a9c97Smrg	if test -n "$finish_cmds"; then
1782af1a9c97Smrg	  # Do each command in the finish commands.
1783af1a9c97Smrg	  func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
1784af1a9c97Smrg'"$cmd"'"'
178550806d53Smrg	fi
1786af1a9c97Smrg	if test -n "$finish_eval"; then
1787af1a9c97Smrg	  # Do the single finish_eval.
1788af1a9c97Smrg	  eval cmds=\"$finish_eval\"
1789af1a9c97Smrg	  $opt_dry_run || eval "$cmds" || admincmds="$admincmds
1790af1a9c97Smrg       $cmds"
1791af1a9c97Smrg	fi
1792af1a9c97Smrg      done
1793af1a9c97Smrg    fi
179450806d53Smrg
1795af1a9c97Smrg    # Exit here if they wanted silent mode.
1796af1a9c97Smrg    $opt_silent && exit $EXIT_SUCCESS
179750806d53Smrg
1798af1a9c97Smrg    $ECHO "X----------------------------------------------------------------------" | $Xsed
1799af1a9c97Smrg    $ECHO "Libraries have been installed in:"
1800af1a9c97Smrg    for libdir in $libdirs; do
1801af1a9c97Smrg      $ECHO "   $libdir"
1802af1a9c97Smrg    done
1803af1a9c97Smrg    $ECHO
1804af1a9c97Smrg    $ECHO "If you ever happen to want to link against installed libraries"
1805af1a9c97Smrg    $ECHO "in a given directory, LIBDIR, you must either use libtool, and"
1806af1a9c97Smrg    $ECHO "specify the full pathname of the library, or use the \`-LLIBDIR'"
1807af1a9c97Smrg    $ECHO "flag during linking and do at least one of the following:"
1808af1a9c97Smrg    if test -n "$shlibpath_var"; then
1809af1a9c97Smrg      $ECHO "   - add LIBDIR to the \`$shlibpath_var' environment variable"
1810af1a9c97Smrg      $ECHO "     during execution"
1811af1a9c97Smrg    fi
1812af1a9c97Smrg    if test -n "$runpath_var"; then
1813af1a9c97Smrg      $ECHO "   - add LIBDIR to the \`$runpath_var' environment variable"
1814af1a9c97Smrg      $ECHO "     during linking"
1815af1a9c97Smrg    fi
1816af1a9c97Smrg    if test -n "$hardcode_libdir_flag_spec"; then
1817af1a9c97Smrg      libdir=LIBDIR
1818af1a9c97Smrg      eval flag=\"$hardcode_libdir_flag_spec\"
1819af1a9c97Smrg
1820af1a9c97Smrg      $ECHO "   - use the \`$flag' linker flag"
1821af1a9c97Smrg    fi
1822af1a9c97Smrg    if test -n "$admincmds"; then
1823af1a9c97Smrg      $ECHO "   - have your system administrator run these commands:$admincmds"
1824af1a9c97Smrg    fi
1825af1a9c97Smrg    if test -f /etc/ld.so.conf; then
1826af1a9c97Smrg      $ECHO "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
1827af1a9c97Smrg    fi
1828af1a9c97Smrg    $ECHO
1829af1a9c97Smrg
1830af1a9c97Smrg    $ECHO "See any operating system documentation about shared libraries for"
1831af1a9c97Smrg    case $host in
1832af1a9c97Smrg      solaris2.[6789]|solaris2.1[0-9])
1833af1a9c97Smrg        $ECHO "more information, such as the ld(1), crle(1) and ld.so(8) manual"
1834af1a9c97Smrg	$ECHO "pages."
1835af1a9c97Smrg	;;
1836af1a9c97Smrg      *)
1837af1a9c97Smrg        $ECHO "more information, such as the ld(1) and ld.so(8) manual pages."
1838af1a9c97Smrg        ;;
1839af1a9c97Smrg    esac
1840af1a9c97Smrg    $ECHO "X----------------------------------------------------------------------" | $Xsed
1841af1a9c97Smrg    exit $EXIT_SUCCESS
1842af1a9c97Smrg}
1843af1a9c97Smrg
1844af1a9c97Smrgtest "$mode" = finish && func_mode_finish ${1+"$@"}
1845af1a9c97Smrg
1846af1a9c97Smrg
1847af1a9c97Smrg# func_mode_install arg...
1848af1a9c97Smrgfunc_mode_install ()
1849af1a9c97Smrg{
1850af1a9c97Smrg    $opt_debug
1851af1a9c97Smrg    # There may be an optional sh(1) argument at the beginning of
1852af1a9c97Smrg    # install_prog (especially on Windows NT).
1853af1a9c97Smrg    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
1854af1a9c97Smrg       # Allow the use of GNU shtool's install command.
1855af1a9c97Smrg       $ECHO "X$nonopt" | $GREP shtool >/dev/null; then
1856af1a9c97Smrg      # Aesthetically quote it.
1857af1a9c97Smrg      func_quote_for_eval "$nonopt"
1858af1a9c97Smrg      install_prog="$func_quote_for_eval_result "
1859af1a9c97Smrg      arg=$1
1860af1a9c97Smrg      shift
1861af1a9c97Smrg    else
1862af1a9c97Smrg      install_prog=
1863af1a9c97Smrg      arg=$nonopt
1864af1a9c97Smrg    fi
1865af1a9c97Smrg
1866af1a9c97Smrg    # The real first argument should be the name of the installation program.
1867af1a9c97Smrg    # Aesthetically quote it.
1868af1a9c97Smrg    func_quote_for_eval "$arg"
1869af1a9c97Smrg    install_prog="$install_prog$func_quote_for_eval_result"
1870af1a9c97Smrg
1871af1a9c97Smrg    # We need to accept at least all the BSD install flags.
1872af1a9c97Smrg    dest=
1873af1a9c97Smrg    files=
1874af1a9c97Smrg    opts=
1875af1a9c97Smrg    prev=
1876af1a9c97Smrg    install_type=
1877af1a9c97Smrg    isdir=no
1878af1a9c97Smrg    stripme=
1879af1a9c97Smrg    for arg
1880af1a9c97Smrg    do
1881af1a9c97Smrg      if test -n "$dest"; then
1882af1a9c97Smrg	files="$files $dest"
1883af1a9c97Smrg	dest=$arg
1884af1a9c97Smrg	continue
1885af1a9c97Smrg      fi
1886af1a9c97Smrg
1887af1a9c97Smrg      case $arg in
1888af1a9c97Smrg      -d) isdir=yes ;;
1889af1a9c97Smrg      -f)
1890af1a9c97Smrg	case " $install_prog " in
1891af1a9c97Smrg	*[\\\ /]cp\ *) ;;
1892af1a9c97Smrg	*) prev=$arg ;;
1893af1a9c97Smrg	esac
1894af1a9c97Smrg	;;
1895af1a9c97Smrg      -g | -m | -o)
1896af1a9c97Smrg	prev=$arg
1897af1a9c97Smrg	;;
1898af1a9c97Smrg      -s)
1899af1a9c97Smrg	stripme=" -s"
1900af1a9c97Smrg	continue
1901af1a9c97Smrg	;;
1902af1a9c97Smrg      -*)
1903af1a9c97Smrg	;;
1904af1a9c97Smrg      *)
1905af1a9c97Smrg	# If the previous option needed an argument, then skip it.
1906af1a9c97Smrg	if test -n "$prev"; then
190750806d53Smrg	  prev=
190850806d53Smrg	else
1909af1a9c97Smrg	  dest=$arg
1910af1a9c97Smrg	  continue
191150806d53Smrg	fi
191250806d53Smrg	;;
1913af1a9c97Smrg      esac
191450806d53Smrg
1915af1a9c97Smrg      # Aesthetically quote the argument.
1916af1a9c97Smrg      func_quote_for_eval "$arg"
1917af1a9c97Smrg      install_prog="$install_prog $func_quote_for_eval_result"
1918af1a9c97Smrg    done
191950806d53Smrg
1920af1a9c97Smrg    test -z "$install_prog" && \
1921af1a9c97Smrg      func_fatal_help "you must specify an install program"
192250806d53Smrg
1923af1a9c97Smrg    test -n "$prev" && \
1924af1a9c97Smrg      func_fatal_help "the \`$prev' option requires an argument"
192550806d53Smrg
1926af1a9c97Smrg    if test -z "$files"; then
1927af1a9c97Smrg      if test -z "$dest"; then
1928af1a9c97Smrg	func_fatal_help "no file or destination specified"
1929af1a9c97Smrg      else
1930af1a9c97Smrg	func_fatal_help "you must specify a destination"
1931af1a9c97Smrg      fi
193250806d53Smrg    fi
193350806d53Smrg
1934af1a9c97Smrg    # Strip any trailing slash from the destination.
1935af1a9c97Smrg    func_stripname '' '/' "$dest"
1936af1a9c97Smrg    dest=$func_stripname_result
193750806d53Smrg
1938af1a9c97Smrg    # Check to see that the destination is a directory.
1939af1a9c97Smrg    test -d "$dest" && isdir=yes
1940af1a9c97Smrg    if test "$isdir" = yes; then
1941af1a9c97Smrg      destdir="$dest"
1942af1a9c97Smrg      destname=
194350806d53Smrg    else
1944af1a9c97Smrg      func_dirname_and_basename "$dest" "" "."
1945af1a9c97Smrg      destdir="$func_dirname_result"
1946af1a9c97Smrg      destname="$func_basename_result"
194750806d53Smrg
1948af1a9c97Smrg      # Not a directory, so check to see that there is only one file specified.
1949af1a9c97Smrg      set dummy $files; shift
1950af1a9c97Smrg      test "$#" -gt 1 && \
1951af1a9c97Smrg	func_fatal_help "\`$dest' is not a directory"
195250806d53Smrg    fi
1953af1a9c97Smrg    case $destdir in
1954af1a9c97Smrg    [\\/]* | [A-Za-z]:[\\/]*) ;;
195550806d53Smrg    *)
1956af1a9c97Smrg      for file in $files; do
1957af1a9c97Smrg	case $file in
1958af1a9c97Smrg	*.lo) ;;
1959af1a9c97Smrg	*)
1960af1a9c97Smrg	  func_fatal_help "\`$destdir' must be an absolute directory name"
1961af1a9c97Smrg	  ;;
1962af1a9c97Smrg	esac
1963af1a9c97Smrg      done
196450806d53Smrg      ;;
196550806d53Smrg    esac
196650806d53Smrg
1967af1a9c97Smrg    # This variable tells wrapper scripts just to set variables rather
1968af1a9c97Smrg    # than running their programs.
1969af1a9c97Smrg    libtool_install_magic="$magic"
197050806d53Smrg
1971af1a9c97Smrg    staticlibs=
1972af1a9c97Smrg    future_libdirs=
1973af1a9c97Smrg    current_libdirs=
1974af1a9c97Smrg    for file in $files; do
197550806d53Smrg
1976af1a9c97Smrg      # Do each installation.
1977af1a9c97Smrg      case $file in
1978af1a9c97Smrg      *.$libext)
1979af1a9c97Smrg	# Do the static libraries later.
1980af1a9c97Smrg	staticlibs="$staticlibs $file"
1981af1a9c97Smrg	;;
1982af1a9c97Smrg
1983af1a9c97Smrg      *.la)
1984af1a9c97Smrg	# Check to see that this really is a libtool archive.
1985af1a9c97Smrg	func_lalib_unsafe_p "$file" \
1986af1a9c97Smrg	  || func_fatal_help "\`$file' is not a valid libtool archive"
1987af1a9c97Smrg
1988af1a9c97Smrg	library_names=
1989af1a9c97Smrg	old_library=
1990af1a9c97Smrg	relink_command=
1991af1a9c97Smrg	func_source "$file"
1992af1a9c97Smrg
1993af1a9c97Smrg	# Add the libdir to current_libdirs if it is the destination.
1994af1a9c97Smrg	if test "X$destdir" = "X$libdir"; then
1995af1a9c97Smrg	  case "$current_libdirs " in
1996af1a9c97Smrg	  *" $libdir "*) ;;
1997af1a9c97Smrg	  *) current_libdirs="$current_libdirs $libdir" ;;
199850806d53Smrg	  esac
1999af1a9c97Smrg	else
2000af1a9c97Smrg	  # Note the libdir as a future libdir.
2001af1a9c97Smrg	  case "$future_libdirs " in
2002af1a9c97Smrg	  *" $libdir "*) ;;
2003af1a9c97Smrg	  *) future_libdirs="$future_libdirs $libdir" ;;
2004af1a9c97Smrg	  esac
2005af1a9c97Smrg	fi
200650806d53Smrg
2007af1a9c97Smrg	func_dirname "$file" "/" ""
2008af1a9c97Smrg	dir="$func_dirname_result"
2009af1a9c97Smrg	dir="$dir$objdir"
2010af1a9c97Smrg
2011af1a9c97Smrg	if test -n "$relink_command"; then
2012af1a9c97Smrg	  # Determine the prefix the user has applied to our future dir.
2013af1a9c97Smrg	  inst_prefix_dir=`$ECHO "X$destdir" | $Xsed -e "s%$libdir\$%%"`
2014af1a9c97Smrg
2015af1a9c97Smrg	  # Don't allow the user to place us outside of our expected
2016af1a9c97Smrg	  # location b/c this prevents finding dependent libraries that
2017af1a9c97Smrg	  # are installed to the same prefix.
2018af1a9c97Smrg	  # At present, this check doesn't affect windows .dll's that
2019af1a9c97Smrg	  # are installed into $libdir/../bin (currently, that works fine)
2020af1a9c97Smrg	  # but it's something to keep an eye on.
2021af1a9c97Smrg	  test "$inst_prefix_dir" = "$destdir" && \
2022af1a9c97Smrg	    func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
2023af1a9c97Smrg
2024af1a9c97Smrg	  if test -n "$inst_prefix_dir"; then
2025af1a9c97Smrg	    # Stick the inst_prefix_dir data into the link command.
2026af1a9c97Smrg	    relink_command=`$ECHO "X$relink_command" | $Xsed -e "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
2027af1a9c97Smrg	  else
2028af1a9c97Smrg	    relink_command=`$ECHO "X$relink_command" | $Xsed -e "s%@inst_prefix_dir@%%"`
2029af1a9c97Smrg	  fi
2030af1a9c97Smrg
2031af1a9c97Smrg	  func_warning "relinking \`$file'"
2032af1a9c97Smrg	  func_show_eval "$relink_command" \
2033af1a9c97Smrg	    'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
2034af1a9c97Smrg	fi
2035af1a9c97Smrg
2036af1a9c97Smrg	# See the names of the shared library.
2037af1a9c97Smrg	set dummy $library_names; shift
2038af1a9c97Smrg	if test -n "$1"; then
2039af1a9c97Smrg	  realname="$1"
2040af1a9c97Smrg	  shift
2041af1a9c97Smrg
2042af1a9c97Smrg	  srcname="$realname"
2043af1a9c97Smrg	  test -n "$relink_command" && srcname="$realname"T
2044af1a9c97Smrg
2045af1a9c97Smrg	  # Install the shared library and build the symlinks.
2046af1a9c97Smrg	  func_show_eval "$install_prog $dir/$srcname $destdir/$realname" \
2047af1a9c97Smrg	      'exit $?'
2048af1a9c97Smrg	  tstripme="$stripme"
2049af1a9c97Smrg	  case $host_os in
2050af1a9c97Smrg	  cygwin* | mingw* | pw32* | cegcc*)
2051af1a9c97Smrg	    case $realname in
2052af1a9c97Smrg	    *.dll.a)
2053af1a9c97Smrg	      tstripme=""
2054af1a9c97Smrg	      ;;
2055af1a9c97Smrg	    esac
205650806d53Smrg	    ;;
205750806d53Smrg	  esac
2058af1a9c97Smrg	  if test -n "$tstripme" && test -n "$striplib"; then
2059af1a9c97Smrg	    func_show_eval "$striplib $destdir/$realname" 'exit $?'
206050806d53Smrg	  fi
2061af1a9c97Smrg
2062af1a9c97Smrg	  if test "$#" -gt 0; then
2063af1a9c97Smrg	    # Delete the old symlinks, and create new ones.
2064af1a9c97Smrg	    # Try `ln -sf' first, because the `ln' binary might depend on
2065af1a9c97Smrg	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
2066af1a9c97Smrg	    # so we also need to try rm && ln -s.
2067af1a9c97Smrg	    for linkname
2068af1a9c97Smrg	    do
2069af1a9c97Smrg	      test "$linkname" != "$realname" \
2070af1a9c97Smrg		&& func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
207150806d53Smrg	    done
207250806d53Smrg	  fi
207350806d53Smrg
2074af1a9c97Smrg	  # Do each command in the postinstall commands.
2075af1a9c97Smrg	  lib="$destdir/$realname"
2076af1a9c97Smrg	  func_execute_cmds "$postinstall_cmds" 'exit $?'
207750806d53Smrg	fi
207850806d53Smrg
2079af1a9c97Smrg	# Install the pseudo-library for information purposes.
2080af1a9c97Smrg	func_basename "$file"
2081af1a9c97Smrg	name="$func_basename_result"
2082af1a9c97Smrg	instname="$dir/$name"i
2083af1a9c97Smrg	func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
208450806d53Smrg
2085af1a9c97Smrg	# Maybe install the static library, too.
2086af1a9c97Smrg	test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library"
2087af1a9c97Smrg	;;
208850806d53Smrg
2089af1a9c97Smrg      *.lo)
2090af1a9c97Smrg	# Install (i.e. copy) a libtool object.
209150806d53Smrg
2092af1a9c97Smrg	# Figure out destination file name, if it wasn't already specified.
2093af1a9c97Smrg	if test -n "$destname"; then
2094af1a9c97Smrg	  destfile="$destdir/$destname"
2095af1a9c97Smrg	else
2096af1a9c97Smrg	  func_basename "$file"
2097af1a9c97Smrg	  destfile="$func_basename_result"
2098af1a9c97Smrg	  destfile="$destdir/$destfile"
209950806d53Smrg	fi
210050806d53Smrg
2101af1a9c97Smrg	# Deduce the name of the destination old-style object file.
2102af1a9c97Smrg	case $destfile in
2103af1a9c97Smrg	*.lo)
2104af1a9c97Smrg	  func_lo2o "$destfile"
2105af1a9c97Smrg	  staticdest=$func_lo2o_result
2106af1a9c97Smrg	  ;;
2107af1a9c97Smrg	*.$objext)
2108af1a9c97Smrg	  staticdest="$destfile"
2109af1a9c97Smrg	  destfile=
2110af1a9c97Smrg	  ;;
2111af1a9c97Smrg	*)
2112af1a9c97Smrg	  func_fatal_help "cannot copy a libtool object to \`$destfile'"
2113af1a9c97Smrg	  ;;
2114af1a9c97Smrg	esac
211550806d53Smrg
2116af1a9c97Smrg	# Install the libtool object if requested.
2117af1a9c97Smrg	test -n "$destfile" && \
2118af1a9c97Smrg	  func_show_eval "$install_prog $file $destfile" 'exit $?'
211950806d53Smrg
2120af1a9c97Smrg	# Install the old object if enabled.
2121af1a9c97Smrg	if test "$build_old_libs" = yes; then
2122af1a9c97Smrg	  # Deduce the name of the old-style object file.
2123af1a9c97Smrg	  func_lo2o "$file"
2124af1a9c97Smrg	  staticobj=$func_lo2o_result
2125af1a9c97Smrg	  func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
212650806d53Smrg	fi
2127af1a9c97Smrg	exit $EXIT_SUCCESS
2128af1a9c97Smrg	;;
212950806d53Smrg
2130af1a9c97Smrg      *)
2131af1a9c97Smrg	# Figure out destination file name, if it wasn't already specified.
2132af1a9c97Smrg	if test -n "$destname"; then
2133af1a9c97Smrg	  destfile="$destdir/$destname"
2134af1a9c97Smrg	else
2135af1a9c97Smrg	  func_basename "$file"
2136af1a9c97Smrg	  destfile="$func_basename_result"
2137af1a9c97Smrg	  destfile="$destdir/$destfile"
2138af1a9c97Smrg	fi
213950806d53Smrg
2140af1a9c97Smrg	# If the file is missing, and there is a .exe on the end, strip it
2141af1a9c97Smrg	# because it is most likely a libtool script we actually want to
2142af1a9c97Smrg	# install
2143af1a9c97Smrg	stripped_ext=""
2144af1a9c97Smrg	case $file in
2145af1a9c97Smrg	  *.exe)
2146af1a9c97Smrg	    if test ! -f "$file"; then
2147af1a9c97Smrg	      func_stripname '' '.exe' "$file"
2148af1a9c97Smrg	      file=$func_stripname_result
2149af1a9c97Smrg	      stripped_ext=".exe"
2150af1a9c97Smrg	    fi
2151af1a9c97Smrg	    ;;
2152af1a9c97Smrg	esac
2153af1a9c97Smrg
2154af1a9c97Smrg	# Do a test to see if this is really a libtool program.
2155af1a9c97Smrg	case $host in
2156af1a9c97Smrg	*cygwin* | *mingw*)
2157af1a9c97Smrg	    if func_ltwrapper_executable_p "$file"; then
2158af1a9c97Smrg	      func_ltwrapper_scriptname "$file"
2159af1a9c97Smrg	      wrapper=$func_ltwrapper_scriptname_result
2160af1a9c97Smrg	    else
2161af1a9c97Smrg	      func_stripname '' '.exe' "$file"
2162af1a9c97Smrg	      wrapper=$func_stripname_result
2163af1a9c97Smrg	    fi
2164af1a9c97Smrg	    ;;
216550806d53Smrg	*)
2166af1a9c97Smrg	    wrapper=$file
2167af1a9c97Smrg	    ;;
2168af1a9c97Smrg	esac
2169af1a9c97Smrg	if func_ltwrapper_script_p "$wrapper"; then
2170af1a9c97Smrg	  notinst_deplibs=
2171af1a9c97Smrg	  relink_command=
2172af1a9c97Smrg
2173af1a9c97Smrg	  func_source "$wrapper"
2174af1a9c97Smrg
2175af1a9c97Smrg	  # Check the variables that should have been set.
2176af1a9c97Smrg	  test -z "$generated_by_libtool_version" && \
2177af1a9c97Smrg	    func_fatal_error "invalid libtool wrapper script \`$wrapper'"
2178af1a9c97Smrg
2179af1a9c97Smrg	  finalize=yes
2180af1a9c97Smrg	  for lib in $notinst_deplibs; do
2181af1a9c97Smrg	    # Check to see that each library is installed.
2182af1a9c97Smrg	    libdir=
2183af1a9c97Smrg	    if test -f "$lib"; then
2184af1a9c97Smrg	      func_source "$lib"
2185af1a9c97Smrg	    fi
2186af1a9c97Smrg	    libfile="$libdir/"`$ECHO "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test
2187af1a9c97Smrg	    if test -n "$libdir" && test ! -f "$libfile"; then
2188af1a9c97Smrg	      func_warning "\`$lib' has not been installed in \`$libdir'"
2189af1a9c97Smrg	      finalize=no
2190af1a9c97Smrg	    fi
2191af1a9c97Smrg	  done
2192af1a9c97Smrg
2193af1a9c97Smrg	  relink_command=
2194af1a9c97Smrg	  func_source "$wrapper"
2195af1a9c97Smrg
2196af1a9c97Smrg	  outputname=
2197af1a9c97Smrg	  if test "$fast_install" = no && test -n "$relink_command"; then
2198af1a9c97Smrg	    $opt_dry_run || {
2199af1a9c97Smrg	      if test "$finalize" = yes; then
2200af1a9c97Smrg	        tmpdir=`func_mktempdir`
2201af1a9c97Smrg		func_basename "$file$stripped_ext"
2202af1a9c97Smrg		file="$func_basename_result"
2203af1a9c97Smrg	        outputname="$tmpdir/$file"
2204af1a9c97Smrg	        # Replace the output file specification.
2205af1a9c97Smrg	        relink_command=`$ECHO "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'`
2206af1a9c97Smrg
2207af1a9c97Smrg	        $opt_silent || {
2208af1a9c97Smrg	          func_quote_for_expand "$relink_command"
2209af1a9c97Smrg		  eval "func_echo $func_quote_for_expand_result"
2210af1a9c97Smrg	        }
2211af1a9c97Smrg	        if eval "$relink_command"; then :
2212af1a9c97Smrg	          else
2213af1a9c97Smrg		  func_error "error: relink \`$file' with the above command before installing it"
2214af1a9c97Smrg		  $opt_dry_run || ${RM}r "$tmpdir"
2215af1a9c97Smrg		  continue
2216af1a9c97Smrg	        fi
2217af1a9c97Smrg	        file="$outputname"
2218af1a9c97Smrg	      else
2219af1a9c97Smrg	        func_warning "cannot relink \`$file'"
2220af1a9c97Smrg	      fi
2221af1a9c97Smrg	    }
2222af1a9c97Smrg	  else
2223af1a9c97Smrg	    # Install the binary that we compiled earlier.
2224af1a9c97Smrg	    file=`$ECHO "X$file$stripped_ext" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"`
222550806d53Smrg	  fi
2226af1a9c97Smrg	fi
2227af1a9c97Smrg
2228af1a9c97Smrg	# remove .exe since cygwin /usr/bin/install will append another
2229af1a9c97Smrg	# one anyway
2230af1a9c97Smrg	case $install_prog,$host in
2231af1a9c97Smrg	*/usr/bin/install*,*cygwin*)
2232af1a9c97Smrg	  case $file:$destfile in
2233af1a9c97Smrg	  *.exe:*.exe)
2234af1a9c97Smrg	    # this is ok
2235af1a9c97Smrg	    ;;
2236af1a9c97Smrg	  *.exe:*)
2237af1a9c97Smrg	    destfile=$destfile.exe
2238af1a9c97Smrg	    ;;
2239af1a9c97Smrg	  *:*.exe)
2240af1a9c97Smrg	    func_stripname '' '.exe' "$destfile"
2241af1a9c97Smrg	    destfile=$func_stripname_result
2242af1a9c97Smrg	    ;;
2243af1a9c97Smrg	  esac
224450806d53Smrg	  ;;
224550806d53Smrg	esac
2246af1a9c97Smrg	func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
2247af1a9c97Smrg	$opt_dry_run || if test -n "$outputname"; then
2248af1a9c97Smrg	  ${RM}r "$tmpdir"
2249af1a9c97Smrg	fi
2250af1a9c97Smrg	;;
2251af1a9c97Smrg      esac
2252af1a9c97Smrg    done
225350806d53Smrg
2254af1a9c97Smrg    for file in $staticlibs; do
2255af1a9c97Smrg      func_basename "$file"
2256af1a9c97Smrg      name="$func_basename_result"
2257af1a9c97Smrg
2258af1a9c97Smrg      # Set up the ranlib parameters.
2259af1a9c97Smrg      oldlib="$destdir/$name"
2260af1a9c97Smrg
2261af1a9c97Smrg      func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
2262af1a9c97Smrg
2263af1a9c97Smrg      if test -n "$stripme" && test -n "$old_striplib"; then
2264af1a9c97Smrg	func_show_eval "$old_striplib $oldlib" 'exit $?'
2265af1a9c97Smrg      fi
2266af1a9c97Smrg
2267af1a9c97Smrg      # Do each command in the postinstall commands.
2268af1a9c97Smrg      func_execute_cmds "$old_postinstall_cmds" 'exit $?'
2269af1a9c97Smrg    done
2270af1a9c97Smrg
2271af1a9c97Smrg    test -n "$future_libdirs" && \
2272af1a9c97Smrg      func_warning "remember to run \`$progname --finish$future_libdirs'"
2273af1a9c97Smrg
2274af1a9c97Smrg    if test -n "$current_libdirs"; then
2275af1a9c97Smrg      # Maybe just do a dry run.
2276af1a9c97Smrg      $opt_dry_run && current_libdirs=" -n$current_libdirs"
2277af1a9c97Smrg      exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
2278af1a9c97Smrg    else
2279af1a9c97Smrg      exit $EXIT_SUCCESS
2280af1a9c97Smrg    fi
2281af1a9c97Smrg}
2282af1a9c97Smrg
2283af1a9c97Smrgtest "$mode" = install && func_mode_install ${1+"$@"}
2284af1a9c97Smrg
2285af1a9c97Smrg
2286af1a9c97Smrg# func_generate_dlsyms outputname originator pic_p
2287af1a9c97Smrg# Extract symbols from dlprefiles and create ${outputname}S.o with
2288af1a9c97Smrg# a dlpreopen symbol table.
2289af1a9c97Smrgfunc_generate_dlsyms ()
2290af1a9c97Smrg{
2291af1a9c97Smrg    $opt_debug
2292af1a9c97Smrg    my_outputname="$1"
2293af1a9c97Smrg    my_originator="$2"
2294af1a9c97Smrg    my_pic_p="${3-no}"
2295af1a9c97Smrg    my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'`
2296af1a9c97Smrg    my_dlsyms=
2297af1a9c97Smrg
2298af1a9c97Smrg    if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
2299af1a9c97Smrg      if test -n "$NM" && test -n "$global_symbol_pipe"; then
2300af1a9c97Smrg	my_dlsyms="${my_outputname}S.c"
2301af1a9c97Smrg      else
2302af1a9c97Smrg	func_error "not configured to extract global symbols from dlpreopened files"
2303af1a9c97Smrg      fi
2304af1a9c97Smrg    fi
2305af1a9c97Smrg
2306af1a9c97Smrg    if test -n "$my_dlsyms"; then
2307af1a9c97Smrg      case $my_dlsyms in
2308af1a9c97Smrg      "") ;;
2309af1a9c97Smrg      *.c)
2310af1a9c97Smrg	# Discover the nlist of each of the dlfiles.
2311af1a9c97Smrg	nlist="$output_objdir/${my_outputname}.nm"
2312af1a9c97Smrg
2313af1a9c97Smrg	func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
2314af1a9c97Smrg
2315af1a9c97Smrg	# Parse the name list into a source file.
2316af1a9c97Smrg	func_verbose "creating $output_objdir/$my_dlsyms"
2317af1a9c97Smrg
2318af1a9c97Smrg	$opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
2319af1a9c97Smrg/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */
2320af1a9c97Smrg/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */
2321af1a9c97Smrg
2322af1a9c97Smrg#ifdef __cplusplus
2323af1a9c97Smrgextern \"C\" {
2324af1a9c97Smrg#endif
2325af1a9c97Smrg
2326af1a9c97Smrg/* External symbol declarations for the compiler. */\
2327af1a9c97Smrg"
2328af1a9c97Smrg
2329af1a9c97Smrg	if test "$dlself" = yes; then
2330af1a9c97Smrg	  func_verbose "generating symbol list for \`$output'"
2331af1a9c97Smrg
2332af1a9c97Smrg	  $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
2333af1a9c97Smrg
2334af1a9c97Smrg	  # Add our own program objects to the symbol list.
2335af1a9c97Smrg	  progfiles=`$ECHO "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
2336af1a9c97Smrg	  for progfile in $progfiles; do
2337af1a9c97Smrg	    func_verbose "extracting global C symbols from \`$progfile'"
2338af1a9c97Smrg	    $opt_dry_run || eval "$NM $progfile | $global_symbol_pipe >> '$nlist'"
2339af1a9c97Smrg	  done
2340af1a9c97Smrg
2341af1a9c97Smrg	  if test -n "$exclude_expsyms"; then
2342af1a9c97Smrg	    $opt_dry_run || {
2343af1a9c97Smrg	      eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
2344af1a9c97Smrg	      eval '$MV "$nlist"T "$nlist"'
2345af1a9c97Smrg	    }
234650806d53Smrg	  fi
2347af1a9c97Smrg
2348af1a9c97Smrg	  if test -n "$export_symbols_regex"; then
2349af1a9c97Smrg	    $opt_dry_run || {
2350af1a9c97Smrg	      eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
2351af1a9c97Smrg	      eval '$MV "$nlist"T "$nlist"'
2352af1a9c97Smrg	    }
2353af1a9c97Smrg	  fi
2354af1a9c97Smrg
2355af1a9c97Smrg	  # Prepare the list of exported symbols
2356af1a9c97Smrg	  if test -z "$export_symbols"; then
2357af1a9c97Smrg	    export_symbols="$output_objdir/$outputname.exp"
2358af1a9c97Smrg	    $opt_dry_run || {
2359af1a9c97Smrg	      $RM $export_symbols
2360af1a9c97Smrg	      eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
2361af1a9c97Smrg	      case $host in
2362af1a9c97Smrg	      *cygwin* | *mingw* | *cegcc* )
2363af1a9c97Smrg                eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
2364af1a9c97Smrg                eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
2365af1a9c97Smrg	        ;;
2366af1a9c97Smrg	      esac
2367af1a9c97Smrg	    }
236850806d53Smrg	  else
2369af1a9c97Smrg	    $opt_dry_run || {
2370af1a9c97Smrg	      eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
2371af1a9c97Smrg	      eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
2372af1a9c97Smrg	      eval '$MV "$nlist"T "$nlist"'
2373af1a9c97Smrg	      case $host in
2374af1a9c97Smrg	        *cygwin | *mingw* | *cegcc* )
2375af1a9c97Smrg	          eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
2376af1a9c97Smrg	          eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
2377af1a9c97Smrg	          ;;
2378af1a9c97Smrg	      esac
2379af1a9c97Smrg	    }
238050806d53Smrg	  fi
2381af1a9c97Smrg	fi
238250806d53Smrg
2383af1a9c97Smrg	for dlprefile in $dlprefiles; do
2384af1a9c97Smrg	  func_verbose "extracting global C symbols from \`$dlprefile'"
2385af1a9c97Smrg	  func_basename "$dlprefile"
2386af1a9c97Smrg	  name="$func_basename_result"
2387af1a9c97Smrg	  $opt_dry_run || {
2388af1a9c97Smrg	    eval '$ECHO ": $name " >> "$nlist"'
2389af1a9c97Smrg	    eval "$NM $dlprefile 2>/dev/null | $global_symbol_pipe >> '$nlist'"
2390af1a9c97Smrg	  }
2391af1a9c97Smrg	done
2392af1a9c97Smrg
2393af1a9c97Smrg	$opt_dry_run || {
2394af1a9c97Smrg	  # Make sure we have at least an empty file.
2395af1a9c97Smrg	  test -f "$nlist" || : > "$nlist"
2396af1a9c97Smrg
2397af1a9c97Smrg	  if test -n "$exclude_expsyms"; then
2398af1a9c97Smrg	    $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
2399af1a9c97Smrg	    $MV "$nlist"T "$nlist"
240050806d53Smrg	  fi
2401af1a9c97Smrg
2402af1a9c97Smrg	  # Try sorting and uniquifying the output.
2403af1a9c97Smrg	  if $GREP -v "^: " < "$nlist" |
2404af1a9c97Smrg	      if sort -k 3 </dev/null >/dev/null 2>&1; then
2405af1a9c97Smrg		sort -k 3
2406af1a9c97Smrg	      else
2407af1a9c97Smrg		sort +2
2408af1a9c97Smrg	      fi |
2409af1a9c97Smrg	      uniq > "$nlist"S; then
2410af1a9c97Smrg	    :
241150806d53Smrg	  else
2412af1a9c97Smrg	    $GREP -v "^: " < "$nlist" > "$nlist"S
241350806d53Smrg	  fi
241450806d53Smrg
2415af1a9c97Smrg	  if test -f "$nlist"S; then
2416af1a9c97Smrg	    eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
241750806d53Smrg	  else
2418af1a9c97Smrg	    $ECHO '/* NONE */' >> "$output_objdir/$my_dlsyms"
241950806d53Smrg	  fi
242050806d53Smrg
2421af1a9c97Smrg	  $ECHO >> "$output_objdir/$my_dlsyms" "\
242250806d53Smrg
2423af1a9c97Smrg/* The mapping between symbol names and symbols.  */
2424af1a9c97Smrgtypedef struct {
2425af1a9c97Smrg  const char *name;
2426af1a9c97Smrg  void *address;
2427af1a9c97Smrg} lt_dlsymlist;
2428af1a9c97Smrg"
2429af1a9c97Smrg	  case $host in
2430af1a9c97Smrg	  *cygwin* | *mingw* | *cegcc* )
2431af1a9c97Smrg	    $ECHO >> "$output_objdir/$my_dlsyms" "\
2432af1a9c97Smrg/* DATA imports from DLLs on WIN32 con't be const, because
2433af1a9c97Smrg   runtime relocations are performed -- see ld's documentation
2434af1a9c97Smrg   on pseudo-relocs.  */"
2435af1a9c97Smrg	    lt_dlsym_const= ;;
2436af1a9c97Smrg	  *osf5*)
2437af1a9c97Smrg	    echo >> "$output_objdir/$my_dlsyms" "\
2438af1a9c97Smrg/* This system does not cope well with relocations in const data */"
2439af1a9c97Smrg	    lt_dlsym_const= ;;
2440af1a9c97Smrg	  *)
2441af1a9c97Smrg	    lt_dlsym_const=const ;;
2442af1a9c97Smrg	  esac
244350806d53Smrg
2444af1a9c97Smrg	  $ECHO >> "$output_objdir/$my_dlsyms" "\
2445af1a9c97Smrgextern $lt_dlsym_const lt_dlsymlist
2446af1a9c97Smrglt_${my_prefix}_LTX_preloaded_symbols[];
2447af1a9c97Smrg$lt_dlsym_const lt_dlsymlist
2448af1a9c97Smrglt_${my_prefix}_LTX_preloaded_symbols[] =
2449af1a9c97Smrg{\
2450af1a9c97Smrg  { \"$my_originator\", (void *) 0 },"
245150806d53Smrg
2452af1a9c97Smrg	  case $need_lib_prefix in
2453af1a9c97Smrg	  no)
2454af1a9c97Smrg	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
2455af1a9c97Smrg	    ;;
2456af1a9c97Smrg	  *)
2457af1a9c97Smrg	    eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
2458af1a9c97Smrg	    ;;
2459af1a9c97Smrg	  esac
2460af1a9c97Smrg	  $ECHO >> "$output_objdir/$my_dlsyms" "\
2461af1a9c97Smrg  {0, (void *) 0}
2462af1a9c97Smrg};
246350806d53Smrg
2464af1a9c97Smrg/* This works around a problem in FreeBSD linker */
2465af1a9c97Smrg#ifdef FREEBSD_WORKAROUND
2466af1a9c97Smrgstatic const void *lt_preloaded_setup() {
2467af1a9c97Smrg  return lt_${my_prefix}_LTX_preloaded_symbols;
2468af1a9c97Smrg}
2469af1a9c97Smrg#endif
2470af1a9c97Smrg
2471af1a9c97Smrg#ifdef __cplusplus
2472af1a9c97Smrg}
2473af1a9c97Smrg#endif\
2474af1a9c97Smrg"
2475af1a9c97Smrg	} # !$opt_dry_run
2476af1a9c97Smrg
2477af1a9c97Smrg	pic_flag_for_symtable=
2478af1a9c97Smrg	case "$compile_command " in
2479af1a9c97Smrg	*" -static "*) ;;
2480af1a9c97Smrg	*)
2481af1a9c97Smrg	  case $host in
2482af1a9c97Smrg	  # compiling the symbol table file with pic_flag works around
2483af1a9c97Smrg	  # a FreeBSD bug that causes programs to crash when -lm is
2484af1a9c97Smrg	  # linked before any other PIC object.  But we must not use
2485af1a9c97Smrg	  # pic_flag when linking with -static.  The problem exists in
2486af1a9c97Smrg	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
2487af1a9c97Smrg	  *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
2488af1a9c97Smrg	    pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
2489af1a9c97Smrg	  *-*-hpux*)
2490af1a9c97Smrg	    pic_flag_for_symtable=" $pic_flag"  ;;
2491af1a9c97Smrg	  *)
2492af1a9c97Smrg	    if test "X$my_pic_p" != Xno; then
2493af1a9c97Smrg	      pic_flag_for_symtable=" $pic_flag"
249450806d53Smrg	    fi
2495af1a9c97Smrg	    ;;
2496af1a9c97Smrg	  esac
2497af1a9c97Smrg	  ;;
2498af1a9c97Smrg	esac
2499af1a9c97Smrg	symtab_cflags=
2500af1a9c97Smrg	for arg in $LTCFLAGS; do
2501af1a9c97Smrg	  case $arg in
2502af1a9c97Smrg	  -pie | -fpie | -fPIE) ;;
2503af1a9c97Smrg	  *) symtab_cflags="$symtab_cflags $arg" ;;
2504af1a9c97Smrg	  esac
2505af1a9c97Smrg	done
250650806d53Smrg
2507af1a9c97Smrg	# Now compile the dynamic symbol file.
2508af1a9c97Smrg	func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
250950806d53Smrg
2510af1a9c97Smrg	# Clean up the generated files.
2511af1a9c97Smrg	func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"'
251250806d53Smrg
2513af1a9c97Smrg	# Transform the symbol file into the correct name.
2514af1a9c97Smrg	symfileobj="$output_objdir/${my_outputname}S.$objext"
2515af1a9c97Smrg	case $host in
2516af1a9c97Smrg	*cygwin* | *mingw* | *cegcc* )
2517af1a9c97Smrg	  if test -f "$output_objdir/$my_outputname.def"; then
2518af1a9c97Smrg	    compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
2519af1a9c97Smrg	    finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
2520af1a9c97Smrg	  else
2521af1a9c97Smrg	    compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
2522af1a9c97Smrg	    finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
252350806d53Smrg	  fi
2524af1a9c97Smrg	  ;;
2525af1a9c97Smrg	*)
2526af1a9c97Smrg	  compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
2527af1a9c97Smrg	  finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
2528af1a9c97Smrg	  ;;
2529af1a9c97Smrg	esac
2530af1a9c97Smrg	;;
2531af1a9c97Smrg      *)
2532af1a9c97Smrg	func_fatal_error "unknown suffix for \`$my_dlsyms'"
2533af1a9c97Smrg	;;
2534af1a9c97Smrg      esac
2535af1a9c97Smrg    else
2536af1a9c97Smrg      # We keep going just in case the user didn't refer to
2537af1a9c97Smrg      # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
2538af1a9c97Smrg      # really was required.
253950806d53Smrg
2540af1a9c97Smrg      # Nullify the symbol file.
2541af1a9c97Smrg      compile_command=`$ECHO "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"`
2542af1a9c97Smrg      finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"`
2543af1a9c97Smrg    fi
2544af1a9c97Smrg}
254550806d53Smrg
2546af1a9c97Smrg# func_win32_libid arg
2547af1a9c97Smrg# return the library type of file 'arg'
2548af1a9c97Smrg#
2549af1a9c97Smrg# Need a lot of goo to handle *both* DLLs and import libs
2550af1a9c97Smrg# Has to be a shell function in order to 'eat' the argument
2551af1a9c97Smrg# that is supplied when $file_magic_command is called.
2552af1a9c97Smrgfunc_win32_libid ()
2553af1a9c97Smrg{
2554af1a9c97Smrg  $opt_debug
2555af1a9c97Smrg  win32_libid_type="unknown"
2556af1a9c97Smrg  win32_fileres=`file -L $1 2>/dev/null`
2557af1a9c97Smrg  case $win32_fileres in
2558af1a9c97Smrg  *ar\ archive\ import\ library*) # definitely import
2559af1a9c97Smrg    win32_libid_type="x86 archive import"
2560af1a9c97Smrg    ;;
2561af1a9c97Smrg  *ar\ archive*) # could be an import, or static
2562af1a9c97Smrg    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
2563af1a9c97Smrg       $EGREP 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
2564af1a9c97Smrg      win32_nmres=`eval $NM -f posix -A $1 |
2565af1a9c97Smrg	$SED -n -e '
2566af1a9c97Smrg	    1,100{
2567af1a9c97Smrg		/ I /{
2568af1a9c97Smrg		    s,.*,import,
2569af1a9c97Smrg		    p
2570af1a9c97Smrg		    q
2571af1a9c97Smrg		}
2572af1a9c97Smrg	    }'`
2573af1a9c97Smrg      case $win32_nmres in
2574af1a9c97Smrg      import*)  win32_libid_type="x86 archive import";;
2575af1a9c97Smrg      *)        win32_libid_type="x86 archive static";;
2576af1a9c97Smrg      esac
2577af1a9c97Smrg    fi
2578af1a9c97Smrg    ;;
2579af1a9c97Smrg  *DLL*)
2580af1a9c97Smrg    win32_libid_type="x86 DLL"
2581af1a9c97Smrg    ;;
2582af1a9c97Smrg  *executable*) # but shell scripts are "executable" too...
2583af1a9c97Smrg    case $win32_fileres in
2584af1a9c97Smrg    *MS\ Windows\ PE\ Intel*)
2585af1a9c97Smrg      win32_libid_type="x86 DLL"
2586af1a9c97Smrg      ;;
2587af1a9c97Smrg    esac
2588af1a9c97Smrg    ;;
2589af1a9c97Smrg  esac
2590af1a9c97Smrg  $ECHO "$win32_libid_type"
2591af1a9c97Smrg}
259250806d53Smrg
259350806d53Smrg
259450806d53Smrg
2595af1a9c97Smrg# func_extract_an_archive dir oldlib
2596af1a9c97Smrgfunc_extract_an_archive ()
2597af1a9c97Smrg{
2598af1a9c97Smrg    $opt_debug
2599af1a9c97Smrg    f_ex_an_ar_dir="$1"; shift
2600af1a9c97Smrg    f_ex_an_ar_oldlib="$1"
2601af1a9c97Smrg    func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" 'exit $?'
2602af1a9c97Smrg    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
2603af1a9c97Smrg     :
2604af1a9c97Smrg    else
2605af1a9c97Smrg      func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
2606af1a9c97Smrg    fi
2607af1a9c97Smrg}
260850806d53Smrg
260950806d53Smrg
2610af1a9c97Smrg# func_extract_archives gentop oldlib ...
2611af1a9c97Smrgfunc_extract_archives ()
2612af1a9c97Smrg{
2613af1a9c97Smrg    $opt_debug
2614af1a9c97Smrg    my_gentop="$1"; shift
2615af1a9c97Smrg    my_oldlibs=${1+"$@"}
2616af1a9c97Smrg    my_oldobjs=""
2617af1a9c97Smrg    my_xlib=""
2618af1a9c97Smrg    my_xabs=""
2619af1a9c97Smrg    my_xdir=""
262050806d53Smrg
2621af1a9c97Smrg    for my_xlib in $my_oldlibs; do
2622af1a9c97Smrg      # Extract the objects.
2623af1a9c97Smrg      case $my_xlib in
2624af1a9c97Smrg	[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
2625af1a9c97Smrg	*) my_xabs=`pwd`"/$my_xlib" ;;
2626af1a9c97Smrg      esac
2627af1a9c97Smrg      func_basename "$my_xlib"
2628af1a9c97Smrg      my_xlib="$func_basename_result"
2629af1a9c97Smrg      my_xlib_u=$my_xlib
2630af1a9c97Smrg      while :; do
2631af1a9c97Smrg        case " $extracted_archives " in
2632af1a9c97Smrg	*" $my_xlib_u "*)
2633af1a9c97Smrg	  func_arith $extracted_serial + 1
2634af1a9c97Smrg	  extracted_serial=$func_arith_result
2635af1a9c97Smrg	  my_xlib_u=lt$extracted_serial-$my_xlib ;;
2636af1a9c97Smrg	*) break ;;
2637af1a9c97Smrg	esac
2638af1a9c97Smrg      done
2639af1a9c97Smrg      extracted_archives="$extracted_archives $my_xlib_u"
2640af1a9c97Smrg      my_xdir="$my_gentop/$my_xlib_u"
264150806d53Smrg
2642af1a9c97Smrg      func_mkdir_p "$my_xdir"
264350806d53Smrg
2644af1a9c97Smrg      case $host in
2645af1a9c97Smrg      *-darwin*)
2646af1a9c97Smrg	func_verbose "Extracting $my_xabs"
2647af1a9c97Smrg	# Do not bother doing anything if just a dry run
2648af1a9c97Smrg	$opt_dry_run || {
2649af1a9c97Smrg	  darwin_orig_dir=`pwd`
2650af1a9c97Smrg	  cd $my_xdir || exit $?
2651af1a9c97Smrg	  darwin_archive=$my_xabs
2652af1a9c97Smrg	  darwin_curdir=`pwd`
2653af1a9c97Smrg	  darwin_base_archive=`basename "$darwin_archive"`
2654af1a9c97Smrg	  darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
2655af1a9c97Smrg	  if test -n "$darwin_arches"; then
2656af1a9c97Smrg	    darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
2657af1a9c97Smrg	    darwin_arch=
2658af1a9c97Smrg	    func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
2659af1a9c97Smrg	    for darwin_arch in  $darwin_arches ; do
2660af1a9c97Smrg	      func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
2661af1a9c97Smrg	      $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
2662af1a9c97Smrg	      cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
2663af1a9c97Smrg	      func_extract_an_archive "`pwd`" "${darwin_base_archive}"
2664af1a9c97Smrg	      cd "$darwin_curdir"
2665af1a9c97Smrg	      $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
2666af1a9c97Smrg	    done # $darwin_arches
2667af1a9c97Smrg            ## Okay now we've a bunch of thin objects, gotta fatten them up :)
2668af1a9c97Smrg	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u`
2669af1a9c97Smrg	    darwin_file=
2670af1a9c97Smrg	    darwin_files=
2671af1a9c97Smrg	    for darwin_file in $darwin_filelist; do
2672af1a9c97Smrg	      darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP`
2673af1a9c97Smrg	      $LIPO -create -output "$darwin_file" $darwin_files
2674af1a9c97Smrg	    done # $darwin_filelist
2675af1a9c97Smrg	    $RM -rf unfat-$$
2676af1a9c97Smrg	    cd "$darwin_orig_dir"
267750806d53Smrg	  else
2678af1a9c97Smrg	    cd $darwin_orig_dir
2679af1a9c97Smrg	    func_extract_an_archive "$my_xdir" "$my_xabs"
2680af1a9c97Smrg	  fi # $darwin_arches
2681af1a9c97Smrg	} # !$opt_dry_run
2682af1a9c97Smrg	;;
2683af1a9c97Smrg      *)
2684af1a9c97Smrg        func_extract_an_archive "$my_xdir" "$my_xabs"
2685af1a9c97Smrg	;;
2686af1a9c97Smrg      esac
2687af1a9c97Smrg      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
2688af1a9c97Smrg    done
268950806d53Smrg
2690af1a9c97Smrg    func_extract_archives_result="$my_oldobjs"
2691af1a9c97Smrg}
269250806d53Smrg
269350806d53Smrg
269450806d53Smrg
2695af1a9c97Smrg# func_emit_wrapper_part1 [arg=no]
2696af1a9c97Smrg#
2697af1a9c97Smrg# Emit the first part of a libtool wrapper script on stdout.
2698af1a9c97Smrg# For more information, see the description associated with
2699af1a9c97Smrg# func_emit_wrapper(), below.
2700af1a9c97Smrgfunc_emit_wrapper_part1 ()
2701af1a9c97Smrg{
2702af1a9c97Smrg	func_emit_wrapper_part1_arg1=no
2703af1a9c97Smrg	if test -n "$1" ; then
2704af1a9c97Smrg	  func_emit_wrapper_part1_arg1=$1
270550806d53Smrg	fi
270650806d53Smrg
2707af1a9c97Smrg	$ECHO "\
2708af1a9c97Smrg#! $SHELL
270950806d53Smrg
2710af1a9c97Smrg# $output - temporary wrapper script for $objdir/$outputname
2711af1a9c97Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
2712af1a9c97Smrg#
2713af1a9c97Smrg# The $output program cannot be directly executed until all the libtool
2714af1a9c97Smrg# libraries that it depends on are installed.
2715af1a9c97Smrg#
2716af1a9c97Smrg# This wrapper script should never be moved out of the build directory.
2717af1a9c97Smrg# If it is, it will not operate correctly.
271850806d53Smrg
2719af1a9c97Smrg# Sed substitution that helps us do robust quoting.  It backslashifies
2720af1a9c97Smrg# metacharacters that are still active within double-quoted strings.
2721af1a9c97SmrgXsed='${SED} -e 1s/^X//'
2722af1a9c97Smrgsed_quote_subst='$sed_quote_subst'
272350806d53Smrg
2724af1a9c97Smrg# Be Bourne compatible
2725af1a9c97Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
2726af1a9c97Smrg  emulate sh
2727af1a9c97Smrg  NULLCMD=:
2728af1a9c97Smrg  # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
2729af1a9c97Smrg  # is contrary to our usage.  Disable this feature.
2730af1a9c97Smrg  alias -g '\${1+\"\$@\"}'='\"\$@\"'
2731af1a9c97Smrg  setopt NO_GLOB_SUBST
2732af1a9c97Smrgelse
2733af1a9c97Smrg  case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
2734af1a9c97Smrgfi
2735af1a9c97SmrgBIN_SH=xpg4; export BIN_SH # for Tru64
2736af1a9c97SmrgDUALCASE=1; export DUALCASE # for MKS sh
273750806d53Smrg
2738af1a9c97Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout
2739af1a9c97Smrg# if CDPATH is set.
2740af1a9c97Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
274150806d53Smrg
2742af1a9c97Smrgrelink_command=\"$relink_command\"
274350806d53Smrg
2744af1a9c97Smrg# This environment variable determines our operation mode.
2745af1a9c97Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then
2746af1a9c97Smrg  # install mode needs the following variables:
2747af1a9c97Smrg  generated_by_libtool_version='$macro_version'
2748af1a9c97Smrg  notinst_deplibs='$notinst_deplibs'
2749af1a9c97Smrgelse
2750af1a9c97Smrg  # When we are sourced in execute mode, \$file and \$ECHO are already set.
2751af1a9c97Smrg  if test \"\$libtool_execute_magic\" != \"$magic\"; then
2752af1a9c97Smrg    ECHO=\"$qecho\"
2753af1a9c97Smrg    file=\"\$0\"
2754af1a9c97Smrg    # Make sure echo works.
2755af1a9c97Smrg    if test \"X\$1\" = X--no-reexec; then
2756af1a9c97Smrg      # Discard the --no-reexec flag, and continue.
2757af1a9c97Smrg      shift
2758af1a9c97Smrg    elif test \"X\`{ \$ECHO '\t'; } 2>/dev/null\`\" = 'X\t'; then
2759af1a9c97Smrg      # Yippee, \$ECHO works!
2760af1a9c97Smrg      :
2761af1a9c97Smrg    else
2762af1a9c97Smrg      # Restart under the correct shell, and then maybe \$ECHO will work.
2763af1a9c97Smrg      exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"}
2764af1a9c97Smrg    fi
2765af1a9c97Smrg  fi\
2766af1a9c97Smrg"
2767af1a9c97Smrg	$ECHO "\
276850806d53Smrg
2769af1a9c97Smrg  # Find the directory that this script lives in.
2770af1a9c97Smrg  thisdir=\`\$ECHO \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\`
2771af1a9c97Smrg  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
277250806d53Smrg
2773af1a9c97Smrg  # Follow symbolic links until we get to the real thisdir.
2774af1a9c97Smrg  file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\`
2775af1a9c97Smrg  while test -n \"\$file\"; do
2776af1a9c97Smrg    destdir=\`\$ECHO \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\`
277750806d53Smrg
2778af1a9c97Smrg    # If there was a directory component, then change thisdir.
2779af1a9c97Smrg    if test \"x\$destdir\" != \"x\$file\"; then
2780af1a9c97Smrg      case \"\$destdir\" in
2781af1a9c97Smrg      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
2782af1a9c97Smrg      *) thisdir=\"\$thisdir/\$destdir\" ;;
278350806d53Smrg      esac
2784af1a9c97Smrg    fi
278550806d53Smrg
2786af1a9c97Smrg    file=\`\$ECHO \"X\$file\" | \$Xsed -e 's%^.*/%%'\`
2787af1a9c97Smrg    file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\`
2788af1a9c97Smrg  done
2789af1a9c97Smrg"
2790af1a9c97Smrg}
2791af1a9c97Smrg# end: func_emit_wrapper_part1
2792af1a9c97Smrg
2793af1a9c97Smrg# func_emit_wrapper_part2 [arg=no]
2794af1a9c97Smrg#
2795af1a9c97Smrg# Emit the second part of a libtool wrapper script on stdout.
2796af1a9c97Smrg# For more information, see the description associated with
2797af1a9c97Smrg# func_emit_wrapper(), below.
2798af1a9c97Smrgfunc_emit_wrapper_part2 ()
2799af1a9c97Smrg{
2800af1a9c97Smrg	func_emit_wrapper_part2_arg1=no
2801af1a9c97Smrg	if test -n "$1" ; then
2802af1a9c97Smrg	  func_emit_wrapper_part2_arg1=$1
280350806d53Smrg	fi
280450806d53Smrg
2805af1a9c97Smrg	$ECHO "\
280650806d53Smrg
2807af1a9c97Smrg  # Usually 'no', except on cygwin/mingw when embedded into
2808af1a9c97Smrg  # the cwrapper.
2809af1a9c97Smrg  WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_part2_arg1
2810af1a9c97Smrg  if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
2811af1a9c97Smrg    # special case for '.'
2812af1a9c97Smrg    if test \"\$thisdir\" = \".\"; then
2813af1a9c97Smrg      thisdir=\`pwd\`
2814af1a9c97Smrg    fi
2815af1a9c97Smrg    # remove .libs from thisdir
2816af1a9c97Smrg    case \"\$thisdir\" in
2817af1a9c97Smrg    *[\\\\/]$objdir ) thisdir=\`\$ECHO \"X\$thisdir\" | \$Xsed -e 's%[\\\\/][^\\\\/]*$%%'\` ;;
2818af1a9c97Smrg    $objdir )   thisdir=. ;;
2819af1a9c97Smrg    esac
2820af1a9c97Smrg  fi
2821af1a9c97Smrg
2822af1a9c97Smrg  # Try to get the absolute directory name.
2823af1a9c97Smrg  absdir=\`cd \"\$thisdir\" && pwd\`
2824af1a9c97Smrg  test -n \"\$absdir\" && thisdir=\"\$absdir\"
2825af1a9c97Smrg"
2826af1a9c97Smrg
2827af1a9c97Smrg	if test "$fast_install" = yes; then
2828af1a9c97Smrg	  $ECHO "\
2829af1a9c97Smrg  program=lt-'$outputname'$exeext
2830af1a9c97Smrg  progdir=\"\$thisdir/$objdir\"
2831af1a9c97Smrg
2832af1a9c97Smrg  if test ! -f \"\$progdir/\$program\" ||
2833af1a9c97Smrg     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
2834af1a9c97Smrg       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
2835af1a9c97Smrg
2836af1a9c97Smrg    file=\"\$\$-\$program\"
2837af1a9c97Smrg
2838af1a9c97Smrg    if test ! -d \"\$progdir\"; then
2839af1a9c97Smrg      $MKDIR \"\$progdir\"
2840af1a9c97Smrg    else
2841af1a9c97Smrg      $RM \"\$progdir/\$file\"
2842af1a9c97Smrg    fi"
2843af1a9c97Smrg
2844af1a9c97Smrg	  $ECHO "\
2845af1a9c97Smrg
2846af1a9c97Smrg    # relink executable if necessary
2847af1a9c97Smrg    if test -n \"\$relink_command\"; then
2848af1a9c97Smrg      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
2849af1a9c97Smrg      else
2850af1a9c97Smrg	$ECHO \"\$relink_command_output\" >&2
2851af1a9c97Smrg	$RM \"\$progdir/\$file\"
2852af1a9c97Smrg	exit 1
285350806d53Smrg      fi
2854af1a9c97Smrg    fi
285550806d53Smrg
2856af1a9c97Smrg    $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
2857af1a9c97Smrg    { $RM \"\$progdir/\$program\";
2858af1a9c97Smrg      $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
2859af1a9c97Smrg    $RM \"\$progdir/\$file\"
2860af1a9c97Smrg  fi"
2861af1a9c97Smrg	else
2862af1a9c97Smrg	  $ECHO "\
2863af1a9c97Smrg  program='$outputname'
2864af1a9c97Smrg  progdir=\"\$thisdir/$objdir\"
2865af1a9c97Smrg"
286650806d53Smrg	fi
286750806d53Smrg
2868af1a9c97Smrg	$ECHO "\
286950806d53Smrg
2870af1a9c97Smrg  if test -f \"\$progdir/\$program\"; then"
287150806d53Smrg
2872af1a9c97Smrg	# Export our shlibpath_var if we have one.
2873af1a9c97Smrg	if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
2874af1a9c97Smrg	  $ECHO "\
2875af1a9c97Smrg    # Add our own library path to $shlibpath_var
2876af1a9c97Smrg    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
2877af1a9c97Smrg
2878af1a9c97Smrg    # Some systems cannot cope with colon-terminated $shlibpath_var
2879af1a9c97Smrg    # The second colon is a workaround for a bug in BeOS R4 sed
2880af1a9c97Smrg    $shlibpath_var=\`\$ECHO \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\`
288150806d53Smrg
2882af1a9c97Smrg    export $shlibpath_var
2883af1a9c97Smrg"
288450806d53Smrg	fi
288550806d53Smrg
2886af1a9c97Smrg	# fixup the dll searchpath if we need to.
2887af1a9c97Smrg	if test -n "$dllsearchpath"; then
2888af1a9c97Smrg	  $ECHO "\
2889af1a9c97Smrg    # Add the dll search path components to the executable PATH
2890af1a9c97Smrg    PATH=$dllsearchpath:\$PATH
2891af1a9c97Smrg"
2892af1a9c97Smrg	fi
289350806d53Smrg
2894af1a9c97Smrg	$ECHO "\
2895af1a9c97Smrg    if test \"\$libtool_execute_magic\" != \"$magic\"; then
2896af1a9c97Smrg      # Run the actual program with our arguments.
2897af1a9c97Smrg"
2898af1a9c97Smrg	case $host in
2899af1a9c97Smrg	# Backslashes separate directories on plain windows
2900af1a9c97Smrg	*-*-mingw | *-*-os2* | *-cegcc*)
2901af1a9c97Smrg	  $ECHO "\
2902af1a9c97Smrg      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
2903af1a9c97Smrg"
290450806d53Smrg	  ;;
290550806d53Smrg
290650806d53Smrg	*)
2907af1a9c97Smrg	  $ECHO "\
2908af1a9c97Smrg      exec \"\$progdir/\$program\" \${1+\"\$@\"}
2909af1a9c97Smrg"
291050806d53Smrg	  ;;
291150806d53Smrg	esac
2912af1a9c97Smrg	$ECHO "\
2913af1a9c97Smrg      \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
2914af1a9c97Smrg      exit 1
2915af1a9c97Smrg    fi
2916af1a9c97Smrg  else
2917af1a9c97Smrg    # The program doesn't exist.
2918af1a9c97Smrg    \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
2919af1a9c97Smrg    \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
2920af1a9c97Smrg    $ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
2921af1a9c97Smrg    exit 1
2922af1a9c97Smrg  fi
2923af1a9c97Smrgfi\
2924af1a9c97Smrg"
2925af1a9c97Smrg}
2926af1a9c97Smrg# end: func_emit_wrapper_part2
292750806d53Smrg
292850806d53Smrg
2929af1a9c97Smrg# func_emit_wrapper [arg=no]
2930af1a9c97Smrg#
2931af1a9c97Smrg# Emit a libtool wrapper script on stdout.
2932af1a9c97Smrg# Don't directly open a file because we may want to
2933af1a9c97Smrg# incorporate the script contents within a cygwin/mingw
2934af1a9c97Smrg# wrapper executable.  Must ONLY be called from within
2935af1a9c97Smrg# func_mode_link because it depends on a number of variables
2936af1a9c97Smrg# set therein.
2937af1a9c97Smrg#
2938af1a9c97Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
2939af1a9c97Smrg# variable will take.  If 'yes', then the emitted script
2940af1a9c97Smrg# will assume that the directory in which it is stored is
2941af1a9c97Smrg# the $objdir directory.  This is a cygwin/mingw-specific
2942af1a9c97Smrg# behavior.
2943af1a9c97Smrgfunc_emit_wrapper ()
2944af1a9c97Smrg{
2945af1a9c97Smrg	func_emit_wrapper_arg1=no
2946af1a9c97Smrg	if test -n "$1" ; then
2947af1a9c97Smrg	  func_emit_wrapper_arg1=$1
294850806d53Smrg	fi
294950806d53Smrg
2950af1a9c97Smrg	# split this up so that func_emit_cwrapperexe_src
2951af1a9c97Smrg	# can call each part independently.
2952af1a9c97Smrg	func_emit_wrapper_part1 "${func_emit_wrapper_arg1}"
2953af1a9c97Smrg	func_emit_wrapper_part2 "${func_emit_wrapper_arg1}"
2954af1a9c97Smrg}
295550806d53Smrg
295650806d53Smrg
2957af1a9c97Smrg# func_to_host_path arg
2958af1a9c97Smrg#
2959af1a9c97Smrg# Convert paths to host format when used with build tools.
2960af1a9c97Smrg# Intended for use with "native" mingw (where libtool itself
2961af1a9c97Smrg# is running under the msys shell), or in the following cross-
2962af1a9c97Smrg# build environments:
2963af1a9c97Smrg#    $build          $host
2964af1a9c97Smrg#    mingw (msys)    mingw  [e.g. native]
2965af1a9c97Smrg#    cygwin          mingw
2966af1a9c97Smrg#    *nix + wine     mingw
2967af1a9c97Smrg# where wine is equipped with the `winepath' executable.
2968af1a9c97Smrg# In the native mingw case, the (msys) shell automatically
2969af1a9c97Smrg# converts paths for any non-msys applications it launches,
2970af1a9c97Smrg# but that facility isn't available from inside the cwrapper.
2971af1a9c97Smrg# Similar accommodations are necessary for $host mingw and
2972af1a9c97Smrg# $build cygwin.  Calling this function does no harm for other
2973af1a9c97Smrg# $host/$build combinations not listed above.
2974af1a9c97Smrg#
2975af1a9c97Smrg# ARG is the path (on $build) that should be converted to
2976af1a9c97Smrg# the proper representation for $host. The result is stored
2977af1a9c97Smrg# in $func_to_host_path_result.
2978af1a9c97Smrgfunc_to_host_path ()
2979af1a9c97Smrg{
2980af1a9c97Smrg  func_to_host_path_result="$1"
2981af1a9c97Smrg  if test -n "$1" ; then
2982af1a9c97Smrg    case $host in
2983af1a9c97Smrg      *mingw* )
2984af1a9c97Smrg        lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
2985af1a9c97Smrg        case $build in
2986af1a9c97Smrg          *mingw* ) # actually, msys
2987af1a9c97Smrg            # awkward: cmd appends spaces to result
2988af1a9c97Smrg            lt_sed_strip_trailing_spaces="s/[ ]*\$//"
2989af1a9c97Smrg            func_to_host_path_tmp1=`( cmd //c echo "$1" |\
2990af1a9c97Smrg              $SED -e "$lt_sed_strip_trailing_spaces" ) 2>/dev/null || echo ""`
2991af1a9c97Smrg            func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\
2992af1a9c97Smrg              $SED -e "$lt_sed_naive_backslashify"`
2993af1a9c97Smrg            ;;
2994af1a9c97Smrg          *cygwin* )
2995af1a9c97Smrg            func_to_host_path_tmp1=`cygpath -w "$1"`
2996af1a9c97Smrg            func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\
2997af1a9c97Smrg              $SED -e "$lt_sed_naive_backslashify"`
2998af1a9c97Smrg            ;;
2999af1a9c97Smrg          * )
3000af1a9c97Smrg            # Unfortunately, winepath does not exit with a non-zero
3001af1a9c97Smrg            # error code, so we are forced to check the contents of
3002af1a9c97Smrg            # stdout. On the other hand, if the command is not
3003af1a9c97Smrg            # found, the shell will set an exit code of 127 and print
3004af1a9c97Smrg            # *an error message* to stdout. So we must check for both
3005af1a9c97Smrg            # error code of zero AND non-empty stdout, which explains
3006af1a9c97Smrg            # the odd construction:
3007af1a9c97Smrg            func_to_host_path_tmp1=`winepath -w "$1" 2>/dev/null`
3008af1a9c97Smrg            if test "$?" -eq 0 && test -n "${func_to_host_path_tmp1}"; then
3009af1a9c97Smrg              func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\
3010af1a9c97Smrg                $SED -e "$lt_sed_naive_backslashify"`
3011af1a9c97Smrg            else
3012af1a9c97Smrg              # Allow warning below.
3013af1a9c97Smrg              func_to_host_path_result=""
3014af1a9c97Smrg            fi
3015af1a9c97Smrg            ;;
3016af1a9c97Smrg        esac
3017af1a9c97Smrg        if test -z "$func_to_host_path_result" ; then
3018af1a9c97Smrg          func_error "Could not determine host path corresponding to"
3019af1a9c97Smrg          func_error "  '$1'"
3020af1a9c97Smrg          func_error "Continuing, but uninstalled executables may not work."
3021af1a9c97Smrg          # Fallback:
3022af1a9c97Smrg          func_to_host_path_result="$1"
3023af1a9c97Smrg        fi
3024af1a9c97Smrg        ;;
3025af1a9c97Smrg    esac
3026af1a9c97Smrg  fi
3027af1a9c97Smrg}
3028af1a9c97Smrg# end: func_to_host_path
302950806d53Smrg
3030af1a9c97Smrg# func_to_host_pathlist arg
3031af1a9c97Smrg#
3032af1a9c97Smrg# Convert pathlists to host format when used with build tools.
3033af1a9c97Smrg# See func_to_host_path(), above. This function supports the
3034af1a9c97Smrg# following $build/$host combinations (but does no harm for
3035af1a9c97Smrg# combinations not listed here):
3036af1a9c97Smrg#    $build          $host
3037af1a9c97Smrg#    mingw (msys)    mingw  [e.g. native]
3038af1a9c97Smrg#    cygwin          mingw
3039af1a9c97Smrg#    *nix + wine     mingw
3040af1a9c97Smrg#
3041af1a9c97Smrg# Path separators are also converted from $build format to
3042af1a9c97Smrg# $host format. If ARG begins or ends with a path separator
3043af1a9c97Smrg# character, it is preserved (but converted to $host format)
3044af1a9c97Smrg# on output.
3045af1a9c97Smrg#
3046af1a9c97Smrg# ARG is a pathlist (on $build) that should be converted to
3047af1a9c97Smrg# the proper representation on $host. The result is stored
3048af1a9c97Smrg# in $func_to_host_pathlist_result.
3049af1a9c97Smrgfunc_to_host_pathlist ()
3050af1a9c97Smrg{
3051af1a9c97Smrg  func_to_host_pathlist_result="$1"
3052af1a9c97Smrg  if test -n "$1" ; then
3053af1a9c97Smrg    case $host in
3054af1a9c97Smrg      *mingw* )
3055af1a9c97Smrg        lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
3056af1a9c97Smrg        # Remove leading and trailing path separator characters from
3057af1a9c97Smrg        # ARG. msys behavior is inconsistent here, cygpath turns them
3058af1a9c97Smrg        # into '.;' and ';.', and winepath ignores them completely.
3059af1a9c97Smrg        func_to_host_pathlist_tmp2="$1"
3060af1a9c97Smrg        # Once set for this call, this variable should not be
3061af1a9c97Smrg        # reassigned. It is used in tha fallback case.
3062af1a9c97Smrg        func_to_host_pathlist_tmp1=`echo "$func_to_host_pathlist_tmp2" |\
3063af1a9c97Smrg          $SED -e 's|^:*||' -e 's|:*$||'`
3064af1a9c97Smrg        case $build in
3065af1a9c97Smrg          *mingw* ) # Actually, msys.
3066af1a9c97Smrg            # Awkward: cmd appends spaces to result.
3067af1a9c97Smrg            lt_sed_strip_trailing_spaces="s/[ ]*\$//"
3068af1a9c97Smrg            func_to_host_pathlist_tmp2=`( cmd //c echo "$func_to_host_pathlist_tmp1" |\
3069af1a9c97Smrg              $SED -e "$lt_sed_strip_trailing_spaces" ) 2>/dev/null || echo ""`
3070af1a9c97Smrg            func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp2" |\
3071af1a9c97Smrg              $SED -e "$lt_sed_naive_backslashify"`
3072af1a9c97Smrg            ;;
3073af1a9c97Smrg          *cygwin* )
3074af1a9c97Smrg            func_to_host_pathlist_tmp2=`cygpath -w -p "$func_to_host_pathlist_tmp1"`
3075af1a9c97Smrg            func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp2" |\
3076af1a9c97Smrg              $SED -e "$lt_sed_naive_backslashify"`
3077af1a9c97Smrg            ;;
3078af1a9c97Smrg          * )
3079af1a9c97Smrg            # unfortunately, winepath doesn't convert pathlists
3080af1a9c97Smrg            func_to_host_pathlist_result=""
3081af1a9c97Smrg            func_to_host_pathlist_oldIFS=$IFS
3082af1a9c97Smrg            IFS=:
3083af1a9c97Smrg            for func_to_host_pathlist_f in $func_to_host_pathlist_tmp1 ; do
3084af1a9c97Smrg              IFS=$func_to_host_pathlist_oldIFS
3085af1a9c97Smrg              if test -n "$func_to_host_pathlist_f" ; then
3086af1a9c97Smrg                func_to_host_path "$func_to_host_pathlist_f"
3087af1a9c97Smrg                if test -n "$func_to_host_path_result" ; then
3088af1a9c97Smrg                  if test -z "$func_to_host_pathlist_result" ; then
3089af1a9c97Smrg                    func_to_host_pathlist_result="$func_to_host_path_result"
3090af1a9c97Smrg                  else
3091af1a9c97Smrg                    func_to_host_pathlist_result="$func_to_host_pathlist_result;$func_to_host_path_result"
3092af1a9c97Smrg                  fi
3093af1a9c97Smrg                fi
3094af1a9c97Smrg              fi
3095af1a9c97Smrg              IFS=:
3096af1a9c97Smrg            done
3097af1a9c97Smrg            IFS=$func_to_host_pathlist_oldIFS
3098af1a9c97Smrg            ;;
3099af1a9c97Smrg        esac
3100af1a9c97Smrg        if test -z "$func_to_host_pathlist_result" ; then
3101af1a9c97Smrg          func_error "Could not determine the host path(s) corresponding to"
3102af1a9c97Smrg          func_error "  '$1'"
3103af1a9c97Smrg          func_error "Continuing, but uninstalled executables may not work."
3104af1a9c97Smrg          # Fallback. This may break if $1 contains DOS-style drive
3105af1a9c97Smrg          # specifications. The fix is not to complicate the expression
3106af1a9c97Smrg          # below, but for the user to provide a working wine installation
3107af1a9c97Smrg          # with winepath so that path translation in the cross-to-mingw
3108af1a9c97Smrg          # case works properly.
3109af1a9c97Smrg          lt_replace_pathsep_nix_to_dos="s|:|;|g"
3110af1a9c97Smrg          func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp1" |\
3111af1a9c97Smrg            $SED -e "$lt_replace_pathsep_nix_to_dos"`
3112af1a9c97Smrg        fi
3113af1a9c97Smrg        # Now, add the leading and trailing path separators back
3114af1a9c97Smrg        case "$1" in
3115af1a9c97Smrg          :* ) func_to_host_pathlist_result=";$func_to_host_pathlist_result"
3116af1a9c97Smrg            ;;
3117af1a9c97Smrg        esac
3118af1a9c97Smrg        case "$1" in
3119af1a9c97Smrg          *: ) func_to_host_pathlist_result="$func_to_host_pathlist_result;"
3120af1a9c97Smrg            ;;
3121af1a9c97Smrg        esac
3122af1a9c97Smrg        ;;
3123af1a9c97Smrg    esac
3124af1a9c97Smrg  fi
3125af1a9c97Smrg}
3126af1a9c97Smrg# end: func_to_host_pathlist
312750806d53Smrg
3128af1a9c97Smrg# func_emit_cwrapperexe_src
3129af1a9c97Smrg# emit the source code for a wrapper executable on stdout
3130af1a9c97Smrg# Must ONLY be called from within func_mode_link because
3131af1a9c97Smrg# it depends on a number of variable set therein.
3132af1a9c97Smrgfunc_emit_cwrapperexe_src ()
3133af1a9c97Smrg{
3134af1a9c97Smrg	cat <<EOF
313550806d53Smrg
3136af1a9c97Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
3137af1a9c97Smrg   Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
313850806d53Smrg
3139af1a9c97Smrg   The $output program cannot be directly executed until all the libtool
3140af1a9c97Smrg   libraries that it depends on are installed.
314150806d53Smrg
3142af1a9c97Smrg   This wrapper executable should never be moved out of the build directory.
3143af1a9c97Smrg   If it is, it will not operate correctly.
314450806d53Smrg
3145af1a9c97Smrg   Currently, it simply execs the wrapper *script* "$SHELL $output",
3146af1a9c97Smrg   but could eventually absorb all of the scripts functionality and
3147af1a9c97Smrg   exec $objdir/$outputname directly.
3148af1a9c97Smrg*/
3149af1a9c97SmrgEOF
3150af1a9c97Smrg	    cat <<"EOF"
3151af1a9c97Smrg#include <stdio.h>
3152af1a9c97Smrg#include <stdlib.h>
3153af1a9c97Smrg#ifdef _MSC_VER
3154af1a9c97Smrg# include <direct.h>
3155af1a9c97Smrg# include <process.h>
3156af1a9c97Smrg# include <io.h>
3157af1a9c97Smrg# define setmode _setmode
3158af1a9c97Smrg#else
3159af1a9c97Smrg# include <unistd.h>
3160af1a9c97Smrg# include <stdint.h>
3161af1a9c97Smrg# ifdef __CYGWIN__
3162af1a9c97Smrg#  include <io.h>
3163af1a9c97Smrg#  define HAVE_SETENV
3164af1a9c97Smrg#  ifdef __STRICT_ANSI__
3165af1a9c97Smrgchar *realpath (const char *, char *);
3166af1a9c97Smrgint putenv (char *);
3167af1a9c97Smrgint setenv (const char *, const char *, int);
3168af1a9c97Smrg#  endif
3169af1a9c97Smrg# endif
3170af1a9c97Smrg#endif
3171af1a9c97Smrg#include <malloc.h>
3172af1a9c97Smrg#include <stdarg.h>
3173af1a9c97Smrg#include <assert.h>
3174af1a9c97Smrg#include <string.h>
3175af1a9c97Smrg#include <ctype.h>
3176af1a9c97Smrg#include <errno.h>
3177af1a9c97Smrg#include <fcntl.h>
3178af1a9c97Smrg#include <sys/stat.h>
317950806d53Smrg
3180af1a9c97Smrg#if defined(PATH_MAX)
3181af1a9c97Smrg# define LT_PATHMAX PATH_MAX
3182af1a9c97Smrg#elif defined(MAXPATHLEN)
3183af1a9c97Smrg# define LT_PATHMAX MAXPATHLEN
3184af1a9c97Smrg#else
3185af1a9c97Smrg# define LT_PATHMAX 1024
3186af1a9c97Smrg#endif
318750806d53Smrg
3188af1a9c97Smrg#ifndef S_IXOTH
3189af1a9c97Smrg# define S_IXOTH 0
3190af1a9c97Smrg#endif
3191af1a9c97Smrg#ifndef S_IXGRP
3192af1a9c97Smrg# define S_IXGRP 0
3193af1a9c97Smrg#endif
319450806d53Smrg
3195af1a9c97Smrg#ifdef _MSC_VER
3196af1a9c97Smrg# define S_IXUSR _S_IEXEC
3197af1a9c97Smrg# define stat _stat
3198af1a9c97Smrg# ifndef _INTPTR_T_DEFINED
3199af1a9c97Smrg#  define intptr_t int
3200af1a9c97Smrg# endif
3201af1a9c97Smrg#endif
320250806d53Smrg
3203af1a9c97Smrg#ifndef DIR_SEPARATOR
3204af1a9c97Smrg# define DIR_SEPARATOR '/'
3205af1a9c97Smrg# define PATH_SEPARATOR ':'
3206af1a9c97Smrg#endif
320750806d53Smrg
3208af1a9c97Smrg#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
3209af1a9c97Smrg  defined (__OS2__)
3210af1a9c97Smrg# define HAVE_DOS_BASED_FILE_SYSTEM
3211af1a9c97Smrg# define FOPEN_WB "wb"
3212af1a9c97Smrg# ifndef DIR_SEPARATOR_2
3213af1a9c97Smrg#  define DIR_SEPARATOR_2 '\\'
3214af1a9c97Smrg# endif
3215af1a9c97Smrg# ifndef PATH_SEPARATOR_2
3216af1a9c97Smrg#  define PATH_SEPARATOR_2 ';'
3217af1a9c97Smrg# endif
3218af1a9c97Smrg#endif
321950806d53Smrg
3220af1a9c97Smrg#ifndef DIR_SEPARATOR_2
3221af1a9c97Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
3222af1a9c97Smrg#else /* DIR_SEPARATOR_2 */
3223af1a9c97Smrg# define IS_DIR_SEPARATOR(ch) \
3224af1a9c97Smrg	(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
3225af1a9c97Smrg#endif /* DIR_SEPARATOR_2 */
322650806d53Smrg
3227af1a9c97Smrg#ifndef PATH_SEPARATOR_2
3228af1a9c97Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
3229af1a9c97Smrg#else /* PATH_SEPARATOR_2 */
3230af1a9c97Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
3231af1a9c97Smrg#endif /* PATH_SEPARATOR_2 */
323250806d53Smrg
3233af1a9c97Smrg#ifdef __CYGWIN__
3234af1a9c97Smrg# define FOPEN_WB "wb"
3235af1a9c97Smrg#endif
323650806d53Smrg
3237af1a9c97Smrg#ifndef FOPEN_WB
3238af1a9c97Smrg# define FOPEN_WB "w"
3239af1a9c97Smrg#endif
3240af1a9c97Smrg#ifndef _O_BINARY
3241af1a9c97Smrg# define _O_BINARY 0
3242af1a9c97Smrg#endif
324350806d53Smrg
3244af1a9c97Smrg#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
3245af1a9c97Smrg#define XFREE(stale) do { \
3246af1a9c97Smrg  if (stale) { free ((void *) stale); stale = 0; } \
3247af1a9c97Smrg} while (0)
324850806d53Smrg
3249af1a9c97Smrg#undef LTWRAPPER_DEBUGPRINTF
3250af1a9c97Smrg#if defined DEBUGWRAPPER
3251af1a9c97Smrg# define LTWRAPPER_DEBUGPRINTF(args) ltwrapper_debugprintf args
3252af1a9c97Smrgstatic void
3253af1a9c97Smrgltwrapper_debugprintf (const char *fmt, ...)
3254af1a9c97Smrg{
3255af1a9c97Smrg    va_list args;
3256af1a9c97Smrg    va_start (args, fmt);
3257af1a9c97Smrg    (void) vfprintf (stderr, fmt, args);
3258af1a9c97Smrg    va_end (args);
3259af1a9c97Smrg}
3260af1a9c97Smrg#else
3261af1a9c97Smrg# define LTWRAPPER_DEBUGPRINTF(args)
3262af1a9c97Smrg#endif
326350806d53Smrg
3264af1a9c97Smrgconst char *program_name = NULL;
326550806d53Smrg
3266af1a9c97Smrgvoid *xmalloc (size_t num);
3267af1a9c97Smrgchar *xstrdup (const char *string);
3268af1a9c97Smrgconst char *base_name (const char *name);
3269af1a9c97Smrgchar *find_executable (const char *wrapper);
3270af1a9c97Smrgchar *chase_symlinks (const char *pathspec);
3271af1a9c97Smrgint make_executable (const char *path);
3272af1a9c97Smrgint check_executable (const char *path);
3273af1a9c97Smrgchar *strendzap (char *str, const char *pat);
3274af1a9c97Smrgvoid lt_fatal (const char *message, ...);
3275af1a9c97Smrgvoid lt_setenv (const char *name, const char *value);
3276af1a9c97Smrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end);
3277af1a9c97Smrgvoid lt_opt_process_env_set (const char *arg);
3278af1a9c97Smrgvoid lt_opt_process_env_prepend (const char *arg);
3279af1a9c97Smrgvoid lt_opt_process_env_append (const char *arg);
3280af1a9c97Smrgint lt_split_name_value (const char *arg, char** name, char** value);
3281af1a9c97Smrgvoid lt_update_exe_path (const char *name, const char *value);
3282af1a9c97Smrgvoid lt_update_lib_path (const char *name, const char *value);
3283af1a9c97Smrg
3284af1a9c97Smrgstatic const char *script_text_part1 =
3285af1a9c97SmrgEOF
328650806d53Smrg
3287af1a9c97Smrg	    func_emit_wrapper_part1 yes |
3288af1a9c97Smrg	        $SED -e 's/\([\\"]\)/\\\1/g' \
3289af1a9c97Smrg	             -e 's/^/  "/' -e 's/$/\\n"/'
3290af1a9c97Smrg	    echo ";"
3291af1a9c97Smrg	    cat <<EOF
329250806d53Smrg
3293af1a9c97Smrgstatic const char *script_text_part2 =
3294af1a9c97SmrgEOF
3295af1a9c97Smrg	    func_emit_wrapper_part2 yes |
3296af1a9c97Smrg	        $SED -e 's/\([\\"]\)/\\\1/g' \
3297af1a9c97Smrg	             -e 's/^/  "/' -e 's/$/\\n"/'
3298af1a9c97Smrg	    echo ";"
3299af1a9c97Smrg
3300af1a9c97Smrg	    cat <<EOF
3301af1a9c97Smrgconst char * MAGIC_EXE = "$magic_exe";
3302af1a9c97Smrgconst char * LIB_PATH_VARNAME = "$shlibpath_var";
3303af1a9c97SmrgEOF
330450806d53Smrg
3305af1a9c97Smrg	    if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
3306af1a9c97Smrg              func_to_host_pathlist "$temp_rpath"
3307af1a9c97Smrg	      cat <<EOF
3308af1a9c97Smrgconst char * LIB_PATH_VALUE   = "$func_to_host_pathlist_result";
3309af1a9c97SmrgEOF
3310af1a9c97Smrg	    else
3311af1a9c97Smrg	      cat <<"EOF"
3312af1a9c97Smrgconst char * LIB_PATH_VALUE   = "";
3313af1a9c97SmrgEOF
331450806d53Smrg	    fi
331550806d53Smrg
3316af1a9c97Smrg	    if test -n "$dllsearchpath"; then
3317af1a9c97Smrg              func_to_host_pathlist "$dllsearchpath:"
3318af1a9c97Smrg	      cat <<EOF
3319af1a9c97Smrgconst char * EXE_PATH_VARNAME = "PATH";
3320af1a9c97Smrgconst char * EXE_PATH_VALUE   = "$func_to_host_pathlist_result";
332150806d53SmrgEOF
332250806d53Smrg	    else
3323af1a9c97Smrg	      cat <<"EOF"
3324af1a9c97Smrgconst char * EXE_PATH_VARNAME = "";
3325af1a9c97Smrgconst char * EXE_PATH_VALUE   = "";
3326af1a9c97SmrgEOF
332750806d53Smrg	    fi
3328af1a9c97Smrg
3329af1a9c97Smrg	    if test "$fast_install" = yes; then
3330af1a9c97Smrg	      cat <<EOF
3331af1a9c97Smrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
3332af1a9c97SmrgEOF
333350806d53Smrg	    else
3334af1a9c97Smrg	      cat <<EOF
3335af1a9c97Smrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
3336af1a9c97SmrgEOF
333750806d53Smrg	    fi
333850806d53Smrg
333950806d53Smrg
3340af1a9c97Smrg	    cat <<"EOF"
334150806d53Smrg
3342af1a9c97Smrg#define LTWRAPPER_OPTION_PREFIX         "--lt-"
3343af1a9c97Smrg#define LTWRAPPER_OPTION_PREFIX_LENGTH  5
334450806d53Smrg
3345af1a9c97Smrgstatic const size_t opt_prefix_len         = LTWRAPPER_OPTION_PREFIX_LENGTH;
3346af1a9c97Smrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
334750806d53Smrg
3348af1a9c97Smrgstatic const char *dumpscript_opt       = LTWRAPPER_OPTION_PREFIX "dump-script";
334950806d53Smrg
3350af1a9c97Smrgstatic const size_t env_set_opt_len     = LTWRAPPER_OPTION_PREFIX_LENGTH + 7;
3351af1a9c97Smrgstatic const char *env_set_opt          = LTWRAPPER_OPTION_PREFIX "env-set";
3352af1a9c97Smrg  /* argument is putenv-style "foo=bar", value of foo is set to bar */
335350806d53Smrg
3354af1a9c97Smrgstatic const size_t env_prepend_opt_len = LTWRAPPER_OPTION_PREFIX_LENGTH + 11;
3355af1a9c97Smrgstatic const char *env_prepend_opt      = LTWRAPPER_OPTION_PREFIX "env-prepend";
3356af1a9c97Smrg  /* argument is putenv-style "foo=bar", new value of foo is bar${foo} */
335750806d53Smrg
3358af1a9c97Smrgstatic const size_t env_append_opt_len  = LTWRAPPER_OPTION_PREFIX_LENGTH + 10;
3359af1a9c97Smrgstatic const char *env_append_opt       = LTWRAPPER_OPTION_PREFIX "env-append";
3360af1a9c97Smrg  /* argument is putenv-style "foo=bar", new value of foo is ${foo}bar */
336150806d53Smrg
3362af1a9c97Smrgint
3363af1a9c97Smrgmain (int argc, char *argv[])
3364af1a9c97Smrg{
3365af1a9c97Smrg  char **newargz;
3366af1a9c97Smrg  int  newargc;
3367af1a9c97Smrg  char *tmp_pathspec;
3368af1a9c97Smrg  char *actual_cwrapper_path;
3369af1a9c97Smrg  char *actual_cwrapper_name;
3370af1a9c97Smrg  char *target_name;
3371af1a9c97Smrg  char *lt_argv_zero;
3372af1a9c97Smrg  intptr_t rval = 127;
337350806d53Smrg
3374af1a9c97Smrg  int i;
337550806d53Smrg
3376af1a9c97Smrg  program_name = (char *) xstrdup (base_name (argv[0]));
3377af1a9c97Smrg  LTWRAPPER_DEBUGPRINTF (("(main) argv[0]      : %s\n", argv[0]));
3378af1a9c97Smrg  LTWRAPPER_DEBUGPRINTF (("(main) program_name : %s\n", program_name));
337950806d53Smrg
3380af1a9c97Smrg  /* very simple arg parsing; don't want to rely on getopt */
3381af1a9c97Smrg  for (i = 1; i < argc; i++)
3382af1a9c97Smrg    {
3383af1a9c97Smrg      if (strcmp (argv[i], dumpscript_opt) == 0)
3384af1a9c97Smrg	{
3385af1a9c97SmrgEOF
3386af1a9c97Smrg	    case "$host" in
3387af1a9c97Smrg	      *mingw* | *cygwin* )
3388af1a9c97Smrg		# make stdout use "unix" line endings
3389af1a9c97Smrg		echo "          setmode(1,_O_BINARY);"
3390af1a9c97Smrg		;;
3391af1a9c97Smrg	      esac
339250806d53Smrg
3393af1a9c97Smrg	    cat <<"EOF"
3394af1a9c97Smrg	  printf ("%s", script_text_part1);
3395af1a9c97Smrg	  printf ("%s", script_text_part2);
3396af1a9c97Smrg	  return 0;
3397af1a9c97Smrg	}
3398af1a9c97Smrg    }
339950806d53Smrg
3400af1a9c97Smrg  newargz = XMALLOC (char *, argc + 1);
3401af1a9c97Smrg  tmp_pathspec = find_executable (argv[0]);
3402af1a9c97Smrg  if (tmp_pathspec == NULL)
3403af1a9c97Smrg    lt_fatal ("Couldn't find %s", argv[0]);
3404af1a9c97Smrg  LTWRAPPER_DEBUGPRINTF (("(main) found exe (before symlink chase) at : %s\n",
3405af1a9c97Smrg			  tmp_pathspec));
3406af1a9c97Smrg
3407af1a9c97Smrg  actual_cwrapper_path = chase_symlinks (tmp_pathspec);
3408af1a9c97Smrg  LTWRAPPER_DEBUGPRINTF (("(main) found exe (after symlink chase) at : %s\n",
3409af1a9c97Smrg			  actual_cwrapper_path));
3410af1a9c97Smrg  XFREE (tmp_pathspec);
3411af1a9c97Smrg
3412af1a9c97Smrg  actual_cwrapper_name = xstrdup( base_name (actual_cwrapper_path));
3413af1a9c97Smrg  strendzap (actual_cwrapper_path, actual_cwrapper_name);
3414af1a9c97Smrg
3415af1a9c97Smrg  /* wrapper name transforms */
3416af1a9c97Smrg  strendzap (actual_cwrapper_name, ".exe");
3417af1a9c97Smrg  tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
3418af1a9c97Smrg  XFREE (actual_cwrapper_name);
3419af1a9c97Smrg  actual_cwrapper_name = tmp_pathspec;
3420af1a9c97Smrg  tmp_pathspec = 0;
3421af1a9c97Smrg
3422af1a9c97Smrg  /* target_name transforms -- use actual target program name; might have lt- prefix */
3423af1a9c97Smrg  target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
3424af1a9c97Smrg  strendzap (target_name, ".exe");
3425af1a9c97Smrg  tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
3426af1a9c97Smrg  XFREE (target_name);
3427af1a9c97Smrg  target_name = tmp_pathspec;
3428af1a9c97Smrg  tmp_pathspec = 0;
3429af1a9c97Smrg
3430af1a9c97Smrg  LTWRAPPER_DEBUGPRINTF (("(main) libtool target name: %s\n",
3431af1a9c97Smrg			  target_name));
3432af1a9c97SmrgEOF
343350806d53Smrg
3434af1a9c97Smrg	    cat <<EOF
3435af1a9c97Smrg  newargz[0] =
3436af1a9c97Smrg    XMALLOC (char, (strlen (actual_cwrapper_path) +
3437af1a9c97Smrg		    strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
3438af1a9c97Smrg  strcpy (newargz[0], actual_cwrapper_path);
3439af1a9c97Smrg  strcat (newargz[0], "$objdir");
3440af1a9c97Smrg  strcat (newargz[0], "/");
3441af1a9c97SmrgEOF
344250806d53Smrg
3443af1a9c97Smrg	    cat <<"EOF"
3444af1a9c97Smrg  /* stop here, and copy so we don't have to do this twice */
3445af1a9c97Smrg  tmp_pathspec = xstrdup (newargz[0]);
344650806d53Smrg
3447af1a9c97Smrg  /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
3448af1a9c97Smrg  strcat (newargz[0], actual_cwrapper_name);
344950806d53Smrg
3450af1a9c97Smrg  /* DO want the lt- prefix here if it exists, so use target_name */
3451af1a9c97Smrg  lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
3452af1a9c97Smrg  XFREE (tmp_pathspec);
3453af1a9c97Smrg  tmp_pathspec = NULL;
3454af1a9c97SmrgEOF
345550806d53Smrg
3456af1a9c97Smrg	    case $host_os in
3457af1a9c97Smrg	      mingw*)
3458af1a9c97Smrg	    cat <<"EOF"
3459af1a9c97Smrg  {
3460af1a9c97Smrg    char* p;
3461af1a9c97Smrg    while ((p = strchr (newargz[0], '\\')) != NULL)
3462af1a9c97Smrg      {
3463af1a9c97Smrg	*p = '/';
3464af1a9c97Smrg      }
3465af1a9c97Smrg    while ((p = strchr (lt_argv_zero, '\\')) != NULL)
3466af1a9c97Smrg      {
3467af1a9c97Smrg	*p = '/';
3468af1a9c97Smrg      }
3469af1a9c97Smrg  }
3470af1a9c97SmrgEOF
3471af1a9c97Smrg	    ;;
3472af1a9c97Smrg	    esac
347350806d53Smrg
3474af1a9c97Smrg	    cat <<"EOF"
3475af1a9c97Smrg  XFREE (target_name);
3476af1a9c97Smrg  XFREE (actual_cwrapper_path);
3477af1a9c97Smrg  XFREE (actual_cwrapper_name);
347850806d53Smrg
3479af1a9c97Smrg  lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
3480af1a9c97Smrg  lt_setenv ("DUALCASE", "1");  /* for MSK sh */
3481af1a9c97Smrg  lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
3482af1a9c97Smrg  lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
348350806d53Smrg
3484af1a9c97Smrg  newargc=0;
3485af1a9c97Smrg  for (i = 1; i < argc; i++)
3486af1a9c97Smrg    {
3487af1a9c97Smrg      if (strncmp (argv[i], env_set_opt, env_set_opt_len) == 0)
3488af1a9c97Smrg        {
3489af1a9c97Smrg          if (argv[i][env_set_opt_len] == '=')
3490af1a9c97Smrg            {
3491af1a9c97Smrg              const char *p = argv[i] + env_set_opt_len + 1;
3492af1a9c97Smrg              lt_opt_process_env_set (p);
3493af1a9c97Smrg            }
3494af1a9c97Smrg          else if (argv[i][env_set_opt_len] == '\0' && i + 1 < argc)
3495af1a9c97Smrg            {
3496af1a9c97Smrg              lt_opt_process_env_set (argv[++i]); /* don't copy */
3497af1a9c97Smrg            }
3498af1a9c97Smrg          else
3499af1a9c97Smrg            lt_fatal ("%s missing required argument", env_set_opt);
3500af1a9c97Smrg          continue;
3501af1a9c97Smrg        }
3502af1a9c97Smrg      if (strncmp (argv[i], env_prepend_opt, env_prepend_opt_len) == 0)
3503af1a9c97Smrg        {
3504af1a9c97Smrg          if (argv[i][env_prepend_opt_len] == '=')
3505af1a9c97Smrg            {
3506af1a9c97Smrg              const char *p = argv[i] + env_prepend_opt_len + 1;
3507af1a9c97Smrg              lt_opt_process_env_prepend (p);
3508af1a9c97Smrg            }
3509af1a9c97Smrg          else if (argv[i][env_prepend_opt_len] == '\0' && i + 1 < argc)
3510af1a9c97Smrg            {
3511af1a9c97Smrg              lt_opt_process_env_prepend (argv[++i]); /* don't copy */
3512af1a9c97Smrg            }
3513af1a9c97Smrg          else
3514af1a9c97Smrg            lt_fatal ("%s missing required argument", env_prepend_opt);
3515af1a9c97Smrg          continue;
3516af1a9c97Smrg        }
3517af1a9c97Smrg      if (strncmp (argv[i], env_append_opt, env_append_opt_len) == 0)
3518af1a9c97Smrg        {
3519af1a9c97Smrg          if (argv[i][env_append_opt_len] == '=')
3520af1a9c97Smrg            {
3521af1a9c97Smrg              const char *p = argv[i] + env_append_opt_len + 1;
3522af1a9c97Smrg              lt_opt_process_env_append (p);
3523af1a9c97Smrg            }
3524af1a9c97Smrg          else if (argv[i][env_append_opt_len] == '\0' && i + 1 < argc)
3525af1a9c97Smrg            {
3526af1a9c97Smrg              lt_opt_process_env_append (argv[++i]); /* don't copy */
3527af1a9c97Smrg            }
3528af1a9c97Smrg          else
3529af1a9c97Smrg            lt_fatal ("%s missing required argument", env_append_opt);
3530af1a9c97Smrg          continue;
3531af1a9c97Smrg        }
3532af1a9c97Smrg      if (strncmp (argv[i], ltwrapper_option_prefix, opt_prefix_len) == 0)
3533af1a9c97Smrg        {
3534af1a9c97Smrg          /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
3535af1a9c97Smrg             namespace, but it is not one of the ones we know about and
3536af1a9c97Smrg             have already dealt with, above (inluding dump-script), then
3537af1a9c97Smrg             report an error. Otherwise, targets might begin to believe
3538af1a9c97Smrg             they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
3539af1a9c97Smrg             namespace. The first time any user complains about this, we'll
3540af1a9c97Smrg             need to make LTWRAPPER_OPTION_PREFIX a configure-time option
3541af1a9c97Smrg             or a configure.ac-settable value.
3542af1a9c97Smrg           */
3543af1a9c97Smrg          lt_fatal ("Unrecognized option in %s namespace: '%s'",
3544af1a9c97Smrg                    ltwrapper_option_prefix, argv[i]);
3545af1a9c97Smrg        }
3546af1a9c97Smrg      /* otherwise ... */
3547af1a9c97Smrg      newargz[++newargc] = xstrdup (argv[i]);
3548af1a9c97Smrg    }
3549af1a9c97Smrg  newargz[++newargc] = NULL;
355050806d53Smrg
3551af1a9c97Smrg  LTWRAPPER_DEBUGPRINTF     (("(main) lt_argv_zero : %s\n", (lt_argv_zero ? lt_argv_zero : "<NULL>")));
3552af1a9c97Smrg  for (i = 0; i < newargc; i++)
3553af1a9c97Smrg    {
3554af1a9c97Smrg      LTWRAPPER_DEBUGPRINTF (("(main) newargz[%d]   : %s\n", i, (newargz[i] ? newargz[i] : "<NULL>")));
3555af1a9c97Smrg    }
355650806d53Smrg
3557af1a9c97SmrgEOF
355850806d53Smrg
3559af1a9c97Smrg	    case $host_os in
3560af1a9c97Smrg	      mingw*)
3561af1a9c97Smrg		cat <<"EOF"
3562af1a9c97Smrg  /* execv doesn't actually work on mingw as expected on unix */
3563af1a9c97Smrg  rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
3564af1a9c97Smrg  if (rval == -1)
3565af1a9c97Smrg    {
3566af1a9c97Smrg      /* failed to start process */
3567af1a9c97Smrg      LTWRAPPER_DEBUGPRINTF (("(main) failed to launch target \"%s\": errno = %d\n", lt_argv_zero, errno));
3568af1a9c97Smrg      return 127;
3569af1a9c97Smrg    }
3570af1a9c97Smrg  return rval;
3571af1a9c97SmrgEOF
3572af1a9c97Smrg		;;
3573af1a9c97Smrg	      *)
3574af1a9c97Smrg		cat <<"EOF"
3575af1a9c97Smrg  execv (lt_argv_zero, newargz);
3576af1a9c97Smrg  return rval; /* =127, but avoids unused variable warning */
3577af1a9c97SmrgEOF
3578af1a9c97Smrg		;;
3579af1a9c97Smrg	    esac
358050806d53Smrg
3581af1a9c97Smrg	    cat <<"EOF"
3582af1a9c97Smrg}
358350806d53Smrg
3584af1a9c97Smrgvoid *
3585af1a9c97Smrgxmalloc (size_t num)
3586af1a9c97Smrg{
3587af1a9c97Smrg  void *p = (void *) malloc (num);
3588af1a9c97Smrg  if (!p)
3589af1a9c97Smrg    lt_fatal ("Memory exhausted");
359050806d53Smrg
3591af1a9c97Smrg  return p;
3592af1a9c97Smrg}
359350806d53Smrg
3594af1a9c97Smrgchar *
3595af1a9c97Smrgxstrdup (const char *string)
3596af1a9c97Smrg{
3597af1a9c97Smrg  return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
3598af1a9c97Smrg			  string) : NULL;
3599af1a9c97Smrg}
360050806d53Smrg
3601af1a9c97Smrgconst char *
3602af1a9c97Smrgbase_name (const char *name)
3603af1a9c97Smrg{
3604af1a9c97Smrg  const char *base;
360550806d53Smrg
3606af1a9c97Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
3607af1a9c97Smrg  /* Skip over the disk name in MSDOS pathnames. */
3608af1a9c97Smrg  if (isalpha ((unsigned char) name[0]) && name[1] == ':')
3609af1a9c97Smrg    name += 2;
3610af1a9c97Smrg#endif
361150806d53Smrg
3612af1a9c97Smrg  for (base = name; *name; name++)
3613af1a9c97Smrg    if (IS_DIR_SEPARATOR (*name))
3614af1a9c97Smrg      base = name + 1;
3615af1a9c97Smrg  return base;
3616af1a9c97Smrg}
361750806d53Smrg
3618af1a9c97Smrgint
3619af1a9c97Smrgcheck_executable (const char *path)
3620af1a9c97Smrg{
3621af1a9c97Smrg  struct stat st;
362250806d53Smrg
3623af1a9c97Smrg  LTWRAPPER_DEBUGPRINTF (("(check_executable)  : %s\n",
3624af1a9c97Smrg			  path ? (*path ? path : "EMPTY!") : "NULL!"));
3625af1a9c97Smrg  if ((!path) || (!*path))
3626af1a9c97Smrg    return 0;
362750806d53Smrg
3628af1a9c97Smrg  if ((stat (path, &st) >= 0)
3629af1a9c97Smrg      && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
3630af1a9c97Smrg    return 1;
3631af1a9c97Smrg  else
3632af1a9c97Smrg    return 0;
3633af1a9c97Smrg}
363450806d53Smrg
3635af1a9c97Smrgint
3636af1a9c97Smrgmake_executable (const char *path)
3637af1a9c97Smrg{
3638af1a9c97Smrg  int rval = 0;
3639af1a9c97Smrg  struct stat st;
364050806d53Smrg
3641af1a9c97Smrg  LTWRAPPER_DEBUGPRINTF (("(make_executable)   : %s\n",
3642af1a9c97Smrg			  path ? (*path ? path : "EMPTY!") : "NULL!"));
3643af1a9c97Smrg  if ((!path) || (!*path))
3644af1a9c97Smrg    return 0;
364550806d53Smrg
3646af1a9c97Smrg  if (stat (path, &st) >= 0)
3647af1a9c97Smrg    {
3648af1a9c97Smrg      rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
3649af1a9c97Smrg    }
3650af1a9c97Smrg  return rval;
3651af1a9c97Smrg}
365250806d53Smrg
3653af1a9c97Smrg/* Searches for the full path of the wrapper.  Returns
3654af1a9c97Smrg   newly allocated full path name if found, NULL otherwise
3655af1a9c97Smrg   Does not chase symlinks, even on platforms that support them.
3656af1a9c97Smrg*/
3657af1a9c97Smrgchar *
3658af1a9c97Smrgfind_executable (const char *wrapper)
3659af1a9c97Smrg{
3660af1a9c97Smrg  int has_slash = 0;
3661af1a9c97Smrg  const char *p;
3662af1a9c97Smrg  const char *p_next;
3663af1a9c97Smrg  /* static buffer for getcwd */
3664af1a9c97Smrg  char tmp[LT_PATHMAX + 1];
3665af1a9c97Smrg  int tmp_len;
3666af1a9c97Smrg  char *concat_name;
366750806d53Smrg
3668af1a9c97Smrg  LTWRAPPER_DEBUGPRINTF (("(find_executable)   : %s\n",
3669af1a9c97Smrg			  wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!"));
367050806d53Smrg
3671af1a9c97Smrg  if ((wrapper == NULL) || (*wrapper == '\0'))
3672af1a9c97Smrg    return NULL;
367350806d53Smrg
3674af1a9c97Smrg  /* Absolute path? */
3675af1a9c97Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
3676af1a9c97Smrg  if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
3677af1a9c97Smrg    {
3678af1a9c97Smrg      concat_name = xstrdup (wrapper);
3679af1a9c97Smrg      if (check_executable (concat_name))
3680af1a9c97Smrg	return concat_name;
3681af1a9c97Smrg      XFREE (concat_name);
3682af1a9c97Smrg    }
3683af1a9c97Smrg  else
3684af1a9c97Smrg    {
3685af1a9c97Smrg#endif
3686af1a9c97Smrg      if (IS_DIR_SEPARATOR (wrapper[0]))
3687af1a9c97Smrg	{
3688af1a9c97Smrg	  concat_name = xstrdup (wrapper);
3689af1a9c97Smrg	  if (check_executable (concat_name))
3690af1a9c97Smrg	    return concat_name;
3691af1a9c97Smrg	  XFREE (concat_name);
3692af1a9c97Smrg	}
3693af1a9c97Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
3694af1a9c97Smrg    }
3695af1a9c97Smrg#endif
369650806d53Smrg
3697af1a9c97Smrg  for (p = wrapper; *p; p++)
3698af1a9c97Smrg    if (*p == '/')
3699af1a9c97Smrg      {
3700af1a9c97Smrg	has_slash = 1;
3701af1a9c97Smrg	break;
3702af1a9c97Smrg      }
3703af1a9c97Smrg  if (!has_slash)
3704af1a9c97Smrg    {
3705af1a9c97Smrg      /* no slashes; search PATH */
3706af1a9c97Smrg      const char *path = getenv ("PATH");
3707af1a9c97Smrg      if (path != NULL)
3708af1a9c97Smrg	{
3709af1a9c97Smrg	  for (p = path; *p; p = p_next)
3710af1a9c97Smrg	    {
3711af1a9c97Smrg	      const char *q;
3712af1a9c97Smrg	      size_t p_len;
3713af1a9c97Smrg	      for (q = p; *q; q++)
3714af1a9c97Smrg		if (IS_PATH_SEPARATOR (*q))
3715af1a9c97Smrg		  break;
3716af1a9c97Smrg	      p_len = q - p;
3717af1a9c97Smrg	      p_next = (*q == '\0' ? q : q + 1);
3718af1a9c97Smrg	      if (p_len == 0)
3719af1a9c97Smrg		{
3720af1a9c97Smrg		  /* empty path: current directory */
3721af1a9c97Smrg		  if (getcwd (tmp, LT_PATHMAX) == NULL)
3722af1a9c97Smrg		    lt_fatal ("getcwd failed");
3723af1a9c97Smrg		  tmp_len = strlen (tmp);
3724af1a9c97Smrg		  concat_name =
3725af1a9c97Smrg		    XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
3726af1a9c97Smrg		  memcpy (concat_name, tmp, tmp_len);
3727af1a9c97Smrg		  concat_name[tmp_len] = '/';
3728af1a9c97Smrg		  strcpy (concat_name + tmp_len + 1, wrapper);
3729af1a9c97Smrg		}
3730af1a9c97Smrg	      else
3731af1a9c97Smrg		{
3732af1a9c97Smrg		  concat_name =
3733af1a9c97Smrg		    XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
3734af1a9c97Smrg		  memcpy (concat_name, p, p_len);
3735af1a9c97Smrg		  concat_name[p_len] = '/';
3736af1a9c97Smrg		  strcpy (concat_name + p_len + 1, wrapper);
3737af1a9c97Smrg		}
3738af1a9c97Smrg	      if (check_executable (concat_name))
3739af1a9c97Smrg		return concat_name;
3740af1a9c97Smrg	      XFREE (concat_name);
3741af1a9c97Smrg	    }
3742af1a9c97Smrg	}
3743af1a9c97Smrg      /* not found in PATH; assume curdir */
3744af1a9c97Smrg    }
3745af1a9c97Smrg  /* Relative path | not found in path: prepend cwd */
3746af1a9c97Smrg  if (getcwd (tmp, LT_PATHMAX) == NULL)
3747af1a9c97Smrg    lt_fatal ("getcwd failed");
3748af1a9c97Smrg  tmp_len = strlen (tmp);
3749af1a9c97Smrg  concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
3750af1a9c97Smrg  memcpy (concat_name, tmp, tmp_len);
3751af1a9c97Smrg  concat_name[tmp_len] = '/';
3752af1a9c97Smrg  strcpy (concat_name + tmp_len + 1, wrapper);
375350806d53Smrg
3754af1a9c97Smrg  if (check_executable (concat_name))
3755af1a9c97Smrg    return concat_name;
3756af1a9c97Smrg  XFREE (concat_name);
3757af1a9c97Smrg  return NULL;
3758af1a9c97Smrg}
375950806d53Smrg
3760af1a9c97Smrgchar *
3761af1a9c97Smrgchase_symlinks (const char *pathspec)
3762af1a9c97Smrg{
3763af1a9c97Smrg#ifndef S_ISLNK
3764af1a9c97Smrg  return xstrdup (pathspec);
3765af1a9c97Smrg#else
3766af1a9c97Smrg  char buf[LT_PATHMAX];
3767af1a9c97Smrg  struct stat s;
3768af1a9c97Smrg  char *tmp_pathspec = xstrdup (pathspec);
3769af1a9c97Smrg  char *p;
3770af1a9c97Smrg  int has_symlinks = 0;
3771af1a9c97Smrg  while (strlen (tmp_pathspec) && !has_symlinks)
3772af1a9c97Smrg    {
3773af1a9c97Smrg      LTWRAPPER_DEBUGPRINTF (("checking path component for symlinks: %s\n",
3774af1a9c97Smrg			      tmp_pathspec));
3775af1a9c97Smrg      if (lstat (tmp_pathspec, &s) == 0)
3776af1a9c97Smrg	{
3777af1a9c97Smrg	  if (S_ISLNK (s.st_mode) != 0)
3778af1a9c97Smrg	    {
3779af1a9c97Smrg	      has_symlinks = 1;
3780af1a9c97Smrg	      break;
3781af1a9c97Smrg	    }
378250806d53Smrg
3783af1a9c97Smrg	  /* search backwards for last DIR_SEPARATOR */
3784af1a9c97Smrg	  p = tmp_pathspec + strlen (tmp_pathspec) - 1;
3785af1a9c97Smrg	  while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
3786af1a9c97Smrg	    p--;
3787af1a9c97Smrg	  if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
3788af1a9c97Smrg	    {
3789af1a9c97Smrg	      /* no more DIR_SEPARATORS left */
3790af1a9c97Smrg	      break;
3791af1a9c97Smrg	    }
3792af1a9c97Smrg	  *p = '\0';
3793af1a9c97Smrg	}
3794af1a9c97Smrg      else
3795af1a9c97Smrg	{
3796af1a9c97Smrg	  char *errstr = strerror (errno);
3797af1a9c97Smrg	  lt_fatal ("Error accessing file %s (%s)", tmp_pathspec, errstr);
3798af1a9c97Smrg	}
3799af1a9c97Smrg    }
3800af1a9c97Smrg  XFREE (tmp_pathspec);
380150806d53Smrg
3802af1a9c97Smrg  if (!has_symlinks)
3803af1a9c97Smrg    {
3804af1a9c97Smrg      return xstrdup (pathspec);
3805af1a9c97Smrg    }
380650806d53Smrg
3807af1a9c97Smrg  tmp_pathspec = realpath (pathspec, buf);
3808af1a9c97Smrg  if (tmp_pathspec == 0)
3809af1a9c97Smrg    {
3810af1a9c97Smrg      lt_fatal ("Could not follow symlinks for %s", pathspec);
3811af1a9c97Smrg    }
3812af1a9c97Smrg  return xstrdup (tmp_pathspec);
3813af1a9c97Smrg#endif
3814af1a9c97Smrg}
381550806d53Smrg
3816af1a9c97Smrgchar *
3817af1a9c97Smrgstrendzap (char *str, const char *pat)
3818af1a9c97Smrg{
3819af1a9c97Smrg  size_t len, patlen;
382050806d53Smrg
3821af1a9c97Smrg  assert (str != NULL);
3822af1a9c97Smrg  assert (pat != NULL);
382350806d53Smrg
3824af1a9c97Smrg  len = strlen (str);
3825af1a9c97Smrg  patlen = strlen (pat);
382650806d53Smrg
3827af1a9c97Smrg  if (patlen <= len)
3828af1a9c97Smrg    {
3829af1a9c97Smrg      str += len - patlen;
3830af1a9c97Smrg      if (strcmp (str, pat) == 0)
3831af1a9c97Smrg	*str = '\0';
3832af1a9c97Smrg    }
3833af1a9c97Smrg  return str;
3834af1a9c97Smrg}
383550806d53Smrg
3836af1a9c97Smrgstatic void
3837af1a9c97Smrglt_error_core (int exit_status, const char *mode,
3838af1a9c97Smrg	       const char *message, va_list ap)
3839af1a9c97Smrg{
3840af1a9c97Smrg  fprintf (stderr, "%s: %s: ", program_name, mode);
3841af1a9c97Smrg  vfprintf (stderr, message, ap);
3842af1a9c97Smrg  fprintf (stderr, ".\n");
384350806d53Smrg
3844af1a9c97Smrg  if (exit_status >= 0)
3845af1a9c97Smrg    exit (exit_status);
3846af1a9c97Smrg}
384750806d53Smrg
3848af1a9c97Smrgvoid
3849af1a9c97Smrglt_fatal (const char *message, ...)
3850af1a9c97Smrg{
3851af1a9c97Smrg  va_list ap;
3852af1a9c97Smrg  va_start (ap, message);
3853af1a9c97Smrg  lt_error_core (EXIT_FAILURE, "FATAL", message, ap);
3854af1a9c97Smrg  va_end (ap);
3855af1a9c97Smrg}
385650806d53Smrg
3857af1a9c97Smrgvoid
3858af1a9c97Smrglt_setenv (const char *name, const char *value)
3859af1a9c97Smrg{
3860af1a9c97Smrg  LTWRAPPER_DEBUGPRINTF (("(lt_setenv) setting '%s' to '%s'\n",
3861af1a9c97Smrg                          (name ? name : "<NULL>"),
3862af1a9c97Smrg                          (value ? value : "<NULL>")));
3863af1a9c97Smrg  {
3864af1a9c97Smrg#ifdef HAVE_SETENV
3865af1a9c97Smrg    /* always make a copy, for consistency with !HAVE_SETENV */
3866af1a9c97Smrg    char *str = xstrdup (value);
3867af1a9c97Smrg    setenv (name, str, 1);
3868af1a9c97Smrg#else
3869af1a9c97Smrg    int len = strlen (name) + 1 + strlen (value) + 1;
3870af1a9c97Smrg    char *str = XMALLOC (char, len);
3871af1a9c97Smrg    sprintf (str, "%s=%s", name, value);
3872af1a9c97Smrg    if (putenv (str) != EXIT_SUCCESS)
3873af1a9c97Smrg      {
3874af1a9c97Smrg        XFREE (str);
3875af1a9c97Smrg      }
3876af1a9c97Smrg#endif
3877af1a9c97Smrg  }
3878af1a9c97Smrg}
387950806d53Smrg
3880af1a9c97Smrgchar *
3881af1a9c97Smrglt_extend_str (const char *orig_value, const char *add, int to_end)
3882af1a9c97Smrg{
3883af1a9c97Smrg  char *new_value;
3884af1a9c97Smrg  if (orig_value && *orig_value)
3885af1a9c97Smrg    {
3886af1a9c97Smrg      int orig_value_len = strlen (orig_value);
3887af1a9c97Smrg      int add_len = strlen (add);
3888af1a9c97Smrg      new_value = XMALLOC (char, add_len + orig_value_len + 1);
3889af1a9c97Smrg      if (to_end)
3890af1a9c97Smrg        {
3891af1a9c97Smrg          strcpy (new_value, orig_value);
3892af1a9c97Smrg          strcpy (new_value + orig_value_len, add);
3893af1a9c97Smrg        }
3894af1a9c97Smrg      else
3895af1a9c97Smrg        {
3896af1a9c97Smrg          strcpy (new_value, add);
3897af1a9c97Smrg          strcpy (new_value + add_len, orig_value);
3898af1a9c97Smrg        }
3899af1a9c97Smrg    }
3900af1a9c97Smrg  else
3901af1a9c97Smrg    {
3902af1a9c97Smrg      new_value = xstrdup (add);
3903af1a9c97Smrg    }
3904af1a9c97Smrg  return new_value;
3905af1a9c97Smrg}
390650806d53Smrg
3907af1a9c97Smrgint
3908af1a9c97Smrglt_split_name_value (const char *arg, char** name, char** value)
3909af1a9c97Smrg{
3910af1a9c97Smrg  const char *p;
3911af1a9c97Smrg  int len;
3912af1a9c97Smrg  if (!arg || !*arg)
3913af1a9c97Smrg    return 1;
391450806d53Smrg
3915af1a9c97Smrg  p = strchr (arg, (int)'=');
391650806d53Smrg
3917af1a9c97Smrg  if (!p)
3918af1a9c97Smrg    return 1;
391950806d53Smrg
3920af1a9c97Smrg  *value = xstrdup (++p);
392150806d53Smrg
3922af1a9c97Smrg  len = strlen (arg) - strlen (*value);
3923af1a9c97Smrg  *name = XMALLOC (char, len);
3924af1a9c97Smrg  strncpy (*name, arg, len-1);
3925af1a9c97Smrg  (*name)[len - 1] = '\0';
392650806d53Smrg
3927af1a9c97Smrg  return 0;
3928af1a9c97Smrg}
392950806d53Smrg
3930af1a9c97Smrgvoid
3931af1a9c97Smrglt_opt_process_env_set (const char *arg)
3932af1a9c97Smrg{
3933af1a9c97Smrg  char *name = NULL;
3934af1a9c97Smrg  char *value = NULL;
393550806d53Smrg
3936af1a9c97Smrg  if (lt_split_name_value (arg, &name, &value) != 0)
3937af1a9c97Smrg    {
3938af1a9c97Smrg      XFREE (name);
3939af1a9c97Smrg      XFREE (value);
3940af1a9c97Smrg      lt_fatal ("bad argument for %s: '%s'", env_set_opt, arg);
3941af1a9c97Smrg    }
394250806d53Smrg
3943af1a9c97Smrg  lt_setenv (name, value);
3944af1a9c97Smrg  XFREE (name);
3945af1a9c97Smrg  XFREE (value);
3946af1a9c97Smrg}
394750806d53Smrg
3948af1a9c97Smrgvoid
3949af1a9c97Smrglt_opt_process_env_prepend (const char *arg)
3950af1a9c97Smrg{
3951af1a9c97Smrg  char *name = NULL;
3952af1a9c97Smrg  char *value = NULL;
3953af1a9c97Smrg  char *new_value = NULL;
395450806d53Smrg
3955af1a9c97Smrg  if (lt_split_name_value (arg, &name, &value) != 0)
3956af1a9c97Smrg    {
3957af1a9c97Smrg      XFREE (name);
3958af1a9c97Smrg      XFREE (value);
3959af1a9c97Smrg      lt_fatal ("bad argument for %s: '%s'", env_prepend_opt, arg);
3960af1a9c97Smrg    }
396150806d53Smrg
3962af1a9c97Smrg  new_value = lt_extend_str (getenv (name), value, 0);
3963af1a9c97Smrg  lt_setenv (name, new_value);
3964af1a9c97Smrg  XFREE (new_value);
3965af1a9c97Smrg  XFREE (name);
3966af1a9c97Smrg  XFREE (value);
3967af1a9c97Smrg}
396850806d53Smrg
3969af1a9c97Smrgvoid
3970af1a9c97Smrglt_opt_process_env_append (const char *arg)
3971af1a9c97Smrg{
3972af1a9c97Smrg  char *name = NULL;
3973af1a9c97Smrg  char *value = NULL;
3974af1a9c97Smrg  char *new_value = NULL;
397550806d53Smrg
3976af1a9c97Smrg  if (lt_split_name_value (arg, &name, &value) != 0)
3977af1a9c97Smrg    {
3978af1a9c97Smrg      XFREE (name);
3979af1a9c97Smrg      XFREE (value);
3980af1a9c97Smrg      lt_fatal ("bad argument for %s: '%s'", env_append_opt, arg);
3981af1a9c97Smrg    }
398250806d53Smrg
3983af1a9c97Smrg  new_value = lt_extend_str (getenv (name), value, 1);
3984af1a9c97Smrg  lt_setenv (name, new_value);
3985af1a9c97Smrg  XFREE (new_value);
3986af1a9c97Smrg  XFREE (name);
3987af1a9c97Smrg  XFREE (value);
3988af1a9c97Smrg}
398950806d53Smrg
3990af1a9c97Smrgvoid
3991af1a9c97Smrglt_update_exe_path (const char *name, const char *value)
3992af1a9c97Smrg{
3993af1a9c97Smrg  LTWRAPPER_DEBUGPRINTF (("(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
3994af1a9c97Smrg                          (name ? name : "<NULL>"),
3995af1a9c97Smrg                          (value ? value : "<NULL>")));
399650806d53Smrg
3997af1a9c97Smrg  if (name && *name && value && *value)
3998af1a9c97Smrg    {
3999af1a9c97Smrg      char *new_value = lt_extend_str (getenv (name), value, 0);
4000af1a9c97Smrg      /* some systems can't cope with a ':'-terminated path #' */
4001af1a9c97Smrg      int len = strlen (new_value);
4002af1a9c97Smrg      while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
4003af1a9c97Smrg        {
4004af1a9c97Smrg          new_value[len-1] = '\0';
4005af1a9c97Smrg        }
4006af1a9c97Smrg      lt_setenv (name, new_value);
4007af1a9c97Smrg      XFREE (new_value);
4008af1a9c97Smrg    }
4009af1a9c97Smrg}
401050806d53Smrg
4011af1a9c97Smrgvoid
4012af1a9c97Smrglt_update_lib_path (const char *name, const char *value)
4013af1a9c97Smrg{
4014af1a9c97Smrg  LTWRAPPER_DEBUGPRINTF (("(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
4015af1a9c97Smrg                          (name ? name : "<NULL>"),
4016af1a9c97Smrg                          (value ? value : "<NULL>")));
401750806d53Smrg
4018af1a9c97Smrg  if (name && *name && value && *value)
4019af1a9c97Smrg    {
4020af1a9c97Smrg      char *new_value = lt_extend_str (getenv (name), value, 0);
4021af1a9c97Smrg      lt_setenv (name, new_value);
4022af1a9c97Smrg      XFREE (new_value);
4023af1a9c97Smrg    }
4024af1a9c97Smrg}
402550806d53Smrg
402650806d53Smrg
4027af1a9c97SmrgEOF
4028af1a9c97Smrg}
4029af1a9c97Smrg# end: func_emit_cwrapperexe_src
403050806d53Smrg
4031af1a9c97Smrg# func_mode_link arg...
4032af1a9c97Smrgfunc_mode_link ()
4033af1a9c97Smrg{
4034af1a9c97Smrg    $opt_debug
4035af1a9c97Smrg    case $host in
4036af1a9c97Smrg    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
4037af1a9c97Smrg      # It is impossible to link a dll without this setting, and
4038af1a9c97Smrg      # we shouldn't force the makefile maintainer to figure out
4039af1a9c97Smrg      # which system we are compiling for in order to pass an extra
4040af1a9c97Smrg      # flag for every libtool invocation.
4041af1a9c97Smrg      # allow_undefined=no
404250806d53Smrg
4043af1a9c97Smrg      # FIXME: Unfortunately, there are problems with the above when trying
4044af1a9c97Smrg      # to make a dll which has undefined symbols, in which case not
4045af1a9c97Smrg      # even a static library is built.  For now, we need to specify
4046af1a9c97Smrg      # -no-undefined on the libtool link line when we can be certain
4047af1a9c97Smrg      # that all symbols are satisfied, otherwise we get a static library.
4048af1a9c97Smrg      allow_undefined=yes
4049af1a9c97Smrg      ;;
4050af1a9c97Smrg    *)
4051af1a9c97Smrg      allow_undefined=yes
4052af1a9c97Smrg      ;;
4053af1a9c97Smrg    esac
4054af1a9c97Smrg    libtool_args=$nonopt
4055af1a9c97Smrg    base_compile="$nonopt $@"
4056af1a9c97Smrg    compile_command=$nonopt
4057af1a9c97Smrg    finalize_command=$nonopt
405850806d53Smrg
4059af1a9c97Smrg    compile_rpath=
4060af1a9c97Smrg    finalize_rpath=
4061af1a9c97Smrg    compile_shlibpath=
4062af1a9c97Smrg    finalize_shlibpath=
4063af1a9c97Smrg    convenience=
4064af1a9c97Smrg    old_convenience=
4065af1a9c97Smrg    deplibs=
4066af1a9c97Smrg    old_deplibs=
4067af1a9c97Smrg    compiler_flags=
4068af1a9c97Smrg    linker_flags=
4069af1a9c97Smrg    dllsearchpath=
4070af1a9c97Smrg    lib_search_path=`pwd`
4071af1a9c97Smrg    inst_prefix_dir=
4072af1a9c97Smrg    new_inherited_linker_flags=
407350806d53Smrg
4074af1a9c97Smrg    avoid_version=no
4075af1a9c97Smrg    dlfiles=
4076af1a9c97Smrg    dlprefiles=
4077af1a9c97Smrg    dlself=no
4078af1a9c97Smrg    export_dynamic=no
4079af1a9c97Smrg    export_symbols=
4080af1a9c97Smrg    export_symbols_regex=
4081af1a9c97Smrg    generated=
4082af1a9c97Smrg    libobjs=
4083af1a9c97Smrg    ltlibs=
4084af1a9c97Smrg    module=no
4085af1a9c97Smrg    no_install=no
4086af1a9c97Smrg    objs=
4087af1a9c97Smrg    non_pic_objects=
4088af1a9c97Smrg    precious_files_regex=
4089af1a9c97Smrg    prefer_static_libs=no
4090af1a9c97Smrg    preload=no
4091af1a9c97Smrg    prev=
4092af1a9c97Smrg    prevarg=
4093af1a9c97Smrg    release=
4094af1a9c97Smrg    rpath=
4095af1a9c97Smrg    xrpath=
4096af1a9c97Smrg    perm_rpath=
4097af1a9c97Smrg    temp_rpath=
4098af1a9c97Smrg    thread_safe=no
4099af1a9c97Smrg    vinfo=
4100af1a9c97Smrg    vinfo_number=no
4101af1a9c97Smrg    weak_libs=
4102af1a9c97Smrg    single_module="${wl}-single_module"
4103af1a9c97Smrg    func_infer_tag $base_compile
410450806d53Smrg
4105af1a9c97Smrg    # We need to know -static, to get the right output filenames.
4106af1a9c97Smrg    for arg
4107af1a9c97Smrg    do
4108af1a9c97Smrg      case $arg in
4109af1a9c97Smrg      -shared)
4110af1a9c97Smrg	test "$build_libtool_libs" != yes && \
4111af1a9c97Smrg	  func_fatal_configuration "can not build a shared library"
4112af1a9c97Smrg	build_old_libs=no
4113af1a9c97Smrg	break
4114af1a9c97Smrg	;;
4115af1a9c97Smrg      -all-static | -static | -static-libtool-libs)
4116af1a9c97Smrg	case $arg in
4117af1a9c97Smrg	-all-static)
4118af1a9c97Smrg	  if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
4119af1a9c97Smrg	    func_warning "complete static linking is impossible in this configuration"
4120af1a9c97Smrg	  fi
4121af1a9c97Smrg	  if test -n "$link_static_flag"; then
4122af1a9c97Smrg	    dlopen_self=$dlopen_self_static
4123af1a9c97Smrg	  fi
4124af1a9c97Smrg	  prefer_static_libs=yes
4125af1a9c97Smrg	  ;;
4126af1a9c97Smrg	-static)
4127af1a9c97Smrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
4128af1a9c97Smrg	    dlopen_self=$dlopen_self_static
4129af1a9c97Smrg	  fi
4130af1a9c97Smrg	  prefer_static_libs=built
4131af1a9c97Smrg	  ;;
4132af1a9c97Smrg	-static-libtool-libs)
4133af1a9c97Smrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
4134af1a9c97Smrg	    dlopen_self=$dlopen_self_static
4135af1a9c97Smrg	  fi
4136af1a9c97Smrg	  prefer_static_libs=yes
4137af1a9c97Smrg	  ;;
4138af1a9c97Smrg	esac
4139af1a9c97Smrg	build_libtool_libs=no
4140af1a9c97Smrg	build_old_libs=yes
4141af1a9c97Smrg	break
4142af1a9c97Smrg	;;
4143af1a9c97Smrg      esac
4144af1a9c97Smrg    done
414550806d53Smrg
4146af1a9c97Smrg    # See if our shared archives depend on static archives.
4147af1a9c97Smrg    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
414850806d53Smrg
4149af1a9c97Smrg    # Go through the arguments, transforming them on the way.
4150af1a9c97Smrg    while test "$#" -gt 0; do
4151af1a9c97Smrg      arg="$1"
4152af1a9c97Smrg      shift
4153af1a9c97Smrg      func_quote_for_eval "$arg"
4154af1a9c97Smrg      qarg=$func_quote_for_eval_unquoted_result
4155af1a9c97Smrg      func_append libtool_args " $func_quote_for_eval_result"
415650806d53Smrg
4157af1a9c97Smrg      # If the previous option needs an argument, assign it.
4158af1a9c97Smrg      if test -n "$prev"; then
4159af1a9c97Smrg	case $prev in
4160af1a9c97Smrg	output)
4161af1a9c97Smrg	  func_append compile_command " @OUTPUT@"
4162af1a9c97Smrg	  func_append finalize_command " @OUTPUT@"
4163af1a9c97Smrg	  ;;
4164af1a9c97Smrg	esac
416550806d53Smrg
4166af1a9c97Smrg	case $prev in
4167af1a9c97Smrg	dlfiles|dlprefiles)
4168af1a9c97Smrg	  if test "$preload" = no; then
4169af1a9c97Smrg	    # Add the symbol object into the linking commands.
4170af1a9c97Smrg	    func_append compile_command " @SYMFILE@"
4171af1a9c97Smrg	    func_append finalize_command " @SYMFILE@"
4172af1a9c97Smrg	    preload=yes
417350806d53Smrg	  fi
4174af1a9c97Smrg	  case $arg in
4175af1a9c97Smrg	  *.la | *.lo) ;;  # We handle these cases below.
4176af1a9c97Smrg	  force)
4177af1a9c97Smrg	    if test "$dlself" = no; then
4178af1a9c97Smrg	      dlself=needless
4179af1a9c97Smrg	      export_dynamic=yes
4180af1a9c97Smrg	    fi
4181af1a9c97Smrg	    prev=
4182af1a9c97Smrg	    continue
4183af1a9c97Smrg	    ;;
4184af1a9c97Smrg	  self)
4185af1a9c97Smrg	    if test "$prev" = dlprefiles; then
4186af1a9c97Smrg	      dlself=yes
4187af1a9c97Smrg	    elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
4188af1a9c97Smrg	      dlself=yes
4189af1a9c97Smrg	    else
4190af1a9c97Smrg	      dlself=needless
4191af1a9c97Smrg	      export_dynamic=yes
4192af1a9c97Smrg	    fi
4193af1a9c97Smrg	    prev=
4194af1a9c97Smrg	    continue
4195af1a9c97Smrg	    ;;
4196af1a9c97Smrg	  *)
4197af1a9c97Smrg	    if test "$prev" = dlfiles; then
4198af1a9c97Smrg	      dlfiles="$dlfiles $arg"
4199af1a9c97Smrg	    else
4200af1a9c97Smrg	      dlprefiles="$dlprefiles $arg"
4201af1a9c97Smrg	    fi
4202af1a9c97Smrg	    prev=
4203af1a9c97Smrg	    continue
4204af1a9c97Smrg	    ;;
4205af1a9c97Smrg	  esac
4206af1a9c97Smrg	  ;;
4207af1a9c97Smrg	expsyms)
4208af1a9c97Smrg	  export_symbols="$arg"
4209af1a9c97Smrg	  test -f "$arg" \
4210af1a9c97Smrg	    || func_fatal_error "symbol file \`$arg' does not exist"
4211af1a9c97Smrg	  prev=
4212af1a9c97Smrg	  continue
4213af1a9c97Smrg	  ;;
4214af1a9c97Smrg	expsyms_regex)
4215af1a9c97Smrg	  export_symbols_regex="$arg"
4216af1a9c97Smrg	  prev=
4217af1a9c97Smrg	  continue
4218af1a9c97Smrg	  ;;
4219af1a9c97Smrg	framework)
422050806d53Smrg	  case $host in
4221af1a9c97Smrg	    *-*-darwin*)
4222af1a9c97Smrg	      case "$deplibs " in
4223af1a9c97Smrg		*" $qarg.ltframework "*) ;;
4224af1a9c97Smrg		*) deplibs="$deplibs $qarg.ltframework" # this is fixed later
4225af1a9c97Smrg		   ;;
4226af1a9c97Smrg	      esac
4227af1a9c97Smrg	      ;;
422850806d53Smrg	  esac
4229af1a9c97Smrg	  prev=
4230af1a9c97Smrg	  continue
423150806d53Smrg	  ;;
4232af1a9c97Smrg	inst_prefix)
4233af1a9c97Smrg	  inst_prefix_dir="$arg"
4234af1a9c97Smrg	  prev=
4235af1a9c97Smrg	  continue
423650806d53Smrg	  ;;
4237af1a9c97Smrg	objectlist)
4238af1a9c97Smrg	  if test -f "$arg"; then
4239af1a9c97Smrg	    save_arg=$arg
4240af1a9c97Smrg	    moreargs=
4241af1a9c97Smrg	    for fil in `cat "$save_arg"`
4242af1a9c97Smrg	    do
4243af1a9c97Smrg#	      moreargs="$moreargs $fil"
4244af1a9c97Smrg	      arg=$fil
4245af1a9c97Smrg	      # A libtool-controlled object.
424650806d53Smrg
4247af1a9c97Smrg	      # Check to see that this really is a libtool object.
4248af1a9c97Smrg	      if func_lalib_unsafe_p "$arg"; then
4249af1a9c97Smrg		pic_object=
4250af1a9c97Smrg		non_pic_object=
425150806d53Smrg
4252af1a9c97Smrg		# Read the .lo file
4253af1a9c97Smrg		func_source "$arg"
425450806d53Smrg
4255af1a9c97Smrg		if test -z "$pic_object" ||
4256af1a9c97Smrg		   test -z "$non_pic_object" ||
4257af1a9c97Smrg		   test "$pic_object" = none &&
4258af1a9c97Smrg		   test "$non_pic_object" = none; then
4259af1a9c97Smrg		  func_fatal_error "cannot find name of object for \`$arg'"
4260af1a9c97Smrg		fi
426150806d53Smrg
4262af1a9c97Smrg		# Extract subdirectory from the argument.
4263af1a9c97Smrg		func_dirname "$arg" "/" ""
4264af1a9c97Smrg		xdir="$func_dirname_result"
426550806d53Smrg
4266af1a9c97Smrg		if test "$pic_object" != none; then
4267af1a9c97Smrg		  # Prepend the subdirectory the object is found in.
4268af1a9c97Smrg		  pic_object="$xdir$pic_object"
426950806d53Smrg
4270af1a9c97Smrg		  if test "$prev" = dlfiles; then
4271af1a9c97Smrg		    if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
4272af1a9c97Smrg		      dlfiles="$dlfiles $pic_object"
4273af1a9c97Smrg		      prev=
4274af1a9c97Smrg		      continue
4275af1a9c97Smrg		    else
4276af1a9c97Smrg		      # If libtool objects are unsupported, then we need to preload.
4277af1a9c97Smrg		      prev=dlprefiles
4278af1a9c97Smrg		    fi
4279af1a9c97Smrg		  fi
428050806d53Smrg
4281af1a9c97Smrg		  # CHECK ME:  I think I busted this.  -Ossama
4282af1a9c97Smrg		  if test "$prev" = dlprefiles; then
4283af1a9c97Smrg		    # Preload the old-style object.
4284af1a9c97Smrg		    dlprefiles="$dlprefiles $pic_object"
4285af1a9c97Smrg		    prev=
4286af1a9c97Smrg		  fi
428750806d53Smrg
4288af1a9c97Smrg		  # A PIC object.
4289af1a9c97Smrg		  func_append libobjs " $pic_object"
4290af1a9c97Smrg		  arg="$pic_object"
4291af1a9c97Smrg		fi
429250806d53Smrg
4293af1a9c97Smrg		# Non-PIC object.
4294af1a9c97Smrg		if test "$non_pic_object" != none; then
4295af1a9c97Smrg		  # Prepend the subdirectory the object is found in.
4296af1a9c97Smrg		  non_pic_object="$xdir$non_pic_object"
4297af1a9c97Smrg
4298af1a9c97Smrg		  # A standard non-PIC object
4299af1a9c97Smrg		  func_append non_pic_objects " $non_pic_object"
4300af1a9c97Smrg		  if test -z "$pic_object" || test "$pic_object" = none ; then
4301af1a9c97Smrg		    arg="$non_pic_object"
4302af1a9c97Smrg		  fi
4303af1a9c97Smrg		else
4304af1a9c97Smrg		  # If the PIC object exists, use it instead.
4305af1a9c97Smrg		  # $xdir was prepended to $pic_object above.
4306af1a9c97Smrg		  non_pic_object="$pic_object"
4307af1a9c97Smrg		  func_append non_pic_objects " $non_pic_object"
4308af1a9c97Smrg		fi
4309af1a9c97Smrg	      else
4310af1a9c97Smrg		# Only an error if not doing a dry-run.
4311af1a9c97Smrg		if $opt_dry_run; then
4312af1a9c97Smrg		  # Extract subdirectory from the argument.
4313af1a9c97Smrg		  func_dirname "$arg" "/" ""
4314af1a9c97Smrg		  xdir="$func_dirname_result"
4315af1a9c97Smrg
4316af1a9c97Smrg		  func_lo2o "$arg"
4317af1a9c97Smrg		  pic_object=$xdir$objdir/$func_lo2o_result
4318af1a9c97Smrg		  non_pic_object=$xdir$func_lo2o_result
4319af1a9c97Smrg		  func_append libobjs " $pic_object"
4320af1a9c97Smrg		  func_append non_pic_objects " $non_pic_object"
4321af1a9c97Smrg	        else
4322af1a9c97Smrg		  func_fatal_error "\`$arg' is not a valid libtool object"
4323af1a9c97Smrg		fi
4324af1a9c97Smrg	      fi
4325af1a9c97Smrg	    done
432650806d53Smrg	  else
4327af1a9c97Smrg	    func_fatal_error "link input file \`$arg' does not exist"
432850806d53Smrg	  fi
4329af1a9c97Smrg	  arg=$save_arg
4330af1a9c97Smrg	  prev=
4331af1a9c97Smrg	  continue
4332af1a9c97Smrg	  ;;
4333af1a9c97Smrg	precious_regex)
4334af1a9c97Smrg	  precious_files_regex="$arg"
4335af1a9c97Smrg	  prev=
4336af1a9c97Smrg	  continue
4337af1a9c97Smrg	  ;;
4338af1a9c97Smrg	release)
4339af1a9c97Smrg	  release="-$arg"
4340af1a9c97Smrg	  prev=
4341af1a9c97Smrg	  continue
4342af1a9c97Smrg	  ;;
4343af1a9c97Smrg	rpath | xrpath)
4344af1a9c97Smrg	  # We need an absolute path.
4345af1a9c97Smrg	  case $arg in
4346af1a9c97Smrg	  [\\/]* | [A-Za-z]:[\\/]*) ;;
4347af1a9c97Smrg	  *)
4348af1a9c97Smrg	    func_fatal_error "only absolute run-paths are allowed"
4349af1a9c97Smrg	    ;;
4350af1a9c97Smrg	  esac
4351af1a9c97Smrg	  if test "$prev" = rpath; then
4352af1a9c97Smrg	    case "$rpath " in
4353af1a9c97Smrg	    *" $arg "*) ;;
4354af1a9c97Smrg	    *) rpath="$rpath $arg" ;;
4355af1a9c97Smrg	    esac
435650806d53Smrg	  else
4357af1a9c97Smrg	    case "$xrpath " in
4358af1a9c97Smrg	    *" $arg "*) ;;
4359af1a9c97Smrg	    *) xrpath="$xrpath $arg" ;;
4360af1a9c97Smrg	    esac
436150806d53Smrg	  fi
4362af1a9c97Smrg	  prev=
4363af1a9c97Smrg	  continue
4364af1a9c97Smrg	  ;;
4365af1a9c97Smrg	shrext)
4366af1a9c97Smrg	  shrext_cmds="$arg"
4367af1a9c97Smrg	  prev=
4368af1a9c97Smrg	  continue
4369af1a9c97Smrg	  ;;
4370af1a9c97Smrg	weak)
4371af1a9c97Smrg	  weak_libs="$weak_libs $arg"
4372af1a9c97Smrg	  prev=
4373af1a9c97Smrg	  continue
4374af1a9c97Smrg	  ;;
4375af1a9c97Smrg	xcclinker)
4376af1a9c97Smrg	  linker_flags="$linker_flags $qarg"
4377af1a9c97Smrg	  compiler_flags="$compiler_flags $qarg"
4378af1a9c97Smrg	  prev=
4379af1a9c97Smrg	  func_append compile_command " $qarg"
4380af1a9c97Smrg	  func_append finalize_command " $qarg"
4381af1a9c97Smrg	  continue
4382af1a9c97Smrg	  ;;
4383af1a9c97Smrg	xcompiler)
4384af1a9c97Smrg	  compiler_flags="$compiler_flags $qarg"
4385af1a9c97Smrg	  prev=
4386af1a9c97Smrg	  func_append compile_command " $qarg"
4387af1a9c97Smrg	  func_append finalize_command " $qarg"
4388af1a9c97Smrg	  continue
4389af1a9c97Smrg	  ;;
4390af1a9c97Smrg	xlinker)
4391af1a9c97Smrg	  linker_flags="$linker_flags $qarg"
4392af1a9c97Smrg	  compiler_flags="$compiler_flags $wl$qarg"
4393af1a9c97Smrg	  prev=
4394af1a9c97Smrg	  func_append compile_command " $wl$qarg"
4395af1a9c97Smrg	  func_append finalize_command " $wl$qarg"
4396af1a9c97Smrg	  continue
4397af1a9c97Smrg	  ;;
4398af1a9c97Smrg	*)
4399af1a9c97Smrg	  eval "$prev=\"\$arg\""
4400af1a9c97Smrg	  prev=
4401af1a9c97Smrg	  continue
4402af1a9c97Smrg	  ;;
440350806d53Smrg	esac
4404af1a9c97Smrg      fi # test -n "$prev"
440550806d53Smrg
4406af1a9c97Smrg      prevarg="$arg"
440750806d53Smrg
4408af1a9c97Smrg      case $arg in
4409af1a9c97Smrg      -all-static)
4410af1a9c97Smrg	if test -n "$link_static_flag"; then
4411af1a9c97Smrg	  # See comment for -static flag below, for more details.
4412af1a9c97Smrg	  func_append compile_command " $link_static_flag"
4413af1a9c97Smrg	  func_append finalize_command " $link_static_flag"
4414af1a9c97Smrg	fi
4415af1a9c97Smrg	continue
4416af1a9c97Smrg	;;
441750806d53Smrg
4418af1a9c97Smrg      -allow-undefined)
4419af1a9c97Smrg	# FIXME: remove this flag sometime in the future.
4420af1a9c97Smrg	func_fatal_error "\`-allow-undefined' must not be used because it is the default"
4421af1a9c97Smrg	;;
442250806d53Smrg
4423af1a9c97Smrg      -avoid-version)
4424af1a9c97Smrg	avoid_version=yes
4425af1a9c97Smrg	continue
4426af1a9c97Smrg	;;
442750806d53Smrg
4428af1a9c97Smrg      -dlopen)
4429af1a9c97Smrg	prev=dlfiles
4430af1a9c97Smrg	continue
4431af1a9c97Smrg	;;
443250806d53Smrg
4433af1a9c97Smrg      -dlpreopen)
4434af1a9c97Smrg	prev=dlprefiles
4435af1a9c97Smrg	continue
4436af1a9c97Smrg	;;
443750806d53Smrg
4438af1a9c97Smrg      -export-dynamic)
4439af1a9c97Smrg	export_dynamic=yes
4440af1a9c97Smrg	continue
4441af1a9c97Smrg	;;
444250806d53Smrg
4443af1a9c97Smrg      -export-symbols | -export-symbols-regex)
4444af1a9c97Smrg	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
4445af1a9c97Smrg	  func_fatal_error "more than one -exported-symbols argument is not allowed"
4446af1a9c97Smrg	fi
4447af1a9c97Smrg	if test "X$arg" = "X-export-symbols"; then
4448af1a9c97Smrg	  prev=expsyms
4449af1a9c97Smrg	else
4450af1a9c97Smrg	  prev=expsyms_regex
4451af1a9c97Smrg	fi
4452af1a9c97Smrg	continue
4453af1a9c97Smrg	;;
445450806d53Smrg
4455af1a9c97Smrg      -framework)
4456af1a9c97Smrg	prev=framework
4457af1a9c97Smrg	continue
4458af1a9c97Smrg	;;
445950806d53Smrg
4460af1a9c97Smrg      -inst-prefix-dir)
4461af1a9c97Smrg	prev=inst_prefix
4462af1a9c97Smrg	continue
4463af1a9c97Smrg	;;
446450806d53Smrg
4465af1a9c97Smrg      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
4466af1a9c97Smrg      # so, if we see these flags be careful not to treat them like -L
4467af1a9c97Smrg      -L[A-Z][A-Z]*:*)
4468af1a9c97Smrg	case $with_gcc/$host in
4469af1a9c97Smrg	no/*-*-irix* | /*-*-irix*)
4470af1a9c97Smrg	  func_append compile_command " $arg"
4471af1a9c97Smrg	  func_append finalize_command " $arg"
4472af1a9c97Smrg	  ;;
4473af1a9c97Smrg	esac
4474af1a9c97Smrg	continue
4475af1a9c97Smrg	;;
447650806d53Smrg
4477af1a9c97Smrg      -L*)
4478af1a9c97Smrg	func_stripname '-L' '' "$arg"
4479af1a9c97Smrg	dir=$func_stripname_result
4480af1a9c97Smrg	if test -z "$dir"; then
4481af1a9c97Smrg	  if test "$#" -gt 0; then
4482af1a9c97Smrg	    func_fatal_error "require no space between \`-L' and \`$1'"
4483af1a9c97Smrg	  else
4484af1a9c97Smrg	    func_fatal_error "need path for \`-L' option"
4485af1a9c97Smrg	  fi
4486af1a9c97Smrg	fi
4487af1a9c97Smrg	# We need an absolute path.
4488af1a9c97Smrg	case $dir in
4489af1a9c97Smrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
4490af1a9c97Smrg	*)
4491af1a9c97Smrg	  absdir=`cd "$dir" && pwd`
4492af1a9c97Smrg	  test -z "$absdir" && \
4493af1a9c97Smrg	    func_fatal_error "cannot determine absolute directory name of \`$dir'"
4494af1a9c97Smrg	  dir="$absdir"
4495af1a9c97Smrg	  ;;
4496af1a9c97Smrg	esac
4497af1a9c97Smrg	case "$deplibs " in
4498af1a9c97Smrg	*" -L$dir "*) ;;
4499af1a9c97Smrg	*)
4500af1a9c97Smrg	  deplibs="$deplibs -L$dir"
4501af1a9c97Smrg	  lib_search_path="$lib_search_path $dir"
4502af1a9c97Smrg	  ;;
4503af1a9c97Smrg	esac
4504af1a9c97Smrg	case $host in
4505af1a9c97Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
4506af1a9c97Smrg	  testbindir=`$ECHO "X$dir" | $Xsed -e 's*/lib$*/bin*'`
4507af1a9c97Smrg	  case :$dllsearchpath: in
4508af1a9c97Smrg	  *":$dir:"*) ;;
4509af1a9c97Smrg	  ::) dllsearchpath=$dir;;
4510af1a9c97Smrg	  *) dllsearchpath="$dllsearchpath:$dir";;
4511af1a9c97Smrg	  esac
4512af1a9c97Smrg	  case :$dllsearchpath: in
4513af1a9c97Smrg	  *":$testbindir:"*) ;;
4514af1a9c97Smrg	  ::) dllsearchpath=$testbindir;;
4515af1a9c97Smrg	  *) dllsearchpath="$dllsearchpath:$testbindir";;
4516af1a9c97Smrg	  esac
4517af1a9c97Smrg	  ;;
4518af1a9c97Smrg	esac
4519af1a9c97Smrg	continue
4520af1a9c97Smrg	;;
452150806d53Smrg
4522af1a9c97Smrg      -l*)
4523af1a9c97Smrg	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
4524af1a9c97Smrg	  case $host in
4525af1a9c97Smrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc*)
4526af1a9c97Smrg	    # These systems don't actually have a C or math library (as such)
4527af1a9c97Smrg	    continue
4528af1a9c97Smrg	    ;;
4529af1a9c97Smrg	  *-*-os2*)
4530af1a9c97Smrg	    # These systems don't actually have a C library (as such)
4531af1a9c97Smrg	    test "X$arg" = "X-lc" && continue
4532af1a9c97Smrg	    ;;
4533af1a9c97Smrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
4534af1a9c97Smrg	    # Do not include libc due to us having libc/libc_r.
4535af1a9c97Smrg	    test "X$arg" = "X-lc" && continue
4536af1a9c97Smrg	    ;;
4537af1a9c97Smrg	  *-*-rhapsody* | *-*-darwin1.[012])
4538af1a9c97Smrg	    # Rhapsody C and math libraries are in the System framework
4539af1a9c97Smrg	    deplibs="$deplibs System.ltframework"
4540af1a9c97Smrg	    continue
4541af1a9c97Smrg	    ;;
4542af1a9c97Smrg	  *-*-sco3.2v5* | *-*-sco5v6*)
4543af1a9c97Smrg	    # Causes problems with __ctype
4544af1a9c97Smrg	    test "X$arg" = "X-lc" && continue
4545af1a9c97Smrg	    ;;
4546af1a9c97Smrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
4547af1a9c97Smrg	    # Compiler inserts libc in the correct place for threads to work
4548af1a9c97Smrg	    test "X$arg" = "X-lc" && continue
4549af1a9c97Smrg	    ;;
4550af1a9c97Smrg	  esac
4551af1a9c97Smrg	elif test "X$arg" = "X-lc_r"; then
4552af1a9c97Smrg	 case $host in
4553af1a9c97Smrg	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
4554af1a9c97Smrg	   # Do not include libc_r directly, use -pthread flag.
4555af1a9c97Smrg	   continue
4556af1a9c97Smrg	   ;;
4557af1a9c97Smrg	 esac
4558af1a9c97Smrg	fi
4559af1a9c97Smrg	deplibs="$deplibs $arg"
4560af1a9c97Smrg	continue
4561af1a9c97Smrg	;;
456250806d53Smrg
4563af1a9c97Smrg      -module)
4564af1a9c97Smrg	module=yes
4565af1a9c97Smrg	continue
4566af1a9c97Smrg	;;
456750806d53Smrg
4568af1a9c97Smrg      # Tru64 UNIX uses -model [arg] to determine the layout of C++
4569af1a9c97Smrg      # classes, name mangling, and exception handling.
4570af1a9c97Smrg      # Darwin uses the -arch flag to determine output architecture.
4571af1a9c97Smrg      -model|-arch|-isysroot)
4572af1a9c97Smrg	compiler_flags="$compiler_flags $arg"
4573af1a9c97Smrg	func_append compile_command " $arg"
4574af1a9c97Smrg	func_append finalize_command " $arg"
4575af1a9c97Smrg	prev=xcompiler
4576af1a9c97Smrg	continue
4577af1a9c97Smrg	;;
457850806d53Smrg
4579af1a9c97Smrg      -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
4580af1a9c97Smrg	compiler_flags="$compiler_flags $arg"
4581af1a9c97Smrg	func_append compile_command " $arg"
4582af1a9c97Smrg	func_append finalize_command " $arg"
4583af1a9c97Smrg	case "$new_inherited_linker_flags " in
4584af1a9c97Smrg	    *" $arg "*) ;;
4585af1a9c97Smrg	    * ) new_inherited_linker_flags="$new_inherited_linker_flags $arg" ;;
4586af1a9c97Smrg	esac
4587af1a9c97Smrg	continue
4588af1a9c97Smrg	;;
458950806d53Smrg
4590af1a9c97Smrg      -multi_module)
4591af1a9c97Smrg	single_module="${wl}-multi_module"
4592af1a9c97Smrg	continue
4593af1a9c97Smrg	;;
459450806d53Smrg
4595af1a9c97Smrg      -no-fast-install)
4596af1a9c97Smrg	fast_install=no
4597af1a9c97Smrg	continue
4598af1a9c97Smrg	;;
459950806d53Smrg
4600af1a9c97Smrg      -no-install)
4601af1a9c97Smrg	case $host in
4602af1a9c97Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
4603af1a9c97Smrg	  # The PATH hackery in wrapper scripts is required on Windows
4604af1a9c97Smrg	  # and Darwin in order for the loader to find any dlls it needs.
4605af1a9c97Smrg	  func_warning "\`-no-install' is ignored for $host"
4606af1a9c97Smrg	  func_warning "assuming \`-no-fast-install' instead"
4607af1a9c97Smrg	  fast_install=no
4608af1a9c97Smrg	  ;;
4609af1a9c97Smrg	*) no_install=yes ;;
4610af1a9c97Smrg	esac
4611af1a9c97Smrg	continue
4612af1a9c97Smrg	;;
461350806d53Smrg
4614af1a9c97Smrg      -no-undefined)
4615af1a9c97Smrg	allow_undefined=no
4616af1a9c97Smrg	continue
4617af1a9c97Smrg	;;
461850806d53Smrg
4619af1a9c97Smrg      -objectlist)
4620af1a9c97Smrg	prev=objectlist
4621af1a9c97Smrg	continue
4622af1a9c97Smrg	;;
462350806d53Smrg
4624af1a9c97Smrg      -o) prev=output ;;
462550806d53Smrg
4626af1a9c97Smrg      -precious-files-regex)
4627af1a9c97Smrg	prev=precious_regex
4628af1a9c97Smrg	continue
4629af1a9c97Smrg	;;
463050806d53Smrg
4631af1a9c97Smrg      -release)
4632af1a9c97Smrg	prev=release
4633af1a9c97Smrg	continue
4634af1a9c97Smrg	;;
463550806d53Smrg
4636af1a9c97Smrg      -rpath)
4637af1a9c97Smrg	prev=rpath
4638af1a9c97Smrg	continue
4639af1a9c97Smrg	;;
464050806d53Smrg
4641af1a9c97Smrg      -R)
4642af1a9c97Smrg	prev=xrpath
4643af1a9c97Smrg	continue
4644af1a9c97Smrg	;;
464550806d53Smrg
4646af1a9c97Smrg      -R*)
4647af1a9c97Smrg	func_stripname '-R' '' "$arg"
4648af1a9c97Smrg	dir=$func_stripname_result
4649af1a9c97Smrg	# We need an absolute path.
4650af1a9c97Smrg	case $dir in
4651af1a9c97Smrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
4652af1a9c97Smrg	*)
4653af1a9c97Smrg	  func_fatal_error "only absolute run-paths are allowed"
4654af1a9c97Smrg	  ;;
4655af1a9c97Smrg	esac
4656af1a9c97Smrg	case "$xrpath " in
4657af1a9c97Smrg	*" $dir "*) ;;
4658af1a9c97Smrg	*) xrpath="$xrpath $dir" ;;
4659af1a9c97Smrg	esac
4660af1a9c97Smrg	continue
4661af1a9c97Smrg	;;
466250806d53Smrg
4663af1a9c97Smrg      -shared)
4664af1a9c97Smrg	# The effects of -shared are defined in a previous loop.
4665af1a9c97Smrg	continue
4666af1a9c97Smrg	;;
466750806d53Smrg
4668af1a9c97Smrg      -shrext)
4669af1a9c97Smrg	prev=shrext
4670af1a9c97Smrg	continue
4671af1a9c97Smrg	;;
467250806d53Smrg
4673af1a9c97Smrg      -static | -static-libtool-libs)
4674af1a9c97Smrg	# The effects of -static are defined in a previous loop.
4675af1a9c97Smrg	# We used to do the same as -all-static on platforms that
4676af1a9c97Smrg	# didn't have a PIC flag, but the assumption that the effects
4677af1a9c97Smrg	# would be equivalent was wrong.  It would break on at least
4678af1a9c97Smrg	# Digital Unix and AIX.
4679af1a9c97Smrg	continue
4680af1a9c97Smrg	;;
468150806d53Smrg
4682af1a9c97Smrg      -thread-safe)
4683af1a9c97Smrg	thread_safe=yes
4684af1a9c97Smrg	continue
4685af1a9c97Smrg	;;
468650806d53Smrg
4687af1a9c97Smrg      -version-info)
4688af1a9c97Smrg	prev=vinfo
4689af1a9c97Smrg	continue
4690af1a9c97Smrg	;;
469150806d53Smrg
4692af1a9c97Smrg      -version-number)
4693af1a9c97Smrg	prev=vinfo
4694af1a9c97Smrg	vinfo_number=yes
4695af1a9c97Smrg	continue
4696af1a9c97Smrg	;;
469750806d53Smrg
4698af1a9c97Smrg      -weak)
4699af1a9c97Smrg        prev=weak
4700af1a9c97Smrg	continue
4701af1a9c97Smrg	;;
470250806d53Smrg
4703af1a9c97Smrg      -Wc,*)
4704af1a9c97Smrg	func_stripname '-Wc,' '' "$arg"
4705af1a9c97Smrg	args=$func_stripname_result
4706af1a9c97Smrg	arg=
4707af1a9c97Smrg	save_ifs="$IFS"; IFS=','
4708af1a9c97Smrg	for flag in $args; do
4709af1a9c97Smrg	  IFS="$save_ifs"
4710af1a9c97Smrg          func_quote_for_eval "$flag"
4711af1a9c97Smrg	  arg="$arg $wl$func_quote_for_eval_result"
4712af1a9c97Smrg	  compiler_flags="$compiler_flags $func_quote_for_eval_result"
4713af1a9c97Smrg	done
4714af1a9c97Smrg	IFS="$save_ifs"
4715af1a9c97Smrg	func_stripname ' ' '' "$arg"
4716af1a9c97Smrg	arg=$func_stripname_result
4717af1a9c97Smrg	;;
471850806d53Smrg
4719af1a9c97Smrg      -Wl,*)
4720af1a9c97Smrg	func_stripname '-Wl,' '' "$arg"
4721af1a9c97Smrg	args=$func_stripname_result
4722af1a9c97Smrg	arg=
4723af1a9c97Smrg	save_ifs="$IFS"; IFS=','
4724af1a9c97Smrg	for flag in $args; do
4725af1a9c97Smrg	  IFS="$save_ifs"
4726af1a9c97Smrg          func_quote_for_eval "$flag"
4727af1a9c97Smrg	  arg="$arg $wl$func_quote_for_eval_result"
4728af1a9c97Smrg	  compiler_flags="$compiler_flags $wl$func_quote_for_eval_result"
4729af1a9c97Smrg	  linker_flags="$linker_flags $func_quote_for_eval_result"
4730af1a9c97Smrg	done
4731af1a9c97Smrg	IFS="$save_ifs"
4732af1a9c97Smrg	func_stripname ' ' '' "$arg"
4733af1a9c97Smrg	arg=$func_stripname_result
4734af1a9c97Smrg	;;
473550806d53Smrg
4736af1a9c97Smrg      -Xcompiler)
4737af1a9c97Smrg	prev=xcompiler
4738af1a9c97Smrg	continue
4739af1a9c97Smrg	;;
474050806d53Smrg
4741af1a9c97Smrg      -Xlinker)
4742af1a9c97Smrg	prev=xlinker
4743af1a9c97Smrg	continue
4744af1a9c97Smrg	;;
474550806d53Smrg
4746af1a9c97Smrg      -XCClinker)
4747af1a9c97Smrg	prev=xcclinker
4748af1a9c97Smrg	continue
4749af1a9c97Smrg	;;
475050806d53Smrg
4751af1a9c97Smrg      # -msg_* for osf cc
4752af1a9c97Smrg      -msg_*)
4753af1a9c97Smrg	func_quote_for_eval "$arg"
4754af1a9c97Smrg	arg="$func_quote_for_eval_result"
4755af1a9c97Smrg	;;
475650806d53Smrg
4757af1a9c97Smrg      # -64, -mips[0-9] enable 64-bit mode on the SGI compiler
4758af1a9c97Smrg      # -r[0-9][0-9]* specifies the processor on the SGI compiler
4759af1a9c97Smrg      # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler
4760af1a9c97Smrg      # +DA*, +DD* enable 64-bit mode on the HP compiler
4761af1a9c97Smrg      # -q* pass through compiler args for the IBM compiler
4762af1a9c97Smrg      # -m*, -t[45]*, -txscale* pass through architecture-specific
4763af1a9c97Smrg      # compiler args for GCC
4764af1a9c97Smrg      # -F/path gives path to uninstalled frameworks, gcc on darwin
4765af1a9c97Smrg      # -p, -pg, --coverage, -fprofile-* pass through profiling flag for GCC
4766af1a9c97Smrg      # @file GCC response files
4767af1a9c97Smrg      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
4768af1a9c97Smrg      -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*)
4769af1a9c97Smrg        func_quote_for_eval "$arg"
4770af1a9c97Smrg	arg="$func_quote_for_eval_result"
4771af1a9c97Smrg        func_append compile_command " $arg"
4772af1a9c97Smrg        func_append finalize_command " $arg"
4773af1a9c97Smrg        compiler_flags="$compiler_flags $arg"
4774af1a9c97Smrg        continue
4775af1a9c97Smrg        ;;
477650806d53Smrg
4777af1a9c97Smrg      # Some other compiler flag.
4778af1a9c97Smrg      -* | +*)
4779af1a9c97Smrg        func_quote_for_eval "$arg"
4780af1a9c97Smrg	arg="$func_quote_for_eval_result"
4781af1a9c97Smrg	;;
478250806d53Smrg
4783af1a9c97Smrg      *.$objext)
4784af1a9c97Smrg	# A standard object.
4785af1a9c97Smrg	objs="$objs $arg"
4786af1a9c97Smrg	;;
478750806d53Smrg
4788af1a9c97Smrg      *.lo)
4789af1a9c97Smrg	# A libtool-controlled object.
479050806d53Smrg
4791af1a9c97Smrg	# Check to see that this really is a libtool object.
4792af1a9c97Smrg	if func_lalib_unsafe_p "$arg"; then
4793af1a9c97Smrg	  pic_object=
4794af1a9c97Smrg	  non_pic_object=
479550806d53Smrg
4796af1a9c97Smrg	  # Read the .lo file
4797af1a9c97Smrg	  func_source "$arg"
479850806d53Smrg
4799af1a9c97Smrg	  if test -z "$pic_object" ||
4800af1a9c97Smrg	     test -z "$non_pic_object" ||
4801af1a9c97Smrg	     test "$pic_object" = none &&
4802af1a9c97Smrg	     test "$non_pic_object" = none; then
4803af1a9c97Smrg	    func_fatal_error "cannot find name of object for \`$arg'"
4804af1a9c97Smrg	  fi
480550806d53Smrg
4806af1a9c97Smrg	  # Extract subdirectory from the argument.
4807af1a9c97Smrg	  func_dirname "$arg" "/" ""
4808af1a9c97Smrg	  xdir="$func_dirname_result"
480950806d53Smrg
4810af1a9c97Smrg	  if test "$pic_object" != none; then
4811af1a9c97Smrg	    # Prepend the subdirectory the object is found in.
4812af1a9c97Smrg	    pic_object="$xdir$pic_object"
481350806d53Smrg
4814af1a9c97Smrg	    if test "$prev" = dlfiles; then
4815af1a9c97Smrg	      if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
4816af1a9c97Smrg		dlfiles="$dlfiles $pic_object"
4817af1a9c97Smrg		prev=
4818af1a9c97Smrg		continue
4819af1a9c97Smrg	      else
4820af1a9c97Smrg		# If libtool objects are unsupported, then we need to preload.
4821af1a9c97Smrg		prev=dlprefiles
4822af1a9c97Smrg	      fi
4823af1a9c97Smrg	    fi
482450806d53Smrg
4825af1a9c97Smrg	    # CHECK ME:  I think I busted this.  -Ossama
4826af1a9c97Smrg	    if test "$prev" = dlprefiles; then
4827af1a9c97Smrg	      # Preload the old-style object.
4828af1a9c97Smrg	      dlprefiles="$dlprefiles $pic_object"
4829af1a9c97Smrg	      prev=
4830af1a9c97Smrg	    fi
483150806d53Smrg
4832af1a9c97Smrg	    # A PIC object.
4833af1a9c97Smrg	    func_append libobjs " $pic_object"
4834af1a9c97Smrg	    arg="$pic_object"
4835af1a9c97Smrg	  fi
483650806d53Smrg
4837af1a9c97Smrg	  # Non-PIC object.
4838af1a9c97Smrg	  if test "$non_pic_object" != none; then
4839af1a9c97Smrg	    # Prepend the subdirectory the object is found in.
4840af1a9c97Smrg	    non_pic_object="$xdir$non_pic_object"
484150806d53Smrg
4842af1a9c97Smrg	    # A standard non-PIC object
4843af1a9c97Smrg	    func_append non_pic_objects " $non_pic_object"
4844af1a9c97Smrg	    if test -z "$pic_object" || test "$pic_object" = none ; then
4845af1a9c97Smrg	      arg="$non_pic_object"
4846af1a9c97Smrg	    fi
4847af1a9c97Smrg	  else
4848af1a9c97Smrg	    # If the PIC object exists, use it instead.
4849af1a9c97Smrg	    # $xdir was prepended to $pic_object above.
4850af1a9c97Smrg	    non_pic_object="$pic_object"
4851af1a9c97Smrg	    func_append non_pic_objects " $non_pic_object"
4852af1a9c97Smrg	  fi
4853af1a9c97Smrg	else
4854af1a9c97Smrg	  # Only an error if not doing a dry-run.
4855af1a9c97Smrg	  if $opt_dry_run; then
4856af1a9c97Smrg	    # Extract subdirectory from the argument.
4857af1a9c97Smrg	    func_dirname "$arg" "/" ""
4858af1a9c97Smrg	    xdir="$func_dirname_result"
4859af1a9c97Smrg
4860af1a9c97Smrg	    func_lo2o "$arg"
4861af1a9c97Smrg	    pic_object=$xdir$objdir/$func_lo2o_result
4862af1a9c97Smrg	    non_pic_object=$xdir$func_lo2o_result
4863af1a9c97Smrg	    func_append libobjs " $pic_object"
4864af1a9c97Smrg	    func_append non_pic_objects " $non_pic_object"
4865af1a9c97Smrg	  else
4866af1a9c97Smrg	    func_fatal_error "\`$arg' is not a valid libtool object"
4867af1a9c97Smrg	  fi
4868af1a9c97Smrg	fi
4869af1a9c97Smrg	;;
4870af1a9c97Smrg
4871af1a9c97Smrg      *.$libext)
4872af1a9c97Smrg	# An archive.
4873af1a9c97Smrg	deplibs="$deplibs $arg"
4874af1a9c97Smrg	old_deplibs="$old_deplibs $arg"
4875af1a9c97Smrg	continue
4876af1a9c97Smrg	;;
4877af1a9c97Smrg
4878af1a9c97Smrg      *.la)
4879af1a9c97Smrg	# A libtool-controlled library.
4880af1a9c97Smrg
4881af1a9c97Smrg	if test "$prev" = dlfiles; then
4882af1a9c97Smrg	  # This library was specified with -dlopen.
4883af1a9c97Smrg	  dlfiles="$dlfiles $arg"
4884af1a9c97Smrg	  prev=
4885af1a9c97Smrg	elif test "$prev" = dlprefiles; then
4886af1a9c97Smrg	  # The library was specified with -dlpreopen.
4887af1a9c97Smrg	  dlprefiles="$dlprefiles $arg"
4888af1a9c97Smrg	  prev=
4889af1a9c97Smrg	else
4890af1a9c97Smrg	  deplibs="$deplibs $arg"
4891af1a9c97Smrg	fi
4892af1a9c97Smrg	continue
4893af1a9c97Smrg	;;
4894af1a9c97Smrg
4895af1a9c97Smrg      # Some other compiler argument.
4896af1a9c97Smrg      *)
4897af1a9c97Smrg	# Unknown arguments in both finalize_command and compile_command need
4898af1a9c97Smrg	# to be aesthetically quoted because they are evaled later.
4899af1a9c97Smrg	func_quote_for_eval "$arg"
4900af1a9c97Smrg	arg="$func_quote_for_eval_result"
4901af1a9c97Smrg	;;
4902af1a9c97Smrg      esac # arg
4903af1a9c97Smrg
4904af1a9c97Smrg      # Now actually substitute the argument into the commands.
4905af1a9c97Smrg      if test -n "$arg"; then
4906af1a9c97Smrg	func_append compile_command " $arg"
4907af1a9c97Smrg	func_append finalize_command " $arg"
4908af1a9c97Smrg      fi
4909af1a9c97Smrg    done # argument parsing loop
4910af1a9c97Smrg
4911af1a9c97Smrg    test -n "$prev" && \
4912af1a9c97Smrg      func_fatal_help "the \`$prevarg' option requires an argument"
4913af1a9c97Smrg
4914af1a9c97Smrg    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
4915af1a9c97Smrg      eval arg=\"$export_dynamic_flag_spec\"
4916af1a9c97Smrg      func_append compile_command " $arg"
4917af1a9c97Smrg      func_append finalize_command " $arg"
4918af1a9c97Smrg    fi
4919af1a9c97Smrg
4920af1a9c97Smrg    oldlibs=
4921af1a9c97Smrg    # calculate the name of the file, without its directory
4922af1a9c97Smrg    func_basename "$output"
4923af1a9c97Smrg    outputname="$func_basename_result"
4924af1a9c97Smrg    libobjs_save="$libobjs"
4925af1a9c97Smrg
4926af1a9c97Smrg    if test -n "$shlibpath_var"; then
4927af1a9c97Smrg      # get the directories listed in $shlibpath_var
4928af1a9c97Smrg      eval shlib_search_path=\`\$ECHO \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\`
4929af1a9c97Smrg    else
4930af1a9c97Smrg      shlib_search_path=
4931af1a9c97Smrg    fi
4932af1a9c97Smrg    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
4933af1a9c97Smrg    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
4934af1a9c97Smrg
4935af1a9c97Smrg    func_dirname "$output" "/" ""
4936af1a9c97Smrg    output_objdir="$func_dirname_result$objdir"
4937af1a9c97Smrg    # Create the object directory.
4938af1a9c97Smrg    func_mkdir_p "$output_objdir"
4939af1a9c97Smrg
4940af1a9c97Smrg    # Determine the type of output
4941af1a9c97Smrg    case $output in
4942af1a9c97Smrg    "")
4943af1a9c97Smrg      func_fatal_help "you must specify an output file"
4944af1a9c97Smrg      ;;
4945af1a9c97Smrg    *.$libext) linkmode=oldlib ;;
4946af1a9c97Smrg    *.lo | *.$objext) linkmode=obj ;;
4947af1a9c97Smrg    *.la) linkmode=lib ;;
4948af1a9c97Smrg    *) linkmode=prog ;; # Anything else should be a program.
4949af1a9c97Smrg    esac
4950af1a9c97Smrg
4951af1a9c97Smrg    specialdeplibs=
4952af1a9c97Smrg
4953af1a9c97Smrg    libs=
4954af1a9c97Smrg    # Find all interdependent deplibs by searching for libraries
4955af1a9c97Smrg    # that are linked more than once (e.g. -la -lb -la)
4956af1a9c97Smrg    for deplib in $deplibs; do
4957af1a9c97Smrg      if $opt_duplicate_deps ; then
4958af1a9c97Smrg	case "$libs " in
4959af1a9c97Smrg	*" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
4960af1a9c97Smrg	esac
4961af1a9c97Smrg      fi
4962af1a9c97Smrg      libs="$libs $deplib"
4963af1a9c97Smrg    done
4964af1a9c97Smrg
4965af1a9c97Smrg    if test "$linkmode" = lib; then
4966af1a9c97Smrg      libs="$predeps $libs $compiler_lib_search_path $postdeps"
4967af1a9c97Smrg
4968af1a9c97Smrg      # Compute libraries that are listed more than once in $predeps
4969af1a9c97Smrg      # $postdeps and mark them as special (i.e., whose duplicates are
4970af1a9c97Smrg      # not to be eliminated).
4971af1a9c97Smrg      pre_post_deps=
4972af1a9c97Smrg      if $opt_duplicate_compiler_generated_deps; then
4973af1a9c97Smrg	for pre_post_dep in $predeps $postdeps; do
4974af1a9c97Smrg	  case "$pre_post_deps " in
4975af1a9c97Smrg	  *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;;
4976af1a9c97Smrg	  esac
4977af1a9c97Smrg	  pre_post_deps="$pre_post_deps $pre_post_dep"
4978af1a9c97Smrg	done
4979af1a9c97Smrg      fi
4980af1a9c97Smrg      pre_post_deps=
4981af1a9c97Smrg    fi
4982af1a9c97Smrg
4983af1a9c97Smrg    deplibs=
4984af1a9c97Smrg    newdependency_libs=
4985af1a9c97Smrg    newlib_search_path=
4986af1a9c97Smrg    need_relink=no # whether we're linking any uninstalled libtool libraries
4987af1a9c97Smrg    notinst_deplibs= # not-installed libtool libraries
4988af1a9c97Smrg    notinst_path= # paths that contain not-installed libtool libraries
4989af1a9c97Smrg
4990af1a9c97Smrg    case $linkmode in
4991af1a9c97Smrg    lib)
4992af1a9c97Smrg	passes="conv dlpreopen link"
4993af1a9c97Smrg	for file in $dlfiles $dlprefiles; do
4994af1a9c97Smrg	  case $file in
4995af1a9c97Smrg	  *.la) ;;
4996af1a9c97Smrg	  *)
4997af1a9c97Smrg	    func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file"
4998af1a9c97Smrg	    ;;
4999af1a9c97Smrg	  esac
5000af1a9c97Smrg	done
5001af1a9c97Smrg	;;
5002af1a9c97Smrg    prog)
5003af1a9c97Smrg	compile_deplibs=
5004af1a9c97Smrg	finalize_deplibs=
5005af1a9c97Smrg	alldeplibs=no
5006af1a9c97Smrg	newdlfiles=
5007af1a9c97Smrg	newdlprefiles=
5008af1a9c97Smrg	passes="conv scan dlopen dlpreopen link"
5009af1a9c97Smrg	;;
5010af1a9c97Smrg    *)  passes="conv"
5011af1a9c97Smrg	;;
5012af1a9c97Smrg    esac
5013af1a9c97Smrg
5014af1a9c97Smrg    for pass in $passes; do
5015af1a9c97Smrg      # The preopen pass in lib mode reverses $deplibs; put it back here
5016af1a9c97Smrg      # so that -L comes before libs that need it for instance...
5017af1a9c97Smrg      if test "$linkmode,$pass" = "lib,link"; then
5018af1a9c97Smrg	## FIXME: Find the place where the list is rebuilt in the wrong
5019af1a9c97Smrg	##        order, and fix it there properly
5020af1a9c97Smrg        tmp_deplibs=
5021af1a9c97Smrg	for deplib in $deplibs; do
5022af1a9c97Smrg	  tmp_deplibs="$deplib $tmp_deplibs"
5023af1a9c97Smrg	done
5024af1a9c97Smrg	deplibs="$tmp_deplibs"
5025af1a9c97Smrg      fi
5026af1a9c97Smrg
5027af1a9c97Smrg      if test "$linkmode,$pass" = "lib,link" ||
5028af1a9c97Smrg	 test "$linkmode,$pass" = "prog,scan"; then
5029af1a9c97Smrg	libs="$deplibs"
5030af1a9c97Smrg	deplibs=
5031af1a9c97Smrg      fi
5032af1a9c97Smrg      if test "$linkmode" = prog; then
5033af1a9c97Smrg	case $pass in
5034af1a9c97Smrg	dlopen) libs="$dlfiles" ;;
5035af1a9c97Smrg	dlpreopen) libs="$dlprefiles" ;;
5036af1a9c97Smrg	link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
5037af1a9c97Smrg	esac
5038af1a9c97Smrg      fi
5039af1a9c97Smrg      if test "$linkmode,$pass" = "lib,dlpreopen"; then
5040af1a9c97Smrg	# Collect and forward deplibs of preopened libtool libs
5041af1a9c97Smrg	for lib in $dlprefiles; do
5042af1a9c97Smrg	  # Ignore non-libtool-libs
5043af1a9c97Smrg	  dependency_libs=
5044af1a9c97Smrg	  case $lib in
5045af1a9c97Smrg	  *.la)	func_source "$lib" ;;
5046af1a9c97Smrg	  esac
5047af1a9c97Smrg
5048af1a9c97Smrg	  # Collect preopened libtool deplibs, except any this library
5049af1a9c97Smrg	  # has declared as weak libs
5050af1a9c97Smrg	  for deplib in $dependency_libs; do
5051af1a9c97Smrg            deplib_base=`$ECHO "X$deplib" | $Xsed -e "$basename"`
5052af1a9c97Smrg	    case " $weak_libs " in
5053af1a9c97Smrg	    *" $deplib_base "*) ;;
5054af1a9c97Smrg	    *) deplibs="$deplibs $deplib" ;;
5055af1a9c97Smrg	    esac
5056af1a9c97Smrg	  done
5057af1a9c97Smrg	done
5058af1a9c97Smrg	libs="$dlprefiles"
5059af1a9c97Smrg      fi
5060af1a9c97Smrg      if test "$pass" = dlopen; then
5061af1a9c97Smrg	# Collect dlpreopened libraries
5062af1a9c97Smrg	save_deplibs="$deplibs"
5063af1a9c97Smrg	deplibs=
5064af1a9c97Smrg      fi
5065af1a9c97Smrg
5066af1a9c97Smrg      for deplib in $libs; do
5067af1a9c97Smrg	lib=
5068af1a9c97Smrg	found=no
5069af1a9c97Smrg	case $deplib in
5070af1a9c97Smrg	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
5071af1a9c97Smrg	  if test "$linkmode,$pass" = "prog,link"; then
5072af1a9c97Smrg	    compile_deplibs="$deplib $compile_deplibs"
5073af1a9c97Smrg	    finalize_deplibs="$deplib $finalize_deplibs"
5074af1a9c97Smrg	  else
5075af1a9c97Smrg	    compiler_flags="$compiler_flags $deplib"
5076af1a9c97Smrg	    if test "$linkmode" = lib ; then
5077af1a9c97Smrg		case "$new_inherited_linker_flags " in
5078af1a9c97Smrg		    *" $deplib "*) ;;
5079af1a9c97Smrg		    * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;;
5080af1a9c97Smrg		esac
5081af1a9c97Smrg	    fi
5082af1a9c97Smrg	  fi
5083af1a9c97Smrg	  continue
5084af1a9c97Smrg	  ;;
5085af1a9c97Smrg	-l*)
5086af1a9c97Smrg	  if test "$linkmode" != lib && test "$linkmode" != prog; then
5087af1a9c97Smrg	    func_warning "\`-l' is ignored for archives/objects"
5088af1a9c97Smrg	    continue
5089af1a9c97Smrg	  fi
5090af1a9c97Smrg	  func_stripname '-l' '' "$deplib"
5091af1a9c97Smrg	  name=$func_stripname_result
5092af1a9c97Smrg	  if test "$linkmode" = lib; then
5093af1a9c97Smrg	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
5094af1a9c97Smrg	  else
5095af1a9c97Smrg	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
5096af1a9c97Smrg	  fi
5097af1a9c97Smrg	  for searchdir in $searchdirs; do
5098af1a9c97Smrg	    for search_ext in .la $std_shrext .so .a; do
5099af1a9c97Smrg	      # Search the libtool library
5100af1a9c97Smrg	      lib="$searchdir/lib${name}${search_ext}"
5101af1a9c97Smrg	      if test -f "$lib"; then
5102af1a9c97Smrg		if test "$search_ext" = ".la"; then
5103af1a9c97Smrg		  found=yes
5104af1a9c97Smrg		else
5105af1a9c97Smrg		  found=no
5106af1a9c97Smrg		fi
5107af1a9c97Smrg		break 2
5108af1a9c97Smrg	      fi
5109af1a9c97Smrg	    done
5110af1a9c97Smrg	  done
5111af1a9c97Smrg	  if test "$found" != yes; then
5112af1a9c97Smrg	    # deplib doesn't seem to be a libtool library
5113af1a9c97Smrg	    if test "$linkmode,$pass" = "prog,link"; then
5114af1a9c97Smrg	      compile_deplibs="$deplib $compile_deplibs"
5115af1a9c97Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
5116af1a9c97Smrg	    else
5117af1a9c97Smrg	      deplibs="$deplib $deplibs"
5118af1a9c97Smrg	      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
5119af1a9c97Smrg	    fi
5120af1a9c97Smrg	    continue
5121af1a9c97Smrg	  else # deplib is a libtool library
5122af1a9c97Smrg	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
5123af1a9c97Smrg	    # We need to do some special things here, and not later.
5124af1a9c97Smrg	    if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
5125af1a9c97Smrg	      case " $predeps $postdeps " in
5126af1a9c97Smrg	      *" $deplib "*)
5127af1a9c97Smrg		if func_lalib_p "$lib"; then
5128af1a9c97Smrg		  library_names=
5129af1a9c97Smrg		  old_library=
5130af1a9c97Smrg		  func_source "$lib"
5131af1a9c97Smrg		  for l in $old_library $library_names; do
5132af1a9c97Smrg		    ll="$l"
5133af1a9c97Smrg		  done
5134af1a9c97Smrg		  if test "X$ll" = "X$old_library" ; then # only static version available
5135af1a9c97Smrg		    found=no
5136af1a9c97Smrg		    func_dirname "$lib" "" "."
5137af1a9c97Smrg		    ladir="$func_dirname_result"
5138af1a9c97Smrg		    lib=$ladir/$old_library
5139af1a9c97Smrg		    if test "$linkmode,$pass" = "prog,link"; then
5140af1a9c97Smrg		      compile_deplibs="$deplib $compile_deplibs"
5141af1a9c97Smrg		      finalize_deplibs="$deplib $finalize_deplibs"
5142af1a9c97Smrg		    else
5143af1a9c97Smrg		      deplibs="$deplib $deplibs"
5144af1a9c97Smrg		      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
5145af1a9c97Smrg		    fi
5146af1a9c97Smrg		    continue
5147af1a9c97Smrg		  fi
5148af1a9c97Smrg		fi
5149af1a9c97Smrg		;;
5150af1a9c97Smrg	      *) ;;
5151af1a9c97Smrg	      esac
5152af1a9c97Smrg	    fi
5153af1a9c97Smrg	  fi
5154af1a9c97Smrg	  ;; # -l
5155af1a9c97Smrg	*.ltframework)
5156af1a9c97Smrg	  if test "$linkmode,$pass" = "prog,link"; then
5157af1a9c97Smrg	    compile_deplibs="$deplib $compile_deplibs"
5158af1a9c97Smrg	    finalize_deplibs="$deplib $finalize_deplibs"
5159af1a9c97Smrg	  else
5160af1a9c97Smrg	    deplibs="$deplib $deplibs"
5161af1a9c97Smrg	    if test "$linkmode" = lib ; then
5162af1a9c97Smrg		case "$new_inherited_linker_flags " in
5163af1a9c97Smrg		    *" $deplib "*) ;;
5164af1a9c97Smrg		    * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;;
5165af1a9c97Smrg		esac
5166af1a9c97Smrg	    fi
5167af1a9c97Smrg	  fi
5168af1a9c97Smrg	  continue
5169af1a9c97Smrg	  ;;
5170af1a9c97Smrg	-L*)
5171af1a9c97Smrg	  case $linkmode in
5172af1a9c97Smrg	  lib)
5173af1a9c97Smrg	    deplibs="$deplib $deplibs"
5174af1a9c97Smrg	    test "$pass" = conv && continue
5175af1a9c97Smrg	    newdependency_libs="$deplib $newdependency_libs"
5176af1a9c97Smrg	    func_stripname '-L' '' "$deplib"
5177af1a9c97Smrg	    newlib_search_path="$newlib_search_path $func_stripname_result"
5178af1a9c97Smrg	    ;;
5179af1a9c97Smrg	  prog)
5180af1a9c97Smrg	    if test "$pass" = conv; then
5181af1a9c97Smrg	      deplibs="$deplib $deplibs"
5182af1a9c97Smrg	      continue
5183af1a9c97Smrg	    fi
5184af1a9c97Smrg	    if test "$pass" = scan; then
5185af1a9c97Smrg	      deplibs="$deplib $deplibs"
5186af1a9c97Smrg	    else
5187af1a9c97Smrg	      compile_deplibs="$deplib $compile_deplibs"
5188af1a9c97Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
5189af1a9c97Smrg	    fi
5190af1a9c97Smrg	    func_stripname '-L' '' "$deplib"
5191af1a9c97Smrg	    newlib_search_path="$newlib_search_path $func_stripname_result"
5192af1a9c97Smrg	    ;;
5193af1a9c97Smrg	  *)
5194af1a9c97Smrg	    func_warning "\`-L' is ignored for archives/objects"
5195af1a9c97Smrg	    ;;
5196af1a9c97Smrg	  esac # linkmode
5197af1a9c97Smrg	  continue
5198af1a9c97Smrg	  ;; # -L
5199af1a9c97Smrg	-R*)
5200af1a9c97Smrg	  if test "$pass" = link; then
5201af1a9c97Smrg	    func_stripname '-R' '' "$deplib"
5202af1a9c97Smrg	    dir=$func_stripname_result
5203af1a9c97Smrg	    # Make sure the xrpath contains only unique directories.
5204af1a9c97Smrg	    case "$xrpath " in
5205af1a9c97Smrg	    *" $dir "*) ;;
5206af1a9c97Smrg	    *) xrpath="$xrpath $dir" ;;
5207af1a9c97Smrg	    esac
5208af1a9c97Smrg	  fi
5209af1a9c97Smrg	  deplibs="$deplib $deplibs"
5210af1a9c97Smrg	  continue
5211af1a9c97Smrg	  ;;
5212af1a9c97Smrg	*.la) lib="$deplib" ;;
5213af1a9c97Smrg	*.$libext)
5214af1a9c97Smrg	  if test "$pass" = conv; then
5215af1a9c97Smrg	    deplibs="$deplib $deplibs"
5216af1a9c97Smrg	    continue
5217af1a9c97Smrg	  fi
5218af1a9c97Smrg	  case $linkmode in
5219af1a9c97Smrg	  lib)
5220af1a9c97Smrg	    # Linking convenience modules into shared libraries is allowed,
5221af1a9c97Smrg	    # but linking other static libraries is non-portable.
5222af1a9c97Smrg	    case " $dlpreconveniencelibs " in
5223af1a9c97Smrg	    *" $deplib "*) ;;
5224af1a9c97Smrg	    *)
5225af1a9c97Smrg	      valid_a_lib=no
5226af1a9c97Smrg	      case $deplibs_check_method in
5227af1a9c97Smrg		match_pattern*)
5228af1a9c97Smrg		  set dummy $deplibs_check_method; shift
5229af1a9c97Smrg		  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
5230af1a9c97Smrg		  if eval "\$ECHO \"X$deplib\"" 2>/dev/null | $Xsed -e 10q \
5231af1a9c97Smrg		    | $EGREP "$match_pattern_regex" > /dev/null; then
5232af1a9c97Smrg		    valid_a_lib=yes
5233af1a9c97Smrg		  fi
5234af1a9c97Smrg		;;
5235af1a9c97Smrg		pass_all)
5236af1a9c97Smrg		  valid_a_lib=yes
5237af1a9c97Smrg		;;
5238af1a9c97Smrg	      esac
5239af1a9c97Smrg	      if test "$valid_a_lib" != yes; then
5240af1a9c97Smrg		$ECHO
5241af1a9c97Smrg		$ECHO "*** Warning: Trying to link with static lib archive $deplib."
5242af1a9c97Smrg		$ECHO "*** I have the capability to make that library automatically link in when"
5243af1a9c97Smrg		$ECHO "*** you link to this library.  But I can only do this if you have a"
5244af1a9c97Smrg		$ECHO "*** shared version of the library, which you do not appear to have"
5245af1a9c97Smrg		$ECHO "*** because the file extensions .$libext of this argument makes me believe"
5246af1a9c97Smrg		$ECHO "*** that it is just a static archive that I should not use here."
5247af1a9c97Smrg	      else
5248af1a9c97Smrg		$ECHO
5249af1a9c97Smrg		$ECHO "*** Warning: Linking the shared library $output against the"
5250af1a9c97Smrg		$ECHO "*** static library $deplib is not portable!"
5251af1a9c97Smrg		deplibs="$deplib $deplibs"
5252af1a9c97Smrg	      fi
5253af1a9c97Smrg	      ;;
5254af1a9c97Smrg	    esac
5255af1a9c97Smrg	    continue
5256af1a9c97Smrg	    ;;
5257af1a9c97Smrg	  prog)
5258af1a9c97Smrg	    if test "$pass" != link; then
5259af1a9c97Smrg	      deplibs="$deplib $deplibs"
5260af1a9c97Smrg	    else
5261af1a9c97Smrg	      compile_deplibs="$deplib $compile_deplibs"
5262af1a9c97Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
5263af1a9c97Smrg	    fi
5264af1a9c97Smrg	    continue
5265af1a9c97Smrg	    ;;
5266af1a9c97Smrg	  esac # linkmode
5267af1a9c97Smrg	  ;; # *.$libext
5268af1a9c97Smrg	*.lo | *.$objext)
5269af1a9c97Smrg	  if test "$pass" = conv; then
5270af1a9c97Smrg	    deplibs="$deplib $deplibs"
5271af1a9c97Smrg	  elif test "$linkmode" = prog; then
5272af1a9c97Smrg	    if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
5273af1a9c97Smrg	      # If there is no dlopen support or we're linking statically,
5274af1a9c97Smrg	      # we need to preload.
5275af1a9c97Smrg	      newdlprefiles="$newdlprefiles $deplib"
5276af1a9c97Smrg	      compile_deplibs="$deplib $compile_deplibs"
5277af1a9c97Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
5278af1a9c97Smrg	    else
5279af1a9c97Smrg	      newdlfiles="$newdlfiles $deplib"
5280af1a9c97Smrg	    fi
5281af1a9c97Smrg	  fi
5282af1a9c97Smrg	  continue
5283af1a9c97Smrg	  ;;
5284af1a9c97Smrg	%DEPLIBS%)
5285af1a9c97Smrg	  alldeplibs=yes
5286af1a9c97Smrg	  continue
5287af1a9c97Smrg	  ;;
5288af1a9c97Smrg	esac # case $deplib
5289af1a9c97Smrg
5290af1a9c97Smrg	if test "$found" = yes || test -f "$lib"; then :
5291af1a9c97Smrg	else
5292af1a9c97Smrg	  func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'"
5293af1a9c97Smrg	fi
5294af1a9c97Smrg
5295af1a9c97Smrg	# Check to see that this really is a libtool archive.
5296af1a9c97Smrg	func_lalib_unsafe_p "$lib" \
5297af1a9c97Smrg	  || func_fatal_error "\`$lib' is not a valid libtool archive"
5298af1a9c97Smrg
5299af1a9c97Smrg	func_dirname "$lib" "" "."
5300af1a9c97Smrg	ladir="$func_dirname_result"
5301af1a9c97Smrg
5302af1a9c97Smrg	dlname=
5303af1a9c97Smrg	dlopen=
5304af1a9c97Smrg	dlpreopen=
5305af1a9c97Smrg	libdir=
5306af1a9c97Smrg	library_names=
5307af1a9c97Smrg	old_library=
5308af1a9c97Smrg	inherited_linker_flags=
5309af1a9c97Smrg	# If the library was installed with an old release of libtool,
5310af1a9c97Smrg	# it will not redefine variables installed, or shouldnotlink
5311af1a9c97Smrg	installed=yes
5312af1a9c97Smrg	shouldnotlink=no
5313af1a9c97Smrg	avoidtemprpath=
5314af1a9c97Smrg
5315af1a9c97Smrg
5316af1a9c97Smrg	# Read the .la file
5317af1a9c97Smrg	func_source "$lib"
5318af1a9c97Smrg
5319af1a9c97Smrg	# Convert "-framework foo" to "foo.ltframework"
5320af1a9c97Smrg	if test -n "$inherited_linker_flags"; then
5321af1a9c97Smrg	  tmp_inherited_linker_flags=`$ECHO "X$inherited_linker_flags" | $Xsed -e 's/-framework \([^ $]*\)/\1.ltframework/g'`
5322af1a9c97Smrg	  for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
5323af1a9c97Smrg	    case " $new_inherited_linker_flags " in
5324af1a9c97Smrg	      *" $tmp_inherited_linker_flag "*) ;;
5325af1a9c97Smrg	      *) new_inherited_linker_flags="$new_inherited_linker_flags $tmp_inherited_linker_flag";;
5326af1a9c97Smrg	    esac
5327af1a9c97Smrg	  done
5328af1a9c97Smrg	fi
5329af1a9c97Smrg	dependency_libs=`$ECHO "X $dependency_libs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
5330af1a9c97Smrg	if test "$linkmode,$pass" = "lib,link" ||
5331af1a9c97Smrg	   test "$linkmode,$pass" = "prog,scan" ||
5332af1a9c97Smrg	   { test "$linkmode" != prog && test "$linkmode" != lib; }; then
5333af1a9c97Smrg	  test -n "$dlopen" && dlfiles="$dlfiles $dlopen"
5334af1a9c97Smrg	  test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen"
5335af1a9c97Smrg	fi
5336af1a9c97Smrg
5337af1a9c97Smrg	if test "$pass" = conv; then
5338af1a9c97Smrg	  # Only check for convenience libraries
5339af1a9c97Smrg	  deplibs="$lib $deplibs"
5340af1a9c97Smrg	  if test -z "$libdir"; then
5341af1a9c97Smrg	    if test -z "$old_library"; then
5342af1a9c97Smrg	      func_fatal_error "cannot find name of link library for \`$lib'"
5343af1a9c97Smrg	    fi
5344af1a9c97Smrg	    # It is a libtool convenience library, so add in its objects.
5345af1a9c97Smrg	    convenience="$convenience $ladir/$objdir/$old_library"
5346af1a9c97Smrg	    old_convenience="$old_convenience $ladir/$objdir/$old_library"
5347af1a9c97Smrg	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
5348af1a9c97Smrg	    func_fatal_error "\`$lib' is not a convenience library"
5349af1a9c97Smrg	  fi
5350af1a9c97Smrg	  tmp_libs=
5351af1a9c97Smrg	  for deplib in $dependency_libs; do
5352af1a9c97Smrg	    deplibs="$deplib $deplibs"
5353af1a9c97Smrg	    if $opt_duplicate_deps ; then
5354af1a9c97Smrg	      case "$tmp_libs " in
5355af1a9c97Smrg	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
5356af1a9c97Smrg	      esac
5357af1a9c97Smrg	    fi
5358af1a9c97Smrg	    tmp_libs="$tmp_libs $deplib"
5359af1a9c97Smrg	  done
5360af1a9c97Smrg	  continue
5361af1a9c97Smrg	fi # $pass = conv
5362af1a9c97Smrg
5363af1a9c97Smrg
5364af1a9c97Smrg	# Get the name of the library we link against.
5365af1a9c97Smrg	linklib=
5366af1a9c97Smrg	for l in $old_library $library_names; do
5367af1a9c97Smrg	  linklib="$l"
5368af1a9c97Smrg	done
5369af1a9c97Smrg	if test -z "$linklib"; then
5370af1a9c97Smrg	  func_fatal_error "cannot find name of link library for \`$lib'"
5371af1a9c97Smrg	fi
5372af1a9c97Smrg
5373af1a9c97Smrg	# This library was specified with -dlopen.
5374af1a9c97Smrg	if test "$pass" = dlopen; then
5375af1a9c97Smrg	  if test -z "$libdir"; then
5376af1a9c97Smrg	    func_fatal_error "cannot -dlopen a convenience library: \`$lib'"
5377af1a9c97Smrg	  fi
5378af1a9c97Smrg	  if test -z "$dlname" ||
5379af1a9c97Smrg	     test "$dlopen_support" != yes ||
5380af1a9c97Smrg	     test "$build_libtool_libs" = no; then
5381af1a9c97Smrg	    # If there is no dlname, no dlopen support or we're linking
5382af1a9c97Smrg	    # statically, we need to preload.  We also need to preload any
5383af1a9c97Smrg	    # dependent libraries so libltdl's deplib preloader doesn't
5384af1a9c97Smrg	    # bomb out in the load deplibs phase.
5385af1a9c97Smrg	    dlprefiles="$dlprefiles $lib $dependency_libs"
5386af1a9c97Smrg	  else
5387af1a9c97Smrg	    newdlfiles="$newdlfiles $lib"
5388af1a9c97Smrg	  fi
5389af1a9c97Smrg	  continue
5390af1a9c97Smrg	fi # $pass = dlopen
5391af1a9c97Smrg
5392af1a9c97Smrg	# We need an absolute path.
5393af1a9c97Smrg	case $ladir in
5394af1a9c97Smrg	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
5395af1a9c97Smrg	*)
5396af1a9c97Smrg	  abs_ladir=`cd "$ladir" && pwd`
5397af1a9c97Smrg	  if test -z "$abs_ladir"; then
5398af1a9c97Smrg	    func_warning "cannot determine absolute directory name of \`$ladir'"
5399af1a9c97Smrg	    func_warning "passing it literally to the linker, although it might fail"
5400af1a9c97Smrg	    abs_ladir="$ladir"
5401af1a9c97Smrg	  fi
5402af1a9c97Smrg	  ;;
5403af1a9c97Smrg	esac
5404af1a9c97Smrg	func_basename "$lib"
5405af1a9c97Smrg	laname="$func_basename_result"
5406af1a9c97Smrg
5407af1a9c97Smrg	# Find the relevant object directory and library name.
5408af1a9c97Smrg	if test "X$installed" = Xyes; then
5409af1a9c97Smrg	  if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
5410af1a9c97Smrg	    func_warning "library \`$lib' was moved."
5411af1a9c97Smrg	    dir="$ladir"
5412af1a9c97Smrg	    absdir="$abs_ladir"
5413af1a9c97Smrg	    libdir="$abs_ladir"
5414af1a9c97Smrg	  else
5415af1a9c97Smrg	    dir="$libdir"
5416af1a9c97Smrg	    absdir="$libdir"
5417af1a9c97Smrg	  fi
5418af1a9c97Smrg	  test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
5419af1a9c97Smrg	else
5420af1a9c97Smrg	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
5421af1a9c97Smrg	    dir="$ladir"
5422af1a9c97Smrg	    absdir="$abs_ladir"
5423af1a9c97Smrg	    # Remove this search path later
5424af1a9c97Smrg	    notinst_path="$notinst_path $abs_ladir"
5425af1a9c97Smrg	  else
5426af1a9c97Smrg	    dir="$ladir/$objdir"
5427af1a9c97Smrg	    absdir="$abs_ladir/$objdir"
5428af1a9c97Smrg	    # Remove this search path later
5429af1a9c97Smrg	    notinst_path="$notinst_path $abs_ladir"
5430af1a9c97Smrg	  fi
5431af1a9c97Smrg	fi # $installed = yes
5432af1a9c97Smrg	func_stripname 'lib' '.la' "$laname"
5433af1a9c97Smrg	name=$func_stripname_result
5434af1a9c97Smrg
5435af1a9c97Smrg	# This library was specified with -dlpreopen.
5436af1a9c97Smrg	if test "$pass" = dlpreopen; then
5437af1a9c97Smrg	  if test -z "$libdir" && test "$linkmode" = prog; then
5438af1a9c97Smrg	    func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'"
5439af1a9c97Smrg	  fi
5440af1a9c97Smrg	  # Prefer using a static library (so that no silly _DYNAMIC symbols
5441af1a9c97Smrg	  # are required to link).
5442af1a9c97Smrg	  if test -n "$old_library"; then
5443af1a9c97Smrg	    newdlprefiles="$newdlprefiles $dir/$old_library"
5444af1a9c97Smrg	    # Keep a list of preopened convenience libraries to check
5445af1a9c97Smrg	    # that they are being used correctly in the link pass.
5446af1a9c97Smrg	    test -z "$libdir" && \
5447af1a9c97Smrg		dlpreconveniencelibs="$dlpreconveniencelibs $dir/$old_library"
5448af1a9c97Smrg	  # Otherwise, use the dlname, so that lt_dlopen finds it.
5449af1a9c97Smrg	  elif test -n "$dlname"; then
5450af1a9c97Smrg	    newdlprefiles="$newdlprefiles $dir/$dlname"
5451af1a9c97Smrg	  else
5452af1a9c97Smrg	    newdlprefiles="$newdlprefiles $dir/$linklib"
5453af1a9c97Smrg	  fi
5454af1a9c97Smrg	fi # $pass = dlpreopen
5455af1a9c97Smrg
5456af1a9c97Smrg	if test -z "$libdir"; then
5457af1a9c97Smrg	  # Link the convenience library
5458af1a9c97Smrg	  if test "$linkmode" = lib; then
5459af1a9c97Smrg	    deplibs="$dir/$old_library $deplibs"
5460af1a9c97Smrg	  elif test "$linkmode,$pass" = "prog,link"; then
5461af1a9c97Smrg	    compile_deplibs="$dir/$old_library $compile_deplibs"
5462af1a9c97Smrg	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
5463af1a9c97Smrg	  else
5464af1a9c97Smrg	    deplibs="$lib $deplibs" # used for prog,scan pass
5465af1a9c97Smrg	  fi
5466af1a9c97Smrg	  continue
5467af1a9c97Smrg	fi
5468af1a9c97Smrg
5469af1a9c97Smrg
5470af1a9c97Smrg	if test "$linkmode" = prog && test "$pass" != link; then
5471af1a9c97Smrg	  newlib_search_path="$newlib_search_path $ladir"
5472af1a9c97Smrg	  deplibs="$lib $deplibs"
5473af1a9c97Smrg
5474af1a9c97Smrg	  linkalldeplibs=no
5475af1a9c97Smrg	  if test "$link_all_deplibs" != no || test -z "$library_names" ||
5476af1a9c97Smrg	     test "$build_libtool_libs" = no; then
5477af1a9c97Smrg	    linkalldeplibs=yes
5478af1a9c97Smrg	  fi
5479af1a9c97Smrg
5480af1a9c97Smrg	  tmp_libs=
5481af1a9c97Smrg	  for deplib in $dependency_libs; do
5482af1a9c97Smrg	    case $deplib in
5483af1a9c97Smrg	    -L*) func_stripname '-L' '' "$deplib"
5484af1a9c97Smrg	         newlib_search_path="$newlib_search_path $func_stripname_result"
5485af1a9c97Smrg		 ;;
5486af1a9c97Smrg	    esac
5487af1a9c97Smrg	    # Need to link against all dependency_libs?
5488af1a9c97Smrg	    if test "$linkalldeplibs" = yes; then
5489af1a9c97Smrg	      deplibs="$deplib $deplibs"
5490af1a9c97Smrg	    else
5491af1a9c97Smrg	      # Need to hardcode shared library paths
5492af1a9c97Smrg	      # or/and link against static libraries
5493af1a9c97Smrg	      newdependency_libs="$deplib $newdependency_libs"
5494af1a9c97Smrg	    fi
5495af1a9c97Smrg	    if $opt_duplicate_deps ; then
5496af1a9c97Smrg	      case "$tmp_libs " in
5497af1a9c97Smrg	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
5498af1a9c97Smrg	      esac
5499af1a9c97Smrg	    fi
5500af1a9c97Smrg	    tmp_libs="$tmp_libs $deplib"
5501af1a9c97Smrg	  done # for deplib
5502af1a9c97Smrg	  continue
5503af1a9c97Smrg	fi # $linkmode = prog...
5504af1a9c97Smrg
5505af1a9c97Smrg	if test "$linkmode,$pass" = "prog,link"; then
5506af1a9c97Smrg	  if test -n "$library_names" &&
5507af1a9c97Smrg	     { { test "$prefer_static_libs" = no ||
5508af1a9c97Smrg	         test "$prefer_static_libs,$installed" = "built,yes"; } ||
5509af1a9c97Smrg	       test -z "$old_library"; }; then
5510af1a9c97Smrg	    # We need to hardcode the library path
5511af1a9c97Smrg	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
5512af1a9c97Smrg	      # Make sure the rpath contains only unique directories.
5513af1a9c97Smrg	      case "$temp_rpath:" in
5514af1a9c97Smrg	      *"$absdir:"*) ;;
5515af1a9c97Smrg	      *) temp_rpath="$temp_rpath$absdir:" ;;
5516af1a9c97Smrg	      esac
5517af1a9c97Smrg	    fi
5518af1a9c97Smrg
5519af1a9c97Smrg	    # Hardcode the library path.
5520af1a9c97Smrg	    # Skip directories that are in the system default run-time
5521af1a9c97Smrg	    # search path.
5522af1a9c97Smrg	    case " $sys_lib_dlsearch_path " in
5523af1a9c97Smrg	    *" $absdir "*) ;;
5524af1a9c97Smrg	    *)
5525af1a9c97Smrg	      case "$compile_rpath " in
5526af1a9c97Smrg	      *" $absdir "*) ;;
5527af1a9c97Smrg	      *) compile_rpath="$compile_rpath $absdir"
5528af1a9c97Smrg	      esac
5529af1a9c97Smrg	      ;;
5530af1a9c97Smrg	    esac
5531af1a9c97Smrg	    case " $sys_lib_dlsearch_path " in
5532af1a9c97Smrg	    *" $libdir "*) ;;
5533af1a9c97Smrg	    *)
5534af1a9c97Smrg	      case "$finalize_rpath " in
5535af1a9c97Smrg	      *" $libdir "*) ;;
5536af1a9c97Smrg	      *) finalize_rpath="$finalize_rpath $libdir"
5537af1a9c97Smrg	      esac
5538af1a9c97Smrg	      ;;
5539af1a9c97Smrg	    esac
5540af1a9c97Smrg	  fi # $linkmode,$pass = prog,link...
5541af1a9c97Smrg
5542af1a9c97Smrg	  if test "$alldeplibs" = yes &&
5543af1a9c97Smrg	     { test "$deplibs_check_method" = pass_all ||
5544af1a9c97Smrg	       { test "$build_libtool_libs" = yes &&
5545af1a9c97Smrg		 test -n "$library_names"; }; }; then
5546af1a9c97Smrg	    # We only need to search for static libraries
5547af1a9c97Smrg	    continue
5548af1a9c97Smrg	  fi
5549af1a9c97Smrg	fi
5550af1a9c97Smrg
5551af1a9c97Smrg	link_static=no # Whether the deplib will be linked statically
5552af1a9c97Smrg	use_static_libs=$prefer_static_libs
5553af1a9c97Smrg	if test "$use_static_libs" = built && test "$installed" = yes; then
5554af1a9c97Smrg	  use_static_libs=no
5555af1a9c97Smrg	fi
5556af1a9c97Smrg	if test -n "$library_names" &&
5557af1a9c97Smrg	   { test "$use_static_libs" = no || test -z "$old_library"; }; then
5558af1a9c97Smrg	  case $host in
5559af1a9c97Smrg	  *cygwin* | *mingw* | *cegcc*)
5560af1a9c97Smrg	      # No point in relinking DLLs because paths are not encoded
5561af1a9c97Smrg	      notinst_deplibs="$notinst_deplibs $lib"
5562af1a9c97Smrg	      need_relink=no
5563af1a9c97Smrg	    ;;
5564af1a9c97Smrg	  *)
5565af1a9c97Smrg	    if test "$installed" = no; then
5566af1a9c97Smrg	      notinst_deplibs="$notinst_deplibs $lib"
5567af1a9c97Smrg	      need_relink=yes
5568af1a9c97Smrg	    fi
5569af1a9c97Smrg	    ;;
5570af1a9c97Smrg	  esac
5571af1a9c97Smrg	  # This is a shared library
5572af1a9c97Smrg
5573af1a9c97Smrg	  # Warn about portability, can't link against -module's on some
5574af1a9c97Smrg	  # systems (darwin).  Don't bleat about dlopened modules though!
5575af1a9c97Smrg	  dlopenmodule=""
5576af1a9c97Smrg	  for dlpremoduletest in $dlprefiles; do
5577af1a9c97Smrg	    if test "X$dlpremoduletest" = "X$lib"; then
5578af1a9c97Smrg	      dlopenmodule="$dlpremoduletest"
5579af1a9c97Smrg	      break
5580af1a9c97Smrg	    fi
5581af1a9c97Smrg	  done
5582af1a9c97Smrg	  if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then
5583af1a9c97Smrg	    $ECHO
5584af1a9c97Smrg	    if test "$linkmode" = prog; then
5585af1a9c97Smrg	      $ECHO "*** Warning: Linking the executable $output against the loadable module"
5586af1a9c97Smrg	    else
5587af1a9c97Smrg	      $ECHO "*** Warning: Linking the shared library $output against the loadable module"
5588af1a9c97Smrg	    fi
5589af1a9c97Smrg	    $ECHO "*** $linklib is not portable!"
5590af1a9c97Smrg	  fi
5591af1a9c97Smrg	  if test "$linkmode" = lib &&
5592af1a9c97Smrg	     test "$hardcode_into_libs" = yes; then
5593af1a9c97Smrg	    # Hardcode the library path.
5594af1a9c97Smrg	    # Skip directories that are in the system default run-time
5595af1a9c97Smrg	    # search path.
5596af1a9c97Smrg	    case " $sys_lib_dlsearch_path " in
5597af1a9c97Smrg	    *" $absdir "*) ;;
5598af1a9c97Smrg	    *)
5599af1a9c97Smrg	      case "$compile_rpath " in
5600af1a9c97Smrg	      *" $absdir "*) ;;
5601af1a9c97Smrg	      *) compile_rpath="$compile_rpath $absdir"
5602af1a9c97Smrg	      esac
5603af1a9c97Smrg	      ;;
5604af1a9c97Smrg	    esac
5605af1a9c97Smrg	    case " $sys_lib_dlsearch_path " in
5606af1a9c97Smrg	    *" $libdir "*) ;;
5607af1a9c97Smrg	    *)
5608af1a9c97Smrg	      case "$finalize_rpath " in
5609af1a9c97Smrg	      *" $libdir "*) ;;
5610af1a9c97Smrg	      *) finalize_rpath="$finalize_rpath $libdir"
5611af1a9c97Smrg	      esac
5612af1a9c97Smrg	      ;;
5613af1a9c97Smrg	    esac
5614af1a9c97Smrg	  fi
5615af1a9c97Smrg
5616af1a9c97Smrg	  if test -n "$old_archive_from_expsyms_cmds"; then
5617af1a9c97Smrg	    # figure out the soname
5618af1a9c97Smrg	    set dummy $library_names
5619af1a9c97Smrg	    shift
5620af1a9c97Smrg	    realname="$1"
5621af1a9c97Smrg	    shift
5622af1a9c97Smrg	    libname=`eval "\\$ECHO \"$libname_spec\""`
5623af1a9c97Smrg	    # use dlname if we got it. it's perfectly good, no?
5624af1a9c97Smrg	    if test -n "$dlname"; then
5625af1a9c97Smrg	      soname="$dlname"
5626af1a9c97Smrg	    elif test -n "$soname_spec"; then
5627af1a9c97Smrg	      # bleh windows
5628af1a9c97Smrg	      case $host in
5629af1a9c97Smrg	      *cygwin* | mingw* | *cegcc*)
5630af1a9c97Smrg	        func_arith $current - $age
5631af1a9c97Smrg		major=$func_arith_result
5632af1a9c97Smrg		versuffix="-$major"
5633af1a9c97Smrg		;;
5634af1a9c97Smrg	      esac
5635af1a9c97Smrg	      eval soname=\"$soname_spec\"
5636af1a9c97Smrg	    else
5637af1a9c97Smrg	      soname="$realname"
5638af1a9c97Smrg	    fi
5639af1a9c97Smrg
5640af1a9c97Smrg	    # Make a new name for the extract_expsyms_cmds to use
5641af1a9c97Smrg	    soroot="$soname"
5642af1a9c97Smrg	    func_basename "$soroot"
5643af1a9c97Smrg	    soname="$func_basename_result"
5644af1a9c97Smrg	    func_stripname 'lib' '.dll' "$soname"
5645af1a9c97Smrg	    newlib=libimp-$func_stripname_result.a
5646af1a9c97Smrg
5647af1a9c97Smrg	    # If the library has no export list, then create one now
5648af1a9c97Smrg	    if test -f "$output_objdir/$soname-def"; then :
5649af1a9c97Smrg	    else
5650af1a9c97Smrg	      func_verbose "extracting exported symbol list from \`$soname'"
5651af1a9c97Smrg	      func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
5652af1a9c97Smrg	    fi
5653af1a9c97Smrg
5654af1a9c97Smrg	    # Create $newlib
5655af1a9c97Smrg	    if test -f "$output_objdir/$newlib"; then :; else
5656af1a9c97Smrg	      func_verbose "generating import library for \`$soname'"
5657af1a9c97Smrg	      func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
5658af1a9c97Smrg	    fi
5659af1a9c97Smrg	    # make sure the library variables are pointing to the new library
5660af1a9c97Smrg	    dir=$output_objdir
5661af1a9c97Smrg	    linklib=$newlib
5662af1a9c97Smrg	  fi # test -n "$old_archive_from_expsyms_cmds"
5663af1a9c97Smrg
5664af1a9c97Smrg	  if test "$linkmode" = prog || test "$mode" != relink; then
5665af1a9c97Smrg	    add_shlibpath=
5666af1a9c97Smrg	    add_dir=
5667af1a9c97Smrg	    add=
5668af1a9c97Smrg	    lib_linked=yes
5669af1a9c97Smrg	    case $hardcode_action in
5670af1a9c97Smrg	    immediate | unsupported)
5671af1a9c97Smrg	      if test "$hardcode_direct" = no; then
5672af1a9c97Smrg		add="$dir/$linklib"
5673af1a9c97Smrg		case $host in
5674af1a9c97Smrg		  *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
5675af1a9c97Smrg		  *-*-sysv4*uw2*) add_dir="-L$dir" ;;
5676af1a9c97Smrg		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
5677af1a9c97Smrg		    *-*-unixware7*) add_dir="-L$dir" ;;
5678af1a9c97Smrg		  *-*-darwin* )
5679af1a9c97Smrg		    # if the lib is a (non-dlopened) module then we can not
5680af1a9c97Smrg		    # link against it, someone is ignoring the earlier warnings
5681af1a9c97Smrg		    if /usr/bin/file -L $add 2> /dev/null |
5682af1a9c97Smrg			 $GREP ": [^:]* bundle" >/dev/null ; then
5683af1a9c97Smrg		      if test "X$dlopenmodule" != "X$lib"; then
5684af1a9c97Smrg			$ECHO "*** Warning: lib $linklib is a module, not a shared library"
5685af1a9c97Smrg			if test -z "$old_library" ; then
5686af1a9c97Smrg			  $ECHO
5687af1a9c97Smrg			  $ECHO "*** And there doesn't seem to be a static archive available"
5688af1a9c97Smrg			  $ECHO "*** The link will probably fail, sorry"
5689af1a9c97Smrg			else
5690af1a9c97Smrg			  add="$dir/$old_library"
5691af1a9c97Smrg			fi
5692af1a9c97Smrg		      elif test -n "$old_library"; then
5693af1a9c97Smrg			add="$dir/$old_library"
5694af1a9c97Smrg		      fi
5695af1a9c97Smrg		    fi
5696af1a9c97Smrg		esac
5697af1a9c97Smrg	      elif test "$hardcode_minus_L" = no; then
5698af1a9c97Smrg		case $host in
5699af1a9c97Smrg		*-*-sunos*) add_shlibpath="$dir" ;;
5700af1a9c97Smrg		esac
5701af1a9c97Smrg		add_dir="-L$dir"
5702af1a9c97Smrg		add="-l$name"
5703af1a9c97Smrg	      elif test "$hardcode_shlibpath_var" = no; then
5704af1a9c97Smrg		add_shlibpath="$dir"
5705af1a9c97Smrg		add="-l$name"
5706af1a9c97Smrg	      else
5707af1a9c97Smrg		lib_linked=no
5708af1a9c97Smrg	      fi
5709af1a9c97Smrg	      ;;
5710af1a9c97Smrg	    relink)
5711af1a9c97Smrg	      if test "$hardcode_direct" = yes &&
5712af1a9c97Smrg	         test "$hardcode_direct_absolute" = no; then
5713af1a9c97Smrg		add="$dir/$linklib"
5714af1a9c97Smrg	      elif test "$hardcode_minus_L" = yes; then
5715af1a9c97Smrg		add_dir="-L$dir"
5716af1a9c97Smrg		# Try looking first in the location we're being installed to.
5717af1a9c97Smrg		if test -n "$inst_prefix_dir"; then
5718af1a9c97Smrg		  case $libdir in
5719af1a9c97Smrg		    [\\/]*)
5720af1a9c97Smrg		      add_dir="$add_dir -L$inst_prefix_dir$libdir"
5721af1a9c97Smrg		      ;;
5722af1a9c97Smrg		  esac
5723af1a9c97Smrg		fi
5724af1a9c97Smrg		add="-l$name"
5725af1a9c97Smrg	      elif test "$hardcode_shlibpath_var" = yes; then
5726af1a9c97Smrg		add_shlibpath="$dir"
5727af1a9c97Smrg		add="-l$name"
5728af1a9c97Smrg	      else
5729af1a9c97Smrg		lib_linked=no
5730af1a9c97Smrg	      fi
5731af1a9c97Smrg	      ;;
5732af1a9c97Smrg	    *) lib_linked=no ;;
5733af1a9c97Smrg	    esac
5734af1a9c97Smrg
5735af1a9c97Smrg	    if test "$lib_linked" != yes; then
5736af1a9c97Smrg	      func_fatal_configuration "unsupported hardcode properties"
5737af1a9c97Smrg	    fi
5738af1a9c97Smrg
5739af1a9c97Smrg	    if test -n "$add_shlibpath"; then
5740af1a9c97Smrg	      case :$compile_shlibpath: in
5741af1a9c97Smrg	      *":$add_shlibpath:"*) ;;
5742af1a9c97Smrg	      *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;;
5743af1a9c97Smrg	      esac
5744af1a9c97Smrg	    fi
5745af1a9c97Smrg	    if test "$linkmode" = prog; then
5746af1a9c97Smrg	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
5747af1a9c97Smrg	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
5748af1a9c97Smrg	    else
5749af1a9c97Smrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
5750af1a9c97Smrg	      test -n "$add" && deplibs="$add $deplibs"
5751af1a9c97Smrg	      if test "$hardcode_direct" != yes &&
5752af1a9c97Smrg		 test "$hardcode_minus_L" != yes &&
5753af1a9c97Smrg		 test "$hardcode_shlibpath_var" = yes; then
5754af1a9c97Smrg		case :$finalize_shlibpath: in
5755af1a9c97Smrg		*":$libdir:"*) ;;
5756af1a9c97Smrg		*) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
5757af1a9c97Smrg		esac
5758af1a9c97Smrg	      fi
5759af1a9c97Smrg	    fi
5760af1a9c97Smrg	  fi
5761af1a9c97Smrg
5762af1a9c97Smrg	  if test "$linkmode" = prog || test "$mode" = relink; then
5763af1a9c97Smrg	    add_shlibpath=
5764af1a9c97Smrg	    add_dir=
5765af1a9c97Smrg	    add=
5766af1a9c97Smrg	    # Finalize command for both is simple: just hardcode it.
5767af1a9c97Smrg	    if test "$hardcode_direct" = yes &&
5768af1a9c97Smrg	       test "$hardcode_direct_absolute" = no; then
5769af1a9c97Smrg	      add="$libdir/$linklib"
5770af1a9c97Smrg	    elif test "$hardcode_minus_L" = yes; then
5771af1a9c97Smrg	      add_dir="-L$libdir"
5772af1a9c97Smrg	      add="-l$name"
5773af1a9c97Smrg	    elif test "$hardcode_shlibpath_var" = yes; then
5774af1a9c97Smrg	      case :$finalize_shlibpath: in
5775af1a9c97Smrg	      *":$libdir:"*) ;;
5776af1a9c97Smrg	      *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
5777af1a9c97Smrg	      esac
5778af1a9c97Smrg	      add="-l$name"
5779af1a9c97Smrg	    elif test "$hardcode_automatic" = yes; then
5780af1a9c97Smrg	      if test -n "$inst_prefix_dir" &&
5781af1a9c97Smrg		 test -f "$inst_prefix_dir$libdir/$linklib" ; then
5782af1a9c97Smrg		add="$inst_prefix_dir$libdir/$linklib"
5783af1a9c97Smrg	      else
5784af1a9c97Smrg		add="$libdir/$linklib"
5785af1a9c97Smrg	      fi
5786af1a9c97Smrg	    else
5787af1a9c97Smrg	      # We cannot seem to hardcode it, guess we'll fake it.
5788af1a9c97Smrg	      add_dir="-L$libdir"
5789af1a9c97Smrg	      # Try looking first in the location we're being installed to.
5790af1a9c97Smrg	      if test -n "$inst_prefix_dir"; then
5791af1a9c97Smrg		case $libdir in
5792af1a9c97Smrg		  [\\/]*)
5793af1a9c97Smrg		    add_dir="$add_dir -L$inst_prefix_dir$libdir"
5794af1a9c97Smrg		    ;;
5795af1a9c97Smrg		esac
5796af1a9c97Smrg	      fi
5797af1a9c97Smrg	      add="-l$name"
5798af1a9c97Smrg	    fi
5799af1a9c97Smrg
5800af1a9c97Smrg	    if test "$linkmode" = prog; then
5801af1a9c97Smrg	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
5802af1a9c97Smrg	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
5803af1a9c97Smrg	    else
5804af1a9c97Smrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
5805af1a9c97Smrg	      test -n "$add" && deplibs="$add $deplibs"
5806af1a9c97Smrg	    fi
5807af1a9c97Smrg	  fi
5808af1a9c97Smrg	elif test "$linkmode" = prog; then
5809af1a9c97Smrg	  # Here we assume that one of hardcode_direct or hardcode_minus_L
5810af1a9c97Smrg	  # is not unsupported.  This is valid on all known static and
5811af1a9c97Smrg	  # shared platforms.
5812af1a9c97Smrg	  if test "$hardcode_direct" != unsupported; then
5813af1a9c97Smrg	    test -n "$old_library" && linklib="$old_library"
5814af1a9c97Smrg	    compile_deplibs="$dir/$linklib $compile_deplibs"
5815af1a9c97Smrg	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
5816af1a9c97Smrg	  else
5817af1a9c97Smrg	    compile_deplibs="-l$name -L$dir $compile_deplibs"
5818af1a9c97Smrg	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
5819af1a9c97Smrg	  fi
5820af1a9c97Smrg	elif test "$build_libtool_libs" = yes; then
5821af1a9c97Smrg	  # Not a shared library
5822af1a9c97Smrg	  if test "$deplibs_check_method" != pass_all; then
5823af1a9c97Smrg	    # We're trying link a shared library against a static one
5824af1a9c97Smrg	    # but the system doesn't support it.
5825af1a9c97Smrg
5826af1a9c97Smrg	    # Just print a warning and add the library to dependency_libs so
5827af1a9c97Smrg	    # that the program can be linked against the static library.
5828af1a9c97Smrg	    $ECHO
5829af1a9c97Smrg	    $ECHO "*** Warning: This system can not link to static lib archive $lib."
5830af1a9c97Smrg	    $ECHO "*** I have the capability to make that library automatically link in when"
5831af1a9c97Smrg	    $ECHO "*** you link to this library.  But I can only do this if you have a"
5832af1a9c97Smrg	    $ECHO "*** shared version of the library, which you do not appear to have."
5833af1a9c97Smrg	    if test "$module" = yes; then
5834af1a9c97Smrg	      $ECHO "*** But as you try to build a module library, libtool will still create "
5835af1a9c97Smrg	      $ECHO "*** a static module, that should work as long as the dlopening application"
5836af1a9c97Smrg	      $ECHO "*** is linked with the -dlopen flag to resolve symbols at runtime."
5837af1a9c97Smrg	      if test -z "$global_symbol_pipe"; then
5838af1a9c97Smrg		$ECHO
5839af1a9c97Smrg		$ECHO "*** However, this would only work if libtool was able to extract symbol"
5840af1a9c97Smrg		$ECHO "*** lists from a program, using \`nm' or equivalent, but libtool could"
5841af1a9c97Smrg		$ECHO "*** not find such a program.  So, this module is probably useless."
5842af1a9c97Smrg		$ECHO "*** \`nm' from GNU binutils and a full rebuild may help."
5843af1a9c97Smrg	      fi
5844af1a9c97Smrg	      if test "$build_old_libs" = no; then
5845af1a9c97Smrg		build_libtool_libs=module
5846af1a9c97Smrg		build_old_libs=yes
5847af1a9c97Smrg	      else
5848af1a9c97Smrg		build_libtool_libs=no
5849af1a9c97Smrg	      fi
5850af1a9c97Smrg	    fi
5851af1a9c97Smrg	  else
5852af1a9c97Smrg	    deplibs="$dir/$old_library $deplibs"
5853af1a9c97Smrg	    link_static=yes
5854af1a9c97Smrg	  fi
5855af1a9c97Smrg	fi # link shared/static library?
5856af1a9c97Smrg
5857af1a9c97Smrg	if test "$linkmode" = lib; then
5858af1a9c97Smrg	  if test -n "$dependency_libs" &&
5859af1a9c97Smrg	     { test "$hardcode_into_libs" != yes ||
5860af1a9c97Smrg	       test "$build_old_libs" = yes ||
5861af1a9c97Smrg	       test "$link_static" = yes; }; then
5862af1a9c97Smrg	    # Extract -R from dependency_libs
5863af1a9c97Smrg	    temp_deplibs=
5864af1a9c97Smrg	    for libdir in $dependency_libs; do
5865af1a9c97Smrg	      case $libdir in
5866af1a9c97Smrg	      -R*) func_stripname '-R' '' "$libdir"
5867af1a9c97Smrg	           temp_xrpath=$func_stripname_result
5868af1a9c97Smrg		   case " $xrpath " in
5869af1a9c97Smrg		   *" $temp_xrpath "*) ;;
5870af1a9c97Smrg		   *) xrpath="$xrpath $temp_xrpath";;
5871af1a9c97Smrg		   esac;;
5872af1a9c97Smrg	      *) temp_deplibs="$temp_deplibs $libdir";;
5873af1a9c97Smrg	      esac
5874af1a9c97Smrg	    done
5875af1a9c97Smrg	    dependency_libs="$temp_deplibs"
5876af1a9c97Smrg	  fi
5877af1a9c97Smrg
5878af1a9c97Smrg	  newlib_search_path="$newlib_search_path $absdir"
5879af1a9c97Smrg	  # Link against this library
5880af1a9c97Smrg	  test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
5881af1a9c97Smrg	  # ... and its dependency_libs
5882af1a9c97Smrg	  tmp_libs=
5883af1a9c97Smrg	  for deplib in $dependency_libs; do
5884af1a9c97Smrg	    newdependency_libs="$deplib $newdependency_libs"
5885af1a9c97Smrg	    if $opt_duplicate_deps ; then
5886af1a9c97Smrg	      case "$tmp_libs " in
5887af1a9c97Smrg	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
5888af1a9c97Smrg	      esac
5889af1a9c97Smrg	    fi
5890af1a9c97Smrg	    tmp_libs="$tmp_libs $deplib"
5891af1a9c97Smrg	  done
5892af1a9c97Smrg
5893af1a9c97Smrg	  if test "$link_all_deplibs" != no; then
5894af1a9c97Smrg	    # Add the search paths of all dependency libraries
5895af1a9c97Smrg	    for deplib in $dependency_libs; do
5896af1a9c97Smrg	      case $deplib in
5897af1a9c97Smrg	      -L*) path="$deplib" ;;
5898af1a9c97Smrg	      *.la)
5899af1a9c97Smrg	        func_dirname "$deplib" "" "."
5900af1a9c97Smrg		dir="$func_dirname_result"
5901af1a9c97Smrg		# We need an absolute path.
5902af1a9c97Smrg		case $dir in
5903af1a9c97Smrg		[\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
5904af1a9c97Smrg		*)
5905af1a9c97Smrg		  absdir=`cd "$dir" && pwd`
5906af1a9c97Smrg		  if test -z "$absdir"; then
5907af1a9c97Smrg		    func_warning "cannot determine absolute directory name of \`$dir'"
5908af1a9c97Smrg		    absdir="$dir"
5909af1a9c97Smrg		  fi
5910af1a9c97Smrg		  ;;
5911af1a9c97Smrg		esac
5912af1a9c97Smrg		if $GREP "^installed=no" $deplib > /dev/null; then
5913af1a9c97Smrg		case $host in
5914af1a9c97Smrg		*-*-darwin*)
5915af1a9c97Smrg		  depdepl=
5916af1a9c97Smrg		  eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
5917af1a9c97Smrg		  if test -n "$deplibrary_names" ; then
5918af1a9c97Smrg		    for tmp in $deplibrary_names ; do
5919af1a9c97Smrg		      depdepl=$tmp
5920af1a9c97Smrg		    done
5921af1a9c97Smrg		    if test -f "$absdir/$objdir/$depdepl" ; then
5922af1a9c97Smrg		      depdepl="$absdir/$objdir/$depdepl"
5923af1a9c97Smrg		      darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
5924af1a9c97Smrg                      if test -z "$darwin_install_name"; then
5925af1a9c97Smrg                          darwin_install_name=`${OTOOL64} -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
5926af1a9c97Smrg                      fi
5927af1a9c97Smrg		      compiler_flags="$compiler_flags ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}"
5928af1a9c97Smrg		      linker_flags="$linker_flags -dylib_file ${darwin_install_name}:${depdepl}"
5929af1a9c97Smrg		      path=
5930af1a9c97Smrg		    fi
5931af1a9c97Smrg		  fi
5932af1a9c97Smrg		  ;;
5933af1a9c97Smrg		*)
5934af1a9c97Smrg		  path="-L$absdir/$objdir"
5935af1a9c97Smrg		  ;;
5936af1a9c97Smrg		esac
5937af1a9c97Smrg		else
5938af1a9c97Smrg		  eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
5939af1a9c97Smrg		  test -z "$libdir" && \
5940af1a9c97Smrg		    func_fatal_error "\`$deplib' is not a valid libtool archive"
5941af1a9c97Smrg		  test "$absdir" != "$libdir" && \
5942af1a9c97Smrg		    func_warning "\`$deplib' seems to be moved"
5943af1a9c97Smrg
5944af1a9c97Smrg		  path="-L$absdir"
5945af1a9c97Smrg		fi
5946af1a9c97Smrg		;;
5947af1a9c97Smrg	      esac
5948af1a9c97Smrg	      case " $deplibs " in
5949af1a9c97Smrg	      *" $path "*) ;;
5950af1a9c97Smrg	      *) deplibs="$path $deplibs" ;;
5951af1a9c97Smrg	      esac
5952af1a9c97Smrg	    done
5953af1a9c97Smrg	  fi # link_all_deplibs != no
5954af1a9c97Smrg	fi # linkmode = lib
5955af1a9c97Smrg      done # for deplib in $libs
5956af1a9c97Smrg      if test "$pass" = link; then
5957af1a9c97Smrg	if test "$linkmode" = "prog"; then
5958af1a9c97Smrg	  compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
5959af1a9c97Smrg	  finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
5960af1a9c97Smrg	else
5961af1a9c97Smrg	  compiler_flags="$compiler_flags "`$ECHO "X $new_inherited_linker_flags" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
5962af1a9c97Smrg	fi
5963af1a9c97Smrg      fi
5964af1a9c97Smrg      dependency_libs="$newdependency_libs"
5965af1a9c97Smrg      if test "$pass" = dlpreopen; then
5966af1a9c97Smrg	# Link the dlpreopened libraries before other libraries
5967af1a9c97Smrg	for deplib in $save_deplibs; do
5968af1a9c97Smrg	  deplibs="$deplib $deplibs"
5969af1a9c97Smrg	done
5970af1a9c97Smrg      fi
5971af1a9c97Smrg      if test "$pass" != dlopen; then
5972af1a9c97Smrg	if test "$pass" != conv; then
5973af1a9c97Smrg	  # Make sure lib_search_path contains only unique directories.
5974af1a9c97Smrg	  lib_search_path=
5975af1a9c97Smrg	  for dir in $newlib_search_path; do
5976af1a9c97Smrg	    case "$lib_search_path " in
5977af1a9c97Smrg	    *" $dir "*) ;;
5978af1a9c97Smrg	    *) lib_search_path="$lib_search_path $dir" ;;
5979af1a9c97Smrg	    esac
5980af1a9c97Smrg	  done
5981af1a9c97Smrg	  newlib_search_path=
5982af1a9c97Smrg	fi
5983af1a9c97Smrg
5984af1a9c97Smrg	if test "$linkmode,$pass" != "prog,link"; then
5985af1a9c97Smrg	  vars="deplibs"
5986af1a9c97Smrg	else
5987af1a9c97Smrg	  vars="compile_deplibs finalize_deplibs"
5988af1a9c97Smrg	fi
5989af1a9c97Smrg	for var in $vars dependency_libs; do
5990af1a9c97Smrg	  # Add libraries to $var in reverse order
5991af1a9c97Smrg	  eval tmp_libs=\"\$$var\"
5992af1a9c97Smrg	  new_libs=
5993af1a9c97Smrg	  for deplib in $tmp_libs; do
5994af1a9c97Smrg	    # FIXME: Pedantically, this is the right thing to do, so
5995af1a9c97Smrg	    #        that some nasty dependency loop isn't accidentally
5996af1a9c97Smrg	    #        broken:
5997af1a9c97Smrg	    #new_libs="$deplib $new_libs"
5998af1a9c97Smrg	    # Pragmatically, this seems to cause very few problems in
5999af1a9c97Smrg	    # practice:
6000af1a9c97Smrg	    case $deplib in
6001af1a9c97Smrg	    -L*) new_libs="$deplib $new_libs" ;;
6002af1a9c97Smrg	    -R*) ;;
6003af1a9c97Smrg	    *)
6004af1a9c97Smrg	      # And here is the reason: when a library appears more
6005af1a9c97Smrg	      # than once as an explicit dependence of a library, or
6006af1a9c97Smrg	      # is implicitly linked in more than once by the
6007af1a9c97Smrg	      # compiler, it is considered special, and multiple
6008af1a9c97Smrg	      # occurrences thereof are not removed.  Compare this
6009af1a9c97Smrg	      # with having the same library being listed as a
6010af1a9c97Smrg	      # dependency of multiple other libraries: in this case,
6011af1a9c97Smrg	      # we know (pedantically, we assume) the library does not
6012af1a9c97Smrg	      # need to be listed more than once, so we keep only the
6013af1a9c97Smrg	      # last copy.  This is not always right, but it is rare
6014af1a9c97Smrg	      # enough that we require users that really mean to play
6015af1a9c97Smrg	      # such unportable linking tricks to link the library
6016af1a9c97Smrg	      # using -Wl,-lname, so that libtool does not consider it
6017af1a9c97Smrg	      # for duplicate removal.
6018af1a9c97Smrg	      case " $specialdeplibs " in
6019af1a9c97Smrg	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
6020af1a9c97Smrg	      *)
6021af1a9c97Smrg		case " $new_libs " in
6022af1a9c97Smrg		*" $deplib "*) ;;
6023af1a9c97Smrg		*) new_libs="$deplib $new_libs" ;;
6024af1a9c97Smrg		esac
6025af1a9c97Smrg		;;
6026af1a9c97Smrg	      esac
6027af1a9c97Smrg	      ;;
6028af1a9c97Smrg	    esac
6029af1a9c97Smrg	  done
6030af1a9c97Smrg	  tmp_libs=
6031af1a9c97Smrg	  for deplib in $new_libs; do
6032af1a9c97Smrg	    case $deplib in
6033af1a9c97Smrg	    -L*)
6034af1a9c97Smrg	      case " $tmp_libs " in
6035af1a9c97Smrg	      *" $deplib "*) ;;
6036af1a9c97Smrg	      *) tmp_libs="$tmp_libs $deplib" ;;
6037af1a9c97Smrg	      esac
6038af1a9c97Smrg	      ;;
6039af1a9c97Smrg	    *) tmp_libs="$tmp_libs $deplib" ;;
6040af1a9c97Smrg	    esac
6041af1a9c97Smrg	  done
6042af1a9c97Smrg	  eval $var=\"$tmp_libs\"
6043af1a9c97Smrg	done # for var
6044af1a9c97Smrg      fi
6045af1a9c97Smrg      # Last step: remove runtime libs from dependency_libs
6046af1a9c97Smrg      # (they stay in deplibs)
6047af1a9c97Smrg      tmp_libs=
6048af1a9c97Smrg      for i in $dependency_libs ; do
6049af1a9c97Smrg	case " $predeps $postdeps $compiler_lib_search_path " in
6050af1a9c97Smrg	*" $i "*)
6051af1a9c97Smrg	  i=""
6052af1a9c97Smrg	  ;;
6053af1a9c97Smrg	esac
6054af1a9c97Smrg	if test -n "$i" ; then
6055af1a9c97Smrg	  tmp_libs="$tmp_libs $i"
6056af1a9c97Smrg	fi
6057af1a9c97Smrg      done
6058af1a9c97Smrg      dependency_libs=$tmp_libs
6059af1a9c97Smrg    done # for pass
6060af1a9c97Smrg    if test "$linkmode" = prog; then
6061af1a9c97Smrg      dlfiles="$newdlfiles"
6062af1a9c97Smrg    fi
6063af1a9c97Smrg    if test "$linkmode" = prog || test "$linkmode" = lib; then
6064af1a9c97Smrg      dlprefiles="$newdlprefiles"
6065af1a9c97Smrg    fi
6066af1a9c97Smrg
6067af1a9c97Smrg    case $linkmode in
6068af1a9c97Smrg    oldlib)
6069af1a9c97Smrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
6070af1a9c97Smrg	func_warning "\`-dlopen' is ignored for archives"
6071af1a9c97Smrg      fi
6072af1a9c97Smrg
6073af1a9c97Smrg      case " $deplibs" in
6074af1a9c97Smrg      *\ -l* | *\ -L*)
6075af1a9c97Smrg	func_warning "\`-l' and \`-L' are ignored for archives" ;;
6076af1a9c97Smrg      esac
6077af1a9c97Smrg
6078af1a9c97Smrg      test -n "$rpath" && \
6079af1a9c97Smrg	func_warning "\`-rpath' is ignored for archives"
6080af1a9c97Smrg
6081af1a9c97Smrg      test -n "$xrpath" && \
6082af1a9c97Smrg	func_warning "\`-R' is ignored for archives"
6083af1a9c97Smrg
6084af1a9c97Smrg      test -n "$vinfo" && \
6085af1a9c97Smrg	func_warning "\`-version-info/-version-number' is ignored for archives"
6086af1a9c97Smrg
6087af1a9c97Smrg      test -n "$release" && \
6088af1a9c97Smrg	func_warning "\`-release' is ignored for archives"
6089af1a9c97Smrg
6090af1a9c97Smrg      test -n "$export_symbols$export_symbols_regex" && \
6091af1a9c97Smrg	func_warning "\`-export-symbols' is ignored for archives"
6092af1a9c97Smrg
6093af1a9c97Smrg      # Now set the variables for building old libraries.
6094af1a9c97Smrg      build_libtool_libs=no
6095af1a9c97Smrg      oldlibs="$output"
6096af1a9c97Smrg      objs="$objs$old_deplibs"
6097af1a9c97Smrg      ;;
6098af1a9c97Smrg
6099af1a9c97Smrg    lib)
6100af1a9c97Smrg      # Make sure we only generate libraries of the form `libNAME.la'.
6101af1a9c97Smrg      case $outputname in
6102af1a9c97Smrg      lib*)
6103af1a9c97Smrg	func_stripname 'lib' '.la' "$outputname"
6104af1a9c97Smrg	name=$func_stripname_result
6105af1a9c97Smrg	eval shared_ext=\"$shrext_cmds\"
6106af1a9c97Smrg	eval libname=\"$libname_spec\"
6107af1a9c97Smrg	;;
6108af1a9c97Smrg      *)
6109af1a9c97Smrg	test "$module" = no && \
6110af1a9c97Smrg	  func_fatal_help "libtool library \`$output' must begin with \`lib'"
6111af1a9c97Smrg
6112af1a9c97Smrg	if test "$need_lib_prefix" != no; then
6113af1a9c97Smrg	  # Add the "lib" prefix for modules if required
6114af1a9c97Smrg	  func_stripname '' '.la' "$outputname"
6115af1a9c97Smrg	  name=$func_stripname_result
6116af1a9c97Smrg	  eval shared_ext=\"$shrext_cmds\"
6117af1a9c97Smrg	  eval libname=\"$libname_spec\"
6118af1a9c97Smrg	else
6119af1a9c97Smrg	  func_stripname '' '.la' "$outputname"
6120af1a9c97Smrg	  libname=$func_stripname_result
6121af1a9c97Smrg	fi
6122af1a9c97Smrg	;;
6123af1a9c97Smrg      esac
6124af1a9c97Smrg
6125af1a9c97Smrg      if test -n "$objs"; then
6126af1a9c97Smrg	if test "$deplibs_check_method" != pass_all; then
6127af1a9c97Smrg	  func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs"
6128af1a9c97Smrg	else
6129af1a9c97Smrg	  $ECHO
6130af1a9c97Smrg	  $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
6131af1a9c97Smrg	  $ECHO "*** objects $objs is not portable!"
6132af1a9c97Smrg	  libobjs="$libobjs $objs"
6133af1a9c97Smrg	fi
6134af1a9c97Smrg      fi
6135af1a9c97Smrg
6136af1a9c97Smrg      test "$dlself" != no && \
6137af1a9c97Smrg	func_warning "\`-dlopen self' is ignored for libtool libraries"
6138af1a9c97Smrg
6139af1a9c97Smrg      set dummy $rpath
6140af1a9c97Smrg      shift
6141af1a9c97Smrg      test "$#" -gt 1 && \
6142af1a9c97Smrg	func_warning "ignoring multiple \`-rpath's for a libtool library"
6143af1a9c97Smrg
6144af1a9c97Smrg      install_libdir="$1"
6145af1a9c97Smrg
6146af1a9c97Smrg      oldlibs=
6147af1a9c97Smrg      if test -z "$rpath"; then
6148af1a9c97Smrg	if test "$build_libtool_libs" = yes; then
6149af1a9c97Smrg	  # Building a libtool convenience library.
6150af1a9c97Smrg	  # Some compilers have problems with a `.al' extension so
6151af1a9c97Smrg	  # convenience libraries should have the same extension an
6152af1a9c97Smrg	  # archive normally would.
6153af1a9c97Smrg	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
6154af1a9c97Smrg	  build_libtool_libs=convenience
6155af1a9c97Smrg	  build_old_libs=yes
6156af1a9c97Smrg	fi
6157af1a9c97Smrg
6158af1a9c97Smrg	test -n "$vinfo" && \
6159af1a9c97Smrg	  func_warning "\`-version-info/-version-number' is ignored for convenience libraries"
6160af1a9c97Smrg
6161af1a9c97Smrg	test -n "$release" && \
6162af1a9c97Smrg	  func_warning "\`-release' is ignored for convenience libraries"
6163af1a9c97Smrg      else
6164af1a9c97Smrg
6165af1a9c97Smrg	# Parse the version information argument.
6166af1a9c97Smrg	save_ifs="$IFS"; IFS=':'
6167af1a9c97Smrg	set dummy $vinfo 0 0 0
6168af1a9c97Smrg	shift
6169af1a9c97Smrg	IFS="$save_ifs"
6170af1a9c97Smrg
6171af1a9c97Smrg	test -n "$7" && \
6172af1a9c97Smrg	  func_fatal_help "too many parameters to \`-version-info'"
6173af1a9c97Smrg
6174af1a9c97Smrg	# convert absolute version numbers to libtool ages
6175af1a9c97Smrg	# this retains compatibility with .la files and attempts
6176af1a9c97Smrg	# to make the code below a bit more comprehensible
6177af1a9c97Smrg
6178af1a9c97Smrg	case $vinfo_number in
6179af1a9c97Smrg	yes)
6180af1a9c97Smrg	  number_major="$1"
6181af1a9c97Smrg	  number_minor="$2"
6182af1a9c97Smrg	  number_revision="$3"
6183af1a9c97Smrg	  #
6184af1a9c97Smrg	  # There are really only two kinds -- those that
6185af1a9c97Smrg	  # use the current revision as the major version
6186af1a9c97Smrg	  # and those that subtract age and use age as
6187af1a9c97Smrg	  # a minor version.  But, then there is irix
6188af1a9c97Smrg	  # which has an extra 1 added just for fun
6189af1a9c97Smrg	  #
6190af1a9c97Smrg	  case $version_type in
6191af1a9c97Smrg	  darwin|linux|osf|windows|none)
6192af1a9c97Smrg	    func_arith $number_major + $number_minor
6193af1a9c97Smrg	    current=$func_arith_result
6194af1a9c97Smrg	    age="$number_minor"
6195af1a9c97Smrg	    revision="$number_revision"
6196af1a9c97Smrg	    ;;
6197af1a9c97Smrg	  freebsd-aout|freebsd-elf|sunos)
6198af1a9c97Smrg	    current="$number_major"
6199af1a9c97Smrg	    revision="$number_minor"
6200af1a9c97Smrg	    age="0"
6201af1a9c97Smrg	    ;;
6202af1a9c97Smrg	  irix|nonstopux)
6203af1a9c97Smrg	    func_arith $number_major + $number_minor
6204af1a9c97Smrg	    current=$func_arith_result
6205af1a9c97Smrg	    age="$number_minor"
6206af1a9c97Smrg	    revision="$number_minor"
6207af1a9c97Smrg	    lt_irix_increment=no
6208af1a9c97Smrg	    ;;
6209af1a9c97Smrg	  esac
6210af1a9c97Smrg	  ;;
6211af1a9c97Smrg	no)
6212af1a9c97Smrg	  current="$1"
6213af1a9c97Smrg	  revision="$2"
6214af1a9c97Smrg	  age="$3"
6215af1a9c97Smrg	  ;;
6216af1a9c97Smrg	esac
6217af1a9c97Smrg
6218af1a9c97Smrg	# Check that each of the things are valid numbers.
6219af1a9c97Smrg	case $current in
6220af1a9c97Smrg	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]) ;;
6221af1a9c97Smrg	*)
6222af1a9c97Smrg	  func_error "CURRENT \`$current' must be a nonnegative integer"
6223af1a9c97Smrg	  func_fatal_error "\`$vinfo' is not valid version information"
6224af1a9c97Smrg	  ;;
6225af1a9c97Smrg	esac
6226af1a9c97Smrg
6227af1a9c97Smrg	case $revision in
6228af1a9c97Smrg	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]) ;;
6229af1a9c97Smrg	*)
6230af1a9c97Smrg	  func_error "REVISION \`$revision' must be a nonnegative integer"
6231af1a9c97Smrg	  func_fatal_error "\`$vinfo' is not valid version information"
6232af1a9c97Smrg	  ;;
6233af1a9c97Smrg	esac
6234af1a9c97Smrg
6235af1a9c97Smrg	case $age in
6236af1a9c97Smrg	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]) ;;
6237af1a9c97Smrg	*)
6238af1a9c97Smrg	  func_error "AGE \`$age' must be a nonnegative integer"
6239af1a9c97Smrg	  func_fatal_error "\`$vinfo' is not valid version information"
6240af1a9c97Smrg	  ;;
6241af1a9c97Smrg	esac
6242af1a9c97Smrg
6243af1a9c97Smrg	if test "$age" -gt "$current"; then
6244af1a9c97Smrg	  func_error "AGE \`$age' is greater than the current interface number \`$current'"
6245af1a9c97Smrg	  func_fatal_error "\`$vinfo' is not valid version information"
6246af1a9c97Smrg	fi
6247af1a9c97Smrg
6248af1a9c97Smrg	# Calculate the version variables.
6249af1a9c97Smrg	major=
6250af1a9c97Smrg	versuffix=
6251af1a9c97Smrg	verstring=
6252af1a9c97Smrg	case $version_type in
6253af1a9c97Smrg	none) ;;
6254af1a9c97Smrg
6255af1a9c97Smrg	darwin)
6256af1a9c97Smrg	  # Like Linux, but with the current version available in
6257af1a9c97Smrg	  # verstring for coding it into the library header
6258af1a9c97Smrg	  func_arith $current - $age
6259af1a9c97Smrg	  major=.$func_arith_result
6260af1a9c97Smrg	  versuffix="$major.$age.$revision"
6261af1a9c97Smrg	  # Darwin ld doesn't like 0 for these options...
6262af1a9c97Smrg	  func_arith $current + 1
6263af1a9c97Smrg	  minor_current=$func_arith_result
6264af1a9c97Smrg	  xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
6265af1a9c97Smrg	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
6266af1a9c97Smrg	  ;;
6267af1a9c97Smrg
6268af1a9c97Smrg	freebsd-aout)
6269af1a9c97Smrg	  major=".$current"
6270af1a9c97Smrg	  versuffix=".$current.$revision";
6271af1a9c97Smrg	  ;;
6272af1a9c97Smrg
6273af1a9c97Smrg	freebsd-elf)
6274af1a9c97Smrg	  major=".$current"
6275af1a9c97Smrg	  versuffix=".$current"
6276af1a9c97Smrg	  ;;
6277af1a9c97Smrg
6278af1a9c97Smrg	irix | nonstopux)
6279af1a9c97Smrg	  if test "X$lt_irix_increment" = "Xno"; then
6280af1a9c97Smrg	    func_arith $current - $age
6281af1a9c97Smrg	  else
6282af1a9c97Smrg	    func_arith $current - $age + 1
6283af1a9c97Smrg	  fi
6284af1a9c97Smrg	  major=$func_arith_result
6285af1a9c97Smrg
6286af1a9c97Smrg	  case $version_type in
6287af1a9c97Smrg	    nonstopux) verstring_prefix=nonstopux ;;
6288af1a9c97Smrg	    *)         verstring_prefix=sgi ;;
6289af1a9c97Smrg	  esac
6290af1a9c97Smrg	  verstring="$verstring_prefix$major.$revision"
6291af1a9c97Smrg
6292af1a9c97Smrg	  # Add in all the interfaces that we are compatible with.
6293af1a9c97Smrg	  loop=$revision
6294af1a9c97Smrg	  while test "$loop" -ne 0; do
6295af1a9c97Smrg	    func_arith $revision - $loop
6296af1a9c97Smrg	    iface=$func_arith_result
6297af1a9c97Smrg	    func_arith $loop - 1
6298af1a9c97Smrg	    loop=$func_arith_result
6299af1a9c97Smrg	    verstring="$verstring_prefix$major.$iface:$verstring"
6300af1a9c97Smrg	  done
6301af1a9c97Smrg
6302af1a9c97Smrg	  # Before this point, $major must not contain `.'.
6303af1a9c97Smrg	  major=.$major
6304af1a9c97Smrg	  versuffix="$major.$revision"
6305af1a9c97Smrg	  ;;
6306af1a9c97Smrg
6307af1a9c97Smrg	linux)
6308af1a9c97Smrg	  func_arith $current - $age
6309af1a9c97Smrg	  major=.$func_arith_result
6310af1a9c97Smrg	  versuffix="$major.$age.$revision"
6311af1a9c97Smrg	  ;;
6312af1a9c97Smrg
6313af1a9c97Smrg	osf)
6314af1a9c97Smrg	  func_arith $current - $age
6315af1a9c97Smrg	  major=.$func_arith_result
6316af1a9c97Smrg	  versuffix=".$current.$age.$revision"
6317af1a9c97Smrg	  verstring="$current.$age.$revision"
6318af1a9c97Smrg
6319af1a9c97Smrg	  # Add in all the interfaces that we are compatible with.
6320af1a9c97Smrg	  loop=$age
6321af1a9c97Smrg	  while test "$loop" -ne 0; do
6322af1a9c97Smrg	    func_arith $current - $loop
6323af1a9c97Smrg	    iface=$func_arith_result
6324af1a9c97Smrg	    func_arith $loop - 1
6325af1a9c97Smrg	    loop=$func_arith_result
6326af1a9c97Smrg	    verstring="$verstring:${iface}.0"
6327af1a9c97Smrg	  done
6328af1a9c97Smrg
6329af1a9c97Smrg	  # Make executables depend on our current version.
6330af1a9c97Smrg	  verstring="$verstring:${current}.0"
6331af1a9c97Smrg	  ;;
6332af1a9c97Smrg
6333af1a9c97Smrg	qnx)
6334af1a9c97Smrg	  major=".$current"
6335af1a9c97Smrg	  versuffix=".$current"
6336af1a9c97Smrg	  ;;
6337af1a9c97Smrg
6338af1a9c97Smrg	sunos)
6339af1a9c97Smrg	  major=".$current"
6340af1a9c97Smrg	  versuffix=".$current.$revision"
6341af1a9c97Smrg	  ;;
6342af1a9c97Smrg
6343af1a9c97Smrg	windows)
6344af1a9c97Smrg	  # Use '-' rather than '.', since we only want one
6345af1a9c97Smrg	  # extension on DOS 8.3 filesystems.
6346af1a9c97Smrg	  func_arith $current - $age
6347af1a9c97Smrg	  major=$func_arith_result
6348af1a9c97Smrg	  versuffix="-$major"
6349af1a9c97Smrg	  ;;
6350af1a9c97Smrg
6351af1a9c97Smrg	*)
6352af1a9c97Smrg	  func_fatal_configuration "unknown library version type \`$version_type'"
6353af1a9c97Smrg	  ;;
6354af1a9c97Smrg	esac
6355af1a9c97Smrg
6356af1a9c97Smrg	# Clear the version info if we defaulted, and they specified a release.
6357af1a9c97Smrg	if test -z "$vinfo" && test -n "$release"; then
6358af1a9c97Smrg	  major=
6359af1a9c97Smrg	  case $version_type in
6360af1a9c97Smrg	  darwin)
6361af1a9c97Smrg	    # we can't check for "0.0" in archive_cmds due to quoting
6362af1a9c97Smrg	    # problems, so we reset it completely
6363af1a9c97Smrg	    verstring=
6364af1a9c97Smrg	    ;;
6365af1a9c97Smrg	  *)
6366af1a9c97Smrg	    verstring="0.0"
6367af1a9c97Smrg	    ;;
6368af1a9c97Smrg	  esac
6369af1a9c97Smrg	  if test "$need_version" = no; then
6370af1a9c97Smrg	    versuffix=
6371af1a9c97Smrg	  else
6372af1a9c97Smrg	    versuffix=".0.0"
6373af1a9c97Smrg	  fi
6374af1a9c97Smrg	fi
6375af1a9c97Smrg
6376af1a9c97Smrg	# Remove version info from name if versioning should be avoided
6377af1a9c97Smrg	if test "$avoid_version" = yes && test "$need_version" = no; then
6378af1a9c97Smrg	  major=
6379af1a9c97Smrg	  versuffix=
6380af1a9c97Smrg	  verstring=""
6381af1a9c97Smrg	fi
6382af1a9c97Smrg
6383af1a9c97Smrg	# Check to see if the archive will have undefined symbols.
6384af1a9c97Smrg	if test "$allow_undefined" = yes; then
6385af1a9c97Smrg	  if test "$allow_undefined_flag" = unsupported; then
6386af1a9c97Smrg	    func_warning "undefined symbols not allowed in $host shared libraries"
6387af1a9c97Smrg	    build_libtool_libs=no
6388af1a9c97Smrg	    build_old_libs=yes
6389af1a9c97Smrg	  fi
6390af1a9c97Smrg	else
6391af1a9c97Smrg	  # Don't allow undefined symbols.
6392af1a9c97Smrg	  allow_undefined_flag="$no_undefined_flag"
6393af1a9c97Smrg	fi
6394af1a9c97Smrg
6395af1a9c97Smrg      fi
6396af1a9c97Smrg
6397af1a9c97Smrg      func_generate_dlsyms "$libname" "$libname" "yes"
6398af1a9c97Smrg      libobjs="$libobjs $symfileobj"
6399af1a9c97Smrg      test "X$libobjs" = "X " && libobjs=
6400af1a9c97Smrg
6401af1a9c97Smrg      if test "$mode" != relink; then
6402af1a9c97Smrg	# Remove our outputs, but don't remove object files since they
6403af1a9c97Smrg	# may have been created when compiling PIC objects.
6404af1a9c97Smrg	removelist=
6405af1a9c97Smrg	tempremovelist=`$ECHO "$output_objdir/*"`
6406af1a9c97Smrg	for p in $tempremovelist; do
6407af1a9c97Smrg	  case $p in
6408af1a9c97Smrg	    *.$objext | *.gcno)
6409af1a9c97Smrg	       ;;
6410af1a9c97Smrg	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
6411af1a9c97Smrg	       if test "X$precious_files_regex" != "X"; then
6412af1a9c97Smrg		 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
6413af1a9c97Smrg		 then
6414af1a9c97Smrg		   continue
6415af1a9c97Smrg		 fi
6416af1a9c97Smrg	       fi
6417af1a9c97Smrg	       removelist="$removelist $p"
6418af1a9c97Smrg	       ;;
6419af1a9c97Smrg	    *) ;;
6420af1a9c97Smrg	  esac
6421af1a9c97Smrg	done
6422af1a9c97Smrg	test -n "$removelist" && \
6423af1a9c97Smrg	  func_show_eval "${RM}r \$removelist"
6424af1a9c97Smrg      fi
6425af1a9c97Smrg
6426af1a9c97Smrg      # Now set the variables for building old libraries.
6427af1a9c97Smrg      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
6428af1a9c97Smrg	oldlibs="$oldlibs $output_objdir/$libname.$libext"
6429af1a9c97Smrg
6430af1a9c97Smrg	# Transform .lo files to .o files.
6431af1a9c97Smrg	oldobjs="$objs "`$ECHO "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP`
6432af1a9c97Smrg      fi
6433af1a9c97Smrg
6434af1a9c97Smrg      # Eliminate all temporary directories.
6435af1a9c97Smrg      #for path in $notinst_path; do
6436af1a9c97Smrg      #	lib_search_path=`$ECHO "X$lib_search_path " | $Xsed -e "s% $path % %g"`
6437af1a9c97Smrg      #	deplibs=`$ECHO "X$deplibs " | $Xsed -e "s% -L$path % %g"`
6438af1a9c97Smrg      #	dependency_libs=`$ECHO "X$dependency_libs " | $Xsed -e "s% -L$path % %g"`
6439af1a9c97Smrg      #done
6440af1a9c97Smrg
6441af1a9c97Smrg      if test -n "$xrpath"; then
6442af1a9c97Smrg	# If the user specified any rpath flags, then add them.
6443af1a9c97Smrg	temp_xrpath=
6444af1a9c97Smrg	for libdir in $xrpath; do
6445af1a9c97Smrg	  temp_xrpath="$temp_xrpath -R$libdir"
6446af1a9c97Smrg	  case "$finalize_rpath " in
6447af1a9c97Smrg	  *" $libdir "*) ;;
6448af1a9c97Smrg	  *) finalize_rpath="$finalize_rpath $libdir" ;;
6449af1a9c97Smrg	  esac
6450af1a9c97Smrg	done
6451af1a9c97Smrg	if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
6452af1a9c97Smrg	  dependency_libs="$temp_xrpath $dependency_libs"
6453af1a9c97Smrg	fi
6454af1a9c97Smrg      fi
6455af1a9c97Smrg
6456af1a9c97Smrg      # Make sure dlfiles contains only unique files that won't be dlpreopened
6457af1a9c97Smrg      old_dlfiles="$dlfiles"
6458af1a9c97Smrg      dlfiles=
6459af1a9c97Smrg      for lib in $old_dlfiles; do
6460af1a9c97Smrg	case " $dlprefiles $dlfiles " in
6461af1a9c97Smrg	*" $lib "*) ;;
6462af1a9c97Smrg	*) dlfiles="$dlfiles $lib" ;;
6463af1a9c97Smrg	esac
6464af1a9c97Smrg      done
6465af1a9c97Smrg
6466af1a9c97Smrg      # Make sure dlprefiles contains only unique files
6467af1a9c97Smrg      old_dlprefiles="$dlprefiles"
6468af1a9c97Smrg      dlprefiles=
6469af1a9c97Smrg      for lib in $old_dlprefiles; do
6470af1a9c97Smrg	case "$dlprefiles " in
6471af1a9c97Smrg	*" $lib "*) ;;
6472af1a9c97Smrg	*) dlprefiles="$dlprefiles $lib" ;;
6473af1a9c97Smrg	esac
6474af1a9c97Smrg      done
6475af1a9c97Smrg
6476af1a9c97Smrg      if test "$build_libtool_libs" = yes; then
6477af1a9c97Smrg	if test -n "$rpath"; then
6478af1a9c97Smrg	  case $host in
6479af1a9c97Smrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc*)
6480af1a9c97Smrg	    # these systems don't actually have a c library (as such)!
6481af1a9c97Smrg	    ;;
6482af1a9c97Smrg	  *-*-rhapsody* | *-*-darwin1.[012])
6483af1a9c97Smrg	    # Rhapsody C library is in the System framework
6484af1a9c97Smrg	    deplibs="$deplibs System.ltframework"
6485af1a9c97Smrg	    ;;
6486af1a9c97Smrg	  *-*-netbsd*)
6487af1a9c97Smrg	    # Don't link with libc until the a.out ld.so is fixed.
6488af1a9c97Smrg	    ;;
6489af1a9c97Smrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
6490af1a9c97Smrg	    # Do not include libc due to us having libc/libc_r.
6491af1a9c97Smrg	    ;;
6492af1a9c97Smrg	  *-*-sco3.2v5* | *-*-sco5v6*)
6493af1a9c97Smrg	    # Causes problems with __ctype
6494af1a9c97Smrg	    ;;
6495af1a9c97Smrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
6496af1a9c97Smrg	    # Compiler inserts libc in the correct place for threads to work
6497af1a9c97Smrg	    ;;
6498af1a9c97Smrg	  *)
6499af1a9c97Smrg	    # Add libc to deplibs on all other systems if necessary.
6500af1a9c97Smrg	    if test "$build_libtool_need_lc" = "yes"; then
6501af1a9c97Smrg	      deplibs="$deplibs -lc"
6502af1a9c97Smrg	    fi
6503af1a9c97Smrg	    ;;
6504af1a9c97Smrg	  esac
6505af1a9c97Smrg	fi
6506af1a9c97Smrg
6507af1a9c97Smrg	# Transform deplibs into only deplibs that can be linked in shared.
6508af1a9c97Smrg	name_save=$name
6509af1a9c97Smrg	libname_save=$libname
6510af1a9c97Smrg	release_save=$release
6511af1a9c97Smrg	versuffix_save=$versuffix
6512af1a9c97Smrg	major_save=$major
6513af1a9c97Smrg	# I'm not sure if I'm treating the release correctly.  I think
6514af1a9c97Smrg	# release should show up in the -l (ie -lgmp5) so we don't want to
6515af1a9c97Smrg	# add it in twice.  Is that correct?
6516af1a9c97Smrg	release=""
6517af1a9c97Smrg	versuffix=""
6518af1a9c97Smrg	major=""
6519af1a9c97Smrg	newdeplibs=
6520af1a9c97Smrg	droppeddeps=no
6521af1a9c97Smrg	case $deplibs_check_method in
6522af1a9c97Smrg	pass_all)
6523af1a9c97Smrg	  # Don't check for shared/static.  Everything works.
6524af1a9c97Smrg	  # This might be a little naive.  We might want to check
6525af1a9c97Smrg	  # whether the library exists or not.  But this is on
6526af1a9c97Smrg	  # osf3 & osf4 and I'm not really sure... Just
6527af1a9c97Smrg	  # implementing what was already the behavior.
6528af1a9c97Smrg	  newdeplibs=$deplibs
6529af1a9c97Smrg	  ;;
6530af1a9c97Smrg	test_compile)
6531af1a9c97Smrg	  # This code stresses the "libraries are programs" paradigm to its
6532af1a9c97Smrg	  # limits. Maybe even breaks it.  We compile a program, linking it
6533af1a9c97Smrg	  # against the deplibs as a proxy for the library.  Then we can check
6534af1a9c97Smrg	  # whether they linked in statically or dynamically with ldd.
6535af1a9c97Smrg	  $opt_dry_run || $RM conftest.c
6536af1a9c97Smrg	  cat > conftest.c <<EOF
6537af1a9c97Smrg	  int main() { return 0; }
6538af1a9c97SmrgEOF
6539af1a9c97Smrg	  $opt_dry_run || $RM conftest
6540af1a9c97Smrg	  if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
6541af1a9c97Smrg	    ldd_output=`ldd conftest`
6542af1a9c97Smrg	    for i in $deplibs; do
6543af1a9c97Smrg	      case $i in
6544af1a9c97Smrg	      -l*)
6545af1a9c97Smrg		func_stripname -l '' "$i"
6546af1a9c97Smrg		name=$func_stripname_result
6547af1a9c97Smrg		if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6548af1a9c97Smrg		  case " $predeps $postdeps " in
6549af1a9c97Smrg		  *" $i "*)
6550af1a9c97Smrg		    newdeplibs="$newdeplibs $i"
6551af1a9c97Smrg		    i=""
6552af1a9c97Smrg		    ;;
6553af1a9c97Smrg		  esac
6554af1a9c97Smrg		fi
6555af1a9c97Smrg		if test -n "$i" ; then
6556af1a9c97Smrg		  libname=`eval "\\$ECHO \"$libname_spec\""`
6557af1a9c97Smrg		  deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
6558af1a9c97Smrg		  set dummy $deplib_matches; shift
6559af1a9c97Smrg		  deplib_match=$1
6560af1a9c97Smrg		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
6561af1a9c97Smrg		    newdeplibs="$newdeplibs $i"
6562af1a9c97Smrg		  else
6563af1a9c97Smrg		    droppeddeps=yes
6564af1a9c97Smrg		    $ECHO
6565af1a9c97Smrg		    $ECHO "*** Warning: dynamic linker does not accept needed library $i."
6566af1a9c97Smrg		    $ECHO "*** I have the capability to make that library automatically link in when"
6567af1a9c97Smrg		    $ECHO "*** you link to this library.  But I can only do this if you have a"
6568af1a9c97Smrg		    $ECHO "*** shared version of the library, which I believe you do not have"
6569af1a9c97Smrg		    $ECHO "*** because a test_compile did reveal that the linker did not use it for"
6570af1a9c97Smrg		    $ECHO "*** its dynamic dependency list that programs get resolved with at runtime."
6571af1a9c97Smrg		  fi
6572af1a9c97Smrg		fi
6573af1a9c97Smrg		;;
6574af1a9c97Smrg	      *)
6575af1a9c97Smrg		newdeplibs="$newdeplibs $i"
6576af1a9c97Smrg		;;
6577af1a9c97Smrg	      esac
6578af1a9c97Smrg	    done
6579af1a9c97Smrg	  else
6580af1a9c97Smrg	    # Error occurred in the first compile.  Let's try to salvage
6581af1a9c97Smrg	    # the situation: Compile a separate program for each library.
6582af1a9c97Smrg	    for i in $deplibs; do
6583af1a9c97Smrg	      case $i in
6584af1a9c97Smrg	      -l*)
6585af1a9c97Smrg		func_stripname -l '' "$i"
6586af1a9c97Smrg		name=$func_stripname_result
6587af1a9c97Smrg		$opt_dry_run || $RM conftest
6588af1a9c97Smrg		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
6589af1a9c97Smrg		  ldd_output=`ldd conftest`
6590af1a9c97Smrg		  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6591af1a9c97Smrg		    case " $predeps $postdeps " in
6592af1a9c97Smrg		    *" $i "*)
6593af1a9c97Smrg		      newdeplibs="$newdeplibs $i"
6594af1a9c97Smrg		      i=""
6595af1a9c97Smrg		      ;;
6596af1a9c97Smrg		    esac
6597af1a9c97Smrg		  fi
6598af1a9c97Smrg		  if test -n "$i" ; then
6599af1a9c97Smrg		    libname=`eval "\\$ECHO \"$libname_spec\""`
6600af1a9c97Smrg		    deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
6601af1a9c97Smrg		    set dummy $deplib_matches; shift
6602af1a9c97Smrg		    deplib_match=$1
6603af1a9c97Smrg		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
6604af1a9c97Smrg		      newdeplibs="$newdeplibs $i"
6605af1a9c97Smrg		    else
6606af1a9c97Smrg		      droppeddeps=yes
6607af1a9c97Smrg		      $ECHO
6608af1a9c97Smrg		      $ECHO "*** Warning: dynamic linker does not accept needed library $i."
6609af1a9c97Smrg		      $ECHO "*** I have the capability to make that library automatically link in when"
6610af1a9c97Smrg		      $ECHO "*** you link to this library.  But I can only do this if you have a"
6611af1a9c97Smrg		      $ECHO "*** shared version of the library, which you do not appear to have"
6612af1a9c97Smrg		      $ECHO "*** because a test_compile did reveal that the linker did not use this one"
6613af1a9c97Smrg		      $ECHO "*** as a dynamic dependency that programs can get resolved with at runtime."
6614af1a9c97Smrg		    fi
6615af1a9c97Smrg		  fi
6616af1a9c97Smrg		else
6617af1a9c97Smrg		  droppeddeps=yes
6618af1a9c97Smrg		  $ECHO
6619af1a9c97Smrg		  $ECHO "*** Warning!  Library $i is needed by this library but I was not able to"
6620af1a9c97Smrg		  $ECHO "*** make it link in!  You will probably need to install it or some"
6621af1a9c97Smrg		  $ECHO "*** library that it depends on before this library will be fully"
6622af1a9c97Smrg		  $ECHO "*** functional.  Installing it before continuing would be even better."
6623af1a9c97Smrg		fi
6624af1a9c97Smrg		;;
6625af1a9c97Smrg	      *)
6626af1a9c97Smrg		newdeplibs="$newdeplibs $i"
6627af1a9c97Smrg		;;
6628af1a9c97Smrg	      esac
6629af1a9c97Smrg	    done
6630af1a9c97Smrg	  fi
6631af1a9c97Smrg	  ;;
6632af1a9c97Smrg	file_magic*)
6633af1a9c97Smrg	  set dummy $deplibs_check_method; shift
6634af1a9c97Smrg	  file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
6635af1a9c97Smrg	  for a_deplib in $deplibs; do
6636af1a9c97Smrg	    case $a_deplib in
6637af1a9c97Smrg	    -l*)
6638af1a9c97Smrg	      func_stripname -l '' "$a_deplib"
6639af1a9c97Smrg	      name=$func_stripname_result
6640af1a9c97Smrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6641af1a9c97Smrg		case " $predeps $postdeps " in
6642af1a9c97Smrg		*" $a_deplib "*)
6643af1a9c97Smrg		  newdeplibs="$newdeplibs $a_deplib"
6644af1a9c97Smrg		  a_deplib=""
6645af1a9c97Smrg		  ;;
6646af1a9c97Smrg		esac
6647af1a9c97Smrg	      fi
6648af1a9c97Smrg	      if test -n "$a_deplib" ; then
6649af1a9c97Smrg		libname=`eval "\\$ECHO \"$libname_spec\""`
6650af1a9c97Smrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
6651af1a9c97Smrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
6652af1a9c97Smrg		  for potent_lib in $potential_libs; do
6653af1a9c97Smrg		      # Follow soft links.
6654af1a9c97Smrg		      if ls -lLd "$potent_lib" 2>/dev/null |
6655af1a9c97Smrg			 $GREP " -> " >/dev/null; then
6656af1a9c97Smrg			continue
6657af1a9c97Smrg		      fi
6658af1a9c97Smrg		      # The statement above tries to avoid entering an
6659af1a9c97Smrg		      # endless loop below, in case of cyclic links.
6660af1a9c97Smrg		      # We might still enter an endless loop, since a link
6661af1a9c97Smrg		      # loop can be closed while we follow links,
6662af1a9c97Smrg		      # but so what?
6663af1a9c97Smrg		      potlib="$potent_lib"
6664af1a9c97Smrg		      while test -h "$potlib" 2>/dev/null; do
6665af1a9c97Smrg			potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
6666af1a9c97Smrg			case $potliblink in
6667af1a9c97Smrg			[\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
6668af1a9c97Smrg			*) potlib=`$ECHO "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";;
6669af1a9c97Smrg			esac
6670af1a9c97Smrg		      done
6671af1a9c97Smrg		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
6672af1a9c97Smrg			 $SED -e 10q |
6673af1a9c97Smrg			 $EGREP "$file_magic_regex" > /dev/null; then
6674af1a9c97Smrg			newdeplibs="$newdeplibs $a_deplib"
6675af1a9c97Smrg			a_deplib=""
6676af1a9c97Smrg			break 2
6677af1a9c97Smrg		      fi
6678af1a9c97Smrg		  done
6679af1a9c97Smrg		done
6680af1a9c97Smrg	      fi
6681af1a9c97Smrg	      if test -n "$a_deplib" ; then
6682af1a9c97Smrg		droppeddeps=yes
6683af1a9c97Smrg		$ECHO
6684af1a9c97Smrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
6685af1a9c97Smrg		$ECHO "*** I have the capability to make that library automatically link in when"
6686af1a9c97Smrg		$ECHO "*** you link to this library.  But I can only do this if you have a"
6687af1a9c97Smrg		$ECHO "*** shared version of the library, which you do not appear to have"
6688af1a9c97Smrg		$ECHO "*** because I did check the linker path looking for a file starting"
6689af1a9c97Smrg		if test -z "$potlib" ; then
6690af1a9c97Smrg		  $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
6691af1a9c97Smrg		else
6692af1a9c97Smrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
6693af1a9c97Smrg		  $ECHO "*** using a file magic. Last file checked: $potlib"
6694af1a9c97Smrg		fi
6695af1a9c97Smrg	      fi
6696af1a9c97Smrg	      ;;
6697af1a9c97Smrg	    *)
6698af1a9c97Smrg	      # Add a -L argument.
6699af1a9c97Smrg	      newdeplibs="$newdeplibs $a_deplib"
6700af1a9c97Smrg	      ;;
6701af1a9c97Smrg	    esac
6702af1a9c97Smrg	  done # Gone through all deplibs.
6703af1a9c97Smrg	  ;;
6704af1a9c97Smrg	match_pattern*)
6705af1a9c97Smrg	  set dummy $deplibs_check_method; shift
6706af1a9c97Smrg	  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
6707af1a9c97Smrg	  for a_deplib in $deplibs; do
6708af1a9c97Smrg	    case $a_deplib in
6709af1a9c97Smrg	    -l*)
6710af1a9c97Smrg	      func_stripname -l '' "$a_deplib"
6711af1a9c97Smrg	      name=$func_stripname_result
6712af1a9c97Smrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6713af1a9c97Smrg		case " $predeps $postdeps " in
6714af1a9c97Smrg		*" $a_deplib "*)
6715af1a9c97Smrg		  newdeplibs="$newdeplibs $a_deplib"
6716af1a9c97Smrg		  a_deplib=""
6717af1a9c97Smrg		  ;;
6718af1a9c97Smrg		esac
6719af1a9c97Smrg	      fi
6720af1a9c97Smrg	      if test -n "$a_deplib" ; then
6721af1a9c97Smrg		libname=`eval "\\$ECHO \"$libname_spec\""`
6722af1a9c97Smrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
6723af1a9c97Smrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
6724af1a9c97Smrg		  for potent_lib in $potential_libs; do
6725af1a9c97Smrg		    potlib="$potent_lib" # see symlink-check above in file_magic test
6726af1a9c97Smrg		    if eval "\$ECHO \"X$potent_lib\"" 2>/dev/null | $Xsed -e 10q | \
6727af1a9c97Smrg		       $EGREP "$match_pattern_regex" > /dev/null; then
6728af1a9c97Smrg		      newdeplibs="$newdeplibs $a_deplib"
6729af1a9c97Smrg		      a_deplib=""
6730af1a9c97Smrg		      break 2
6731af1a9c97Smrg		    fi
6732af1a9c97Smrg		  done
6733af1a9c97Smrg		done
6734af1a9c97Smrg	      fi
6735af1a9c97Smrg	      if test -n "$a_deplib" ; then
6736af1a9c97Smrg		droppeddeps=yes
6737af1a9c97Smrg		$ECHO
6738af1a9c97Smrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
6739af1a9c97Smrg		$ECHO "*** I have the capability to make that library automatically link in when"
6740af1a9c97Smrg		$ECHO "*** you link to this library.  But I can only do this if you have a"
6741af1a9c97Smrg		$ECHO "*** shared version of the library, which you do not appear to have"
6742af1a9c97Smrg		$ECHO "*** because I did check the linker path looking for a file starting"
6743af1a9c97Smrg		if test -z "$potlib" ; then
6744af1a9c97Smrg		  $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
6745af1a9c97Smrg		else
6746af1a9c97Smrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
6747af1a9c97Smrg		  $ECHO "*** using a regex pattern. Last file checked: $potlib"
6748af1a9c97Smrg		fi
6749af1a9c97Smrg	      fi
6750af1a9c97Smrg	      ;;
6751af1a9c97Smrg	    *)
6752af1a9c97Smrg	      # Add a -L argument.
6753af1a9c97Smrg	      newdeplibs="$newdeplibs $a_deplib"
6754af1a9c97Smrg	      ;;
6755af1a9c97Smrg	    esac
6756af1a9c97Smrg	  done # Gone through all deplibs.
6757af1a9c97Smrg	  ;;
6758af1a9c97Smrg	none | unknown | *)
6759af1a9c97Smrg	  newdeplibs=""
6760af1a9c97Smrg	  tmp_deplibs=`$ECHO "X $deplibs" | $Xsed \
6761af1a9c97Smrg	      -e 's/ -lc$//' -e 's/ -[LR][^ ]*//g'`
6762af1a9c97Smrg	  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6763af1a9c97Smrg	    for i in $predeps $postdeps ; do
6764af1a9c97Smrg	      # can't use Xsed below, because $i might contain '/'
6765af1a9c97Smrg	      tmp_deplibs=`$ECHO "X $tmp_deplibs" | $Xsed -e "s,$i,,"`
6766af1a9c97Smrg	    done
6767af1a9c97Smrg	  fi
6768af1a9c97Smrg	  if $ECHO "X $tmp_deplibs" | $Xsed -e 's/[	 ]//g' |
6769af1a9c97Smrg	     $GREP . >/dev/null; then
6770af1a9c97Smrg	    $ECHO
6771af1a9c97Smrg	    if test "X$deplibs_check_method" = "Xnone"; then
6772af1a9c97Smrg	      $ECHO "*** Warning: inter-library dependencies are not supported in this platform."
6773af1a9c97Smrg	    else
6774af1a9c97Smrg	      $ECHO "*** Warning: inter-library dependencies are not known to be supported."
6775af1a9c97Smrg	    fi
6776af1a9c97Smrg	    $ECHO "*** All declared inter-library dependencies are being dropped."
6777af1a9c97Smrg	    droppeddeps=yes
6778af1a9c97Smrg	  fi
6779af1a9c97Smrg	  ;;
6780af1a9c97Smrg	esac
6781af1a9c97Smrg	versuffix=$versuffix_save
6782af1a9c97Smrg	major=$major_save
6783af1a9c97Smrg	release=$release_save
6784af1a9c97Smrg	libname=$libname_save
6785af1a9c97Smrg	name=$name_save
6786af1a9c97Smrg
6787af1a9c97Smrg	case $host in
6788af1a9c97Smrg	*-*-rhapsody* | *-*-darwin1.[012])
6789af1a9c97Smrg	  # On Rhapsody replace the C library with the System framework
6790af1a9c97Smrg	  newdeplibs=`$ECHO "X $newdeplibs" | $Xsed -e 's/ -lc / System.ltframework /'`
6791af1a9c97Smrg	  ;;
6792af1a9c97Smrg	esac
6793af1a9c97Smrg
6794af1a9c97Smrg	if test "$droppeddeps" = yes; then
6795af1a9c97Smrg	  if test "$module" = yes; then
6796af1a9c97Smrg	    $ECHO
6797af1a9c97Smrg	    $ECHO "*** Warning: libtool could not satisfy all declared inter-library"
6798af1a9c97Smrg	    $ECHO "*** dependencies of module $libname.  Therefore, libtool will create"
6799af1a9c97Smrg	    $ECHO "*** a static module, that should work as long as the dlopening"
6800af1a9c97Smrg	    $ECHO "*** application is linked with the -dlopen flag."
6801af1a9c97Smrg	    if test -z "$global_symbol_pipe"; then
6802af1a9c97Smrg	      $ECHO
6803af1a9c97Smrg	      $ECHO "*** However, this would only work if libtool was able to extract symbol"
6804af1a9c97Smrg	      $ECHO "*** lists from a program, using \`nm' or equivalent, but libtool could"
6805af1a9c97Smrg	      $ECHO "*** not find such a program.  So, this module is probably useless."
6806af1a9c97Smrg	      $ECHO "*** \`nm' from GNU binutils and a full rebuild may help."
6807af1a9c97Smrg	    fi
6808af1a9c97Smrg	    if test "$build_old_libs" = no; then
6809af1a9c97Smrg	      oldlibs="$output_objdir/$libname.$libext"
6810af1a9c97Smrg	      build_libtool_libs=module
6811af1a9c97Smrg	      build_old_libs=yes
6812af1a9c97Smrg	    else
6813af1a9c97Smrg	      build_libtool_libs=no
6814af1a9c97Smrg	    fi
6815af1a9c97Smrg	  else
6816af1a9c97Smrg	    $ECHO "*** The inter-library dependencies that have been dropped here will be"
6817af1a9c97Smrg	    $ECHO "*** automatically added whenever a program is linked with this library"
6818af1a9c97Smrg	    $ECHO "*** or is declared to -dlopen it."
6819af1a9c97Smrg
6820af1a9c97Smrg	    if test "$allow_undefined" = no; then
6821af1a9c97Smrg	      $ECHO
6822af1a9c97Smrg	      $ECHO "*** Since this library must not contain undefined symbols,"
6823af1a9c97Smrg	      $ECHO "*** because either the platform does not support them or"
6824af1a9c97Smrg	      $ECHO "*** it was explicitly requested with -no-undefined,"
6825af1a9c97Smrg	      $ECHO "*** libtool will only create a static version of it."
6826af1a9c97Smrg	      if test "$build_old_libs" = no; then
6827af1a9c97Smrg		oldlibs="$output_objdir/$libname.$libext"
6828af1a9c97Smrg		build_libtool_libs=module
6829af1a9c97Smrg		build_old_libs=yes
6830af1a9c97Smrg	      else
6831af1a9c97Smrg		build_libtool_libs=no
6832af1a9c97Smrg	      fi
6833af1a9c97Smrg	    fi
6834af1a9c97Smrg	  fi
6835af1a9c97Smrg	fi
6836af1a9c97Smrg	# Done checking deplibs!
6837af1a9c97Smrg	deplibs=$newdeplibs
6838af1a9c97Smrg      fi
6839af1a9c97Smrg      # Time to change all our "foo.ltframework" stuff back to "-framework foo"
6840af1a9c97Smrg      case $host in
6841af1a9c97Smrg	*-*-darwin*)
6842af1a9c97Smrg	  newdeplibs=`$ECHO "X $newdeplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
6843af1a9c97Smrg	  new_inherited_linker_flags=`$ECHO "X $new_inherited_linker_flags" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
6844af1a9c97Smrg	  deplibs=`$ECHO "X $deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
6845af1a9c97Smrg	  ;;
6846af1a9c97Smrg      esac
6847af1a9c97Smrg
6848af1a9c97Smrg      # move library search paths that coincide with paths to not yet
6849af1a9c97Smrg      # installed libraries to the beginning of the library search list
6850af1a9c97Smrg      new_libs=
6851af1a9c97Smrg      for path in $notinst_path; do
6852af1a9c97Smrg	case " $new_libs " in
6853af1a9c97Smrg	*" -L$path/$objdir "*) ;;
6854af1a9c97Smrg	*)
6855af1a9c97Smrg	  case " $deplibs " in
6856af1a9c97Smrg	  *" -L$path/$objdir "*)
6857af1a9c97Smrg	    new_libs="$new_libs -L$path/$objdir" ;;
6858af1a9c97Smrg	  esac
6859af1a9c97Smrg	  ;;
6860af1a9c97Smrg	esac
6861af1a9c97Smrg      done
6862af1a9c97Smrg      for deplib in $deplibs; do
6863af1a9c97Smrg	case $deplib in
6864af1a9c97Smrg	-L*)
6865af1a9c97Smrg	  case " $new_libs " in
6866af1a9c97Smrg	  *" $deplib "*) ;;
6867af1a9c97Smrg	  *) new_libs="$new_libs $deplib" ;;
6868af1a9c97Smrg	  esac
6869af1a9c97Smrg	  ;;
6870af1a9c97Smrg	*) new_libs="$new_libs $deplib" ;;
6871af1a9c97Smrg	esac
6872af1a9c97Smrg      done
6873af1a9c97Smrg      deplibs="$new_libs"
6874af1a9c97Smrg
6875af1a9c97Smrg      # All the library-specific variables (install_libdir is set above).
6876af1a9c97Smrg      library_names=
6877af1a9c97Smrg      old_library=
6878af1a9c97Smrg      dlname=
6879af1a9c97Smrg
6880af1a9c97Smrg      # Test again, we may have decided not to build it any more
6881af1a9c97Smrg      if test "$build_libtool_libs" = yes; then
6882af1a9c97Smrg	if test "$hardcode_into_libs" = yes; then
6883af1a9c97Smrg	  # Hardcode the library paths
6884af1a9c97Smrg	  hardcode_libdirs=
6885af1a9c97Smrg	  dep_rpath=
6886af1a9c97Smrg	  rpath="$finalize_rpath"
6887af1a9c97Smrg	  test "$mode" != relink && rpath="$compile_rpath$rpath"
6888af1a9c97Smrg	  for libdir in $rpath; do
6889af1a9c97Smrg	    if test -n "$hardcode_libdir_flag_spec"; then
6890af1a9c97Smrg	      if test -n "$hardcode_libdir_separator"; then
6891af1a9c97Smrg		if test -z "$hardcode_libdirs"; then
6892af1a9c97Smrg		  hardcode_libdirs="$libdir"
6893af1a9c97Smrg		else
6894af1a9c97Smrg		  # Just accumulate the unique libdirs.
6895af1a9c97Smrg		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
6896af1a9c97Smrg		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
6897af1a9c97Smrg		    ;;
6898af1a9c97Smrg		  *)
6899af1a9c97Smrg		    hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
6900af1a9c97Smrg		    ;;
6901af1a9c97Smrg		  esac
6902af1a9c97Smrg		fi
6903af1a9c97Smrg	      else
6904af1a9c97Smrg		eval flag=\"$hardcode_libdir_flag_spec\"
6905af1a9c97Smrg		dep_rpath="$dep_rpath $flag"
6906af1a9c97Smrg	      fi
6907af1a9c97Smrg	    elif test -n "$runpath_var"; then
6908af1a9c97Smrg	      case "$perm_rpath " in
6909af1a9c97Smrg	      *" $libdir "*) ;;
6910af1a9c97Smrg	      *) perm_rpath="$perm_rpath $libdir" ;;
6911af1a9c97Smrg	      esac
6912af1a9c97Smrg	    fi
6913af1a9c97Smrg	  done
6914af1a9c97Smrg	  # Substitute the hardcoded libdirs into the rpath.
6915af1a9c97Smrg	  if test -n "$hardcode_libdir_separator" &&
6916af1a9c97Smrg	     test -n "$hardcode_libdirs"; then
6917af1a9c97Smrg	    libdir="$hardcode_libdirs"
6918af1a9c97Smrg	    if test -n "$hardcode_libdir_flag_spec_ld"; then
6919af1a9c97Smrg	      eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\"
6920af1a9c97Smrg	    else
6921af1a9c97Smrg	      eval dep_rpath=\"$hardcode_libdir_flag_spec\"
6922af1a9c97Smrg	    fi
6923af1a9c97Smrg	  fi
6924af1a9c97Smrg	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
6925af1a9c97Smrg	    # We should set the runpath_var.
6926af1a9c97Smrg	    rpath=
6927af1a9c97Smrg	    for dir in $perm_rpath; do
6928af1a9c97Smrg	      rpath="$rpath$dir:"
6929af1a9c97Smrg	    done
6930af1a9c97Smrg	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
6931af1a9c97Smrg	  fi
6932af1a9c97Smrg	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
6933af1a9c97Smrg	fi
693450806d53Smrg
6935af1a9c97Smrg	shlibpath="$finalize_shlibpath"
6936af1a9c97Smrg	test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
6937af1a9c97Smrg	if test -n "$shlibpath"; then
6938af1a9c97Smrg	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
6939af1a9c97Smrg	fi
694050806d53Smrg
6941af1a9c97Smrg	# Get the real and link names of the library.
6942af1a9c97Smrg	eval shared_ext=\"$shrext_cmds\"
6943af1a9c97Smrg	eval library_names=\"$library_names_spec\"
6944af1a9c97Smrg	set dummy $library_names
6945af1a9c97Smrg	shift
6946af1a9c97Smrg	realname="$1"
6947af1a9c97Smrg	shift
694850806d53Smrg
6949af1a9c97Smrg	if test -n "$soname_spec"; then
6950af1a9c97Smrg	  eval soname=\"$soname_spec\"
6951af1a9c97Smrg	else
6952af1a9c97Smrg	  soname="$realname"
6953af1a9c97Smrg	fi
6954af1a9c97Smrg	if test -z "$dlname"; then
6955af1a9c97Smrg	  dlname=$soname
6956af1a9c97Smrg	fi
695750806d53Smrg
6958af1a9c97Smrg	lib="$output_objdir/$realname"
6959af1a9c97Smrg	linknames=
6960af1a9c97Smrg	for link
6961af1a9c97Smrg	do
6962af1a9c97Smrg	  linknames="$linknames $link"
6963af1a9c97Smrg	done
696450806d53Smrg
6965af1a9c97Smrg	# Use standard objects if they are pic
6966af1a9c97Smrg	test -z "$pic_flag" && libobjs=`$ECHO "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
6967af1a9c97Smrg	test "X$libobjs" = "X " && libobjs=
696850806d53Smrg
6969af1a9c97Smrg	delfiles=
6970af1a9c97Smrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
6971af1a9c97Smrg	  $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
6972af1a9c97Smrg	  export_symbols="$output_objdir/$libname.uexp"
6973af1a9c97Smrg	  delfiles="$delfiles $export_symbols"
6974af1a9c97Smrg	fi
697550806d53Smrg
6976af1a9c97Smrg	orig_export_symbols=
6977af1a9c97Smrg	case $host_os in
6978af1a9c97Smrg	cygwin* | mingw* | cegcc*)
6979af1a9c97Smrg	  if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
6980af1a9c97Smrg	    # exporting using user supplied symfile
6981af1a9c97Smrg	    if test "x`$SED 1q $export_symbols`" != xEXPORTS; then
6982af1a9c97Smrg	      # and it's NOT already a .def file. Must figure out
6983af1a9c97Smrg	      # which of the given symbols are data symbols and tag
6984af1a9c97Smrg	      # them as such. So, trigger use of export_symbols_cmds.
6985af1a9c97Smrg	      # export_symbols gets reassigned inside the "prepare
6986af1a9c97Smrg	      # the list of exported symbols" if statement, so the
6987af1a9c97Smrg	      # include_expsyms logic still works.
6988af1a9c97Smrg	      orig_export_symbols="$export_symbols"
6989af1a9c97Smrg	      export_symbols=
6990af1a9c97Smrg	      always_export_symbols=yes
6991af1a9c97Smrg	    fi
6992af1a9c97Smrg	  fi
6993af1a9c97Smrg	  ;;
6994af1a9c97Smrg	esac
699550806d53Smrg
6996af1a9c97Smrg	# Prepare the list of exported symbols
6997af1a9c97Smrg	if test -z "$export_symbols"; then
6998af1a9c97Smrg	  if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
6999af1a9c97Smrg	    func_verbose "generating symbol list for \`$libname.la'"
7000af1a9c97Smrg	    export_symbols="$output_objdir/$libname.exp"
7001af1a9c97Smrg	    $opt_dry_run || $RM $export_symbols
7002af1a9c97Smrg	    cmds=$export_symbols_cmds
7003af1a9c97Smrg	    save_ifs="$IFS"; IFS='~'
7004af1a9c97Smrg	    for cmd in $cmds; do
7005af1a9c97Smrg	      IFS="$save_ifs"
7006af1a9c97Smrg	      eval cmd=\"$cmd\"
7007af1a9c97Smrg	      func_len " $cmd"
7008af1a9c97Smrg	      len=$func_len_result
7009af1a9c97Smrg	      if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
7010af1a9c97Smrg		func_show_eval "$cmd" 'exit $?'
7011af1a9c97Smrg		skipped_export=false
7012af1a9c97Smrg	      else
7013af1a9c97Smrg		# The command line is too long to execute in one step.
7014af1a9c97Smrg		func_verbose "using reloadable object file for export list..."
7015af1a9c97Smrg		skipped_export=:
7016af1a9c97Smrg		# Break out early, otherwise skipped_export may be
7017af1a9c97Smrg		# set to false by a later but shorter cmd.
7018af1a9c97Smrg		break
7019af1a9c97Smrg	      fi
7020af1a9c97Smrg	    done
7021af1a9c97Smrg	    IFS="$save_ifs"
7022af1a9c97Smrg	    if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then
7023af1a9c97Smrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
7024af1a9c97Smrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
7025af1a9c97Smrg	    fi
7026af1a9c97Smrg	  fi
702750806d53Smrg	fi
702850806d53Smrg
7029af1a9c97Smrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
7030af1a9c97Smrg	  tmp_export_symbols="$export_symbols"
7031af1a9c97Smrg	  test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
7032af1a9c97Smrg	  $opt_dry_run || eval '$ECHO "X$include_expsyms" | $Xsed | $SP2NL >> "$tmp_export_symbols"'
7033af1a9c97Smrg	fi
703450806d53Smrg
7035af1a9c97Smrg	if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then
7036af1a9c97Smrg	  # The given exports_symbols file has to be filtered, so filter it.
7037af1a9c97Smrg	  func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
7038af1a9c97Smrg	  # FIXME: $output_objdir/$libname.filter potentially contains lots of
7039af1a9c97Smrg	  # 's' commands which not all seds can handle. GNU sed should be fine
7040af1a9c97Smrg	  # though. Also, the filter scales superlinearly with the number of
7041af1a9c97Smrg	  # global variables. join(1) would be nice here, but unfortunately
7042af1a9c97Smrg	  # isn't a blessed tool.
7043af1a9c97Smrg	  $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
7044af1a9c97Smrg	  delfiles="$delfiles $export_symbols $output_objdir/$libname.filter"
7045af1a9c97Smrg	  export_symbols=$output_objdir/$libname.def
7046af1a9c97Smrg	  $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
7047af1a9c97Smrg	fi
704850806d53Smrg
7049af1a9c97Smrg	tmp_deplibs=
7050af1a9c97Smrg	for test_deplib in $deplibs; do
7051af1a9c97Smrg	  case " $convenience " in
7052af1a9c97Smrg	  *" $test_deplib "*) ;;
7053af1a9c97Smrg	  *)
7054af1a9c97Smrg	    tmp_deplibs="$tmp_deplibs $test_deplib"
7055af1a9c97Smrg	    ;;
7056af1a9c97Smrg	  esac
7057af1a9c97Smrg	done
7058af1a9c97Smrg	deplibs="$tmp_deplibs"
705950806d53Smrg
7060af1a9c97Smrg	if test -n "$convenience"; then
7061af1a9c97Smrg	  if test -n "$whole_archive_flag_spec" &&
7062af1a9c97Smrg	    test "$compiler_needs_object" = yes &&
7063af1a9c97Smrg	    test -z "$libobjs"; then
7064af1a9c97Smrg	    # extract the archives, so we have objects to list.
7065af1a9c97Smrg	    # TODO: could optimize this to just extract one archive.
7066af1a9c97Smrg	    whole_archive_flag_spec=
7067af1a9c97Smrg	  fi
7068af1a9c97Smrg	  if test -n "$whole_archive_flag_spec"; then
7069af1a9c97Smrg	    save_libobjs=$libobjs
7070af1a9c97Smrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
7071af1a9c97Smrg	    test "X$libobjs" = "X " && libobjs=
7072af1a9c97Smrg	  else
7073af1a9c97Smrg	    gentop="$output_objdir/${outputname}x"
7074af1a9c97Smrg	    generated="$generated $gentop"
707550806d53Smrg
7076af1a9c97Smrg	    func_extract_archives $gentop $convenience
7077af1a9c97Smrg	    libobjs="$libobjs $func_extract_archives_result"
7078af1a9c97Smrg	    test "X$libobjs" = "X " && libobjs=
7079af1a9c97Smrg	  fi
708050806d53Smrg	fi
708150806d53Smrg
7082af1a9c97Smrg	if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
7083af1a9c97Smrg	  eval flag=\"$thread_safe_flag_spec\"
7084af1a9c97Smrg	  linker_flags="$linker_flags $flag"
708550806d53Smrg	fi
708650806d53Smrg
7087af1a9c97Smrg	# Make a backup of the uninstalled library when relinking
7088af1a9c97Smrg	if test "$mode" = relink; then
7089af1a9c97Smrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
7090af1a9c97Smrg	fi
709150806d53Smrg
7092af1a9c97Smrg	# Do each of the archive commands.
7093af1a9c97Smrg	if test "$module" = yes && test -n "$module_cmds" ; then
7094af1a9c97Smrg	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
7095af1a9c97Smrg	    eval test_cmds=\"$module_expsym_cmds\"
7096af1a9c97Smrg	    cmds=$module_expsym_cmds
7097af1a9c97Smrg	  else
7098af1a9c97Smrg	    eval test_cmds=\"$module_cmds\"
7099af1a9c97Smrg	    cmds=$module_cmds
7100af1a9c97Smrg	  fi
710150806d53Smrg	else
7102af1a9c97Smrg	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
7103af1a9c97Smrg	    eval test_cmds=\"$archive_expsym_cmds\"
7104af1a9c97Smrg	    cmds=$archive_expsym_cmds
7105af1a9c97Smrg	  else
7106af1a9c97Smrg	    eval test_cmds=\"$archive_cmds\"
7107af1a9c97Smrg	    cmds=$archive_cmds
7108af1a9c97Smrg	  fi
710950806d53Smrg	fi
711050806d53Smrg
7111af1a9c97Smrg	if test "X$skipped_export" != "X:" &&
7112af1a9c97Smrg	   func_len " $test_cmds" &&
7113af1a9c97Smrg	   len=$func_len_result &&
7114af1a9c97Smrg	   test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
7115af1a9c97Smrg	  :
7116af1a9c97Smrg	else
7117af1a9c97Smrg	  # The command line is too long to link in one step, link piecewise
7118af1a9c97Smrg	  # or, if using GNU ld and skipped_export is not :, use a linker
7119af1a9c97Smrg	  # script.
712050806d53Smrg
7121af1a9c97Smrg	  # Save the value of $output and $libobjs because we want to
7122af1a9c97Smrg	  # use them later.  If we have whole_archive_flag_spec, we
7123af1a9c97Smrg	  # want to use save_libobjs as it was before
7124af1a9c97Smrg	  # whole_archive_flag_spec was expanded, because we can't
7125af1a9c97Smrg	  # assume the linker understands whole_archive_flag_spec.
7126af1a9c97Smrg	  # This may have to be revisited, in case too many
7127af1a9c97Smrg	  # convenience libraries get linked in and end up exceeding
7128af1a9c97Smrg	  # the spec.
7129af1a9c97Smrg	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
7130af1a9c97Smrg	    save_libobjs=$libobjs
7131af1a9c97Smrg	  fi
7132af1a9c97Smrg	  save_output=$output
7133af1a9c97Smrg	  output_la=`$ECHO "X$output" | $Xsed -e "$basename"`
713450806d53Smrg
7135af1a9c97Smrg	  # Clear the reloadable object creation command queue and
7136af1a9c97Smrg	  # initialize k to one.
7137af1a9c97Smrg	  test_cmds=
7138af1a9c97Smrg	  concat_cmds=
7139af1a9c97Smrg	  objlist=
7140af1a9c97Smrg	  last_robj=
7141af1a9c97Smrg	  k=1
7142af1a9c97Smrg
7143af1a9c97Smrg	  if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
7144af1a9c97Smrg	    output=${output_objdir}/${output_la}.lnkscript
7145af1a9c97Smrg	    func_verbose "creating GNU ld script: $output"
7146af1a9c97Smrg	    $ECHO 'INPUT (' > $output
7147af1a9c97Smrg	    for obj in $save_libobjs
714850806d53Smrg	    do
7149af1a9c97Smrg	      $ECHO "$obj" >> $output
7150af1a9c97Smrg	    done
7151af1a9c97Smrg	    $ECHO ')' >> $output
7152af1a9c97Smrg	    delfiles="$delfiles $output"
7153af1a9c97Smrg	  elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then
7154af1a9c97Smrg	    output=${output_objdir}/${output_la}.lnk
7155af1a9c97Smrg	    func_verbose "creating linker input file list: $output"
7156af1a9c97Smrg	    : > $output
7157af1a9c97Smrg	    set x $save_libobjs
7158af1a9c97Smrg	    shift
7159af1a9c97Smrg	    firstobj=
7160af1a9c97Smrg	    if test "$compiler_needs_object" = yes; then
7161af1a9c97Smrg	      firstobj="$1 "
7162af1a9c97Smrg	      shift
7163af1a9c97Smrg	    fi
7164af1a9c97Smrg	    for obj
7165af1a9c97Smrg	    do
7166af1a9c97Smrg	      $ECHO "$obj" >> $output
7167af1a9c97Smrg	    done
7168af1a9c97Smrg	    delfiles="$delfiles $output"
7169af1a9c97Smrg	    output=$firstobj\"$file_list_spec$output\"
7170af1a9c97Smrg	  else
7171af1a9c97Smrg	    if test -n "$save_libobjs"; then
7172af1a9c97Smrg	      func_verbose "creating reloadable object files..."
7173af1a9c97Smrg	      output=$output_objdir/$output_la-${k}.$objext
7174af1a9c97Smrg	      eval test_cmds=\"$reload_cmds\"
7175af1a9c97Smrg	      func_len " $test_cmds"
7176af1a9c97Smrg	      len0=$func_len_result
7177af1a9c97Smrg	      len=$len0
7178af1a9c97Smrg
7179af1a9c97Smrg	      # Loop over the list of objects to be linked.
7180af1a9c97Smrg	      for obj in $save_libobjs
7181af1a9c97Smrg	      do
7182af1a9c97Smrg		func_len " $obj"
7183af1a9c97Smrg		func_arith $len + $func_len_result
7184af1a9c97Smrg		len=$func_arith_result
7185af1a9c97Smrg		if test "X$objlist" = X ||
7186af1a9c97Smrg		   test "$len" -lt "$max_cmd_len"; then
7187af1a9c97Smrg		  func_append objlist " $obj"
7188af1a9c97Smrg		else
7189af1a9c97Smrg		  # The command $test_cmds is almost too long, add a
7190af1a9c97Smrg		  # command to the queue.
7191af1a9c97Smrg		  if test "$k" -eq 1 ; then
7192af1a9c97Smrg		    # The first file doesn't have a previous command to add.
7193af1a9c97Smrg		    eval concat_cmds=\"$reload_cmds $objlist $last_robj\"
7194af1a9c97Smrg		  else
7195af1a9c97Smrg		    # All subsequent reloadable object files will link in
7196af1a9c97Smrg		    # the last one created.
7197af1a9c97Smrg		    eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj~\$RM $last_robj\"
7198af1a9c97Smrg		  fi
7199af1a9c97Smrg		  last_robj=$output_objdir/$output_la-${k}.$objext
7200af1a9c97Smrg		  func_arith $k + 1
7201af1a9c97Smrg		  k=$func_arith_result
7202af1a9c97Smrg		  output=$output_objdir/$output_la-${k}.$objext
7203af1a9c97Smrg		  objlist=$obj
7204af1a9c97Smrg		  func_len " $last_robj"
7205af1a9c97Smrg		  func_arith $len0 + $func_len_result
7206af1a9c97Smrg		  len=$func_arith_result
7207af1a9c97Smrg		fi
7208af1a9c97Smrg	      done
7209af1a9c97Smrg	      # Handle the remaining objects by creating one last
7210af1a9c97Smrg	      # reloadable object file.  All subsequent reloadable object
7211af1a9c97Smrg	      # files will link in the last one created.
7212af1a9c97Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
7213af1a9c97Smrg	      eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\"
7214af1a9c97Smrg	      if test -n "$last_robj"; then
7215af1a9c97Smrg	        eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\"
7216af1a9c97Smrg	      fi
7217af1a9c97Smrg	      delfiles="$delfiles $output"
721850806d53Smrg
7219af1a9c97Smrg	    else
7220af1a9c97Smrg	      output=
7221af1a9c97Smrg	    fi
722250806d53Smrg
7223af1a9c97Smrg	    if ${skipped_export-false}; then
7224af1a9c97Smrg	      func_verbose "generating symbol list for \`$libname.la'"
7225af1a9c97Smrg	      export_symbols="$output_objdir/$libname.exp"
7226af1a9c97Smrg	      $opt_dry_run || $RM $export_symbols
7227af1a9c97Smrg	      libobjs=$output
7228af1a9c97Smrg	      # Append the command to create the export file.
7229af1a9c97Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
7230af1a9c97Smrg	      eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
7231af1a9c97Smrg	      if test -n "$last_robj"; then
7232af1a9c97Smrg		eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
7233af1a9c97Smrg	      fi
723450806d53Smrg	    fi
723550806d53Smrg
7236af1a9c97Smrg	    test -n "$save_libobjs" &&
7237af1a9c97Smrg	      func_verbose "creating a temporary reloadable object file: $output"
723850806d53Smrg
7239af1a9c97Smrg	    # Loop through the commands generated above and execute them.
7240af1a9c97Smrg	    save_ifs="$IFS"; IFS='~'
7241af1a9c97Smrg	    for cmd in $concat_cmds; do
7242af1a9c97Smrg	      IFS="$save_ifs"
7243af1a9c97Smrg	      $opt_silent || {
7244af1a9c97Smrg		  func_quote_for_expand "$cmd"
7245af1a9c97Smrg		  eval "func_echo $func_quote_for_expand_result"
7246af1a9c97Smrg	      }
7247af1a9c97Smrg	      $opt_dry_run || eval "$cmd" || {
7248af1a9c97Smrg		lt_exit=$?
7249af1a9c97Smrg
7250af1a9c97Smrg		# Restore the uninstalled library and exit
7251af1a9c97Smrg		if test "$mode" = relink; then
7252af1a9c97Smrg		  ( cd "$output_objdir" && \
7253af1a9c97Smrg		    $RM "${realname}T" && \
7254af1a9c97Smrg		    $MV "${realname}U" "$realname" )
7255af1a9c97Smrg		fi
725650806d53Smrg
7257af1a9c97Smrg		exit $lt_exit
7258af1a9c97Smrg	      }
7259af1a9c97Smrg	    done
7260af1a9c97Smrg	    IFS="$save_ifs"
726150806d53Smrg
7262af1a9c97Smrg	    if test -n "$export_symbols_regex" && ${skipped_export-false}; then
7263af1a9c97Smrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
7264af1a9c97Smrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
726550806d53Smrg	    fi
726650806d53Smrg	  fi
726750806d53Smrg
7268af1a9c97Smrg          if ${skipped_export-false}; then
7269af1a9c97Smrg	    if test -n "$export_symbols" && test -n "$include_expsyms"; then
7270af1a9c97Smrg	      tmp_export_symbols="$export_symbols"
7271af1a9c97Smrg	      test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
7272af1a9c97Smrg	      $opt_dry_run || eval '$ECHO "X$include_expsyms" | $Xsed | $SP2NL >> "$tmp_export_symbols"'
7273af1a9c97Smrg	    fi
727450806d53Smrg
7275af1a9c97Smrg	    if test -n "$orig_export_symbols"; then
7276af1a9c97Smrg	      # The given exports_symbols file has to be filtered, so filter it.
7277af1a9c97Smrg	      func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
7278af1a9c97Smrg	      # FIXME: $output_objdir/$libname.filter potentially contains lots of
7279af1a9c97Smrg	      # 's' commands which not all seds can handle. GNU sed should be fine
7280af1a9c97Smrg	      # though. Also, the filter scales superlinearly with the number of
7281af1a9c97Smrg	      # global variables. join(1) would be nice here, but unfortunately
7282af1a9c97Smrg	      # isn't a blessed tool.
7283af1a9c97Smrg	      $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
7284af1a9c97Smrg	      delfiles="$delfiles $export_symbols $output_objdir/$libname.filter"
7285af1a9c97Smrg	      export_symbols=$output_objdir/$libname.def
7286af1a9c97Smrg	      $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
7287af1a9c97Smrg	    fi
7288af1a9c97Smrg	  fi
728950806d53Smrg
7290af1a9c97Smrg	  libobjs=$output
7291af1a9c97Smrg	  # Restore the value of output.
7292af1a9c97Smrg	  output=$save_output
729350806d53Smrg
7294af1a9c97Smrg	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
7295af1a9c97Smrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
7296af1a9c97Smrg	    test "X$libobjs" = "X " && libobjs=
7297af1a9c97Smrg	  fi
7298af1a9c97Smrg	  # Expand the library linking commands again to reset the
7299af1a9c97Smrg	  # value of $libobjs for piecewise linking.
730050806d53Smrg
7301af1a9c97Smrg	  # Do each of the archive commands.
7302af1a9c97Smrg	  if test "$module" = yes && test -n "$module_cmds" ; then
7303af1a9c97Smrg	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
7304af1a9c97Smrg	      cmds=$module_expsym_cmds
7305af1a9c97Smrg	    else
7306af1a9c97Smrg	      cmds=$module_cmds
730750806d53Smrg	    fi
730850806d53Smrg	  else
7309af1a9c97Smrg	    if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
7310af1a9c97Smrg	      cmds=$archive_expsym_cmds
7311af1a9c97Smrg	    else
7312af1a9c97Smrg	      cmds=$archive_cmds
7313af1a9c97Smrg	    fi
731450806d53Smrg	  fi
7315af1a9c97Smrg	fi
731650806d53Smrg
7317af1a9c97Smrg	if test -n "$delfiles"; then
7318af1a9c97Smrg	  # Append the command to remove temporary files to $cmds.
7319af1a9c97Smrg	  eval cmds=\"\$cmds~\$RM $delfiles\"
7320af1a9c97Smrg	fi
732150806d53Smrg
7322af1a9c97Smrg	# Add any objects from preloaded convenience libraries
7323af1a9c97Smrg	if test -n "$dlprefiles"; then
7324af1a9c97Smrg	  gentop="$output_objdir/${outputname}x"
7325af1a9c97Smrg	  generated="$generated $gentop"
732650806d53Smrg
7327af1a9c97Smrg	  func_extract_archives $gentop $dlprefiles
7328af1a9c97Smrg	  libobjs="$libobjs $func_extract_archives_result"
7329af1a9c97Smrg	  test "X$libobjs" = "X " && libobjs=
7330af1a9c97Smrg	fi
733150806d53Smrg
7332af1a9c97Smrg	save_ifs="$IFS"; IFS='~'
7333af1a9c97Smrg	for cmd in $cmds; do
7334af1a9c97Smrg	  IFS="$save_ifs"
7335af1a9c97Smrg	  eval cmd=\"$cmd\"
7336af1a9c97Smrg	  $opt_silent || {
7337af1a9c97Smrg	    func_quote_for_expand "$cmd"
7338af1a9c97Smrg	    eval "func_echo $func_quote_for_expand_result"
7339af1a9c97Smrg	  }
7340af1a9c97Smrg	  $opt_dry_run || eval "$cmd" || {
7341af1a9c97Smrg	    lt_exit=$?
734250806d53Smrg
7343af1a9c97Smrg	    # Restore the uninstalled library and exit
7344af1a9c97Smrg	    if test "$mode" = relink; then
7345af1a9c97Smrg	      ( cd "$output_objdir" && \
7346af1a9c97Smrg	        $RM "${realname}T" && \
7347af1a9c97Smrg		$MV "${realname}U" "$realname" )
7348af1a9c97Smrg	    fi
734950806d53Smrg
7350af1a9c97Smrg	    exit $lt_exit
7351af1a9c97Smrg	  }
7352af1a9c97Smrg	done
7353af1a9c97Smrg	IFS="$save_ifs"
735450806d53Smrg
7355af1a9c97Smrg	# Restore the uninstalled library and exit
7356af1a9c97Smrg	if test "$mode" = relink; then
7357af1a9c97Smrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
735850806d53Smrg
7359af1a9c97Smrg	  if test -n "$convenience"; then
7360af1a9c97Smrg	    if test -z "$whole_archive_flag_spec"; then
7361af1a9c97Smrg	      func_show_eval '${RM}r "$gentop"'
7362af1a9c97Smrg	    fi
7363af1a9c97Smrg	  fi
736450806d53Smrg
7365af1a9c97Smrg	  exit $EXIT_SUCCESS
7366af1a9c97Smrg	fi
7367af1a9c97Smrg
7368af1a9c97Smrg	# Create links to the real library.
7369af1a9c97Smrg	for linkname in $linknames; do
7370af1a9c97Smrg	  if test "$realname" != "$linkname"; then
7371af1a9c97Smrg	    func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
737250806d53Smrg	  fi
737350806d53Smrg	done
737450806d53Smrg
7375af1a9c97Smrg	# If -module or -export-dynamic was specified, set the dlname.
7376af1a9c97Smrg	if test "$module" = yes || test "$export_dynamic" = yes; then
7377af1a9c97Smrg	  # On all known operating systems, these are identical.
7378af1a9c97Smrg	  dlname="$soname"
7379af1a9c97Smrg	fi
7380af1a9c97Smrg      fi
738150806d53Smrg      ;;
738250806d53Smrg
7383af1a9c97Smrg    obj)
7384af1a9c97Smrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
7385af1a9c97Smrg	func_warning "\`-dlopen' is ignored for objects"
7386af1a9c97Smrg      fi
738750806d53Smrg
7388af1a9c97Smrg      case " $deplibs" in
7389af1a9c97Smrg      *\ -l* | *\ -L*)
7390af1a9c97Smrg	func_warning "\`-l' and \`-L' are ignored for objects" ;;
739150806d53Smrg      esac
739250806d53Smrg
7393af1a9c97Smrg      test -n "$rpath" && \
7394af1a9c97Smrg	func_warning "\`-rpath' is ignored for objects"
7395af1a9c97Smrg
7396af1a9c97Smrg      test -n "$xrpath" && \
7397af1a9c97Smrg	func_warning "\`-R' is ignored for objects"
739850806d53Smrg
7399af1a9c97Smrg      test -n "$vinfo" && \
7400af1a9c97Smrg	func_warning "\`-version-info' is ignored for objects"
740150806d53Smrg
7402af1a9c97Smrg      test -n "$release" && \
7403af1a9c97Smrg	func_warning "\`-release' is ignored for objects"
7404af1a9c97Smrg
7405af1a9c97Smrg      case $output in
7406af1a9c97Smrg      *.lo)
7407af1a9c97Smrg	test -n "$objs$old_deplibs" && \
7408af1a9c97Smrg	  func_fatal_error "cannot build library object \`$output' from non-libtool objects"
7409af1a9c97Smrg
7410af1a9c97Smrg	libobj=$output
7411af1a9c97Smrg	func_lo2o "$libobj"
7412af1a9c97Smrg	obj=$func_lo2o_result
741350806d53Smrg	;;
741450806d53Smrg      *)
7415af1a9c97Smrg	libobj=
7416af1a9c97Smrg	obj="$output"
741750806d53Smrg	;;
741850806d53Smrg      esac
741950806d53Smrg
7420af1a9c97Smrg      # Delete the old objects.
7421af1a9c97Smrg      $opt_dry_run || $RM $obj $libobj
742250806d53Smrg
7423af1a9c97Smrg      # Objects from convenience libraries.  This assumes
7424af1a9c97Smrg      # single-version convenience libraries.  Whenever we create
7425af1a9c97Smrg      # different ones for PIC/non-PIC, this we'll have to duplicate
7426af1a9c97Smrg      # the extraction.
7427af1a9c97Smrg      reload_conv_objs=
7428af1a9c97Smrg      gentop=
7429af1a9c97Smrg      # reload_cmds runs $LD directly, so let us get rid of
7430af1a9c97Smrg      # -Wl from whole_archive_flag_spec and hope we can get by with
7431af1a9c97Smrg      # turning comma into space..
7432af1a9c97Smrg      wl=
743350806d53Smrg
7434af1a9c97Smrg      if test -n "$convenience"; then
7435af1a9c97Smrg	if test -n "$whole_archive_flag_spec"; then
7436af1a9c97Smrg	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
7437af1a9c97Smrg	  reload_conv_objs=$reload_objs\ `$ECHO "X$tmp_whole_archive_flags" | $Xsed -e 's|,| |g'`
7438af1a9c97Smrg	else
7439af1a9c97Smrg	  gentop="$output_objdir/${obj}x"
7440af1a9c97Smrg	  generated="$generated $gentop"
744150806d53Smrg
7442af1a9c97Smrg	  func_extract_archives $gentop $convenience
7443af1a9c97Smrg	  reload_conv_objs="$reload_objs $func_extract_archives_result"
7444af1a9c97Smrg	fi
744550806d53Smrg      fi
744650806d53Smrg
7447af1a9c97Smrg      # Create the old-style object.
7448af1a9c97Smrg      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
744950806d53Smrg
7450af1a9c97Smrg      output="$obj"
7451af1a9c97Smrg      func_execute_cmds "$reload_cmds" 'exit $?'
745250806d53Smrg
7453af1a9c97Smrg      # Exit if we aren't doing a library object file.
7454af1a9c97Smrg      if test -z "$libobj"; then
7455af1a9c97Smrg	if test -n "$gentop"; then
7456af1a9c97Smrg	  func_show_eval '${RM}r "$gentop"'
7457af1a9c97Smrg	fi
7458af1a9c97Smrg
7459af1a9c97Smrg	exit $EXIT_SUCCESS
746050806d53Smrg      fi
7461af1a9c97Smrg
7462af1a9c97Smrg      if test "$build_libtool_libs" != yes; then
7463af1a9c97Smrg	if test -n "$gentop"; then
7464af1a9c97Smrg	  func_show_eval '${RM}r "$gentop"'
7465af1a9c97Smrg	fi
7466af1a9c97Smrg
7467af1a9c97Smrg	# Create an invalid libtool object if no PIC, so that we don't
7468af1a9c97Smrg	# accidentally link it into a program.
7469af1a9c97Smrg	# $show "echo timestamp > $libobj"
7470af1a9c97Smrg	# $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
7471af1a9c97Smrg	exit $EXIT_SUCCESS
7472af1a9c97Smrg      fi
7473af1a9c97Smrg
7474af1a9c97Smrg      if test -n "$pic_flag" || test "$pic_mode" != default; then
7475af1a9c97Smrg	# Only do commands if we really have different PIC objects.
7476af1a9c97Smrg	reload_objs="$libobjs $reload_conv_objs"
7477af1a9c97Smrg	output="$libobj"
7478af1a9c97Smrg	func_execute_cmds "$reload_cmds" 'exit $?'
7479af1a9c97Smrg      fi
7480af1a9c97Smrg
7481af1a9c97Smrg      if test -n "$gentop"; then
7482af1a9c97Smrg	func_show_eval '${RM}r "$gentop"'
7483af1a9c97Smrg      fi
7484af1a9c97Smrg
7485af1a9c97Smrg      exit $EXIT_SUCCESS
748650806d53Smrg      ;;
748750806d53Smrg
7488af1a9c97Smrg    prog)
7489af1a9c97Smrg      case $host in
7490af1a9c97Smrg	*cygwin*) func_stripname '' '.exe' "$output"
7491af1a9c97Smrg	          output=$func_stripname_result.exe;;
7492af1a9c97Smrg      esac
7493af1a9c97Smrg      test -n "$vinfo" && \
7494af1a9c97Smrg	func_warning "\`-version-info' is ignored for programs"
749550806d53Smrg
7496af1a9c97Smrg      test -n "$release" && \
7497af1a9c97Smrg	func_warning "\`-release' is ignored for programs"
749850806d53Smrg
7499af1a9c97Smrg      test "$preload" = yes \
7500af1a9c97Smrg        && test "$dlopen_support" = unknown \
7501af1a9c97Smrg	&& test "$dlopen_self" = unknown \
7502af1a9c97Smrg	&& test "$dlopen_self_static" = unknown && \
7503af1a9c97Smrg	  func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support."
7504af1a9c97Smrg
7505af1a9c97Smrg      case $host in
7506af1a9c97Smrg      *-*-rhapsody* | *-*-darwin1.[012])
7507af1a9c97Smrg	# On Rhapsody replace the C library is the System framework
7508af1a9c97Smrg	compile_deplibs=`$ECHO "X $compile_deplibs" | $Xsed -e 's/ -lc / System.ltframework /'`
7509af1a9c97Smrg	finalize_deplibs=`$ECHO "X $finalize_deplibs" | $Xsed -e 's/ -lc / System.ltframework /'`
751050806d53Smrg	;;
7511af1a9c97Smrg      esac
751250806d53Smrg
7513af1a9c97Smrg      case $host in
7514af1a9c97Smrg      *-*-darwin*)
7515af1a9c97Smrg	# Don't allow lazy linking, it breaks C++ global constructors
7516af1a9c97Smrg	# But is supposedly fixed on 10.4 or later (yay!).
7517af1a9c97Smrg	if test "$tagname" = CXX ; then
7518af1a9c97Smrg	  case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
7519af1a9c97Smrg	    10.[0123])
7520af1a9c97Smrg	      compile_command="$compile_command ${wl}-bind_at_load"
7521af1a9c97Smrg	      finalize_command="$finalize_command ${wl}-bind_at_load"
7522af1a9c97Smrg	    ;;
7523af1a9c97Smrg	  esac
752450806d53Smrg	fi
7525af1a9c97Smrg	# Time to change all our "foo.ltframework" stuff back to "-framework foo"
7526af1a9c97Smrg	compile_deplibs=`$ECHO "X $compile_deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
7527af1a9c97Smrg	finalize_deplibs=`$ECHO "X $finalize_deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
7528af1a9c97Smrg	;;
7529af1a9c97Smrg      esac
753050806d53Smrg
753150806d53Smrg
7532af1a9c97Smrg      # move library search paths that coincide with paths to not yet
7533af1a9c97Smrg      # installed libraries to the beginning of the library search list
7534af1a9c97Smrg      new_libs=
7535af1a9c97Smrg      for path in $notinst_path; do
7536af1a9c97Smrg	case " $new_libs " in
7537af1a9c97Smrg	*" -L$path/$objdir "*) ;;
7538af1a9c97Smrg	*)
7539af1a9c97Smrg	  case " $compile_deplibs " in
7540af1a9c97Smrg	  *" -L$path/$objdir "*)
7541af1a9c97Smrg	    new_libs="$new_libs -L$path/$objdir" ;;
754250806d53Smrg	  esac
7543af1a9c97Smrg	  ;;
7544af1a9c97Smrg	esac
7545af1a9c97Smrg      done
7546af1a9c97Smrg      for deplib in $compile_deplibs; do
7547af1a9c97Smrg	case $deplib in
7548af1a9c97Smrg	-L*)
7549af1a9c97Smrg	  case " $new_libs " in
7550af1a9c97Smrg	  *" $deplib "*) ;;
7551af1a9c97Smrg	  *) new_libs="$new_libs $deplib" ;;
755250806d53Smrg	  esac
7553af1a9c97Smrg	  ;;
7554af1a9c97Smrg	*) new_libs="$new_libs $deplib" ;;
7555af1a9c97Smrg	esac
7556af1a9c97Smrg      done
7557af1a9c97Smrg      compile_deplibs="$new_libs"
755850806d53Smrg
755950806d53Smrg
7560af1a9c97Smrg      compile_command="$compile_command $compile_deplibs"
7561af1a9c97Smrg      finalize_command="$finalize_command $finalize_deplibs"
756250806d53Smrg
7563af1a9c97Smrg      if test -n "$rpath$xrpath"; then
7564af1a9c97Smrg	# If the user specified any rpath flags, then add them.
7565af1a9c97Smrg	for libdir in $rpath $xrpath; do
7566af1a9c97Smrg	  # This is the magic to use -rpath.
7567af1a9c97Smrg	  case "$finalize_rpath " in
7568af1a9c97Smrg	  *" $libdir "*) ;;
7569af1a9c97Smrg	  *) finalize_rpath="$finalize_rpath $libdir" ;;
7570af1a9c97Smrg	  esac
7571af1a9c97Smrg	done
7572af1a9c97Smrg      fi
757350806d53Smrg
7574af1a9c97Smrg      # Now hardcode the library paths
7575af1a9c97Smrg      rpath=
7576af1a9c97Smrg      hardcode_libdirs=
7577af1a9c97Smrg      for libdir in $compile_rpath $finalize_rpath; do
7578af1a9c97Smrg	if test -n "$hardcode_libdir_flag_spec"; then
7579af1a9c97Smrg	  if test -n "$hardcode_libdir_separator"; then
7580af1a9c97Smrg	    if test -z "$hardcode_libdirs"; then
7581af1a9c97Smrg	      hardcode_libdirs="$libdir"
7582af1a9c97Smrg	    else
7583af1a9c97Smrg	      # Just accumulate the unique libdirs.
7584af1a9c97Smrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
7585af1a9c97Smrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
7586af1a9c97Smrg		;;
7587af1a9c97Smrg	      *)
7588af1a9c97Smrg		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
7589af1a9c97Smrg		;;
7590af1a9c97Smrg	      esac
7591af1a9c97Smrg	    fi
759250806d53Smrg	  else
7593af1a9c97Smrg	    eval flag=\"$hardcode_libdir_flag_spec\"
7594af1a9c97Smrg	    rpath="$rpath $flag"
759550806d53Smrg	  fi
7596af1a9c97Smrg	elif test -n "$runpath_var"; then
7597af1a9c97Smrg	  case "$perm_rpath " in
7598af1a9c97Smrg	  *" $libdir "*) ;;
7599af1a9c97Smrg	  *) perm_rpath="$perm_rpath $libdir" ;;
7600af1a9c97Smrg	  esac
7601af1a9c97Smrg	fi
7602af1a9c97Smrg	case $host in
7603af1a9c97Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
7604af1a9c97Smrg	  testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'`
7605af1a9c97Smrg	  case :$dllsearchpath: in
7606af1a9c97Smrg	  *":$libdir:"*) ;;
7607af1a9c97Smrg	  ::) dllsearchpath=$libdir;;
7608af1a9c97Smrg	  *) dllsearchpath="$dllsearchpath:$libdir";;
7609af1a9c97Smrg	  esac
7610af1a9c97Smrg	  case :$dllsearchpath: in
7611af1a9c97Smrg	  *":$testbindir:"*) ;;
7612af1a9c97Smrg	  ::) dllsearchpath=$testbindir;;
7613af1a9c97Smrg	  *) dllsearchpath="$dllsearchpath:$testbindir";;
7614af1a9c97Smrg	  esac
7615af1a9c97Smrg	  ;;
7616af1a9c97Smrg	esac
7617af1a9c97Smrg      done
7618af1a9c97Smrg      # Substitute the hardcoded libdirs into the rpath.
7619af1a9c97Smrg      if test -n "$hardcode_libdir_separator" &&
7620af1a9c97Smrg	 test -n "$hardcode_libdirs"; then
7621af1a9c97Smrg	libdir="$hardcode_libdirs"
7622af1a9c97Smrg	eval rpath=\" $hardcode_libdir_flag_spec\"
7623af1a9c97Smrg      fi
7624af1a9c97Smrg      compile_rpath="$rpath"
762550806d53Smrg
7626af1a9c97Smrg      rpath=
7627af1a9c97Smrg      hardcode_libdirs=
7628af1a9c97Smrg      for libdir in $finalize_rpath; do
7629af1a9c97Smrg	if test -n "$hardcode_libdir_flag_spec"; then
7630af1a9c97Smrg	  if test -n "$hardcode_libdir_separator"; then
7631af1a9c97Smrg	    if test -z "$hardcode_libdirs"; then
7632af1a9c97Smrg	      hardcode_libdirs="$libdir"
7633af1a9c97Smrg	    else
7634af1a9c97Smrg	      # Just accumulate the unique libdirs.
7635af1a9c97Smrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
7636af1a9c97Smrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
7637af1a9c97Smrg		;;
7638af1a9c97Smrg	      *)
7639af1a9c97Smrg		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
7640af1a9c97Smrg		;;
7641af1a9c97Smrg	      esac
7642af1a9c97Smrg	    fi
764350806d53Smrg	  else
7644af1a9c97Smrg	    eval flag=\"$hardcode_libdir_flag_spec\"
7645af1a9c97Smrg	    rpath="$rpath $flag"
764650806d53Smrg	  fi
7647af1a9c97Smrg	elif test -n "$runpath_var"; then
7648af1a9c97Smrg	  case "$finalize_perm_rpath " in
7649af1a9c97Smrg	  *" $libdir "*) ;;
7650af1a9c97Smrg	  *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;;
7651af1a9c97Smrg	  esac
765250806d53Smrg	fi
7653af1a9c97Smrg      done
7654af1a9c97Smrg      # Substitute the hardcoded libdirs into the rpath.
7655af1a9c97Smrg      if test -n "$hardcode_libdir_separator" &&
7656af1a9c97Smrg	 test -n "$hardcode_libdirs"; then
7657af1a9c97Smrg	libdir="$hardcode_libdirs"
7658af1a9c97Smrg	eval rpath=\" $hardcode_libdir_flag_spec\"
7659af1a9c97Smrg      fi
7660af1a9c97Smrg      finalize_rpath="$rpath"
766150806d53Smrg
7662af1a9c97Smrg      if test -n "$libobjs" && test "$build_old_libs" = yes; then
7663af1a9c97Smrg	# Transform all the library objects into standard objects.
7664af1a9c97Smrg	compile_command=`$ECHO "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
7665af1a9c97Smrg	finalize_command=`$ECHO "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
7666af1a9c97Smrg      fi
766750806d53Smrg
7668af1a9c97Smrg      func_generate_dlsyms "$outputname" "@PROGRAM@" "no"
766950806d53Smrg
7670af1a9c97Smrg      # template prelinking step
7671af1a9c97Smrg      if test -n "$prelink_cmds"; then
7672af1a9c97Smrg	func_execute_cmds "$prelink_cmds" 'exit $?'
7673af1a9c97Smrg      fi
767450806d53Smrg
7675af1a9c97Smrg      wrappers_required=yes
7676af1a9c97Smrg      case $host in
7677af1a9c97Smrg      *cygwin* | *mingw* )
7678af1a9c97Smrg        if test "$build_libtool_libs" != yes; then
7679af1a9c97Smrg          wrappers_required=no
7680af1a9c97Smrg        fi
7681af1a9c97Smrg        ;;
7682af1a9c97Smrg      *cegcc)
7683af1a9c97Smrg        # Disable wrappers for cegcc, we are cross compiling anyway.
7684af1a9c97Smrg        wrappers_required=no
7685af1a9c97Smrg        ;;
7686af1a9c97Smrg      *)
7687af1a9c97Smrg        if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
7688af1a9c97Smrg          wrappers_required=no
7689af1a9c97Smrg        fi
7690af1a9c97Smrg        ;;
7691af1a9c97Smrg      esac
7692af1a9c97Smrg      if test "$wrappers_required" = no; then
7693af1a9c97Smrg	# Replace the output file specification.
7694af1a9c97Smrg	compile_command=`$ECHO "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
7695af1a9c97Smrg	link_command="$compile_command$compile_rpath"
769650806d53Smrg
7697af1a9c97Smrg	# We have no uninstalled library dependencies, so finalize right now.
7698af1a9c97Smrg	exit_status=0
7699af1a9c97Smrg	func_show_eval "$link_command" 'exit_status=$?'
770050806d53Smrg
7701af1a9c97Smrg	# Delete the generated files.
7702af1a9c97Smrg	if test -f "$output_objdir/${outputname}S.${objext}"; then
7703af1a9c97Smrg	  func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"'
770450806d53Smrg	fi
770550806d53Smrg
7706af1a9c97Smrg	exit $exit_status
7707af1a9c97Smrg      fi
770850806d53Smrg
7709af1a9c97Smrg      if test -n "$compile_shlibpath$finalize_shlibpath"; then
7710af1a9c97Smrg	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
7711af1a9c97Smrg      fi
7712af1a9c97Smrg      if test -n "$finalize_shlibpath"; then
7713af1a9c97Smrg	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
7714af1a9c97Smrg      fi
771550806d53Smrg
7716af1a9c97Smrg      compile_var=
7717af1a9c97Smrg      finalize_var=
7718af1a9c97Smrg      if test -n "$runpath_var"; then
7719af1a9c97Smrg	if test -n "$perm_rpath"; then
7720af1a9c97Smrg	  # We should set the runpath_var.
7721af1a9c97Smrg	  rpath=
7722af1a9c97Smrg	  for dir in $perm_rpath; do
7723af1a9c97Smrg	    rpath="$rpath$dir:"
7724af1a9c97Smrg	  done
7725af1a9c97Smrg	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
772650806d53Smrg	fi
7727af1a9c97Smrg	if test -n "$finalize_perm_rpath"; then
7728af1a9c97Smrg	  # We should set the runpath_var.
7729af1a9c97Smrg	  rpath=
7730af1a9c97Smrg	  for dir in $finalize_perm_rpath; do
7731af1a9c97Smrg	    rpath="$rpath$dir:"
7732af1a9c97Smrg	  done
7733af1a9c97Smrg	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
773450806d53Smrg	fi
7735af1a9c97Smrg      fi
773650806d53Smrg
7737af1a9c97Smrg      if test "$no_install" = yes; then
7738af1a9c97Smrg	# We don't need to create a wrapper script.
7739af1a9c97Smrg	link_command="$compile_var$compile_command$compile_rpath"
7740af1a9c97Smrg	# Replace the output file specification.
7741af1a9c97Smrg	link_command=`$ECHO "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
7742af1a9c97Smrg	# Delete the old output file.
7743af1a9c97Smrg	$opt_dry_run || $RM $output
7744af1a9c97Smrg	# Link the executable and exit
7745af1a9c97Smrg	func_show_eval "$link_command" 'exit $?'
774650806d53Smrg	exit $EXIT_SUCCESS
7747af1a9c97Smrg      fi
774850806d53Smrg
7749af1a9c97Smrg      if test "$hardcode_action" = relink; then
7750af1a9c97Smrg	# Fast installation is not supported
7751af1a9c97Smrg	link_command="$compile_var$compile_command$compile_rpath"
7752af1a9c97Smrg	relink_command="$finalize_var$finalize_command$finalize_rpath"
7753af1a9c97Smrg
7754af1a9c97Smrg	func_warning "this platform does not like uninstalled shared libraries"
7755af1a9c97Smrg	func_warning "\`$output' will be relinked during installation"
7756af1a9c97Smrg      else
7757af1a9c97Smrg	if test "$fast_install" != no; then
7758af1a9c97Smrg	  link_command="$finalize_var$compile_command$finalize_rpath"
7759af1a9c97Smrg	  if test "$fast_install" = yes; then
7760af1a9c97Smrg	    relink_command=`$ECHO "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'`
7761af1a9c97Smrg	  else
7762af1a9c97Smrg	    # fast_install is set to needless
7763af1a9c97Smrg	    relink_command=
7764af1a9c97Smrg	  fi
776550806d53Smrg	else
7766af1a9c97Smrg	  link_command="$compile_var$compile_command$compile_rpath"
7767af1a9c97Smrg	  relink_command="$finalize_var$finalize_command$finalize_rpath"
776850806d53Smrg	fi
7769af1a9c97Smrg      fi
777050806d53Smrg
7771af1a9c97Smrg      # Replace the output file specification.
7772af1a9c97Smrg      link_command=`$ECHO "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
777350806d53Smrg
7774af1a9c97Smrg      # Delete the old output files.
7775af1a9c97Smrg      $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
777650806d53Smrg
7777af1a9c97Smrg      func_show_eval "$link_command" 'exit $?'
777850806d53Smrg
7779af1a9c97Smrg      # Now create the wrapper script.
7780af1a9c97Smrg      func_verbose "creating $output"
778150806d53Smrg
7782af1a9c97Smrg      # Quote the relink command for shipping.
7783af1a9c97Smrg      if test -n "$relink_command"; then
7784af1a9c97Smrg	# Preserve any variables that may affect compiler behavior
7785af1a9c97Smrg	for var in $variables_saved_for_relink; do
7786af1a9c97Smrg	  if eval test -z \"\${$var+set}\"; then
7787af1a9c97Smrg	    relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
7788af1a9c97Smrg	  elif eval var_value=\$$var; test -z "$var_value"; then
7789af1a9c97Smrg	    relink_command="$var=; export $var; $relink_command"
779050806d53Smrg	  else
7791af1a9c97Smrg	    func_quote_for_eval "$var_value"
7792af1a9c97Smrg	    relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
779350806d53Smrg	  fi
7794af1a9c97Smrg	done
7795af1a9c97Smrg	relink_command="(cd `pwd`; $relink_command)"
7796af1a9c97Smrg	relink_command=`$ECHO "X$relink_command" | $Xsed -e "$sed_quote_subst"`
7797af1a9c97Smrg      fi
779850806d53Smrg
7799af1a9c97Smrg      # Quote $ECHO for shipping.
7800af1a9c97Smrg      if test "X$ECHO" = "X$SHELL $progpath --fallback-echo"; then
7801af1a9c97Smrg	case $progpath in
7802af1a9c97Smrg	[\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $progpath --fallback-echo";;
7803af1a9c97Smrg	*) qecho="$SHELL `pwd`/$progpath --fallback-echo";;
7804af1a9c97Smrg	esac
7805af1a9c97Smrg	qecho=`$ECHO "X$qecho" | $Xsed -e "$sed_quote_subst"`
7806af1a9c97Smrg      else
7807af1a9c97Smrg	qecho=`$ECHO "X$ECHO" | $Xsed -e "$sed_quote_subst"`
7808af1a9c97Smrg      fi
7809af1a9c97Smrg
7810af1a9c97Smrg      # Only actually do things if not in dry run mode.
7811af1a9c97Smrg      $opt_dry_run || {
7812af1a9c97Smrg	# win32 will think the script is a binary if it has
7813af1a9c97Smrg	# a .exe suffix, so we strip it off here.
7814af1a9c97Smrg	case $output in
7815af1a9c97Smrg	  *.exe) func_stripname '' '.exe' "$output"
7816af1a9c97Smrg	         output=$func_stripname_result ;;
7817af1a9c97Smrg	esac
7818af1a9c97Smrg	# test for cygwin because mv fails w/o .exe extensions
7819af1a9c97Smrg	case $host in
7820af1a9c97Smrg	  *cygwin*)
7821af1a9c97Smrg	    exeext=.exe
7822af1a9c97Smrg	    func_stripname '' '.exe' "$outputname"
7823af1a9c97Smrg	    outputname=$func_stripname_result ;;
7824af1a9c97Smrg	  *) exeext= ;;
782550806d53Smrg	esac
7826af1a9c97Smrg	case $host in
7827af1a9c97Smrg	  *cygwin* | *mingw* )
7828af1a9c97Smrg	    func_dirname_and_basename "$output" "" "."
7829af1a9c97Smrg	    output_name=$func_basename_result
7830af1a9c97Smrg	    output_path=$func_dirname_result
7831af1a9c97Smrg	    cwrappersource="$output_path/$objdir/lt-$output_name.c"
7832af1a9c97Smrg	    cwrapper="$output_path/$output_name.exe"
7833af1a9c97Smrg	    $RM $cwrappersource $cwrapper
7834af1a9c97Smrg	    trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
7835af1a9c97Smrg
7836af1a9c97Smrg	    func_emit_cwrapperexe_src > $cwrappersource
7837af1a9c97Smrg
7838af1a9c97Smrg	    # The wrapper executable is built using the $host compiler,
7839af1a9c97Smrg	    # because it contains $host paths and files. If cross-
7840af1a9c97Smrg	    # compiling, it, like the target executable, must be
7841af1a9c97Smrg	    # executed on the $host or under an emulation environment.
7842af1a9c97Smrg	    $opt_dry_run || {
7843af1a9c97Smrg	      $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
7844af1a9c97Smrg	      $STRIP $cwrapper
7845af1a9c97Smrg	    }
784650806d53Smrg
7847af1a9c97Smrg	    # Now, create the wrapper script for func_source use:
7848af1a9c97Smrg	    func_ltwrapper_scriptname $cwrapper
7849af1a9c97Smrg	    $RM $func_ltwrapper_scriptname_result
7850af1a9c97Smrg	    trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
7851af1a9c97Smrg	    $opt_dry_run || {
7852af1a9c97Smrg	      # note: this script will not be executed, so do not chmod.
7853af1a9c97Smrg	      if test "x$build" = "x$host" ; then
7854af1a9c97Smrg		$cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
7855af1a9c97Smrg	      else
7856af1a9c97Smrg		func_emit_wrapper no > $func_ltwrapper_scriptname_result
7857af1a9c97Smrg	      fi
7858af1a9c97Smrg	    }
7859af1a9c97Smrg	  ;;
7860af1a9c97Smrg	  * )
7861af1a9c97Smrg	    $RM $output
7862af1a9c97Smrg	    trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
786350806d53Smrg
7864af1a9c97Smrg	    func_emit_wrapper no > $output
7865af1a9c97Smrg	    chmod +x $output
7866af1a9c97Smrg	  ;;
7867af1a9c97Smrg	esac
7868af1a9c97Smrg      }
7869af1a9c97Smrg      exit $EXIT_SUCCESS
7870af1a9c97Smrg      ;;
7871af1a9c97Smrg    esac
787250806d53Smrg
7873af1a9c97Smrg    # See if we need to build an old-fashioned archive.
7874af1a9c97Smrg    for oldlib in $oldlibs; do
787550806d53Smrg
7876af1a9c97Smrg      if test "$build_libtool_libs" = convenience; then
7877af1a9c97Smrg	oldobjs="$libobjs_save $symfileobj"
7878af1a9c97Smrg	addlibs="$convenience"
7879af1a9c97Smrg	build_libtool_libs=no
7880af1a9c97Smrg      else
7881af1a9c97Smrg	if test "$build_libtool_libs" = module; then
7882af1a9c97Smrg	  oldobjs="$libobjs_save"
7883af1a9c97Smrg	  build_libtool_libs=no
7884af1a9c97Smrg	else
7885af1a9c97Smrg	  oldobjs="$old_deplibs $non_pic_objects"
7886af1a9c97Smrg	  if test "$preload" = yes && test -f "$symfileobj"; then
7887af1a9c97Smrg	    oldobjs="$oldobjs $symfileobj"
7888af1a9c97Smrg	  fi
7889af1a9c97Smrg	fi
7890af1a9c97Smrg	addlibs="$old_convenience"
789150806d53Smrg      fi
789250806d53Smrg
7893af1a9c97Smrg      if test -n "$addlibs"; then
7894af1a9c97Smrg	gentop="$output_objdir/${outputname}x"
7895af1a9c97Smrg	generated="$generated $gentop"
789650806d53Smrg
7897af1a9c97Smrg	func_extract_archives $gentop $addlibs
7898af1a9c97Smrg	oldobjs="$oldobjs $func_extract_archives_result"
7899af1a9c97Smrg      fi
790050806d53Smrg
7901af1a9c97Smrg      # Do each command in the archive commands.
7902af1a9c97Smrg      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
7903af1a9c97Smrg	cmds=$old_archive_from_new_cmds
7904af1a9c97Smrg      else
790550806d53Smrg
7906af1a9c97Smrg	# Add any objects from preloaded convenience libraries
7907af1a9c97Smrg	if test -n "$dlprefiles"; then
7908af1a9c97Smrg	  gentop="$output_objdir/${outputname}x"
7909af1a9c97Smrg	  generated="$generated $gentop"
791050806d53Smrg
7911af1a9c97Smrg	  func_extract_archives $gentop $dlprefiles
7912af1a9c97Smrg	  oldobjs="$oldobjs $func_extract_archives_result"
7913af1a9c97Smrg	fi
791450806d53Smrg
7915af1a9c97Smrg	# POSIX demands no paths to be encoded in archives.  We have
7916af1a9c97Smrg	# to avoid creating archives with duplicate basenames if we
7917af1a9c97Smrg	# might have to extract them afterwards, e.g., when creating a
7918af1a9c97Smrg	# static archive out of a convenience library, or when linking
7919af1a9c97Smrg	# the entirety of a libtool archive into another (currently
7920af1a9c97Smrg	# not supported by libtool).
7921af1a9c97Smrg	if (for obj in $oldobjs
7922af1a9c97Smrg	    do
7923af1a9c97Smrg	      func_basename "$obj"
7924af1a9c97Smrg	      $ECHO "$func_basename_result"
7925af1a9c97Smrg	    done | sort | sort -uc >/dev/null 2>&1); then
7926af1a9c97Smrg	  :
7927af1a9c97Smrg	else
7928af1a9c97Smrg	  $ECHO "copying selected object files to avoid basename conflicts..."
7929af1a9c97Smrg	  gentop="$output_objdir/${outputname}x"
7930af1a9c97Smrg	  generated="$generated $gentop"
7931af1a9c97Smrg	  func_mkdir_p "$gentop"
7932af1a9c97Smrg	  save_oldobjs=$oldobjs
7933af1a9c97Smrg	  oldobjs=
7934af1a9c97Smrg	  counter=1
7935af1a9c97Smrg	  for obj in $save_oldobjs
7936af1a9c97Smrg	  do
7937af1a9c97Smrg	    func_basename "$obj"
7938af1a9c97Smrg	    objbase="$func_basename_result"
7939af1a9c97Smrg	    case " $oldobjs " in
7940af1a9c97Smrg	    " ") oldobjs=$obj ;;
7941af1a9c97Smrg	    *[\ /]"$objbase "*)
7942af1a9c97Smrg	      while :; do
7943af1a9c97Smrg		# Make sure we don't pick an alternate name that also
7944af1a9c97Smrg		# overlaps.
7945af1a9c97Smrg		newobj=lt$counter-$objbase
7946af1a9c97Smrg		func_arith $counter + 1
7947af1a9c97Smrg		counter=$func_arith_result
7948af1a9c97Smrg		case " $oldobjs " in
7949af1a9c97Smrg		*[\ /]"$newobj "*) ;;
7950af1a9c97Smrg		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
7951af1a9c97Smrg		esac
7952af1a9c97Smrg	      done
7953af1a9c97Smrg	      func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
7954af1a9c97Smrg	      oldobjs="$oldobjs $gentop/$newobj"
7955af1a9c97Smrg	      ;;
7956af1a9c97Smrg	    *) oldobjs="$oldobjs $obj" ;;
7957af1a9c97Smrg	    esac
795850806d53Smrg	  done
795950806d53Smrg	fi
7960af1a9c97Smrg	eval cmds=\"$old_archive_cmds\"
796150806d53Smrg
7962af1a9c97Smrg	func_len " $cmds"
7963af1a9c97Smrg	len=$func_len_result
7964af1a9c97Smrg	if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
7965af1a9c97Smrg	  cmds=$old_archive_cmds
7966af1a9c97Smrg	else
7967af1a9c97Smrg	  # the command line is too long to link in one step, link in parts
7968af1a9c97Smrg	  func_verbose "using piecewise archive linking..."
7969af1a9c97Smrg	  save_RANLIB=$RANLIB
7970af1a9c97Smrg	  RANLIB=:
7971af1a9c97Smrg	  objlist=
7972af1a9c97Smrg	  concat_cmds=
7973af1a9c97Smrg	  save_oldobjs=$oldobjs
7974af1a9c97Smrg	  oldobjs=
7975af1a9c97Smrg	  # Is there a better way of finding the last object in the list?
7976af1a9c97Smrg	  for obj in $save_oldobjs
7977af1a9c97Smrg	  do
7978af1a9c97Smrg	    last_oldobj=$obj
7979af1a9c97Smrg	  done
7980af1a9c97Smrg	  eval test_cmds=\"$old_archive_cmds\"
7981af1a9c97Smrg	  func_len " $test_cmds"
7982af1a9c97Smrg	  len0=$func_len_result
7983af1a9c97Smrg	  len=$len0
7984af1a9c97Smrg	  for obj in $save_oldobjs
7985af1a9c97Smrg	  do
7986af1a9c97Smrg	    func_len " $obj"
7987af1a9c97Smrg	    func_arith $len + $func_len_result
7988af1a9c97Smrg	    len=$func_arith_result
7989af1a9c97Smrg	    func_append objlist " $obj"
7990af1a9c97Smrg	    if test "$len" -lt "$max_cmd_len"; then
7991af1a9c97Smrg	      :
7992af1a9c97Smrg	    else
7993af1a9c97Smrg	      # the above command should be used before it gets too long
7994af1a9c97Smrg	      oldobjs=$objlist
7995af1a9c97Smrg	      if test "$obj" = "$last_oldobj" ; then
7996af1a9c97Smrg		RANLIB=$save_RANLIB
7997af1a9c97Smrg	      fi
7998af1a9c97Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
7999af1a9c97Smrg	      eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
8000af1a9c97Smrg	      objlist=
8001af1a9c97Smrg	      len=$len0
8002af1a9c97Smrg	    fi
8003af1a9c97Smrg	  done
8004af1a9c97Smrg	  RANLIB=$save_RANLIB
8005af1a9c97Smrg	  oldobjs=$objlist
8006af1a9c97Smrg	  if test "X$oldobjs" = "X" ; then
8007af1a9c97Smrg	    eval cmds=\"\$concat_cmds\"
8008af1a9c97Smrg	  else
8009af1a9c97Smrg	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
8010af1a9c97Smrg	  fi
8011af1a9c97Smrg	fi
8012af1a9c97Smrg      fi
8013af1a9c97Smrg      func_execute_cmds "$cmds" 'exit $?'
801450806d53Smrg    done
801550806d53Smrg
8016af1a9c97Smrg    test -n "$generated" && \
8017af1a9c97Smrg      func_show_eval "${RM}r$generated"
801850806d53Smrg
8019af1a9c97Smrg    # Now create the libtool archive.
8020af1a9c97Smrg    case $output in
8021af1a9c97Smrg    *.la)
8022af1a9c97Smrg      old_library=
8023af1a9c97Smrg      test "$build_old_libs" = yes && old_library="$libname.$libext"
8024af1a9c97Smrg      func_verbose "creating $output"
802550806d53Smrg
8026af1a9c97Smrg      # Preserve any variables that may affect compiler behavior
8027af1a9c97Smrg      for var in $variables_saved_for_relink; do
8028af1a9c97Smrg	if eval test -z \"\${$var+set}\"; then
8029af1a9c97Smrg	  relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
8030af1a9c97Smrg	elif eval var_value=\$$var; test -z "$var_value"; then
8031af1a9c97Smrg	  relink_command="$var=; export $var; $relink_command"
803250806d53Smrg	else
8033af1a9c97Smrg	  func_quote_for_eval "$var_value"
8034af1a9c97Smrg	  relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
803550806d53Smrg	fi
8036af1a9c97Smrg      done
8037af1a9c97Smrg      # Quote the link command for shipping.
8038af1a9c97Smrg      relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
8039af1a9c97Smrg      relink_command=`$ECHO "X$relink_command" | $Xsed -e "$sed_quote_subst"`
8040af1a9c97Smrg      if test "$hardcode_automatic" = yes ; then
8041af1a9c97Smrg	relink_command=
8042af1a9c97Smrg      fi
804350806d53Smrg
8044af1a9c97Smrg      # Only create the output if not a dry run.
8045af1a9c97Smrg      $opt_dry_run || {
8046af1a9c97Smrg	for installed in no yes; do
8047af1a9c97Smrg	  if test "$installed" = yes; then
8048af1a9c97Smrg	    if test -z "$install_libdir"; then
8049af1a9c97Smrg	      break
8050af1a9c97Smrg	    fi
8051af1a9c97Smrg	    output="$output_objdir/$outputname"i
8052af1a9c97Smrg	    # Replace all uninstalled libtool libraries with the installed ones
8053af1a9c97Smrg	    newdependency_libs=
8054af1a9c97Smrg	    for deplib in $dependency_libs; do
8055af1a9c97Smrg	      case $deplib in
8056af1a9c97Smrg	      *.la)
8057af1a9c97Smrg		func_basename "$deplib"
8058af1a9c97Smrg		name="$func_basename_result"
8059af1a9c97Smrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
8060af1a9c97Smrg		test -z "$libdir" && \
8061af1a9c97Smrg		  func_fatal_error "\`$deplib' is not a valid libtool archive"
8062af1a9c97Smrg		newdependency_libs="$newdependency_libs $libdir/$name"
8063af1a9c97Smrg		;;
8064af1a9c97Smrg	      *) newdependency_libs="$newdependency_libs $deplib" ;;
8065af1a9c97Smrg	      esac
8066af1a9c97Smrg	    done
8067af1a9c97Smrg	    dependency_libs="$newdependency_libs"
8068af1a9c97Smrg	    newdlfiles=
8069af1a9c97Smrg
8070af1a9c97Smrg	    for lib in $dlfiles; do
8071af1a9c97Smrg	      case $lib in
8072af1a9c97Smrg	      *.la)
8073af1a9c97Smrg	        func_basename "$lib"
8074af1a9c97Smrg		name="$func_basename_result"
8075af1a9c97Smrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
8076af1a9c97Smrg		test -z "$libdir" && \
8077af1a9c97Smrg		  func_fatal_error "\`$lib' is not a valid libtool archive"
8078af1a9c97Smrg		newdlfiles="$newdlfiles $libdir/$name"
8079af1a9c97Smrg		;;
8080af1a9c97Smrg	      *) newdlfiles="$newdlfiles $lib" ;;
8081af1a9c97Smrg	      esac
8082af1a9c97Smrg	    done
8083af1a9c97Smrg	    dlfiles="$newdlfiles"
8084af1a9c97Smrg	    newdlprefiles=
8085af1a9c97Smrg	    for lib in $dlprefiles; do
8086af1a9c97Smrg	      case $lib in
8087af1a9c97Smrg	      *.la)
8088af1a9c97Smrg		# Only pass preopened files to the pseudo-archive (for
8089af1a9c97Smrg		# eventual linking with the app. that links it) if we
8090af1a9c97Smrg		# didn't already link the preopened objects directly into
8091af1a9c97Smrg		# the library:
8092af1a9c97Smrg		func_basename "$lib"
8093af1a9c97Smrg		name="$func_basename_result"
8094af1a9c97Smrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
8095af1a9c97Smrg		test -z "$libdir" && \
8096af1a9c97Smrg		  func_fatal_error "\`$lib' is not a valid libtool archive"
8097af1a9c97Smrg		newdlprefiles="$newdlprefiles $libdir/$name"
8098af1a9c97Smrg		;;
8099af1a9c97Smrg	      esac
8100af1a9c97Smrg	    done
8101af1a9c97Smrg	    dlprefiles="$newdlprefiles"
8102af1a9c97Smrg	  else
8103af1a9c97Smrg	    newdlfiles=
8104af1a9c97Smrg	    for lib in $dlfiles; do
8105af1a9c97Smrg	      case $lib in
8106af1a9c97Smrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
8107af1a9c97Smrg		*) abs=`pwd`"/$lib" ;;
8108af1a9c97Smrg	      esac
8109af1a9c97Smrg	      newdlfiles="$newdlfiles $abs"
8110af1a9c97Smrg	    done
8111af1a9c97Smrg	    dlfiles="$newdlfiles"
8112af1a9c97Smrg	    newdlprefiles=
8113af1a9c97Smrg	    for lib in $dlprefiles; do
8114af1a9c97Smrg	      case $lib in
8115af1a9c97Smrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
8116af1a9c97Smrg		*) abs=`pwd`"/$lib" ;;
8117af1a9c97Smrg	      esac
8118af1a9c97Smrg	      newdlprefiles="$newdlprefiles $abs"
8119af1a9c97Smrg	    done
8120af1a9c97Smrg	    dlprefiles="$newdlprefiles"
8121af1a9c97Smrg	  fi
8122af1a9c97Smrg	  $RM $output
8123af1a9c97Smrg	  # place dlname in correct position for cygwin
8124af1a9c97Smrg	  tdlname=$dlname
8125af1a9c97Smrg	  case $host,$output,$installed,$module,$dlname in
8126af1a9c97Smrg	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;;
8127af1a9c97Smrg	  esac
8128af1a9c97Smrg	  $ECHO > $output "\
8129af1a9c97Smrg# $outputname - a libtool library file
8130af1a9c97Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
8131af1a9c97Smrg#
8132af1a9c97Smrg# Please DO NOT delete this file!
8133af1a9c97Smrg# It is necessary for linking the library.
813450806d53Smrg
8135af1a9c97Smrg# The name that we can dlopen(3).
8136af1a9c97Smrgdlname='$tdlname'
813750806d53Smrg
8138af1a9c97Smrg# Names of this library.
8139af1a9c97Smrglibrary_names='$library_names'
814050806d53Smrg
8141af1a9c97Smrg# The name of the static archive.
8142af1a9c97Smrgold_library='$old_library'
814350806d53Smrg
8144af1a9c97Smrg# Linker flags that can not go in dependency_libs.
8145af1a9c97Smrginherited_linker_flags='$new_inherited_linker_flags'
814650806d53Smrg
8147af1a9c97Smrg# Libraries that this one depends upon.
8148af1a9c97Smrgdependency_libs='$dependency_libs'
814950806d53Smrg
8150af1a9c97Smrg# Names of additional weak libraries provided by this library
8151af1a9c97Smrgweak_library_names='$weak_libs'
815250806d53Smrg
8153af1a9c97Smrg# Version information for $libname.
8154af1a9c97Smrgcurrent=$current
8155af1a9c97Smrgage=$age
8156af1a9c97Smrgrevision=$revision
815750806d53Smrg
8158af1a9c97Smrg# Is this an already installed library?
8159af1a9c97Smrginstalled=$installed
816050806d53Smrg
8161af1a9c97Smrg# Should we warn about portability when linking against -modules?
8162af1a9c97Smrgshouldnotlink=$module
816350806d53Smrg
8164af1a9c97Smrg# Files to dlopen/dlpreopen
8165af1a9c97Smrgdlopen='$dlfiles'
8166af1a9c97Smrgdlpreopen='$dlprefiles'
816750806d53Smrg
8168af1a9c97Smrg# Directory that this library needs to be installed in:
8169af1a9c97Smrglibdir='$install_libdir'"
8170af1a9c97Smrg	  if test "$installed" = no && test "$need_relink" = yes; then
8171af1a9c97Smrg	    $ECHO >> $output "\
8172af1a9c97Smrgrelink_command=\"$relink_command\""
8173af1a9c97Smrg	  fi
8174af1a9c97Smrg	done
8175af1a9c97Smrg      }
817650806d53Smrg
8177af1a9c97Smrg      # Do a symbolic link so that the libtool archive can be found in
8178af1a9c97Smrg      # LD_LIBRARY_PATH before the program is installed.
8179af1a9c97Smrg      func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
8180af1a9c97Smrg      ;;
8181af1a9c97Smrg    esac
8182af1a9c97Smrg    exit $EXIT_SUCCESS
8183af1a9c97Smrg}
818450806d53Smrg
8185af1a9c97Smrg{ test "$mode" = link || test "$mode" = relink; } &&
8186af1a9c97Smrg    func_mode_link ${1+"$@"}
818750806d53Smrg
818850806d53Smrg
8189af1a9c97Smrg# func_mode_uninstall arg...
8190af1a9c97Smrgfunc_mode_uninstall ()
8191af1a9c97Smrg{
8192af1a9c97Smrg    $opt_debug
8193af1a9c97Smrg    RM="$nonopt"
819450806d53Smrg    files=
819550806d53Smrg    rmforce=
819650806d53Smrg    exit_status=0
819750806d53Smrg
819850806d53Smrg    # This variable tells wrapper scripts just to set variables rather
819950806d53Smrg    # than running their programs.
820050806d53Smrg    libtool_install_magic="$magic"
820150806d53Smrg
820250806d53Smrg    for arg
820350806d53Smrg    do
820450806d53Smrg      case $arg in
8205af1a9c97Smrg      -f) RM="$RM $arg"; rmforce=yes ;;
8206af1a9c97Smrg      -*) RM="$RM $arg" ;;
820750806d53Smrg      *) files="$files $arg" ;;
820850806d53Smrg      esac
820950806d53Smrg    done
821050806d53Smrg
8211af1a9c97Smrg    test -z "$RM" && \
8212af1a9c97Smrg      func_fatal_help "you must specify an RM program"
821350806d53Smrg
821450806d53Smrg    rmdirs=
821550806d53Smrg
821650806d53Smrg    origobjdir="$objdir"
821750806d53Smrg    for file in $files; do
8218af1a9c97Smrg      func_dirname "$file" "" "."
8219af1a9c97Smrg      dir="$func_dirname_result"
8220af1a9c97Smrg      if test "X$dir" = X.; then
822150806d53Smrg	objdir="$origobjdir"
822250806d53Smrg      else
822350806d53Smrg	objdir="$dir/$origobjdir"
822450806d53Smrg      fi
8225af1a9c97Smrg      func_basename "$file"
8226af1a9c97Smrg      name="$func_basename_result"
822750806d53Smrg      test "$mode" = uninstall && objdir="$dir"
822850806d53Smrg
822950806d53Smrg      # Remember objdir for removal later, being careful to avoid duplicates
823050806d53Smrg      if test "$mode" = clean; then
823150806d53Smrg	case " $rmdirs " in
823250806d53Smrg	  *" $objdir "*) ;;
823350806d53Smrg	  *) rmdirs="$rmdirs $objdir" ;;
823450806d53Smrg	esac
823550806d53Smrg      fi
823650806d53Smrg
823750806d53Smrg      # Don't error if the file doesn't exist and rm -f was used.
8238af1a9c97Smrg      if { test -L "$file"; } >/dev/null 2>&1 ||
8239af1a9c97Smrg	 { test -h "$file"; } >/dev/null 2>&1 ||
8240af1a9c97Smrg	 test -f "$file"; then
824150806d53Smrg	:
824250806d53Smrg      elif test -d "$file"; then
824350806d53Smrg	exit_status=1
824450806d53Smrg	continue
824550806d53Smrg      elif test "$rmforce" = yes; then
824650806d53Smrg	continue
824750806d53Smrg      fi
824850806d53Smrg
824950806d53Smrg      rmfiles="$file"
825050806d53Smrg
825150806d53Smrg      case $name in
825250806d53Smrg      *.la)
825350806d53Smrg	# Possibly a libtool archive, so verify it.
8254af1a9c97Smrg	if func_lalib_p "$file"; then
8255af1a9c97Smrg	  func_source $dir/$name
825650806d53Smrg
825750806d53Smrg	  # Delete the libtool libraries and symlinks.
825850806d53Smrg	  for n in $library_names; do
825950806d53Smrg	    rmfiles="$rmfiles $objdir/$n"
826050806d53Smrg	  done
826150806d53Smrg	  test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library"
826250806d53Smrg
826350806d53Smrg	  case "$mode" in
826450806d53Smrg	  clean)
826550806d53Smrg	    case "  $library_names " in
826650806d53Smrg	    # "  " in the beginning catches empty $dlname
826750806d53Smrg	    *" $dlname "*) ;;
826850806d53Smrg	    *) rmfiles="$rmfiles $objdir/$dlname" ;;
826950806d53Smrg	    esac
8270af1a9c97Smrg	    test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i"
827150806d53Smrg	    ;;
827250806d53Smrg	  uninstall)
827350806d53Smrg	    if test -n "$library_names"; then
827450806d53Smrg	      # Do each command in the postuninstall commands.
8275af1a9c97Smrg	      func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
827650806d53Smrg	    fi
827750806d53Smrg
827850806d53Smrg	    if test -n "$old_library"; then
827950806d53Smrg	      # Do each command in the old_postuninstall commands.
8280af1a9c97Smrg	      func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
828150806d53Smrg	    fi
828250806d53Smrg	    # FIXME: should reinstall the best remaining shared library.
828350806d53Smrg	    ;;
828450806d53Smrg	  esac
828550806d53Smrg	fi
828650806d53Smrg	;;
828750806d53Smrg
828850806d53Smrg      *.lo)
828950806d53Smrg	# Possibly a libtool object, so verify it.
8290af1a9c97Smrg	if func_lalib_p "$file"; then
829150806d53Smrg
829250806d53Smrg	  # Read the .lo file
8293af1a9c97Smrg	  func_source $dir/$name
829450806d53Smrg
829550806d53Smrg	  # Add PIC object to the list of files to remove.
8296af1a9c97Smrg	  if test -n "$pic_object" &&
8297af1a9c97Smrg	     test "$pic_object" != none; then
829850806d53Smrg	    rmfiles="$rmfiles $dir/$pic_object"
829950806d53Smrg	  fi
830050806d53Smrg
830150806d53Smrg	  # Add non-PIC object to the list of files to remove.
8302af1a9c97Smrg	  if test -n "$non_pic_object" &&
8303af1a9c97Smrg	     test "$non_pic_object" != none; then
830450806d53Smrg	    rmfiles="$rmfiles $dir/$non_pic_object"
830550806d53Smrg	  fi
830650806d53Smrg	fi
830750806d53Smrg	;;
830850806d53Smrg
830950806d53Smrg      *)
831050806d53Smrg	if test "$mode" = clean ; then
831150806d53Smrg	  noexename=$name
831250806d53Smrg	  case $file in
831350806d53Smrg	  *.exe)
8314af1a9c97Smrg	    func_stripname '' '.exe' "$file"
8315af1a9c97Smrg	    file=$func_stripname_result
8316af1a9c97Smrg	    func_stripname '' '.exe' "$name"
8317af1a9c97Smrg	    noexename=$func_stripname_result
831850806d53Smrg	    # $file with .exe has already been added to rmfiles,
831950806d53Smrg	    # add $file without .exe
832050806d53Smrg	    rmfiles="$rmfiles $file"
832150806d53Smrg	    ;;
832250806d53Smrg	  esac
832350806d53Smrg	  # Do a test to see if this is a libtool program.
8324af1a9c97Smrg	  if func_ltwrapper_p "$file"; then
8325af1a9c97Smrg	    if func_ltwrapper_executable_p "$file"; then
8326af1a9c97Smrg	      func_ltwrapper_scriptname "$file"
8327af1a9c97Smrg	      relink_command=
8328af1a9c97Smrg	      func_source $func_ltwrapper_scriptname_result
8329af1a9c97Smrg	      rmfiles="$rmfiles $func_ltwrapper_scriptname_result"
8330af1a9c97Smrg	    else
8331af1a9c97Smrg	      relink_command=
8332af1a9c97Smrg	      func_source $dir/$noexename
8333af1a9c97Smrg	    fi
833450806d53Smrg
833550806d53Smrg	    # note $name still contains .exe if it was in $file originally
833650806d53Smrg	    # as does the version of $file that was added into $rmfiles
833750806d53Smrg	    rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}"
833850806d53Smrg	    if test "$fast_install" = yes && test -n "$relink_command"; then
833950806d53Smrg	      rmfiles="$rmfiles $objdir/lt-$name"
834050806d53Smrg	    fi
834150806d53Smrg	    if test "X$noexename" != "X$name" ; then
834250806d53Smrg	      rmfiles="$rmfiles $objdir/lt-${noexename}.c"
834350806d53Smrg	    fi
834450806d53Smrg	  fi
834550806d53Smrg	fi
834650806d53Smrg	;;
834750806d53Smrg      esac
8348af1a9c97Smrg      func_show_eval "$RM $rmfiles" 'exit_status=1'
834950806d53Smrg    done
835050806d53Smrg    objdir="$origobjdir"
835150806d53Smrg
835250806d53Smrg    # Try to remove the ${objdir}s in the directories where we deleted files
835350806d53Smrg    for dir in $rmdirs; do
835450806d53Smrg      if test -d "$dir"; then
8355af1a9c97Smrg	func_show_eval "rmdir $dir >/dev/null 2>&1"
835650806d53Smrg      fi
835750806d53Smrg    done
835850806d53Smrg
835950806d53Smrg    exit $exit_status
8360af1a9c97Smrg}
836150806d53Smrg
8362af1a9c97Smrg{ test "$mode" = uninstall || test "$mode" = clean; } &&
8363af1a9c97Smrg    func_mode_uninstall ${1+"$@"}
836450806d53Smrg
8365af1a9c97Smrgtest -z "$mode" && {
8366af1a9c97Smrg  help="$generic_help"
8367af1a9c97Smrg  func_fatal_help "you must specify a MODE"
8368af1a9c97Smrg}
8369af1a9c97Smrg
8370af1a9c97Smrgtest -z "$exec_cmd" && \
8371af1a9c97Smrg  func_fatal_help "invalid operation mode \`$mode'"
837250806d53Smrg
837350806d53Smrgif test -n "$exec_cmd"; then
8374af1a9c97Smrg  eval exec "$exec_cmd"
837550806d53Smrg  exit $EXIT_FAILURE
837650806d53Smrgfi
837750806d53Smrg
8378af1a9c97Smrgexit $exit_status
837950806d53Smrg
838050806d53Smrg
838150806d53Smrg# The TAGs below are defined such that we never get into a situation
838250806d53Smrg# in which we disable both kinds of libraries.  Given conflicting
838350806d53Smrg# choices, we go for a static library, that is the most portable,
838450806d53Smrg# since we can't tell whether shared libraries were disabled because
838550806d53Smrg# the user asked for that or because the platform doesn't support
838650806d53Smrg# them.  This is particularly important on AIX, because we don't
838750806d53Smrg# support having both static and shared libraries enabled at the same
838850806d53Smrg# time on that platform, so we default to a shared-only configuration.
838950806d53Smrg# If a disable-shared tag is given, we'll fallback to a static-only
839050806d53Smrg# configuration.  But we'll never go from static-only to shared-only.
839150806d53Smrg
839250806d53Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
8393af1a9c97Smrgbuild_libtool_libs=no
8394af1a9c97Smrgbuild_old_libs=yes
839550806d53Smrg# ### END LIBTOOL TAG CONFIG: disable-shared
839650806d53Smrg
839750806d53Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static
8398af1a9c97Smrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
839950806d53Smrg# ### END LIBTOOL TAG CONFIG: disable-static
840050806d53Smrg
840150806d53Smrg# Local Variables:
840250806d53Smrg# mode:shell-script
840350806d53Smrg# sh-indentation:2
840450806d53Smrg# End:
8405af1a9c97Smrg# vi:sw=2
8406af1a9c97Smrg
8407