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