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