ltmain.sh revision 5a3d36df
15a3d36dfSmrg# Generated from ltmain.m4sh.
25a3d36dfSmrg
35a3d36dfSmrg# ltmain.sh (GNU libtool) 2.2.6
45a3d36dfSmrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
55a3d36dfSmrg
65a3d36dfSmrg# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007 2008 Free Software Foundation, Inc.
75a3d36dfSmrg# This is free software; see the source for copying conditions.  There is NO
85a3d36dfSmrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
95a3d36dfSmrg
105a3d36dfSmrg# GNU Libtool is free software; you can redistribute it and/or modify
1123a0898aSmrg# it under the terms of the GNU General Public License as published by
1223a0898aSmrg# the Free Software Foundation; either version 2 of the License, or
1323a0898aSmrg# (at your option) any later version.
1423a0898aSmrg#
155a3d36dfSmrg# As a special exception to the GNU General Public License,
165a3d36dfSmrg# if you distribute this file as part of a program or library that
175a3d36dfSmrg# is built using GNU Libtool, you may include this file under the
185a3d36dfSmrg# same distribution terms that you use for the rest of that program.
195a3d36dfSmrg#
205a3d36dfSmrg# GNU Libtool is distributed in the hope that it will be useful, but
2123a0898aSmrg# WITHOUT ANY WARRANTY; without even the implied warranty of
2223a0898aSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
2323a0898aSmrg# General Public License for more details.
2423a0898aSmrg#
2523a0898aSmrg# You should have received a copy of the GNU General Public License
265a3d36dfSmrg# along with GNU Libtool; see the file COPYING.  If not, a copy
275a3d36dfSmrg# can be downloaded from http://www.gnu.org/licenses/gpl.html,
285a3d36dfSmrg# or obtained by writing to the Free Software Foundation, Inc.,
295a3d36dfSmrg# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
30b3062210Smrg
315a3d36dfSmrg# Usage: $progname [OPTION]... [MODE-ARG]...
325a3d36dfSmrg#
335a3d36dfSmrg# Provide generalized library-building support services.
345a3d36dfSmrg#
355a3d36dfSmrg#     --config             show all configuration variables
365a3d36dfSmrg#     --debug              enable verbose shell tracing
375a3d36dfSmrg# -n, --dry-run            display commands without modifying any files
385a3d36dfSmrg#     --features           display basic configuration information and exit
395a3d36dfSmrg#     --mode=MODE          use operation mode MODE
405a3d36dfSmrg#     --preserve-dup-deps  don't remove duplicate dependency libraries
415a3d36dfSmrg#     --quiet, --silent    don't print informational messages
425a3d36dfSmrg#     --tag=TAG            use configuration variables from tag TAG
435a3d36dfSmrg# -v, --verbose            print informational messages (default)
445a3d36dfSmrg#     --version            print version information
455a3d36dfSmrg# -h, --help               print short or long help message
465a3d36dfSmrg#
475a3d36dfSmrg# MODE must be one of the following:
485a3d36dfSmrg#
495a3d36dfSmrg#       clean              remove files from the build directory
505a3d36dfSmrg#       compile            compile a source file into a libtool object
515a3d36dfSmrg#       execute            automatically set library path, then run a program
525a3d36dfSmrg#       finish             complete the installation of libtool libraries
535a3d36dfSmrg#       install            install libraries or executables
545a3d36dfSmrg#       link               create a library or an executable
555a3d36dfSmrg#       uninstall          remove libraries from an installed directory
565a3d36dfSmrg#
575a3d36dfSmrg# MODE-ARGS vary depending on the MODE.
585a3d36dfSmrg# Try `$progname --help --mode=MODE' for a more detailed description of MODE.
595a3d36dfSmrg#
605a3d36dfSmrg# When reporting a bug, please describe a test case to reproduce it and
615a3d36dfSmrg# include the following information:
625a3d36dfSmrg#
635a3d36dfSmrg#       host-triplet:	$host
645a3d36dfSmrg#       shell:		$SHELL
655a3d36dfSmrg#       compiler:		$LTCC
665a3d36dfSmrg#       compiler flags:		$LTCFLAGS
675a3d36dfSmrg#       linker:		$LD (gnu? $with_gnu_ld)
685a3d36dfSmrg#       $progname:		(GNU libtool) 2.2.6 Debian-2.2.6a-1ubuntu1
695a3d36dfSmrg#       automake:		$automake_version
705a3d36dfSmrg#       autoconf:		$autoconf_version
715a3d36dfSmrg#
725a3d36dfSmrg# Report bugs to <bug-libtool@gnu.org>.
7323a0898aSmrg
7423a0898aSmrgPROGRAM=ltmain.sh
7523a0898aSmrgPACKAGE=libtool
765a3d36dfSmrgVERSION="2.2.6 Debian-2.2.6a-1ubuntu1"
775a3d36dfSmrgTIMESTAMP=""
785a3d36dfSmrgpackage_revision=1.3012
7923a0898aSmrg
805a3d36dfSmrg# Be Bourne compatible
8123a0898aSmrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
8223a0898aSmrg  emulate sh
8323a0898aSmrg  NULLCMD=:
8423a0898aSmrg  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
8523a0898aSmrg  # is contrary to our usage.  Disable this feature.
8623a0898aSmrg  alias -g '${1+"$@"}'='"$@"'
8723a0898aSmrg  setopt NO_GLOB_SUBST
8823a0898aSmrgelse
8923a0898aSmrg  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
9023a0898aSmrgfi
9123a0898aSmrgBIN_SH=xpg4; export BIN_SH # for Tru64
9223a0898aSmrgDUALCASE=1; export DUALCASE # for MKS sh
9323a0898aSmrg
945a3d36dfSmrg# NLS nuisances: We save the old values to restore during execute mode.
9523a0898aSmrg# Only set LANG and LC_ALL to C if already set.
9623a0898aSmrg# These must not be set unconditionally because not all systems understand
9723a0898aSmrg# e.g. LANG=C (notably SCO).
985a3d36dfSmrglt_user_locale=
995a3d36dfSmrglt_safe_locale=
1007f7f5e4eSmrgfor lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
10123a0898aSmrgdo
10223a0898aSmrg  eval "if test \"\${$lt_var+set}\" = set; then
1035a3d36dfSmrg          save_$lt_var=\$$lt_var
1045a3d36dfSmrg          $lt_var=C
10523a0898aSmrg	  export $lt_var
1065a3d36dfSmrg	  lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\"
1075a3d36dfSmrg	  lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
10823a0898aSmrg	fi"
10923a0898aSmrgdone
11023a0898aSmrg
1115a3d36dfSmrg$lt_unset CDPATH
1125a3d36dfSmrg
1135a3d36dfSmrg
1145a3d36dfSmrg
1155a3d36dfSmrg
1165a3d36dfSmrg
1175a3d36dfSmrg: ${CP="cp -f"}
1185a3d36dfSmrg: ${ECHO="echo"}
1195a3d36dfSmrg: ${EGREP="/bin/grep -E"}
1205a3d36dfSmrg: ${FGREP="/bin/grep -F"}
1215a3d36dfSmrg: ${GREP="/bin/grep"}
1225a3d36dfSmrg: ${LN_S="ln -s"}
1235a3d36dfSmrg: ${MAKE="make"}
1245a3d36dfSmrg: ${MKDIR="mkdir"}
1255a3d36dfSmrg: ${MV="mv -f"}
1265a3d36dfSmrg: ${RM="rm -f"}
1275a3d36dfSmrg: ${SED="/bin/sed"}
1285a3d36dfSmrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
1295a3d36dfSmrg: ${Xsed="$SED -e 1s/^X//"}
1305a3d36dfSmrg
1315a3d36dfSmrg# Global variables:
1325a3d36dfSmrgEXIT_SUCCESS=0
1335a3d36dfSmrgEXIT_FAILURE=1
1345a3d36dfSmrgEXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
1355a3d36dfSmrgEXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
1365a3d36dfSmrg
1375a3d36dfSmrgexit_status=$EXIT_SUCCESS
1387f7f5e4eSmrg
13923a0898aSmrg# Make sure IFS has a sensible default
14023a0898aSmrglt_nl='
14123a0898aSmrg'
14223a0898aSmrgIFS=" 	$lt_nl"
14323a0898aSmrg
1445a3d36dfSmrgdirname="s,/[^/]*$,,"
1455a3d36dfSmrgbasename="s,^.*/,,"
1465a3d36dfSmrg
1475a3d36dfSmrg# func_dirname_and_basename file append nondir_replacement
1485a3d36dfSmrg# perform func_basename and func_dirname in a single function
1495a3d36dfSmrg# call:
1505a3d36dfSmrg#   dirname:  Compute the dirname of FILE.  If nonempty,
1515a3d36dfSmrg#             add APPEND to the result, otherwise set result
1525a3d36dfSmrg#             to NONDIR_REPLACEMENT.
1535a3d36dfSmrg#             value returned in "$func_dirname_result"
1545a3d36dfSmrg#   basename: Compute filename of FILE.
1555a3d36dfSmrg#             value retuned in "$func_basename_result"
1565a3d36dfSmrg# Implementation must be kept synchronized with func_dirname
1575a3d36dfSmrg# and func_basename. For efficiency, we do not delegate to
1585a3d36dfSmrg# those functions but instead duplicate the functionality here.
1595a3d36dfSmrgfunc_dirname_and_basename ()
1605a3d36dfSmrg{
1615a3d36dfSmrg  # Extract subdirectory from the argument.
1625a3d36dfSmrg  func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"`
1635a3d36dfSmrg  if test "X$func_dirname_result" = "X${1}"; then
1645a3d36dfSmrg    func_dirname_result="${3}"
1655a3d36dfSmrg  else
1665a3d36dfSmrg    func_dirname_result="$func_dirname_result${2}"
1675a3d36dfSmrg  fi
1685a3d36dfSmrg  func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"`
1695a3d36dfSmrg}
1707f7f5e4eSmrg
1715a3d36dfSmrg# Generated shell functions inserted here.
1725a3d36dfSmrg
1735a3d36dfSmrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
1745a3d36dfSmrg# is ksh but when the shell is invoked as "sh" and the current value of
1755a3d36dfSmrg# the _XPG environment variable is not equal to 1 (one), the special
1765a3d36dfSmrg# positional parameter $0, within a function call, is the name of the
1775a3d36dfSmrg# function.
1785a3d36dfSmrgprogpath="$0"
1795a3d36dfSmrg
1805a3d36dfSmrg# The name of this program:
1815a3d36dfSmrg# In the unlikely event $progname began with a '-', it would play havoc with
1825a3d36dfSmrg# func_echo (imagine progname=-n), so we prepend ./ in that case:
1835a3d36dfSmrgfunc_dirname_and_basename "$progpath"
1845a3d36dfSmrgprogname=$func_basename_result
1855a3d36dfSmrgcase $progname in
1865a3d36dfSmrg  -*) progname=./$progname ;;
1875a3d36dfSmrgesac
1885a3d36dfSmrg
1895a3d36dfSmrg# Make sure we have an absolute path for reexecution:
1905a3d36dfSmrgcase $progpath in
1915a3d36dfSmrg  [\\/]*|[A-Za-z]:\\*) ;;
1925a3d36dfSmrg  *[\\/]*)
1935a3d36dfSmrg     progdir=$func_dirname_result
1945a3d36dfSmrg     progdir=`cd "$progdir" && pwd`
1955a3d36dfSmrg     progpath="$progdir/$progname"
1965a3d36dfSmrg     ;;
1975a3d36dfSmrg  *)
1985a3d36dfSmrg     save_IFS="$IFS"
1995a3d36dfSmrg     IFS=:
2005a3d36dfSmrg     for progdir in $PATH; do
2015a3d36dfSmrg       IFS="$save_IFS"
2025a3d36dfSmrg       test -x "$progdir/$progname" && break
2035a3d36dfSmrg     done
2045a3d36dfSmrg     IFS="$save_IFS"
2055a3d36dfSmrg     test -n "$progdir" || progdir=`pwd`
2065a3d36dfSmrg     progpath="$progdir/$progname"
2075a3d36dfSmrg     ;;
2085a3d36dfSmrgesac
2095a3d36dfSmrg
2105a3d36dfSmrg# Sed substitution that helps us do robust quoting.  It backslashifies
2115a3d36dfSmrg# metacharacters that are still active within double-quoted strings.
2125a3d36dfSmrgXsed="${SED}"' -e 1s/^X//'
2135a3d36dfSmrgsed_quote_subst='s/\([`"$\\]\)/\\\1/g'
2145a3d36dfSmrg
2155a3d36dfSmrg# Same as above, but do not quote variable references.
2165a3d36dfSmrgdouble_quote_subst='s/\(["`\\]\)/\\\1/g'
2175a3d36dfSmrg
2185a3d36dfSmrg# Re-`\' parameter expansions in output of double_quote_subst that were
2195a3d36dfSmrg# `\'-ed in input to the same.  If an odd number of `\' preceded a '$'
2205a3d36dfSmrg# in input to double_quote_subst, that '$' was protected from expansion.
2215a3d36dfSmrg# Since each input `\' is now two `\'s, look for any number of runs of
2225a3d36dfSmrg# four `\'s followed by two `\'s and then a '$'.  `\' that '$'.
2235a3d36dfSmrgbs='\\'
2245a3d36dfSmrgbs2='\\\\'
2255a3d36dfSmrgbs4='\\\\\\\\'
2265a3d36dfSmrgdollar='\$'
2275a3d36dfSmrgsed_double_backslash="\
2285a3d36dfSmrg  s/$bs4/&\\
2295a3d36dfSmrg/g
2305a3d36dfSmrg  s/^$bs2$dollar/$bs&/
2315a3d36dfSmrg  s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
2325a3d36dfSmrg  s/\n//g"
2335a3d36dfSmrg
2345a3d36dfSmrg# Standard options:
2355a3d36dfSmrgopt_dry_run=false
2365a3d36dfSmrgopt_help=false
2375a3d36dfSmrgopt_quiet=false
2385a3d36dfSmrgopt_verbose=false
2395a3d36dfSmrgopt_warning=:
2405a3d36dfSmrg
2415a3d36dfSmrg# func_echo arg...
2425a3d36dfSmrg# Echo program name prefixed message, along with the current mode
2435a3d36dfSmrg# name if it has been set yet.
2445a3d36dfSmrgfunc_echo ()
2455a3d36dfSmrg{
2465a3d36dfSmrg    $ECHO "$progname${mode+: }$mode: $*"
2475a3d36dfSmrg}
2485a3d36dfSmrg
2495a3d36dfSmrg# func_verbose arg...
2505a3d36dfSmrg# Echo program name prefixed message in verbose mode only.
2515a3d36dfSmrgfunc_verbose ()
2525a3d36dfSmrg{
2535a3d36dfSmrg    $opt_verbose && func_echo ${1+"$@"}
2545a3d36dfSmrg
2555a3d36dfSmrg    # A bug in bash halts the script if the last line of a function
2565a3d36dfSmrg    # fails when set -e is in force, so we need another command to
2575a3d36dfSmrg    # work around that:
2585a3d36dfSmrg    :
2595a3d36dfSmrg}
2605a3d36dfSmrg
2615a3d36dfSmrg# func_error arg...
2625a3d36dfSmrg# Echo program name prefixed message to standard error.
2635a3d36dfSmrgfunc_error ()
2645a3d36dfSmrg{
2655a3d36dfSmrg    $ECHO "$progname${mode+: }$mode: "${1+"$@"} 1>&2
2665a3d36dfSmrg}
2675a3d36dfSmrg
2685a3d36dfSmrg# func_warning arg...
2695a3d36dfSmrg# Echo program name prefixed warning message to standard error.
2705a3d36dfSmrgfunc_warning ()
2715a3d36dfSmrg{
2725a3d36dfSmrg    $opt_warning && $ECHO "$progname${mode+: }$mode: warning: "${1+"$@"} 1>&2
2735a3d36dfSmrg
2745a3d36dfSmrg    # bash bug again:
2755a3d36dfSmrg    :
2765a3d36dfSmrg}
2775a3d36dfSmrg
2785a3d36dfSmrg# func_fatal_error arg...
2795a3d36dfSmrg# Echo program name prefixed message to standard error, and exit.
2805a3d36dfSmrgfunc_fatal_error ()
2815a3d36dfSmrg{
2825a3d36dfSmrg    func_error ${1+"$@"}
2835a3d36dfSmrg    exit $EXIT_FAILURE
2845a3d36dfSmrg}
2855a3d36dfSmrg
2865a3d36dfSmrg# func_fatal_help arg...
2875a3d36dfSmrg# Echo program name prefixed message to standard error, followed by
2885a3d36dfSmrg# a help hint, and exit.
2895a3d36dfSmrgfunc_fatal_help ()
2905a3d36dfSmrg{
2915a3d36dfSmrg    func_error ${1+"$@"}
2925a3d36dfSmrg    func_fatal_error "$help"
2935a3d36dfSmrg}
2945a3d36dfSmrghelp="Try \`$progname --help' for more information."  ## default
2955a3d36dfSmrg
2965a3d36dfSmrg
2975a3d36dfSmrg# func_grep expression filename
2985a3d36dfSmrg# Check whether EXPRESSION matches any line of FILENAME, without output.
2995a3d36dfSmrgfunc_grep ()
3005a3d36dfSmrg{
3015a3d36dfSmrg    $GREP "$1" "$2" >/dev/null 2>&1
3025a3d36dfSmrg}
3035a3d36dfSmrg
3045a3d36dfSmrg
3055a3d36dfSmrg# func_mkdir_p directory-path
3065a3d36dfSmrg# Make sure the entire path to DIRECTORY-PATH is available.
3075a3d36dfSmrgfunc_mkdir_p ()
3085a3d36dfSmrg{
3095a3d36dfSmrg    my_directory_path="$1"
3105a3d36dfSmrg    my_dir_list=
3115a3d36dfSmrg
3125a3d36dfSmrg    if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
3135a3d36dfSmrg
3145a3d36dfSmrg      # Protect directory names starting with `-'
3155a3d36dfSmrg      case $my_directory_path in
3165a3d36dfSmrg        -*) my_directory_path="./$my_directory_path" ;;
3175a3d36dfSmrg      esac
3185a3d36dfSmrg
3195a3d36dfSmrg      # While some portion of DIR does not yet exist...
3205a3d36dfSmrg      while test ! -d "$my_directory_path"; do
3215a3d36dfSmrg        # ...make a list in topmost first order.  Use a colon delimited
3225a3d36dfSmrg	# list incase some portion of path contains whitespace.
3235a3d36dfSmrg        my_dir_list="$my_directory_path:$my_dir_list"
3245a3d36dfSmrg
3255a3d36dfSmrg        # If the last portion added has no slash in it, the list is done
3265a3d36dfSmrg        case $my_directory_path in */*) ;; *) break ;; esac
3275a3d36dfSmrg
3285a3d36dfSmrg        # ...otherwise throw away the child directory and loop
3295a3d36dfSmrg        my_directory_path=`$ECHO "X$my_directory_path" | $Xsed -e "$dirname"`
3305a3d36dfSmrg      done
3315a3d36dfSmrg      my_dir_list=`$ECHO "X$my_dir_list" | $Xsed -e 's,:*$,,'`
3325a3d36dfSmrg
3335a3d36dfSmrg      save_mkdir_p_IFS="$IFS"; IFS=':'
3345a3d36dfSmrg      for my_dir in $my_dir_list; do
3355a3d36dfSmrg	IFS="$save_mkdir_p_IFS"
3365a3d36dfSmrg        # mkdir can fail with a `File exist' error if two processes
3375a3d36dfSmrg        # try to create one of the directories concurrently.  Don't
3385a3d36dfSmrg        # stop in that case!
3395a3d36dfSmrg        $MKDIR "$my_dir" 2>/dev/null || :
3405a3d36dfSmrg      done
3415a3d36dfSmrg      IFS="$save_mkdir_p_IFS"
3425a3d36dfSmrg
3435a3d36dfSmrg      # Bail out if we (or some other process) failed to create a directory.
3445a3d36dfSmrg      test -d "$my_directory_path" || \
3455a3d36dfSmrg        func_fatal_error "Failed to create \`$1'"
3465a3d36dfSmrg    fi
3475a3d36dfSmrg}
34823a0898aSmrg
34923a0898aSmrg
35023a0898aSmrg# func_mktempdir [string]
35123a0898aSmrg# Make a temporary directory that won't clash with other running
35223a0898aSmrg# libtool processes, and avoids race conditions if possible.  If
35323a0898aSmrg# given, STRING is the basename for that directory.
35423a0898aSmrgfunc_mktempdir ()
35523a0898aSmrg{
35623a0898aSmrg    my_template="${TMPDIR-/tmp}/${1-$progname}"
35723a0898aSmrg
3585a3d36dfSmrg    if test "$opt_dry_run" = ":"; then
35923a0898aSmrg      # Return a directory name, but don't create it in dry-run mode
36023a0898aSmrg      my_tmpdir="${my_template}-$$"
36123a0898aSmrg    else
36223a0898aSmrg
36323a0898aSmrg      # If mktemp works, use that first and foremost
36423a0898aSmrg      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
36523a0898aSmrg
36623a0898aSmrg      if test ! -d "$my_tmpdir"; then
3675a3d36dfSmrg        # Failing that, at least try and use $RANDOM to avoid a race
3685a3d36dfSmrg        my_tmpdir="${my_template}-${RANDOM-0}$$"
36923a0898aSmrg
3705a3d36dfSmrg        save_mktempdir_umask=`umask`
3715a3d36dfSmrg        umask 0077
3725a3d36dfSmrg        $MKDIR "$my_tmpdir"
3735a3d36dfSmrg        umask $save_mktempdir_umask
37423a0898aSmrg      fi
37523a0898aSmrg
37623a0898aSmrg      # If we're not in dry-run mode, bomb out on failure
3775a3d36dfSmrg      test -d "$my_tmpdir" || \
3785a3d36dfSmrg        func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
37923a0898aSmrg    fi
38023a0898aSmrg
3815a3d36dfSmrg    $ECHO "X$my_tmpdir" | $Xsed
38223a0898aSmrg}
38323a0898aSmrg
38423a0898aSmrg
3855a3d36dfSmrg# func_quote_for_eval arg
3865a3d36dfSmrg# Aesthetically quote ARG to be evaled later.
3875a3d36dfSmrg# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
3885a3d36dfSmrg# is double-quoted, suitable for a subsequent eval, whereas
3895a3d36dfSmrg# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
3905a3d36dfSmrg# which are still active within double quotes backslashified.
3915a3d36dfSmrgfunc_quote_for_eval ()
39223a0898aSmrg{
3935a3d36dfSmrg    case $1 in
3945a3d36dfSmrg      *[\\\`\"\$]*)
3955a3d36dfSmrg	func_quote_for_eval_unquoted_result=`$ECHO "X$1" | $Xsed -e "$sed_quote_subst"` ;;
3965a3d36dfSmrg      *)
3975a3d36dfSmrg        func_quote_for_eval_unquoted_result="$1" ;;
3985a3d36dfSmrg    esac
3995a3d36dfSmrg
4005a3d36dfSmrg    case $func_quote_for_eval_unquoted_result in
4015a3d36dfSmrg      # Double-quote args containing shell metacharacters to delay
4025a3d36dfSmrg      # word splitting, command substitution and and variable
4035a3d36dfSmrg      # expansion for a subsequent eval.
4045a3d36dfSmrg      # Many Bourne shells cannot handle close brackets correctly
4055a3d36dfSmrg      # in scan sets, so we specify it separately.
4065a3d36dfSmrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
4075a3d36dfSmrg        func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
4085a3d36dfSmrg        ;;
4095a3d36dfSmrg      *)
4105a3d36dfSmrg        func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
41123a0898aSmrg    esac
41223a0898aSmrg}
41323a0898aSmrg
41423a0898aSmrg
4155a3d36dfSmrg# func_quote_for_expand arg
4165a3d36dfSmrg# Aesthetically quote ARG to be evaled later; same as above,
4175a3d36dfSmrg# but do not quote variable references.
4185a3d36dfSmrgfunc_quote_for_expand ()
41923a0898aSmrg{
4205a3d36dfSmrg    case $1 in
4215a3d36dfSmrg      *[\\\`\"]*)
4225a3d36dfSmrg	my_arg=`$ECHO "X$1" | $Xsed \
4235a3d36dfSmrg	    -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
42423a0898aSmrg      *)
4255a3d36dfSmrg        my_arg="$1" ;;
4265a3d36dfSmrg    esac
4275a3d36dfSmrg
4285a3d36dfSmrg    case $my_arg in
4295a3d36dfSmrg      # Double-quote args containing shell metacharacters to delay
4305a3d36dfSmrg      # word splitting and command substitution for a subsequent eval.
4315a3d36dfSmrg      # Many Bourne shells cannot handle close brackets correctly
4325a3d36dfSmrg      # in scan sets, so we specify it separately.
4335a3d36dfSmrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
4345a3d36dfSmrg        my_arg="\"$my_arg\""
4355a3d36dfSmrg        ;;
4365a3d36dfSmrg    esac
4375a3d36dfSmrg
4385a3d36dfSmrg    func_quote_for_expand_result="$my_arg"
43923a0898aSmrg}
44023a0898aSmrg
44123a0898aSmrg
4425a3d36dfSmrg# func_show_eval cmd [fail_exp]
4435a3d36dfSmrg# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
4445a3d36dfSmrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
4455a3d36dfSmrg# is given, then evaluate it.
4465a3d36dfSmrgfunc_show_eval ()
44723a0898aSmrg{
4485a3d36dfSmrg    my_cmd="$1"
4495a3d36dfSmrg    my_fail_exp="${2-:}"
4507f7f5e4eSmrg
4515a3d36dfSmrg    ${opt_silent-false} || {
4525a3d36dfSmrg      func_quote_for_expand "$my_cmd"
4535a3d36dfSmrg      eval "func_echo $func_quote_for_expand_result"
4545a3d36dfSmrg    }
4555a3d36dfSmrg
4565a3d36dfSmrg    if ${opt_dry_run-false}; then :; else
4575a3d36dfSmrg      eval "$my_cmd"
4585a3d36dfSmrg      my_status=$?
4595a3d36dfSmrg      if test "$my_status" -eq 0; then :; else
4605a3d36dfSmrg	eval "(exit $my_status); $my_fail_exp"
4615a3d36dfSmrg      fi
46223a0898aSmrg    fi
46323a0898aSmrg}
46423a0898aSmrg
4655a3d36dfSmrg
4665a3d36dfSmrg# func_show_eval_locale cmd [fail_exp]
4675a3d36dfSmrg# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
4685a3d36dfSmrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
4695a3d36dfSmrg# is given, then evaluate it.  Use the saved locale for evaluation.
4705a3d36dfSmrgfunc_show_eval_locale ()
47123a0898aSmrg{
4725a3d36dfSmrg    my_cmd="$1"
4735a3d36dfSmrg    my_fail_exp="${2-:}"
4745a3d36dfSmrg
4755a3d36dfSmrg    ${opt_silent-false} || {
4765a3d36dfSmrg      func_quote_for_expand "$my_cmd"
4775a3d36dfSmrg      eval "func_echo $func_quote_for_expand_result"
4785a3d36dfSmrg    }
4795a3d36dfSmrg
4805a3d36dfSmrg    if ${opt_dry_run-false}; then :; else
4815a3d36dfSmrg      eval "$lt_user_locale
4825a3d36dfSmrg	    $my_cmd"
4835a3d36dfSmrg      my_status=$?
4845a3d36dfSmrg      eval "$lt_safe_locale"
4855a3d36dfSmrg      if test "$my_status" -eq 0; then :; else
4865a3d36dfSmrg	eval "(exit $my_status); $my_fail_exp"
4875a3d36dfSmrg      fi
48823a0898aSmrg    fi
4895a3d36dfSmrg}
49023a0898aSmrg
4917f7f5e4eSmrg
4925a3d36dfSmrg
4935a3d36dfSmrg
4945a3d36dfSmrg
4955a3d36dfSmrg# func_version
4965a3d36dfSmrg# Echo version message to standard output and exit.
4975a3d36dfSmrgfunc_version ()
4985a3d36dfSmrg{
4995a3d36dfSmrg    $SED -n '/^# '$PROGRAM' (GNU /,/# warranty; / {
5005a3d36dfSmrg        s/^# //
5015a3d36dfSmrg	s/^# *$//
5025a3d36dfSmrg        s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
5035a3d36dfSmrg        p
5045a3d36dfSmrg     }' < "$progpath"
5055a3d36dfSmrg     exit $?
5065a3d36dfSmrg}
5075a3d36dfSmrg
5085a3d36dfSmrg# func_usage
5095a3d36dfSmrg# Echo short help message to standard output and exit.
5105a3d36dfSmrgfunc_usage ()
5115a3d36dfSmrg{
5125a3d36dfSmrg    $SED -n '/^# Usage:/,/# -h/ {
5135a3d36dfSmrg        s/^# //
5145a3d36dfSmrg	s/^# *$//
5155a3d36dfSmrg	s/\$progname/'$progname'/
5165a3d36dfSmrg	p
5175a3d36dfSmrg    }' < "$progpath"
5185a3d36dfSmrg    $ECHO
5195a3d36dfSmrg    $ECHO "run \`$progname --help | more' for full usage"
5205a3d36dfSmrg    exit $?
5215a3d36dfSmrg}
5225a3d36dfSmrg
5235a3d36dfSmrg# func_help
5245a3d36dfSmrg# Echo long help message to standard output and exit.
5255a3d36dfSmrgfunc_help ()
5265a3d36dfSmrg{
5275a3d36dfSmrg    $SED -n '/^# Usage:/,/# Report bugs to/ {
5285a3d36dfSmrg        s/^# //
5295a3d36dfSmrg	s/^# *$//
5305a3d36dfSmrg	s*\$progname*'$progname'*
5315a3d36dfSmrg	s*\$host*'"$host"'*
5325a3d36dfSmrg	s*\$SHELL*'"$SHELL"'*
5335a3d36dfSmrg	s*\$LTCC*'"$LTCC"'*
5345a3d36dfSmrg	s*\$LTCFLAGS*'"$LTCFLAGS"'*
5355a3d36dfSmrg	s*\$LD*'"$LD"'*
5365a3d36dfSmrg	s/\$with_gnu_ld/'"$with_gnu_ld"'/
5375a3d36dfSmrg	s/\$automake_version/'"`(automake --version) 2>/dev/null |$SED 1q`"'/
5385a3d36dfSmrg	s/\$autoconf_version/'"`(autoconf --version) 2>/dev/null |$SED 1q`"'/
5395a3d36dfSmrg	p
5405a3d36dfSmrg     }' < "$progpath"
5415a3d36dfSmrg    exit $?
5425a3d36dfSmrg}
5435a3d36dfSmrg
5445a3d36dfSmrg# func_missing_arg argname
5455a3d36dfSmrg# Echo program name prefixed message to standard error and set global
5465a3d36dfSmrg# exit_cmd.
5475a3d36dfSmrgfunc_missing_arg ()
5485a3d36dfSmrg{
5495a3d36dfSmrg    func_error "missing argument for $1"
5505a3d36dfSmrg    exit_cmd=exit
55123a0898aSmrg}
55223a0898aSmrg
5535a3d36dfSmrgexit_cmd=:
5547f7f5e4eSmrg
5557f7f5e4eSmrg
5565a3d36dfSmrg
5575a3d36dfSmrg
5585a3d36dfSmrg
5595a3d36dfSmrg# Check that we have a working $ECHO.
5605a3d36dfSmrgif test "X$1" = X--no-reexec; then
5615a3d36dfSmrg  # Discard the --no-reexec flag, and continue.
5627f7f5e4eSmrg  shift
5635a3d36dfSmrgelif test "X$1" = X--fallback-echo; then
5645a3d36dfSmrg  # Avoid inline document here, it may be left over
5655a3d36dfSmrg  :
5665a3d36dfSmrgelif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t'; then
5675a3d36dfSmrg  # Yippee, $ECHO works!
5685a3d36dfSmrg  :
5695a3d36dfSmrgelse
5705a3d36dfSmrg  # Restart under the correct shell, and then maybe $ECHO will work.
5715a3d36dfSmrg  exec $SHELL "$progpath" --no-reexec ${1+"$@"}
5725a3d36dfSmrgfi
57323a0898aSmrg
5745a3d36dfSmrgif test "X$1" = X--fallback-echo; then
5755a3d36dfSmrg  # used as fallback echo
5765a3d36dfSmrg  shift
5775a3d36dfSmrg  cat <<EOF
5785a3d36dfSmrg$*
5795a3d36dfSmrgEOF
5805a3d36dfSmrg  exit $EXIT_SUCCESS
5815a3d36dfSmrgfi
58223a0898aSmrg
5835a3d36dfSmrgmagic="%%%MAGIC variable%%%"
5845a3d36dfSmrgmagic_exe="%%%MAGIC EXE variable%%%"
58523a0898aSmrg
5865a3d36dfSmrg# Global variables.
5875a3d36dfSmrg# $mode is unset
5885a3d36dfSmrgnonopt=
5895a3d36dfSmrgexecute_dlfiles=
5905a3d36dfSmrgpreserve_args=
5915a3d36dfSmrglo2o="s/\\.lo\$/.${objext}/"
5925a3d36dfSmrgo2lo="s/\\.${objext}\$/.lo/"
5935a3d36dfSmrgextracted_archives=
5945a3d36dfSmrgextracted_serial=0
5957f7f5e4eSmrg
5965a3d36dfSmrgopt_dry_run=false
5975a3d36dfSmrgopt_duplicate_deps=false
5985a3d36dfSmrgopt_silent=false
5995a3d36dfSmrgopt_debug=:
60023a0898aSmrg
6015a3d36dfSmrg# If this variable is set in any of the actions, the command in it
6025a3d36dfSmrg# will be execed at the end.  This prevents here-documents from being
6035a3d36dfSmrg# left over by shells.
6045a3d36dfSmrgexec_cmd=
6055a3d36dfSmrg
6065a3d36dfSmrg# func_fatal_configuration arg...
6075a3d36dfSmrg# Echo program name prefixed message to standard error, followed by
6085a3d36dfSmrg# a configuration failure hint, and exit.
6095a3d36dfSmrgfunc_fatal_configuration ()
6105a3d36dfSmrg{
6115a3d36dfSmrg    func_error ${1+"$@"}
6125a3d36dfSmrg    func_error "See the $PACKAGE documentation for more information."
6135a3d36dfSmrg    func_fatal_error "Fatal configuration error."
6145a3d36dfSmrg}
61523a0898aSmrg
6167f7f5e4eSmrg
6175a3d36dfSmrg# func_config
6185a3d36dfSmrg# Display the configuration for all the tags in this script.
6195a3d36dfSmrgfunc_config ()
6205a3d36dfSmrg{
6215a3d36dfSmrg    re_begincf='^# ### BEGIN LIBTOOL'
6225a3d36dfSmrg    re_endcf='^# ### END LIBTOOL'
6235a3d36dfSmrg
6245a3d36dfSmrg    # Default configuration.
6255a3d36dfSmrg    $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
62623a0898aSmrg
62723a0898aSmrg    # Now print the configurations for the tags.
62823a0898aSmrg    for tagname in $taglist; do
6295a3d36dfSmrg      $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
63023a0898aSmrg    done
631b3062210Smrg
6325a3d36dfSmrg    exit $?
6335a3d36dfSmrg}
634b3062210Smrg
6355a3d36dfSmrg# func_features
6365a3d36dfSmrg# Display the features supported by this script.
6375a3d36dfSmrgfunc_features ()
6385a3d36dfSmrg{
6395a3d36dfSmrg    $ECHO "host: $host"
64023a0898aSmrg    if test "$build_libtool_libs" = yes; then
6415a3d36dfSmrg      $ECHO "enable shared libraries"
64223a0898aSmrg    else
6435a3d36dfSmrg      $ECHO "disable shared libraries"
64423a0898aSmrg    fi
64523a0898aSmrg    if test "$build_old_libs" = yes; then
6465a3d36dfSmrg      $ECHO "enable static libraries"
64723a0898aSmrg    else
6485a3d36dfSmrg      $ECHO "disable static libraries"
64923a0898aSmrg    fi
6505a3d36dfSmrg
65123a0898aSmrg    exit $?
6525a3d36dfSmrg}
65323a0898aSmrg
6545a3d36dfSmrg# func_enable_tag tagname
6555a3d36dfSmrg# Verify that TAGNAME is valid, and either flag an error and exit, or
6565a3d36dfSmrg# enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
6575a3d36dfSmrg# variable here.
6585a3d36dfSmrgfunc_enable_tag ()
6595a3d36dfSmrg{
6605a3d36dfSmrg  # Global variable:
6615a3d36dfSmrg  tagname="$1"
66223a0898aSmrg
6635a3d36dfSmrg  re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
6645a3d36dfSmrg  re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
6655a3d36dfSmrg  sed_extractcf="/$re_begincf/,/$re_endcf/p"
6667f7f5e4eSmrg
6675a3d36dfSmrg  # Validate tagname.
6685a3d36dfSmrg  case $tagname in
6695a3d36dfSmrg    *[!-_A-Za-z0-9,/]*)
6705a3d36dfSmrg      func_fatal_error "invalid tag name: $tagname"
6715a3d36dfSmrg      ;;
6725a3d36dfSmrg  esac
67323a0898aSmrg
6745a3d36dfSmrg  # Don't test for the "default" C tag, as we know it's
6755a3d36dfSmrg  # there but not specially marked.
6765a3d36dfSmrg  case $tagname in
6775a3d36dfSmrg    CC) ;;
6785a3d36dfSmrg    *)
6795a3d36dfSmrg      if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
6805a3d36dfSmrg	taglist="$taglist $tagname"
6815a3d36dfSmrg
6825a3d36dfSmrg	# Evaluate the configuration.  Be careful to quote the path
6835a3d36dfSmrg	# and the sed script, to avoid splitting on whitespace, but
6845a3d36dfSmrg	# also don't use non-portable quotes within backquotes within
6855a3d36dfSmrg	# quotes we have to do it in 2 steps:
6865a3d36dfSmrg	extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
6875a3d36dfSmrg	eval "$extractedcf"
6885a3d36dfSmrg      else
6895a3d36dfSmrg	func_error "ignoring unknown tag $tagname"
6905a3d36dfSmrg      fi
6915a3d36dfSmrg      ;;
6925a3d36dfSmrg  esac
6935a3d36dfSmrg}
6945a3d36dfSmrg
6955a3d36dfSmrg# Parse options once, thoroughly.  This comes as soon as possible in
6965a3d36dfSmrg# the script to make things like `libtool --version' happen quickly.
6975a3d36dfSmrg{
698b3062210Smrg
6995a3d36dfSmrg  # Shorthand for --mode=foo, only valid as the first argument
7005a3d36dfSmrg  case $1 in
7015a3d36dfSmrg  clean|clea|cle|cl)
7025a3d36dfSmrg    shift; set dummy --mode clean ${1+"$@"}; shift
70323a0898aSmrg    ;;
7045a3d36dfSmrg  compile|compil|compi|comp|com|co|c)
7055a3d36dfSmrg    shift; set dummy --mode compile ${1+"$@"}; shift
70623a0898aSmrg    ;;
7075a3d36dfSmrg  execute|execut|execu|exec|exe|ex|e)
7085a3d36dfSmrg    shift; set dummy --mode execute ${1+"$@"}; shift
7097f7f5e4eSmrg    ;;
7105a3d36dfSmrg  finish|finis|fini|fin|fi|f)
7115a3d36dfSmrg    shift; set dummy --mode finish ${1+"$@"}; shift
7127f7f5e4eSmrg    ;;
7135a3d36dfSmrg  install|instal|insta|inst|ins|in|i)
7145a3d36dfSmrg    shift; set dummy --mode install ${1+"$@"}; shift
7155a3d36dfSmrg    ;;
7165a3d36dfSmrg  link|lin|li|l)
7175a3d36dfSmrg    shift; set dummy --mode link ${1+"$@"}; shift
7185a3d36dfSmrg    ;;
7195a3d36dfSmrg  uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
7205a3d36dfSmrg    shift; set dummy --mode uninstall ${1+"$@"}; shift
72123a0898aSmrg    ;;
72223a0898aSmrg  esac
72323a0898aSmrg
7245a3d36dfSmrg  # Parse non-mode specific arguments:
7255a3d36dfSmrg  while test "$#" -gt 0; do
7265a3d36dfSmrg    opt="$1"
7275a3d36dfSmrg    shift
7287f7f5e4eSmrg
7295a3d36dfSmrg    case $opt in
7305a3d36dfSmrg      --config)		func_config					;;
7317f7f5e4eSmrg
7325a3d36dfSmrg      --debug)		preserve_args="$preserve_args $opt"
7335a3d36dfSmrg			func_echo "enabling shell trace mode"
7345a3d36dfSmrg			opt_debug='set -x'
7355a3d36dfSmrg			$opt_debug
7365a3d36dfSmrg			;;
7377f7f5e4eSmrg
7385a3d36dfSmrg      -dlopen)		test "$#" -eq 0 && func_missing_arg "$opt" && break
7395a3d36dfSmrg			execute_dlfiles="$execute_dlfiles $1"
7405a3d36dfSmrg			shift
7415a3d36dfSmrg			;;
7427f7f5e4eSmrg
7435a3d36dfSmrg      --dry-run | -n)	opt_dry_run=:					;;
7445a3d36dfSmrg      --features)       func_features					;;
7455a3d36dfSmrg      --finish)		mode="finish"					;;
7465a3d36dfSmrg
7475a3d36dfSmrg      --mode)		test "$#" -eq 0 && func_missing_arg "$opt" && break
7485a3d36dfSmrg			case $1 in
7495a3d36dfSmrg			  # Valid mode arguments:
7505a3d36dfSmrg			  clean)	;;
7515a3d36dfSmrg			  compile)	;;
7525a3d36dfSmrg			  execute)	;;
7535a3d36dfSmrg			  finish)	;;
7545a3d36dfSmrg			  install)	;;
7555a3d36dfSmrg			  link)		;;
7565a3d36dfSmrg			  relink)	;;
7575a3d36dfSmrg			  uninstall)	;;
7585a3d36dfSmrg
7595a3d36dfSmrg			  # Catch anything else as an error
7605a3d36dfSmrg			  *) func_error "invalid argument for $opt"
7615a3d36dfSmrg			     exit_cmd=exit
7625a3d36dfSmrg			     break
7635a3d36dfSmrg			     ;;
7645a3d36dfSmrg		        esac
7655a3d36dfSmrg
7665a3d36dfSmrg			mode="$1"
7675a3d36dfSmrg			shift
7685a3d36dfSmrg			;;
7695a3d36dfSmrg
7705a3d36dfSmrg      --preserve-dup-deps)
7715a3d36dfSmrg			opt_duplicate_deps=:				;;
7725a3d36dfSmrg
7735a3d36dfSmrg      --quiet|--silent)	preserve_args="$preserve_args $opt"
7745a3d36dfSmrg			opt_silent=:
7755a3d36dfSmrg			;;
7765a3d36dfSmrg
7775a3d36dfSmrg      --verbose| -v)	preserve_args="$preserve_args $opt"
7785a3d36dfSmrg			opt_silent=false
7795a3d36dfSmrg			;;
7805a3d36dfSmrg
7815a3d36dfSmrg      --tag)		test "$#" -eq 0 && func_missing_arg "$opt" && break
7825a3d36dfSmrg			preserve_args="$preserve_args $opt $1"
7835a3d36dfSmrg			func_enable_tag "$1"	# tagname is set here
7845a3d36dfSmrg			shift
7855a3d36dfSmrg			;;
7865a3d36dfSmrg
7875a3d36dfSmrg      # Separate optargs to long options:
7885a3d36dfSmrg      -dlopen=*|--mode=*|--tag=*)
7895a3d36dfSmrg			func_opt_split "$opt"
7905a3d36dfSmrg			set dummy "$func_opt_split_opt" "$func_opt_split_arg" ${1+"$@"}
7915a3d36dfSmrg			shift
7925a3d36dfSmrg			;;
7935a3d36dfSmrg
7945a3d36dfSmrg      -\?|-h)		func_usage					;;
7955a3d36dfSmrg      --help)		opt_help=:					;;
7965a3d36dfSmrg      --version)	func_version					;;
7975a3d36dfSmrg
7985a3d36dfSmrg      -*)		func_fatal_help "unrecognized option \`$opt'"	;;
7995a3d36dfSmrg
8005a3d36dfSmrg      *)		nonopt="$opt"
8015a3d36dfSmrg			break
8025a3d36dfSmrg			;;
8035a3d36dfSmrg    esac
8045a3d36dfSmrg  done
8055a3d36dfSmrg
8065a3d36dfSmrg
8075a3d36dfSmrg  case $host in
8085a3d36dfSmrg    *cygwin* | *mingw* | *pw32* | *cegcc*)
8095a3d36dfSmrg      # don't eliminate duplications in $postdeps and $predeps
8105a3d36dfSmrg      opt_duplicate_compiler_generated_deps=:
811b3062210Smrg      ;;
812b3062210Smrg    *)
8135a3d36dfSmrg      opt_duplicate_compiler_generated_deps=$opt_duplicate_deps
8145a3d36dfSmrg      ;;
8155a3d36dfSmrg  esac
8167f7f5e4eSmrg
8175a3d36dfSmrg  # Having warned about all mis-specified options, bail out if
8185a3d36dfSmrg  # anything was wrong.
8195a3d36dfSmrg  $exit_cmd $EXIT_FAILURE
8205a3d36dfSmrg}
8215a3d36dfSmrg
8225a3d36dfSmrg# func_check_version_match
8235a3d36dfSmrg# Ensure that we are using m4 macros, and libtool script from the same
8245a3d36dfSmrg# release of libtool.
8255a3d36dfSmrgfunc_check_version_match ()
8265a3d36dfSmrg{
8275a3d36dfSmrg  if test "$package_revision" != "$macro_revision"; then
8285a3d36dfSmrg    if test "$VERSION" != "$macro_version"; then
8295a3d36dfSmrg      if test -z "$macro_version"; then
8305a3d36dfSmrg        cat >&2 <<_LT_EOF
8315a3d36dfSmrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
8325a3d36dfSmrg$progname: definition of this LT_INIT comes from an older release.
8335a3d36dfSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
8345a3d36dfSmrg$progname: and run autoconf again.
8355a3d36dfSmrg_LT_EOF
8365a3d36dfSmrg      else
8375a3d36dfSmrg        cat >&2 <<_LT_EOF
8385a3d36dfSmrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
8395a3d36dfSmrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
8405a3d36dfSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
8415a3d36dfSmrg$progname: and run autoconf again.
8425a3d36dfSmrg_LT_EOF
84323a0898aSmrg      fi
8445a3d36dfSmrg    else
8455a3d36dfSmrg      cat >&2 <<_LT_EOF
8465a3d36dfSmrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
8475a3d36dfSmrg$progname: but the definition of this LT_INIT comes from revision $macro_revision.
8485a3d36dfSmrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision
8495a3d36dfSmrg$progname: of $PACKAGE $VERSION and run autoconf again.
8505a3d36dfSmrg_LT_EOF
8515a3d36dfSmrg    fi
8525a3d36dfSmrg
8535a3d36dfSmrg    exit $EXIT_MISMATCH
8545a3d36dfSmrg  fi
8555a3d36dfSmrg}
8565a3d36dfSmrg
8575a3d36dfSmrg
8585a3d36dfSmrg## ----------- ##
8595a3d36dfSmrg##    Main.    ##
8605a3d36dfSmrg## ----------- ##
8615a3d36dfSmrg
8625a3d36dfSmrg$opt_help || {
8635a3d36dfSmrg  # Sanity checks first:
8645a3d36dfSmrg  func_check_version_match
8655a3d36dfSmrg
8665a3d36dfSmrg  if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
8675a3d36dfSmrg    func_fatal_configuration "not configured to build any kind of library"
86823a0898aSmrg  fi
86923a0898aSmrg
8705a3d36dfSmrg  test -z "$mode" && func_fatal_error "error: you must specify a MODE."
8715a3d36dfSmrg
8725a3d36dfSmrg
8735a3d36dfSmrg  # Darwin sucks
8745a3d36dfSmrg  eval std_shrext=\"$shrext_cmds\"
8755a3d36dfSmrg
8765a3d36dfSmrg
87723a0898aSmrg  # Only execute mode is allowed to have -dlopen flags.
87823a0898aSmrg  if test -n "$execute_dlfiles" && test "$mode" != execute; then
8795a3d36dfSmrg    func_error "unrecognized option \`-dlopen'"
8805a3d36dfSmrg    $ECHO "$help" 1>&2
88123a0898aSmrg    exit $EXIT_FAILURE
88223a0898aSmrg  fi
88323a0898aSmrg
88423a0898aSmrg  # Change the help message to a mode-specific one.
88523a0898aSmrg  generic_help="$help"
8865a3d36dfSmrg  help="Try \`$progname --help --mode=$mode' for more information."
8875a3d36dfSmrg}
88823a0898aSmrg
88923a0898aSmrg
8905a3d36dfSmrg# func_lalib_p file
8915a3d36dfSmrg# True iff FILE is a libtool `.la' library or `.lo' object file.
8925a3d36dfSmrg# This function is only a basic sanity check; it will hardly flush out
8935a3d36dfSmrg# determined imposters.
8945a3d36dfSmrgfunc_lalib_p ()
8955a3d36dfSmrg{
8965a3d36dfSmrg    test -f "$1" &&
8975a3d36dfSmrg      $SED -e 4q "$1" 2>/dev/null \
8985a3d36dfSmrg        | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
8995a3d36dfSmrg}
90023a0898aSmrg
9015a3d36dfSmrg# func_lalib_unsafe_p file
9025a3d36dfSmrg# True iff FILE is a libtool `.la' library or `.lo' object file.
9035a3d36dfSmrg# This function implements the same check as func_lalib_p without
9045a3d36dfSmrg# resorting to external programs.  To this end, it redirects stdin and
9055a3d36dfSmrg# closes it afterwards, without saving the original file descriptor.
9065a3d36dfSmrg# As a safety measure, use it only where a negative result would be
9075a3d36dfSmrg# fatal anyway.  Works if `file' does not exist.
9085a3d36dfSmrgfunc_lalib_unsafe_p ()
9095a3d36dfSmrg{
9105a3d36dfSmrg    lalib_p=no
9115a3d36dfSmrg    if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
9125a3d36dfSmrg	for lalib_p_l in 1 2 3 4
9135a3d36dfSmrg	do
9145a3d36dfSmrg	    read lalib_p_line
9155a3d36dfSmrg	    case "$lalib_p_line" in
9165a3d36dfSmrg		\#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
9175a3d36dfSmrg	    esac
9185a3d36dfSmrg	done
9195a3d36dfSmrg	exec 0<&5 5<&-
9205a3d36dfSmrg    fi
9215a3d36dfSmrg    test "$lalib_p" = yes
9225a3d36dfSmrg}
92323a0898aSmrg
9245a3d36dfSmrg# func_ltwrapper_script_p file
9255a3d36dfSmrg# True iff FILE is a libtool wrapper script
9265a3d36dfSmrg# This function is only a basic sanity check; it will hardly flush out
9275a3d36dfSmrg# determined imposters.
9285a3d36dfSmrgfunc_ltwrapper_script_p ()
9295a3d36dfSmrg{
9305a3d36dfSmrg    func_lalib_p "$1"
9315a3d36dfSmrg}
93223a0898aSmrg
9335a3d36dfSmrg# func_ltwrapper_executable_p file
9345a3d36dfSmrg# True iff FILE is a libtool wrapper executable
9355a3d36dfSmrg# This function is only a basic sanity check; it will hardly flush out
9365a3d36dfSmrg# determined imposters.
9375a3d36dfSmrgfunc_ltwrapper_executable_p ()
9385a3d36dfSmrg{
9395a3d36dfSmrg    func_ltwrapper_exec_suffix=
9405a3d36dfSmrg    case $1 in
9415a3d36dfSmrg    *.exe) ;;
9425a3d36dfSmrg    *) func_ltwrapper_exec_suffix=.exe ;;
9435a3d36dfSmrg    esac
9445a3d36dfSmrg    $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
9455a3d36dfSmrg}
9467f7f5e4eSmrg
9475a3d36dfSmrg# func_ltwrapper_scriptname file
9485a3d36dfSmrg# Assumes file is an ltwrapper_executable
9495a3d36dfSmrg# uses $file to determine the appropriate filename for a
9505a3d36dfSmrg# temporary ltwrapper_script.
9515a3d36dfSmrgfunc_ltwrapper_scriptname ()
9525a3d36dfSmrg{
9535a3d36dfSmrg    func_ltwrapper_scriptname_result=""
9545a3d36dfSmrg    if func_ltwrapper_executable_p "$1"; then
9555a3d36dfSmrg	func_dirname_and_basename "$1" "" "."
9565a3d36dfSmrg	func_stripname '' '.exe' "$func_basename_result"
9575a3d36dfSmrg	func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper"
9585a3d36dfSmrg    fi
9595a3d36dfSmrg}
9605a3d36dfSmrg
9615a3d36dfSmrg# func_ltwrapper_p file
9625a3d36dfSmrg# True iff FILE is a libtool wrapper script or wrapper executable
9635a3d36dfSmrg# This function is only a basic sanity check; it will hardly flush out
9645a3d36dfSmrg# determined imposters.
9655a3d36dfSmrgfunc_ltwrapper_p ()
9665a3d36dfSmrg{
9675a3d36dfSmrg    func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
9685a3d36dfSmrg}
9695a3d36dfSmrg
9705a3d36dfSmrg
9715a3d36dfSmrg# func_execute_cmds commands fail_cmd
9725a3d36dfSmrg# Execute tilde-delimited COMMANDS.
9735a3d36dfSmrg# If FAIL_CMD is given, eval that upon failure.
9745a3d36dfSmrg# FAIL_CMD may read-access the current command in variable CMD!
9755a3d36dfSmrgfunc_execute_cmds ()
9765a3d36dfSmrg{
9775a3d36dfSmrg    $opt_debug
9785a3d36dfSmrg    save_ifs=$IFS; IFS='~'
9795a3d36dfSmrg    for cmd in $1; do
9805a3d36dfSmrg      IFS=$save_ifs
9815a3d36dfSmrg      eval cmd=\"$cmd\"
9825a3d36dfSmrg      func_show_eval "$cmd" "${2-:}"
9835a3d36dfSmrg    done
9845a3d36dfSmrg    IFS=$save_ifs
9855a3d36dfSmrg}
9865a3d36dfSmrg
9875a3d36dfSmrg
9885a3d36dfSmrg# func_source file
9895a3d36dfSmrg# Source FILE, adding directory component if necessary.
9905a3d36dfSmrg# Note that it is not necessary on cygwin/mingw to append a dot to
9915a3d36dfSmrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe
9925a3d36dfSmrg# behavior happens only for exec(3), not for open(2)!  Also, sourcing
9935a3d36dfSmrg# `FILE.' does not work on cygwin managed mounts.
9945a3d36dfSmrgfunc_source ()
9955a3d36dfSmrg{
9965a3d36dfSmrg    $opt_debug
9975a3d36dfSmrg    case $1 in
9985a3d36dfSmrg    */* | *\\*)	. "$1" ;;
9995a3d36dfSmrg    *)		. "./$1" ;;
10005a3d36dfSmrg    esac
10015a3d36dfSmrg}
10025a3d36dfSmrg
10035a3d36dfSmrg
10045a3d36dfSmrg# func_infer_tag arg
10055a3d36dfSmrg# Infer tagged configuration to use if any are available and
10065a3d36dfSmrg# if one wasn't chosen via the "--tag" command line option.
10075a3d36dfSmrg# Only attempt this if the compiler in the base compile
10085a3d36dfSmrg# command doesn't match the default compiler.
10095a3d36dfSmrg# arg is usually of the form 'gcc ...'
10105a3d36dfSmrgfunc_infer_tag ()
10115a3d36dfSmrg{
10125a3d36dfSmrg    $opt_debug
10135a3d36dfSmrg    if test -n "$available_tags" && test -z "$tagname"; then
10145a3d36dfSmrg      CC_quoted=
10155a3d36dfSmrg      for arg in $CC; do
10165a3d36dfSmrg        func_quote_for_eval "$arg"
10175a3d36dfSmrg	CC_quoted="$CC_quoted $func_quote_for_eval_result"
10185a3d36dfSmrg      done
10195a3d36dfSmrg      case $@ in
10205a3d36dfSmrg      # Blanks in the command may have been stripped by the calling shell,
10215a3d36dfSmrg      # but not from the CC environment variable when configure was run.
10225a3d36dfSmrg      " $CC "* | "$CC "* | " `$ECHO $CC` "* | "`$ECHO $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$ECHO $CC_quoted` "* | "`$ECHO $CC_quoted` "*) ;;
10235a3d36dfSmrg      # Blanks at the start of $base_compile will cause this to fail
10245a3d36dfSmrg      # if we don't check for them as well.
10255a3d36dfSmrg      *)
10265a3d36dfSmrg	for z in $available_tags; do
10275a3d36dfSmrg	  if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
10285a3d36dfSmrg	    # Evaluate the configuration.
10295a3d36dfSmrg	    eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
10305a3d36dfSmrg	    CC_quoted=
10315a3d36dfSmrg	    for arg in $CC; do
10325a3d36dfSmrg	      # Double-quote args containing other shell metacharacters.
10335a3d36dfSmrg	      func_quote_for_eval "$arg"
10345a3d36dfSmrg	      CC_quoted="$CC_quoted $func_quote_for_eval_result"
10355a3d36dfSmrg	    done
10365a3d36dfSmrg	    case "$@ " in
10375a3d36dfSmrg	      " $CC "* | "$CC "* | " `$ECHO $CC` "* | "`$ECHO $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$ECHO $CC_quoted` "* | "`$ECHO $CC_quoted` "*)
10385a3d36dfSmrg	      # The compiler in the base compile command matches
10395a3d36dfSmrg	      # the one in the tagged configuration.
10405a3d36dfSmrg	      # Assume this is the tagged configuration we want.
10415a3d36dfSmrg	      tagname=$z
10425a3d36dfSmrg	      break
10435a3d36dfSmrg	      ;;
10445a3d36dfSmrg	    esac
10455a3d36dfSmrg	  fi
10465a3d36dfSmrg	done
10475a3d36dfSmrg	# If $tagname still isn't set, then no tagged configuration
10485a3d36dfSmrg	# was found and let the user know that the "--tag" command
10495a3d36dfSmrg	# line option must be used.
10505a3d36dfSmrg	if test -z "$tagname"; then
10515a3d36dfSmrg	  func_echo "unable to infer tagged configuration"
10525a3d36dfSmrg	  func_fatal_error "specify a tag with \`--tag'"
10535a3d36dfSmrg#	else
10545a3d36dfSmrg#	  func_verbose "using $tagname tagged configuration"
10555a3d36dfSmrg	fi
10565a3d36dfSmrg	;;
10575a3d36dfSmrg      esac
10585a3d36dfSmrg    fi
10595a3d36dfSmrg}
10605a3d36dfSmrg
10615a3d36dfSmrg
10625a3d36dfSmrg
10635a3d36dfSmrg# func_write_libtool_object output_name pic_name nonpic_name
10645a3d36dfSmrg# Create a libtool object file (analogous to a ".la" file),
10655a3d36dfSmrg# but don't create it if we're doing a dry run.
10665a3d36dfSmrgfunc_write_libtool_object ()
10675a3d36dfSmrg{
10685a3d36dfSmrg    write_libobj=${1}
10695a3d36dfSmrg    if test "$build_libtool_libs" = yes; then
10705a3d36dfSmrg      write_lobj=\'${2}\'
10715a3d36dfSmrg    else
10725a3d36dfSmrg      write_lobj=none
10735a3d36dfSmrg    fi
10745a3d36dfSmrg
10755a3d36dfSmrg    if test "$build_old_libs" = yes; then
10765a3d36dfSmrg      write_oldobj=\'${3}\'
10775a3d36dfSmrg    else
10785a3d36dfSmrg      write_oldobj=none
10795a3d36dfSmrg    fi
10805a3d36dfSmrg
10815a3d36dfSmrg    $opt_dry_run || {
10825a3d36dfSmrg      cat >${write_libobj}T <<EOF
10835a3d36dfSmrg# $write_libobj - a libtool object file
10845a3d36dfSmrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
10855a3d36dfSmrg#
10865a3d36dfSmrg# Please DO NOT delete this file!
10875a3d36dfSmrg# It is necessary for linking the library.
10885a3d36dfSmrg
10895a3d36dfSmrg# Name of the PIC object.
10905a3d36dfSmrgpic_object=$write_lobj
10915a3d36dfSmrg
10925a3d36dfSmrg# Name of the non-PIC object
10935a3d36dfSmrgnon_pic_object=$write_oldobj
10945a3d36dfSmrg
10955a3d36dfSmrgEOF
10965a3d36dfSmrg      $MV "${write_libobj}T" "${write_libobj}"
10975a3d36dfSmrg    }
10985a3d36dfSmrg}
10995a3d36dfSmrg
11005a3d36dfSmrg# func_mode_compile arg...
11015a3d36dfSmrgfunc_mode_compile ()
11025a3d36dfSmrg{
11035a3d36dfSmrg    $opt_debug
11045a3d36dfSmrg    # Get the compilation command and the source file.
11055a3d36dfSmrg    base_compile=
11065a3d36dfSmrg    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
11075a3d36dfSmrg    suppress_opt=yes
11085a3d36dfSmrg    suppress_output=
11095a3d36dfSmrg    arg_mode=normal
11105a3d36dfSmrg    libobj=
11115a3d36dfSmrg    later=
11125a3d36dfSmrg    pie_flag=
11135a3d36dfSmrg
11145a3d36dfSmrg    for arg
11155a3d36dfSmrg    do
11165a3d36dfSmrg      case $arg_mode in
11175a3d36dfSmrg      arg  )
11185a3d36dfSmrg	# do not "continue".  Instead, add this to base_compile
11195a3d36dfSmrg	lastarg="$arg"
11205a3d36dfSmrg	arg_mode=normal
11215a3d36dfSmrg	;;
11225a3d36dfSmrg
11235a3d36dfSmrg      target )
11245a3d36dfSmrg	libobj="$arg"
11255a3d36dfSmrg	arg_mode=normal
11265a3d36dfSmrg	continue
11275a3d36dfSmrg	;;
11285a3d36dfSmrg
11295a3d36dfSmrg      normal )
11305a3d36dfSmrg	# Accept any command-line options.
11315a3d36dfSmrg	case $arg in
11325a3d36dfSmrg	-o)
11335a3d36dfSmrg	  test -n "$libobj" && \
11345a3d36dfSmrg	    func_fatal_error "you cannot specify \`-o' more than once"
11355a3d36dfSmrg	  arg_mode=target
11365a3d36dfSmrg	  continue
11375a3d36dfSmrg	  ;;
11385a3d36dfSmrg
11395a3d36dfSmrg	-pie | -fpie | -fPIE)
11405a3d36dfSmrg          pie_flag="$pie_flag $arg"
11415a3d36dfSmrg	  continue
11425a3d36dfSmrg	  ;;
11435a3d36dfSmrg
11445a3d36dfSmrg	-shared | -static | -prefer-pic | -prefer-non-pic)
11455a3d36dfSmrg	  later="$later $arg"
11465a3d36dfSmrg	  continue
11475a3d36dfSmrg	  ;;
11485a3d36dfSmrg
11495a3d36dfSmrg	-no-suppress)
115023a0898aSmrg	  suppress_opt=no
115123a0898aSmrg	  continue
115223a0898aSmrg	  ;;
115323a0898aSmrg
115423a0898aSmrg	-Xcompiler)
115523a0898aSmrg	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
115623a0898aSmrg	  continue      #  The current "srcfile" will either be retained or
115723a0898aSmrg	  ;;            #  replaced later.  I would guess that would be a bug.
115823a0898aSmrg
115923a0898aSmrg	-Wc,*)
11605a3d36dfSmrg	  func_stripname '-Wc,' '' "$arg"
11615a3d36dfSmrg	  args=$func_stripname_result
116223a0898aSmrg	  lastarg=
116323a0898aSmrg	  save_ifs="$IFS"; IFS=','
11645a3d36dfSmrg	  for arg in $args; do
116523a0898aSmrg	    IFS="$save_ifs"
11665a3d36dfSmrg	    func_quote_for_eval "$arg"
11675a3d36dfSmrg	    lastarg="$lastarg $func_quote_for_eval_result"
116823a0898aSmrg	  done
116923a0898aSmrg	  IFS="$save_ifs"
11705a3d36dfSmrg	  func_stripname ' ' '' "$lastarg"
11715a3d36dfSmrg	  lastarg=$func_stripname_result
117223a0898aSmrg
117323a0898aSmrg	  # Add the arguments to base_compile.
117423a0898aSmrg	  base_compile="$base_compile $lastarg"
117523a0898aSmrg	  continue
117623a0898aSmrg	  ;;
117723a0898aSmrg
11785a3d36dfSmrg	*)
117923a0898aSmrg	  # Accept the current argument as the source file.
118023a0898aSmrg	  # The previous "srcfile" becomes the current argument.
118123a0898aSmrg	  #
118223a0898aSmrg	  lastarg="$srcfile"
118323a0898aSmrg	  srcfile="$arg"
118423a0898aSmrg	  ;;
118523a0898aSmrg	esac  #  case $arg
118623a0898aSmrg	;;
118723a0898aSmrg      esac    #  case $arg_mode
118823a0898aSmrg
118923a0898aSmrg      # Aesthetically quote the previous argument.
11905a3d36dfSmrg      func_quote_for_eval "$lastarg"
11915a3d36dfSmrg      base_compile="$base_compile $func_quote_for_eval_result"
119223a0898aSmrg    done # for arg
119323a0898aSmrg
119423a0898aSmrg    case $arg_mode in
119523a0898aSmrg    arg)
11965a3d36dfSmrg      func_fatal_error "you must specify an argument for -Xcompile"
119723a0898aSmrg      ;;
119823a0898aSmrg    target)
11995a3d36dfSmrg      func_fatal_error "you must specify a target with \`-o'"
120023a0898aSmrg      ;;
120123a0898aSmrg    *)
120223a0898aSmrg      # Get the name of the library object.
12035a3d36dfSmrg      test -z "$libobj" && {
12045a3d36dfSmrg	func_basename "$srcfile"
12055a3d36dfSmrg	libobj="$func_basename_result"
12065a3d36dfSmrg      }
120723a0898aSmrg      ;;
120823a0898aSmrg    esac
120923a0898aSmrg
121023a0898aSmrg    # Recognize several different file suffixes.
121123a0898aSmrg    # If the user specifies -o file.o, it is replaced with file.lo
121223a0898aSmrg    case $libobj in
12135a3d36dfSmrg    *.[cCFSifmso] | \
12145a3d36dfSmrg    *.ada | *.adb | *.ads | *.asm | \
12155a3d36dfSmrg    *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
12165a3d36dfSmrg    *.[fF][09]? | *.for | *.java | *.obj | *.sx)
12175a3d36dfSmrg      func_xform "$libobj"
12185a3d36dfSmrg      libobj=$func_xform_result
12195a3d36dfSmrg      ;;
122023a0898aSmrg    esac
122123a0898aSmrg
122223a0898aSmrg    case $libobj in
12235a3d36dfSmrg    *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
122423a0898aSmrg    *)
12255a3d36dfSmrg      func_fatal_error "cannot determine name of library object from \`$libobj'"
122623a0898aSmrg      ;;
122723a0898aSmrg    esac
122823a0898aSmrg
122923a0898aSmrg    func_infer_tag $base_compile
123023a0898aSmrg
123123a0898aSmrg    for arg in $later; do
123223a0898aSmrg      case $arg in
12335a3d36dfSmrg      -shared)
12345a3d36dfSmrg	test "$build_libtool_libs" != yes && \
12355a3d36dfSmrg	  func_fatal_configuration "can not build a shared library"
12365a3d36dfSmrg	build_old_libs=no
12375a3d36dfSmrg	continue
12385a3d36dfSmrg	;;
12395a3d36dfSmrg
124023a0898aSmrg      -static)
12415a3d36dfSmrg	build_libtool_libs=no
124223a0898aSmrg	build_old_libs=yes
124323a0898aSmrg	continue
124423a0898aSmrg	;;
124523a0898aSmrg
124623a0898aSmrg      -prefer-pic)
124723a0898aSmrg	pic_mode=yes
124823a0898aSmrg	continue
124923a0898aSmrg	;;
125023a0898aSmrg
125123a0898aSmrg      -prefer-non-pic)
125223a0898aSmrg	pic_mode=no
125323a0898aSmrg	continue
125423a0898aSmrg	;;
125523a0898aSmrg      esac
125623a0898aSmrg    done
125723a0898aSmrg
12585a3d36dfSmrg    func_quote_for_eval "$libobj"
12595a3d36dfSmrg    test "X$libobj" != "X$func_quote_for_eval_result" \
12605a3d36dfSmrg      && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'	 &()|`$[]' \
12615a3d36dfSmrg      && func_warning "libobj name \`$libobj' may not contain shell special characters."
12625a3d36dfSmrg    func_dirname_and_basename "$obj" "/" ""
12635a3d36dfSmrg    objname="$func_basename_result"
12645a3d36dfSmrg    xdir="$func_dirname_result"
126523a0898aSmrg    lobj=${xdir}$objdir/$objname
126623a0898aSmrg
12675a3d36dfSmrg    test -z "$base_compile" && \
12685a3d36dfSmrg      func_fatal_help "you must specify a compilation command"
126923a0898aSmrg
127023a0898aSmrg    # Delete any leftover library objects.
127123a0898aSmrg    if test "$build_old_libs" = yes; then
127223a0898aSmrg      removelist="$obj $lobj $libobj ${libobj}T"
127323a0898aSmrg    else
127423a0898aSmrg      removelist="$lobj $libobj ${libobj}T"
127523a0898aSmrg    fi
127623a0898aSmrg
127723a0898aSmrg    # On Cygwin there's no "real" PIC flag so we must build both object types
127823a0898aSmrg    case $host_os in
12795a3d36dfSmrg    cygwin* | mingw* | pw32* | os2* | cegcc*)
128023a0898aSmrg      pic_mode=default
128123a0898aSmrg      ;;
128223a0898aSmrg    esac
128323a0898aSmrg    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
128423a0898aSmrg      # non-PIC code in shared libraries is not supported
128523a0898aSmrg      pic_mode=default
128623a0898aSmrg    fi
128723a0898aSmrg
128823a0898aSmrg    # Calculate the filename of the output object if compiler does
128923a0898aSmrg    # not support -o with -c
129023a0898aSmrg    if test "$compiler_c_o" = no; then
12915a3d36dfSmrg      output_obj=`$ECHO "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext}
129223a0898aSmrg      lockfile="$output_obj.lock"
129323a0898aSmrg    else
129423a0898aSmrg      output_obj=
129523a0898aSmrg      need_locks=no
129623a0898aSmrg      lockfile=
129723a0898aSmrg    fi
129823a0898aSmrg
129923a0898aSmrg    # Lock this critical section if it is needed
130023a0898aSmrg    # We use this script file to make the link, it avoids creating a new file
130123a0898aSmrg    if test "$need_locks" = yes; then
13025a3d36dfSmrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
13035a3d36dfSmrg	func_echo "Waiting for $lockfile to be removed"
130423a0898aSmrg	sleep 2
130523a0898aSmrg      done
130623a0898aSmrg    elif test "$need_locks" = warn; then
130723a0898aSmrg      if test -f "$lockfile"; then
13085a3d36dfSmrg	$ECHO "\
130923a0898aSmrg*** ERROR, $lockfile exists and contains:
131023a0898aSmrg`cat $lockfile 2>/dev/null`
131123a0898aSmrg
131223a0898aSmrgThis indicates that another process is trying to use the same
131323a0898aSmrgtemporary object file, and libtool could not work around it because
131423a0898aSmrgyour compiler does not support \`-c' and \`-o' together.  If you
131523a0898aSmrgrepeat this compilation, it may succeed, by chance, but you had better
131623a0898aSmrgavoid parallel builds (make -j) in this platform, or get a better
131723a0898aSmrgcompiler."
131823a0898aSmrg
13195a3d36dfSmrg	$opt_dry_run || $RM $removelist
132023a0898aSmrg	exit $EXIT_FAILURE
132123a0898aSmrg      fi
13225a3d36dfSmrg      removelist="$removelist $output_obj"
13235a3d36dfSmrg      $ECHO "$srcfile" > "$lockfile"
132423a0898aSmrg    fi
132523a0898aSmrg
13265a3d36dfSmrg    $opt_dry_run || $RM $removelist
13275a3d36dfSmrg    removelist="$removelist $lockfile"
13285a3d36dfSmrg    trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
13295a3d36dfSmrg
133023a0898aSmrg    if test -n "$fix_srcfile_path"; then
133123a0898aSmrg      eval srcfile=\"$fix_srcfile_path\"
133223a0898aSmrg    fi
13335a3d36dfSmrg    func_quote_for_eval "$srcfile"
13345a3d36dfSmrg    qsrcfile=$func_quote_for_eval_result
133523a0898aSmrg
133623a0898aSmrg    # Only build a PIC object if we are building libtool libraries.
133723a0898aSmrg    if test "$build_libtool_libs" = yes; then
133823a0898aSmrg      # Without this assignment, base_compile gets emptied.
133923a0898aSmrg      fbsd_hideous_sh_bug=$base_compile
134023a0898aSmrg
134123a0898aSmrg      if test "$pic_mode" != no; then
134223a0898aSmrg	command="$base_compile $qsrcfile $pic_flag"
134323a0898aSmrg      else
134423a0898aSmrg	# Don't build PIC code
134523a0898aSmrg	command="$base_compile $qsrcfile"
134623a0898aSmrg      fi
134723a0898aSmrg
13485a3d36dfSmrg      func_mkdir_p "$xdir$objdir"
134923a0898aSmrg
135023a0898aSmrg      if test -z "$output_obj"; then
135123a0898aSmrg	# Place PIC objects in $objdir
135223a0898aSmrg	command="$command -o $lobj"
135323a0898aSmrg      fi
135423a0898aSmrg
13555a3d36dfSmrg      func_show_eval_locale "$command"	\
13565a3d36dfSmrg          'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
135723a0898aSmrg
135823a0898aSmrg      if test "$need_locks" = warn &&
135923a0898aSmrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
13605a3d36dfSmrg	$ECHO "\
136123a0898aSmrg*** ERROR, $lockfile contains:
136223a0898aSmrg`cat $lockfile 2>/dev/null`
136323a0898aSmrg
136423a0898aSmrgbut it should contain:
136523a0898aSmrg$srcfile
136623a0898aSmrg
136723a0898aSmrgThis indicates that another process is trying to use the same
136823a0898aSmrgtemporary object file, and libtool could not work around it because
136923a0898aSmrgyour compiler does not support \`-c' and \`-o' together.  If you
137023a0898aSmrgrepeat this compilation, it may succeed, by chance, but you had better
137123a0898aSmrgavoid parallel builds (make -j) in this platform, or get a better
137223a0898aSmrgcompiler."
137323a0898aSmrg
13745a3d36dfSmrg	$opt_dry_run || $RM $removelist
137523a0898aSmrg	exit $EXIT_FAILURE
137623a0898aSmrg      fi
137723a0898aSmrg
137823a0898aSmrg      # Just move the object if needed, then go on to compile the next one
137923a0898aSmrg      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
13805a3d36dfSmrg	func_show_eval '$MV "$output_obj" "$lobj"' \
13815a3d36dfSmrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
138223a0898aSmrg      fi
138323a0898aSmrg
138423a0898aSmrg      # Allow error messages only from the first compilation.
138523a0898aSmrg      if test "$suppress_opt" = yes; then
13865a3d36dfSmrg	suppress_output=' >/dev/null 2>&1'
138723a0898aSmrg      fi
138823a0898aSmrg    fi
138923a0898aSmrg
139023a0898aSmrg    # Only build a position-dependent object if we build old libraries.
139123a0898aSmrg    if test "$build_old_libs" = yes; then
139223a0898aSmrg      if test "$pic_mode" != yes; then
139323a0898aSmrg	# Don't build PIC code
13945a3d36dfSmrg	command="$base_compile $qsrcfile$pie_flag"
139523a0898aSmrg      else
139623a0898aSmrg	command="$base_compile $qsrcfile $pic_flag"
139723a0898aSmrg      fi
139823a0898aSmrg      if test "$compiler_c_o" = yes; then
139923a0898aSmrg	command="$command -o $obj"
140023a0898aSmrg      fi
140123a0898aSmrg
140223a0898aSmrg      # Suppress compiler output if we already did a PIC compilation.
140323a0898aSmrg      command="$command$suppress_output"
14045a3d36dfSmrg      func_show_eval_locale "$command" \
14055a3d36dfSmrg        '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
140623a0898aSmrg
140723a0898aSmrg      if test "$need_locks" = warn &&
140823a0898aSmrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
14095a3d36dfSmrg	$ECHO "\
141023a0898aSmrg*** ERROR, $lockfile contains:
141123a0898aSmrg`cat $lockfile 2>/dev/null`
141223a0898aSmrg
141323a0898aSmrgbut it should contain:
141423a0898aSmrg$srcfile
141523a0898aSmrg
141623a0898aSmrgThis indicates that another process is trying to use the same
141723a0898aSmrgtemporary object file, and libtool could not work around it because
141823a0898aSmrgyour compiler does not support \`-c' and \`-o' together.  If you
141923a0898aSmrgrepeat this compilation, it may succeed, by chance, but you had better
142023a0898aSmrgavoid parallel builds (make -j) in this platform, or get a better
142123a0898aSmrgcompiler."
142223a0898aSmrg
14235a3d36dfSmrg	$opt_dry_run || $RM $removelist
142423a0898aSmrg	exit $EXIT_FAILURE
142523a0898aSmrg      fi
142623a0898aSmrg
142723a0898aSmrg      # Just move the object if needed
142823a0898aSmrg      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
14295a3d36dfSmrg	func_show_eval '$MV "$output_obj" "$obj"' \
14305a3d36dfSmrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
143123a0898aSmrg      fi
143223a0898aSmrg    fi
143323a0898aSmrg
14345a3d36dfSmrg    $opt_dry_run || {
14355a3d36dfSmrg      func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
143623a0898aSmrg
14375a3d36dfSmrg      # Unlock the critical section if it was locked
14385a3d36dfSmrg      if test "$need_locks" != no; then
14395a3d36dfSmrg	removelist=$lockfile
14405a3d36dfSmrg        $RM "$lockfile"
14415a3d36dfSmrg      fi
14425a3d36dfSmrg    }
144323a0898aSmrg
144423a0898aSmrg    exit $EXIT_SUCCESS
14455a3d36dfSmrg}
144623a0898aSmrg
14475a3d36dfSmrg$opt_help || {
14485a3d36dfSmrgtest "$mode" = compile && func_mode_compile ${1+"$@"}
14495a3d36dfSmrg}
145023a0898aSmrg
14515a3d36dfSmrgfunc_mode_help ()
14525a3d36dfSmrg{
14535a3d36dfSmrg    # We need to display help for each of the modes.
14545a3d36dfSmrg    case $mode in
14555a3d36dfSmrg      "")
14565a3d36dfSmrg        # Generic help is extracted from the usage comments
14575a3d36dfSmrg        # at the start of this file.
14585a3d36dfSmrg        func_help
14595a3d36dfSmrg        ;;
146023a0898aSmrg
14615a3d36dfSmrg      clean)
14625a3d36dfSmrg        $ECHO \
14635a3d36dfSmrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
146423a0898aSmrg
14655a3d36dfSmrgRemove files from the build directory.
146623a0898aSmrg
14675a3d36dfSmrgRM is the name of the program to use to delete files associated with each FILE
14685a3d36dfSmrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
14695a3d36dfSmrgto RM.
147023a0898aSmrg
14715a3d36dfSmrgIf FILE is a libtool library, object or program, all the files associated
14725a3d36dfSmrgwith it are deleted. Otherwise, only FILE itself is deleted using RM."
14735a3d36dfSmrg        ;;
147423a0898aSmrg
14755a3d36dfSmrg      compile)
14765a3d36dfSmrg      $ECHO \
14775a3d36dfSmrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
147823a0898aSmrg
14795a3d36dfSmrgCompile a source file into a libtool library object.
148023a0898aSmrg
14815a3d36dfSmrgThis mode accepts the following additional options:
148223a0898aSmrg
14835a3d36dfSmrg  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
14845a3d36dfSmrg  -no-suppress      do not suppress compiler output for multiple passes
14855a3d36dfSmrg  -prefer-pic       try to building PIC objects only
14865a3d36dfSmrg  -prefer-non-pic   try to building non-PIC objects only
14875a3d36dfSmrg  -shared           do not build a \`.o' file suitable for static linking
14885a3d36dfSmrg  -static           only build a \`.o' file suitable for static linking
148923a0898aSmrg
14905a3d36dfSmrgCOMPILE-COMMAND is a command to be used in creating a \`standard' object file
14915a3d36dfSmrgfrom the given SOURCEFILE.
149223a0898aSmrg
14935a3d36dfSmrgThe output file name is determined by removing the directory component from
14945a3d36dfSmrgSOURCEFILE, then substituting the C source code suffix \`.c' with the
14955a3d36dfSmrglibrary object suffix, \`.lo'."
14965a3d36dfSmrg        ;;
149723a0898aSmrg
14985a3d36dfSmrg      execute)
14995a3d36dfSmrg        $ECHO \
15005a3d36dfSmrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
150123a0898aSmrg
15025a3d36dfSmrgAutomatically set library path, then run a program.
150323a0898aSmrg
15045a3d36dfSmrgThis mode accepts the following additional options:
150523a0898aSmrg
15065a3d36dfSmrg  -dlopen FILE      add the directory containing FILE to the library path
150723a0898aSmrg
15085a3d36dfSmrgThis mode sets the library path environment variable according to \`-dlopen'
15095a3d36dfSmrgflags.
151023a0898aSmrg
15115a3d36dfSmrgIf any of the ARGS are libtool executable wrappers, then they are translated
15125a3d36dfSmrginto their corresponding uninstalled binary, and any of their required library
15135a3d36dfSmrgdirectories are added to the library path.
151423a0898aSmrg
15155a3d36dfSmrgThen, COMMAND is executed, with ARGS as arguments."
15165a3d36dfSmrg        ;;
151723a0898aSmrg
15185a3d36dfSmrg      finish)
15195a3d36dfSmrg        $ECHO \
15205a3d36dfSmrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
152123a0898aSmrg
15225a3d36dfSmrgComplete the installation of libtool libraries.
152323a0898aSmrg
15245a3d36dfSmrgEach LIBDIR is a directory that contains libtool libraries.
152523a0898aSmrg
15265a3d36dfSmrgThe commands that this mode executes may require superuser privileges.  Use
15275a3d36dfSmrgthe \`--dry-run' option if you just want to see what would be executed."
15285a3d36dfSmrg        ;;
152923a0898aSmrg
15305a3d36dfSmrg      install)
15315a3d36dfSmrg        $ECHO \
15325a3d36dfSmrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
153323a0898aSmrg
15345a3d36dfSmrgInstall executables or libraries.
153523a0898aSmrg
15365a3d36dfSmrgINSTALL-COMMAND is the installation command.  The first component should be
15375a3d36dfSmrgeither the \`install' or \`cp' program.
153823a0898aSmrg
15395a3d36dfSmrgThe following components of INSTALL-COMMAND are treated specially:
154023a0898aSmrg
15415a3d36dfSmrg  -inst-prefix PREFIX-DIR  Use PREFIX-DIR as a staging area for installation
154223a0898aSmrg
15435a3d36dfSmrgThe rest of the components are interpreted as arguments to that command (only
15445a3d36dfSmrgBSD-compatible install options are recognized)."
15455a3d36dfSmrg        ;;
154623a0898aSmrg
15475a3d36dfSmrg      link)
15485a3d36dfSmrg        $ECHO \
15495a3d36dfSmrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
155023a0898aSmrg
15515a3d36dfSmrgLink object files or libraries together to form another library, or to
15525a3d36dfSmrgcreate an executable program.
155323a0898aSmrg
15545a3d36dfSmrgLINK-COMMAND is a command using the C compiler that you would use to create
15555a3d36dfSmrga program from several object files.
155623a0898aSmrg
15575a3d36dfSmrgThe following components of LINK-COMMAND are treated specially:
155823a0898aSmrg
15595a3d36dfSmrg  -all-static       do not do any dynamic linking at all
15605a3d36dfSmrg  -avoid-version    do not add a version suffix if possible
15615a3d36dfSmrg  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
15625a3d36dfSmrg  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
15635a3d36dfSmrg  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
15645a3d36dfSmrg  -export-symbols SYMFILE
15655a3d36dfSmrg                    try to export only the symbols listed in SYMFILE
15665a3d36dfSmrg  -export-symbols-regex REGEX
15675a3d36dfSmrg                    try to export only the symbols matching REGEX
15685a3d36dfSmrg  -LLIBDIR          search LIBDIR for required installed libraries
15695a3d36dfSmrg  -lNAME            OUTPUT-FILE requires the installed library libNAME
15705a3d36dfSmrg  -module           build a library that can dlopened
15715a3d36dfSmrg  -no-fast-install  disable the fast-install mode
15725a3d36dfSmrg  -no-install       link a not-installable executable
15735a3d36dfSmrg  -no-undefined     declare that a library does not refer to external symbols
15745a3d36dfSmrg  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
15755a3d36dfSmrg  -objectlist FILE  Use a list of object files found in FILE to specify objects
15765a3d36dfSmrg  -precious-files-regex REGEX
15775a3d36dfSmrg                    don't remove output files matching REGEX
15785a3d36dfSmrg  -release RELEASE  specify package release information
15795a3d36dfSmrg  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
15805a3d36dfSmrg  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
15815a3d36dfSmrg  -shared           only do dynamic linking of libtool libraries
15825a3d36dfSmrg  -shrext SUFFIX    override the standard shared library file extension
15835a3d36dfSmrg  -static           do not do any dynamic linking of uninstalled libtool libraries
15845a3d36dfSmrg  -static-libtool-libs
15855a3d36dfSmrg                    do not do any dynamic linking of libtool libraries
15865a3d36dfSmrg  -version-info CURRENT[:REVISION[:AGE]]
15875a3d36dfSmrg                    specify library version info [each variable defaults to 0]
15885a3d36dfSmrg  -weak LIBNAME     declare that the target provides the LIBNAME interface
158923a0898aSmrg
15905a3d36dfSmrgAll other options (arguments beginning with \`-') are ignored.
159123a0898aSmrg
15925a3d36dfSmrgEvery other argument is treated as a filename.  Files ending in \`.la' are
15935a3d36dfSmrgtreated as uninstalled libtool libraries, other files are standard or library
15945a3d36dfSmrgobject files.
159523a0898aSmrg
15965a3d36dfSmrgIf the OUTPUT-FILE ends in \`.la', then a libtool library is created,
15975a3d36dfSmrgonly library objects (\`.lo' files) may be specified, and \`-rpath' is
15985a3d36dfSmrgrequired, except when creating a convenience library.
159923a0898aSmrg
16005a3d36dfSmrgIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
16015a3d36dfSmrgusing \`ar' and \`ranlib', or on Windows using \`lib'.
160223a0898aSmrg
16035a3d36dfSmrgIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
16045a3d36dfSmrgis created, otherwise an executable program is created."
1605b3062210Smrg        ;;
160623a0898aSmrg
16075a3d36dfSmrg      uninstall)
16085a3d36dfSmrg        $ECHO \
16095a3d36dfSmrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
161023a0898aSmrg
16115a3d36dfSmrgRemove libraries from an installation directory.
161223a0898aSmrg
16135a3d36dfSmrgRM is the name of the program to use to delete files associated with each FILE
16145a3d36dfSmrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
16155a3d36dfSmrgto RM.
161623a0898aSmrg
16175a3d36dfSmrgIf FILE is a libtool library, all the files associated with it are deleted.
16185a3d36dfSmrgOtherwise, only FILE itself is deleted using RM."
16195a3d36dfSmrg        ;;
16207f7f5e4eSmrg
16215a3d36dfSmrg      *)
16225a3d36dfSmrg        func_fatal_help "invalid operation mode \`$mode'"
16235a3d36dfSmrg        ;;
16245a3d36dfSmrg    esac
16257f7f5e4eSmrg
16265a3d36dfSmrg    $ECHO
16275a3d36dfSmrg    $ECHO "Try \`$progname --help' for more information about other modes."
16287f7f5e4eSmrg
16295a3d36dfSmrg    exit $?
16305a3d36dfSmrg}
16317f7f5e4eSmrg
16325a3d36dfSmrg  # Now that we've collected a possible --mode arg, show help if necessary
16335a3d36dfSmrg  $opt_help && func_mode_help
16347f7f5e4eSmrg
16357f7f5e4eSmrg
16365a3d36dfSmrg# func_mode_execute arg...
16375a3d36dfSmrgfunc_mode_execute ()
16385a3d36dfSmrg{
16395a3d36dfSmrg    $opt_debug
16405a3d36dfSmrg    # The first argument is the command name.
16415a3d36dfSmrg    cmd="$nonopt"
16425a3d36dfSmrg    test -z "$cmd" && \
16435a3d36dfSmrg      func_fatal_help "you must specify a COMMAND"
1644b3062210Smrg
16455a3d36dfSmrg    # Handle -dlopen flags immediately.
16465a3d36dfSmrg    for file in $execute_dlfiles; do
16475a3d36dfSmrg      test -f "$file" \
16485a3d36dfSmrg	|| func_fatal_help "\`$file' is not a file"
1649b3062210Smrg
16505a3d36dfSmrg      dir=
16515a3d36dfSmrg      case $file in
16525a3d36dfSmrg      *.la)
16535a3d36dfSmrg	# Check to see that this really is a libtool archive.
16545a3d36dfSmrg	func_lalib_unsafe_p "$file" \
16555a3d36dfSmrg	  || func_fatal_help "\`$lib' is not a valid libtool archive"
1656b3062210Smrg
16575a3d36dfSmrg	# Read the libtool library.
16585a3d36dfSmrg	dlname=
16595a3d36dfSmrg	library_names=
16605a3d36dfSmrg	func_source "$file"
166123a0898aSmrg
16625a3d36dfSmrg	# Skip this library if it cannot be dlopened.
16635a3d36dfSmrg	if test -z "$dlname"; then
16645a3d36dfSmrg	  # Warn if it was a shared library.
16655a3d36dfSmrg	  test -n "$library_names" && \
16665a3d36dfSmrg	    func_warning "\`$file' was not linked with \`-export-dynamic'"
16675a3d36dfSmrg	  continue
16685a3d36dfSmrg	fi
166923a0898aSmrg
16705a3d36dfSmrg	func_dirname "$file" "" "."
16715a3d36dfSmrg	dir="$func_dirname_result"
167223a0898aSmrg
16735a3d36dfSmrg	if test -f "$dir/$objdir/$dlname"; then
16745a3d36dfSmrg	  dir="$dir/$objdir"
16755a3d36dfSmrg	else
16765a3d36dfSmrg	  if test ! -f "$dir/$dlname"; then
16775a3d36dfSmrg	    func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'"
16785a3d36dfSmrg	  fi
16795a3d36dfSmrg	fi
1680b3062210Smrg	;;
168123a0898aSmrg
16825a3d36dfSmrg      *.lo)
16835a3d36dfSmrg	# Just add the directory containing the .lo file.
16845a3d36dfSmrg	func_dirname "$file" "" "."
16855a3d36dfSmrg	dir="$func_dirname_result"
1686b3062210Smrg	;;
168723a0898aSmrg
16885a3d36dfSmrg      *)
16895a3d36dfSmrg	func_warning "\`-dlopen' is ignored for non-libtool libraries and objects"
1690b3062210Smrg	continue
1691b3062210Smrg	;;
16925a3d36dfSmrg      esac
169323a0898aSmrg
16945a3d36dfSmrg      # Get the absolute pathname.
16955a3d36dfSmrg      absdir=`cd "$dir" && pwd`
16965a3d36dfSmrg      test -n "$absdir" && dir="$absdir"
16977f7f5e4eSmrg
16985a3d36dfSmrg      # Now add the directory to shlibpath_var.
16995a3d36dfSmrg      if eval "test -z \"\$$shlibpath_var\""; then
17005a3d36dfSmrg	eval "$shlibpath_var=\"\$dir\""
17015a3d36dfSmrg      else
17025a3d36dfSmrg	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
17035a3d36dfSmrg      fi
17045a3d36dfSmrg    done
17057f7f5e4eSmrg
17065a3d36dfSmrg    # This variable tells wrapper scripts just to set shlibpath_var
17075a3d36dfSmrg    # rather than running their programs.
17085a3d36dfSmrg    libtool_execute_magic="$magic"
17097f7f5e4eSmrg
17105a3d36dfSmrg    # Check if any of the arguments is a wrapper script.
17115a3d36dfSmrg    args=
17125a3d36dfSmrg    for file
17135a3d36dfSmrg    do
17145a3d36dfSmrg      case $file in
17155a3d36dfSmrg      -*) ;;
17165a3d36dfSmrg      *)
17175a3d36dfSmrg	# Do a test to see if this is really a libtool program.
17185a3d36dfSmrg	if func_ltwrapper_script_p "$file"; then
17195a3d36dfSmrg	  func_source "$file"
17205a3d36dfSmrg	  # Transform arg to wrapped name.
17215a3d36dfSmrg	  file="$progdir/$program"
17225a3d36dfSmrg	elif func_ltwrapper_executable_p "$file"; then
17235a3d36dfSmrg	  func_ltwrapper_scriptname "$file"
17245a3d36dfSmrg	  func_source "$func_ltwrapper_scriptname_result"
17255a3d36dfSmrg	  # Transform arg to wrapped name.
17265a3d36dfSmrg	  file="$progdir/$program"
17275a3d36dfSmrg	fi
17285a3d36dfSmrg	;;
17295a3d36dfSmrg      esac
17305a3d36dfSmrg      # Quote arguments (to preserve shell metacharacters).
17315a3d36dfSmrg      func_quote_for_eval "$file"
17325a3d36dfSmrg      args="$args $func_quote_for_eval_result"
17335a3d36dfSmrg    done
17347f7f5e4eSmrg
17355a3d36dfSmrg    if test "X$opt_dry_run" = Xfalse; then
17365a3d36dfSmrg      if test -n "$shlibpath_var"; then
17375a3d36dfSmrg	# Export the shlibpath_var.
17385a3d36dfSmrg	eval "export $shlibpath_var"
17395a3d36dfSmrg      fi
17407f7f5e4eSmrg
17415a3d36dfSmrg      # Restore saved environment variables
17425a3d36dfSmrg      for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
17435a3d36dfSmrg      do
17445a3d36dfSmrg	eval "if test \"\${save_$lt_var+set}\" = set; then
17455a3d36dfSmrg                $lt_var=\$save_$lt_var; export $lt_var
1746b3062210Smrg	      else
17475a3d36dfSmrg		$lt_unset $lt_var
17485a3d36dfSmrg	      fi"
17495a3d36dfSmrg      done
17507f7f5e4eSmrg
17515a3d36dfSmrg      # Now prepare to actually exec the command.
17525a3d36dfSmrg      exec_cmd="\$cmd$args"
17535a3d36dfSmrg    else
17545a3d36dfSmrg      # Display what would be done.
17555a3d36dfSmrg      if test -n "$shlibpath_var"; then
17565a3d36dfSmrg	eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
17575a3d36dfSmrg	$ECHO "export $shlibpath_var"
17585a3d36dfSmrg      fi
17595a3d36dfSmrg      $ECHO "$cmd$args"
17605a3d36dfSmrg      exit $EXIT_SUCCESS
17615a3d36dfSmrg    fi
17625a3d36dfSmrg}
17637f7f5e4eSmrg
17645a3d36dfSmrgtest "$mode" = execute && func_mode_execute ${1+"$@"}
17657f7f5e4eSmrg
1766b3062210Smrg
17675a3d36dfSmrg# func_mode_finish arg...
17685a3d36dfSmrgfunc_mode_finish ()
17695a3d36dfSmrg{
17705a3d36dfSmrg    $opt_debug
17715a3d36dfSmrg    libdirs="$nonopt"
17725a3d36dfSmrg    admincmds=
177323a0898aSmrg
17745a3d36dfSmrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
17755a3d36dfSmrg      for dir
17765a3d36dfSmrg      do
17775a3d36dfSmrg	libdirs="$libdirs $dir"
17785a3d36dfSmrg      done
177923a0898aSmrg
17805a3d36dfSmrg      for libdir in $libdirs; do
17815a3d36dfSmrg	if test -n "$finish_cmds"; then
17825a3d36dfSmrg	  # Do each command in the finish commands.
17835a3d36dfSmrg	  func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
17845a3d36dfSmrg'"$cmd"'"'
1785b3062210Smrg	fi
17865a3d36dfSmrg	if test -n "$finish_eval"; then
17875a3d36dfSmrg	  # Do the single finish_eval.
17885a3d36dfSmrg	  eval cmds=\"$finish_eval\"
17895a3d36dfSmrg	  $opt_dry_run || eval "$cmds" || admincmds="$admincmds
17905a3d36dfSmrg       $cmds"
17915a3d36dfSmrg	fi
17925a3d36dfSmrg      done
17935a3d36dfSmrg    fi
179423a0898aSmrg
17955a3d36dfSmrg    # Exit here if they wanted silent mode.
17965a3d36dfSmrg    $opt_silent && exit $EXIT_SUCCESS
179723a0898aSmrg
17985a3d36dfSmrg    $ECHO "X----------------------------------------------------------------------" | $Xsed
17995a3d36dfSmrg    $ECHO "Libraries have been installed in:"
18005a3d36dfSmrg    for libdir in $libdirs; do
18015a3d36dfSmrg      $ECHO "   $libdir"
18025a3d36dfSmrg    done
18035a3d36dfSmrg    $ECHO
18045a3d36dfSmrg    $ECHO "If you ever happen to want to link against installed libraries"
18055a3d36dfSmrg    $ECHO "in a given directory, LIBDIR, you must either use libtool, and"
18065a3d36dfSmrg    $ECHO "specify the full pathname of the library, or use the \`-LLIBDIR'"
18075a3d36dfSmrg    $ECHO "flag during linking and do at least one of the following:"
18085a3d36dfSmrg    if test -n "$shlibpath_var"; then
18095a3d36dfSmrg      $ECHO "   - add LIBDIR to the \`$shlibpath_var' environment variable"
18105a3d36dfSmrg      $ECHO "     during execution"
18115a3d36dfSmrg    fi
18125a3d36dfSmrg    if test -n "$runpath_var"; then
18135a3d36dfSmrg      $ECHO "   - add LIBDIR to the \`$runpath_var' environment variable"
18145a3d36dfSmrg      $ECHO "     during linking"
18155a3d36dfSmrg    fi
18165a3d36dfSmrg    if test -n "$hardcode_libdir_flag_spec"; then
18175a3d36dfSmrg      libdir=LIBDIR
18185a3d36dfSmrg      eval flag=\"$hardcode_libdir_flag_spec\"
18195a3d36dfSmrg
18205a3d36dfSmrg      $ECHO "   - use the \`$flag' linker flag"
18215a3d36dfSmrg    fi
18225a3d36dfSmrg    if test -n "$admincmds"; then
18235a3d36dfSmrg      $ECHO "   - have your system administrator run these commands:$admincmds"
18245a3d36dfSmrg    fi
18255a3d36dfSmrg    if test -f /etc/ld.so.conf; then
18265a3d36dfSmrg      $ECHO "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
18275a3d36dfSmrg    fi
18285a3d36dfSmrg    $ECHO
18295a3d36dfSmrg
18305a3d36dfSmrg    $ECHO "See any operating system documentation about shared libraries for"
18315a3d36dfSmrg    case $host in
18325a3d36dfSmrg      solaris2.[6789]|solaris2.1[0-9])
18335a3d36dfSmrg        $ECHO "more information, such as the ld(1), crle(1) and ld.so(8) manual"
18345a3d36dfSmrg	$ECHO "pages."
18355a3d36dfSmrg	;;
18365a3d36dfSmrg      *)
18375a3d36dfSmrg        $ECHO "more information, such as the ld(1) and ld.so(8) manual pages."
18385a3d36dfSmrg        ;;
18395a3d36dfSmrg    esac
18405a3d36dfSmrg    $ECHO "X----------------------------------------------------------------------" | $Xsed
18415a3d36dfSmrg    exit $EXIT_SUCCESS
18425a3d36dfSmrg}
18435a3d36dfSmrg
18445a3d36dfSmrgtest "$mode" = finish && func_mode_finish ${1+"$@"}
18455a3d36dfSmrg
18465a3d36dfSmrg
18475a3d36dfSmrg# func_mode_install arg...
18485a3d36dfSmrgfunc_mode_install ()
18495a3d36dfSmrg{
18505a3d36dfSmrg    $opt_debug
18515a3d36dfSmrg    # There may be an optional sh(1) argument at the beginning of
18525a3d36dfSmrg    # install_prog (especially on Windows NT).
18535a3d36dfSmrg    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
18545a3d36dfSmrg       # Allow the use of GNU shtool's install command.
18555a3d36dfSmrg       $ECHO "X$nonopt" | $GREP shtool >/dev/null; then
18565a3d36dfSmrg      # Aesthetically quote it.
18575a3d36dfSmrg      func_quote_for_eval "$nonopt"
18585a3d36dfSmrg      install_prog="$func_quote_for_eval_result "
18595a3d36dfSmrg      arg=$1
18605a3d36dfSmrg      shift
18615a3d36dfSmrg    else
18625a3d36dfSmrg      install_prog=
18635a3d36dfSmrg      arg=$nonopt
18645a3d36dfSmrg    fi
18655a3d36dfSmrg
18665a3d36dfSmrg    # The real first argument should be the name of the installation program.
18675a3d36dfSmrg    # Aesthetically quote it.
18685a3d36dfSmrg    func_quote_for_eval "$arg"
18695a3d36dfSmrg    install_prog="$install_prog$func_quote_for_eval_result"
18705a3d36dfSmrg
18715a3d36dfSmrg    # We need to accept at least all the BSD install flags.
18725a3d36dfSmrg    dest=
18735a3d36dfSmrg    files=
18745a3d36dfSmrg    opts=
18755a3d36dfSmrg    prev=
18765a3d36dfSmrg    install_type=
18775a3d36dfSmrg    isdir=no
18785a3d36dfSmrg    stripme=
18795a3d36dfSmrg    for arg
18805a3d36dfSmrg    do
18815a3d36dfSmrg      if test -n "$dest"; then
18825a3d36dfSmrg	files="$files $dest"
18835a3d36dfSmrg	dest=$arg
18845a3d36dfSmrg	continue
18855a3d36dfSmrg      fi
18865a3d36dfSmrg
18875a3d36dfSmrg      case $arg in
18885a3d36dfSmrg      -d) isdir=yes ;;
18895a3d36dfSmrg      -f)
18905a3d36dfSmrg	case " $install_prog " in
18915a3d36dfSmrg	*[\\\ /]cp\ *) ;;
18925a3d36dfSmrg	*) prev=$arg ;;
18935a3d36dfSmrg	esac
18945a3d36dfSmrg	;;
18955a3d36dfSmrg      -g | -m | -o)
18965a3d36dfSmrg	prev=$arg
18975a3d36dfSmrg	;;
18985a3d36dfSmrg      -s)
18995a3d36dfSmrg	stripme=" -s"
19005a3d36dfSmrg	continue
19015a3d36dfSmrg	;;
19025a3d36dfSmrg      -*)
19035a3d36dfSmrg	;;
19045a3d36dfSmrg      *)
19055a3d36dfSmrg	# If the previous option needed an argument, then skip it.
19065a3d36dfSmrg	if test -n "$prev"; then
1907b3062210Smrg	  prev=
19087f7f5e4eSmrg	else
19095a3d36dfSmrg	  dest=$arg
19105a3d36dfSmrg	  continue
191123a0898aSmrg	fi
1912b3062210Smrg	;;
19135a3d36dfSmrg      esac
191423a0898aSmrg
19155a3d36dfSmrg      # Aesthetically quote the argument.
19165a3d36dfSmrg      func_quote_for_eval "$arg"
19175a3d36dfSmrg      install_prog="$install_prog $func_quote_for_eval_result"
19185a3d36dfSmrg    done
191923a0898aSmrg
19205a3d36dfSmrg    test -z "$install_prog" && \
19215a3d36dfSmrg      func_fatal_help "you must specify an install program"
192223a0898aSmrg
19235a3d36dfSmrg    test -n "$prev" && \
19245a3d36dfSmrg      func_fatal_help "the \`$prev' option requires an argument"
19257f7f5e4eSmrg
19265a3d36dfSmrg    if test -z "$files"; then
19275a3d36dfSmrg      if test -z "$dest"; then
19285a3d36dfSmrg	func_fatal_help "no file or destination specified"
19295a3d36dfSmrg      else
19305a3d36dfSmrg	func_fatal_help "you must specify a destination"
19315a3d36dfSmrg      fi
1932b3062210Smrg    fi
19337f7f5e4eSmrg
19345a3d36dfSmrg    # Strip any trailing slash from the destination.
19355a3d36dfSmrg    func_stripname '' '/' "$dest"
19365a3d36dfSmrg    dest=$func_stripname_result
19377f7f5e4eSmrg
19385a3d36dfSmrg    # Check to see that the destination is a directory.
19395a3d36dfSmrg    test -d "$dest" && isdir=yes
19405a3d36dfSmrg    if test "$isdir" = yes; then
19415a3d36dfSmrg      destdir="$dest"
19425a3d36dfSmrg      destname=
1943b3062210Smrg    else
19445a3d36dfSmrg      func_dirname_and_basename "$dest" "" "."
19455a3d36dfSmrg      destdir="$func_dirname_result"
19465a3d36dfSmrg      destname="$func_basename_result"
19477f7f5e4eSmrg
19485a3d36dfSmrg      # Not a directory, so check to see that there is only one file specified.
19495a3d36dfSmrg      set dummy $files; shift
19505a3d36dfSmrg      test "$#" -gt 1 && \
19515a3d36dfSmrg	func_fatal_help "\`$dest' is not a directory"
19527f7f5e4eSmrg    fi
19535a3d36dfSmrg    case $destdir in
19545a3d36dfSmrg    [\\/]* | [A-Za-z]:[\\/]*) ;;
1955b3062210Smrg    *)
19565a3d36dfSmrg      for file in $files; do
19575a3d36dfSmrg	case $file in
19585a3d36dfSmrg	*.lo) ;;
19595a3d36dfSmrg	*)
19605a3d36dfSmrg	  func_fatal_help "\`$destdir' must be an absolute directory name"
19615a3d36dfSmrg	  ;;
19625a3d36dfSmrg	esac
19635a3d36dfSmrg      done
1964b3062210Smrg      ;;
1965b3062210Smrg    esac
196623a0898aSmrg
19675a3d36dfSmrg    # This variable tells wrapper scripts just to set variables rather
19685a3d36dfSmrg    # than running their programs.
19695a3d36dfSmrg    libtool_install_magic="$magic"
197023a0898aSmrg
19715a3d36dfSmrg    staticlibs=
19725a3d36dfSmrg    future_libdirs=
19735a3d36dfSmrg    current_libdirs=
19745a3d36dfSmrg    for file in $files; do
197523a0898aSmrg
19765a3d36dfSmrg      # Do each installation.
19775a3d36dfSmrg      case $file in
19785a3d36dfSmrg      *.$libext)
19795a3d36dfSmrg	# Do the static libraries later.
19805a3d36dfSmrg	staticlibs="$staticlibs $file"
19815a3d36dfSmrg	;;
19825a3d36dfSmrg
19835a3d36dfSmrg      *.la)
19845a3d36dfSmrg	# Check to see that this really is a libtool archive.
19855a3d36dfSmrg	func_lalib_unsafe_p "$file" \
19865a3d36dfSmrg	  || func_fatal_help "\`$file' is not a valid libtool archive"
19875a3d36dfSmrg
19885a3d36dfSmrg	library_names=
19895a3d36dfSmrg	old_library=
19905a3d36dfSmrg	relink_command=
19915a3d36dfSmrg	func_source "$file"
19925a3d36dfSmrg
19935a3d36dfSmrg	# Add the libdir to current_libdirs if it is the destination.
19945a3d36dfSmrg	if test "X$destdir" = "X$libdir"; then
19955a3d36dfSmrg	  case "$current_libdirs " in
19965a3d36dfSmrg	  *" $libdir "*) ;;
19975a3d36dfSmrg	  *) current_libdirs="$current_libdirs $libdir" ;;
19987f7f5e4eSmrg	  esac
19995a3d36dfSmrg	else
20005a3d36dfSmrg	  # Note the libdir as a future libdir.
20015a3d36dfSmrg	  case "$future_libdirs " in
20025a3d36dfSmrg	  *" $libdir "*) ;;
20035a3d36dfSmrg	  *) future_libdirs="$future_libdirs $libdir" ;;
20045a3d36dfSmrg	  esac
20055a3d36dfSmrg	fi
200623a0898aSmrg
20075a3d36dfSmrg	func_dirname "$file" "/" ""
20085a3d36dfSmrg	dir="$func_dirname_result"
20095a3d36dfSmrg	dir="$dir$objdir"
20105a3d36dfSmrg
20115a3d36dfSmrg	if test -n "$relink_command"; then
20125a3d36dfSmrg	  # Determine the prefix the user has applied to our future dir.
20135a3d36dfSmrg	  inst_prefix_dir=`$ECHO "X$destdir" | $Xsed -e "s%$libdir\$%%"`
20145a3d36dfSmrg
20155a3d36dfSmrg	  # Don't allow the user to place us outside of our expected
20165a3d36dfSmrg	  # location b/c this prevents finding dependent libraries that
20175a3d36dfSmrg	  # are installed to the same prefix.
20185a3d36dfSmrg	  # At present, this check doesn't affect windows .dll's that
20195a3d36dfSmrg	  # are installed into $libdir/../bin (currently, that works fine)
20205a3d36dfSmrg	  # but it's something to keep an eye on.
20215a3d36dfSmrg	  test "$inst_prefix_dir" = "$destdir" && \
20225a3d36dfSmrg	    func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
20235a3d36dfSmrg
20245a3d36dfSmrg	  if test -n "$inst_prefix_dir"; then
20255a3d36dfSmrg	    # Stick the inst_prefix_dir data into the link command.
20265a3d36dfSmrg	    relink_command=`$ECHO "X$relink_command" | $Xsed -e "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
20275a3d36dfSmrg	  else
20285a3d36dfSmrg	    relink_command=`$ECHO "X$relink_command" | $Xsed -e "s%@inst_prefix_dir@%%"`
20295a3d36dfSmrg	  fi
20305a3d36dfSmrg
20315a3d36dfSmrg	  func_warning "relinking \`$file'"
20325a3d36dfSmrg	  func_show_eval "$relink_command" \
20335a3d36dfSmrg	    'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
20345a3d36dfSmrg	fi
20355a3d36dfSmrg
20365a3d36dfSmrg	# See the names of the shared library.
20375a3d36dfSmrg	set dummy $library_names; shift
20385a3d36dfSmrg	if test -n "$1"; then
20395a3d36dfSmrg	  realname="$1"
20405a3d36dfSmrg	  shift
20415a3d36dfSmrg
20425a3d36dfSmrg	  srcname="$realname"
20435a3d36dfSmrg	  test -n "$relink_command" && srcname="$realname"T
20445a3d36dfSmrg
20455a3d36dfSmrg	  # Install the shared library and build the symlinks.
20465a3d36dfSmrg	  func_show_eval "$install_prog $dir/$srcname $destdir/$realname" \
20475a3d36dfSmrg	      'exit $?'
20485a3d36dfSmrg	  tstripme="$stripme"
20495a3d36dfSmrg	  case $host_os in
20505a3d36dfSmrg	  cygwin* | mingw* | pw32* | cegcc*)
20515a3d36dfSmrg	    case $realname in
20525a3d36dfSmrg	    *.dll.a)
20535a3d36dfSmrg	      tstripme=""
20545a3d36dfSmrg	      ;;
20555a3d36dfSmrg	    esac
20567f7f5e4eSmrg	    ;;
20577f7f5e4eSmrg	  esac
20585a3d36dfSmrg	  if test -n "$tstripme" && test -n "$striplib"; then
20595a3d36dfSmrg	    func_show_eval "$striplib $destdir/$realname" 'exit $?'
2060b3062210Smrg	  fi
20615a3d36dfSmrg
20625a3d36dfSmrg	  if test "$#" -gt 0; then
20635a3d36dfSmrg	    # Delete the old symlinks, and create new ones.
20645a3d36dfSmrg	    # Try `ln -sf' first, because the `ln' binary might depend on
20655a3d36dfSmrg	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
20665a3d36dfSmrg	    # so we also need to try rm && ln -s.
20675a3d36dfSmrg	    for linkname
20685a3d36dfSmrg	    do
20695a3d36dfSmrg	      test "$linkname" != "$realname" \
20705a3d36dfSmrg		&& func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
2071b3062210Smrg	    done
2072b3062210Smrg	  fi
207323a0898aSmrg
20745a3d36dfSmrg	  # Do each command in the postinstall commands.
20755a3d36dfSmrg	  lib="$destdir/$realname"
20765a3d36dfSmrg	  func_execute_cmds "$postinstall_cmds" 'exit $?'
2077b3062210Smrg	fi
207823a0898aSmrg
20795a3d36dfSmrg	# Install the pseudo-library for information purposes.
20805a3d36dfSmrg	func_basename "$file"
20815a3d36dfSmrg	name="$func_basename_result"
20825a3d36dfSmrg	instname="$dir/$name"i
20835a3d36dfSmrg	func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
208423a0898aSmrg
20855a3d36dfSmrg	# Maybe install the static library, too.
20865a3d36dfSmrg	test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library"
20875a3d36dfSmrg	;;
208823a0898aSmrg
20895a3d36dfSmrg      *.lo)
20905a3d36dfSmrg	# Install (i.e. copy) a libtool object.
209123a0898aSmrg
20925a3d36dfSmrg	# Figure out destination file name, if it wasn't already specified.
20935a3d36dfSmrg	if test -n "$destname"; then
20945a3d36dfSmrg	  destfile="$destdir/$destname"
20955a3d36dfSmrg	else
20965a3d36dfSmrg	  func_basename "$file"
20975a3d36dfSmrg	  destfile="$func_basename_result"
20985a3d36dfSmrg	  destfile="$destdir/$destfile"
2099b3062210Smrg	fi
210023a0898aSmrg
21015a3d36dfSmrg	# Deduce the name of the destination old-style object file.
21025a3d36dfSmrg	case $destfile in
21035a3d36dfSmrg	*.lo)
21045a3d36dfSmrg	  func_lo2o "$destfile"
21055a3d36dfSmrg	  staticdest=$func_lo2o_result
21065a3d36dfSmrg	  ;;
21075a3d36dfSmrg	*.$objext)
21085a3d36dfSmrg	  staticdest="$destfile"
21095a3d36dfSmrg	  destfile=
21105a3d36dfSmrg	  ;;
21115a3d36dfSmrg	*)
21125a3d36dfSmrg	  func_fatal_help "cannot copy a libtool object to \`$destfile'"
21135a3d36dfSmrg	  ;;
21145a3d36dfSmrg	esac
211523a0898aSmrg
21165a3d36dfSmrg	# Install the libtool object if requested.
21175a3d36dfSmrg	test -n "$destfile" && \
21185a3d36dfSmrg	  func_show_eval "$install_prog $file $destfile" 'exit $?'
211923a0898aSmrg
21205a3d36dfSmrg	# Install the old object if enabled.
21215a3d36dfSmrg	if test "$build_old_libs" = yes; then
21225a3d36dfSmrg	  # Deduce the name of the old-style object file.
21235a3d36dfSmrg	  func_lo2o "$file"
21245a3d36dfSmrg	  staticobj=$func_lo2o_result
21255a3d36dfSmrg	  func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
212623a0898aSmrg	fi
21275a3d36dfSmrg	exit $EXIT_SUCCESS
21285a3d36dfSmrg	;;
212923a0898aSmrg
21305a3d36dfSmrg      *)
21315a3d36dfSmrg	# Figure out destination file name, if it wasn't already specified.
21325a3d36dfSmrg	if test -n "$destname"; then
21335a3d36dfSmrg	  destfile="$destdir/$destname"
21345a3d36dfSmrg	else
21355a3d36dfSmrg	  func_basename "$file"
21365a3d36dfSmrg	  destfile="$func_basename_result"
21375a3d36dfSmrg	  destfile="$destdir/$destfile"
21385a3d36dfSmrg	fi
213923a0898aSmrg
21405a3d36dfSmrg	# If the file is missing, and there is a .exe on the end, strip it
21415a3d36dfSmrg	# because it is most likely a libtool script we actually want to
21425a3d36dfSmrg	# install
21435a3d36dfSmrg	stripped_ext=""
21445a3d36dfSmrg	case $file in
21455a3d36dfSmrg	  *.exe)
21465a3d36dfSmrg	    if test ! -f "$file"; then
21475a3d36dfSmrg	      func_stripname '' '.exe' "$file"
21485a3d36dfSmrg	      file=$func_stripname_result
21495a3d36dfSmrg	      stripped_ext=".exe"
21505a3d36dfSmrg	    fi
21515a3d36dfSmrg	    ;;
21525a3d36dfSmrg	esac
21535a3d36dfSmrg
21545a3d36dfSmrg	# Do a test to see if this is really a libtool program.
21555a3d36dfSmrg	case $host in
21565a3d36dfSmrg	*cygwin* | *mingw*)
21575a3d36dfSmrg	    if func_ltwrapper_executable_p "$file"; then
21585a3d36dfSmrg	      func_ltwrapper_scriptname "$file"
21595a3d36dfSmrg	      wrapper=$func_ltwrapper_scriptname_result
21605a3d36dfSmrg	    else
21615a3d36dfSmrg	      func_stripname '' '.exe' "$file"
21625a3d36dfSmrg	      wrapper=$func_stripname_result
21635a3d36dfSmrg	    fi
21645a3d36dfSmrg	    ;;
2165b3062210Smrg	*)
21665a3d36dfSmrg	    wrapper=$file
21675a3d36dfSmrg	    ;;
21685a3d36dfSmrg	esac
21695a3d36dfSmrg	if func_ltwrapper_script_p "$wrapper"; then
21705a3d36dfSmrg	  notinst_deplibs=
21715a3d36dfSmrg	  relink_command=
21725a3d36dfSmrg
21735a3d36dfSmrg	  func_source "$wrapper"
21745a3d36dfSmrg
21755a3d36dfSmrg	  # Check the variables that should have been set.
21765a3d36dfSmrg	  test -z "$generated_by_libtool_version" && \
21775a3d36dfSmrg	    func_fatal_error "invalid libtool wrapper script \`$wrapper'"
21785a3d36dfSmrg
21795a3d36dfSmrg	  finalize=yes
21805a3d36dfSmrg	  for lib in $notinst_deplibs; do
21815a3d36dfSmrg	    # Check to see that each library is installed.
21825a3d36dfSmrg	    libdir=
21835a3d36dfSmrg	    if test -f "$lib"; then
21845a3d36dfSmrg	      func_source "$lib"
21855a3d36dfSmrg	    fi
21865a3d36dfSmrg	    libfile="$libdir/"`$ECHO "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test
21875a3d36dfSmrg	    if test -n "$libdir" && test ! -f "$libfile"; then
21885a3d36dfSmrg	      func_warning "\`$lib' has not been installed in \`$libdir'"
21895a3d36dfSmrg	      finalize=no
21905a3d36dfSmrg	    fi
21915a3d36dfSmrg	  done
21925a3d36dfSmrg
21935a3d36dfSmrg	  relink_command=
21945a3d36dfSmrg	  func_source "$wrapper"
21955a3d36dfSmrg
21965a3d36dfSmrg	  outputname=
21975a3d36dfSmrg	  if test "$fast_install" = no && test -n "$relink_command"; then
21985a3d36dfSmrg	    $opt_dry_run || {
21995a3d36dfSmrg	      if test "$finalize" = yes; then
22005a3d36dfSmrg	        tmpdir=`func_mktempdir`
22015a3d36dfSmrg		func_basename "$file$stripped_ext"
22025a3d36dfSmrg		file="$func_basename_result"
22035a3d36dfSmrg	        outputname="$tmpdir/$file"
22045a3d36dfSmrg	        # Replace the output file specification.
22055a3d36dfSmrg	        relink_command=`$ECHO "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'`
22065a3d36dfSmrg
22075a3d36dfSmrg	        $opt_silent || {
22085a3d36dfSmrg	          func_quote_for_expand "$relink_command"
22095a3d36dfSmrg		  eval "func_echo $func_quote_for_expand_result"
22105a3d36dfSmrg	        }
22115a3d36dfSmrg	        if eval "$relink_command"; then :
22125a3d36dfSmrg	          else
22135a3d36dfSmrg		  func_error "error: relink \`$file' with the above command before installing it"
22145a3d36dfSmrg		  $opt_dry_run || ${RM}r "$tmpdir"
22155a3d36dfSmrg		  continue
22165a3d36dfSmrg	        fi
22175a3d36dfSmrg	        file="$outputname"
22185a3d36dfSmrg	      else
22195a3d36dfSmrg	        func_warning "cannot relink \`$file'"
22205a3d36dfSmrg	      fi
22215a3d36dfSmrg	    }
22225a3d36dfSmrg	  else
22235a3d36dfSmrg	    # Install the binary that we compiled earlier.
22245a3d36dfSmrg	    file=`$ECHO "X$file$stripped_ext" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"`
2225b3062210Smrg	  fi
22265a3d36dfSmrg	fi
22275a3d36dfSmrg
22285a3d36dfSmrg	# remove .exe since cygwin /usr/bin/install will append another
22295a3d36dfSmrg	# one anyway
22305a3d36dfSmrg	case $install_prog,$host in
22315a3d36dfSmrg	*/usr/bin/install*,*cygwin*)
22325a3d36dfSmrg	  case $file:$destfile in
22335a3d36dfSmrg	  *.exe:*.exe)
22345a3d36dfSmrg	    # this is ok
22355a3d36dfSmrg	    ;;
22365a3d36dfSmrg	  *.exe:*)
22375a3d36dfSmrg	    destfile=$destfile.exe
22385a3d36dfSmrg	    ;;
22395a3d36dfSmrg	  *:*.exe)
22405a3d36dfSmrg	    func_stripname '' '.exe' "$destfile"
22415a3d36dfSmrg	    destfile=$func_stripname_result
22425a3d36dfSmrg	    ;;
22435a3d36dfSmrg	  esac
2244b3062210Smrg	  ;;
2245b3062210Smrg	esac
22465a3d36dfSmrg	func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
22475a3d36dfSmrg	$opt_dry_run || if test -n "$outputname"; then
22485a3d36dfSmrg	  ${RM}r "$tmpdir"
22495a3d36dfSmrg	fi
22505a3d36dfSmrg	;;
22515a3d36dfSmrg      esac
22525a3d36dfSmrg    done
225323a0898aSmrg
22545a3d36dfSmrg    for file in $staticlibs; do
22555a3d36dfSmrg      func_basename "$file"
22565a3d36dfSmrg      name="$func_basename_result"
22575a3d36dfSmrg
22585a3d36dfSmrg      # Set up the ranlib parameters.
22595a3d36dfSmrg      oldlib="$destdir/$name"
22605a3d36dfSmrg
22615a3d36dfSmrg      func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
22625a3d36dfSmrg
22635a3d36dfSmrg      if test -n "$stripme" && test -n "$old_striplib"; then
22645a3d36dfSmrg	func_show_eval "$old_striplib $oldlib" 'exit $?'
22655a3d36dfSmrg      fi
22665a3d36dfSmrg
22675a3d36dfSmrg      # Do each command in the postinstall commands.
22685a3d36dfSmrg      func_execute_cmds "$old_postinstall_cmds" 'exit $?'
22695a3d36dfSmrg    done
22705a3d36dfSmrg
22715a3d36dfSmrg    test -n "$future_libdirs" && \
22725a3d36dfSmrg      func_warning "remember to run \`$progname --finish$future_libdirs'"
22735a3d36dfSmrg
22745a3d36dfSmrg    if test -n "$current_libdirs"; then
22755a3d36dfSmrg      # Maybe just do a dry run.
22765a3d36dfSmrg      $opt_dry_run && current_libdirs=" -n$current_libdirs"
22775a3d36dfSmrg      exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
22785a3d36dfSmrg    else
22795a3d36dfSmrg      exit $EXIT_SUCCESS
22805a3d36dfSmrg    fi
22815a3d36dfSmrg}
22825a3d36dfSmrg
22835a3d36dfSmrgtest "$mode" = install && func_mode_install ${1+"$@"}
22845a3d36dfSmrg
22855a3d36dfSmrg
22865a3d36dfSmrg# func_generate_dlsyms outputname originator pic_p
22875a3d36dfSmrg# Extract symbols from dlprefiles and create ${outputname}S.o with
22885a3d36dfSmrg# a dlpreopen symbol table.
22895a3d36dfSmrgfunc_generate_dlsyms ()
22905a3d36dfSmrg{
22915a3d36dfSmrg    $opt_debug
22925a3d36dfSmrg    my_outputname="$1"
22935a3d36dfSmrg    my_originator="$2"
22945a3d36dfSmrg    my_pic_p="${3-no}"
22955a3d36dfSmrg    my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'`
22965a3d36dfSmrg    my_dlsyms=
22975a3d36dfSmrg
22985a3d36dfSmrg    if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
22995a3d36dfSmrg      if test -n "$NM" && test -n "$global_symbol_pipe"; then
23005a3d36dfSmrg	my_dlsyms="${my_outputname}S.c"
23015a3d36dfSmrg      else
23025a3d36dfSmrg	func_error "not configured to extract global symbols from dlpreopened files"
23035a3d36dfSmrg      fi
23045a3d36dfSmrg    fi
23055a3d36dfSmrg
23065a3d36dfSmrg    if test -n "$my_dlsyms"; then
23075a3d36dfSmrg      case $my_dlsyms in
23085a3d36dfSmrg      "") ;;
23095a3d36dfSmrg      *.c)
23105a3d36dfSmrg	# Discover the nlist of each of the dlfiles.
23115a3d36dfSmrg	nlist="$output_objdir/${my_outputname}.nm"
23125a3d36dfSmrg
23135a3d36dfSmrg	func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
23145a3d36dfSmrg
23155a3d36dfSmrg	# Parse the name list into a source file.
23165a3d36dfSmrg	func_verbose "creating $output_objdir/$my_dlsyms"
23175a3d36dfSmrg
23185a3d36dfSmrg	$opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
23195a3d36dfSmrg/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */
23205a3d36dfSmrg/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */
23215a3d36dfSmrg
23225a3d36dfSmrg#ifdef __cplusplus
23235a3d36dfSmrgextern \"C\" {
23245a3d36dfSmrg#endif
23255a3d36dfSmrg
23265a3d36dfSmrg/* External symbol declarations for the compiler. */\
23275a3d36dfSmrg"
23285a3d36dfSmrg
23295a3d36dfSmrg	if test "$dlself" = yes; then
23305a3d36dfSmrg	  func_verbose "generating symbol list for \`$output'"
23315a3d36dfSmrg
23325a3d36dfSmrg	  $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
23335a3d36dfSmrg
23345a3d36dfSmrg	  # Add our own program objects to the symbol list.
23355a3d36dfSmrg	  progfiles=`$ECHO "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
23365a3d36dfSmrg	  for progfile in $progfiles; do
23375a3d36dfSmrg	    func_verbose "extracting global C symbols from \`$progfile'"
23385a3d36dfSmrg	    $opt_dry_run || eval "$NM $progfile | $global_symbol_pipe >> '$nlist'"
23395a3d36dfSmrg	  done
23405a3d36dfSmrg
23415a3d36dfSmrg	  if test -n "$exclude_expsyms"; then
23425a3d36dfSmrg	    $opt_dry_run || {
23435a3d36dfSmrg	      eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
23445a3d36dfSmrg	      eval '$MV "$nlist"T "$nlist"'
23455a3d36dfSmrg	    }
2346b3062210Smrg	  fi
23475a3d36dfSmrg
23485a3d36dfSmrg	  if test -n "$export_symbols_regex"; then
23495a3d36dfSmrg	    $opt_dry_run || {
23505a3d36dfSmrg	      eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
23515a3d36dfSmrg	      eval '$MV "$nlist"T "$nlist"'
23525a3d36dfSmrg	    }
23535a3d36dfSmrg	  fi
23545a3d36dfSmrg
23555a3d36dfSmrg	  # Prepare the list of exported symbols
23565a3d36dfSmrg	  if test -z "$export_symbols"; then
23575a3d36dfSmrg	    export_symbols="$output_objdir/$outputname.exp"
23585a3d36dfSmrg	    $opt_dry_run || {
23595a3d36dfSmrg	      $RM $export_symbols
23605a3d36dfSmrg	      eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
23615a3d36dfSmrg	      case $host in
23625a3d36dfSmrg	      *cygwin* | *mingw* | *cegcc* )
23635a3d36dfSmrg                eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
23645a3d36dfSmrg                eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
23655a3d36dfSmrg	        ;;
23665a3d36dfSmrg	      esac
23675a3d36dfSmrg	    }
2368b3062210Smrg	  else
23695a3d36dfSmrg	    $opt_dry_run || {
23705a3d36dfSmrg	      eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
23715a3d36dfSmrg	      eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
23725a3d36dfSmrg	      eval '$MV "$nlist"T "$nlist"'
23735a3d36dfSmrg	      case $host in
23745a3d36dfSmrg	        *cygwin | *mingw* | *cegcc* )
23755a3d36dfSmrg	          eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
23765a3d36dfSmrg	          eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
23775a3d36dfSmrg	          ;;
23785a3d36dfSmrg	      esac
23795a3d36dfSmrg	    }
2380b3062210Smrg	  fi
23815a3d36dfSmrg	fi
238223a0898aSmrg
23835a3d36dfSmrg	for dlprefile in $dlprefiles; do
23845a3d36dfSmrg	  func_verbose "extracting global C symbols from \`$dlprefile'"
23855a3d36dfSmrg	  func_basename "$dlprefile"
23865a3d36dfSmrg	  name="$func_basename_result"
23875a3d36dfSmrg	  $opt_dry_run || {
23885a3d36dfSmrg	    eval '$ECHO ": $name " >> "$nlist"'
23895a3d36dfSmrg	    eval "$NM $dlprefile 2>/dev/null | $global_symbol_pipe >> '$nlist'"
23905a3d36dfSmrg	  }
23915a3d36dfSmrg	done
23925a3d36dfSmrg
23935a3d36dfSmrg	$opt_dry_run || {
23945a3d36dfSmrg	  # Make sure we have at least an empty file.
23955a3d36dfSmrg	  test -f "$nlist" || : > "$nlist"
23965a3d36dfSmrg
23975a3d36dfSmrg	  if test -n "$exclude_expsyms"; then
23985a3d36dfSmrg	    $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
23995a3d36dfSmrg	    $MV "$nlist"T "$nlist"
2400b3062210Smrg	  fi
24015a3d36dfSmrg
24025a3d36dfSmrg	  # Try sorting and uniquifying the output.
24035a3d36dfSmrg	  if $GREP -v "^: " < "$nlist" |
24045a3d36dfSmrg	      if sort -k 3 </dev/null >/dev/null 2>&1; then
24055a3d36dfSmrg		sort -k 3
24065a3d36dfSmrg	      else
24075a3d36dfSmrg		sort +2
24085a3d36dfSmrg	      fi |
24095a3d36dfSmrg	      uniq > "$nlist"S; then
24105a3d36dfSmrg	    :
2411b3062210Smrg	  else
24125a3d36dfSmrg	    $GREP -v "^: " < "$nlist" > "$nlist"S
2413b3062210Smrg	  fi
241423a0898aSmrg
24155a3d36dfSmrg	  if test -f "$nlist"S; then
24165a3d36dfSmrg	    eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
2417b3062210Smrg	  else
24185a3d36dfSmrg	    $ECHO '/* NONE */' >> "$output_objdir/$my_dlsyms"
2419b3062210Smrg	  fi
242023a0898aSmrg
24215a3d36dfSmrg	  $ECHO >> "$output_objdir/$my_dlsyms" "\
242223a0898aSmrg
24235a3d36dfSmrg/* The mapping between symbol names and symbols.  */
24245a3d36dfSmrgtypedef struct {
24255a3d36dfSmrg  const char *name;
24265a3d36dfSmrg  void *address;
24275a3d36dfSmrg} lt_dlsymlist;
24285a3d36dfSmrg"
24295a3d36dfSmrg	  case $host in
24305a3d36dfSmrg	  *cygwin* | *mingw* | *cegcc* )
24315a3d36dfSmrg	    $ECHO >> "$output_objdir/$my_dlsyms" "\
24325a3d36dfSmrg/* DATA imports from DLLs on WIN32 con't be const, because
24335a3d36dfSmrg   runtime relocations are performed -- see ld's documentation
24345a3d36dfSmrg   on pseudo-relocs.  */"
24355a3d36dfSmrg	    lt_dlsym_const= ;;
24365a3d36dfSmrg	  *osf5*)
24375a3d36dfSmrg	    echo >> "$output_objdir/$my_dlsyms" "\
24385a3d36dfSmrg/* This system does not cope well with relocations in const data */"
24395a3d36dfSmrg	    lt_dlsym_const= ;;
24405a3d36dfSmrg	  *)
24415a3d36dfSmrg	    lt_dlsym_const=const ;;
24425a3d36dfSmrg	  esac
244323a0898aSmrg
24445a3d36dfSmrg	  $ECHO >> "$output_objdir/$my_dlsyms" "\
24455a3d36dfSmrgextern $lt_dlsym_const lt_dlsymlist
24465a3d36dfSmrglt_${my_prefix}_LTX_preloaded_symbols[];
24475a3d36dfSmrg$lt_dlsym_const lt_dlsymlist
24485a3d36dfSmrglt_${my_prefix}_LTX_preloaded_symbols[] =
24495a3d36dfSmrg{\
24505a3d36dfSmrg  { \"$my_originator\", (void *) 0 },"
245123a0898aSmrg
24525a3d36dfSmrg	  case $need_lib_prefix in
24535a3d36dfSmrg	  no)
24545a3d36dfSmrg	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
24555a3d36dfSmrg	    ;;
24565a3d36dfSmrg	  *)
24575a3d36dfSmrg	    eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
24585a3d36dfSmrg	    ;;
24595a3d36dfSmrg	  esac
24605a3d36dfSmrg	  $ECHO >> "$output_objdir/$my_dlsyms" "\
24615a3d36dfSmrg  {0, (void *) 0}
24625a3d36dfSmrg};
24637f7f5e4eSmrg
24645a3d36dfSmrg/* This works around a problem in FreeBSD linker */
24655a3d36dfSmrg#ifdef FREEBSD_WORKAROUND
24665a3d36dfSmrgstatic const void *lt_preloaded_setup() {
24675a3d36dfSmrg  return lt_${my_prefix}_LTX_preloaded_symbols;
24685a3d36dfSmrg}
24695a3d36dfSmrg#endif
24705a3d36dfSmrg
24715a3d36dfSmrg#ifdef __cplusplus
24725a3d36dfSmrg}
24735a3d36dfSmrg#endif\
24745a3d36dfSmrg"
24755a3d36dfSmrg	} # !$opt_dry_run
24765a3d36dfSmrg
24775a3d36dfSmrg	pic_flag_for_symtable=
24785a3d36dfSmrg	case "$compile_command " in
24795a3d36dfSmrg	*" -static "*) ;;
24805a3d36dfSmrg	*)
24815a3d36dfSmrg	  case $host in
24825a3d36dfSmrg	  # compiling the symbol table file with pic_flag works around
24835a3d36dfSmrg	  # a FreeBSD bug that causes programs to crash when -lm is
24845a3d36dfSmrg	  # linked before any other PIC object.  But we must not use
24855a3d36dfSmrg	  # pic_flag when linking with -static.  The problem exists in
24865a3d36dfSmrg	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
24875a3d36dfSmrg	  *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
24885a3d36dfSmrg	    pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
24895a3d36dfSmrg	  *-*-hpux*)
24905a3d36dfSmrg	    pic_flag_for_symtable=" $pic_flag"  ;;
24915a3d36dfSmrg	  *)
24925a3d36dfSmrg	    if test "X$my_pic_p" != Xno; then
24935a3d36dfSmrg	      pic_flag_for_symtable=" $pic_flag"
2494b3062210Smrg	    fi
24955a3d36dfSmrg	    ;;
24965a3d36dfSmrg	  esac
24975a3d36dfSmrg	  ;;
24985a3d36dfSmrg	esac
24995a3d36dfSmrg	symtab_cflags=
25005a3d36dfSmrg	for arg in $LTCFLAGS; do
25015a3d36dfSmrg	  case $arg in
25025a3d36dfSmrg	  -pie | -fpie | -fPIE) ;;
25035a3d36dfSmrg	  *) symtab_cflags="$symtab_cflags $arg" ;;
25045a3d36dfSmrg	  esac
25055a3d36dfSmrg	done
250623a0898aSmrg
25075a3d36dfSmrg	# Now compile the dynamic symbol file.
25085a3d36dfSmrg	func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
25097f7f5e4eSmrg
25105a3d36dfSmrg	# Clean up the generated files.
25115a3d36dfSmrg	func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"'
251223a0898aSmrg
25135a3d36dfSmrg	# Transform the symbol file into the correct name.
25145a3d36dfSmrg	symfileobj="$output_objdir/${my_outputname}S.$objext"
25155a3d36dfSmrg	case $host in
25165a3d36dfSmrg	*cygwin* | *mingw* | *cegcc* )
25175a3d36dfSmrg	  if test -f "$output_objdir/$my_outputname.def"; then
25185a3d36dfSmrg	    compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
25195a3d36dfSmrg	    finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
25205a3d36dfSmrg	  else
25215a3d36dfSmrg	    compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
25225a3d36dfSmrg	    finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
2523b3062210Smrg	  fi
25245a3d36dfSmrg	  ;;
25255a3d36dfSmrg	*)
25265a3d36dfSmrg	  compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
25275a3d36dfSmrg	  finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
25285a3d36dfSmrg	  ;;
25295a3d36dfSmrg	esac
25305a3d36dfSmrg	;;
25315a3d36dfSmrg      *)
25325a3d36dfSmrg	func_fatal_error "unknown suffix for \`$my_dlsyms'"
25335a3d36dfSmrg	;;
25345a3d36dfSmrg      esac
25355a3d36dfSmrg    else
25365a3d36dfSmrg      # We keep going just in case the user didn't refer to
25375a3d36dfSmrg      # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
25385a3d36dfSmrg      # really was required.
253923a0898aSmrg
25405a3d36dfSmrg      # Nullify the symbol file.
25415a3d36dfSmrg      compile_command=`$ECHO "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"`
25425a3d36dfSmrg      finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"`
25435a3d36dfSmrg    fi
25445a3d36dfSmrg}
25457f7f5e4eSmrg
25465a3d36dfSmrg# func_win32_libid arg
25475a3d36dfSmrg# return the library type of file 'arg'
25485a3d36dfSmrg#
25495a3d36dfSmrg# Need a lot of goo to handle *both* DLLs and import libs
25505a3d36dfSmrg# Has to be a shell function in order to 'eat' the argument
25515a3d36dfSmrg# that is supplied when $file_magic_command is called.
25525a3d36dfSmrgfunc_win32_libid ()
25535a3d36dfSmrg{
25545a3d36dfSmrg  $opt_debug
25555a3d36dfSmrg  win32_libid_type="unknown"
25565a3d36dfSmrg  win32_fileres=`file -L $1 2>/dev/null`
25575a3d36dfSmrg  case $win32_fileres in
25585a3d36dfSmrg  *ar\ archive\ import\ library*) # definitely import
25595a3d36dfSmrg    win32_libid_type="x86 archive import"
25605a3d36dfSmrg    ;;
25615a3d36dfSmrg  *ar\ archive*) # could be an import, or static
25625a3d36dfSmrg    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
25635a3d36dfSmrg       $EGREP 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
25645a3d36dfSmrg      win32_nmres=`eval $NM -f posix -A $1 |
25655a3d36dfSmrg	$SED -n -e '
25665a3d36dfSmrg	    1,100{
25675a3d36dfSmrg		/ I /{
25685a3d36dfSmrg		    s,.*,import,
25695a3d36dfSmrg		    p
25705a3d36dfSmrg		    q
25715a3d36dfSmrg		}
25725a3d36dfSmrg	    }'`
25735a3d36dfSmrg      case $win32_nmres in
25745a3d36dfSmrg      import*)  win32_libid_type="x86 archive import";;
25755a3d36dfSmrg      *)        win32_libid_type="x86 archive static";;
25765a3d36dfSmrg      esac
25775a3d36dfSmrg    fi
25785a3d36dfSmrg    ;;
25795a3d36dfSmrg  *DLL*)
25805a3d36dfSmrg    win32_libid_type="x86 DLL"
25815a3d36dfSmrg    ;;
25825a3d36dfSmrg  *executable*) # but shell scripts are "executable" too...
25835a3d36dfSmrg    case $win32_fileres in
25845a3d36dfSmrg    *MS\ Windows\ PE\ Intel*)
25855a3d36dfSmrg      win32_libid_type="x86 DLL"
25865a3d36dfSmrg      ;;
25875a3d36dfSmrg    esac
25885a3d36dfSmrg    ;;
25895a3d36dfSmrg  esac
25905a3d36dfSmrg  $ECHO "$win32_libid_type"
25915a3d36dfSmrg}
25927f7f5e4eSmrg
25937f7f5e4eSmrg
25947f7f5e4eSmrg
25955a3d36dfSmrg# func_extract_an_archive dir oldlib
25965a3d36dfSmrgfunc_extract_an_archive ()
25975a3d36dfSmrg{
25985a3d36dfSmrg    $opt_debug
25995a3d36dfSmrg    f_ex_an_ar_dir="$1"; shift
26005a3d36dfSmrg    f_ex_an_ar_oldlib="$1"
26015a3d36dfSmrg    func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" 'exit $?'
26025a3d36dfSmrg    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
26035a3d36dfSmrg     :
26045a3d36dfSmrg    else
26055a3d36dfSmrg      func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
26065a3d36dfSmrg    fi
26075a3d36dfSmrg}
260823a0898aSmrg
260923a0898aSmrg
26105a3d36dfSmrg# func_extract_archives gentop oldlib ...
26115a3d36dfSmrgfunc_extract_archives ()
26125a3d36dfSmrg{
26135a3d36dfSmrg    $opt_debug
26145a3d36dfSmrg    my_gentop="$1"; shift
26155a3d36dfSmrg    my_oldlibs=${1+"$@"}
26165a3d36dfSmrg    my_oldobjs=""
26175a3d36dfSmrg    my_xlib=""
26185a3d36dfSmrg    my_xabs=""
26195a3d36dfSmrg    my_xdir=""
26207f7f5e4eSmrg
26215a3d36dfSmrg    for my_xlib in $my_oldlibs; do
26225a3d36dfSmrg      # Extract the objects.
26235a3d36dfSmrg      case $my_xlib in
26245a3d36dfSmrg	[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
26255a3d36dfSmrg	*) my_xabs=`pwd`"/$my_xlib" ;;
26265a3d36dfSmrg      esac
26275a3d36dfSmrg      func_basename "$my_xlib"
26285a3d36dfSmrg      my_xlib="$func_basename_result"
26295a3d36dfSmrg      my_xlib_u=$my_xlib
26305a3d36dfSmrg      while :; do
26315a3d36dfSmrg        case " $extracted_archives " in
26325a3d36dfSmrg	*" $my_xlib_u "*)
26335a3d36dfSmrg	  func_arith $extracted_serial + 1
26345a3d36dfSmrg	  extracted_serial=$func_arith_result
26355a3d36dfSmrg	  my_xlib_u=lt$extracted_serial-$my_xlib ;;
26365a3d36dfSmrg	*) break ;;
26375a3d36dfSmrg	esac
26385a3d36dfSmrg      done
26395a3d36dfSmrg      extracted_archives="$extracted_archives $my_xlib_u"
26405a3d36dfSmrg      my_xdir="$my_gentop/$my_xlib_u"
26417f7f5e4eSmrg
26425a3d36dfSmrg      func_mkdir_p "$my_xdir"
26437f7f5e4eSmrg
26445a3d36dfSmrg      case $host in
26455a3d36dfSmrg      *-darwin*)
26465a3d36dfSmrg	func_verbose "Extracting $my_xabs"
26475a3d36dfSmrg	# Do not bother doing anything if just a dry run
26485a3d36dfSmrg	$opt_dry_run || {
26495a3d36dfSmrg	  darwin_orig_dir=`pwd`
26505a3d36dfSmrg	  cd $my_xdir || exit $?
26515a3d36dfSmrg	  darwin_archive=$my_xabs
26525a3d36dfSmrg	  darwin_curdir=`pwd`
26535a3d36dfSmrg	  darwin_base_archive=`basename "$darwin_archive"`
26545a3d36dfSmrg	  darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
26555a3d36dfSmrg	  if test -n "$darwin_arches"; then
26565a3d36dfSmrg	    darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
26575a3d36dfSmrg	    darwin_arch=
26585a3d36dfSmrg	    func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
26595a3d36dfSmrg	    for darwin_arch in  $darwin_arches ; do
26605a3d36dfSmrg	      func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
26615a3d36dfSmrg	      $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
26625a3d36dfSmrg	      cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
26635a3d36dfSmrg	      func_extract_an_archive "`pwd`" "${darwin_base_archive}"
26645a3d36dfSmrg	      cd "$darwin_curdir"
26655a3d36dfSmrg	      $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
26665a3d36dfSmrg	    done # $darwin_arches
26675a3d36dfSmrg            ## Okay now we've a bunch of thin objects, gotta fatten them up :)
26685a3d36dfSmrg	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u`
26695a3d36dfSmrg	    darwin_file=
26705a3d36dfSmrg	    darwin_files=
26715a3d36dfSmrg	    for darwin_file in $darwin_filelist; do
26725a3d36dfSmrg	      darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP`
26735a3d36dfSmrg	      $LIPO -create -output "$darwin_file" $darwin_files
26745a3d36dfSmrg	    done # $darwin_filelist
26755a3d36dfSmrg	    $RM -rf unfat-$$
26765a3d36dfSmrg	    cd "$darwin_orig_dir"
2677b3062210Smrg	  else
26785a3d36dfSmrg	    cd $darwin_orig_dir
26795a3d36dfSmrg	    func_extract_an_archive "$my_xdir" "$my_xabs"
26805a3d36dfSmrg	  fi # $darwin_arches
26815a3d36dfSmrg	} # !$opt_dry_run
26825a3d36dfSmrg	;;
26835a3d36dfSmrg      *)
26845a3d36dfSmrg        func_extract_an_archive "$my_xdir" "$my_xabs"
26855a3d36dfSmrg	;;
26865a3d36dfSmrg      esac
26875a3d36dfSmrg      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
26885a3d36dfSmrg    done
26897f7f5e4eSmrg
26905a3d36dfSmrg    func_extract_archives_result="$my_oldobjs"
26915a3d36dfSmrg}
269223a0898aSmrg
269323a0898aSmrg
26947f7f5e4eSmrg
26955a3d36dfSmrg# func_emit_wrapper_part1 [arg=no]
26965a3d36dfSmrg#
26975a3d36dfSmrg# Emit the first part of a libtool wrapper script on stdout.
26985a3d36dfSmrg# For more information, see the description associated with
26995a3d36dfSmrg# func_emit_wrapper(), below.
27005a3d36dfSmrgfunc_emit_wrapper_part1 ()
27015a3d36dfSmrg{
27025a3d36dfSmrg	func_emit_wrapper_part1_arg1=no
27035a3d36dfSmrg	if test -n "$1" ; then
27045a3d36dfSmrg	  func_emit_wrapper_part1_arg1=$1
2705b3062210Smrg	fi
2706b3062210Smrg
27075a3d36dfSmrg	$ECHO "\
27085a3d36dfSmrg#! $SHELL
27097f7f5e4eSmrg
27105a3d36dfSmrg# $output - temporary wrapper script for $objdir/$outputname
27115a3d36dfSmrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
27125a3d36dfSmrg#
27135a3d36dfSmrg# The $output program cannot be directly executed until all the libtool
27145a3d36dfSmrg# libraries that it depends on are installed.
27155a3d36dfSmrg#
27165a3d36dfSmrg# This wrapper script should never be moved out of the build directory.
27175a3d36dfSmrg# If it is, it will not operate correctly.
271823a0898aSmrg
27195a3d36dfSmrg# Sed substitution that helps us do robust quoting.  It backslashifies
27205a3d36dfSmrg# metacharacters that are still active within double-quoted strings.
27215a3d36dfSmrgXsed='${SED} -e 1s/^X//'
27225a3d36dfSmrgsed_quote_subst='$sed_quote_subst'
272323a0898aSmrg
27245a3d36dfSmrg# Be Bourne compatible
27255a3d36dfSmrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
27265a3d36dfSmrg  emulate sh
27275a3d36dfSmrg  NULLCMD=:
27285a3d36dfSmrg  # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
27295a3d36dfSmrg  # is contrary to our usage.  Disable this feature.
27305a3d36dfSmrg  alias -g '\${1+\"\$@\"}'='\"\$@\"'
27315a3d36dfSmrg  setopt NO_GLOB_SUBST
27325a3d36dfSmrgelse
27335a3d36dfSmrg  case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
27345a3d36dfSmrgfi
27355a3d36dfSmrgBIN_SH=xpg4; export BIN_SH # for Tru64
27365a3d36dfSmrgDUALCASE=1; export DUALCASE # for MKS sh
273723a0898aSmrg
27385a3d36dfSmrg# The HP-UX ksh and POSIX shell print the target directory to stdout
27395a3d36dfSmrg# if CDPATH is set.
27405a3d36dfSmrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
274123a0898aSmrg
27425a3d36dfSmrgrelink_command=\"$relink_command\"
274323a0898aSmrg
27445a3d36dfSmrg# This environment variable determines our operation mode.
27455a3d36dfSmrgif test \"\$libtool_install_magic\" = \"$magic\"; then
27465a3d36dfSmrg  # install mode needs the following variables:
27475a3d36dfSmrg  generated_by_libtool_version='$macro_version'
27485a3d36dfSmrg  notinst_deplibs='$notinst_deplibs'
27495a3d36dfSmrgelse
27505a3d36dfSmrg  # When we are sourced in execute mode, \$file and \$ECHO are already set.
27515a3d36dfSmrg  if test \"\$libtool_execute_magic\" != \"$magic\"; then
27525a3d36dfSmrg    ECHO=\"$qecho\"
27535a3d36dfSmrg    file=\"\$0\"
27545a3d36dfSmrg    # Make sure echo works.
27555a3d36dfSmrg    if test \"X\$1\" = X--no-reexec; then
27565a3d36dfSmrg      # Discard the --no-reexec flag, and continue.
27575a3d36dfSmrg      shift
27585a3d36dfSmrg    elif test \"X\`{ \$ECHO '\t'; } 2>/dev/null\`\" = 'X\t'; then
27595a3d36dfSmrg      # Yippee, \$ECHO works!
27605a3d36dfSmrg      :
27615a3d36dfSmrg    else
27625a3d36dfSmrg      # Restart under the correct shell, and then maybe \$ECHO will work.
27635a3d36dfSmrg      exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"}
27645a3d36dfSmrg    fi
27655a3d36dfSmrg  fi\
27665a3d36dfSmrg"
27675a3d36dfSmrg	$ECHO "\
276823a0898aSmrg
27695a3d36dfSmrg  # Find the directory that this script lives in.
27705a3d36dfSmrg  thisdir=\`\$ECHO \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\`
27715a3d36dfSmrg  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
277223a0898aSmrg
27735a3d36dfSmrg  # Follow symbolic links until we get to the real thisdir.
27745a3d36dfSmrg  file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\`
27755a3d36dfSmrg  while test -n \"\$file\"; do
27765a3d36dfSmrg    destdir=\`\$ECHO \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\`
277723a0898aSmrg
27785a3d36dfSmrg    # If there was a directory component, then change thisdir.
27795a3d36dfSmrg    if test \"x\$destdir\" != \"x\$file\"; then
27805a3d36dfSmrg      case \"\$destdir\" in
27815a3d36dfSmrg      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
27825a3d36dfSmrg      *) thisdir=\"\$thisdir/\$destdir\" ;;
2783b3062210Smrg      esac
27845a3d36dfSmrg    fi
278523a0898aSmrg
27865a3d36dfSmrg    file=\`\$ECHO \"X\$file\" | \$Xsed -e 's%^.*/%%'\`
27875a3d36dfSmrg    file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\`
27885a3d36dfSmrg  done
27895a3d36dfSmrg"
27905a3d36dfSmrg}
27915a3d36dfSmrg# end: func_emit_wrapper_part1
27925a3d36dfSmrg
27935a3d36dfSmrg# func_emit_wrapper_part2 [arg=no]
27945a3d36dfSmrg#
27955a3d36dfSmrg# Emit the second part of a libtool wrapper script on stdout.
27965a3d36dfSmrg# For more information, see the description associated with
27975a3d36dfSmrg# func_emit_wrapper(), below.
27985a3d36dfSmrgfunc_emit_wrapper_part2 ()
27995a3d36dfSmrg{
28005a3d36dfSmrg	func_emit_wrapper_part2_arg1=no
28015a3d36dfSmrg	if test -n "$1" ; then
28025a3d36dfSmrg	  func_emit_wrapper_part2_arg1=$1
2803b3062210Smrg	fi
280423a0898aSmrg
28055a3d36dfSmrg	$ECHO "\
280623a0898aSmrg
28075a3d36dfSmrg  # Usually 'no', except on cygwin/mingw when embedded into
28085a3d36dfSmrg  # the cwrapper.
28095a3d36dfSmrg  WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_part2_arg1
28105a3d36dfSmrg  if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
28115a3d36dfSmrg    # special case for '.'
28125a3d36dfSmrg    if test \"\$thisdir\" = \".\"; then
28135a3d36dfSmrg      thisdir=\`pwd\`
28145a3d36dfSmrg    fi
28155a3d36dfSmrg    # remove .libs from thisdir
28165a3d36dfSmrg    case \"\$thisdir\" in
28175a3d36dfSmrg    *[\\\\/]$objdir ) thisdir=\`\$ECHO \"X\$thisdir\" | \$Xsed -e 's%[\\\\/][^\\\\/]*$%%'\` ;;
28185a3d36dfSmrg    $objdir )   thisdir=. ;;
28195a3d36dfSmrg    esac
28205a3d36dfSmrg  fi
28215a3d36dfSmrg
28225a3d36dfSmrg  # Try to get the absolute directory name.
28235a3d36dfSmrg  absdir=\`cd \"\$thisdir\" && pwd\`
28245a3d36dfSmrg  test -n \"\$absdir\" && thisdir=\"\$absdir\"
28255a3d36dfSmrg"
28265a3d36dfSmrg
28275a3d36dfSmrg	if test "$fast_install" = yes; then
28285a3d36dfSmrg	  $ECHO "\
28295a3d36dfSmrg  program=lt-'$outputname'$exeext
28305a3d36dfSmrg  progdir=\"\$thisdir/$objdir\"
28315a3d36dfSmrg
28325a3d36dfSmrg  if test ! -f \"\$progdir/\$program\" ||
28335a3d36dfSmrg     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
28345a3d36dfSmrg       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
28355a3d36dfSmrg
28365a3d36dfSmrg    file=\"\$\$-\$program\"
28375a3d36dfSmrg
28385a3d36dfSmrg    if test ! -d \"\$progdir\"; then
28395a3d36dfSmrg      $MKDIR \"\$progdir\"
28405a3d36dfSmrg    else
28415a3d36dfSmrg      $RM \"\$progdir/\$file\"
28425a3d36dfSmrg    fi"
28435a3d36dfSmrg
28445a3d36dfSmrg	  $ECHO "\
28455a3d36dfSmrg
28465a3d36dfSmrg    # relink executable if necessary
28475a3d36dfSmrg    if test -n \"\$relink_command\"; then
28485a3d36dfSmrg      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
28495a3d36dfSmrg      else
28505a3d36dfSmrg	$ECHO \"\$relink_command_output\" >&2
28515a3d36dfSmrg	$RM \"\$progdir/\$file\"
28525a3d36dfSmrg	exit 1
2853b3062210Smrg      fi
28545a3d36dfSmrg    fi
285523a0898aSmrg
28565a3d36dfSmrg    $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
28575a3d36dfSmrg    { $RM \"\$progdir/\$program\";
28585a3d36dfSmrg      $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
28595a3d36dfSmrg    $RM \"\$progdir/\$file\"
28605a3d36dfSmrg  fi"
28615a3d36dfSmrg	else
28625a3d36dfSmrg	  $ECHO "\
28635a3d36dfSmrg  program='$outputname'
28645a3d36dfSmrg  progdir=\"\$thisdir/$objdir\"
28655a3d36dfSmrg"
2866b3062210Smrg	fi
286723a0898aSmrg
28685a3d36dfSmrg	$ECHO "\
286923a0898aSmrg
28705a3d36dfSmrg  if test -f \"\$progdir/\$program\"; then"
287123a0898aSmrg
28725a3d36dfSmrg	# Export our shlibpath_var if we have one.
28735a3d36dfSmrg	if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
28745a3d36dfSmrg	  $ECHO "\
28755a3d36dfSmrg    # Add our own library path to $shlibpath_var
28765a3d36dfSmrg    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
287723a0898aSmrg
28785a3d36dfSmrg    # Some systems cannot cope with colon-terminated $shlibpath_var
28795a3d36dfSmrg    # The second colon is a workaround for a bug in BeOS R4 sed
28805a3d36dfSmrg    $shlibpath_var=\`\$ECHO \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\`
28815a3d36dfSmrg
28825a3d36dfSmrg    export $shlibpath_var
28835a3d36dfSmrg"
2884b3062210Smrg	fi
288523a0898aSmrg
28865a3d36dfSmrg	# fixup the dll searchpath if we need to.
28875a3d36dfSmrg	if test -n "$dllsearchpath"; then
28885a3d36dfSmrg	  $ECHO "\
28895a3d36dfSmrg    # Add the dll search path components to the executable PATH
28905a3d36dfSmrg    PATH=$dllsearchpath:\$PATH
28915a3d36dfSmrg"
28925a3d36dfSmrg	fi
289323a0898aSmrg
28945a3d36dfSmrg	$ECHO "\
28955a3d36dfSmrg    if test \"\$libtool_execute_magic\" != \"$magic\"; then
28965a3d36dfSmrg      # Run the actual program with our arguments.
28975a3d36dfSmrg"
28985a3d36dfSmrg	case $host in
28995a3d36dfSmrg	# Backslashes separate directories on plain windows
29005a3d36dfSmrg	*-*-mingw | *-*-os2* | *-cegcc*)
29015a3d36dfSmrg	  $ECHO "\
29025a3d36dfSmrg      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
29035a3d36dfSmrg"
2904b3062210Smrg	  ;;
290523a0898aSmrg
2906b3062210Smrg	*)
29075a3d36dfSmrg	  $ECHO "\
29085a3d36dfSmrg      exec \"\$progdir/\$program\" \${1+\"\$@\"}
29095a3d36dfSmrg"
2910b3062210Smrg	  ;;
2911b3062210Smrg	esac
29125a3d36dfSmrg	$ECHO "\
29135a3d36dfSmrg      \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
29145a3d36dfSmrg      exit 1
29155a3d36dfSmrg    fi
29165a3d36dfSmrg  else
29175a3d36dfSmrg    # The program doesn't exist.
29185a3d36dfSmrg    \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
29195a3d36dfSmrg    \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
29205a3d36dfSmrg    $ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
29215a3d36dfSmrg    exit 1
29225a3d36dfSmrg  fi
29235a3d36dfSmrgfi\
29245a3d36dfSmrg"
29255a3d36dfSmrg}
29265a3d36dfSmrg# end: func_emit_wrapper_part2
292723a0898aSmrg
292823a0898aSmrg
29295a3d36dfSmrg# func_emit_wrapper [arg=no]
29305a3d36dfSmrg#
29315a3d36dfSmrg# Emit a libtool wrapper script on stdout.
29325a3d36dfSmrg# Don't directly open a file because we may want to
29335a3d36dfSmrg# incorporate the script contents within a cygwin/mingw
29345a3d36dfSmrg# wrapper executable.  Must ONLY be called from within
29355a3d36dfSmrg# func_mode_link because it depends on a number of variables
29365a3d36dfSmrg# set therein.
29375a3d36dfSmrg#
29385a3d36dfSmrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
29395a3d36dfSmrg# variable will take.  If 'yes', then the emitted script
29405a3d36dfSmrg# will assume that the directory in which it is stored is
29415a3d36dfSmrg# the $objdir directory.  This is a cygwin/mingw-specific
29425a3d36dfSmrg# behavior.
29435a3d36dfSmrgfunc_emit_wrapper ()
29445a3d36dfSmrg{
29455a3d36dfSmrg	func_emit_wrapper_arg1=no
29465a3d36dfSmrg	if test -n "$1" ; then
29475a3d36dfSmrg	  func_emit_wrapper_arg1=$1
2948b3062210Smrg	fi
294923a0898aSmrg
29505a3d36dfSmrg	# split this up so that func_emit_cwrapperexe_src
29515a3d36dfSmrg	# can call each part independently.
29525a3d36dfSmrg	func_emit_wrapper_part1 "${func_emit_wrapper_arg1}"
29535a3d36dfSmrg	func_emit_wrapper_part2 "${func_emit_wrapper_arg1}"
29545a3d36dfSmrg}
295523a0898aSmrg
295623a0898aSmrg
29575a3d36dfSmrg# func_to_host_path arg
29585a3d36dfSmrg#
29595a3d36dfSmrg# Convert paths to host format when used with build tools.
29605a3d36dfSmrg# Intended for use with "native" mingw (where libtool itself
29615a3d36dfSmrg# is running under the msys shell), or in the following cross-
29625a3d36dfSmrg# build environments:
29635a3d36dfSmrg#    $build          $host
29645a3d36dfSmrg#    mingw (msys)    mingw  [e.g. native]
29655a3d36dfSmrg#    cygwin          mingw
29665a3d36dfSmrg#    *nix + wine     mingw
29675a3d36dfSmrg# where wine is equipped with the `winepath' executable.
29685a3d36dfSmrg# In the native mingw case, the (msys) shell automatically
29695a3d36dfSmrg# converts paths for any non-msys applications it launches,
29705a3d36dfSmrg# but that facility isn't available from inside the cwrapper.
29715a3d36dfSmrg# Similar accommodations are necessary for $host mingw and
29725a3d36dfSmrg# $build cygwin.  Calling this function does no harm for other
29735a3d36dfSmrg# $host/$build combinations not listed above.
29745a3d36dfSmrg#
29755a3d36dfSmrg# ARG is the path (on $build) that should be converted to
29765a3d36dfSmrg# the proper representation for $host. The result is stored
29775a3d36dfSmrg# in $func_to_host_path_result.
29785a3d36dfSmrgfunc_to_host_path ()
29795a3d36dfSmrg{
29805a3d36dfSmrg  func_to_host_path_result="$1"
29815a3d36dfSmrg  if test -n "$1" ; then
29825a3d36dfSmrg    case $host in
29835a3d36dfSmrg      *mingw* )
29845a3d36dfSmrg        lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
29855a3d36dfSmrg        case $build in
29865a3d36dfSmrg          *mingw* ) # actually, msys
29875a3d36dfSmrg            # awkward: cmd appends spaces to result
29885a3d36dfSmrg            lt_sed_strip_trailing_spaces="s/[ ]*\$//"
29895a3d36dfSmrg            func_to_host_path_tmp1=`( cmd //c echo "$1" |\
29905a3d36dfSmrg              $SED -e "$lt_sed_strip_trailing_spaces" ) 2>/dev/null || echo ""`
29915a3d36dfSmrg            func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\
29925a3d36dfSmrg              $SED -e "$lt_sed_naive_backslashify"`
29935a3d36dfSmrg            ;;
29945a3d36dfSmrg          *cygwin* )
29955a3d36dfSmrg            func_to_host_path_tmp1=`cygpath -w "$1"`
29965a3d36dfSmrg            func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\
29975a3d36dfSmrg              $SED -e "$lt_sed_naive_backslashify"`
29985a3d36dfSmrg            ;;
29995a3d36dfSmrg          * )
30005a3d36dfSmrg            # Unfortunately, winepath does not exit with a non-zero
30015a3d36dfSmrg            # error code, so we are forced to check the contents of
30025a3d36dfSmrg            # stdout. On the other hand, if the command is not
30035a3d36dfSmrg            # found, the shell will set an exit code of 127 and print
30045a3d36dfSmrg            # *an error message* to stdout. So we must check for both
30055a3d36dfSmrg            # error code of zero AND non-empty stdout, which explains
30065a3d36dfSmrg            # the odd construction:
30075a3d36dfSmrg            func_to_host_path_tmp1=`winepath -w "$1" 2>/dev/null`
30085a3d36dfSmrg            if test "$?" -eq 0 && test -n "${func_to_host_path_tmp1}"; then
30095a3d36dfSmrg              func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\
30105a3d36dfSmrg                $SED -e "$lt_sed_naive_backslashify"`
30115a3d36dfSmrg            else
30125a3d36dfSmrg              # Allow warning below.
30135a3d36dfSmrg              func_to_host_path_result=""
30145a3d36dfSmrg            fi
30155a3d36dfSmrg            ;;
30165a3d36dfSmrg        esac
30175a3d36dfSmrg        if test -z "$func_to_host_path_result" ; then
30185a3d36dfSmrg          func_error "Could not determine host path corresponding to"
30195a3d36dfSmrg          func_error "  '$1'"
30205a3d36dfSmrg          func_error "Continuing, but uninstalled executables may not work."
30215a3d36dfSmrg          # Fallback:
30225a3d36dfSmrg          func_to_host_path_result="$1"
30235a3d36dfSmrg        fi
30245a3d36dfSmrg        ;;
30255a3d36dfSmrg    esac
30265a3d36dfSmrg  fi
30275a3d36dfSmrg}
30285a3d36dfSmrg# end: func_to_host_path
302923a0898aSmrg
30305a3d36dfSmrg# func_to_host_pathlist arg
30315a3d36dfSmrg#
30325a3d36dfSmrg# Convert pathlists to host format when used with build tools.
30335a3d36dfSmrg# See func_to_host_path(), above. This function supports the
30345a3d36dfSmrg# following $build/$host combinations (but does no harm for
30355a3d36dfSmrg# combinations not listed here):
30365a3d36dfSmrg#    $build          $host
30375a3d36dfSmrg#    mingw (msys)    mingw  [e.g. native]
30385a3d36dfSmrg#    cygwin          mingw
30395a3d36dfSmrg#    *nix + wine     mingw
30405a3d36dfSmrg#
30415a3d36dfSmrg# Path separators are also converted from $build format to
30425a3d36dfSmrg# $host format. If ARG begins or ends with a path separator
30435a3d36dfSmrg# character, it is preserved (but converted to $host format)
30445a3d36dfSmrg# on output.
30455a3d36dfSmrg#
30465a3d36dfSmrg# ARG is a pathlist (on $build) that should be converted to
30475a3d36dfSmrg# the proper representation on $host. The result is stored
30485a3d36dfSmrg# in $func_to_host_pathlist_result.
30495a3d36dfSmrgfunc_to_host_pathlist ()
30505a3d36dfSmrg{
30515a3d36dfSmrg  func_to_host_pathlist_result="$1"
30525a3d36dfSmrg  if test -n "$1" ; then
30535a3d36dfSmrg    case $host in
30545a3d36dfSmrg      *mingw* )
30555a3d36dfSmrg        lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
30565a3d36dfSmrg        # Remove leading and trailing path separator characters from
30575a3d36dfSmrg        # ARG. msys behavior is inconsistent here, cygpath turns them
30585a3d36dfSmrg        # into '.;' and ';.', and winepath ignores them completely.
30595a3d36dfSmrg        func_to_host_pathlist_tmp2="$1"
30605a3d36dfSmrg        # Once set for this call, this variable should not be
30615a3d36dfSmrg        # reassigned. It is used in tha fallback case.
30625a3d36dfSmrg        func_to_host_pathlist_tmp1=`echo "$func_to_host_pathlist_tmp2" |\
30635a3d36dfSmrg          $SED -e 's|^:*||' -e 's|:*$||'`
30645a3d36dfSmrg        case $build in
30655a3d36dfSmrg          *mingw* ) # Actually, msys.
30665a3d36dfSmrg            # Awkward: cmd appends spaces to result.
30675a3d36dfSmrg            lt_sed_strip_trailing_spaces="s/[ ]*\$//"
30685a3d36dfSmrg            func_to_host_pathlist_tmp2=`( cmd //c echo "$func_to_host_pathlist_tmp1" |\
30695a3d36dfSmrg              $SED -e "$lt_sed_strip_trailing_spaces" ) 2>/dev/null || echo ""`
30705a3d36dfSmrg            func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp2" |\
30715a3d36dfSmrg              $SED -e "$lt_sed_naive_backslashify"`
30725a3d36dfSmrg            ;;
30735a3d36dfSmrg          *cygwin* )
30745a3d36dfSmrg            func_to_host_pathlist_tmp2=`cygpath -w -p "$func_to_host_pathlist_tmp1"`
30755a3d36dfSmrg            func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp2" |\
30765a3d36dfSmrg              $SED -e "$lt_sed_naive_backslashify"`
30775a3d36dfSmrg            ;;
30785a3d36dfSmrg          * )
30795a3d36dfSmrg            # unfortunately, winepath doesn't convert pathlists
30805a3d36dfSmrg            func_to_host_pathlist_result=""
30815a3d36dfSmrg            func_to_host_pathlist_oldIFS=$IFS
30825a3d36dfSmrg            IFS=:
30835a3d36dfSmrg            for func_to_host_pathlist_f in $func_to_host_pathlist_tmp1 ; do
30845a3d36dfSmrg              IFS=$func_to_host_pathlist_oldIFS
30855a3d36dfSmrg              if test -n "$func_to_host_pathlist_f" ; then
30865a3d36dfSmrg                func_to_host_path "$func_to_host_pathlist_f"
30875a3d36dfSmrg                if test -n "$func_to_host_path_result" ; then
30885a3d36dfSmrg                  if test -z "$func_to_host_pathlist_result" ; then
30895a3d36dfSmrg                    func_to_host_pathlist_result="$func_to_host_path_result"
30905a3d36dfSmrg                  else
30915a3d36dfSmrg                    func_to_host_pathlist_result="$func_to_host_pathlist_result;$func_to_host_path_result"
30925a3d36dfSmrg                  fi
30935a3d36dfSmrg                fi
30945a3d36dfSmrg              fi
30955a3d36dfSmrg              IFS=:
30965a3d36dfSmrg            done
30975a3d36dfSmrg            IFS=$func_to_host_pathlist_oldIFS
30985a3d36dfSmrg            ;;
30995a3d36dfSmrg        esac
31005a3d36dfSmrg        if test -z "$func_to_host_pathlist_result" ; then
31015a3d36dfSmrg          func_error "Could not determine the host path(s) corresponding to"
31025a3d36dfSmrg          func_error "  '$1'"
31035a3d36dfSmrg          func_error "Continuing, but uninstalled executables may not work."
31045a3d36dfSmrg          # Fallback. This may break if $1 contains DOS-style drive
31055a3d36dfSmrg          # specifications. The fix is not to complicate the expression
31065a3d36dfSmrg          # below, but for the user to provide a working wine installation
31075a3d36dfSmrg          # with winepath so that path translation in the cross-to-mingw
31085a3d36dfSmrg          # case works properly.
31095a3d36dfSmrg          lt_replace_pathsep_nix_to_dos="s|:|;|g"
31105a3d36dfSmrg          func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp1" |\
31115a3d36dfSmrg            $SED -e "$lt_replace_pathsep_nix_to_dos"`
31125a3d36dfSmrg        fi
31135a3d36dfSmrg        # Now, add the leading and trailing path separators back
31145a3d36dfSmrg        case "$1" in
31155a3d36dfSmrg          :* ) func_to_host_pathlist_result=";$func_to_host_pathlist_result"
31165a3d36dfSmrg            ;;
31175a3d36dfSmrg        esac
31185a3d36dfSmrg        case "$1" in
31195a3d36dfSmrg          *: ) func_to_host_pathlist_result="$func_to_host_pathlist_result;"
31205a3d36dfSmrg            ;;
31215a3d36dfSmrg        esac
31225a3d36dfSmrg        ;;
31235a3d36dfSmrg    esac
31245a3d36dfSmrg  fi
31255a3d36dfSmrg}
31265a3d36dfSmrg# end: func_to_host_pathlist
312723a0898aSmrg
31285a3d36dfSmrg# func_emit_cwrapperexe_src
31295a3d36dfSmrg# emit the source code for a wrapper executable on stdout
31305a3d36dfSmrg# Must ONLY be called from within func_mode_link because
31315a3d36dfSmrg# it depends on a number of variable set therein.
31325a3d36dfSmrgfunc_emit_cwrapperexe_src ()
31335a3d36dfSmrg{
31345a3d36dfSmrg	cat <<EOF
313523a0898aSmrg
31365a3d36dfSmrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
31375a3d36dfSmrg   Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
313823a0898aSmrg
31395a3d36dfSmrg   The $output program cannot be directly executed until all the libtool
31405a3d36dfSmrg   libraries that it depends on are installed.
314123a0898aSmrg
31425a3d36dfSmrg   This wrapper executable should never be moved out of the build directory.
31435a3d36dfSmrg   If it is, it will not operate correctly.
314423a0898aSmrg
31455a3d36dfSmrg   Currently, it simply execs the wrapper *script* "$SHELL $output",
31465a3d36dfSmrg   but could eventually absorb all of the scripts functionality and
31475a3d36dfSmrg   exec $objdir/$outputname directly.
31485a3d36dfSmrg*/
31495a3d36dfSmrgEOF
31505a3d36dfSmrg	    cat <<"EOF"
31515a3d36dfSmrg#include <stdio.h>
31525a3d36dfSmrg#include <stdlib.h>
31535a3d36dfSmrg#ifdef _MSC_VER
31545a3d36dfSmrg# include <direct.h>
31555a3d36dfSmrg# include <process.h>
31565a3d36dfSmrg# include <io.h>
31575a3d36dfSmrg# define setmode _setmode
31585a3d36dfSmrg#else
31595a3d36dfSmrg# include <unistd.h>
31605a3d36dfSmrg# include <stdint.h>
31615a3d36dfSmrg# ifdef __CYGWIN__
31625a3d36dfSmrg#  include <io.h>
31635a3d36dfSmrg#  define HAVE_SETENV
31645a3d36dfSmrg#  ifdef __STRICT_ANSI__
31655a3d36dfSmrgchar *realpath (const char *, char *);
31665a3d36dfSmrgint putenv (char *);
31675a3d36dfSmrgint setenv (const char *, const char *, int);
31685a3d36dfSmrg#  endif
31695a3d36dfSmrg# endif
31705a3d36dfSmrg#endif
31715a3d36dfSmrg#include <malloc.h>
31725a3d36dfSmrg#include <stdarg.h>
31735a3d36dfSmrg#include <assert.h>
31745a3d36dfSmrg#include <string.h>
31755a3d36dfSmrg#include <ctype.h>
31765a3d36dfSmrg#include <errno.h>
31775a3d36dfSmrg#include <fcntl.h>
31785a3d36dfSmrg#include <sys/stat.h>
31797f7f5e4eSmrg
31805a3d36dfSmrg#if defined(PATH_MAX)
31815a3d36dfSmrg# define LT_PATHMAX PATH_MAX
31825a3d36dfSmrg#elif defined(MAXPATHLEN)
31835a3d36dfSmrg# define LT_PATHMAX MAXPATHLEN
31845a3d36dfSmrg#else
31855a3d36dfSmrg# define LT_PATHMAX 1024
31865a3d36dfSmrg#endif
31877f7f5e4eSmrg
31885a3d36dfSmrg#ifndef S_IXOTH
31895a3d36dfSmrg# define S_IXOTH 0
31905a3d36dfSmrg#endif
31915a3d36dfSmrg#ifndef S_IXGRP
31925a3d36dfSmrg# define S_IXGRP 0
31935a3d36dfSmrg#endif
31947f7f5e4eSmrg
31955a3d36dfSmrg#ifdef _MSC_VER
31965a3d36dfSmrg# define S_IXUSR _S_IEXEC
31975a3d36dfSmrg# define stat _stat
31985a3d36dfSmrg# ifndef _INTPTR_T_DEFINED
31995a3d36dfSmrg#  define intptr_t int
32005a3d36dfSmrg# endif
32015a3d36dfSmrg#endif
32027f7f5e4eSmrg
32035a3d36dfSmrg#ifndef DIR_SEPARATOR
32045a3d36dfSmrg# define DIR_SEPARATOR '/'
32055a3d36dfSmrg# define PATH_SEPARATOR ':'
32065a3d36dfSmrg#endif
32077f7f5e4eSmrg
32085a3d36dfSmrg#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
32095a3d36dfSmrg  defined (__OS2__)
32105a3d36dfSmrg# define HAVE_DOS_BASED_FILE_SYSTEM
32115a3d36dfSmrg# define FOPEN_WB "wb"
32125a3d36dfSmrg# ifndef DIR_SEPARATOR_2
32135a3d36dfSmrg#  define DIR_SEPARATOR_2 '\\'
32145a3d36dfSmrg# endif
32155a3d36dfSmrg# ifndef PATH_SEPARATOR_2
32165a3d36dfSmrg#  define PATH_SEPARATOR_2 ';'
32175a3d36dfSmrg# endif
32185a3d36dfSmrg#endif
32197f7f5e4eSmrg
32205a3d36dfSmrg#ifndef DIR_SEPARATOR_2
32215a3d36dfSmrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
32225a3d36dfSmrg#else /* DIR_SEPARATOR_2 */
32235a3d36dfSmrg# define IS_DIR_SEPARATOR(ch) \
32245a3d36dfSmrg	(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
32255a3d36dfSmrg#endif /* DIR_SEPARATOR_2 */
322623a0898aSmrg
32275a3d36dfSmrg#ifndef PATH_SEPARATOR_2
32285a3d36dfSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
32295a3d36dfSmrg#else /* PATH_SEPARATOR_2 */
32305a3d36dfSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
32315a3d36dfSmrg#endif /* PATH_SEPARATOR_2 */
323223a0898aSmrg
32335a3d36dfSmrg#ifdef __CYGWIN__
32345a3d36dfSmrg# define FOPEN_WB "wb"
32355a3d36dfSmrg#endif
323623a0898aSmrg
32375a3d36dfSmrg#ifndef FOPEN_WB
32385a3d36dfSmrg# define FOPEN_WB "w"
32395a3d36dfSmrg#endif
32405a3d36dfSmrg#ifndef _O_BINARY
32415a3d36dfSmrg# define _O_BINARY 0
32425a3d36dfSmrg#endif
324323a0898aSmrg
32445a3d36dfSmrg#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
32455a3d36dfSmrg#define XFREE(stale) do { \
32465a3d36dfSmrg  if (stale) { free ((void *) stale); stale = 0; } \
32475a3d36dfSmrg} while (0)
324823a0898aSmrg
32495a3d36dfSmrg#undef LTWRAPPER_DEBUGPRINTF
32505a3d36dfSmrg#if defined DEBUGWRAPPER
32515a3d36dfSmrg# define LTWRAPPER_DEBUGPRINTF(args) ltwrapper_debugprintf args
32525a3d36dfSmrgstatic void
32535a3d36dfSmrgltwrapper_debugprintf (const char *fmt, ...)
32545a3d36dfSmrg{
32555a3d36dfSmrg    va_list args;
32565a3d36dfSmrg    va_start (args, fmt);
32575a3d36dfSmrg    (void) vfprintf (stderr, fmt, args);
32585a3d36dfSmrg    va_end (args);
32595a3d36dfSmrg}
32605a3d36dfSmrg#else
32615a3d36dfSmrg# define LTWRAPPER_DEBUGPRINTF(args)
32625a3d36dfSmrg#endif
326323a0898aSmrg
32645a3d36dfSmrgconst char *program_name = NULL;
326523a0898aSmrg
32665a3d36dfSmrgvoid *xmalloc (size_t num);
32675a3d36dfSmrgchar *xstrdup (const char *string);
32685a3d36dfSmrgconst char *base_name (const char *name);
32695a3d36dfSmrgchar *find_executable (const char *wrapper);
32705a3d36dfSmrgchar *chase_symlinks (const char *pathspec);
32715a3d36dfSmrgint make_executable (const char *path);
32725a3d36dfSmrgint check_executable (const char *path);
32735a3d36dfSmrgchar *strendzap (char *str, const char *pat);
32745a3d36dfSmrgvoid lt_fatal (const char *message, ...);
32755a3d36dfSmrgvoid lt_setenv (const char *name, const char *value);
32765a3d36dfSmrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end);
32775a3d36dfSmrgvoid lt_opt_process_env_set (const char *arg);
32785a3d36dfSmrgvoid lt_opt_process_env_prepend (const char *arg);
32795a3d36dfSmrgvoid lt_opt_process_env_append (const char *arg);
32805a3d36dfSmrgint lt_split_name_value (const char *arg, char** name, char** value);
32815a3d36dfSmrgvoid lt_update_exe_path (const char *name, const char *value);
32825a3d36dfSmrgvoid lt_update_lib_path (const char *name, const char *value);
32835a3d36dfSmrg
32845a3d36dfSmrgstatic const char *script_text_part1 =
32855a3d36dfSmrgEOF
328623a0898aSmrg
32875a3d36dfSmrg	    func_emit_wrapper_part1 yes |
32885a3d36dfSmrg	        $SED -e 's/\([\\"]\)/\\\1/g' \
32895a3d36dfSmrg	             -e 's/^/  "/' -e 's/$/\\n"/'
32905a3d36dfSmrg	    echo ";"
32915a3d36dfSmrg	    cat <<EOF
329223a0898aSmrg
32935a3d36dfSmrgstatic const char *script_text_part2 =
32945a3d36dfSmrgEOF
32955a3d36dfSmrg	    func_emit_wrapper_part2 yes |
32965a3d36dfSmrg	        $SED -e 's/\([\\"]\)/\\\1/g' \
32975a3d36dfSmrg	             -e 's/^/  "/' -e 's/$/\\n"/'
32985a3d36dfSmrg	    echo ";"
32995a3d36dfSmrg
33005a3d36dfSmrg	    cat <<EOF
33015a3d36dfSmrgconst char * MAGIC_EXE = "$magic_exe";
33025a3d36dfSmrgconst char * LIB_PATH_VARNAME = "$shlibpath_var";
33035a3d36dfSmrgEOF
330423a0898aSmrg
33055a3d36dfSmrg	    if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
33065a3d36dfSmrg              func_to_host_pathlist "$temp_rpath"
33075a3d36dfSmrg	      cat <<EOF
33085a3d36dfSmrgconst char * LIB_PATH_VALUE   = "$func_to_host_pathlist_result";
33095a3d36dfSmrgEOF
33105a3d36dfSmrg	    else
33115a3d36dfSmrg	      cat <<"EOF"
33125a3d36dfSmrgconst char * LIB_PATH_VALUE   = "";
33135a3d36dfSmrgEOF
3314b3062210Smrg	    fi
331523a0898aSmrg
33165a3d36dfSmrg	    if test -n "$dllsearchpath"; then
33175a3d36dfSmrg              func_to_host_pathlist "$dllsearchpath:"
33185a3d36dfSmrg	      cat <<EOF
33195a3d36dfSmrgconst char * EXE_PATH_VARNAME = "PATH";
33205a3d36dfSmrgconst char * EXE_PATH_VALUE   = "$func_to_host_pathlist_result";
3321b3062210SmrgEOF
3322b3062210Smrg	    else
33235a3d36dfSmrg	      cat <<"EOF"
33245a3d36dfSmrgconst char * EXE_PATH_VARNAME = "";
33255a3d36dfSmrgconst char * EXE_PATH_VALUE   = "";
33265a3d36dfSmrgEOF
3327b3062210Smrg	    fi
33285a3d36dfSmrg
33295a3d36dfSmrg	    if test "$fast_install" = yes; then
33305a3d36dfSmrg	      cat <<EOF
33315a3d36dfSmrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
33325a3d36dfSmrgEOF
3333b3062210Smrg	    else
33345a3d36dfSmrg	      cat <<EOF
33355a3d36dfSmrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
33365a3d36dfSmrgEOF
3337b3062210Smrg	    fi
333823a0898aSmrg
333923a0898aSmrg
33405a3d36dfSmrg	    cat <<"EOF"
334123a0898aSmrg
33425a3d36dfSmrg#define LTWRAPPER_OPTION_PREFIX         "--lt-"
33435a3d36dfSmrg#define LTWRAPPER_OPTION_PREFIX_LENGTH  5
334423a0898aSmrg
33455a3d36dfSmrgstatic const size_t opt_prefix_len         = LTWRAPPER_OPTION_PREFIX_LENGTH;
33465a3d36dfSmrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
334723a0898aSmrg
33485a3d36dfSmrgstatic const char *dumpscript_opt       = LTWRAPPER_OPTION_PREFIX "dump-script";
334923a0898aSmrg
33505a3d36dfSmrgstatic const size_t env_set_opt_len     = LTWRAPPER_OPTION_PREFIX_LENGTH + 7;
33515a3d36dfSmrgstatic const char *env_set_opt          = LTWRAPPER_OPTION_PREFIX "env-set";
33525a3d36dfSmrg  /* argument is putenv-style "foo=bar", value of foo is set to bar */
335323a0898aSmrg
33545a3d36dfSmrgstatic const size_t env_prepend_opt_len = LTWRAPPER_OPTION_PREFIX_LENGTH + 11;
33555a3d36dfSmrgstatic const char *env_prepend_opt      = LTWRAPPER_OPTION_PREFIX "env-prepend";
33565a3d36dfSmrg  /* argument is putenv-style "foo=bar", new value of foo is bar${foo} */
335723a0898aSmrg
33585a3d36dfSmrgstatic const size_t env_append_opt_len  = LTWRAPPER_OPTION_PREFIX_LENGTH + 10;
33595a3d36dfSmrgstatic const char *env_append_opt       = LTWRAPPER_OPTION_PREFIX "env-append";
33605a3d36dfSmrg  /* argument is putenv-style "foo=bar", new value of foo is ${foo}bar */
336123a0898aSmrg
33625a3d36dfSmrgint
33635a3d36dfSmrgmain (int argc, char *argv[])
33645a3d36dfSmrg{
33655a3d36dfSmrg  char **newargz;
33665a3d36dfSmrg  int  newargc;
33675a3d36dfSmrg  char *tmp_pathspec;
33685a3d36dfSmrg  char *actual_cwrapper_path;
33695a3d36dfSmrg  char *actual_cwrapper_name;
33705a3d36dfSmrg  char *target_name;
33715a3d36dfSmrg  char *lt_argv_zero;
33725a3d36dfSmrg  intptr_t rval = 127;
337323a0898aSmrg
33745a3d36dfSmrg  int i;
337523a0898aSmrg
33765a3d36dfSmrg  program_name = (char *) xstrdup (base_name (argv[0]));
33775a3d36dfSmrg  LTWRAPPER_DEBUGPRINTF (("(main) argv[0]      : %s\n", argv[0]));
33785a3d36dfSmrg  LTWRAPPER_DEBUGPRINTF (("(main) program_name : %s\n", program_name));
337923a0898aSmrg
33805a3d36dfSmrg  /* very simple arg parsing; don't want to rely on getopt */
33815a3d36dfSmrg  for (i = 1; i < argc; i++)
33825a3d36dfSmrg    {
33835a3d36dfSmrg      if (strcmp (argv[i], dumpscript_opt) == 0)
33845a3d36dfSmrg	{
33855a3d36dfSmrgEOF
33865a3d36dfSmrg	    case "$host" in
33875a3d36dfSmrg	      *mingw* | *cygwin* )
33885a3d36dfSmrg		# make stdout use "unix" line endings
33895a3d36dfSmrg		echo "          setmode(1,_O_BINARY);"
33905a3d36dfSmrg		;;
33915a3d36dfSmrg	      esac
339223a0898aSmrg
33935a3d36dfSmrg	    cat <<"EOF"
33945a3d36dfSmrg	  printf ("%s", script_text_part1);
33955a3d36dfSmrg	  printf ("%s", script_text_part2);
33965a3d36dfSmrg	  return 0;
33975a3d36dfSmrg	}
33985a3d36dfSmrg    }
339923a0898aSmrg
34005a3d36dfSmrg  newargz = XMALLOC (char *, argc + 1);
34015a3d36dfSmrg  tmp_pathspec = find_executable (argv[0]);
34025a3d36dfSmrg  if (tmp_pathspec == NULL)
34035a3d36dfSmrg    lt_fatal ("Couldn't find %s", argv[0]);
34045a3d36dfSmrg  LTWRAPPER_DEBUGPRINTF (("(main) found exe (before symlink chase) at : %s\n",
34055a3d36dfSmrg			  tmp_pathspec));
34065a3d36dfSmrg
34075a3d36dfSmrg  actual_cwrapper_path = chase_symlinks (tmp_pathspec);
34085a3d36dfSmrg  LTWRAPPER_DEBUGPRINTF (("(main) found exe (after symlink chase) at : %s\n",
34095a3d36dfSmrg			  actual_cwrapper_path));
34105a3d36dfSmrg  XFREE (tmp_pathspec);
34115a3d36dfSmrg
34125a3d36dfSmrg  actual_cwrapper_name = xstrdup( base_name (actual_cwrapper_path));
34135a3d36dfSmrg  strendzap (actual_cwrapper_path, actual_cwrapper_name);
34145a3d36dfSmrg
34155a3d36dfSmrg  /* wrapper name transforms */
34165a3d36dfSmrg  strendzap (actual_cwrapper_name, ".exe");
34175a3d36dfSmrg  tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
34185a3d36dfSmrg  XFREE (actual_cwrapper_name);
34195a3d36dfSmrg  actual_cwrapper_name = tmp_pathspec;
34205a3d36dfSmrg  tmp_pathspec = 0;
34215a3d36dfSmrg
34225a3d36dfSmrg  /* target_name transforms -- use actual target program name; might have lt- prefix */
34235a3d36dfSmrg  target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
34245a3d36dfSmrg  strendzap (target_name, ".exe");
34255a3d36dfSmrg  tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
34265a3d36dfSmrg  XFREE (target_name);
34275a3d36dfSmrg  target_name = tmp_pathspec;
34285a3d36dfSmrg  tmp_pathspec = 0;
34295a3d36dfSmrg
34305a3d36dfSmrg  LTWRAPPER_DEBUGPRINTF (("(main) libtool target name: %s\n",
34315a3d36dfSmrg			  target_name));
34325a3d36dfSmrgEOF
343323a0898aSmrg
34345a3d36dfSmrg	    cat <<EOF
34355a3d36dfSmrg  newargz[0] =
34365a3d36dfSmrg    XMALLOC (char, (strlen (actual_cwrapper_path) +
34375a3d36dfSmrg		    strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
34385a3d36dfSmrg  strcpy (newargz[0], actual_cwrapper_path);
34395a3d36dfSmrg  strcat (newargz[0], "$objdir");
34405a3d36dfSmrg  strcat (newargz[0], "/");
34415a3d36dfSmrgEOF
344223a0898aSmrg
34435a3d36dfSmrg	    cat <<"EOF"
34445a3d36dfSmrg  /* stop here, and copy so we don't have to do this twice */
34455a3d36dfSmrg  tmp_pathspec = xstrdup (newargz[0]);
344623a0898aSmrg
34475a3d36dfSmrg  /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
34485a3d36dfSmrg  strcat (newargz[0], actual_cwrapper_name);
344923a0898aSmrg
34505a3d36dfSmrg  /* DO want the lt- prefix here if it exists, so use target_name */
34515a3d36dfSmrg  lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
34525a3d36dfSmrg  XFREE (tmp_pathspec);
34535a3d36dfSmrg  tmp_pathspec = NULL;
34545a3d36dfSmrgEOF
345523a0898aSmrg
34565a3d36dfSmrg	    case $host_os in
34575a3d36dfSmrg	      mingw*)
34585a3d36dfSmrg	    cat <<"EOF"
34595a3d36dfSmrg  {
34605a3d36dfSmrg    char* p;
34615a3d36dfSmrg    while ((p = strchr (newargz[0], '\\')) != NULL)
34625a3d36dfSmrg      {
34635a3d36dfSmrg	*p = '/';
34645a3d36dfSmrg      }
34655a3d36dfSmrg    while ((p = strchr (lt_argv_zero, '\\')) != NULL)
34665a3d36dfSmrg      {
34675a3d36dfSmrg	*p = '/';
34685a3d36dfSmrg      }
34695a3d36dfSmrg  }
34705a3d36dfSmrgEOF
34715a3d36dfSmrg	    ;;
34725a3d36dfSmrg	    esac
347323a0898aSmrg
34745a3d36dfSmrg	    cat <<"EOF"
34755a3d36dfSmrg  XFREE (target_name);
34765a3d36dfSmrg  XFREE (actual_cwrapper_path);
34775a3d36dfSmrg  XFREE (actual_cwrapper_name);
347823a0898aSmrg
34795a3d36dfSmrg  lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
34805a3d36dfSmrg  lt_setenv ("DUALCASE", "1");  /* for MSK sh */
34815a3d36dfSmrg  lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
34825a3d36dfSmrg  lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
348323a0898aSmrg
34845a3d36dfSmrg  newargc=0;
34855a3d36dfSmrg  for (i = 1; i < argc; i++)
34865a3d36dfSmrg    {
34875a3d36dfSmrg      if (strncmp (argv[i], env_set_opt, env_set_opt_len) == 0)
34885a3d36dfSmrg        {
34895a3d36dfSmrg          if (argv[i][env_set_opt_len] == '=')
34905a3d36dfSmrg            {
34915a3d36dfSmrg              const char *p = argv[i] + env_set_opt_len + 1;
34925a3d36dfSmrg              lt_opt_process_env_set (p);
34935a3d36dfSmrg            }
34945a3d36dfSmrg          else if (argv[i][env_set_opt_len] == '\0' && i + 1 < argc)
34955a3d36dfSmrg            {
34965a3d36dfSmrg              lt_opt_process_env_set (argv[++i]); /* don't copy */
34975a3d36dfSmrg            }
34985a3d36dfSmrg          else
34995a3d36dfSmrg            lt_fatal ("%s missing required argument", env_set_opt);
35005a3d36dfSmrg          continue;
35015a3d36dfSmrg        }
35025a3d36dfSmrg      if (strncmp (argv[i], env_prepend_opt, env_prepend_opt_len) == 0)
35035a3d36dfSmrg        {
35045a3d36dfSmrg          if (argv[i][env_prepend_opt_len] == '=')
35055a3d36dfSmrg            {
35065a3d36dfSmrg              const char *p = argv[i] + env_prepend_opt_len + 1;
35075a3d36dfSmrg              lt_opt_process_env_prepend (p);
35085a3d36dfSmrg            }
35095a3d36dfSmrg          else if (argv[i][env_prepend_opt_len] == '\0' && i + 1 < argc)
35105a3d36dfSmrg            {
35115a3d36dfSmrg              lt_opt_process_env_prepend (argv[++i]); /* don't copy */
35125a3d36dfSmrg            }
35135a3d36dfSmrg          else
35145a3d36dfSmrg            lt_fatal ("%s missing required argument", env_prepend_opt);
35155a3d36dfSmrg          continue;
35165a3d36dfSmrg        }
35175a3d36dfSmrg      if (strncmp (argv[i], env_append_opt, env_append_opt_len) == 0)
35185a3d36dfSmrg        {
35195a3d36dfSmrg          if (argv[i][env_append_opt_len] == '=')
35205a3d36dfSmrg            {
35215a3d36dfSmrg              const char *p = argv[i] + env_append_opt_len + 1;
35225a3d36dfSmrg              lt_opt_process_env_append (p);
35235a3d36dfSmrg            }
35245a3d36dfSmrg          else if (argv[i][env_append_opt_len] == '\0' && i + 1 < argc)
35255a3d36dfSmrg            {
35265a3d36dfSmrg              lt_opt_process_env_append (argv[++i]); /* don't copy */
35275a3d36dfSmrg            }
35285a3d36dfSmrg          else
35295a3d36dfSmrg            lt_fatal ("%s missing required argument", env_append_opt);
35305a3d36dfSmrg          continue;
35315a3d36dfSmrg        }
35325a3d36dfSmrg      if (strncmp (argv[i], ltwrapper_option_prefix, opt_prefix_len) == 0)
35335a3d36dfSmrg        {
35345a3d36dfSmrg          /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
35355a3d36dfSmrg             namespace, but it is not one of the ones we know about and
35365a3d36dfSmrg             have already dealt with, above (inluding dump-script), then
35375a3d36dfSmrg             report an error. Otherwise, targets might begin to believe
35385a3d36dfSmrg             they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
35395a3d36dfSmrg             namespace. The first time any user complains about this, we'll
35405a3d36dfSmrg             need to make LTWRAPPER_OPTION_PREFIX a configure-time option
35415a3d36dfSmrg             or a configure.ac-settable value.
35425a3d36dfSmrg           */
35435a3d36dfSmrg          lt_fatal ("Unrecognized option in %s namespace: '%s'",
35445a3d36dfSmrg                    ltwrapper_option_prefix, argv[i]);
35455a3d36dfSmrg        }
35465a3d36dfSmrg      /* otherwise ... */
35475a3d36dfSmrg      newargz[++newargc] = xstrdup (argv[i]);
35485a3d36dfSmrg    }
35495a3d36dfSmrg  newargz[++newargc] = NULL;
355023a0898aSmrg
35515a3d36dfSmrg  LTWRAPPER_DEBUGPRINTF     (("(main) lt_argv_zero : %s\n", (lt_argv_zero ? lt_argv_zero : "<NULL>")));
35525a3d36dfSmrg  for (i = 0; i < newargc; i++)
35535a3d36dfSmrg    {
35545a3d36dfSmrg      LTWRAPPER_DEBUGPRINTF (("(main) newargz[%d]   : %s\n", i, (newargz[i] ? newargz[i] : "<NULL>")));
35555a3d36dfSmrg    }
355623a0898aSmrg
35575a3d36dfSmrgEOF
355823a0898aSmrg
35595a3d36dfSmrg	    case $host_os in
35605a3d36dfSmrg	      mingw*)
35615a3d36dfSmrg		cat <<"EOF"
35625a3d36dfSmrg  /* execv doesn't actually work on mingw as expected on unix */
35635a3d36dfSmrg  rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
35645a3d36dfSmrg  if (rval == -1)
35655a3d36dfSmrg    {
35665a3d36dfSmrg      /* failed to start process */
35675a3d36dfSmrg      LTWRAPPER_DEBUGPRINTF (("(main) failed to launch target \"%s\": errno = %d\n", lt_argv_zero, errno));
35685a3d36dfSmrg      return 127;
35695a3d36dfSmrg    }
35705a3d36dfSmrg  return rval;
35715a3d36dfSmrgEOF
35725a3d36dfSmrg		;;
35735a3d36dfSmrg	      *)
35745a3d36dfSmrg		cat <<"EOF"
35755a3d36dfSmrg  execv (lt_argv_zero, newargz);
35765a3d36dfSmrg  return rval; /* =127, but avoids unused variable warning */
35775a3d36dfSmrgEOF
35785a3d36dfSmrg		;;
35795a3d36dfSmrg	    esac
358023a0898aSmrg
35815a3d36dfSmrg	    cat <<"EOF"
35825a3d36dfSmrg}
358323a0898aSmrg
35845a3d36dfSmrgvoid *
35855a3d36dfSmrgxmalloc (size_t num)
35865a3d36dfSmrg{
35875a3d36dfSmrg  void *p = (void *) malloc (num);
35885a3d36dfSmrg  if (!p)
35895a3d36dfSmrg    lt_fatal ("Memory exhausted");
359023a0898aSmrg
35915a3d36dfSmrg  return p;
35925a3d36dfSmrg}
359323a0898aSmrg
35945a3d36dfSmrgchar *
35955a3d36dfSmrgxstrdup (const char *string)
35965a3d36dfSmrg{
35975a3d36dfSmrg  return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
35985a3d36dfSmrg			  string) : NULL;
35995a3d36dfSmrg}
360023a0898aSmrg
36015a3d36dfSmrgconst char *
36025a3d36dfSmrgbase_name (const char *name)
36035a3d36dfSmrg{
36045a3d36dfSmrg  const char *base;
3605b3062210Smrg
36065a3d36dfSmrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
36075a3d36dfSmrg  /* Skip over the disk name in MSDOS pathnames. */
36085a3d36dfSmrg  if (isalpha ((unsigned char) name[0]) && name[1] == ':')
36095a3d36dfSmrg    name += 2;
36105a3d36dfSmrg#endif
3611b3062210Smrg
36125a3d36dfSmrg  for (base = name; *name; name++)
36135a3d36dfSmrg    if (IS_DIR_SEPARATOR (*name))
36145a3d36dfSmrg      base = name + 1;
36155a3d36dfSmrg  return base;
36165a3d36dfSmrg}
3617b3062210Smrg
36185a3d36dfSmrgint
36195a3d36dfSmrgcheck_executable (const char *path)
36205a3d36dfSmrg{
36215a3d36dfSmrg  struct stat st;
3622b3062210Smrg
36235a3d36dfSmrg  LTWRAPPER_DEBUGPRINTF (("(check_executable)  : %s\n",
36245a3d36dfSmrg			  path ? (*path ? path : "EMPTY!") : "NULL!"));
36255a3d36dfSmrg  if ((!path) || (!*path))
36265a3d36dfSmrg    return 0;
3627b3062210Smrg
36285a3d36dfSmrg  if ((stat (path, &st) >= 0)
36295a3d36dfSmrg      && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
36305a3d36dfSmrg    return 1;
36315a3d36dfSmrg  else
36325a3d36dfSmrg    return 0;
36335a3d36dfSmrg}
363423a0898aSmrg
36355a3d36dfSmrgint
36365a3d36dfSmrgmake_executable (const char *path)
36375a3d36dfSmrg{
36385a3d36dfSmrg  int rval = 0;
36395a3d36dfSmrg  struct stat st;
364023a0898aSmrg
36415a3d36dfSmrg  LTWRAPPER_DEBUGPRINTF (("(make_executable)   : %s\n",
36425a3d36dfSmrg			  path ? (*path ? path : "EMPTY!") : "NULL!"));
36435a3d36dfSmrg  if ((!path) || (!*path))
36445a3d36dfSmrg    return 0;
364523a0898aSmrg
36465a3d36dfSmrg  if (stat (path, &st) >= 0)
36475a3d36dfSmrg    {
36485a3d36dfSmrg      rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
36495a3d36dfSmrg    }
36505a3d36dfSmrg  return rval;
36515a3d36dfSmrg}
3652b3062210Smrg
36535a3d36dfSmrg/* Searches for the full path of the wrapper.  Returns
36545a3d36dfSmrg   newly allocated full path name if found, NULL otherwise
36555a3d36dfSmrg   Does not chase symlinks, even on platforms that support them.
36565a3d36dfSmrg*/
36575a3d36dfSmrgchar *
36585a3d36dfSmrgfind_executable (const char *wrapper)
36595a3d36dfSmrg{
36605a3d36dfSmrg  int has_slash = 0;
36615a3d36dfSmrg  const char *p;
36625a3d36dfSmrg  const char *p_next;
36635a3d36dfSmrg  /* static buffer for getcwd */
36645a3d36dfSmrg  char tmp[LT_PATHMAX + 1];
36655a3d36dfSmrg  int tmp_len;
36665a3d36dfSmrg  char *concat_name;
3667b3062210Smrg
36685a3d36dfSmrg  LTWRAPPER_DEBUGPRINTF (("(find_executable)   : %s\n",
36695a3d36dfSmrg			  wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!"));
3670b3062210Smrg
36715a3d36dfSmrg  if ((wrapper == NULL) || (*wrapper == '\0'))
36725a3d36dfSmrg    return NULL;
3673b3062210Smrg
36745a3d36dfSmrg  /* Absolute path? */
36755a3d36dfSmrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
36765a3d36dfSmrg  if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
36775a3d36dfSmrg    {
36785a3d36dfSmrg      concat_name = xstrdup (wrapper);
36795a3d36dfSmrg      if (check_executable (concat_name))
36805a3d36dfSmrg	return concat_name;
36815a3d36dfSmrg      XFREE (concat_name);
36825a3d36dfSmrg    }
36835a3d36dfSmrg  else
36845a3d36dfSmrg    {
36855a3d36dfSmrg#endif
36865a3d36dfSmrg      if (IS_DIR_SEPARATOR (wrapper[0]))
36875a3d36dfSmrg	{
36885a3d36dfSmrg	  concat_name = xstrdup (wrapper);
36895a3d36dfSmrg	  if (check_executable (concat_name))
36905a3d36dfSmrg	    return concat_name;
36915a3d36dfSmrg	  XFREE (concat_name);
36925a3d36dfSmrg	}
36935a3d36dfSmrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
36945a3d36dfSmrg    }
36955a3d36dfSmrg#endif
369623a0898aSmrg
36975a3d36dfSmrg  for (p = wrapper; *p; p++)
36985a3d36dfSmrg    if (*p == '/')
36995a3d36dfSmrg      {
37005a3d36dfSmrg	has_slash = 1;
37015a3d36dfSmrg	break;
37025a3d36dfSmrg      }
37035a3d36dfSmrg  if (!has_slash)
37045a3d36dfSmrg    {
37055a3d36dfSmrg      /* no slashes; search PATH */
37065a3d36dfSmrg      const char *path = getenv ("PATH");
37075a3d36dfSmrg      if (path != NULL)
37085a3d36dfSmrg	{
37095a3d36dfSmrg	  for (p = path; *p; p = p_next)
37105a3d36dfSmrg	    {
37115a3d36dfSmrg	      const char *q;
37125a3d36dfSmrg	      size_t p_len;
37135a3d36dfSmrg	      for (q = p; *q; q++)
37145a3d36dfSmrg		if (IS_PATH_SEPARATOR (*q))
37155a3d36dfSmrg		  break;
37165a3d36dfSmrg	      p_len = q - p;
37175a3d36dfSmrg	      p_next = (*q == '\0' ? q : q + 1);
37185a3d36dfSmrg	      if (p_len == 0)
37195a3d36dfSmrg		{
37205a3d36dfSmrg		  /* empty path: current directory */
37215a3d36dfSmrg		  if (getcwd (tmp, LT_PATHMAX) == NULL)
37225a3d36dfSmrg		    lt_fatal ("getcwd failed");
37235a3d36dfSmrg		  tmp_len = strlen (tmp);
37245a3d36dfSmrg		  concat_name =
37255a3d36dfSmrg		    XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
37265a3d36dfSmrg		  memcpy (concat_name, tmp, tmp_len);
37275a3d36dfSmrg		  concat_name[tmp_len] = '/';
37285a3d36dfSmrg		  strcpy (concat_name + tmp_len + 1, wrapper);
37295a3d36dfSmrg		}
37305a3d36dfSmrg	      else
37315a3d36dfSmrg		{
37325a3d36dfSmrg		  concat_name =
37335a3d36dfSmrg		    XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
37345a3d36dfSmrg		  memcpy (concat_name, p, p_len);
37355a3d36dfSmrg		  concat_name[p_len] = '/';
37365a3d36dfSmrg		  strcpy (concat_name + p_len + 1, wrapper);
37375a3d36dfSmrg		}
37385a3d36dfSmrg	      if (check_executable (concat_name))
37395a3d36dfSmrg		return concat_name;
37405a3d36dfSmrg	      XFREE (concat_name);
37415a3d36dfSmrg	    }
37425a3d36dfSmrg	}
37435a3d36dfSmrg      /* not found in PATH; assume curdir */
37445a3d36dfSmrg    }
37455a3d36dfSmrg  /* Relative path | not found in path: prepend cwd */
37465a3d36dfSmrg  if (getcwd (tmp, LT_PATHMAX) == NULL)
37475a3d36dfSmrg    lt_fatal ("getcwd failed");
37485a3d36dfSmrg  tmp_len = strlen (tmp);
37495a3d36dfSmrg  concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
37505a3d36dfSmrg  memcpy (concat_name, tmp, tmp_len);
37515a3d36dfSmrg  concat_name[tmp_len] = '/';
37525a3d36dfSmrg  strcpy (concat_name + tmp_len + 1, wrapper);
375323a0898aSmrg
37545a3d36dfSmrg  if (check_executable (concat_name))
37555a3d36dfSmrg    return concat_name;
37565a3d36dfSmrg  XFREE (concat_name);
37575a3d36dfSmrg  return NULL;
37585a3d36dfSmrg}
375923a0898aSmrg
37605a3d36dfSmrgchar *
37615a3d36dfSmrgchase_symlinks (const char *pathspec)
37625a3d36dfSmrg{
37635a3d36dfSmrg#ifndef S_ISLNK
37645a3d36dfSmrg  return xstrdup (pathspec);
37655a3d36dfSmrg#else
37665a3d36dfSmrg  char buf[LT_PATHMAX];
37675a3d36dfSmrg  struct stat s;
37685a3d36dfSmrg  char *tmp_pathspec = xstrdup (pathspec);
37695a3d36dfSmrg  char *p;
37705a3d36dfSmrg  int has_symlinks = 0;
37715a3d36dfSmrg  while (strlen (tmp_pathspec) && !has_symlinks)
37725a3d36dfSmrg    {
37735a3d36dfSmrg      LTWRAPPER_DEBUGPRINTF (("checking path component for symlinks: %s\n",
37745a3d36dfSmrg			      tmp_pathspec));
37755a3d36dfSmrg      if (lstat (tmp_pathspec, &s) == 0)
37765a3d36dfSmrg	{
37775a3d36dfSmrg	  if (S_ISLNK (s.st_mode) != 0)
37785a3d36dfSmrg	    {
37795a3d36dfSmrg	      has_symlinks = 1;
37805a3d36dfSmrg	      break;
37815a3d36dfSmrg	    }
378223a0898aSmrg
37835a3d36dfSmrg	  /* search backwards for last DIR_SEPARATOR */
37845a3d36dfSmrg	  p = tmp_pathspec + strlen (tmp_pathspec) - 1;
37855a3d36dfSmrg	  while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
37865a3d36dfSmrg	    p--;
37875a3d36dfSmrg	  if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
37885a3d36dfSmrg	    {
37895a3d36dfSmrg	      /* no more DIR_SEPARATORS left */
37905a3d36dfSmrg	      break;
37915a3d36dfSmrg	    }
37925a3d36dfSmrg	  *p = '\0';
37935a3d36dfSmrg	}
37945a3d36dfSmrg      else
37955a3d36dfSmrg	{
37965a3d36dfSmrg	  char *errstr = strerror (errno);
37975a3d36dfSmrg	  lt_fatal ("Error accessing file %s (%s)", tmp_pathspec, errstr);
37985a3d36dfSmrg	}
37995a3d36dfSmrg    }
38005a3d36dfSmrg  XFREE (tmp_pathspec);
380123a0898aSmrg
38025a3d36dfSmrg  if (!has_symlinks)
38035a3d36dfSmrg    {
38045a3d36dfSmrg      return xstrdup (pathspec);
38055a3d36dfSmrg    }
380623a0898aSmrg
38075a3d36dfSmrg  tmp_pathspec = realpath (pathspec, buf);
38085a3d36dfSmrg  if (tmp_pathspec == 0)
38095a3d36dfSmrg    {
38105a3d36dfSmrg      lt_fatal ("Could not follow symlinks for %s", pathspec);
38115a3d36dfSmrg    }
38125a3d36dfSmrg  return xstrdup (tmp_pathspec);
38135a3d36dfSmrg#endif
38145a3d36dfSmrg}
381523a0898aSmrg
38165a3d36dfSmrgchar *
38175a3d36dfSmrgstrendzap (char *str, const char *pat)
38185a3d36dfSmrg{
38195a3d36dfSmrg  size_t len, patlen;
382023a0898aSmrg
38215a3d36dfSmrg  assert (str != NULL);
38225a3d36dfSmrg  assert (pat != NULL);
382323a0898aSmrg
38245a3d36dfSmrg  len = strlen (str);
38255a3d36dfSmrg  patlen = strlen (pat);
382623a0898aSmrg
38275a3d36dfSmrg  if (patlen <= len)
38285a3d36dfSmrg    {
38295a3d36dfSmrg      str += len - patlen;
38305a3d36dfSmrg      if (strcmp (str, pat) == 0)
38315a3d36dfSmrg	*str = '\0';
38325a3d36dfSmrg    }
38335a3d36dfSmrg  return str;
38345a3d36dfSmrg}
383523a0898aSmrg
38365a3d36dfSmrgstatic void
38375a3d36dfSmrglt_error_core (int exit_status, const char *mode,
38385a3d36dfSmrg	       const char *message, va_list ap)
38395a3d36dfSmrg{
38405a3d36dfSmrg  fprintf (stderr, "%s: %s: ", program_name, mode);
38415a3d36dfSmrg  vfprintf (stderr, message, ap);
38425a3d36dfSmrg  fprintf (stderr, ".\n");
384323a0898aSmrg
38445a3d36dfSmrg  if (exit_status >= 0)
38455a3d36dfSmrg    exit (exit_status);
38465a3d36dfSmrg}
384723a0898aSmrg
38485a3d36dfSmrgvoid
38495a3d36dfSmrglt_fatal (const char *message, ...)
38505a3d36dfSmrg{
38515a3d36dfSmrg  va_list ap;
38525a3d36dfSmrg  va_start (ap, message);
38535a3d36dfSmrg  lt_error_core (EXIT_FAILURE, "FATAL", message, ap);
38545a3d36dfSmrg  va_end (ap);
38555a3d36dfSmrg}
385623a0898aSmrg
38575a3d36dfSmrgvoid
38585a3d36dfSmrglt_setenv (const char *name, const char *value)
38595a3d36dfSmrg{
38605a3d36dfSmrg  LTWRAPPER_DEBUGPRINTF (("(lt_setenv) setting '%s' to '%s'\n",
38615a3d36dfSmrg                          (name ? name : "<NULL>"),
38625a3d36dfSmrg                          (value ? value : "<NULL>")));
38635a3d36dfSmrg  {
38645a3d36dfSmrg#ifdef HAVE_SETENV
38655a3d36dfSmrg    /* always make a copy, for consistency with !HAVE_SETENV */
38665a3d36dfSmrg    char *str = xstrdup (value);
38675a3d36dfSmrg    setenv (name, str, 1);
38685a3d36dfSmrg#else
38695a3d36dfSmrg    int len = strlen (name) + 1 + strlen (value) + 1;
38705a3d36dfSmrg    char *str = XMALLOC (char, len);
38715a3d36dfSmrg    sprintf (str, "%s=%s", name, value);
38725a3d36dfSmrg    if (putenv (str) != EXIT_SUCCESS)
38735a3d36dfSmrg      {
38745a3d36dfSmrg        XFREE (str);
38755a3d36dfSmrg      }
38765a3d36dfSmrg#endif
38775a3d36dfSmrg  }
38785a3d36dfSmrg}
387923a0898aSmrg
38805a3d36dfSmrgchar *
38815a3d36dfSmrglt_extend_str (const char *orig_value, const char *add, int to_end)
38825a3d36dfSmrg{
38835a3d36dfSmrg  char *new_value;
38845a3d36dfSmrg  if (orig_value && *orig_value)
38855a3d36dfSmrg    {
38865a3d36dfSmrg      int orig_value_len = strlen (orig_value);
38875a3d36dfSmrg      int add_len = strlen (add);
38885a3d36dfSmrg      new_value = XMALLOC (char, add_len + orig_value_len + 1);
38895a3d36dfSmrg      if (to_end)
38905a3d36dfSmrg        {
38915a3d36dfSmrg          strcpy (new_value, orig_value);
38925a3d36dfSmrg          strcpy (new_value + orig_value_len, add);
38935a3d36dfSmrg        }
38945a3d36dfSmrg      else
38955a3d36dfSmrg        {
38965a3d36dfSmrg          strcpy (new_value, add);
38975a3d36dfSmrg          strcpy (new_value + add_len, orig_value);
38985a3d36dfSmrg        }
38995a3d36dfSmrg    }
39005a3d36dfSmrg  else
39015a3d36dfSmrg    {
39025a3d36dfSmrg      new_value = xstrdup (add);
39035a3d36dfSmrg    }
39045a3d36dfSmrg  return new_value;
39055a3d36dfSmrg}
390623a0898aSmrg
39075a3d36dfSmrgint
39085a3d36dfSmrglt_split_name_value (const char *arg, char** name, char** value)
39095a3d36dfSmrg{
39105a3d36dfSmrg  const char *p;
39115a3d36dfSmrg  int len;
39125a3d36dfSmrg  if (!arg || !*arg)
39135a3d36dfSmrg    return 1;
391423a0898aSmrg
39155a3d36dfSmrg  p = strchr (arg, (int)'=');
391623a0898aSmrg
39175a3d36dfSmrg  if (!p)
39185a3d36dfSmrg    return 1;
391923a0898aSmrg
39205a3d36dfSmrg  *value = xstrdup (++p);
392123a0898aSmrg
39225a3d36dfSmrg  len = strlen (arg) - strlen (*value);
39235a3d36dfSmrg  *name = XMALLOC (char, len);
39245a3d36dfSmrg  strncpy (*name, arg, len-1);
39255a3d36dfSmrg  (*name)[len - 1] = '\0';
392623a0898aSmrg
39275a3d36dfSmrg  return 0;
39285a3d36dfSmrg}
392923a0898aSmrg
39305a3d36dfSmrgvoid
39315a3d36dfSmrglt_opt_process_env_set (const char *arg)
39325a3d36dfSmrg{
39335a3d36dfSmrg  char *name = NULL;
39345a3d36dfSmrg  char *value = NULL;
393523a0898aSmrg
39365a3d36dfSmrg  if (lt_split_name_value (arg, &name, &value) != 0)
39375a3d36dfSmrg    {
39385a3d36dfSmrg      XFREE (name);
39395a3d36dfSmrg      XFREE (value);
39405a3d36dfSmrg      lt_fatal ("bad argument for %s: '%s'", env_set_opt, arg);
39415a3d36dfSmrg    }
394223a0898aSmrg
39435a3d36dfSmrg  lt_setenv (name, value);
39445a3d36dfSmrg  XFREE (name);
39455a3d36dfSmrg  XFREE (value);
39465a3d36dfSmrg}
394723a0898aSmrg
39485a3d36dfSmrgvoid
39495a3d36dfSmrglt_opt_process_env_prepend (const char *arg)
39505a3d36dfSmrg{
39515a3d36dfSmrg  char *name = NULL;
39525a3d36dfSmrg  char *value = NULL;
39535a3d36dfSmrg  char *new_value = NULL;
395423a0898aSmrg
39555a3d36dfSmrg  if (lt_split_name_value (arg, &name, &value) != 0)
39565a3d36dfSmrg    {
39575a3d36dfSmrg      XFREE (name);
39585a3d36dfSmrg      XFREE (value);
39595a3d36dfSmrg      lt_fatal ("bad argument for %s: '%s'", env_prepend_opt, arg);
39605a3d36dfSmrg    }
396123a0898aSmrg
39625a3d36dfSmrg  new_value = lt_extend_str (getenv (name), value, 0);
39635a3d36dfSmrg  lt_setenv (name, new_value);
39645a3d36dfSmrg  XFREE (new_value);
39655a3d36dfSmrg  XFREE (name);
39665a3d36dfSmrg  XFREE (value);
39675a3d36dfSmrg}
396823a0898aSmrg
39695a3d36dfSmrgvoid
39705a3d36dfSmrglt_opt_process_env_append (const char *arg)
39715a3d36dfSmrg{
39725a3d36dfSmrg  char *name = NULL;
39735a3d36dfSmrg  char *value = NULL;
39745a3d36dfSmrg  char *new_value = NULL;
397523a0898aSmrg
39765a3d36dfSmrg  if (lt_split_name_value (arg, &name, &value) != 0)
39775a3d36dfSmrg    {
39785a3d36dfSmrg      XFREE (name);
39795a3d36dfSmrg      XFREE (value);
39805a3d36dfSmrg      lt_fatal ("bad argument for %s: '%s'", env_append_opt, arg);
39815a3d36dfSmrg    }
398223a0898aSmrg
39835a3d36dfSmrg  new_value = lt_extend_str (getenv (name), value, 1);
39845a3d36dfSmrg  lt_setenv (name, new_value);
39855a3d36dfSmrg  XFREE (new_value);
39865a3d36dfSmrg  XFREE (name);
39875a3d36dfSmrg  XFREE (value);
39885a3d36dfSmrg}
398923a0898aSmrg
39905a3d36dfSmrgvoid
39915a3d36dfSmrglt_update_exe_path (const char *name, const char *value)
39925a3d36dfSmrg{
39935a3d36dfSmrg  LTWRAPPER_DEBUGPRINTF (("(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
39945a3d36dfSmrg                          (name ? name : "<NULL>"),
39955a3d36dfSmrg                          (value ? value : "<NULL>")));
399623a0898aSmrg
39975a3d36dfSmrg  if (name && *name && value && *value)
39985a3d36dfSmrg    {
39995a3d36dfSmrg      char *new_value = lt_extend_str (getenv (name), value, 0);
40005a3d36dfSmrg      /* some systems can't cope with a ':'-terminated path #' */
40015a3d36dfSmrg      int len = strlen (new_value);
40025a3d36dfSmrg      while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
40035a3d36dfSmrg        {
40045a3d36dfSmrg          new_value[len-1] = '\0';
40055a3d36dfSmrg        }
40065a3d36dfSmrg      lt_setenv (name, new_value);
40075a3d36dfSmrg      XFREE (new_value);
40085a3d36dfSmrg    }
40095a3d36dfSmrg}
401023a0898aSmrg
40115a3d36dfSmrgvoid
40125a3d36dfSmrglt_update_lib_path (const char *name, const char *value)
40135a3d36dfSmrg{
40145a3d36dfSmrg  LTWRAPPER_DEBUGPRINTF (("(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
40155a3d36dfSmrg                          (name ? name : "<NULL>"),
40165a3d36dfSmrg                          (value ? value : "<NULL>")));
401723a0898aSmrg
40185a3d36dfSmrg  if (name && *name && value && *value)
40195a3d36dfSmrg    {
40205a3d36dfSmrg      char *new_value = lt_extend_str (getenv (name), value, 0);
40215a3d36dfSmrg      lt_setenv (name, new_value);
40225a3d36dfSmrg      XFREE (new_value);
40235a3d36dfSmrg    }
40245a3d36dfSmrg}
402523a0898aSmrg
402623a0898aSmrg
40275a3d36dfSmrgEOF
40285a3d36dfSmrg}
40295a3d36dfSmrg# end: func_emit_cwrapperexe_src
403023a0898aSmrg
40315a3d36dfSmrg# func_mode_link arg...
40325a3d36dfSmrgfunc_mode_link ()
40335a3d36dfSmrg{
40345a3d36dfSmrg    $opt_debug
40355a3d36dfSmrg    case $host in
40365a3d36dfSmrg    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
40375a3d36dfSmrg      # It is impossible to link a dll without this setting, and
40385a3d36dfSmrg      # we shouldn't force the makefile maintainer to figure out
40395a3d36dfSmrg      # which system we are compiling for in order to pass an extra
40405a3d36dfSmrg      # flag for every libtool invocation.
40415a3d36dfSmrg      # allow_undefined=no
404223a0898aSmrg
40435a3d36dfSmrg      # FIXME: Unfortunately, there are problems with the above when trying
40445a3d36dfSmrg      # to make a dll which has undefined symbols, in which case not
40455a3d36dfSmrg      # even a static library is built.  For now, we need to specify
40465a3d36dfSmrg      # -no-undefined on the libtool link line when we can be certain
40475a3d36dfSmrg      # that all symbols are satisfied, otherwise we get a static library.
40485a3d36dfSmrg      allow_undefined=yes
40495a3d36dfSmrg      ;;
40505a3d36dfSmrg    *)
40515a3d36dfSmrg      allow_undefined=yes
40525a3d36dfSmrg      ;;
40535a3d36dfSmrg    esac
40545a3d36dfSmrg    libtool_args=$nonopt
40555a3d36dfSmrg    base_compile="$nonopt $@"
40565a3d36dfSmrg    compile_command=$nonopt
40575a3d36dfSmrg    finalize_command=$nonopt
405823a0898aSmrg
40595a3d36dfSmrg    compile_rpath=
40605a3d36dfSmrg    finalize_rpath=
40615a3d36dfSmrg    compile_shlibpath=
40625a3d36dfSmrg    finalize_shlibpath=
40635a3d36dfSmrg    convenience=
40645a3d36dfSmrg    old_convenience=
40655a3d36dfSmrg    deplibs=
40665a3d36dfSmrg    old_deplibs=
40675a3d36dfSmrg    compiler_flags=
40685a3d36dfSmrg    linker_flags=
40695a3d36dfSmrg    dllsearchpath=
40705a3d36dfSmrg    lib_search_path=`pwd`
40715a3d36dfSmrg    inst_prefix_dir=
40725a3d36dfSmrg    new_inherited_linker_flags=
407323a0898aSmrg
40745a3d36dfSmrg    avoid_version=no
40755a3d36dfSmrg    dlfiles=
40765a3d36dfSmrg    dlprefiles=
40775a3d36dfSmrg    dlself=no
40785a3d36dfSmrg    export_dynamic=no
40795a3d36dfSmrg    export_symbols=
40805a3d36dfSmrg    export_symbols_regex=
40815a3d36dfSmrg    generated=
40825a3d36dfSmrg    libobjs=
40835a3d36dfSmrg    ltlibs=
40845a3d36dfSmrg    module=no
40855a3d36dfSmrg    no_install=no
40865a3d36dfSmrg    objs=
40875a3d36dfSmrg    non_pic_objects=
40885a3d36dfSmrg    precious_files_regex=
40895a3d36dfSmrg    prefer_static_libs=no
40905a3d36dfSmrg    preload=no
40915a3d36dfSmrg    prev=
40925a3d36dfSmrg    prevarg=
40935a3d36dfSmrg    release=
40945a3d36dfSmrg    rpath=
40955a3d36dfSmrg    xrpath=
40965a3d36dfSmrg    perm_rpath=
40975a3d36dfSmrg    temp_rpath=
40985a3d36dfSmrg    thread_safe=no
40995a3d36dfSmrg    vinfo=
41005a3d36dfSmrg    vinfo_number=no
41015a3d36dfSmrg    weak_libs=
41025a3d36dfSmrg    single_module="${wl}-single_module"
41035a3d36dfSmrg    func_infer_tag $base_compile
41045a3d36dfSmrg
41055a3d36dfSmrg    # We need to know -static, to get the right output filenames.
41065a3d36dfSmrg    for arg
41075a3d36dfSmrg    do
41085a3d36dfSmrg      case $arg in
41095a3d36dfSmrg      -shared)
41105a3d36dfSmrg	test "$build_libtool_libs" != yes && \
41115a3d36dfSmrg	  func_fatal_configuration "can not build a shared library"
41125a3d36dfSmrg	build_old_libs=no
41135a3d36dfSmrg	break
41145a3d36dfSmrg	;;
41155a3d36dfSmrg      -all-static | -static | -static-libtool-libs)
41165a3d36dfSmrg	case $arg in
41175a3d36dfSmrg	-all-static)
41185a3d36dfSmrg	  if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
41195a3d36dfSmrg	    func_warning "complete static linking is impossible in this configuration"
41205a3d36dfSmrg	  fi
41215a3d36dfSmrg	  if test -n "$link_static_flag"; then
41225a3d36dfSmrg	    dlopen_self=$dlopen_self_static
41235a3d36dfSmrg	  fi
41245a3d36dfSmrg	  prefer_static_libs=yes
41255a3d36dfSmrg	  ;;
41265a3d36dfSmrg	-static)
41275a3d36dfSmrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
41285a3d36dfSmrg	    dlopen_self=$dlopen_self_static
4129b3062210Smrg	  fi
41305a3d36dfSmrg	  prefer_static_libs=built
41315a3d36dfSmrg	  ;;
41325a3d36dfSmrg	-static-libtool-libs)
41335a3d36dfSmrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
41345a3d36dfSmrg	    dlopen_self=$dlopen_self_static
41355a3d36dfSmrg	  fi
41365a3d36dfSmrg	  prefer_static_libs=yes
41375a3d36dfSmrg	  ;;
41385a3d36dfSmrg	esac
41395a3d36dfSmrg	build_libtool_libs=no
41405a3d36dfSmrg	build_old_libs=yes
41415a3d36dfSmrg	break
41425a3d36dfSmrg	;;
41435a3d36dfSmrg      esac
41445a3d36dfSmrg    done
414523a0898aSmrg
41465a3d36dfSmrg    # See if our shared archives depend on static archives.
41475a3d36dfSmrg    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
414823a0898aSmrg
41495a3d36dfSmrg    # Go through the arguments, transforming them on the way.
41505a3d36dfSmrg    while test "$#" -gt 0; do
41515a3d36dfSmrg      arg="$1"
41525a3d36dfSmrg      shift
41535a3d36dfSmrg      func_quote_for_eval "$arg"
41545a3d36dfSmrg      qarg=$func_quote_for_eval_unquoted_result
41555a3d36dfSmrg      func_append libtool_args " $func_quote_for_eval_result"
415623a0898aSmrg
41575a3d36dfSmrg      # If the previous option needs an argument, assign it.
41585a3d36dfSmrg      if test -n "$prev"; then
41595a3d36dfSmrg	case $prev in
41605a3d36dfSmrg	output)
41615a3d36dfSmrg	  func_append compile_command " @OUTPUT@"
41625a3d36dfSmrg	  func_append finalize_command " @OUTPUT@"
41635a3d36dfSmrg	  ;;
41645a3d36dfSmrg	esac
416523a0898aSmrg
41665a3d36dfSmrg	case $prev in
41675a3d36dfSmrg	dlfiles|dlprefiles)
41685a3d36dfSmrg	  if test "$preload" = no; then
41695a3d36dfSmrg	    # Add the symbol object into the linking commands.
41705a3d36dfSmrg	    func_append compile_command " @SYMFILE@"
41715a3d36dfSmrg	    func_append finalize_command " @SYMFILE@"
41725a3d36dfSmrg	    preload=yes
41735a3d36dfSmrg	  fi
41745a3d36dfSmrg	  case $arg in
41755a3d36dfSmrg	  *.la | *.lo) ;;  # We handle these cases below.
41765a3d36dfSmrg	  force)
41775a3d36dfSmrg	    if test "$dlself" = no; then
41785a3d36dfSmrg	      dlself=needless
41795a3d36dfSmrg	      export_dynamic=yes
41805a3d36dfSmrg	    fi
41815a3d36dfSmrg	    prev=
41825a3d36dfSmrg	    continue
41835a3d36dfSmrg	    ;;
41845a3d36dfSmrg	  self)
41855a3d36dfSmrg	    if test "$prev" = dlprefiles; then
41865a3d36dfSmrg	      dlself=yes
41875a3d36dfSmrg	    elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
41885a3d36dfSmrg	      dlself=yes
4189b3062210Smrg	    else
41905a3d36dfSmrg	      dlself=needless
41915a3d36dfSmrg	      export_dynamic=yes
4192b3062210Smrg	    fi
41935a3d36dfSmrg	    prev=
41945a3d36dfSmrg	    continue
41955a3d36dfSmrg	    ;;
41965a3d36dfSmrg	  *)
41975a3d36dfSmrg	    if test "$prev" = dlfiles; then
41985a3d36dfSmrg	      dlfiles="$dlfiles $arg"
4199b3062210Smrg	    else
42005a3d36dfSmrg	      dlprefiles="$dlprefiles $arg"
4201b3062210Smrg	    fi
42025a3d36dfSmrg	    prev=
42035a3d36dfSmrg	    continue
42045a3d36dfSmrg	    ;;
42055a3d36dfSmrg	  esac
42065a3d36dfSmrg	  ;;
42075a3d36dfSmrg	expsyms)
42085a3d36dfSmrg	  export_symbols="$arg"
42095a3d36dfSmrg	  test -f "$arg" \
42105a3d36dfSmrg	    || func_fatal_error "symbol file \`$arg' does not exist"
42115a3d36dfSmrg	  prev=
42125a3d36dfSmrg	  continue
42135a3d36dfSmrg	  ;;
42145a3d36dfSmrg	expsyms_regex)
42155a3d36dfSmrg	  export_symbols_regex="$arg"
42165a3d36dfSmrg	  prev=
42175a3d36dfSmrg	  continue
42185a3d36dfSmrg	  ;;
42195a3d36dfSmrg	framework)
42205a3d36dfSmrg	  case $host in
42215a3d36dfSmrg	    *-*-darwin*)
42225a3d36dfSmrg	      case "$deplibs " in
42235a3d36dfSmrg		*" $qarg.ltframework "*) ;;
42245a3d36dfSmrg		*) deplibs="$deplibs $qarg.ltframework" # this is fixed later
42255a3d36dfSmrg		   ;;
42265a3d36dfSmrg	      esac
4227b3062210Smrg	      ;;
42285a3d36dfSmrg	  esac
42295a3d36dfSmrg	  prev=
42305a3d36dfSmrg	  continue
42315a3d36dfSmrg	  ;;
42325a3d36dfSmrg	inst_prefix)
42335a3d36dfSmrg	  inst_prefix_dir="$arg"
42345a3d36dfSmrg	  prev=
42355a3d36dfSmrg	  continue
42365a3d36dfSmrg	  ;;
42375a3d36dfSmrg	objectlist)
42385a3d36dfSmrg	  if test -f "$arg"; then
42395a3d36dfSmrg	    save_arg=$arg
42405a3d36dfSmrg	    moreargs=
42415a3d36dfSmrg	    for fil in `cat "$save_arg"`
42425a3d36dfSmrg	    do
42435a3d36dfSmrg#	      moreargs="$moreargs $fil"
42445a3d36dfSmrg	      arg=$fil
42455a3d36dfSmrg	      # A libtool-controlled object.
424623a0898aSmrg
42475a3d36dfSmrg	      # Check to see that this really is a libtool object.
42485a3d36dfSmrg	      if func_lalib_unsafe_p "$arg"; then
42495a3d36dfSmrg		pic_object=
42505a3d36dfSmrg		non_pic_object=
425123a0898aSmrg
42525a3d36dfSmrg		# Read the .lo file
42535a3d36dfSmrg		func_source "$arg"
425423a0898aSmrg
42555a3d36dfSmrg		if test -z "$pic_object" ||
42565a3d36dfSmrg		   test -z "$non_pic_object" ||
42575a3d36dfSmrg		   test "$pic_object" = none &&
42585a3d36dfSmrg		   test "$non_pic_object" = none; then
42595a3d36dfSmrg		  func_fatal_error "cannot find name of object for \`$arg'"
42605a3d36dfSmrg		fi
426123a0898aSmrg
42625a3d36dfSmrg		# Extract subdirectory from the argument.
42635a3d36dfSmrg		func_dirname "$arg" "/" ""
42645a3d36dfSmrg		xdir="$func_dirname_result"
426523a0898aSmrg
42665a3d36dfSmrg		if test "$pic_object" != none; then
42675a3d36dfSmrg		  # Prepend the subdirectory the object is found in.
42685a3d36dfSmrg		  pic_object="$xdir$pic_object"
426923a0898aSmrg
42705a3d36dfSmrg		  if test "$prev" = dlfiles; then
42715a3d36dfSmrg		    if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
42725a3d36dfSmrg		      dlfiles="$dlfiles $pic_object"
42735a3d36dfSmrg		      prev=
42745a3d36dfSmrg		      continue
42755a3d36dfSmrg		    else
42765a3d36dfSmrg		      # If libtool objects are unsupported, then we need to preload.
42775a3d36dfSmrg		      prev=dlprefiles
42785a3d36dfSmrg		    fi
42795a3d36dfSmrg		  fi
428023a0898aSmrg
42815a3d36dfSmrg		  # CHECK ME:  I think I busted this.  -Ossama
42825a3d36dfSmrg		  if test "$prev" = dlprefiles; then
42835a3d36dfSmrg		    # Preload the old-style object.
42845a3d36dfSmrg		    dlprefiles="$dlprefiles $pic_object"
42855a3d36dfSmrg		    prev=
42865a3d36dfSmrg		  fi
428723a0898aSmrg
42885a3d36dfSmrg		  # A PIC object.
42895a3d36dfSmrg		  func_append libobjs " $pic_object"
42905a3d36dfSmrg		  arg="$pic_object"
42915a3d36dfSmrg		fi
429223a0898aSmrg
42935a3d36dfSmrg		# Non-PIC object.
42945a3d36dfSmrg		if test "$non_pic_object" != none; then
42955a3d36dfSmrg		  # Prepend the subdirectory the object is found in.
42965a3d36dfSmrg		  non_pic_object="$xdir$non_pic_object"
429723a0898aSmrg
42985a3d36dfSmrg		  # A standard non-PIC object
42995a3d36dfSmrg		  func_append non_pic_objects " $non_pic_object"
43005a3d36dfSmrg		  if test -z "$pic_object" || test "$pic_object" = none ; then
43015a3d36dfSmrg		    arg="$non_pic_object"
43025a3d36dfSmrg		  fi
43035a3d36dfSmrg		else
43045a3d36dfSmrg		  # If the PIC object exists, use it instead.
43055a3d36dfSmrg		  # $xdir was prepended to $pic_object above.
43065a3d36dfSmrg		  non_pic_object="$pic_object"
43075a3d36dfSmrg		  func_append non_pic_objects " $non_pic_object"
43085a3d36dfSmrg		fi
43095a3d36dfSmrg	      else
43105a3d36dfSmrg		# Only an error if not doing a dry-run.
43115a3d36dfSmrg		if $opt_dry_run; then
43125a3d36dfSmrg		  # Extract subdirectory from the argument.
43135a3d36dfSmrg		  func_dirname "$arg" "/" ""
43145a3d36dfSmrg		  xdir="$func_dirname_result"
43155a3d36dfSmrg
43165a3d36dfSmrg		  func_lo2o "$arg"
43175a3d36dfSmrg		  pic_object=$xdir$objdir/$func_lo2o_result
43185a3d36dfSmrg		  non_pic_object=$xdir$func_lo2o_result
43195a3d36dfSmrg		  func_append libobjs " $pic_object"
43205a3d36dfSmrg		  func_append non_pic_objects " $non_pic_object"
43215a3d36dfSmrg	        else
43225a3d36dfSmrg		  func_fatal_error "\`$arg' is not a valid libtool object"
43235a3d36dfSmrg		fi
43245a3d36dfSmrg	      fi
43255a3d36dfSmrg	    done
43265a3d36dfSmrg	  else
43275a3d36dfSmrg	    func_fatal_error "link input file \`$arg' does not exist"
43285a3d36dfSmrg	  fi
43295a3d36dfSmrg	  arg=$save_arg
43305a3d36dfSmrg	  prev=
43315a3d36dfSmrg	  continue
43325a3d36dfSmrg	  ;;
43335a3d36dfSmrg	precious_regex)
43345a3d36dfSmrg	  precious_files_regex="$arg"
43355a3d36dfSmrg	  prev=
43365a3d36dfSmrg	  continue
43375a3d36dfSmrg	  ;;
43385a3d36dfSmrg	release)
43395a3d36dfSmrg	  release="-$arg"
43405a3d36dfSmrg	  prev=
43415a3d36dfSmrg	  continue
43425a3d36dfSmrg	  ;;
43435a3d36dfSmrg	rpath | xrpath)
43445a3d36dfSmrg	  # We need an absolute path.
43455a3d36dfSmrg	  case $arg in
43465a3d36dfSmrg	  [\\/]* | [A-Za-z]:[\\/]*) ;;
43475a3d36dfSmrg	  *)
43485a3d36dfSmrg	    func_fatal_error "only absolute run-paths are allowed"
43495a3d36dfSmrg	    ;;
43505a3d36dfSmrg	  esac
43515a3d36dfSmrg	  if test "$prev" = rpath; then
43525a3d36dfSmrg	    case "$rpath " in
43535a3d36dfSmrg	    *" $arg "*) ;;
43545a3d36dfSmrg	    *) rpath="$rpath $arg" ;;
43555a3d36dfSmrg	    esac
43565a3d36dfSmrg	  else
43575a3d36dfSmrg	    case "$xrpath " in
43585a3d36dfSmrg	    *" $arg "*) ;;
43595a3d36dfSmrg	    *) xrpath="$xrpath $arg" ;;
43605a3d36dfSmrg	    esac
43615a3d36dfSmrg	  fi
43625a3d36dfSmrg	  prev=
43635a3d36dfSmrg	  continue
43645a3d36dfSmrg	  ;;
43655a3d36dfSmrg	shrext)
43665a3d36dfSmrg	  shrext_cmds="$arg"
43675a3d36dfSmrg	  prev=
43685a3d36dfSmrg	  continue
43695a3d36dfSmrg	  ;;
43705a3d36dfSmrg	weak)
43715a3d36dfSmrg	  weak_libs="$weak_libs $arg"
43725a3d36dfSmrg	  prev=
43735a3d36dfSmrg	  continue
43745a3d36dfSmrg	  ;;
43755a3d36dfSmrg	xcclinker)
43765a3d36dfSmrg	  linker_flags="$linker_flags $qarg"
43775a3d36dfSmrg	  compiler_flags="$compiler_flags $qarg"
43785a3d36dfSmrg	  prev=
43795a3d36dfSmrg	  func_append compile_command " $qarg"
43805a3d36dfSmrg	  func_append finalize_command " $qarg"
43815a3d36dfSmrg	  continue
43825a3d36dfSmrg	  ;;
43835a3d36dfSmrg	xcompiler)
43845a3d36dfSmrg	  compiler_flags="$compiler_flags $qarg"
43855a3d36dfSmrg	  prev=
43865a3d36dfSmrg	  func_append compile_command " $qarg"
43875a3d36dfSmrg	  func_append finalize_command " $qarg"
43885a3d36dfSmrg	  continue
43895a3d36dfSmrg	  ;;
43905a3d36dfSmrg	xlinker)
43915a3d36dfSmrg	  linker_flags="$linker_flags $qarg"
43925a3d36dfSmrg	  compiler_flags="$compiler_flags $wl$qarg"
43935a3d36dfSmrg	  prev=
43945a3d36dfSmrg	  func_append compile_command " $wl$qarg"
43955a3d36dfSmrg	  func_append finalize_command " $wl$qarg"
43965a3d36dfSmrg	  continue
4397b3062210Smrg	  ;;
4398b3062210Smrg	*)
43995a3d36dfSmrg	  eval "$prev=\"\$arg\""
44005a3d36dfSmrg	  prev=
44015a3d36dfSmrg	  continue
4402b3062210Smrg	  ;;
4403b3062210Smrg	esac
44045a3d36dfSmrg      fi # test -n "$prev"
440523a0898aSmrg
44065a3d36dfSmrg      prevarg="$arg"
440723a0898aSmrg
44085a3d36dfSmrg      case $arg in
44095a3d36dfSmrg      -all-static)
44105a3d36dfSmrg	if test -n "$link_static_flag"; then
44115a3d36dfSmrg	  # See comment for -static flag below, for more details.
44125a3d36dfSmrg	  func_append compile_command " $link_static_flag"
44135a3d36dfSmrg	  func_append finalize_command " $link_static_flag"
44147f7f5e4eSmrg	fi
44155a3d36dfSmrg	continue
44165a3d36dfSmrg	;;
441723a0898aSmrg
44185a3d36dfSmrg      -allow-undefined)
44195a3d36dfSmrg	# FIXME: remove this flag sometime in the future.
44205a3d36dfSmrg	func_fatal_error "\`-allow-undefined' must not be used because it is the default"
44215a3d36dfSmrg	;;
442223a0898aSmrg
44235a3d36dfSmrg      -avoid-version)
44245a3d36dfSmrg	avoid_version=yes
44255a3d36dfSmrg	continue
44265a3d36dfSmrg	;;
442723a0898aSmrg
44285a3d36dfSmrg      -dlopen)
44295a3d36dfSmrg	prev=dlfiles
44305a3d36dfSmrg	continue
44315a3d36dfSmrg	;;
443223a0898aSmrg
44335a3d36dfSmrg      -dlpreopen)
44345a3d36dfSmrg	prev=dlprefiles
44355a3d36dfSmrg	continue
44365a3d36dfSmrg	;;
44377f7f5e4eSmrg
44385a3d36dfSmrg      -export-dynamic)
44395a3d36dfSmrg	export_dynamic=yes
44405a3d36dfSmrg	continue
44415a3d36dfSmrg	;;
44427f7f5e4eSmrg
44435a3d36dfSmrg      -export-symbols | -export-symbols-regex)
44445a3d36dfSmrg	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
44455a3d36dfSmrg	  func_fatal_error "more than one -exported-symbols argument is not allowed"
44465a3d36dfSmrg	fi
44475a3d36dfSmrg	if test "X$arg" = "X-export-symbols"; then
44485a3d36dfSmrg	  prev=expsyms
4449b3062210Smrg	else
44505a3d36dfSmrg	  prev=expsyms_regex
4451b3062210Smrg	fi
44525a3d36dfSmrg	continue
44535a3d36dfSmrg	;;
44547f7f5e4eSmrg
44555a3d36dfSmrg      -framework)
44565a3d36dfSmrg	prev=framework
44575a3d36dfSmrg	continue
44585a3d36dfSmrg	;;
44597f7f5e4eSmrg
44605a3d36dfSmrg      -inst-prefix-dir)
44615a3d36dfSmrg	prev=inst_prefix
44625a3d36dfSmrg	continue
44635a3d36dfSmrg	;;
44647f7f5e4eSmrg
44655a3d36dfSmrg      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
44665a3d36dfSmrg      # so, if we see these flags be careful not to treat them like -L
44675a3d36dfSmrg      -L[A-Z][A-Z]*:*)
44685a3d36dfSmrg	case $with_gcc/$host in
44695a3d36dfSmrg	no/*-*-irix* | /*-*-irix*)
44705a3d36dfSmrg	  func_append compile_command " $arg"
44715a3d36dfSmrg	  func_append finalize_command " $arg"
44725a3d36dfSmrg	  ;;
44735a3d36dfSmrg	esac
44745a3d36dfSmrg	continue
44755a3d36dfSmrg	;;
44767f7f5e4eSmrg
44775a3d36dfSmrg      -L*)
44785a3d36dfSmrg	func_stripname '-L' '' "$arg"
44795a3d36dfSmrg	dir=$func_stripname_result
44805a3d36dfSmrg	if test -z "$dir"; then
44815a3d36dfSmrg	  if test "$#" -gt 0; then
44825a3d36dfSmrg	    func_fatal_error "require no space between \`-L' and \`$1'"
4483b3062210Smrg	  else
44845a3d36dfSmrg	    func_fatal_error "need path for \`-L' option"
4485b3062210Smrg	  fi
44865a3d36dfSmrg	fi
44875a3d36dfSmrg	# We need an absolute path.
44885a3d36dfSmrg	case $dir in
44895a3d36dfSmrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
44905a3d36dfSmrg	*)
44915a3d36dfSmrg	  absdir=`cd "$dir" && pwd`
44925a3d36dfSmrg	  test -z "$absdir" && \
44935a3d36dfSmrg	    func_fatal_error "cannot determine absolute directory name of \`$dir'"
44945a3d36dfSmrg	  dir="$absdir"
44955a3d36dfSmrg	  ;;
44967f7f5e4eSmrg	esac
44975a3d36dfSmrg	case "$deplibs " in
44985a3d36dfSmrg	*" -L$dir "*) ;;
44995a3d36dfSmrg	*)
45005a3d36dfSmrg	  deplibs="$deplibs -L$dir"
45015a3d36dfSmrg	  lib_search_path="$lib_search_path $dir"
45025a3d36dfSmrg	  ;;
4503b3062210Smrg	esac
4504b3062210Smrg	case $host in
45055a3d36dfSmrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
45065a3d36dfSmrg	  testbindir=`$ECHO "X$dir" | $Xsed -e 's*/lib$*/bin*'`
45075a3d36dfSmrg	  case :$dllsearchpath: in
45085a3d36dfSmrg	  *":$dir:"*) ;;
45095a3d36dfSmrg	  ::) dllsearchpath=$dir;;
45105a3d36dfSmrg	  *) dllsearchpath="$dllsearchpath:$dir";;
45115a3d36dfSmrg	  esac
45125a3d36dfSmrg	  case :$dllsearchpath: in
45135a3d36dfSmrg	  *":$testbindir:"*) ;;
45145a3d36dfSmrg	  ::) dllsearchpath=$testbindir;;
45155a3d36dfSmrg	  *) dllsearchpath="$dllsearchpath:$testbindir";;
45165a3d36dfSmrg	  esac
45175a3d36dfSmrg	  ;;
4518b3062210Smrg	esac
45195a3d36dfSmrg	continue
45205a3d36dfSmrg	;;
45217f7f5e4eSmrg
45225a3d36dfSmrg      -l*)
45235a3d36dfSmrg	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
45245a3d36dfSmrg	  case $host in
45255a3d36dfSmrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc*)
45265a3d36dfSmrg	    # These systems don't actually have a C or math library (as such)
45275a3d36dfSmrg	    continue
45285a3d36dfSmrg	    ;;
45295a3d36dfSmrg	  *-*-os2*)
45305a3d36dfSmrg	    # These systems don't actually have a C library (as such)
45315a3d36dfSmrg	    test "X$arg" = "X-lc" && continue
45325a3d36dfSmrg	    ;;
45335a3d36dfSmrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
45345a3d36dfSmrg	    # Do not include libc due to us having libc/libc_r.
45355a3d36dfSmrg	    test "X$arg" = "X-lc" && continue
45365a3d36dfSmrg	    ;;
45375a3d36dfSmrg	  *-*-rhapsody* | *-*-darwin1.[012])
45385a3d36dfSmrg	    # Rhapsody C and math libraries are in the System framework
45395a3d36dfSmrg	    deplibs="$deplibs System.ltframework"
45405a3d36dfSmrg	    continue
45415a3d36dfSmrg	    ;;
45425a3d36dfSmrg	  *-*-sco3.2v5* | *-*-sco5v6*)
45435a3d36dfSmrg	    # Causes problems with __ctype
45445a3d36dfSmrg	    test "X$arg" = "X-lc" && continue
45455a3d36dfSmrg	    ;;
45465a3d36dfSmrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
45475a3d36dfSmrg	    # Compiler inserts libc in the correct place for threads to work
45485a3d36dfSmrg	    test "X$arg" = "X-lc" && continue
45495a3d36dfSmrg	    ;;
45505a3d36dfSmrg	  esac
45515a3d36dfSmrg	elif test "X$arg" = "X-lc_r"; then
45525a3d36dfSmrg	 case $host in
45535a3d36dfSmrg	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
45545a3d36dfSmrg	   # Do not include libc_r directly, use -pthread flag.
45555a3d36dfSmrg	   continue
45565a3d36dfSmrg	   ;;
45575a3d36dfSmrg	 esac
45585a3d36dfSmrg	fi
45595a3d36dfSmrg	deplibs="$deplibs $arg"
45605a3d36dfSmrg	continue
45615a3d36dfSmrg	;;
45627f7f5e4eSmrg
45635a3d36dfSmrg      -module)
45645a3d36dfSmrg	module=yes
45655a3d36dfSmrg	continue
45665a3d36dfSmrg	;;
45677f7f5e4eSmrg
45685a3d36dfSmrg      # Tru64 UNIX uses -model [arg] to determine the layout of C++
45695a3d36dfSmrg      # classes, name mangling, and exception handling.
45705a3d36dfSmrg      # Darwin uses the -arch flag to determine output architecture.
45715a3d36dfSmrg      -model|-arch|-isysroot)
45725a3d36dfSmrg	compiler_flags="$compiler_flags $arg"
45735a3d36dfSmrg	func_append compile_command " $arg"
45745a3d36dfSmrg	func_append finalize_command " $arg"
45755a3d36dfSmrg	prev=xcompiler
45765a3d36dfSmrg	continue
45775a3d36dfSmrg	;;
45787f7f5e4eSmrg
45795a3d36dfSmrg      -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
45805a3d36dfSmrg	compiler_flags="$compiler_flags $arg"
45815a3d36dfSmrg	func_append compile_command " $arg"
45825a3d36dfSmrg	func_append finalize_command " $arg"
45835a3d36dfSmrg	case "$new_inherited_linker_flags " in
45845a3d36dfSmrg	    *" $arg "*) ;;
45855a3d36dfSmrg	    * ) new_inherited_linker_flags="$new_inherited_linker_flags $arg" ;;
45865a3d36dfSmrg	esac
45875a3d36dfSmrg	continue
45885a3d36dfSmrg	;;
45897f7f5e4eSmrg
45905a3d36dfSmrg      -multi_module)
45915a3d36dfSmrg	single_module="${wl}-multi_module"
45925a3d36dfSmrg	continue
45935a3d36dfSmrg	;;
45947f7f5e4eSmrg
45955a3d36dfSmrg      -no-fast-install)
45965a3d36dfSmrg	fast_install=no
45975a3d36dfSmrg	continue
45985a3d36dfSmrg	;;
45997f7f5e4eSmrg
46005a3d36dfSmrg      -no-install)
46015a3d36dfSmrg	case $host in
46025a3d36dfSmrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
46035a3d36dfSmrg	  # The PATH hackery in wrapper scripts is required on Windows
46045a3d36dfSmrg	  # and Darwin in order for the loader to find any dlls it needs.
46055a3d36dfSmrg	  func_warning "\`-no-install' is ignored for $host"
46065a3d36dfSmrg	  func_warning "assuming \`-no-fast-install' instead"
46075a3d36dfSmrg	  fast_install=no
46085a3d36dfSmrg	  ;;
46095a3d36dfSmrg	*) no_install=yes ;;
46105a3d36dfSmrg	esac
46115a3d36dfSmrg	continue
46125a3d36dfSmrg	;;
46137f7f5e4eSmrg
46145a3d36dfSmrg      -no-undefined)
46155a3d36dfSmrg	allow_undefined=no
46165a3d36dfSmrg	continue
46175a3d36dfSmrg	;;
46187f7f5e4eSmrg
46195a3d36dfSmrg      -objectlist)
46205a3d36dfSmrg	prev=objectlist
46215a3d36dfSmrg	continue
46225a3d36dfSmrg	;;
46237f7f5e4eSmrg
46245a3d36dfSmrg      -o) prev=output ;;
46257f7f5e4eSmrg
46265a3d36dfSmrg      -precious-files-regex)
46275a3d36dfSmrg	prev=precious_regex
46285a3d36dfSmrg	continue
46295a3d36dfSmrg	;;
46307f7f5e4eSmrg
46315a3d36dfSmrg      -release)
46325a3d36dfSmrg	prev=release
46335a3d36dfSmrg	continue
46345a3d36dfSmrg	;;
46357f7f5e4eSmrg
46365a3d36dfSmrg      -rpath)
46375a3d36dfSmrg	prev=rpath
46385a3d36dfSmrg	continue
46395a3d36dfSmrg	;;
46407f7f5e4eSmrg
46415a3d36dfSmrg      -R)
46425a3d36dfSmrg	prev=xrpath
46435a3d36dfSmrg	continue
46445a3d36dfSmrg	;;
46457f7f5e4eSmrg
46465a3d36dfSmrg      -R*)
46475a3d36dfSmrg	func_stripname '-R' '' "$arg"
46485a3d36dfSmrg	dir=$func_stripname_result
46495a3d36dfSmrg	# We need an absolute path.
46505a3d36dfSmrg	case $dir in
46515a3d36dfSmrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
46525a3d36dfSmrg	*)
46535a3d36dfSmrg	  func_fatal_error "only absolute run-paths are allowed"
46545a3d36dfSmrg	  ;;
46555a3d36dfSmrg	esac
46565a3d36dfSmrg	case "$xrpath " in
46575a3d36dfSmrg	*" $dir "*) ;;
46585a3d36dfSmrg	*) xrpath="$xrpath $dir" ;;
46595a3d36dfSmrg	esac
46605a3d36dfSmrg	continue
46615a3d36dfSmrg	;;
46627f7f5e4eSmrg
46635a3d36dfSmrg      -shared)
46645a3d36dfSmrg	# The effects of -shared are defined in a previous loop.
46655a3d36dfSmrg	continue
46665a3d36dfSmrg	;;
46677f7f5e4eSmrg
46685a3d36dfSmrg      -shrext)
46695a3d36dfSmrg	prev=shrext
46705a3d36dfSmrg	continue
46715a3d36dfSmrg	;;
46727f7f5e4eSmrg
46735a3d36dfSmrg      -static | -static-libtool-libs)
46745a3d36dfSmrg	# The effects of -static are defined in a previous loop.
46755a3d36dfSmrg	# We used to do the same as -all-static on platforms that
46765a3d36dfSmrg	# didn't have a PIC flag, but the assumption that the effects
46775a3d36dfSmrg	# would be equivalent was wrong.  It would break on at least
46785a3d36dfSmrg	# Digital Unix and AIX.
46795a3d36dfSmrg	continue
46805a3d36dfSmrg	;;
46817f7f5e4eSmrg
46825a3d36dfSmrg      -thread-safe)
46835a3d36dfSmrg	thread_safe=yes
46845a3d36dfSmrg	continue
46855a3d36dfSmrg	;;
46867f7f5e4eSmrg
46875a3d36dfSmrg      -version-info)
46885a3d36dfSmrg	prev=vinfo
46895a3d36dfSmrg	continue
46905a3d36dfSmrg	;;
46917f7f5e4eSmrg
46925a3d36dfSmrg      -version-number)
46935a3d36dfSmrg	prev=vinfo
46945a3d36dfSmrg	vinfo_number=yes
46955a3d36dfSmrg	continue
46965a3d36dfSmrg	;;
46977f7f5e4eSmrg
46985a3d36dfSmrg      -weak)
46995a3d36dfSmrg        prev=weak
47005a3d36dfSmrg	continue
47015a3d36dfSmrg	;;
47027f7f5e4eSmrg
47035a3d36dfSmrg      -Wc,*)
47045a3d36dfSmrg	func_stripname '-Wc,' '' "$arg"
47055a3d36dfSmrg	args=$func_stripname_result
47065a3d36dfSmrg	arg=
47075a3d36dfSmrg	save_ifs="$IFS"; IFS=','
47085a3d36dfSmrg	for flag in $args; do
47095a3d36dfSmrg	  IFS="$save_ifs"
47105a3d36dfSmrg          func_quote_for_eval "$flag"
47115a3d36dfSmrg	  arg="$arg $wl$func_quote_for_eval_result"
47125a3d36dfSmrg	  compiler_flags="$compiler_flags $func_quote_for_eval_result"
47135a3d36dfSmrg	done
47145a3d36dfSmrg	IFS="$save_ifs"
47155a3d36dfSmrg	func_stripname ' ' '' "$arg"
47165a3d36dfSmrg	arg=$func_stripname_result
47175a3d36dfSmrg	;;
47187f7f5e4eSmrg
47195a3d36dfSmrg      -Wl,*)
47205a3d36dfSmrg	func_stripname '-Wl,' '' "$arg"
47215a3d36dfSmrg	args=$func_stripname_result
47225a3d36dfSmrg	arg=
47235a3d36dfSmrg	save_ifs="$IFS"; IFS=','
47245a3d36dfSmrg	for flag in $args; do
47255a3d36dfSmrg	  IFS="$save_ifs"
47265a3d36dfSmrg          func_quote_for_eval "$flag"
47275a3d36dfSmrg	  arg="$arg $wl$func_quote_for_eval_result"
47285a3d36dfSmrg	  compiler_flags="$compiler_flags $wl$func_quote_for_eval_result"
47295a3d36dfSmrg	  linker_flags="$linker_flags $func_quote_for_eval_result"
47305a3d36dfSmrg	done
47315a3d36dfSmrg	IFS="$save_ifs"
47325a3d36dfSmrg	func_stripname ' ' '' "$arg"
47335a3d36dfSmrg	arg=$func_stripname_result
47345a3d36dfSmrg	;;
47357f7f5e4eSmrg
47365a3d36dfSmrg      -Xcompiler)
47375a3d36dfSmrg	prev=xcompiler
47385a3d36dfSmrg	continue
47395a3d36dfSmrg	;;
47407f7f5e4eSmrg
47415a3d36dfSmrg      -Xlinker)
47425a3d36dfSmrg	prev=xlinker
47435a3d36dfSmrg	continue
47445a3d36dfSmrg	;;
47457f7f5e4eSmrg
47465a3d36dfSmrg      -XCClinker)
47475a3d36dfSmrg	prev=xcclinker
47485a3d36dfSmrg	continue
47495a3d36dfSmrg	;;
47507f7f5e4eSmrg
47515a3d36dfSmrg      # -msg_* for osf cc
47525a3d36dfSmrg      -msg_*)
47535a3d36dfSmrg	func_quote_for_eval "$arg"
47545a3d36dfSmrg	arg="$func_quote_for_eval_result"
47555a3d36dfSmrg	;;
47567f7f5e4eSmrg
47575a3d36dfSmrg      # -64, -mips[0-9] enable 64-bit mode on the SGI compiler
47585a3d36dfSmrg      # -r[0-9][0-9]* specifies the processor on the SGI compiler
47595a3d36dfSmrg      # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler
47605a3d36dfSmrg      # +DA*, +DD* enable 64-bit mode on the HP compiler
47615a3d36dfSmrg      # -q* pass through compiler args for the IBM compiler
47625a3d36dfSmrg      # -m*, -t[45]*, -txscale* pass through architecture-specific
47635a3d36dfSmrg      # compiler args for GCC
47645a3d36dfSmrg      # -F/path gives path to uninstalled frameworks, gcc on darwin
47655a3d36dfSmrg      # -p, -pg, --coverage, -fprofile-* pass through profiling flag for GCC
47665a3d36dfSmrg      # @file GCC response files
47675a3d36dfSmrg      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
47685a3d36dfSmrg      -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*)
47695a3d36dfSmrg        func_quote_for_eval "$arg"
47705a3d36dfSmrg	arg="$func_quote_for_eval_result"
47715a3d36dfSmrg        func_append compile_command " $arg"
47725a3d36dfSmrg        func_append finalize_command " $arg"
47735a3d36dfSmrg        compiler_flags="$compiler_flags $arg"
47745a3d36dfSmrg        continue
47755a3d36dfSmrg        ;;
477623a0898aSmrg
47775a3d36dfSmrg      # Some other compiler flag.
47785a3d36dfSmrg      -* | +*)
47795a3d36dfSmrg        func_quote_for_eval "$arg"
47805a3d36dfSmrg	arg="$func_quote_for_eval_result"
47815a3d36dfSmrg	;;
4782b3062210Smrg
47835a3d36dfSmrg      *.$objext)
47845a3d36dfSmrg	# A standard object.
47855a3d36dfSmrg	objs="$objs $arg"
47865a3d36dfSmrg	;;
4787b3062210Smrg
47885a3d36dfSmrg      *.lo)
47895a3d36dfSmrg	# A libtool-controlled object.
4790b3062210Smrg
47915a3d36dfSmrg	# Check to see that this really is a libtool object.
47925a3d36dfSmrg	if func_lalib_unsafe_p "$arg"; then
47935a3d36dfSmrg	  pic_object=
47945a3d36dfSmrg	  non_pic_object=
4795b3062210Smrg
47965a3d36dfSmrg	  # Read the .lo file
47975a3d36dfSmrg	  func_source "$arg"
4798b3062210Smrg
47995a3d36dfSmrg	  if test -z "$pic_object" ||
48005a3d36dfSmrg	     test -z "$non_pic_object" ||
48015a3d36dfSmrg	     test "$pic_object" = none &&
48025a3d36dfSmrg	     test "$non_pic_object" = none; then
48035a3d36dfSmrg	    func_fatal_error "cannot find name of object for \`$arg'"
48045a3d36dfSmrg	  fi
4805b3062210Smrg
48065a3d36dfSmrg	  # Extract subdirectory from the argument.
48075a3d36dfSmrg	  func_dirname "$arg" "/" ""
48085a3d36dfSmrg	  xdir="$func_dirname_result"
4809b3062210Smrg
48105a3d36dfSmrg	  if test "$pic_object" != none; then
48115a3d36dfSmrg	    # Prepend the subdirectory the object is found in.
48125a3d36dfSmrg	    pic_object="$xdir$pic_object"
4813b3062210Smrg
48145a3d36dfSmrg	    if test "$prev" = dlfiles; then
48155a3d36dfSmrg	      if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
48165a3d36dfSmrg		dlfiles="$dlfiles $pic_object"
48175a3d36dfSmrg		prev=
48185a3d36dfSmrg		continue
48195a3d36dfSmrg	      else
48205a3d36dfSmrg		# If libtool objects are unsupported, then we need to preload.
48215a3d36dfSmrg		prev=dlprefiles
48225a3d36dfSmrg	      fi
48235a3d36dfSmrg	    fi
4824b3062210Smrg
48255a3d36dfSmrg	    # CHECK ME:  I think I busted this.  -Ossama
48265a3d36dfSmrg	    if test "$prev" = dlprefiles; then
48275a3d36dfSmrg	      # Preload the old-style object.
48285a3d36dfSmrg	      dlprefiles="$dlprefiles $pic_object"
48295a3d36dfSmrg	      prev=
48305a3d36dfSmrg	    fi
4831b3062210Smrg
48325a3d36dfSmrg	    # A PIC object.
48335a3d36dfSmrg	    func_append libobjs " $pic_object"
48345a3d36dfSmrg	    arg="$pic_object"
48355a3d36dfSmrg	  fi
4836b3062210Smrg
48375a3d36dfSmrg	  # Non-PIC object.
48385a3d36dfSmrg	  if test "$non_pic_object" != none; then
48395a3d36dfSmrg	    # Prepend the subdirectory the object is found in.
48405a3d36dfSmrg	    non_pic_object="$xdir$non_pic_object"
4841b3062210Smrg
48425a3d36dfSmrg	    # A standard non-PIC object
48435a3d36dfSmrg	    func_append non_pic_objects " $non_pic_object"
48445a3d36dfSmrg	    if test -z "$pic_object" || test "$pic_object" = none ; then
48455a3d36dfSmrg	      arg="$non_pic_object"
48465a3d36dfSmrg	    fi
48475a3d36dfSmrg	  else
48485a3d36dfSmrg	    # If the PIC object exists, use it instead.
48495a3d36dfSmrg	    # $xdir was prepended to $pic_object above.
48505a3d36dfSmrg	    non_pic_object="$pic_object"
48515a3d36dfSmrg	    func_append non_pic_objects " $non_pic_object"
48525a3d36dfSmrg	  fi
48535a3d36dfSmrg	else
48545a3d36dfSmrg	  # Only an error if not doing a dry-run.
48555a3d36dfSmrg	  if $opt_dry_run; then
48565a3d36dfSmrg	    # Extract subdirectory from the argument.
48575a3d36dfSmrg	    func_dirname "$arg" "/" ""
48585a3d36dfSmrg	    xdir="$func_dirname_result"
48595a3d36dfSmrg
48605a3d36dfSmrg	    func_lo2o "$arg"
48615a3d36dfSmrg	    pic_object=$xdir$objdir/$func_lo2o_result
48625a3d36dfSmrg	    non_pic_object=$xdir$func_lo2o_result
48635a3d36dfSmrg	    func_append libobjs " $pic_object"
48645a3d36dfSmrg	    func_append non_pic_objects " $non_pic_object"
48655a3d36dfSmrg	  else
48665a3d36dfSmrg	    func_fatal_error "\`$arg' is not a valid libtool object"
48675a3d36dfSmrg	  fi
48685a3d36dfSmrg	fi
48695a3d36dfSmrg	;;
4870b3062210Smrg
48715a3d36dfSmrg      *.$libext)
48725a3d36dfSmrg	# An archive.
48735a3d36dfSmrg	deplibs="$deplibs $arg"
48745a3d36dfSmrg	old_deplibs="$old_deplibs $arg"
48755a3d36dfSmrg	continue
48765a3d36dfSmrg	;;
4877b3062210Smrg
48785a3d36dfSmrg      *.la)
48795a3d36dfSmrg	# A libtool-controlled library.
4880b3062210Smrg
48815a3d36dfSmrg	if test "$prev" = dlfiles; then
48825a3d36dfSmrg	  # This library was specified with -dlopen.
48835a3d36dfSmrg	  dlfiles="$dlfiles $arg"
48845a3d36dfSmrg	  prev=
48855a3d36dfSmrg	elif test "$prev" = dlprefiles; then
48865a3d36dfSmrg	  # The library was specified with -dlpreopen.
48875a3d36dfSmrg	  dlprefiles="$dlprefiles $arg"
48885a3d36dfSmrg	  prev=
48895a3d36dfSmrg	else
48905a3d36dfSmrg	  deplibs="$deplibs $arg"
48915a3d36dfSmrg	fi
48925a3d36dfSmrg	continue
48935a3d36dfSmrg	;;
4894b3062210Smrg
48955a3d36dfSmrg      # Some other compiler argument.
48965a3d36dfSmrg      *)
48975a3d36dfSmrg	# Unknown arguments in both finalize_command and compile_command need
48985a3d36dfSmrg	# to be aesthetically quoted because they are evaled later.
48995a3d36dfSmrg	func_quote_for_eval "$arg"
49005a3d36dfSmrg	arg="$func_quote_for_eval_result"
49015a3d36dfSmrg	;;
49025a3d36dfSmrg      esac # arg
490323a0898aSmrg
49045a3d36dfSmrg      # Now actually substitute the argument into the commands.
49055a3d36dfSmrg      if test -n "$arg"; then
49065a3d36dfSmrg	func_append compile_command " $arg"
49075a3d36dfSmrg	func_append finalize_command " $arg"
49085a3d36dfSmrg      fi
49095a3d36dfSmrg    done # argument parsing loop
491023a0898aSmrg
49115a3d36dfSmrg    test -n "$prev" && \
49125a3d36dfSmrg      func_fatal_help "the \`$prevarg' option requires an argument"
491323a0898aSmrg
49145a3d36dfSmrg    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
49155a3d36dfSmrg      eval arg=\"$export_dynamic_flag_spec\"
49165a3d36dfSmrg      func_append compile_command " $arg"
49175a3d36dfSmrg      func_append finalize_command " $arg"
4918b3062210Smrg    fi
491923a0898aSmrg
49205a3d36dfSmrg    oldlibs=
49215a3d36dfSmrg    # calculate the name of the file, without its directory
49225a3d36dfSmrg    func_basename "$output"
49235a3d36dfSmrg    outputname="$func_basename_result"
49245a3d36dfSmrg    libobjs_save="$libobjs"
49255a3d36dfSmrg
49265a3d36dfSmrg    if test -n "$shlibpath_var"; then
49275a3d36dfSmrg      # get the directories listed in $shlibpath_var
49285a3d36dfSmrg      eval shlib_search_path=\`\$ECHO \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\`
49295a3d36dfSmrg    else
49305a3d36dfSmrg      shlib_search_path=
49315a3d36dfSmrg    fi
49325a3d36dfSmrg    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
49335a3d36dfSmrg    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
49345a3d36dfSmrg
49355a3d36dfSmrg    func_dirname "$output" "/" ""
49365a3d36dfSmrg    output_objdir="$func_dirname_result$objdir"
49375a3d36dfSmrg    # Create the object directory.
49385a3d36dfSmrg    func_mkdir_p "$output_objdir"
49395a3d36dfSmrg
49405a3d36dfSmrg    # Determine the type of output
49415a3d36dfSmrg    case $output in
49425a3d36dfSmrg    "")
49435a3d36dfSmrg      func_fatal_help "you must specify an output file"
49445a3d36dfSmrg      ;;
49455a3d36dfSmrg    *.$libext) linkmode=oldlib ;;
49465a3d36dfSmrg    *.lo | *.$objext) linkmode=obj ;;
49475a3d36dfSmrg    *.la) linkmode=lib ;;
49485a3d36dfSmrg    *) linkmode=prog ;; # Anything else should be a program.
49495a3d36dfSmrg    esac
49505a3d36dfSmrg
49515a3d36dfSmrg    specialdeplibs=
49525a3d36dfSmrg
49535a3d36dfSmrg    libs=
49545a3d36dfSmrg    # Find all interdependent deplibs by searching for libraries
49555a3d36dfSmrg    # that are linked more than once (e.g. -la -lb -la)
49565a3d36dfSmrg    for deplib in $deplibs; do
49575a3d36dfSmrg      if $opt_duplicate_deps ; then
49585a3d36dfSmrg	case "$libs " in
49595a3d36dfSmrg	*" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
49605a3d36dfSmrg	esac
49615a3d36dfSmrg      fi
49625a3d36dfSmrg      libs="$libs $deplib"
49635a3d36dfSmrg    done
49645a3d36dfSmrg
49655a3d36dfSmrg    if test "$linkmode" = lib; then
49665a3d36dfSmrg      libs="$predeps $libs $compiler_lib_search_path $postdeps"
49675a3d36dfSmrg
49685a3d36dfSmrg      # Compute libraries that are listed more than once in $predeps
49695a3d36dfSmrg      # $postdeps and mark them as special (i.e., whose duplicates are
49705a3d36dfSmrg      # not to be eliminated).
49715a3d36dfSmrg      pre_post_deps=
49725a3d36dfSmrg      if $opt_duplicate_compiler_generated_deps; then
49735a3d36dfSmrg	for pre_post_dep in $predeps $postdeps; do
49745a3d36dfSmrg	  case "$pre_post_deps " in
49755a3d36dfSmrg	  *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;;
49765a3d36dfSmrg	  esac
49775a3d36dfSmrg	  pre_post_deps="$pre_post_deps $pre_post_dep"
49785a3d36dfSmrg	done
49795a3d36dfSmrg      fi
49805a3d36dfSmrg      pre_post_deps=
49815a3d36dfSmrg    fi
49825a3d36dfSmrg
49835a3d36dfSmrg    deplibs=
49845a3d36dfSmrg    newdependency_libs=
49855a3d36dfSmrg    newlib_search_path=
49865a3d36dfSmrg    need_relink=no # whether we're linking any uninstalled libtool libraries
49875a3d36dfSmrg    notinst_deplibs= # not-installed libtool libraries
49885a3d36dfSmrg    notinst_path= # paths that contain not-installed libtool libraries
49895a3d36dfSmrg
49905a3d36dfSmrg    case $linkmode in
49915a3d36dfSmrg    lib)
49925a3d36dfSmrg	passes="conv dlpreopen link"
49935a3d36dfSmrg	for file in $dlfiles $dlprefiles; do
49945a3d36dfSmrg	  case $file in
49955a3d36dfSmrg	  *.la) ;;
49965a3d36dfSmrg	  *)
49975a3d36dfSmrg	    func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file"
49985a3d36dfSmrg	    ;;
49995a3d36dfSmrg	  esac
50005a3d36dfSmrg	done
50015a3d36dfSmrg	;;
50025a3d36dfSmrg    prog)
50035a3d36dfSmrg	compile_deplibs=
50045a3d36dfSmrg	finalize_deplibs=
50055a3d36dfSmrg	alldeplibs=no
50065a3d36dfSmrg	newdlfiles=
50075a3d36dfSmrg	newdlprefiles=
50085a3d36dfSmrg	passes="conv scan dlopen dlpreopen link"
50095a3d36dfSmrg	;;
50105a3d36dfSmrg    *)  passes="conv"
50115a3d36dfSmrg	;;
50125a3d36dfSmrg    esac
50135a3d36dfSmrg
50145a3d36dfSmrg    for pass in $passes; do
50155a3d36dfSmrg      # The preopen pass in lib mode reverses $deplibs; put it back here
50165a3d36dfSmrg      # so that -L comes before libs that need it for instance...
50175a3d36dfSmrg      if test "$linkmode,$pass" = "lib,link"; then
50185a3d36dfSmrg	## FIXME: Find the place where the list is rebuilt in the wrong
50195a3d36dfSmrg	##        order, and fix it there properly
50205a3d36dfSmrg        tmp_deplibs=
50215a3d36dfSmrg	for deplib in $deplibs; do
50225a3d36dfSmrg	  tmp_deplibs="$deplib $tmp_deplibs"
50235a3d36dfSmrg	done
50245a3d36dfSmrg	deplibs="$tmp_deplibs"
50255a3d36dfSmrg      fi
50265a3d36dfSmrg
50275a3d36dfSmrg      if test "$linkmode,$pass" = "lib,link" ||
50285a3d36dfSmrg	 test "$linkmode,$pass" = "prog,scan"; then
50295a3d36dfSmrg	libs="$deplibs"
50305a3d36dfSmrg	deplibs=
50315a3d36dfSmrg      fi
50325a3d36dfSmrg      if test "$linkmode" = prog; then
50335a3d36dfSmrg	case $pass in
50345a3d36dfSmrg	dlopen) libs="$dlfiles" ;;
50355a3d36dfSmrg	dlpreopen) libs="$dlprefiles" ;;
50365a3d36dfSmrg	link)
50375a3d36dfSmrg	  libs="$deplibs %DEPLIBS%"
50385a3d36dfSmrg	  test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs"
50395a3d36dfSmrg	  ;;
50405a3d36dfSmrg	esac
50415a3d36dfSmrg      fi
50425a3d36dfSmrg      if test "$linkmode,$pass" = "lib,dlpreopen"; then
50435a3d36dfSmrg	# Collect and forward deplibs of preopened libtool libs
50445a3d36dfSmrg	for lib in $dlprefiles; do
50455a3d36dfSmrg	  # Ignore non-libtool-libs
50465a3d36dfSmrg	  dependency_libs=
50475a3d36dfSmrg	  case $lib in
50485a3d36dfSmrg	  *.la)	func_source "$lib" ;;
50495a3d36dfSmrg	  esac
50505a3d36dfSmrg
50515a3d36dfSmrg	  # Collect preopened libtool deplibs, except any this library
50525a3d36dfSmrg	  # has declared as weak libs
50535a3d36dfSmrg	  for deplib in $dependency_libs; do
50545a3d36dfSmrg            deplib_base=`$ECHO "X$deplib" | $Xsed -e "$basename"`
50555a3d36dfSmrg	    case " $weak_libs " in
50565a3d36dfSmrg	    *" $deplib_base "*) ;;
50575a3d36dfSmrg	    *) deplibs="$deplibs $deplib" ;;
50585a3d36dfSmrg	    esac
50595a3d36dfSmrg	  done
50605a3d36dfSmrg	done
50615a3d36dfSmrg	libs="$dlprefiles"
50625a3d36dfSmrg      fi
50635a3d36dfSmrg      if test "$pass" = dlopen; then
50645a3d36dfSmrg	# Collect dlpreopened libraries
50655a3d36dfSmrg	save_deplibs="$deplibs"
50665a3d36dfSmrg	deplibs=
50675a3d36dfSmrg      fi
50685a3d36dfSmrg
50695a3d36dfSmrg      for deplib in $libs; do
50705a3d36dfSmrg	lib=
50715a3d36dfSmrg	found=no
50725a3d36dfSmrg	case $deplib in
50735a3d36dfSmrg	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
50745a3d36dfSmrg	  if test "$linkmode,$pass" = "prog,link"; then
50755a3d36dfSmrg	    compile_deplibs="$deplib $compile_deplibs"
50765a3d36dfSmrg	    finalize_deplibs="$deplib $finalize_deplibs"
50775a3d36dfSmrg	  else
50785a3d36dfSmrg	    compiler_flags="$compiler_flags $deplib"
50795a3d36dfSmrg	    if test "$linkmode" = lib ; then
50805a3d36dfSmrg		case "$new_inherited_linker_flags " in
50815a3d36dfSmrg		    *" $deplib "*) ;;
50825a3d36dfSmrg		    * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;;
50835a3d36dfSmrg		esac
50845a3d36dfSmrg	    fi
50855a3d36dfSmrg	  fi
50865a3d36dfSmrg	  continue
50875a3d36dfSmrg	  ;;
50885a3d36dfSmrg	-l*)
50895a3d36dfSmrg	  if test "$linkmode" != lib && test "$linkmode" != prog; then
50905a3d36dfSmrg	    func_warning "\`-l' is ignored for archives/objects"
50915a3d36dfSmrg	    continue
50925a3d36dfSmrg	  fi
50935a3d36dfSmrg	  func_stripname '-l' '' "$deplib"
50945a3d36dfSmrg	  name=$func_stripname_result
50955a3d36dfSmrg	  if test "$linkmode" = lib; then
50965a3d36dfSmrg	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
50975a3d36dfSmrg	  else
50985a3d36dfSmrg	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
50995a3d36dfSmrg	  fi
51005a3d36dfSmrg	  for searchdir in $searchdirs; do
51015a3d36dfSmrg	    for search_ext in .la $std_shrext .so .a; do
51025a3d36dfSmrg	      # Search the libtool library
51035a3d36dfSmrg	      lib="$searchdir/lib${name}${search_ext}"
51045a3d36dfSmrg	      if test -f "$lib"; then
51055a3d36dfSmrg		if test "$search_ext" = ".la"; then
51065a3d36dfSmrg		  found=yes
51075a3d36dfSmrg		else
51085a3d36dfSmrg		  found=no
51095a3d36dfSmrg		fi
51105a3d36dfSmrg		break 2
51115a3d36dfSmrg	      fi
51125a3d36dfSmrg	    done
51135a3d36dfSmrg	  done
51145a3d36dfSmrg	  if test "$found" != yes; then
51155a3d36dfSmrg	    # deplib doesn't seem to be a libtool library
51165a3d36dfSmrg	    if test "$linkmode,$pass" = "prog,link"; then
51175a3d36dfSmrg	      compile_deplibs="$deplib $compile_deplibs"
51185a3d36dfSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
51195a3d36dfSmrg	    else
51205a3d36dfSmrg	      deplibs="$deplib $deplibs"
51215a3d36dfSmrg	      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
51225a3d36dfSmrg	    fi
51235a3d36dfSmrg	    continue
51245a3d36dfSmrg	  else # deplib is a libtool library
51255a3d36dfSmrg	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
51265a3d36dfSmrg	    # We need to do some special things here, and not later.
51275a3d36dfSmrg	    if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
51285a3d36dfSmrg	      case " $predeps $postdeps " in
51295a3d36dfSmrg	      *" $deplib "*)
51305a3d36dfSmrg		if func_lalib_p "$lib"; then
51315a3d36dfSmrg		  library_names=
51325a3d36dfSmrg		  old_library=
51335a3d36dfSmrg		  func_source "$lib"
51345a3d36dfSmrg		  for l in $old_library $library_names; do
51355a3d36dfSmrg		    ll="$l"
51365a3d36dfSmrg		  done
51375a3d36dfSmrg		  if test "X$ll" = "X$old_library" ; then # only static version available
51385a3d36dfSmrg		    found=no
51395a3d36dfSmrg		    func_dirname "$lib" "" "."
51405a3d36dfSmrg		    ladir="$func_dirname_result"
51415a3d36dfSmrg		    lib=$ladir/$old_library
51425a3d36dfSmrg		    if test "$linkmode,$pass" = "prog,link"; then
51435a3d36dfSmrg		      compile_deplibs="$deplib $compile_deplibs"
51445a3d36dfSmrg		      finalize_deplibs="$deplib $finalize_deplibs"
51455a3d36dfSmrg		    else
51465a3d36dfSmrg		      deplibs="$deplib $deplibs"
51475a3d36dfSmrg		      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
51485a3d36dfSmrg		    fi
51495a3d36dfSmrg		    continue
51505a3d36dfSmrg		  fi
51515a3d36dfSmrg		fi
51525a3d36dfSmrg		;;
51535a3d36dfSmrg	      *) ;;
51545a3d36dfSmrg	      esac
51555a3d36dfSmrg	    fi
51565a3d36dfSmrg	  fi
51575a3d36dfSmrg	  ;; # -l
51585a3d36dfSmrg	*.ltframework)
51595a3d36dfSmrg	  if test "$linkmode,$pass" = "prog,link"; then
51605a3d36dfSmrg	    compile_deplibs="$deplib $compile_deplibs"
51615a3d36dfSmrg	    finalize_deplibs="$deplib $finalize_deplibs"
51625a3d36dfSmrg	  else
51635a3d36dfSmrg	    deplibs="$deplib $deplibs"
51645a3d36dfSmrg	    if test "$linkmode" = lib ; then
51655a3d36dfSmrg		case "$new_inherited_linker_flags " in
51665a3d36dfSmrg		    *" $deplib "*) ;;
51675a3d36dfSmrg		    * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;;
51685a3d36dfSmrg		esac
51695a3d36dfSmrg	    fi
51705a3d36dfSmrg	  fi
51715a3d36dfSmrg	  continue
51725a3d36dfSmrg	  ;;
51735a3d36dfSmrg	-L*)
51745a3d36dfSmrg	  case $linkmode in
51755a3d36dfSmrg	  lib)
51765a3d36dfSmrg	    deplibs="$deplib $deplibs"
51775a3d36dfSmrg	    test "$pass" = conv && continue
51785a3d36dfSmrg	    newdependency_libs="$deplib $newdependency_libs"
51795a3d36dfSmrg	    func_stripname '-L' '' "$deplib"
51805a3d36dfSmrg	    newlib_search_path="$newlib_search_path $func_stripname_result"
51815a3d36dfSmrg	    ;;
51825a3d36dfSmrg	  prog)
51835a3d36dfSmrg	    if test "$pass" = conv; then
51845a3d36dfSmrg	      deplibs="$deplib $deplibs"
51855a3d36dfSmrg	      continue
51865a3d36dfSmrg	    fi
51875a3d36dfSmrg	    if test "$pass" = scan; then
51885a3d36dfSmrg	      deplibs="$deplib $deplibs"
51895a3d36dfSmrg	    else
51905a3d36dfSmrg	      compile_deplibs="$deplib $compile_deplibs"
51915a3d36dfSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
51925a3d36dfSmrg	    fi
51935a3d36dfSmrg	    func_stripname '-L' '' "$deplib"
51945a3d36dfSmrg	    newlib_search_path="$newlib_search_path $func_stripname_result"
51955a3d36dfSmrg	    ;;
51965a3d36dfSmrg	  *)
51975a3d36dfSmrg	    func_warning "\`-L' is ignored for archives/objects"
51985a3d36dfSmrg	    ;;
51995a3d36dfSmrg	  esac # linkmode
52005a3d36dfSmrg	  continue
52015a3d36dfSmrg	  ;; # -L
52025a3d36dfSmrg	-R*)
52035a3d36dfSmrg	  if test "$pass" = link; then
52045a3d36dfSmrg	    func_stripname '-R' '' "$deplib"
52055a3d36dfSmrg	    dir=$func_stripname_result
52065a3d36dfSmrg	    # Make sure the xrpath contains only unique directories.
52075a3d36dfSmrg	    case "$xrpath " in
52085a3d36dfSmrg	    *" $dir "*) ;;
52095a3d36dfSmrg	    *) xrpath="$xrpath $dir" ;;
52105a3d36dfSmrg	    esac
52115a3d36dfSmrg	  fi
52125a3d36dfSmrg	  deplibs="$deplib $deplibs"
52135a3d36dfSmrg	  continue
52145a3d36dfSmrg	  ;;
52155a3d36dfSmrg	*.la) lib="$deplib" ;;
52165a3d36dfSmrg	*.$libext)
52175a3d36dfSmrg	  if test "$pass" = conv; then
52185a3d36dfSmrg	    deplibs="$deplib $deplibs"
52195a3d36dfSmrg	    continue
52205a3d36dfSmrg	  fi
52215a3d36dfSmrg	  case $linkmode in
52225a3d36dfSmrg	  lib)
52235a3d36dfSmrg	    # Linking convenience modules into shared libraries is allowed,
52245a3d36dfSmrg	    # but linking other static libraries is non-portable.
52255a3d36dfSmrg	    case " $dlpreconveniencelibs " in
52265a3d36dfSmrg	    *" $deplib "*) ;;
52275a3d36dfSmrg	    *)
52285a3d36dfSmrg	      valid_a_lib=no
52295a3d36dfSmrg	      case $deplibs_check_method in
52305a3d36dfSmrg		match_pattern*)
52315a3d36dfSmrg		  set dummy $deplibs_check_method; shift
52325a3d36dfSmrg		  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
52335a3d36dfSmrg		  if eval "\$ECHO \"X$deplib\"" 2>/dev/null | $Xsed -e 10q \
52345a3d36dfSmrg		    | $EGREP "$match_pattern_regex" > /dev/null; then
52355a3d36dfSmrg		    valid_a_lib=yes
52365a3d36dfSmrg		  fi
52375a3d36dfSmrg		;;
52385a3d36dfSmrg		pass_all)
52395a3d36dfSmrg		  valid_a_lib=yes
52405a3d36dfSmrg		;;
52415a3d36dfSmrg	      esac
52425a3d36dfSmrg	      if test "$valid_a_lib" != yes; then
52435a3d36dfSmrg		$ECHO
52445a3d36dfSmrg		$ECHO "*** Warning: Trying to link with static lib archive $deplib."
52455a3d36dfSmrg		$ECHO "*** I have the capability to make that library automatically link in when"
52465a3d36dfSmrg		$ECHO "*** you link to this library.  But I can only do this if you have a"
52475a3d36dfSmrg		$ECHO "*** shared version of the library, which you do not appear to have"
52485a3d36dfSmrg		$ECHO "*** because the file extensions .$libext of this argument makes me believe"
52495a3d36dfSmrg		$ECHO "*** that it is just a static archive that I should not use here."
52505a3d36dfSmrg	      else
52515a3d36dfSmrg		$ECHO
52525a3d36dfSmrg		$ECHO "*** Warning: Linking the shared library $output against the"
52535a3d36dfSmrg		$ECHO "*** static library $deplib is not portable!"
52545a3d36dfSmrg		deplibs="$deplib $deplibs"
52555a3d36dfSmrg	      fi
52565a3d36dfSmrg	      ;;
52575a3d36dfSmrg	    esac
52585a3d36dfSmrg	    continue
52595a3d36dfSmrg	    ;;
52605a3d36dfSmrg	  prog)
52615a3d36dfSmrg	    if test "$pass" != link; then
52625a3d36dfSmrg	      deplibs="$deplib $deplibs"
52635a3d36dfSmrg	    else
52645a3d36dfSmrg	      compile_deplibs="$deplib $compile_deplibs"
52655a3d36dfSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
52665a3d36dfSmrg	    fi
52675a3d36dfSmrg	    continue
52685a3d36dfSmrg	    ;;
52695a3d36dfSmrg	  esac # linkmode
52705a3d36dfSmrg	  ;; # *.$libext
52715a3d36dfSmrg	*.lo | *.$objext)
52725a3d36dfSmrg	  if test "$pass" = conv; then
52735a3d36dfSmrg	    deplibs="$deplib $deplibs"
52745a3d36dfSmrg	  elif test "$linkmode" = prog; then
52755a3d36dfSmrg	    if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
52765a3d36dfSmrg	      # If there is no dlopen support or we're linking statically,
52775a3d36dfSmrg	      # we need to preload.
52785a3d36dfSmrg	      newdlprefiles="$newdlprefiles $deplib"
52795a3d36dfSmrg	      compile_deplibs="$deplib $compile_deplibs"
52805a3d36dfSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
52815a3d36dfSmrg	    else
52825a3d36dfSmrg	      newdlfiles="$newdlfiles $deplib"
52835a3d36dfSmrg	    fi
52845a3d36dfSmrg	  fi
52855a3d36dfSmrg	  continue
52865a3d36dfSmrg	  ;;
52875a3d36dfSmrg	%DEPLIBS%)
52885a3d36dfSmrg	  alldeplibs=yes
52895a3d36dfSmrg	  continue
52905a3d36dfSmrg	  ;;
52915a3d36dfSmrg	esac # case $deplib
52925a3d36dfSmrg
52935a3d36dfSmrg	if test "$found" = yes || test -f "$lib"; then :
52945a3d36dfSmrg	else
52955a3d36dfSmrg	  func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'"
52965a3d36dfSmrg	fi
52975a3d36dfSmrg
52985a3d36dfSmrg	# Check to see that this really is a libtool archive.
52995a3d36dfSmrg	func_lalib_unsafe_p "$lib" \
53005a3d36dfSmrg	  || func_fatal_error "\`$lib' is not a valid libtool archive"
53015a3d36dfSmrg
53025a3d36dfSmrg	func_dirname "$lib" "" "."
53035a3d36dfSmrg	ladir="$func_dirname_result"
53045a3d36dfSmrg
53055a3d36dfSmrg	dlname=
53065a3d36dfSmrg	dlopen=
53075a3d36dfSmrg	dlpreopen=
53085a3d36dfSmrg	libdir=
53095a3d36dfSmrg	library_names=
53105a3d36dfSmrg	old_library=
53115a3d36dfSmrg	inherited_linker_flags=
53125a3d36dfSmrg	# If the library was installed with an old release of libtool,
53135a3d36dfSmrg	# it will not redefine variables installed, or shouldnotlink
53145a3d36dfSmrg	installed=yes
53155a3d36dfSmrg	shouldnotlink=no
53165a3d36dfSmrg	avoidtemprpath=
53175a3d36dfSmrg
53185a3d36dfSmrg
53195a3d36dfSmrg	# Read the .la file
53205a3d36dfSmrg	func_source "$lib"
53215a3d36dfSmrg
53225a3d36dfSmrg	# Convert "-framework foo" to "foo.ltframework"
53235a3d36dfSmrg	if test -n "$inherited_linker_flags"; then
53245a3d36dfSmrg	  tmp_inherited_linker_flags=`$ECHO "X$inherited_linker_flags" | $Xsed -e 's/-framework \([^ $]*\)/\1.ltframework/g'`
53255a3d36dfSmrg	  for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
53265a3d36dfSmrg	    case " $new_inherited_linker_flags " in
53275a3d36dfSmrg	      *" $tmp_inherited_linker_flag "*) ;;
53285a3d36dfSmrg	      *) new_inherited_linker_flags="$new_inherited_linker_flags $tmp_inherited_linker_flag";;
53295a3d36dfSmrg	    esac
53305a3d36dfSmrg	  done
53315a3d36dfSmrg	fi
53325a3d36dfSmrg	dependency_libs=`$ECHO "X $dependency_libs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
53335a3d36dfSmrg	if test "$linkmode,$pass" = "lib,link" ||
53345a3d36dfSmrg	   test "$linkmode,$pass" = "prog,scan" ||
53355a3d36dfSmrg	   { test "$linkmode" != prog && test "$linkmode" != lib; }; then
53365a3d36dfSmrg	  test -n "$dlopen" && dlfiles="$dlfiles $dlopen"
53375a3d36dfSmrg	  test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen"
53385a3d36dfSmrg	fi
53395a3d36dfSmrg
53405a3d36dfSmrg	if test "$pass" = conv; then
53415a3d36dfSmrg	  # Only check for convenience libraries
53425a3d36dfSmrg	  deplibs="$lib $deplibs"
53435a3d36dfSmrg	  if test -z "$libdir"; then
53445a3d36dfSmrg	    if test -z "$old_library"; then
53455a3d36dfSmrg	      func_fatal_error "cannot find name of link library for \`$lib'"
53465a3d36dfSmrg	    fi
53475a3d36dfSmrg	    # It is a libtool convenience library, so add in its objects.
53485a3d36dfSmrg	    convenience="$convenience $ladir/$objdir/$old_library"
53495a3d36dfSmrg	    old_convenience="$old_convenience $ladir/$objdir/$old_library"
53505a3d36dfSmrg	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
53515a3d36dfSmrg	    func_fatal_error "\`$lib' is not a convenience library"
53525a3d36dfSmrg	  fi
53535a3d36dfSmrg	  tmp_libs=
53545a3d36dfSmrg	  for deplib in $dependency_libs; do
53555a3d36dfSmrg	    deplibs="$deplib $deplibs"
53565a3d36dfSmrg	    if $opt_duplicate_deps ; then
53575a3d36dfSmrg	      case "$tmp_libs " in
53585a3d36dfSmrg	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
53595a3d36dfSmrg	      esac
53605a3d36dfSmrg	    fi
53615a3d36dfSmrg	    tmp_libs="$tmp_libs $deplib"
53625a3d36dfSmrg	  done
53635a3d36dfSmrg	  continue
53645a3d36dfSmrg	fi # $pass = conv
53655a3d36dfSmrg
53665a3d36dfSmrg
53675a3d36dfSmrg	# Get the name of the library we link against.
53685a3d36dfSmrg	linklib=
53695a3d36dfSmrg	for l in $old_library $library_names; do
53705a3d36dfSmrg	  linklib="$l"
53715a3d36dfSmrg	done
53725a3d36dfSmrg	if test -z "$linklib"; then
53735a3d36dfSmrg	  func_fatal_error "cannot find name of link library for \`$lib'"
53745a3d36dfSmrg	fi
53755a3d36dfSmrg
53765a3d36dfSmrg	# This library was specified with -dlopen.
53775a3d36dfSmrg	if test "$pass" = dlopen; then
53785a3d36dfSmrg	  if test -z "$libdir"; then
53795a3d36dfSmrg	    func_fatal_error "cannot -dlopen a convenience library: \`$lib'"
53805a3d36dfSmrg	  fi
53815a3d36dfSmrg	  if test -z "$dlname" ||
53825a3d36dfSmrg	     test "$dlopen_support" != yes ||
53835a3d36dfSmrg	     test "$build_libtool_libs" = no; then
53845a3d36dfSmrg	    # If there is no dlname, no dlopen support or we're linking
53855a3d36dfSmrg	    # statically, we need to preload.  We also need to preload any
53865a3d36dfSmrg	    # dependent libraries so libltdl's deplib preloader doesn't
53875a3d36dfSmrg	    # bomb out in the load deplibs phase.
53885a3d36dfSmrg	    dlprefiles="$dlprefiles $lib $dependency_libs"
53895a3d36dfSmrg	  else
53905a3d36dfSmrg	    newdlfiles="$newdlfiles $lib"
53915a3d36dfSmrg	  fi
53925a3d36dfSmrg	  continue
53935a3d36dfSmrg	fi # $pass = dlopen
53945a3d36dfSmrg
53955a3d36dfSmrg	# We need an absolute path.
53965a3d36dfSmrg	case $ladir in
53975a3d36dfSmrg	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
53985a3d36dfSmrg	*)
53995a3d36dfSmrg	  abs_ladir=`cd "$ladir" && pwd`
54005a3d36dfSmrg	  if test -z "$abs_ladir"; then
54015a3d36dfSmrg	    func_warning "cannot determine absolute directory name of \`$ladir'"
54025a3d36dfSmrg	    func_warning "passing it literally to the linker, although it might fail"
54035a3d36dfSmrg	    abs_ladir="$ladir"
54045a3d36dfSmrg	  fi
54055a3d36dfSmrg	  ;;
54065a3d36dfSmrg	esac
54075a3d36dfSmrg	func_basename "$lib"
54085a3d36dfSmrg	laname="$func_basename_result"
54095a3d36dfSmrg
54105a3d36dfSmrg	# Find the relevant object directory and library name.
54115a3d36dfSmrg	if test "X$installed" = Xyes; then
54125a3d36dfSmrg	  if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
54135a3d36dfSmrg	    func_warning "library \`$lib' was moved."
54145a3d36dfSmrg	    dir="$ladir"
54155a3d36dfSmrg	    absdir="$abs_ladir"
54165a3d36dfSmrg	    libdir="$abs_ladir"
54175a3d36dfSmrg	  else
54185a3d36dfSmrg	    dir="$libdir"
54195a3d36dfSmrg	    absdir="$libdir"
54205a3d36dfSmrg	  fi
54215a3d36dfSmrg	  test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
54225a3d36dfSmrg	else
54235a3d36dfSmrg	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
54245a3d36dfSmrg	    dir="$ladir"
54255a3d36dfSmrg	    absdir="$abs_ladir"
54265a3d36dfSmrg	    # Remove this search path later
54275a3d36dfSmrg	    notinst_path="$notinst_path $abs_ladir"
54285a3d36dfSmrg	  else
54295a3d36dfSmrg	    dir="$ladir/$objdir"
54305a3d36dfSmrg	    absdir="$abs_ladir/$objdir"
54315a3d36dfSmrg	    # Remove this search path later
54325a3d36dfSmrg	    notinst_path="$notinst_path $abs_ladir"
54335a3d36dfSmrg	  fi
54345a3d36dfSmrg	fi # $installed = yes
54355a3d36dfSmrg	func_stripname 'lib' '.la' "$laname"
54365a3d36dfSmrg	name=$func_stripname_result
54375a3d36dfSmrg
54385a3d36dfSmrg	# This library was specified with -dlpreopen.
54395a3d36dfSmrg	if test "$pass" = dlpreopen; then
54405a3d36dfSmrg	  if test -z "$libdir" && test "$linkmode" = prog; then
54415a3d36dfSmrg	    func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'"
54425a3d36dfSmrg	  fi
54435a3d36dfSmrg	  # Prefer using a static library (so that no silly _DYNAMIC symbols
54445a3d36dfSmrg	  # are required to link).
54455a3d36dfSmrg	  if test -n "$old_library"; then
54465a3d36dfSmrg	    newdlprefiles="$newdlprefiles $dir/$old_library"
54475a3d36dfSmrg	    # Keep a list of preopened convenience libraries to check
54485a3d36dfSmrg	    # that they are being used correctly in the link pass.
54495a3d36dfSmrg	    test -z "$libdir" && \
54505a3d36dfSmrg		dlpreconveniencelibs="$dlpreconveniencelibs $dir/$old_library"
54515a3d36dfSmrg	  # Otherwise, use the dlname, so that lt_dlopen finds it.
54525a3d36dfSmrg	  elif test -n "$dlname"; then
54535a3d36dfSmrg	    newdlprefiles="$newdlprefiles $dir/$dlname"
54545a3d36dfSmrg	  else
54555a3d36dfSmrg	    newdlprefiles="$newdlprefiles $dir/$linklib"
54565a3d36dfSmrg	  fi
54575a3d36dfSmrg	fi # $pass = dlpreopen
54585a3d36dfSmrg
54595a3d36dfSmrg	if test -z "$libdir"; then
54605a3d36dfSmrg	  # Link the convenience library
54615a3d36dfSmrg	  if test "$linkmode" = lib; then
54625a3d36dfSmrg	    deplibs="$dir/$old_library $deplibs"
54635a3d36dfSmrg	  elif test "$linkmode,$pass" = "prog,link"; then
54645a3d36dfSmrg	    compile_deplibs="$dir/$old_library $compile_deplibs"
54655a3d36dfSmrg	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
54665a3d36dfSmrg	  else
54675a3d36dfSmrg	    deplibs="$lib $deplibs" # used for prog,scan pass
54685a3d36dfSmrg	  fi
54695a3d36dfSmrg	  continue
54705a3d36dfSmrg	fi
54715a3d36dfSmrg
54725a3d36dfSmrg
54735a3d36dfSmrg	if test "$linkmode" = prog && test "$pass" != link; then
54745a3d36dfSmrg	  newlib_search_path="$newlib_search_path $ladir"
54755a3d36dfSmrg	  deplibs="$lib $deplibs"
54765a3d36dfSmrg
54775a3d36dfSmrg	  linkalldeplibs=no
54785a3d36dfSmrg	  if test "$link_all_deplibs" != no || test -z "$library_names" ||
54795a3d36dfSmrg	     test "$build_libtool_libs" = no; then
54805a3d36dfSmrg	    linkalldeplibs=yes
54815a3d36dfSmrg	  fi
54825a3d36dfSmrg
54835a3d36dfSmrg	  tmp_libs=
54845a3d36dfSmrg	  for deplib in $dependency_libs; do
54855a3d36dfSmrg	    case $deplib in
54865a3d36dfSmrg	    -L*) func_stripname '-L' '' "$deplib"
54875a3d36dfSmrg	         newlib_search_path="$newlib_search_path $func_stripname_result"
54885a3d36dfSmrg		 ;;
54895a3d36dfSmrg	    esac
54905a3d36dfSmrg	    # Need to link against all dependency_libs?
54915a3d36dfSmrg	    if test "$linkalldeplibs" = yes; then
54925a3d36dfSmrg	      deplibs="$deplib $deplibs"
54935a3d36dfSmrg	    else
54945a3d36dfSmrg	      # Need to hardcode shared library paths
54955a3d36dfSmrg	      # or/and link against static libraries
54965a3d36dfSmrg	      newdependency_libs="$deplib $newdependency_libs"
54975a3d36dfSmrg	    fi
54985a3d36dfSmrg	    if $opt_duplicate_deps ; then
54995a3d36dfSmrg	      case "$tmp_libs " in
55005a3d36dfSmrg	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
55015a3d36dfSmrg	      esac
55025a3d36dfSmrg	    fi
55035a3d36dfSmrg	    tmp_libs="$tmp_libs $deplib"
55045a3d36dfSmrg	  done # for deplib
55055a3d36dfSmrg	  continue
55065a3d36dfSmrg	fi # $linkmode = prog...
55075a3d36dfSmrg
55085a3d36dfSmrg	if test "$linkmode,$pass" = "prog,link"; then
55095a3d36dfSmrg	  if test -n "$library_names" &&
55105a3d36dfSmrg	     { { test "$prefer_static_libs" = no ||
55115a3d36dfSmrg	         test "$prefer_static_libs,$installed" = "built,yes"; } ||
55125a3d36dfSmrg	       test -z "$old_library"; }; then
55135a3d36dfSmrg	    # We need to hardcode the library path
55145a3d36dfSmrg	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
55155a3d36dfSmrg	      # Make sure the rpath contains only unique directories.
55165a3d36dfSmrg	      case "$temp_rpath:" in
55175a3d36dfSmrg	      *"$absdir:"*) ;;
55185a3d36dfSmrg	      *) temp_rpath="$temp_rpath$absdir:" ;;
55195a3d36dfSmrg	      esac
55205a3d36dfSmrg	    fi
55215a3d36dfSmrg
55225a3d36dfSmrg	    # Hardcode the library path.
55235a3d36dfSmrg	    # Skip directories that are in the system default run-time
55245a3d36dfSmrg	    # search path.
55255a3d36dfSmrg	    case " $sys_lib_dlsearch_path " in
55265a3d36dfSmrg	    *" $absdir "*) ;;
55275a3d36dfSmrg	    *)
55285a3d36dfSmrg	      case "$compile_rpath " in
55295a3d36dfSmrg	      *" $absdir "*) ;;
55305a3d36dfSmrg	      *) compile_rpath="$compile_rpath $absdir"
55315a3d36dfSmrg	      esac
55325a3d36dfSmrg	      ;;
55335a3d36dfSmrg	    esac
55345a3d36dfSmrg	    case " $sys_lib_dlsearch_path " in
55355a3d36dfSmrg	    *" $libdir "*) ;;
55365a3d36dfSmrg	    *)
55375a3d36dfSmrg	      case "$finalize_rpath " in
55385a3d36dfSmrg	      *" $libdir "*) ;;
55395a3d36dfSmrg	      *) finalize_rpath="$finalize_rpath $libdir"
55405a3d36dfSmrg	      esac
55415a3d36dfSmrg	      ;;
55425a3d36dfSmrg	    esac
55435a3d36dfSmrg	  fi # $linkmode,$pass = prog,link...
55445a3d36dfSmrg
55455a3d36dfSmrg	  if test "$alldeplibs" = yes &&
55465a3d36dfSmrg	     { test "$deplibs_check_method" = pass_all ||
55475a3d36dfSmrg	       { test "$build_libtool_libs" = yes &&
55485a3d36dfSmrg		 test -n "$library_names"; }; }; then
55495a3d36dfSmrg	    # We only need to search for static libraries
55505a3d36dfSmrg	    continue
55515a3d36dfSmrg	  fi
55525a3d36dfSmrg	fi
55535a3d36dfSmrg
55545a3d36dfSmrg	link_static=no # Whether the deplib will be linked statically
55555a3d36dfSmrg	use_static_libs=$prefer_static_libs
55565a3d36dfSmrg	if test "$use_static_libs" = built && test "$installed" = yes; then
55575a3d36dfSmrg	  use_static_libs=no
55585a3d36dfSmrg	fi
55595a3d36dfSmrg	if test -n "$library_names" &&
55605a3d36dfSmrg	   { test "$use_static_libs" = no || test -z "$old_library"; }; then
55615a3d36dfSmrg	  case $host in
55625a3d36dfSmrg	  *cygwin* | *mingw* | *cegcc*)
55635a3d36dfSmrg	      # No point in relinking DLLs because paths are not encoded
55645a3d36dfSmrg	      notinst_deplibs="$notinst_deplibs $lib"
55655a3d36dfSmrg	      need_relink=no
55665a3d36dfSmrg	    ;;
55675a3d36dfSmrg	  *)
55685a3d36dfSmrg	    if test "$installed" = no; then
55695a3d36dfSmrg	      notinst_deplibs="$notinst_deplibs $lib"
55705a3d36dfSmrg	      need_relink=yes
55715a3d36dfSmrg	    fi
55725a3d36dfSmrg	    ;;
55735a3d36dfSmrg	  esac
55745a3d36dfSmrg	  # This is a shared library
55755a3d36dfSmrg
55765a3d36dfSmrg	  # Warn about portability, can't link against -module's on some
55775a3d36dfSmrg	  # systems (darwin).  Don't bleat about dlopened modules though!
55785a3d36dfSmrg	  dlopenmodule=""
55795a3d36dfSmrg	  for dlpremoduletest in $dlprefiles; do
55805a3d36dfSmrg	    if test "X$dlpremoduletest" = "X$lib"; then
55815a3d36dfSmrg	      dlopenmodule="$dlpremoduletest"
55825a3d36dfSmrg	      break
55835a3d36dfSmrg	    fi
55845a3d36dfSmrg	  done
55855a3d36dfSmrg	  if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then
55865a3d36dfSmrg	    $ECHO
55875a3d36dfSmrg	    if test "$linkmode" = prog; then
55885a3d36dfSmrg	      $ECHO "*** Warning: Linking the executable $output against the loadable module"
55895a3d36dfSmrg	    else
55905a3d36dfSmrg	      $ECHO "*** Warning: Linking the shared library $output against the loadable module"
55915a3d36dfSmrg	    fi
55925a3d36dfSmrg	    $ECHO "*** $linklib is not portable!"
55935a3d36dfSmrg	  fi
55945a3d36dfSmrg	  if test "$linkmode" = lib &&
55955a3d36dfSmrg	     test "$hardcode_into_libs" = yes; then
55965a3d36dfSmrg	    # Hardcode the library path.
55975a3d36dfSmrg	    # Skip directories that are in the system default run-time
55985a3d36dfSmrg	    # search path.
55995a3d36dfSmrg	    case " $sys_lib_dlsearch_path " in
56005a3d36dfSmrg	    *" $absdir "*) ;;
56015a3d36dfSmrg	    *)
56025a3d36dfSmrg	      case "$compile_rpath " in
56035a3d36dfSmrg	      *" $absdir "*) ;;
56045a3d36dfSmrg	      *) compile_rpath="$compile_rpath $absdir"
56055a3d36dfSmrg	      esac
56065a3d36dfSmrg	      ;;
56075a3d36dfSmrg	    esac
56085a3d36dfSmrg	    case " $sys_lib_dlsearch_path " in
56095a3d36dfSmrg	    *" $libdir "*) ;;
56105a3d36dfSmrg	    *)
56115a3d36dfSmrg	      case "$finalize_rpath " in
56125a3d36dfSmrg	      *" $libdir "*) ;;
56135a3d36dfSmrg	      *) finalize_rpath="$finalize_rpath $libdir"
56145a3d36dfSmrg	      esac
56155a3d36dfSmrg	      ;;
56165a3d36dfSmrg	    esac
56175a3d36dfSmrg	  fi
56185a3d36dfSmrg
56195a3d36dfSmrg	  if test -n "$old_archive_from_expsyms_cmds"; then
56205a3d36dfSmrg	    # figure out the soname
56215a3d36dfSmrg	    set dummy $library_names
56225a3d36dfSmrg	    shift
56235a3d36dfSmrg	    realname="$1"
56245a3d36dfSmrg	    shift
56255a3d36dfSmrg	    libname=`eval "\\$ECHO \"$libname_spec\""`
56265a3d36dfSmrg	    # use dlname if we got it. it's perfectly good, no?
56275a3d36dfSmrg	    if test -n "$dlname"; then
56285a3d36dfSmrg	      soname="$dlname"
56295a3d36dfSmrg	    elif test -n "$soname_spec"; then
56305a3d36dfSmrg	      # bleh windows
56315a3d36dfSmrg	      case $host in
56325a3d36dfSmrg	      *cygwin* | mingw* | *cegcc*)
56335a3d36dfSmrg	        func_arith $current - $age
56345a3d36dfSmrg		major=$func_arith_result
56355a3d36dfSmrg		versuffix="-$major"
56365a3d36dfSmrg		;;
56375a3d36dfSmrg	      esac
56385a3d36dfSmrg	      eval soname=\"$soname_spec\"
56395a3d36dfSmrg	    else
56405a3d36dfSmrg	      soname="$realname"
56415a3d36dfSmrg	    fi
56425a3d36dfSmrg
56435a3d36dfSmrg	    # Make a new name for the extract_expsyms_cmds to use
56445a3d36dfSmrg	    soroot="$soname"
56455a3d36dfSmrg	    func_basename "$soroot"
56465a3d36dfSmrg	    soname="$func_basename_result"
56475a3d36dfSmrg	    func_stripname 'lib' '.dll' "$soname"
56485a3d36dfSmrg	    newlib=libimp-$func_stripname_result.a
56495a3d36dfSmrg
56505a3d36dfSmrg	    # If the library has no export list, then create one now
56515a3d36dfSmrg	    if test -f "$output_objdir/$soname-def"; then :
56525a3d36dfSmrg	    else
56535a3d36dfSmrg	      func_verbose "extracting exported symbol list from \`$soname'"
56545a3d36dfSmrg	      func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
56555a3d36dfSmrg	    fi
56565a3d36dfSmrg
56575a3d36dfSmrg	    # Create $newlib
56585a3d36dfSmrg	    if test -f "$output_objdir/$newlib"; then :; else
56595a3d36dfSmrg	      func_verbose "generating import library for \`$soname'"
56605a3d36dfSmrg	      func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
56615a3d36dfSmrg	    fi
56625a3d36dfSmrg	    # make sure the library variables are pointing to the new library
56635a3d36dfSmrg	    dir=$output_objdir
56645a3d36dfSmrg	    linklib=$newlib
56655a3d36dfSmrg	  fi # test -n "$old_archive_from_expsyms_cmds"
56665a3d36dfSmrg
56675a3d36dfSmrg	  if test "$linkmode" = prog || test "$mode" != relink; then
56685a3d36dfSmrg	    add_shlibpath=
56695a3d36dfSmrg	    add_dir=
56705a3d36dfSmrg	    add=
56715a3d36dfSmrg	    lib_linked=yes
56725a3d36dfSmrg	    case $hardcode_action in
56735a3d36dfSmrg	    immediate | unsupported)
56745a3d36dfSmrg	      if test "$hardcode_direct" = no; then
56755a3d36dfSmrg		add="$dir/$linklib"
56765a3d36dfSmrg		case $host in
56775a3d36dfSmrg		  *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
56785a3d36dfSmrg		  *-*-sysv4*uw2*) add_dir="-L$dir" ;;
56795a3d36dfSmrg		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
56805a3d36dfSmrg		    *-*-unixware7*) add_dir="-L$dir" ;;
56815a3d36dfSmrg		  *-*-darwin* )
56825a3d36dfSmrg		    # if the lib is a (non-dlopened) module then we can not
56835a3d36dfSmrg		    # link against it, someone is ignoring the earlier warnings
56845a3d36dfSmrg		    if /usr/bin/file -L $add 2> /dev/null |
56855a3d36dfSmrg			 $GREP ": [^:]* bundle" >/dev/null ; then
56865a3d36dfSmrg		      if test "X$dlopenmodule" != "X$lib"; then
56875a3d36dfSmrg			$ECHO "*** Warning: lib $linklib is a module, not a shared library"
56885a3d36dfSmrg			if test -z "$old_library" ; then
56895a3d36dfSmrg			  $ECHO
56905a3d36dfSmrg			  $ECHO "*** And there doesn't seem to be a static archive available"
56915a3d36dfSmrg			  $ECHO "*** The link will probably fail, sorry"
56925a3d36dfSmrg			else
56935a3d36dfSmrg			  add="$dir/$old_library"
56945a3d36dfSmrg			fi
56955a3d36dfSmrg		      elif test -n "$old_library"; then
56965a3d36dfSmrg			add="$dir/$old_library"
56975a3d36dfSmrg		      fi
56985a3d36dfSmrg		    fi
56995a3d36dfSmrg		esac
57005a3d36dfSmrg	      elif test "$hardcode_minus_L" = no; then
57015a3d36dfSmrg		case $host in
57025a3d36dfSmrg		*-*-sunos*) add_shlibpath="$dir" ;;
57035a3d36dfSmrg		esac
57045a3d36dfSmrg		add_dir="-L$dir"
57055a3d36dfSmrg		add="-l$name"
57065a3d36dfSmrg	      elif test "$hardcode_shlibpath_var" = no; then
57075a3d36dfSmrg		add_shlibpath="$dir"
57085a3d36dfSmrg		add="-l$name"
57095a3d36dfSmrg	      else
57105a3d36dfSmrg		lib_linked=no
57115a3d36dfSmrg	      fi
57125a3d36dfSmrg	      ;;
57135a3d36dfSmrg	    relink)
57145a3d36dfSmrg	      if test "$hardcode_direct" = yes &&
57155a3d36dfSmrg	         test "$hardcode_direct_absolute" = no; then
57165a3d36dfSmrg		add="$dir/$linklib"
57175a3d36dfSmrg	      elif test "$hardcode_minus_L" = yes; then
57185a3d36dfSmrg		add_dir="-L$dir"
57195a3d36dfSmrg		# Try looking first in the location we're being installed to.
57205a3d36dfSmrg		if test -n "$inst_prefix_dir"; then
57215a3d36dfSmrg		  case $libdir in
57225a3d36dfSmrg		    [\\/]*)
57235a3d36dfSmrg		      add_dir="$add_dir -L$inst_prefix_dir$libdir"
57245a3d36dfSmrg		      ;;
57255a3d36dfSmrg		  esac
57265a3d36dfSmrg		fi
57275a3d36dfSmrg		add="-l$name"
57285a3d36dfSmrg	      elif test "$hardcode_shlibpath_var" = yes; then
57295a3d36dfSmrg		add_shlibpath="$dir"
57305a3d36dfSmrg		add="-l$name"
57315a3d36dfSmrg	      else
57325a3d36dfSmrg		lib_linked=no
57335a3d36dfSmrg	      fi
57345a3d36dfSmrg	      ;;
57355a3d36dfSmrg	    *) lib_linked=no ;;
57365a3d36dfSmrg	    esac
57375a3d36dfSmrg
57385a3d36dfSmrg	    if test "$lib_linked" != yes; then
57395a3d36dfSmrg	      func_fatal_configuration "unsupported hardcode properties"
57405a3d36dfSmrg	    fi
57415a3d36dfSmrg
57425a3d36dfSmrg	    if test -n "$add_shlibpath"; then
57435a3d36dfSmrg	      case :$compile_shlibpath: in
57445a3d36dfSmrg	      *":$add_shlibpath:"*) ;;
57455a3d36dfSmrg	      *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;;
57465a3d36dfSmrg	      esac
57475a3d36dfSmrg	    fi
57485a3d36dfSmrg	    if test "$linkmode" = prog; then
57495a3d36dfSmrg	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
57505a3d36dfSmrg	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
57515a3d36dfSmrg	    else
57525a3d36dfSmrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
57535a3d36dfSmrg	      test -n "$add" && deplibs="$add $deplibs"
57545a3d36dfSmrg	      if test "$hardcode_direct" != yes &&
57555a3d36dfSmrg		 test "$hardcode_minus_L" != yes &&
57565a3d36dfSmrg		 test "$hardcode_shlibpath_var" = yes; then
57575a3d36dfSmrg		case :$finalize_shlibpath: in
57585a3d36dfSmrg		*":$libdir:"*) ;;
57595a3d36dfSmrg		*) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
57605a3d36dfSmrg		esac
57615a3d36dfSmrg	      fi
57625a3d36dfSmrg	    fi
57635a3d36dfSmrg	  fi
57645a3d36dfSmrg
57655a3d36dfSmrg	  if test "$linkmode" = prog || test "$mode" = relink; then
57665a3d36dfSmrg	    add_shlibpath=
57675a3d36dfSmrg	    add_dir=
57685a3d36dfSmrg	    add=
57695a3d36dfSmrg	    # Finalize command for both is simple: just hardcode it.
57705a3d36dfSmrg	    if test "$hardcode_direct" = yes &&
57715a3d36dfSmrg	       test "$hardcode_direct_absolute" = no; then
57725a3d36dfSmrg	      add="$libdir/$linklib"
57735a3d36dfSmrg	    elif test "$hardcode_minus_L" = yes; then
57745a3d36dfSmrg	      add_dir="-L$libdir"
57755a3d36dfSmrg	      add="-l$name"
57765a3d36dfSmrg	    elif test "$hardcode_shlibpath_var" = yes; then
57775a3d36dfSmrg	      case :$finalize_shlibpath: in
57785a3d36dfSmrg	      *":$libdir:"*) ;;
57795a3d36dfSmrg	      *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
57805a3d36dfSmrg	      esac
57815a3d36dfSmrg	      add="-l$name"
57825a3d36dfSmrg	    elif test "$hardcode_automatic" = yes; then
57835a3d36dfSmrg	      if test -n "$inst_prefix_dir" &&
57845a3d36dfSmrg		 test -f "$inst_prefix_dir$libdir/$linklib" ; then
57855a3d36dfSmrg		add="$inst_prefix_dir$libdir/$linklib"
57865a3d36dfSmrg	      else
57875a3d36dfSmrg		add="$libdir/$linklib"
57885a3d36dfSmrg	      fi
57895a3d36dfSmrg	    else
57905a3d36dfSmrg	      # We cannot seem to hardcode it, guess we'll fake it.
57915a3d36dfSmrg	      add_dir="-L$libdir"
57925a3d36dfSmrg	      # Try looking first in the location we're being installed to.
57935a3d36dfSmrg	      if test -n "$inst_prefix_dir"; then
57945a3d36dfSmrg		case $libdir in
57955a3d36dfSmrg		  [\\/]*)
57965a3d36dfSmrg		    add_dir="$add_dir -L$inst_prefix_dir$libdir"
57975a3d36dfSmrg		    ;;
57985a3d36dfSmrg		esac
57995a3d36dfSmrg	      fi
58005a3d36dfSmrg	      add="-l$name"
58015a3d36dfSmrg	    fi
58025a3d36dfSmrg
58035a3d36dfSmrg	    if test "$linkmode" = prog; then
58045a3d36dfSmrg	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
58055a3d36dfSmrg	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
58065a3d36dfSmrg	    else
58075a3d36dfSmrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
58085a3d36dfSmrg	      test -n "$add" && deplibs="$add $deplibs"
58095a3d36dfSmrg	    fi
58105a3d36dfSmrg	  fi
58115a3d36dfSmrg	elif test "$linkmode" = prog; then
58125a3d36dfSmrg	  # Here we assume that one of hardcode_direct or hardcode_minus_L
58135a3d36dfSmrg	  # is not unsupported.  This is valid on all known static and
58145a3d36dfSmrg	  # shared platforms.
58155a3d36dfSmrg	  if test "$hardcode_direct" != unsupported; then
58165a3d36dfSmrg	    test -n "$old_library" && linklib="$old_library"
58175a3d36dfSmrg	    compile_deplibs="$dir/$linklib $compile_deplibs"
58185a3d36dfSmrg	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
58195a3d36dfSmrg	  else
58205a3d36dfSmrg	    compile_deplibs="-l$name -L$dir $compile_deplibs"
58215a3d36dfSmrg	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
58225a3d36dfSmrg	  fi
58235a3d36dfSmrg	elif test "$build_libtool_libs" = yes; then
58245a3d36dfSmrg	  # Not a shared library
58255a3d36dfSmrg	  if test "$deplibs_check_method" != pass_all; then
58265a3d36dfSmrg	    # We're trying link a shared library against a static one
58275a3d36dfSmrg	    # but the system doesn't support it.
58285a3d36dfSmrg
58295a3d36dfSmrg	    # Just print a warning and add the library to dependency_libs so
58305a3d36dfSmrg	    # that the program can be linked against the static library.
58315a3d36dfSmrg	    $ECHO
58325a3d36dfSmrg	    $ECHO "*** Warning: This system can not link to static lib archive $lib."
58335a3d36dfSmrg	    $ECHO "*** I have the capability to make that library automatically link in when"
58345a3d36dfSmrg	    $ECHO "*** you link to this library.  But I can only do this if you have a"
58355a3d36dfSmrg	    $ECHO "*** shared version of the library, which you do not appear to have."
58365a3d36dfSmrg	    if test "$module" = yes; then
58375a3d36dfSmrg	      $ECHO "*** But as you try to build a module library, libtool will still create "
58385a3d36dfSmrg	      $ECHO "*** a static module, that should work as long as the dlopening application"
58395a3d36dfSmrg	      $ECHO "*** is linked with the -dlopen flag to resolve symbols at runtime."
58405a3d36dfSmrg	      if test -z "$global_symbol_pipe"; then
58415a3d36dfSmrg		$ECHO
58425a3d36dfSmrg		$ECHO "*** However, this would only work if libtool was able to extract symbol"
58435a3d36dfSmrg		$ECHO "*** lists from a program, using \`nm' or equivalent, but libtool could"
58445a3d36dfSmrg		$ECHO "*** not find such a program.  So, this module is probably useless."
58455a3d36dfSmrg		$ECHO "*** \`nm' from GNU binutils and a full rebuild may help."
58465a3d36dfSmrg	      fi
58475a3d36dfSmrg	      if test "$build_old_libs" = no; then
58485a3d36dfSmrg		build_libtool_libs=module
58495a3d36dfSmrg		build_old_libs=yes
58505a3d36dfSmrg	      else
58515a3d36dfSmrg		build_libtool_libs=no
58525a3d36dfSmrg	      fi
58535a3d36dfSmrg	    fi
58545a3d36dfSmrg	  else
58555a3d36dfSmrg	    deplibs="$dir/$old_library $deplibs"
58565a3d36dfSmrg	    link_static=yes
58575a3d36dfSmrg	  fi
58585a3d36dfSmrg	fi # link shared/static library?
58595a3d36dfSmrg
58605a3d36dfSmrg	if test "$linkmode" = lib; then
58615a3d36dfSmrg	  if test -n "$dependency_libs" &&
58625a3d36dfSmrg	     { test "$hardcode_into_libs" != yes ||
58635a3d36dfSmrg	       test "$build_old_libs" = yes ||
58645a3d36dfSmrg	       test "$link_static" = yes; }; then
58655a3d36dfSmrg	    # Extract -R from dependency_libs
58665a3d36dfSmrg	    temp_deplibs=
58675a3d36dfSmrg	    for libdir in $dependency_libs; do
58685a3d36dfSmrg	      case $libdir in
58695a3d36dfSmrg	      -R*) func_stripname '-R' '' "$libdir"
58705a3d36dfSmrg	           temp_xrpath=$func_stripname_result
58715a3d36dfSmrg		   case " $xrpath " in
58725a3d36dfSmrg		   *" $temp_xrpath "*) ;;
58735a3d36dfSmrg		   *) xrpath="$xrpath $temp_xrpath";;
58745a3d36dfSmrg		   esac;;
58755a3d36dfSmrg	      *) temp_deplibs="$temp_deplibs $libdir";;
58765a3d36dfSmrg	      esac
58775a3d36dfSmrg	    done
58785a3d36dfSmrg	    dependency_libs="$temp_deplibs"
58795a3d36dfSmrg	  fi
58805a3d36dfSmrg
58815a3d36dfSmrg	  newlib_search_path="$newlib_search_path $absdir"
58825a3d36dfSmrg	  # Link against this library
58835a3d36dfSmrg	  test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
58845a3d36dfSmrg	  # ... and its dependency_libs
58855a3d36dfSmrg	  tmp_libs=
58865a3d36dfSmrg	  for deplib in $dependency_libs; do
58875a3d36dfSmrg	    newdependency_libs="$deplib $newdependency_libs"
58885a3d36dfSmrg	    if $opt_duplicate_deps ; then
58895a3d36dfSmrg	      case "$tmp_libs " in
58905a3d36dfSmrg	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
58915a3d36dfSmrg	      esac
58925a3d36dfSmrg	    fi
58935a3d36dfSmrg	    tmp_libs="$tmp_libs $deplib"
58945a3d36dfSmrg	  done
58955a3d36dfSmrg
58965a3d36dfSmrg	  if test "$link_all_deplibs" != no; then
58975a3d36dfSmrg	    # Add the search paths of all dependency libraries
58985a3d36dfSmrg	    for deplib in $dependency_libs; do
58995a3d36dfSmrg	      case $deplib in
59005a3d36dfSmrg	      -L*) path="$deplib" ;;
59015a3d36dfSmrg	      *.la)
59025a3d36dfSmrg	        func_dirname "$deplib" "" "."
59035a3d36dfSmrg		dir="$func_dirname_result"
59045a3d36dfSmrg		# We need an absolute path.
59055a3d36dfSmrg		case $dir in
59065a3d36dfSmrg		[\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
59075a3d36dfSmrg		*)
59085a3d36dfSmrg		  absdir=`cd "$dir" && pwd`
59095a3d36dfSmrg		  if test -z "$absdir"; then
59105a3d36dfSmrg		    func_warning "cannot determine absolute directory name of \`$dir'"
59115a3d36dfSmrg		    absdir="$dir"
59125a3d36dfSmrg		  fi
59135a3d36dfSmrg		  ;;
59145a3d36dfSmrg		esac
59155a3d36dfSmrg		if $GREP "^installed=no" $deplib > /dev/null; then
59165a3d36dfSmrg		case $host in
59175a3d36dfSmrg		*-*-darwin*)
59185a3d36dfSmrg		  depdepl=
59195a3d36dfSmrg		  eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
59205a3d36dfSmrg		  if test -n "$deplibrary_names" ; then
59215a3d36dfSmrg		    for tmp in $deplibrary_names ; do
59225a3d36dfSmrg		      depdepl=$tmp
59235a3d36dfSmrg		    done
59245a3d36dfSmrg		    if test -f "$absdir/$objdir/$depdepl" ; then
59255a3d36dfSmrg		      depdepl="$absdir/$objdir/$depdepl"
59265a3d36dfSmrg		      darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
59275a3d36dfSmrg                      if test -z "$darwin_install_name"; then
59285a3d36dfSmrg                          darwin_install_name=`${OTOOL64} -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
59295a3d36dfSmrg                      fi
59305a3d36dfSmrg		      compiler_flags="$compiler_flags ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}"
59315a3d36dfSmrg		      linker_flags="$linker_flags -dylib_file ${darwin_install_name}:${depdepl}"
59325a3d36dfSmrg		      path=
59335a3d36dfSmrg		    fi
59345a3d36dfSmrg		  fi
59355a3d36dfSmrg		  ;;
59365a3d36dfSmrg		*)
59375a3d36dfSmrg		  path="-L$absdir/$objdir"
59385a3d36dfSmrg		  ;;
59395a3d36dfSmrg		esac
59405a3d36dfSmrg		else
59415a3d36dfSmrg		  eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
59425a3d36dfSmrg		  test -z "$libdir" && \
59435a3d36dfSmrg		    func_fatal_error "\`$deplib' is not a valid libtool archive"
59445a3d36dfSmrg		  test "$absdir" != "$libdir" && \
59455a3d36dfSmrg		    func_warning "\`$deplib' seems to be moved"
59465a3d36dfSmrg
59475a3d36dfSmrg		  path="-L$absdir"
59485a3d36dfSmrg		fi
59495a3d36dfSmrg		;;
59505a3d36dfSmrg	      esac
59515a3d36dfSmrg	      case " $deplibs " in
59525a3d36dfSmrg	      *" $path "*) ;;
59535a3d36dfSmrg	      *) deplibs="$path $deplibs" ;;
59545a3d36dfSmrg	      esac
59555a3d36dfSmrg	    done
59565a3d36dfSmrg	  fi # link_all_deplibs != no
59575a3d36dfSmrg	fi # linkmode = lib
59585a3d36dfSmrg      done # for deplib in $libs
59595a3d36dfSmrg      if test "$pass" = link; then
59605a3d36dfSmrg	if test "$linkmode" = "prog"; then
59615a3d36dfSmrg	  compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
59625a3d36dfSmrg	  finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
59635a3d36dfSmrg	else
59645a3d36dfSmrg	  compiler_flags="$compiler_flags "`$ECHO "X $new_inherited_linker_flags" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
59655a3d36dfSmrg	fi
59665a3d36dfSmrg      fi
59675a3d36dfSmrg      dependency_libs="$newdependency_libs"
59685a3d36dfSmrg      if test "$pass" = dlpreopen; then
59695a3d36dfSmrg	# Link the dlpreopened libraries before other libraries
59705a3d36dfSmrg	for deplib in $save_deplibs; do
59715a3d36dfSmrg	  deplibs="$deplib $deplibs"
59725a3d36dfSmrg	done
59735a3d36dfSmrg      fi
59745a3d36dfSmrg      if test "$pass" != dlopen; then
59755a3d36dfSmrg	if test "$pass" != conv; then
59765a3d36dfSmrg	  # Make sure lib_search_path contains only unique directories.
59775a3d36dfSmrg	  lib_search_path=
59785a3d36dfSmrg	  for dir in $newlib_search_path; do
59795a3d36dfSmrg	    case "$lib_search_path " in
59805a3d36dfSmrg	    *" $dir "*) ;;
59815a3d36dfSmrg	    *) lib_search_path="$lib_search_path $dir" ;;
59825a3d36dfSmrg	    esac
59835a3d36dfSmrg	  done
59845a3d36dfSmrg	  newlib_search_path=
59855a3d36dfSmrg	fi
59865a3d36dfSmrg
59875a3d36dfSmrg	if test "$linkmode,$pass" != "prog,link"; then
59885a3d36dfSmrg	  vars="deplibs"
59895a3d36dfSmrg	else
59905a3d36dfSmrg	  vars="compile_deplibs finalize_deplibs"
59915a3d36dfSmrg	fi
59925a3d36dfSmrg	for var in $vars dependency_libs; do
59935a3d36dfSmrg	  # Add libraries to $var in reverse order
59945a3d36dfSmrg	  eval tmp_libs=\"\$$var\"
59955a3d36dfSmrg	  new_libs=
59965a3d36dfSmrg	  for deplib in $tmp_libs; do
59975a3d36dfSmrg	    # FIXME: Pedantically, this is the right thing to do, so
59985a3d36dfSmrg	    #        that some nasty dependency loop isn't accidentally
59995a3d36dfSmrg	    #        broken:
60005a3d36dfSmrg	    #new_libs="$deplib $new_libs"
60015a3d36dfSmrg	    # Pragmatically, this seems to cause very few problems in
60025a3d36dfSmrg	    # practice:
60035a3d36dfSmrg	    case $deplib in
60045a3d36dfSmrg	    -L*) new_libs="$deplib $new_libs" ;;
60055a3d36dfSmrg	    -R*) ;;
60065a3d36dfSmrg	    *)
60075a3d36dfSmrg	      # And here is the reason: when a library appears more
60085a3d36dfSmrg	      # than once as an explicit dependence of a library, or
60095a3d36dfSmrg	      # is implicitly linked in more than once by the
60105a3d36dfSmrg	      # compiler, it is considered special, and multiple
60115a3d36dfSmrg	      # occurrences thereof are not removed.  Compare this
60125a3d36dfSmrg	      # with having the same library being listed as a
60135a3d36dfSmrg	      # dependency of multiple other libraries: in this case,
60145a3d36dfSmrg	      # we know (pedantically, we assume) the library does not
60155a3d36dfSmrg	      # need to be listed more than once, so we keep only the
60165a3d36dfSmrg	      # last copy.  This is not always right, but it is rare
60175a3d36dfSmrg	      # enough that we require users that really mean to play
60185a3d36dfSmrg	      # such unportable linking tricks to link the library
60195a3d36dfSmrg	      # using -Wl,-lname, so that libtool does not consider it
60205a3d36dfSmrg	      # for duplicate removal.
60215a3d36dfSmrg	      case " $specialdeplibs " in
60225a3d36dfSmrg	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
60235a3d36dfSmrg	      *)
60245a3d36dfSmrg		case " $new_libs " in
60255a3d36dfSmrg		*" $deplib "*) ;;
60265a3d36dfSmrg		*) new_libs="$deplib $new_libs" ;;
60275a3d36dfSmrg		esac
60285a3d36dfSmrg		;;
60295a3d36dfSmrg	      esac
60305a3d36dfSmrg	      ;;
60315a3d36dfSmrg	    esac
60325a3d36dfSmrg	  done
60335a3d36dfSmrg	  tmp_libs=
60345a3d36dfSmrg	  for deplib in $new_libs; do
60355a3d36dfSmrg	    case $deplib in
60365a3d36dfSmrg	    -L*)
60375a3d36dfSmrg	      case " $tmp_libs " in
60385a3d36dfSmrg	      *" $deplib "*) ;;
60395a3d36dfSmrg	      *) tmp_libs="$tmp_libs $deplib" ;;
60405a3d36dfSmrg	      esac
60415a3d36dfSmrg	      ;;
60425a3d36dfSmrg	    *) tmp_libs="$tmp_libs $deplib" ;;
60435a3d36dfSmrg	    esac
60445a3d36dfSmrg	  done
60455a3d36dfSmrg	  eval $var=\"$tmp_libs\"
60465a3d36dfSmrg	done # for var
60475a3d36dfSmrg      fi
60485a3d36dfSmrg      # Last step: remove runtime libs from dependency_libs
60495a3d36dfSmrg      # (they stay in deplibs)
60505a3d36dfSmrg      tmp_libs=
60515a3d36dfSmrg      for i in $dependency_libs ; do
60525a3d36dfSmrg	case " $predeps $postdeps $compiler_lib_search_path " in
60535a3d36dfSmrg	*" $i "*)
60545a3d36dfSmrg	  i=""
60555a3d36dfSmrg	  ;;
60565a3d36dfSmrg	esac
60575a3d36dfSmrg	if test -n "$i" ; then
60585a3d36dfSmrg	  tmp_libs="$tmp_libs $i"
60595a3d36dfSmrg	fi
60605a3d36dfSmrg      done
60615a3d36dfSmrg      dependency_libs=$tmp_libs
60625a3d36dfSmrg    done # for pass
60635a3d36dfSmrg    if test "$linkmode" = prog; then
60645a3d36dfSmrg      dlfiles="$newdlfiles"
60655a3d36dfSmrg    fi
60665a3d36dfSmrg    if test "$linkmode" = prog || test "$linkmode" = lib; then
60675a3d36dfSmrg      dlprefiles="$newdlprefiles"
60685a3d36dfSmrg    fi
60695a3d36dfSmrg
60705a3d36dfSmrg    case $linkmode in
60715a3d36dfSmrg    oldlib)
60725a3d36dfSmrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
60735a3d36dfSmrg	func_warning "\`-dlopen' is ignored for archives"
60745a3d36dfSmrg      fi
60755a3d36dfSmrg
60765a3d36dfSmrg      case " $deplibs" in
60775a3d36dfSmrg      *\ -l* | *\ -L*)
60785a3d36dfSmrg	func_warning "\`-l' and \`-L' are ignored for archives" ;;
60795a3d36dfSmrg      esac
60805a3d36dfSmrg
60815a3d36dfSmrg      test -n "$rpath" && \
60825a3d36dfSmrg	func_warning "\`-rpath' is ignored for archives"
60835a3d36dfSmrg
60845a3d36dfSmrg      test -n "$xrpath" && \
60855a3d36dfSmrg	func_warning "\`-R' is ignored for archives"
60865a3d36dfSmrg
60875a3d36dfSmrg      test -n "$vinfo" && \
60885a3d36dfSmrg	func_warning "\`-version-info/-version-number' is ignored for archives"
60895a3d36dfSmrg
60905a3d36dfSmrg      test -n "$release" && \
60915a3d36dfSmrg	func_warning "\`-release' is ignored for archives"
60925a3d36dfSmrg
60935a3d36dfSmrg      test -n "$export_symbols$export_symbols_regex" && \
60945a3d36dfSmrg	func_warning "\`-export-symbols' is ignored for archives"
60955a3d36dfSmrg
60965a3d36dfSmrg      # Now set the variables for building old libraries.
60975a3d36dfSmrg      build_libtool_libs=no
60985a3d36dfSmrg      oldlibs="$output"
60995a3d36dfSmrg      objs="$objs$old_deplibs"
61005a3d36dfSmrg      ;;
61015a3d36dfSmrg
61025a3d36dfSmrg    lib)
61035a3d36dfSmrg      # Make sure we only generate libraries of the form `libNAME.la'.
61045a3d36dfSmrg      case $outputname in
61055a3d36dfSmrg      lib*)
61065a3d36dfSmrg	func_stripname 'lib' '.la' "$outputname"
61075a3d36dfSmrg	name=$func_stripname_result
61085a3d36dfSmrg	eval shared_ext=\"$shrext_cmds\"
61095a3d36dfSmrg	eval libname=\"$libname_spec\"
61105a3d36dfSmrg	;;
61115a3d36dfSmrg      *)
61125a3d36dfSmrg	test "$module" = no && \
61135a3d36dfSmrg	  func_fatal_help "libtool library \`$output' must begin with \`lib'"
61145a3d36dfSmrg
61155a3d36dfSmrg	if test "$need_lib_prefix" != no; then
61165a3d36dfSmrg	  # Add the "lib" prefix for modules if required
61175a3d36dfSmrg	  func_stripname '' '.la' "$outputname"
61185a3d36dfSmrg	  name=$func_stripname_result
61195a3d36dfSmrg	  eval shared_ext=\"$shrext_cmds\"
61205a3d36dfSmrg	  eval libname=\"$libname_spec\"
61215a3d36dfSmrg	else
61225a3d36dfSmrg	  func_stripname '' '.la' "$outputname"
61235a3d36dfSmrg	  libname=$func_stripname_result
61245a3d36dfSmrg	fi
61255a3d36dfSmrg	;;
61265a3d36dfSmrg      esac
61275a3d36dfSmrg
61285a3d36dfSmrg      if test -n "$objs"; then
61295a3d36dfSmrg	if test "$deplibs_check_method" != pass_all; then
61305a3d36dfSmrg	  func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs"
61315a3d36dfSmrg	else
61325a3d36dfSmrg	  $ECHO
61335a3d36dfSmrg	  $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
61345a3d36dfSmrg	  $ECHO "*** objects $objs is not portable!"
61355a3d36dfSmrg	  libobjs="$libobjs $objs"
61365a3d36dfSmrg	fi
61375a3d36dfSmrg      fi
61385a3d36dfSmrg
61395a3d36dfSmrg      test "$dlself" != no && \
61405a3d36dfSmrg	func_warning "\`-dlopen self' is ignored for libtool libraries"
61415a3d36dfSmrg
61425a3d36dfSmrg      set dummy $rpath
61435a3d36dfSmrg      shift
61445a3d36dfSmrg      test "$#" -gt 1 && \
61455a3d36dfSmrg	func_warning "ignoring multiple \`-rpath's for a libtool library"
61465a3d36dfSmrg
61475a3d36dfSmrg      install_libdir="$1"
61485a3d36dfSmrg
61495a3d36dfSmrg      oldlibs=
61505a3d36dfSmrg      if test -z "$rpath"; then
61515a3d36dfSmrg	if test "$build_libtool_libs" = yes; then
61525a3d36dfSmrg	  # Building a libtool convenience library.
61535a3d36dfSmrg	  # Some compilers have problems with a `.al' extension so
61545a3d36dfSmrg	  # convenience libraries should have the same extension an
61555a3d36dfSmrg	  # archive normally would.
61565a3d36dfSmrg	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
61575a3d36dfSmrg	  build_libtool_libs=convenience
61585a3d36dfSmrg	  build_old_libs=yes
61595a3d36dfSmrg	fi
61605a3d36dfSmrg
61615a3d36dfSmrg	test -n "$vinfo" && \
61625a3d36dfSmrg	  func_warning "\`-version-info/-version-number' is ignored for convenience libraries"
61635a3d36dfSmrg
61645a3d36dfSmrg	test -n "$release" && \
61655a3d36dfSmrg	  func_warning "\`-release' is ignored for convenience libraries"
61665a3d36dfSmrg      else
61675a3d36dfSmrg
61685a3d36dfSmrg	# Parse the version information argument.
61695a3d36dfSmrg	save_ifs="$IFS"; IFS=':'
61705a3d36dfSmrg	set dummy $vinfo 0 0 0
61715a3d36dfSmrg	shift
61725a3d36dfSmrg	IFS="$save_ifs"
61735a3d36dfSmrg
61745a3d36dfSmrg	test -n "$7" && \
61755a3d36dfSmrg	  func_fatal_help "too many parameters to \`-version-info'"
61765a3d36dfSmrg
61775a3d36dfSmrg	# convert absolute version numbers to libtool ages
61785a3d36dfSmrg	# this retains compatibility with .la files and attempts
61795a3d36dfSmrg	# to make the code below a bit more comprehensible
61805a3d36dfSmrg
61815a3d36dfSmrg	case $vinfo_number in
61825a3d36dfSmrg	yes)
61835a3d36dfSmrg	  number_major="$1"
61845a3d36dfSmrg	  number_minor="$2"
61855a3d36dfSmrg	  number_revision="$3"
61865a3d36dfSmrg	  #
61875a3d36dfSmrg	  # There are really only two kinds -- those that
61885a3d36dfSmrg	  # use the current revision as the major version
61895a3d36dfSmrg	  # and those that subtract age and use age as
61905a3d36dfSmrg	  # a minor version.  But, then there is irix
61915a3d36dfSmrg	  # which has an extra 1 added just for fun
61925a3d36dfSmrg	  #
61935a3d36dfSmrg	  case $version_type in
61945a3d36dfSmrg	  darwin|linux|osf|windows|none)
61955a3d36dfSmrg	    func_arith $number_major + $number_minor
61965a3d36dfSmrg	    current=$func_arith_result
61975a3d36dfSmrg	    age="$number_minor"
61985a3d36dfSmrg	    revision="$number_revision"
61995a3d36dfSmrg	    ;;
62005a3d36dfSmrg	  freebsd-aout|freebsd-elf|sunos)
62015a3d36dfSmrg	    current="$number_major"
62025a3d36dfSmrg	    revision="$number_minor"
62035a3d36dfSmrg	    age="0"
62045a3d36dfSmrg	    ;;
62055a3d36dfSmrg	  irix|nonstopux)
62065a3d36dfSmrg	    func_arith $number_major + $number_minor
62075a3d36dfSmrg	    current=$func_arith_result
62085a3d36dfSmrg	    age="$number_minor"
62095a3d36dfSmrg	    revision="$number_minor"
62105a3d36dfSmrg	    lt_irix_increment=no
62115a3d36dfSmrg	    ;;
62125a3d36dfSmrg	  *)
62135a3d36dfSmrg	    func_fatal_configuration "$modename: unknown library version type \`$version_type'"
62145a3d36dfSmrg	    ;;
62155a3d36dfSmrg	  esac
62165a3d36dfSmrg	  ;;
62175a3d36dfSmrg	no)
62185a3d36dfSmrg	  current="$1"
62195a3d36dfSmrg	  revision="$2"
62205a3d36dfSmrg	  age="$3"
62215a3d36dfSmrg	  ;;
62225a3d36dfSmrg	esac
62235a3d36dfSmrg
62245a3d36dfSmrg	# Check that each of the things are valid numbers.
62255a3d36dfSmrg	case $current in
62265a3d36dfSmrg	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]) ;;
62275a3d36dfSmrg	*)
62285a3d36dfSmrg	  func_error "CURRENT \`$current' must be a nonnegative integer"
62295a3d36dfSmrg	  func_fatal_error "\`$vinfo' is not valid version information"
62305a3d36dfSmrg	  ;;
62315a3d36dfSmrg	esac
62325a3d36dfSmrg
62335a3d36dfSmrg	case $revision in
62345a3d36dfSmrg	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]) ;;
62355a3d36dfSmrg	*)
62365a3d36dfSmrg	  func_error "REVISION \`$revision' must be a nonnegative integer"
62375a3d36dfSmrg	  func_fatal_error "\`$vinfo' is not valid version information"
62385a3d36dfSmrg	  ;;
62395a3d36dfSmrg	esac
62405a3d36dfSmrg
62415a3d36dfSmrg	case $age in
62425a3d36dfSmrg	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]) ;;
62435a3d36dfSmrg	*)
62445a3d36dfSmrg	  func_error "AGE \`$age' must be a nonnegative integer"
62455a3d36dfSmrg	  func_fatal_error "\`$vinfo' is not valid version information"
62465a3d36dfSmrg	  ;;
62475a3d36dfSmrg	esac
62485a3d36dfSmrg
62495a3d36dfSmrg	if test "$age" -gt "$current"; then
62505a3d36dfSmrg	  func_error "AGE \`$age' is greater than the current interface number \`$current'"
62515a3d36dfSmrg	  func_fatal_error "\`$vinfo' is not valid version information"
62525a3d36dfSmrg	fi
62535a3d36dfSmrg
62545a3d36dfSmrg	# Calculate the version variables.
62555a3d36dfSmrg	major=
62565a3d36dfSmrg	versuffix=
62575a3d36dfSmrg	verstring=
62585a3d36dfSmrg	case $version_type in
62595a3d36dfSmrg	none) ;;
62605a3d36dfSmrg
62615a3d36dfSmrg	darwin)
62625a3d36dfSmrg	  # Like Linux, but with the current version available in
62635a3d36dfSmrg	  # verstring for coding it into the library header
62645a3d36dfSmrg	  func_arith $current - $age
62655a3d36dfSmrg	  major=.$func_arith_result
62665a3d36dfSmrg	  versuffix="$major.$age.$revision"
62675a3d36dfSmrg	  # Darwin ld doesn't like 0 for these options...
62685a3d36dfSmrg	  func_arith $current + 1
62695a3d36dfSmrg	  minor_current=$func_arith_result
62705a3d36dfSmrg	  xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
62715a3d36dfSmrg	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
62725a3d36dfSmrg	  ;;
62735a3d36dfSmrg
62745a3d36dfSmrg	freebsd-aout)
62755a3d36dfSmrg	  major=".$current"
62765a3d36dfSmrg	  versuffix=".$current.$revision";
62775a3d36dfSmrg	  ;;
62785a3d36dfSmrg
62795a3d36dfSmrg	freebsd-elf)
62805a3d36dfSmrg	  major=".$current"
62815a3d36dfSmrg	  versuffix=".$current"
62825a3d36dfSmrg	  ;;
62835a3d36dfSmrg
62845a3d36dfSmrg	irix | nonstopux)
62855a3d36dfSmrg	  if test "X$lt_irix_increment" = "Xno"; then
62865a3d36dfSmrg	    func_arith $current - $age
62875a3d36dfSmrg	  else
62885a3d36dfSmrg	    func_arith $current - $age + 1
62895a3d36dfSmrg	  fi
62905a3d36dfSmrg	  major=$func_arith_result
62915a3d36dfSmrg
62925a3d36dfSmrg	  case $version_type in
62935a3d36dfSmrg	    nonstopux) verstring_prefix=nonstopux ;;
62945a3d36dfSmrg	    *)         verstring_prefix=sgi ;;
62955a3d36dfSmrg	  esac
62965a3d36dfSmrg	  verstring="$verstring_prefix$major.$revision"
62975a3d36dfSmrg
62985a3d36dfSmrg	  # Add in all the interfaces that we are compatible with.
62995a3d36dfSmrg	  loop=$revision
63005a3d36dfSmrg	  while test "$loop" -ne 0; do
63015a3d36dfSmrg	    func_arith $revision - $loop
63025a3d36dfSmrg	    iface=$func_arith_result
63035a3d36dfSmrg	    func_arith $loop - 1
63045a3d36dfSmrg	    loop=$func_arith_result
63055a3d36dfSmrg	    verstring="$verstring_prefix$major.$iface:$verstring"
63065a3d36dfSmrg	  done
63075a3d36dfSmrg
63085a3d36dfSmrg	  # Before this point, $major must not contain `.'.
63095a3d36dfSmrg	  major=.$major
63105a3d36dfSmrg	  versuffix="$major.$revision"
63115a3d36dfSmrg	  ;;
63125a3d36dfSmrg
63135a3d36dfSmrg	linux)
63145a3d36dfSmrg	  func_arith $current - $age
63155a3d36dfSmrg	  major=.$func_arith_result
63165a3d36dfSmrg	  versuffix="$major.$age.$revision"
63175a3d36dfSmrg	  ;;
63185a3d36dfSmrg
63195a3d36dfSmrg	osf)
63205a3d36dfSmrg	  func_arith $current - $age
63215a3d36dfSmrg	  major=.$func_arith_result
63225a3d36dfSmrg	  versuffix=".$current.$age.$revision"
63235a3d36dfSmrg	  verstring="$current.$age.$revision"
63245a3d36dfSmrg
63255a3d36dfSmrg	  # Add in all the interfaces that we are compatible with.
63265a3d36dfSmrg	  loop=$age
63275a3d36dfSmrg	  while test "$loop" -ne 0; do
63285a3d36dfSmrg	    func_arith $current - $loop
63295a3d36dfSmrg	    iface=$func_arith_result
63305a3d36dfSmrg	    func_arith $loop - 1
63315a3d36dfSmrg	    loop=$func_arith_result
63325a3d36dfSmrg	    verstring="$verstring:${iface}.0"
63335a3d36dfSmrg	  done
63345a3d36dfSmrg
63355a3d36dfSmrg	  # Make executables depend on our current version.
63365a3d36dfSmrg	  verstring="$verstring:${current}.0"
63375a3d36dfSmrg	  ;;
63385a3d36dfSmrg
63395a3d36dfSmrg	qnx)
63405a3d36dfSmrg	  major=".$current"
63415a3d36dfSmrg	  versuffix=".$current"
63425a3d36dfSmrg	  ;;
63435a3d36dfSmrg
63445a3d36dfSmrg	sunos)
63455a3d36dfSmrg	  major=".$current"
63465a3d36dfSmrg	  versuffix=".$current.$revision"
63475a3d36dfSmrg	  ;;
63485a3d36dfSmrg
63495a3d36dfSmrg	windows)
63505a3d36dfSmrg	  # Use '-' rather than '.', since we only want one
63515a3d36dfSmrg	  # extension on DOS 8.3 filesystems.
63525a3d36dfSmrg	  func_arith $current - $age
63535a3d36dfSmrg	  major=$func_arith_result
63545a3d36dfSmrg	  versuffix="-$major"
63555a3d36dfSmrg	  ;;
63565a3d36dfSmrg
63575a3d36dfSmrg	*)
63585a3d36dfSmrg	  func_fatal_configuration "unknown library version type \`$version_type'"
63595a3d36dfSmrg	  ;;
63605a3d36dfSmrg	esac
63615a3d36dfSmrg
63625a3d36dfSmrg	# Clear the version info if we defaulted, and they specified a release.
63635a3d36dfSmrg	if test -z "$vinfo" && test -n "$release"; then
63645a3d36dfSmrg	  major=
63655a3d36dfSmrg	  case $version_type in
63665a3d36dfSmrg	  darwin)
63675a3d36dfSmrg	    # we can't check for "0.0" in archive_cmds due to quoting
63685a3d36dfSmrg	    # problems, so we reset it completely
63695a3d36dfSmrg	    verstring=
63705a3d36dfSmrg	    ;;
63715a3d36dfSmrg	  *)
63725a3d36dfSmrg	    verstring="0.0"
63735a3d36dfSmrg	    ;;
63745a3d36dfSmrg	  esac
63755a3d36dfSmrg	  if test "$need_version" = no; then
63765a3d36dfSmrg	    versuffix=
63775a3d36dfSmrg	  else
63785a3d36dfSmrg	    versuffix=".0.0"
63795a3d36dfSmrg	  fi
63805a3d36dfSmrg	fi
63815a3d36dfSmrg
63825a3d36dfSmrg	# Remove version info from name if versioning should be avoided
63835a3d36dfSmrg	if test "$avoid_version" = yes && test "$need_version" = no; then
63845a3d36dfSmrg	  major=
63855a3d36dfSmrg	  versuffix=
63865a3d36dfSmrg	  verstring=""
63875a3d36dfSmrg	fi
63885a3d36dfSmrg
63895a3d36dfSmrg	# Check to see if the archive will have undefined symbols.
63905a3d36dfSmrg	if test "$allow_undefined" = yes; then
63915a3d36dfSmrg	  if test "$allow_undefined_flag" = unsupported; then
63925a3d36dfSmrg	    func_warning "undefined symbols not allowed in $host shared libraries"
63935a3d36dfSmrg	    build_libtool_libs=no
63945a3d36dfSmrg	    build_old_libs=yes
63955a3d36dfSmrg	  fi
63965a3d36dfSmrg	else
63975a3d36dfSmrg	  # Don't allow undefined symbols.
63985a3d36dfSmrg	  allow_undefined_flag="$no_undefined_flag"
63995a3d36dfSmrg	fi
64005a3d36dfSmrg
64015a3d36dfSmrg      fi
64025a3d36dfSmrg
64035a3d36dfSmrg      func_generate_dlsyms "$libname" "$libname" "yes"
64045a3d36dfSmrg      libobjs="$libobjs $symfileobj"
64055a3d36dfSmrg      test "X$libobjs" = "X " && libobjs=
64065a3d36dfSmrg
64075a3d36dfSmrg      if test "$mode" != relink; then
64085a3d36dfSmrg	# Remove our outputs, but don't remove object files since they
64095a3d36dfSmrg	# may have been created when compiling PIC objects.
64105a3d36dfSmrg	removelist=
64115a3d36dfSmrg	tempremovelist=`$ECHO "$output_objdir/*"`
64125a3d36dfSmrg	for p in $tempremovelist; do
64135a3d36dfSmrg	  case $p in
64145a3d36dfSmrg	    *.$objext | *.gcno)
64155a3d36dfSmrg	       ;;
64165a3d36dfSmrg	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
64175a3d36dfSmrg	       if test "X$precious_files_regex" != "X"; then
64185a3d36dfSmrg		 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
64195a3d36dfSmrg		 then
64205a3d36dfSmrg		   continue
64215a3d36dfSmrg		 fi
64225a3d36dfSmrg	       fi
64235a3d36dfSmrg	       removelist="$removelist $p"
64245a3d36dfSmrg	       ;;
64255a3d36dfSmrg	    *) ;;
64265a3d36dfSmrg	  esac
64275a3d36dfSmrg	done
64285a3d36dfSmrg	test -n "$removelist" && \
64295a3d36dfSmrg	  func_show_eval "${RM}r \$removelist"
64305a3d36dfSmrg      fi
64315a3d36dfSmrg
64325a3d36dfSmrg      # Now set the variables for building old libraries.
64335a3d36dfSmrg      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
64345a3d36dfSmrg	oldlibs="$oldlibs $output_objdir/$libname.$libext"
64355a3d36dfSmrg
64365a3d36dfSmrg	# Transform .lo files to .o files.
64375a3d36dfSmrg	oldobjs="$objs "`$ECHO "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP`
64385a3d36dfSmrg      fi
64395a3d36dfSmrg
64405a3d36dfSmrg      # Eliminate all temporary directories.
64415a3d36dfSmrg      #for path in $notinst_path; do
64425a3d36dfSmrg      #	lib_search_path=`$ECHO "X$lib_search_path " | $Xsed -e "s% $path % %g"`
64435a3d36dfSmrg      #	deplibs=`$ECHO "X$deplibs " | $Xsed -e "s% -L$path % %g"`
64445a3d36dfSmrg      #	dependency_libs=`$ECHO "X$dependency_libs " | $Xsed -e "s% -L$path % %g"`
64455a3d36dfSmrg      #done
64465a3d36dfSmrg
64475a3d36dfSmrg      if test -n "$xrpath"; then
64485a3d36dfSmrg	# If the user specified any rpath flags, then add them.
64495a3d36dfSmrg	temp_xrpath=
64505a3d36dfSmrg	for libdir in $xrpath; do
64515a3d36dfSmrg	  temp_xrpath="$temp_xrpath -R$libdir"
64525a3d36dfSmrg	  case "$finalize_rpath " in
64535a3d36dfSmrg	  *" $libdir "*) ;;
64545a3d36dfSmrg	  *) finalize_rpath="$finalize_rpath $libdir" ;;
64555a3d36dfSmrg	  esac
64565a3d36dfSmrg	done
64575a3d36dfSmrg	if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
64585a3d36dfSmrg	  dependency_libs="$temp_xrpath $dependency_libs"
64595a3d36dfSmrg	fi
64605a3d36dfSmrg      fi
64615a3d36dfSmrg
64625a3d36dfSmrg      # Make sure dlfiles contains only unique files that won't be dlpreopened
64635a3d36dfSmrg      old_dlfiles="$dlfiles"
64645a3d36dfSmrg      dlfiles=
64655a3d36dfSmrg      for lib in $old_dlfiles; do
64665a3d36dfSmrg	case " $dlprefiles $dlfiles " in
64675a3d36dfSmrg	*" $lib "*) ;;
64685a3d36dfSmrg	*) dlfiles="$dlfiles $lib" ;;
64695a3d36dfSmrg	esac
64705a3d36dfSmrg      done
64715a3d36dfSmrg
64725a3d36dfSmrg      # Make sure dlprefiles contains only unique files
64735a3d36dfSmrg      old_dlprefiles="$dlprefiles"
64745a3d36dfSmrg      dlprefiles=
64755a3d36dfSmrg      for lib in $old_dlprefiles; do
64765a3d36dfSmrg	case "$dlprefiles " in
64775a3d36dfSmrg	*" $lib "*) ;;
64785a3d36dfSmrg	*) dlprefiles="$dlprefiles $lib" ;;
64795a3d36dfSmrg	esac
64805a3d36dfSmrg      done
64815a3d36dfSmrg
64825a3d36dfSmrg      if test "$build_libtool_libs" = yes; then
64835a3d36dfSmrg	if test -n "$rpath"; then
64845a3d36dfSmrg	  case $host in
64855a3d36dfSmrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc*)
64865a3d36dfSmrg	    # these systems don't actually have a c library (as such)!
64875a3d36dfSmrg	    ;;
64885a3d36dfSmrg	  *-*-rhapsody* | *-*-darwin1.[012])
64895a3d36dfSmrg	    # Rhapsody C library is in the System framework
64905a3d36dfSmrg	    deplibs="$deplibs System.ltframework"
64915a3d36dfSmrg	    ;;
64925a3d36dfSmrg	  *-*-netbsd*)
64935a3d36dfSmrg	    # Don't link with libc until the a.out ld.so is fixed.
64945a3d36dfSmrg	    ;;
64955a3d36dfSmrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
64965a3d36dfSmrg	    # Do not include libc due to us having libc/libc_r.
64975a3d36dfSmrg	    ;;
64985a3d36dfSmrg	  *-*-sco3.2v5* | *-*-sco5v6*)
64995a3d36dfSmrg	    # Causes problems with __ctype
65005a3d36dfSmrg	    ;;
65015a3d36dfSmrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
65025a3d36dfSmrg	    # Compiler inserts libc in the correct place for threads to work
65035a3d36dfSmrg	    ;;
65045a3d36dfSmrg	  *)
65055a3d36dfSmrg	    # Add libc to deplibs on all other systems if necessary.
65065a3d36dfSmrg	    if test "$build_libtool_need_lc" = "yes"; then
65075a3d36dfSmrg	      deplibs="$deplibs -lc"
65085a3d36dfSmrg	    fi
65095a3d36dfSmrg	    ;;
65105a3d36dfSmrg	  esac
65115a3d36dfSmrg	fi
65125a3d36dfSmrg
65135a3d36dfSmrg	# Transform deplibs into only deplibs that can be linked in shared.
65145a3d36dfSmrg	name_save=$name
65155a3d36dfSmrg	libname_save=$libname
65165a3d36dfSmrg	release_save=$release
65175a3d36dfSmrg	versuffix_save=$versuffix
65185a3d36dfSmrg	major_save=$major
65195a3d36dfSmrg	# I'm not sure if I'm treating the release correctly.  I think
65205a3d36dfSmrg	# release should show up in the -l (ie -lgmp5) so we don't want to
65215a3d36dfSmrg	# add it in twice.  Is that correct?
65225a3d36dfSmrg	release=""
65235a3d36dfSmrg	versuffix=""
65245a3d36dfSmrg	major=""
65255a3d36dfSmrg	newdeplibs=
65265a3d36dfSmrg	droppeddeps=no
65275a3d36dfSmrg	case $deplibs_check_method in
65285a3d36dfSmrg	pass_all)
65295a3d36dfSmrg	  # Don't check for shared/static.  Everything works.
65305a3d36dfSmrg	  # This might be a little naive.  We might want to check
65315a3d36dfSmrg	  # whether the library exists or not.  But this is on
65325a3d36dfSmrg	  # osf3 & osf4 and I'm not really sure... Just
65335a3d36dfSmrg	  # implementing what was already the behavior.
65345a3d36dfSmrg	  newdeplibs=$deplibs
65355a3d36dfSmrg	  ;;
65365a3d36dfSmrg	test_compile)
65375a3d36dfSmrg	  # This code stresses the "libraries are programs" paradigm to its
65385a3d36dfSmrg	  # limits. Maybe even breaks it.  We compile a program, linking it
65395a3d36dfSmrg	  # against the deplibs as a proxy for the library.  Then we can check
65405a3d36dfSmrg	  # whether they linked in statically or dynamically with ldd.
65415a3d36dfSmrg	  $opt_dry_run || $RM conftest.c
65425a3d36dfSmrg	  cat > conftest.c <<EOF
65435a3d36dfSmrg	  int main() { return 0; }
65445a3d36dfSmrgEOF
65455a3d36dfSmrg	  $opt_dry_run || $RM conftest
65465a3d36dfSmrg	  if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
65475a3d36dfSmrg	    ldd_output=`ldd conftest`
65485a3d36dfSmrg	    for i in $deplibs; do
65495a3d36dfSmrg	      case $i in
65505a3d36dfSmrg	      -l*)
65515a3d36dfSmrg		func_stripname -l '' "$i"
65525a3d36dfSmrg		name=$func_stripname_result
65535a3d36dfSmrg		if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
65545a3d36dfSmrg		  case " $predeps $postdeps " in
65555a3d36dfSmrg		  *" $i "*)
65565a3d36dfSmrg		    newdeplibs="$newdeplibs $i"
65575a3d36dfSmrg		    i=""
65585a3d36dfSmrg		    ;;
65595a3d36dfSmrg		  esac
65605a3d36dfSmrg		fi
65615a3d36dfSmrg		if test -n "$i" ; then
65625a3d36dfSmrg		  libname=`eval "\\$ECHO \"$libname_spec\""`
65635a3d36dfSmrg		  deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
65645a3d36dfSmrg		  set dummy $deplib_matches; shift
65655a3d36dfSmrg		  deplib_match=$1
65665a3d36dfSmrg		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
65675a3d36dfSmrg		    newdeplibs="$newdeplibs $i"
65685a3d36dfSmrg		  else
65695a3d36dfSmrg		    droppeddeps=yes
65705a3d36dfSmrg		    $ECHO
65715a3d36dfSmrg		    $ECHO "*** Warning: dynamic linker does not accept needed library $i."
65725a3d36dfSmrg		    $ECHO "*** I have the capability to make that library automatically link in when"
65735a3d36dfSmrg		    $ECHO "*** you link to this library.  But I can only do this if you have a"
65745a3d36dfSmrg		    $ECHO "*** shared version of the library, which I believe you do not have"
65755a3d36dfSmrg		    $ECHO "*** because a test_compile did reveal that the linker did not use it for"
65765a3d36dfSmrg		    $ECHO "*** its dynamic dependency list that programs get resolved with at runtime."
65775a3d36dfSmrg		  fi
65785a3d36dfSmrg		fi
65795a3d36dfSmrg		;;
65805a3d36dfSmrg	      *)
65815a3d36dfSmrg		newdeplibs="$newdeplibs $i"
65825a3d36dfSmrg		;;
65835a3d36dfSmrg	      esac
65845a3d36dfSmrg	    done
65855a3d36dfSmrg	  else
65865a3d36dfSmrg	    # Error occurred in the first compile.  Let's try to salvage
65875a3d36dfSmrg	    # the situation: Compile a separate program for each library.
65885a3d36dfSmrg	    for i in $deplibs; do
65895a3d36dfSmrg	      case $i in
65905a3d36dfSmrg	      -l*)
65915a3d36dfSmrg		func_stripname -l '' "$i"
65925a3d36dfSmrg		name=$func_stripname_result
65935a3d36dfSmrg		$opt_dry_run || $RM conftest
65945a3d36dfSmrg		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
65955a3d36dfSmrg		  ldd_output=`ldd conftest`
65965a3d36dfSmrg		  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
65975a3d36dfSmrg		    case " $predeps $postdeps " in
65985a3d36dfSmrg		    *" $i "*)
65995a3d36dfSmrg		      newdeplibs="$newdeplibs $i"
66005a3d36dfSmrg		      i=""
66015a3d36dfSmrg		      ;;
66025a3d36dfSmrg		    esac
66035a3d36dfSmrg		  fi
66045a3d36dfSmrg		  if test -n "$i" ; then
66055a3d36dfSmrg		    libname=`eval "\\$ECHO \"$libname_spec\""`
66065a3d36dfSmrg		    deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
66075a3d36dfSmrg		    set dummy $deplib_matches; shift
66085a3d36dfSmrg		    deplib_match=$1
66095a3d36dfSmrg		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
66105a3d36dfSmrg		      newdeplibs="$newdeplibs $i"
66115a3d36dfSmrg		    else
66125a3d36dfSmrg		      droppeddeps=yes
66135a3d36dfSmrg		      $ECHO
66145a3d36dfSmrg		      $ECHO "*** Warning: dynamic linker does not accept needed library $i."
66155a3d36dfSmrg		      $ECHO "*** I have the capability to make that library automatically link in when"
66165a3d36dfSmrg		      $ECHO "*** you link to this library.  But I can only do this if you have a"
66175a3d36dfSmrg		      $ECHO "*** shared version of the library, which you do not appear to have"
66185a3d36dfSmrg		      $ECHO "*** because a test_compile did reveal that the linker did not use this one"
66195a3d36dfSmrg		      $ECHO "*** as a dynamic dependency that programs can get resolved with at runtime."
66205a3d36dfSmrg		    fi
66215a3d36dfSmrg		  fi
66225a3d36dfSmrg		else
66235a3d36dfSmrg		  droppeddeps=yes
66245a3d36dfSmrg		  $ECHO
66255a3d36dfSmrg		  $ECHO "*** Warning!  Library $i is needed by this library but I was not able to"
66265a3d36dfSmrg		  $ECHO "*** make it link in!  You will probably need to install it or some"
66275a3d36dfSmrg		  $ECHO "*** library that it depends on before this library will be fully"
66285a3d36dfSmrg		  $ECHO "*** functional.  Installing it before continuing would be even better."
66295a3d36dfSmrg		fi
66305a3d36dfSmrg		;;
66315a3d36dfSmrg	      *)
66325a3d36dfSmrg		newdeplibs="$newdeplibs $i"
66335a3d36dfSmrg		;;
66345a3d36dfSmrg	      esac
66355a3d36dfSmrg	    done
66365a3d36dfSmrg	  fi
66375a3d36dfSmrg	  ;;
66385a3d36dfSmrg	file_magic*)
66395a3d36dfSmrg	  set dummy $deplibs_check_method; shift
66405a3d36dfSmrg	  file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
66415a3d36dfSmrg	  for a_deplib in $deplibs; do
66425a3d36dfSmrg	    case $a_deplib in
66435a3d36dfSmrg	    -l*)
66445a3d36dfSmrg	      func_stripname -l '' "$a_deplib"
66455a3d36dfSmrg	      name=$func_stripname_result
66465a3d36dfSmrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
66475a3d36dfSmrg		case " $predeps $postdeps " in
66485a3d36dfSmrg		*" $a_deplib "*)
66495a3d36dfSmrg		  newdeplibs="$newdeplibs $a_deplib"
66505a3d36dfSmrg		  a_deplib=""
66515a3d36dfSmrg		  ;;
66525a3d36dfSmrg		esac
66535a3d36dfSmrg	      fi
66545a3d36dfSmrg	      if test -n "$a_deplib" ; then
66555a3d36dfSmrg		libname=`eval "\\$ECHO \"$libname_spec\""`
66565a3d36dfSmrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
66575a3d36dfSmrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
66585a3d36dfSmrg		  for potent_lib in $potential_libs; do
66595a3d36dfSmrg		      # Follow soft links.
66605a3d36dfSmrg		      if ls -lLd "$potent_lib" 2>/dev/null |
66615a3d36dfSmrg			 $GREP " -> " >/dev/null; then
66625a3d36dfSmrg			continue
66635a3d36dfSmrg		      fi
66645a3d36dfSmrg		      # The statement above tries to avoid entering an
66655a3d36dfSmrg		      # endless loop below, in case of cyclic links.
66665a3d36dfSmrg		      # We might still enter an endless loop, since a link
66675a3d36dfSmrg		      # loop can be closed while we follow links,
66685a3d36dfSmrg		      # but so what?
66695a3d36dfSmrg		      potlib="$potent_lib"
66705a3d36dfSmrg		      while test -h "$potlib" 2>/dev/null; do
66715a3d36dfSmrg			potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
66725a3d36dfSmrg			case $potliblink in
66735a3d36dfSmrg			[\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
66745a3d36dfSmrg			*) potlib=`$ECHO "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";;
66755a3d36dfSmrg			esac
66765a3d36dfSmrg		      done
66775a3d36dfSmrg		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
66785a3d36dfSmrg			 $SED -e 10q |
66795a3d36dfSmrg			 $EGREP "$file_magic_regex" > /dev/null; then
66805a3d36dfSmrg			newdeplibs="$newdeplibs $a_deplib"
66815a3d36dfSmrg			a_deplib=""
66825a3d36dfSmrg			break 2
66835a3d36dfSmrg		      fi
66845a3d36dfSmrg		  done
66855a3d36dfSmrg		done
66865a3d36dfSmrg	      fi
66875a3d36dfSmrg	      if test -n "$a_deplib" ; then
66885a3d36dfSmrg		droppeddeps=yes
66895a3d36dfSmrg		$ECHO
66905a3d36dfSmrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
66915a3d36dfSmrg		$ECHO "*** I have the capability to make that library automatically link in when"
66925a3d36dfSmrg		$ECHO "*** you link to this library.  But I can only do this if you have a"
66935a3d36dfSmrg		$ECHO "*** shared version of the library, which you do not appear to have"
66945a3d36dfSmrg		$ECHO "*** because I did check the linker path looking for a file starting"
66955a3d36dfSmrg		if test -z "$potlib" ; then
66965a3d36dfSmrg		  $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
66975a3d36dfSmrg		else
66985a3d36dfSmrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
66995a3d36dfSmrg		  $ECHO "*** using a file magic. Last file checked: $potlib"
67005a3d36dfSmrg		fi
67015a3d36dfSmrg	      fi
67025a3d36dfSmrg	      ;;
67035a3d36dfSmrg	    *)
67045a3d36dfSmrg	      # Add a -L argument.
67055a3d36dfSmrg	      newdeplibs="$newdeplibs $a_deplib"
67065a3d36dfSmrg	      ;;
67075a3d36dfSmrg	    esac
67085a3d36dfSmrg	  done # Gone through all deplibs.
67095a3d36dfSmrg	  ;;
67105a3d36dfSmrg	match_pattern*)
67115a3d36dfSmrg	  set dummy $deplibs_check_method; shift
67125a3d36dfSmrg	  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
67135a3d36dfSmrg	  for a_deplib in $deplibs; do
67145a3d36dfSmrg	    case $a_deplib in
67155a3d36dfSmrg	    -l*)
67165a3d36dfSmrg	      func_stripname -l '' "$a_deplib"
67175a3d36dfSmrg	      name=$func_stripname_result
67185a3d36dfSmrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
67195a3d36dfSmrg		case " $predeps $postdeps " in
67205a3d36dfSmrg		*" $a_deplib "*)
67215a3d36dfSmrg		  newdeplibs="$newdeplibs $a_deplib"
67225a3d36dfSmrg		  a_deplib=""
67235a3d36dfSmrg		  ;;
67245a3d36dfSmrg		esac
67255a3d36dfSmrg	      fi
67265a3d36dfSmrg	      if test -n "$a_deplib" ; then
67275a3d36dfSmrg		libname=`eval "\\$ECHO \"$libname_spec\""`
67285a3d36dfSmrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
67295a3d36dfSmrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
67305a3d36dfSmrg		  for potent_lib in $potential_libs; do
67315a3d36dfSmrg		    potlib="$potent_lib" # see symlink-check above in file_magic test
67325a3d36dfSmrg		    if eval "\$ECHO \"X$potent_lib\"" 2>/dev/null | $Xsed -e 10q | \
67335a3d36dfSmrg		       $EGREP "$match_pattern_regex" > /dev/null; then
67345a3d36dfSmrg		      newdeplibs="$newdeplibs $a_deplib"
67355a3d36dfSmrg		      a_deplib=""
67365a3d36dfSmrg		      break 2
67375a3d36dfSmrg		    fi
67385a3d36dfSmrg		  done
67395a3d36dfSmrg		done
67405a3d36dfSmrg	      fi
67415a3d36dfSmrg	      if test -n "$a_deplib" ; then
67425a3d36dfSmrg		droppeddeps=yes
67435a3d36dfSmrg		$ECHO
67445a3d36dfSmrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
67455a3d36dfSmrg		$ECHO "*** I have the capability to make that library automatically link in when"
67465a3d36dfSmrg		$ECHO "*** you link to this library.  But I can only do this if you have a"
67475a3d36dfSmrg		$ECHO "*** shared version of the library, which you do not appear to have"
67485a3d36dfSmrg		$ECHO "*** because I did check the linker path looking for a file starting"
67495a3d36dfSmrg		if test -z "$potlib" ; then
67505a3d36dfSmrg		  $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
67515a3d36dfSmrg		else
67525a3d36dfSmrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
67535a3d36dfSmrg		  $ECHO "*** using a regex pattern. Last file checked: $potlib"
67545a3d36dfSmrg		fi
67555a3d36dfSmrg	      fi
67565a3d36dfSmrg	      ;;
67575a3d36dfSmrg	    *)
67585a3d36dfSmrg	      # Add a -L argument.
67595a3d36dfSmrg	      newdeplibs="$newdeplibs $a_deplib"
67605a3d36dfSmrg	      ;;
67615a3d36dfSmrg	    esac
67625a3d36dfSmrg	  done # Gone through all deplibs.
67635a3d36dfSmrg	  ;;
67645a3d36dfSmrg	none | unknown | *)
67655a3d36dfSmrg	  newdeplibs=""
67665a3d36dfSmrg	  tmp_deplibs=`$ECHO "X $deplibs" | $Xsed \
67675a3d36dfSmrg	      -e 's/ -lc$//' -e 's/ -[LR][^ ]*//g'`
67685a3d36dfSmrg	  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
67695a3d36dfSmrg	    for i in $predeps $postdeps ; do
67705a3d36dfSmrg	      # can't use Xsed below, because $i might contain '/'
67715a3d36dfSmrg	      tmp_deplibs=`$ECHO "X $tmp_deplibs" | $Xsed -e "s,$i,,"`
67725a3d36dfSmrg	    done
67735a3d36dfSmrg	  fi
67745a3d36dfSmrg	  if $ECHO "X $tmp_deplibs" | $Xsed -e 's/[	 ]//g' |
67755a3d36dfSmrg	     $GREP . >/dev/null; then
67765a3d36dfSmrg	    $ECHO
67775a3d36dfSmrg	    if test "X$deplibs_check_method" = "Xnone"; then
67785a3d36dfSmrg	      $ECHO "*** Warning: inter-library dependencies are not supported in this platform."
67795a3d36dfSmrg	    else
67805a3d36dfSmrg	      $ECHO "*** Warning: inter-library dependencies are not known to be supported."
67815a3d36dfSmrg	    fi
67825a3d36dfSmrg	    $ECHO "*** All declared inter-library dependencies are being dropped."
67835a3d36dfSmrg	    droppeddeps=yes
67845a3d36dfSmrg	  fi
67855a3d36dfSmrg	  ;;
67865a3d36dfSmrg	esac
67875a3d36dfSmrg	versuffix=$versuffix_save
67885a3d36dfSmrg	major=$major_save
67895a3d36dfSmrg	release=$release_save
67905a3d36dfSmrg	libname=$libname_save
67915a3d36dfSmrg	name=$name_save
67925a3d36dfSmrg
67935a3d36dfSmrg	case $host in
67945a3d36dfSmrg	*-*-rhapsody* | *-*-darwin1.[012])
67955a3d36dfSmrg	  # On Rhapsody replace the C library with the System framework
67965a3d36dfSmrg	  newdeplibs=`$ECHO "X $newdeplibs" | $Xsed -e 's/ -lc / System.ltframework /'`
67975a3d36dfSmrg	  ;;
67985a3d36dfSmrg	esac
67995a3d36dfSmrg
68005a3d36dfSmrg	if test "$droppeddeps" = yes; then
68015a3d36dfSmrg	  if test "$module" = yes; then
68025a3d36dfSmrg	    $ECHO
68035a3d36dfSmrg	    $ECHO "*** Warning: libtool could not satisfy all declared inter-library"
68045a3d36dfSmrg	    $ECHO "*** dependencies of module $libname.  Therefore, libtool will create"
68055a3d36dfSmrg	    $ECHO "*** a static module, that should work as long as the dlopening"
68065a3d36dfSmrg	    $ECHO "*** application is linked with the -dlopen flag."
68075a3d36dfSmrg	    if test -z "$global_symbol_pipe"; then
68085a3d36dfSmrg	      $ECHO
68095a3d36dfSmrg	      $ECHO "*** However, this would only work if libtool was able to extract symbol"
68105a3d36dfSmrg	      $ECHO "*** lists from a program, using \`nm' or equivalent, but libtool could"
68115a3d36dfSmrg	      $ECHO "*** not find such a program.  So, this module is probably useless."
68125a3d36dfSmrg	      $ECHO "*** \`nm' from GNU binutils and a full rebuild may help."
68135a3d36dfSmrg	    fi
68145a3d36dfSmrg	    if test "$build_old_libs" = no; then
68155a3d36dfSmrg	      oldlibs="$output_objdir/$libname.$libext"
68165a3d36dfSmrg	      build_libtool_libs=module
68175a3d36dfSmrg	      build_old_libs=yes
68185a3d36dfSmrg	    else
68195a3d36dfSmrg	      build_libtool_libs=no
68205a3d36dfSmrg	    fi
68215a3d36dfSmrg	  else
68225a3d36dfSmrg	    $ECHO "*** The inter-library dependencies that have been dropped here will be"
68235a3d36dfSmrg	    $ECHO "*** automatically added whenever a program is linked with this library"
68245a3d36dfSmrg	    $ECHO "*** or is declared to -dlopen it."
68255a3d36dfSmrg
68265a3d36dfSmrg	    if test "$allow_undefined" = no; then
68275a3d36dfSmrg	      $ECHO
68285a3d36dfSmrg	      $ECHO "*** Since this library must not contain undefined symbols,"
68295a3d36dfSmrg	      $ECHO "*** because either the platform does not support them or"
68305a3d36dfSmrg	      $ECHO "*** it was explicitly requested with -no-undefined,"
68315a3d36dfSmrg	      $ECHO "*** libtool will only create a static version of it."
68325a3d36dfSmrg	      if test "$build_old_libs" = no; then
68335a3d36dfSmrg		oldlibs="$output_objdir/$libname.$libext"
68345a3d36dfSmrg		build_libtool_libs=module
68355a3d36dfSmrg		build_old_libs=yes
68365a3d36dfSmrg	      else
68375a3d36dfSmrg		build_libtool_libs=no
68385a3d36dfSmrg	      fi
68395a3d36dfSmrg	    fi
68405a3d36dfSmrg	  fi
68415a3d36dfSmrg	fi
68425a3d36dfSmrg	# Done checking deplibs!
68435a3d36dfSmrg	deplibs=$newdeplibs
68445a3d36dfSmrg      fi
68455a3d36dfSmrg      # Time to change all our "foo.ltframework" stuff back to "-framework foo"
68465a3d36dfSmrg      case $host in
68475a3d36dfSmrg	*-*-darwin*)
68485a3d36dfSmrg	  newdeplibs=`$ECHO "X $newdeplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
68495a3d36dfSmrg	  new_inherited_linker_flags=`$ECHO "X $new_inherited_linker_flags" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
68505a3d36dfSmrg	  deplibs=`$ECHO "X $deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
68515a3d36dfSmrg	  ;;
68525a3d36dfSmrg      esac
68535a3d36dfSmrg
68545a3d36dfSmrg      # move library search paths that coincide with paths to not yet
68555a3d36dfSmrg      # installed libraries to the beginning of the library search list
68565a3d36dfSmrg      new_libs=
68575a3d36dfSmrg      for path in $notinst_path; do
68585a3d36dfSmrg	case " $new_libs " in
68595a3d36dfSmrg	*" -L$path/$objdir "*) ;;
68605a3d36dfSmrg	*)
68615a3d36dfSmrg	  case " $deplibs " in
68625a3d36dfSmrg	  *" -L$path/$objdir "*)
68635a3d36dfSmrg	    new_libs="$new_libs -L$path/$objdir" ;;
68645a3d36dfSmrg	  esac
68655a3d36dfSmrg	  ;;
68665a3d36dfSmrg	esac
68675a3d36dfSmrg      done
68685a3d36dfSmrg      for deplib in $deplibs; do
68695a3d36dfSmrg	case $deplib in
68705a3d36dfSmrg	-L*)
68715a3d36dfSmrg	  case " $new_libs " in
68725a3d36dfSmrg	  *" $deplib "*) ;;
68735a3d36dfSmrg	  *) new_libs="$new_libs $deplib" ;;
68745a3d36dfSmrg	  esac
68755a3d36dfSmrg	  ;;
68765a3d36dfSmrg	*) new_libs="$new_libs $deplib" ;;
68775a3d36dfSmrg	esac
68785a3d36dfSmrg      done
68795a3d36dfSmrg      deplibs="$new_libs"
68805a3d36dfSmrg
68815a3d36dfSmrg      # All the library-specific variables (install_libdir is set above).
68825a3d36dfSmrg      library_names=
68835a3d36dfSmrg      old_library=
68845a3d36dfSmrg      dlname=
68855a3d36dfSmrg
68865a3d36dfSmrg      # Test again, we may have decided not to build it any more
68875a3d36dfSmrg      if test "$build_libtool_libs" = yes; then
68885a3d36dfSmrg	if test "$hardcode_into_libs" = yes; then
68895a3d36dfSmrg	  # Hardcode the library paths
68905a3d36dfSmrg	  hardcode_libdirs=
68915a3d36dfSmrg	  dep_rpath=
68925a3d36dfSmrg	  rpath="$finalize_rpath"
68935a3d36dfSmrg	  test "$mode" != relink && rpath="$compile_rpath$rpath"
68945a3d36dfSmrg	  for libdir in $rpath; do
68955a3d36dfSmrg	    if test -n "$hardcode_libdir_flag_spec"; then
68965a3d36dfSmrg	      if test -n "$hardcode_libdir_separator"; then
68975a3d36dfSmrg		if test -z "$hardcode_libdirs"; then
68985a3d36dfSmrg		  hardcode_libdirs="$libdir"
68995a3d36dfSmrg		else
69005a3d36dfSmrg		  # Just accumulate the unique libdirs.
69015a3d36dfSmrg		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
69025a3d36dfSmrg		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
69035a3d36dfSmrg		    ;;
69045a3d36dfSmrg		  *)
69055a3d36dfSmrg		    hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
69065a3d36dfSmrg		    ;;
69075a3d36dfSmrg		  esac
69085a3d36dfSmrg		fi
69095a3d36dfSmrg	      else
69105a3d36dfSmrg		eval flag=\"$hardcode_libdir_flag_spec\"
69115a3d36dfSmrg		dep_rpath="$dep_rpath $flag"
69125a3d36dfSmrg	      fi
69135a3d36dfSmrg	    elif test -n "$runpath_var"; then
69145a3d36dfSmrg	      case "$perm_rpath " in
69155a3d36dfSmrg	      *" $libdir "*) ;;
69165a3d36dfSmrg	      *) perm_rpath="$perm_rpath $libdir" ;;
69175a3d36dfSmrg	      esac
69185a3d36dfSmrg	    fi
69195a3d36dfSmrg	  done
69205a3d36dfSmrg	  # Substitute the hardcoded libdirs into the rpath.
69215a3d36dfSmrg	  if test -n "$hardcode_libdir_separator" &&
69225a3d36dfSmrg	     test -n "$hardcode_libdirs"; then
69235a3d36dfSmrg	    libdir="$hardcode_libdirs"
69245a3d36dfSmrg	    if test -n "$hardcode_libdir_flag_spec_ld"; then
69255a3d36dfSmrg	      eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\"
69265a3d36dfSmrg	    else
69275a3d36dfSmrg	      eval dep_rpath=\"$hardcode_libdir_flag_spec\"
69285a3d36dfSmrg	    fi
69295a3d36dfSmrg	  fi
69305a3d36dfSmrg	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
69315a3d36dfSmrg	    # We should set the runpath_var.
69325a3d36dfSmrg	    rpath=
69335a3d36dfSmrg	    for dir in $perm_rpath; do
69345a3d36dfSmrg	      rpath="$rpath$dir:"
69355a3d36dfSmrg	    done
69365a3d36dfSmrg	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
69375a3d36dfSmrg	  fi
69385a3d36dfSmrg	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
69395a3d36dfSmrg	fi
694023a0898aSmrg
69415a3d36dfSmrg	shlibpath="$finalize_shlibpath"
69425a3d36dfSmrg	test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
69435a3d36dfSmrg	if test -n "$shlibpath"; then
69445a3d36dfSmrg	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
69455a3d36dfSmrg	fi
694623a0898aSmrg
69475a3d36dfSmrg	# Get the real and link names of the library.
69485a3d36dfSmrg	eval shared_ext=\"$shrext_cmds\"
69495a3d36dfSmrg	eval library_names=\"$library_names_spec\"
69505a3d36dfSmrg	set dummy $library_names
69515a3d36dfSmrg	shift
69525a3d36dfSmrg	realname="$1"
69535a3d36dfSmrg	shift
695423a0898aSmrg
69555a3d36dfSmrg	if test -n "$soname_spec"; then
69565a3d36dfSmrg	  eval soname=\"$soname_spec\"
69575a3d36dfSmrg	else
69585a3d36dfSmrg	  soname="$realname"
69595a3d36dfSmrg	fi
69605a3d36dfSmrg	if test -z "$dlname"; then
69615a3d36dfSmrg	  dlname=$soname
69625a3d36dfSmrg	fi
696323a0898aSmrg
69645a3d36dfSmrg	lib="$output_objdir/$realname"
69655a3d36dfSmrg	linknames=
69665a3d36dfSmrg	for link
69675a3d36dfSmrg	do
69685a3d36dfSmrg	  linknames="$linknames $link"
69695a3d36dfSmrg	done
697023a0898aSmrg
69715a3d36dfSmrg	# Use standard objects if they are pic
69725a3d36dfSmrg	test -z "$pic_flag" && libobjs=`$ECHO "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
69735a3d36dfSmrg	test "X$libobjs" = "X " && libobjs=
697423a0898aSmrg
69755a3d36dfSmrg	delfiles=
69765a3d36dfSmrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
69775a3d36dfSmrg	  $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
69785a3d36dfSmrg	  export_symbols="$output_objdir/$libname.uexp"
69795a3d36dfSmrg	  delfiles="$delfiles $export_symbols"
69805a3d36dfSmrg	fi
698123a0898aSmrg
69825a3d36dfSmrg	orig_export_symbols=
69835a3d36dfSmrg	case $host_os in
69845a3d36dfSmrg	cygwin* | mingw* | cegcc*)
69855a3d36dfSmrg	  if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
69865a3d36dfSmrg	    # exporting using user supplied symfile
69875a3d36dfSmrg	    if test "x`$SED 1q $export_symbols`" != xEXPORTS; then
69885a3d36dfSmrg	      # and it's NOT already a .def file. Must figure out
69895a3d36dfSmrg	      # which of the given symbols are data symbols and tag
69905a3d36dfSmrg	      # them as such. So, trigger use of export_symbols_cmds.
69915a3d36dfSmrg	      # export_symbols gets reassigned inside the "prepare
69925a3d36dfSmrg	      # the list of exported symbols" if statement, so the
69935a3d36dfSmrg	      # include_expsyms logic still works.
69945a3d36dfSmrg	      orig_export_symbols="$export_symbols"
69955a3d36dfSmrg	      export_symbols=
69965a3d36dfSmrg	      always_export_symbols=yes
69975a3d36dfSmrg	    fi
69985a3d36dfSmrg	  fi
69995a3d36dfSmrg	  ;;
70005a3d36dfSmrg	esac
700123a0898aSmrg
70025a3d36dfSmrg	# Prepare the list of exported symbols
70035a3d36dfSmrg	if test -z "$export_symbols"; then
70045a3d36dfSmrg	  if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
70055a3d36dfSmrg	    func_verbose "generating symbol list for \`$libname.la'"
70065a3d36dfSmrg	    export_symbols="$output_objdir/$libname.exp"
70075a3d36dfSmrg	    $opt_dry_run || $RM $export_symbols
70085a3d36dfSmrg	    cmds=$export_symbols_cmds
70095a3d36dfSmrg	    save_ifs="$IFS"; IFS='~'
70105a3d36dfSmrg	    for cmd in $cmds; do
70115a3d36dfSmrg	      IFS="$save_ifs"
70125a3d36dfSmrg	      eval cmd=\"$cmd\"
70135a3d36dfSmrg	      func_len " $cmd"
70145a3d36dfSmrg	      len=$func_len_result
70155a3d36dfSmrg	      if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
70165a3d36dfSmrg		func_show_eval "$cmd" 'exit $?'
70175a3d36dfSmrg		skipped_export=false
70185a3d36dfSmrg	      else
70195a3d36dfSmrg		# The command line is too long to execute in one step.
70205a3d36dfSmrg		func_verbose "using reloadable object file for export list..."
70215a3d36dfSmrg		skipped_export=:
70225a3d36dfSmrg		# Break out early, otherwise skipped_export may be
70235a3d36dfSmrg		# set to false by a later but shorter cmd.
70245a3d36dfSmrg		break
70255a3d36dfSmrg	      fi
70265a3d36dfSmrg	    done
70275a3d36dfSmrg	    IFS="$save_ifs"
70285a3d36dfSmrg	    if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then
70295a3d36dfSmrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
70305a3d36dfSmrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
70315a3d36dfSmrg	    fi
70325a3d36dfSmrg	  fi
70337f7f5e4eSmrg	fi
703423a0898aSmrg
70355a3d36dfSmrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
70365a3d36dfSmrg	  tmp_export_symbols="$export_symbols"
70375a3d36dfSmrg	  test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
70385a3d36dfSmrg	  $opt_dry_run || eval '$ECHO "X$include_expsyms" | $Xsed | $SP2NL >> "$tmp_export_symbols"'
70395a3d36dfSmrg	fi
704023a0898aSmrg
70415a3d36dfSmrg	if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then
70425a3d36dfSmrg	  # The given exports_symbols file has to be filtered, so filter it.
70435a3d36dfSmrg	  func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
70445a3d36dfSmrg	  # FIXME: $output_objdir/$libname.filter potentially contains lots of
70455a3d36dfSmrg	  # 's' commands which not all seds can handle. GNU sed should be fine
70465a3d36dfSmrg	  # though. Also, the filter scales superlinearly with the number of
70475a3d36dfSmrg	  # global variables. join(1) would be nice here, but unfortunately
70485a3d36dfSmrg	  # isn't a blessed tool.
70495a3d36dfSmrg	  $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
70505a3d36dfSmrg	  delfiles="$delfiles $export_symbols $output_objdir/$libname.filter"
70515a3d36dfSmrg	  export_symbols=$output_objdir/$libname.def
70525a3d36dfSmrg	  $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
70535a3d36dfSmrg	fi
705423a0898aSmrg
70555a3d36dfSmrg	tmp_deplibs=
70565a3d36dfSmrg	for test_deplib in $deplibs; do
70575a3d36dfSmrg	  case " $convenience " in
70585a3d36dfSmrg	  *" $test_deplib "*) ;;
70595a3d36dfSmrg	  *)
70605a3d36dfSmrg	    tmp_deplibs="$tmp_deplibs $test_deplib"
70615a3d36dfSmrg	    ;;
70625a3d36dfSmrg	  esac
70635a3d36dfSmrg	done
70645a3d36dfSmrg	deplibs="$tmp_deplibs"
706523a0898aSmrg
70665a3d36dfSmrg	if test -n "$convenience"; then
70675a3d36dfSmrg	  if test -n "$whole_archive_flag_spec" &&
70685a3d36dfSmrg	    test "$compiler_needs_object" = yes &&
70695a3d36dfSmrg	    test -z "$libobjs"; then
70705a3d36dfSmrg	    # extract the archives, so we have objects to list.
70715a3d36dfSmrg	    # TODO: could optimize this to just extract one archive.
70725a3d36dfSmrg	    whole_archive_flag_spec=
70735a3d36dfSmrg	  fi
70745a3d36dfSmrg	  if test -n "$whole_archive_flag_spec"; then
70755a3d36dfSmrg	    save_libobjs=$libobjs
70765a3d36dfSmrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
70775a3d36dfSmrg	    test "X$libobjs" = "X " && libobjs=
70785a3d36dfSmrg	  else
70795a3d36dfSmrg	    gentop="$output_objdir/${outputname}x"
70805a3d36dfSmrg	    generated="$generated $gentop"
708123a0898aSmrg
70825a3d36dfSmrg	    func_extract_archives $gentop $convenience
70835a3d36dfSmrg	    libobjs="$libobjs $func_extract_archives_result"
70845a3d36dfSmrg	    test "X$libobjs" = "X " && libobjs=
70855a3d36dfSmrg	  fi
7086b3062210Smrg	fi
708723a0898aSmrg
70885a3d36dfSmrg	if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
70895a3d36dfSmrg	  eval flag=\"$thread_safe_flag_spec\"
70905a3d36dfSmrg	  linker_flags="$linker_flags $flag"
7091b3062210Smrg	fi
709223a0898aSmrg
70935a3d36dfSmrg	# Make a backup of the uninstalled library when relinking
70945a3d36dfSmrg	if test "$mode" = relink; then
70955a3d36dfSmrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
70965a3d36dfSmrg	fi
709723a0898aSmrg
70985a3d36dfSmrg	# Do each of the archive commands.
70995a3d36dfSmrg	if test "$module" = yes && test -n "$module_cmds" ; then
71005a3d36dfSmrg	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
71015a3d36dfSmrg	    eval test_cmds=\"$module_expsym_cmds\"
71025a3d36dfSmrg	    cmds=$module_expsym_cmds
71035a3d36dfSmrg	  else
71045a3d36dfSmrg	    eval test_cmds=\"$module_cmds\"
71055a3d36dfSmrg	    cmds=$module_cmds
71065a3d36dfSmrg	  fi
7107b3062210Smrg	else
71085a3d36dfSmrg	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
71095a3d36dfSmrg	    eval test_cmds=\"$archive_expsym_cmds\"
71105a3d36dfSmrg	    cmds=$archive_expsym_cmds
71115a3d36dfSmrg	  else
71125a3d36dfSmrg	    eval test_cmds=\"$archive_cmds\"
71135a3d36dfSmrg	    cmds=$archive_cmds
71145a3d36dfSmrg	  fi
7115b3062210Smrg	fi
711623a0898aSmrg
71175a3d36dfSmrg	if test "X$skipped_export" != "X:" &&
71185a3d36dfSmrg	   func_len " $test_cmds" &&
71195a3d36dfSmrg	   len=$func_len_result &&
71205a3d36dfSmrg	   test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
71215a3d36dfSmrg	  :
71225a3d36dfSmrg	else
71235a3d36dfSmrg	  # The command line is too long to link in one step, link piecewise
71245a3d36dfSmrg	  # or, if using GNU ld and skipped_export is not :, use a linker
71255a3d36dfSmrg	  # script.
712623a0898aSmrg
71275a3d36dfSmrg	  # Save the value of $output and $libobjs because we want to
71285a3d36dfSmrg	  # use them later.  If we have whole_archive_flag_spec, we
71295a3d36dfSmrg	  # want to use save_libobjs as it was before
71305a3d36dfSmrg	  # whole_archive_flag_spec was expanded, because we can't
71315a3d36dfSmrg	  # assume the linker understands whole_archive_flag_spec.
71325a3d36dfSmrg	  # This may have to be revisited, in case too many
71335a3d36dfSmrg	  # convenience libraries get linked in and end up exceeding
71345a3d36dfSmrg	  # the spec.
71355a3d36dfSmrg	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
71365a3d36dfSmrg	    save_libobjs=$libobjs
71375a3d36dfSmrg	  fi
71385a3d36dfSmrg	  save_output=$output
71395a3d36dfSmrg	  output_la=`$ECHO "X$output" | $Xsed -e "$basename"`
714023a0898aSmrg
71415a3d36dfSmrg	  # Clear the reloadable object creation command queue and
71425a3d36dfSmrg	  # initialize k to one.
71435a3d36dfSmrg	  test_cmds=
71445a3d36dfSmrg	  concat_cmds=
71455a3d36dfSmrg	  objlist=
71465a3d36dfSmrg	  last_robj=
71475a3d36dfSmrg	  k=1
71485a3d36dfSmrg
71495a3d36dfSmrg	  if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
71505a3d36dfSmrg	    output=${output_objdir}/${output_la}.lnkscript
71515a3d36dfSmrg	    func_verbose "creating GNU ld script: $output"
71525a3d36dfSmrg	    $ECHO 'INPUT (' > $output
71535a3d36dfSmrg	    for obj in $save_libobjs
7154b3062210Smrg	    do
71555a3d36dfSmrg	      $ECHO "$obj" >> $output
71565a3d36dfSmrg	    done
71575a3d36dfSmrg	    $ECHO ')' >> $output
71585a3d36dfSmrg	    delfiles="$delfiles $output"
71595a3d36dfSmrg	  elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then
71605a3d36dfSmrg	    output=${output_objdir}/${output_la}.lnk
71615a3d36dfSmrg	    func_verbose "creating linker input file list: $output"
71625a3d36dfSmrg	    : > $output
71635a3d36dfSmrg	    set x $save_libobjs
71645a3d36dfSmrg	    shift
71655a3d36dfSmrg	    firstobj=
71665a3d36dfSmrg	    if test "$compiler_needs_object" = yes; then
71675a3d36dfSmrg	      firstobj="$1 "
71685a3d36dfSmrg	      shift
71695a3d36dfSmrg	    fi
71705a3d36dfSmrg	    for obj
71715a3d36dfSmrg	    do
71725a3d36dfSmrg	      $ECHO "$obj" >> $output
71735a3d36dfSmrg	    done
71745a3d36dfSmrg	    delfiles="$delfiles $output"
71755a3d36dfSmrg	    output=$firstobj\"$file_list_spec$output\"
71765a3d36dfSmrg	  else
71775a3d36dfSmrg	    if test -n "$save_libobjs"; then
71785a3d36dfSmrg	      func_verbose "creating reloadable object files..."
71795a3d36dfSmrg	      output=$output_objdir/$output_la-${k}.$objext
71805a3d36dfSmrg	      eval test_cmds=\"$reload_cmds\"
71815a3d36dfSmrg	      func_len " $test_cmds"
71825a3d36dfSmrg	      len0=$func_len_result
71835a3d36dfSmrg	      len=$len0
71845a3d36dfSmrg
71855a3d36dfSmrg	      # Loop over the list of objects to be linked.
71865a3d36dfSmrg	      for obj in $save_libobjs
71875a3d36dfSmrg	      do
71885a3d36dfSmrg		func_len " $obj"
71895a3d36dfSmrg		func_arith $len + $func_len_result
71905a3d36dfSmrg		len=$func_arith_result
71915a3d36dfSmrg		if test "X$objlist" = X ||
71925a3d36dfSmrg		   test "$len" -lt "$max_cmd_len"; then
71935a3d36dfSmrg		  func_append objlist " $obj"
71945a3d36dfSmrg		else
71955a3d36dfSmrg		  # The command $test_cmds is almost too long, add a
71965a3d36dfSmrg		  # command to the queue.
71975a3d36dfSmrg		  if test "$k" -eq 1 ; then
71985a3d36dfSmrg		    # The first file doesn't have a previous command to add.
71995a3d36dfSmrg		    eval concat_cmds=\"$reload_cmds $objlist $last_robj\"
72005a3d36dfSmrg		  else
72015a3d36dfSmrg		    # All subsequent reloadable object files will link in
72025a3d36dfSmrg		    # the last one created.
72035a3d36dfSmrg		    eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj~\$RM $last_robj\"
72045a3d36dfSmrg		  fi
72055a3d36dfSmrg		  last_robj=$output_objdir/$output_la-${k}.$objext
72065a3d36dfSmrg		  func_arith $k + 1
72075a3d36dfSmrg		  k=$func_arith_result
72085a3d36dfSmrg		  output=$output_objdir/$output_la-${k}.$objext
72095a3d36dfSmrg		  objlist=$obj
72105a3d36dfSmrg		  func_len " $last_robj"
72115a3d36dfSmrg		  func_arith $len0 + $func_len_result
72125a3d36dfSmrg		  len=$func_arith_result
72135a3d36dfSmrg		fi
72145a3d36dfSmrg	      done
72155a3d36dfSmrg	      # Handle the remaining objects by creating one last
72165a3d36dfSmrg	      # reloadable object file.  All subsequent reloadable object
72175a3d36dfSmrg	      # files will link in the last one created.
72185a3d36dfSmrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
72195a3d36dfSmrg	      eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\"
72205a3d36dfSmrg	      if test -n "$last_robj"; then
72215a3d36dfSmrg	        eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\"
72225a3d36dfSmrg	      fi
72235a3d36dfSmrg	      delfiles="$delfiles $output"
722423a0898aSmrg
72255a3d36dfSmrg	    else
72265a3d36dfSmrg	      output=
72275a3d36dfSmrg	    fi
722823a0898aSmrg
72295a3d36dfSmrg	    if ${skipped_export-false}; then
72305a3d36dfSmrg	      func_verbose "generating symbol list for \`$libname.la'"
72315a3d36dfSmrg	      export_symbols="$output_objdir/$libname.exp"
72325a3d36dfSmrg	      $opt_dry_run || $RM $export_symbols
72335a3d36dfSmrg	      libobjs=$output
72345a3d36dfSmrg	      # Append the command to create the export file.
72355a3d36dfSmrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
72365a3d36dfSmrg	      eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
72375a3d36dfSmrg	      if test -n "$last_robj"; then
72385a3d36dfSmrg		eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
72395a3d36dfSmrg	      fi
72407f7f5e4eSmrg	    fi
724123a0898aSmrg
72425a3d36dfSmrg	    test -n "$save_libobjs" &&
72435a3d36dfSmrg	      func_verbose "creating a temporary reloadable object file: $output"
724423a0898aSmrg
72455a3d36dfSmrg	    # Loop through the commands generated above and execute them.
72465a3d36dfSmrg	    save_ifs="$IFS"; IFS='~'
72475a3d36dfSmrg	    for cmd in $concat_cmds; do
72485a3d36dfSmrg	      IFS="$save_ifs"
72495a3d36dfSmrg	      $opt_silent || {
72505a3d36dfSmrg		  func_quote_for_expand "$cmd"
72515a3d36dfSmrg		  eval "func_echo $func_quote_for_expand_result"
72525a3d36dfSmrg	      }
72535a3d36dfSmrg	      $opt_dry_run || eval "$cmd" || {
72545a3d36dfSmrg		lt_exit=$?
72555a3d36dfSmrg
72565a3d36dfSmrg		# Restore the uninstalled library and exit
72575a3d36dfSmrg		if test "$mode" = relink; then
72585a3d36dfSmrg		  ( cd "$output_objdir" && \
72595a3d36dfSmrg		    $RM "${realname}T" && \
72605a3d36dfSmrg		    $MV "${realname}U" "$realname" )
72615a3d36dfSmrg		fi
72627f7f5e4eSmrg
72635a3d36dfSmrg		exit $lt_exit
72645a3d36dfSmrg	      }
72655a3d36dfSmrg	    done
72665a3d36dfSmrg	    IFS="$save_ifs"
7267b3062210Smrg
72685a3d36dfSmrg	    if test -n "$export_symbols_regex" && ${skipped_export-false}; then
72695a3d36dfSmrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
72705a3d36dfSmrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
727123a0898aSmrg	    fi
727223a0898aSmrg	  fi
727323a0898aSmrg
72745a3d36dfSmrg          if ${skipped_export-false}; then
72755a3d36dfSmrg	    if test -n "$export_symbols" && test -n "$include_expsyms"; then
72765a3d36dfSmrg	      tmp_export_symbols="$export_symbols"
72775a3d36dfSmrg	      test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
72785a3d36dfSmrg	      $opt_dry_run || eval '$ECHO "X$include_expsyms" | $Xsed | $SP2NL >> "$tmp_export_symbols"'
72795a3d36dfSmrg	    fi
728023a0898aSmrg
72815a3d36dfSmrg	    if test -n "$orig_export_symbols"; then
72825a3d36dfSmrg	      # The given exports_symbols file has to be filtered, so filter it.
72835a3d36dfSmrg	      func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
72845a3d36dfSmrg	      # FIXME: $output_objdir/$libname.filter potentially contains lots of
72855a3d36dfSmrg	      # 's' commands which not all seds can handle. GNU sed should be fine
72865a3d36dfSmrg	      # though. Also, the filter scales superlinearly with the number of
72875a3d36dfSmrg	      # global variables. join(1) would be nice here, but unfortunately
72885a3d36dfSmrg	      # isn't a blessed tool.
72895a3d36dfSmrg	      $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
72905a3d36dfSmrg	      delfiles="$delfiles $export_symbols $output_objdir/$libname.filter"
72915a3d36dfSmrg	      export_symbols=$output_objdir/$libname.def
72925a3d36dfSmrg	      $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
72935a3d36dfSmrg	    fi
72945a3d36dfSmrg	  fi
729523a0898aSmrg
72965a3d36dfSmrg	  libobjs=$output
72975a3d36dfSmrg	  # Restore the value of output.
72985a3d36dfSmrg	  output=$save_output
729923a0898aSmrg
73005a3d36dfSmrg	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
73015a3d36dfSmrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
73025a3d36dfSmrg	    test "X$libobjs" = "X " && libobjs=
73035a3d36dfSmrg	  fi
73045a3d36dfSmrg	  # Expand the library linking commands again to reset the
73055a3d36dfSmrg	  # value of $libobjs for piecewise linking.
730623a0898aSmrg
73075a3d36dfSmrg	  # Do each of the archive commands.
73085a3d36dfSmrg	  if test "$module" = yes && test -n "$module_cmds" ; then
73095a3d36dfSmrg	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
73105a3d36dfSmrg	      cmds=$module_expsym_cmds
73115a3d36dfSmrg	    else
73125a3d36dfSmrg	      cmds=$module_cmds
7313b3062210Smrg	    fi
7314b3062210Smrg	  else
73155a3d36dfSmrg	    if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
73165a3d36dfSmrg	      cmds=$archive_expsym_cmds
73175a3d36dfSmrg	    else
73185a3d36dfSmrg	      cmds=$archive_cmds
73195a3d36dfSmrg	    fi
7320b3062210Smrg	  fi
73215a3d36dfSmrg	fi
732223a0898aSmrg
73235a3d36dfSmrg	if test -n "$delfiles"; then
73245a3d36dfSmrg	  # Append the command to remove temporary files to $cmds.
73255a3d36dfSmrg	  eval cmds=\"\$cmds~\$RM $delfiles\"
73265a3d36dfSmrg	fi
732723a0898aSmrg
73285a3d36dfSmrg	# Add any objects from preloaded convenience libraries
73295a3d36dfSmrg	if test -n "$dlprefiles"; then
73305a3d36dfSmrg	  gentop="$output_objdir/${outputname}x"
73315a3d36dfSmrg	  generated="$generated $gentop"
733223a0898aSmrg
73335a3d36dfSmrg	  func_extract_archives $gentop $dlprefiles
73345a3d36dfSmrg	  libobjs="$libobjs $func_extract_archives_result"
73355a3d36dfSmrg	  test "X$libobjs" = "X " && libobjs=
73365a3d36dfSmrg	fi
733723a0898aSmrg
73385a3d36dfSmrg	save_ifs="$IFS"; IFS='~'
73395a3d36dfSmrg	for cmd in $cmds; do
73405a3d36dfSmrg	  IFS="$save_ifs"
73415a3d36dfSmrg	  eval cmd=\"$cmd\"
73425a3d36dfSmrg	  $opt_silent || {
73435a3d36dfSmrg	    func_quote_for_expand "$cmd"
73445a3d36dfSmrg	    eval "func_echo $func_quote_for_expand_result"
73455a3d36dfSmrg	  }
73465a3d36dfSmrg	  $opt_dry_run || eval "$cmd" || {
73475a3d36dfSmrg	    lt_exit=$?
73487f7f5e4eSmrg
73495a3d36dfSmrg	    # Restore the uninstalled library and exit
73505a3d36dfSmrg	    if test "$mode" = relink; then
73515a3d36dfSmrg	      ( cd "$output_objdir" && \
73525a3d36dfSmrg	        $RM "${realname}T" && \
73535a3d36dfSmrg		$MV "${realname}U" "$realname" )
73545a3d36dfSmrg	    fi
73557f7f5e4eSmrg
73565a3d36dfSmrg	    exit $lt_exit
73575a3d36dfSmrg	  }
73585a3d36dfSmrg	done
73595a3d36dfSmrg	IFS="$save_ifs"
73607f7f5e4eSmrg
73615a3d36dfSmrg	# Restore the uninstalled library and exit
73625a3d36dfSmrg	if test "$mode" = relink; then
73635a3d36dfSmrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
73647f7f5e4eSmrg
73655a3d36dfSmrg	  if test -n "$convenience"; then
73665a3d36dfSmrg	    if test -z "$whole_archive_flag_spec"; then
73675a3d36dfSmrg	      func_show_eval '${RM}r "$gentop"'
73685a3d36dfSmrg	    fi
73695a3d36dfSmrg	  fi
73707f7f5e4eSmrg
73715a3d36dfSmrg	  exit $EXIT_SUCCESS
73725a3d36dfSmrg	fi
73735a3d36dfSmrg
73745a3d36dfSmrg	# Create links to the real library.
73755a3d36dfSmrg	for linkname in $linknames; do
73765a3d36dfSmrg	  if test "$realname" != "$linkname"; then
73775a3d36dfSmrg	    func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
7378b3062210Smrg	  fi
7379b3062210Smrg	done
73807f7f5e4eSmrg
73815a3d36dfSmrg	# If -module or -export-dynamic was specified, set the dlname.
73825a3d36dfSmrg	if test "$module" = yes || test "$export_dynamic" = yes; then
73835a3d36dfSmrg	  # On all known operating systems, these are identical.
73845a3d36dfSmrg	  dlname="$soname"
73855a3d36dfSmrg	fi
73865a3d36dfSmrg      fi
738723a0898aSmrg      ;;
738823a0898aSmrg
73895a3d36dfSmrg    obj)
73905a3d36dfSmrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
73915a3d36dfSmrg	func_warning "\`-dlopen' is ignored for objects"
73925a3d36dfSmrg      fi
7393b3062210Smrg
73945a3d36dfSmrg      case " $deplibs" in
73955a3d36dfSmrg      *\ -l* | *\ -L*)
73965a3d36dfSmrg	func_warning "\`-l' and \`-L' are ignored for objects" ;;
73977f7f5e4eSmrg      esac
739823a0898aSmrg
73995a3d36dfSmrg      test -n "$rpath" && \
74005a3d36dfSmrg	func_warning "\`-rpath' is ignored for objects"
74015a3d36dfSmrg
74025a3d36dfSmrg      test -n "$xrpath" && \
74035a3d36dfSmrg	func_warning "\`-R' is ignored for objects"
740423a0898aSmrg
74055a3d36dfSmrg      test -n "$vinfo" && \
74065a3d36dfSmrg	func_warning "\`-version-info' is ignored for objects"
74077f7f5e4eSmrg
74085a3d36dfSmrg      test -n "$release" && \
74095a3d36dfSmrg	func_warning "\`-release' is ignored for objects"
74105a3d36dfSmrg
74115a3d36dfSmrg      case $output in
74125a3d36dfSmrg      *.lo)
74135a3d36dfSmrg	test -n "$objs$old_deplibs" && \
74145a3d36dfSmrg	  func_fatal_error "cannot build library object \`$output' from non-libtool objects"
74155a3d36dfSmrg
74165a3d36dfSmrg	libobj=$output
74175a3d36dfSmrg	func_lo2o "$libobj"
74185a3d36dfSmrg	obj=$func_lo2o_result
7419b3062210Smrg	;;
7420b3062210Smrg      *)
74215a3d36dfSmrg	libobj=
74225a3d36dfSmrg	obj="$output"
742323a0898aSmrg	;;
74247f7f5e4eSmrg      esac
742523a0898aSmrg
74265a3d36dfSmrg      # Delete the old objects.
74275a3d36dfSmrg      $opt_dry_run || $RM $obj $libobj
742823a0898aSmrg
74295a3d36dfSmrg      # Objects from convenience libraries.  This assumes
74305a3d36dfSmrg      # single-version convenience libraries.  Whenever we create
74315a3d36dfSmrg      # different ones for PIC/non-PIC, this we'll have to duplicate
74325a3d36dfSmrg      # the extraction.
74335a3d36dfSmrg      reload_conv_objs=
74345a3d36dfSmrg      gentop=
74355a3d36dfSmrg      # reload_cmds runs $LD directly, so let us get rid of
74365a3d36dfSmrg      # -Wl from whole_archive_flag_spec and hope we can get by with
74375a3d36dfSmrg      # turning comma into space..
74385a3d36dfSmrg      wl=
743923a0898aSmrg
74405a3d36dfSmrg      if test -n "$convenience"; then
74415a3d36dfSmrg	if test -n "$whole_archive_flag_spec"; then
74425a3d36dfSmrg	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
74435a3d36dfSmrg	  reload_conv_objs=$reload_objs\ `$ECHO "X$tmp_whole_archive_flags" | $Xsed -e 's|,| |g'`
74445a3d36dfSmrg	else
74455a3d36dfSmrg	  gentop="$output_objdir/${obj}x"
74465a3d36dfSmrg	  generated="$generated $gentop"
7447b3062210Smrg
74485a3d36dfSmrg	  func_extract_archives $gentop $convenience
74495a3d36dfSmrg	  reload_conv_objs="$reload_objs $func_extract_archives_result"
74505a3d36dfSmrg	fi
7451b3062210Smrg      fi
7452b3062210Smrg
74535a3d36dfSmrg      # Create the old-style object.
74545a3d36dfSmrg      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
7455b3062210Smrg
74565a3d36dfSmrg      output="$obj"
74575a3d36dfSmrg      func_execute_cmds "$reload_cmds" 'exit $?'
7458b3062210Smrg
74595a3d36dfSmrg      # Exit if we aren't doing a library object file.
74605a3d36dfSmrg      if test -z "$libobj"; then
74615a3d36dfSmrg	if test -n "$gentop"; then
74625a3d36dfSmrg	  func_show_eval '${RM}r "$gentop"'
74635a3d36dfSmrg	fi
74645a3d36dfSmrg
74655a3d36dfSmrg	exit $EXIT_SUCCESS
7466b3062210Smrg      fi
74675a3d36dfSmrg
74685a3d36dfSmrg      if test "$build_libtool_libs" != yes; then
74695a3d36dfSmrg	if test -n "$gentop"; then
74705a3d36dfSmrg	  func_show_eval '${RM}r "$gentop"'
74715a3d36dfSmrg	fi
74725a3d36dfSmrg
74735a3d36dfSmrg	# Create an invalid libtool object if no PIC, so that we don't
74745a3d36dfSmrg	# accidentally link it into a program.
74755a3d36dfSmrg	# $show "echo timestamp > $libobj"
74765a3d36dfSmrg	# $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
74775a3d36dfSmrg	exit $EXIT_SUCCESS
74785a3d36dfSmrg      fi
74795a3d36dfSmrg
74805a3d36dfSmrg      if test -n "$pic_flag" || test "$pic_mode" != default; then
74815a3d36dfSmrg	# Only do commands if we really have different PIC objects.
74825a3d36dfSmrg	reload_objs="$libobjs $reload_conv_objs"
74835a3d36dfSmrg	output="$libobj"
74845a3d36dfSmrg	func_execute_cmds "$reload_cmds" 'exit $?'
74855a3d36dfSmrg      fi
74865a3d36dfSmrg
74875a3d36dfSmrg      if test -n "$gentop"; then
74885a3d36dfSmrg	func_show_eval '${RM}r "$gentop"'
74895a3d36dfSmrg      fi
74905a3d36dfSmrg
74915a3d36dfSmrg      exit $EXIT_SUCCESS
7492b3062210Smrg      ;;
749323a0898aSmrg
74945a3d36dfSmrg    prog)
74955a3d36dfSmrg      case $host in
74965a3d36dfSmrg	*cygwin*) func_stripname '' '.exe' "$output"
74975a3d36dfSmrg	          output=$func_stripname_result.exe;;
74985a3d36dfSmrg      esac
74995a3d36dfSmrg      test -n "$vinfo" && \
75005a3d36dfSmrg	func_warning "\`-version-info' is ignored for programs"
750123a0898aSmrg
75025a3d36dfSmrg      test -n "$release" && \
75035a3d36dfSmrg	func_warning "\`-release' is ignored for programs"
750423a0898aSmrg
75055a3d36dfSmrg      test "$preload" = yes \
75065a3d36dfSmrg        && test "$dlopen_support" = unknown \
75075a3d36dfSmrg	&& test "$dlopen_self" = unknown \
75085a3d36dfSmrg	&& test "$dlopen_self_static" = unknown && \
75095a3d36dfSmrg	  func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support."
75105a3d36dfSmrg
75115a3d36dfSmrg      case $host in
75125a3d36dfSmrg      *-*-rhapsody* | *-*-darwin1.[012])
75135a3d36dfSmrg	# On Rhapsody replace the C library is the System framework
75145a3d36dfSmrg	compile_deplibs=`$ECHO "X $compile_deplibs" | $Xsed -e 's/ -lc / System.ltframework /'`
75155a3d36dfSmrg	finalize_deplibs=`$ECHO "X $finalize_deplibs" | $Xsed -e 's/ -lc / System.ltframework /'`
7516b3062210Smrg	;;
75175a3d36dfSmrg      esac
7518b3062210Smrg
75195a3d36dfSmrg      case $host in
75205a3d36dfSmrg      *-*-darwin*)
75215a3d36dfSmrg	# Don't allow lazy linking, it breaks C++ global constructors
75225a3d36dfSmrg	# But is supposedly fixed on 10.4 or later (yay!).
75235a3d36dfSmrg	if test "$tagname" = CXX ; then
75245a3d36dfSmrg	  case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
75255a3d36dfSmrg	    10.[0123])
75265a3d36dfSmrg	      compile_command="$compile_command ${wl}-bind_at_load"
75275a3d36dfSmrg	      finalize_command="$finalize_command ${wl}-bind_at_load"
75285a3d36dfSmrg	    ;;
75295a3d36dfSmrg	  esac
7530b3062210Smrg	fi
75315a3d36dfSmrg	# Time to change all our "foo.ltframework" stuff back to "-framework foo"
75325a3d36dfSmrg	compile_deplibs=`$ECHO "X $compile_deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
75335a3d36dfSmrg	finalize_deplibs=`$ECHO "X $finalize_deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
75345a3d36dfSmrg	;;
75355a3d36dfSmrg      esac
7536b3062210Smrg
7537b3062210Smrg
75385a3d36dfSmrg      # move library search paths that coincide with paths to not yet
75395a3d36dfSmrg      # installed libraries to the beginning of the library search list
75405a3d36dfSmrg      new_libs=
75415a3d36dfSmrg      for path in $notinst_path; do
75425a3d36dfSmrg	case " $new_libs " in
75435a3d36dfSmrg	*" -L$path/$objdir "*) ;;
75445a3d36dfSmrg	*)
75455a3d36dfSmrg	  case " $compile_deplibs " in
75465a3d36dfSmrg	  *" -L$path/$objdir "*)
75475a3d36dfSmrg	    new_libs="$new_libs -L$path/$objdir" ;;
75487f7f5e4eSmrg	  esac
75495a3d36dfSmrg	  ;;
75505a3d36dfSmrg	esac
75515a3d36dfSmrg      done
75525a3d36dfSmrg      for deplib in $compile_deplibs; do
75535a3d36dfSmrg	case $deplib in
75545a3d36dfSmrg	-L*)
75555a3d36dfSmrg	  case " $new_libs " in
75565a3d36dfSmrg	  *" $deplib "*) ;;
75575a3d36dfSmrg	  *) new_libs="$new_libs $deplib" ;;
75587f7f5e4eSmrg	  esac
75595a3d36dfSmrg	  ;;
75605a3d36dfSmrg	*) new_libs="$new_libs $deplib" ;;
75615a3d36dfSmrg	esac
75625a3d36dfSmrg      done
75635a3d36dfSmrg      compile_deplibs="$new_libs"
756423a0898aSmrg
7565b3062210Smrg
75665a3d36dfSmrg      compile_command="$compile_command $compile_deplibs"
75675a3d36dfSmrg      finalize_command="$finalize_command $finalize_deplibs"
7568b3062210Smrg
75695a3d36dfSmrg      if test -n "$rpath$xrpath"; then
75705a3d36dfSmrg	# If the user specified any rpath flags, then add them.
75715a3d36dfSmrg	for libdir in $rpath $xrpath; do
75725a3d36dfSmrg	  # This is the magic to use -rpath.
75735a3d36dfSmrg	  case "$finalize_rpath " in
75745a3d36dfSmrg	  *" $libdir "*) ;;
75755a3d36dfSmrg	  *) finalize_rpath="$finalize_rpath $libdir" ;;
75765a3d36dfSmrg	  esac
75775a3d36dfSmrg	done
75785a3d36dfSmrg      fi
7579b3062210Smrg
75805a3d36dfSmrg      # Now hardcode the library paths
75815a3d36dfSmrg      rpath=
75825a3d36dfSmrg      hardcode_libdirs=
75835a3d36dfSmrg      for libdir in $compile_rpath $finalize_rpath; do
75845a3d36dfSmrg	if test -n "$hardcode_libdir_flag_spec"; then
75855a3d36dfSmrg	  if test -n "$hardcode_libdir_separator"; then
75865a3d36dfSmrg	    if test -z "$hardcode_libdirs"; then
75875a3d36dfSmrg	      hardcode_libdirs="$libdir"
75885a3d36dfSmrg	    else
75895a3d36dfSmrg	      # Just accumulate the unique libdirs.
75905a3d36dfSmrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
75915a3d36dfSmrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
75925a3d36dfSmrg		;;
75935a3d36dfSmrg	      *)
75945a3d36dfSmrg		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
75955a3d36dfSmrg		;;
75965a3d36dfSmrg	      esac
75975a3d36dfSmrg	    fi
7598b3062210Smrg	  else
75995a3d36dfSmrg	    eval flag=\"$hardcode_libdir_flag_spec\"
76005a3d36dfSmrg	    rpath="$rpath $flag"
7601b3062210Smrg	  fi
76025a3d36dfSmrg	elif test -n "$runpath_var"; then
76035a3d36dfSmrg	  case "$perm_rpath " in
76045a3d36dfSmrg	  *" $libdir "*) ;;
76055a3d36dfSmrg	  *) perm_rpath="$perm_rpath $libdir" ;;
76065a3d36dfSmrg	  esac
76075a3d36dfSmrg	fi
76085a3d36dfSmrg	case $host in
76095a3d36dfSmrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
76105a3d36dfSmrg	  testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'`
76115a3d36dfSmrg	  case :$dllsearchpath: in
76125a3d36dfSmrg	  *":$libdir:"*) ;;
76135a3d36dfSmrg	  ::) dllsearchpath=$libdir;;
76145a3d36dfSmrg	  *) dllsearchpath="$dllsearchpath:$libdir";;
76155a3d36dfSmrg	  esac
76165a3d36dfSmrg	  case :$dllsearchpath: in
76175a3d36dfSmrg	  *":$testbindir:"*) ;;
76185a3d36dfSmrg	  ::) dllsearchpath=$testbindir;;
76195a3d36dfSmrg	  *) dllsearchpath="$dllsearchpath:$testbindir";;
76205a3d36dfSmrg	  esac
76215a3d36dfSmrg	  ;;
76225a3d36dfSmrg	esac
76235a3d36dfSmrg      done
76245a3d36dfSmrg      # Substitute the hardcoded libdirs into the rpath.
76255a3d36dfSmrg      if test -n "$hardcode_libdir_separator" &&
76265a3d36dfSmrg	 test -n "$hardcode_libdirs"; then
76275a3d36dfSmrg	libdir="$hardcode_libdirs"
76285a3d36dfSmrg	eval rpath=\" $hardcode_libdir_flag_spec\"
76295a3d36dfSmrg      fi
76305a3d36dfSmrg      compile_rpath="$rpath"
7631b3062210Smrg
76325a3d36dfSmrg      rpath=
76335a3d36dfSmrg      hardcode_libdirs=
76345a3d36dfSmrg      for libdir in $finalize_rpath; do
76355a3d36dfSmrg	if test -n "$hardcode_libdir_flag_spec"; then
76365a3d36dfSmrg	  if test -n "$hardcode_libdir_separator"; then
76375a3d36dfSmrg	    if test -z "$hardcode_libdirs"; then
76385a3d36dfSmrg	      hardcode_libdirs="$libdir"
76395a3d36dfSmrg	    else
76405a3d36dfSmrg	      # Just accumulate the unique libdirs.
76415a3d36dfSmrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
76425a3d36dfSmrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
76435a3d36dfSmrg		;;
76445a3d36dfSmrg	      *)
76455a3d36dfSmrg		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
76465a3d36dfSmrg		;;
76475a3d36dfSmrg	      esac
76485a3d36dfSmrg	    fi
764923a0898aSmrg	  else
76505a3d36dfSmrg	    eval flag=\"$hardcode_libdir_flag_spec\"
76515a3d36dfSmrg	    rpath="$rpath $flag"
765223a0898aSmrg	  fi
76535a3d36dfSmrg	elif test -n "$runpath_var"; then
76545a3d36dfSmrg	  case "$finalize_perm_rpath " in
76555a3d36dfSmrg	  *" $libdir "*) ;;
76565a3d36dfSmrg	  *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;;
76575a3d36dfSmrg	  esac
765823a0898aSmrg	fi
76595a3d36dfSmrg      done
76605a3d36dfSmrg      # Substitute the hardcoded libdirs into the rpath.
76615a3d36dfSmrg      if test -n "$hardcode_libdir_separator" &&
76625a3d36dfSmrg	 test -n "$hardcode_libdirs"; then
76635a3d36dfSmrg	libdir="$hardcode_libdirs"
76645a3d36dfSmrg	eval rpath=\" $hardcode_libdir_flag_spec\"
76655a3d36dfSmrg      fi
76665a3d36dfSmrg      finalize_rpath="$rpath"
766723a0898aSmrg
76685a3d36dfSmrg      if test -n "$libobjs" && test "$build_old_libs" = yes; then
76695a3d36dfSmrg	# Transform all the library objects into standard objects.
76705a3d36dfSmrg	compile_command=`$ECHO "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
76715a3d36dfSmrg	finalize_command=`$ECHO "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
76725a3d36dfSmrg      fi
767323a0898aSmrg
76745a3d36dfSmrg      func_generate_dlsyms "$outputname" "@PROGRAM@" "no"
767523a0898aSmrg
76765a3d36dfSmrg      # template prelinking step
76775a3d36dfSmrg      if test -n "$prelink_cmds"; then
76785a3d36dfSmrg	func_execute_cmds "$prelink_cmds" 'exit $?'
76795a3d36dfSmrg      fi
768023a0898aSmrg
76815a3d36dfSmrg      wrappers_required=yes
76825a3d36dfSmrg      case $host in
76835a3d36dfSmrg      *cygwin* | *mingw* )
76845a3d36dfSmrg        if test "$build_libtool_libs" != yes; then
76855a3d36dfSmrg          wrappers_required=no
76865a3d36dfSmrg        fi
76875a3d36dfSmrg        ;;
76885a3d36dfSmrg      *cegcc)
76895a3d36dfSmrg        # Disable wrappers for cegcc, we are cross compiling anyway.
76905a3d36dfSmrg        wrappers_required=no
76915a3d36dfSmrg        ;;
76925a3d36dfSmrg      *)
76935a3d36dfSmrg        if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
76945a3d36dfSmrg          wrappers_required=no
76955a3d36dfSmrg        fi
76965a3d36dfSmrg        ;;
76975a3d36dfSmrg      esac
76985a3d36dfSmrg      if test "$wrappers_required" = no; then
76995a3d36dfSmrg	# Replace the output file specification.
77005a3d36dfSmrg	compile_command=`$ECHO "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
77015a3d36dfSmrg	link_command="$compile_command$compile_rpath"
770223a0898aSmrg
77035a3d36dfSmrg	# We have no uninstalled library dependencies, so finalize right now.
77045a3d36dfSmrg	exit_status=0
77055a3d36dfSmrg	func_show_eval "$link_command" 'exit_status=$?'
770623a0898aSmrg
77075a3d36dfSmrg	# Delete the generated files.
77085a3d36dfSmrg	if test -f "$output_objdir/${outputname}S.${objext}"; then
77095a3d36dfSmrg	  func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"'
771023a0898aSmrg	fi
771123a0898aSmrg
77125a3d36dfSmrg	exit $exit_status
77135a3d36dfSmrg      fi
771423a0898aSmrg
77155a3d36dfSmrg      if test -n "$compile_shlibpath$finalize_shlibpath"; then
77165a3d36dfSmrg	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
77175a3d36dfSmrg      fi
77185a3d36dfSmrg      if test -n "$finalize_shlibpath"; then
77195a3d36dfSmrg	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
77205a3d36dfSmrg      fi
7721b3062210Smrg
77225a3d36dfSmrg      compile_var=
77235a3d36dfSmrg      finalize_var=
77245a3d36dfSmrg      if test -n "$runpath_var"; then
77255a3d36dfSmrg	if test -n "$perm_rpath"; then
77265a3d36dfSmrg	  # We should set the runpath_var.
77275a3d36dfSmrg	  rpath=
77285a3d36dfSmrg	  for dir in $perm_rpath; do
77295a3d36dfSmrg	    rpath="$rpath$dir:"
77305a3d36dfSmrg	  done
77315a3d36dfSmrg	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
773223a0898aSmrg	fi
77335a3d36dfSmrg	if test -n "$finalize_perm_rpath"; then
77345a3d36dfSmrg	  # We should set the runpath_var.
77355a3d36dfSmrg	  rpath=
77365a3d36dfSmrg	  for dir in $finalize_perm_rpath; do
77375a3d36dfSmrg	    rpath="$rpath$dir:"
77385a3d36dfSmrg	  done
77395a3d36dfSmrg	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
774023a0898aSmrg	fi
77415a3d36dfSmrg      fi
774223a0898aSmrg
77435a3d36dfSmrg      if test "$no_install" = yes; then
77445a3d36dfSmrg	# We don't need to create a wrapper script.
77455a3d36dfSmrg	link_command="$compile_var$compile_command$compile_rpath"
77465a3d36dfSmrg	# Replace the output file specification.
77475a3d36dfSmrg	link_command=`$ECHO "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
77485a3d36dfSmrg	# Delete the old output file.
77495a3d36dfSmrg	$opt_dry_run || $RM $output
77505a3d36dfSmrg	# Link the executable and exit
77515a3d36dfSmrg	func_show_eval "$link_command" 'exit $?'
7752b3062210Smrg	exit $EXIT_SUCCESS
77535a3d36dfSmrg      fi
77547f7f5e4eSmrg
77555a3d36dfSmrg      if test "$hardcode_action" = relink; then
77565a3d36dfSmrg	# Fast installation is not supported
77575a3d36dfSmrg	link_command="$compile_var$compile_command$compile_rpath"
77585a3d36dfSmrg	relink_command="$finalize_var$finalize_command$finalize_rpath"
77595a3d36dfSmrg
77605a3d36dfSmrg	func_warning "this platform does not like uninstalled shared libraries"
77615a3d36dfSmrg	func_warning "\`$output' will be relinked during installation"
77625a3d36dfSmrg      else
77635a3d36dfSmrg	if test "$fast_install" != no; then
77645a3d36dfSmrg	  link_command="$finalize_var$compile_command$finalize_rpath"
77655a3d36dfSmrg	  if test "$fast_install" = yes; then
77665a3d36dfSmrg	    relink_command=`$ECHO "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'`
77675a3d36dfSmrg	  else
77685a3d36dfSmrg	    # fast_install is set to needless
77695a3d36dfSmrg	    relink_command=
77705a3d36dfSmrg	  fi
777123a0898aSmrg	else
77725a3d36dfSmrg	  link_command="$compile_var$compile_command$compile_rpath"
77735a3d36dfSmrg	  relink_command="$finalize_var$finalize_command$finalize_rpath"
777423a0898aSmrg	fi
77755a3d36dfSmrg      fi
777623a0898aSmrg
77775a3d36dfSmrg      # Replace the output file specification.
77785a3d36dfSmrg      link_command=`$ECHO "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
777923a0898aSmrg
77805a3d36dfSmrg      # Delete the old output files.
77815a3d36dfSmrg      $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
778223a0898aSmrg
77835a3d36dfSmrg      func_show_eval "$link_command" 'exit $?'
7784b3062210Smrg
77855a3d36dfSmrg      # Now create the wrapper script.
77865a3d36dfSmrg      func_verbose "creating $output"
7787b3062210Smrg
77885a3d36dfSmrg      # Quote the relink command for shipping.
77895a3d36dfSmrg      if test -n "$relink_command"; then
77905a3d36dfSmrg	# Preserve any variables that may affect compiler behavior
77915a3d36dfSmrg	for var in $variables_saved_for_relink; do
77925a3d36dfSmrg	  if eval test -z \"\${$var+set}\"; then
77935a3d36dfSmrg	    relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
77945a3d36dfSmrg	  elif eval var_value=\$$var; test -z "$var_value"; then
77955a3d36dfSmrg	    relink_command="$var=; export $var; $relink_command"
779623a0898aSmrg	  else
77975a3d36dfSmrg	    func_quote_for_eval "$var_value"
77985a3d36dfSmrg	    relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
779923a0898aSmrg	  fi
78005a3d36dfSmrg	done
78015a3d36dfSmrg	relink_command="(cd `pwd`; $relink_command)"
78025a3d36dfSmrg	relink_command=`$ECHO "X$relink_command" | $Xsed -e "$sed_quote_subst"`
78035a3d36dfSmrg      fi
78047f7f5e4eSmrg
78055a3d36dfSmrg      # Quote $ECHO for shipping.
78065a3d36dfSmrg      if test "X$ECHO" = "X$SHELL $progpath --fallback-echo"; then
78075a3d36dfSmrg	case $progpath in
78085a3d36dfSmrg	[\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $progpath --fallback-echo";;
78095a3d36dfSmrg	*) qecho="$SHELL `pwd`/$progpath --fallback-echo";;
78105a3d36dfSmrg	esac
78115a3d36dfSmrg	qecho=`$ECHO "X$qecho" | $Xsed -e "$sed_quote_subst"`
78125a3d36dfSmrg      else
78135a3d36dfSmrg	qecho=`$ECHO "X$ECHO" | $Xsed -e "$sed_quote_subst"`
78145a3d36dfSmrg      fi
78155a3d36dfSmrg
78165a3d36dfSmrg      # Only actually do things if not in dry run mode.
78175a3d36dfSmrg      $opt_dry_run || {
78185a3d36dfSmrg	# win32 will think the script is a binary if it has
78195a3d36dfSmrg	# a .exe suffix, so we strip it off here.
78205a3d36dfSmrg	case $output in
78215a3d36dfSmrg	  *.exe) func_stripname '' '.exe' "$output"
78225a3d36dfSmrg	         output=$func_stripname_result ;;
78235a3d36dfSmrg	esac
78245a3d36dfSmrg	# test for cygwin because mv fails w/o .exe extensions
78255a3d36dfSmrg	case $host in
78265a3d36dfSmrg	  *cygwin*)
78275a3d36dfSmrg	    exeext=.exe
78285a3d36dfSmrg	    func_stripname '' '.exe' "$outputname"
78295a3d36dfSmrg	    outputname=$func_stripname_result ;;
78305a3d36dfSmrg	  *) exeext= ;;
783123a0898aSmrg	esac
78325a3d36dfSmrg	case $host in
78335a3d36dfSmrg	  *cygwin* | *mingw* )
78345a3d36dfSmrg	    func_dirname_and_basename "$output" "" "."
78355a3d36dfSmrg	    output_name=$func_basename_result
78365a3d36dfSmrg	    output_path=$func_dirname_result
78375a3d36dfSmrg	    cwrappersource="$output_path/$objdir/lt-$output_name.c"
78385a3d36dfSmrg	    cwrapper="$output_path/$output_name.exe"
78395a3d36dfSmrg	    $RM $cwrappersource $cwrapper
78405a3d36dfSmrg	    trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
78415a3d36dfSmrg
78425a3d36dfSmrg	    func_emit_cwrapperexe_src > $cwrappersource
78435a3d36dfSmrg
78445a3d36dfSmrg	    # The wrapper executable is built using the $host compiler,
78455a3d36dfSmrg	    # because it contains $host paths and files. If cross-
78465a3d36dfSmrg	    # compiling, it, like the target executable, must be
78475a3d36dfSmrg	    # executed on the $host or under an emulation environment.
78485a3d36dfSmrg	    $opt_dry_run || {
78495a3d36dfSmrg	      $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
78505a3d36dfSmrg	      $STRIP $cwrapper
78515a3d36dfSmrg	    }
785223a0898aSmrg
78535a3d36dfSmrg	    # Now, create the wrapper script for func_source use:
78545a3d36dfSmrg	    func_ltwrapper_scriptname $cwrapper
78555a3d36dfSmrg	    $RM $func_ltwrapper_scriptname_result
78565a3d36dfSmrg	    trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
78575a3d36dfSmrg	    $opt_dry_run || {
78585a3d36dfSmrg	      # note: this script will not be executed, so do not chmod.
78595a3d36dfSmrg	      if test "x$build" = "x$host" ; then
78605a3d36dfSmrg		$cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
78615a3d36dfSmrg	      else
78625a3d36dfSmrg		func_emit_wrapper no > $func_ltwrapper_scriptname_result
78635a3d36dfSmrg	      fi
78645a3d36dfSmrg	    }
78655a3d36dfSmrg	  ;;
78665a3d36dfSmrg	  * )
78675a3d36dfSmrg	    $RM $output
78685a3d36dfSmrg	    trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
786923a0898aSmrg
78705a3d36dfSmrg	    func_emit_wrapper no > $output
78715a3d36dfSmrg	    chmod +x $output
78725a3d36dfSmrg	  ;;
78735a3d36dfSmrg	esac
78745a3d36dfSmrg      }
78755a3d36dfSmrg      exit $EXIT_SUCCESS
78765a3d36dfSmrg      ;;
78775a3d36dfSmrg    esac
787823a0898aSmrg
78795a3d36dfSmrg    # See if we need to build an old-fashioned archive.
78805a3d36dfSmrg    for oldlib in $oldlibs; do
788123a0898aSmrg
78825a3d36dfSmrg      if test "$build_libtool_libs" = convenience; then
78835a3d36dfSmrg	oldobjs="$libobjs_save $symfileobj"
78845a3d36dfSmrg	addlibs="$convenience"
78855a3d36dfSmrg	build_libtool_libs=no
78865a3d36dfSmrg      else
78875a3d36dfSmrg	if test "$build_libtool_libs" = module; then
78885a3d36dfSmrg	  oldobjs="$libobjs_save"
78895a3d36dfSmrg	  build_libtool_libs=no
78905a3d36dfSmrg	else
78915a3d36dfSmrg	  oldobjs="$old_deplibs $non_pic_objects"
78925a3d36dfSmrg	  if test "$preload" = yes && test -f "$symfileobj"; then
78935a3d36dfSmrg	    oldobjs="$oldobjs $symfileobj"
78945a3d36dfSmrg	  fi
78955a3d36dfSmrg	fi
78965a3d36dfSmrg	addlibs="$old_convenience"
789723a0898aSmrg      fi
789823a0898aSmrg
78995a3d36dfSmrg      if test -n "$addlibs"; then
79005a3d36dfSmrg	gentop="$output_objdir/${outputname}x"
79015a3d36dfSmrg	generated="$generated $gentop"
790223a0898aSmrg
79035a3d36dfSmrg	func_extract_archives $gentop $addlibs
79045a3d36dfSmrg	oldobjs="$oldobjs $func_extract_archives_result"
79055a3d36dfSmrg      fi
790623a0898aSmrg
79075a3d36dfSmrg      # Do each command in the archive commands.
79085a3d36dfSmrg      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
79095a3d36dfSmrg	cmds=$old_archive_from_new_cmds
79105a3d36dfSmrg      else
791123a0898aSmrg
79125a3d36dfSmrg	# Add any objects from preloaded convenience libraries
79135a3d36dfSmrg	if test -n "$dlprefiles"; then
79145a3d36dfSmrg	  gentop="$output_objdir/${outputname}x"
79155a3d36dfSmrg	  generated="$generated $gentop"
791623a0898aSmrg
79175a3d36dfSmrg	  func_extract_archives $gentop $dlprefiles
79185a3d36dfSmrg	  oldobjs="$oldobjs $func_extract_archives_result"
79195a3d36dfSmrg	fi
792023a0898aSmrg
79215a3d36dfSmrg	# POSIX demands no paths to be encoded in archives.  We have
79225a3d36dfSmrg	# to avoid creating archives with duplicate basenames if we
79235a3d36dfSmrg	# might have to extract them afterwards, e.g., when creating a
79245a3d36dfSmrg	# static archive out of a convenience library, or when linking
79255a3d36dfSmrg	# the entirety of a libtool archive into another (currently
79265a3d36dfSmrg	# not supported by libtool).
79275a3d36dfSmrg	if (for obj in $oldobjs
79285a3d36dfSmrg	    do
79295a3d36dfSmrg	      func_basename "$obj"
79305a3d36dfSmrg	      $ECHO "$func_basename_result"
79315a3d36dfSmrg	    done | sort | sort -uc >/dev/null 2>&1); then
79325a3d36dfSmrg	  :
79335a3d36dfSmrg	else
79345a3d36dfSmrg	  $ECHO "copying selected object files to avoid basename conflicts..."
79355a3d36dfSmrg	  gentop="$output_objdir/${outputname}x"
79365a3d36dfSmrg	  generated="$generated $gentop"
79375a3d36dfSmrg	  func_mkdir_p "$gentop"
79385a3d36dfSmrg	  save_oldobjs=$oldobjs
79395a3d36dfSmrg	  oldobjs=
79405a3d36dfSmrg	  counter=1
79415a3d36dfSmrg	  for obj in $save_oldobjs
79425a3d36dfSmrg	  do
79435a3d36dfSmrg	    func_basename "$obj"
79445a3d36dfSmrg	    objbase="$func_basename_result"
79455a3d36dfSmrg	    case " $oldobjs " in
79465a3d36dfSmrg	    " ") oldobjs=$obj ;;
79475a3d36dfSmrg	    *[\ /]"$objbase "*)
79485a3d36dfSmrg	      while :; do
79495a3d36dfSmrg		# Make sure we don't pick an alternate name that also
79505a3d36dfSmrg		# overlaps.
79515a3d36dfSmrg		newobj=lt$counter-$objbase
79525a3d36dfSmrg		func_arith $counter + 1
79535a3d36dfSmrg		counter=$func_arith_result
79545a3d36dfSmrg		case " $oldobjs " in
79555a3d36dfSmrg		*[\ /]"$newobj "*) ;;
79565a3d36dfSmrg		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
79575a3d36dfSmrg		esac
79585a3d36dfSmrg	      done
79595a3d36dfSmrg	      func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
79605a3d36dfSmrg	      oldobjs="$oldobjs $gentop/$newobj"
79615a3d36dfSmrg	      ;;
79625a3d36dfSmrg	    *) oldobjs="$oldobjs $obj" ;;
79635a3d36dfSmrg	    esac
796423a0898aSmrg	  done
79657f7f5e4eSmrg	fi
79665a3d36dfSmrg	eval cmds=\"$old_archive_cmds\"
7967b3062210Smrg
79685a3d36dfSmrg	func_len " $cmds"
79695a3d36dfSmrg	len=$func_len_result
79705a3d36dfSmrg	if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
79715a3d36dfSmrg	  cmds=$old_archive_cmds
79725a3d36dfSmrg	else
79735a3d36dfSmrg	  # the command line is too long to link in one step, link in parts
79745a3d36dfSmrg	  func_verbose "using piecewise archive linking..."
79755a3d36dfSmrg	  save_RANLIB=$RANLIB
79765a3d36dfSmrg	  RANLIB=:
79775a3d36dfSmrg	  objlist=
79785a3d36dfSmrg	  concat_cmds=
79795a3d36dfSmrg	  save_oldobjs=$oldobjs
79805a3d36dfSmrg	  oldobjs=
79815a3d36dfSmrg	  # Is there a better way of finding the last object in the list?
79825a3d36dfSmrg	  for obj in $save_oldobjs
79835a3d36dfSmrg	  do
79845a3d36dfSmrg	    last_oldobj=$obj
79855a3d36dfSmrg	  done
79865a3d36dfSmrg	  eval test_cmds=\"$old_archive_cmds\"
79875a3d36dfSmrg	  func_len " $test_cmds"
79885a3d36dfSmrg	  len0=$func_len_result
79895a3d36dfSmrg	  len=$len0
79905a3d36dfSmrg	  for obj in $save_oldobjs
79915a3d36dfSmrg	  do
79925a3d36dfSmrg	    func_len " $obj"
79935a3d36dfSmrg	    func_arith $len + $func_len_result
79945a3d36dfSmrg	    len=$func_arith_result
79955a3d36dfSmrg	    func_append objlist " $obj"
79965a3d36dfSmrg	    if test "$len" -lt "$max_cmd_len"; then
79975a3d36dfSmrg	      :
79985a3d36dfSmrg	    else
79995a3d36dfSmrg	      # the above command should be used before it gets too long
80005a3d36dfSmrg	      oldobjs=$objlist
80015a3d36dfSmrg	      if test "$obj" = "$last_oldobj" ; then
80025a3d36dfSmrg		RANLIB=$save_RANLIB
80035a3d36dfSmrg	      fi
80045a3d36dfSmrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
80055a3d36dfSmrg	      eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
80065a3d36dfSmrg	      objlist=
80075a3d36dfSmrg	      len=$len0
80085a3d36dfSmrg	    fi
80095a3d36dfSmrg	  done
80105a3d36dfSmrg	  RANLIB=$save_RANLIB
80115a3d36dfSmrg	  oldobjs=$objlist
80125a3d36dfSmrg	  if test "X$oldobjs" = "X" ; then
80135a3d36dfSmrg	    eval cmds=\"\$concat_cmds\"
80145a3d36dfSmrg	  else
80155a3d36dfSmrg	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
80165a3d36dfSmrg	  fi
80175a3d36dfSmrg	fi
80185a3d36dfSmrg      fi
80195a3d36dfSmrg      func_execute_cmds "$cmds" 'exit $?'
802023a0898aSmrg    done
802123a0898aSmrg
80225a3d36dfSmrg    test -n "$generated" && \
80235a3d36dfSmrg      func_show_eval "${RM}r$generated"
802423a0898aSmrg
80255a3d36dfSmrg    # Now create the libtool archive.
80265a3d36dfSmrg    case $output in
80275a3d36dfSmrg    *.la)
80285a3d36dfSmrg      old_library=
80295a3d36dfSmrg      test "$build_old_libs" = yes && old_library="$libname.$libext"
80305a3d36dfSmrg      func_verbose "creating $output"
80317f7f5e4eSmrg
80325a3d36dfSmrg      # Preserve any variables that may affect compiler behavior
80335a3d36dfSmrg      for var in $variables_saved_for_relink; do
80345a3d36dfSmrg	if eval test -z \"\${$var+set}\"; then
80355a3d36dfSmrg	  relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
80365a3d36dfSmrg	elif eval var_value=\$$var; test -z "$var_value"; then
80375a3d36dfSmrg	  relink_command="$var=; export $var; $relink_command"
8038b3062210Smrg	else
80395a3d36dfSmrg	  func_quote_for_eval "$var_value"
80405a3d36dfSmrg	  relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
8041b3062210Smrg	fi
80425a3d36dfSmrg      done
80435a3d36dfSmrg      # Quote the link command for shipping.
80445a3d36dfSmrg      relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
80455a3d36dfSmrg      relink_command=`$ECHO "X$relink_command" | $Xsed -e "$sed_quote_subst"`
80465a3d36dfSmrg      if test "$hardcode_automatic" = yes ; then
80475a3d36dfSmrg	relink_command=
80485a3d36dfSmrg      fi
804923a0898aSmrg
80505a3d36dfSmrg      # Only create the output if not a dry run.
80515a3d36dfSmrg      $opt_dry_run || {
80525a3d36dfSmrg	for installed in no yes; do
80535a3d36dfSmrg	  if test "$installed" = yes; then
80545a3d36dfSmrg	    if test -z "$install_libdir"; then
80555a3d36dfSmrg	      break
80565a3d36dfSmrg	    fi
80575a3d36dfSmrg	    output="$output_objdir/$outputname"i
80585a3d36dfSmrg	    # Replace all uninstalled libtool libraries with the installed ones
80595a3d36dfSmrg	    newdependency_libs=
80605a3d36dfSmrg	    for deplib in $dependency_libs; do
80615a3d36dfSmrg	      case $deplib in
80625a3d36dfSmrg	      *.la)
80635a3d36dfSmrg		func_basename "$deplib"
80645a3d36dfSmrg		name="$func_basename_result"
80655a3d36dfSmrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
80665a3d36dfSmrg		test -z "$libdir" && \
80675a3d36dfSmrg		  func_fatal_error "\`$deplib' is not a valid libtool archive"
80685a3d36dfSmrg		newdependency_libs="$newdependency_libs $libdir/$name"
80695a3d36dfSmrg		;;
80705a3d36dfSmrg	      *) newdependency_libs="$newdependency_libs $deplib" ;;
80715a3d36dfSmrg	      esac
80725a3d36dfSmrg	    done
80735a3d36dfSmrg	    dependency_libs="$newdependency_libs"
80745a3d36dfSmrg	    newdlfiles=
80755a3d36dfSmrg
80765a3d36dfSmrg	    for lib in $dlfiles; do
80775a3d36dfSmrg	      case $lib in
80785a3d36dfSmrg	      *.la)
80795a3d36dfSmrg	        func_basename "$lib"
80805a3d36dfSmrg		name="$func_basename_result"
80815a3d36dfSmrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
80825a3d36dfSmrg		test -z "$libdir" && \
80835a3d36dfSmrg		  func_fatal_error "\`$lib' is not a valid libtool archive"
80845a3d36dfSmrg		newdlfiles="$newdlfiles $libdir/$name"
80855a3d36dfSmrg		;;
80865a3d36dfSmrg	      *) newdlfiles="$newdlfiles $lib" ;;
80875a3d36dfSmrg	      esac
80885a3d36dfSmrg	    done
80895a3d36dfSmrg	    dlfiles="$newdlfiles"
80905a3d36dfSmrg	    newdlprefiles=
80915a3d36dfSmrg	    for lib in $dlprefiles; do
80925a3d36dfSmrg	      case $lib in
80935a3d36dfSmrg	      *.la)
80945a3d36dfSmrg		# Only pass preopened files to the pseudo-archive (for
80955a3d36dfSmrg		# eventual linking with the app. that links it) if we
80965a3d36dfSmrg		# didn't already link the preopened objects directly into
80975a3d36dfSmrg		# the library:
80985a3d36dfSmrg		func_basename "$lib"
80995a3d36dfSmrg		name="$func_basename_result"
81005a3d36dfSmrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
81015a3d36dfSmrg		test -z "$libdir" && \
81025a3d36dfSmrg		  func_fatal_error "\`$lib' is not a valid libtool archive"
81035a3d36dfSmrg		newdlprefiles="$newdlprefiles $libdir/$name"
81045a3d36dfSmrg		;;
81055a3d36dfSmrg	      esac
81065a3d36dfSmrg	    done
81075a3d36dfSmrg	    dlprefiles="$newdlprefiles"
81085a3d36dfSmrg	  else
81095a3d36dfSmrg	    newdlfiles=
81105a3d36dfSmrg	    for lib in $dlfiles; do
81115a3d36dfSmrg	      case $lib in
81125a3d36dfSmrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
81135a3d36dfSmrg		*) abs=`pwd`"/$lib" ;;
81145a3d36dfSmrg	      esac
81155a3d36dfSmrg	      newdlfiles="$newdlfiles $abs"
81165a3d36dfSmrg	    done
81175a3d36dfSmrg	    dlfiles="$newdlfiles"
81185a3d36dfSmrg	    newdlprefiles=
81195a3d36dfSmrg	    for lib in $dlprefiles; do
81205a3d36dfSmrg	      case $lib in
81215a3d36dfSmrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
81225a3d36dfSmrg		*) abs=`pwd`"/$lib" ;;
81235a3d36dfSmrg	      esac
81245a3d36dfSmrg	      newdlprefiles="$newdlprefiles $abs"
81255a3d36dfSmrg	    done
81265a3d36dfSmrg	    dlprefiles="$newdlprefiles"
81275a3d36dfSmrg	  fi
81285a3d36dfSmrg	  $RM $output
81295a3d36dfSmrg	  # place dlname in correct position for cygwin
81305a3d36dfSmrg	  tdlname=$dlname
81315a3d36dfSmrg	  case $host,$output,$installed,$module,$dlname in
81325a3d36dfSmrg	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;;
81335a3d36dfSmrg	  esac
81345a3d36dfSmrg	  $ECHO > $output "\
81355a3d36dfSmrg# $outputname - a libtool library file
81365a3d36dfSmrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
81375a3d36dfSmrg#
81385a3d36dfSmrg# Please DO NOT delete this file!
81395a3d36dfSmrg# It is necessary for linking the library.
814023a0898aSmrg
81415a3d36dfSmrg# The name that we can dlopen(3).
81425a3d36dfSmrgdlname='$tdlname'
814323a0898aSmrg
81445a3d36dfSmrg# Names of this library.
81455a3d36dfSmrglibrary_names='$library_names'
814623a0898aSmrg
81475a3d36dfSmrg# The name of the static archive.
81485a3d36dfSmrgold_library='$old_library'
814923a0898aSmrg
81505a3d36dfSmrg# Linker flags that can not go in dependency_libs.
81515a3d36dfSmrginherited_linker_flags='$new_inherited_linker_flags'
815223a0898aSmrg
81535a3d36dfSmrg# Libraries that this one depends upon.
81545a3d36dfSmrgdependency_libs='$dependency_libs'
815523a0898aSmrg
81565a3d36dfSmrg# Names of additional weak libraries provided by this library
81575a3d36dfSmrgweak_library_names='$weak_libs'
815823a0898aSmrg
81595a3d36dfSmrg# Version information for $libname.
81605a3d36dfSmrgcurrent=$current
81615a3d36dfSmrgage=$age
81625a3d36dfSmrgrevision=$revision
816323a0898aSmrg
81645a3d36dfSmrg# Is this an already installed library?
81655a3d36dfSmrginstalled=$installed
816623a0898aSmrg
81675a3d36dfSmrg# Should we warn about portability when linking against -modules?
81685a3d36dfSmrgshouldnotlink=$module
816923a0898aSmrg
81705a3d36dfSmrg# Files to dlopen/dlpreopen
81715a3d36dfSmrgdlopen='$dlfiles'
81725a3d36dfSmrgdlpreopen='$dlprefiles'
817323a0898aSmrg
81745a3d36dfSmrg# Directory that this library needs to be installed in:
81755a3d36dfSmrglibdir='$install_libdir'"
81765a3d36dfSmrg	  if test "$installed" = no && test "$need_relink" = yes; then
81775a3d36dfSmrg	    $ECHO >> $output "\
81785a3d36dfSmrgrelink_command=\"$relink_command\""
81795a3d36dfSmrg	  fi
81805a3d36dfSmrg	done
81815a3d36dfSmrg      }
818223a0898aSmrg
81835a3d36dfSmrg      # Do a symbolic link so that the libtool archive can be found in
81845a3d36dfSmrg      # LD_LIBRARY_PATH before the program is installed.
81855a3d36dfSmrg      func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
81865a3d36dfSmrg      ;;
81875a3d36dfSmrg    esac
81885a3d36dfSmrg    exit $EXIT_SUCCESS
81895a3d36dfSmrg}
8190b3062210Smrg
81915a3d36dfSmrg{ test "$mode" = link || test "$mode" = relink; } &&
81925a3d36dfSmrg    func_mode_link ${1+"$@"}
819323a0898aSmrg
819423a0898aSmrg
81955a3d36dfSmrg# func_mode_uninstall arg...
81965a3d36dfSmrgfunc_mode_uninstall ()
81975a3d36dfSmrg{
81985a3d36dfSmrg    $opt_debug
81995a3d36dfSmrg    RM="$nonopt"
820023a0898aSmrg    files=
820123a0898aSmrg    rmforce=
820223a0898aSmrg    exit_status=0
820323a0898aSmrg
820423a0898aSmrg    # This variable tells wrapper scripts just to set variables rather
820523a0898aSmrg    # than running their programs.
820623a0898aSmrg    libtool_install_magic="$magic"
820723a0898aSmrg
820823a0898aSmrg    for arg
820923a0898aSmrg    do
821023a0898aSmrg      case $arg in
82115a3d36dfSmrg      -f) RM="$RM $arg"; rmforce=yes ;;
82125a3d36dfSmrg      -*) RM="$RM $arg" ;;
821323a0898aSmrg      *) files="$files $arg" ;;
821423a0898aSmrg      esac
821523a0898aSmrg    done
821623a0898aSmrg
82175a3d36dfSmrg    test -z "$RM" && \
82185a3d36dfSmrg      func_fatal_help "you must specify an RM program"
821923a0898aSmrg
822023a0898aSmrg    rmdirs=
822123a0898aSmrg
822223a0898aSmrg    origobjdir="$objdir"
822323a0898aSmrg    for file in $files; do
82245a3d36dfSmrg      func_dirname "$file" "" "."
82255a3d36dfSmrg      dir="$func_dirname_result"
82265a3d36dfSmrg      if test "X$dir" = X.; then
822723a0898aSmrg	objdir="$origobjdir"
822823a0898aSmrg      else
822923a0898aSmrg	objdir="$dir/$origobjdir"
823023a0898aSmrg      fi
82315a3d36dfSmrg      func_basename "$file"
82325a3d36dfSmrg      name="$func_basename_result"
823323a0898aSmrg      test "$mode" = uninstall && objdir="$dir"
823423a0898aSmrg
823523a0898aSmrg      # Remember objdir for removal later, being careful to avoid duplicates
823623a0898aSmrg      if test "$mode" = clean; then
823723a0898aSmrg	case " $rmdirs " in
823823a0898aSmrg	  *" $objdir "*) ;;
823923a0898aSmrg	  *) rmdirs="$rmdirs $objdir" ;;
824023a0898aSmrg	esac
824123a0898aSmrg      fi
824223a0898aSmrg
824323a0898aSmrg      # Don't error if the file doesn't exist and rm -f was used.
82445a3d36dfSmrg      if { test -L "$file"; } >/dev/null 2>&1 ||
82455a3d36dfSmrg	 { test -h "$file"; } >/dev/null 2>&1 ||
82465a3d36dfSmrg	 test -f "$file"; then
824723a0898aSmrg	:
824823a0898aSmrg      elif test -d "$file"; then
824923a0898aSmrg	exit_status=1
825023a0898aSmrg	continue
825123a0898aSmrg      elif test "$rmforce" = yes; then
825223a0898aSmrg	continue
825323a0898aSmrg      fi
825423a0898aSmrg
825523a0898aSmrg      rmfiles="$file"
825623a0898aSmrg
825723a0898aSmrg      case $name in
825823a0898aSmrg      *.la)
825923a0898aSmrg	# Possibly a libtool archive, so verify it.
82605a3d36dfSmrg	if func_lalib_p "$file"; then
82615a3d36dfSmrg	  func_source $dir/$name
826223a0898aSmrg
826323a0898aSmrg	  # Delete the libtool libraries and symlinks.
826423a0898aSmrg	  for n in $library_names; do
826523a0898aSmrg	    rmfiles="$rmfiles $objdir/$n"
826623a0898aSmrg	  done
826723a0898aSmrg	  test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library"
826823a0898aSmrg
826923a0898aSmrg	  case "$mode" in
827023a0898aSmrg	  clean)
827123a0898aSmrg	    case "  $library_names " in
827223a0898aSmrg	    # "  " in the beginning catches empty $dlname
827323a0898aSmrg	    *" $dlname "*) ;;
827423a0898aSmrg	    *) rmfiles="$rmfiles $objdir/$dlname" ;;
827523a0898aSmrg	    esac
82765a3d36dfSmrg	    test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i"
827723a0898aSmrg	    ;;
827823a0898aSmrg	  uninstall)
827923a0898aSmrg	    if test -n "$library_names"; then
828023a0898aSmrg	      # Do each command in the postuninstall commands.
82815a3d36dfSmrg	      func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
828223a0898aSmrg	    fi
828323a0898aSmrg
828423a0898aSmrg	    if test -n "$old_library"; then
828523a0898aSmrg	      # Do each command in the old_postuninstall commands.
82865a3d36dfSmrg	      func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
828723a0898aSmrg	    fi
828823a0898aSmrg	    # FIXME: should reinstall the best remaining shared library.
828923a0898aSmrg	    ;;
829023a0898aSmrg	  esac
829123a0898aSmrg	fi
829223a0898aSmrg	;;
829323a0898aSmrg
829423a0898aSmrg      *.lo)
829523a0898aSmrg	# Possibly a libtool object, so verify it.
82965a3d36dfSmrg	if func_lalib_p "$file"; then
829723a0898aSmrg
829823a0898aSmrg	  # Read the .lo file
82995a3d36dfSmrg	  func_source $dir/$name
830023a0898aSmrg
830123a0898aSmrg	  # Add PIC object to the list of files to remove.
83025a3d36dfSmrg	  if test -n "$pic_object" &&
83035a3d36dfSmrg	     test "$pic_object" != none; then
830423a0898aSmrg	    rmfiles="$rmfiles $dir/$pic_object"
830523a0898aSmrg	  fi
830623a0898aSmrg
830723a0898aSmrg	  # Add non-PIC object to the list of files to remove.
83085a3d36dfSmrg	  if test -n "$non_pic_object" &&
83095a3d36dfSmrg	     test "$non_pic_object" != none; then
831023a0898aSmrg	    rmfiles="$rmfiles $dir/$non_pic_object"
831123a0898aSmrg	  fi
831223a0898aSmrg	fi
831323a0898aSmrg	;;
831423a0898aSmrg
831523a0898aSmrg      *)
831623a0898aSmrg	if test "$mode" = clean ; then
831723a0898aSmrg	  noexename=$name
831823a0898aSmrg	  case $file in
831923a0898aSmrg	  *.exe)
83205a3d36dfSmrg	    func_stripname '' '.exe' "$file"
83215a3d36dfSmrg	    file=$func_stripname_result
83225a3d36dfSmrg	    func_stripname '' '.exe' "$name"
83235a3d36dfSmrg	    noexename=$func_stripname_result
832423a0898aSmrg	    # $file with .exe has already been added to rmfiles,
832523a0898aSmrg	    # add $file without .exe
832623a0898aSmrg	    rmfiles="$rmfiles $file"
832723a0898aSmrg	    ;;
832823a0898aSmrg	  esac
832923a0898aSmrg	  # Do a test to see if this is a libtool program.
83305a3d36dfSmrg	  if func_ltwrapper_p "$file"; then
83315a3d36dfSmrg	    if func_ltwrapper_executable_p "$file"; then
83325a3d36dfSmrg	      func_ltwrapper_scriptname "$file"
83335a3d36dfSmrg	      relink_command=
83345a3d36dfSmrg	      func_source $func_ltwrapper_scriptname_result
83355a3d36dfSmrg	      rmfiles="$rmfiles $func_ltwrapper_scriptname_result"
83365a3d36dfSmrg	    else
83375a3d36dfSmrg	      relink_command=
83385a3d36dfSmrg	      func_source $dir/$noexename
83395a3d36dfSmrg	    fi
834023a0898aSmrg
834123a0898aSmrg	    # note $name still contains .exe if it was in $file originally
834223a0898aSmrg	    # as does the version of $file that was added into $rmfiles
834323a0898aSmrg	    rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}"
834423a0898aSmrg	    if test "$fast_install" = yes && test -n "$relink_command"; then
834523a0898aSmrg	      rmfiles="$rmfiles $objdir/lt-$name"
834623a0898aSmrg	    fi
834723a0898aSmrg	    if test "X$noexename" != "X$name" ; then
834823a0898aSmrg	      rmfiles="$rmfiles $objdir/lt-${noexename}.c"
834923a0898aSmrg	    fi
835023a0898aSmrg	  fi
835123a0898aSmrg	fi
835223a0898aSmrg	;;
835323a0898aSmrg      esac
83545a3d36dfSmrg      func_show_eval "$RM $rmfiles" 'exit_status=1'
835523a0898aSmrg    done
835623a0898aSmrg    objdir="$origobjdir"
835723a0898aSmrg
835823a0898aSmrg    # Try to remove the ${objdir}s in the directories where we deleted files
835923a0898aSmrg    for dir in $rmdirs; do
836023a0898aSmrg      if test -d "$dir"; then
83615a3d36dfSmrg	func_show_eval "rmdir $dir >/dev/null 2>&1"
836223a0898aSmrg      fi
836323a0898aSmrg    done
836423a0898aSmrg
836523a0898aSmrg    exit $exit_status
83665a3d36dfSmrg}
836723a0898aSmrg
83685a3d36dfSmrg{ test "$mode" = uninstall || test "$mode" = clean; } &&
83695a3d36dfSmrg    func_mode_uninstall ${1+"$@"}
83707f7f5e4eSmrg
83715a3d36dfSmrgtest -z "$mode" && {
83725a3d36dfSmrg  help="$generic_help"
83735a3d36dfSmrg  func_fatal_help "you must specify a MODE"
83745a3d36dfSmrg}
83755a3d36dfSmrg
83765a3d36dfSmrgtest -z "$exec_cmd" && \
83775a3d36dfSmrg  func_fatal_help "invalid operation mode \`$mode'"
837823a0898aSmrg
837923a0898aSmrgif test -n "$exec_cmd"; then
83805a3d36dfSmrg  eval exec "$exec_cmd"
838123a0898aSmrg  exit $EXIT_FAILURE
838223a0898aSmrgfi
838323a0898aSmrg
83845a3d36dfSmrgexit $exit_status
838523a0898aSmrg
838623a0898aSmrg
838723a0898aSmrg# The TAGs below are defined such that we never get into a situation
838823a0898aSmrg# in which we disable both kinds of libraries.  Given conflicting
838923a0898aSmrg# choices, we go for a static library, that is the most portable,
839023a0898aSmrg# since we can't tell whether shared libraries were disabled because
839123a0898aSmrg# the user asked for that or because the platform doesn't support
839223a0898aSmrg# them.  This is particularly important on AIX, because we don't
839323a0898aSmrg# support having both static and shared libraries enabled at the same
839423a0898aSmrg# time on that platform, so we default to a shared-only configuration.
839523a0898aSmrg# If a disable-shared tag is given, we'll fallback to a static-only
839623a0898aSmrg# configuration.  But we'll never go from static-only to shared-only.
839723a0898aSmrg
839823a0898aSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
83995a3d36dfSmrgbuild_libtool_libs=no
84005a3d36dfSmrgbuild_old_libs=yes
840123a0898aSmrg# ### END LIBTOOL TAG CONFIG: disable-shared
840223a0898aSmrg
840323a0898aSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static
84045a3d36dfSmrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
840523a0898aSmrg# ### END LIBTOOL TAG CONFIG: disable-static
840623a0898aSmrg
840723a0898aSmrg# Local Variables:
840823a0898aSmrg# mode:shell-script
840923a0898aSmrg# sh-indentation:2
841023a0898aSmrg# End:
84115a3d36dfSmrg# vi:sw=2
84125a3d36dfSmrg
8413