ltmain.sh revision 7a3b38f7
17a3b38f7Smrg# Generated from ltmain.m4sh.
27a3b38f7Smrg
37a3b38f7Smrg# ltmain.sh (GNU libtool) 2.2.6
47a3b38f7Smrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
57a3b38f7Smrg
67a3b38f7Smrg# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007 2008 Free Software Foundation, Inc.
77a3b38f7Smrg# This is free software; see the source for copying conditions.  There is NO
87a3b38f7Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
97a3b38f7Smrg
107a3b38f7Smrg# GNU Libtool is free software; you can redistribute it and/or modify
11ff559fabSmrg# it under the terms of the GNU General Public License as published by
12ff559fabSmrg# the Free Software Foundation; either version 2 of the License, or
13ff559fabSmrg# (at your option) any later version.
14ff559fabSmrg#
157a3b38f7Smrg# As a special exception to the GNU General Public License,
167a3b38f7Smrg# if you distribute this file as part of a program or library that
177a3b38f7Smrg# is built using GNU Libtool, you may include this file under the
187a3b38f7Smrg# same distribution terms that you use for the rest of that program.
197a3b38f7Smrg#
207a3b38f7Smrg# GNU Libtool is distributed in the hope that it will be useful, but
21ff559fabSmrg# WITHOUT ANY WARRANTY; without even the implied warranty of
22ff559fabSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
23ff559fabSmrg# General Public License for more details.
24ff559fabSmrg#
25ff559fabSmrg# You should have received a copy of the GNU General Public License
267a3b38f7Smrg# along with GNU Libtool; see the file COPYING.  If not, a copy
277a3b38f7Smrg# can be downloaded from http://www.gnu.org/licenses/gpl.html,
287a3b38f7Smrg# or obtained by writing to the Free Software Foundation, Inc.,
297a3b38f7Smrg# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
307a3b38f7Smrg
317a3b38f7Smrg# Usage: $progname [OPTION]... [MODE-ARG]...
327a3b38f7Smrg#
337a3b38f7Smrg# Provide generalized library-building support services.
34ff559fabSmrg#
357a3b38f7Smrg#     --config             show all configuration variables
367a3b38f7Smrg#     --debug              enable verbose shell tracing
377a3b38f7Smrg# -n, --dry-run            display commands without modifying any files
387a3b38f7Smrg#     --features           display basic configuration information and exit
397a3b38f7Smrg#     --mode=MODE          use operation mode MODE
407a3b38f7Smrg#     --preserve-dup-deps  don't remove duplicate dependency libraries
417a3b38f7Smrg#     --quiet, --silent    don't print informational messages
427a3b38f7Smrg#     --tag=TAG            use configuration variables from tag TAG
437a3b38f7Smrg# -v, --verbose            print informational messages (default)
447a3b38f7Smrg#     --version            print version information
457a3b38f7Smrg# -h, --help               print short or long help message
467a3b38f7Smrg#
477a3b38f7Smrg# MODE must be one of the following:
487a3b38f7Smrg#
497a3b38f7Smrg#       clean              remove files from the build directory
507a3b38f7Smrg#       compile            compile a source file into a libtool object
517a3b38f7Smrg#       execute            automatically set library path, then run a program
527a3b38f7Smrg#       finish             complete the installation of libtool libraries
537a3b38f7Smrg#       install            install libraries or executables
547a3b38f7Smrg#       link               create a library or an executable
557a3b38f7Smrg#       uninstall          remove libraries from an installed directory
567a3b38f7Smrg#
577a3b38f7Smrg# MODE-ARGS vary depending on the MODE.
587a3b38f7Smrg# Try `$progname --help --mode=MODE' for a more detailed description of MODE.
597a3b38f7Smrg#
607a3b38f7Smrg# When reporting a bug, please describe a test case to reproduce it and
617a3b38f7Smrg# include the following information:
627a3b38f7Smrg#
637a3b38f7Smrg#       host-triplet:	$host
647a3b38f7Smrg#       shell:		$SHELL
657a3b38f7Smrg#       compiler:		$LTCC
667a3b38f7Smrg#       compiler flags:		$LTCFLAGS
677a3b38f7Smrg#       linker:		$LD (gnu? $with_gnu_ld)
687a3b38f7Smrg#       $progname:		(GNU libtool) 2.2.6
697a3b38f7Smrg#       automake:		$automake_version
707a3b38f7Smrg#       autoconf:		$autoconf_version
717a3b38f7Smrg#
727a3b38f7Smrg# Report bugs to <bug-libtool@gnu.org>.
737a3b38f7Smrg
747a3b38f7SmrgPROGRAM=ltmain.sh
757a3b38f7SmrgPACKAGE=libtool
767a3b38f7SmrgVERSION=2.2.6
777a3b38f7SmrgTIMESTAMP=""
787a3b38f7Smrgpackage_revision=1.3012
797a3b38f7Smrg
807a3b38f7Smrg# Be Bourne compatible
817a3b38f7Smrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
827a3b38f7Smrg  emulate sh
837a3b38f7Smrg  NULLCMD=:
847a3b38f7Smrg  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
857a3b38f7Smrg  # is contrary to our usage.  Disable this feature.
867a3b38f7Smrg  alias -g '${1+"$@"}'='"$@"'
877a3b38f7Smrg  setopt NO_GLOB_SUBST
887a3b38f7Smrgelse
897a3b38f7Smrg  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
907a3b38f7Smrgfi
917a3b38f7SmrgBIN_SH=xpg4; export BIN_SH # for Tru64
927a3b38f7SmrgDUALCASE=1; export DUALCASE # for MKS sh
937a3b38f7Smrg
947a3b38f7Smrg# NLS nuisances: We save the old values to restore during execute mode.
957a3b38f7Smrg# Only set LANG and LC_ALL to C if already set.
967a3b38f7Smrg# These must not be set unconditionally because not all systems understand
977a3b38f7Smrg# e.g. LANG=C (notably SCO).
987a3b38f7Smrglt_user_locale=
997a3b38f7Smrglt_safe_locale=
1007a3b38f7Smrgfor lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
1017a3b38f7Smrgdo
1027a3b38f7Smrg  eval "if test \"\${$lt_var+set}\" = set; then
1037a3b38f7Smrg          save_$lt_var=\$$lt_var
1047a3b38f7Smrg          $lt_var=C
1057a3b38f7Smrg	  export $lt_var
1067a3b38f7Smrg	  lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\"
1077a3b38f7Smrg	  lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
1087a3b38f7Smrg	fi"
1097a3b38f7Smrgdone
1107a3b38f7Smrg
1117a3b38f7Smrg$lt_unset CDPATH
1127a3b38f7Smrg
1137a3b38f7Smrg
1147a3b38f7Smrg
1157a3b38f7Smrg
1167a3b38f7Smrg
1177a3b38f7Smrg: ${CP="cp -f"}
1187a3b38f7Smrg: ${ECHO="echo"}
1197a3b38f7Smrg: ${EGREP="/bin/grep -E"}
1207a3b38f7Smrg: ${FGREP="/bin/grep -F"}
1217a3b38f7Smrg: ${GREP="/bin/grep"}
1227a3b38f7Smrg: ${LN_S="ln -s"}
1237a3b38f7Smrg: ${MAKE="make"}
1247a3b38f7Smrg: ${MKDIR="mkdir"}
1257a3b38f7Smrg: ${MV="mv -f"}
1267a3b38f7Smrg: ${RM="rm -f"}
1277a3b38f7Smrg: ${SED="/bin/sed"}
1287a3b38f7Smrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
1297a3b38f7Smrg: ${Xsed="$SED -e 1s/^X//"}
130ff559fabSmrg
1317a3b38f7Smrg# Global variables:
1327a3b38f7SmrgEXIT_SUCCESS=0
1337a3b38f7SmrgEXIT_FAILURE=1
1347a3b38f7SmrgEXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
1357a3b38f7SmrgEXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
1367a3b38f7Smrg
1377a3b38f7Smrgexit_status=$EXIT_SUCCESS
1387a3b38f7Smrg
1397a3b38f7Smrg# Make sure IFS has a sensible default
1407a3b38f7Smrglt_nl='
1417a3b38f7Smrg'
1427a3b38f7SmrgIFS=" 	$lt_nl"
1437a3b38f7Smrg
1447a3b38f7Smrgdirname="s,/[^/]*$,,"
1457a3b38f7Smrgbasename="s,^.*/,,"
1467a3b38f7Smrg
1477a3b38f7Smrg# func_dirname_and_basename file append nondir_replacement
1487a3b38f7Smrg# perform func_basename and func_dirname in a single function
1497a3b38f7Smrg# call:
1507a3b38f7Smrg#   dirname:  Compute the dirname of FILE.  If nonempty,
1517a3b38f7Smrg#             add APPEND to the result, otherwise set result
1527a3b38f7Smrg#             to NONDIR_REPLACEMENT.
1537a3b38f7Smrg#             value returned in "$func_dirname_result"
1547a3b38f7Smrg#   basename: Compute filename of FILE.
1557a3b38f7Smrg#             value retuned in "$func_basename_result"
1567a3b38f7Smrg# Implementation must be kept synchronized with func_dirname
1577a3b38f7Smrg# and func_basename. For efficiency, we do not delegate to
1587a3b38f7Smrg# those functions but instead duplicate the functionality here.
1597a3b38f7Smrgfunc_dirname_and_basename ()
1607a3b38f7Smrg{
1617a3b38f7Smrg  # Extract subdirectory from the argument.
1627a3b38f7Smrg  func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"`
1637a3b38f7Smrg  if test "X$func_dirname_result" = "X${1}"; then
1647a3b38f7Smrg    func_dirname_result="${3}"
1657a3b38f7Smrg  else
1667a3b38f7Smrg    func_dirname_result="$func_dirname_result${2}"
1677a3b38f7Smrg  fi
1687a3b38f7Smrg  func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"`
1697a3b38f7Smrg}
1707a3b38f7Smrg
1717a3b38f7Smrg# Generated shell functions inserted here.
172ff559fabSmrg
173ff559fabSmrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
174ff559fabSmrg# is ksh but when the shell is invoked as "sh" and the current value of
175ff559fabSmrg# the _XPG environment variable is not equal to 1 (one), the special
176ff559fabSmrg# positional parameter $0, within a function call, is the name of the
177ff559fabSmrg# function.
178ff559fabSmrgprogpath="$0"
179ff559fabSmrg
180ff559fabSmrg# The name of this program:
1817a3b38f7Smrg# In the unlikely event $progname began with a '-', it would play havoc with
1827a3b38f7Smrg# func_echo (imagine progname=-n), so we prepend ./ in that case:
1837a3b38f7Smrgfunc_dirname_and_basename "$progpath"
1847a3b38f7Smrgprogname=$func_basename_result
1857a3b38f7Smrgcase $progname in
1867a3b38f7Smrg  -*) progname=./$progname ;;
1877a3b38f7Smrgesac
188ff559fabSmrg
1897a3b38f7Smrg# Make sure we have an absolute path for reexecution:
1907a3b38f7Smrgcase $progpath in
1917a3b38f7Smrg  [\\/]*|[A-Za-z]:\\*) ;;
1927a3b38f7Smrg  *[\\/]*)
1937a3b38f7Smrg     progdir=$func_dirname_result
1947a3b38f7Smrg     progdir=`cd "$progdir" && pwd`
1957a3b38f7Smrg     progpath="$progdir/$progname"
1967a3b38f7Smrg     ;;
1977a3b38f7Smrg  *)
1987a3b38f7Smrg     save_IFS="$IFS"
1997a3b38f7Smrg     IFS=:
2007a3b38f7Smrg     for progdir in $PATH; do
2017a3b38f7Smrg       IFS="$save_IFS"
2027a3b38f7Smrg       test -x "$progdir/$progname" && break
2037a3b38f7Smrg     done
2047a3b38f7Smrg     IFS="$save_IFS"
2057a3b38f7Smrg     test -n "$progdir" || progdir=`pwd`
2067a3b38f7Smrg     progpath="$progdir/$progname"
2077a3b38f7Smrg     ;;
2087a3b38f7Smrgesac
209ff559fabSmrg
2107a3b38f7Smrg# Sed substitution that helps us do robust quoting.  It backslashifies
2117a3b38f7Smrg# metacharacters that are still active within double-quoted strings.
2127a3b38f7SmrgXsed="${SED}"' -e 1s/^X//'
2137a3b38f7Smrgsed_quote_subst='s/\([`"$\\]\)/\\\1/g'
2147a3b38f7Smrg
2157a3b38f7Smrg# Same as above, but do not quote variable references.
2167a3b38f7Smrgdouble_quote_subst='s/\(["`\\]\)/\\\1/g'
2177a3b38f7Smrg
2187a3b38f7Smrg# Re-`\' parameter expansions in output of double_quote_subst that were
2197a3b38f7Smrg# `\'-ed in input to the same.  If an odd number of `\' preceded a '$'
2207a3b38f7Smrg# in input to double_quote_subst, that '$' was protected from expansion.
2217a3b38f7Smrg# Since each input `\' is now two `\'s, look for any number of runs of
2227a3b38f7Smrg# four `\'s followed by two `\'s and then a '$'.  `\' that '$'.
2237a3b38f7Smrgbs='\\'
2247a3b38f7Smrgbs2='\\\\'
2257a3b38f7Smrgbs4='\\\\\\\\'
2267a3b38f7Smrgdollar='\$'
2277a3b38f7Smrgsed_double_backslash="\
2287a3b38f7Smrg  s/$bs4/&\\
2297a3b38f7Smrg/g
2307a3b38f7Smrg  s/^$bs2$dollar/$bs&/
2317a3b38f7Smrg  s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
2327a3b38f7Smrg  s/\n//g"
2337a3b38f7Smrg
2347a3b38f7Smrg# Standard options:
2357a3b38f7Smrgopt_dry_run=false
2367a3b38f7Smrgopt_help=false
2377a3b38f7Smrgopt_quiet=false
2387a3b38f7Smrgopt_verbose=false
2397a3b38f7Smrgopt_warning=:
2407a3b38f7Smrg
2417a3b38f7Smrg# func_echo arg...
2427a3b38f7Smrg# Echo program name prefixed message, along with the current mode
2437a3b38f7Smrg# name if it has been set yet.
2447a3b38f7Smrgfunc_echo ()
2457a3b38f7Smrg{
2467a3b38f7Smrg    $ECHO "$progname${mode+: }$mode: $*"
2477a3b38f7Smrg}
248ff559fabSmrg
2497a3b38f7Smrg# func_verbose arg...
2507a3b38f7Smrg# Echo program name prefixed message in verbose mode only.
2517a3b38f7Smrgfunc_verbose ()
2527a3b38f7Smrg{
2537a3b38f7Smrg    $opt_verbose && func_echo ${1+"$@"}
254ff559fabSmrg
2557a3b38f7Smrg    # A bug in bash halts the script if the last line of a function
2567a3b38f7Smrg    # fails when set -e is in force, so we need another command to
2577a3b38f7Smrg    # work around that:
2587a3b38f7Smrg    :
2597a3b38f7Smrg}
260ff559fabSmrg
2617a3b38f7Smrg# func_error arg...
2627a3b38f7Smrg# Echo program name prefixed message to standard error.
2637a3b38f7Smrgfunc_error ()
2647a3b38f7Smrg{
2657a3b38f7Smrg    $ECHO "$progname${mode+: }$mode: "${1+"$@"} 1>&2
2667a3b38f7Smrg}
267ff559fabSmrg
2687a3b38f7Smrg# func_warning arg...
2697a3b38f7Smrg# Echo program name prefixed warning message to standard error.
2707a3b38f7Smrgfunc_warning ()
2717a3b38f7Smrg{
2727a3b38f7Smrg    $opt_warning && $ECHO "$progname${mode+: }$mode: warning: "${1+"$@"} 1>&2
273ff559fabSmrg
2747a3b38f7Smrg    # bash bug again:
2757a3b38f7Smrg    :
2767a3b38f7Smrg}
277ff559fabSmrg
2787a3b38f7Smrg# func_fatal_error arg...
2797a3b38f7Smrg# Echo program name prefixed message to standard error, and exit.
2807a3b38f7Smrgfunc_fatal_error ()
2817a3b38f7Smrg{
2827a3b38f7Smrg    func_error ${1+"$@"}
2837a3b38f7Smrg    exit $EXIT_FAILURE
2847a3b38f7Smrg}
285ff559fabSmrg
2867a3b38f7Smrg# func_fatal_help arg...
2877a3b38f7Smrg# Echo program name prefixed message to standard error, followed by
2887a3b38f7Smrg# a help hint, and exit.
2897a3b38f7Smrgfunc_fatal_help ()
2907a3b38f7Smrg{
2917a3b38f7Smrg    func_error ${1+"$@"}
2927a3b38f7Smrg    func_fatal_error "$help"
2937a3b38f7Smrg}
2947a3b38f7Smrghelp="Try \`$progname --help' for more information."  ## default
295ff559fabSmrg
296ff559fabSmrg
2977a3b38f7Smrg# func_grep expression filename
2987a3b38f7Smrg# Check whether EXPRESSION matches any line of FILENAME, without output.
2997a3b38f7Smrgfunc_grep ()
3007a3b38f7Smrg{
3017a3b38f7Smrg    $GREP "$1" "$2" >/dev/null 2>&1
3027a3b38f7Smrg}
3037a3b38f7Smrg
3047a3b38f7Smrg
3057a3b38f7Smrg# func_mkdir_p directory-path
3067a3b38f7Smrg# Make sure the entire path to DIRECTORY-PATH is available.
3077a3b38f7Smrgfunc_mkdir_p ()
3087a3b38f7Smrg{
3097a3b38f7Smrg    my_directory_path="$1"
3107a3b38f7Smrg    my_dir_list=
3117a3b38f7Smrg
3127a3b38f7Smrg    if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
3137a3b38f7Smrg
3147a3b38f7Smrg      # Protect directory names starting with `-'
3157a3b38f7Smrg      case $my_directory_path in
3167a3b38f7Smrg        -*) my_directory_path="./$my_directory_path" ;;
3177a3b38f7Smrg      esac
3187a3b38f7Smrg
3197a3b38f7Smrg      # While some portion of DIR does not yet exist...
3207a3b38f7Smrg      while test ! -d "$my_directory_path"; do
3217a3b38f7Smrg        # ...make a list in topmost first order.  Use a colon delimited
3227a3b38f7Smrg	# list incase some portion of path contains whitespace.
3237a3b38f7Smrg        my_dir_list="$my_directory_path:$my_dir_list"
3247a3b38f7Smrg
3257a3b38f7Smrg        # If the last portion added has no slash in it, the list is done
3267a3b38f7Smrg        case $my_directory_path in */*) ;; *) break ;; esac
3277a3b38f7Smrg
3287a3b38f7Smrg        # ...otherwise throw away the child directory and loop
3297a3b38f7Smrg        my_directory_path=`$ECHO "X$my_directory_path" | $Xsed -e "$dirname"`
3307a3b38f7Smrg      done
3317a3b38f7Smrg      my_dir_list=`$ECHO "X$my_dir_list" | $Xsed -e 's,:*$,,'`
3327a3b38f7Smrg
3337a3b38f7Smrg      save_mkdir_p_IFS="$IFS"; IFS=':'
3347a3b38f7Smrg      for my_dir in $my_dir_list; do
3357a3b38f7Smrg	IFS="$save_mkdir_p_IFS"
3367a3b38f7Smrg        # mkdir can fail with a `File exist' error if two processes
3377a3b38f7Smrg        # try to create one of the directories concurrently.  Don't
3387a3b38f7Smrg        # stop in that case!
3397a3b38f7Smrg        $MKDIR "$my_dir" 2>/dev/null || :
3407a3b38f7Smrg      done
3417a3b38f7Smrg      IFS="$save_mkdir_p_IFS"
3427a3b38f7Smrg
3437a3b38f7Smrg      # Bail out if we (or some other process) failed to create a directory.
3447a3b38f7Smrg      test -d "$my_directory_path" || \
3457a3b38f7Smrg        func_fatal_error "Failed to create \`$1'"
3467a3b38f7Smrg    fi
3477a3b38f7Smrg}
348ff559fabSmrg
349ff559fabSmrg
350ff559fabSmrg# func_mktempdir [string]
351ff559fabSmrg# Make a temporary directory that won't clash with other running
352ff559fabSmrg# libtool processes, and avoids race conditions if possible.  If
353ff559fabSmrg# given, STRING is the basename for that directory.
354ff559fabSmrgfunc_mktempdir ()
355ff559fabSmrg{
356ff559fabSmrg    my_template="${TMPDIR-/tmp}/${1-$progname}"
357ff559fabSmrg
3587a3b38f7Smrg    if test "$opt_dry_run" = ":"; then
359ff559fabSmrg      # Return a directory name, but don't create it in dry-run mode
360ff559fabSmrg      my_tmpdir="${my_template}-$$"
361ff559fabSmrg    else
362ff559fabSmrg
363ff559fabSmrg      # If mktemp works, use that first and foremost
364ff559fabSmrg      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
365ff559fabSmrg
366ff559fabSmrg      if test ! -d "$my_tmpdir"; then
3677a3b38f7Smrg        # Failing that, at least try and use $RANDOM to avoid a race
3687a3b38f7Smrg        my_tmpdir="${my_template}-${RANDOM-0}$$"
369ff559fabSmrg
3707a3b38f7Smrg        save_mktempdir_umask=`umask`
3717a3b38f7Smrg        umask 0077
3727a3b38f7Smrg        $MKDIR "$my_tmpdir"
3737a3b38f7Smrg        umask $save_mktempdir_umask
374ff559fabSmrg      fi
375ff559fabSmrg
376ff559fabSmrg      # If we're not in dry-run mode, bomb out on failure
3777a3b38f7Smrg      test -d "$my_tmpdir" || \
3787a3b38f7Smrg        func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
379ff559fabSmrg    fi
380ff559fabSmrg
3817a3b38f7Smrg    $ECHO "X$my_tmpdir" | $Xsed
382ff559fabSmrg}
383ff559fabSmrg
384ff559fabSmrg
3857a3b38f7Smrg# func_quote_for_eval arg
3867a3b38f7Smrg# Aesthetically quote ARG to be evaled later.
3877a3b38f7Smrg# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
3887a3b38f7Smrg# is double-quoted, suitable for a subsequent eval, whereas
3897a3b38f7Smrg# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
3907a3b38f7Smrg# which are still active within double quotes backslashified.
3917a3b38f7Smrgfunc_quote_for_eval ()
392ff559fabSmrg{
3937a3b38f7Smrg    case $1 in
3947a3b38f7Smrg      *[\\\`\"\$]*)
3957a3b38f7Smrg	func_quote_for_eval_unquoted_result=`$ECHO "X$1" | $Xsed -e "$sed_quote_subst"` ;;
3967a3b38f7Smrg      *)
3977a3b38f7Smrg        func_quote_for_eval_unquoted_result="$1" ;;
3987a3b38f7Smrg    esac
3997a3b38f7Smrg
4007a3b38f7Smrg    case $func_quote_for_eval_unquoted_result in
4017a3b38f7Smrg      # Double-quote args containing shell metacharacters to delay
4027a3b38f7Smrg      # word splitting, command substitution and and variable
4037a3b38f7Smrg      # expansion for a subsequent eval.
4047a3b38f7Smrg      # Many Bourne shells cannot handle close brackets correctly
4057a3b38f7Smrg      # in scan sets, so we specify it separately.
4067a3b38f7Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
4077a3b38f7Smrg        func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
4087a3b38f7Smrg        ;;
4097a3b38f7Smrg      *)
4107a3b38f7Smrg        func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
411ff559fabSmrg    esac
412ff559fabSmrg}
413ff559fabSmrg
414ff559fabSmrg
4157a3b38f7Smrg# func_quote_for_expand arg
4167a3b38f7Smrg# Aesthetically quote ARG to be evaled later; same as above,
4177a3b38f7Smrg# but do not quote variable references.
4187a3b38f7Smrgfunc_quote_for_expand ()
419ff559fabSmrg{
4207a3b38f7Smrg    case $1 in
4217a3b38f7Smrg      *[\\\`\"]*)
4227a3b38f7Smrg	my_arg=`$ECHO "X$1" | $Xsed \
4237a3b38f7Smrg	    -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
424ff559fabSmrg      *)
4257a3b38f7Smrg        my_arg="$1" ;;
4267a3b38f7Smrg    esac
4277a3b38f7Smrg
4287a3b38f7Smrg    case $my_arg in
4297a3b38f7Smrg      # Double-quote args containing shell metacharacters to delay
4307a3b38f7Smrg      # word splitting and command substitution for a subsequent eval.
4317a3b38f7Smrg      # Many Bourne shells cannot handle close brackets correctly
4327a3b38f7Smrg      # in scan sets, so we specify it separately.
4337a3b38f7Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
4347a3b38f7Smrg        my_arg="\"$my_arg\""
4357a3b38f7Smrg        ;;
4367a3b38f7Smrg    esac
4377a3b38f7Smrg
4387a3b38f7Smrg    func_quote_for_expand_result="$my_arg"
439ff559fabSmrg}
440ff559fabSmrg
441ff559fabSmrg
4427a3b38f7Smrg# func_show_eval cmd [fail_exp]
4437a3b38f7Smrg# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
4447a3b38f7Smrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
4457a3b38f7Smrg# is given, then evaluate it.
4467a3b38f7Smrgfunc_show_eval ()
447ff559fabSmrg{
4487a3b38f7Smrg    my_cmd="$1"
4497a3b38f7Smrg    my_fail_exp="${2-:}"
450ff559fabSmrg
4517a3b38f7Smrg    ${opt_silent-false} || {
4527a3b38f7Smrg      func_quote_for_expand "$my_cmd"
4537a3b38f7Smrg      eval "func_echo $func_quote_for_expand_result"
4547a3b38f7Smrg    }
4557a3b38f7Smrg
4567a3b38f7Smrg    if ${opt_dry_run-false}; then :; else
4577a3b38f7Smrg      eval "$my_cmd"
4587a3b38f7Smrg      my_status=$?
4597a3b38f7Smrg      if test "$my_status" -eq 0; then :; else
4607a3b38f7Smrg	eval "(exit $my_status); $my_fail_exp"
4617a3b38f7Smrg      fi
462ff559fabSmrg    fi
463ff559fabSmrg}
464ff559fabSmrg
4657a3b38f7Smrg
4667a3b38f7Smrg# func_show_eval_locale cmd [fail_exp]
4677a3b38f7Smrg# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
4687a3b38f7Smrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
4697a3b38f7Smrg# is given, then evaluate it.  Use the saved locale for evaluation.
4707a3b38f7Smrgfunc_show_eval_locale ()
471ff559fabSmrg{
4727a3b38f7Smrg    my_cmd="$1"
4737a3b38f7Smrg    my_fail_exp="${2-:}"
474ff559fabSmrg
4757a3b38f7Smrg    ${opt_silent-false} || {
4767a3b38f7Smrg      func_quote_for_expand "$my_cmd"
4777a3b38f7Smrg      eval "func_echo $func_quote_for_expand_result"
4787a3b38f7Smrg    }
4797a3b38f7Smrg
4807a3b38f7Smrg    if ${opt_dry_run-false}; then :; else
4817a3b38f7Smrg      eval "$lt_user_locale
4827a3b38f7Smrg	    $my_cmd"
4837a3b38f7Smrg      my_status=$?
4847a3b38f7Smrg      eval "$lt_safe_locale"
4857a3b38f7Smrg      if test "$my_status" -eq 0; then :; else
4867a3b38f7Smrg	eval "(exit $my_status); $my_fail_exp"
487ff559fabSmrg      fi
4887a3b38f7Smrg    fi
489ff559fabSmrg}
490ff559fabSmrg
491ff559fabSmrg
492ff559fabSmrg
4937a3b38f7Smrg
4947a3b38f7Smrg
4957a3b38f7Smrg# func_version
4967a3b38f7Smrg# Echo version message to standard output and exit.
4977a3b38f7Smrgfunc_version ()
4987a3b38f7Smrg{
4997a3b38f7Smrg    $SED -n '/^# '$PROGRAM' (GNU /,/# warranty; / {
5007a3b38f7Smrg        s/^# //
5017a3b38f7Smrg	s/^# *$//
5027a3b38f7Smrg        s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
5037a3b38f7Smrg        p
5047a3b38f7Smrg     }' < "$progpath"
5057a3b38f7Smrg     exit $?
5067a3b38f7Smrg}
5077a3b38f7Smrg
5087a3b38f7Smrg# func_usage
5097a3b38f7Smrg# Echo short help message to standard output and exit.
5107a3b38f7Smrgfunc_usage ()
5117a3b38f7Smrg{
5127a3b38f7Smrg    $SED -n '/^# Usage:/,/# -h/ {
5137a3b38f7Smrg        s/^# //
5147a3b38f7Smrg	s/^# *$//
5157a3b38f7Smrg	s/\$progname/'$progname'/
5167a3b38f7Smrg	p
5177a3b38f7Smrg    }' < "$progpath"
5187a3b38f7Smrg    $ECHO
5197a3b38f7Smrg    $ECHO "run \`$progname --help | more' for full usage"
5207a3b38f7Smrg    exit $?
5217a3b38f7Smrg}
5227a3b38f7Smrg
5237a3b38f7Smrg# func_help
5247a3b38f7Smrg# Echo long help message to standard output and exit.
5257a3b38f7Smrgfunc_help ()
5267a3b38f7Smrg{
5277a3b38f7Smrg    $SED -n '/^# Usage:/,/# Report bugs to/ {
5287a3b38f7Smrg        s/^# //
5297a3b38f7Smrg	s/^# *$//
5307a3b38f7Smrg	s*\$progname*'$progname'*
5317a3b38f7Smrg	s*\$host*'"$host"'*
5327a3b38f7Smrg	s*\$SHELL*'"$SHELL"'*
5337a3b38f7Smrg	s*\$LTCC*'"$LTCC"'*
5347a3b38f7Smrg	s*\$LTCFLAGS*'"$LTCFLAGS"'*
5357a3b38f7Smrg	s*\$LD*'"$LD"'*
5367a3b38f7Smrg	s/\$with_gnu_ld/'"$with_gnu_ld"'/
5377a3b38f7Smrg	s/\$automake_version/'"`(automake --version) 2>/dev/null |$SED 1q`"'/
5387a3b38f7Smrg	s/\$autoconf_version/'"`(autoconf --version) 2>/dev/null |$SED 1q`"'/
5397a3b38f7Smrg	p
5407a3b38f7Smrg     }' < "$progpath"
5417a3b38f7Smrg    exit $?
5427a3b38f7Smrg}
5437a3b38f7Smrg
5447a3b38f7Smrg# func_missing_arg argname
5457a3b38f7Smrg# Echo program name prefixed message to standard error and set global
5467a3b38f7Smrg# exit_cmd.
5477a3b38f7Smrgfunc_missing_arg ()
5487a3b38f7Smrg{
5497a3b38f7Smrg    func_error "missing argument for $1"
5507a3b38f7Smrg    exit_cmd=exit
5517a3b38f7Smrg}
5527a3b38f7Smrg
5537a3b38f7Smrgexit_cmd=:
5547a3b38f7Smrg
5557a3b38f7Smrg
5567a3b38f7Smrg
5577a3b38f7Smrg
5587a3b38f7Smrg
5597a3b38f7Smrg# Check that we have a working $ECHO.
5607a3b38f7Smrgif test "X$1" = X--no-reexec; then
5617a3b38f7Smrg  # Discard the --no-reexec flag, and continue.
562ff559fabSmrg  shift
5637a3b38f7Smrgelif test "X$1" = X--fallback-echo; then
5647a3b38f7Smrg  # Avoid inline document here, it may be left over
5657a3b38f7Smrg  :
5667a3b38f7Smrgelif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t'; then
5677a3b38f7Smrg  # Yippee, $ECHO works!
5687a3b38f7Smrg  :
5697a3b38f7Smrgelse
5707a3b38f7Smrg  # Restart under the correct shell, and then maybe $ECHO will work.
5717a3b38f7Smrg  exec $SHELL "$progpath" --no-reexec ${1+"$@"}
5727a3b38f7Smrgfi
573ff559fabSmrg
5747a3b38f7Smrgif test "X$1" = X--fallback-echo; then
5757a3b38f7Smrg  # used as fallback echo
5767a3b38f7Smrg  shift
5777a3b38f7Smrg  cat <<EOF
5787a3b38f7Smrg$*
5797a3b38f7SmrgEOF
5807a3b38f7Smrg  exit $EXIT_SUCCESS
5817a3b38f7Smrgfi
582ff559fabSmrg
5837a3b38f7Smrgmagic="%%%MAGIC variable%%%"
5847a3b38f7Smrgmagic_exe="%%%MAGIC EXE variable%%%"
585ff559fabSmrg
5867a3b38f7Smrg# Global variables.
5877a3b38f7Smrg# $mode is unset
5887a3b38f7Smrgnonopt=
5897a3b38f7Smrgexecute_dlfiles=
5907a3b38f7Smrgpreserve_args=
5917a3b38f7Smrglo2o="s/\\.lo\$/.${objext}/"
5927a3b38f7Smrgo2lo="s/\\.${objext}\$/.lo/"
5937a3b38f7Smrgextracted_archives=
5947a3b38f7Smrgextracted_serial=0
595ff559fabSmrg
5967a3b38f7Smrgopt_dry_run=false
5977a3b38f7Smrgopt_duplicate_deps=false
5987a3b38f7Smrgopt_silent=false
5997a3b38f7Smrgopt_debug=:
600ff559fabSmrg
6017a3b38f7Smrg# If this variable is set in any of the actions, the command in it
6027a3b38f7Smrg# will be execed at the end.  This prevents here-documents from being
6037a3b38f7Smrg# left over by shells.
6047a3b38f7Smrgexec_cmd=
605ff559fabSmrg
6067a3b38f7Smrg# func_fatal_configuration arg...
6077a3b38f7Smrg# Echo program name prefixed message to standard error, followed by
6087a3b38f7Smrg# a configuration failure hint, and exit.
6097a3b38f7Smrgfunc_fatal_configuration ()
6107a3b38f7Smrg{
6117a3b38f7Smrg    func_error ${1+"$@"}
6127a3b38f7Smrg    func_error "See the $PACKAGE documentation for more information."
6137a3b38f7Smrg    func_fatal_error "Fatal configuration error."
6147a3b38f7Smrg}
6157a3b38f7Smrg
6167a3b38f7Smrg
6177a3b38f7Smrg# func_config
6187a3b38f7Smrg# Display the configuration for all the tags in this script.
6197a3b38f7Smrgfunc_config ()
6207a3b38f7Smrg{
6217a3b38f7Smrg    re_begincf='^# ### BEGIN LIBTOOL'
6227a3b38f7Smrg    re_endcf='^# ### END LIBTOOL'
6237a3b38f7Smrg
6247a3b38f7Smrg    # Default configuration.
6257a3b38f7Smrg    $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
626ff559fabSmrg
627ff559fabSmrg    # Now print the configurations for the tags.
628ff559fabSmrg    for tagname in $taglist; do
6297a3b38f7Smrg      $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
630ff559fabSmrg    done
631ff559fabSmrg
6327a3b38f7Smrg    exit $?
6337a3b38f7Smrg}
634ff559fabSmrg
6357a3b38f7Smrg# func_features
6367a3b38f7Smrg# Display the features supported by this script.
6377a3b38f7Smrgfunc_features ()
6387a3b38f7Smrg{
6397a3b38f7Smrg    $ECHO "host: $host"
640ff559fabSmrg    if test "$build_libtool_libs" = yes; then
6417a3b38f7Smrg      $ECHO "enable shared libraries"
642ff559fabSmrg    else
6437a3b38f7Smrg      $ECHO "disable shared libraries"
644ff559fabSmrg    fi
645ff559fabSmrg    if test "$build_old_libs" = yes; then
6467a3b38f7Smrg      $ECHO "enable static libraries"
647ff559fabSmrg    else
6487a3b38f7Smrg      $ECHO "disable static libraries"
649ff559fabSmrg    fi
6507a3b38f7Smrg
651ff559fabSmrg    exit $?
6527a3b38f7Smrg}
6537a3b38f7Smrg
6547a3b38f7Smrg# func_enable_tag tagname
6557a3b38f7Smrg# Verify that TAGNAME is valid, and either flag an error and exit, or
6567a3b38f7Smrg# enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
6577a3b38f7Smrg# variable here.
6587a3b38f7Smrgfunc_enable_tag ()
6597a3b38f7Smrg{
6607a3b38f7Smrg  # Global variable:
6617a3b38f7Smrg  tagname="$1"
662ff559fabSmrg
6637a3b38f7Smrg  re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
6647a3b38f7Smrg  re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
6657a3b38f7Smrg  sed_extractcf="/$re_begincf/,/$re_endcf/p"
666ff559fabSmrg
6677a3b38f7Smrg  # Validate tagname.
6687a3b38f7Smrg  case $tagname in
6697a3b38f7Smrg    *[!-_A-Za-z0-9,/]*)
6707a3b38f7Smrg      func_fatal_error "invalid tag name: $tagname"
6717a3b38f7Smrg      ;;
6727a3b38f7Smrg  esac
673ff559fabSmrg
6747a3b38f7Smrg  # Don't test for the "default" C tag, as we know it's
6757a3b38f7Smrg  # there but not specially marked.
6767a3b38f7Smrg  case $tagname in
6777a3b38f7Smrg    CC) ;;
6787a3b38f7Smrg    *)
6797a3b38f7Smrg      if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
6807a3b38f7Smrg	taglist="$taglist $tagname"
6817a3b38f7Smrg
6827a3b38f7Smrg	# Evaluate the configuration.  Be careful to quote the path
6837a3b38f7Smrg	# and the sed script, to avoid splitting on whitespace, but
6847a3b38f7Smrg	# also don't use non-portable quotes within backquotes within
6857a3b38f7Smrg	# quotes we have to do it in 2 steps:
6867a3b38f7Smrg	extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
6877a3b38f7Smrg	eval "$extractedcf"
6887a3b38f7Smrg      else
6897a3b38f7Smrg	func_error "ignoring unknown tag $tagname"
6907a3b38f7Smrg      fi
6917a3b38f7Smrg      ;;
6927a3b38f7Smrg  esac
6937a3b38f7Smrg}
694ff559fabSmrg
6957a3b38f7Smrg# Parse options once, thoroughly.  This comes as soon as possible in
6967a3b38f7Smrg# the script to make things like `libtool --version' happen quickly.
6977a3b38f7Smrg{
698ff559fabSmrg
6997a3b38f7Smrg  # Shorthand for --mode=foo, only valid as the first argument
7007a3b38f7Smrg  case $1 in
7017a3b38f7Smrg  clean|clea|cle|cl)
7027a3b38f7Smrg    shift; set dummy --mode clean ${1+"$@"}; shift
703ff559fabSmrg    ;;
7047a3b38f7Smrg  compile|compil|compi|comp|com|co|c)
7057a3b38f7Smrg    shift; set dummy --mode compile ${1+"$@"}; shift
706ff559fabSmrg    ;;
7077a3b38f7Smrg  execute|execut|execu|exec|exe|ex|e)
7087a3b38f7Smrg    shift; set dummy --mode execute ${1+"$@"}; shift
709ff559fabSmrg    ;;
7107a3b38f7Smrg  finish|finis|fini|fin|fi|f)
7117a3b38f7Smrg    shift; set dummy --mode finish ${1+"$@"}; shift
712ff559fabSmrg    ;;
7137a3b38f7Smrg  install|instal|insta|inst|ins|in|i)
7147a3b38f7Smrg    shift; set dummy --mode install ${1+"$@"}; shift
7157a3b38f7Smrg    ;;
7167a3b38f7Smrg  link|lin|li|l)
7177a3b38f7Smrg    shift; set dummy --mode link ${1+"$@"}; shift
7187a3b38f7Smrg    ;;
7197a3b38f7Smrg  uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
7207a3b38f7Smrg    shift; set dummy --mode uninstall ${1+"$@"}; shift
721ff559fabSmrg    ;;
722ff559fabSmrg  esac
723ff559fabSmrg
7247a3b38f7Smrg  # Parse non-mode specific arguments:
7257a3b38f7Smrg  while test "$#" -gt 0; do
7267a3b38f7Smrg    opt="$1"
7277a3b38f7Smrg    shift
728ff559fabSmrg
7297a3b38f7Smrg    case $opt in
7307a3b38f7Smrg      --config)		func_config					;;
731ff559fabSmrg
7327a3b38f7Smrg      --debug)		preserve_args="$preserve_args $opt"
7337a3b38f7Smrg			func_echo "enabling shell trace mode"
7347a3b38f7Smrg			opt_debug='set -x'
7357a3b38f7Smrg			$opt_debug
7367a3b38f7Smrg			;;
737ff559fabSmrg
7387a3b38f7Smrg      -dlopen)		test "$#" -eq 0 && func_missing_arg "$opt" && break
7397a3b38f7Smrg			execute_dlfiles="$execute_dlfiles $1"
7407a3b38f7Smrg			shift
7417a3b38f7Smrg			;;
742ff559fabSmrg
7437a3b38f7Smrg      --dry-run | -n)	opt_dry_run=:					;;
7447a3b38f7Smrg      --features)       func_features					;;
7457a3b38f7Smrg      --finish)		mode="finish"					;;
7467a3b38f7Smrg
7477a3b38f7Smrg      --mode)		test "$#" -eq 0 && func_missing_arg "$opt" && break
7487a3b38f7Smrg			case $1 in
7497a3b38f7Smrg			  # Valid mode arguments:
7507a3b38f7Smrg			  clean)	;;
7517a3b38f7Smrg			  compile)	;;
7527a3b38f7Smrg			  execute)	;;
7537a3b38f7Smrg			  finish)	;;
7547a3b38f7Smrg			  install)	;;
7557a3b38f7Smrg			  link)		;;
7567a3b38f7Smrg			  relink)	;;
7577a3b38f7Smrg			  uninstall)	;;
7587a3b38f7Smrg
7597a3b38f7Smrg			  # Catch anything else as an error
7607a3b38f7Smrg			  *) func_error "invalid argument for $opt"
7617a3b38f7Smrg			     exit_cmd=exit
7627a3b38f7Smrg			     break
7637a3b38f7Smrg			     ;;
7647a3b38f7Smrg		        esac
7657a3b38f7Smrg
7667a3b38f7Smrg			mode="$1"
7677a3b38f7Smrg			shift
7687a3b38f7Smrg			;;
7697a3b38f7Smrg
7707a3b38f7Smrg      --preserve-dup-deps)
7717a3b38f7Smrg			opt_duplicate_deps=:				;;
7727a3b38f7Smrg
7737a3b38f7Smrg      --quiet|--silent)	preserve_args="$preserve_args $opt"
7747a3b38f7Smrg			opt_silent=:
7757a3b38f7Smrg			;;
7767a3b38f7Smrg
7777a3b38f7Smrg      --verbose| -v)	preserve_args="$preserve_args $opt"
7787a3b38f7Smrg			opt_silent=false
7797a3b38f7Smrg			;;
7807a3b38f7Smrg
7817a3b38f7Smrg      --tag)		test "$#" -eq 0 && func_missing_arg "$opt" && break
7827a3b38f7Smrg			preserve_args="$preserve_args $opt $1"
7837a3b38f7Smrg			func_enable_tag "$1"	# tagname is set here
7847a3b38f7Smrg			shift
7857a3b38f7Smrg			;;
7867a3b38f7Smrg
7877a3b38f7Smrg      # Separate optargs to long options:
7887a3b38f7Smrg      -dlopen=*|--mode=*|--tag=*)
7897a3b38f7Smrg			func_opt_split "$opt"
7907a3b38f7Smrg			set dummy "$func_opt_split_opt" "$func_opt_split_arg" ${1+"$@"}
7917a3b38f7Smrg			shift
7927a3b38f7Smrg			;;
7937a3b38f7Smrg
7947a3b38f7Smrg      -\?|-h)		func_usage					;;
7957a3b38f7Smrg      --help)		opt_help=:					;;
7967a3b38f7Smrg      --version)	func_version					;;
7977a3b38f7Smrg
7987a3b38f7Smrg      -*)		func_fatal_help "unrecognized option \`$opt'"	;;
7997a3b38f7Smrg
8007a3b38f7Smrg      *)		nonopt="$opt"
8017a3b38f7Smrg			break
8027a3b38f7Smrg			;;
8037a3b38f7Smrg    esac
8047a3b38f7Smrg  done
8057a3b38f7Smrg
8067a3b38f7Smrg
8077a3b38f7Smrg  case $host in
8087a3b38f7Smrg    *cygwin* | *mingw* | *pw32* | *cegcc*)
8097a3b38f7Smrg      # don't eliminate duplications in $postdeps and $predeps
8107a3b38f7Smrg      opt_duplicate_compiler_generated_deps=:
811ff559fabSmrg      ;;
812ff559fabSmrg    *)
8137a3b38f7Smrg      opt_duplicate_compiler_generated_deps=$opt_duplicate_deps
8147a3b38f7Smrg      ;;
8157a3b38f7Smrg  esac
816ff559fabSmrg
8177a3b38f7Smrg  # Having warned about all mis-specified options, bail out if
8187a3b38f7Smrg  # anything was wrong.
8197a3b38f7Smrg  $exit_cmd $EXIT_FAILURE
8207a3b38f7Smrg}
8217a3b38f7Smrg
8227a3b38f7Smrg# func_check_version_match
8237a3b38f7Smrg# Ensure that we are using m4 macros, and libtool script from the same
8247a3b38f7Smrg# release of libtool.
8257a3b38f7Smrgfunc_check_version_match ()
8267a3b38f7Smrg{
8277a3b38f7Smrg  if test "$package_revision" != "$macro_revision"; then
8287a3b38f7Smrg    if test "$VERSION" != "$macro_version"; then
8297a3b38f7Smrg      if test -z "$macro_version"; then
8307a3b38f7Smrg        cat >&2 <<_LT_EOF
8317a3b38f7Smrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
8327a3b38f7Smrg$progname: definition of this LT_INIT comes from an older release.
8337a3b38f7Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
8347a3b38f7Smrg$progname: and run autoconf again.
8357a3b38f7Smrg_LT_EOF
8367a3b38f7Smrg      else
8377a3b38f7Smrg        cat >&2 <<_LT_EOF
8387a3b38f7Smrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
8397a3b38f7Smrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
8407a3b38f7Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
8417a3b38f7Smrg$progname: and run autoconf again.
8427a3b38f7Smrg_LT_EOF
843ff559fabSmrg      fi
8447a3b38f7Smrg    else
8457a3b38f7Smrg      cat >&2 <<_LT_EOF
8467a3b38f7Smrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
8477a3b38f7Smrg$progname: but the definition of this LT_INIT comes from revision $macro_revision.
8487a3b38f7Smrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision
8497a3b38f7Smrg$progname: of $PACKAGE $VERSION and run autoconf again.
8507a3b38f7Smrg_LT_EOF
8517a3b38f7Smrg    fi
8527a3b38f7Smrg
8537a3b38f7Smrg    exit $EXIT_MISMATCH
8547a3b38f7Smrg  fi
8557a3b38f7Smrg}
8567a3b38f7Smrg
8577a3b38f7Smrg
8587a3b38f7Smrg## ----------- ##
8597a3b38f7Smrg##    Main.    ##
8607a3b38f7Smrg## ----------- ##
8617a3b38f7Smrg
8627a3b38f7Smrg$opt_help || {
8637a3b38f7Smrg  # Sanity checks first:
8647a3b38f7Smrg  func_check_version_match
8657a3b38f7Smrg
8667a3b38f7Smrg  if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
8677a3b38f7Smrg    func_fatal_configuration "not configured to build any kind of library"
868ff559fabSmrg  fi
869ff559fabSmrg
8707a3b38f7Smrg  test -z "$mode" && func_fatal_error "error: you must specify a MODE."
8717a3b38f7Smrg
8727a3b38f7Smrg
8737a3b38f7Smrg  # Darwin sucks
8747a3b38f7Smrg  eval std_shrext=\"$shrext_cmds\"
8757a3b38f7Smrg
8767a3b38f7Smrg
877ff559fabSmrg  # Only execute mode is allowed to have -dlopen flags.
878ff559fabSmrg  if test -n "$execute_dlfiles" && test "$mode" != execute; then
8797a3b38f7Smrg    func_error "unrecognized option \`-dlopen'"
8807a3b38f7Smrg    $ECHO "$help" 1>&2
881ff559fabSmrg    exit $EXIT_FAILURE
882ff559fabSmrg  fi
883ff559fabSmrg
884ff559fabSmrg  # Change the help message to a mode-specific one.
885ff559fabSmrg  generic_help="$help"
8867a3b38f7Smrg  help="Try \`$progname --help --mode=$mode' for more information."
8877a3b38f7Smrg}
888ff559fabSmrg
889ff559fabSmrg
8907a3b38f7Smrg# func_lalib_p file
8917a3b38f7Smrg# True iff FILE is a libtool `.la' library or `.lo' object file.
8927a3b38f7Smrg# This function is only a basic sanity check; it will hardly flush out
8937a3b38f7Smrg# determined imposters.
8947a3b38f7Smrgfunc_lalib_p ()
8957a3b38f7Smrg{
8967a3b38f7Smrg    test -f "$1" &&
8977a3b38f7Smrg      $SED -e 4q "$1" 2>/dev/null \
8987a3b38f7Smrg        | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
8997a3b38f7Smrg}
900ff559fabSmrg
9017a3b38f7Smrg# func_lalib_unsafe_p file
9027a3b38f7Smrg# True iff FILE is a libtool `.la' library or `.lo' object file.
9037a3b38f7Smrg# This function implements the same check as func_lalib_p without
9047a3b38f7Smrg# resorting to external programs.  To this end, it redirects stdin and
9057a3b38f7Smrg# closes it afterwards, without saving the original file descriptor.
9067a3b38f7Smrg# As a safety measure, use it only where a negative result would be
9077a3b38f7Smrg# fatal anyway.  Works if `file' does not exist.
9087a3b38f7Smrgfunc_lalib_unsafe_p ()
9097a3b38f7Smrg{
9107a3b38f7Smrg    lalib_p=no
9117a3b38f7Smrg    if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
9127a3b38f7Smrg	for lalib_p_l in 1 2 3 4
9137a3b38f7Smrg	do
9147a3b38f7Smrg	    read lalib_p_line
9157a3b38f7Smrg	    case "$lalib_p_line" in
9167a3b38f7Smrg		\#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
9177a3b38f7Smrg	    esac
9187a3b38f7Smrg	done
9197a3b38f7Smrg	exec 0<&5 5<&-
9207a3b38f7Smrg    fi
9217a3b38f7Smrg    test "$lalib_p" = yes
9227a3b38f7Smrg}
923ff559fabSmrg
9247a3b38f7Smrg# func_ltwrapper_script_p file
9257a3b38f7Smrg# True iff FILE is a libtool wrapper script
9267a3b38f7Smrg# This function is only a basic sanity check; it will hardly flush out
9277a3b38f7Smrg# determined imposters.
9287a3b38f7Smrgfunc_ltwrapper_script_p ()
9297a3b38f7Smrg{
9307a3b38f7Smrg    func_lalib_p "$1"
9317a3b38f7Smrg}
932ff559fabSmrg
9337a3b38f7Smrg# func_ltwrapper_executable_p file
9347a3b38f7Smrg# True iff FILE is a libtool wrapper executable
9357a3b38f7Smrg# This function is only a basic sanity check; it will hardly flush out
9367a3b38f7Smrg# determined imposters.
9377a3b38f7Smrgfunc_ltwrapper_executable_p ()
9387a3b38f7Smrg{
9397a3b38f7Smrg    func_ltwrapper_exec_suffix=
9407a3b38f7Smrg    case $1 in
9417a3b38f7Smrg    *.exe) ;;
9427a3b38f7Smrg    *) func_ltwrapper_exec_suffix=.exe ;;
9437a3b38f7Smrg    esac
9447a3b38f7Smrg    $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
9457a3b38f7Smrg}
946ff559fabSmrg
9477a3b38f7Smrg# func_ltwrapper_scriptname file
9487a3b38f7Smrg# Assumes file is an ltwrapper_executable
9497a3b38f7Smrg# uses $file to determine the appropriate filename for a
9507a3b38f7Smrg# temporary ltwrapper_script.
9517a3b38f7Smrgfunc_ltwrapper_scriptname ()
9527a3b38f7Smrg{
9537a3b38f7Smrg    func_ltwrapper_scriptname_result=""
9547a3b38f7Smrg    if func_ltwrapper_executable_p "$1"; then
9557a3b38f7Smrg	func_dirname_and_basename "$1" "" "."
9567a3b38f7Smrg	func_stripname '' '.exe' "$func_basename_result"
9577a3b38f7Smrg	func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper"
9587a3b38f7Smrg    fi
9597a3b38f7Smrg}
960ff559fabSmrg
9617a3b38f7Smrg# func_ltwrapper_p file
9627a3b38f7Smrg# True iff FILE is a libtool wrapper script or wrapper executable
9637a3b38f7Smrg# This function is only a basic sanity check; it will hardly flush out
9647a3b38f7Smrg# determined imposters.
9657a3b38f7Smrgfunc_ltwrapper_p ()
9667a3b38f7Smrg{
9677a3b38f7Smrg    func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
9687a3b38f7Smrg}
969ff559fabSmrg
970ff559fabSmrg
9717a3b38f7Smrg# func_execute_cmds commands fail_cmd
9727a3b38f7Smrg# Execute tilde-delimited COMMANDS.
9737a3b38f7Smrg# If FAIL_CMD is given, eval that upon failure.
9747a3b38f7Smrg# FAIL_CMD may read-access the current command in variable CMD!
9757a3b38f7Smrgfunc_execute_cmds ()
9767a3b38f7Smrg{
9777a3b38f7Smrg    $opt_debug
9787a3b38f7Smrg    save_ifs=$IFS; IFS='~'
9797a3b38f7Smrg    for cmd in $1; do
9807a3b38f7Smrg      IFS=$save_ifs
9817a3b38f7Smrg      eval cmd=\"$cmd\"
9827a3b38f7Smrg      func_show_eval "$cmd" "${2-:}"
9837a3b38f7Smrg    done
9847a3b38f7Smrg    IFS=$save_ifs
9857a3b38f7Smrg}
9867a3b38f7Smrg
9877a3b38f7Smrg
9887a3b38f7Smrg# func_source file
9897a3b38f7Smrg# Source FILE, adding directory component if necessary.
9907a3b38f7Smrg# Note that it is not necessary on cygwin/mingw to append a dot to
9917a3b38f7Smrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe
9927a3b38f7Smrg# behavior happens only for exec(3), not for open(2)!  Also, sourcing
9937a3b38f7Smrg# `FILE.' does not work on cygwin managed mounts.
9947a3b38f7Smrgfunc_source ()
9957a3b38f7Smrg{
9967a3b38f7Smrg    $opt_debug
9977a3b38f7Smrg    case $1 in
9987a3b38f7Smrg    */* | *\\*)	. "$1" ;;
9997a3b38f7Smrg    *)		. "./$1" ;;
10007a3b38f7Smrg    esac
10017a3b38f7Smrg}
10027a3b38f7Smrg
10037a3b38f7Smrg
10047a3b38f7Smrg# func_infer_tag arg
10057a3b38f7Smrg# Infer tagged configuration to use if any are available and
10067a3b38f7Smrg# if one wasn't chosen via the "--tag" command line option.
10077a3b38f7Smrg# Only attempt this if the compiler in the base compile
10087a3b38f7Smrg# command doesn't match the default compiler.
10097a3b38f7Smrg# arg is usually of the form 'gcc ...'
10107a3b38f7Smrgfunc_infer_tag ()
10117a3b38f7Smrg{
10127a3b38f7Smrg    $opt_debug
10137a3b38f7Smrg    if test -n "$available_tags" && test -z "$tagname"; then
10147a3b38f7Smrg      CC_quoted=
10157a3b38f7Smrg      for arg in $CC; do
10167a3b38f7Smrg        func_quote_for_eval "$arg"
10177a3b38f7Smrg	CC_quoted="$CC_quoted $func_quote_for_eval_result"
10187a3b38f7Smrg      done
10197a3b38f7Smrg      case $@ in
10207a3b38f7Smrg      # Blanks in the command may have been stripped by the calling shell,
10217a3b38f7Smrg      # but not from the CC environment variable when configure was run.
10227a3b38f7Smrg      " $CC "* | "$CC "* | " `$ECHO $CC` "* | "`$ECHO $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$ECHO $CC_quoted` "* | "`$ECHO $CC_quoted` "*) ;;
10237a3b38f7Smrg      # Blanks at the start of $base_compile will cause this to fail
10247a3b38f7Smrg      # if we don't check for them as well.
10257a3b38f7Smrg      *)
10267a3b38f7Smrg	for z in $available_tags; do
10277a3b38f7Smrg	  if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
10287a3b38f7Smrg	    # Evaluate the configuration.
10297a3b38f7Smrg	    eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
10307a3b38f7Smrg	    CC_quoted=
10317a3b38f7Smrg	    for arg in $CC; do
10327a3b38f7Smrg	      # Double-quote args containing other shell metacharacters.
10337a3b38f7Smrg	      func_quote_for_eval "$arg"
10347a3b38f7Smrg	      CC_quoted="$CC_quoted $func_quote_for_eval_result"
10357a3b38f7Smrg	    done
10367a3b38f7Smrg	    case "$@ " in
10377a3b38f7Smrg	      " $CC "* | "$CC "* | " `$ECHO $CC` "* | "`$ECHO $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$ECHO $CC_quoted` "* | "`$ECHO $CC_quoted` "*)
10387a3b38f7Smrg	      # The compiler in the base compile command matches
10397a3b38f7Smrg	      # the one in the tagged configuration.
10407a3b38f7Smrg	      # Assume this is the tagged configuration we want.
10417a3b38f7Smrg	      tagname=$z
10427a3b38f7Smrg	      break
10437a3b38f7Smrg	      ;;
1044ff559fabSmrg	    esac
10457a3b38f7Smrg	  fi
10467a3b38f7Smrg	done
10477a3b38f7Smrg	# If $tagname still isn't set, then no tagged configuration
10487a3b38f7Smrg	# was found and let the user know that the "--tag" command
10497a3b38f7Smrg	# line option must be used.
10507a3b38f7Smrg	if test -z "$tagname"; then
10517a3b38f7Smrg	  func_echo "unable to infer tagged configuration"
10527a3b38f7Smrg	  func_fatal_error "specify a tag with \`--tag'"
10537a3b38f7Smrg#	else
10547a3b38f7Smrg#	  func_verbose "using $tagname tagged configuration"
10557a3b38f7Smrg	fi
10567a3b38f7Smrg	;;
10577a3b38f7Smrg      esac
10587a3b38f7Smrg    fi
10597a3b38f7Smrg}
10607a3b38f7Smrg
10617a3b38f7Smrg
10627a3b38f7Smrg
10637a3b38f7Smrg# func_write_libtool_object output_name pic_name nonpic_name
10647a3b38f7Smrg# Create a libtool object file (analogous to a ".la" file),
10657a3b38f7Smrg# but don't create it if we're doing a dry run.
10667a3b38f7Smrgfunc_write_libtool_object ()
10677a3b38f7Smrg{
10687a3b38f7Smrg    write_libobj=${1}
10697a3b38f7Smrg    if test "$build_libtool_libs" = yes; then
10707a3b38f7Smrg      write_lobj=\'${2}\'
10717a3b38f7Smrg    else
10727a3b38f7Smrg      write_lobj=none
10737a3b38f7Smrg    fi
10747a3b38f7Smrg
10757a3b38f7Smrg    if test "$build_old_libs" = yes; then
10767a3b38f7Smrg      write_oldobj=\'${3}\'
10777a3b38f7Smrg    else
10787a3b38f7Smrg      write_oldobj=none
10797a3b38f7Smrg    fi
10807a3b38f7Smrg
10817a3b38f7Smrg    $opt_dry_run || {
10827a3b38f7Smrg      cat >${write_libobj}T <<EOF
10837a3b38f7Smrg# $write_libobj - a libtool object file
10847a3b38f7Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
10857a3b38f7Smrg#
10867a3b38f7Smrg# Please DO NOT delete this file!
10877a3b38f7Smrg# It is necessary for linking the library.
10887a3b38f7Smrg
10897a3b38f7Smrg# Name of the PIC object.
10907a3b38f7Smrgpic_object=$write_lobj
10917a3b38f7Smrg
10927a3b38f7Smrg# Name of the non-PIC object
10937a3b38f7Smrgnon_pic_object=$write_oldobj
10947a3b38f7Smrg
10957a3b38f7SmrgEOF
10967a3b38f7Smrg      $MV "${write_libobj}T" "${write_libobj}"
10977a3b38f7Smrg    }
10987a3b38f7Smrg}
10997a3b38f7Smrg
11007a3b38f7Smrg# func_mode_compile arg...
11017a3b38f7Smrgfunc_mode_compile ()
11027a3b38f7Smrg{
11037a3b38f7Smrg    $opt_debug
11047a3b38f7Smrg    # Get the compilation command and the source file.
11057a3b38f7Smrg    base_compile=
11067a3b38f7Smrg    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
11077a3b38f7Smrg    suppress_opt=yes
11087a3b38f7Smrg    suppress_output=
11097a3b38f7Smrg    arg_mode=normal
11107a3b38f7Smrg    libobj=
11117a3b38f7Smrg    later=
11127a3b38f7Smrg    pie_flag=
11137a3b38f7Smrg
11147a3b38f7Smrg    for arg
11157a3b38f7Smrg    do
11167a3b38f7Smrg      case $arg_mode in
11177a3b38f7Smrg      arg  )
11187a3b38f7Smrg	# do not "continue".  Instead, add this to base_compile
11197a3b38f7Smrg	lastarg="$arg"
11207a3b38f7Smrg	arg_mode=normal
11217a3b38f7Smrg	;;
11227a3b38f7Smrg
11237a3b38f7Smrg      target )
11247a3b38f7Smrg	libobj="$arg"
11257a3b38f7Smrg	arg_mode=normal
11267a3b38f7Smrg	continue
11277a3b38f7Smrg	;;
11287a3b38f7Smrg
11297a3b38f7Smrg      normal )
11307a3b38f7Smrg	# Accept any command-line options.
11317a3b38f7Smrg	case $arg in
11327a3b38f7Smrg	-o)
11337a3b38f7Smrg	  test -n "$libobj" && \
11347a3b38f7Smrg	    func_fatal_error "you cannot specify \`-o' more than once"
11357a3b38f7Smrg	  arg_mode=target
11367a3b38f7Smrg	  continue
11377a3b38f7Smrg	  ;;
11387a3b38f7Smrg
11397a3b38f7Smrg	-pie | -fpie | -fPIE)
11407a3b38f7Smrg          pie_flag="$pie_flag $arg"
11417a3b38f7Smrg	  continue
11427a3b38f7Smrg	  ;;
11437a3b38f7Smrg
11447a3b38f7Smrg	-shared | -static | -prefer-pic | -prefer-non-pic)
11457a3b38f7Smrg	  later="$later $arg"
11467a3b38f7Smrg	  continue
11477a3b38f7Smrg	  ;;
11487a3b38f7Smrg
11497a3b38f7Smrg	-no-suppress)
11507a3b38f7Smrg	  suppress_opt=no
11517a3b38f7Smrg	  continue
11527a3b38f7Smrg	  ;;
11537a3b38f7Smrg
11547a3b38f7Smrg	-Xcompiler)
11557a3b38f7Smrg	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
11567a3b38f7Smrg	  continue      #  The current "srcfile" will either be retained or
11577a3b38f7Smrg	  ;;            #  replaced later.  I would guess that would be a bug.
11587a3b38f7Smrg
11597a3b38f7Smrg	-Wc,*)
11607a3b38f7Smrg	  func_stripname '-Wc,' '' "$arg"
11617a3b38f7Smrg	  args=$func_stripname_result
11627a3b38f7Smrg	  lastarg=
11637a3b38f7Smrg	  save_ifs="$IFS"; IFS=','
11647a3b38f7Smrg	  for arg in $args; do
11657a3b38f7Smrg	    IFS="$save_ifs"
11667a3b38f7Smrg	    func_quote_for_eval "$arg"
11677a3b38f7Smrg	    lastarg="$lastarg $func_quote_for_eval_result"
1168ff559fabSmrg	  done
1169ff559fabSmrg	  IFS="$save_ifs"
11707a3b38f7Smrg	  func_stripname ' ' '' "$lastarg"
11717a3b38f7Smrg	  lastarg=$func_stripname_result
1172ff559fabSmrg
1173ff559fabSmrg	  # Add the arguments to base_compile.
1174ff559fabSmrg	  base_compile="$base_compile $lastarg"
1175ff559fabSmrg	  continue
1176ff559fabSmrg	  ;;
1177ff559fabSmrg
11787a3b38f7Smrg	*)
1179ff559fabSmrg	  # Accept the current argument as the source file.
1180ff559fabSmrg	  # The previous "srcfile" becomes the current argument.
1181ff559fabSmrg	  #
1182ff559fabSmrg	  lastarg="$srcfile"
1183ff559fabSmrg	  srcfile="$arg"
1184ff559fabSmrg	  ;;
1185ff559fabSmrg	esac  #  case $arg
1186ff559fabSmrg	;;
1187ff559fabSmrg      esac    #  case $arg_mode
1188ff559fabSmrg
1189ff559fabSmrg      # Aesthetically quote the previous argument.
11907a3b38f7Smrg      func_quote_for_eval "$lastarg"
11917a3b38f7Smrg      base_compile="$base_compile $func_quote_for_eval_result"
1192ff559fabSmrg    done # for arg
1193ff559fabSmrg
1194ff559fabSmrg    case $arg_mode in
1195ff559fabSmrg    arg)
11967a3b38f7Smrg      func_fatal_error "you must specify an argument for -Xcompile"
1197ff559fabSmrg      ;;
1198ff559fabSmrg    target)
11997a3b38f7Smrg      func_fatal_error "you must specify a target with \`-o'"
1200ff559fabSmrg      ;;
1201ff559fabSmrg    *)
1202ff559fabSmrg      # Get the name of the library object.
12037a3b38f7Smrg      test -z "$libobj" && {
12047a3b38f7Smrg	func_basename "$srcfile"
12057a3b38f7Smrg	libobj="$func_basename_result"
12067a3b38f7Smrg      }
1207ff559fabSmrg      ;;
1208ff559fabSmrg    esac
1209ff559fabSmrg
1210ff559fabSmrg    # Recognize several different file suffixes.
1211ff559fabSmrg    # If the user specifies -o file.o, it is replaced with file.lo
1212ff559fabSmrg    case $libobj in
12137a3b38f7Smrg    *.[cCFSifmso] | \
12147a3b38f7Smrg    *.ada | *.adb | *.ads | *.asm | \
12157a3b38f7Smrg    *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
12167a3b38f7Smrg    *.[fF][09]? | *.for | *.java | *.obj | *.sx)
12177a3b38f7Smrg      func_xform "$libobj"
12187a3b38f7Smrg      libobj=$func_xform_result
12197a3b38f7Smrg      ;;
1220ff559fabSmrg    esac
1221ff559fabSmrg
1222ff559fabSmrg    case $libobj in
12237a3b38f7Smrg    *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
1224ff559fabSmrg    *)
12257a3b38f7Smrg      func_fatal_error "cannot determine name of library object from \`$libobj'"
1226ff559fabSmrg      ;;
1227ff559fabSmrg    esac
1228ff559fabSmrg
1229ff559fabSmrg    func_infer_tag $base_compile
1230ff559fabSmrg
1231ff559fabSmrg    for arg in $later; do
1232ff559fabSmrg      case $arg in
12337a3b38f7Smrg      -shared)
12347a3b38f7Smrg	test "$build_libtool_libs" != yes && \
12357a3b38f7Smrg	  func_fatal_configuration "can not build a shared library"
12367a3b38f7Smrg	build_old_libs=no
12377a3b38f7Smrg	continue
12387a3b38f7Smrg	;;
12397a3b38f7Smrg
1240ff559fabSmrg      -static)
12417a3b38f7Smrg	build_libtool_libs=no
1242ff559fabSmrg	build_old_libs=yes
1243ff559fabSmrg	continue
1244ff559fabSmrg	;;
1245ff559fabSmrg
1246ff559fabSmrg      -prefer-pic)
1247ff559fabSmrg	pic_mode=yes
1248ff559fabSmrg	continue
1249ff559fabSmrg	;;
1250ff559fabSmrg
1251ff559fabSmrg      -prefer-non-pic)
1252ff559fabSmrg	pic_mode=no
1253ff559fabSmrg	continue
1254ff559fabSmrg	;;
1255ff559fabSmrg      esac
1256ff559fabSmrg    done
1257ff559fabSmrg
12587a3b38f7Smrg    func_quote_for_eval "$libobj"
12597a3b38f7Smrg    test "X$libobj" != "X$func_quote_for_eval_result" \
12607a3b38f7Smrg      && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'	 &()|`$[]' \
12617a3b38f7Smrg      && func_warning "libobj name \`$libobj' may not contain shell special characters."
12627a3b38f7Smrg    func_dirname_and_basename "$obj" "/" ""
12637a3b38f7Smrg    objname="$func_basename_result"
12647a3b38f7Smrg    xdir="$func_dirname_result"
1265ff559fabSmrg    lobj=${xdir}$objdir/$objname
1266ff559fabSmrg
12677a3b38f7Smrg    test -z "$base_compile" && \
12687a3b38f7Smrg      func_fatal_help "you must specify a compilation command"
1269ff559fabSmrg
1270ff559fabSmrg    # Delete any leftover library objects.
1271ff559fabSmrg    if test "$build_old_libs" = yes; then
1272ff559fabSmrg      removelist="$obj $lobj $libobj ${libobj}T"
1273ff559fabSmrg    else
1274ff559fabSmrg      removelist="$lobj $libobj ${libobj}T"
1275ff559fabSmrg    fi
1276ff559fabSmrg
1277ff559fabSmrg    # On Cygwin there's no "real" PIC flag so we must build both object types
1278ff559fabSmrg    case $host_os in
12797a3b38f7Smrg    cygwin* | mingw* | pw32* | os2* | cegcc*)
1280ff559fabSmrg      pic_mode=default
1281ff559fabSmrg      ;;
1282ff559fabSmrg    esac
1283ff559fabSmrg    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
1284ff559fabSmrg      # non-PIC code in shared libraries is not supported
1285ff559fabSmrg      pic_mode=default
1286ff559fabSmrg    fi
1287ff559fabSmrg
1288ff559fabSmrg    # Calculate the filename of the output object if compiler does
1289ff559fabSmrg    # not support -o with -c
1290ff559fabSmrg    if test "$compiler_c_o" = no; then
12917a3b38f7Smrg      output_obj=`$ECHO "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext}
1292ff559fabSmrg      lockfile="$output_obj.lock"
1293ff559fabSmrg    else
1294ff559fabSmrg      output_obj=
1295ff559fabSmrg      need_locks=no
1296ff559fabSmrg      lockfile=
1297ff559fabSmrg    fi
1298ff559fabSmrg
1299ff559fabSmrg    # Lock this critical section if it is needed
1300ff559fabSmrg    # We use this script file to make the link, it avoids creating a new file
1301ff559fabSmrg    if test "$need_locks" = yes; then
13027a3b38f7Smrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
13037a3b38f7Smrg	func_echo "Waiting for $lockfile to be removed"
1304ff559fabSmrg	sleep 2
1305ff559fabSmrg      done
1306ff559fabSmrg    elif test "$need_locks" = warn; then
1307ff559fabSmrg      if test -f "$lockfile"; then
13087a3b38f7Smrg	$ECHO "\
1309ff559fabSmrg*** ERROR, $lockfile exists and contains:
1310ff559fabSmrg`cat $lockfile 2>/dev/null`
1311ff559fabSmrg
1312ff559fabSmrgThis indicates that another process is trying to use the same
1313ff559fabSmrgtemporary object file, and libtool could not work around it because
1314ff559fabSmrgyour compiler does not support \`-c' and \`-o' together.  If you
1315ff559fabSmrgrepeat this compilation, it may succeed, by chance, but you had better
1316ff559fabSmrgavoid parallel builds (make -j) in this platform, or get a better
1317ff559fabSmrgcompiler."
1318ff559fabSmrg
13197a3b38f7Smrg	$opt_dry_run || $RM $removelist
1320ff559fabSmrg	exit $EXIT_FAILURE
1321ff559fabSmrg      fi
13227a3b38f7Smrg      removelist="$removelist $output_obj"
13237a3b38f7Smrg      $ECHO "$srcfile" > "$lockfile"
1324ff559fabSmrg    fi
1325ff559fabSmrg
13267a3b38f7Smrg    $opt_dry_run || $RM $removelist
13277a3b38f7Smrg    removelist="$removelist $lockfile"
13287a3b38f7Smrg    trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
13297a3b38f7Smrg
1330ff559fabSmrg    if test -n "$fix_srcfile_path"; then
1331ff559fabSmrg      eval srcfile=\"$fix_srcfile_path\"
1332ff559fabSmrg    fi
13337a3b38f7Smrg    func_quote_for_eval "$srcfile"
13347a3b38f7Smrg    qsrcfile=$func_quote_for_eval_result
1335ff559fabSmrg
1336ff559fabSmrg    # Only build a PIC object if we are building libtool libraries.
1337ff559fabSmrg    if test "$build_libtool_libs" = yes; then
1338ff559fabSmrg      # Without this assignment, base_compile gets emptied.
1339ff559fabSmrg      fbsd_hideous_sh_bug=$base_compile
1340ff559fabSmrg
1341ff559fabSmrg      if test "$pic_mode" != no; then
1342ff559fabSmrg	command="$base_compile $qsrcfile $pic_flag"
1343ff559fabSmrg      else
1344ff559fabSmrg	# Don't build PIC code
1345ff559fabSmrg	command="$base_compile $qsrcfile"
1346ff559fabSmrg      fi
1347ff559fabSmrg
13487a3b38f7Smrg      func_mkdir_p "$xdir$objdir"
1349ff559fabSmrg
1350ff559fabSmrg      if test -z "$output_obj"; then
1351ff559fabSmrg	# Place PIC objects in $objdir
1352ff559fabSmrg	command="$command -o $lobj"
1353ff559fabSmrg      fi
1354ff559fabSmrg
13557a3b38f7Smrg      func_show_eval_locale "$command"	\
13567a3b38f7Smrg          'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
1357ff559fabSmrg
1358ff559fabSmrg      if test "$need_locks" = warn &&
1359ff559fabSmrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
13607a3b38f7Smrg	$ECHO "\
1361ff559fabSmrg*** ERROR, $lockfile contains:
1362ff559fabSmrg`cat $lockfile 2>/dev/null`
1363ff559fabSmrg
1364ff559fabSmrgbut it should contain:
1365ff559fabSmrg$srcfile
1366ff559fabSmrg
1367ff559fabSmrgThis indicates that another process is trying to use the same
1368ff559fabSmrgtemporary object file, and libtool could not work around it because
1369ff559fabSmrgyour compiler does not support \`-c' and \`-o' together.  If you
1370ff559fabSmrgrepeat this compilation, it may succeed, by chance, but you had better
1371ff559fabSmrgavoid parallel builds (make -j) in this platform, or get a better
1372ff559fabSmrgcompiler."
1373ff559fabSmrg
13747a3b38f7Smrg	$opt_dry_run || $RM $removelist
1375ff559fabSmrg	exit $EXIT_FAILURE
1376ff559fabSmrg      fi
1377ff559fabSmrg
1378ff559fabSmrg      # Just move the object if needed, then go on to compile the next one
1379ff559fabSmrg      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
13807a3b38f7Smrg	func_show_eval '$MV "$output_obj" "$lobj"' \
13817a3b38f7Smrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
1382ff559fabSmrg      fi
1383ff559fabSmrg
1384ff559fabSmrg      # Allow error messages only from the first compilation.
1385ff559fabSmrg      if test "$suppress_opt" = yes; then
13867a3b38f7Smrg	suppress_output=' >/dev/null 2>&1'
1387ff559fabSmrg      fi
1388ff559fabSmrg    fi
1389ff559fabSmrg
1390ff559fabSmrg    # Only build a position-dependent object if we build old libraries.
1391ff559fabSmrg    if test "$build_old_libs" = yes; then
1392ff559fabSmrg      if test "$pic_mode" != yes; then
1393ff559fabSmrg	# Don't build PIC code
13947a3b38f7Smrg	command="$base_compile $qsrcfile$pie_flag"
1395ff559fabSmrg      else
1396ff559fabSmrg	command="$base_compile $qsrcfile $pic_flag"
1397ff559fabSmrg      fi
1398ff559fabSmrg      if test "$compiler_c_o" = yes; then
1399ff559fabSmrg	command="$command -o $obj"
1400ff559fabSmrg      fi
1401ff559fabSmrg
1402ff559fabSmrg      # Suppress compiler output if we already did a PIC compilation.
1403ff559fabSmrg      command="$command$suppress_output"
14047a3b38f7Smrg      func_show_eval_locale "$command" \
14057a3b38f7Smrg        '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
1406ff559fabSmrg
1407ff559fabSmrg      if test "$need_locks" = warn &&
1408ff559fabSmrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
14097a3b38f7Smrg	$ECHO "\
1410ff559fabSmrg*** ERROR, $lockfile contains:
1411ff559fabSmrg`cat $lockfile 2>/dev/null`
1412ff559fabSmrg
1413ff559fabSmrgbut it should contain:
1414ff559fabSmrg$srcfile
1415ff559fabSmrg
1416ff559fabSmrgThis indicates that another process is trying to use the same
1417ff559fabSmrgtemporary object file, and libtool could not work around it because
1418ff559fabSmrgyour compiler does not support \`-c' and \`-o' together.  If you
1419ff559fabSmrgrepeat this compilation, it may succeed, by chance, but you had better
1420ff559fabSmrgavoid parallel builds (make -j) in this platform, or get a better
1421ff559fabSmrgcompiler."
1422ff559fabSmrg
14237a3b38f7Smrg	$opt_dry_run || $RM $removelist
1424ff559fabSmrg	exit $EXIT_FAILURE
1425ff559fabSmrg      fi
1426ff559fabSmrg
1427ff559fabSmrg      # Just move the object if needed
1428ff559fabSmrg      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
14297a3b38f7Smrg	func_show_eval '$MV "$output_obj" "$obj"' \
14307a3b38f7Smrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
1431ff559fabSmrg      fi
1432ff559fabSmrg    fi
1433ff559fabSmrg
14347a3b38f7Smrg    $opt_dry_run || {
14357a3b38f7Smrg      func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
1436ff559fabSmrg
14377a3b38f7Smrg      # Unlock the critical section if it was locked
14387a3b38f7Smrg      if test "$need_locks" != no; then
14397a3b38f7Smrg	removelist=$lockfile
14407a3b38f7Smrg        $RM "$lockfile"
14417a3b38f7Smrg      fi
14427a3b38f7Smrg    }
1443ff559fabSmrg
1444ff559fabSmrg    exit $EXIT_SUCCESS
14457a3b38f7Smrg}
1446ff559fabSmrg
14477a3b38f7Smrg$opt_help || {
14487a3b38f7Smrgtest "$mode" = compile && func_mode_compile ${1+"$@"}
14497a3b38f7Smrg}
1450ff559fabSmrg
14517a3b38f7Smrgfunc_mode_help ()
14527a3b38f7Smrg{
14537a3b38f7Smrg    # We need to display help for each of the modes.
14547a3b38f7Smrg    case $mode in
14557a3b38f7Smrg      "")
14567a3b38f7Smrg        # Generic help is extracted from the usage comments
14577a3b38f7Smrg        # at the start of this file.
14587a3b38f7Smrg        func_help
14597a3b38f7Smrg        ;;
1460ff559fabSmrg
14617a3b38f7Smrg      clean)
14627a3b38f7Smrg        $ECHO \
14637a3b38f7Smrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
1464ff559fabSmrg
14657a3b38f7SmrgRemove files from the build directory.
1466ff559fabSmrg
14677a3b38f7SmrgRM is the name of the program to use to delete files associated with each FILE
14687a3b38f7Smrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
14697a3b38f7Smrgto RM.
1470ff559fabSmrg
14717a3b38f7SmrgIf FILE is a libtool library, object or program, all the files associated
14727a3b38f7Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM."
14737a3b38f7Smrg        ;;
1474ff559fabSmrg
14757a3b38f7Smrg      compile)
14767a3b38f7Smrg      $ECHO \
14777a3b38f7Smrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
1478ff559fabSmrg
14797a3b38f7SmrgCompile a source file into a libtool library object.
1480ff559fabSmrg
14817a3b38f7SmrgThis mode accepts the following additional options:
1482ff559fabSmrg
14837a3b38f7Smrg  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
14847a3b38f7Smrg  -no-suppress      do not suppress compiler output for multiple passes
14857a3b38f7Smrg  -prefer-pic       try to building PIC objects only
14867a3b38f7Smrg  -prefer-non-pic   try to building non-PIC objects only
14877a3b38f7Smrg  -shared           do not build a \`.o' file suitable for static linking
14887a3b38f7Smrg  -static           only build a \`.o' file suitable for static linking
1489ff559fabSmrg
14907a3b38f7SmrgCOMPILE-COMMAND is a command to be used in creating a \`standard' object file
14917a3b38f7Smrgfrom the given SOURCEFILE.
1492ff559fabSmrg
14937a3b38f7SmrgThe output file name is determined by removing the directory component from
14947a3b38f7SmrgSOURCEFILE, then substituting the C source code suffix \`.c' with the
14957a3b38f7Smrglibrary object suffix, \`.lo'."
14967a3b38f7Smrg        ;;
1497ff559fabSmrg
14987a3b38f7Smrg      execute)
14997a3b38f7Smrg        $ECHO \
15007a3b38f7Smrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
1501ff559fabSmrg
15027a3b38f7SmrgAutomatically set library path, then run a program.
1503ff559fabSmrg
15047a3b38f7SmrgThis mode accepts the following additional options:
1505ff559fabSmrg
15067a3b38f7Smrg  -dlopen FILE      add the directory containing FILE to the library path
1507ff559fabSmrg
15087a3b38f7SmrgThis mode sets the library path environment variable according to \`-dlopen'
15097a3b38f7Smrgflags.
1510ff559fabSmrg
15117a3b38f7SmrgIf any of the ARGS are libtool executable wrappers, then they are translated
15127a3b38f7Smrginto their corresponding uninstalled binary, and any of their required library
15137a3b38f7Smrgdirectories are added to the library path.
1514ff559fabSmrg
15157a3b38f7SmrgThen, COMMAND is executed, with ARGS as arguments."
15167a3b38f7Smrg        ;;
1517ff559fabSmrg
15187a3b38f7Smrg      finish)
15197a3b38f7Smrg        $ECHO \
15207a3b38f7Smrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
1521ff559fabSmrg
15227a3b38f7SmrgComplete the installation of libtool libraries.
1523ff559fabSmrg
15247a3b38f7SmrgEach LIBDIR is a directory that contains libtool libraries.
1525ff559fabSmrg
15267a3b38f7SmrgThe commands that this mode executes may require superuser privileges.  Use
15277a3b38f7Smrgthe \`--dry-run' option if you just want to see what would be executed."
15287a3b38f7Smrg        ;;
1529ff559fabSmrg
15307a3b38f7Smrg      install)
15317a3b38f7Smrg        $ECHO \
15327a3b38f7Smrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
1533ff559fabSmrg
15347a3b38f7SmrgInstall executables or libraries.
1535ff559fabSmrg
15367a3b38f7SmrgINSTALL-COMMAND is the installation command.  The first component should be
15377a3b38f7Smrgeither the \`install' or \`cp' program.
1538ff559fabSmrg
15397a3b38f7SmrgThe following components of INSTALL-COMMAND are treated specially:
1540ff559fabSmrg
15417a3b38f7Smrg  -inst-prefix PREFIX-DIR  Use PREFIX-DIR as a staging area for installation
1542ff559fabSmrg
15437a3b38f7SmrgThe rest of the components are interpreted as arguments to that command (only
15447a3b38f7SmrgBSD-compatible install options are recognized)."
15457a3b38f7Smrg        ;;
1546ff559fabSmrg
15477a3b38f7Smrg      link)
15487a3b38f7Smrg        $ECHO \
15497a3b38f7Smrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
1550ff559fabSmrg
15517a3b38f7SmrgLink object files or libraries together to form another library, or to
15527a3b38f7Smrgcreate an executable program.
1553ff559fabSmrg
15547a3b38f7SmrgLINK-COMMAND is a command using the C compiler that you would use to create
15557a3b38f7Smrga program from several object files.
1556ff559fabSmrg
15577a3b38f7SmrgThe following components of LINK-COMMAND are treated specially:
1558ff559fabSmrg
15597a3b38f7Smrg  -all-static       do not do any dynamic linking at all
15607a3b38f7Smrg  -avoid-version    do not add a version suffix if possible
15617a3b38f7Smrg  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
15627a3b38f7Smrg  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
15637a3b38f7Smrg  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
15647a3b38f7Smrg  -export-symbols SYMFILE
15657a3b38f7Smrg                    try to export only the symbols listed in SYMFILE
15667a3b38f7Smrg  -export-symbols-regex REGEX
15677a3b38f7Smrg                    try to export only the symbols matching REGEX
15687a3b38f7Smrg  -LLIBDIR          search LIBDIR for required installed libraries
15697a3b38f7Smrg  -lNAME            OUTPUT-FILE requires the installed library libNAME
15707a3b38f7Smrg  -module           build a library that can dlopened
15717a3b38f7Smrg  -no-fast-install  disable the fast-install mode
15727a3b38f7Smrg  -no-install       link a not-installable executable
15737a3b38f7Smrg  -no-undefined     declare that a library does not refer to external symbols
15747a3b38f7Smrg  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
15757a3b38f7Smrg  -objectlist FILE  Use a list of object files found in FILE to specify objects
15767a3b38f7Smrg  -precious-files-regex REGEX
15777a3b38f7Smrg                    don't remove output files matching REGEX
15787a3b38f7Smrg  -release RELEASE  specify package release information
15797a3b38f7Smrg  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
15807a3b38f7Smrg  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
15817a3b38f7Smrg  -shared           only do dynamic linking of libtool libraries
15827a3b38f7Smrg  -shrext SUFFIX    override the standard shared library file extension
15837a3b38f7Smrg  -static           do not do any dynamic linking of uninstalled libtool libraries
15847a3b38f7Smrg  -static-libtool-libs
15857a3b38f7Smrg                    do not do any dynamic linking of libtool libraries
15867a3b38f7Smrg  -version-info CURRENT[:REVISION[:AGE]]
15877a3b38f7Smrg                    specify library version info [each variable defaults to 0]
15887a3b38f7Smrg  -weak LIBNAME     declare that the target provides the LIBNAME interface
1589ff559fabSmrg
15907a3b38f7SmrgAll other options (arguments beginning with \`-') are ignored.
1591ff559fabSmrg
15927a3b38f7SmrgEvery other argument is treated as a filename.  Files ending in \`.la' are
15937a3b38f7Smrgtreated as uninstalled libtool libraries, other files are standard or library
15947a3b38f7Smrgobject files.
1595ff559fabSmrg
15967a3b38f7SmrgIf the OUTPUT-FILE ends in \`.la', then a libtool library is created,
15977a3b38f7Smrgonly library objects (\`.lo' files) may be specified, and \`-rpath' is
15987a3b38f7Smrgrequired, except when creating a convenience library.
1599ff559fabSmrg
16007a3b38f7SmrgIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
16017a3b38f7Smrgusing \`ar' and \`ranlib', or on Windows using \`lib'.
1602ff559fabSmrg
16037a3b38f7SmrgIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
16047a3b38f7Smrgis created, otherwise an executable program is created."
1605ff559fabSmrg        ;;
1606ff559fabSmrg
16077a3b38f7Smrg      uninstall)
16087a3b38f7Smrg        $ECHO \
16097a3b38f7Smrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
1610ff559fabSmrg
16117a3b38f7SmrgRemove libraries from an installation directory.
1612ff559fabSmrg
16137a3b38f7SmrgRM is the name of the program to use to delete files associated with each FILE
16147a3b38f7Smrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
16157a3b38f7Smrgto RM.
1616ff559fabSmrg
16177a3b38f7SmrgIf FILE is a libtool library, all the files associated with it are deleted.
16187a3b38f7SmrgOtherwise, only FILE itself is deleted using RM."
16197a3b38f7Smrg        ;;
1620ff559fabSmrg
16217a3b38f7Smrg      *)
16227a3b38f7Smrg        func_fatal_help "invalid operation mode \`$mode'"
16237a3b38f7Smrg        ;;
16247a3b38f7Smrg    esac
1625ff559fabSmrg
16267a3b38f7Smrg    $ECHO
16277a3b38f7Smrg    $ECHO "Try \`$progname --help' for more information about other modes."
1628ff559fabSmrg
16297a3b38f7Smrg    exit $?
16307a3b38f7Smrg}
1631ff559fabSmrg
16327a3b38f7Smrg  # Now that we've collected a possible --mode arg, show help if necessary
16337a3b38f7Smrg  $opt_help && func_mode_help
1634ff559fabSmrg
1635ff559fabSmrg
16367a3b38f7Smrg# func_mode_execute arg...
16377a3b38f7Smrgfunc_mode_execute ()
16387a3b38f7Smrg{
16397a3b38f7Smrg    $opt_debug
16407a3b38f7Smrg    # The first argument is the command name.
16417a3b38f7Smrg    cmd="$nonopt"
16427a3b38f7Smrg    test -z "$cmd" && \
16437a3b38f7Smrg      func_fatal_help "you must specify a COMMAND"
1644ff559fabSmrg
16457a3b38f7Smrg    # Handle -dlopen flags immediately.
16467a3b38f7Smrg    for file in $execute_dlfiles; do
16477a3b38f7Smrg      test -f "$file" \
16487a3b38f7Smrg	|| func_fatal_help "\`$file' is not a file"
1649ff559fabSmrg
16507a3b38f7Smrg      dir=
16517a3b38f7Smrg      case $file in
16527a3b38f7Smrg      *.la)
16537a3b38f7Smrg	# Check to see that this really is a libtool archive.
16547a3b38f7Smrg	func_lalib_unsafe_p "$file" \
16557a3b38f7Smrg	  || func_fatal_help "\`$lib' is not a valid libtool archive"
1656ff559fabSmrg
16577a3b38f7Smrg	# Read the libtool library.
16587a3b38f7Smrg	dlname=
16597a3b38f7Smrg	library_names=
16607a3b38f7Smrg	func_source "$file"
1661ff559fabSmrg
16627a3b38f7Smrg	# Skip this library if it cannot be dlopened.
16637a3b38f7Smrg	if test -z "$dlname"; then
16647a3b38f7Smrg	  # Warn if it was a shared library.
16657a3b38f7Smrg	  test -n "$library_names" && \
16667a3b38f7Smrg	    func_warning "\`$file' was not linked with \`-export-dynamic'"
16677a3b38f7Smrg	  continue
16687a3b38f7Smrg	fi
1669ff559fabSmrg
16707a3b38f7Smrg	func_dirname "$file" "" "."
16717a3b38f7Smrg	dir="$func_dirname_result"
1672ff559fabSmrg
16737a3b38f7Smrg	if test -f "$dir/$objdir/$dlname"; then
16747a3b38f7Smrg	  dir="$dir/$objdir"
16757a3b38f7Smrg	else
16767a3b38f7Smrg	  if test ! -f "$dir/$dlname"; then
16777a3b38f7Smrg	    func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'"
16787a3b38f7Smrg	  fi
16797a3b38f7Smrg	fi
1680ff559fabSmrg	;;
1681ff559fabSmrg
16827a3b38f7Smrg      *.lo)
16837a3b38f7Smrg	# Just add the directory containing the .lo file.
16847a3b38f7Smrg	func_dirname "$file" "" "."
16857a3b38f7Smrg	dir="$func_dirname_result"
1686ff559fabSmrg	;;
1687ff559fabSmrg
16887a3b38f7Smrg      *)
16897a3b38f7Smrg	func_warning "\`-dlopen' is ignored for non-libtool libraries and objects"
1690ff559fabSmrg	continue
1691ff559fabSmrg	;;
16927a3b38f7Smrg      esac
1693ff559fabSmrg
16947a3b38f7Smrg      # Get the absolute pathname.
16957a3b38f7Smrg      absdir=`cd "$dir" && pwd`
16967a3b38f7Smrg      test -n "$absdir" && dir="$absdir"
1697ff559fabSmrg
16987a3b38f7Smrg      # Now add the directory to shlibpath_var.
16997a3b38f7Smrg      if eval "test -z \"\$$shlibpath_var\""; then
17007a3b38f7Smrg	eval "$shlibpath_var=\"\$dir\""
17017a3b38f7Smrg      else
17027a3b38f7Smrg	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
17037a3b38f7Smrg      fi
17047a3b38f7Smrg    done
1705ff559fabSmrg
17067a3b38f7Smrg    # This variable tells wrapper scripts just to set shlibpath_var
17077a3b38f7Smrg    # rather than running their programs.
17087a3b38f7Smrg    libtool_execute_magic="$magic"
1709ff559fabSmrg
17107a3b38f7Smrg    # Check if any of the arguments is a wrapper script.
17117a3b38f7Smrg    args=
17127a3b38f7Smrg    for file
17137a3b38f7Smrg    do
17147a3b38f7Smrg      case $file in
17157a3b38f7Smrg      -*) ;;
17167a3b38f7Smrg      *)
17177a3b38f7Smrg	# Do a test to see if this is really a libtool program.
17187a3b38f7Smrg	if func_ltwrapper_script_p "$file"; then
17197a3b38f7Smrg	  func_source "$file"
17207a3b38f7Smrg	  # Transform arg to wrapped name.
17217a3b38f7Smrg	  file="$progdir/$program"
17227a3b38f7Smrg	elif func_ltwrapper_executable_p "$file"; then
17237a3b38f7Smrg	  func_ltwrapper_scriptname "$file"
17247a3b38f7Smrg	  func_source "$func_ltwrapper_scriptname_result"
17257a3b38f7Smrg	  # Transform arg to wrapped name.
17267a3b38f7Smrg	  file="$progdir/$program"
17277a3b38f7Smrg	fi
17287a3b38f7Smrg	;;
17297a3b38f7Smrg      esac
17307a3b38f7Smrg      # Quote arguments (to preserve shell metacharacters).
17317a3b38f7Smrg      func_quote_for_eval "$file"
17327a3b38f7Smrg      args="$args $func_quote_for_eval_result"
17337a3b38f7Smrg    done
1734ff559fabSmrg
17357a3b38f7Smrg    if test "X$opt_dry_run" = Xfalse; then
17367a3b38f7Smrg      if test -n "$shlibpath_var"; then
17377a3b38f7Smrg	# Export the shlibpath_var.
17387a3b38f7Smrg	eval "export $shlibpath_var"
17397a3b38f7Smrg      fi
1740ff559fabSmrg
17417a3b38f7Smrg      # Restore saved environment variables
17427a3b38f7Smrg      for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
17437a3b38f7Smrg      do
17447a3b38f7Smrg	eval "if test \"\${save_$lt_var+set}\" = set; then
17457a3b38f7Smrg                $lt_var=\$save_$lt_var; export $lt_var
17467a3b38f7Smrg	      else
17477a3b38f7Smrg		$lt_unset $lt_var
17487a3b38f7Smrg	      fi"
17497a3b38f7Smrg      done
1750ff559fabSmrg
17517a3b38f7Smrg      # Now prepare to actually exec the command.
17527a3b38f7Smrg      exec_cmd="\$cmd$args"
17537a3b38f7Smrg    else
17547a3b38f7Smrg      # Display what would be done.
17557a3b38f7Smrg      if test -n "$shlibpath_var"; then
17567a3b38f7Smrg	eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
17577a3b38f7Smrg	$ECHO "export $shlibpath_var"
17587a3b38f7Smrg      fi
17597a3b38f7Smrg      $ECHO "$cmd$args"
17607a3b38f7Smrg      exit $EXIT_SUCCESS
17617a3b38f7Smrg    fi
17627a3b38f7Smrg}
1763ff559fabSmrg
17647a3b38f7Smrgtest "$mode" = execute && func_mode_execute ${1+"$@"}
1765ff559fabSmrg
1766ff559fabSmrg
17677a3b38f7Smrg# func_mode_finish arg...
17687a3b38f7Smrgfunc_mode_finish ()
17697a3b38f7Smrg{
17707a3b38f7Smrg    $opt_debug
17717a3b38f7Smrg    libdirs="$nonopt"
17727a3b38f7Smrg    admincmds=
1773ff559fabSmrg
17747a3b38f7Smrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
17757a3b38f7Smrg      for dir
17767a3b38f7Smrg      do
17777a3b38f7Smrg	libdirs="$libdirs $dir"
17787a3b38f7Smrg      done
1779ff559fabSmrg
17807a3b38f7Smrg      for libdir in $libdirs; do
17817a3b38f7Smrg	if test -n "$finish_cmds"; then
17827a3b38f7Smrg	  # Do each command in the finish commands.
17837a3b38f7Smrg	  func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
17847a3b38f7Smrg'"$cmd"'"'
17857a3b38f7Smrg	fi
17867a3b38f7Smrg	if test -n "$finish_eval"; then
17877a3b38f7Smrg	  # Do the single finish_eval.
17887a3b38f7Smrg	  eval cmds=\"$finish_eval\"
17897a3b38f7Smrg	  $opt_dry_run || eval "$cmds" || admincmds="$admincmds
17907a3b38f7Smrg       $cmds"
17917a3b38f7Smrg	fi
17927a3b38f7Smrg      done
17937a3b38f7Smrg    fi
1794ff559fabSmrg
17957a3b38f7Smrg    # Exit here if they wanted silent mode.
17967a3b38f7Smrg    $opt_silent && exit $EXIT_SUCCESS
1797ff559fabSmrg
17987a3b38f7Smrg    $ECHO "X----------------------------------------------------------------------" | $Xsed
17997a3b38f7Smrg    $ECHO "Libraries have been installed in:"
18007a3b38f7Smrg    for libdir in $libdirs; do
18017a3b38f7Smrg      $ECHO "   $libdir"
18027a3b38f7Smrg    done
18037a3b38f7Smrg    $ECHO
18047a3b38f7Smrg    $ECHO "If you ever happen to want to link against installed libraries"
18057a3b38f7Smrg    $ECHO "in a given directory, LIBDIR, you must either use libtool, and"
18067a3b38f7Smrg    $ECHO "specify the full pathname of the library, or use the \`-LLIBDIR'"
18077a3b38f7Smrg    $ECHO "flag during linking and do at least one of the following:"
18087a3b38f7Smrg    if test -n "$shlibpath_var"; then
18097a3b38f7Smrg      $ECHO "   - add LIBDIR to the \`$shlibpath_var' environment variable"
18107a3b38f7Smrg      $ECHO "     during execution"
18117a3b38f7Smrg    fi
18127a3b38f7Smrg    if test -n "$runpath_var"; then
18137a3b38f7Smrg      $ECHO "   - add LIBDIR to the \`$runpath_var' environment variable"
18147a3b38f7Smrg      $ECHO "     during linking"
18157a3b38f7Smrg    fi
18167a3b38f7Smrg    if test -n "$hardcode_libdir_flag_spec"; then
18177a3b38f7Smrg      libdir=LIBDIR
18187a3b38f7Smrg      eval flag=\"$hardcode_libdir_flag_spec\"
1819ff559fabSmrg
18207a3b38f7Smrg      $ECHO "   - use the \`$flag' linker flag"
18217a3b38f7Smrg    fi
18227a3b38f7Smrg    if test -n "$admincmds"; then
18237a3b38f7Smrg      $ECHO "   - have your system administrator run these commands:$admincmds"
18247a3b38f7Smrg    fi
18257a3b38f7Smrg    if test -f /etc/ld.so.conf; then
18267a3b38f7Smrg      $ECHO "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
18277a3b38f7Smrg    fi
18287a3b38f7Smrg    $ECHO
1829ff559fabSmrg
18307a3b38f7Smrg    $ECHO "See any operating system documentation about shared libraries for"
18317a3b38f7Smrg    case $host in
18327a3b38f7Smrg      solaris2.[6789]|solaris2.1[0-9])
18337a3b38f7Smrg        $ECHO "more information, such as the ld(1), crle(1) and ld.so(8) manual"
18347a3b38f7Smrg	$ECHO "pages."
1835ff559fabSmrg	;;
18367a3b38f7Smrg      *)
18377a3b38f7Smrg        $ECHO "more information, such as the ld(1) and ld.so(8) manual pages."
18387a3b38f7Smrg        ;;
18397a3b38f7Smrg    esac
18407a3b38f7Smrg    $ECHO "X----------------------------------------------------------------------" | $Xsed
18417a3b38f7Smrg    exit $EXIT_SUCCESS
18427a3b38f7Smrg}
1843ff559fabSmrg
18447a3b38f7Smrgtest "$mode" = finish && func_mode_finish ${1+"$@"}
1845ff559fabSmrg
1846ff559fabSmrg
18477a3b38f7Smrg# func_mode_install arg...
18487a3b38f7Smrgfunc_mode_install ()
18497a3b38f7Smrg{
18507a3b38f7Smrg    $opt_debug
18517a3b38f7Smrg    # There may be an optional sh(1) argument at the beginning of
18527a3b38f7Smrg    # install_prog (especially on Windows NT).
18537a3b38f7Smrg    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
18547a3b38f7Smrg       # Allow the use of GNU shtool's install command.
18557a3b38f7Smrg       $ECHO "X$nonopt" | $GREP shtool >/dev/null; then
18567a3b38f7Smrg      # Aesthetically quote it.
18577a3b38f7Smrg      func_quote_for_eval "$nonopt"
18587a3b38f7Smrg      install_prog="$func_quote_for_eval_result "
18597a3b38f7Smrg      arg=$1
18607a3b38f7Smrg      shift
18617a3b38f7Smrg    else
18627a3b38f7Smrg      install_prog=
18637a3b38f7Smrg      arg=$nonopt
18647a3b38f7Smrg    fi
1865ff559fabSmrg
18667a3b38f7Smrg    # The real first argument should be the name of the installation program.
18677a3b38f7Smrg    # Aesthetically quote it.
18687a3b38f7Smrg    func_quote_for_eval "$arg"
18697a3b38f7Smrg    install_prog="$install_prog$func_quote_for_eval_result"
18707a3b38f7Smrg
18717a3b38f7Smrg    # We need to accept at least all the BSD install flags.
18727a3b38f7Smrg    dest=
18737a3b38f7Smrg    files=
18747a3b38f7Smrg    opts=
18757a3b38f7Smrg    prev=
18767a3b38f7Smrg    install_type=
18777a3b38f7Smrg    isdir=no
18787a3b38f7Smrg    stripme=
18797a3b38f7Smrg    for arg
18807a3b38f7Smrg    do
18817a3b38f7Smrg      if test -n "$dest"; then
18827a3b38f7Smrg	files="$files $dest"
18837a3b38f7Smrg	dest=$arg
18847a3b38f7Smrg	continue
1885ff559fabSmrg      fi
1886ff559fabSmrg
18877a3b38f7Smrg      case $arg in
18887a3b38f7Smrg      -d) isdir=yes ;;
18897a3b38f7Smrg      -f)
18907a3b38f7Smrg	case " $install_prog " in
18917a3b38f7Smrg	*[\\\ /]cp\ *) ;;
18927a3b38f7Smrg	*) prev=$arg ;;
18937a3b38f7Smrg	esac
18947a3b38f7Smrg	;;
18957a3b38f7Smrg      -g | -m | -o)
18967a3b38f7Smrg	prev=$arg
18977a3b38f7Smrg	;;
18987a3b38f7Smrg      -s)
18997a3b38f7Smrg	stripme=" -s"
19007a3b38f7Smrg	continue
19017a3b38f7Smrg	;;
19027a3b38f7Smrg      -*)
19037a3b38f7Smrg	;;
19047a3b38f7Smrg      *)
19057a3b38f7Smrg	# If the previous option needed an argument, then skip it.
19067a3b38f7Smrg	if test -n "$prev"; then
19077a3b38f7Smrg	  prev=
19087a3b38f7Smrg	else
19097a3b38f7Smrg	  dest=$arg
19107a3b38f7Smrg	  continue
19117a3b38f7Smrg	fi
19127a3b38f7Smrg	;;
19137a3b38f7Smrg      esac
1914ff559fabSmrg
19157a3b38f7Smrg      # Aesthetically quote the argument.
19167a3b38f7Smrg      func_quote_for_eval "$arg"
19177a3b38f7Smrg      install_prog="$install_prog $func_quote_for_eval_result"
19187a3b38f7Smrg    done
1919ff559fabSmrg
19207a3b38f7Smrg    test -z "$install_prog" && \
19217a3b38f7Smrg      func_fatal_help "you must specify an install program"
1922ff559fabSmrg
19237a3b38f7Smrg    test -n "$prev" && \
19247a3b38f7Smrg      func_fatal_help "the \`$prev' option requires an argument"
1925ff559fabSmrg
19267a3b38f7Smrg    if test -z "$files"; then
19277a3b38f7Smrg      if test -z "$dest"; then
19287a3b38f7Smrg	func_fatal_help "no file or destination specified"
19297a3b38f7Smrg      else
19307a3b38f7Smrg	func_fatal_help "you must specify a destination"
1931ff559fabSmrg      fi
1932ff559fabSmrg    fi
1933ff559fabSmrg
19347a3b38f7Smrg    # Strip any trailing slash from the destination.
19357a3b38f7Smrg    func_stripname '' '/' "$dest"
19367a3b38f7Smrg    dest=$func_stripname_result
1937ff559fabSmrg
19387a3b38f7Smrg    # Check to see that the destination is a directory.
19397a3b38f7Smrg    test -d "$dest" && isdir=yes
19407a3b38f7Smrg    if test "$isdir" = yes; then
19417a3b38f7Smrg      destdir="$dest"
19427a3b38f7Smrg      destname=
19437a3b38f7Smrg    else
19447a3b38f7Smrg      func_dirname_and_basename "$dest" "" "."
19457a3b38f7Smrg      destdir="$func_dirname_result"
19467a3b38f7Smrg      destname="$func_basename_result"
19477a3b38f7Smrg
19487a3b38f7Smrg      # Not a directory, so check to see that there is only one file specified.
19497a3b38f7Smrg      set dummy $files; shift
19507a3b38f7Smrg      test "$#" -gt 1 && \
19517a3b38f7Smrg	func_fatal_help "\`$dest' is not a directory"
19527a3b38f7Smrg    fi
19537a3b38f7Smrg    case $destdir in
19547a3b38f7Smrg    [\\/]* | [A-Za-z]:[\\/]*) ;;
1955ff559fabSmrg    *)
19567a3b38f7Smrg      for file in $files; do
19577a3b38f7Smrg	case $file in
19587a3b38f7Smrg	*.lo) ;;
19597a3b38f7Smrg	*)
19607a3b38f7Smrg	  func_fatal_help "\`$destdir' must be an absolute directory name"
19617a3b38f7Smrg	  ;;
19627a3b38f7Smrg	esac
19637a3b38f7Smrg      done
1964ff559fabSmrg      ;;
1965ff559fabSmrg    esac
1966ff559fabSmrg
19677a3b38f7Smrg    # This variable tells wrapper scripts just to set variables rather
19687a3b38f7Smrg    # than running their programs.
19697a3b38f7Smrg    libtool_install_magic="$magic"
1970ff559fabSmrg
19717a3b38f7Smrg    staticlibs=
19727a3b38f7Smrg    future_libdirs=
19737a3b38f7Smrg    current_libdirs=
19747a3b38f7Smrg    for file in $files; do
1975ff559fabSmrg
19767a3b38f7Smrg      # Do each installation.
19777a3b38f7Smrg      case $file in
19787a3b38f7Smrg      *.$libext)
19797a3b38f7Smrg	# Do the static libraries later.
19807a3b38f7Smrg	staticlibs="$staticlibs $file"
19817a3b38f7Smrg	;;
19827a3b38f7Smrg
19837a3b38f7Smrg      *.la)
19847a3b38f7Smrg	# Check to see that this really is a libtool archive.
19857a3b38f7Smrg	func_lalib_unsafe_p "$file" \
19867a3b38f7Smrg	  || func_fatal_help "\`$file' is not a valid libtool archive"
19877a3b38f7Smrg
19887a3b38f7Smrg	library_names=
19897a3b38f7Smrg	old_library=
19907a3b38f7Smrg	relink_command=
19917a3b38f7Smrg	func_source "$file"
19927a3b38f7Smrg
19937a3b38f7Smrg	# Add the libdir to current_libdirs if it is the destination.
19947a3b38f7Smrg	if test "X$destdir" = "X$libdir"; then
19957a3b38f7Smrg	  case "$current_libdirs " in
19967a3b38f7Smrg	  *" $libdir "*) ;;
19977a3b38f7Smrg	  *) current_libdirs="$current_libdirs $libdir" ;;
1998ff559fabSmrg	  esac
19997a3b38f7Smrg	else
20007a3b38f7Smrg	  # Note the libdir as a future libdir.
20017a3b38f7Smrg	  case "$future_libdirs " in
20027a3b38f7Smrg	  *" $libdir "*) ;;
20037a3b38f7Smrg	  *) future_libdirs="$future_libdirs $libdir" ;;
20047a3b38f7Smrg	  esac
20057a3b38f7Smrg	fi
2006ff559fabSmrg
20077a3b38f7Smrg	func_dirname "$file" "/" ""
20087a3b38f7Smrg	dir="$func_dirname_result"
20097a3b38f7Smrg	dir="$dir$objdir"
20107a3b38f7Smrg
20117a3b38f7Smrg	if test -n "$relink_command"; then
20127a3b38f7Smrg	  # Determine the prefix the user has applied to our future dir.
20137a3b38f7Smrg	  inst_prefix_dir=`$ECHO "X$destdir" | $Xsed -e "s%$libdir\$%%"`
20147a3b38f7Smrg
20157a3b38f7Smrg	  # Don't allow the user to place us outside of our expected
20167a3b38f7Smrg	  # location b/c this prevents finding dependent libraries that
20177a3b38f7Smrg	  # are installed to the same prefix.
20187a3b38f7Smrg	  # At present, this check doesn't affect windows .dll's that
20197a3b38f7Smrg	  # are installed into $libdir/../bin (currently, that works fine)
20207a3b38f7Smrg	  # but it's something to keep an eye on.
20217a3b38f7Smrg	  test "$inst_prefix_dir" = "$destdir" && \
20227a3b38f7Smrg	    func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
20237a3b38f7Smrg
20247a3b38f7Smrg	  if test -n "$inst_prefix_dir"; then
20257a3b38f7Smrg	    # Stick the inst_prefix_dir data into the link command.
20267a3b38f7Smrg	    relink_command=`$ECHO "X$relink_command" | $Xsed -e "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
20277a3b38f7Smrg	  else
20287a3b38f7Smrg	    relink_command=`$ECHO "X$relink_command" | $Xsed -e "s%@inst_prefix_dir@%%"`
20297a3b38f7Smrg	  fi
20307a3b38f7Smrg
20317a3b38f7Smrg	  func_warning "relinking \`$file'"
20327a3b38f7Smrg	  func_show_eval "$relink_command" \
20337a3b38f7Smrg	    'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
20347a3b38f7Smrg	fi
20357a3b38f7Smrg
20367a3b38f7Smrg	# See the names of the shared library.
20377a3b38f7Smrg	set dummy $library_names; shift
20387a3b38f7Smrg	if test -n "$1"; then
20397a3b38f7Smrg	  realname="$1"
20407a3b38f7Smrg	  shift
20417a3b38f7Smrg
20427a3b38f7Smrg	  srcname="$realname"
20437a3b38f7Smrg	  test -n "$relink_command" && srcname="$realname"T
20447a3b38f7Smrg
20457a3b38f7Smrg	  # Install the shared library and build the symlinks.
20467a3b38f7Smrg	  func_show_eval "$install_prog $dir/$srcname $destdir/$realname" \
20477a3b38f7Smrg	      'exit $?'
20487a3b38f7Smrg	  tstripme="$stripme"
20497a3b38f7Smrg	  case $host_os in
20507a3b38f7Smrg	  cygwin* | mingw* | pw32* | cegcc*)
20517a3b38f7Smrg	    case $realname in
20527a3b38f7Smrg	    *.dll.a)
20537a3b38f7Smrg	      tstripme=""
20547a3b38f7Smrg	      ;;
20557a3b38f7Smrg	    esac
2056ff559fabSmrg	    ;;
2057ff559fabSmrg	  esac
20587a3b38f7Smrg	  if test -n "$tstripme" && test -n "$striplib"; then
20597a3b38f7Smrg	    func_show_eval "$striplib $destdir/$realname" 'exit $?'
2060ff559fabSmrg	  fi
20617a3b38f7Smrg
20627a3b38f7Smrg	  if test "$#" -gt 0; then
20637a3b38f7Smrg	    # Delete the old symlinks, and create new ones.
20647a3b38f7Smrg	    # Try `ln -sf' first, because the `ln' binary might depend on
20657a3b38f7Smrg	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
20667a3b38f7Smrg	    # so we also need to try rm && ln -s.
20677a3b38f7Smrg	    for linkname
20687a3b38f7Smrg	    do
20697a3b38f7Smrg	      test "$linkname" != "$realname" \
20707a3b38f7Smrg		&& func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
2071ff559fabSmrg	    done
2072ff559fabSmrg	  fi
2073ff559fabSmrg
20747a3b38f7Smrg	  # Do each command in the postinstall commands.
20757a3b38f7Smrg	  lib="$destdir/$realname"
20767a3b38f7Smrg	  func_execute_cmds "$postinstall_cmds" 'exit $?'
2077ff559fabSmrg	fi
2078ff559fabSmrg
20797a3b38f7Smrg	# Install the pseudo-library for information purposes.
20807a3b38f7Smrg	func_basename "$file"
20817a3b38f7Smrg	name="$func_basename_result"
20827a3b38f7Smrg	instname="$dir/$name"i
20837a3b38f7Smrg	func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
2084ff559fabSmrg
20857a3b38f7Smrg	# Maybe install the static library, too.
20867a3b38f7Smrg	test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library"
20877a3b38f7Smrg	;;
2088ff559fabSmrg
20897a3b38f7Smrg      *.lo)
20907a3b38f7Smrg	# Install (i.e. copy) a libtool object.
2091ff559fabSmrg
20927a3b38f7Smrg	# Figure out destination file name, if it wasn't already specified.
20937a3b38f7Smrg	if test -n "$destname"; then
20947a3b38f7Smrg	  destfile="$destdir/$destname"
20957a3b38f7Smrg	else
20967a3b38f7Smrg	  func_basename "$file"
20977a3b38f7Smrg	  destfile="$func_basename_result"
20987a3b38f7Smrg	  destfile="$destdir/$destfile"
20997a3b38f7Smrg	fi
21007a3b38f7Smrg
21017a3b38f7Smrg	# Deduce the name of the destination old-style object file.
21027a3b38f7Smrg	case $destfile in
21037a3b38f7Smrg	*.lo)
21047a3b38f7Smrg	  func_lo2o "$destfile"
21057a3b38f7Smrg	  staticdest=$func_lo2o_result
21067a3b38f7Smrg	  ;;
21077a3b38f7Smrg	*.$objext)
21087a3b38f7Smrg	  staticdest="$destfile"
21097a3b38f7Smrg	  destfile=
21107a3b38f7Smrg	  ;;
21117a3b38f7Smrg	*)
21127a3b38f7Smrg	  func_fatal_help "cannot copy a libtool object to \`$destfile'"
21137a3b38f7Smrg	  ;;
2114ff559fabSmrg	esac
2115ff559fabSmrg
21167a3b38f7Smrg	# Install the libtool object if requested.
21177a3b38f7Smrg	test -n "$destfile" && \
21187a3b38f7Smrg	  func_show_eval "$install_prog $file $destfile" 'exit $?'
21197a3b38f7Smrg
21207a3b38f7Smrg	# Install the old object if enabled.
21217a3b38f7Smrg	if test "$build_old_libs" = yes; then
21227a3b38f7Smrg	  # Deduce the name of the old-style object file.
21237a3b38f7Smrg	  func_lo2o "$file"
21247a3b38f7Smrg	  staticobj=$func_lo2o_result
21257a3b38f7Smrg	  func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
2126ff559fabSmrg	fi
21277a3b38f7Smrg	exit $EXIT_SUCCESS
21287a3b38f7Smrg	;;
2129ff559fabSmrg
21307a3b38f7Smrg      *)
21317a3b38f7Smrg	# Figure out destination file name, if it wasn't already specified.
21327a3b38f7Smrg	if test -n "$destname"; then
21337a3b38f7Smrg	  destfile="$destdir/$destname"
21347a3b38f7Smrg	else
21357a3b38f7Smrg	  func_basename "$file"
21367a3b38f7Smrg	  destfile="$func_basename_result"
21377a3b38f7Smrg	  destfile="$destdir/$destfile"
21387a3b38f7Smrg	fi
21397a3b38f7Smrg
21407a3b38f7Smrg	# If the file is missing, and there is a .exe on the end, strip it
21417a3b38f7Smrg	# because it is most likely a libtool script we actually want to
21427a3b38f7Smrg	# install
21437a3b38f7Smrg	stripped_ext=""
21447a3b38f7Smrg	case $file in
21457a3b38f7Smrg	  *.exe)
21467a3b38f7Smrg	    if test ! -f "$file"; then
21477a3b38f7Smrg	      func_stripname '' '.exe' "$file"
21487a3b38f7Smrg	      file=$func_stripname_result
21497a3b38f7Smrg	      stripped_ext=".exe"
2150ff559fabSmrg	    fi
21517a3b38f7Smrg	    ;;
21527a3b38f7Smrg	esac
2153ff559fabSmrg
21547a3b38f7Smrg	# Do a test to see if this is really a libtool program.
21557a3b38f7Smrg	case $host in
21567a3b38f7Smrg	*cygwin* | *mingw*)
21577a3b38f7Smrg	    if func_ltwrapper_executable_p "$file"; then
21587a3b38f7Smrg	      func_ltwrapper_scriptname "$file"
21597a3b38f7Smrg	      wrapper=$func_ltwrapper_scriptname_result
21607a3b38f7Smrg	    else
21617a3b38f7Smrg	      func_stripname '' '.exe' "$file"
21627a3b38f7Smrg	      wrapper=$func_stripname_result
21637a3b38f7Smrg	    fi
21647a3b38f7Smrg	    ;;
21657a3b38f7Smrg	*)
21667a3b38f7Smrg	    wrapper=$file
21677a3b38f7Smrg	    ;;
21687a3b38f7Smrg	esac
21697a3b38f7Smrg	if func_ltwrapper_script_p "$wrapper"; then
21707a3b38f7Smrg	  notinst_deplibs=
21717a3b38f7Smrg	  relink_command=
2172ff559fabSmrg
21737a3b38f7Smrg	  func_source "$wrapper"
2174ff559fabSmrg
21757a3b38f7Smrg	  # Check the variables that should have been set.
21767a3b38f7Smrg	  test -z "$generated_by_libtool_version" && \
21777a3b38f7Smrg	    func_fatal_error "invalid libtool wrapper script \`$wrapper'"
21787a3b38f7Smrg
21797a3b38f7Smrg	  finalize=yes
21807a3b38f7Smrg	  for lib in $notinst_deplibs; do
21817a3b38f7Smrg	    # Check to see that each library is installed.
21827a3b38f7Smrg	    libdir=
21837a3b38f7Smrg	    if test -f "$lib"; then
21847a3b38f7Smrg	      func_source "$lib"
21857a3b38f7Smrg	    fi
21867a3b38f7Smrg	    libfile="$libdir/"`$ECHO "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test
21877a3b38f7Smrg	    if test -n "$libdir" && test ! -f "$libfile"; then
21887a3b38f7Smrg	      func_warning "\`$lib' has not been installed in \`$libdir'"
21897a3b38f7Smrg	      finalize=no
21907a3b38f7Smrg	    fi
21917a3b38f7Smrg	  done
21927a3b38f7Smrg
21937a3b38f7Smrg	  relink_command=
21947a3b38f7Smrg	  func_source "$wrapper"
21957a3b38f7Smrg
21967a3b38f7Smrg	  outputname=
21977a3b38f7Smrg	  if test "$fast_install" = no && test -n "$relink_command"; then
21987a3b38f7Smrg	    $opt_dry_run || {
21997a3b38f7Smrg	      if test "$finalize" = yes; then
22007a3b38f7Smrg	        tmpdir=`func_mktempdir`
22017a3b38f7Smrg		func_basename "$file$stripped_ext"
22027a3b38f7Smrg		file="$func_basename_result"
22037a3b38f7Smrg	        outputname="$tmpdir/$file"
22047a3b38f7Smrg	        # Replace the output file specification.
22057a3b38f7Smrg	        relink_command=`$ECHO "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'`
22067a3b38f7Smrg
22077a3b38f7Smrg	        $opt_silent || {
22087a3b38f7Smrg	          func_quote_for_expand "$relink_command"
22097a3b38f7Smrg		  eval "func_echo $func_quote_for_expand_result"
22107a3b38f7Smrg	        }
22117a3b38f7Smrg	        if eval "$relink_command"; then :
22127a3b38f7Smrg	          else
22137a3b38f7Smrg		  func_error "error: relink \`$file' with the above command before installing it"
22147a3b38f7Smrg		  $opt_dry_run || ${RM}r "$tmpdir"
22157a3b38f7Smrg		  continue
22167a3b38f7Smrg	        fi
22177a3b38f7Smrg	        file="$outputname"
22187a3b38f7Smrg	      else
22197a3b38f7Smrg	        func_warning "cannot relink \`$file'"
22207a3b38f7Smrg	      fi
22217a3b38f7Smrg	    }
2222ff559fabSmrg	  else
22237a3b38f7Smrg	    # Install the binary that we compiled earlier.
22247a3b38f7Smrg	    file=`$ECHO "X$file$stripped_ext" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"`
2225ff559fabSmrg	  fi
22267a3b38f7Smrg	fi
2227ff559fabSmrg
22287a3b38f7Smrg	# remove .exe since cygwin /usr/bin/install will append another
22297a3b38f7Smrg	# one anyway
22307a3b38f7Smrg	case $install_prog,$host in
22317a3b38f7Smrg	*/usr/bin/install*,*cygwin*)
22327a3b38f7Smrg	  case $file:$destfile in
22337a3b38f7Smrg	  *.exe:*.exe)
22347a3b38f7Smrg	    # this is ok
22357a3b38f7Smrg	    ;;
22367a3b38f7Smrg	  *.exe:*)
22377a3b38f7Smrg	    destfile=$destfile.exe
22387a3b38f7Smrg	    ;;
22397a3b38f7Smrg	  *:*.exe)
22407a3b38f7Smrg	    func_stripname '' '.exe' "$destfile"
22417a3b38f7Smrg	    destfile=$func_stripname_result
22427a3b38f7Smrg	    ;;
22437a3b38f7Smrg	  esac
2244ff559fabSmrg	  ;;
2245ff559fabSmrg	esac
22467a3b38f7Smrg	func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
22477a3b38f7Smrg	$opt_dry_run || if test -n "$outputname"; then
22487a3b38f7Smrg	  ${RM}r "$tmpdir"
22497a3b38f7Smrg	fi
22507a3b38f7Smrg	;;
22517a3b38f7Smrg      esac
22527a3b38f7Smrg    done
2253ff559fabSmrg
22547a3b38f7Smrg    for file in $staticlibs; do
22557a3b38f7Smrg      func_basename "$file"
22567a3b38f7Smrg      name="$func_basename_result"
2257ff559fabSmrg
22587a3b38f7Smrg      # Set up the ranlib parameters.
22597a3b38f7Smrg      oldlib="$destdir/$name"
2260ff559fabSmrg
22617a3b38f7Smrg      func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
2262ff559fabSmrg
22637a3b38f7Smrg      if test -n "$stripme" && test -n "$old_striplib"; then
22647a3b38f7Smrg	func_show_eval "$old_striplib $oldlib" 'exit $?'
22657a3b38f7Smrg      fi
2266ff559fabSmrg
22677a3b38f7Smrg      # Do each command in the postinstall commands.
22687a3b38f7Smrg      func_execute_cmds "$old_postinstall_cmds" 'exit $?'
22697a3b38f7Smrg    done
2270ff559fabSmrg
22717a3b38f7Smrg    test -n "$future_libdirs" && \
22727a3b38f7Smrg      func_warning "remember to run \`$progname --finish$future_libdirs'"
2273ff559fabSmrg
22747a3b38f7Smrg    if test -n "$current_libdirs"; then
22757a3b38f7Smrg      # Maybe just do a dry run.
22767a3b38f7Smrg      $opt_dry_run && current_libdirs=" -n$current_libdirs"
22777a3b38f7Smrg      exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
22787a3b38f7Smrg    else
22797a3b38f7Smrg      exit $EXIT_SUCCESS
22807a3b38f7Smrg    fi
22817a3b38f7Smrg}
2282ff559fabSmrg
22837a3b38f7Smrgtest "$mode" = install && func_mode_install ${1+"$@"}
2284ff559fabSmrg
2285ff559fabSmrg
22867a3b38f7Smrg# func_generate_dlsyms outputname originator pic_p
22877a3b38f7Smrg# Extract symbols from dlprefiles and create ${outputname}S.o with
22887a3b38f7Smrg# a dlpreopen symbol table.
22897a3b38f7Smrgfunc_generate_dlsyms ()
22907a3b38f7Smrg{
22917a3b38f7Smrg    $opt_debug
22927a3b38f7Smrg    my_outputname="$1"
22937a3b38f7Smrg    my_originator="$2"
22947a3b38f7Smrg    my_pic_p="${3-no}"
22957a3b38f7Smrg    my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'`
22967a3b38f7Smrg    my_dlsyms=
22977a3b38f7Smrg
22987a3b38f7Smrg    if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
22997a3b38f7Smrg      if test -n "$NM" && test -n "$global_symbol_pipe"; then
23007a3b38f7Smrg	my_dlsyms="${my_outputname}S.c"
23017a3b38f7Smrg      else
23027a3b38f7Smrg	func_error "not configured to extract global symbols from dlpreopened files"
23037a3b38f7Smrg      fi
23047a3b38f7Smrg    fi
2305ff559fabSmrg
23067a3b38f7Smrg    if test -n "$my_dlsyms"; then
23077a3b38f7Smrg      case $my_dlsyms in
23087a3b38f7Smrg      "") ;;
23097a3b38f7Smrg      *.c)
23107a3b38f7Smrg	# Discover the nlist of each of the dlfiles.
23117a3b38f7Smrg	nlist="$output_objdir/${my_outputname}.nm"
23127a3b38f7Smrg
23137a3b38f7Smrg	func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
23147a3b38f7Smrg
23157a3b38f7Smrg	# Parse the name list into a source file.
23167a3b38f7Smrg	func_verbose "creating $output_objdir/$my_dlsyms"
23177a3b38f7Smrg
23187a3b38f7Smrg	$opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
23197a3b38f7Smrg/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */
23207a3b38f7Smrg/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */
23217a3b38f7Smrg
23227a3b38f7Smrg#ifdef __cplusplus
23237a3b38f7Smrgextern \"C\" {
23247a3b38f7Smrg#endif
23257a3b38f7Smrg
23267a3b38f7Smrg/* External symbol declarations for the compiler. */\
23277a3b38f7Smrg"
23287a3b38f7Smrg
23297a3b38f7Smrg	if test "$dlself" = yes; then
23307a3b38f7Smrg	  func_verbose "generating symbol list for \`$output'"
23317a3b38f7Smrg
23327a3b38f7Smrg	  $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
23337a3b38f7Smrg
23347a3b38f7Smrg	  # Add our own program objects to the symbol list.
23357a3b38f7Smrg	  progfiles=`$ECHO "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
23367a3b38f7Smrg	  for progfile in $progfiles; do
23377a3b38f7Smrg	    func_verbose "extracting global C symbols from \`$progfile'"
23387a3b38f7Smrg	    $opt_dry_run || eval "$NM $progfile | $global_symbol_pipe >> '$nlist'"
23397a3b38f7Smrg	  done
23407a3b38f7Smrg
23417a3b38f7Smrg	  if test -n "$exclude_expsyms"; then
23427a3b38f7Smrg	    $opt_dry_run || {
23437a3b38f7Smrg	      eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
23447a3b38f7Smrg	      eval '$MV "$nlist"T "$nlist"'
23457a3b38f7Smrg	    }
2346ff559fabSmrg	  fi
2347ff559fabSmrg
23487a3b38f7Smrg	  if test -n "$export_symbols_regex"; then
23497a3b38f7Smrg	    $opt_dry_run || {
23507a3b38f7Smrg	      eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
23517a3b38f7Smrg	      eval '$MV "$nlist"T "$nlist"'
23527a3b38f7Smrg	    }
2353ff559fabSmrg	  fi
23547a3b38f7Smrg
23557a3b38f7Smrg	  # Prepare the list of exported symbols
23567a3b38f7Smrg	  if test -z "$export_symbols"; then
23577a3b38f7Smrg	    export_symbols="$output_objdir/$outputname.exp"
23587a3b38f7Smrg	    $opt_dry_run || {
23597a3b38f7Smrg	      $RM $export_symbols
23607a3b38f7Smrg	      eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
23617a3b38f7Smrg	      case $host in
23627a3b38f7Smrg	      *cygwin* | *mingw* | *cegcc* )
23637a3b38f7Smrg                eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
23647a3b38f7Smrg                eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
23657a3b38f7Smrg	        ;;
2366ff559fabSmrg	      esac
23677a3b38f7Smrg	    }
23687a3b38f7Smrg	  else
23697a3b38f7Smrg	    $opt_dry_run || {
23707a3b38f7Smrg	      eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
23717a3b38f7Smrg	      eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
23727a3b38f7Smrg	      eval '$MV "$nlist"T "$nlist"'
23737a3b38f7Smrg	      case $host in
23747a3b38f7Smrg	        *cygwin | *mingw* | *cegcc* )
23757a3b38f7Smrg	          eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
23767a3b38f7Smrg	          eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
23777a3b38f7Smrg	          ;;
2378ff559fabSmrg	      esac
23797a3b38f7Smrg	    }
2380ff559fabSmrg	  fi
23817a3b38f7Smrg	fi
2382ff559fabSmrg
23837a3b38f7Smrg	for dlprefile in $dlprefiles; do
23847a3b38f7Smrg	  func_verbose "extracting global C symbols from \`$dlprefile'"
23857a3b38f7Smrg	  func_basename "$dlprefile"
23867a3b38f7Smrg	  name="$func_basename_result"
23877a3b38f7Smrg	  $opt_dry_run || {
23887a3b38f7Smrg	    eval '$ECHO ": $name " >> "$nlist"'
23897a3b38f7Smrg	    eval "$NM $dlprefile 2>/dev/null | $global_symbol_pipe >> '$nlist'"
23907a3b38f7Smrg	  }
23917a3b38f7Smrg	done
2392ff559fabSmrg
23937a3b38f7Smrg	$opt_dry_run || {
23947a3b38f7Smrg	  # Make sure we have at least an empty file.
23957a3b38f7Smrg	  test -f "$nlist" || : > "$nlist"
2396ff559fabSmrg
23977a3b38f7Smrg	  if test -n "$exclude_expsyms"; then
23987a3b38f7Smrg	    $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
23997a3b38f7Smrg	    $MV "$nlist"T "$nlist"
2400ff559fabSmrg	  fi
2401ff559fabSmrg
24027a3b38f7Smrg	  # Try sorting and uniquifying the output.
24037a3b38f7Smrg	  if $GREP -v "^: " < "$nlist" |
24047a3b38f7Smrg	      if sort -k 3 </dev/null >/dev/null 2>&1; then
24057a3b38f7Smrg		sort -k 3
2406ff559fabSmrg	      else
24077a3b38f7Smrg		sort +2
24087a3b38f7Smrg	      fi |
24097a3b38f7Smrg	      uniq > "$nlist"S; then
24107a3b38f7Smrg	    :
2411ff559fabSmrg	  else
24127a3b38f7Smrg	    $GREP -v "^: " < "$nlist" > "$nlist"S
2413ff559fabSmrg	  fi
2414ff559fabSmrg
24157a3b38f7Smrg	  if test -f "$nlist"S; then
24167a3b38f7Smrg	    eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
2417ff559fabSmrg	  else
24187a3b38f7Smrg	    $ECHO '/* NONE */' >> "$output_objdir/$my_dlsyms"
2419ff559fabSmrg	  fi
2420ff559fabSmrg
24217a3b38f7Smrg	  $ECHO >> "$output_objdir/$my_dlsyms" "\
2422ff559fabSmrg
24237a3b38f7Smrg/* The mapping between symbol names and symbols.  */
24247a3b38f7Smrgtypedef struct {
24257a3b38f7Smrg  const char *name;
24267a3b38f7Smrg  void *address;
24277a3b38f7Smrg} lt_dlsymlist;
24287a3b38f7Smrg"
24297a3b38f7Smrg	  case $host in
24307a3b38f7Smrg	  *cygwin* | *mingw* | *cegcc* )
24317a3b38f7Smrg	    $ECHO >> "$output_objdir/$my_dlsyms" "\
24327a3b38f7Smrg/* DATA imports from DLLs on WIN32 con't be const, because
24337a3b38f7Smrg   runtime relocations are performed -- see ld's documentation
24347a3b38f7Smrg   on pseudo-relocs.  */"
24357a3b38f7Smrg	    lt_dlsym_const= ;;
24367a3b38f7Smrg	  *osf5*)
24377a3b38f7Smrg	    echo >> "$output_objdir/$my_dlsyms" "\
24387a3b38f7Smrg/* This system does not cope well with relocations in const data */"
24397a3b38f7Smrg	    lt_dlsym_const= ;;
24407a3b38f7Smrg	  *)
24417a3b38f7Smrg	    lt_dlsym_const=const ;;
24427a3b38f7Smrg	  esac
24437a3b38f7Smrg
24447a3b38f7Smrg	  $ECHO >> "$output_objdir/$my_dlsyms" "\
24457a3b38f7Smrgextern $lt_dlsym_const lt_dlsymlist
24467a3b38f7Smrglt_${my_prefix}_LTX_preloaded_symbols[];
24477a3b38f7Smrg$lt_dlsym_const lt_dlsymlist
24487a3b38f7Smrglt_${my_prefix}_LTX_preloaded_symbols[] =
24497a3b38f7Smrg{\
24507a3b38f7Smrg  { \"$my_originator\", (void *) 0 },"
24517a3b38f7Smrg
24527a3b38f7Smrg	  case $need_lib_prefix in
24537a3b38f7Smrg	  no)
24547a3b38f7Smrg	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
24557a3b38f7Smrg	    ;;
24567a3b38f7Smrg	  *)
24577a3b38f7Smrg	    eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
24587a3b38f7Smrg	    ;;
24597a3b38f7Smrg	  esac
24607a3b38f7Smrg	  $ECHO >> "$output_objdir/$my_dlsyms" "\
24617a3b38f7Smrg  {0, (void *) 0}
24627a3b38f7Smrg};
24637a3b38f7Smrg
24647a3b38f7Smrg/* This works around a problem in FreeBSD linker */
24657a3b38f7Smrg#ifdef FREEBSD_WORKAROUND
24667a3b38f7Smrgstatic const void *lt_preloaded_setup() {
24677a3b38f7Smrg  return lt_${my_prefix}_LTX_preloaded_symbols;
24687a3b38f7Smrg}
24697a3b38f7Smrg#endif
24707a3b38f7Smrg
24717a3b38f7Smrg#ifdef __cplusplus
24727a3b38f7Smrg}
24737a3b38f7Smrg#endif\
24747a3b38f7Smrg"
24757a3b38f7Smrg	} # !$opt_dry_run
24767a3b38f7Smrg
24777a3b38f7Smrg	pic_flag_for_symtable=
24787a3b38f7Smrg	case "$compile_command " in
24797a3b38f7Smrg	*" -static "*) ;;
24807a3b38f7Smrg	*)
24817a3b38f7Smrg	  case $host in
24827a3b38f7Smrg	  # compiling the symbol table file with pic_flag works around
24837a3b38f7Smrg	  # a FreeBSD bug that causes programs to crash when -lm is
24847a3b38f7Smrg	  # linked before any other PIC object.  But we must not use
24857a3b38f7Smrg	  # pic_flag when linking with -static.  The problem exists in
24867a3b38f7Smrg	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
24877a3b38f7Smrg	  *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
24887a3b38f7Smrg	    pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
24897a3b38f7Smrg	  *-*-hpux*)
24907a3b38f7Smrg	    pic_flag_for_symtable=" $pic_flag"  ;;
24917a3b38f7Smrg	  *)
24927a3b38f7Smrg	    if test "X$my_pic_p" != Xno; then
24937a3b38f7Smrg	      pic_flag_for_symtable=" $pic_flag"
2494ff559fabSmrg	    fi
24957a3b38f7Smrg	    ;;
24967a3b38f7Smrg	  esac
24977a3b38f7Smrg	  ;;
24987a3b38f7Smrg	esac
24997a3b38f7Smrg	symtab_cflags=
25007a3b38f7Smrg	for arg in $LTCFLAGS; do
25017a3b38f7Smrg	  case $arg in
25027a3b38f7Smrg	  -pie | -fpie | -fPIE) ;;
25037a3b38f7Smrg	  *) symtab_cflags="$symtab_cflags $arg" ;;
25047a3b38f7Smrg	  esac
25057a3b38f7Smrg	done
2506ff559fabSmrg
25077a3b38f7Smrg	# Now compile the dynamic symbol file.
25087a3b38f7Smrg	func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
2509ff559fabSmrg
25107a3b38f7Smrg	# Clean up the generated files.
25117a3b38f7Smrg	func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"'
25127a3b38f7Smrg
25137a3b38f7Smrg	# Transform the symbol file into the correct name.
25147a3b38f7Smrg	symfileobj="$output_objdir/${my_outputname}S.$objext"
25157a3b38f7Smrg	case $host in
25167a3b38f7Smrg	*cygwin* | *mingw* | *cegcc* )
25177a3b38f7Smrg	  if test -f "$output_objdir/$my_outputname.def"; then
25187a3b38f7Smrg	    compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
25197a3b38f7Smrg	    finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
25207a3b38f7Smrg	  else
25217a3b38f7Smrg	    compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
25227a3b38f7Smrg	    finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
25237a3b38f7Smrg	  fi
25247a3b38f7Smrg	  ;;
25257a3b38f7Smrg	*)
25267a3b38f7Smrg	  compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
25277a3b38f7Smrg	  finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
2528ff559fabSmrg	  ;;
2529ff559fabSmrg	esac
25307a3b38f7Smrg	;;
25317a3b38f7Smrg      *)
25327a3b38f7Smrg	func_fatal_error "unknown suffix for \`$my_dlsyms'"
25337a3b38f7Smrg	;;
25347a3b38f7Smrg      esac
25357a3b38f7Smrg    else
25367a3b38f7Smrg      # We keep going just in case the user didn't refer to
25377a3b38f7Smrg      # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
25387a3b38f7Smrg      # really was required.
25397a3b38f7Smrg
25407a3b38f7Smrg      # Nullify the symbol file.
25417a3b38f7Smrg      compile_command=`$ECHO "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"`
25427a3b38f7Smrg      finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"`
2543ff559fabSmrg    fi
25447a3b38f7Smrg}
2545ff559fabSmrg
25467a3b38f7Smrg# func_win32_libid arg
25477a3b38f7Smrg# return the library type of file 'arg'
25487a3b38f7Smrg#
25497a3b38f7Smrg# Need a lot of goo to handle *both* DLLs and import libs
25507a3b38f7Smrg# Has to be a shell function in order to 'eat' the argument
25517a3b38f7Smrg# that is supplied when $file_magic_command is called.
25527a3b38f7Smrgfunc_win32_libid ()
25537a3b38f7Smrg{
25547a3b38f7Smrg  $opt_debug
25557a3b38f7Smrg  win32_libid_type="unknown"
25567a3b38f7Smrg  win32_fileres=`file -L $1 2>/dev/null`
25577a3b38f7Smrg  case $win32_fileres in
25587a3b38f7Smrg  *ar\ archive\ import\ library*) # definitely import
25597a3b38f7Smrg    win32_libid_type="x86 archive import"
25607a3b38f7Smrg    ;;
25617a3b38f7Smrg  *ar\ archive*) # could be an import, or static
25627a3b38f7Smrg    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
25637a3b38f7Smrg       $EGREP 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
25647a3b38f7Smrg      win32_nmres=`eval $NM -f posix -A $1 |
25657a3b38f7Smrg	$SED -n -e '
25667a3b38f7Smrg	    1,100{
25677a3b38f7Smrg		/ I /{
25687a3b38f7Smrg		    s,.*,import,
25697a3b38f7Smrg		    p
25707a3b38f7Smrg		    q
25717a3b38f7Smrg		}
25727a3b38f7Smrg	    }'`
25737a3b38f7Smrg      case $win32_nmres in
25747a3b38f7Smrg      import*)  win32_libid_type="x86 archive import";;
25757a3b38f7Smrg      *)        win32_libid_type="x86 archive static";;
25767a3b38f7Smrg      esac
25777a3b38f7Smrg    fi
25787a3b38f7Smrg    ;;
25797a3b38f7Smrg  *DLL*)
25807a3b38f7Smrg    win32_libid_type="x86 DLL"
25817a3b38f7Smrg    ;;
25827a3b38f7Smrg  *executable*) # but shell scripts are "executable" too...
25837a3b38f7Smrg    case $win32_fileres in
25847a3b38f7Smrg    *MS\ Windows\ PE\ Intel*)
25857a3b38f7Smrg      win32_libid_type="x86 DLL"
25867a3b38f7Smrg      ;;
25877a3b38f7Smrg    esac
25887a3b38f7Smrg    ;;
25897a3b38f7Smrg  esac
25907a3b38f7Smrg  $ECHO "$win32_libid_type"
25917a3b38f7Smrg}
2592ff559fabSmrg
2593ff559fabSmrg
2594ff559fabSmrg
25957a3b38f7Smrg# func_extract_an_archive dir oldlib
25967a3b38f7Smrgfunc_extract_an_archive ()
25977a3b38f7Smrg{
25987a3b38f7Smrg    $opt_debug
25997a3b38f7Smrg    f_ex_an_ar_dir="$1"; shift
26007a3b38f7Smrg    f_ex_an_ar_oldlib="$1"
26017a3b38f7Smrg    func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" 'exit $?'
26027a3b38f7Smrg    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
26037a3b38f7Smrg     :
26047a3b38f7Smrg    else
26057a3b38f7Smrg      func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
26067a3b38f7Smrg    fi
26077a3b38f7Smrg}
2608ff559fabSmrg
2609ff559fabSmrg
26107a3b38f7Smrg# func_extract_archives gentop oldlib ...
26117a3b38f7Smrgfunc_extract_archives ()
26127a3b38f7Smrg{
26137a3b38f7Smrg    $opt_debug
26147a3b38f7Smrg    my_gentop="$1"; shift
26157a3b38f7Smrg    my_oldlibs=${1+"$@"}
26167a3b38f7Smrg    my_oldobjs=""
26177a3b38f7Smrg    my_xlib=""
26187a3b38f7Smrg    my_xabs=""
26197a3b38f7Smrg    my_xdir=""
2620ff559fabSmrg
26217a3b38f7Smrg    for my_xlib in $my_oldlibs; do
26227a3b38f7Smrg      # Extract the objects.
26237a3b38f7Smrg      case $my_xlib in
26247a3b38f7Smrg	[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
26257a3b38f7Smrg	*) my_xabs=`pwd`"/$my_xlib" ;;
26267a3b38f7Smrg      esac
26277a3b38f7Smrg      func_basename "$my_xlib"
26287a3b38f7Smrg      my_xlib="$func_basename_result"
26297a3b38f7Smrg      my_xlib_u=$my_xlib
26307a3b38f7Smrg      while :; do
26317a3b38f7Smrg        case " $extracted_archives " in
26327a3b38f7Smrg	*" $my_xlib_u "*)
26337a3b38f7Smrg	  func_arith $extracted_serial + 1
26347a3b38f7Smrg	  extracted_serial=$func_arith_result
26357a3b38f7Smrg	  my_xlib_u=lt$extracted_serial-$my_xlib ;;
26367a3b38f7Smrg	*) break ;;
26377a3b38f7Smrg	esac
26387a3b38f7Smrg      done
26397a3b38f7Smrg      extracted_archives="$extracted_archives $my_xlib_u"
26407a3b38f7Smrg      my_xdir="$my_gentop/$my_xlib_u"
2641ff559fabSmrg
26427a3b38f7Smrg      func_mkdir_p "$my_xdir"
2643ff559fabSmrg
26447a3b38f7Smrg      case $host in
26457a3b38f7Smrg      *-darwin*)
26467a3b38f7Smrg	func_verbose "Extracting $my_xabs"
26477a3b38f7Smrg	# Do not bother doing anything if just a dry run
26487a3b38f7Smrg	$opt_dry_run || {
26497a3b38f7Smrg	  darwin_orig_dir=`pwd`
26507a3b38f7Smrg	  cd $my_xdir || exit $?
26517a3b38f7Smrg	  darwin_archive=$my_xabs
26527a3b38f7Smrg	  darwin_curdir=`pwd`
26537a3b38f7Smrg	  darwin_base_archive=`basename "$darwin_archive"`
26547a3b38f7Smrg	  darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
26557a3b38f7Smrg	  if test -n "$darwin_arches"; then
26567a3b38f7Smrg	    darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
26577a3b38f7Smrg	    darwin_arch=
26587a3b38f7Smrg	    func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
26597a3b38f7Smrg	    for darwin_arch in  $darwin_arches ; do
26607a3b38f7Smrg	      func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
26617a3b38f7Smrg	      $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
26627a3b38f7Smrg	      cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
26637a3b38f7Smrg	      func_extract_an_archive "`pwd`" "${darwin_base_archive}"
26647a3b38f7Smrg	      cd "$darwin_curdir"
26657a3b38f7Smrg	      $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
26667a3b38f7Smrg	    done # $darwin_arches
26677a3b38f7Smrg            ## Okay now we've a bunch of thin objects, gotta fatten them up :)
26687a3b38f7Smrg	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u`
26697a3b38f7Smrg	    darwin_file=
26707a3b38f7Smrg	    darwin_files=
26717a3b38f7Smrg	    for darwin_file in $darwin_filelist; do
26727a3b38f7Smrg	      darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP`
26737a3b38f7Smrg	      $LIPO -create -output "$darwin_file" $darwin_files
26747a3b38f7Smrg	    done # $darwin_filelist
26757a3b38f7Smrg	    $RM -rf unfat-$$
26767a3b38f7Smrg	    cd "$darwin_orig_dir"
26777a3b38f7Smrg	  else
26787a3b38f7Smrg	    cd $darwin_orig_dir
26797a3b38f7Smrg	    func_extract_an_archive "$my_xdir" "$my_xabs"
26807a3b38f7Smrg	  fi # $darwin_arches
26817a3b38f7Smrg	} # !$opt_dry_run
26827a3b38f7Smrg	;;
26837a3b38f7Smrg      *)
26847a3b38f7Smrg        func_extract_an_archive "$my_xdir" "$my_xabs"
26857a3b38f7Smrg	;;
2686ff559fabSmrg      esac
26877a3b38f7Smrg      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
26887a3b38f7Smrg    done
2689ff559fabSmrg
26907a3b38f7Smrg    func_extract_archives_result="$my_oldobjs"
26917a3b38f7Smrg}
2692ff559fabSmrg
2693ff559fabSmrg
2694ff559fabSmrg
26957a3b38f7Smrg# func_emit_wrapper_part1 [arg=no]
26967a3b38f7Smrg#
26977a3b38f7Smrg# Emit the first part of a libtool wrapper script on stdout.
26987a3b38f7Smrg# For more information, see the description associated with
26997a3b38f7Smrg# func_emit_wrapper(), below.
27007a3b38f7Smrgfunc_emit_wrapper_part1 ()
27017a3b38f7Smrg{
27027a3b38f7Smrg	func_emit_wrapper_part1_arg1=no
27037a3b38f7Smrg	if test -n "$1" ; then
27047a3b38f7Smrg	  func_emit_wrapper_part1_arg1=$1
2705ff559fabSmrg	fi
2706ff559fabSmrg
27077a3b38f7Smrg	$ECHO "\
27087a3b38f7Smrg#! $SHELL
2709ff559fabSmrg
27107a3b38f7Smrg# $output - temporary wrapper script for $objdir/$outputname
27117a3b38f7Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
27127a3b38f7Smrg#
27137a3b38f7Smrg# The $output program cannot be directly executed until all the libtool
27147a3b38f7Smrg# libraries that it depends on are installed.
27157a3b38f7Smrg#
27167a3b38f7Smrg# This wrapper script should never be moved out of the build directory.
27177a3b38f7Smrg# If it is, it will not operate correctly.
2718ff559fabSmrg
27197a3b38f7Smrg# Sed substitution that helps us do robust quoting.  It backslashifies
27207a3b38f7Smrg# metacharacters that are still active within double-quoted strings.
27217a3b38f7SmrgXsed='${SED} -e 1s/^X//'
27227a3b38f7Smrgsed_quote_subst='$sed_quote_subst'
2723ff559fabSmrg
27247a3b38f7Smrg# Be Bourne compatible
27257a3b38f7Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
27267a3b38f7Smrg  emulate sh
27277a3b38f7Smrg  NULLCMD=:
27287a3b38f7Smrg  # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
27297a3b38f7Smrg  # is contrary to our usage.  Disable this feature.
27307a3b38f7Smrg  alias -g '\${1+\"\$@\"}'='\"\$@\"'
27317a3b38f7Smrg  setopt NO_GLOB_SUBST
27327a3b38f7Smrgelse
27337a3b38f7Smrg  case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
27347a3b38f7Smrgfi
27357a3b38f7SmrgBIN_SH=xpg4; export BIN_SH # for Tru64
27367a3b38f7SmrgDUALCASE=1; export DUALCASE # for MKS sh
2737ff559fabSmrg
27387a3b38f7Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout
27397a3b38f7Smrg# if CDPATH is set.
27407a3b38f7Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
2741ff559fabSmrg
27427a3b38f7Smrgrelink_command=\"$relink_command\"
2743ff559fabSmrg
27447a3b38f7Smrg# This environment variable determines our operation mode.
27457a3b38f7Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then
27467a3b38f7Smrg  # install mode needs the following variables:
27477a3b38f7Smrg  generated_by_libtool_version='$macro_version'
27487a3b38f7Smrg  notinst_deplibs='$notinst_deplibs'
27497a3b38f7Smrgelse
27507a3b38f7Smrg  # When we are sourced in execute mode, \$file and \$ECHO are already set.
27517a3b38f7Smrg  if test \"\$libtool_execute_magic\" != \"$magic\"; then
27527a3b38f7Smrg    ECHO=\"$qecho\"
27537a3b38f7Smrg    file=\"\$0\"
27547a3b38f7Smrg    # Make sure echo works.
27557a3b38f7Smrg    if test \"X\$1\" = X--no-reexec; then
27567a3b38f7Smrg      # Discard the --no-reexec flag, and continue.
27577a3b38f7Smrg      shift
27587a3b38f7Smrg    elif test \"X\`{ \$ECHO '\t'; } 2>/dev/null\`\" = 'X\t'; then
27597a3b38f7Smrg      # Yippee, \$ECHO works!
27607a3b38f7Smrg      :
27617a3b38f7Smrg    else
27627a3b38f7Smrg      # Restart under the correct shell, and then maybe \$ECHO will work.
27637a3b38f7Smrg      exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"}
27647a3b38f7Smrg    fi
27657a3b38f7Smrg  fi\
27667a3b38f7Smrg"
27677a3b38f7Smrg	$ECHO "\
2768ff559fabSmrg
27697a3b38f7Smrg  # Find the directory that this script lives in.
27707a3b38f7Smrg  thisdir=\`\$ECHO \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\`
27717a3b38f7Smrg  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
2772ff559fabSmrg
27737a3b38f7Smrg  # Follow symbolic links until we get to the real thisdir.
27747a3b38f7Smrg  file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\`
27757a3b38f7Smrg  while test -n \"\$file\"; do
27767a3b38f7Smrg    destdir=\`\$ECHO \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\`
2777ff559fabSmrg
27787a3b38f7Smrg    # If there was a directory component, then change thisdir.
27797a3b38f7Smrg    if test \"x\$destdir\" != \"x\$file\"; then
27807a3b38f7Smrg      case \"\$destdir\" in
27817a3b38f7Smrg      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
27827a3b38f7Smrg      *) thisdir=\"\$thisdir/\$destdir\" ;;
27837a3b38f7Smrg      esac
27847a3b38f7Smrg    fi
2785ff559fabSmrg
27867a3b38f7Smrg    file=\`\$ECHO \"X\$file\" | \$Xsed -e 's%^.*/%%'\`
27877a3b38f7Smrg    file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\`
27887a3b38f7Smrg  done
27897a3b38f7Smrg"
27907a3b38f7Smrg}
27917a3b38f7Smrg# end: func_emit_wrapper_part1
2792ff559fabSmrg
27937a3b38f7Smrg# func_emit_wrapper_part2 [arg=no]
27947a3b38f7Smrg#
27957a3b38f7Smrg# Emit the second part of a libtool wrapper script on stdout.
27967a3b38f7Smrg# For more information, see the description associated with
27977a3b38f7Smrg# func_emit_wrapper(), below.
27987a3b38f7Smrgfunc_emit_wrapper_part2 ()
27997a3b38f7Smrg{
28007a3b38f7Smrg	func_emit_wrapper_part2_arg1=no
28017a3b38f7Smrg	if test -n "$1" ; then
28027a3b38f7Smrg	  func_emit_wrapper_part2_arg1=$1
28037a3b38f7Smrg	fi
2804ff559fabSmrg
28057a3b38f7Smrg	$ECHO "\
2806ff559fabSmrg
28077a3b38f7Smrg  # Usually 'no', except on cygwin/mingw when embedded into
28087a3b38f7Smrg  # the cwrapper.
28097a3b38f7Smrg  WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_part2_arg1
28107a3b38f7Smrg  if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
28117a3b38f7Smrg    # special case for '.'
28127a3b38f7Smrg    if test \"\$thisdir\" = \".\"; then
28137a3b38f7Smrg      thisdir=\`pwd\`
28147a3b38f7Smrg    fi
28157a3b38f7Smrg    # remove .libs from thisdir
28167a3b38f7Smrg    case \"\$thisdir\" in
28177a3b38f7Smrg    *[\\\\/]$objdir ) thisdir=\`\$ECHO \"X\$thisdir\" | \$Xsed -e 's%[\\\\/][^\\\\/]*$%%'\` ;;
28187a3b38f7Smrg    $objdir )   thisdir=. ;;
28197a3b38f7Smrg    esac
28207a3b38f7Smrg  fi
2821ff559fabSmrg
28227a3b38f7Smrg  # Try to get the absolute directory name.
28237a3b38f7Smrg  absdir=\`cd \"\$thisdir\" && pwd\`
28247a3b38f7Smrg  test -n \"\$absdir\" && thisdir=\"\$absdir\"
28257a3b38f7Smrg"
2826ff559fabSmrg
28277a3b38f7Smrg	if test "$fast_install" = yes; then
28287a3b38f7Smrg	  $ECHO "\
28297a3b38f7Smrg  program=lt-'$outputname'$exeext
28307a3b38f7Smrg  progdir=\"\$thisdir/$objdir\"
2831ff559fabSmrg
28327a3b38f7Smrg  if test ! -f \"\$progdir/\$program\" ||
28337a3b38f7Smrg     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
28347a3b38f7Smrg       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
2835ff559fabSmrg
28367a3b38f7Smrg    file=\"\$\$-\$program\"
2837ff559fabSmrg
28387a3b38f7Smrg    if test ! -d \"\$progdir\"; then
28397a3b38f7Smrg      $MKDIR \"\$progdir\"
28407a3b38f7Smrg    else
28417a3b38f7Smrg      $RM \"\$progdir/\$file\"
28427a3b38f7Smrg    fi"
2843ff559fabSmrg
28447a3b38f7Smrg	  $ECHO "\
2845ff559fabSmrg
28467a3b38f7Smrg    # relink executable if necessary
28477a3b38f7Smrg    if test -n \"\$relink_command\"; then
28487a3b38f7Smrg      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
28497a3b38f7Smrg      else
28507a3b38f7Smrg	$ECHO \"\$relink_command_output\" >&2
28517a3b38f7Smrg	$RM \"\$progdir/\$file\"
28527a3b38f7Smrg	exit 1
28537a3b38f7Smrg      fi
28547a3b38f7Smrg    fi
2855ff559fabSmrg
28567a3b38f7Smrg    $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
28577a3b38f7Smrg    { $RM \"\$progdir/\$program\";
28587a3b38f7Smrg      $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
28597a3b38f7Smrg    $RM \"\$progdir/\$file\"
28607a3b38f7Smrg  fi"
28617a3b38f7Smrg	else
28627a3b38f7Smrg	  $ECHO "\
28637a3b38f7Smrg  program='$outputname'
28647a3b38f7Smrg  progdir=\"\$thisdir/$objdir\"
28657a3b38f7Smrg"
28667a3b38f7Smrg	fi
2867ff559fabSmrg
28687a3b38f7Smrg	$ECHO "\
2869ff559fabSmrg
28707a3b38f7Smrg  if test -f \"\$progdir/\$program\"; then"
2871ff559fabSmrg
28727a3b38f7Smrg	# Export our shlibpath_var if we have one.
28737a3b38f7Smrg	if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
28747a3b38f7Smrg	  $ECHO "\
28757a3b38f7Smrg    # Add our own library path to $shlibpath_var
28767a3b38f7Smrg    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
2877ff559fabSmrg
28787a3b38f7Smrg    # Some systems cannot cope with colon-terminated $shlibpath_var
28797a3b38f7Smrg    # The second colon is a workaround for a bug in BeOS R4 sed
28807a3b38f7Smrg    $shlibpath_var=\`\$ECHO \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\`
2881ff559fabSmrg
28827a3b38f7Smrg    export $shlibpath_var
28837a3b38f7Smrg"
2884ff559fabSmrg	fi
2885ff559fabSmrg
28867a3b38f7Smrg	# fixup the dll searchpath if we need to.
28877a3b38f7Smrg	if test -n "$dllsearchpath"; then
28887a3b38f7Smrg	  $ECHO "\
28897a3b38f7Smrg    # Add the dll search path components to the executable PATH
28907a3b38f7Smrg    PATH=$dllsearchpath:\$PATH
28917a3b38f7Smrg"
2892ff559fabSmrg	fi
2893ff559fabSmrg
28947a3b38f7Smrg	$ECHO "\
28957a3b38f7Smrg    if test \"\$libtool_execute_magic\" != \"$magic\"; then
28967a3b38f7Smrg      # Run the actual program with our arguments.
28977a3b38f7Smrg"
28987a3b38f7Smrg	case $host in
28997a3b38f7Smrg	# Backslashes separate directories on plain windows
29007a3b38f7Smrg	*-*-mingw | *-*-os2* | *-cegcc*)
29017a3b38f7Smrg	  $ECHO "\
29027a3b38f7Smrg      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
29037a3b38f7Smrg"
29047a3b38f7Smrg	  ;;
29057a3b38f7Smrg
29067a3b38f7Smrg	*)
29077a3b38f7Smrg	  $ECHO "\
29087a3b38f7Smrg      exec \"\$progdir/\$program\" \${1+\"\$@\"}
29097a3b38f7Smrg"
29107a3b38f7Smrg	  ;;
29117a3b38f7Smrg	esac
29127a3b38f7Smrg	$ECHO "\
29137a3b38f7Smrg      \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
29147a3b38f7Smrg      exit 1
29157a3b38f7Smrg    fi
29167a3b38f7Smrg  else
29177a3b38f7Smrg    # The program doesn't exist.
29187a3b38f7Smrg    \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
29197a3b38f7Smrg    \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
29207a3b38f7Smrg    $ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
29217a3b38f7Smrg    exit 1
29227a3b38f7Smrg  fi
29237a3b38f7Smrgfi\
29247a3b38f7Smrg"
29257a3b38f7Smrg}
29267a3b38f7Smrg# end: func_emit_wrapper_part2
29277a3b38f7Smrg
29287a3b38f7Smrg
29297a3b38f7Smrg# func_emit_wrapper [arg=no]
29307a3b38f7Smrg#
29317a3b38f7Smrg# Emit a libtool wrapper script on stdout.
29327a3b38f7Smrg# Don't directly open a file because we may want to
29337a3b38f7Smrg# incorporate the script contents within a cygwin/mingw
29347a3b38f7Smrg# wrapper executable.  Must ONLY be called from within
29357a3b38f7Smrg# func_mode_link because it depends on a number of variables
29367a3b38f7Smrg# set therein.
29377a3b38f7Smrg#
29387a3b38f7Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
29397a3b38f7Smrg# variable will take.  If 'yes', then the emitted script
29407a3b38f7Smrg# will assume that the directory in which it is stored is
29417a3b38f7Smrg# the $objdir directory.  This is a cygwin/mingw-specific
29427a3b38f7Smrg# behavior.
29437a3b38f7Smrgfunc_emit_wrapper ()
29447a3b38f7Smrg{
29457a3b38f7Smrg	func_emit_wrapper_arg1=no
29467a3b38f7Smrg	if test -n "$1" ; then
29477a3b38f7Smrg	  func_emit_wrapper_arg1=$1
2948ff559fabSmrg	fi
2949ff559fabSmrg
29507a3b38f7Smrg	# split this up so that func_emit_cwrapperexe_src
29517a3b38f7Smrg	# can call each part independently.
29527a3b38f7Smrg	func_emit_wrapper_part1 "${func_emit_wrapper_arg1}"
29537a3b38f7Smrg	func_emit_wrapper_part2 "${func_emit_wrapper_arg1}"
29547a3b38f7Smrg}
2955ff559fabSmrg
2956ff559fabSmrg
29577a3b38f7Smrg# func_to_host_path arg
29587a3b38f7Smrg#
29597a3b38f7Smrg# Convert paths to host format when used with build tools.
29607a3b38f7Smrg# Intended for use with "native" mingw (where libtool itself
29617a3b38f7Smrg# is running under the msys shell), or in the following cross-
29627a3b38f7Smrg# build environments:
29637a3b38f7Smrg#    $build          $host
29647a3b38f7Smrg#    mingw (msys)    mingw  [e.g. native]
29657a3b38f7Smrg#    cygwin          mingw
29667a3b38f7Smrg#    *nix + wine     mingw
29677a3b38f7Smrg# where wine is equipped with the `winepath' executable.
29687a3b38f7Smrg# In the native mingw case, the (msys) shell automatically
29697a3b38f7Smrg# converts paths for any non-msys applications it launches,
29707a3b38f7Smrg# but that facility isn't available from inside the cwrapper.
29717a3b38f7Smrg# Similar accommodations are necessary for $host mingw and
29727a3b38f7Smrg# $build cygwin.  Calling this function does no harm for other
29737a3b38f7Smrg# $host/$build combinations not listed above.
29747a3b38f7Smrg#
29757a3b38f7Smrg# ARG is the path (on $build) that should be converted to
29767a3b38f7Smrg# the proper representation for $host. The result is stored
29777a3b38f7Smrg# in $func_to_host_path_result.
29787a3b38f7Smrgfunc_to_host_path ()
29797a3b38f7Smrg{
29807a3b38f7Smrg  func_to_host_path_result="$1"
29817a3b38f7Smrg  if test -n "$1" ; then
29827a3b38f7Smrg    case $host in
29837a3b38f7Smrg      *mingw* )
29847a3b38f7Smrg        lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
29857a3b38f7Smrg        case $build in
29867a3b38f7Smrg          *mingw* ) # actually, msys
29877a3b38f7Smrg            # awkward: cmd appends spaces to result
29887a3b38f7Smrg            lt_sed_strip_trailing_spaces="s/[ ]*\$//"
29897a3b38f7Smrg            func_to_host_path_tmp1=`( cmd //c echo "$1" |\
29907a3b38f7Smrg              $SED -e "$lt_sed_strip_trailing_spaces" ) 2>/dev/null || echo ""`
29917a3b38f7Smrg            func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\
29927a3b38f7Smrg              $SED -e "$lt_sed_naive_backslashify"`
29937a3b38f7Smrg            ;;
29947a3b38f7Smrg          *cygwin* )
29957a3b38f7Smrg            func_to_host_path_tmp1=`cygpath -w "$1"`
29967a3b38f7Smrg            func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\
29977a3b38f7Smrg              $SED -e "$lt_sed_naive_backslashify"`
29987a3b38f7Smrg            ;;
29997a3b38f7Smrg          * )
30007a3b38f7Smrg            # Unfortunately, winepath does not exit with a non-zero
30017a3b38f7Smrg            # error code, so we are forced to check the contents of
30027a3b38f7Smrg            # stdout. On the other hand, if the command is not
30037a3b38f7Smrg            # found, the shell will set an exit code of 127 and print
30047a3b38f7Smrg            # *an error message* to stdout. So we must check for both
30057a3b38f7Smrg            # error code of zero AND non-empty stdout, which explains
30067a3b38f7Smrg            # the odd construction:
30077a3b38f7Smrg            func_to_host_path_tmp1=`winepath -w "$1" 2>/dev/null`
30087a3b38f7Smrg            if test "$?" -eq 0 && test -n "${func_to_host_path_tmp1}"; then
30097a3b38f7Smrg              func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\
30107a3b38f7Smrg                $SED -e "$lt_sed_naive_backslashify"`
30117a3b38f7Smrg            else
30127a3b38f7Smrg              # Allow warning below.
30137a3b38f7Smrg              func_to_host_path_result=""
30147a3b38f7Smrg            fi
30157a3b38f7Smrg            ;;
30167a3b38f7Smrg        esac
30177a3b38f7Smrg        if test -z "$func_to_host_path_result" ; then
30187a3b38f7Smrg          func_error "Could not determine host path corresponding to"
30197a3b38f7Smrg          func_error "  '$1'"
30207a3b38f7Smrg          func_error "Continuing, but uninstalled executables may not work."
30217a3b38f7Smrg          # Fallback:
30227a3b38f7Smrg          func_to_host_path_result="$1"
30237a3b38f7Smrg        fi
30247a3b38f7Smrg        ;;
30257a3b38f7Smrg    esac
30267a3b38f7Smrg  fi
30277a3b38f7Smrg}
30287a3b38f7Smrg# end: func_to_host_path
3029ff559fabSmrg
30307a3b38f7Smrg# func_to_host_pathlist arg
30317a3b38f7Smrg#
30327a3b38f7Smrg# Convert pathlists to host format when used with build tools.
30337a3b38f7Smrg# See func_to_host_path(), above. This function supports the
30347a3b38f7Smrg# following $build/$host combinations (but does no harm for
30357a3b38f7Smrg# combinations not listed here):
30367a3b38f7Smrg#    $build          $host
30377a3b38f7Smrg#    mingw (msys)    mingw  [e.g. native]
30387a3b38f7Smrg#    cygwin          mingw
30397a3b38f7Smrg#    *nix + wine     mingw
30407a3b38f7Smrg#
30417a3b38f7Smrg# Path separators are also converted from $build format to
30427a3b38f7Smrg# $host format. If ARG begins or ends with a path separator
30437a3b38f7Smrg# character, it is preserved (but converted to $host format)
30447a3b38f7Smrg# on output.
30457a3b38f7Smrg#
30467a3b38f7Smrg# ARG is a pathlist (on $build) that should be converted to
30477a3b38f7Smrg# the proper representation on $host. The result is stored
30487a3b38f7Smrg# in $func_to_host_pathlist_result.
30497a3b38f7Smrgfunc_to_host_pathlist ()
30507a3b38f7Smrg{
30517a3b38f7Smrg  func_to_host_pathlist_result="$1"
30527a3b38f7Smrg  if test -n "$1" ; then
30537a3b38f7Smrg    case $host in
30547a3b38f7Smrg      *mingw* )
30557a3b38f7Smrg        lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
30567a3b38f7Smrg        # Remove leading and trailing path separator characters from
30577a3b38f7Smrg        # ARG. msys behavior is inconsistent here, cygpath turns them
30587a3b38f7Smrg        # into '.;' and ';.', and winepath ignores them completely.
30597a3b38f7Smrg        func_to_host_pathlist_tmp2="$1"
30607a3b38f7Smrg        # Once set for this call, this variable should not be
30617a3b38f7Smrg        # reassigned. It is used in tha fallback case.
30627a3b38f7Smrg        func_to_host_pathlist_tmp1=`echo "$func_to_host_pathlist_tmp2" |\
30637a3b38f7Smrg          $SED -e 's|^:*||' -e 's|:*$||'`
30647a3b38f7Smrg        case $build in
30657a3b38f7Smrg          *mingw* ) # Actually, msys.
30667a3b38f7Smrg            # Awkward: cmd appends spaces to result.
30677a3b38f7Smrg            lt_sed_strip_trailing_spaces="s/[ ]*\$//"
30687a3b38f7Smrg            func_to_host_pathlist_tmp2=`( cmd //c echo "$func_to_host_pathlist_tmp1" |\
30697a3b38f7Smrg              $SED -e "$lt_sed_strip_trailing_spaces" ) 2>/dev/null || echo ""`
30707a3b38f7Smrg            func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp2" |\
30717a3b38f7Smrg              $SED -e "$lt_sed_naive_backslashify"`
30727a3b38f7Smrg            ;;
30737a3b38f7Smrg          *cygwin* )
30747a3b38f7Smrg            func_to_host_pathlist_tmp2=`cygpath -w -p "$func_to_host_pathlist_tmp1"`
30757a3b38f7Smrg            func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp2" |\
30767a3b38f7Smrg              $SED -e "$lt_sed_naive_backslashify"`
30777a3b38f7Smrg            ;;
30787a3b38f7Smrg          * )
30797a3b38f7Smrg            # unfortunately, winepath doesn't convert pathlists
30807a3b38f7Smrg            func_to_host_pathlist_result=""
30817a3b38f7Smrg            func_to_host_pathlist_oldIFS=$IFS
30827a3b38f7Smrg            IFS=:
30837a3b38f7Smrg            for func_to_host_pathlist_f in $func_to_host_pathlist_tmp1 ; do
30847a3b38f7Smrg              IFS=$func_to_host_pathlist_oldIFS
30857a3b38f7Smrg              if test -n "$func_to_host_pathlist_f" ; then
30867a3b38f7Smrg                func_to_host_path "$func_to_host_pathlist_f"
30877a3b38f7Smrg                if test -n "$func_to_host_path_result" ; then
30887a3b38f7Smrg                  if test -z "$func_to_host_pathlist_result" ; then
30897a3b38f7Smrg                    func_to_host_pathlist_result="$func_to_host_path_result"
30907a3b38f7Smrg                  else
30917a3b38f7Smrg                    func_to_host_pathlist_result="$func_to_host_pathlist_result;$func_to_host_path_result"
30927a3b38f7Smrg                  fi
30937a3b38f7Smrg                fi
30947a3b38f7Smrg              fi
30957a3b38f7Smrg              IFS=:
30967a3b38f7Smrg            done
30977a3b38f7Smrg            IFS=$func_to_host_pathlist_oldIFS
30987a3b38f7Smrg            ;;
30997a3b38f7Smrg        esac
31007a3b38f7Smrg        if test -z "$func_to_host_pathlist_result" ; then
31017a3b38f7Smrg          func_error "Could not determine the host path(s) corresponding to"
31027a3b38f7Smrg          func_error "  '$1'"
31037a3b38f7Smrg          func_error "Continuing, but uninstalled executables may not work."
31047a3b38f7Smrg          # Fallback. This may break if $1 contains DOS-style drive
31057a3b38f7Smrg          # specifications. The fix is not to complicate the expression
31067a3b38f7Smrg          # below, but for the user to provide a working wine installation
31077a3b38f7Smrg          # with winepath so that path translation in the cross-to-mingw
31087a3b38f7Smrg          # case works properly.
31097a3b38f7Smrg          lt_replace_pathsep_nix_to_dos="s|:|;|g"
31107a3b38f7Smrg          func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp1" |\
31117a3b38f7Smrg            $SED -e "$lt_replace_pathsep_nix_to_dos"`
31127a3b38f7Smrg        fi
31137a3b38f7Smrg        # Now, add the leading and trailing path separators back
31147a3b38f7Smrg        case "$1" in
31157a3b38f7Smrg          :* ) func_to_host_pathlist_result=";$func_to_host_pathlist_result"
31167a3b38f7Smrg            ;;
31177a3b38f7Smrg        esac
31187a3b38f7Smrg        case "$1" in
31197a3b38f7Smrg          *: ) func_to_host_pathlist_result="$func_to_host_pathlist_result;"
31207a3b38f7Smrg            ;;
31217a3b38f7Smrg        esac
31227a3b38f7Smrg        ;;
31237a3b38f7Smrg    esac
31247a3b38f7Smrg  fi
31257a3b38f7Smrg}
31267a3b38f7Smrg# end: func_to_host_pathlist
3127ff559fabSmrg
31287a3b38f7Smrg# func_emit_cwrapperexe_src
31297a3b38f7Smrg# emit the source code for a wrapper executable on stdout
31307a3b38f7Smrg# Must ONLY be called from within func_mode_link because
31317a3b38f7Smrg# it depends on a number of variable set therein.
31327a3b38f7Smrgfunc_emit_cwrapperexe_src ()
31337a3b38f7Smrg{
31347a3b38f7Smrg	cat <<EOF
3135ff559fabSmrg
31367a3b38f7Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
31377a3b38f7Smrg   Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
3138ff559fabSmrg
31397a3b38f7Smrg   The $output program cannot be directly executed until all the libtool
31407a3b38f7Smrg   libraries that it depends on are installed.
3141ff559fabSmrg
31427a3b38f7Smrg   This wrapper executable should never be moved out of the build directory.
31437a3b38f7Smrg   If it is, it will not operate correctly.
31447a3b38f7Smrg
31457a3b38f7Smrg   Currently, it simply execs the wrapper *script* "$SHELL $output",
31467a3b38f7Smrg   but could eventually absorb all of the scripts functionality and
31477a3b38f7Smrg   exec $objdir/$outputname directly.
31487a3b38f7Smrg*/
31497a3b38f7SmrgEOF
31507a3b38f7Smrg	    cat <<"EOF"
31517a3b38f7Smrg#include <stdio.h>
31527a3b38f7Smrg#include <stdlib.h>
31537a3b38f7Smrg#ifdef _MSC_VER
31547a3b38f7Smrg# include <direct.h>
31557a3b38f7Smrg# include <process.h>
31567a3b38f7Smrg# include <io.h>
31577a3b38f7Smrg# define setmode _setmode
31587a3b38f7Smrg#else
31597a3b38f7Smrg# include <unistd.h>
31607a3b38f7Smrg# include <stdint.h>
31617a3b38f7Smrg# ifdef __CYGWIN__
31627a3b38f7Smrg#  include <io.h>
31637a3b38f7Smrg#  define HAVE_SETENV
31647a3b38f7Smrg#  ifdef __STRICT_ANSI__
31657a3b38f7Smrgchar *realpath (const char *, char *);
31667a3b38f7Smrgint putenv (char *);
31677a3b38f7Smrgint setenv (const char *, const char *, int);
31687a3b38f7Smrg#  endif
31697a3b38f7Smrg# endif
31707a3b38f7Smrg#endif
31717a3b38f7Smrg#include <malloc.h>
31727a3b38f7Smrg#include <stdarg.h>
31737a3b38f7Smrg#include <assert.h>
31747a3b38f7Smrg#include <string.h>
31757a3b38f7Smrg#include <ctype.h>
31767a3b38f7Smrg#include <errno.h>
31777a3b38f7Smrg#include <fcntl.h>
31787a3b38f7Smrg#include <sys/stat.h>
31797a3b38f7Smrg
31807a3b38f7Smrg#if defined(PATH_MAX)
31817a3b38f7Smrg# define LT_PATHMAX PATH_MAX
31827a3b38f7Smrg#elif defined(MAXPATHLEN)
31837a3b38f7Smrg# define LT_PATHMAX MAXPATHLEN
31847a3b38f7Smrg#else
31857a3b38f7Smrg# define LT_PATHMAX 1024
31867a3b38f7Smrg#endif
31877a3b38f7Smrg
31887a3b38f7Smrg#ifndef S_IXOTH
31897a3b38f7Smrg# define S_IXOTH 0
31907a3b38f7Smrg#endif
31917a3b38f7Smrg#ifndef S_IXGRP
31927a3b38f7Smrg# define S_IXGRP 0
31937a3b38f7Smrg#endif
31947a3b38f7Smrg
31957a3b38f7Smrg#ifdef _MSC_VER
31967a3b38f7Smrg# define S_IXUSR _S_IEXEC
31977a3b38f7Smrg# define stat _stat
31987a3b38f7Smrg# ifndef _INTPTR_T_DEFINED
31997a3b38f7Smrg#  define intptr_t int
32007a3b38f7Smrg# endif
32017a3b38f7Smrg#endif
32027a3b38f7Smrg
32037a3b38f7Smrg#ifndef DIR_SEPARATOR
32047a3b38f7Smrg# define DIR_SEPARATOR '/'
32057a3b38f7Smrg# define PATH_SEPARATOR ':'
32067a3b38f7Smrg#endif
32077a3b38f7Smrg
32087a3b38f7Smrg#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
32097a3b38f7Smrg  defined (__OS2__)
32107a3b38f7Smrg# define HAVE_DOS_BASED_FILE_SYSTEM
32117a3b38f7Smrg# define FOPEN_WB "wb"
32127a3b38f7Smrg# ifndef DIR_SEPARATOR_2
32137a3b38f7Smrg#  define DIR_SEPARATOR_2 '\\'
32147a3b38f7Smrg# endif
32157a3b38f7Smrg# ifndef PATH_SEPARATOR_2
32167a3b38f7Smrg#  define PATH_SEPARATOR_2 ';'
32177a3b38f7Smrg# endif
32187a3b38f7Smrg#endif
32197a3b38f7Smrg
32207a3b38f7Smrg#ifndef DIR_SEPARATOR_2
32217a3b38f7Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
32227a3b38f7Smrg#else /* DIR_SEPARATOR_2 */
32237a3b38f7Smrg# define IS_DIR_SEPARATOR(ch) \
32247a3b38f7Smrg	(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
32257a3b38f7Smrg#endif /* DIR_SEPARATOR_2 */
32267a3b38f7Smrg
32277a3b38f7Smrg#ifndef PATH_SEPARATOR_2
32287a3b38f7Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
32297a3b38f7Smrg#else /* PATH_SEPARATOR_2 */
32307a3b38f7Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
32317a3b38f7Smrg#endif /* PATH_SEPARATOR_2 */
32327a3b38f7Smrg
32337a3b38f7Smrg#ifdef __CYGWIN__
32347a3b38f7Smrg# define FOPEN_WB "wb"
32357a3b38f7Smrg#endif
32367a3b38f7Smrg
32377a3b38f7Smrg#ifndef FOPEN_WB
32387a3b38f7Smrg# define FOPEN_WB "w"
32397a3b38f7Smrg#endif
32407a3b38f7Smrg#ifndef _O_BINARY
32417a3b38f7Smrg# define _O_BINARY 0
32427a3b38f7Smrg#endif
32437a3b38f7Smrg
32447a3b38f7Smrg#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
32457a3b38f7Smrg#define XFREE(stale) do { \
32467a3b38f7Smrg  if (stale) { free ((void *) stale); stale = 0; } \
32477a3b38f7Smrg} while (0)
32487a3b38f7Smrg
32497a3b38f7Smrg#undef LTWRAPPER_DEBUGPRINTF
32507a3b38f7Smrg#if defined DEBUGWRAPPER
32517a3b38f7Smrg# define LTWRAPPER_DEBUGPRINTF(args) ltwrapper_debugprintf args
32527a3b38f7Smrgstatic void
32537a3b38f7Smrgltwrapper_debugprintf (const char *fmt, ...)
32547a3b38f7Smrg{
32557a3b38f7Smrg    va_list args;
32567a3b38f7Smrg    va_start (args, fmt);
32577a3b38f7Smrg    (void) vfprintf (stderr, fmt, args);
32587a3b38f7Smrg    va_end (args);
32597a3b38f7Smrg}
32607a3b38f7Smrg#else
32617a3b38f7Smrg# define LTWRAPPER_DEBUGPRINTF(args)
32627a3b38f7Smrg#endif
32637a3b38f7Smrg
32647a3b38f7Smrgconst char *program_name = NULL;
32657a3b38f7Smrg
32667a3b38f7Smrgvoid *xmalloc (size_t num);
32677a3b38f7Smrgchar *xstrdup (const char *string);
32687a3b38f7Smrgconst char *base_name (const char *name);
32697a3b38f7Smrgchar *find_executable (const char *wrapper);
32707a3b38f7Smrgchar *chase_symlinks (const char *pathspec);
32717a3b38f7Smrgint make_executable (const char *path);
32727a3b38f7Smrgint check_executable (const char *path);
32737a3b38f7Smrgchar *strendzap (char *str, const char *pat);
32747a3b38f7Smrgvoid lt_fatal (const char *message, ...);
32757a3b38f7Smrgvoid lt_setenv (const char *name, const char *value);
32767a3b38f7Smrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end);
32777a3b38f7Smrgvoid lt_opt_process_env_set (const char *arg);
32787a3b38f7Smrgvoid lt_opt_process_env_prepend (const char *arg);
32797a3b38f7Smrgvoid lt_opt_process_env_append (const char *arg);
32807a3b38f7Smrgint lt_split_name_value (const char *arg, char** name, char** value);
32817a3b38f7Smrgvoid lt_update_exe_path (const char *name, const char *value);
32827a3b38f7Smrgvoid lt_update_lib_path (const char *name, const char *value);
32837a3b38f7Smrg
32847a3b38f7Smrgstatic const char *script_text_part1 =
32857a3b38f7SmrgEOF
32867a3b38f7Smrg
32877a3b38f7Smrg	    func_emit_wrapper_part1 yes |
32887a3b38f7Smrg	        $SED -e 's/\([\\"]\)/\\\1/g' \
32897a3b38f7Smrg	             -e 's/^/  "/' -e 's/$/\\n"/'
32907a3b38f7Smrg	    echo ";"
32917a3b38f7Smrg	    cat <<EOF
32927a3b38f7Smrg
32937a3b38f7Smrgstatic const char *script_text_part2 =
32947a3b38f7SmrgEOF
32957a3b38f7Smrg	    func_emit_wrapper_part2 yes |
32967a3b38f7Smrg	        $SED -e 's/\([\\"]\)/\\\1/g' \
32977a3b38f7Smrg	             -e 's/^/  "/' -e 's/$/\\n"/'
32987a3b38f7Smrg	    echo ";"
32997a3b38f7Smrg
33007a3b38f7Smrg	    cat <<EOF
33017a3b38f7Smrgconst char * MAGIC_EXE = "$magic_exe";
33027a3b38f7Smrgconst char * LIB_PATH_VARNAME = "$shlibpath_var";
33037a3b38f7SmrgEOF
33047a3b38f7Smrg
33057a3b38f7Smrg	    if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
33067a3b38f7Smrg              func_to_host_pathlist "$temp_rpath"
33077a3b38f7Smrg	      cat <<EOF
33087a3b38f7Smrgconst char * LIB_PATH_VALUE   = "$func_to_host_pathlist_result";
3309ff559fabSmrgEOF
3310ff559fabSmrg	    else
33117a3b38f7Smrg	      cat <<"EOF"
33127a3b38f7Smrgconst char * LIB_PATH_VALUE   = "";
33137a3b38f7SmrgEOF
3314ff559fabSmrg	    fi
33157a3b38f7Smrg
33167a3b38f7Smrg	    if test -n "$dllsearchpath"; then
33177a3b38f7Smrg              func_to_host_pathlist "$dllsearchpath:"
33187a3b38f7Smrg	      cat <<EOF
33197a3b38f7Smrgconst char * EXE_PATH_VARNAME = "PATH";
33207a3b38f7Smrgconst char * EXE_PATH_VALUE   = "$func_to_host_pathlist_result";
33217a3b38f7SmrgEOF
3322ff559fabSmrg	    else
33237a3b38f7Smrg	      cat <<"EOF"
33247a3b38f7Smrgconst char * EXE_PATH_VARNAME = "";
33257a3b38f7Smrgconst char * EXE_PATH_VALUE   = "";
33267a3b38f7SmrgEOF
3327ff559fabSmrg	    fi
33287a3b38f7Smrg
33297a3b38f7Smrg	    if test "$fast_install" = yes; then
33307a3b38f7Smrg	      cat <<EOF
33317a3b38f7Smrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
33327a3b38f7SmrgEOF
3333ff559fabSmrg	    else
33347a3b38f7Smrg	      cat <<EOF
33357a3b38f7Smrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
33367a3b38f7SmrgEOF
3337ff559fabSmrg	    fi
3338ff559fabSmrg
3339ff559fabSmrg
33407a3b38f7Smrg	    cat <<"EOF"
3341ff559fabSmrg
33427a3b38f7Smrg#define LTWRAPPER_OPTION_PREFIX         "--lt-"
33437a3b38f7Smrg#define LTWRAPPER_OPTION_PREFIX_LENGTH  5
3344ff559fabSmrg
33457a3b38f7Smrgstatic const size_t opt_prefix_len         = LTWRAPPER_OPTION_PREFIX_LENGTH;
33467a3b38f7Smrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
3347ff559fabSmrg
33487a3b38f7Smrgstatic const char *dumpscript_opt       = LTWRAPPER_OPTION_PREFIX "dump-script";
3349ff559fabSmrg
33507a3b38f7Smrgstatic const size_t env_set_opt_len     = LTWRAPPER_OPTION_PREFIX_LENGTH + 7;
33517a3b38f7Smrgstatic const char *env_set_opt          = LTWRAPPER_OPTION_PREFIX "env-set";
33527a3b38f7Smrg  /* argument is putenv-style "foo=bar", value of foo is set to bar */
3353ff559fabSmrg
33547a3b38f7Smrgstatic const size_t env_prepend_opt_len = LTWRAPPER_OPTION_PREFIX_LENGTH + 11;
33557a3b38f7Smrgstatic const char *env_prepend_opt      = LTWRAPPER_OPTION_PREFIX "env-prepend";
33567a3b38f7Smrg  /* argument is putenv-style "foo=bar", new value of foo is bar${foo} */
3357ff559fabSmrg
33587a3b38f7Smrgstatic const size_t env_append_opt_len  = LTWRAPPER_OPTION_PREFIX_LENGTH + 10;
33597a3b38f7Smrgstatic const char *env_append_opt       = LTWRAPPER_OPTION_PREFIX "env-append";
33607a3b38f7Smrg  /* argument is putenv-style "foo=bar", new value of foo is ${foo}bar */
3361ff559fabSmrg
33627a3b38f7Smrgint
33637a3b38f7Smrgmain (int argc, char *argv[])
33647a3b38f7Smrg{
33657a3b38f7Smrg  char **newargz;
33667a3b38f7Smrg  int  newargc;
33677a3b38f7Smrg  char *tmp_pathspec;
33687a3b38f7Smrg  char *actual_cwrapper_path;
33697a3b38f7Smrg  char *actual_cwrapper_name;
33707a3b38f7Smrg  char *target_name;
33717a3b38f7Smrg  char *lt_argv_zero;
33727a3b38f7Smrg  intptr_t rval = 127;
3373ff559fabSmrg
33747a3b38f7Smrg  int i;
3375ff559fabSmrg
33767a3b38f7Smrg  program_name = (char *) xstrdup (base_name (argv[0]));
33777a3b38f7Smrg  LTWRAPPER_DEBUGPRINTF (("(main) argv[0]      : %s\n", argv[0]));
33787a3b38f7Smrg  LTWRAPPER_DEBUGPRINTF (("(main) program_name : %s\n", program_name));
3379ff559fabSmrg
33807a3b38f7Smrg  /* very simple arg parsing; don't want to rely on getopt */
33817a3b38f7Smrg  for (i = 1; i < argc; i++)
33827a3b38f7Smrg    {
33837a3b38f7Smrg      if (strcmp (argv[i], dumpscript_opt) == 0)
33847a3b38f7Smrg	{
33857a3b38f7SmrgEOF
33867a3b38f7Smrg	    case "$host" in
33877a3b38f7Smrg	      *mingw* | *cygwin* )
33887a3b38f7Smrg		# make stdout use "unix" line endings
33897a3b38f7Smrg		echo "          setmode(1,_O_BINARY);"
33907a3b38f7Smrg		;;
33917a3b38f7Smrg	      esac
3392ff559fabSmrg
33937a3b38f7Smrg	    cat <<"EOF"
33947a3b38f7Smrg	  printf ("%s", script_text_part1);
33957a3b38f7Smrg	  printf ("%s", script_text_part2);
33967a3b38f7Smrg	  return 0;
33977a3b38f7Smrg	}
33987a3b38f7Smrg    }
3399ff559fabSmrg
34007a3b38f7Smrg  newargz = XMALLOC (char *, argc + 1);
34017a3b38f7Smrg  tmp_pathspec = find_executable (argv[0]);
34027a3b38f7Smrg  if (tmp_pathspec == NULL)
34037a3b38f7Smrg    lt_fatal ("Couldn't find %s", argv[0]);
34047a3b38f7Smrg  LTWRAPPER_DEBUGPRINTF (("(main) found exe (before symlink chase) at : %s\n",
34057a3b38f7Smrg			  tmp_pathspec));
34067a3b38f7Smrg
34077a3b38f7Smrg  actual_cwrapper_path = chase_symlinks (tmp_pathspec);
34087a3b38f7Smrg  LTWRAPPER_DEBUGPRINTF (("(main) found exe (after symlink chase) at : %s\n",
34097a3b38f7Smrg			  actual_cwrapper_path));
34107a3b38f7Smrg  XFREE (tmp_pathspec);
34117a3b38f7Smrg
34127a3b38f7Smrg  actual_cwrapper_name = xstrdup( base_name (actual_cwrapper_path));
34137a3b38f7Smrg  strendzap (actual_cwrapper_path, actual_cwrapper_name);
34147a3b38f7Smrg
34157a3b38f7Smrg  /* wrapper name transforms */
34167a3b38f7Smrg  strendzap (actual_cwrapper_name, ".exe");
34177a3b38f7Smrg  tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
34187a3b38f7Smrg  XFREE (actual_cwrapper_name);
34197a3b38f7Smrg  actual_cwrapper_name = tmp_pathspec;
34207a3b38f7Smrg  tmp_pathspec = 0;
34217a3b38f7Smrg
34227a3b38f7Smrg  /* target_name transforms -- use actual target program name; might have lt- prefix */
34237a3b38f7Smrg  target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
34247a3b38f7Smrg  strendzap (target_name, ".exe");
34257a3b38f7Smrg  tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
34267a3b38f7Smrg  XFREE (target_name);
34277a3b38f7Smrg  target_name = tmp_pathspec;
34287a3b38f7Smrg  tmp_pathspec = 0;
34297a3b38f7Smrg
34307a3b38f7Smrg  LTWRAPPER_DEBUGPRINTF (("(main) libtool target name: %s\n",
34317a3b38f7Smrg			  target_name));
34327a3b38f7SmrgEOF
3433ff559fabSmrg
34347a3b38f7Smrg	    cat <<EOF
34357a3b38f7Smrg  newargz[0] =
34367a3b38f7Smrg    XMALLOC (char, (strlen (actual_cwrapper_path) +
34377a3b38f7Smrg		    strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
34387a3b38f7Smrg  strcpy (newargz[0], actual_cwrapper_path);
34397a3b38f7Smrg  strcat (newargz[0], "$objdir");
34407a3b38f7Smrg  strcat (newargz[0], "/");
34417a3b38f7SmrgEOF
3442ff559fabSmrg
34437a3b38f7Smrg	    cat <<"EOF"
34447a3b38f7Smrg  /* stop here, and copy so we don't have to do this twice */
34457a3b38f7Smrg  tmp_pathspec = xstrdup (newargz[0]);
3446ff559fabSmrg
34477a3b38f7Smrg  /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
34487a3b38f7Smrg  strcat (newargz[0], actual_cwrapper_name);
3449ff559fabSmrg
34507a3b38f7Smrg  /* DO want the lt- prefix here if it exists, so use target_name */
34517a3b38f7Smrg  lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
34527a3b38f7Smrg  XFREE (tmp_pathspec);
34537a3b38f7Smrg  tmp_pathspec = NULL;
34547a3b38f7SmrgEOF
3455ff559fabSmrg
34567a3b38f7Smrg	    case $host_os in
34577a3b38f7Smrg	      mingw*)
34587a3b38f7Smrg	    cat <<"EOF"
34597a3b38f7Smrg  {
34607a3b38f7Smrg    char* p;
34617a3b38f7Smrg    while ((p = strchr (newargz[0], '\\')) != NULL)
34627a3b38f7Smrg      {
34637a3b38f7Smrg	*p = '/';
34647a3b38f7Smrg      }
34657a3b38f7Smrg    while ((p = strchr (lt_argv_zero, '\\')) != NULL)
34667a3b38f7Smrg      {
34677a3b38f7Smrg	*p = '/';
34687a3b38f7Smrg      }
34697a3b38f7Smrg  }
34707a3b38f7SmrgEOF
34717a3b38f7Smrg	    ;;
34727a3b38f7Smrg	    esac
3473ff559fabSmrg
34747a3b38f7Smrg	    cat <<"EOF"
34757a3b38f7Smrg  XFREE (target_name);
34767a3b38f7Smrg  XFREE (actual_cwrapper_path);
34777a3b38f7Smrg  XFREE (actual_cwrapper_name);
3478ff559fabSmrg
34797a3b38f7Smrg  lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
34807a3b38f7Smrg  lt_setenv ("DUALCASE", "1");  /* for MSK sh */
34817a3b38f7Smrg  lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
34827a3b38f7Smrg  lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
3483ff559fabSmrg
34847a3b38f7Smrg  newargc=0;
34857a3b38f7Smrg  for (i = 1; i < argc; i++)
34867a3b38f7Smrg    {
34877a3b38f7Smrg      if (strncmp (argv[i], env_set_opt, env_set_opt_len) == 0)
34887a3b38f7Smrg        {
34897a3b38f7Smrg          if (argv[i][env_set_opt_len] == '=')
34907a3b38f7Smrg            {
34917a3b38f7Smrg              const char *p = argv[i] + env_set_opt_len + 1;
34927a3b38f7Smrg              lt_opt_process_env_set (p);
34937a3b38f7Smrg            }
34947a3b38f7Smrg          else if (argv[i][env_set_opt_len] == '\0' && i + 1 < argc)
34957a3b38f7Smrg            {
34967a3b38f7Smrg              lt_opt_process_env_set (argv[++i]); /* don't copy */
34977a3b38f7Smrg            }
34987a3b38f7Smrg          else
34997a3b38f7Smrg            lt_fatal ("%s missing required argument", env_set_opt);
35007a3b38f7Smrg          continue;
35017a3b38f7Smrg        }
35027a3b38f7Smrg      if (strncmp (argv[i], env_prepend_opt, env_prepend_opt_len) == 0)
35037a3b38f7Smrg        {
35047a3b38f7Smrg          if (argv[i][env_prepend_opt_len] == '=')
35057a3b38f7Smrg            {
35067a3b38f7Smrg              const char *p = argv[i] + env_prepend_opt_len + 1;
35077a3b38f7Smrg              lt_opt_process_env_prepend (p);
35087a3b38f7Smrg            }
35097a3b38f7Smrg          else if (argv[i][env_prepend_opt_len] == '\0' && i + 1 < argc)
35107a3b38f7Smrg            {
35117a3b38f7Smrg              lt_opt_process_env_prepend (argv[++i]); /* don't copy */
35127a3b38f7Smrg            }
35137a3b38f7Smrg          else
35147a3b38f7Smrg            lt_fatal ("%s missing required argument", env_prepend_opt);
35157a3b38f7Smrg          continue;
35167a3b38f7Smrg        }
35177a3b38f7Smrg      if (strncmp (argv[i], env_append_opt, env_append_opt_len) == 0)
35187a3b38f7Smrg        {
35197a3b38f7Smrg          if (argv[i][env_append_opt_len] == '=')
35207a3b38f7Smrg            {
35217a3b38f7Smrg              const char *p = argv[i] + env_append_opt_len + 1;
35227a3b38f7Smrg              lt_opt_process_env_append (p);
35237a3b38f7Smrg            }
35247a3b38f7Smrg          else if (argv[i][env_append_opt_len] == '\0' && i + 1 < argc)
35257a3b38f7Smrg            {
35267a3b38f7Smrg              lt_opt_process_env_append (argv[++i]); /* don't copy */
35277a3b38f7Smrg            }
35287a3b38f7Smrg          else
35297a3b38f7Smrg            lt_fatal ("%s missing required argument", env_append_opt);
35307a3b38f7Smrg          continue;
35317a3b38f7Smrg        }
35327a3b38f7Smrg      if (strncmp (argv[i], ltwrapper_option_prefix, opt_prefix_len) == 0)
35337a3b38f7Smrg        {
35347a3b38f7Smrg          /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
35357a3b38f7Smrg             namespace, but it is not one of the ones we know about and
35367a3b38f7Smrg             have already dealt with, above (inluding dump-script), then
35377a3b38f7Smrg             report an error. Otherwise, targets might begin to believe
35387a3b38f7Smrg             they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
35397a3b38f7Smrg             namespace. The first time any user complains about this, we'll
35407a3b38f7Smrg             need to make LTWRAPPER_OPTION_PREFIX a configure-time option
35417a3b38f7Smrg             or a configure.ac-settable value.
35427a3b38f7Smrg           */
35437a3b38f7Smrg          lt_fatal ("Unrecognized option in %s namespace: '%s'",
35447a3b38f7Smrg                    ltwrapper_option_prefix, argv[i]);
35457a3b38f7Smrg        }
35467a3b38f7Smrg      /* otherwise ... */
35477a3b38f7Smrg      newargz[++newargc] = xstrdup (argv[i]);
35487a3b38f7Smrg    }
35497a3b38f7Smrg  newargz[++newargc] = NULL;
3550ff559fabSmrg
35517a3b38f7Smrg  LTWRAPPER_DEBUGPRINTF     (("(main) lt_argv_zero : %s\n", (lt_argv_zero ? lt_argv_zero : "<NULL>")));
35527a3b38f7Smrg  for (i = 0; i < newargc; i++)
35537a3b38f7Smrg    {
35547a3b38f7Smrg      LTWRAPPER_DEBUGPRINTF (("(main) newargz[%d]   : %s\n", i, (newargz[i] ? newargz[i] : "<NULL>")));
35557a3b38f7Smrg    }
3556ff559fabSmrg
35577a3b38f7SmrgEOF
3558ff559fabSmrg
35597a3b38f7Smrg	    case $host_os in
35607a3b38f7Smrg	      mingw*)
35617a3b38f7Smrg		cat <<"EOF"
35627a3b38f7Smrg  /* execv doesn't actually work on mingw as expected on unix */
35637a3b38f7Smrg  rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
35647a3b38f7Smrg  if (rval == -1)
35657a3b38f7Smrg    {
35667a3b38f7Smrg      /* failed to start process */
35677a3b38f7Smrg      LTWRAPPER_DEBUGPRINTF (("(main) failed to launch target \"%s\": errno = %d\n", lt_argv_zero, errno));
35687a3b38f7Smrg      return 127;
35697a3b38f7Smrg    }
35707a3b38f7Smrg  return rval;
35717a3b38f7SmrgEOF
35727a3b38f7Smrg		;;
35737a3b38f7Smrg	      *)
35747a3b38f7Smrg		cat <<"EOF"
35757a3b38f7Smrg  execv (lt_argv_zero, newargz);
35767a3b38f7Smrg  return rval; /* =127, but avoids unused variable warning */
35777a3b38f7SmrgEOF
35787a3b38f7Smrg		;;
35797a3b38f7Smrg	    esac
3580ff559fabSmrg
35817a3b38f7Smrg	    cat <<"EOF"
35827a3b38f7Smrg}
3583ff559fabSmrg
35847a3b38f7Smrgvoid *
35857a3b38f7Smrgxmalloc (size_t num)
35867a3b38f7Smrg{
35877a3b38f7Smrg  void *p = (void *) malloc (num);
35887a3b38f7Smrg  if (!p)
35897a3b38f7Smrg    lt_fatal ("Memory exhausted");
3590ff559fabSmrg
35917a3b38f7Smrg  return p;
35927a3b38f7Smrg}
3593ff559fabSmrg
35947a3b38f7Smrgchar *
35957a3b38f7Smrgxstrdup (const char *string)
35967a3b38f7Smrg{
35977a3b38f7Smrg  return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
35987a3b38f7Smrg			  string) : NULL;
35997a3b38f7Smrg}
3600ff559fabSmrg
36017a3b38f7Smrgconst char *
36027a3b38f7Smrgbase_name (const char *name)
36037a3b38f7Smrg{
36047a3b38f7Smrg  const char *base;
3605ff559fabSmrg
36067a3b38f7Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
36077a3b38f7Smrg  /* Skip over the disk name in MSDOS pathnames. */
36087a3b38f7Smrg  if (isalpha ((unsigned char) name[0]) && name[1] == ':')
36097a3b38f7Smrg    name += 2;
36107a3b38f7Smrg#endif
3611ff559fabSmrg
36127a3b38f7Smrg  for (base = name; *name; name++)
36137a3b38f7Smrg    if (IS_DIR_SEPARATOR (*name))
36147a3b38f7Smrg      base = name + 1;
36157a3b38f7Smrg  return base;
36167a3b38f7Smrg}
3617ff559fabSmrg
36187a3b38f7Smrgint
36197a3b38f7Smrgcheck_executable (const char *path)
36207a3b38f7Smrg{
36217a3b38f7Smrg  struct stat st;
3622ff559fabSmrg
36237a3b38f7Smrg  LTWRAPPER_DEBUGPRINTF (("(check_executable)  : %s\n",
36247a3b38f7Smrg			  path ? (*path ? path : "EMPTY!") : "NULL!"));
36257a3b38f7Smrg  if ((!path) || (!*path))
36267a3b38f7Smrg    return 0;
3627ff559fabSmrg
36287a3b38f7Smrg  if ((stat (path, &st) >= 0)
36297a3b38f7Smrg      && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
36307a3b38f7Smrg    return 1;
36317a3b38f7Smrg  else
36327a3b38f7Smrg    return 0;
36337a3b38f7Smrg}
3634ff559fabSmrg
36357a3b38f7Smrgint
36367a3b38f7Smrgmake_executable (const char *path)
36377a3b38f7Smrg{
36387a3b38f7Smrg  int rval = 0;
36397a3b38f7Smrg  struct stat st;
3640ff559fabSmrg
36417a3b38f7Smrg  LTWRAPPER_DEBUGPRINTF (("(make_executable)   : %s\n",
36427a3b38f7Smrg			  path ? (*path ? path : "EMPTY!") : "NULL!"));
36437a3b38f7Smrg  if ((!path) || (!*path))
36447a3b38f7Smrg    return 0;
3645ff559fabSmrg
36467a3b38f7Smrg  if (stat (path, &st) >= 0)
36477a3b38f7Smrg    {
36487a3b38f7Smrg      rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
36497a3b38f7Smrg    }
36507a3b38f7Smrg  return rval;
36517a3b38f7Smrg}
3652ff559fabSmrg
36537a3b38f7Smrg/* Searches for the full path of the wrapper.  Returns
36547a3b38f7Smrg   newly allocated full path name if found, NULL otherwise
36557a3b38f7Smrg   Does not chase symlinks, even on platforms that support them.
36567a3b38f7Smrg*/
36577a3b38f7Smrgchar *
36587a3b38f7Smrgfind_executable (const char *wrapper)
36597a3b38f7Smrg{
36607a3b38f7Smrg  int has_slash = 0;
36617a3b38f7Smrg  const char *p;
36627a3b38f7Smrg  const char *p_next;
36637a3b38f7Smrg  /* static buffer for getcwd */
36647a3b38f7Smrg  char tmp[LT_PATHMAX + 1];
36657a3b38f7Smrg  int tmp_len;
36667a3b38f7Smrg  char *concat_name;
3667ff559fabSmrg
36687a3b38f7Smrg  LTWRAPPER_DEBUGPRINTF (("(find_executable)   : %s\n",
36697a3b38f7Smrg			  wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!"));
3670ff559fabSmrg
36717a3b38f7Smrg  if ((wrapper == NULL) || (*wrapper == '\0'))
36727a3b38f7Smrg    return NULL;
3673ff559fabSmrg
36747a3b38f7Smrg  /* Absolute path? */
36757a3b38f7Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
36767a3b38f7Smrg  if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
36777a3b38f7Smrg    {
36787a3b38f7Smrg      concat_name = xstrdup (wrapper);
36797a3b38f7Smrg      if (check_executable (concat_name))
36807a3b38f7Smrg	return concat_name;
36817a3b38f7Smrg      XFREE (concat_name);
36827a3b38f7Smrg    }
36837a3b38f7Smrg  else
36847a3b38f7Smrg    {
36857a3b38f7Smrg#endif
36867a3b38f7Smrg      if (IS_DIR_SEPARATOR (wrapper[0]))
36877a3b38f7Smrg	{
36887a3b38f7Smrg	  concat_name = xstrdup (wrapper);
36897a3b38f7Smrg	  if (check_executable (concat_name))
36907a3b38f7Smrg	    return concat_name;
36917a3b38f7Smrg	  XFREE (concat_name);
36927a3b38f7Smrg	}
36937a3b38f7Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
36947a3b38f7Smrg    }
36957a3b38f7Smrg#endif
3696ff559fabSmrg
36977a3b38f7Smrg  for (p = wrapper; *p; p++)
36987a3b38f7Smrg    if (*p == '/')
36997a3b38f7Smrg      {
37007a3b38f7Smrg	has_slash = 1;
37017a3b38f7Smrg	break;
37027a3b38f7Smrg      }
37037a3b38f7Smrg  if (!has_slash)
37047a3b38f7Smrg    {
37057a3b38f7Smrg      /* no slashes; search PATH */
37067a3b38f7Smrg      const char *path = getenv ("PATH");
37077a3b38f7Smrg      if (path != NULL)
37087a3b38f7Smrg	{
37097a3b38f7Smrg	  for (p = path; *p; p = p_next)
37107a3b38f7Smrg	    {
37117a3b38f7Smrg	      const char *q;
37127a3b38f7Smrg	      size_t p_len;
37137a3b38f7Smrg	      for (q = p; *q; q++)
37147a3b38f7Smrg		if (IS_PATH_SEPARATOR (*q))
37157a3b38f7Smrg		  break;
37167a3b38f7Smrg	      p_len = q - p;
37177a3b38f7Smrg	      p_next = (*q == '\0' ? q : q + 1);
37187a3b38f7Smrg	      if (p_len == 0)
37197a3b38f7Smrg		{
37207a3b38f7Smrg		  /* empty path: current directory */
37217a3b38f7Smrg		  if (getcwd (tmp, LT_PATHMAX) == NULL)
37227a3b38f7Smrg		    lt_fatal ("getcwd failed");
37237a3b38f7Smrg		  tmp_len = strlen (tmp);
37247a3b38f7Smrg		  concat_name =
37257a3b38f7Smrg		    XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
37267a3b38f7Smrg		  memcpy (concat_name, tmp, tmp_len);
37277a3b38f7Smrg		  concat_name[tmp_len] = '/';
37287a3b38f7Smrg		  strcpy (concat_name + tmp_len + 1, wrapper);
37297a3b38f7Smrg		}
37307a3b38f7Smrg	      else
37317a3b38f7Smrg		{
37327a3b38f7Smrg		  concat_name =
37337a3b38f7Smrg		    XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
37347a3b38f7Smrg		  memcpy (concat_name, p, p_len);
37357a3b38f7Smrg		  concat_name[p_len] = '/';
37367a3b38f7Smrg		  strcpy (concat_name + p_len + 1, wrapper);
37377a3b38f7Smrg		}
37387a3b38f7Smrg	      if (check_executable (concat_name))
37397a3b38f7Smrg		return concat_name;
37407a3b38f7Smrg	      XFREE (concat_name);
37417a3b38f7Smrg	    }
37427a3b38f7Smrg	}
37437a3b38f7Smrg      /* not found in PATH; assume curdir */
37447a3b38f7Smrg    }
37457a3b38f7Smrg  /* Relative path | not found in path: prepend cwd */
37467a3b38f7Smrg  if (getcwd (tmp, LT_PATHMAX) == NULL)
37477a3b38f7Smrg    lt_fatal ("getcwd failed");
37487a3b38f7Smrg  tmp_len = strlen (tmp);
37497a3b38f7Smrg  concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
37507a3b38f7Smrg  memcpy (concat_name, tmp, tmp_len);
37517a3b38f7Smrg  concat_name[tmp_len] = '/';
37527a3b38f7Smrg  strcpy (concat_name + tmp_len + 1, wrapper);
3753ff559fabSmrg
37547a3b38f7Smrg  if (check_executable (concat_name))
37557a3b38f7Smrg    return concat_name;
37567a3b38f7Smrg  XFREE (concat_name);
37577a3b38f7Smrg  return NULL;
37587a3b38f7Smrg}
3759ff559fabSmrg
37607a3b38f7Smrgchar *
37617a3b38f7Smrgchase_symlinks (const char *pathspec)
37627a3b38f7Smrg{
37637a3b38f7Smrg#ifndef S_ISLNK
37647a3b38f7Smrg  return xstrdup (pathspec);
37657a3b38f7Smrg#else
37667a3b38f7Smrg  char buf[LT_PATHMAX];
37677a3b38f7Smrg  struct stat s;
37687a3b38f7Smrg  char *tmp_pathspec = xstrdup (pathspec);
37697a3b38f7Smrg  char *p;
37707a3b38f7Smrg  int has_symlinks = 0;
37717a3b38f7Smrg  while (strlen (tmp_pathspec) && !has_symlinks)
37727a3b38f7Smrg    {
37737a3b38f7Smrg      LTWRAPPER_DEBUGPRINTF (("checking path component for symlinks: %s\n",
37747a3b38f7Smrg			      tmp_pathspec));
37757a3b38f7Smrg      if (lstat (tmp_pathspec, &s) == 0)
37767a3b38f7Smrg	{
37777a3b38f7Smrg	  if (S_ISLNK (s.st_mode) != 0)
37787a3b38f7Smrg	    {
37797a3b38f7Smrg	      has_symlinks = 1;
37807a3b38f7Smrg	      break;
37817a3b38f7Smrg	    }
3782ff559fabSmrg
37837a3b38f7Smrg	  /* search backwards for last DIR_SEPARATOR */
37847a3b38f7Smrg	  p = tmp_pathspec + strlen (tmp_pathspec) - 1;
37857a3b38f7Smrg	  while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
37867a3b38f7Smrg	    p--;
37877a3b38f7Smrg	  if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
37887a3b38f7Smrg	    {
37897a3b38f7Smrg	      /* no more DIR_SEPARATORS left */
37907a3b38f7Smrg	      break;
37917a3b38f7Smrg	    }
37927a3b38f7Smrg	  *p = '\0';
37937a3b38f7Smrg	}
37947a3b38f7Smrg      else
37957a3b38f7Smrg	{
37967a3b38f7Smrg	  char *errstr = strerror (errno);
37977a3b38f7Smrg	  lt_fatal ("Error accessing file %s (%s)", tmp_pathspec, errstr);
37987a3b38f7Smrg	}
37997a3b38f7Smrg    }
38007a3b38f7Smrg  XFREE (tmp_pathspec);
3801ff559fabSmrg
38027a3b38f7Smrg  if (!has_symlinks)
38037a3b38f7Smrg    {
38047a3b38f7Smrg      return xstrdup (pathspec);
38057a3b38f7Smrg    }
3806ff559fabSmrg
38077a3b38f7Smrg  tmp_pathspec = realpath (pathspec, buf);
38087a3b38f7Smrg  if (tmp_pathspec == 0)
38097a3b38f7Smrg    {
38107a3b38f7Smrg      lt_fatal ("Could not follow symlinks for %s", pathspec);
38117a3b38f7Smrg    }
38127a3b38f7Smrg  return xstrdup (tmp_pathspec);
38137a3b38f7Smrg#endif
38147a3b38f7Smrg}
3815ff559fabSmrg
38167a3b38f7Smrgchar *
38177a3b38f7Smrgstrendzap (char *str, const char *pat)
38187a3b38f7Smrg{
38197a3b38f7Smrg  size_t len, patlen;
3820ff559fabSmrg
38217a3b38f7Smrg  assert (str != NULL);
38227a3b38f7Smrg  assert (pat != NULL);
3823ff559fabSmrg
38247a3b38f7Smrg  len = strlen (str);
38257a3b38f7Smrg  patlen = strlen (pat);
3826ff559fabSmrg
38277a3b38f7Smrg  if (patlen <= len)
38287a3b38f7Smrg    {
38297a3b38f7Smrg      str += len - patlen;
38307a3b38f7Smrg      if (strcmp (str, pat) == 0)
38317a3b38f7Smrg	*str = '\0';
38327a3b38f7Smrg    }
38337a3b38f7Smrg  return str;
38347a3b38f7Smrg}
3835ff559fabSmrg
38367a3b38f7Smrgstatic void
38377a3b38f7Smrglt_error_core (int exit_status, const char *mode,
38387a3b38f7Smrg	       const char *message, va_list ap)
38397a3b38f7Smrg{
38407a3b38f7Smrg  fprintf (stderr, "%s: %s: ", program_name, mode);
38417a3b38f7Smrg  vfprintf (stderr, message, ap);
38427a3b38f7Smrg  fprintf (stderr, ".\n");
3843ff559fabSmrg
38447a3b38f7Smrg  if (exit_status >= 0)
38457a3b38f7Smrg    exit (exit_status);
38467a3b38f7Smrg}
3847ff559fabSmrg
38487a3b38f7Smrgvoid
38497a3b38f7Smrglt_fatal (const char *message, ...)
38507a3b38f7Smrg{
38517a3b38f7Smrg  va_list ap;
38527a3b38f7Smrg  va_start (ap, message);
38537a3b38f7Smrg  lt_error_core (EXIT_FAILURE, "FATAL", message, ap);
38547a3b38f7Smrg  va_end (ap);
38557a3b38f7Smrg}
3856ff559fabSmrg
38577a3b38f7Smrgvoid
38587a3b38f7Smrglt_setenv (const char *name, const char *value)
38597a3b38f7Smrg{
38607a3b38f7Smrg  LTWRAPPER_DEBUGPRINTF (("(lt_setenv) setting '%s' to '%s'\n",
38617a3b38f7Smrg                          (name ? name : "<NULL>"),
38627a3b38f7Smrg                          (value ? value : "<NULL>")));
38637a3b38f7Smrg  {
38647a3b38f7Smrg#ifdef HAVE_SETENV
38657a3b38f7Smrg    /* always make a copy, for consistency with !HAVE_SETENV */
38667a3b38f7Smrg    char *str = xstrdup (value);
38677a3b38f7Smrg    setenv (name, str, 1);
38687a3b38f7Smrg#else
38697a3b38f7Smrg    int len = strlen (name) + 1 + strlen (value) + 1;
38707a3b38f7Smrg    char *str = XMALLOC (char, len);
38717a3b38f7Smrg    sprintf (str, "%s=%s", name, value);
38727a3b38f7Smrg    if (putenv (str) != EXIT_SUCCESS)
38737a3b38f7Smrg      {
38747a3b38f7Smrg        XFREE (str);
38757a3b38f7Smrg      }
38767a3b38f7Smrg#endif
38777a3b38f7Smrg  }
38787a3b38f7Smrg}
3879ff559fabSmrg
38807a3b38f7Smrgchar *
38817a3b38f7Smrglt_extend_str (const char *orig_value, const char *add, int to_end)
38827a3b38f7Smrg{
38837a3b38f7Smrg  char *new_value;
38847a3b38f7Smrg  if (orig_value && *orig_value)
38857a3b38f7Smrg    {
38867a3b38f7Smrg      int orig_value_len = strlen (orig_value);
38877a3b38f7Smrg      int add_len = strlen (add);
38887a3b38f7Smrg      new_value = XMALLOC (char, add_len + orig_value_len + 1);
38897a3b38f7Smrg      if (to_end)
38907a3b38f7Smrg        {
38917a3b38f7Smrg          strcpy (new_value, orig_value);
38927a3b38f7Smrg          strcpy (new_value + orig_value_len, add);
38937a3b38f7Smrg        }
38947a3b38f7Smrg      else
38957a3b38f7Smrg        {
38967a3b38f7Smrg          strcpy (new_value, add);
38977a3b38f7Smrg          strcpy (new_value + add_len, orig_value);
38987a3b38f7Smrg        }
38997a3b38f7Smrg    }
39007a3b38f7Smrg  else
39017a3b38f7Smrg    {
39027a3b38f7Smrg      new_value = xstrdup (add);
39037a3b38f7Smrg    }
39047a3b38f7Smrg  return new_value;
39057a3b38f7Smrg}
3906ff559fabSmrg
39077a3b38f7Smrgint
39087a3b38f7Smrglt_split_name_value (const char *arg, char** name, char** value)
39097a3b38f7Smrg{
39107a3b38f7Smrg  const char *p;
39117a3b38f7Smrg  int len;
39127a3b38f7Smrg  if (!arg || !*arg)
39137a3b38f7Smrg    return 1;
3914ff559fabSmrg
39157a3b38f7Smrg  p = strchr (arg, (int)'=');
3916ff559fabSmrg
39177a3b38f7Smrg  if (!p)
39187a3b38f7Smrg    return 1;
3919ff559fabSmrg
39207a3b38f7Smrg  *value = xstrdup (++p);
3921ff559fabSmrg
39227a3b38f7Smrg  len = strlen (arg) - strlen (*value);
39237a3b38f7Smrg  *name = XMALLOC (char, len);
39247a3b38f7Smrg  strncpy (*name, arg, len-1);
39257a3b38f7Smrg  (*name)[len - 1] = '\0';
3926ff559fabSmrg
39277a3b38f7Smrg  return 0;
39287a3b38f7Smrg}
3929ff559fabSmrg
39307a3b38f7Smrgvoid
39317a3b38f7Smrglt_opt_process_env_set (const char *arg)
39327a3b38f7Smrg{
39337a3b38f7Smrg  char *name = NULL;
39347a3b38f7Smrg  char *value = NULL;
3935ff559fabSmrg
39367a3b38f7Smrg  if (lt_split_name_value (arg, &name, &value) != 0)
39377a3b38f7Smrg    {
39387a3b38f7Smrg      XFREE (name);
39397a3b38f7Smrg      XFREE (value);
39407a3b38f7Smrg      lt_fatal ("bad argument for %s: '%s'", env_set_opt, arg);
39417a3b38f7Smrg    }
3942ff559fabSmrg
39437a3b38f7Smrg  lt_setenv (name, value);
39447a3b38f7Smrg  XFREE (name);
39457a3b38f7Smrg  XFREE (value);
39467a3b38f7Smrg}
3947ff559fabSmrg
39487a3b38f7Smrgvoid
39497a3b38f7Smrglt_opt_process_env_prepend (const char *arg)
39507a3b38f7Smrg{
39517a3b38f7Smrg  char *name = NULL;
39527a3b38f7Smrg  char *value = NULL;
39537a3b38f7Smrg  char *new_value = NULL;
3954ff559fabSmrg
39557a3b38f7Smrg  if (lt_split_name_value (arg, &name, &value) != 0)
39567a3b38f7Smrg    {
39577a3b38f7Smrg      XFREE (name);
39587a3b38f7Smrg      XFREE (value);
39597a3b38f7Smrg      lt_fatal ("bad argument for %s: '%s'", env_prepend_opt, arg);
39607a3b38f7Smrg    }
3961ff559fabSmrg
39627a3b38f7Smrg  new_value = lt_extend_str (getenv (name), value, 0);
39637a3b38f7Smrg  lt_setenv (name, new_value);
39647a3b38f7Smrg  XFREE (new_value);
39657a3b38f7Smrg  XFREE (name);
39667a3b38f7Smrg  XFREE (value);
39677a3b38f7Smrg}
3968ff559fabSmrg
39697a3b38f7Smrgvoid
39707a3b38f7Smrglt_opt_process_env_append (const char *arg)
39717a3b38f7Smrg{
39727a3b38f7Smrg  char *name = NULL;
39737a3b38f7Smrg  char *value = NULL;
39747a3b38f7Smrg  char *new_value = NULL;
3975ff559fabSmrg
39767a3b38f7Smrg  if (lt_split_name_value (arg, &name, &value) != 0)
39777a3b38f7Smrg    {
39787a3b38f7Smrg      XFREE (name);
39797a3b38f7Smrg      XFREE (value);
39807a3b38f7Smrg      lt_fatal ("bad argument for %s: '%s'", env_append_opt, arg);
39817a3b38f7Smrg    }
3982ff559fabSmrg
39837a3b38f7Smrg  new_value = lt_extend_str (getenv (name), value, 1);
39847a3b38f7Smrg  lt_setenv (name, new_value);
39857a3b38f7Smrg  XFREE (new_value);
39867a3b38f7Smrg  XFREE (name);
39877a3b38f7Smrg  XFREE (value);
39887a3b38f7Smrg}
3989ff559fabSmrg
39907a3b38f7Smrgvoid
39917a3b38f7Smrglt_update_exe_path (const char *name, const char *value)
39927a3b38f7Smrg{
39937a3b38f7Smrg  LTWRAPPER_DEBUGPRINTF (("(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
39947a3b38f7Smrg                          (name ? name : "<NULL>"),
39957a3b38f7Smrg                          (value ? value : "<NULL>")));
3996ff559fabSmrg
39977a3b38f7Smrg  if (name && *name && value && *value)
39987a3b38f7Smrg    {
39997a3b38f7Smrg      char *new_value = lt_extend_str (getenv (name), value, 0);
40007a3b38f7Smrg      /* some systems can't cope with a ':'-terminated path #' */
40017a3b38f7Smrg      int len = strlen (new_value);
40027a3b38f7Smrg      while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
40037a3b38f7Smrg        {
40047a3b38f7Smrg          new_value[len-1] = '\0';
40057a3b38f7Smrg        }
40067a3b38f7Smrg      lt_setenv (name, new_value);
40077a3b38f7Smrg      XFREE (new_value);
40087a3b38f7Smrg    }
40097a3b38f7Smrg}
4010ff559fabSmrg
40117a3b38f7Smrgvoid
40127a3b38f7Smrglt_update_lib_path (const char *name, const char *value)
40137a3b38f7Smrg{
40147a3b38f7Smrg  LTWRAPPER_DEBUGPRINTF (("(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
40157a3b38f7Smrg                          (name ? name : "<NULL>"),
40167a3b38f7Smrg                          (value ? value : "<NULL>")));
4017ff559fabSmrg
40187a3b38f7Smrg  if (name && *name && value && *value)
40197a3b38f7Smrg    {
40207a3b38f7Smrg      char *new_value = lt_extend_str (getenv (name), value, 0);
40217a3b38f7Smrg      lt_setenv (name, new_value);
40227a3b38f7Smrg      XFREE (new_value);
40237a3b38f7Smrg    }
40247a3b38f7Smrg}
4025ff559fabSmrg
4026ff559fabSmrg
40277a3b38f7SmrgEOF
40287a3b38f7Smrg}
40297a3b38f7Smrg# end: func_emit_cwrapperexe_src
4030ff559fabSmrg
40317a3b38f7Smrg# func_mode_link arg...
40327a3b38f7Smrgfunc_mode_link ()
40337a3b38f7Smrg{
40347a3b38f7Smrg    $opt_debug
40357a3b38f7Smrg    case $host in
40367a3b38f7Smrg    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
40377a3b38f7Smrg      # It is impossible to link a dll without this setting, and
40387a3b38f7Smrg      # we shouldn't force the makefile maintainer to figure out
40397a3b38f7Smrg      # which system we are compiling for in order to pass an extra
40407a3b38f7Smrg      # flag for every libtool invocation.
40417a3b38f7Smrg      # allow_undefined=no
4042ff559fabSmrg
40437a3b38f7Smrg      # FIXME: Unfortunately, there are problems with the above when trying
40447a3b38f7Smrg      # to make a dll which has undefined symbols, in which case not
40457a3b38f7Smrg      # even a static library is built.  For now, we need to specify
40467a3b38f7Smrg      # -no-undefined on the libtool link line when we can be certain
40477a3b38f7Smrg      # that all symbols are satisfied, otherwise we get a static library.
40487a3b38f7Smrg      allow_undefined=yes
40497a3b38f7Smrg      ;;
40507a3b38f7Smrg    *)
40517a3b38f7Smrg      allow_undefined=yes
40527a3b38f7Smrg      ;;
40537a3b38f7Smrg    esac
40547a3b38f7Smrg    libtool_args=$nonopt
40557a3b38f7Smrg    base_compile="$nonopt $@"
40567a3b38f7Smrg    compile_command=$nonopt
40577a3b38f7Smrg    finalize_command=$nonopt
4058ff559fabSmrg
40597a3b38f7Smrg    compile_rpath=
40607a3b38f7Smrg    finalize_rpath=
40617a3b38f7Smrg    compile_shlibpath=
40627a3b38f7Smrg    finalize_shlibpath=
40637a3b38f7Smrg    convenience=
40647a3b38f7Smrg    old_convenience=
40657a3b38f7Smrg    deplibs=
40667a3b38f7Smrg    old_deplibs=
40677a3b38f7Smrg    compiler_flags=
40687a3b38f7Smrg    linker_flags=
40697a3b38f7Smrg    dllsearchpath=
40707a3b38f7Smrg    lib_search_path=`pwd`
40717a3b38f7Smrg    inst_prefix_dir=
40727a3b38f7Smrg    new_inherited_linker_flags=
4073ff559fabSmrg
40747a3b38f7Smrg    avoid_version=no
40757a3b38f7Smrg    dlfiles=
40767a3b38f7Smrg    dlprefiles=
40777a3b38f7Smrg    dlself=no
40787a3b38f7Smrg    export_dynamic=no
40797a3b38f7Smrg    export_symbols=
40807a3b38f7Smrg    export_symbols_regex=
40817a3b38f7Smrg    generated=
40827a3b38f7Smrg    libobjs=
40837a3b38f7Smrg    ltlibs=
40847a3b38f7Smrg    module=no
40857a3b38f7Smrg    no_install=no
40867a3b38f7Smrg    objs=
40877a3b38f7Smrg    non_pic_objects=
40887a3b38f7Smrg    precious_files_regex=
40897a3b38f7Smrg    prefer_static_libs=no
40907a3b38f7Smrg    preload=no
40917a3b38f7Smrg    prev=
40927a3b38f7Smrg    prevarg=
40937a3b38f7Smrg    release=
40947a3b38f7Smrg    rpath=
40957a3b38f7Smrg    xrpath=
40967a3b38f7Smrg    perm_rpath=
40977a3b38f7Smrg    temp_rpath=
40987a3b38f7Smrg    thread_safe=no
40997a3b38f7Smrg    vinfo=
41007a3b38f7Smrg    vinfo_number=no
41017a3b38f7Smrg    weak_libs=
41027a3b38f7Smrg    single_module="${wl}-single_module"
41037a3b38f7Smrg    func_infer_tag $base_compile
4104ff559fabSmrg
41057a3b38f7Smrg    # We need to know -static, to get the right output filenames.
41067a3b38f7Smrg    for arg
41077a3b38f7Smrg    do
41087a3b38f7Smrg      case $arg in
41097a3b38f7Smrg      -shared)
41107a3b38f7Smrg	test "$build_libtool_libs" != yes && \
41117a3b38f7Smrg	  func_fatal_configuration "can not build a shared library"
41127a3b38f7Smrg	build_old_libs=no
41137a3b38f7Smrg	break
41147a3b38f7Smrg	;;
41157a3b38f7Smrg      -all-static | -static | -static-libtool-libs)
41167a3b38f7Smrg	case $arg in
41177a3b38f7Smrg	-all-static)
41187a3b38f7Smrg	  if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
41197a3b38f7Smrg	    func_warning "complete static linking is impossible in this configuration"
4120ff559fabSmrg	  fi
41217a3b38f7Smrg	  if test -n "$link_static_flag"; then
41227a3b38f7Smrg	    dlopen_self=$dlopen_self_static
4123ff559fabSmrg	  fi
41247a3b38f7Smrg	  prefer_static_libs=yes
4125ff559fabSmrg	  ;;
41267a3b38f7Smrg	-static)
41277a3b38f7Smrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
41287a3b38f7Smrg	    dlopen_self=$dlopen_self_static
41297a3b38f7Smrg	  fi
41307a3b38f7Smrg	  prefer_static_libs=built
41317a3b38f7Smrg	  ;;
41327a3b38f7Smrg	-static-libtool-libs)
41337a3b38f7Smrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
41347a3b38f7Smrg	    dlopen_self=$dlopen_self_static
41357a3b38f7Smrg	  fi
41367a3b38f7Smrg	  prefer_static_libs=yes
4137ff559fabSmrg	  ;;
4138ff559fabSmrg	esac
41397a3b38f7Smrg	build_libtool_libs=no
41407a3b38f7Smrg	build_old_libs=yes
41417a3b38f7Smrg	break
41427a3b38f7Smrg	;;
41437a3b38f7Smrg      esac
41447a3b38f7Smrg    done
4145ff559fabSmrg
41467a3b38f7Smrg    # See if our shared archives depend on static archives.
41477a3b38f7Smrg    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
4148ff559fabSmrg
41497a3b38f7Smrg    # Go through the arguments, transforming them on the way.
41507a3b38f7Smrg    while test "$#" -gt 0; do
41517a3b38f7Smrg      arg="$1"
41527a3b38f7Smrg      shift
41537a3b38f7Smrg      func_quote_for_eval "$arg"
41547a3b38f7Smrg      qarg=$func_quote_for_eval_unquoted_result
41557a3b38f7Smrg      func_append libtool_args " $func_quote_for_eval_result"
4156ff559fabSmrg
41577a3b38f7Smrg      # If the previous option needs an argument, assign it.
41587a3b38f7Smrg      if test -n "$prev"; then
41597a3b38f7Smrg	case $prev in
41607a3b38f7Smrg	output)
41617a3b38f7Smrg	  func_append compile_command " @OUTPUT@"
41627a3b38f7Smrg	  func_append finalize_command " @OUTPUT@"
41637a3b38f7Smrg	  ;;
41647a3b38f7Smrg	esac
4165ff559fabSmrg
41667a3b38f7Smrg	case $prev in
41677a3b38f7Smrg	dlfiles|dlprefiles)
41687a3b38f7Smrg	  if test "$preload" = no; then
41697a3b38f7Smrg	    # Add the symbol object into the linking commands.
41707a3b38f7Smrg	    func_append compile_command " @SYMFILE@"
41717a3b38f7Smrg	    func_append finalize_command " @SYMFILE@"
41727a3b38f7Smrg	    preload=yes
41737a3b38f7Smrg	  fi
41747a3b38f7Smrg	  case $arg in
41757a3b38f7Smrg	  *.la | *.lo) ;;  # We handle these cases below.
41767a3b38f7Smrg	  force)
41777a3b38f7Smrg	    if test "$dlself" = no; then
41787a3b38f7Smrg	      dlself=needless
41797a3b38f7Smrg	      export_dynamic=yes
41807a3b38f7Smrg	    fi
41817a3b38f7Smrg	    prev=
41827a3b38f7Smrg	    continue
41837a3b38f7Smrg	    ;;
41847a3b38f7Smrg	  self)
41857a3b38f7Smrg	    if test "$prev" = dlprefiles; then
41867a3b38f7Smrg	      dlself=yes
41877a3b38f7Smrg	    elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
41887a3b38f7Smrg	      dlself=yes
41897a3b38f7Smrg	    else
41907a3b38f7Smrg	      dlself=needless
41917a3b38f7Smrg	      export_dynamic=yes
41927a3b38f7Smrg	    fi
41937a3b38f7Smrg	    prev=
41947a3b38f7Smrg	    continue
4195ff559fabSmrg	    ;;
4196ff559fabSmrg	  *)
41977a3b38f7Smrg	    if test "$prev" = dlfiles; then
41987a3b38f7Smrg	      dlfiles="$dlfiles $arg"
41997a3b38f7Smrg	    else
42007a3b38f7Smrg	      dlprefiles="$dlprefiles $arg"
42017a3b38f7Smrg	    fi
42027a3b38f7Smrg	    prev=
42037a3b38f7Smrg	    continue
4204ff559fabSmrg	    ;;
4205ff559fabSmrg	  esac
42067a3b38f7Smrg	  ;;
42077a3b38f7Smrg	expsyms)
42087a3b38f7Smrg	  export_symbols="$arg"
42097a3b38f7Smrg	  test -f "$arg" \
42107a3b38f7Smrg	    || func_fatal_error "symbol file \`$arg' does not exist"
42117a3b38f7Smrg	  prev=
42127a3b38f7Smrg	  continue
42137a3b38f7Smrg	  ;;
42147a3b38f7Smrg	expsyms_regex)
42157a3b38f7Smrg	  export_symbols_regex="$arg"
42167a3b38f7Smrg	  prev=
42177a3b38f7Smrg	  continue
42187a3b38f7Smrg	  ;;
42197a3b38f7Smrg	framework)
42207a3b38f7Smrg	  case $host in
42217a3b38f7Smrg	    *-*-darwin*)
42227a3b38f7Smrg	      case "$deplibs " in
42237a3b38f7Smrg		*" $qarg.ltframework "*) ;;
42247a3b38f7Smrg		*) deplibs="$deplibs $qarg.ltframework" # this is fixed later
42257a3b38f7Smrg		   ;;
42267a3b38f7Smrg	      esac
42277a3b38f7Smrg	      ;;
42287a3b38f7Smrg	  esac
42297a3b38f7Smrg	  prev=
42307a3b38f7Smrg	  continue
42317a3b38f7Smrg	  ;;
42327a3b38f7Smrg	inst_prefix)
42337a3b38f7Smrg	  inst_prefix_dir="$arg"
42347a3b38f7Smrg	  prev=
42357a3b38f7Smrg	  continue
42367a3b38f7Smrg	  ;;
42377a3b38f7Smrg	objectlist)
42387a3b38f7Smrg	  if test -f "$arg"; then
42397a3b38f7Smrg	    save_arg=$arg
42407a3b38f7Smrg	    moreargs=
42417a3b38f7Smrg	    for fil in `cat "$save_arg"`
42427a3b38f7Smrg	    do
42437a3b38f7Smrg#	      moreargs="$moreargs $fil"
42447a3b38f7Smrg	      arg=$fil
42457a3b38f7Smrg	      # A libtool-controlled object.
4246ff559fabSmrg
42477a3b38f7Smrg	      # Check to see that this really is a libtool object.
42487a3b38f7Smrg	      if func_lalib_unsafe_p "$arg"; then
42497a3b38f7Smrg		pic_object=
42507a3b38f7Smrg		non_pic_object=
4251ff559fabSmrg
42527a3b38f7Smrg		# Read the .lo file
42537a3b38f7Smrg		func_source "$arg"
4254ff559fabSmrg
42557a3b38f7Smrg		if test -z "$pic_object" ||
42567a3b38f7Smrg		   test -z "$non_pic_object" ||
42577a3b38f7Smrg		   test "$pic_object" = none &&
42587a3b38f7Smrg		   test "$non_pic_object" = none; then
42597a3b38f7Smrg		  func_fatal_error "cannot find name of object for \`$arg'"
42607a3b38f7Smrg		fi
4261ff559fabSmrg
42627a3b38f7Smrg		# Extract subdirectory from the argument.
42637a3b38f7Smrg		func_dirname "$arg" "/" ""
42647a3b38f7Smrg		xdir="$func_dirname_result"
4265ff559fabSmrg
42667a3b38f7Smrg		if test "$pic_object" != none; then
42677a3b38f7Smrg		  # Prepend the subdirectory the object is found in.
42687a3b38f7Smrg		  pic_object="$xdir$pic_object"
4269ff559fabSmrg
42707a3b38f7Smrg		  if test "$prev" = dlfiles; then
42717a3b38f7Smrg		    if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
42727a3b38f7Smrg		      dlfiles="$dlfiles $pic_object"
42737a3b38f7Smrg		      prev=
42747a3b38f7Smrg		      continue
42757a3b38f7Smrg		    else
42767a3b38f7Smrg		      # If libtool objects are unsupported, then we need to preload.
42777a3b38f7Smrg		      prev=dlprefiles
42787a3b38f7Smrg		    fi
42797a3b38f7Smrg		  fi
4280ff559fabSmrg
42817a3b38f7Smrg		  # CHECK ME:  I think I busted this.  -Ossama
42827a3b38f7Smrg		  if test "$prev" = dlprefiles; then
42837a3b38f7Smrg		    # Preload the old-style object.
42847a3b38f7Smrg		    dlprefiles="$dlprefiles $pic_object"
42857a3b38f7Smrg		    prev=
42867a3b38f7Smrg		  fi
4287ff559fabSmrg
42887a3b38f7Smrg		  # A PIC object.
42897a3b38f7Smrg		  func_append libobjs " $pic_object"
42907a3b38f7Smrg		  arg="$pic_object"
42917a3b38f7Smrg		fi
4292ff559fabSmrg
42937a3b38f7Smrg		# Non-PIC object.
42947a3b38f7Smrg		if test "$non_pic_object" != none; then
42957a3b38f7Smrg		  # Prepend the subdirectory the object is found in.
42967a3b38f7Smrg		  non_pic_object="$xdir$non_pic_object"
4297ff559fabSmrg
42987a3b38f7Smrg		  # A standard non-PIC object
42997a3b38f7Smrg		  func_append non_pic_objects " $non_pic_object"
43007a3b38f7Smrg		  if test -z "$pic_object" || test "$pic_object" = none ; then
43017a3b38f7Smrg		    arg="$non_pic_object"
43027a3b38f7Smrg		  fi
43037a3b38f7Smrg		else
43047a3b38f7Smrg		  # If the PIC object exists, use it instead.
43057a3b38f7Smrg		  # $xdir was prepended to $pic_object above.
43067a3b38f7Smrg		  non_pic_object="$pic_object"
43077a3b38f7Smrg		  func_append non_pic_objects " $non_pic_object"
43087a3b38f7Smrg		fi
43097a3b38f7Smrg	      else
43107a3b38f7Smrg		# Only an error if not doing a dry-run.
43117a3b38f7Smrg		if $opt_dry_run; then
43127a3b38f7Smrg		  # Extract subdirectory from the argument.
43137a3b38f7Smrg		  func_dirname "$arg" "/" ""
43147a3b38f7Smrg		  xdir="$func_dirname_result"
43157a3b38f7Smrg
43167a3b38f7Smrg		  func_lo2o "$arg"
43177a3b38f7Smrg		  pic_object=$xdir$objdir/$func_lo2o_result
43187a3b38f7Smrg		  non_pic_object=$xdir$func_lo2o_result
43197a3b38f7Smrg		  func_append libobjs " $pic_object"
43207a3b38f7Smrg		  func_append non_pic_objects " $non_pic_object"
43217a3b38f7Smrg	        else
43227a3b38f7Smrg		  func_fatal_error "\`$arg' is not a valid libtool object"
43237a3b38f7Smrg		fi
43247a3b38f7Smrg	      fi
43257a3b38f7Smrg	    done
43267a3b38f7Smrg	  else
43277a3b38f7Smrg	    func_fatal_error "link input file \`$arg' does not exist"
43287a3b38f7Smrg	  fi
43297a3b38f7Smrg	  arg=$save_arg
43307a3b38f7Smrg	  prev=
43317a3b38f7Smrg	  continue
43327a3b38f7Smrg	  ;;
43337a3b38f7Smrg	precious_regex)
43347a3b38f7Smrg	  precious_files_regex="$arg"
43357a3b38f7Smrg	  prev=
43367a3b38f7Smrg	  continue
43377a3b38f7Smrg	  ;;
43387a3b38f7Smrg	release)
43397a3b38f7Smrg	  release="-$arg"
43407a3b38f7Smrg	  prev=
43417a3b38f7Smrg	  continue
43427a3b38f7Smrg	  ;;
43437a3b38f7Smrg	rpath | xrpath)
43447a3b38f7Smrg	  # We need an absolute path.
43457a3b38f7Smrg	  case $arg in
43467a3b38f7Smrg	  [\\/]* | [A-Za-z]:[\\/]*) ;;
43477a3b38f7Smrg	  *)
43487a3b38f7Smrg	    func_fatal_error "only absolute run-paths are allowed"
43497a3b38f7Smrg	    ;;
43507a3b38f7Smrg	  esac
43517a3b38f7Smrg	  if test "$prev" = rpath; then
43527a3b38f7Smrg	    case "$rpath " in
43537a3b38f7Smrg	    *" $arg "*) ;;
43547a3b38f7Smrg	    *) rpath="$rpath $arg" ;;
43557a3b38f7Smrg	    esac
43567a3b38f7Smrg	  else
43577a3b38f7Smrg	    case "$xrpath " in
43587a3b38f7Smrg	    *" $arg "*) ;;
43597a3b38f7Smrg	    *) xrpath="$xrpath $arg" ;;
43607a3b38f7Smrg	    esac
43617a3b38f7Smrg	  fi
43627a3b38f7Smrg	  prev=
43637a3b38f7Smrg	  continue
43647a3b38f7Smrg	  ;;
43657a3b38f7Smrg	shrext)
43667a3b38f7Smrg	  shrext_cmds="$arg"
43677a3b38f7Smrg	  prev=
43687a3b38f7Smrg	  continue
43697a3b38f7Smrg	  ;;
43707a3b38f7Smrg	weak)
43717a3b38f7Smrg	  weak_libs="$weak_libs $arg"
43727a3b38f7Smrg	  prev=
43737a3b38f7Smrg	  continue
43747a3b38f7Smrg	  ;;
43757a3b38f7Smrg	xcclinker)
43767a3b38f7Smrg	  linker_flags="$linker_flags $qarg"
43777a3b38f7Smrg	  compiler_flags="$compiler_flags $qarg"
43787a3b38f7Smrg	  prev=
43797a3b38f7Smrg	  func_append compile_command " $qarg"
43807a3b38f7Smrg	  func_append finalize_command " $qarg"
43817a3b38f7Smrg	  continue
43827a3b38f7Smrg	  ;;
43837a3b38f7Smrg	xcompiler)
43847a3b38f7Smrg	  compiler_flags="$compiler_flags $qarg"
43857a3b38f7Smrg	  prev=
43867a3b38f7Smrg	  func_append compile_command " $qarg"
43877a3b38f7Smrg	  func_append finalize_command " $qarg"
43887a3b38f7Smrg	  continue
43897a3b38f7Smrg	  ;;
43907a3b38f7Smrg	xlinker)
43917a3b38f7Smrg	  linker_flags="$linker_flags $qarg"
43927a3b38f7Smrg	  compiler_flags="$compiler_flags $wl$qarg"
43937a3b38f7Smrg	  prev=
43947a3b38f7Smrg	  func_append compile_command " $wl$qarg"
43957a3b38f7Smrg	  func_append finalize_command " $wl$qarg"
43967a3b38f7Smrg	  continue
43977a3b38f7Smrg	  ;;
43987a3b38f7Smrg	*)
43997a3b38f7Smrg	  eval "$prev=\"\$arg\""
44007a3b38f7Smrg	  prev=
44017a3b38f7Smrg	  continue
44027a3b38f7Smrg	  ;;
4403ff559fabSmrg	esac
44047a3b38f7Smrg      fi # test -n "$prev"
4405ff559fabSmrg
44067a3b38f7Smrg      prevarg="$arg"
4407ff559fabSmrg
44087a3b38f7Smrg      case $arg in
44097a3b38f7Smrg      -all-static)
44107a3b38f7Smrg	if test -n "$link_static_flag"; then
44117a3b38f7Smrg	  # See comment for -static flag below, for more details.
44127a3b38f7Smrg	  func_append compile_command " $link_static_flag"
44137a3b38f7Smrg	  func_append finalize_command " $link_static_flag"
44147a3b38f7Smrg	fi
44157a3b38f7Smrg	continue
44167a3b38f7Smrg	;;
4417ff559fabSmrg
44187a3b38f7Smrg      -allow-undefined)
44197a3b38f7Smrg	# FIXME: remove this flag sometime in the future.
44207a3b38f7Smrg	func_fatal_error "\`-allow-undefined' must not be used because it is the default"
44217a3b38f7Smrg	;;
4422ff559fabSmrg
44237a3b38f7Smrg      -avoid-version)
44247a3b38f7Smrg	avoid_version=yes
44257a3b38f7Smrg	continue
44267a3b38f7Smrg	;;
4427ff559fabSmrg
44287a3b38f7Smrg      -dlopen)
44297a3b38f7Smrg	prev=dlfiles
44307a3b38f7Smrg	continue
44317a3b38f7Smrg	;;
4432ff559fabSmrg
44337a3b38f7Smrg      -dlpreopen)
44347a3b38f7Smrg	prev=dlprefiles
44357a3b38f7Smrg	continue
44367a3b38f7Smrg	;;
4437ff559fabSmrg
44387a3b38f7Smrg      -export-dynamic)
44397a3b38f7Smrg	export_dynamic=yes
44407a3b38f7Smrg	continue
44417a3b38f7Smrg	;;
4442ff559fabSmrg
44437a3b38f7Smrg      -export-symbols | -export-symbols-regex)
44447a3b38f7Smrg	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
44457a3b38f7Smrg	  func_fatal_error "more than one -exported-symbols argument is not allowed"
44467a3b38f7Smrg	fi
44477a3b38f7Smrg	if test "X$arg" = "X-export-symbols"; then
44487a3b38f7Smrg	  prev=expsyms
44497a3b38f7Smrg	else
44507a3b38f7Smrg	  prev=expsyms_regex
44517a3b38f7Smrg	fi
44527a3b38f7Smrg	continue
44537a3b38f7Smrg	;;
4454ff559fabSmrg
44557a3b38f7Smrg      -framework)
44567a3b38f7Smrg	prev=framework
44577a3b38f7Smrg	continue
44587a3b38f7Smrg	;;
4459ff559fabSmrg
44607a3b38f7Smrg      -inst-prefix-dir)
44617a3b38f7Smrg	prev=inst_prefix
44627a3b38f7Smrg	continue
44637a3b38f7Smrg	;;
4464ff559fabSmrg
44657a3b38f7Smrg      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
44667a3b38f7Smrg      # so, if we see these flags be careful not to treat them like -L
44677a3b38f7Smrg      -L[A-Z][A-Z]*:*)
44687a3b38f7Smrg	case $with_gcc/$host in
44697a3b38f7Smrg	no/*-*-irix* | /*-*-irix*)
44707a3b38f7Smrg	  func_append compile_command " $arg"
44717a3b38f7Smrg	  func_append finalize_command " $arg"
44727a3b38f7Smrg	  ;;
44737a3b38f7Smrg	esac
44747a3b38f7Smrg	continue
44757a3b38f7Smrg	;;
4476ff559fabSmrg
44777a3b38f7Smrg      -L*)
44787a3b38f7Smrg	func_stripname '-L' '' "$arg"
44797a3b38f7Smrg	dir=$func_stripname_result
44807a3b38f7Smrg	if test -z "$dir"; then
44817a3b38f7Smrg	  if test "$#" -gt 0; then
44827a3b38f7Smrg	    func_fatal_error "require no space between \`-L' and \`$1'"
44837a3b38f7Smrg	  else
44847a3b38f7Smrg	    func_fatal_error "need path for \`-L' option"
44857a3b38f7Smrg	  fi
44867a3b38f7Smrg	fi
44877a3b38f7Smrg	# We need an absolute path.
44887a3b38f7Smrg	case $dir in
44897a3b38f7Smrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
44907a3b38f7Smrg	*)
44917a3b38f7Smrg	  absdir=`cd "$dir" && pwd`
44927a3b38f7Smrg	  test -z "$absdir" && \
44937a3b38f7Smrg	    func_fatal_error "cannot determine absolute directory name of \`$dir'"
44947a3b38f7Smrg	  dir="$absdir"
44957a3b38f7Smrg	  ;;
44967a3b38f7Smrg	esac
44977a3b38f7Smrg	case "$deplibs " in
44987a3b38f7Smrg	*" -L$dir "*) ;;
44997a3b38f7Smrg	*)
45007a3b38f7Smrg	  deplibs="$deplibs -L$dir"
45017a3b38f7Smrg	  lib_search_path="$lib_search_path $dir"
45027a3b38f7Smrg	  ;;
45037a3b38f7Smrg	esac
45047a3b38f7Smrg	case $host in
45057a3b38f7Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
45067a3b38f7Smrg	  testbindir=`$ECHO "X$dir" | $Xsed -e 's*/lib$*/bin*'`
45077a3b38f7Smrg	  case :$dllsearchpath: in
45087a3b38f7Smrg	  *":$dir:"*) ;;
45097a3b38f7Smrg	  ::) dllsearchpath=$dir;;
45107a3b38f7Smrg	  *) dllsearchpath="$dllsearchpath:$dir";;
45117a3b38f7Smrg	  esac
45127a3b38f7Smrg	  case :$dllsearchpath: in
45137a3b38f7Smrg	  *":$testbindir:"*) ;;
45147a3b38f7Smrg	  ::) dllsearchpath=$testbindir;;
45157a3b38f7Smrg	  *) dllsearchpath="$dllsearchpath:$testbindir";;
45167a3b38f7Smrg	  esac
45177a3b38f7Smrg	  ;;
45187a3b38f7Smrg	esac
45197a3b38f7Smrg	continue
45207a3b38f7Smrg	;;
4521ff559fabSmrg
45227a3b38f7Smrg      -l*)
45237a3b38f7Smrg	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
45247a3b38f7Smrg	  case $host in
45257a3b38f7Smrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc*)
45267a3b38f7Smrg	    # These systems don't actually have a C or math library (as such)
45277a3b38f7Smrg	    continue
45287a3b38f7Smrg	    ;;
45297a3b38f7Smrg	  *-*-os2*)
45307a3b38f7Smrg	    # These systems don't actually have a C library (as such)
45317a3b38f7Smrg	    test "X$arg" = "X-lc" && continue
45327a3b38f7Smrg	    ;;
45337a3b38f7Smrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
45347a3b38f7Smrg	    # Do not include libc due to us having libc/libc_r.
45357a3b38f7Smrg	    test "X$arg" = "X-lc" && continue
45367a3b38f7Smrg	    ;;
45377a3b38f7Smrg	  *-*-rhapsody* | *-*-darwin1.[012])
45387a3b38f7Smrg	    # Rhapsody C and math libraries are in the System framework
45397a3b38f7Smrg	    deplibs="$deplibs System.ltframework"
45407a3b38f7Smrg	    continue
45417a3b38f7Smrg	    ;;
45427a3b38f7Smrg	  *-*-sco3.2v5* | *-*-sco5v6*)
45437a3b38f7Smrg	    # Causes problems with __ctype
45447a3b38f7Smrg	    test "X$arg" = "X-lc" && continue
45457a3b38f7Smrg	    ;;
45467a3b38f7Smrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
45477a3b38f7Smrg	    # Compiler inserts libc in the correct place for threads to work
45487a3b38f7Smrg	    test "X$arg" = "X-lc" && continue
45497a3b38f7Smrg	    ;;
45507a3b38f7Smrg	  esac
45517a3b38f7Smrg	elif test "X$arg" = "X-lc_r"; then
45527a3b38f7Smrg	 case $host in
45537a3b38f7Smrg	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
45547a3b38f7Smrg	   # Do not include libc_r directly, use -pthread flag.
45557a3b38f7Smrg	   continue
45567a3b38f7Smrg	   ;;
45577a3b38f7Smrg	 esac
45587a3b38f7Smrg	fi
45597a3b38f7Smrg	deplibs="$deplibs $arg"
45607a3b38f7Smrg	continue
45617a3b38f7Smrg	;;
4562ff559fabSmrg
45637a3b38f7Smrg      -module)
45647a3b38f7Smrg	module=yes
45657a3b38f7Smrg	continue
45667a3b38f7Smrg	;;
4567ff559fabSmrg
45687a3b38f7Smrg      # Tru64 UNIX uses -model [arg] to determine the layout of C++
45697a3b38f7Smrg      # classes, name mangling, and exception handling.
45707a3b38f7Smrg      # Darwin uses the -arch flag to determine output architecture.
45717a3b38f7Smrg      -model|-arch|-isysroot)
45727a3b38f7Smrg	compiler_flags="$compiler_flags $arg"
45737a3b38f7Smrg	func_append compile_command " $arg"
45747a3b38f7Smrg	func_append finalize_command " $arg"
45757a3b38f7Smrg	prev=xcompiler
45767a3b38f7Smrg	continue
45777a3b38f7Smrg	;;
4578ff559fabSmrg
45797a3b38f7Smrg      -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
45807a3b38f7Smrg	compiler_flags="$compiler_flags $arg"
45817a3b38f7Smrg	func_append compile_command " $arg"
45827a3b38f7Smrg	func_append finalize_command " $arg"
45837a3b38f7Smrg	case "$new_inherited_linker_flags " in
45847a3b38f7Smrg	    *" $arg "*) ;;
45857a3b38f7Smrg	    * ) new_inherited_linker_flags="$new_inherited_linker_flags $arg" ;;
45867a3b38f7Smrg	esac
45877a3b38f7Smrg	continue
45887a3b38f7Smrg	;;
4589ff559fabSmrg
45907a3b38f7Smrg      -multi_module)
45917a3b38f7Smrg	single_module="${wl}-multi_module"
45927a3b38f7Smrg	continue
45937a3b38f7Smrg	;;
4594ff559fabSmrg
45957a3b38f7Smrg      -no-fast-install)
45967a3b38f7Smrg	fast_install=no
45977a3b38f7Smrg	continue
45987a3b38f7Smrg	;;
4599ff559fabSmrg
46007a3b38f7Smrg      -no-install)
46017a3b38f7Smrg	case $host in
46027a3b38f7Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
46037a3b38f7Smrg	  # The PATH hackery in wrapper scripts is required on Windows
46047a3b38f7Smrg	  # and Darwin in order for the loader to find any dlls it needs.
46057a3b38f7Smrg	  func_warning "\`-no-install' is ignored for $host"
46067a3b38f7Smrg	  func_warning "assuming \`-no-fast-install' instead"
46077a3b38f7Smrg	  fast_install=no
46087a3b38f7Smrg	  ;;
46097a3b38f7Smrg	*) no_install=yes ;;
46107a3b38f7Smrg	esac
46117a3b38f7Smrg	continue
46127a3b38f7Smrg	;;
4613ff559fabSmrg
46147a3b38f7Smrg      -no-undefined)
46157a3b38f7Smrg	allow_undefined=no
46167a3b38f7Smrg	continue
46177a3b38f7Smrg	;;
4618ff559fabSmrg
46197a3b38f7Smrg      -objectlist)
46207a3b38f7Smrg	prev=objectlist
46217a3b38f7Smrg	continue
46227a3b38f7Smrg	;;
4623ff559fabSmrg
46247a3b38f7Smrg      -o) prev=output ;;
4625ff559fabSmrg
46267a3b38f7Smrg      -precious-files-regex)
46277a3b38f7Smrg	prev=precious_regex
46287a3b38f7Smrg	continue
46297a3b38f7Smrg	;;
4630ff559fabSmrg
46317a3b38f7Smrg      -release)
46327a3b38f7Smrg	prev=release
46337a3b38f7Smrg	continue
46347a3b38f7Smrg	;;
4635ff559fabSmrg
46367a3b38f7Smrg      -rpath)
46377a3b38f7Smrg	prev=rpath
46387a3b38f7Smrg	continue
46397a3b38f7Smrg	;;
4640ff559fabSmrg
46417a3b38f7Smrg      -R)
46427a3b38f7Smrg	prev=xrpath
46437a3b38f7Smrg	continue
46447a3b38f7Smrg	;;
4645ff559fabSmrg
46467a3b38f7Smrg      -R*)
46477a3b38f7Smrg	func_stripname '-R' '' "$arg"
46487a3b38f7Smrg	dir=$func_stripname_result
46497a3b38f7Smrg	# We need an absolute path.
46507a3b38f7Smrg	case $dir in
46517a3b38f7Smrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
46527a3b38f7Smrg	*)
46537a3b38f7Smrg	  func_fatal_error "only absolute run-paths are allowed"
46547a3b38f7Smrg	  ;;
46557a3b38f7Smrg	esac
46567a3b38f7Smrg	case "$xrpath " in
46577a3b38f7Smrg	*" $dir "*) ;;
46587a3b38f7Smrg	*) xrpath="$xrpath $dir" ;;
46597a3b38f7Smrg	esac
46607a3b38f7Smrg	continue
46617a3b38f7Smrg	;;
4662ff559fabSmrg
46637a3b38f7Smrg      -shared)
46647a3b38f7Smrg	# The effects of -shared are defined in a previous loop.
46657a3b38f7Smrg	continue
46667a3b38f7Smrg	;;
4667ff559fabSmrg
46687a3b38f7Smrg      -shrext)
46697a3b38f7Smrg	prev=shrext
46707a3b38f7Smrg	continue
46717a3b38f7Smrg	;;
4672ff559fabSmrg
46737a3b38f7Smrg      -static | -static-libtool-libs)
46747a3b38f7Smrg	# The effects of -static are defined in a previous loop.
46757a3b38f7Smrg	# We used to do the same as -all-static on platforms that
46767a3b38f7Smrg	# didn't have a PIC flag, but the assumption that the effects
46777a3b38f7Smrg	# would be equivalent was wrong.  It would break on at least
46787a3b38f7Smrg	# Digital Unix and AIX.
46797a3b38f7Smrg	continue
46807a3b38f7Smrg	;;
4681ff559fabSmrg
46827a3b38f7Smrg      -thread-safe)
46837a3b38f7Smrg	thread_safe=yes
46847a3b38f7Smrg	continue
46857a3b38f7Smrg	;;
4686ff559fabSmrg
46877a3b38f7Smrg      -version-info)
46887a3b38f7Smrg	prev=vinfo
46897a3b38f7Smrg	continue
46907a3b38f7Smrg	;;
4691ff559fabSmrg
46927a3b38f7Smrg      -version-number)
46937a3b38f7Smrg	prev=vinfo
46947a3b38f7Smrg	vinfo_number=yes
46957a3b38f7Smrg	continue
46967a3b38f7Smrg	;;
4697ff559fabSmrg
46987a3b38f7Smrg      -weak)
46997a3b38f7Smrg        prev=weak
47007a3b38f7Smrg	continue
47017a3b38f7Smrg	;;
4702ff559fabSmrg
47037a3b38f7Smrg      -Wc,*)
47047a3b38f7Smrg	func_stripname '-Wc,' '' "$arg"
47057a3b38f7Smrg	args=$func_stripname_result
47067a3b38f7Smrg	arg=
47077a3b38f7Smrg	save_ifs="$IFS"; IFS=','
47087a3b38f7Smrg	for flag in $args; do
47097a3b38f7Smrg	  IFS="$save_ifs"
47107a3b38f7Smrg          func_quote_for_eval "$flag"
47117a3b38f7Smrg	  arg="$arg $wl$func_quote_for_eval_result"
47127a3b38f7Smrg	  compiler_flags="$compiler_flags $func_quote_for_eval_result"
47137a3b38f7Smrg	done
47147a3b38f7Smrg	IFS="$save_ifs"
47157a3b38f7Smrg	func_stripname ' ' '' "$arg"
47167a3b38f7Smrg	arg=$func_stripname_result
47177a3b38f7Smrg	;;
4718ff559fabSmrg
47197a3b38f7Smrg      -Wl,*)
47207a3b38f7Smrg	func_stripname '-Wl,' '' "$arg"
47217a3b38f7Smrg	args=$func_stripname_result
47227a3b38f7Smrg	arg=
47237a3b38f7Smrg	save_ifs="$IFS"; IFS=','
47247a3b38f7Smrg	for flag in $args; do
47257a3b38f7Smrg	  IFS="$save_ifs"
47267a3b38f7Smrg          func_quote_for_eval "$flag"
47277a3b38f7Smrg	  arg="$arg $wl$func_quote_for_eval_result"
47287a3b38f7Smrg	  compiler_flags="$compiler_flags $wl$func_quote_for_eval_result"
47297a3b38f7Smrg	  linker_flags="$linker_flags $func_quote_for_eval_result"
47307a3b38f7Smrg	done
47317a3b38f7Smrg	IFS="$save_ifs"
47327a3b38f7Smrg	func_stripname ' ' '' "$arg"
47337a3b38f7Smrg	arg=$func_stripname_result
47347a3b38f7Smrg	;;
4735ff559fabSmrg
47367a3b38f7Smrg      -Xcompiler)
47377a3b38f7Smrg	prev=xcompiler
47387a3b38f7Smrg	continue
47397a3b38f7Smrg	;;
4740ff559fabSmrg
47417a3b38f7Smrg      -Xlinker)
47427a3b38f7Smrg	prev=xlinker
47437a3b38f7Smrg	continue
47447a3b38f7Smrg	;;
4745ff559fabSmrg
47467a3b38f7Smrg      -XCClinker)
47477a3b38f7Smrg	prev=xcclinker
47487a3b38f7Smrg	continue
47497a3b38f7Smrg	;;
4750ff559fabSmrg
47517a3b38f7Smrg      # -msg_* for osf cc
47527a3b38f7Smrg      -msg_*)
47537a3b38f7Smrg	func_quote_for_eval "$arg"
47547a3b38f7Smrg	arg="$func_quote_for_eval_result"
47557a3b38f7Smrg	;;
4756ff559fabSmrg
47577a3b38f7Smrg      # -64, -mips[0-9] enable 64-bit mode on the SGI compiler
47587a3b38f7Smrg      # -r[0-9][0-9]* specifies the processor on the SGI compiler
47597a3b38f7Smrg      # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler
47607a3b38f7Smrg      # +DA*, +DD* enable 64-bit mode on the HP compiler
47617a3b38f7Smrg      # -q* pass through compiler args for the IBM compiler
47627a3b38f7Smrg      # -m*, -t[45]*, -txscale* pass through architecture-specific
47637a3b38f7Smrg      # compiler args for GCC
47647a3b38f7Smrg      # -F/path gives path to uninstalled frameworks, gcc on darwin
47657a3b38f7Smrg      # -p, -pg, --coverage, -fprofile-* pass through profiling flag for GCC
47667a3b38f7Smrg      # @file GCC response files
47677a3b38f7Smrg      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
47687a3b38f7Smrg      -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*)
47697a3b38f7Smrg        func_quote_for_eval "$arg"
47707a3b38f7Smrg	arg="$func_quote_for_eval_result"
47717a3b38f7Smrg        func_append compile_command " $arg"
47727a3b38f7Smrg        func_append finalize_command " $arg"
47737a3b38f7Smrg        compiler_flags="$compiler_flags $arg"
47747a3b38f7Smrg        continue
47757a3b38f7Smrg        ;;
4776ff559fabSmrg
47777a3b38f7Smrg      # Some other compiler flag.
47787a3b38f7Smrg      -* | +*)
47797a3b38f7Smrg        func_quote_for_eval "$arg"
47807a3b38f7Smrg	arg="$func_quote_for_eval_result"
47817a3b38f7Smrg	;;
4782ff559fabSmrg
47837a3b38f7Smrg      *.$objext)
47847a3b38f7Smrg	# A standard object.
47857a3b38f7Smrg	objs="$objs $arg"
47867a3b38f7Smrg	;;
47877a3b38f7Smrg
47887a3b38f7Smrg      *.lo)
47897a3b38f7Smrg	# A libtool-controlled object.
47907a3b38f7Smrg
47917a3b38f7Smrg	# Check to see that this really is a libtool object.
47927a3b38f7Smrg	if func_lalib_unsafe_p "$arg"; then
47937a3b38f7Smrg	  pic_object=
47947a3b38f7Smrg	  non_pic_object=
47957a3b38f7Smrg
47967a3b38f7Smrg	  # Read the .lo file
47977a3b38f7Smrg	  func_source "$arg"
47987a3b38f7Smrg
47997a3b38f7Smrg	  if test -z "$pic_object" ||
48007a3b38f7Smrg	     test -z "$non_pic_object" ||
48017a3b38f7Smrg	     test "$pic_object" = none &&
48027a3b38f7Smrg	     test "$non_pic_object" = none; then
48037a3b38f7Smrg	    func_fatal_error "cannot find name of object for \`$arg'"
48047a3b38f7Smrg	  fi
48057a3b38f7Smrg
48067a3b38f7Smrg	  # Extract subdirectory from the argument.
48077a3b38f7Smrg	  func_dirname "$arg" "/" ""
48087a3b38f7Smrg	  xdir="$func_dirname_result"
48097a3b38f7Smrg
48107a3b38f7Smrg	  if test "$pic_object" != none; then
48117a3b38f7Smrg	    # Prepend the subdirectory the object is found in.
48127a3b38f7Smrg	    pic_object="$xdir$pic_object"
48137a3b38f7Smrg
48147a3b38f7Smrg	    if test "$prev" = dlfiles; then
48157a3b38f7Smrg	      if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
48167a3b38f7Smrg		dlfiles="$dlfiles $pic_object"
48177a3b38f7Smrg		prev=
48187a3b38f7Smrg		continue
48197a3b38f7Smrg	      else
48207a3b38f7Smrg		# If libtool objects are unsupported, then we need to preload.
48217a3b38f7Smrg		prev=dlprefiles
48227a3b38f7Smrg	      fi
48237a3b38f7Smrg	    fi
48247a3b38f7Smrg
48257a3b38f7Smrg	    # CHECK ME:  I think I busted this.  -Ossama
48267a3b38f7Smrg	    if test "$prev" = dlprefiles; then
48277a3b38f7Smrg	      # Preload the old-style object.
48287a3b38f7Smrg	      dlprefiles="$dlprefiles $pic_object"
48297a3b38f7Smrg	      prev=
48307a3b38f7Smrg	    fi
48317a3b38f7Smrg
48327a3b38f7Smrg	    # A PIC object.
48337a3b38f7Smrg	    func_append libobjs " $pic_object"
48347a3b38f7Smrg	    arg="$pic_object"
48357a3b38f7Smrg	  fi
48367a3b38f7Smrg
48377a3b38f7Smrg	  # Non-PIC object.
48387a3b38f7Smrg	  if test "$non_pic_object" != none; then
48397a3b38f7Smrg	    # Prepend the subdirectory the object is found in.
48407a3b38f7Smrg	    non_pic_object="$xdir$non_pic_object"
48417a3b38f7Smrg
48427a3b38f7Smrg	    # A standard non-PIC object
48437a3b38f7Smrg	    func_append non_pic_objects " $non_pic_object"
48447a3b38f7Smrg	    if test -z "$pic_object" || test "$pic_object" = none ; then
48457a3b38f7Smrg	      arg="$non_pic_object"
48467a3b38f7Smrg	    fi
48477a3b38f7Smrg	  else
48487a3b38f7Smrg	    # If the PIC object exists, use it instead.
48497a3b38f7Smrg	    # $xdir was prepended to $pic_object above.
48507a3b38f7Smrg	    non_pic_object="$pic_object"
48517a3b38f7Smrg	    func_append non_pic_objects " $non_pic_object"
48527a3b38f7Smrg	  fi
48537a3b38f7Smrg	else
48547a3b38f7Smrg	  # Only an error if not doing a dry-run.
48557a3b38f7Smrg	  if $opt_dry_run; then
48567a3b38f7Smrg	    # Extract subdirectory from the argument.
48577a3b38f7Smrg	    func_dirname "$arg" "/" ""
48587a3b38f7Smrg	    xdir="$func_dirname_result"
48597a3b38f7Smrg
48607a3b38f7Smrg	    func_lo2o "$arg"
48617a3b38f7Smrg	    pic_object=$xdir$objdir/$func_lo2o_result
48627a3b38f7Smrg	    non_pic_object=$xdir$func_lo2o_result
48637a3b38f7Smrg	    func_append libobjs " $pic_object"
48647a3b38f7Smrg	    func_append non_pic_objects " $non_pic_object"
48657a3b38f7Smrg	  else
48667a3b38f7Smrg	    func_fatal_error "\`$arg' is not a valid libtool object"
48677a3b38f7Smrg	  fi
48687a3b38f7Smrg	fi
48697a3b38f7Smrg	;;
48707a3b38f7Smrg
48717a3b38f7Smrg      *.$libext)
48727a3b38f7Smrg	# An archive.
48737a3b38f7Smrg	deplibs="$deplibs $arg"
48747a3b38f7Smrg	old_deplibs="$old_deplibs $arg"
48757a3b38f7Smrg	continue
48767a3b38f7Smrg	;;
48777a3b38f7Smrg
48787a3b38f7Smrg      *.la)
48797a3b38f7Smrg	# A libtool-controlled library.
48807a3b38f7Smrg
48817a3b38f7Smrg	if test "$prev" = dlfiles; then
48827a3b38f7Smrg	  # This library was specified with -dlopen.
48837a3b38f7Smrg	  dlfiles="$dlfiles $arg"
48847a3b38f7Smrg	  prev=
48857a3b38f7Smrg	elif test "$prev" = dlprefiles; then
48867a3b38f7Smrg	  # The library was specified with -dlpreopen.
48877a3b38f7Smrg	  dlprefiles="$dlprefiles $arg"
48887a3b38f7Smrg	  prev=
48897a3b38f7Smrg	else
48907a3b38f7Smrg	  deplibs="$deplibs $arg"
48917a3b38f7Smrg	fi
48927a3b38f7Smrg	continue
48937a3b38f7Smrg	;;
48947a3b38f7Smrg
48957a3b38f7Smrg      # Some other compiler argument.
48967a3b38f7Smrg      *)
48977a3b38f7Smrg	# Unknown arguments in both finalize_command and compile_command need
48987a3b38f7Smrg	# to be aesthetically quoted because they are evaled later.
48997a3b38f7Smrg	func_quote_for_eval "$arg"
49007a3b38f7Smrg	arg="$func_quote_for_eval_result"
49017a3b38f7Smrg	;;
49027a3b38f7Smrg      esac # arg
49037a3b38f7Smrg
49047a3b38f7Smrg      # Now actually substitute the argument into the commands.
49057a3b38f7Smrg      if test -n "$arg"; then
49067a3b38f7Smrg	func_append compile_command " $arg"
49077a3b38f7Smrg	func_append finalize_command " $arg"
49087a3b38f7Smrg      fi
49097a3b38f7Smrg    done # argument parsing loop
49107a3b38f7Smrg
49117a3b38f7Smrg    test -n "$prev" && \
49127a3b38f7Smrg      func_fatal_help "the \`$prevarg' option requires an argument"
49137a3b38f7Smrg
49147a3b38f7Smrg    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
49157a3b38f7Smrg      eval arg=\"$export_dynamic_flag_spec\"
49167a3b38f7Smrg      func_append compile_command " $arg"
49177a3b38f7Smrg      func_append finalize_command " $arg"
49187a3b38f7Smrg    fi
49197a3b38f7Smrg
49207a3b38f7Smrg    oldlibs=
49217a3b38f7Smrg    # calculate the name of the file, without its directory
49227a3b38f7Smrg    func_basename "$output"
49237a3b38f7Smrg    outputname="$func_basename_result"
49247a3b38f7Smrg    libobjs_save="$libobjs"
49257a3b38f7Smrg
49267a3b38f7Smrg    if test -n "$shlibpath_var"; then
49277a3b38f7Smrg      # get the directories listed in $shlibpath_var
49287a3b38f7Smrg      eval shlib_search_path=\`\$ECHO \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\`
4929ff559fabSmrg    else
49307a3b38f7Smrg      shlib_search_path=
4931ff559fabSmrg    fi
49327a3b38f7Smrg    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
49337a3b38f7Smrg    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
4934ff559fabSmrg
49357a3b38f7Smrg    func_dirname "$output" "/" ""
49367a3b38f7Smrg    output_objdir="$func_dirname_result$objdir"
49377a3b38f7Smrg    # Create the object directory.
49387a3b38f7Smrg    func_mkdir_p "$output_objdir"
4939ff559fabSmrg
49407a3b38f7Smrg    # Determine the type of output
49417a3b38f7Smrg    case $output in
49427a3b38f7Smrg    "")
49437a3b38f7Smrg      func_fatal_help "you must specify an output file"
49447a3b38f7Smrg      ;;
49457a3b38f7Smrg    *.$libext) linkmode=oldlib ;;
49467a3b38f7Smrg    *.lo | *.$objext) linkmode=obj ;;
49477a3b38f7Smrg    *.la) linkmode=lib ;;
49487a3b38f7Smrg    *) linkmode=prog ;; # Anything else should be a program.
49497a3b38f7Smrg    esac
49507a3b38f7Smrg
49517a3b38f7Smrg    specialdeplibs=
49527a3b38f7Smrg
49537a3b38f7Smrg    libs=
49547a3b38f7Smrg    # Find all interdependent deplibs by searching for libraries
49557a3b38f7Smrg    # that are linked more than once (e.g. -la -lb -la)
49567a3b38f7Smrg    for deplib in $deplibs; do
49577a3b38f7Smrg      if $opt_duplicate_deps ; then
49587a3b38f7Smrg	case "$libs " in
49597a3b38f7Smrg	*" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
49607a3b38f7Smrg	esac
49617a3b38f7Smrg      fi
49627a3b38f7Smrg      libs="$libs $deplib"
49637a3b38f7Smrg    done
49647a3b38f7Smrg
49657a3b38f7Smrg    if test "$linkmode" = lib; then
49667a3b38f7Smrg      libs="$predeps $libs $compiler_lib_search_path $postdeps"
49677a3b38f7Smrg
49687a3b38f7Smrg      # Compute libraries that are listed more than once in $predeps
49697a3b38f7Smrg      # $postdeps and mark them as special (i.e., whose duplicates are
49707a3b38f7Smrg      # not to be eliminated).
49717a3b38f7Smrg      pre_post_deps=
49727a3b38f7Smrg      if $opt_duplicate_compiler_generated_deps; then
49737a3b38f7Smrg	for pre_post_dep in $predeps $postdeps; do
49747a3b38f7Smrg	  case "$pre_post_deps " in
49757a3b38f7Smrg	  *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;;
49767a3b38f7Smrg	  esac
49777a3b38f7Smrg	  pre_post_deps="$pre_post_deps $pre_post_dep"
49787a3b38f7Smrg	done
49797a3b38f7Smrg      fi
49807a3b38f7Smrg      pre_post_deps=
49817a3b38f7Smrg    fi
49827a3b38f7Smrg
49837a3b38f7Smrg    deplibs=
49847a3b38f7Smrg    newdependency_libs=
49857a3b38f7Smrg    newlib_search_path=
49867a3b38f7Smrg    need_relink=no # whether we're linking any uninstalled libtool libraries
49877a3b38f7Smrg    notinst_deplibs= # not-installed libtool libraries
49887a3b38f7Smrg    notinst_path= # paths that contain not-installed libtool libraries
49897a3b38f7Smrg
49907a3b38f7Smrg    case $linkmode in
49917a3b38f7Smrg    lib)
49927a3b38f7Smrg	passes="conv dlpreopen link"
49937a3b38f7Smrg	for file in $dlfiles $dlprefiles; do
49947a3b38f7Smrg	  case $file in
49957a3b38f7Smrg	  *.la) ;;
49967a3b38f7Smrg	  *)
49977a3b38f7Smrg	    func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file"
49987a3b38f7Smrg	    ;;
49997a3b38f7Smrg	  esac
50007a3b38f7Smrg	done
50017a3b38f7Smrg	;;
50027a3b38f7Smrg    prog)
50037a3b38f7Smrg	compile_deplibs=
50047a3b38f7Smrg	finalize_deplibs=
50057a3b38f7Smrg	alldeplibs=no
50067a3b38f7Smrg	newdlfiles=
50077a3b38f7Smrg	newdlprefiles=
50087a3b38f7Smrg	passes="conv scan dlopen dlpreopen link"
50097a3b38f7Smrg	;;
50107a3b38f7Smrg    *)  passes="conv"
50117a3b38f7Smrg	;;
50127a3b38f7Smrg    esac
50137a3b38f7Smrg
50147a3b38f7Smrg    for pass in $passes; do
50157a3b38f7Smrg      # The preopen pass in lib mode reverses $deplibs; put it back here
50167a3b38f7Smrg      # so that -L comes before libs that need it for instance...
50177a3b38f7Smrg      if test "$linkmode,$pass" = "lib,link"; then
50187a3b38f7Smrg	## FIXME: Find the place where the list is rebuilt in the wrong
50197a3b38f7Smrg	##        order, and fix it there properly
50207a3b38f7Smrg        tmp_deplibs=
50217a3b38f7Smrg	for deplib in $deplibs; do
50227a3b38f7Smrg	  tmp_deplibs="$deplib $tmp_deplibs"
50237a3b38f7Smrg	done
50247a3b38f7Smrg	deplibs="$tmp_deplibs"
50257a3b38f7Smrg      fi
50267a3b38f7Smrg
50277a3b38f7Smrg      if test "$linkmode,$pass" = "lib,link" ||
50287a3b38f7Smrg	 test "$linkmode,$pass" = "prog,scan"; then
50297a3b38f7Smrg	libs="$deplibs"
50307a3b38f7Smrg	deplibs=
50317a3b38f7Smrg      fi
50327a3b38f7Smrg      if test "$linkmode" = prog; then
50337a3b38f7Smrg	case $pass in
50347a3b38f7Smrg	dlopen) libs="$dlfiles" ;;
50357a3b38f7Smrg	dlpreopen) libs="$dlprefiles" ;;
50367a3b38f7Smrg	link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
50377a3b38f7Smrg	esac
50387a3b38f7Smrg      fi
50397a3b38f7Smrg      if test "$linkmode,$pass" = "lib,dlpreopen"; then
50407a3b38f7Smrg	# Collect and forward deplibs of preopened libtool libs
50417a3b38f7Smrg	for lib in $dlprefiles; do
50427a3b38f7Smrg	  # Ignore non-libtool-libs
50437a3b38f7Smrg	  dependency_libs=
50447a3b38f7Smrg	  case $lib in
50457a3b38f7Smrg	  *.la)	func_source "$lib" ;;
50467a3b38f7Smrg	  esac
50477a3b38f7Smrg
50487a3b38f7Smrg	  # Collect preopened libtool deplibs, except any this library
50497a3b38f7Smrg	  # has declared as weak libs
50507a3b38f7Smrg	  for deplib in $dependency_libs; do
50517a3b38f7Smrg            deplib_base=`$ECHO "X$deplib" | $Xsed -e "$basename"`
50527a3b38f7Smrg	    case " $weak_libs " in
50537a3b38f7Smrg	    *" $deplib_base "*) ;;
50547a3b38f7Smrg	    *) deplibs="$deplibs $deplib" ;;
50557a3b38f7Smrg	    esac
50567a3b38f7Smrg	  done
50577a3b38f7Smrg	done
50587a3b38f7Smrg	libs="$dlprefiles"
50597a3b38f7Smrg      fi
50607a3b38f7Smrg      if test "$pass" = dlopen; then
50617a3b38f7Smrg	# Collect dlpreopened libraries
50627a3b38f7Smrg	save_deplibs="$deplibs"
50637a3b38f7Smrg	deplibs=
50647a3b38f7Smrg      fi
50657a3b38f7Smrg
50667a3b38f7Smrg      for deplib in $libs; do
50677a3b38f7Smrg	lib=
50687a3b38f7Smrg	found=no
50697a3b38f7Smrg	case $deplib in
50707a3b38f7Smrg	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
50717a3b38f7Smrg	  if test "$linkmode,$pass" = "prog,link"; then
50727a3b38f7Smrg	    compile_deplibs="$deplib $compile_deplibs"
50737a3b38f7Smrg	    finalize_deplibs="$deplib $finalize_deplibs"
50747a3b38f7Smrg	  else
50757a3b38f7Smrg	    compiler_flags="$compiler_flags $deplib"
50767a3b38f7Smrg	    if test "$linkmode" = lib ; then
50777a3b38f7Smrg		case "$new_inherited_linker_flags " in
50787a3b38f7Smrg		    *" $deplib "*) ;;
50797a3b38f7Smrg		    * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;;
50807a3b38f7Smrg		esac
50817a3b38f7Smrg	    fi
50827a3b38f7Smrg	  fi
50837a3b38f7Smrg	  continue
50847a3b38f7Smrg	  ;;
50857a3b38f7Smrg	-l*)
50867a3b38f7Smrg	  if test "$linkmode" != lib && test "$linkmode" != prog; then
50877a3b38f7Smrg	    func_warning "\`-l' is ignored for archives/objects"
50887a3b38f7Smrg	    continue
50897a3b38f7Smrg	  fi
50907a3b38f7Smrg	  func_stripname '-l' '' "$deplib"
50917a3b38f7Smrg	  name=$func_stripname_result
50927a3b38f7Smrg	  if test "$linkmode" = lib; then
50937a3b38f7Smrg	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
50947a3b38f7Smrg	  else
50957a3b38f7Smrg	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
50967a3b38f7Smrg	  fi
50977a3b38f7Smrg	  for searchdir in $searchdirs; do
50987a3b38f7Smrg	    for search_ext in .la $std_shrext .so .a; do
50997a3b38f7Smrg	      # Search the libtool library
51007a3b38f7Smrg	      lib="$searchdir/lib${name}${search_ext}"
51017a3b38f7Smrg	      if test -f "$lib"; then
51027a3b38f7Smrg		if test "$search_ext" = ".la"; then
51037a3b38f7Smrg		  found=yes
51047a3b38f7Smrg		else
51057a3b38f7Smrg		  found=no
51067a3b38f7Smrg		fi
51077a3b38f7Smrg		break 2
51087a3b38f7Smrg	      fi
51097a3b38f7Smrg	    done
51107a3b38f7Smrg	  done
51117a3b38f7Smrg	  if test "$found" != yes; then
51127a3b38f7Smrg	    # deplib doesn't seem to be a libtool library
51137a3b38f7Smrg	    if test "$linkmode,$pass" = "prog,link"; then
51147a3b38f7Smrg	      compile_deplibs="$deplib $compile_deplibs"
51157a3b38f7Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
51167a3b38f7Smrg	    else
51177a3b38f7Smrg	      deplibs="$deplib $deplibs"
51187a3b38f7Smrg	      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
51197a3b38f7Smrg	    fi
51207a3b38f7Smrg	    continue
51217a3b38f7Smrg	  else # deplib is a libtool library
51227a3b38f7Smrg	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
51237a3b38f7Smrg	    # We need to do some special things here, and not later.
51247a3b38f7Smrg	    if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
51257a3b38f7Smrg	      case " $predeps $postdeps " in
51267a3b38f7Smrg	      *" $deplib "*)
51277a3b38f7Smrg		if func_lalib_p "$lib"; then
51287a3b38f7Smrg		  library_names=
51297a3b38f7Smrg		  old_library=
51307a3b38f7Smrg		  func_source "$lib"
51317a3b38f7Smrg		  for l in $old_library $library_names; do
51327a3b38f7Smrg		    ll="$l"
51337a3b38f7Smrg		  done
51347a3b38f7Smrg		  if test "X$ll" = "X$old_library" ; then # only static version available
51357a3b38f7Smrg		    found=no
51367a3b38f7Smrg		    func_dirname "$lib" "" "."
51377a3b38f7Smrg		    ladir="$func_dirname_result"
51387a3b38f7Smrg		    lib=$ladir/$old_library
51397a3b38f7Smrg		    if test "$linkmode,$pass" = "prog,link"; then
51407a3b38f7Smrg		      compile_deplibs="$deplib $compile_deplibs"
51417a3b38f7Smrg		      finalize_deplibs="$deplib $finalize_deplibs"
51427a3b38f7Smrg		    else
51437a3b38f7Smrg		      deplibs="$deplib $deplibs"
51447a3b38f7Smrg		      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
51457a3b38f7Smrg		    fi
51467a3b38f7Smrg		    continue
51477a3b38f7Smrg		  fi
51487a3b38f7Smrg		fi
51497a3b38f7Smrg		;;
51507a3b38f7Smrg	      *) ;;
51517a3b38f7Smrg	      esac
51527a3b38f7Smrg	    fi
51537a3b38f7Smrg	  fi
51547a3b38f7Smrg	  ;; # -l
51557a3b38f7Smrg	*.ltframework)
51567a3b38f7Smrg	  if test "$linkmode,$pass" = "prog,link"; then
51577a3b38f7Smrg	    compile_deplibs="$deplib $compile_deplibs"
51587a3b38f7Smrg	    finalize_deplibs="$deplib $finalize_deplibs"
51597a3b38f7Smrg	  else
51607a3b38f7Smrg	    deplibs="$deplib $deplibs"
51617a3b38f7Smrg	    if test "$linkmode" = lib ; then
51627a3b38f7Smrg		case "$new_inherited_linker_flags " in
51637a3b38f7Smrg		    *" $deplib "*) ;;
51647a3b38f7Smrg		    * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;;
51657a3b38f7Smrg		esac
51667a3b38f7Smrg	    fi
51677a3b38f7Smrg	  fi
51687a3b38f7Smrg	  continue
51697a3b38f7Smrg	  ;;
51707a3b38f7Smrg	-L*)
51717a3b38f7Smrg	  case $linkmode in
51727a3b38f7Smrg	  lib)
51737a3b38f7Smrg	    deplibs="$deplib $deplibs"
51747a3b38f7Smrg	    test "$pass" = conv && continue
51757a3b38f7Smrg	    newdependency_libs="$deplib $newdependency_libs"
51767a3b38f7Smrg	    func_stripname '-L' '' "$deplib"
51777a3b38f7Smrg	    newlib_search_path="$newlib_search_path $func_stripname_result"
51787a3b38f7Smrg	    ;;
51797a3b38f7Smrg	  prog)
51807a3b38f7Smrg	    if test "$pass" = conv; then
51817a3b38f7Smrg	      deplibs="$deplib $deplibs"
51827a3b38f7Smrg	      continue
51837a3b38f7Smrg	    fi
51847a3b38f7Smrg	    if test "$pass" = scan; then
51857a3b38f7Smrg	      deplibs="$deplib $deplibs"
51867a3b38f7Smrg	    else
51877a3b38f7Smrg	      compile_deplibs="$deplib $compile_deplibs"
51887a3b38f7Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
51897a3b38f7Smrg	    fi
51907a3b38f7Smrg	    func_stripname '-L' '' "$deplib"
51917a3b38f7Smrg	    newlib_search_path="$newlib_search_path $func_stripname_result"
51927a3b38f7Smrg	    ;;
51937a3b38f7Smrg	  *)
51947a3b38f7Smrg	    func_warning "\`-L' is ignored for archives/objects"
51957a3b38f7Smrg	    ;;
51967a3b38f7Smrg	  esac # linkmode
51977a3b38f7Smrg	  continue
51987a3b38f7Smrg	  ;; # -L
51997a3b38f7Smrg	-R*)
52007a3b38f7Smrg	  if test "$pass" = link; then
52017a3b38f7Smrg	    func_stripname '-R' '' "$deplib"
52027a3b38f7Smrg	    dir=$func_stripname_result
52037a3b38f7Smrg	    # Make sure the xrpath contains only unique directories.
52047a3b38f7Smrg	    case "$xrpath " in
52057a3b38f7Smrg	    *" $dir "*) ;;
52067a3b38f7Smrg	    *) xrpath="$xrpath $dir" ;;
52077a3b38f7Smrg	    esac
52087a3b38f7Smrg	  fi
52097a3b38f7Smrg	  deplibs="$deplib $deplibs"
52107a3b38f7Smrg	  continue
52117a3b38f7Smrg	  ;;
52127a3b38f7Smrg	*.la) lib="$deplib" ;;
52137a3b38f7Smrg	*.$libext)
52147a3b38f7Smrg	  if test "$pass" = conv; then
52157a3b38f7Smrg	    deplibs="$deplib $deplibs"
52167a3b38f7Smrg	    continue
52177a3b38f7Smrg	  fi
52187a3b38f7Smrg	  case $linkmode in
52197a3b38f7Smrg	  lib)
52207a3b38f7Smrg	    # Linking convenience modules into shared libraries is allowed,
52217a3b38f7Smrg	    # but linking other static libraries is non-portable.
52227a3b38f7Smrg	    case " $dlpreconveniencelibs " in
52237a3b38f7Smrg	    *" $deplib "*) ;;
52247a3b38f7Smrg	    *)
52257a3b38f7Smrg	      valid_a_lib=no
52267a3b38f7Smrg	      case $deplibs_check_method in
52277a3b38f7Smrg		match_pattern*)
52287a3b38f7Smrg		  set dummy $deplibs_check_method; shift
52297a3b38f7Smrg		  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
52307a3b38f7Smrg		  if eval "\$ECHO \"X$deplib\"" 2>/dev/null | $Xsed -e 10q \
52317a3b38f7Smrg		    | $EGREP "$match_pattern_regex" > /dev/null; then
52327a3b38f7Smrg		    valid_a_lib=yes
52337a3b38f7Smrg		  fi
52347a3b38f7Smrg		;;
52357a3b38f7Smrg		pass_all)
52367a3b38f7Smrg		  valid_a_lib=yes
52377a3b38f7Smrg		;;
52387a3b38f7Smrg	      esac
52397a3b38f7Smrg	      if test "$valid_a_lib" != yes; then
52407a3b38f7Smrg		$ECHO
52417a3b38f7Smrg		$ECHO "*** Warning: Trying to link with static lib archive $deplib."
52427a3b38f7Smrg		$ECHO "*** I have the capability to make that library automatically link in when"
52437a3b38f7Smrg		$ECHO "*** you link to this library.  But I can only do this if you have a"
52447a3b38f7Smrg		$ECHO "*** shared version of the library, which you do not appear to have"
52457a3b38f7Smrg		$ECHO "*** because the file extensions .$libext of this argument makes me believe"
52467a3b38f7Smrg		$ECHO "*** that it is just a static archive that I should not use here."
52477a3b38f7Smrg	      else
52487a3b38f7Smrg		$ECHO
52497a3b38f7Smrg		$ECHO "*** Warning: Linking the shared library $output against the"
52507a3b38f7Smrg		$ECHO "*** static library $deplib is not portable!"
52517a3b38f7Smrg		deplibs="$deplib $deplibs"
52527a3b38f7Smrg	      fi
52537a3b38f7Smrg	      ;;
52547a3b38f7Smrg	    esac
52557a3b38f7Smrg	    continue
52567a3b38f7Smrg	    ;;
52577a3b38f7Smrg	  prog)
52587a3b38f7Smrg	    if test "$pass" != link; then
52597a3b38f7Smrg	      deplibs="$deplib $deplibs"
52607a3b38f7Smrg	    else
52617a3b38f7Smrg	      compile_deplibs="$deplib $compile_deplibs"
52627a3b38f7Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
52637a3b38f7Smrg	    fi
52647a3b38f7Smrg	    continue
52657a3b38f7Smrg	    ;;
52667a3b38f7Smrg	  esac # linkmode
52677a3b38f7Smrg	  ;; # *.$libext
52687a3b38f7Smrg	*.lo | *.$objext)
52697a3b38f7Smrg	  if test "$pass" = conv; then
52707a3b38f7Smrg	    deplibs="$deplib $deplibs"
52717a3b38f7Smrg	  elif test "$linkmode" = prog; then
52727a3b38f7Smrg	    if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
52737a3b38f7Smrg	      # If there is no dlopen support or we're linking statically,
52747a3b38f7Smrg	      # we need to preload.
52757a3b38f7Smrg	      newdlprefiles="$newdlprefiles $deplib"
52767a3b38f7Smrg	      compile_deplibs="$deplib $compile_deplibs"
52777a3b38f7Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
52787a3b38f7Smrg	    else
52797a3b38f7Smrg	      newdlfiles="$newdlfiles $deplib"
52807a3b38f7Smrg	    fi
52817a3b38f7Smrg	  fi
52827a3b38f7Smrg	  continue
52837a3b38f7Smrg	  ;;
52847a3b38f7Smrg	%DEPLIBS%)
52857a3b38f7Smrg	  alldeplibs=yes
52867a3b38f7Smrg	  continue
52877a3b38f7Smrg	  ;;
52887a3b38f7Smrg	esac # case $deplib
52897a3b38f7Smrg
52907a3b38f7Smrg	if test "$found" = yes || test -f "$lib"; then :
52917a3b38f7Smrg	else
52927a3b38f7Smrg	  func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'"
52937a3b38f7Smrg	fi
52947a3b38f7Smrg
52957a3b38f7Smrg	# Check to see that this really is a libtool archive.
52967a3b38f7Smrg	func_lalib_unsafe_p "$lib" \
52977a3b38f7Smrg	  || func_fatal_error "\`$lib' is not a valid libtool archive"
52987a3b38f7Smrg
52997a3b38f7Smrg	func_dirname "$lib" "" "."
53007a3b38f7Smrg	ladir="$func_dirname_result"
53017a3b38f7Smrg
53027a3b38f7Smrg	dlname=
53037a3b38f7Smrg	dlopen=
53047a3b38f7Smrg	dlpreopen=
53057a3b38f7Smrg	libdir=
53067a3b38f7Smrg	library_names=
53077a3b38f7Smrg	old_library=
53087a3b38f7Smrg	inherited_linker_flags=
53097a3b38f7Smrg	# If the library was installed with an old release of libtool,
53107a3b38f7Smrg	# it will not redefine variables installed, or shouldnotlink
53117a3b38f7Smrg	installed=yes
53127a3b38f7Smrg	shouldnotlink=no
53137a3b38f7Smrg	avoidtemprpath=
53147a3b38f7Smrg
53157a3b38f7Smrg
53167a3b38f7Smrg	# Read the .la file
53177a3b38f7Smrg	func_source "$lib"
53187a3b38f7Smrg
53197a3b38f7Smrg	# Convert "-framework foo" to "foo.ltframework"
53207a3b38f7Smrg	if test -n "$inherited_linker_flags"; then
53217a3b38f7Smrg	  tmp_inherited_linker_flags=`$ECHO "X$inherited_linker_flags" | $Xsed -e 's/-framework \([^ $]*\)/\1.ltframework/g'`
53227a3b38f7Smrg	  for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
53237a3b38f7Smrg	    case " $new_inherited_linker_flags " in
53247a3b38f7Smrg	      *" $tmp_inherited_linker_flag "*) ;;
53257a3b38f7Smrg	      *) new_inherited_linker_flags="$new_inherited_linker_flags $tmp_inherited_linker_flag";;
53267a3b38f7Smrg	    esac
53277a3b38f7Smrg	  done
53287a3b38f7Smrg	fi
53297a3b38f7Smrg	dependency_libs=`$ECHO "X $dependency_libs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
53307a3b38f7Smrg	if test "$linkmode,$pass" = "lib,link" ||
53317a3b38f7Smrg	   test "$linkmode,$pass" = "prog,scan" ||
53327a3b38f7Smrg	   { test "$linkmode" != prog && test "$linkmode" != lib; }; then
53337a3b38f7Smrg	  test -n "$dlopen" && dlfiles="$dlfiles $dlopen"
53347a3b38f7Smrg	  test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen"
53357a3b38f7Smrg	fi
53367a3b38f7Smrg
53377a3b38f7Smrg	if test "$pass" = conv; then
53387a3b38f7Smrg	  # Only check for convenience libraries
53397a3b38f7Smrg	  deplibs="$lib $deplibs"
53407a3b38f7Smrg	  if test -z "$libdir"; then
53417a3b38f7Smrg	    if test -z "$old_library"; then
53427a3b38f7Smrg	      func_fatal_error "cannot find name of link library for \`$lib'"
53437a3b38f7Smrg	    fi
53447a3b38f7Smrg	    # It is a libtool convenience library, so add in its objects.
53457a3b38f7Smrg	    convenience="$convenience $ladir/$objdir/$old_library"
53467a3b38f7Smrg	    old_convenience="$old_convenience $ladir/$objdir/$old_library"
53477a3b38f7Smrg	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
53487a3b38f7Smrg	    func_fatal_error "\`$lib' is not a convenience library"
53497a3b38f7Smrg	  fi
53507a3b38f7Smrg	  tmp_libs=
53517a3b38f7Smrg	  for deplib in $dependency_libs; do
53527a3b38f7Smrg	    deplibs="$deplib $deplibs"
53537a3b38f7Smrg	    if $opt_duplicate_deps ; then
53547a3b38f7Smrg	      case "$tmp_libs " in
53557a3b38f7Smrg	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
53567a3b38f7Smrg	      esac
53577a3b38f7Smrg	    fi
53587a3b38f7Smrg	    tmp_libs="$tmp_libs $deplib"
53597a3b38f7Smrg	  done
53607a3b38f7Smrg	  continue
53617a3b38f7Smrg	fi # $pass = conv
53627a3b38f7Smrg
53637a3b38f7Smrg
53647a3b38f7Smrg	# Get the name of the library we link against.
53657a3b38f7Smrg	linklib=
53667a3b38f7Smrg	for l in $old_library $library_names; do
53677a3b38f7Smrg	  linklib="$l"
53687a3b38f7Smrg	done
53697a3b38f7Smrg	if test -z "$linklib"; then
53707a3b38f7Smrg	  func_fatal_error "cannot find name of link library for \`$lib'"
53717a3b38f7Smrg	fi
53727a3b38f7Smrg
53737a3b38f7Smrg	# This library was specified with -dlopen.
53747a3b38f7Smrg	if test "$pass" = dlopen; then
53757a3b38f7Smrg	  if test -z "$libdir"; then
53767a3b38f7Smrg	    func_fatal_error "cannot -dlopen a convenience library: \`$lib'"
53777a3b38f7Smrg	  fi
53787a3b38f7Smrg	  if test -z "$dlname" ||
53797a3b38f7Smrg	     test "$dlopen_support" != yes ||
53807a3b38f7Smrg	     test "$build_libtool_libs" = no; then
53817a3b38f7Smrg	    # If there is no dlname, no dlopen support or we're linking
53827a3b38f7Smrg	    # statically, we need to preload.  We also need to preload any
53837a3b38f7Smrg	    # dependent libraries so libltdl's deplib preloader doesn't
53847a3b38f7Smrg	    # bomb out in the load deplibs phase.
53857a3b38f7Smrg	    dlprefiles="$dlprefiles $lib $dependency_libs"
53867a3b38f7Smrg	  else
53877a3b38f7Smrg	    newdlfiles="$newdlfiles $lib"
53887a3b38f7Smrg	  fi
53897a3b38f7Smrg	  continue
53907a3b38f7Smrg	fi # $pass = dlopen
53917a3b38f7Smrg
53927a3b38f7Smrg	# We need an absolute path.
53937a3b38f7Smrg	case $ladir in
53947a3b38f7Smrg	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
53957a3b38f7Smrg	*)
53967a3b38f7Smrg	  abs_ladir=`cd "$ladir" && pwd`
53977a3b38f7Smrg	  if test -z "$abs_ladir"; then
53987a3b38f7Smrg	    func_warning "cannot determine absolute directory name of \`$ladir'"
53997a3b38f7Smrg	    func_warning "passing it literally to the linker, although it might fail"
54007a3b38f7Smrg	    abs_ladir="$ladir"
54017a3b38f7Smrg	  fi
54027a3b38f7Smrg	  ;;
54037a3b38f7Smrg	esac
54047a3b38f7Smrg	func_basename "$lib"
54057a3b38f7Smrg	laname="$func_basename_result"
54067a3b38f7Smrg
54077a3b38f7Smrg	# Find the relevant object directory and library name.
54087a3b38f7Smrg	if test "X$installed" = Xyes; then
54097a3b38f7Smrg	  if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
54107a3b38f7Smrg	    func_warning "library \`$lib' was moved."
54117a3b38f7Smrg	    dir="$ladir"
54127a3b38f7Smrg	    absdir="$abs_ladir"
54137a3b38f7Smrg	    libdir="$abs_ladir"
54147a3b38f7Smrg	  else
54157a3b38f7Smrg	    dir="$libdir"
54167a3b38f7Smrg	    absdir="$libdir"
54177a3b38f7Smrg	  fi
54187a3b38f7Smrg	  test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
54197a3b38f7Smrg	else
54207a3b38f7Smrg	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
54217a3b38f7Smrg	    dir="$ladir"
54227a3b38f7Smrg	    absdir="$abs_ladir"
54237a3b38f7Smrg	    # Remove this search path later
54247a3b38f7Smrg	    notinst_path="$notinst_path $abs_ladir"
54257a3b38f7Smrg	  else
54267a3b38f7Smrg	    dir="$ladir/$objdir"
54277a3b38f7Smrg	    absdir="$abs_ladir/$objdir"
54287a3b38f7Smrg	    # Remove this search path later
54297a3b38f7Smrg	    notinst_path="$notinst_path $abs_ladir"
54307a3b38f7Smrg	  fi
54317a3b38f7Smrg	fi # $installed = yes
54327a3b38f7Smrg	func_stripname 'lib' '.la' "$laname"
54337a3b38f7Smrg	name=$func_stripname_result
54347a3b38f7Smrg
54357a3b38f7Smrg	# This library was specified with -dlpreopen.
54367a3b38f7Smrg	if test "$pass" = dlpreopen; then
54377a3b38f7Smrg	  if test -z "$libdir" && test "$linkmode" = prog; then
54387a3b38f7Smrg	    func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'"
54397a3b38f7Smrg	  fi
54407a3b38f7Smrg	  # Prefer using a static library (so that no silly _DYNAMIC symbols
54417a3b38f7Smrg	  # are required to link).
54427a3b38f7Smrg	  if test -n "$old_library"; then
54437a3b38f7Smrg	    newdlprefiles="$newdlprefiles $dir/$old_library"
54447a3b38f7Smrg	    # Keep a list of preopened convenience libraries to check
54457a3b38f7Smrg	    # that they are being used correctly in the link pass.
54467a3b38f7Smrg	    test -z "$libdir" && \
54477a3b38f7Smrg		dlpreconveniencelibs="$dlpreconveniencelibs $dir/$old_library"
54487a3b38f7Smrg	  # Otherwise, use the dlname, so that lt_dlopen finds it.
54497a3b38f7Smrg	  elif test -n "$dlname"; then
54507a3b38f7Smrg	    newdlprefiles="$newdlprefiles $dir/$dlname"
54517a3b38f7Smrg	  else
54527a3b38f7Smrg	    newdlprefiles="$newdlprefiles $dir/$linklib"
54537a3b38f7Smrg	  fi
54547a3b38f7Smrg	fi # $pass = dlpreopen
54557a3b38f7Smrg
54567a3b38f7Smrg	if test -z "$libdir"; then
54577a3b38f7Smrg	  # Link the convenience library
54587a3b38f7Smrg	  if test "$linkmode" = lib; then
54597a3b38f7Smrg	    deplibs="$dir/$old_library $deplibs"
54607a3b38f7Smrg	  elif test "$linkmode,$pass" = "prog,link"; then
54617a3b38f7Smrg	    compile_deplibs="$dir/$old_library $compile_deplibs"
54627a3b38f7Smrg	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
54637a3b38f7Smrg	  else
54647a3b38f7Smrg	    deplibs="$lib $deplibs" # used for prog,scan pass
54657a3b38f7Smrg	  fi
54667a3b38f7Smrg	  continue
54677a3b38f7Smrg	fi
54687a3b38f7Smrg
54697a3b38f7Smrg
54707a3b38f7Smrg	if test "$linkmode" = prog && test "$pass" != link; then
54717a3b38f7Smrg	  newlib_search_path="$newlib_search_path $ladir"
54727a3b38f7Smrg	  deplibs="$lib $deplibs"
54737a3b38f7Smrg
54747a3b38f7Smrg	  linkalldeplibs=no
54757a3b38f7Smrg	  if test "$link_all_deplibs" != no || test -z "$library_names" ||
54767a3b38f7Smrg	     test "$build_libtool_libs" = no; then
54777a3b38f7Smrg	    linkalldeplibs=yes
54787a3b38f7Smrg	  fi
54797a3b38f7Smrg
54807a3b38f7Smrg	  tmp_libs=
54817a3b38f7Smrg	  for deplib in $dependency_libs; do
54827a3b38f7Smrg	    case $deplib in
54837a3b38f7Smrg	    -L*) func_stripname '-L' '' "$deplib"
54847a3b38f7Smrg	         newlib_search_path="$newlib_search_path $func_stripname_result"
54857a3b38f7Smrg		 ;;
54867a3b38f7Smrg	    esac
54877a3b38f7Smrg	    # Need to link against all dependency_libs?
54887a3b38f7Smrg	    if test "$linkalldeplibs" = yes; then
54897a3b38f7Smrg	      deplibs="$deplib $deplibs"
54907a3b38f7Smrg	    else
54917a3b38f7Smrg	      # Need to hardcode shared library paths
54927a3b38f7Smrg	      # or/and link against static libraries
54937a3b38f7Smrg	      newdependency_libs="$deplib $newdependency_libs"
54947a3b38f7Smrg	    fi
54957a3b38f7Smrg	    if $opt_duplicate_deps ; then
54967a3b38f7Smrg	      case "$tmp_libs " in
54977a3b38f7Smrg	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
54987a3b38f7Smrg	      esac
54997a3b38f7Smrg	    fi
55007a3b38f7Smrg	    tmp_libs="$tmp_libs $deplib"
55017a3b38f7Smrg	  done # for deplib
55027a3b38f7Smrg	  continue
55037a3b38f7Smrg	fi # $linkmode = prog...
55047a3b38f7Smrg
55057a3b38f7Smrg	if test "$linkmode,$pass" = "prog,link"; then
55067a3b38f7Smrg	  if test -n "$library_names" &&
55077a3b38f7Smrg	     { { test "$prefer_static_libs" = no ||
55087a3b38f7Smrg	         test "$prefer_static_libs,$installed" = "built,yes"; } ||
55097a3b38f7Smrg	       test -z "$old_library"; }; then
55107a3b38f7Smrg	    # We need to hardcode the library path
55117a3b38f7Smrg	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
55127a3b38f7Smrg	      # Make sure the rpath contains only unique directories.
55137a3b38f7Smrg	      case "$temp_rpath:" in
55147a3b38f7Smrg	      *"$absdir:"*) ;;
55157a3b38f7Smrg	      *) temp_rpath="$temp_rpath$absdir:" ;;
55167a3b38f7Smrg	      esac
55177a3b38f7Smrg	    fi
55187a3b38f7Smrg
55197a3b38f7Smrg	    # Hardcode the library path.
55207a3b38f7Smrg	    # Skip directories that are in the system default run-time
55217a3b38f7Smrg	    # search path.
55227a3b38f7Smrg	    case " $sys_lib_dlsearch_path " in
55237a3b38f7Smrg	    *" $absdir "*) ;;
55247a3b38f7Smrg	    *)
55257a3b38f7Smrg	      case "$compile_rpath " in
55267a3b38f7Smrg	      *" $absdir "*) ;;
55277a3b38f7Smrg	      *) compile_rpath="$compile_rpath $absdir"
55287a3b38f7Smrg	      esac
55297a3b38f7Smrg	      ;;
55307a3b38f7Smrg	    esac
55317a3b38f7Smrg	    case " $sys_lib_dlsearch_path " in
55327a3b38f7Smrg	    *" $libdir "*) ;;
55337a3b38f7Smrg	    *)
55347a3b38f7Smrg	      case "$finalize_rpath " in
55357a3b38f7Smrg	      *" $libdir "*) ;;
55367a3b38f7Smrg	      *) finalize_rpath="$finalize_rpath $libdir"
55377a3b38f7Smrg	      esac
55387a3b38f7Smrg	      ;;
55397a3b38f7Smrg	    esac
55407a3b38f7Smrg	  fi # $linkmode,$pass = prog,link...
55417a3b38f7Smrg
55427a3b38f7Smrg	  if test "$alldeplibs" = yes &&
55437a3b38f7Smrg	     { test "$deplibs_check_method" = pass_all ||
55447a3b38f7Smrg	       { test "$build_libtool_libs" = yes &&
55457a3b38f7Smrg		 test -n "$library_names"; }; }; then
55467a3b38f7Smrg	    # We only need to search for static libraries
55477a3b38f7Smrg	    continue
55487a3b38f7Smrg	  fi
55497a3b38f7Smrg	fi
55507a3b38f7Smrg
55517a3b38f7Smrg	link_static=no # Whether the deplib will be linked statically
55527a3b38f7Smrg	use_static_libs=$prefer_static_libs
55537a3b38f7Smrg	if test "$use_static_libs" = built && test "$installed" = yes; then
55547a3b38f7Smrg	  use_static_libs=no
55557a3b38f7Smrg	fi
55567a3b38f7Smrg	if test -n "$library_names" &&
55577a3b38f7Smrg	   { test "$use_static_libs" = no || test -z "$old_library"; }; then
55587a3b38f7Smrg	  case $host in
55597a3b38f7Smrg	  *cygwin* | *mingw* | *cegcc*)
55607a3b38f7Smrg	      # No point in relinking DLLs because paths are not encoded
55617a3b38f7Smrg	      notinst_deplibs="$notinst_deplibs $lib"
55627a3b38f7Smrg	      need_relink=no
55637a3b38f7Smrg	    ;;
55647a3b38f7Smrg	  *)
55657a3b38f7Smrg	    if test "$installed" = no; then
55667a3b38f7Smrg	      notinst_deplibs="$notinst_deplibs $lib"
55677a3b38f7Smrg	      need_relink=yes
55687a3b38f7Smrg	    fi
55697a3b38f7Smrg	    ;;
55707a3b38f7Smrg	  esac
55717a3b38f7Smrg	  # This is a shared library
55727a3b38f7Smrg
55737a3b38f7Smrg	  # Warn about portability, can't link against -module's on some
55747a3b38f7Smrg	  # systems (darwin).  Don't bleat about dlopened modules though!
55757a3b38f7Smrg	  dlopenmodule=""
55767a3b38f7Smrg	  for dlpremoduletest in $dlprefiles; do
55777a3b38f7Smrg	    if test "X$dlpremoduletest" = "X$lib"; then
55787a3b38f7Smrg	      dlopenmodule="$dlpremoduletest"
55797a3b38f7Smrg	      break
55807a3b38f7Smrg	    fi
55817a3b38f7Smrg	  done
55827a3b38f7Smrg	  if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then
55837a3b38f7Smrg	    $ECHO
55847a3b38f7Smrg	    if test "$linkmode" = prog; then
55857a3b38f7Smrg	      $ECHO "*** Warning: Linking the executable $output against the loadable module"
55867a3b38f7Smrg	    else
55877a3b38f7Smrg	      $ECHO "*** Warning: Linking the shared library $output against the loadable module"
55887a3b38f7Smrg	    fi
55897a3b38f7Smrg	    $ECHO "*** $linklib is not portable!"
55907a3b38f7Smrg	  fi
55917a3b38f7Smrg	  if test "$linkmode" = lib &&
55927a3b38f7Smrg	     test "$hardcode_into_libs" = yes; then
55937a3b38f7Smrg	    # Hardcode the library path.
55947a3b38f7Smrg	    # Skip directories that are in the system default run-time
55957a3b38f7Smrg	    # search path.
55967a3b38f7Smrg	    case " $sys_lib_dlsearch_path " in
55977a3b38f7Smrg	    *" $absdir "*) ;;
55987a3b38f7Smrg	    *)
55997a3b38f7Smrg	      case "$compile_rpath " in
56007a3b38f7Smrg	      *" $absdir "*) ;;
56017a3b38f7Smrg	      *) compile_rpath="$compile_rpath $absdir"
56027a3b38f7Smrg	      esac
56037a3b38f7Smrg	      ;;
56047a3b38f7Smrg	    esac
56057a3b38f7Smrg	    case " $sys_lib_dlsearch_path " in
56067a3b38f7Smrg	    *" $libdir "*) ;;
56077a3b38f7Smrg	    *)
56087a3b38f7Smrg	      case "$finalize_rpath " in
56097a3b38f7Smrg	      *" $libdir "*) ;;
56107a3b38f7Smrg	      *) finalize_rpath="$finalize_rpath $libdir"
56117a3b38f7Smrg	      esac
56127a3b38f7Smrg	      ;;
56137a3b38f7Smrg	    esac
56147a3b38f7Smrg	  fi
56157a3b38f7Smrg
56167a3b38f7Smrg	  if test -n "$old_archive_from_expsyms_cmds"; then
56177a3b38f7Smrg	    # figure out the soname
56187a3b38f7Smrg	    set dummy $library_names
56197a3b38f7Smrg	    shift
56207a3b38f7Smrg	    realname="$1"
56217a3b38f7Smrg	    shift
56227a3b38f7Smrg	    libname=`eval "\\$ECHO \"$libname_spec\""`
56237a3b38f7Smrg	    # use dlname if we got it. it's perfectly good, no?
56247a3b38f7Smrg	    if test -n "$dlname"; then
56257a3b38f7Smrg	      soname="$dlname"
56267a3b38f7Smrg	    elif test -n "$soname_spec"; then
56277a3b38f7Smrg	      # bleh windows
56287a3b38f7Smrg	      case $host in
56297a3b38f7Smrg	      *cygwin* | mingw* | *cegcc*)
56307a3b38f7Smrg	        func_arith $current - $age
56317a3b38f7Smrg		major=$func_arith_result
56327a3b38f7Smrg		versuffix="-$major"
56337a3b38f7Smrg		;;
56347a3b38f7Smrg	      esac
56357a3b38f7Smrg	      eval soname=\"$soname_spec\"
56367a3b38f7Smrg	    else
56377a3b38f7Smrg	      soname="$realname"
56387a3b38f7Smrg	    fi
56397a3b38f7Smrg
56407a3b38f7Smrg	    # Make a new name for the extract_expsyms_cmds to use
56417a3b38f7Smrg	    soroot="$soname"
56427a3b38f7Smrg	    func_basename "$soroot"
56437a3b38f7Smrg	    soname="$func_basename_result"
56447a3b38f7Smrg	    func_stripname 'lib' '.dll' "$soname"
56457a3b38f7Smrg	    newlib=libimp-$func_stripname_result.a
56467a3b38f7Smrg
56477a3b38f7Smrg	    # If the library has no export list, then create one now
56487a3b38f7Smrg	    if test -f "$output_objdir/$soname-def"; then :
56497a3b38f7Smrg	    else
56507a3b38f7Smrg	      func_verbose "extracting exported symbol list from \`$soname'"
56517a3b38f7Smrg	      func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
56527a3b38f7Smrg	    fi
56537a3b38f7Smrg
56547a3b38f7Smrg	    # Create $newlib
56557a3b38f7Smrg	    if test -f "$output_objdir/$newlib"; then :; else
56567a3b38f7Smrg	      func_verbose "generating import library for \`$soname'"
56577a3b38f7Smrg	      func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
56587a3b38f7Smrg	    fi
56597a3b38f7Smrg	    # make sure the library variables are pointing to the new library
56607a3b38f7Smrg	    dir=$output_objdir
56617a3b38f7Smrg	    linklib=$newlib
56627a3b38f7Smrg	  fi # test -n "$old_archive_from_expsyms_cmds"
56637a3b38f7Smrg
56647a3b38f7Smrg	  if test "$linkmode" = prog || test "$mode" != relink; then
56657a3b38f7Smrg	    add_shlibpath=
56667a3b38f7Smrg	    add_dir=
56677a3b38f7Smrg	    add=
56687a3b38f7Smrg	    lib_linked=yes
56697a3b38f7Smrg	    case $hardcode_action in
56707a3b38f7Smrg	    immediate | unsupported)
56717a3b38f7Smrg	      if test "$hardcode_direct" = no; then
56727a3b38f7Smrg		add="$dir/$linklib"
56737a3b38f7Smrg		case $host in
56747a3b38f7Smrg		  *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
56757a3b38f7Smrg		  *-*-sysv4*uw2*) add_dir="-L$dir" ;;
56767a3b38f7Smrg		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
56777a3b38f7Smrg		    *-*-unixware7*) add_dir="-L$dir" ;;
56787a3b38f7Smrg		  *-*-darwin* )
56797a3b38f7Smrg		    # if the lib is a (non-dlopened) module then we can not
56807a3b38f7Smrg		    # link against it, someone is ignoring the earlier warnings
56817a3b38f7Smrg		    if /usr/bin/file -L $add 2> /dev/null |
56827a3b38f7Smrg			 $GREP ": [^:]* bundle" >/dev/null ; then
56837a3b38f7Smrg		      if test "X$dlopenmodule" != "X$lib"; then
56847a3b38f7Smrg			$ECHO "*** Warning: lib $linklib is a module, not a shared library"
56857a3b38f7Smrg			if test -z "$old_library" ; then
56867a3b38f7Smrg			  $ECHO
56877a3b38f7Smrg			  $ECHO "*** And there doesn't seem to be a static archive available"
56887a3b38f7Smrg			  $ECHO "*** The link will probably fail, sorry"
56897a3b38f7Smrg			else
56907a3b38f7Smrg			  add="$dir/$old_library"
56917a3b38f7Smrg			fi
56927a3b38f7Smrg		      elif test -n "$old_library"; then
56937a3b38f7Smrg			add="$dir/$old_library"
56947a3b38f7Smrg		      fi
56957a3b38f7Smrg		    fi
56967a3b38f7Smrg		esac
56977a3b38f7Smrg	      elif test "$hardcode_minus_L" = no; then
56987a3b38f7Smrg		case $host in
56997a3b38f7Smrg		*-*-sunos*) add_shlibpath="$dir" ;;
57007a3b38f7Smrg		esac
57017a3b38f7Smrg		add_dir="-L$dir"
57027a3b38f7Smrg		add="-l$name"
57037a3b38f7Smrg	      elif test "$hardcode_shlibpath_var" = no; then
57047a3b38f7Smrg		add_shlibpath="$dir"
57057a3b38f7Smrg		add="-l$name"
57067a3b38f7Smrg	      else
57077a3b38f7Smrg		lib_linked=no
57087a3b38f7Smrg	      fi
57097a3b38f7Smrg	      ;;
57107a3b38f7Smrg	    relink)
57117a3b38f7Smrg	      if test "$hardcode_direct" = yes &&
57127a3b38f7Smrg	         test "$hardcode_direct_absolute" = no; then
57137a3b38f7Smrg		add="$dir/$linklib"
57147a3b38f7Smrg	      elif test "$hardcode_minus_L" = yes; then
57157a3b38f7Smrg		add_dir="-L$dir"
57167a3b38f7Smrg		# Try looking first in the location we're being installed to.
57177a3b38f7Smrg		if test -n "$inst_prefix_dir"; then
57187a3b38f7Smrg		  case $libdir in
57197a3b38f7Smrg		    [\\/]*)
57207a3b38f7Smrg		      add_dir="$add_dir -L$inst_prefix_dir$libdir"
57217a3b38f7Smrg		      ;;
57227a3b38f7Smrg		  esac
57237a3b38f7Smrg		fi
57247a3b38f7Smrg		add="-l$name"
57257a3b38f7Smrg	      elif test "$hardcode_shlibpath_var" = yes; then
57267a3b38f7Smrg		add_shlibpath="$dir"
57277a3b38f7Smrg		add="-l$name"
57287a3b38f7Smrg	      else
57297a3b38f7Smrg		lib_linked=no
57307a3b38f7Smrg	      fi
57317a3b38f7Smrg	      ;;
57327a3b38f7Smrg	    *) lib_linked=no ;;
57337a3b38f7Smrg	    esac
57347a3b38f7Smrg
57357a3b38f7Smrg	    if test "$lib_linked" != yes; then
57367a3b38f7Smrg	      func_fatal_configuration "unsupported hardcode properties"
57377a3b38f7Smrg	    fi
57387a3b38f7Smrg
57397a3b38f7Smrg	    if test -n "$add_shlibpath"; then
57407a3b38f7Smrg	      case :$compile_shlibpath: in
57417a3b38f7Smrg	      *":$add_shlibpath:"*) ;;
57427a3b38f7Smrg	      *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;;
57437a3b38f7Smrg	      esac
57447a3b38f7Smrg	    fi
57457a3b38f7Smrg	    if test "$linkmode" = prog; then
57467a3b38f7Smrg	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
57477a3b38f7Smrg	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
57487a3b38f7Smrg	    else
57497a3b38f7Smrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
57507a3b38f7Smrg	      test -n "$add" && deplibs="$add $deplibs"
57517a3b38f7Smrg	      if test "$hardcode_direct" != yes &&
57527a3b38f7Smrg		 test "$hardcode_minus_L" != yes &&
57537a3b38f7Smrg		 test "$hardcode_shlibpath_var" = yes; then
57547a3b38f7Smrg		case :$finalize_shlibpath: in
57557a3b38f7Smrg		*":$libdir:"*) ;;
57567a3b38f7Smrg		*) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
57577a3b38f7Smrg		esac
57587a3b38f7Smrg	      fi
57597a3b38f7Smrg	    fi
57607a3b38f7Smrg	  fi
57617a3b38f7Smrg
57627a3b38f7Smrg	  if test "$linkmode" = prog || test "$mode" = relink; then
57637a3b38f7Smrg	    add_shlibpath=
57647a3b38f7Smrg	    add_dir=
57657a3b38f7Smrg	    add=
57667a3b38f7Smrg	    # Finalize command for both is simple: just hardcode it.
57677a3b38f7Smrg	    if test "$hardcode_direct" = yes &&
57687a3b38f7Smrg	       test "$hardcode_direct_absolute" = no; then
57697a3b38f7Smrg	      add="$libdir/$linklib"
57707a3b38f7Smrg	    elif test "$hardcode_minus_L" = yes; then
57717a3b38f7Smrg	      add_dir="-L$libdir"
57727a3b38f7Smrg	      add="-l$name"
57737a3b38f7Smrg	    elif test "$hardcode_shlibpath_var" = yes; then
57747a3b38f7Smrg	      case :$finalize_shlibpath: in
57757a3b38f7Smrg	      *":$libdir:"*) ;;
57767a3b38f7Smrg	      *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
57777a3b38f7Smrg	      esac
57787a3b38f7Smrg	      add="-l$name"
57797a3b38f7Smrg	    elif test "$hardcode_automatic" = yes; then
57807a3b38f7Smrg	      if test -n "$inst_prefix_dir" &&
57817a3b38f7Smrg		 test -f "$inst_prefix_dir$libdir/$linklib" ; then
57827a3b38f7Smrg		add="$inst_prefix_dir$libdir/$linklib"
57837a3b38f7Smrg	      else
57847a3b38f7Smrg		add="$libdir/$linklib"
57857a3b38f7Smrg	      fi
57867a3b38f7Smrg	    else
57877a3b38f7Smrg	      # We cannot seem to hardcode it, guess we'll fake it.
57887a3b38f7Smrg	      add_dir="-L$libdir"
57897a3b38f7Smrg	      # Try looking first in the location we're being installed to.
57907a3b38f7Smrg	      if test -n "$inst_prefix_dir"; then
57917a3b38f7Smrg		case $libdir in
57927a3b38f7Smrg		  [\\/]*)
57937a3b38f7Smrg		    add_dir="$add_dir -L$inst_prefix_dir$libdir"
57947a3b38f7Smrg		    ;;
57957a3b38f7Smrg		esac
57967a3b38f7Smrg	      fi
57977a3b38f7Smrg	      add="-l$name"
57987a3b38f7Smrg	    fi
57997a3b38f7Smrg
58007a3b38f7Smrg	    if test "$linkmode" = prog; then
58017a3b38f7Smrg	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
58027a3b38f7Smrg	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
58037a3b38f7Smrg	    else
58047a3b38f7Smrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
58057a3b38f7Smrg	      test -n "$add" && deplibs="$add $deplibs"
58067a3b38f7Smrg	    fi
58077a3b38f7Smrg	  fi
58087a3b38f7Smrg	elif test "$linkmode" = prog; then
58097a3b38f7Smrg	  # Here we assume that one of hardcode_direct or hardcode_minus_L
58107a3b38f7Smrg	  # is not unsupported.  This is valid on all known static and
58117a3b38f7Smrg	  # shared platforms.
58127a3b38f7Smrg	  if test "$hardcode_direct" != unsupported; then
58137a3b38f7Smrg	    test -n "$old_library" && linklib="$old_library"
58147a3b38f7Smrg	    compile_deplibs="$dir/$linklib $compile_deplibs"
58157a3b38f7Smrg	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
58167a3b38f7Smrg	  else
58177a3b38f7Smrg	    compile_deplibs="-l$name -L$dir $compile_deplibs"
58187a3b38f7Smrg	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
58197a3b38f7Smrg	  fi
58207a3b38f7Smrg	elif test "$build_libtool_libs" = yes; then
58217a3b38f7Smrg	  # Not a shared library
58227a3b38f7Smrg	  if test "$deplibs_check_method" != pass_all; then
58237a3b38f7Smrg	    # We're trying link a shared library against a static one
58247a3b38f7Smrg	    # but the system doesn't support it.
58257a3b38f7Smrg
58267a3b38f7Smrg	    # Just print a warning and add the library to dependency_libs so
58277a3b38f7Smrg	    # that the program can be linked against the static library.
58287a3b38f7Smrg	    $ECHO
58297a3b38f7Smrg	    $ECHO "*** Warning: This system can not link to static lib archive $lib."
58307a3b38f7Smrg	    $ECHO "*** I have the capability to make that library automatically link in when"
58317a3b38f7Smrg	    $ECHO "*** you link to this library.  But I can only do this if you have a"
58327a3b38f7Smrg	    $ECHO "*** shared version of the library, which you do not appear to have."
58337a3b38f7Smrg	    if test "$module" = yes; then
58347a3b38f7Smrg	      $ECHO "*** But as you try to build a module library, libtool will still create "
58357a3b38f7Smrg	      $ECHO "*** a static module, that should work as long as the dlopening application"
58367a3b38f7Smrg	      $ECHO "*** is linked with the -dlopen flag to resolve symbols at runtime."
58377a3b38f7Smrg	      if test -z "$global_symbol_pipe"; then
58387a3b38f7Smrg		$ECHO
58397a3b38f7Smrg		$ECHO "*** However, this would only work if libtool was able to extract symbol"
58407a3b38f7Smrg		$ECHO "*** lists from a program, using \`nm' or equivalent, but libtool could"
58417a3b38f7Smrg		$ECHO "*** not find such a program.  So, this module is probably useless."
58427a3b38f7Smrg		$ECHO "*** \`nm' from GNU binutils and a full rebuild may help."
58437a3b38f7Smrg	      fi
58447a3b38f7Smrg	      if test "$build_old_libs" = no; then
58457a3b38f7Smrg		build_libtool_libs=module
58467a3b38f7Smrg		build_old_libs=yes
58477a3b38f7Smrg	      else
58487a3b38f7Smrg		build_libtool_libs=no
58497a3b38f7Smrg	      fi
58507a3b38f7Smrg	    fi
58517a3b38f7Smrg	  else
58527a3b38f7Smrg	    deplibs="$dir/$old_library $deplibs"
58537a3b38f7Smrg	    link_static=yes
58547a3b38f7Smrg	  fi
58557a3b38f7Smrg	fi # link shared/static library?
58567a3b38f7Smrg
58577a3b38f7Smrg	if test "$linkmode" = lib; then
58587a3b38f7Smrg	  if test -n "$dependency_libs" &&
58597a3b38f7Smrg	     { test "$hardcode_into_libs" != yes ||
58607a3b38f7Smrg	       test "$build_old_libs" = yes ||
58617a3b38f7Smrg	       test "$link_static" = yes; }; then
58627a3b38f7Smrg	    # Extract -R from dependency_libs
58637a3b38f7Smrg	    temp_deplibs=
58647a3b38f7Smrg	    for libdir in $dependency_libs; do
58657a3b38f7Smrg	      case $libdir in
58667a3b38f7Smrg	      -R*) func_stripname '-R' '' "$libdir"
58677a3b38f7Smrg	           temp_xrpath=$func_stripname_result
58687a3b38f7Smrg		   case " $xrpath " in
58697a3b38f7Smrg		   *" $temp_xrpath "*) ;;
58707a3b38f7Smrg		   *) xrpath="$xrpath $temp_xrpath";;
58717a3b38f7Smrg		   esac;;
58727a3b38f7Smrg	      *) temp_deplibs="$temp_deplibs $libdir";;
58737a3b38f7Smrg	      esac
58747a3b38f7Smrg	    done
58757a3b38f7Smrg	    dependency_libs="$temp_deplibs"
58767a3b38f7Smrg	  fi
58777a3b38f7Smrg
58787a3b38f7Smrg	  newlib_search_path="$newlib_search_path $absdir"
58797a3b38f7Smrg	  # Link against this library
58807a3b38f7Smrg	  test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
58817a3b38f7Smrg	  # ... and its dependency_libs
58827a3b38f7Smrg	  tmp_libs=
58837a3b38f7Smrg	  for deplib in $dependency_libs; do
58847a3b38f7Smrg	    newdependency_libs="$deplib $newdependency_libs"
58857a3b38f7Smrg	    if $opt_duplicate_deps ; then
58867a3b38f7Smrg	      case "$tmp_libs " in
58877a3b38f7Smrg	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
58887a3b38f7Smrg	      esac
58897a3b38f7Smrg	    fi
58907a3b38f7Smrg	    tmp_libs="$tmp_libs $deplib"
58917a3b38f7Smrg	  done
58927a3b38f7Smrg
58937a3b38f7Smrg	  if test "$link_all_deplibs" != no; then
58947a3b38f7Smrg	    # Add the search paths of all dependency libraries
58957a3b38f7Smrg	    for deplib in $dependency_libs; do
58967a3b38f7Smrg	      case $deplib in
58977a3b38f7Smrg	      -L*) path="$deplib" ;;
58987a3b38f7Smrg	      *.la)
58997a3b38f7Smrg	        func_dirname "$deplib" "" "."
59007a3b38f7Smrg		dir="$func_dirname_result"
59017a3b38f7Smrg		# We need an absolute path.
59027a3b38f7Smrg		case $dir in
59037a3b38f7Smrg		[\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
59047a3b38f7Smrg		*)
59057a3b38f7Smrg		  absdir=`cd "$dir" && pwd`
59067a3b38f7Smrg		  if test -z "$absdir"; then
59077a3b38f7Smrg		    func_warning "cannot determine absolute directory name of \`$dir'"
59087a3b38f7Smrg		    absdir="$dir"
59097a3b38f7Smrg		  fi
59107a3b38f7Smrg		  ;;
59117a3b38f7Smrg		esac
59127a3b38f7Smrg		if $GREP "^installed=no" $deplib > /dev/null; then
59137a3b38f7Smrg		case $host in
59147a3b38f7Smrg		*-*-darwin*)
59157a3b38f7Smrg		  depdepl=
59167a3b38f7Smrg		  eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
59177a3b38f7Smrg		  if test -n "$deplibrary_names" ; then
59187a3b38f7Smrg		    for tmp in $deplibrary_names ; do
59197a3b38f7Smrg		      depdepl=$tmp
59207a3b38f7Smrg		    done
59217a3b38f7Smrg		    if test -f "$absdir/$objdir/$depdepl" ; then
59227a3b38f7Smrg		      depdepl="$absdir/$objdir/$depdepl"
59237a3b38f7Smrg		      darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
59247a3b38f7Smrg                      if test -z "$darwin_install_name"; then
59257a3b38f7Smrg                          darwin_install_name=`${OTOOL64} -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
59267a3b38f7Smrg                      fi
59277a3b38f7Smrg		      compiler_flags="$compiler_flags ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}"
59287a3b38f7Smrg		      linker_flags="$linker_flags -dylib_file ${darwin_install_name}:${depdepl}"
59297a3b38f7Smrg		      path=
59307a3b38f7Smrg		    fi
59317a3b38f7Smrg		  fi
59327a3b38f7Smrg		  ;;
59337a3b38f7Smrg		*)
59347a3b38f7Smrg		  path="-L$absdir/$objdir"
59357a3b38f7Smrg		  ;;
59367a3b38f7Smrg		esac
59377a3b38f7Smrg		else
59387a3b38f7Smrg		  eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
59397a3b38f7Smrg		  test -z "$libdir" && \
59407a3b38f7Smrg		    func_fatal_error "\`$deplib' is not a valid libtool archive"
59417a3b38f7Smrg		  test "$absdir" != "$libdir" && \
59427a3b38f7Smrg		    func_warning "\`$deplib' seems to be moved"
59437a3b38f7Smrg
59447a3b38f7Smrg		  path="-L$absdir"
59457a3b38f7Smrg		fi
59467a3b38f7Smrg		;;
59477a3b38f7Smrg	      esac
59487a3b38f7Smrg	      case " $deplibs " in
59497a3b38f7Smrg	      *" $path "*) ;;
59507a3b38f7Smrg	      *) deplibs="$path $deplibs" ;;
59517a3b38f7Smrg	      esac
59527a3b38f7Smrg	    done
59537a3b38f7Smrg	  fi # link_all_deplibs != no
59547a3b38f7Smrg	fi # linkmode = lib
59557a3b38f7Smrg      done # for deplib in $libs
59567a3b38f7Smrg      if test "$pass" = link; then
59577a3b38f7Smrg	if test "$linkmode" = "prog"; then
59587a3b38f7Smrg	  compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
59597a3b38f7Smrg	  finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
59607a3b38f7Smrg	else
59617a3b38f7Smrg	  compiler_flags="$compiler_flags "`$ECHO "X $new_inherited_linker_flags" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
59627a3b38f7Smrg	fi
59637a3b38f7Smrg      fi
59647a3b38f7Smrg      dependency_libs="$newdependency_libs"
59657a3b38f7Smrg      if test "$pass" = dlpreopen; then
59667a3b38f7Smrg	# Link the dlpreopened libraries before other libraries
59677a3b38f7Smrg	for deplib in $save_deplibs; do
59687a3b38f7Smrg	  deplibs="$deplib $deplibs"
59697a3b38f7Smrg	done
59707a3b38f7Smrg      fi
59717a3b38f7Smrg      if test "$pass" != dlopen; then
59727a3b38f7Smrg	if test "$pass" != conv; then
59737a3b38f7Smrg	  # Make sure lib_search_path contains only unique directories.
59747a3b38f7Smrg	  lib_search_path=
59757a3b38f7Smrg	  for dir in $newlib_search_path; do
59767a3b38f7Smrg	    case "$lib_search_path " in
59777a3b38f7Smrg	    *" $dir "*) ;;
59787a3b38f7Smrg	    *) lib_search_path="$lib_search_path $dir" ;;
59797a3b38f7Smrg	    esac
59807a3b38f7Smrg	  done
59817a3b38f7Smrg	  newlib_search_path=
59827a3b38f7Smrg	fi
59837a3b38f7Smrg
59847a3b38f7Smrg	if test "$linkmode,$pass" != "prog,link"; then
59857a3b38f7Smrg	  vars="deplibs"
59867a3b38f7Smrg	else
59877a3b38f7Smrg	  vars="compile_deplibs finalize_deplibs"
59887a3b38f7Smrg	fi
59897a3b38f7Smrg	for var in $vars dependency_libs; do
59907a3b38f7Smrg	  # Add libraries to $var in reverse order
59917a3b38f7Smrg	  eval tmp_libs=\"\$$var\"
59927a3b38f7Smrg	  new_libs=
59937a3b38f7Smrg	  for deplib in $tmp_libs; do
59947a3b38f7Smrg	    # FIXME: Pedantically, this is the right thing to do, so
59957a3b38f7Smrg	    #        that some nasty dependency loop isn't accidentally
59967a3b38f7Smrg	    #        broken:
59977a3b38f7Smrg	    #new_libs="$deplib $new_libs"
59987a3b38f7Smrg	    # Pragmatically, this seems to cause very few problems in
59997a3b38f7Smrg	    # practice:
60007a3b38f7Smrg	    case $deplib in
60017a3b38f7Smrg	    -L*) new_libs="$deplib $new_libs" ;;
60027a3b38f7Smrg	    -R*) ;;
60037a3b38f7Smrg	    *)
60047a3b38f7Smrg	      # And here is the reason: when a library appears more
60057a3b38f7Smrg	      # than once as an explicit dependence of a library, or
60067a3b38f7Smrg	      # is implicitly linked in more than once by the
60077a3b38f7Smrg	      # compiler, it is considered special, and multiple
60087a3b38f7Smrg	      # occurrences thereof are not removed.  Compare this
60097a3b38f7Smrg	      # with having the same library being listed as a
60107a3b38f7Smrg	      # dependency of multiple other libraries: in this case,
60117a3b38f7Smrg	      # we know (pedantically, we assume) the library does not
60127a3b38f7Smrg	      # need to be listed more than once, so we keep only the
60137a3b38f7Smrg	      # last copy.  This is not always right, but it is rare
60147a3b38f7Smrg	      # enough that we require users that really mean to play
60157a3b38f7Smrg	      # such unportable linking tricks to link the library
60167a3b38f7Smrg	      # using -Wl,-lname, so that libtool does not consider it
60177a3b38f7Smrg	      # for duplicate removal.
60187a3b38f7Smrg	      case " $specialdeplibs " in
60197a3b38f7Smrg	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
60207a3b38f7Smrg	      *)
60217a3b38f7Smrg		case " $new_libs " in
60227a3b38f7Smrg		*" $deplib "*) ;;
60237a3b38f7Smrg		*) new_libs="$deplib $new_libs" ;;
60247a3b38f7Smrg		esac
60257a3b38f7Smrg		;;
60267a3b38f7Smrg	      esac
60277a3b38f7Smrg	      ;;
60287a3b38f7Smrg	    esac
60297a3b38f7Smrg	  done
60307a3b38f7Smrg	  tmp_libs=
60317a3b38f7Smrg	  for deplib in $new_libs; do
60327a3b38f7Smrg	    case $deplib in
60337a3b38f7Smrg	    -L*)
60347a3b38f7Smrg	      case " $tmp_libs " in
60357a3b38f7Smrg	      *" $deplib "*) ;;
60367a3b38f7Smrg	      *) tmp_libs="$tmp_libs $deplib" ;;
60377a3b38f7Smrg	      esac
60387a3b38f7Smrg	      ;;
60397a3b38f7Smrg	    *) tmp_libs="$tmp_libs $deplib" ;;
60407a3b38f7Smrg	    esac
60417a3b38f7Smrg	  done
60427a3b38f7Smrg	  eval $var=\"$tmp_libs\"
60437a3b38f7Smrg	done # for var
60447a3b38f7Smrg      fi
60457a3b38f7Smrg      # Last step: remove runtime libs from dependency_libs
60467a3b38f7Smrg      # (they stay in deplibs)
60477a3b38f7Smrg      tmp_libs=
60487a3b38f7Smrg      for i in $dependency_libs ; do
60497a3b38f7Smrg	case " $predeps $postdeps $compiler_lib_search_path " in
60507a3b38f7Smrg	*" $i "*)
60517a3b38f7Smrg	  i=""
60527a3b38f7Smrg	  ;;
60537a3b38f7Smrg	esac
60547a3b38f7Smrg	if test -n "$i" ; then
60557a3b38f7Smrg	  tmp_libs="$tmp_libs $i"
60567a3b38f7Smrg	fi
60577a3b38f7Smrg      done
60587a3b38f7Smrg      dependency_libs=$tmp_libs
60597a3b38f7Smrg    done # for pass
60607a3b38f7Smrg    if test "$linkmode" = prog; then
60617a3b38f7Smrg      dlfiles="$newdlfiles"
60627a3b38f7Smrg    fi
60637a3b38f7Smrg    if test "$linkmode" = prog || test "$linkmode" = lib; then
60647a3b38f7Smrg      dlprefiles="$newdlprefiles"
60657a3b38f7Smrg    fi
60667a3b38f7Smrg
60677a3b38f7Smrg    case $linkmode in
60687a3b38f7Smrg    oldlib)
60697a3b38f7Smrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
60707a3b38f7Smrg	func_warning "\`-dlopen' is ignored for archives"
60717a3b38f7Smrg      fi
60727a3b38f7Smrg
60737a3b38f7Smrg      case " $deplibs" in
60747a3b38f7Smrg      *\ -l* | *\ -L*)
60757a3b38f7Smrg	func_warning "\`-l' and \`-L' are ignored for archives" ;;
60767a3b38f7Smrg      esac
60777a3b38f7Smrg
60787a3b38f7Smrg      test -n "$rpath" && \
60797a3b38f7Smrg	func_warning "\`-rpath' is ignored for archives"
60807a3b38f7Smrg
60817a3b38f7Smrg      test -n "$xrpath" && \
60827a3b38f7Smrg	func_warning "\`-R' is ignored for archives"
60837a3b38f7Smrg
60847a3b38f7Smrg      test -n "$vinfo" && \
60857a3b38f7Smrg	func_warning "\`-version-info/-version-number' is ignored for archives"
60867a3b38f7Smrg
60877a3b38f7Smrg      test -n "$release" && \
60887a3b38f7Smrg	func_warning "\`-release' is ignored for archives"
60897a3b38f7Smrg
60907a3b38f7Smrg      test -n "$export_symbols$export_symbols_regex" && \
60917a3b38f7Smrg	func_warning "\`-export-symbols' is ignored for archives"
60927a3b38f7Smrg
60937a3b38f7Smrg      # Now set the variables for building old libraries.
60947a3b38f7Smrg      build_libtool_libs=no
60957a3b38f7Smrg      oldlibs="$output"
60967a3b38f7Smrg      objs="$objs$old_deplibs"
60977a3b38f7Smrg      ;;
60987a3b38f7Smrg
60997a3b38f7Smrg    lib)
61007a3b38f7Smrg      # Make sure we only generate libraries of the form `libNAME.la'.
61017a3b38f7Smrg      case $outputname in
61027a3b38f7Smrg      lib*)
61037a3b38f7Smrg	func_stripname 'lib' '.la' "$outputname"
61047a3b38f7Smrg	name=$func_stripname_result
61057a3b38f7Smrg	eval shared_ext=\"$shrext_cmds\"
61067a3b38f7Smrg	eval libname=\"$libname_spec\"
61077a3b38f7Smrg	;;
61087a3b38f7Smrg      *)
61097a3b38f7Smrg	test "$module" = no && \
61107a3b38f7Smrg	  func_fatal_help "libtool library \`$output' must begin with \`lib'"
61117a3b38f7Smrg
61127a3b38f7Smrg	if test "$need_lib_prefix" != no; then
61137a3b38f7Smrg	  # Add the "lib" prefix for modules if required
61147a3b38f7Smrg	  func_stripname '' '.la' "$outputname"
61157a3b38f7Smrg	  name=$func_stripname_result
61167a3b38f7Smrg	  eval shared_ext=\"$shrext_cmds\"
61177a3b38f7Smrg	  eval libname=\"$libname_spec\"
61187a3b38f7Smrg	else
61197a3b38f7Smrg	  func_stripname '' '.la' "$outputname"
61207a3b38f7Smrg	  libname=$func_stripname_result
61217a3b38f7Smrg	fi
61227a3b38f7Smrg	;;
61237a3b38f7Smrg      esac
61247a3b38f7Smrg
61257a3b38f7Smrg      if test -n "$objs"; then
61267a3b38f7Smrg	if test "$deplibs_check_method" != pass_all; then
61277a3b38f7Smrg	  func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs"
61287a3b38f7Smrg	else
61297a3b38f7Smrg	  $ECHO
61307a3b38f7Smrg	  $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
61317a3b38f7Smrg	  $ECHO "*** objects $objs is not portable!"
61327a3b38f7Smrg	  libobjs="$libobjs $objs"
61337a3b38f7Smrg	fi
61347a3b38f7Smrg      fi
61357a3b38f7Smrg
61367a3b38f7Smrg      test "$dlself" != no && \
61377a3b38f7Smrg	func_warning "\`-dlopen self' is ignored for libtool libraries"
61387a3b38f7Smrg
61397a3b38f7Smrg      set dummy $rpath
61407a3b38f7Smrg      shift
61417a3b38f7Smrg      test "$#" -gt 1 && \
61427a3b38f7Smrg	func_warning "ignoring multiple \`-rpath's for a libtool library"
61437a3b38f7Smrg
61447a3b38f7Smrg      install_libdir="$1"
61457a3b38f7Smrg
61467a3b38f7Smrg      oldlibs=
61477a3b38f7Smrg      if test -z "$rpath"; then
61487a3b38f7Smrg	if test "$build_libtool_libs" = yes; then
61497a3b38f7Smrg	  # Building a libtool convenience library.
61507a3b38f7Smrg	  # Some compilers have problems with a `.al' extension so
61517a3b38f7Smrg	  # convenience libraries should have the same extension an
61527a3b38f7Smrg	  # archive normally would.
61537a3b38f7Smrg	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
61547a3b38f7Smrg	  build_libtool_libs=convenience
61557a3b38f7Smrg	  build_old_libs=yes
61567a3b38f7Smrg	fi
61577a3b38f7Smrg
61587a3b38f7Smrg	test -n "$vinfo" && \
61597a3b38f7Smrg	  func_warning "\`-version-info/-version-number' is ignored for convenience libraries"
61607a3b38f7Smrg
61617a3b38f7Smrg	test -n "$release" && \
61627a3b38f7Smrg	  func_warning "\`-release' is ignored for convenience libraries"
61637a3b38f7Smrg      else
61647a3b38f7Smrg
61657a3b38f7Smrg	# Parse the version information argument.
61667a3b38f7Smrg	save_ifs="$IFS"; IFS=':'
61677a3b38f7Smrg	set dummy $vinfo 0 0 0
61687a3b38f7Smrg	shift
61697a3b38f7Smrg	IFS="$save_ifs"
61707a3b38f7Smrg
61717a3b38f7Smrg	test -n "$7" && \
61727a3b38f7Smrg	  func_fatal_help "too many parameters to \`-version-info'"
61737a3b38f7Smrg
61747a3b38f7Smrg	# convert absolute version numbers to libtool ages
61757a3b38f7Smrg	# this retains compatibility with .la files and attempts
61767a3b38f7Smrg	# to make the code below a bit more comprehensible
61777a3b38f7Smrg
61787a3b38f7Smrg	case $vinfo_number in
61797a3b38f7Smrg	yes)
61807a3b38f7Smrg	  number_major="$1"
61817a3b38f7Smrg	  number_minor="$2"
61827a3b38f7Smrg	  number_revision="$3"
61837a3b38f7Smrg	  #
61847a3b38f7Smrg	  # There are really only two kinds -- those that
61857a3b38f7Smrg	  # use the current revision as the major version
61867a3b38f7Smrg	  # and those that subtract age and use age as
61877a3b38f7Smrg	  # a minor version.  But, then there is irix
61887a3b38f7Smrg	  # which has an extra 1 added just for fun
61897a3b38f7Smrg	  #
61907a3b38f7Smrg	  case $version_type in
61917a3b38f7Smrg	  darwin|linux|osf|windows|none)
61927a3b38f7Smrg	    func_arith $number_major + $number_minor
61937a3b38f7Smrg	    current=$func_arith_result
61947a3b38f7Smrg	    age="$number_minor"
61957a3b38f7Smrg	    revision="$number_revision"
61967a3b38f7Smrg	    ;;
61977a3b38f7Smrg	  freebsd-aout|freebsd-elf|sunos)
61987a3b38f7Smrg	    current="$number_major"
61997a3b38f7Smrg	    revision="$number_minor"
62007a3b38f7Smrg	    age="0"
62017a3b38f7Smrg	    ;;
62027a3b38f7Smrg	  irix|nonstopux)
62037a3b38f7Smrg	    func_arith $number_major + $number_minor
62047a3b38f7Smrg	    current=$func_arith_result
62057a3b38f7Smrg	    age="$number_minor"
62067a3b38f7Smrg	    revision="$number_minor"
62077a3b38f7Smrg	    lt_irix_increment=no
62087a3b38f7Smrg	    ;;
62097a3b38f7Smrg	  esac
62107a3b38f7Smrg	  ;;
62117a3b38f7Smrg	no)
62127a3b38f7Smrg	  current="$1"
62137a3b38f7Smrg	  revision="$2"
62147a3b38f7Smrg	  age="$3"
62157a3b38f7Smrg	  ;;
62167a3b38f7Smrg	esac
62177a3b38f7Smrg
62187a3b38f7Smrg	# Check that each of the things are valid numbers.
62197a3b38f7Smrg	case $current in
62207a3b38f7Smrg	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]) ;;
62217a3b38f7Smrg	*)
62227a3b38f7Smrg	  func_error "CURRENT \`$current' must be a nonnegative integer"
62237a3b38f7Smrg	  func_fatal_error "\`$vinfo' is not valid version information"
62247a3b38f7Smrg	  ;;
62257a3b38f7Smrg	esac
62267a3b38f7Smrg
62277a3b38f7Smrg	case $revision in
62287a3b38f7Smrg	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]) ;;
62297a3b38f7Smrg	*)
62307a3b38f7Smrg	  func_error "REVISION \`$revision' must be a nonnegative integer"
62317a3b38f7Smrg	  func_fatal_error "\`$vinfo' is not valid version information"
62327a3b38f7Smrg	  ;;
62337a3b38f7Smrg	esac
62347a3b38f7Smrg
62357a3b38f7Smrg	case $age in
62367a3b38f7Smrg	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]) ;;
62377a3b38f7Smrg	*)
62387a3b38f7Smrg	  func_error "AGE \`$age' must be a nonnegative integer"
62397a3b38f7Smrg	  func_fatal_error "\`$vinfo' is not valid version information"
62407a3b38f7Smrg	  ;;
62417a3b38f7Smrg	esac
62427a3b38f7Smrg
62437a3b38f7Smrg	if test "$age" -gt "$current"; then
62447a3b38f7Smrg	  func_error "AGE \`$age' is greater than the current interface number \`$current'"
62457a3b38f7Smrg	  func_fatal_error "\`$vinfo' is not valid version information"
62467a3b38f7Smrg	fi
62477a3b38f7Smrg
62487a3b38f7Smrg	# Calculate the version variables.
62497a3b38f7Smrg	major=
62507a3b38f7Smrg	versuffix=
62517a3b38f7Smrg	verstring=
62527a3b38f7Smrg	case $version_type in
62537a3b38f7Smrg	none) ;;
62547a3b38f7Smrg
62557a3b38f7Smrg	darwin)
62567a3b38f7Smrg	  # Like Linux, but with the current version available in
62577a3b38f7Smrg	  # verstring for coding it into the library header
62587a3b38f7Smrg	  func_arith $current - $age
62597a3b38f7Smrg	  major=.$func_arith_result
62607a3b38f7Smrg	  versuffix="$major.$age.$revision"
62617a3b38f7Smrg	  # Darwin ld doesn't like 0 for these options...
62627a3b38f7Smrg	  func_arith $current + 1
62637a3b38f7Smrg	  minor_current=$func_arith_result
62647a3b38f7Smrg	  xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
62657a3b38f7Smrg	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
62667a3b38f7Smrg	  ;;
62677a3b38f7Smrg
62687a3b38f7Smrg	freebsd-aout)
62697a3b38f7Smrg	  major=".$current"
62707a3b38f7Smrg	  versuffix=".$current.$revision";
62717a3b38f7Smrg	  ;;
62727a3b38f7Smrg
62737a3b38f7Smrg	freebsd-elf)
62747a3b38f7Smrg	  major=".$current"
62757a3b38f7Smrg	  versuffix=".$current"
62767a3b38f7Smrg	  ;;
62777a3b38f7Smrg
62787a3b38f7Smrg	irix | nonstopux)
62797a3b38f7Smrg	  if test "X$lt_irix_increment" = "Xno"; then
62807a3b38f7Smrg	    func_arith $current - $age
62817a3b38f7Smrg	  else
62827a3b38f7Smrg	    func_arith $current - $age + 1
62837a3b38f7Smrg	  fi
62847a3b38f7Smrg	  major=$func_arith_result
62857a3b38f7Smrg
62867a3b38f7Smrg	  case $version_type in
62877a3b38f7Smrg	    nonstopux) verstring_prefix=nonstopux ;;
62887a3b38f7Smrg	    *)         verstring_prefix=sgi ;;
62897a3b38f7Smrg	  esac
62907a3b38f7Smrg	  verstring="$verstring_prefix$major.$revision"
62917a3b38f7Smrg
62927a3b38f7Smrg	  # Add in all the interfaces that we are compatible with.
62937a3b38f7Smrg	  loop=$revision
62947a3b38f7Smrg	  while test "$loop" -ne 0; do
62957a3b38f7Smrg	    func_arith $revision - $loop
62967a3b38f7Smrg	    iface=$func_arith_result
62977a3b38f7Smrg	    func_arith $loop - 1
62987a3b38f7Smrg	    loop=$func_arith_result
62997a3b38f7Smrg	    verstring="$verstring_prefix$major.$iface:$verstring"
63007a3b38f7Smrg	  done
63017a3b38f7Smrg
63027a3b38f7Smrg	  # Before this point, $major must not contain `.'.
63037a3b38f7Smrg	  major=.$major
63047a3b38f7Smrg	  versuffix="$major.$revision"
63057a3b38f7Smrg	  ;;
63067a3b38f7Smrg
63077a3b38f7Smrg	linux)
63087a3b38f7Smrg	  func_arith $current - $age
63097a3b38f7Smrg	  major=.$func_arith_result
63107a3b38f7Smrg	  versuffix="$major.$age.$revision"
63117a3b38f7Smrg	  ;;
63127a3b38f7Smrg
63137a3b38f7Smrg	osf)
63147a3b38f7Smrg	  func_arith $current - $age
63157a3b38f7Smrg	  major=.$func_arith_result
63167a3b38f7Smrg	  versuffix=".$current.$age.$revision"
63177a3b38f7Smrg	  verstring="$current.$age.$revision"
63187a3b38f7Smrg
63197a3b38f7Smrg	  # Add in all the interfaces that we are compatible with.
63207a3b38f7Smrg	  loop=$age
63217a3b38f7Smrg	  while test "$loop" -ne 0; do
63227a3b38f7Smrg	    func_arith $current - $loop
63237a3b38f7Smrg	    iface=$func_arith_result
63247a3b38f7Smrg	    func_arith $loop - 1
63257a3b38f7Smrg	    loop=$func_arith_result
63267a3b38f7Smrg	    verstring="$verstring:${iface}.0"
63277a3b38f7Smrg	  done
63287a3b38f7Smrg
63297a3b38f7Smrg	  # Make executables depend on our current version.
63307a3b38f7Smrg	  verstring="$verstring:${current}.0"
63317a3b38f7Smrg	  ;;
63327a3b38f7Smrg
63337a3b38f7Smrg	qnx)
63347a3b38f7Smrg	  major=".$current"
63357a3b38f7Smrg	  versuffix=".$current"
63367a3b38f7Smrg	  ;;
63377a3b38f7Smrg
63387a3b38f7Smrg	sunos)
63397a3b38f7Smrg	  major=".$current"
63407a3b38f7Smrg	  versuffix=".$current.$revision"
63417a3b38f7Smrg	  ;;
63427a3b38f7Smrg
63437a3b38f7Smrg	windows)
63447a3b38f7Smrg	  # Use '-' rather than '.', since we only want one
63457a3b38f7Smrg	  # extension on DOS 8.3 filesystems.
63467a3b38f7Smrg	  func_arith $current - $age
63477a3b38f7Smrg	  major=$func_arith_result
63487a3b38f7Smrg	  versuffix="-$major"
63497a3b38f7Smrg	  ;;
63507a3b38f7Smrg
63517a3b38f7Smrg	*)
63527a3b38f7Smrg	  func_fatal_configuration "unknown library version type \`$version_type'"
63537a3b38f7Smrg	  ;;
63547a3b38f7Smrg	esac
63557a3b38f7Smrg
63567a3b38f7Smrg	# Clear the version info if we defaulted, and they specified a release.
63577a3b38f7Smrg	if test -z "$vinfo" && test -n "$release"; then
63587a3b38f7Smrg	  major=
63597a3b38f7Smrg	  case $version_type in
63607a3b38f7Smrg	  darwin)
63617a3b38f7Smrg	    # we can't check for "0.0" in archive_cmds due to quoting
63627a3b38f7Smrg	    # problems, so we reset it completely
63637a3b38f7Smrg	    verstring=
63647a3b38f7Smrg	    ;;
63657a3b38f7Smrg	  *)
63667a3b38f7Smrg	    verstring="0.0"
63677a3b38f7Smrg	    ;;
63687a3b38f7Smrg	  esac
63697a3b38f7Smrg	  if test "$need_version" = no; then
63707a3b38f7Smrg	    versuffix=
63717a3b38f7Smrg	  else
63727a3b38f7Smrg	    versuffix=".0.0"
63737a3b38f7Smrg	  fi
63747a3b38f7Smrg	fi
63757a3b38f7Smrg
63767a3b38f7Smrg	# Remove version info from name if versioning should be avoided
63777a3b38f7Smrg	if test "$avoid_version" = yes && test "$need_version" = no; then
63787a3b38f7Smrg	  major=
63797a3b38f7Smrg	  versuffix=
63807a3b38f7Smrg	  verstring=""
63817a3b38f7Smrg	fi
63827a3b38f7Smrg
63837a3b38f7Smrg	# Check to see if the archive will have undefined symbols.
63847a3b38f7Smrg	if test "$allow_undefined" = yes; then
63857a3b38f7Smrg	  if test "$allow_undefined_flag" = unsupported; then
63867a3b38f7Smrg	    func_warning "undefined symbols not allowed in $host shared libraries"
63877a3b38f7Smrg	    build_libtool_libs=no
63887a3b38f7Smrg	    build_old_libs=yes
63897a3b38f7Smrg	  fi
63907a3b38f7Smrg	else
63917a3b38f7Smrg	  # Don't allow undefined symbols.
63927a3b38f7Smrg	  allow_undefined_flag="$no_undefined_flag"
63937a3b38f7Smrg	fi
63947a3b38f7Smrg
63957a3b38f7Smrg      fi
63967a3b38f7Smrg
63977a3b38f7Smrg      func_generate_dlsyms "$libname" "$libname" "yes"
63987a3b38f7Smrg      libobjs="$libobjs $symfileobj"
63997a3b38f7Smrg      test "X$libobjs" = "X " && libobjs=
64007a3b38f7Smrg
64017a3b38f7Smrg      if test "$mode" != relink; then
64027a3b38f7Smrg	# Remove our outputs, but don't remove object files since they
64037a3b38f7Smrg	# may have been created when compiling PIC objects.
64047a3b38f7Smrg	removelist=
64057a3b38f7Smrg	tempremovelist=`$ECHO "$output_objdir/*"`
64067a3b38f7Smrg	for p in $tempremovelist; do
64077a3b38f7Smrg	  case $p in
64087a3b38f7Smrg	    *.$objext | *.gcno)
64097a3b38f7Smrg	       ;;
64107a3b38f7Smrg	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
64117a3b38f7Smrg	       if test "X$precious_files_regex" != "X"; then
64127a3b38f7Smrg		 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
64137a3b38f7Smrg		 then
64147a3b38f7Smrg		   continue
64157a3b38f7Smrg		 fi
64167a3b38f7Smrg	       fi
64177a3b38f7Smrg	       removelist="$removelist $p"
64187a3b38f7Smrg	       ;;
64197a3b38f7Smrg	    *) ;;
64207a3b38f7Smrg	  esac
64217a3b38f7Smrg	done
64227a3b38f7Smrg	test -n "$removelist" && \
64237a3b38f7Smrg	  func_show_eval "${RM}r \$removelist"
64247a3b38f7Smrg      fi
64257a3b38f7Smrg
64267a3b38f7Smrg      # Now set the variables for building old libraries.
64277a3b38f7Smrg      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
64287a3b38f7Smrg	oldlibs="$oldlibs $output_objdir/$libname.$libext"
64297a3b38f7Smrg
64307a3b38f7Smrg	# Transform .lo files to .o files.
64317a3b38f7Smrg	oldobjs="$objs "`$ECHO "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP`
64327a3b38f7Smrg      fi
64337a3b38f7Smrg
64347a3b38f7Smrg      # Eliminate all temporary directories.
64357a3b38f7Smrg      #for path in $notinst_path; do
64367a3b38f7Smrg      #	lib_search_path=`$ECHO "X$lib_search_path " | $Xsed -e "s% $path % %g"`
64377a3b38f7Smrg      #	deplibs=`$ECHO "X$deplibs " | $Xsed -e "s% -L$path % %g"`
64387a3b38f7Smrg      #	dependency_libs=`$ECHO "X$dependency_libs " | $Xsed -e "s% -L$path % %g"`
64397a3b38f7Smrg      #done
64407a3b38f7Smrg
64417a3b38f7Smrg      if test -n "$xrpath"; then
64427a3b38f7Smrg	# If the user specified any rpath flags, then add them.
64437a3b38f7Smrg	temp_xrpath=
64447a3b38f7Smrg	for libdir in $xrpath; do
64457a3b38f7Smrg	  temp_xrpath="$temp_xrpath -R$libdir"
64467a3b38f7Smrg	  case "$finalize_rpath " in
64477a3b38f7Smrg	  *" $libdir "*) ;;
64487a3b38f7Smrg	  *) finalize_rpath="$finalize_rpath $libdir" ;;
64497a3b38f7Smrg	  esac
64507a3b38f7Smrg	done
64517a3b38f7Smrg	if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
64527a3b38f7Smrg	  dependency_libs="$temp_xrpath $dependency_libs"
64537a3b38f7Smrg	fi
64547a3b38f7Smrg      fi
64557a3b38f7Smrg
64567a3b38f7Smrg      # Make sure dlfiles contains only unique files that won't be dlpreopened
64577a3b38f7Smrg      old_dlfiles="$dlfiles"
64587a3b38f7Smrg      dlfiles=
64597a3b38f7Smrg      for lib in $old_dlfiles; do
64607a3b38f7Smrg	case " $dlprefiles $dlfiles " in
64617a3b38f7Smrg	*" $lib "*) ;;
64627a3b38f7Smrg	*) dlfiles="$dlfiles $lib" ;;
64637a3b38f7Smrg	esac
64647a3b38f7Smrg      done
64657a3b38f7Smrg
64667a3b38f7Smrg      # Make sure dlprefiles contains only unique files
64677a3b38f7Smrg      old_dlprefiles="$dlprefiles"
64687a3b38f7Smrg      dlprefiles=
64697a3b38f7Smrg      for lib in $old_dlprefiles; do
64707a3b38f7Smrg	case "$dlprefiles " in
64717a3b38f7Smrg	*" $lib "*) ;;
64727a3b38f7Smrg	*) dlprefiles="$dlprefiles $lib" ;;
64737a3b38f7Smrg	esac
64747a3b38f7Smrg      done
64757a3b38f7Smrg
64767a3b38f7Smrg      if test "$build_libtool_libs" = yes; then
64777a3b38f7Smrg	if test -n "$rpath"; then
64787a3b38f7Smrg	  case $host in
64797a3b38f7Smrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc*)
64807a3b38f7Smrg	    # these systems don't actually have a c library (as such)!
64817a3b38f7Smrg	    ;;
64827a3b38f7Smrg	  *-*-rhapsody* | *-*-darwin1.[012])
64837a3b38f7Smrg	    # Rhapsody C library is in the System framework
64847a3b38f7Smrg	    deplibs="$deplibs System.ltframework"
64857a3b38f7Smrg	    ;;
64867a3b38f7Smrg	  *-*-netbsd*)
64877a3b38f7Smrg	    # Don't link with libc until the a.out ld.so is fixed.
64887a3b38f7Smrg	    ;;
64897a3b38f7Smrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
64907a3b38f7Smrg	    # Do not include libc due to us having libc/libc_r.
64917a3b38f7Smrg	    ;;
64927a3b38f7Smrg	  *-*-sco3.2v5* | *-*-sco5v6*)
64937a3b38f7Smrg	    # Causes problems with __ctype
64947a3b38f7Smrg	    ;;
64957a3b38f7Smrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
64967a3b38f7Smrg	    # Compiler inserts libc in the correct place for threads to work
64977a3b38f7Smrg	    ;;
64987a3b38f7Smrg	  *)
64997a3b38f7Smrg	    # Add libc to deplibs on all other systems if necessary.
65007a3b38f7Smrg	    if test "$build_libtool_need_lc" = "yes"; then
65017a3b38f7Smrg	      deplibs="$deplibs -lc"
65027a3b38f7Smrg	    fi
65037a3b38f7Smrg	    ;;
65047a3b38f7Smrg	  esac
65057a3b38f7Smrg	fi
65067a3b38f7Smrg
65077a3b38f7Smrg	# Transform deplibs into only deplibs that can be linked in shared.
65087a3b38f7Smrg	name_save=$name
65097a3b38f7Smrg	libname_save=$libname
65107a3b38f7Smrg	release_save=$release
65117a3b38f7Smrg	versuffix_save=$versuffix
65127a3b38f7Smrg	major_save=$major
65137a3b38f7Smrg	# I'm not sure if I'm treating the release correctly.  I think
65147a3b38f7Smrg	# release should show up in the -l (ie -lgmp5) so we don't want to
65157a3b38f7Smrg	# add it in twice.  Is that correct?
65167a3b38f7Smrg	release=""
65177a3b38f7Smrg	versuffix=""
65187a3b38f7Smrg	major=""
65197a3b38f7Smrg	newdeplibs=
65207a3b38f7Smrg	droppeddeps=no
65217a3b38f7Smrg	case $deplibs_check_method in
65227a3b38f7Smrg	pass_all)
65237a3b38f7Smrg	  # Don't check for shared/static.  Everything works.
65247a3b38f7Smrg	  # This might be a little naive.  We might want to check
65257a3b38f7Smrg	  # whether the library exists or not.  But this is on
65267a3b38f7Smrg	  # osf3 & osf4 and I'm not really sure... Just
65277a3b38f7Smrg	  # implementing what was already the behavior.
65287a3b38f7Smrg	  newdeplibs=$deplibs
65297a3b38f7Smrg	  ;;
65307a3b38f7Smrg	test_compile)
65317a3b38f7Smrg	  # This code stresses the "libraries are programs" paradigm to its
65327a3b38f7Smrg	  # limits. Maybe even breaks it.  We compile a program, linking it
65337a3b38f7Smrg	  # against the deplibs as a proxy for the library.  Then we can check
65347a3b38f7Smrg	  # whether they linked in statically or dynamically with ldd.
65357a3b38f7Smrg	  $opt_dry_run || $RM conftest.c
65367a3b38f7Smrg	  cat > conftest.c <<EOF
65377a3b38f7Smrg	  int main() { return 0; }
65387a3b38f7SmrgEOF
65397a3b38f7Smrg	  $opt_dry_run || $RM conftest
65407a3b38f7Smrg	  if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
65417a3b38f7Smrg	    ldd_output=`ldd conftest`
65427a3b38f7Smrg	    for i in $deplibs; do
65437a3b38f7Smrg	      case $i in
65447a3b38f7Smrg	      -l*)
65457a3b38f7Smrg		func_stripname -l '' "$i"
65467a3b38f7Smrg		name=$func_stripname_result
65477a3b38f7Smrg		if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
65487a3b38f7Smrg		  case " $predeps $postdeps " in
65497a3b38f7Smrg		  *" $i "*)
65507a3b38f7Smrg		    newdeplibs="$newdeplibs $i"
65517a3b38f7Smrg		    i=""
65527a3b38f7Smrg		    ;;
65537a3b38f7Smrg		  esac
65547a3b38f7Smrg		fi
65557a3b38f7Smrg		if test -n "$i" ; then
65567a3b38f7Smrg		  libname=`eval "\\$ECHO \"$libname_spec\""`
65577a3b38f7Smrg		  deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
65587a3b38f7Smrg		  set dummy $deplib_matches; shift
65597a3b38f7Smrg		  deplib_match=$1
65607a3b38f7Smrg		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
65617a3b38f7Smrg		    newdeplibs="$newdeplibs $i"
65627a3b38f7Smrg		  else
65637a3b38f7Smrg		    droppeddeps=yes
65647a3b38f7Smrg		    $ECHO
65657a3b38f7Smrg		    $ECHO "*** Warning: dynamic linker does not accept needed library $i."
65667a3b38f7Smrg		    $ECHO "*** I have the capability to make that library automatically link in when"
65677a3b38f7Smrg		    $ECHO "*** you link to this library.  But I can only do this if you have a"
65687a3b38f7Smrg		    $ECHO "*** shared version of the library, which I believe you do not have"
65697a3b38f7Smrg		    $ECHO "*** because a test_compile did reveal that the linker did not use it for"
65707a3b38f7Smrg		    $ECHO "*** its dynamic dependency list that programs get resolved with at runtime."
65717a3b38f7Smrg		  fi
65727a3b38f7Smrg		fi
65737a3b38f7Smrg		;;
65747a3b38f7Smrg	      *)
65757a3b38f7Smrg		newdeplibs="$newdeplibs $i"
65767a3b38f7Smrg		;;
65777a3b38f7Smrg	      esac
65787a3b38f7Smrg	    done
65797a3b38f7Smrg	  else
65807a3b38f7Smrg	    # Error occurred in the first compile.  Let's try to salvage
65817a3b38f7Smrg	    # the situation: Compile a separate program for each library.
65827a3b38f7Smrg	    for i in $deplibs; do
65837a3b38f7Smrg	      case $i in
65847a3b38f7Smrg	      -l*)
65857a3b38f7Smrg		func_stripname -l '' "$i"
65867a3b38f7Smrg		name=$func_stripname_result
65877a3b38f7Smrg		$opt_dry_run || $RM conftest
65887a3b38f7Smrg		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
65897a3b38f7Smrg		  ldd_output=`ldd conftest`
65907a3b38f7Smrg		  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
65917a3b38f7Smrg		    case " $predeps $postdeps " in
65927a3b38f7Smrg		    *" $i "*)
65937a3b38f7Smrg		      newdeplibs="$newdeplibs $i"
65947a3b38f7Smrg		      i=""
65957a3b38f7Smrg		      ;;
65967a3b38f7Smrg		    esac
65977a3b38f7Smrg		  fi
65987a3b38f7Smrg		  if test -n "$i" ; then
65997a3b38f7Smrg		    libname=`eval "\\$ECHO \"$libname_spec\""`
66007a3b38f7Smrg		    deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
66017a3b38f7Smrg		    set dummy $deplib_matches; shift
66027a3b38f7Smrg		    deplib_match=$1
66037a3b38f7Smrg		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
66047a3b38f7Smrg		      newdeplibs="$newdeplibs $i"
66057a3b38f7Smrg		    else
66067a3b38f7Smrg		      droppeddeps=yes
66077a3b38f7Smrg		      $ECHO
66087a3b38f7Smrg		      $ECHO "*** Warning: dynamic linker does not accept needed library $i."
66097a3b38f7Smrg		      $ECHO "*** I have the capability to make that library automatically link in when"
66107a3b38f7Smrg		      $ECHO "*** you link to this library.  But I can only do this if you have a"
66117a3b38f7Smrg		      $ECHO "*** shared version of the library, which you do not appear to have"
66127a3b38f7Smrg		      $ECHO "*** because a test_compile did reveal that the linker did not use this one"
66137a3b38f7Smrg		      $ECHO "*** as a dynamic dependency that programs can get resolved with at runtime."
66147a3b38f7Smrg		    fi
66157a3b38f7Smrg		  fi
66167a3b38f7Smrg		else
66177a3b38f7Smrg		  droppeddeps=yes
66187a3b38f7Smrg		  $ECHO
66197a3b38f7Smrg		  $ECHO "*** Warning!  Library $i is needed by this library but I was not able to"
66207a3b38f7Smrg		  $ECHO "*** make it link in!  You will probably need to install it or some"
66217a3b38f7Smrg		  $ECHO "*** library that it depends on before this library will be fully"
66227a3b38f7Smrg		  $ECHO "*** functional.  Installing it before continuing would be even better."
66237a3b38f7Smrg		fi
66247a3b38f7Smrg		;;
66257a3b38f7Smrg	      *)
66267a3b38f7Smrg		newdeplibs="$newdeplibs $i"
66277a3b38f7Smrg		;;
66287a3b38f7Smrg	      esac
66297a3b38f7Smrg	    done
66307a3b38f7Smrg	  fi
66317a3b38f7Smrg	  ;;
66327a3b38f7Smrg	file_magic*)
66337a3b38f7Smrg	  set dummy $deplibs_check_method; shift
66347a3b38f7Smrg	  file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
66357a3b38f7Smrg	  for a_deplib in $deplibs; do
66367a3b38f7Smrg	    case $a_deplib in
66377a3b38f7Smrg	    -l*)
66387a3b38f7Smrg	      func_stripname -l '' "$a_deplib"
66397a3b38f7Smrg	      name=$func_stripname_result
66407a3b38f7Smrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
66417a3b38f7Smrg		case " $predeps $postdeps " in
66427a3b38f7Smrg		*" $a_deplib "*)
66437a3b38f7Smrg		  newdeplibs="$newdeplibs $a_deplib"
66447a3b38f7Smrg		  a_deplib=""
66457a3b38f7Smrg		  ;;
66467a3b38f7Smrg		esac
66477a3b38f7Smrg	      fi
66487a3b38f7Smrg	      if test -n "$a_deplib" ; then
66497a3b38f7Smrg		libname=`eval "\\$ECHO \"$libname_spec\""`
66507a3b38f7Smrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
66517a3b38f7Smrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
66527a3b38f7Smrg		  for potent_lib in $potential_libs; do
66537a3b38f7Smrg		      # Follow soft links.
66547a3b38f7Smrg		      if ls -lLd "$potent_lib" 2>/dev/null |
66557a3b38f7Smrg			 $GREP " -> " >/dev/null; then
66567a3b38f7Smrg			continue
66577a3b38f7Smrg		      fi
66587a3b38f7Smrg		      # The statement above tries to avoid entering an
66597a3b38f7Smrg		      # endless loop below, in case of cyclic links.
66607a3b38f7Smrg		      # We might still enter an endless loop, since a link
66617a3b38f7Smrg		      # loop can be closed while we follow links,
66627a3b38f7Smrg		      # but so what?
66637a3b38f7Smrg		      potlib="$potent_lib"
66647a3b38f7Smrg		      while test -h "$potlib" 2>/dev/null; do
66657a3b38f7Smrg			potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
66667a3b38f7Smrg			case $potliblink in
66677a3b38f7Smrg			[\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
66687a3b38f7Smrg			*) potlib=`$ECHO "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";;
66697a3b38f7Smrg			esac
66707a3b38f7Smrg		      done
66717a3b38f7Smrg		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
66727a3b38f7Smrg			 $SED -e 10q |
66737a3b38f7Smrg			 $EGREP "$file_magic_regex" > /dev/null; then
66747a3b38f7Smrg			newdeplibs="$newdeplibs $a_deplib"
66757a3b38f7Smrg			a_deplib=""
66767a3b38f7Smrg			break 2
66777a3b38f7Smrg		      fi
66787a3b38f7Smrg		  done
66797a3b38f7Smrg		done
66807a3b38f7Smrg	      fi
66817a3b38f7Smrg	      if test -n "$a_deplib" ; then
66827a3b38f7Smrg		droppeddeps=yes
66837a3b38f7Smrg		$ECHO
66847a3b38f7Smrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
66857a3b38f7Smrg		$ECHO "*** I have the capability to make that library automatically link in when"
66867a3b38f7Smrg		$ECHO "*** you link to this library.  But I can only do this if you have a"
66877a3b38f7Smrg		$ECHO "*** shared version of the library, which you do not appear to have"
66887a3b38f7Smrg		$ECHO "*** because I did check the linker path looking for a file starting"
66897a3b38f7Smrg		if test -z "$potlib" ; then
66907a3b38f7Smrg		  $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
66917a3b38f7Smrg		else
66927a3b38f7Smrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
66937a3b38f7Smrg		  $ECHO "*** using a file magic. Last file checked: $potlib"
66947a3b38f7Smrg		fi
66957a3b38f7Smrg	      fi
66967a3b38f7Smrg	      ;;
66977a3b38f7Smrg	    *)
66987a3b38f7Smrg	      # Add a -L argument.
66997a3b38f7Smrg	      newdeplibs="$newdeplibs $a_deplib"
67007a3b38f7Smrg	      ;;
67017a3b38f7Smrg	    esac
67027a3b38f7Smrg	  done # Gone through all deplibs.
67037a3b38f7Smrg	  ;;
67047a3b38f7Smrg	match_pattern*)
67057a3b38f7Smrg	  set dummy $deplibs_check_method; shift
67067a3b38f7Smrg	  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
67077a3b38f7Smrg	  for a_deplib in $deplibs; do
67087a3b38f7Smrg	    case $a_deplib in
67097a3b38f7Smrg	    -l*)
67107a3b38f7Smrg	      func_stripname -l '' "$a_deplib"
67117a3b38f7Smrg	      name=$func_stripname_result
67127a3b38f7Smrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
67137a3b38f7Smrg		case " $predeps $postdeps " in
67147a3b38f7Smrg		*" $a_deplib "*)
67157a3b38f7Smrg		  newdeplibs="$newdeplibs $a_deplib"
67167a3b38f7Smrg		  a_deplib=""
67177a3b38f7Smrg		  ;;
67187a3b38f7Smrg		esac
67197a3b38f7Smrg	      fi
67207a3b38f7Smrg	      if test -n "$a_deplib" ; then
67217a3b38f7Smrg		libname=`eval "\\$ECHO \"$libname_spec\""`
67227a3b38f7Smrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
67237a3b38f7Smrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
67247a3b38f7Smrg		  for potent_lib in $potential_libs; do
67257a3b38f7Smrg		    potlib="$potent_lib" # see symlink-check above in file_magic test
67267a3b38f7Smrg		    if eval "\$ECHO \"X$potent_lib\"" 2>/dev/null | $Xsed -e 10q | \
67277a3b38f7Smrg		       $EGREP "$match_pattern_regex" > /dev/null; then
67287a3b38f7Smrg		      newdeplibs="$newdeplibs $a_deplib"
67297a3b38f7Smrg		      a_deplib=""
67307a3b38f7Smrg		      break 2
67317a3b38f7Smrg		    fi
67327a3b38f7Smrg		  done
67337a3b38f7Smrg		done
67347a3b38f7Smrg	      fi
67357a3b38f7Smrg	      if test -n "$a_deplib" ; then
67367a3b38f7Smrg		droppeddeps=yes
67377a3b38f7Smrg		$ECHO
67387a3b38f7Smrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
67397a3b38f7Smrg		$ECHO "*** I have the capability to make that library automatically link in when"
67407a3b38f7Smrg		$ECHO "*** you link to this library.  But I can only do this if you have a"
67417a3b38f7Smrg		$ECHO "*** shared version of the library, which you do not appear to have"
67427a3b38f7Smrg		$ECHO "*** because I did check the linker path looking for a file starting"
67437a3b38f7Smrg		if test -z "$potlib" ; then
67447a3b38f7Smrg		  $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
67457a3b38f7Smrg		else
67467a3b38f7Smrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
67477a3b38f7Smrg		  $ECHO "*** using a regex pattern. Last file checked: $potlib"
67487a3b38f7Smrg		fi
67497a3b38f7Smrg	      fi
67507a3b38f7Smrg	      ;;
67517a3b38f7Smrg	    *)
67527a3b38f7Smrg	      # Add a -L argument.
67537a3b38f7Smrg	      newdeplibs="$newdeplibs $a_deplib"
67547a3b38f7Smrg	      ;;
67557a3b38f7Smrg	    esac
67567a3b38f7Smrg	  done # Gone through all deplibs.
67577a3b38f7Smrg	  ;;
67587a3b38f7Smrg	none | unknown | *)
67597a3b38f7Smrg	  newdeplibs=""
67607a3b38f7Smrg	  tmp_deplibs=`$ECHO "X $deplibs" | $Xsed \
67617a3b38f7Smrg	      -e 's/ -lc$//' -e 's/ -[LR][^ ]*//g'`
67627a3b38f7Smrg	  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
67637a3b38f7Smrg	    for i in $predeps $postdeps ; do
67647a3b38f7Smrg	      # can't use Xsed below, because $i might contain '/'
67657a3b38f7Smrg	      tmp_deplibs=`$ECHO "X $tmp_deplibs" | $Xsed -e "s,$i,,"`
67667a3b38f7Smrg	    done
67677a3b38f7Smrg	  fi
67687a3b38f7Smrg	  if $ECHO "X $tmp_deplibs" | $Xsed -e 's/[	 ]//g' |
67697a3b38f7Smrg	     $GREP . >/dev/null; then
67707a3b38f7Smrg	    $ECHO
67717a3b38f7Smrg	    if test "X$deplibs_check_method" = "Xnone"; then
67727a3b38f7Smrg	      $ECHO "*** Warning: inter-library dependencies are not supported in this platform."
67737a3b38f7Smrg	    else
67747a3b38f7Smrg	      $ECHO "*** Warning: inter-library dependencies are not known to be supported."
67757a3b38f7Smrg	    fi
67767a3b38f7Smrg	    $ECHO "*** All declared inter-library dependencies are being dropped."
67777a3b38f7Smrg	    droppeddeps=yes
67787a3b38f7Smrg	  fi
67797a3b38f7Smrg	  ;;
67807a3b38f7Smrg	esac
67817a3b38f7Smrg	versuffix=$versuffix_save
67827a3b38f7Smrg	major=$major_save
67837a3b38f7Smrg	release=$release_save
67847a3b38f7Smrg	libname=$libname_save
67857a3b38f7Smrg	name=$name_save
67867a3b38f7Smrg
67877a3b38f7Smrg	case $host in
67887a3b38f7Smrg	*-*-rhapsody* | *-*-darwin1.[012])
67897a3b38f7Smrg	  # On Rhapsody replace the C library with the System framework
67907a3b38f7Smrg	  newdeplibs=`$ECHO "X $newdeplibs" | $Xsed -e 's/ -lc / System.ltframework /'`
67917a3b38f7Smrg	  ;;
67927a3b38f7Smrg	esac
67937a3b38f7Smrg
67947a3b38f7Smrg	if test "$droppeddeps" = yes; then
67957a3b38f7Smrg	  if test "$module" = yes; then
67967a3b38f7Smrg	    $ECHO
67977a3b38f7Smrg	    $ECHO "*** Warning: libtool could not satisfy all declared inter-library"
67987a3b38f7Smrg	    $ECHO "*** dependencies of module $libname.  Therefore, libtool will create"
67997a3b38f7Smrg	    $ECHO "*** a static module, that should work as long as the dlopening"
68007a3b38f7Smrg	    $ECHO "*** application is linked with the -dlopen flag."
68017a3b38f7Smrg	    if test -z "$global_symbol_pipe"; then
68027a3b38f7Smrg	      $ECHO
68037a3b38f7Smrg	      $ECHO "*** However, this would only work if libtool was able to extract symbol"
68047a3b38f7Smrg	      $ECHO "*** lists from a program, using \`nm' or equivalent, but libtool could"
68057a3b38f7Smrg	      $ECHO "*** not find such a program.  So, this module is probably useless."
68067a3b38f7Smrg	      $ECHO "*** \`nm' from GNU binutils and a full rebuild may help."
68077a3b38f7Smrg	    fi
68087a3b38f7Smrg	    if test "$build_old_libs" = no; then
68097a3b38f7Smrg	      oldlibs="$output_objdir/$libname.$libext"
68107a3b38f7Smrg	      build_libtool_libs=module
68117a3b38f7Smrg	      build_old_libs=yes
68127a3b38f7Smrg	    else
68137a3b38f7Smrg	      build_libtool_libs=no
68147a3b38f7Smrg	    fi
68157a3b38f7Smrg	  else
68167a3b38f7Smrg	    $ECHO "*** The inter-library dependencies that have been dropped here will be"
68177a3b38f7Smrg	    $ECHO "*** automatically added whenever a program is linked with this library"
68187a3b38f7Smrg	    $ECHO "*** or is declared to -dlopen it."
68197a3b38f7Smrg
68207a3b38f7Smrg	    if test "$allow_undefined" = no; then
68217a3b38f7Smrg	      $ECHO
68227a3b38f7Smrg	      $ECHO "*** Since this library must not contain undefined symbols,"
68237a3b38f7Smrg	      $ECHO "*** because either the platform does not support them or"
68247a3b38f7Smrg	      $ECHO "*** it was explicitly requested with -no-undefined,"
68257a3b38f7Smrg	      $ECHO "*** libtool will only create a static version of it."
68267a3b38f7Smrg	      if test "$build_old_libs" = no; then
68277a3b38f7Smrg		oldlibs="$output_objdir/$libname.$libext"
68287a3b38f7Smrg		build_libtool_libs=module
68297a3b38f7Smrg		build_old_libs=yes
68307a3b38f7Smrg	      else
68317a3b38f7Smrg		build_libtool_libs=no
68327a3b38f7Smrg	      fi
68337a3b38f7Smrg	    fi
68347a3b38f7Smrg	  fi
68357a3b38f7Smrg	fi
68367a3b38f7Smrg	# Done checking deplibs!
68377a3b38f7Smrg	deplibs=$newdeplibs
68387a3b38f7Smrg      fi
68397a3b38f7Smrg      # Time to change all our "foo.ltframework" stuff back to "-framework foo"
68407a3b38f7Smrg      case $host in
68417a3b38f7Smrg	*-*-darwin*)
68427a3b38f7Smrg	  newdeplibs=`$ECHO "X $newdeplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
68437a3b38f7Smrg	  new_inherited_linker_flags=`$ECHO "X $new_inherited_linker_flags" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
68447a3b38f7Smrg	  deplibs=`$ECHO "X $deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
68457a3b38f7Smrg	  ;;
68467a3b38f7Smrg      esac
68477a3b38f7Smrg
68487a3b38f7Smrg      # move library search paths that coincide with paths to not yet
68497a3b38f7Smrg      # installed libraries to the beginning of the library search list
68507a3b38f7Smrg      new_libs=
68517a3b38f7Smrg      for path in $notinst_path; do
68527a3b38f7Smrg	case " $new_libs " in
68537a3b38f7Smrg	*" -L$path/$objdir "*) ;;
68547a3b38f7Smrg	*)
68557a3b38f7Smrg	  case " $deplibs " in
68567a3b38f7Smrg	  *" -L$path/$objdir "*)
68577a3b38f7Smrg	    new_libs="$new_libs -L$path/$objdir" ;;
68587a3b38f7Smrg	  esac
68597a3b38f7Smrg	  ;;
68607a3b38f7Smrg	esac
68617a3b38f7Smrg      done
68627a3b38f7Smrg      for deplib in $deplibs; do
68637a3b38f7Smrg	case $deplib in
68647a3b38f7Smrg	-L*)
68657a3b38f7Smrg	  case " $new_libs " in
68667a3b38f7Smrg	  *" $deplib "*) ;;
68677a3b38f7Smrg	  *) new_libs="$new_libs $deplib" ;;
68687a3b38f7Smrg	  esac
68697a3b38f7Smrg	  ;;
68707a3b38f7Smrg	*) new_libs="$new_libs $deplib" ;;
68717a3b38f7Smrg	esac
68727a3b38f7Smrg      done
68737a3b38f7Smrg      deplibs="$new_libs"
68747a3b38f7Smrg
68757a3b38f7Smrg      # All the library-specific variables (install_libdir is set above).
68767a3b38f7Smrg      library_names=
68777a3b38f7Smrg      old_library=
68787a3b38f7Smrg      dlname=
68797a3b38f7Smrg
68807a3b38f7Smrg      # Test again, we may have decided not to build it any more
68817a3b38f7Smrg      if test "$build_libtool_libs" = yes; then
68827a3b38f7Smrg	if test "$hardcode_into_libs" = yes; then
68837a3b38f7Smrg	  # Hardcode the library paths
68847a3b38f7Smrg	  hardcode_libdirs=
68857a3b38f7Smrg	  dep_rpath=
68867a3b38f7Smrg	  rpath="$finalize_rpath"
68877a3b38f7Smrg	  test "$mode" != relink && rpath="$compile_rpath$rpath"
68887a3b38f7Smrg	  for libdir in $rpath; do
68897a3b38f7Smrg	    if test -n "$hardcode_libdir_flag_spec"; then
68907a3b38f7Smrg	      if test -n "$hardcode_libdir_separator"; then
68917a3b38f7Smrg		if test -z "$hardcode_libdirs"; then
68927a3b38f7Smrg		  hardcode_libdirs="$libdir"
68937a3b38f7Smrg		else
68947a3b38f7Smrg		  # Just accumulate the unique libdirs.
68957a3b38f7Smrg		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
68967a3b38f7Smrg		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
68977a3b38f7Smrg		    ;;
68987a3b38f7Smrg		  *)
68997a3b38f7Smrg		    hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
69007a3b38f7Smrg		    ;;
69017a3b38f7Smrg		  esac
69027a3b38f7Smrg		fi
69037a3b38f7Smrg	      else
69047a3b38f7Smrg		eval flag=\"$hardcode_libdir_flag_spec\"
69057a3b38f7Smrg		dep_rpath="$dep_rpath $flag"
69067a3b38f7Smrg	      fi
69077a3b38f7Smrg	    elif test -n "$runpath_var"; then
69087a3b38f7Smrg	      case "$perm_rpath " in
69097a3b38f7Smrg	      *" $libdir "*) ;;
69107a3b38f7Smrg	      *) perm_rpath="$perm_rpath $libdir" ;;
69117a3b38f7Smrg	      esac
69127a3b38f7Smrg	    fi
69137a3b38f7Smrg	  done
69147a3b38f7Smrg	  # Substitute the hardcoded libdirs into the rpath.
69157a3b38f7Smrg	  if test -n "$hardcode_libdir_separator" &&
69167a3b38f7Smrg	     test -n "$hardcode_libdirs"; then
69177a3b38f7Smrg	    libdir="$hardcode_libdirs"
69187a3b38f7Smrg	    if test -n "$hardcode_libdir_flag_spec_ld"; then
69197a3b38f7Smrg	      eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\"
69207a3b38f7Smrg	    else
69217a3b38f7Smrg	      eval dep_rpath=\"$hardcode_libdir_flag_spec\"
69227a3b38f7Smrg	    fi
69237a3b38f7Smrg	  fi
69247a3b38f7Smrg	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
69257a3b38f7Smrg	    # We should set the runpath_var.
69267a3b38f7Smrg	    rpath=
69277a3b38f7Smrg	    for dir in $perm_rpath; do
69287a3b38f7Smrg	      rpath="$rpath$dir:"
69297a3b38f7Smrg	    done
69307a3b38f7Smrg	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
69317a3b38f7Smrg	  fi
69327a3b38f7Smrg	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
69337a3b38f7Smrg	fi
6934ff559fabSmrg
69357a3b38f7Smrg	shlibpath="$finalize_shlibpath"
69367a3b38f7Smrg	test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
69377a3b38f7Smrg	if test -n "$shlibpath"; then
69387a3b38f7Smrg	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
69397a3b38f7Smrg	fi
6940ff559fabSmrg
69417a3b38f7Smrg	# Get the real and link names of the library.
69427a3b38f7Smrg	eval shared_ext=\"$shrext_cmds\"
69437a3b38f7Smrg	eval library_names=\"$library_names_spec\"
69447a3b38f7Smrg	set dummy $library_names
69457a3b38f7Smrg	shift
69467a3b38f7Smrg	realname="$1"
69477a3b38f7Smrg	shift
6948ff559fabSmrg
69497a3b38f7Smrg	if test -n "$soname_spec"; then
69507a3b38f7Smrg	  eval soname=\"$soname_spec\"
69517a3b38f7Smrg	else
69527a3b38f7Smrg	  soname="$realname"
69537a3b38f7Smrg	fi
69547a3b38f7Smrg	if test -z "$dlname"; then
69557a3b38f7Smrg	  dlname=$soname
69567a3b38f7Smrg	fi
6957ff559fabSmrg
69587a3b38f7Smrg	lib="$output_objdir/$realname"
69597a3b38f7Smrg	linknames=
69607a3b38f7Smrg	for link
69617a3b38f7Smrg	do
69627a3b38f7Smrg	  linknames="$linknames $link"
69637a3b38f7Smrg	done
6964ff559fabSmrg
69657a3b38f7Smrg	# Use standard objects if they are pic
69667a3b38f7Smrg	test -z "$pic_flag" && libobjs=`$ECHO "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
69677a3b38f7Smrg	test "X$libobjs" = "X " && libobjs=
6968ff559fabSmrg
69697a3b38f7Smrg	delfiles=
69707a3b38f7Smrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
69717a3b38f7Smrg	  $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
69727a3b38f7Smrg	  export_symbols="$output_objdir/$libname.uexp"
69737a3b38f7Smrg	  delfiles="$delfiles $export_symbols"
69747a3b38f7Smrg	fi
6975ff559fabSmrg
69767a3b38f7Smrg	orig_export_symbols=
69777a3b38f7Smrg	case $host_os in
69787a3b38f7Smrg	cygwin* | mingw* | cegcc*)
69797a3b38f7Smrg	  if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
69807a3b38f7Smrg	    # exporting using user supplied symfile
69817a3b38f7Smrg	    if test "x`$SED 1q $export_symbols`" != xEXPORTS; then
69827a3b38f7Smrg	      # and it's NOT already a .def file. Must figure out
69837a3b38f7Smrg	      # which of the given symbols are data symbols and tag
69847a3b38f7Smrg	      # them as such. So, trigger use of export_symbols_cmds.
69857a3b38f7Smrg	      # export_symbols gets reassigned inside the "prepare
69867a3b38f7Smrg	      # the list of exported symbols" if statement, so the
69877a3b38f7Smrg	      # include_expsyms logic still works.
69887a3b38f7Smrg	      orig_export_symbols="$export_symbols"
69897a3b38f7Smrg	      export_symbols=
69907a3b38f7Smrg	      always_export_symbols=yes
69917a3b38f7Smrg	    fi
69927a3b38f7Smrg	  fi
69937a3b38f7Smrg	  ;;
69947a3b38f7Smrg	esac
6995ff559fabSmrg
69967a3b38f7Smrg	# Prepare the list of exported symbols
69977a3b38f7Smrg	if test -z "$export_symbols"; then
69987a3b38f7Smrg	  if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
69997a3b38f7Smrg	    func_verbose "generating symbol list for \`$libname.la'"
70007a3b38f7Smrg	    export_symbols="$output_objdir/$libname.exp"
70017a3b38f7Smrg	    $opt_dry_run || $RM $export_symbols
70027a3b38f7Smrg	    cmds=$export_symbols_cmds
70037a3b38f7Smrg	    save_ifs="$IFS"; IFS='~'
70047a3b38f7Smrg	    for cmd in $cmds; do
70057a3b38f7Smrg	      IFS="$save_ifs"
70067a3b38f7Smrg	      eval cmd=\"$cmd\"
70077a3b38f7Smrg	      func_len " $cmd"
70087a3b38f7Smrg	      len=$func_len_result
70097a3b38f7Smrg	      if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
70107a3b38f7Smrg		func_show_eval "$cmd" 'exit $?'
70117a3b38f7Smrg		skipped_export=false
70127a3b38f7Smrg	      else
70137a3b38f7Smrg		# The command line is too long to execute in one step.
70147a3b38f7Smrg		func_verbose "using reloadable object file for export list..."
70157a3b38f7Smrg		skipped_export=:
70167a3b38f7Smrg		# Break out early, otherwise skipped_export may be
70177a3b38f7Smrg		# set to false by a later but shorter cmd.
70187a3b38f7Smrg		break
70197a3b38f7Smrg	      fi
70207a3b38f7Smrg	    done
70217a3b38f7Smrg	    IFS="$save_ifs"
70227a3b38f7Smrg	    if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then
70237a3b38f7Smrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
70247a3b38f7Smrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
70257a3b38f7Smrg	    fi
70267a3b38f7Smrg	  fi
70277a3b38f7Smrg	fi
7028ff559fabSmrg
70297a3b38f7Smrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
70307a3b38f7Smrg	  tmp_export_symbols="$export_symbols"
70317a3b38f7Smrg	  test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
70327a3b38f7Smrg	  $opt_dry_run || eval '$ECHO "X$include_expsyms" | $Xsed | $SP2NL >> "$tmp_export_symbols"'
70337a3b38f7Smrg	fi
7034ff559fabSmrg
70357a3b38f7Smrg	if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then
70367a3b38f7Smrg	  # The given exports_symbols file has to be filtered, so filter it.
70377a3b38f7Smrg	  func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
70387a3b38f7Smrg	  # FIXME: $output_objdir/$libname.filter potentially contains lots of
70397a3b38f7Smrg	  # 's' commands which not all seds can handle. GNU sed should be fine
70407a3b38f7Smrg	  # though. Also, the filter scales superlinearly with the number of
70417a3b38f7Smrg	  # global variables. join(1) would be nice here, but unfortunately
70427a3b38f7Smrg	  # isn't a blessed tool.
70437a3b38f7Smrg	  $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
70447a3b38f7Smrg	  delfiles="$delfiles $export_symbols $output_objdir/$libname.filter"
70457a3b38f7Smrg	  export_symbols=$output_objdir/$libname.def
70467a3b38f7Smrg	  $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
7047ff559fabSmrg	fi
7048ff559fabSmrg
70497a3b38f7Smrg	tmp_deplibs=
70507a3b38f7Smrg	for test_deplib in $deplibs; do
70517a3b38f7Smrg	  case " $convenience " in
70527a3b38f7Smrg	  *" $test_deplib "*) ;;
70537a3b38f7Smrg	  *)
70547a3b38f7Smrg	    tmp_deplibs="$tmp_deplibs $test_deplib"
70557a3b38f7Smrg	    ;;
70567a3b38f7Smrg	  esac
70577a3b38f7Smrg	done
70587a3b38f7Smrg	deplibs="$tmp_deplibs"
7059ff559fabSmrg
70607a3b38f7Smrg	if test -n "$convenience"; then
70617a3b38f7Smrg	  if test -n "$whole_archive_flag_spec" &&
70627a3b38f7Smrg	    test "$compiler_needs_object" = yes &&
70637a3b38f7Smrg	    test -z "$libobjs"; then
70647a3b38f7Smrg	    # extract the archives, so we have objects to list.
70657a3b38f7Smrg	    # TODO: could optimize this to just extract one archive.
70667a3b38f7Smrg	    whole_archive_flag_spec=
70677a3b38f7Smrg	  fi
70687a3b38f7Smrg	  if test -n "$whole_archive_flag_spec"; then
70697a3b38f7Smrg	    save_libobjs=$libobjs
70707a3b38f7Smrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
70717a3b38f7Smrg	    test "X$libobjs" = "X " && libobjs=
70727a3b38f7Smrg	  else
70737a3b38f7Smrg	    gentop="$output_objdir/${outputname}x"
70747a3b38f7Smrg	    generated="$generated $gentop"
7075ff559fabSmrg
70767a3b38f7Smrg	    func_extract_archives $gentop $convenience
70777a3b38f7Smrg	    libobjs="$libobjs $func_extract_archives_result"
70787a3b38f7Smrg	    test "X$libobjs" = "X " && libobjs=
70797a3b38f7Smrg	  fi
70807a3b38f7Smrg	fi
7081ff559fabSmrg
70827a3b38f7Smrg	if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
70837a3b38f7Smrg	  eval flag=\"$thread_safe_flag_spec\"
70847a3b38f7Smrg	  linker_flags="$linker_flags $flag"
70857a3b38f7Smrg	fi
7086ff559fabSmrg
70877a3b38f7Smrg	# Make a backup of the uninstalled library when relinking
70887a3b38f7Smrg	if test "$mode" = relink; then
70897a3b38f7Smrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
7090ff559fabSmrg	fi
7091ff559fabSmrg
70927a3b38f7Smrg	# Do each of the archive commands.
70937a3b38f7Smrg	if test "$module" = yes && test -n "$module_cmds" ; then
70947a3b38f7Smrg	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
70957a3b38f7Smrg	    eval test_cmds=\"$module_expsym_cmds\"
70967a3b38f7Smrg	    cmds=$module_expsym_cmds
70977a3b38f7Smrg	  else
70987a3b38f7Smrg	    eval test_cmds=\"$module_cmds\"
70997a3b38f7Smrg	    cmds=$module_cmds
71007a3b38f7Smrg	  fi
71017a3b38f7Smrg	else
71027a3b38f7Smrg	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
71037a3b38f7Smrg	    eval test_cmds=\"$archive_expsym_cmds\"
71047a3b38f7Smrg	    cmds=$archive_expsym_cmds
71057a3b38f7Smrg	  else
71067a3b38f7Smrg	    eval test_cmds=\"$archive_cmds\"
71077a3b38f7Smrg	    cmds=$archive_cmds
71087a3b38f7Smrg	  fi
7109ff559fabSmrg	fi
7110ff559fabSmrg
71117a3b38f7Smrg	if test "X$skipped_export" != "X:" &&
71127a3b38f7Smrg	   func_len " $test_cmds" &&
71137a3b38f7Smrg	   len=$func_len_result &&
71147a3b38f7Smrg	   test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
71157a3b38f7Smrg	  :
71167a3b38f7Smrg	else
71177a3b38f7Smrg	  # The command line is too long to link in one step, link piecewise
71187a3b38f7Smrg	  # or, if using GNU ld and skipped_export is not :, use a linker
71197a3b38f7Smrg	  # script.
7120ff559fabSmrg
71217a3b38f7Smrg	  # Save the value of $output and $libobjs because we want to
71227a3b38f7Smrg	  # use them later.  If we have whole_archive_flag_spec, we
71237a3b38f7Smrg	  # want to use save_libobjs as it was before
71247a3b38f7Smrg	  # whole_archive_flag_spec was expanded, because we can't
71257a3b38f7Smrg	  # assume the linker understands whole_archive_flag_spec.
71267a3b38f7Smrg	  # This may have to be revisited, in case too many
71277a3b38f7Smrg	  # convenience libraries get linked in and end up exceeding
71287a3b38f7Smrg	  # the spec.
71297a3b38f7Smrg	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
71307a3b38f7Smrg	    save_libobjs=$libobjs
71317a3b38f7Smrg	  fi
71327a3b38f7Smrg	  save_output=$output
71337a3b38f7Smrg	  output_la=`$ECHO "X$output" | $Xsed -e "$basename"`
7134ff559fabSmrg
71357a3b38f7Smrg	  # Clear the reloadable object creation command queue and
71367a3b38f7Smrg	  # initialize k to one.
71377a3b38f7Smrg	  test_cmds=
71387a3b38f7Smrg	  concat_cmds=
71397a3b38f7Smrg	  objlist=
71407a3b38f7Smrg	  last_robj=
71417a3b38f7Smrg	  k=1
7142ff559fabSmrg
71437a3b38f7Smrg	  if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
71447a3b38f7Smrg	    output=${output_objdir}/${output_la}.lnkscript
71457a3b38f7Smrg	    func_verbose "creating GNU ld script: $output"
71467a3b38f7Smrg	    $ECHO 'INPUT (' > $output
71477a3b38f7Smrg	    for obj in $save_libobjs
71487a3b38f7Smrg	    do
71497a3b38f7Smrg	      $ECHO "$obj" >> $output
71507a3b38f7Smrg	    done
71517a3b38f7Smrg	    $ECHO ')' >> $output
71527a3b38f7Smrg	    delfiles="$delfiles $output"
71537a3b38f7Smrg	  elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then
71547a3b38f7Smrg	    output=${output_objdir}/${output_la}.lnk
71557a3b38f7Smrg	    func_verbose "creating linker input file list: $output"
71567a3b38f7Smrg	    : > $output
71577a3b38f7Smrg	    set x $save_libobjs
71587a3b38f7Smrg	    shift
71597a3b38f7Smrg	    firstobj=
71607a3b38f7Smrg	    if test "$compiler_needs_object" = yes; then
71617a3b38f7Smrg	      firstobj="$1 "
71627a3b38f7Smrg	      shift
71637a3b38f7Smrg	    fi
71647a3b38f7Smrg	    for obj
71657a3b38f7Smrg	    do
71667a3b38f7Smrg	      $ECHO "$obj" >> $output
71677a3b38f7Smrg	    done
71687a3b38f7Smrg	    delfiles="$delfiles $output"
71697a3b38f7Smrg	    output=$firstobj\"$file_list_spec$output\"
71707a3b38f7Smrg	  else
71717a3b38f7Smrg	    if test -n "$save_libobjs"; then
71727a3b38f7Smrg	      func_verbose "creating reloadable object files..."
71737a3b38f7Smrg	      output=$output_objdir/$output_la-${k}.$objext
71747a3b38f7Smrg	      eval test_cmds=\"$reload_cmds\"
71757a3b38f7Smrg	      func_len " $test_cmds"
71767a3b38f7Smrg	      len0=$func_len_result
71777a3b38f7Smrg	      len=$len0
71787a3b38f7Smrg
71797a3b38f7Smrg	      # Loop over the list of objects to be linked.
71807a3b38f7Smrg	      for obj in $save_libobjs
71817a3b38f7Smrg	      do
71827a3b38f7Smrg		func_len " $obj"
71837a3b38f7Smrg		func_arith $len + $func_len_result
71847a3b38f7Smrg		len=$func_arith_result
71857a3b38f7Smrg		if test "X$objlist" = X ||
71867a3b38f7Smrg		   test "$len" -lt "$max_cmd_len"; then
71877a3b38f7Smrg		  func_append objlist " $obj"
71887a3b38f7Smrg		else
71897a3b38f7Smrg		  # The command $test_cmds is almost too long, add a
71907a3b38f7Smrg		  # command to the queue.
71917a3b38f7Smrg		  if test "$k" -eq 1 ; then
71927a3b38f7Smrg		    # The first file doesn't have a previous command to add.
71937a3b38f7Smrg		    eval concat_cmds=\"$reload_cmds $objlist $last_robj\"
71947a3b38f7Smrg		  else
71957a3b38f7Smrg		    # All subsequent reloadable object files will link in
71967a3b38f7Smrg		    # the last one created.
71977a3b38f7Smrg		    eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj~\$RM $last_robj\"
71987a3b38f7Smrg		  fi
71997a3b38f7Smrg		  last_robj=$output_objdir/$output_la-${k}.$objext
72007a3b38f7Smrg		  func_arith $k + 1
72017a3b38f7Smrg		  k=$func_arith_result
72027a3b38f7Smrg		  output=$output_objdir/$output_la-${k}.$objext
72037a3b38f7Smrg		  objlist=$obj
72047a3b38f7Smrg		  func_len " $last_robj"
72057a3b38f7Smrg		  func_arith $len0 + $func_len_result
72067a3b38f7Smrg		  len=$func_arith_result
72077a3b38f7Smrg		fi
72087a3b38f7Smrg	      done
72097a3b38f7Smrg	      # Handle the remaining objects by creating one last
72107a3b38f7Smrg	      # reloadable object file.  All subsequent reloadable object
72117a3b38f7Smrg	      # files will link in the last one created.
72127a3b38f7Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
72137a3b38f7Smrg	      eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\"
72147a3b38f7Smrg	      if test -n "$last_robj"; then
72157a3b38f7Smrg	        eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\"
72167a3b38f7Smrg	      fi
72177a3b38f7Smrg	      delfiles="$delfiles $output"
7218ff559fabSmrg
72197a3b38f7Smrg	    else
72207a3b38f7Smrg	      output=
72217a3b38f7Smrg	    fi
7222ff559fabSmrg
72237a3b38f7Smrg	    if ${skipped_export-false}; then
72247a3b38f7Smrg	      func_verbose "generating symbol list for \`$libname.la'"
72257a3b38f7Smrg	      export_symbols="$output_objdir/$libname.exp"
72267a3b38f7Smrg	      $opt_dry_run || $RM $export_symbols
72277a3b38f7Smrg	      libobjs=$output
72287a3b38f7Smrg	      # Append the command to create the export file.
72297a3b38f7Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
72307a3b38f7Smrg	      eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
72317a3b38f7Smrg	      if test -n "$last_robj"; then
72327a3b38f7Smrg		eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
72337a3b38f7Smrg	      fi
72347a3b38f7Smrg	    fi
7235ff559fabSmrg
72367a3b38f7Smrg	    test -n "$save_libobjs" &&
72377a3b38f7Smrg	      func_verbose "creating a temporary reloadable object file: $output"
7238ff559fabSmrg
72397a3b38f7Smrg	    # Loop through the commands generated above and execute them.
72407a3b38f7Smrg	    save_ifs="$IFS"; IFS='~'
72417a3b38f7Smrg	    for cmd in $concat_cmds; do
72427a3b38f7Smrg	      IFS="$save_ifs"
72437a3b38f7Smrg	      $opt_silent || {
72447a3b38f7Smrg		  func_quote_for_expand "$cmd"
72457a3b38f7Smrg		  eval "func_echo $func_quote_for_expand_result"
72467a3b38f7Smrg	      }
72477a3b38f7Smrg	      $opt_dry_run || eval "$cmd" || {
72487a3b38f7Smrg		lt_exit=$?
72497a3b38f7Smrg
72507a3b38f7Smrg		# Restore the uninstalled library and exit
72517a3b38f7Smrg		if test "$mode" = relink; then
72527a3b38f7Smrg		  ( cd "$output_objdir" && \
72537a3b38f7Smrg		    $RM "${realname}T" && \
72547a3b38f7Smrg		    $MV "${realname}U" "$realname" )
72557a3b38f7Smrg		fi
7256ff559fabSmrg
72577a3b38f7Smrg		exit $lt_exit
72587a3b38f7Smrg	      }
72597a3b38f7Smrg	    done
72607a3b38f7Smrg	    IFS="$save_ifs"
72617a3b38f7Smrg
72627a3b38f7Smrg	    if test -n "$export_symbols_regex" && ${skipped_export-false}; then
72637a3b38f7Smrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
72647a3b38f7Smrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
7265ff559fabSmrg	    fi
7266ff559fabSmrg	  fi
7267ff559fabSmrg
72687a3b38f7Smrg          if ${skipped_export-false}; then
72697a3b38f7Smrg	    if test -n "$export_symbols" && test -n "$include_expsyms"; then
72707a3b38f7Smrg	      tmp_export_symbols="$export_symbols"
72717a3b38f7Smrg	      test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
72727a3b38f7Smrg	      $opt_dry_run || eval '$ECHO "X$include_expsyms" | $Xsed | $SP2NL >> "$tmp_export_symbols"'
72737a3b38f7Smrg	    fi
7274ff559fabSmrg
72757a3b38f7Smrg	    if test -n "$orig_export_symbols"; then
72767a3b38f7Smrg	      # The given exports_symbols file has to be filtered, so filter it.
72777a3b38f7Smrg	      func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
72787a3b38f7Smrg	      # FIXME: $output_objdir/$libname.filter potentially contains lots of
72797a3b38f7Smrg	      # 's' commands which not all seds can handle. GNU sed should be fine
72807a3b38f7Smrg	      # though. Also, the filter scales superlinearly with the number of
72817a3b38f7Smrg	      # global variables. join(1) would be nice here, but unfortunately
72827a3b38f7Smrg	      # isn't a blessed tool.
72837a3b38f7Smrg	      $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
72847a3b38f7Smrg	      delfiles="$delfiles $export_symbols $output_objdir/$libname.filter"
72857a3b38f7Smrg	      export_symbols=$output_objdir/$libname.def
72867a3b38f7Smrg	      $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
72877a3b38f7Smrg	    fi
72887a3b38f7Smrg	  fi
7289ff559fabSmrg
72907a3b38f7Smrg	  libobjs=$output
72917a3b38f7Smrg	  # Restore the value of output.
72927a3b38f7Smrg	  output=$save_output
7293ff559fabSmrg
72947a3b38f7Smrg	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
72957a3b38f7Smrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
72967a3b38f7Smrg	    test "X$libobjs" = "X " && libobjs=
72977a3b38f7Smrg	  fi
72987a3b38f7Smrg	  # Expand the library linking commands again to reset the
72997a3b38f7Smrg	  # value of $libobjs for piecewise linking.
73007a3b38f7Smrg
73017a3b38f7Smrg	  # Do each of the archive commands.
73027a3b38f7Smrg	  if test "$module" = yes && test -n "$module_cmds" ; then
73037a3b38f7Smrg	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
73047a3b38f7Smrg	      cmds=$module_expsym_cmds
7305ff559fabSmrg	    else
73067a3b38f7Smrg	      cmds=$module_cmds
7307ff559fabSmrg	    fi
7308ff559fabSmrg	  else
73097a3b38f7Smrg	    if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
73107a3b38f7Smrg	      cmds=$archive_expsym_cmds
73117a3b38f7Smrg	    else
73127a3b38f7Smrg	      cmds=$archive_cmds
73137a3b38f7Smrg	    fi
7314ff559fabSmrg	  fi
7315ff559fabSmrg	fi
7316ff559fabSmrg
73177a3b38f7Smrg	if test -n "$delfiles"; then
73187a3b38f7Smrg	  # Append the command to remove temporary files to $cmds.
73197a3b38f7Smrg	  eval cmds=\"\$cmds~\$RM $delfiles\"
73207a3b38f7Smrg	fi
7321ff559fabSmrg
73227a3b38f7Smrg	# Add any objects from preloaded convenience libraries
73237a3b38f7Smrg	if test -n "$dlprefiles"; then
73247a3b38f7Smrg	  gentop="$output_objdir/${outputname}x"
73257a3b38f7Smrg	  generated="$generated $gentop"
7326ff559fabSmrg
73277a3b38f7Smrg	  func_extract_archives $gentop $dlprefiles
73287a3b38f7Smrg	  libobjs="$libobjs $func_extract_archives_result"
73297a3b38f7Smrg	  test "X$libobjs" = "X " && libobjs=
7330ff559fabSmrg	fi
7331ff559fabSmrg
73327a3b38f7Smrg	save_ifs="$IFS"; IFS='~'
73337a3b38f7Smrg	for cmd in $cmds; do
73347a3b38f7Smrg	  IFS="$save_ifs"
73357a3b38f7Smrg	  eval cmd=\"$cmd\"
73367a3b38f7Smrg	  $opt_silent || {
73377a3b38f7Smrg	    func_quote_for_expand "$cmd"
73387a3b38f7Smrg	    eval "func_echo $func_quote_for_expand_result"
73397a3b38f7Smrg	  }
73407a3b38f7Smrg	  $opt_dry_run || eval "$cmd" || {
73417a3b38f7Smrg	    lt_exit=$?
7342ff559fabSmrg
73437a3b38f7Smrg	    # Restore the uninstalled library and exit
73447a3b38f7Smrg	    if test "$mode" = relink; then
73457a3b38f7Smrg	      ( cd "$output_objdir" && \
73467a3b38f7Smrg	        $RM "${realname}T" && \
73477a3b38f7Smrg		$MV "${realname}U" "$realname" )
73487a3b38f7Smrg	    fi
73497a3b38f7Smrg
73507a3b38f7Smrg	    exit $lt_exit
73517a3b38f7Smrg	  }
73527a3b38f7Smrg	done
73537a3b38f7Smrg	IFS="$save_ifs"
73547a3b38f7Smrg
73557a3b38f7Smrg	# Restore the uninstalled library and exit
73567a3b38f7Smrg	if test "$mode" = relink; then
73577a3b38f7Smrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
73587a3b38f7Smrg
73597a3b38f7Smrg	  if test -n "$convenience"; then
73607a3b38f7Smrg	    if test -z "$whole_archive_flag_spec"; then
73617a3b38f7Smrg	      func_show_eval '${RM}r "$gentop"'
7362ff559fabSmrg	    fi
7363ff559fabSmrg	  fi
7364ff559fabSmrg
73657a3b38f7Smrg	  exit $EXIT_SUCCESS
73667a3b38f7Smrg	fi
7367ff559fabSmrg
73687a3b38f7Smrg	# Create links to the real library.
73697a3b38f7Smrg	for linkname in $linknames; do
73707a3b38f7Smrg	  if test "$realname" != "$linkname"; then
73717a3b38f7Smrg	    func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
73727a3b38f7Smrg	  fi
73737a3b38f7Smrg	done
73747a3b38f7Smrg
73757a3b38f7Smrg	# If -module or -export-dynamic was specified, set the dlname.
73767a3b38f7Smrg	if test "$module" = yes || test "$export_dynamic" = yes; then
73777a3b38f7Smrg	  # On all known operating systems, these are identical.
73787a3b38f7Smrg	  dlname="$soname"
73797a3b38f7Smrg	fi
73807a3b38f7Smrg      fi
73817a3b38f7Smrg      ;;
73827a3b38f7Smrg
73837a3b38f7Smrg    obj)
73847a3b38f7Smrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
73857a3b38f7Smrg	func_warning "\`-dlopen' is ignored for objects"
73867a3b38f7Smrg      fi
73877a3b38f7Smrg
73887a3b38f7Smrg      case " $deplibs" in
73897a3b38f7Smrg      *\ -l* | *\ -L*)
73907a3b38f7Smrg	func_warning "\`-l' and \`-L' are ignored for objects" ;;
73917a3b38f7Smrg      esac
73927a3b38f7Smrg
73937a3b38f7Smrg      test -n "$rpath" && \
73947a3b38f7Smrg	func_warning "\`-rpath' is ignored for objects"
73957a3b38f7Smrg
73967a3b38f7Smrg      test -n "$xrpath" && \
73977a3b38f7Smrg	func_warning "\`-R' is ignored for objects"
73987a3b38f7Smrg
73997a3b38f7Smrg      test -n "$vinfo" && \
74007a3b38f7Smrg	func_warning "\`-version-info' is ignored for objects"
74017a3b38f7Smrg
74027a3b38f7Smrg      test -n "$release" && \
74037a3b38f7Smrg	func_warning "\`-release' is ignored for objects"
74047a3b38f7Smrg
74057a3b38f7Smrg      case $output in
74067a3b38f7Smrg      *.lo)
74077a3b38f7Smrg	test -n "$objs$old_deplibs" && \
74087a3b38f7Smrg	  func_fatal_error "cannot build library object \`$output' from non-libtool objects"
74097a3b38f7Smrg
74107a3b38f7Smrg	libobj=$output
74117a3b38f7Smrg	func_lo2o "$libobj"
74127a3b38f7Smrg	obj=$func_lo2o_result
74137a3b38f7Smrg	;;
74147a3b38f7Smrg      *)
74157a3b38f7Smrg	libobj=
74167a3b38f7Smrg	obj="$output"
74177a3b38f7Smrg	;;
74187a3b38f7Smrg      esac
74197a3b38f7Smrg
74207a3b38f7Smrg      # Delete the old objects.
74217a3b38f7Smrg      $opt_dry_run || $RM $obj $libobj
74227a3b38f7Smrg
74237a3b38f7Smrg      # Objects from convenience libraries.  This assumes
74247a3b38f7Smrg      # single-version convenience libraries.  Whenever we create
74257a3b38f7Smrg      # different ones for PIC/non-PIC, this we'll have to duplicate
74267a3b38f7Smrg      # the extraction.
74277a3b38f7Smrg      reload_conv_objs=
74287a3b38f7Smrg      gentop=
74297a3b38f7Smrg      # reload_cmds runs $LD directly, so let us get rid of
74307a3b38f7Smrg      # -Wl from whole_archive_flag_spec and hope we can get by with
74317a3b38f7Smrg      # turning comma into space..
74327a3b38f7Smrg      wl=
74337a3b38f7Smrg
74347a3b38f7Smrg      if test -n "$convenience"; then
74357a3b38f7Smrg	if test -n "$whole_archive_flag_spec"; then
74367a3b38f7Smrg	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
74377a3b38f7Smrg	  reload_conv_objs=$reload_objs\ `$ECHO "X$tmp_whole_archive_flags" | $Xsed -e 's|,| |g'`
74387a3b38f7Smrg	else
74397a3b38f7Smrg	  gentop="$output_objdir/${obj}x"
74407a3b38f7Smrg	  generated="$generated $gentop"
74417a3b38f7Smrg
74427a3b38f7Smrg	  func_extract_archives $gentop $convenience
74437a3b38f7Smrg	  reload_conv_objs="$reload_objs $func_extract_archives_result"
74447a3b38f7Smrg	fi
74457a3b38f7Smrg      fi
7446ff559fabSmrg
74477a3b38f7Smrg      # Create the old-style object.
74487a3b38f7Smrg      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
7449ff559fabSmrg
74507a3b38f7Smrg      output="$obj"
74517a3b38f7Smrg      func_execute_cmds "$reload_cmds" 'exit $?'
7452ff559fabSmrg
74537a3b38f7Smrg      # Exit if we aren't doing a library object file.
74547a3b38f7Smrg      if test -z "$libobj"; then
74557a3b38f7Smrg	if test -n "$gentop"; then
74567a3b38f7Smrg	  func_show_eval '${RM}r "$gentop"'
74577a3b38f7Smrg	fi
7458ff559fabSmrg
74597a3b38f7Smrg	exit $EXIT_SUCCESS
74607a3b38f7Smrg      fi
7461ff559fabSmrg
74627a3b38f7Smrg      if test "$build_libtool_libs" != yes; then
74637a3b38f7Smrg	if test -n "$gentop"; then
74647a3b38f7Smrg	  func_show_eval '${RM}r "$gentop"'
74657a3b38f7Smrg	fi
7466ff559fabSmrg
74677a3b38f7Smrg	# Create an invalid libtool object if no PIC, so that we don't
74687a3b38f7Smrg	# accidentally link it into a program.
74697a3b38f7Smrg	# $show "echo timestamp > $libobj"
74707a3b38f7Smrg	# $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
74717a3b38f7Smrg	exit $EXIT_SUCCESS
74727a3b38f7Smrg      fi
7473ff559fabSmrg
74747a3b38f7Smrg      if test -n "$pic_flag" || test "$pic_mode" != default; then
74757a3b38f7Smrg	# Only do commands if we really have different PIC objects.
74767a3b38f7Smrg	reload_objs="$libobjs $reload_conv_objs"
74777a3b38f7Smrg	output="$libobj"
74787a3b38f7Smrg	func_execute_cmds "$reload_cmds" 'exit $?'
7479ff559fabSmrg      fi
7480ff559fabSmrg
74817a3b38f7Smrg      if test -n "$gentop"; then
74827a3b38f7Smrg	func_show_eval '${RM}r "$gentop"'
74837a3b38f7Smrg      fi
7484ff559fabSmrg
74857a3b38f7Smrg      exit $EXIT_SUCCESS
74867a3b38f7Smrg      ;;
7487ff559fabSmrg
74887a3b38f7Smrg    prog)
74897a3b38f7Smrg      case $host in
74907a3b38f7Smrg	*cygwin*) func_stripname '' '.exe' "$output"
74917a3b38f7Smrg	          output=$func_stripname_result.exe;;
7492ff559fabSmrg      esac
74937a3b38f7Smrg      test -n "$vinfo" && \
74947a3b38f7Smrg	func_warning "\`-version-info' is ignored for programs"
7495ff559fabSmrg
74967a3b38f7Smrg      test -n "$release" && \
74977a3b38f7Smrg	func_warning "\`-release' is ignored for programs"
7498ff559fabSmrg
74997a3b38f7Smrg      test "$preload" = yes \
75007a3b38f7Smrg        && test "$dlopen_support" = unknown \
75017a3b38f7Smrg	&& test "$dlopen_self" = unknown \
75027a3b38f7Smrg	&& test "$dlopen_self_static" = unknown && \
75037a3b38f7Smrg	  func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support."
7504ff559fabSmrg
75057a3b38f7Smrg      case $host in
75067a3b38f7Smrg      *-*-rhapsody* | *-*-darwin1.[012])
75077a3b38f7Smrg	# On Rhapsody replace the C library is the System framework
75087a3b38f7Smrg	compile_deplibs=`$ECHO "X $compile_deplibs" | $Xsed -e 's/ -lc / System.ltframework /'`
75097a3b38f7Smrg	finalize_deplibs=`$ECHO "X $finalize_deplibs" | $Xsed -e 's/ -lc / System.ltframework /'`
7510ff559fabSmrg	;;
7511ff559fabSmrg      esac
7512ff559fabSmrg
75137a3b38f7Smrg      case $host in
75147a3b38f7Smrg      *-*-darwin*)
75157a3b38f7Smrg	# Don't allow lazy linking, it breaks C++ global constructors
75167a3b38f7Smrg	# But is supposedly fixed on 10.4 or later (yay!).
75177a3b38f7Smrg	if test "$tagname" = CXX ; then
75187a3b38f7Smrg	  case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
75197a3b38f7Smrg	    10.[0123])
75207a3b38f7Smrg	      compile_command="$compile_command ${wl}-bind_at_load"
75217a3b38f7Smrg	      finalize_command="$finalize_command ${wl}-bind_at_load"
75227a3b38f7Smrg	    ;;
75237a3b38f7Smrg	  esac
75247a3b38f7Smrg	fi
75257a3b38f7Smrg	# Time to change all our "foo.ltframework" stuff back to "-framework foo"
75267a3b38f7Smrg	compile_deplibs=`$ECHO "X $compile_deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
75277a3b38f7Smrg	finalize_deplibs=`$ECHO "X $finalize_deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
7528ff559fabSmrg	;;
7529ff559fabSmrg      esac
7530ff559fabSmrg
7531ff559fabSmrg
75327a3b38f7Smrg      # move library search paths that coincide with paths to not yet
75337a3b38f7Smrg      # installed libraries to the beginning of the library search list
75347a3b38f7Smrg      new_libs=
75357a3b38f7Smrg      for path in $notinst_path; do
75367a3b38f7Smrg	case " $new_libs " in
75377a3b38f7Smrg	*" -L$path/$objdir "*) ;;
7538ff559fabSmrg	*)
75397a3b38f7Smrg	  case " $compile_deplibs " in
75407a3b38f7Smrg	  *" -L$path/$objdir "*)
75417a3b38f7Smrg	    new_libs="$new_libs -L$path/$objdir" ;;
75427a3b38f7Smrg	  esac
7543ff559fabSmrg	  ;;
7544ff559fabSmrg	esac
7545ff559fabSmrg      done
75467a3b38f7Smrg      for deplib in $compile_deplibs; do
75477a3b38f7Smrg	case $deplib in
75487a3b38f7Smrg	-L*)
75497a3b38f7Smrg	  case " $new_libs " in
75507a3b38f7Smrg	  *" $deplib "*) ;;
75517a3b38f7Smrg	  *) new_libs="$new_libs $deplib" ;;
75527a3b38f7Smrg	  esac
75537a3b38f7Smrg	  ;;
75547a3b38f7Smrg	*) new_libs="$new_libs $deplib" ;;
75557a3b38f7Smrg	esac
75567a3b38f7Smrg      done
75577a3b38f7Smrg      compile_deplibs="$new_libs"
7558ff559fabSmrg
7559ff559fabSmrg
75607a3b38f7Smrg      compile_command="$compile_command $compile_deplibs"
75617a3b38f7Smrg      finalize_command="$finalize_command $finalize_deplibs"
7562ff559fabSmrg
75637a3b38f7Smrg      if test -n "$rpath$xrpath"; then
75647a3b38f7Smrg	# If the user specified any rpath flags, then add them.
75657a3b38f7Smrg	for libdir in $rpath $xrpath; do
75667a3b38f7Smrg	  # This is the magic to use -rpath.
75677a3b38f7Smrg	  case "$finalize_rpath " in
75687a3b38f7Smrg	  *" $libdir "*) ;;
75697a3b38f7Smrg	  *) finalize_rpath="$finalize_rpath $libdir" ;;
75707a3b38f7Smrg	  esac
75717a3b38f7Smrg	done
75727a3b38f7Smrg      fi
7573ff559fabSmrg
75747a3b38f7Smrg      # Now hardcode the library paths
75757a3b38f7Smrg      rpath=
75767a3b38f7Smrg      hardcode_libdirs=
75777a3b38f7Smrg      for libdir in $compile_rpath $finalize_rpath; do
75787a3b38f7Smrg	if test -n "$hardcode_libdir_flag_spec"; then
75797a3b38f7Smrg	  if test -n "$hardcode_libdir_separator"; then
75807a3b38f7Smrg	    if test -z "$hardcode_libdirs"; then
75817a3b38f7Smrg	      hardcode_libdirs="$libdir"
75827a3b38f7Smrg	    else
75837a3b38f7Smrg	      # Just accumulate the unique libdirs.
75847a3b38f7Smrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
75857a3b38f7Smrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
75867a3b38f7Smrg		;;
75877a3b38f7Smrg	      *)
75887a3b38f7Smrg		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
75897a3b38f7Smrg		;;
75907a3b38f7Smrg	      esac
75917a3b38f7Smrg	    fi
75927a3b38f7Smrg	  else
75937a3b38f7Smrg	    eval flag=\"$hardcode_libdir_flag_spec\"
75947a3b38f7Smrg	    rpath="$rpath $flag"
75957a3b38f7Smrg	  fi
75967a3b38f7Smrg	elif test -n "$runpath_var"; then
75977a3b38f7Smrg	  case "$perm_rpath " in
7598ff559fabSmrg	  *" $libdir "*) ;;
75997a3b38f7Smrg	  *) perm_rpath="$perm_rpath $libdir" ;;
7600ff559fabSmrg	  esac
76017a3b38f7Smrg	fi
76027a3b38f7Smrg	case $host in
76037a3b38f7Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
76047a3b38f7Smrg	  testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'`
76057a3b38f7Smrg	  case :$dllsearchpath: in
76067a3b38f7Smrg	  *":$libdir:"*) ;;
76077a3b38f7Smrg	  ::) dllsearchpath=$libdir;;
76087a3b38f7Smrg	  *) dllsearchpath="$dllsearchpath:$libdir";;
76097a3b38f7Smrg	  esac
76107a3b38f7Smrg	  case :$dllsearchpath: in
76117a3b38f7Smrg	  *":$testbindir:"*) ;;
76127a3b38f7Smrg	  ::) dllsearchpath=$testbindir;;
76137a3b38f7Smrg	  *) dllsearchpath="$dllsearchpath:$testbindir";;
76147a3b38f7Smrg	  esac
76157a3b38f7Smrg	  ;;
76167a3b38f7Smrg	esac
76177a3b38f7Smrg      done
76187a3b38f7Smrg      # Substitute the hardcoded libdirs into the rpath.
76197a3b38f7Smrg      if test -n "$hardcode_libdir_separator" &&
76207a3b38f7Smrg	 test -n "$hardcode_libdirs"; then
76217a3b38f7Smrg	libdir="$hardcode_libdirs"
76227a3b38f7Smrg	eval rpath=\" $hardcode_libdir_flag_spec\"
76237a3b38f7Smrg      fi
76247a3b38f7Smrg      compile_rpath="$rpath"
76257a3b38f7Smrg
76267a3b38f7Smrg      rpath=
76277a3b38f7Smrg      hardcode_libdirs=
76287a3b38f7Smrg      for libdir in $finalize_rpath; do
76297a3b38f7Smrg	if test -n "$hardcode_libdir_flag_spec"; then
76307a3b38f7Smrg	  if test -n "$hardcode_libdir_separator"; then
76317a3b38f7Smrg	    if test -z "$hardcode_libdirs"; then
76327a3b38f7Smrg	      hardcode_libdirs="$libdir"
76337a3b38f7Smrg	    else
76347a3b38f7Smrg	      # Just accumulate the unique libdirs.
76357a3b38f7Smrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
76367a3b38f7Smrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
76377a3b38f7Smrg		;;
76387a3b38f7Smrg	      *)
76397a3b38f7Smrg		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
76407a3b38f7Smrg		;;
76417a3b38f7Smrg	      esac
76427a3b38f7Smrg	    fi
76437a3b38f7Smrg	  else
76447a3b38f7Smrg	    eval flag=\"$hardcode_libdir_flag_spec\"
76457a3b38f7Smrg	    rpath="$rpath $flag"
76467a3b38f7Smrg	  fi
76477a3b38f7Smrg	elif test -n "$runpath_var"; then
76487a3b38f7Smrg	  case "$finalize_perm_rpath " in
7649ff559fabSmrg	  *" $libdir "*) ;;
76507a3b38f7Smrg	  *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;;
7651ff559fabSmrg	  esac
7652ff559fabSmrg	fi
76537a3b38f7Smrg      done
76547a3b38f7Smrg      # Substitute the hardcoded libdirs into the rpath.
76557a3b38f7Smrg      if test -n "$hardcode_libdir_separator" &&
76567a3b38f7Smrg	 test -n "$hardcode_libdirs"; then
76577a3b38f7Smrg	libdir="$hardcode_libdirs"
76587a3b38f7Smrg	eval rpath=\" $hardcode_libdir_flag_spec\"
76597a3b38f7Smrg      fi
76607a3b38f7Smrg      finalize_rpath="$rpath"
7661ff559fabSmrg
76627a3b38f7Smrg      if test -n "$libobjs" && test "$build_old_libs" = yes; then
76637a3b38f7Smrg	# Transform all the library objects into standard objects.
76647a3b38f7Smrg	compile_command=`$ECHO "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
76657a3b38f7Smrg	finalize_command=`$ECHO "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
76667a3b38f7Smrg      fi
7667ff559fabSmrg
76687a3b38f7Smrg      func_generate_dlsyms "$outputname" "@PROGRAM@" "no"
7669ff559fabSmrg
76707a3b38f7Smrg      # template prelinking step
76717a3b38f7Smrg      if test -n "$prelink_cmds"; then
76727a3b38f7Smrg	func_execute_cmds "$prelink_cmds" 'exit $?'
76737a3b38f7Smrg      fi
7674ff559fabSmrg
76757a3b38f7Smrg      wrappers_required=yes
76767a3b38f7Smrg      case $host in
76777a3b38f7Smrg      *cygwin* | *mingw* )
76787a3b38f7Smrg        if test "$build_libtool_libs" != yes; then
76797a3b38f7Smrg          wrappers_required=no
76807a3b38f7Smrg        fi
76817a3b38f7Smrg        ;;
76827a3b38f7Smrg      *cegcc)
76837a3b38f7Smrg        # Disable wrappers for cegcc, we are cross compiling anyway.
76847a3b38f7Smrg        wrappers_required=no
76857a3b38f7Smrg        ;;
76867a3b38f7Smrg      *)
76877a3b38f7Smrg        if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
76887a3b38f7Smrg          wrappers_required=no
76897a3b38f7Smrg        fi
76907a3b38f7Smrg        ;;
76917a3b38f7Smrg      esac
76927a3b38f7Smrg      if test "$wrappers_required" = no; then
76937a3b38f7Smrg	# Replace the output file specification.
76947a3b38f7Smrg	compile_command=`$ECHO "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
76957a3b38f7Smrg	link_command="$compile_command$compile_rpath"
7696ff559fabSmrg
76977a3b38f7Smrg	# We have no uninstalled library dependencies, so finalize right now.
76987a3b38f7Smrg	exit_status=0
76997a3b38f7Smrg	func_show_eval "$link_command" 'exit_status=$?'
7700ff559fabSmrg
77017a3b38f7Smrg	# Delete the generated files.
77027a3b38f7Smrg	if test -f "$output_objdir/${outputname}S.${objext}"; then
77037a3b38f7Smrg	  func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"'
77047a3b38f7Smrg	fi
7705ff559fabSmrg
77067a3b38f7Smrg	exit $exit_status
77077a3b38f7Smrg      fi
7708ff559fabSmrg
77097a3b38f7Smrg      if test -n "$compile_shlibpath$finalize_shlibpath"; then
77107a3b38f7Smrg	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
77117a3b38f7Smrg      fi
77127a3b38f7Smrg      if test -n "$finalize_shlibpath"; then
77137a3b38f7Smrg	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
77147a3b38f7Smrg      fi
7715ff559fabSmrg
77167a3b38f7Smrg      compile_var=
77177a3b38f7Smrg      finalize_var=
77187a3b38f7Smrg      if test -n "$runpath_var"; then
77197a3b38f7Smrg	if test -n "$perm_rpath"; then
77207a3b38f7Smrg	  # We should set the runpath_var.
77217a3b38f7Smrg	  rpath=
77227a3b38f7Smrg	  for dir in $perm_rpath; do
77237a3b38f7Smrg	    rpath="$rpath$dir:"
7724ff559fabSmrg	  done
77257a3b38f7Smrg	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
7726ff559fabSmrg	fi
77277a3b38f7Smrg	if test -n "$finalize_perm_rpath"; then
77287a3b38f7Smrg	  # We should set the runpath_var.
77297a3b38f7Smrg	  rpath=
77307a3b38f7Smrg	  for dir in $finalize_perm_rpath; do
77317a3b38f7Smrg	    rpath="$rpath$dir:"
77327a3b38f7Smrg	  done
77337a3b38f7Smrg	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
77347a3b38f7Smrg	fi
77357a3b38f7Smrg      fi
7736ff559fabSmrg
77377a3b38f7Smrg      if test "$no_install" = yes; then
77387a3b38f7Smrg	# We don't need to create a wrapper script.
77397a3b38f7Smrg	link_command="$compile_var$compile_command$compile_rpath"
77407a3b38f7Smrg	# Replace the output file specification.
77417a3b38f7Smrg	link_command=`$ECHO "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
77427a3b38f7Smrg	# Delete the old output file.
77437a3b38f7Smrg	$opt_dry_run || $RM $output
77447a3b38f7Smrg	# Link the executable and exit
77457a3b38f7Smrg	func_show_eval "$link_command" 'exit $?'
77467a3b38f7Smrg	exit $EXIT_SUCCESS
77477a3b38f7Smrg      fi
7748ff559fabSmrg
77497a3b38f7Smrg      if test "$hardcode_action" = relink; then
77507a3b38f7Smrg	# Fast installation is not supported
77517a3b38f7Smrg	link_command="$compile_var$compile_command$compile_rpath"
77527a3b38f7Smrg	relink_command="$finalize_var$finalize_command$finalize_rpath"
7753ff559fabSmrg
77547a3b38f7Smrg	func_warning "this platform does not like uninstalled shared libraries"
77557a3b38f7Smrg	func_warning "\`$output' will be relinked during installation"
77567a3b38f7Smrg      else
77577a3b38f7Smrg	if test "$fast_install" != no; then
77587a3b38f7Smrg	  link_command="$finalize_var$compile_command$finalize_rpath"
77597a3b38f7Smrg	  if test "$fast_install" = yes; then
77607a3b38f7Smrg	    relink_command=`$ECHO "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'`
77617a3b38f7Smrg	  else
77627a3b38f7Smrg	    # fast_install is set to needless
77637a3b38f7Smrg	    relink_command=
77647a3b38f7Smrg	  fi
7765ff559fabSmrg	else
77667a3b38f7Smrg	  link_command="$compile_var$compile_command$compile_rpath"
77677a3b38f7Smrg	  relink_command="$finalize_var$finalize_command$finalize_rpath"
7768ff559fabSmrg	fi
77697a3b38f7Smrg      fi
7770ff559fabSmrg
77717a3b38f7Smrg      # Replace the output file specification.
77727a3b38f7Smrg      link_command=`$ECHO "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
7773ff559fabSmrg
77747a3b38f7Smrg      # Delete the old output files.
77757a3b38f7Smrg      $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
7776ff559fabSmrg
77777a3b38f7Smrg      func_show_eval "$link_command" 'exit $?'
7778ff559fabSmrg
77797a3b38f7Smrg      # Now create the wrapper script.
77807a3b38f7Smrg      func_verbose "creating $output"
7781ff559fabSmrg
77827a3b38f7Smrg      # Quote the relink command for shipping.
77837a3b38f7Smrg      if test -n "$relink_command"; then
77847a3b38f7Smrg	# Preserve any variables that may affect compiler behavior
77857a3b38f7Smrg	for var in $variables_saved_for_relink; do
77867a3b38f7Smrg	  if eval test -z \"\${$var+set}\"; then
77877a3b38f7Smrg	    relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
77887a3b38f7Smrg	  elif eval var_value=\$$var; test -z "$var_value"; then
77897a3b38f7Smrg	    relink_command="$var=; export $var; $relink_command"
77907a3b38f7Smrg	  else
77917a3b38f7Smrg	    func_quote_for_eval "$var_value"
77927a3b38f7Smrg	    relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
77937a3b38f7Smrg	  fi
77947a3b38f7Smrg	done
77957a3b38f7Smrg	relink_command="(cd `pwd`; $relink_command)"
77967a3b38f7Smrg	relink_command=`$ECHO "X$relink_command" | $Xsed -e "$sed_quote_subst"`
77977a3b38f7Smrg      fi
7798ff559fabSmrg
77997a3b38f7Smrg      # Quote $ECHO for shipping.
78007a3b38f7Smrg      if test "X$ECHO" = "X$SHELL $progpath --fallback-echo"; then
78017a3b38f7Smrg	case $progpath in
78027a3b38f7Smrg	[\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $progpath --fallback-echo";;
78037a3b38f7Smrg	*) qecho="$SHELL `pwd`/$progpath --fallback-echo";;
7804ff559fabSmrg	esac
78057a3b38f7Smrg	qecho=`$ECHO "X$qecho" | $Xsed -e "$sed_quote_subst"`
78067a3b38f7Smrg      else
78077a3b38f7Smrg	qecho=`$ECHO "X$ECHO" | $Xsed -e "$sed_quote_subst"`
78087a3b38f7Smrg      fi
7809ff559fabSmrg
78107a3b38f7Smrg      # Only actually do things if not in dry run mode.
78117a3b38f7Smrg      $opt_dry_run || {
78127a3b38f7Smrg	# win32 will think the script is a binary if it has
78137a3b38f7Smrg	# a .exe suffix, so we strip it off here.
78147a3b38f7Smrg	case $output in
78157a3b38f7Smrg	  *.exe) func_stripname '' '.exe' "$output"
78167a3b38f7Smrg	         output=$func_stripname_result ;;
78177a3b38f7Smrg	esac
78187a3b38f7Smrg	# test for cygwin because mv fails w/o .exe extensions
7819ff559fabSmrg	case $host in
78207a3b38f7Smrg	  *cygwin*)
78217a3b38f7Smrg	    exeext=.exe
78227a3b38f7Smrg	    func_stripname '' '.exe' "$outputname"
78237a3b38f7Smrg	    outputname=$func_stripname_result ;;
78247a3b38f7Smrg	  *) exeext= ;;
7825ff559fabSmrg	esac
78267a3b38f7Smrg	case $host in
78277a3b38f7Smrg	  *cygwin* | *mingw* )
78287a3b38f7Smrg	    func_dirname_and_basename "$output" "" "."
78297a3b38f7Smrg	    output_name=$func_basename_result
78307a3b38f7Smrg	    output_path=$func_dirname_result
78317a3b38f7Smrg	    cwrappersource="$output_path/$objdir/lt-$output_name.c"
78327a3b38f7Smrg	    cwrapper="$output_path/$output_name.exe"
78337a3b38f7Smrg	    $RM $cwrappersource $cwrapper
78347a3b38f7Smrg	    trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
78357a3b38f7Smrg
78367a3b38f7Smrg	    func_emit_cwrapperexe_src > $cwrappersource
78377a3b38f7Smrg
78387a3b38f7Smrg	    # The wrapper executable is built using the $host compiler,
78397a3b38f7Smrg	    # because it contains $host paths and files. If cross-
78407a3b38f7Smrg	    # compiling, it, like the target executable, must be
78417a3b38f7Smrg	    # executed on the $host or under an emulation environment.
78427a3b38f7Smrg	    $opt_dry_run || {
78437a3b38f7Smrg	      $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
78447a3b38f7Smrg	      $STRIP $cwrapper
78457a3b38f7Smrg	    }
7846ff559fabSmrg
78477a3b38f7Smrg	    # Now, create the wrapper script for func_source use:
78487a3b38f7Smrg	    func_ltwrapper_scriptname $cwrapper
78497a3b38f7Smrg	    $RM $func_ltwrapper_scriptname_result
78507a3b38f7Smrg	    trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
78517a3b38f7Smrg	    $opt_dry_run || {
78527a3b38f7Smrg	      # note: this script will not be executed, so do not chmod.
78537a3b38f7Smrg	      if test "x$build" = "x$host" ; then
78547a3b38f7Smrg		$cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
7855ff559fabSmrg	      else
78567a3b38f7Smrg		func_emit_wrapper no > $func_ltwrapper_scriptname_result
7857ff559fabSmrg	      fi
78587a3b38f7Smrg	    }
78597a3b38f7Smrg	  ;;
78607a3b38f7Smrg	  * )
78617a3b38f7Smrg	    $RM $output
78627a3b38f7Smrg	    trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
7863ff559fabSmrg
78647a3b38f7Smrg	    func_emit_wrapper no > $output
78657a3b38f7Smrg	    chmod +x $output
7866ff559fabSmrg	  ;;
7867ff559fabSmrg	esac
78687a3b38f7Smrg      }
78697a3b38f7Smrg      exit $EXIT_SUCCESS
78707a3b38f7Smrg      ;;
78717a3b38f7Smrg    esac
7872ff559fabSmrg
78737a3b38f7Smrg    # See if we need to build an old-fashioned archive.
78747a3b38f7Smrg    for oldlib in $oldlibs; do
7875ff559fabSmrg
78767a3b38f7Smrg      if test "$build_libtool_libs" = convenience; then
78777a3b38f7Smrg	oldobjs="$libobjs_save $symfileobj"
78787a3b38f7Smrg	addlibs="$convenience"
78797a3b38f7Smrg	build_libtool_libs=no
78807a3b38f7Smrg      else
78817a3b38f7Smrg	if test "$build_libtool_libs" = module; then
78827a3b38f7Smrg	  oldobjs="$libobjs_save"
78837a3b38f7Smrg	  build_libtool_libs=no
78847a3b38f7Smrg	else
78857a3b38f7Smrg	  oldobjs="$old_deplibs $non_pic_objects"
78867a3b38f7Smrg	  if test "$preload" = yes && test -f "$symfileobj"; then
78877a3b38f7Smrg	    oldobjs="$oldobjs $symfileobj"
78887a3b38f7Smrg	  fi
78897a3b38f7Smrg	fi
78907a3b38f7Smrg	addlibs="$old_convenience"
7891ff559fabSmrg      fi
7892ff559fabSmrg
78937a3b38f7Smrg      if test -n "$addlibs"; then
78947a3b38f7Smrg	gentop="$output_objdir/${outputname}x"
78957a3b38f7Smrg	generated="$generated $gentop"
7896ff559fabSmrg
78977a3b38f7Smrg	func_extract_archives $gentop $addlibs
78987a3b38f7Smrg	oldobjs="$oldobjs $func_extract_archives_result"
78997a3b38f7Smrg      fi
7900ff559fabSmrg
79017a3b38f7Smrg      # Do each command in the archive commands.
79027a3b38f7Smrg      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
79037a3b38f7Smrg	cmds=$old_archive_from_new_cmds
79047a3b38f7Smrg      else
7905ff559fabSmrg
79067a3b38f7Smrg	# Add any objects from preloaded convenience libraries
79077a3b38f7Smrg	if test -n "$dlprefiles"; then
79087a3b38f7Smrg	  gentop="$output_objdir/${outputname}x"
79097a3b38f7Smrg	  generated="$generated $gentop"
7910ff559fabSmrg
79117a3b38f7Smrg	  func_extract_archives $gentop $dlprefiles
79127a3b38f7Smrg	  oldobjs="$oldobjs $func_extract_archives_result"
79137a3b38f7Smrg	fi
7914ff559fabSmrg
79157a3b38f7Smrg	# POSIX demands no paths to be encoded in archives.  We have
79167a3b38f7Smrg	# to avoid creating archives with duplicate basenames if we
79177a3b38f7Smrg	# might have to extract them afterwards, e.g., when creating a
79187a3b38f7Smrg	# static archive out of a convenience library, or when linking
79197a3b38f7Smrg	# the entirety of a libtool archive into another (currently
79207a3b38f7Smrg	# not supported by libtool).
79217a3b38f7Smrg	if (for obj in $oldobjs
79227a3b38f7Smrg	    do
79237a3b38f7Smrg	      func_basename "$obj"
79247a3b38f7Smrg	      $ECHO "$func_basename_result"
79257a3b38f7Smrg	    done | sort | sort -uc >/dev/null 2>&1); then
79267a3b38f7Smrg	  :
79277a3b38f7Smrg	else
79287a3b38f7Smrg	  $ECHO "copying selected object files to avoid basename conflicts..."
79297a3b38f7Smrg	  gentop="$output_objdir/${outputname}x"
79307a3b38f7Smrg	  generated="$generated $gentop"
79317a3b38f7Smrg	  func_mkdir_p "$gentop"
79327a3b38f7Smrg	  save_oldobjs=$oldobjs
79337a3b38f7Smrg	  oldobjs=
79347a3b38f7Smrg	  counter=1
79357a3b38f7Smrg	  for obj in $save_oldobjs
79367a3b38f7Smrg	  do
79377a3b38f7Smrg	    func_basename "$obj"
79387a3b38f7Smrg	    objbase="$func_basename_result"
79397a3b38f7Smrg	    case " $oldobjs " in
79407a3b38f7Smrg	    " ") oldobjs=$obj ;;
79417a3b38f7Smrg	    *[\ /]"$objbase "*)
79427a3b38f7Smrg	      while :; do
79437a3b38f7Smrg		# Make sure we don't pick an alternate name that also
79447a3b38f7Smrg		# overlaps.
79457a3b38f7Smrg		newobj=lt$counter-$objbase
79467a3b38f7Smrg		func_arith $counter + 1
79477a3b38f7Smrg		counter=$func_arith_result
79487a3b38f7Smrg		case " $oldobjs " in
79497a3b38f7Smrg		*[\ /]"$newobj "*) ;;
79507a3b38f7Smrg		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
79517a3b38f7Smrg		esac
79527a3b38f7Smrg	      done
79537a3b38f7Smrg	      func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
79547a3b38f7Smrg	      oldobjs="$oldobjs $gentop/$newobj"
79557a3b38f7Smrg	      ;;
79567a3b38f7Smrg	    *) oldobjs="$oldobjs $obj" ;;
79577a3b38f7Smrg	    esac
7958ff559fabSmrg	  done
7959ff559fabSmrg	fi
79607a3b38f7Smrg	eval cmds=\"$old_archive_cmds\"
7961ff559fabSmrg
79627a3b38f7Smrg	func_len " $cmds"
79637a3b38f7Smrg	len=$func_len_result
79647a3b38f7Smrg	if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
79657a3b38f7Smrg	  cmds=$old_archive_cmds
79667a3b38f7Smrg	else
79677a3b38f7Smrg	  # the command line is too long to link in one step, link in parts
79687a3b38f7Smrg	  func_verbose "using piecewise archive linking..."
79697a3b38f7Smrg	  save_RANLIB=$RANLIB
79707a3b38f7Smrg	  RANLIB=:
79717a3b38f7Smrg	  objlist=
79727a3b38f7Smrg	  concat_cmds=
79737a3b38f7Smrg	  save_oldobjs=$oldobjs
79747a3b38f7Smrg	  oldobjs=
79757a3b38f7Smrg	  # Is there a better way of finding the last object in the list?
79767a3b38f7Smrg	  for obj in $save_oldobjs
79777a3b38f7Smrg	  do
79787a3b38f7Smrg	    last_oldobj=$obj
79797a3b38f7Smrg	  done
79807a3b38f7Smrg	  eval test_cmds=\"$old_archive_cmds\"
79817a3b38f7Smrg	  func_len " $test_cmds"
79827a3b38f7Smrg	  len0=$func_len_result
79837a3b38f7Smrg	  len=$len0
79847a3b38f7Smrg	  for obj in $save_oldobjs
79857a3b38f7Smrg	  do
79867a3b38f7Smrg	    func_len " $obj"
79877a3b38f7Smrg	    func_arith $len + $func_len_result
79887a3b38f7Smrg	    len=$func_arith_result
79897a3b38f7Smrg	    func_append objlist " $obj"
79907a3b38f7Smrg	    if test "$len" -lt "$max_cmd_len"; then
79917a3b38f7Smrg	      :
79927a3b38f7Smrg	    else
79937a3b38f7Smrg	      # the above command should be used before it gets too long
79947a3b38f7Smrg	      oldobjs=$objlist
79957a3b38f7Smrg	      if test "$obj" = "$last_oldobj" ; then
79967a3b38f7Smrg		RANLIB=$save_RANLIB
79977a3b38f7Smrg	      fi
79987a3b38f7Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
79997a3b38f7Smrg	      eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
80007a3b38f7Smrg	      objlist=
80017a3b38f7Smrg	      len=$len0
80027a3b38f7Smrg	    fi
80037a3b38f7Smrg	  done
80047a3b38f7Smrg	  RANLIB=$save_RANLIB
80057a3b38f7Smrg	  oldobjs=$objlist
80067a3b38f7Smrg	  if test "X$oldobjs" = "X" ; then
80077a3b38f7Smrg	    eval cmds=\"\$concat_cmds\"
80087a3b38f7Smrg	  else
80097a3b38f7Smrg	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
80107a3b38f7Smrg	  fi
80117a3b38f7Smrg	fi
80127a3b38f7Smrg      fi
80137a3b38f7Smrg      func_execute_cmds "$cmds" 'exit $?'
8014ff559fabSmrg    done
8015ff559fabSmrg
80167a3b38f7Smrg    test -n "$generated" && \
80177a3b38f7Smrg      func_show_eval "${RM}r$generated"
8018ff559fabSmrg
80197a3b38f7Smrg    # Now create the libtool archive.
80207a3b38f7Smrg    case $output in
80217a3b38f7Smrg    *.la)
80227a3b38f7Smrg      old_library=
80237a3b38f7Smrg      test "$build_old_libs" = yes && old_library="$libname.$libext"
80247a3b38f7Smrg      func_verbose "creating $output"
8025ff559fabSmrg
80267a3b38f7Smrg      # Preserve any variables that may affect compiler behavior
80277a3b38f7Smrg      for var in $variables_saved_for_relink; do
80287a3b38f7Smrg	if eval test -z \"\${$var+set}\"; then
80297a3b38f7Smrg	  relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
80307a3b38f7Smrg	elif eval var_value=\$$var; test -z "$var_value"; then
80317a3b38f7Smrg	  relink_command="$var=; export $var; $relink_command"
8032ff559fabSmrg	else
80337a3b38f7Smrg	  func_quote_for_eval "$var_value"
80347a3b38f7Smrg	  relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
8035ff559fabSmrg	fi
80367a3b38f7Smrg      done
80377a3b38f7Smrg      # Quote the link command for shipping.
80387a3b38f7Smrg      relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
80397a3b38f7Smrg      relink_command=`$ECHO "X$relink_command" | $Xsed -e "$sed_quote_subst"`
80407a3b38f7Smrg      if test "$hardcode_automatic" = yes ; then
80417a3b38f7Smrg	relink_command=
80427a3b38f7Smrg      fi
8043ff559fabSmrg
80447a3b38f7Smrg      # Only create the output if not a dry run.
80457a3b38f7Smrg      $opt_dry_run || {
80467a3b38f7Smrg	for installed in no yes; do
80477a3b38f7Smrg	  if test "$installed" = yes; then
80487a3b38f7Smrg	    if test -z "$install_libdir"; then
80497a3b38f7Smrg	      break
80507a3b38f7Smrg	    fi
80517a3b38f7Smrg	    output="$output_objdir/$outputname"i
80527a3b38f7Smrg	    # Replace all uninstalled libtool libraries with the installed ones
80537a3b38f7Smrg	    newdependency_libs=
80547a3b38f7Smrg	    for deplib in $dependency_libs; do
80557a3b38f7Smrg	      case $deplib in
80567a3b38f7Smrg	      *.la)
80577a3b38f7Smrg		func_basename "$deplib"
80587a3b38f7Smrg		name="$func_basename_result"
80597a3b38f7Smrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
80607a3b38f7Smrg		test -z "$libdir" && \
80617a3b38f7Smrg		  func_fatal_error "\`$deplib' is not a valid libtool archive"
80627a3b38f7Smrg		newdependency_libs="$newdependency_libs $libdir/$name"
80637a3b38f7Smrg		;;
80647a3b38f7Smrg	      *) newdependency_libs="$newdependency_libs $deplib" ;;
80657a3b38f7Smrg	      esac
80667a3b38f7Smrg	    done
80677a3b38f7Smrg	    dependency_libs="$newdependency_libs"
80687a3b38f7Smrg	    newdlfiles=
80697a3b38f7Smrg
80707a3b38f7Smrg	    for lib in $dlfiles; do
80717a3b38f7Smrg	      case $lib in
80727a3b38f7Smrg	      *.la)
80737a3b38f7Smrg	        func_basename "$lib"
80747a3b38f7Smrg		name="$func_basename_result"
80757a3b38f7Smrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
80767a3b38f7Smrg		test -z "$libdir" && \
80777a3b38f7Smrg		  func_fatal_error "\`$lib' is not a valid libtool archive"
80787a3b38f7Smrg		newdlfiles="$newdlfiles $libdir/$name"
80797a3b38f7Smrg		;;
80807a3b38f7Smrg	      *) newdlfiles="$newdlfiles $lib" ;;
80817a3b38f7Smrg	      esac
80827a3b38f7Smrg	    done
80837a3b38f7Smrg	    dlfiles="$newdlfiles"
80847a3b38f7Smrg	    newdlprefiles=
80857a3b38f7Smrg	    for lib in $dlprefiles; do
80867a3b38f7Smrg	      case $lib in
80877a3b38f7Smrg	      *.la)
80887a3b38f7Smrg		# Only pass preopened files to the pseudo-archive (for
80897a3b38f7Smrg		# eventual linking with the app. that links it) if we
80907a3b38f7Smrg		# didn't already link the preopened objects directly into
80917a3b38f7Smrg		# the library:
80927a3b38f7Smrg		func_basename "$lib"
80937a3b38f7Smrg		name="$func_basename_result"
80947a3b38f7Smrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
80957a3b38f7Smrg		test -z "$libdir" && \
80967a3b38f7Smrg		  func_fatal_error "\`$lib' is not a valid libtool archive"
80977a3b38f7Smrg		newdlprefiles="$newdlprefiles $libdir/$name"
80987a3b38f7Smrg		;;
80997a3b38f7Smrg	      esac
81007a3b38f7Smrg	    done
81017a3b38f7Smrg	    dlprefiles="$newdlprefiles"
81027a3b38f7Smrg	  else
81037a3b38f7Smrg	    newdlfiles=
81047a3b38f7Smrg	    for lib in $dlfiles; do
81057a3b38f7Smrg	      case $lib in
81067a3b38f7Smrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
81077a3b38f7Smrg		*) abs=`pwd`"/$lib" ;;
81087a3b38f7Smrg	      esac
81097a3b38f7Smrg	      newdlfiles="$newdlfiles $abs"
81107a3b38f7Smrg	    done
81117a3b38f7Smrg	    dlfiles="$newdlfiles"
81127a3b38f7Smrg	    newdlprefiles=
81137a3b38f7Smrg	    for lib in $dlprefiles; do
81147a3b38f7Smrg	      case $lib in
81157a3b38f7Smrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
81167a3b38f7Smrg		*) abs=`pwd`"/$lib" ;;
81177a3b38f7Smrg	      esac
81187a3b38f7Smrg	      newdlprefiles="$newdlprefiles $abs"
81197a3b38f7Smrg	    done
81207a3b38f7Smrg	    dlprefiles="$newdlprefiles"
81217a3b38f7Smrg	  fi
81227a3b38f7Smrg	  $RM $output
81237a3b38f7Smrg	  # place dlname in correct position for cygwin
81247a3b38f7Smrg	  tdlname=$dlname
81257a3b38f7Smrg	  case $host,$output,$installed,$module,$dlname in
81267a3b38f7Smrg	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;;
81277a3b38f7Smrg	  esac
81287a3b38f7Smrg	  $ECHO > $output "\
81297a3b38f7Smrg# $outputname - a libtool library file
81307a3b38f7Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
81317a3b38f7Smrg#
81327a3b38f7Smrg# Please DO NOT delete this file!
81337a3b38f7Smrg# It is necessary for linking the library.
8134ff559fabSmrg
81357a3b38f7Smrg# The name that we can dlopen(3).
81367a3b38f7Smrgdlname='$tdlname'
8137ff559fabSmrg
81387a3b38f7Smrg# Names of this library.
81397a3b38f7Smrglibrary_names='$library_names'
8140ff559fabSmrg
81417a3b38f7Smrg# The name of the static archive.
81427a3b38f7Smrgold_library='$old_library'
8143ff559fabSmrg
81447a3b38f7Smrg# Linker flags that can not go in dependency_libs.
81457a3b38f7Smrginherited_linker_flags='$new_inherited_linker_flags'
8146ff559fabSmrg
81477a3b38f7Smrg# Libraries that this one depends upon.
81487a3b38f7Smrgdependency_libs='$dependency_libs'
8149ff559fabSmrg
81507a3b38f7Smrg# Names of additional weak libraries provided by this library
81517a3b38f7Smrgweak_library_names='$weak_libs'
8152ff559fabSmrg
81537a3b38f7Smrg# Version information for $libname.
81547a3b38f7Smrgcurrent=$current
81557a3b38f7Smrgage=$age
81567a3b38f7Smrgrevision=$revision
8157ff559fabSmrg
81587a3b38f7Smrg# Is this an already installed library?
81597a3b38f7Smrginstalled=$installed
8160ff559fabSmrg
81617a3b38f7Smrg# Should we warn about portability when linking against -modules?
81627a3b38f7Smrgshouldnotlink=$module
8163ff559fabSmrg
81647a3b38f7Smrg# Files to dlopen/dlpreopen
81657a3b38f7Smrgdlopen='$dlfiles'
81667a3b38f7Smrgdlpreopen='$dlprefiles'
8167ff559fabSmrg
81687a3b38f7Smrg# Directory that this library needs to be installed in:
81697a3b38f7Smrglibdir='$install_libdir'"
81707a3b38f7Smrg	  if test "$installed" = no && test "$need_relink" = yes; then
81717a3b38f7Smrg	    $ECHO >> $output "\
81727a3b38f7Smrgrelink_command=\"$relink_command\""
81737a3b38f7Smrg	  fi
81747a3b38f7Smrg	done
81757a3b38f7Smrg      }
8176ff559fabSmrg
81777a3b38f7Smrg      # Do a symbolic link so that the libtool archive can be found in
81787a3b38f7Smrg      # LD_LIBRARY_PATH before the program is installed.
81797a3b38f7Smrg      func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
81807a3b38f7Smrg      ;;
81817a3b38f7Smrg    esac
81827a3b38f7Smrg    exit $EXIT_SUCCESS
81837a3b38f7Smrg}
8184ff559fabSmrg
81857a3b38f7Smrg{ test "$mode" = link || test "$mode" = relink; } &&
81867a3b38f7Smrg    func_mode_link ${1+"$@"}
8187ff559fabSmrg
8188ff559fabSmrg
81897a3b38f7Smrg# func_mode_uninstall arg...
81907a3b38f7Smrgfunc_mode_uninstall ()
81917a3b38f7Smrg{
81927a3b38f7Smrg    $opt_debug
81937a3b38f7Smrg    RM="$nonopt"
8194ff559fabSmrg    files=
8195ff559fabSmrg    rmforce=
8196ff559fabSmrg    exit_status=0
8197ff559fabSmrg
8198ff559fabSmrg    # This variable tells wrapper scripts just to set variables rather
8199ff559fabSmrg    # than running their programs.
8200ff559fabSmrg    libtool_install_magic="$magic"
8201ff559fabSmrg
8202ff559fabSmrg    for arg
8203ff559fabSmrg    do
8204ff559fabSmrg      case $arg in
82057a3b38f7Smrg      -f) RM="$RM $arg"; rmforce=yes ;;
82067a3b38f7Smrg      -*) RM="$RM $arg" ;;
8207ff559fabSmrg      *) files="$files $arg" ;;
8208ff559fabSmrg      esac
8209ff559fabSmrg    done
8210ff559fabSmrg
82117a3b38f7Smrg    test -z "$RM" && \
82127a3b38f7Smrg      func_fatal_help "you must specify an RM program"
8213ff559fabSmrg
8214ff559fabSmrg    rmdirs=
8215ff559fabSmrg
8216ff559fabSmrg    origobjdir="$objdir"
8217ff559fabSmrg    for file in $files; do
82187a3b38f7Smrg      func_dirname "$file" "" "."
82197a3b38f7Smrg      dir="$func_dirname_result"
82207a3b38f7Smrg      if test "X$dir" = X.; then
8221ff559fabSmrg	objdir="$origobjdir"
8222ff559fabSmrg      else
8223ff559fabSmrg	objdir="$dir/$origobjdir"
8224ff559fabSmrg      fi
82257a3b38f7Smrg      func_basename "$file"
82267a3b38f7Smrg      name="$func_basename_result"
8227ff559fabSmrg      test "$mode" = uninstall && objdir="$dir"
8228ff559fabSmrg
8229ff559fabSmrg      # Remember objdir for removal later, being careful to avoid duplicates
8230ff559fabSmrg      if test "$mode" = clean; then
8231ff559fabSmrg	case " $rmdirs " in
8232ff559fabSmrg	  *" $objdir "*) ;;
8233ff559fabSmrg	  *) rmdirs="$rmdirs $objdir" ;;
8234ff559fabSmrg	esac
8235ff559fabSmrg      fi
8236ff559fabSmrg
8237ff559fabSmrg      # Don't error if the file doesn't exist and rm -f was used.
82387a3b38f7Smrg      if { test -L "$file"; } >/dev/null 2>&1 ||
82397a3b38f7Smrg	 { test -h "$file"; } >/dev/null 2>&1 ||
82407a3b38f7Smrg	 test -f "$file"; then
8241ff559fabSmrg	:
8242ff559fabSmrg      elif test -d "$file"; then
8243ff559fabSmrg	exit_status=1
8244ff559fabSmrg	continue
8245ff559fabSmrg      elif test "$rmforce" = yes; then
8246ff559fabSmrg	continue
8247ff559fabSmrg      fi
8248ff559fabSmrg
8249ff559fabSmrg      rmfiles="$file"
8250ff559fabSmrg
8251ff559fabSmrg      case $name in
8252ff559fabSmrg      *.la)
8253ff559fabSmrg	# Possibly a libtool archive, so verify it.
82547a3b38f7Smrg	if func_lalib_p "$file"; then
82557a3b38f7Smrg	  func_source $dir/$name
8256ff559fabSmrg
8257ff559fabSmrg	  # Delete the libtool libraries and symlinks.
8258ff559fabSmrg	  for n in $library_names; do
8259ff559fabSmrg	    rmfiles="$rmfiles $objdir/$n"
8260ff559fabSmrg	  done
8261ff559fabSmrg	  test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library"
8262ff559fabSmrg
8263ff559fabSmrg	  case "$mode" in
8264ff559fabSmrg	  clean)
8265ff559fabSmrg	    case "  $library_names " in
8266ff559fabSmrg	    # "  " in the beginning catches empty $dlname
8267ff559fabSmrg	    *" $dlname "*) ;;
8268ff559fabSmrg	    *) rmfiles="$rmfiles $objdir/$dlname" ;;
8269ff559fabSmrg	    esac
82707a3b38f7Smrg	    test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i"
8271ff559fabSmrg	    ;;
8272ff559fabSmrg	  uninstall)
8273ff559fabSmrg	    if test -n "$library_names"; then
8274ff559fabSmrg	      # Do each command in the postuninstall commands.
82757a3b38f7Smrg	      func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
8276ff559fabSmrg	    fi
8277ff559fabSmrg
8278ff559fabSmrg	    if test -n "$old_library"; then
8279ff559fabSmrg	      # Do each command in the old_postuninstall commands.
82807a3b38f7Smrg	      func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
8281ff559fabSmrg	    fi
8282ff559fabSmrg	    # FIXME: should reinstall the best remaining shared library.
8283ff559fabSmrg	    ;;
8284ff559fabSmrg	  esac
8285ff559fabSmrg	fi
8286ff559fabSmrg	;;
8287ff559fabSmrg
8288ff559fabSmrg      *.lo)
8289ff559fabSmrg	# Possibly a libtool object, so verify it.
82907a3b38f7Smrg	if func_lalib_p "$file"; then
8291ff559fabSmrg
8292ff559fabSmrg	  # Read the .lo file
82937a3b38f7Smrg	  func_source $dir/$name
8294ff559fabSmrg
8295ff559fabSmrg	  # Add PIC object to the list of files to remove.
82967a3b38f7Smrg	  if test -n "$pic_object" &&
82977a3b38f7Smrg	     test "$pic_object" != none; then
8298ff559fabSmrg	    rmfiles="$rmfiles $dir/$pic_object"
8299ff559fabSmrg	  fi
8300ff559fabSmrg
8301ff559fabSmrg	  # Add non-PIC object to the list of files to remove.
83027a3b38f7Smrg	  if test -n "$non_pic_object" &&
83037a3b38f7Smrg	     test "$non_pic_object" != none; then
8304ff559fabSmrg	    rmfiles="$rmfiles $dir/$non_pic_object"
8305ff559fabSmrg	  fi
8306ff559fabSmrg	fi
8307ff559fabSmrg	;;
8308ff559fabSmrg
8309ff559fabSmrg      *)
8310ff559fabSmrg	if test "$mode" = clean ; then
8311ff559fabSmrg	  noexename=$name
8312ff559fabSmrg	  case $file in
8313ff559fabSmrg	  *.exe)
83147a3b38f7Smrg	    func_stripname '' '.exe' "$file"
83157a3b38f7Smrg	    file=$func_stripname_result
83167a3b38f7Smrg	    func_stripname '' '.exe' "$name"
83177a3b38f7Smrg	    noexename=$func_stripname_result
8318ff559fabSmrg	    # $file with .exe has already been added to rmfiles,
8319ff559fabSmrg	    # add $file without .exe
8320ff559fabSmrg	    rmfiles="$rmfiles $file"
8321ff559fabSmrg	    ;;
8322ff559fabSmrg	  esac
8323ff559fabSmrg	  # Do a test to see if this is a libtool program.
83247a3b38f7Smrg	  if func_ltwrapper_p "$file"; then
83257a3b38f7Smrg	    if func_ltwrapper_executable_p "$file"; then
83267a3b38f7Smrg	      func_ltwrapper_scriptname "$file"
83277a3b38f7Smrg	      relink_command=
83287a3b38f7Smrg	      func_source $func_ltwrapper_scriptname_result
83297a3b38f7Smrg	      rmfiles="$rmfiles $func_ltwrapper_scriptname_result"
83307a3b38f7Smrg	    else
83317a3b38f7Smrg	      relink_command=
83327a3b38f7Smrg	      func_source $dir/$noexename
83337a3b38f7Smrg	    fi
8334ff559fabSmrg
8335ff559fabSmrg	    # note $name still contains .exe if it was in $file originally
8336ff559fabSmrg	    # as does the version of $file that was added into $rmfiles
8337ff559fabSmrg	    rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}"
8338ff559fabSmrg	    if test "$fast_install" = yes && test -n "$relink_command"; then
8339ff559fabSmrg	      rmfiles="$rmfiles $objdir/lt-$name"
8340ff559fabSmrg	    fi
8341ff559fabSmrg	    if test "X$noexename" != "X$name" ; then
8342ff559fabSmrg	      rmfiles="$rmfiles $objdir/lt-${noexename}.c"
8343ff559fabSmrg	    fi
8344ff559fabSmrg	  fi
8345ff559fabSmrg	fi
8346ff559fabSmrg	;;
8347ff559fabSmrg      esac
83487a3b38f7Smrg      func_show_eval "$RM $rmfiles" 'exit_status=1'
8349ff559fabSmrg    done
8350ff559fabSmrg    objdir="$origobjdir"
8351ff559fabSmrg
8352ff559fabSmrg    # Try to remove the ${objdir}s in the directories where we deleted files
8353ff559fabSmrg    for dir in $rmdirs; do
8354ff559fabSmrg      if test -d "$dir"; then
83557a3b38f7Smrg	func_show_eval "rmdir $dir >/dev/null 2>&1"
8356ff559fabSmrg      fi
8357ff559fabSmrg    done
8358ff559fabSmrg
8359ff559fabSmrg    exit $exit_status
83607a3b38f7Smrg}
8361ff559fabSmrg
83627a3b38f7Smrg{ test "$mode" = uninstall || test "$mode" = clean; } &&
83637a3b38f7Smrg    func_mode_uninstall ${1+"$@"}
8364ff559fabSmrg
83657a3b38f7Smrgtest -z "$mode" && {
83667a3b38f7Smrg  help="$generic_help"
83677a3b38f7Smrg  func_fatal_help "you must specify a MODE"
83687a3b38f7Smrg}
83697a3b38f7Smrg
83707a3b38f7Smrgtest -z "$exec_cmd" && \
83717a3b38f7Smrg  func_fatal_help "invalid operation mode \`$mode'"
8372ff559fabSmrg
8373ff559fabSmrgif test -n "$exec_cmd"; then
83747a3b38f7Smrg  eval exec "$exec_cmd"
8375ff559fabSmrg  exit $EXIT_FAILURE
8376ff559fabSmrgfi
8377ff559fabSmrg
83787a3b38f7Smrgexit $exit_status
8379ff559fabSmrg
8380ff559fabSmrg
8381ff559fabSmrg# The TAGs below are defined such that we never get into a situation
8382ff559fabSmrg# in which we disable both kinds of libraries.  Given conflicting
8383ff559fabSmrg# choices, we go for a static library, that is the most portable,
8384ff559fabSmrg# since we can't tell whether shared libraries were disabled because
8385ff559fabSmrg# the user asked for that or because the platform doesn't support
8386ff559fabSmrg# them.  This is particularly important on AIX, because we don't
8387ff559fabSmrg# support having both static and shared libraries enabled at the same
8388ff559fabSmrg# time on that platform, so we default to a shared-only configuration.
8389ff559fabSmrg# If a disable-shared tag is given, we'll fallback to a static-only
8390ff559fabSmrg# configuration.  But we'll never go from static-only to shared-only.
8391ff559fabSmrg
8392ff559fabSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
83937a3b38f7Smrgbuild_libtool_libs=no
83947a3b38f7Smrgbuild_old_libs=yes
8395ff559fabSmrg# ### END LIBTOOL TAG CONFIG: disable-shared
8396ff559fabSmrg
8397ff559fabSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static
83987a3b38f7Smrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
8399ff559fabSmrg# ### END LIBTOOL TAG CONFIG: disable-static
8400ff559fabSmrg
8401ff559fabSmrg# Local Variables:
8402ff559fabSmrg# mode:shell-script
8403ff559fabSmrg# sh-indentation:2
8404ff559fabSmrg# End:
84057a3b38f7Smrg# vi:sw=2
84067a3b38f7Smrg
8407