ltmain.sh revision 6fae4e5d
19c9ff80cSmrg
26fae4e5dSmrg# libtool (GNU libtool) 2.4
39c9ff80cSmrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
49c9ff80cSmrg
56fae4e5dSmrg# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006,
66fae4e5dSmrg# 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
79c9ff80cSmrg# This is free software; see the source for copying conditions.  There is NO
89c9ff80cSmrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
99c9ff80cSmrg
109c9ff80cSmrg# GNU Libtool is free software; you can redistribute it and/or modify
111f0ac6a5Smrg# it under the terms of the GNU General Public License as published by
121f0ac6a5Smrg# the Free Software Foundation; either version 2 of the License, or
131f0ac6a5Smrg# (at your option) any later version.
141f0ac6a5Smrg#
159c9ff80cSmrg# As a special exception to the GNU General Public License,
169c9ff80cSmrg# if you distribute this file as part of a program or library that
179c9ff80cSmrg# is built using GNU Libtool, you may include this file under the
189c9ff80cSmrg# same distribution terms that you use for the rest of that program.
199c9ff80cSmrg#
209c9ff80cSmrg# GNU Libtool is distributed in the hope that it will be useful, but
211f0ac6a5Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of
221f0ac6a5Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
231f0ac6a5Smrg# General Public License for more details.
241f0ac6a5Smrg#
251f0ac6a5Smrg# You should have received a copy of the GNU General Public License
269c9ff80cSmrg# along with GNU Libtool; see the file COPYING.  If not, a copy
279c9ff80cSmrg# can be downloaded from http://www.gnu.org/licenses/gpl.html,
289c9ff80cSmrg# or obtained by writing to the Free Software Foundation, Inc.,
299c9ff80cSmrg# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
301f0ac6a5Smrg
319c9ff80cSmrg# Usage: $progname [OPTION]... [MODE-ARG]...
329c9ff80cSmrg#
339c9ff80cSmrg# Provide generalized library-building support services.
349c9ff80cSmrg#
356fae4e5dSmrg#       --config             show all configuration variables
366fae4e5dSmrg#       --debug              enable verbose shell tracing
376fae4e5dSmrg#   -n, --dry-run            display commands without modifying any files
386fae4e5dSmrg#       --features           display basic configuration information and exit
396fae4e5dSmrg#       --mode=MODE          use operation mode MODE
406fae4e5dSmrg#       --preserve-dup-deps  don't remove duplicate dependency libraries
416fae4e5dSmrg#       --quiet, --silent    don't print informational messages
426fae4e5dSmrg#       --no-quiet, --no-silent
436fae4e5dSmrg#                            print informational messages (default)
446fae4e5dSmrg#       --tag=TAG            use configuration variables from tag TAG
456fae4e5dSmrg#   -v, --verbose            print more informational messages than default
466fae4e5dSmrg#       --no-verbose         don't print the extra informational messages
476fae4e5dSmrg#       --version            print version information
486fae4e5dSmrg#   -h, --help, --help-all   print short, long, or detailed help message
499c9ff80cSmrg#
509c9ff80cSmrg# MODE must be one of the following:
519c9ff80cSmrg#
526fae4e5dSmrg#         clean              remove files from the build directory
536fae4e5dSmrg#         compile            compile a source file into a libtool object
546fae4e5dSmrg#         execute            automatically set library path, then run a program
556fae4e5dSmrg#         finish             complete the installation of libtool libraries
566fae4e5dSmrg#         install            install libraries or executables
576fae4e5dSmrg#         link               create a library or an executable
586fae4e5dSmrg#         uninstall          remove libraries from an installed directory
599c9ff80cSmrg#
606fae4e5dSmrg# MODE-ARGS vary depending on the MODE.  When passed as first option,
616fae4e5dSmrg# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that.
629c9ff80cSmrg# Try `$progname --help --mode=MODE' for a more detailed description of MODE.
639c9ff80cSmrg#
649c9ff80cSmrg# When reporting a bug, please describe a test case to reproduce it and
659c9ff80cSmrg# include the following information:
669c9ff80cSmrg#
676fae4e5dSmrg#         host-triplet:	$host
686fae4e5dSmrg#         shell:		$SHELL
696fae4e5dSmrg#         compiler:		$LTCC
706fae4e5dSmrg#         compiler flags:		$LTCFLAGS
716fae4e5dSmrg#         linker:		$LD (gnu? $with_gnu_ld)
726fae4e5dSmrg#         $progname:	(GNU libtool) 2.4
736fae4e5dSmrg#         automake:	$automake_version
746fae4e5dSmrg#         autoconf:	$autoconf_version
759c9ff80cSmrg#
769c9ff80cSmrg# Report bugs to <bug-libtool@gnu.org>.
776fae4e5dSmrg# GNU libtool home page: <http://www.gnu.org/software/libtool/>.
786fae4e5dSmrg# General help using GNU software: <http://www.gnu.org/gethelp/>.
791f0ac6a5Smrg
806fae4e5dSmrgPROGRAM=libtool
811f0ac6a5SmrgPACKAGE=libtool
826fae4e5dSmrgVERSION=2.4
839c9ff80cSmrgTIMESTAMP=""
846fae4e5dSmrgpackage_revision=1.3293
85e5410a46Smrg
869c9ff80cSmrg# Be Bourne compatible
87e5410a46Smrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
88e5410a46Smrg  emulate sh
89e5410a46Smrg  NULLCMD=:
90e5410a46Smrg  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
91e5410a46Smrg  # is contrary to our usage.  Disable this feature.
92e5410a46Smrg  alias -g '${1+"$@"}'='"$@"'
931f0ac6a5Smrg  setopt NO_GLOB_SUBST
94e5410a46Smrgelse
95e5410a46Smrg  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
961f0ac6a5Smrgfi
97e5410a46SmrgBIN_SH=xpg4; export BIN_SH # for Tru64
98e5410a46SmrgDUALCASE=1; export DUALCASE # for MKS sh
991f0ac6a5Smrg
1006fae4e5dSmrg# A function that is used when there is no print builtin or printf.
1016fae4e5dSmrgfunc_fallback_echo ()
1026fae4e5dSmrg{
1036fae4e5dSmrg  eval 'cat <<_LTECHO_EOF
1046fae4e5dSmrg$1
1056fae4e5dSmrg_LTECHO_EOF'
1066fae4e5dSmrg}
1076fae4e5dSmrg
1089c9ff80cSmrg# NLS nuisances: We save the old values to restore during execute mode.
1099c9ff80cSmrglt_user_locale=
1109c9ff80cSmrglt_safe_locale=
111e5410a46Smrgfor lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
112e5410a46Smrgdo
113e5410a46Smrg  eval "if test \"\${$lt_var+set}\" = set; then
1149c9ff80cSmrg          save_$lt_var=\$$lt_var
1159c9ff80cSmrg          $lt_var=C
116e5410a46Smrg	  export $lt_var
1179c9ff80cSmrg	  lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\"
1189c9ff80cSmrg	  lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
119e5410a46Smrg	fi"
120e5410a46Smrgdone
1216fae4e5dSmrgLC_ALL=C
1226fae4e5dSmrgLANGUAGE=C
1236fae4e5dSmrgexport LANGUAGE LC_ALL
124e5410a46Smrg
1259c9ff80cSmrg$lt_unset CDPATH
1269c9ff80cSmrg
1279c9ff80cSmrg
1286fae4e5dSmrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
1296fae4e5dSmrg# is ksh but when the shell is invoked as "sh" and the current value of
1306fae4e5dSmrg# the _XPG environment variable is not equal to 1 (one), the special
1316fae4e5dSmrg# positional parameter $0, within a function call, is the name of the
1326fae4e5dSmrg# function.
1336fae4e5dSmrgprogpath="$0"
1349c9ff80cSmrg
1359c9ff80cSmrg
1369c9ff80cSmrg
1379c9ff80cSmrg: ${CP="cp -f"}
1386fae4e5dSmrgtest "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'}
1396fae4e5dSmrg: ${EGREP="grep -E"}
1406fae4e5dSmrg: ${FGREP="grep -F"}
1416fae4e5dSmrg: ${GREP="grep"}
1429c9ff80cSmrg: ${LN_S="ln -s"}
1439c9ff80cSmrg: ${MAKE="make"}
1449c9ff80cSmrg: ${MKDIR="mkdir"}
1459c9ff80cSmrg: ${MV="mv -f"}
1469c9ff80cSmrg: ${RM="rm -f"}
1476fae4e5dSmrg: ${SED="sed"}
1489c9ff80cSmrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
1499c9ff80cSmrg: ${Xsed="$SED -e 1s/^X//"}
1509c9ff80cSmrg
1519c9ff80cSmrg# Global variables:
1529c9ff80cSmrgEXIT_SUCCESS=0
1539c9ff80cSmrgEXIT_FAILURE=1
1549c9ff80cSmrgEXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
1559c9ff80cSmrgEXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
1569c9ff80cSmrg
1579c9ff80cSmrgexit_status=$EXIT_SUCCESS
1581f0ac6a5Smrg
1591f0ac6a5Smrg# Make sure IFS has a sensible default
1601f0ac6a5Smrglt_nl='
1611f0ac6a5Smrg'
1621f0ac6a5SmrgIFS=" 	$lt_nl"
1631f0ac6a5Smrg
1649c9ff80cSmrgdirname="s,/[^/]*$,,"
1659c9ff80cSmrgbasename="s,^.*/,,"
1669c9ff80cSmrg
1676fae4e5dSmrg# func_dirname file append nondir_replacement
1686fae4e5dSmrg# Compute the dirname of FILE.  If nonempty, add APPEND to the result,
1696fae4e5dSmrg# otherwise set result to NONDIR_REPLACEMENT.
1706fae4e5dSmrgfunc_dirname ()
1716fae4e5dSmrg{
1726fae4e5dSmrg    func_dirname_result=`$ECHO "${1}" | $SED "$dirname"`
1736fae4e5dSmrg    if test "X$func_dirname_result" = "X${1}"; then
1746fae4e5dSmrg      func_dirname_result="${3}"
1756fae4e5dSmrg    else
1766fae4e5dSmrg      func_dirname_result="$func_dirname_result${2}"
1776fae4e5dSmrg    fi
1786fae4e5dSmrg} # func_dirname may be replaced by extended shell implementation
1796fae4e5dSmrg
1806fae4e5dSmrg
1816fae4e5dSmrg# func_basename file
1826fae4e5dSmrgfunc_basename ()
1836fae4e5dSmrg{
1846fae4e5dSmrg    func_basename_result=`$ECHO "${1}" | $SED "$basename"`
1856fae4e5dSmrg} # func_basename may be replaced by extended shell implementation
1866fae4e5dSmrg
1876fae4e5dSmrg
1889c9ff80cSmrg# func_dirname_and_basename file append nondir_replacement
1899c9ff80cSmrg# perform func_basename and func_dirname in a single function
1909c9ff80cSmrg# call:
1919c9ff80cSmrg#   dirname:  Compute the dirname of FILE.  If nonempty,
1929c9ff80cSmrg#             add APPEND to the result, otherwise set result
1939c9ff80cSmrg#             to NONDIR_REPLACEMENT.
1949c9ff80cSmrg#             value returned in "$func_dirname_result"
1959c9ff80cSmrg#   basename: Compute filename of FILE.
1969c9ff80cSmrg#             value retuned in "$func_basename_result"
1979c9ff80cSmrg# Implementation must be kept synchronized with func_dirname
1989c9ff80cSmrg# and func_basename. For efficiency, we do not delegate to
1999c9ff80cSmrg# those functions but instead duplicate the functionality here.
2009c9ff80cSmrgfunc_dirname_and_basename ()
2019c9ff80cSmrg{
2026fae4e5dSmrg    # Extract subdirectory from the argument.
2036fae4e5dSmrg    func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"`
2046fae4e5dSmrg    if test "X$func_dirname_result" = "X${1}"; then
2056fae4e5dSmrg      func_dirname_result="${3}"
2066fae4e5dSmrg    else
2076fae4e5dSmrg      func_dirname_result="$func_dirname_result${2}"
2086fae4e5dSmrg    fi
2096fae4e5dSmrg    func_basename_result=`$ECHO "${1}" | $SED -e "$basename"`
2106fae4e5dSmrg} # func_dirname_and_basename may be replaced by extended shell implementation
2116fae4e5dSmrg
2126fae4e5dSmrg
2136fae4e5dSmrg# func_stripname prefix suffix name
2146fae4e5dSmrg# strip PREFIX and SUFFIX off of NAME.
2156fae4e5dSmrg# PREFIX and SUFFIX must not contain globbing or regex special
2166fae4e5dSmrg# characters, hashes, percent signs, but SUFFIX may contain a leading
2176fae4e5dSmrg# dot (in which case that matches only a dot).
2186fae4e5dSmrg# func_strip_suffix prefix name
2196fae4e5dSmrgfunc_stripname ()
2206fae4e5dSmrg{
2216fae4e5dSmrg    case ${2} in
2226fae4e5dSmrg      .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;;
2236fae4e5dSmrg      *)  func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;;
2246fae4e5dSmrg    esac
2256fae4e5dSmrg} # func_stripname may be replaced by extended shell implementation
2266fae4e5dSmrg
2276fae4e5dSmrg
2286fae4e5dSmrg# These SED scripts presuppose an absolute path with a trailing slash.
2296fae4e5dSmrgpathcar='s,^/\([^/]*\).*$,\1,'
2306fae4e5dSmrgpathcdr='s,^/[^/]*,,'
2316fae4e5dSmrgremovedotparts=':dotsl
2326fae4e5dSmrg		s@/\./@/@g
2336fae4e5dSmrg		t dotsl
2346fae4e5dSmrg		s,/\.$,/,'
2356fae4e5dSmrgcollapseslashes='s@/\{1,\}@/@g'
2366fae4e5dSmrgfinalslash='s,/*$,/,'
2376fae4e5dSmrg
2386fae4e5dSmrg# func_normal_abspath PATH
2396fae4e5dSmrg# Remove doubled-up and trailing slashes, "." path components,
2406fae4e5dSmrg# and cancel out any ".." path components in PATH after making
2416fae4e5dSmrg# it an absolute path.
2426fae4e5dSmrg#             value returned in "$func_normal_abspath_result"
2436fae4e5dSmrgfunc_normal_abspath ()
2446fae4e5dSmrg{
2456fae4e5dSmrg  # Start from root dir and reassemble the path.
2466fae4e5dSmrg  func_normal_abspath_result=
2476fae4e5dSmrg  func_normal_abspath_tpath=$1
2486fae4e5dSmrg  func_normal_abspath_altnamespace=
2496fae4e5dSmrg  case $func_normal_abspath_tpath in
2506fae4e5dSmrg    "")
2516fae4e5dSmrg      # Empty path, that just means $cwd.
2526fae4e5dSmrg      func_stripname '' '/' "`pwd`"
2536fae4e5dSmrg      func_normal_abspath_result=$func_stripname_result
2546fae4e5dSmrg      return
2556fae4e5dSmrg    ;;
2566fae4e5dSmrg    # The next three entries are used to spot a run of precisely
2576fae4e5dSmrg    # two leading slashes without using negated character classes;
2586fae4e5dSmrg    # we take advantage of case's first-match behaviour.
2596fae4e5dSmrg    ///*)
2606fae4e5dSmrg      # Unusual form of absolute path, do nothing.
2616fae4e5dSmrg    ;;
2626fae4e5dSmrg    //*)
2636fae4e5dSmrg      # Not necessarily an ordinary path; POSIX reserves leading '//'
2646fae4e5dSmrg      # and for example Cygwin uses it to access remote file shares
2656fae4e5dSmrg      # over CIFS/SMB, so we conserve a leading double slash if found.
2666fae4e5dSmrg      func_normal_abspath_altnamespace=/
2676fae4e5dSmrg    ;;
2686fae4e5dSmrg    /*)
2696fae4e5dSmrg      # Absolute path, do nothing.
2706fae4e5dSmrg    ;;
2716fae4e5dSmrg    *)
2726fae4e5dSmrg      # Relative path, prepend $cwd.
2736fae4e5dSmrg      func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
2746fae4e5dSmrg    ;;
2756fae4e5dSmrg  esac
2766fae4e5dSmrg  # Cancel out all the simple stuff to save iterations.  We also want
2776fae4e5dSmrg  # the path to end with a slash for ease of parsing, so make sure
2786fae4e5dSmrg  # there is one (and only one) here.
2796fae4e5dSmrg  func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
2806fae4e5dSmrg        -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"`
2816fae4e5dSmrg  while :; do
2826fae4e5dSmrg    # Processed it all yet?
2836fae4e5dSmrg    if test "$func_normal_abspath_tpath" = / ; then
2846fae4e5dSmrg      # If we ascended to the root using ".." the result may be empty now.
2856fae4e5dSmrg      if test -z "$func_normal_abspath_result" ; then
2866fae4e5dSmrg        func_normal_abspath_result=/
2876fae4e5dSmrg      fi
2886fae4e5dSmrg      break
2896fae4e5dSmrg    fi
2906fae4e5dSmrg    func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
2916fae4e5dSmrg        -e "$pathcar"`
2926fae4e5dSmrg    func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
2936fae4e5dSmrg        -e "$pathcdr"`
2946fae4e5dSmrg    # Figure out what to do with it
2956fae4e5dSmrg    case $func_normal_abspath_tcomponent in
2966fae4e5dSmrg      "")
2976fae4e5dSmrg        # Trailing empty path component, ignore it.
2986fae4e5dSmrg      ;;
2996fae4e5dSmrg      ..)
3006fae4e5dSmrg        # Parent dir; strip last assembled component from result.
3016fae4e5dSmrg        func_dirname "$func_normal_abspath_result"
3026fae4e5dSmrg        func_normal_abspath_result=$func_dirname_result
3036fae4e5dSmrg      ;;
3046fae4e5dSmrg      *)
3056fae4e5dSmrg        # Actual path component, append it.
3066fae4e5dSmrg        func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent
3076fae4e5dSmrg      ;;
3086fae4e5dSmrg    esac
3096fae4e5dSmrg  done
3106fae4e5dSmrg  # Restore leading double-slash if one was found on entry.
3116fae4e5dSmrg  func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
3129c9ff80cSmrg}
3131f0ac6a5Smrg
3146fae4e5dSmrg# func_relative_path SRCDIR DSTDIR
3156fae4e5dSmrg# generates a relative path from SRCDIR to DSTDIR, with a trailing
3166fae4e5dSmrg# slash if non-empty, suitable for immediately appending a filename
3176fae4e5dSmrg# without needing to append a separator.
3186fae4e5dSmrg#             value returned in "$func_relative_path_result"
3196fae4e5dSmrgfunc_relative_path ()
3206fae4e5dSmrg{
3216fae4e5dSmrg  func_relative_path_result=
3226fae4e5dSmrg  func_normal_abspath "$1"
3236fae4e5dSmrg  func_relative_path_tlibdir=$func_normal_abspath_result
3246fae4e5dSmrg  func_normal_abspath "$2"
3256fae4e5dSmrg  func_relative_path_tbindir=$func_normal_abspath_result
3266fae4e5dSmrg
3276fae4e5dSmrg  # Ascend the tree starting from libdir
3286fae4e5dSmrg  while :; do
3296fae4e5dSmrg    # check if we have found a prefix of bindir
3306fae4e5dSmrg    case $func_relative_path_tbindir in
3316fae4e5dSmrg      $func_relative_path_tlibdir)
3326fae4e5dSmrg        # found an exact match
3336fae4e5dSmrg        func_relative_path_tcancelled=
3346fae4e5dSmrg        break
3356fae4e5dSmrg        ;;
3366fae4e5dSmrg      $func_relative_path_tlibdir*)
3376fae4e5dSmrg        # found a matching prefix
3386fae4e5dSmrg        func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
3396fae4e5dSmrg        func_relative_path_tcancelled=$func_stripname_result
3406fae4e5dSmrg        if test -z "$func_relative_path_result"; then
3416fae4e5dSmrg          func_relative_path_result=.
3426fae4e5dSmrg        fi
3436fae4e5dSmrg        break
3446fae4e5dSmrg        ;;
3456fae4e5dSmrg      *)
3466fae4e5dSmrg        func_dirname $func_relative_path_tlibdir
3476fae4e5dSmrg        func_relative_path_tlibdir=${func_dirname_result}
3486fae4e5dSmrg        if test "x$func_relative_path_tlibdir" = x ; then
3496fae4e5dSmrg          # Have to descend all the way to the root!
3506fae4e5dSmrg          func_relative_path_result=../$func_relative_path_result
3516fae4e5dSmrg          func_relative_path_tcancelled=$func_relative_path_tbindir
3526fae4e5dSmrg          break
3536fae4e5dSmrg        fi
3546fae4e5dSmrg        func_relative_path_result=../$func_relative_path_result
3556fae4e5dSmrg        ;;
3566fae4e5dSmrg    esac
3576fae4e5dSmrg  done
3589c9ff80cSmrg
3596fae4e5dSmrg  # Now calculate path; take care to avoid doubling-up slashes.
3606fae4e5dSmrg  func_stripname '' '/' "$func_relative_path_result"
3616fae4e5dSmrg  func_relative_path_result=$func_stripname_result
3626fae4e5dSmrg  func_stripname '/' '/' "$func_relative_path_tcancelled"
3636fae4e5dSmrg  if test "x$func_stripname_result" != x ; then
3646fae4e5dSmrg    func_relative_path_result=${func_relative_path_result}/${func_stripname_result}
3656fae4e5dSmrg  fi
3666fae4e5dSmrg
3676fae4e5dSmrg  # Normalisation. If bindir is libdir, return empty string,
3686fae4e5dSmrg  # else relative path ending with a slash; either way, target
3696fae4e5dSmrg  # file name can be directly appended.
3706fae4e5dSmrg  if test ! -z "$func_relative_path_result"; then
3716fae4e5dSmrg    func_stripname './' '' "$func_relative_path_result/"
3726fae4e5dSmrg    func_relative_path_result=$func_stripname_result
3736fae4e5dSmrg  fi
3746fae4e5dSmrg}
3759c9ff80cSmrg
3769c9ff80cSmrg# The name of this program:
3779c9ff80cSmrgfunc_dirname_and_basename "$progpath"
3789c9ff80cSmrgprogname=$func_basename_result
3799c9ff80cSmrg
3809c9ff80cSmrg# Make sure we have an absolute path for reexecution:
3819c9ff80cSmrgcase $progpath in
3829c9ff80cSmrg  [\\/]*|[A-Za-z]:\\*) ;;
3839c9ff80cSmrg  *[\\/]*)
3849c9ff80cSmrg     progdir=$func_dirname_result
3859c9ff80cSmrg     progdir=`cd "$progdir" && pwd`
3869c9ff80cSmrg     progpath="$progdir/$progname"
3879c9ff80cSmrg     ;;
3889c9ff80cSmrg  *)
3899c9ff80cSmrg     save_IFS="$IFS"
3909c9ff80cSmrg     IFS=:
3919c9ff80cSmrg     for progdir in $PATH; do
3929c9ff80cSmrg       IFS="$save_IFS"
3939c9ff80cSmrg       test -x "$progdir/$progname" && break
3949c9ff80cSmrg     done
3959c9ff80cSmrg     IFS="$save_IFS"
3969c9ff80cSmrg     test -n "$progdir" || progdir=`pwd`
3979c9ff80cSmrg     progpath="$progdir/$progname"
3989c9ff80cSmrg     ;;
3999c9ff80cSmrgesac
4009c9ff80cSmrg
4019c9ff80cSmrg# Sed substitution that helps us do robust quoting.  It backslashifies
4029c9ff80cSmrg# metacharacters that are still active within double-quoted strings.
4039c9ff80cSmrgXsed="${SED}"' -e 1s/^X//'
4049c9ff80cSmrgsed_quote_subst='s/\([`"$\\]\)/\\\1/g'
4059c9ff80cSmrg
4069c9ff80cSmrg# Same as above, but do not quote variable references.
4079c9ff80cSmrgdouble_quote_subst='s/\(["`\\]\)/\\\1/g'
4089c9ff80cSmrg
4096fae4e5dSmrg# Sed substitution that turns a string into a regex matching for the
4106fae4e5dSmrg# string literally.
4116fae4e5dSmrgsed_make_literal_regex='s,[].[^$\\*\/],\\&,g'
4126fae4e5dSmrg
4136fae4e5dSmrg# Sed substitution that converts a w32 file name or path
4146fae4e5dSmrg# which contains forward slashes, into one that contains
4156fae4e5dSmrg# (escaped) backslashes.  A very naive implementation.
4166fae4e5dSmrglt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
4176fae4e5dSmrg
4189c9ff80cSmrg# Re-`\' parameter expansions in output of double_quote_subst that were
4199c9ff80cSmrg# `\'-ed in input to the same.  If an odd number of `\' preceded a '$'
4209c9ff80cSmrg# in input to double_quote_subst, that '$' was protected from expansion.
4219c9ff80cSmrg# Since each input `\' is now two `\'s, look for any number of runs of
4229c9ff80cSmrg# four `\'s followed by two `\'s and then a '$'.  `\' that '$'.
4239c9ff80cSmrgbs='\\'
4249c9ff80cSmrgbs2='\\\\'
4259c9ff80cSmrgbs4='\\\\\\\\'
4269c9ff80cSmrgdollar='\$'
4279c9ff80cSmrgsed_double_backslash="\
4289c9ff80cSmrg  s/$bs4/&\\
4299c9ff80cSmrg/g
4309c9ff80cSmrg  s/^$bs2$dollar/$bs&/
4319c9ff80cSmrg  s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
4329c9ff80cSmrg  s/\n//g"
4339c9ff80cSmrg
4349c9ff80cSmrg# Standard options:
4359c9ff80cSmrgopt_dry_run=false
4369c9ff80cSmrgopt_help=false
4379c9ff80cSmrgopt_quiet=false
4389c9ff80cSmrgopt_verbose=false
4399c9ff80cSmrgopt_warning=:
4409c9ff80cSmrg
4419c9ff80cSmrg# func_echo arg...
4429c9ff80cSmrg# Echo program name prefixed message, along with the current mode
4439c9ff80cSmrg# name if it has been set yet.
4449c9ff80cSmrgfunc_echo ()
4459c9ff80cSmrg{
4466fae4e5dSmrg    $ECHO "$progname: ${opt_mode+$opt_mode: }$*"
4479c9ff80cSmrg}
4489c9ff80cSmrg
4499c9ff80cSmrg# func_verbose arg...
4509c9ff80cSmrg# Echo program name prefixed message in verbose mode only.
4519c9ff80cSmrgfunc_verbose ()
4529c9ff80cSmrg{
4539c9ff80cSmrg    $opt_verbose && func_echo ${1+"$@"}
4549c9ff80cSmrg
4559c9ff80cSmrg    # A bug in bash halts the script if the last line of a function
4569c9ff80cSmrg    # fails when set -e is in force, so we need another command to
4579c9ff80cSmrg    # work around that:
4589c9ff80cSmrg    :
4599c9ff80cSmrg}
4609c9ff80cSmrg
4616fae4e5dSmrg# func_echo_all arg...
4626fae4e5dSmrg# Invoke $ECHO with all args, space-separated.
4636fae4e5dSmrgfunc_echo_all ()
4646fae4e5dSmrg{
4656fae4e5dSmrg    $ECHO "$*"
4666fae4e5dSmrg}
4676fae4e5dSmrg
4689c9ff80cSmrg# func_error arg...
4699c9ff80cSmrg# Echo program name prefixed message to standard error.
4709c9ff80cSmrgfunc_error ()
4719c9ff80cSmrg{
4726fae4e5dSmrg    $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2
4739c9ff80cSmrg}
4749c9ff80cSmrg
4759c9ff80cSmrg# func_warning arg...
4769c9ff80cSmrg# Echo program name prefixed warning message to standard error.
4779c9ff80cSmrgfunc_warning ()
4789c9ff80cSmrg{
4796fae4e5dSmrg    $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2
4809c9ff80cSmrg
4819c9ff80cSmrg    # bash bug again:
4829c9ff80cSmrg    :
4839c9ff80cSmrg}
4849c9ff80cSmrg
4859c9ff80cSmrg# func_fatal_error arg...
4869c9ff80cSmrg# Echo program name prefixed message to standard error, and exit.
4879c9ff80cSmrgfunc_fatal_error ()
4889c9ff80cSmrg{
4899c9ff80cSmrg    func_error ${1+"$@"}
4909c9ff80cSmrg    exit $EXIT_FAILURE
4919c9ff80cSmrg}
4929c9ff80cSmrg
4939c9ff80cSmrg# func_fatal_help arg...
4949c9ff80cSmrg# Echo program name prefixed message to standard error, followed by
4959c9ff80cSmrg# a help hint, and exit.
4969c9ff80cSmrgfunc_fatal_help ()
4979c9ff80cSmrg{
4989c9ff80cSmrg    func_error ${1+"$@"}
4999c9ff80cSmrg    func_fatal_error "$help"
5009c9ff80cSmrg}
5019c9ff80cSmrghelp="Try \`$progname --help' for more information."  ## default
5029c9ff80cSmrg
5039c9ff80cSmrg
5049c9ff80cSmrg# func_grep expression filename
5059c9ff80cSmrg# Check whether EXPRESSION matches any line of FILENAME, without output.
5069c9ff80cSmrgfunc_grep ()
5079c9ff80cSmrg{
5089c9ff80cSmrg    $GREP "$1" "$2" >/dev/null 2>&1
5099c9ff80cSmrg}
5109c9ff80cSmrg
5119c9ff80cSmrg
5129c9ff80cSmrg# func_mkdir_p directory-path
5139c9ff80cSmrg# Make sure the entire path to DIRECTORY-PATH is available.
5149c9ff80cSmrgfunc_mkdir_p ()
5159c9ff80cSmrg{
5169c9ff80cSmrg    my_directory_path="$1"
5179c9ff80cSmrg    my_dir_list=
5189c9ff80cSmrg
5199c9ff80cSmrg    if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
5209c9ff80cSmrg
5219c9ff80cSmrg      # Protect directory names starting with `-'
5229c9ff80cSmrg      case $my_directory_path in
5239c9ff80cSmrg        -*) my_directory_path="./$my_directory_path" ;;
5249c9ff80cSmrg      esac
5259c9ff80cSmrg
5269c9ff80cSmrg      # While some portion of DIR does not yet exist...
5279c9ff80cSmrg      while test ! -d "$my_directory_path"; do
5289c9ff80cSmrg        # ...make a list in topmost first order.  Use a colon delimited
5299c9ff80cSmrg	# list incase some portion of path contains whitespace.
5309c9ff80cSmrg        my_dir_list="$my_directory_path:$my_dir_list"
5319c9ff80cSmrg
5329c9ff80cSmrg        # If the last portion added has no slash in it, the list is done
5339c9ff80cSmrg        case $my_directory_path in */*) ;; *) break ;; esac
5349c9ff80cSmrg
5359c9ff80cSmrg        # ...otherwise throw away the child directory and loop
5366fae4e5dSmrg        my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"`
5379c9ff80cSmrg      done
5386fae4e5dSmrg      my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'`
5399c9ff80cSmrg
5409c9ff80cSmrg      save_mkdir_p_IFS="$IFS"; IFS=':'
5419c9ff80cSmrg      for my_dir in $my_dir_list; do
5429c9ff80cSmrg	IFS="$save_mkdir_p_IFS"
5439c9ff80cSmrg        # mkdir can fail with a `File exist' error if two processes
5449c9ff80cSmrg        # try to create one of the directories concurrently.  Don't
5459c9ff80cSmrg        # stop in that case!
5469c9ff80cSmrg        $MKDIR "$my_dir" 2>/dev/null || :
5479c9ff80cSmrg      done
5489c9ff80cSmrg      IFS="$save_mkdir_p_IFS"
5499c9ff80cSmrg
5509c9ff80cSmrg      # Bail out if we (or some other process) failed to create a directory.
5519c9ff80cSmrg      test -d "$my_directory_path" || \
5529c9ff80cSmrg        func_fatal_error "Failed to create \`$1'"
5539c9ff80cSmrg    fi
5549c9ff80cSmrg}
5551f0ac6a5Smrg
5561f0ac6a5Smrg
5571f0ac6a5Smrg# func_mktempdir [string]
5581f0ac6a5Smrg# Make a temporary directory that won't clash with other running
5591f0ac6a5Smrg# libtool processes, and avoids race conditions if possible.  If
5601f0ac6a5Smrg# given, STRING is the basename for that directory.
5611f0ac6a5Smrgfunc_mktempdir ()
5621f0ac6a5Smrg{
5631f0ac6a5Smrg    my_template="${TMPDIR-/tmp}/${1-$progname}"
5641f0ac6a5Smrg
5659c9ff80cSmrg    if test "$opt_dry_run" = ":"; then
5661f0ac6a5Smrg      # Return a directory name, but don't create it in dry-run mode
5671f0ac6a5Smrg      my_tmpdir="${my_template}-$$"
5681f0ac6a5Smrg    else
5691f0ac6a5Smrg
5701f0ac6a5Smrg      # If mktemp works, use that first and foremost
5711f0ac6a5Smrg      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
5721f0ac6a5Smrg
5731f0ac6a5Smrg      if test ! -d "$my_tmpdir"; then
5749c9ff80cSmrg        # Failing that, at least try and use $RANDOM to avoid a race
5759c9ff80cSmrg        my_tmpdir="${my_template}-${RANDOM-0}$$"
5761f0ac6a5Smrg
5779c9ff80cSmrg        save_mktempdir_umask=`umask`
5789c9ff80cSmrg        umask 0077
5799c9ff80cSmrg        $MKDIR "$my_tmpdir"
5809c9ff80cSmrg        umask $save_mktempdir_umask
5811f0ac6a5Smrg      fi
5821f0ac6a5Smrg
5831f0ac6a5Smrg      # If we're not in dry-run mode, bomb out on failure
5849c9ff80cSmrg      test -d "$my_tmpdir" || \
5859c9ff80cSmrg        func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
5861f0ac6a5Smrg    fi
5871f0ac6a5Smrg
5886fae4e5dSmrg    $ECHO "$my_tmpdir"
5891f0ac6a5Smrg}
5901f0ac6a5Smrg
5911f0ac6a5Smrg
5929c9ff80cSmrg# func_quote_for_eval arg
5939c9ff80cSmrg# Aesthetically quote ARG to be evaled later.
5949c9ff80cSmrg# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
5959c9ff80cSmrg# is double-quoted, suitable for a subsequent eval, whereas
5969c9ff80cSmrg# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
5979c9ff80cSmrg# which are still active within double quotes backslashified.
5989c9ff80cSmrgfunc_quote_for_eval ()
5991f0ac6a5Smrg{
6009c9ff80cSmrg    case $1 in
6019c9ff80cSmrg      *[\\\`\"\$]*)
6026fae4e5dSmrg	func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;;
6039c9ff80cSmrg      *)
6049c9ff80cSmrg        func_quote_for_eval_unquoted_result="$1" ;;
6059c9ff80cSmrg    esac
6069c9ff80cSmrg
6079c9ff80cSmrg    case $func_quote_for_eval_unquoted_result in
6089c9ff80cSmrg      # Double-quote args containing shell metacharacters to delay
6099c9ff80cSmrg      # word splitting, command substitution and and variable
6109c9ff80cSmrg      # expansion for a subsequent eval.
6119c9ff80cSmrg      # Many Bourne shells cannot handle close brackets correctly
6129c9ff80cSmrg      # in scan sets, so we specify it separately.
6139c9ff80cSmrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
6149c9ff80cSmrg        func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
6159c9ff80cSmrg        ;;
6169c9ff80cSmrg      *)
6179c9ff80cSmrg        func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
6181f0ac6a5Smrg    esac
6191f0ac6a5Smrg}
6201f0ac6a5Smrg
6211f0ac6a5Smrg
6229c9ff80cSmrg# func_quote_for_expand arg
6239c9ff80cSmrg# Aesthetically quote ARG to be evaled later; same as above,
6249c9ff80cSmrg# but do not quote variable references.
6259c9ff80cSmrgfunc_quote_for_expand ()
6261f0ac6a5Smrg{
6279c9ff80cSmrg    case $1 in
6289c9ff80cSmrg      *[\\\`\"]*)
6296fae4e5dSmrg	my_arg=`$ECHO "$1" | $SED \
6309c9ff80cSmrg	    -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
6311f0ac6a5Smrg      *)
6329c9ff80cSmrg        my_arg="$1" ;;
6339c9ff80cSmrg    esac
6349c9ff80cSmrg
6359c9ff80cSmrg    case $my_arg in
6369c9ff80cSmrg      # Double-quote args containing shell metacharacters to delay
6379c9ff80cSmrg      # word splitting and command substitution for a subsequent eval.
6389c9ff80cSmrg      # Many Bourne shells cannot handle close brackets correctly
6399c9ff80cSmrg      # in scan sets, so we specify it separately.
6409c9ff80cSmrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
6419c9ff80cSmrg        my_arg="\"$my_arg\""
6429c9ff80cSmrg        ;;
6439c9ff80cSmrg    esac
6449c9ff80cSmrg
6459c9ff80cSmrg    func_quote_for_expand_result="$my_arg"
6461f0ac6a5Smrg}
6471f0ac6a5Smrg
6481f0ac6a5Smrg
6499c9ff80cSmrg# func_show_eval cmd [fail_exp]
6509c9ff80cSmrg# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
6519c9ff80cSmrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
6529c9ff80cSmrg# is given, then evaluate it.
6539c9ff80cSmrgfunc_show_eval ()
6541f0ac6a5Smrg{
6559c9ff80cSmrg    my_cmd="$1"
6569c9ff80cSmrg    my_fail_exp="${2-:}"
6571f0ac6a5Smrg
6589c9ff80cSmrg    ${opt_silent-false} || {
6599c9ff80cSmrg      func_quote_for_expand "$my_cmd"
6609c9ff80cSmrg      eval "func_echo $func_quote_for_expand_result"
6619c9ff80cSmrg    }
6629c9ff80cSmrg
6639c9ff80cSmrg    if ${opt_dry_run-false}; then :; else
6649c9ff80cSmrg      eval "$my_cmd"
6659c9ff80cSmrg      my_status=$?
6669c9ff80cSmrg      if test "$my_status" -eq 0; then :; else
6679c9ff80cSmrg	eval "(exit $my_status); $my_fail_exp"
6689c9ff80cSmrg      fi
6691f0ac6a5Smrg    fi
6701f0ac6a5Smrg}
6711f0ac6a5Smrg
6729c9ff80cSmrg
6739c9ff80cSmrg# func_show_eval_locale cmd [fail_exp]
6749c9ff80cSmrg# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
6759c9ff80cSmrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
6769c9ff80cSmrg# is given, then evaluate it.  Use the saved locale for evaluation.
6779c9ff80cSmrgfunc_show_eval_locale ()
6781f0ac6a5Smrg{
6799c9ff80cSmrg    my_cmd="$1"
6809c9ff80cSmrg    my_fail_exp="${2-:}"
6819c9ff80cSmrg
6829c9ff80cSmrg    ${opt_silent-false} || {
6839c9ff80cSmrg      func_quote_for_expand "$my_cmd"
6849c9ff80cSmrg      eval "func_echo $func_quote_for_expand_result"
6859c9ff80cSmrg    }
6869c9ff80cSmrg
6879c9ff80cSmrg    if ${opt_dry_run-false}; then :; else
6889c9ff80cSmrg      eval "$lt_user_locale
6899c9ff80cSmrg	    $my_cmd"
6909c9ff80cSmrg      my_status=$?
6919c9ff80cSmrg      eval "$lt_safe_locale"
6929c9ff80cSmrg      if test "$my_status" -eq 0; then :; else
6939c9ff80cSmrg	eval "(exit $my_status); $my_fail_exp"
6949c9ff80cSmrg      fi
6951f0ac6a5Smrg    fi
6969c9ff80cSmrg}
6971f0ac6a5Smrg
6986fae4e5dSmrg# func_tr_sh
6996fae4e5dSmrg# Turn $1 into a string suitable for a shell variable name.
7006fae4e5dSmrg# Result is stored in $func_tr_sh_result.  All characters
7016fae4e5dSmrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further,
7026fae4e5dSmrg# if $1 begins with a digit, a '_' is prepended as well.
7036fae4e5dSmrgfunc_tr_sh ()
7046fae4e5dSmrg{
7056fae4e5dSmrg  case $1 in
7066fae4e5dSmrg  [0-9]* | *[!a-zA-Z0-9_]*)
7076fae4e5dSmrg    func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'`
7086fae4e5dSmrg    ;;
7096fae4e5dSmrg  * )
7106fae4e5dSmrg    func_tr_sh_result=$1
7116fae4e5dSmrg    ;;
7126fae4e5dSmrg  esac
7136fae4e5dSmrg}
7149c9ff80cSmrg
7159c9ff80cSmrg
7169c9ff80cSmrg# func_version
7179c9ff80cSmrg# Echo version message to standard output and exit.
7189c9ff80cSmrgfunc_version ()
7199c9ff80cSmrg{
7206fae4e5dSmrg    $opt_debug
7216fae4e5dSmrg
7226fae4e5dSmrg    $SED -n '/(C)/!b go
7236fae4e5dSmrg	:more
7246fae4e5dSmrg	/\./!{
7256fae4e5dSmrg	  N
7266fae4e5dSmrg	  s/\n# / /
7276fae4e5dSmrg	  b more
7286fae4e5dSmrg	}
7296fae4e5dSmrg	:go
7306fae4e5dSmrg	/^# '$PROGRAM' (GNU /,/# warranty; / {
7319c9ff80cSmrg        s/^# //
7329c9ff80cSmrg	s/^# *$//
7339c9ff80cSmrg        s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
7349c9ff80cSmrg        p
7359c9ff80cSmrg     }' < "$progpath"
7369c9ff80cSmrg     exit $?
7379c9ff80cSmrg}
7389c9ff80cSmrg
7399c9ff80cSmrg# func_usage
7409c9ff80cSmrg# Echo short help message to standard output and exit.
7419c9ff80cSmrgfunc_usage ()
7429c9ff80cSmrg{
7436fae4e5dSmrg    $opt_debug
7446fae4e5dSmrg
7456fae4e5dSmrg    $SED -n '/^# Usage:/,/^#  *.*--help/ {
7469c9ff80cSmrg        s/^# //
7479c9ff80cSmrg	s/^# *$//
7489c9ff80cSmrg	s/\$progname/'$progname'/
7499c9ff80cSmrg	p
7509c9ff80cSmrg    }' < "$progpath"
7516fae4e5dSmrg    echo
7529c9ff80cSmrg    $ECHO "run \`$progname --help | more' for full usage"
7539c9ff80cSmrg    exit $?
7549c9ff80cSmrg}
7559c9ff80cSmrg
7566fae4e5dSmrg# func_help [NOEXIT]
7576fae4e5dSmrg# Echo long help message to standard output and exit,
7586fae4e5dSmrg# unless 'noexit' is passed as argument.
7599c9ff80cSmrgfunc_help ()
7609c9ff80cSmrg{
7616fae4e5dSmrg    $opt_debug
7626fae4e5dSmrg
7639c9ff80cSmrg    $SED -n '/^# Usage:/,/# Report bugs to/ {
7646fae4e5dSmrg	:print
7659c9ff80cSmrg        s/^# //
7669c9ff80cSmrg	s/^# *$//
7679c9ff80cSmrg	s*\$progname*'$progname'*
7689c9ff80cSmrg	s*\$host*'"$host"'*
7699c9ff80cSmrg	s*\$SHELL*'"$SHELL"'*
7709c9ff80cSmrg	s*\$LTCC*'"$LTCC"'*
7719c9ff80cSmrg	s*\$LTCFLAGS*'"$LTCFLAGS"'*
7729c9ff80cSmrg	s*\$LD*'"$LD"'*
7739c9ff80cSmrg	s/\$with_gnu_ld/'"$with_gnu_ld"'/
7749c9ff80cSmrg	s/\$automake_version/'"`(automake --version) 2>/dev/null |$SED 1q`"'/
7759c9ff80cSmrg	s/\$autoconf_version/'"`(autoconf --version) 2>/dev/null |$SED 1q`"'/
7769c9ff80cSmrg	p
7776fae4e5dSmrg	d
7786fae4e5dSmrg     }
7796fae4e5dSmrg     /^# .* home page:/b print
7806fae4e5dSmrg     /^# General help using/b print
7816fae4e5dSmrg     ' < "$progpath"
7826fae4e5dSmrg    ret=$?
7836fae4e5dSmrg    if test -z "$1"; then
7846fae4e5dSmrg      exit $ret
7856fae4e5dSmrg    fi
7869c9ff80cSmrg}
7879c9ff80cSmrg
7889c9ff80cSmrg# func_missing_arg argname
7899c9ff80cSmrg# Echo program name prefixed message to standard error and set global
7909c9ff80cSmrg# exit_cmd.
7919c9ff80cSmrgfunc_missing_arg ()
7929c9ff80cSmrg{
7936fae4e5dSmrg    $opt_debug
7946fae4e5dSmrg
7956fae4e5dSmrg    func_error "missing argument for $1."
7969c9ff80cSmrg    exit_cmd=exit
7971f0ac6a5Smrg}
7981f0ac6a5Smrg
7991f0ac6a5Smrg
8006fae4e5dSmrg# func_split_short_opt shortopt
8016fae4e5dSmrg# Set func_split_short_opt_name and func_split_short_opt_arg shell
8026fae4e5dSmrg# variables after splitting SHORTOPT after the 2nd character.
8036fae4e5dSmrgfunc_split_short_opt ()
8046fae4e5dSmrg{
8056fae4e5dSmrg    my_sed_short_opt='1s/^\(..\).*$/\1/;q'
8066fae4e5dSmrg    my_sed_short_rest='1s/^..\(.*\)$/\1/;q'
8071f0ac6a5Smrg
8086fae4e5dSmrg    func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"`
8096fae4e5dSmrg    func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"`
8106fae4e5dSmrg} # func_split_short_opt may be replaced by extended shell implementation
8116fae4e5dSmrg
8126fae4e5dSmrg
8136fae4e5dSmrg# func_split_long_opt longopt
8146fae4e5dSmrg# Set func_split_long_opt_name and func_split_long_opt_arg shell
8156fae4e5dSmrg# variables after splitting LONGOPT at the `=' sign.
8166fae4e5dSmrgfunc_split_long_opt ()
8176fae4e5dSmrg{
8186fae4e5dSmrg    my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q'
8196fae4e5dSmrg    my_sed_long_arg='1s/^--[^=]*=//'
8206fae4e5dSmrg
8216fae4e5dSmrg    func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"`
8226fae4e5dSmrg    func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"`
8236fae4e5dSmrg} # func_split_long_opt may be replaced by extended shell implementation
8246fae4e5dSmrg
8256fae4e5dSmrgexit_cmd=:
8269c9ff80cSmrg
8279c9ff80cSmrg
8289c9ff80cSmrg
8291f0ac6a5Smrg
8301f0ac6a5Smrg
8319c9ff80cSmrgmagic="%%%MAGIC variable%%%"
8329c9ff80cSmrgmagic_exe="%%%MAGIC EXE variable%%%"
8331f0ac6a5Smrg
8349c9ff80cSmrg# Global variables.
8359c9ff80cSmrgnonopt=
8369c9ff80cSmrgpreserve_args=
8379c9ff80cSmrglo2o="s/\\.lo\$/.${objext}/"
8389c9ff80cSmrgo2lo="s/\\.${objext}\$/.lo/"
8399c9ff80cSmrgextracted_archives=
8409c9ff80cSmrgextracted_serial=0
8411f0ac6a5Smrg
8429c9ff80cSmrg# If this variable is set in any of the actions, the command in it
8439c9ff80cSmrg# will be execed at the end.  This prevents here-documents from being
8449c9ff80cSmrg# left over by shells.
8459c9ff80cSmrgexec_cmd=
8469c9ff80cSmrg
8476fae4e5dSmrg# func_append var value
8486fae4e5dSmrg# Append VALUE to the end of shell variable VAR.
8496fae4e5dSmrgfunc_append ()
8506fae4e5dSmrg{
8516fae4e5dSmrg    eval "${1}=\$${1}\${2}"
8526fae4e5dSmrg} # func_append may be replaced by extended shell implementation
8536fae4e5dSmrg
8546fae4e5dSmrg# func_append_quoted var value
8556fae4e5dSmrg# Quote VALUE and append to the end of shell variable VAR, separated
8566fae4e5dSmrg# by a space.
8576fae4e5dSmrgfunc_append_quoted ()
8586fae4e5dSmrg{
8596fae4e5dSmrg    func_quote_for_eval "${2}"
8606fae4e5dSmrg    eval "${1}=\$${1}\\ \$func_quote_for_eval_result"
8616fae4e5dSmrg} # func_append_quoted may be replaced by extended shell implementation
8626fae4e5dSmrg
8636fae4e5dSmrg
8646fae4e5dSmrg# func_arith arithmetic-term...
8656fae4e5dSmrgfunc_arith ()
8666fae4e5dSmrg{
8676fae4e5dSmrg    func_arith_result=`expr "${@}"`
8686fae4e5dSmrg} # func_arith may be replaced by extended shell implementation
8696fae4e5dSmrg
8706fae4e5dSmrg
8716fae4e5dSmrg# func_len string
8726fae4e5dSmrg# STRING may not start with a hyphen.
8736fae4e5dSmrgfunc_len ()
8746fae4e5dSmrg{
8756fae4e5dSmrg    func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len`
8766fae4e5dSmrg} # func_len may be replaced by extended shell implementation
8776fae4e5dSmrg
8786fae4e5dSmrg
8796fae4e5dSmrg# func_lo2o object
8806fae4e5dSmrgfunc_lo2o ()
8816fae4e5dSmrg{
8826fae4e5dSmrg    func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"`
8836fae4e5dSmrg} # func_lo2o may be replaced by extended shell implementation
8846fae4e5dSmrg
8856fae4e5dSmrg
8866fae4e5dSmrg# func_xform libobj-or-source
8876fae4e5dSmrgfunc_xform ()
8886fae4e5dSmrg{
8896fae4e5dSmrg    func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'`
8906fae4e5dSmrg} # func_xform may be replaced by extended shell implementation
8916fae4e5dSmrg
8926fae4e5dSmrg
8939c9ff80cSmrg# func_fatal_configuration arg...
8949c9ff80cSmrg# Echo program name prefixed message to standard error, followed by
8959c9ff80cSmrg# a configuration failure hint, and exit.
8969c9ff80cSmrgfunc_fatal_configuration ()
8979c9ff80cSmrg{
8989c9ff80cSmrg    func_error ${1+"$@"}
8999c9ff80cSmrg    func_error "See the $PACKAGE documentation for more information."
9009c9ff80cSmrg    func_fatal_error "Fatal configuration error."
9019c9ff80cSmrg}
9021f0ac6a5Smrg
903e5410a46Smrg
9049c9ff80cSmrg# func_config
9059c9ff80cSmrg# Display the configuration for all the tags in this script.
9069c9ff80cSmrgfunc_config ()
9079c9ff80cSmrg{
9089c9ff80cSmrg    re_begincf='^# ### BEGIN LIBTOOL'
9099c9ff80cSmrg    re_endcf='^# ### END LIBTOOL'
9109c9ff80cSmrg
9119c9ff80cSmrg    # Default configuration.
9129c9ff80cSmrg    $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
9131f0ac6a5Smrg
9141f0ac6a5Smrg    # Now print the configurations for the tags.
9151f0ac6a5Smrg    for tagname in $taglist; do
9169c9ff80cSmrg      $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
9171f0ac6a5Smrg    done
9181f0ac6a5Smrg
9199c9ff80cSmrg    exit $?
9209c9ff80cSmrg}
9211f0ac6a5Smrg
9229c9ff80cSmrg# func_features
9239c9ff80cSmrg# Display the features supported by this script.
9249c9ff80cSmrgfunc_features ()
9259c9ff80cSmrg{
9266fae4e5dSmrg    echo "host: $host"
9271f0ac6a5Smrg    if test "$build_libtool_libs" = yes; then
9286fae4e5dSmrg      echo "enable shared libraries"
9291f0ac6a5Smrg    else
9306fae4e5dSmrg      echo "disable shared libraries"
9311f0ac6a5Smrg    fi
9321f0ac6a5Smrg    if test "$build_old_libs" = yes; then
9336fae4e5dSmrg      echo "enable static libraries"
9341f0ac6a5Smrg    else
9356fae4e5dSmrg      echo "disable static libraries"
9361f0ac6a5Smrg    fi
9379c9ff80cSmrg
9381f0ac6a5Smrg    exit $?
9399c9ff80cSmrg}
9401f0ac6a5Smrg
9419c9ff80cSmrg# func_enable_tag tagname
9429c9ff80cSmrg# Verify that TAGNAME is valid, and either flag an error and exit, or
9439c9ff80cSmrg# enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
9449c9ff80cSmrg# variable here.
9459c9ff80cSmrgfunc_enable_tag ()
9469c9ff80cSmrg{
9479c9ff80cSmrg  # Global variable:
9489c9ff80cSmrg  tagname="$1"
9491f0ac6a5Smrg
9509c9ff80cSmrg  re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
9519c9ff80cSmrg  re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
9529c9ff80cSmrg  sed_extractcf="/$re_begincf/,/$re_endcf/p"
9531f0ac6a5Smrg
9549c9ff80cSmrg  # Validate tagname.
9559c9ff80cSmrg  case $tagname in
9569c9ff80cSmrg    *[!-_A-Za-z0-9,/]*)
9579c9ff80cSmrg      func_fatal_error "invalid tag name: $tagname"
9589c9ff80cSmrg      ;;
9599c9ff80cSmrg  esac
9601f0ac6a5Smrg
9619c9ff80cSmrg  # Don't test for the "default" C tag, as we know it's
9629c9ff80cSmrg  # there but not specially marked.
9639c9ff80cSmrg  case $tagname in
9649c9ff80cSmrg    CC) ;;
9659c9ff80cSmrg    *)
9669c9ff80cSmrg      if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
9679c9ff80cSmrg	taglist="$taglist $tagname"
9689c9ff80cSmrg
9699c9ff80cSmrg	# Evaluate the configuration.  Be careful to quote the path
9709c9ff80cSmrg	# and the sed script, to avoid splitting on whitespace, but
9719c9ff80cSmrg	# also don't use non-portable quotes within backquotes within
9729c9ff80cSmrg	# quotes we have to do it in 2 steps:
9739c9ff80cSmrg	extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
9749c9ff80cSmrg	eval "$extractedcf"
9759c9ff80cSmrg      else
9769c9ff80cSmrg	func_error "ignoring unknown tag $tagname"
9779c9ff80cSmrg      fi
9789c9ff80cSmrg      ;;
9799c9ff80cSmrg  esac
9809c9ff80cSmrg}
9819c9ff80cSmrg
9826fae4e5dSmrg# func_check_version_match
9836fae4e5dSmrg# Ensure that we are using m4 macros, and libtool script from the same
9846fae4e5dSmrg# release of libtool.
9856fae4e5dSmrgfunc_check_version_match ()
9869c9ff80cSmrg{
9876fae4e5dSmrg  if test "$package_revision" != "$macro_revision"; then
9886fae4e5dSmrg    if test "$VERSION" != "$macro_version"; then
9896fae4e5dSmrg      if test -z "$macro_version"; then
9906fae4e5dSmrg        cat >&2 <<_LT_EOF
9916fae4e5dSmrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
9926fae4e5dSmrg$progname: definition of this LT_INIT comes from an older release.
9936fae4e5dSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
9946fae4e5dSmrg$progname: and run autoconf again.
9956fae4e5dSmrg_LT_EOF
9966fae4e5dSmrg      else
9976fae4e5dSmrg        cat >&2 <<_LT_EOF
9986fae4e5dSmrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
9996fae4e5dSmrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
10006fae4e5dSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
10016fae4e5dSmrg$progname: and run autoconf again.
10026fae4e5dSmrg_LT_EOF
10036fae4e5dSmrg      fi
10046fae4e5dSmrg    else
10056fae4e5dSmrg      cat >&2 <<_LT_EOF
10066fae4e5dSmrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
10076fae4e5dSmrg$progname: but the definition of this LT_INIT comes from revision $macro_revision.
10086fae4e5dSmrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision
10096fae4e5dSmrg$progname: of $PACKAGE $VERSION and run autoconf again.
10106fae4e5dSmrg_LT_EOF
10116fae4e5dSmrg    fi
10121f0ac6a5Smrg
10136fae4e5dSmrg    exit $EXIT_MISMATCH
10146fae4e5dSmrg  fi
10156fae4e5dSmrg}
10166fae4e5dSmrg
10176fae4e5dSmrg
10186fae4e5dSmrg# Shorthand for --mode=foo, only valid as the first argument
10196fae4e5dSmrgcase $1 in
10206fae4e5dSmrgclean|clea|cle|cl)
10216fae4e5dSmrg  shift; set dummy --mode clean ${1+"$@"}; shift
10226fae4e5dSmrg  ;;
10236fae4e5dSmrgcompile|compil|compi|comp|com|co|c)
10246fae4e5dSmrg  shift; set dummy --mode compile ${1+"$@"}; shift
10256fae4e5dSmrg  ;;
10266fae4e5dSmrgexecute|execut|execu|exec|exe|ex|e)
10276fae4e5dSmrg  shift; set dummy --mode execute ${1+"$@"}; shift
10286fae4e5dSmrg  ;;
10296fae4e5dSmrgfinish|finis|fini|fin|fi|f)
10306fae4e5dSmrg  shift; set dummy --mode finish ${1+"$@"}; shift
10316fae4e5dSmrg  ;;
10326fae4e5dSmrginstall|instal|insta|inst|ins|in|i)
10336fae4e5dSmrg  shift; set dummy --mode install ${1+"$@"}; shift
10346fae4e5dSmrg  ;;
10356fae4e5dSmrglink|lin|li|l)
10366fae4e5dSmrg  shift; set dummy --mode link ${1+"$@"}; shift
10376fae4e5dSmrg  ;;
10386fae4e5dSmrguninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
10396fae4e5dSmrg  shift; set dummy --mode uninstall ${1+"$@"}; shift
10406fae4e5dSmrg  ;;
10416fae4e5dSmrgesac
10426fae4e5dSmrg
10436fae4e5dSmrg
10446fae4e5dSmrg
10456fae4e5dSmrg# Option defaults:
10466fae4e5dSmrgopt_debug=:
10476fae4e5dSmrgopt_dry_run=false
10486fae4e5dSmrgopt_config=false
10496fae4e5dSmrgopt_preserve_dup_deps=false
10506fae4e5dSmrgopt_features=false
10516fae4e5dSmrgopt_finish=false
10526fae4e5dSmrgopt_help=false
10536fae4e5dSmrgopt_help_all=false
10546fae4e5dSmrgopt_silent=:
10556fae4e5dSmrgopt_verbose=:
10566fae4e5dSmrgopt_silent=false
10576fae4e5dSmrgopt_verbose=false
10581f0ac6a5Smrg
10596fae4e5dSmrg
10606fae4e5dSmrg# Parse options once, thoroughly.  This comes as soon as possible in the
10616fae4e5dSmrg# script to make things like `--version' happen as quickly as we can.
10626fae4e5dSmrg{
10636fae4e5dSmrg  # this just eases exit handling
10646fae4e5dSmrg  while test $# -gt 0; do
10659c9ff80cSmrg    opt="$1"
10669c9ff80cSmrg    shift
10679c9ff80cSmrg    case $opt in
10686fae4e5dSmrg      --debug|-x)	opt_debug='set -x'
10699c9ff80cSmrg			func_echo "enabling shell trace mode"
10709c9ff80cSmrg			$opt_debug
10719c9ff80cSmrg			;;
10726fae4e5dSmrg      --dry-run|--dryrun|-n)
10736fae4e5dSmrg			opt_dry_run=:
10749c9ff80cSmrg			;;
10756fae4e5dSmrg      --config)
10766fae4e5dSmrg			opt_config=:
10776fae4e5dSmrgfunc_config
10786fae4e5dSmrg			;;
10796fae4e5dSmrg      --dlopen|-dlopen)
10806fae4e5dSmrg			optarg="$1"
10816fae4e5dSmrg			opt_dlopen="${opt_dlopen+$opt_dlopen
10826fae4e5dSmrg}$optarg"
10839c9ff80cSmrg			shift
10849c9ff80cSmrg			;;
10859c9ff80cSmrg      --preserve-dup-deps)
10866fae4e5dSmrg			opt_preserve_dup_deps=:
10879c9ff80cSmrg			;;
10886fae4e5dSmrg      --features)
10896fae4e5dSmrg			opt_features=:
10906fae4e5dSmrgfunc_features
10916fae4e5dSmrg			;;
10926fae4e5dSmrg      --finish)
10936fae4e5dSmrg			opt_finish=:
10946fae4e5dSmrgset dummy --mode finish ${1+"$@"}; shift
10956fae4e5dSmrg			;;
10966fae4e5dSmrg      --help)
10976fae4e5dSmrg			opt_help=:
10986fae4e5dSmrg			;;
10996fae4e5dSmrg      --help-all)
11006fae4e5dSmrg			opt_help_all=:
11016fae4e5dSmrgopt_help=': help-all'
11026fae4e5dSmrg			;;
11036fae4e5dSmrg      --mode)
11046fae4e5dSmrg			test $# = 0 && func_missing_arg $opt && break
11056fae4e5dSmrg			optarg="$1"
11066fae4e5dSmrg			opt_mode="$optarg"
11076fae4e5dSmrgcase $optarg in
11086fae4e5dSmrg  # Valid mode arguments:
11096fae4e5dSmrg  clean|compile|execute|finish|install|link|relink|uninstall) ;;
11106fae4e5dSmrg
11116fae4e5dSmrg  # Catch anything else as an error
11126fae4e5dSmrg  *) func_error "invalid argument for $opt"
11136fae4e5dSmrg     exit_cmd=exit
11146fae4e5dSmrg     break
11156fae4e5dSmrg     ;;
11166fae4e5dSmrgesac
11176fae4e5dSmrg			shift
11186fae4e5dSmrg			;;
11196fae4e5dSmrg      --no-silent|--no-quiet)
11209c9ff80cSmrg			opt_silent=false
11216fae4e5dSmrgfunc_append preserve_args " $opt"
11229c9ff80cSmrg			;;
11236fae4e5dSmrg      --no-verbose)
11246fae4e5dSmrg			opt_verbose=false
11256fae4e5dSmrgfunc_append preserve_args " $opt"
11266fae4e5dSmrg			;;
11276fae4e5dSmrg      --silent|--quiet)
11286fae4e5dSmrg			opt_silent=:
11296fae4e5dSmrgfunc_append preserve_args " $opt"
11306fae4e5dSmrg        opt_verbose=false
11316fae4e5dSmrg			;;
11326fae4e5dSmrg      --verbose|-v)
11336fae4e5dSmrg			opt_verbose=:
11346fae4e5dSmrgfunc_append preserve_args " $opt"
11356fae4e5dSmrgopt_silent=false
11366fae4e5dSmrg			;;
11376fae4e5dSmrg      --tag)
11386fae4e5dSmrg			test $# = 0 && func_missing_arg $opt && break
11396fae4e5dSmrg			optarg="$1"
11406fae4e5dSmrg			opt_tag="$optarg"
11416fae4e5dSmrgfunc_append preserve_args " $opt $optarg"
11426fae4e5dSmrgfunc_enable_tag "$optarg"
11439c9ff80cSmrg			shift
11449c9ff80cSmrg			;;
11459c9ff80cSmrg
11466fae4e5dSmrg      -\?|-h)		func_usage				;;
11476fae4e5dSmrg      --help)		func_help				;;
11486fae4e5dSmrg      --version)	func_version				;;
11496fae4e5dSmrg
11509c9ff80cSmrg      # Separate optargs to long options:
11516fae4e5dSmrg      --*=*)
11526fae4e5dSmrg			func_split_long_opt "$opt"
11536fae4e5dSmrg			set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"}
11549c9ff80cSmrg			shift
11559c9ff80cSmrg			;;
11569c9ff80cSmrg
11576fae4e5dSmrg      # Separate non-argument short options:
11586fae4e5dSmrg      -\?*|-h*|-n*|-v*)
11596fae4e5dSmrg			func_split_short_opt "$opt"
11606fae4e5dSmrg			set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"}
11616fae4e5dSmrg			shift
11629c9ff80cSmrg			;;
11636fae4e5dSmrg
11646fae4e5dSmrg      --)		break					;;
11656fae4e5dSmrg      -*)		func_fatal_help "unrecognized option \`$opt'" ;;
11666fae4e5dSmrg      *)		set dummy "$opt" ${1+"$@"};	shift; break  ;;
11679c9ff80cSmrg    esac
11689c9ff80cSmrg  done
11699c9ff80cSmrg
11706fae4e5dSmrg  # Validate options:
11716fae4e5dSmrg
11726fae4e5dSmrg  # save first non-option argument
11736fae4e5dSmrg  if test "$#" -gt 0; then
11746fae4e5dSmrg    nonopt="$opt"
11756fae4e5dSmrg    shift
11766fae4e5dSmrg  fi
11776fae4e5dSmrg
11786fae4e5dSmrg  # preserve --debug
11796fae4e5dSmrg  test "$opt_debug" = : || func_append preserve_args " --debug"
11809c9ff80cSmrg
11819c9ff80cSmrg  case $host in
11829c9ff80cSmrg    *cygwin* | *mingw* | *pw32* | *cegcc*)
11839c9ff80cSmrg      # don't eliminate duplications in $postdeps and $predeps
11849c9ff80cSmrg      opt_duplicate_compiler_generated_deps=:
11851f0ac6a5Smrg      ;;
11861f0ac6a5Smrg    *)
11876fae4e5dSmrg      opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
11889c9ff80cSmrg      ;;
11899c9ff80cSmrg  esac
11901f0ac6a5Smrg
11916fae4e5dSmrg  $opt_help || {
11926fae4e5dSmrg    # Sanity checks first:
11936fae4e5dSmrg    func_check_version_match
11949c9ff80cSmrg
11956fae4e5dSmrg    if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
11966fae4e5dSmrg      func_fatal_configuration "not configured to build any kind of library"
11979c9ff80cSmrg    fi
11989c9ff80cSmrg
11996fae4e5dSmrg    # Darwin sucks
12006fae4e5dSmrg    eval std_shrext=\"$shrext_cmds\"
12019c9ff80cSmrg
12026fae4e5dSmrg    # Only execute mode is allowed to have -dlopen flags.
12036fae4e5dSmrg    if test -n "$opt_dlopen" && test "$opt_mode" != execute; then
12046fae4e5dSmrg      func_error "unrecognized option \`-dlopen'"
12056fae4e5dSmrg      $ECHO "$help" 1>&2
12066fae4e5dSmrg      exit $EXIT_FAILURE
12076fae4e5dSmrg    fi
12081f0ac6a5Smrg
12096fae4e5dSmrg    # Change the help message to a mode-specific one.
12106fae4e5dSmrg    generic_help="$help"
12116fae4e5dSmrg    help="Try \`$progname --help --mode=$opt_mode' for more information."
12126fae4e5dSmrg  }
12139c9ff80cSmrg
12149c9ff80cSmrg
12156fae4e5dSmrg  # Bail if the options were screwed
12166fae4e5dSmrg  $exit_cmd $EXIT_FAILURE
12176fae4e5dSmrg}
12189c9ff80cSmrg
12199c9ff80cSmrg
12201f0ac6a5Smrg
12211f0ac6a5Smrg
12226fae4e5dSmrg## ----------- ##
12236fae4e5dSmrg##    Main.    ##
12246fae4e5dSmrg## ----------- ##
12251f0ac6a5Smrg
12269c9ff80cSmrg# func_lalib_p file
12279c9ff80cSmrg# True iff FILE is a libtool `.la' library or `.lo' object file.
12289c9ff80cSmrg# This function is only a basic sanity check; it will hardly flush out
12299c9ff80cSmrg# determined imposters.
12309c9ff80cSmrgfunc_lalib_p ()
12319c9ff80cSmrg{
12329c9ff80cSmrg    test -f "$1" &&
12339c9ff80cSmrg      $SED -e 4q "$1" 2>/dev/null \
12349c9ff80cSmrg        | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
12359c9ff80cSmrg}
12361f0ac6a5Smrg
12379c9ff80cSmrg# func_lalib_unsafe_p file
12389c9ff80cSmrg# True iff FILE is a libtool `.la' library or `.lo' object file.
12399c9ff80cSmrg# This function implements the same check as func_lalib_p without
12409c9ff80cSmrg# resorting to external programs.  To this end, it redirects stdin and
12419c9ff80cSmrg# closes it afterwards, without saving the original file descriptor.
12429c9ff80cSmrg# As a safety measure, use it only where a negative result would be
12439c9ff80cSmrg# fatal anyway.  Works if `file' does not exist.
12449c9ff80cSmrgfunc_lalib_unsafe_p ()
12459c9ff80cSmrg{
12469c9ff80cSmrg    lalib_p=no
12479c9ff80cSmrg    if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
12489c9ff80cSmrg	for lalib_p_l in 1 2 3 4
12499c9ff80cSmrg	do
12509c9ff80cSmrg	    read lalib_p_line
12519c9ff80cSmrg	    case "$lalib_p_line" in
12529c9ff80cSmrg		\#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
12539c9ff80cSmrg	    esac
12549c9ff80cSmrg	done
12559c9ff80cSmrg	exec 0<&5 5<&-
12569c9ff80cSmrg    fi
12579c9ff80cSmrg    test "$lalib_p" = yes
12589c9ff80cSmrg}
12591f0ac6a5Smrg
12609c9ff80cSmrg# func_ltwrapper_script_p file
12619c9ff80cSmrg# True iff FILE is a libtool wrapper script
12629c9ff80cSmrg# This function is only a basic sanity check; it will hardly flush out
12639c9ff80cSmrg# determined imposters.
12649c9ff80cSmrgfunc_ltwrapper_script_p ()
12659c9ff80cSmrg{
12669c9ff80cSmrg    func_lalib_p "$1"
12679c9ff80cSmrg}
12681f0ac6a5Smrg
12699c9ff80cSmrg# func_ltwrapper_executable_p file
12709c9ff80cSmrg# True iff FILE is a libtool wrapper executable
12719c9ff80cSmrg# This function is only a basic sanity check; it will hardly flush out
12729c9ff80cSmrg# determined imposters.
12739c9ff80cSmrgfunc_ltwrapper_executable_p ()
12749c9ff80cSmrg{
12759c9ff80cSmrg    func_ltwrapper_exec_suffix=
12769c9ff80cSmrg    case $1 in
12779c9ff80cSmrg    *.exe) ;;
12789c9ff80cSmrg    *) func_ltwrapper_exec_suffix=.exe ;;
12799c9ff80cSmrg    esac
12809c9ff80cSmrg    $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
12819c9ff80cSmrg}
12821f0ac6a5Smrg
12839c9ff80cSmrg# func_ltwrapper_scriptname file
12849c9ff80cSmrg# Assumes file is an ltwrapper_executable
12859c9ff80cSmrg# uses $file to determine the appropriate filename for a
12869c9ff80cSmrg# temporary ltwrapper_script.
12879c9ff80cSmrgfunc_ltwrapper_scriptname ()
12889c9ff80cSmrg{
12896fae4e5dSmrg    func_dirname_and_basename "$1" "" "."
12906fae4e5dSmrg    func_stripname '' '.exe' "$func_basename_result"
12916fae4e5dSmrg    func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper"
12929c9ff80cSmrg}
12939c9ff80cSmrg
12949c9ff80cSmrg# func_ltwrapper_p file
12959c9ff80cSmrg# True iff FILE is a libtool wrapper script or wrapper executable
12969c9ff80cSmrg# This function is only a basic sanity check; it will hardly flush out
12979c9ff80cSmrg# determined imposters.
12989c9ff80cSmrgfunc_ltwrapper_p ()
12999c9ff80cSmrg{
13009c9ff80cSmrg    func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
13019c9ff80cSmrg}
13029c9ff80cSmrg
13039c9ff80cSmrg
13049c9ff80cSmrg# func_execute_cmds commands fail_cmd
13059c9ff80cSmrg# Execute tilde-delimited COMMANDS.
13069c9ff80cSmrg# If FAIL_CMD is given, eval that upon failure.
13079c9ff80cSmrg# FAIL_CMD may read-access the current command in variable CMD!
13089c9ff80cSmrgfunc_execute_cmds ()
13099c9ff80cSmrg{
13109c9ff80cSmrg    $opt_debug
13119c9ff80cSmrg    save_ifs=$IFS; IFS='~'
13129c9ff80cSmrg    for cmd in $1; do
13139c9ff80cSmrg      IFS=$save_ifs
13149c9ff80cSmrg      eval cmd=\"$cmd\"
13159c9ff80cSmrg      func_show_eval "$cmd" "${2-:}"
13169c9ff80cSmrg    done
13179c9ff80cSmrg    IFS=$save_ifs
13189c9ff80cSmrg}
13199c9ff80cSmrg
13209c9ff80cSmrg
13219c9ff80cSmrg# func_source file
13229c9ff80cSmrg# Source FILE, adding directory component if necessary.
13239c9ff80cSmrg# Note that it is not necessary on cygwin/mingw to append a dot to
13249c9ff80cSmrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe
13259c9ff80cSmrg# behavior happens only for exec(3), not for open(2)!  Also, sourcing
13269c9ff80cSmrg# `FILE.' does not work on cygwin managed mounts.
13279c9ff80cSmrgfunc_source ()
13289c9ff80cSmrg{
13299c9ff80cSmrg    $opt_debug
13309c9ff80cSmrg    case $1 in
13319c9ff80cSmrg    */* | *\\*)	. "$1" ;;
13329c9ff80cSmrg    *)		. "./$1" ;;
13339c9ff80cSmrg    esac
13349c9ff80cSmrg}
13359c9ff80cSmrg
13369c9ff80cSmrg
13376fae4e5dSmrg# func_resolve_sysroot PATH
13386fae4e5dSmrg# Replace a leading = in PATH with a sysroot.  Store the result into
13396fae4e5dSmrg# func_resolve_sysroot_result
13406fae4e5dSmrgfunc_resolve_sysroot ()
13416fae4e5dSmrg{
13426fae4e5dSmrg  func_resolve_sysroot_result=$1
13436fae4e5dSmrg  case $func_resolve_sysroot_result in
13446fae4e5dSmrg  =*)
13456fae4e5dSmrg    func_stripname '=' '' "$func_resolve_sysroot_result"
13466fae4e5dSmrg    func_resolve_sysroot_result=$lt_sysroot$func_stripname_result
13476fae4e5dSmrg    ;;
13486fae4e5dSmrg  esac
13496fae4e5dSmrg}
13506fae4e5dSmrg
13516fae4e5dSmrg# func_replace_sysroot PATH
13526fae4e5dSmrg# If PATH begins with the sysroot, replace it with = and
13536fae4e5dSmrg# store the result into func_replace_sysroot_result.
13546fae4e5dSmrgfunc_replace_sysroot ()
13556fae4e5dSmrg{
13566fae4e5dSmrg  case "$lt_sysroot:$1" in
13576fae4e5dSmrg  ?*:"$lt_sysroot"*)
13586fae4e5dSmrg    func_stripname "$lt_sysroot" '' "$1"
13596fae4e5dSmrg    func_replace_sysroot_result="=$func_stripname_result"
13606fae4e5dSmrg    ;;
13616fae4e5dSmrg  *)
13626fae4e5dSmrg    # Including no sysroot.
13636fae4e5dSmrg    func_replace_sysroot_result=$1
13646fae4e5dSmrg    ;;
13656fae4e5dSmrg  esac
13666fae4e5dSmrg}
13676fae4e5dSmrg
13689c9ff80cSmrg# func_infer_tag arg
13699c9ff80cSmrg# Infer tagged configuration to use if any are available and
13709c9ff80cSmrg# if one wasn't chosen via the "--tag" command line option.
13719c9ff80cSmrg# Only attempt this if the compiler in the base compile
13729c9ff80cSmrg# command doesn't match the default compiler.
13739c9ff80cSmrg# arg is usually of the form 'gcc ...'
13749c9ff80cSmrgfunc_infer_tag ()
13759c9ff80cSmrg{
13769c9ff80cSmrg    $opt_debug
13779c9ff80cSmrg    if test -n "$available_tags" && test -z "$tagname"; then
13789c9ff80cSmrg      CC_quoted=
13799c9ff80cSmrg      for arg in $CC; do
13806fae4e5dSmrg	func_append_quoted CC_quoted "$arg"
13819c9ff80cSmrg      done
13826fae4e5dSmrg      CC_expanded=`func_echo_all $CC`
13836fae4e5dSmrg      CC_quoted_expanded=`func_echo_all $CC_quoted`
13849c9ff80cSmrg      case $@ in
13859c9ff80cSmrg      # Blanks in the command may have been stripped by the calling shell,
13869c9ff80cSmrg      # but not from the CC environment variable when configure was run.
13876fae4e5dSmrg      " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
13886fae4e5dSmrg      " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
13899c9ff80cSmrg      # Blanks at the start of $base_compile will cause this to fail
13909c9ff80cSmrg      # if we don't check for them as well.
13919c9ff80cSmrg      *)
13929c9ff80cSmrg	for z in $available_tags; do
13939c9ff80cSmrg	  if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
13949c9ff80cSmrg	    # Evaluate the configuration.
13959c9ff80cSmrg	    eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
13969c9ff80cSmrg	    CC_quoted=
13979c9ff80cSmrg	    for arg in $CC; do
13989c9ff80cSmrg	      # Double-quote args containing other shell metacharacters.
13996fae4e5dSmrg	      func_append_quoted CC_quoted "$arg"
14009c9ff80cSmrg	    done
14016fae4e5dSmrg	    CC_expanded=`func_echo_all $CC`
14026fae4e5dSmrg	    CC_quoted_expanded=`func_echo_all $CC_quoted`
14039c9ff80cSmrg	    case "$@ " in
14046fae4e5dSmrg	    " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
14056fae4e5dSmrg	    " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
14069c9ff80cSmrg	      # The compiler in the base compile command matches
14079c9ff80cSmrg	      # the one in the tagged configuration.
14089c9ff80cSmrg	      # Assume this is the tagged configuration we want.
14099c9ff80cSmrg	      tagname=$z
14109c9ff80cSmrg	      break
14119c9ff80cSmrg	      ;;
14129c9ff80cSmrg	    esac
14139c9ff80cSmrg	  fi
14149c9ff80cSmrg	done
14159c9ff80cSmrg	# If $tagname still isn't set, then no tagged configuration
14169c9ff80cSmrg	# was found and let the user know that the "--tag" command
14179c9ff80cSmrg	# line option must be used.
14189c9ff80cSmrg	if test -z "$tagname"; then
14199c9ff80cSmrg	  func_echo "unable to infer tagged configuration"
14209c9ff80cSmrg	  func_fatal_error "specify a tag with \`--tag'"
14219c9ff80cSmrg#	else
14229c9ff80cSmrg#	  func_verbose "using $tagname tagged configuration"
14239c9ff80cSmrg	fi
14249c9ff80cSmrg	;;
14259c9ff80cSmrg      esac
14269c9ff80cSmrg    fi
14279c9ff80cSmrg}
14289c9ff80cSmrg
14299c9ff80cSmrg
14309c9ff80cSmrg
14319c9ff80cSmrg# func_write_libtool_object output_name pic_name nonpic_name
14329c9ff80cSmrg# Create a libtool object file (analogous to a ".la" file),
14339c9ff80cSmrg# but don't create it if we're doing a dry run.
14349c9ff80cSmrgfunc_write_libtool_object ()
14359c9ff80cSmrg{
14369c9ff80cSmrg    write_libobj=${1}
14379c9ff80cSmrg    if test "$build_libtool_libs" = yes; then
14389c9ff80cSmrg      write_lobj=\'${2}\'
14399c9ff80cSmrg    else
14409c9ff80cSmrg      write_lobj=none
14419c9ff80cSmrg    fi
14429c9ff80cSmrg
14439c9ff80cSmrg    if test "$build_old_libs" = yes; then
14449c9ff80cSmrg      write_oldobj=\'${3}\'
14459c9ff80cSmrg    else
14469c9ff80cSmrg      write_oldobj=none
14479c9ff80cSmrg    fi
14489c9ff80cSmrg
14499c9ff80cSmrg    $opt_dry_run || {
14509c9ff80cSmrg      cat >${write_libobj}T <<EOF
14519c9ff80cSmrg# $write_libobj - a libtool object file
14529c9ff80cSmrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
14539c9ff80cSmrg#
14549c9ff80cSmrg# Please DO NOT delete this file!
14559c9ff80cSmrg# It is necessary for linking the library.
14569c9ff80cSmrg
14579c9ff80cSmrg# Name of the PIC object.
14589c9ff80cSmrgpic_object=$write_lobj
14599c9ff80cSmrg
14609c9ff80cSmrg# Name of the non-PIC object
14619c9ff80cSmrgnon_pic_object=$write_oldobj
14629c9ff80cSmrg
14639c9ff80cSmrgEOF
14649c9ff80cSmrg      $MV "${write_libobj}T" "${write_libobj}"
14659c9ff80cSmrg    }
14669c9ff80cSmrg}
14679c9ff80cSmrg
14686fae4e5dSmrg
14696fae4e5dSmrg##################################################
14706fae4e5dSmrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS #
14716fae4e5dSmrg##################################################
14726fae4e5dSmrg
14736fae4e5dSmrg# func_convert_core_file_wine_to_w32 ARG
14746fae4e5dSmrg# Helper function used by file name conversion functions when $build is *nix,
14756fae4e5dSmrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a
14766fae4e5dSmrg# correctly configured wine environment available, with the winepath program
14776fae4e5dSmrg# in $build's $PATH.
14786fae4e5dSmrg#
14796fae4e5dSmrg# ARG is the $build file name to be converted to w32 format.
14806fae4e5dSmrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will
14816fae4e5dSmrg# be empty on error (or when ARG is empty)
14826fae4e5dSmrgfunc_convert_core_file_wine_to_w32 ()
14836fae4e5dSmrg{
14846fae4e5dSmrg  $opt_debug
14856fae4e5dSmrg  func_convert_core_file_wine_to_w32_result="$1"
14866fae4e5dSmrg  if test -n "$1"; then
14876fae4e5dSmrg    # Unfortunately, winepath does not exit with a non-zero error code, so we
14886fae4e5dSmrg    # are forced to check the contents of stdout. On the other hand, if the
14896fae4e5dSmrg    # command is not found, the shell will set an exit code of 127 and print
14906fae4e5dSmrg    # *an error message* to stdout. So we must check for both error code of
14916fae4e5dSmrg    # zero AND non-empty stdout, which explains the odd construction:
14926fae4e5dSmrg    func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
14936fae4e5dSmrg    if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then
14946fae4e5dSmrg      func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
14956fae4e5dSmrg        $SED -e "$lt_sed_naive_backslashify"`
14966fae4e5dSmrg    else
14976fae4e5dSmrg      func_convert_core_file_wine_to_w32_result=
14986fae4e5dSmrg    fi
14996fae4e5dSmrg  fi
15006fae4e5dSmrg}
15016fae4e5dSmrg# end: func_convert_core_file_wine_to_w32
15026fae4e5dSmrg
15036fae4e5dSmrg
15046fae4e5dSmrg# func_convert_core_path_wine_to_w32 ARG
15056fae4e5dSmrg# Helper function used by path conversion functions when $build is *nix, and
15066fae4e5dSmrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly
15076fae4e5dSmrg# configured wine environment available, with the winepath program in $build's
15086fae4e5dSmrg# $PATH. Assumes ARG has no leading or trailing path separator characters.
15096fae4e5dSmrg#
15106fae4e5dSmrg# ARG is path to be converted from $build format to win32.
15116fae4e5dSmrg# Result is available in $func_convert_core_path_wine_to_w32_result.
15126fae4e5dSmrg# Unconvertible file (directory) names in ARG are skipped; if no directory names
15136fae4e5dSmrg# are convertible, then the result may be empty.
15146fae4e5dSmrgfunc_convert_core_path_wine_to_w32 ()
15156fae4e5dSmrg{
15166fae4e5dSmrg  $opt_debug
15176fae4e5dSmrg  # unfortunately, winepath doesn't convert paths, only file names
15186fae4e5dSmrg  func_convert_core_path_wine_to_w32_result=""
15196fae4e5dSmrg  if test -n "$1"; then
15206fae4e5dSmrg    oldIFS=$IFS
15216fae4e5dSmrg    IFS=:
15226fae4e5dSmrg    for func_convert_core_path_wine_to_w32_f in $1; do
15236fae4e5dSmrg      IFS=$oldIFS
15246fae4e5dSmrg      func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
15256fae4e5dSmrg      if test -n "$func_convert_core_file_wine_to_w32_result" ; then
15266fae4e5dSmrg        if test -z "$func_convert_core_path_wine_to_w32_result"; then
15276fae4e5dSmrg          func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result"
15286fae4e5dSmrg        else
15296fae4e5dSmrg          func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
15306fae4e5dSmrg        fi
15316fae4e5dSmrg      fi
15326fae4e5dSmrg    done
15336fae4e5dSmrg    IFS=$oldIFS
15346fae4e5dSmrg  fi
15356fae4e5dSmrg}
15366fae4e5dSmrg# end: func_convert_core_path_wine_to_w32
15376fae4e5dSmrg
15386fae4e5dSmrg
15396fae4e5dSmrg# func_cygpath ARGS...
15406fae4e5dSmrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when
15416fae4e5dSmrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2)
15426fae4e5dSmrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or
15436fae4e5dSmrg# (2), returns the Cygwin file name or path in func_cygpath_result (input
15446fae4e5dSmrg# file name or path is assumed to be in w32 format, as previously converted
15456fae4e5dSmrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name
15466fae4e5dSmrg# or path in func_cygpath_result (input file name or path is assumed to be in
15476fae4e5dSmrg# Cygwin format). Returns an empty string on error.
15486fae4e5dSmrg#
15496fae4e5dSmrg# ARGS are passed to cygpath, with the last one being the file name or path to
15506fae4e5dSmrg# be converted.
15516fae4e5dSmrg#
15526fae4e5dSmrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH
15536fae4e5dSmrg# environment variable; do not put it in $PATH.
15546fae4e5dSmrgfunc_cygpath ()
15556fae4e5dSmrg{
15566fae4e5dSmrg  $opt_debug
15576fae4e5dSmrg  if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
15586fae4e5dSmrg    func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
15596fae4e5dSmrg    if test "$?" -ne 0; then
15606fae4e5dSmrg      # on failure, ensure result is empty
15616fae4e5dSmrg      func_cygpath_result=
15626fae4e5dSmrg    fi
15636fae4e5dSmrg  else
15646fae4e5dSmrg    func_cygpath_result=
15656fae4e5dSmrg    func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'"
15666fae4e5dSmrg  fi
15676fae4e5dSmrg}
15686fae4e5dSmrg#end: func_cygpath
15696fae4e5dSmrg
15706fae4e5dSmrg
15716fae4e5dSmrg# func_convert_core_msys_to_w32 ARG
15726fae4e5dSmrg# Convert file name or path ARG from MSYS format to w32 format.  Return
15736fae4e5dSmrg# result in func_convert_core_msys_to_w32_result.
15746fae4e5dSmrgfunc_convert_core_msys_to_w32 ()
15756fae4e5dSmrg{
15766fae4e5dSmrg  $opt_debug
15776fae4e5dSmrg  # awkward: cmd appends spaces to result
15786fae4e5dSmrg  func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
15796fae4e5dSmrg    $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"`
15806fae4e5dSmrg}
15816fae4e5dSmrg#end: func_convert_core_msys_to_w32
15826fae4e5dSmrg
15836fae4e5dSmrg
15846fae4e5dSmrg# func_convert_file_check ARG1 ARG2
15856fae4e5dSmrg# Verify that ARG1 (a file name in $build format) was converted to $host
15866fae4e5dSmrg# format in ARG2. Otherwise, emit an error message, but continue (resetting
15876fae4e5dSmrg# func_to_host_file_result to ARG1).
15886fae4e5dSmrgfunc_convert_file_check ()
15896fae4e5dSmrg{
15906fae4e5dSmrg  $opt_debug
15916fae4e5dSmrg  if test -z "$2" && test -n "$1" ; then
15926fae4e5dSmrg    func_error "Could not determine host file name corresponding to"
15936fae4e5dSmrg    func_error "  \`$1'"
15946fae4e5dSmrg    func_error "Continuing, but uninstalled executables may not work."
15956fae4e5dSmrg    # Fallback:
15966fae4e5dSmrg    func_to_host_file_result="$1"
15976fae4e5dSmrg  fi
15986fae4e5dSmrg}
15996fae4e5dSmrg# end func_convert_file_check
16006fae4e5dSmrg
16016fae4e5dSmrg
16026fae4e5dSmrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH
16036fae4e5dSmrg# Verify that FROM_PATH (a path in $build format) was converted to $host
16046fae4e5dSmrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting
16056fae4e5dSmrg# func_to_host_file_result to a simplistic fallback value (see below).
16066fae4e5dSmrgfunc_convert_path_check ()
16076fae4e5dSmrg{
16086fae4e5dSmrg  $opt_debug
16096fae4e5dSmrg  if test -z "$4" && test -n "$3"; then
16106fae4e5dSmrg    func_error "Could not determine the host path corresponding to"
16116fae4e5dSmrg    func_error "  \`$3'"
16126fae4e5dSmrg    func_error "Continuing, but uninstalled executables may not work."
16136fae4e5dSmrg    # Fallback.  This is a deliberately simplistic "conversion" and
16146fae4e5dSmrg    # should not be "improved".  See libtool.info.
16156fae4e5dSmrg    if test "x$1" != "x$2"; then
16166fae4e5dSmrg      lt_replace_pathsep_chars="s|$1|$2|g"
16176fae4e5dSmrg      func_to_host_path_result=`echo "$3" |
16186fae4e5dSmrg        $SED -e "$lt_replace_pathsep_chars"`
16196fae4e5dSmrg    else
16206fae4e5dSmrg      func_to_host_path_result="$3"
16216fae4e5dSmrg    fi
16226fae4e5dSmrg  fi
16236fae4e5dSmrg}
16246fae4e5dSmrg# end func_convert_path_check
16256fae4e5dSmrg
16266fae4e5dSmrg
16276fae4e5dSmrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG
16286fae4e5dSmrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT
16296fae4e5dSmrg# and appending REPL if ORIG matches BACKPAT.
16306fae4e5dSmrgfunc_convert_path_front_back_pathsep ()
16316fae4e5dSmrg{
16326fae4e5dSmrg  $opt_debug
16336fae4e5dSmrg  case $4 in
16346fae4e5dSmrg  $1 ) func_to_host_path_result="$3$func_to_host_path_result"
16356fae4e5dSmrg    ;;
16366fae4e5dSmrg  esac
16376fae4e5dSmrg  case $4 in
16386fae4e5dSmrg  $2 ) func_append func_to_host_path_result "$3"
16396fae4e5dSmrg    ;;
16406fae4e5dSmrg  esac
16416fae4e5dSmrg}
16426fae4e5dSmrg# end func_convert_path_front_back_pathsep
16436fae4e5dSmrg
16446fae4e5dSmrg
16456fae4e5dSmrg##################################################
16466fae4e5dSmrg# $build to $host FILE NAME CONVERSION FUNCTIONS #
16476fae4e5dSmrg##################################################
16486fae4e5dSmrg# invoked via `$to_host_file_cmd ARG'
16496fae4e5dSmrg#
16506fae4e5dSmrg# In each case, ARG is the path to be converted from $build to $host format.
16516fae4e5dSmrg# Result will be available in $func_to_host_file_result.
16526fae4e5dSmrg
16536fae4e5dSmrg
16546fae4e5dSmrg# func_to_host_file ARG
16556fae4e5dSmrg# Converts the file name ARG from $build format to $host format. Return result
16566fae4e5dSmrg# in func_to_host_file_result.
16576fae4e5dSmrgfunc_to_host_file ()
16586fae4e5dSmrg{
16596fae4e5dSmrg  $opt_debug
16606fae4e5dSmrg  $to_host_file_cmd "$1"
16616fae4e5dSmrg}
16626fae4e5dSmrg# end func_to_host_file
16636fae4e5dSmrg
16646fae4e5dSmrg
16656fae4e5dSmrg# func_to_tool_file ARG LAZY
16666fae4e5dSmrg# converts the file name ARG from $build format to toolchain format. Return
16676fae4e5dSmrg# result in func_to_tool_file_result.  If the conversion in use is listed
16686fae4e5dSmrg# in (the comma separated) LAZY, no conversion takes place.
16696fae4e5dSmrgfunc_to_tool_file ()
16706fae4e5dSmrg{
16716fae4e5dSmrg  $opt_debug
16726fae4e5dSmrg  case ,$2, in
16736fae4e5dSmrg    *,"$to_tool_file_cmd",*)
16746fae4e5dSmrg      func_to_tool_file_result=$1
16756fae4e5dSmrg      ;;
16766fae4e5dSmrg    *)
16776fae4e5dSmrg      $to_tool_file_cmd "$1"
16786fae4e5dSmrg      func_to_tool_file_result=$func_to_host_file_result
16796fae4e5dSmrg      ;;
16806fae4e5dSmrg  esac
16816fae4e5dSmrg}
16826fae4e5dSmrg# end func_to_tool_file
16836fae4e5dSmrg
16846fae4e5dSmrg
16856fae4e5dSmrg# func_convert_file_noop ARG
16866fae4e5dSmrg# Copy ARG to func_to_host_file_result.
16876fae4e5dSmrgfunc_convert_file_noop ()
16886fae4e5dSmrg{
16896fae4e5dSmrg  func_to_host_file_result="$1"
16906fae4e5dSmrg}
16916fae4e5dSmrg# end func_convert_file_noop
16926fae4e5dSmrg
16936fae4e5dSmrg
16946fae4e5dSmrg# func_convert_file_msys_to_w32 ARG
16956fae4e5dSmrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic
16966fae4e5dSmrg# conversion to w32 is not available inside the cwrapper.  Returns result in
16976fae4e5dSmrg# func_to_host_file_result.
16986fae4e5dSmrgfunc_convert_file_msys_to_w32 ()
16996fae4e5dSmrg{
17006fae4e5dSmrg  $opt_debug
17016fae4e5dSmrg  func_to_host_file_result="$1"
17026fae4e5dSmrg  if test -n "$1"; then
17036fae4e5dSmrg    func_convert_core_msys_to_w32 "$1"
17046fae4e5dSmrg    func_to_host_file_result="$func_convert_core_msys_to_w32_result"
17056fae4e5dSmrg  fi
17066fae4e5dSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
17076fae4e5dSmrg}
17086fae4e5dSmrg# end func_convert_file_msys_to_w32
17096fae4e5dSmrg
17106fae4e5dSmrg
17116fae4e5dSmrg# func_convert_file_cygwin_to_w32 ARG
17126fae4e5dSmrg# Convert file name ARG from Cygwin to w32 format.  Returns result in
17136fae4e5dSmrg# func_to_host_file_result.
17146fae4e5dSmrgfunc_convert_file_cygwin_to_w32 ()
17156fae4e5dSmrg{
17166fae4e5dSmrg  $opt_debug
17176fae4e5dSmrg  func_to_host_file_result="$1"
17186fae4e5dSmrg  if test -n "$1"; then
17196fae4e5dSmrg    # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
17206fae4e5dSmrg    # LT_CYGPATH in this case.
17216fae4e5dSmrg    func_to_host_file_result=`cygpath -m "$1"`
17226fae4e5dSmrg  fi
17236fae4e5dSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
17246fae4e5dSmrg}
17256fae4e5dSmrg# end func_convert_file_cygwin_to_w32
17266fae4e5dSmrg
17276fae4e5dSmrg
17286fae4e5dSmrg# func_convert_file_nix_to_w32 ARG
17296fae4e5dSmrg# Convert file name ARG from *nix to w32 format.  Requires a wine environment
17306fae4e5dSmrg# and a working winepath. Returns result in func_to_host_file_result.
17316fae4e5dSmrgfunc_convert_file_nix_to_w32 ()
17326fae4e5dSmrg{
17336fae4e5dSmrg  $opt_debug
17346fae4e5dSmrg  func_to_host_file_result="$1"
17356fae4e5dSmrg  if test -n "$1"; then
17366fae4e5dSmrg    func_convert_core_file_wine_to_w32 "$1"
17376fae4e5dSmrg    func_to_host_file_result="$func_convert_core_file_wine_to_w32_result"
17386fae4e5dSmrg  fi
17396fae4e5dSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
17406fae4e5dSmrg}
17416fae4e5dSmrg# end func_convert_file_nix_to_w32
17426fae4e5dSmrg
17436fae4e5dSmrg
17446fae4e5dSmrg# func_convert_file_msys_to_cygwin ARG
17456fae4e5dSmrg# Convert file name ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
17466fae4e5dSmrg# Returns result in func_to_host_file_result.
17476fae4e5dSmrgfunc_convert_file_msys_to_cygwin ()
17486fae4e5dSmrg{
17496fae4e5dSmrg  $opt_debug
17506fae4e5dSmrg  func_to_host_file_result="$1"
17516fae4e5dSmrg  if test -n "$1"; then
17526fae4e5dSmrg    func_convert_core_msys_to_w32 "$1"
17536fae4e5dSmrg    func_cygpath -u "$func_convert_core_msys_to_w32_result"
17546fae4e5dSmrg    func_to_host_file_result="$func_cygpath_result"
17556fae4e5dSmrg  fi
17566fae4e5dSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
17576fae4e5dSmrg}
17586fae4e5dSmrg# end func_convert_file_msys_to_cygwin
17596fae4e5dSmrg
17606fae4e5dSmrg
17616fae4e5dSmrg# func_convert_file_nix_to_cygwin ARG
17626fae4e5dSmrg# Convert file name ARG from *nix to Cygwin format.  Requires Cygwin installed
17636fae4e5dSmrg# in a wine environment, working winepath, and LT_CYGPATH set.  Returns result
17646fae4e5dSmrg# in func_to_host_file_result.
17656fae4e5dSmrgfunc_convert_file_nix_to_cygwin ()
17666fae4e5dSmrg{
17676fae4e5dSmrg  $opt_debug
17686fae4e5dSmrg  func_to_host_file_result="$1"
17696fae4e5dSmrg  if test -n "$1"; then
17706fae4e5dSmrg    # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
17716fae4e5dSmrg    func_convert_core_file_wine_to_w32 "$1"
17726fae4e5dSmrg    func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
17736fae4e5dSmrg    func_to_host_file_result="$func_cygpath_result"
17746fae4e5dSmrg  fi
17756fae4e5dSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
17766fae4e5dSmrg}
17776fae4e5dSmrg# end func_convert_file_nix_to_cygwin
17786fae4e5dSmrg
17796fae4e5dSmrg
17806fae4e5dSmrg#############################################
17816fae4e5dSmrg# $build to $host PATH CONVERSION FUNCTIONS #
17826fae4e5dSmrg#############################################
17836fae4e5dSmrg# invoked via `$to_host_path_cmd ARG'
17846fae4e5dSmrg#
17856fae4e5dSmrg# In each case, ARG is the path to be converted from $build to $host format.
17866fae4e5dSmrg# The result will be available in $func_to_host_path_result.
17876fae4e5dSmrg#
17886fae4e5dSmrg# Path separators are also converted from $build format to $host format.  If
17896fae4e5dSmrg# ARG begins or ends with a path separator character, it is preserved (but
17906fae4e5dSmrg# converted to $host format) on output.
17916fae4e5dSmrg#
17926fae4e5dSmrg# All path conversion functions are named using the following convention:
17936fae4e5dSmrg#   file name conversion function    : func_convert_file_X_to_Y ()
17946fae4e5dSmrg#   path conversion function         : func_convert_path_X_to_Y ()
17956fae4e5dSmrg# where, for any given $build/$host combination the 'X_to_Y' value is the
17966fae4e5dSmrg# same.  If conversion functions are added for new $build/$host combinations,
17976fae4e5dSmrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd
17986fae4e5dSmrg# will break.
17996fae4e5dSmrg
18006fae4e5dSmrg
18016fae4e5dSmrg# func_init_to_host_path_cmd
18026fae4e5dSmrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the
18036fae4e5dSmrg# appropriate value, based on the value of $to_host_file_cmd.
18046fae4e5dSmrgto_host_path_cmd=
18056fae4e5dSmrgfunc_init_to_host_path_cmd ()
18066fae4e5dSmrg{
18076fae4e5dSmrg  $opt_debug
18086fae4e5dSmrg  if test -z "$to_host_path_cmd"; then
18096fae4e5dSmrg    func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
18106fae4e5dSmrg    to_host_path_cmd="func_convert_path_${func_stripname_result}"
18116fae4e5dSmrg  fi
18126fae4e5dSmrg}
18136fae4e5dSmrg
18146fae4e5dSmrg
18156fae4e5dSmrg# func_to_host_path ARG
18166fae4e5dSmrg# Converts the path ARG from $build format to $host format. Return result
18176fae4e5dSmrg# in func_to_host_path_result.
18186fae4e5dSmrgfunc_to_host_path ()
18196fae4e5dSmrg{
18206fae4e5dSmrg  $opt_debug
18216fae4e5dSmrg  func_init_to_host_path_cmd
18226fae4e5dSmrg  $to_host_path_cmd "$1"
18236fae4e5dSmrg}
18246fae4e5dSmrg# end func_to_host_path
18256fae4e5dSmrg
18266fae4e5dSmrg
18276fae4e5dSmrg# func_convert_path_noop ARG
18286fae4e5dSmrg# Copy ARG to func_to_host_path_result.
18296fae4e5dSmrgfunc_convert_path_noop ()
18306fae4e5dSmrg{
18316fae4e5dSmrg  func_to_host_path_result="$1"
18326fae4e5dSmrg}
18336fae4e5dSmrg# end func_convert_path_noop
18346fae4e5dSmrg
18356fae4e5dSmrg
18366fae4e5dSmrg# func_convert_path_msys_to_w32 ARG
18376fae4e5dSmrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic
18386fae4e5dSmrg# conversion to w32 is not available inside the cwrapper.  Returns result in
18396fae4e5dSmrg# func_to_host_path_result.
18406fae4e5dSmrgfunc_convert_path_msys_to_w32 ()
18416fae4e5dSmrg{
18426fae4e5dSmrg  $opt_debug
18436fae4e5dSmrg  func_to_host_path_result="$1"
18446fae4e5dSmrg  if test -n "$1"; then
18456fae4e5dSmrg    # Remove leading and trailing path separator characters from ARG.  MSYS
18466fae4e5dSmrg    # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
18476fae4e5dSmrg    # and winepath ignores them completely.
18486fae4e5dSmrg    func_stripname : : "$1"
18496fae4e5dSmrg    func_to_host_path_tmp1=$func_stripname_result
18506fae4e5dSmrg    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
18516fae4e5dSmrg    func_to_host_path_result="$func_convert_core_msys_to_w32_result"
18526fae4e5dSmrg    func_convert_path_check : ";" \
18536fae4e5dSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
18546fae4e5dSmrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
18556fae4e5dSmrg  fi
18566fae4e5dSmrg}
18576fae4e5dSmrg# end func_convert_path_msys_to_w32
18586fae4e5dSmrg
18596fae4e5dSmrg
18606fae4e5dSmrg# func_convert_path_cygwin_to_w32 ARG
18616fae4e5dSmrg# Convert path ARG from Cygwin to w32 format.  Returns result in
18626fae4e5dSmrg# func_to_host_file_result.
18636fae4e5dSmrgfunc_convert_path_cygwin_to_w32 ()
18646fae4e5dSmrg{
18656fae4e5dSmrg  $opt_debug
18666fae4e5dSmrg  func_to_host_path_result="$1"
18676fae4e5dSmrg  if test -n "$1"; then
18686fae4e5dSmrg    # See func_convert_path_msys_to_w32:
18696fae4e5dSmrg    func_stripname : : "$1"
18706fae4e5dSmrg    func_to_host_path_tmp1=$func_stripname_result
18716fae4e5dSmrg    func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"`
18726fae4e5dSmrg    func_convert_path_check : ";" \
18736fae4e5dSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
18746fae4e5dSmrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
18756fae4e5dSmrg  fi
18766fae4e5dSmrg}
18776fae4e5dSmrg# end func_convert_path_cygwin_to_w32
18786fae4e5dSmrg
18796fae4e5dSmrg
18806fae4e5dSmrg# func_convert_path_nix_to_w32 ARG
18816fae4e5dSmrg# Convert path ARG from *nix to w32 format.  Requires a wine environment and
18826fae4e5dSmrg# a working winepath.  Returns result in func_to_host_file_result.
18836fae4e5dSmrgfunc_convert_path_nix_to_w32 ()
18846fae4e5dSmrg{
18856fae4e5dSmrg  $opt_debug
18866fae4e5dSmrg  func_to_host_path_result="$1"
18876fae4e5dSmrg  if test -n "$1"; then
18886fae4e5dSmrg    # See func_convert_path_msys_to_w32:
18896fae4e5dSmrg    func_stripname : : "$1"
18906fae4e5dSmrg    func_to_host_path_tmp1=$func_stripname_result
18916fae4e5dSmrg    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
18926fae4e5dSmrg    func_to_host_path_result="$func_convert_core_path_wine_to_w32_result"
18936fae4e5dSmrg    func_convert_path_check : ";" \
18946fae4e5dSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
18956fae4e5dSmrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
18966fae4e5dSmrg  fi
18976fae4e5dSmrg}
18986fae4e5dSmrg# end func_convert_path_nix_to_w32
18996fae4e5dSmrg
19006fae4e5dSmrg
19016fae4e5dSmrg# func_convert_path_msys_to_cygwin ARG
19026fae4e5dSmrg# Convert path ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
19036fae4e5dSmrg# Returns result in func_to_host_file_result.
19046fae4e5dSmrgfunc_convert_path_msys_to_cygwin ()
19056fae4e5dSmrg{
19066fae4e5dSmrg  $opt_debug
19076fae4e5dSmrg  func_to_host_path_result="$1"
19086fae4e5dSmrg  if test -n "$1"; then
19096fae4e5dSmrg    # See func_convert_path_msys_to_w32:
19106fae4e5dSmrg    func_stripname : : "$1"
19116fae4e5dSmrg    func_to_host_path_tmp1=$func_stripname_result
19126fae4e5dSmrg    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
19136fae4e5dSmrg    func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
19146fae4e5dSmrg    func_to_host_path_result="$func_cygpath_result"
19156fae4e5dSmrg    func_convert_path_check : : \
19166fae4e5dSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
19176fae4e5dSmrg    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
19186fae4e5dSmrg  fi
19196fae4e5dSmrg}
19206fae4e5dSmrg# end func_convert_path_msys_to_cygwin
19216fae4e5dSmrg
19226fae4e5dSmrg
19236fae4e5dSmrg# func_convert_path_nix_to_cygwin ARG
19246fae4e5dSmrg# Convert path ARG from *nix to Cygwin format.  Requires Cygwin installed in a
19256fae4e5dSmrg# a wine environment, working winepath, and LT_CYGPATH set.  Returns result in
19266fae4e5dSmrg# func_to_host_file_result.
19276fae4e5dSmrgfunc_convert_path_nix_to_cygwin ()
19286fae4e5dSmrg{
19296fae4e5dSmrg  $opt_debug
19306fae4e5dSmrg  func_to_host_path_result="$1"
19316fae4e5dSmrg  if test -n "$1"; then
19326fae4e5dSmrg    # Remove leading and trailing path separator characters from
19336fae4e5dSmrg    # ARG. msys behavior is inconsistent here, cygpath turns them
19346fae4e5dSmrg    # into '.;' and ';.', and winepath ignores them completely.
19356fae4e5dSmrg    func_stripname : : "$1"
19366fae4e5dSmrg    func_to_host_path_tmp1=$func_stripname_result
19376fae4e5dSmrg    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
19386fae4e5dSmrg    func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
19396fae4e5dSmrg    func_to_host_path_result="$func_cygpath_result"
19406fae4e5dSmrg    func_convert_path_check : : \
19416fae4e5dSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
19426fae4e5dSmrg    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
19436fae4e5dSmrg  fi
19446fae4e5dSmrg}
19456fae4e5dSmrg# end func_convert_path_nix_to_cygwin
19466fae4e5dSmrg
19476fae4e5dSmrg
19489c9ff80cSmrg# func_mode_compile arg...
19499c9ff80cSmrgfunc_mode_compile ()
19509c9ff80cSmrg{
19519c9ff80cSmrg    $opt_debug
19529c9ff80cSmrg    # Get the compilation command and the source file.
19539c9ff80cSmrg    base_compile=
19549c9ff80cSmrg    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
19559c9ff80cSmrg    suppress_opt=yes
19569c9ff80cSmrg    suppress_output=
19579c9ff80cSmrg    arg_mode=normal
19589c9ff80cSmrg    libobj=
19599c9ff80cSmrg    later=
19609c9ff80cSmrg    pie_flag=
19619c9ff80cSmrg
19629c9ff80cSmrg    for arg
19639c9ff80cSmrg    do
19649c9ff80cSmrg      case $arg_mode in
19659c9ff80cSmrg      arg  )
19669c9ff80cSmrg	# do not "continue".  Instead, add this to base_compile
19679c9ff80cSmrg	lastarg="$arg"
19689c9ff80cSmrg	arg_mode=normal
19699c9ff80cSmrg	;;
19709c9ff80cSmrg
19719c9ff80cSmrg      target )
19729c9ff80cSmrg	libobj="$arg"
19739c9ff80cSmrg	arg_mode=normal
19749c9ff80cSmrg	continue
19759c9ff80cSmrg	;;
19769c9ff80cSmrg
19779c9ff80cSmrg      normal )
19789c9ff80cSmrg	# Accept any command-line options.
19799c9ff80cSmrg	case $arg in
19809c9ff80cSmrg	-o)
19819c9ff80cSmrg	  test -n "$libobj" && \
19829c9ff80cSmrg	    func_fatal_error "you cannot specify \`-o' more than once"
19839c9ff80cSmrg	  arg_mode=target
19849c9ff80cSmrg	  continue
19859c9ff80cSmrg	  ;;
19869c9ff80cSmrg
19879c9ff80cSmrg	-pie | -fpie | -fPIE)
19886fae4e5dSmrg          func_append pie_flag " $arg"
19899c9ff80cSmrg	  continue
19909c9ff80cSmrg	  ;;
19919c9ff80cSmrg
19929c9ff80cSmrg	-shared | -static | -prefer-pic | -prefer-non-pic)
19936fae4e5dSmrg	  func_append later " $arg"
19949c9ff80cSmrg	  continue
19959c9ff80cSmrg	  ;;
19969c9ff80cSmrg
19979c9ff80cSmrg	-no-suppress)
19981f0ac6a5Smrg	  suppress_opt=no
19991f0ac6a5Smrg	  continue
20001f0ac6a5Smrg	  ;;
20011f0ac6a5Smrg
20021f0ac6a5Smrg	-Xcompiler)
20031f0ac6a5Smrg	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
20041f0ac6a5Smrg	  continue      #  The current "srcfile" will either be retained or
20051f0ac6a5Smrg	  ;;            #  replaced later.  I would guess that would be a bug.
20061f0ac6a5Smrg
20071f0ac6a5Smrg	-Wc,*)
20089c9ff80cSmrg	  func_stripname '-Wc,' '' "$arg"
20099c9ff80cSmrg	  args=$func_stripname_result
20101f0ac6a5Smrg	  lastarg=
20111f0ac6a5Smrg	  save_ifs="$IFS"; IFS=','
20129c9ff80cSmrg	  for arg in $args; do
20131f0ac6a5Smrg	    IFS="$save_ifs"
20146fae4e5dSmrg	    func_append_quoted lastarg "$arg"
20151f0ac6a5Smrg	  done
20161f0ac6a5Smrg	  IFS="$save_ifs"
20179c9ff80cSmrg	  func_stripname ' ' '' "$lastarg"
20189c9ff80cSmrg	  lastarg=$func_stripname_result
20191f0ac6a5Smrg
20201f0ac6a5Smrg	  # Add the arguments to base_compile.
20216fae4e5dSmrg	  func_append base_compile " $lastarg"
20221f0ac6a5Smrg	  continue
20231f0ac6a5Smrg	  ;;
20241f0ac6a5Smrg
20259c9ff80cSmrg	*)
20261f0ac6a5Smrg	  # Accept the current argument as the source file.
20271f0ac6a5Smrg	  # The previous "srcfile" becomes the current argument.
20281f0ac6a5Smrg	  #
20291f0ac6a5Smrg	  lastarg="$srcfile"
20301f0ac6a5Smrg	  srcfile="$arg"
20311f0ac6a5Smrg	  ;;
20321f0ac6a5Smrg	esac  #  case $arg
20331f0ac6a5Smrg	;;
20341f0ac6a5Smrg      esac    #  case $arg_mode
20351f0ac6a5Smrg
20361f0ac6a5Smrg      # Aesthetically quote the previous argument.
20376fae4e5dSmrg      func_append_quoted base_compile "$lastarg"
20381f0ac6a5Smrg    done # for arg
20391f0ac6a5Smrg
20401f0ac6a5Smrg    case $arg_mode in
20411f0ac6a5Smrg    arg)
20429c9ff80cSmrg      func_fatal_error "you must specify an argument for -Xcompile"
20431f0ac6a5Smrg      ;;
20441f0ac6a5Smrg    target)
20459c9ff80cSmrg      func_fatal_error "you must specify a target with \`-o'"
20461f0ac6a5Smrg      ;;
20471f0ac6a5Smrg    *)
20481f0ac6a5Smrg      # Get the name of the library object.
20499c9ff80cSmrg      test -z "$libobj" && {
20509c9ff80cSmrg	func_basename "$srcfile"
20519c9ff80cSmrg	libobj="$func_basename_result"
20529c9ff80cSmrg      }
20531f0ac6a5Smrg      ;;
20541f0ac6a5Smrg    esac
20551f0ac6a5Smrg
20561f0ac6a5Smrg    # Recognize several different file suffixes.
20571f0ac6a5Smrg    # If the user specifies -o file.o, it is replaced with file.lo
20581f0ac6a5Smrg    case $libobj in
20599c9ff80cSmrg    *.[cCFSifmso] | \
20609c9ff80cSmrg    *.ada | *.adb | *.ads | *.asm | \
20619c9ff80cSmrg    *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
20626fae4e5dSmrg    *.[fF][09]? | *.for | *.java | *.obj | *.sx | *.cu | *.cup)
20639c9ff80cSmrg      func_xform "$libobj"
20649c9ff80cSmrg      libobj=$func_xform_result
20659c9ff80cSmrg      ;;
20661f0ac6a5Smrg    esac
20671f0ac6a5Smrg
20681f0ac6a5Smrg    case $libobj in
20699c9ff80cSmrg    *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
20701f0ac6a5Smrg    *)
20719c9ff80cSmrg      func_fatal_error "cannot determine name of library object from \`$libobj'"
20721f0ac6a5Smrg      ;;
20731f0ac6a5Smrg    esac
20741f0ac6a5Smrg
20751f0ac6a5Smrg    func_infer_tag $base_compile
20761f0ac6a5Smrg
20771f0ac6a5Smrg    for arg in $later; do
20781f0ac6a5Smrg      case $arg in
20799c9ff80cSmrg      -shared)
20809c9ff80cSmrg	test "$build_libtool_libs" != yes && \
20819c9ff80cSmrg	  func_fatal_configuration "can not build a shared library"
20829c9ff80cSmrg	build_old_libs=no
20839c9ff80cSmrg	continue
20849c9ff80cSmrg	;;
20859c9ff80cSmrg
20861f0ac6a5Smrg      -static)
20879c9ff80cSmrg	build_libtool_libs=no
20881f0ac6a5Smrg	build_old_libs=yes
20891f0ac6a5Smrg	continue
20901f0ac6a5Smrg	;;
20911f0ac6a5Smrg
20921f0ac6a5Smrg      -prefer-pic)
20931f0ac6a5Smrg	pic_mode=yes
20941f0ac6a5Smrg	continue
20951f0ac6a5Smrg	;;
20961f0ac6a5Smrg
20971f0ac6a5Smrg      -prefer-non-pic)
20981f0ac6a5Smrg	pic_mode=no
20991f0ac6a5Smrg	continue
21001f0ac6a5Smrg	;;
21011f0ac6a5Smrg      esac
21021f0ac6a5Smrg    done
21031f0ac6a5Smrg
21049c9ff80cSmrg    func_quote_for_eval "$libobj"
21059c9ff80cSmrg    test "X$libobj" != "X$func_quote_for_eval_result" \
21069c9ff80cSmrg      && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'	 &()|`$[]' \
21079c9ff80cSmrg      && func_warning "libobj name \`$libobj' may not contain shell special characters."
21089c9ff80cSmrg    func_dirname_and_basename "$obj" "/" ""
21099c9ff80cSmrg    objname="$func_basename_result"
21109c9ff80cSmrg    xdir="$func_dirname_result"
21111f0ac6a5Smrg    lobj=${xdir}$objdir/$objname
21121f0ac6a5Smrg
21139c9ff80cSmrg    test -z "$base_compile" && \
21149c9ff80cSmrg      func_fatal_help "you must specify a compilation command"
21151f0ac6a5Smrg
21161f0ac6a5Smrg    # Delete any leftover library objects.
21171f0ac6a5Smrg    if test "$build_old_libs" = yes; then
21181f0ac6a5Smrg      removelist="$obj $lobj $libobj ${libobj}T"
21191f0ac6a5Smrg    else
21201f0ac6a5Smrg      removelist="$lobj $libobj ${libobj}T"
21211f0ac6a5Smrg    fi
21221f0ac6a5Smrg
21231f0ac6a5Smrg    # On Cygwin there's no "real" PIC flag so we must build both object types
21241f0ac6a5Smrg    case $host_os in
21259c9ff80cSmrg    cygwin* | mingw* | pw32* | os2* | cegcc*)
21261f0ac6a5Smrg      pic_mode=default
21271f0ac6a5Smrg      ;;
21281f0ac6a5Smrg    esac
21291f0ac6a5Smrg    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
21301f0ac6a5Smrg      # non-PIC code in shared libraries is not supported
21311f0ac6a5Smrg      pic_mode=default
21321f0ac6a5Smrg    fi
21331f0ac6a5Smrg
21341f0ac6a5Smrg    # Calculate the filename of the output object if compiler does
21351f0ac6a5Smrg    # not support -o with -c
21361f0ac6a5Smrg    if test "$compiler_c_o" = no; then
21376fae4e5dSmrg      output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext}
21381f0ac6a5Smrg      lockfile="$output_obj.lock"
21391f0ac6a5Smrg    else
21401f0ac6a5Smrg      output_obj=
21411f0ac6a5Smrg      need_locks=no
21421f0ac6a5Smrg      lockfile=
21431f0ac6a5Smrg    fi
21441f0ac6a5Smrg
21451f0ac6a5Smrg    # Lock this critical section if it is needed
21461f0ac6a5Smrg    # We use this script file to make the link, it avoids creating a new file
21471f0ac6a5Smrg    if test "$need_locks" = yes; then
21489c9ff80cSmrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
21499c9ff80cSmrg	func_echo "Waiting for $lockfile to be removed"
21501f0ac6a5Smrg	sleep 2
21511f0ac6a5Smrg      done
21521f0ac6a5Smrg    elif test "$need_locks" = warn; then
21531f0ac6a5Smrg      if test -f "$lockfile"; then
21549c9ff80cSmrg	$ECHO "\
21551f0ac6a5Smrg*** ERROR, $lockfile exists and contains:
21561f0ac6a5Smrg`cat $lockfile 2>/dev/null`
21571f0ac6a5Smrg
21581f0ac6a5SmrgThis indicates that another process is trying to use the same
21591f0ac6a5Smrgtemporary object file, and libtool could not work around it because
21601f0ac6a5Smrgyour compiler does not support \`-c' and \`-o' together.  If you
21611f0ac6a5Smrgrepeat this compilation, it may succeed, by chance, but you had better
21621f0ac6a5Smrgavoid parallel builds (make -j) in this platform, or get a better
21631f0ac6a5Smrgcompiler."
21641f0ac6a5Smrg
21659c9ff80cSmrg	$opt_dry_run || $RM $removelist
21661f0ac6a5Smrg	exit $EXIT_FAILURE
21671f0ac6a5Smrg      fi
21686fae4e5dSmrg      func_append removelist " $output_obj"
21699c9ff80cSmrg      $ECHO "$srcfile" > "$lockfile"
21701f0ac6a5Smrg    fi
21711f0ac6a5Smrg
21729c9ff80cSmrg    $opt_dry_run || $RM $removelist
21736fae4e5dSmrg    func_append removelist " $lockfile"
21749c9ff80cSmrg    trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
21759c9ff80cSmrg
21766fae4e5dSmrg    func_to_tool_file "$srcfile" func_convert_file_msys_to_w32
21776fae4e5dSmrg    srcfile=$func_to_tool_file_result
21789c9ff80cSmrg    func_quote_for_eval "$srcfile"
21799c9ff80cSmrg    qsrcfile=$func_quote_for_eval_result
21801f0ac6a5Smrg
21811f0ac6a5Smrg    # Only build a PIC object if we are building libtool libraries.
21821f0ac6a5Smrg    if test "$build_libtool_libs" = yes; then
21831f0ac6a5Smrg      # Without this assignment, base_compile gets emptied.
21841f0ac6a5Smrg      fbsd_hideous_sh_bug=$base_compile
21851f0ac6a5Smrg
21861f0ac6a5Smrg      if test "$pic_mode" != no; then
21871f0ac6a5Smrg	command="$base_compile $qsrcfile $pic_flag"
21881f0ac6a5Smrg      else
21891f0ac6a5Smrg	# Don't build PIC code
21901f0ac6a5Smrg	command="$base_compile $qsrcfile"
21911f0ac6a5Smrg      fi
21921f0ac6a5Smrg
21939c9ff80cSmrg      func_mkdir_p "$xdir$objdir"
21941f0ac6a5Smrg
21951f0ac6a5Smrg      if test -z "$output_obj"; then
21961f0ac6a5Smrg	# Place PIC objects in $objdir
21976fae4e5dSmrg	func_append command " -o $lobj"
21981f0ac6a5Smrg      fi
21991f0ac6a5Smrg
22009c9ff80cSmrg      func_show_eval_locale "$command"	\
22019c9ff80cSmrg          'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
22021f0ac6a5Smrg
22031f0ac6a5Smrg      if test "$need_locks" = warn &&
22041f0ac6a5Smrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
22059c9ff80cSmrg	$ECHO "\
22061f0ac6a5Smrg*** ERROR, $lockfile contains:
22071f0ac6a5Smrg`cat $lockfile 2>/dev/null`
22081f0ac6a5Smrg
22091f0ac6a5Smrgbut it should contain:
22101f0ac6a5Smrg$srcfile
22111f0ac6a5Smrg
22121f0ac6a5SmrgThis indicates that another process is trying to use the same
22131f0ac6a5Smrgtemporary object file, and libtool could not work around it because
22141f0ac6a5Smrgyour compiler does not support \`-c' and \`-o' together.  If you
22151f0ac6a5Smrgrepeat this compilation, it may succeed, by chance, but you had better
22161f0ac6a5Smrgavoid parallel builds (make -j) in this platform, or get a better
22171f0ac6a5Smrgcompiler."
22181f0ac6a5Smrg
22199c9ff80cSmrg	$opt_dry_run || $RM $removelist
22201f0ac6a5Smrg	exit $EXIT_FAILURE
22211f0ac6a5Smrg      fi
22221f0ac6a5Smrg
22231f0ac6a5Smrg      # Just move the object if needed, then go on to compile the next one
22241f0ac6a5Smrg      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
22259c9ff80cSmrg	func_show_eval '$MV "$output_obj" "$lobj"' \
22269c9ff80cSmrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
22271f0ac6a5Smrg      fi
22281f0ac6a5Smrg
22291f0ac6a5Smrg      # Allow error messages only from the first compilation.
22301f0ac6a5Smrg      if test "$suppress_opt" = yes; then
22319c9ff80cSmrg	suppress_output=' >/dev/null 2>&1'
22321f0ac6a5Smrg      fi
22331f0ac6a5Smrg    fi
22341f0ac6a5Smrg
22351f0ac6a5Smrg    # Only build a position-dependent object if we build old libraries.
22361f0ac6a5Smrg    if test "$build_old_libs" = yes; then
22371f0ac6a5Smrg      if test "$pic_mode" != yes; then
22381f0ac6a5Smrg	# Don't build PIC code
22399c9ff80cSmrg	command="$base_compile $qsrcfile$pie_flag"
22401f0ac6a5Smrg      else
22411f0ac6a5Smrg	command="$base_compile $qsrcfile $pic_flag"
22421f0ac6a5Smrg      fi
22431f0ac6a5Smrg      if test "$compiler_c_o" = yes; then
22446fae4e5dSmrg	func_append command " -o $obj"
22451f0ac6a5Smrg      fi
22461f0ac6a5Smrg
22471f0ac6a5Smrg      # Suppress compiler output if we already did a PIC compilation.
22486fae4e5dSmrg      func_append command "$suppress_output"
22499c9ff80cSmrg      func_show_eval_locale "$command" \
22509c9ff80cSmrg        '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
22511f0ac6a5Smrg
22521f0ac6a5Smrg      if test "$need_locks" = warn &&
22531f0ac6a5Smrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
22549c9ff80cSmrg	$ECHO "\
22551f0ac6a5Smrg*** ERROR, $lockfile contains:
22561f0ac6a5Smrg`cat $lockfile 2>/dev/null`
22571f0ac6a5Smrg
22581f0ac6a5Smrgbut it should contain:
22591f0ac6a5Smrg$srcfile
22601f0ac6a5Smrg
22611f0ac6a5SmrgThis indicates that another process is trying to use the same
22621f0ac6a5Smrgtemporary object file, and libtool could not work around it because
22631f0ac6a5Smrgyour compiler does not support \`-c' and \`-o' together.  If you
22641f0ac6a5Smrgrepeat this compilation, it may succeed, by chance, but you had better
22651f0ac6a5Smrgavoid parallel builds (make -j) in this platform, or get a better
22661f0ac6a5Smrgcompiler."
22671f0ac6a5Smrg
22689c9ff80cSmrg	$opt_dry_run || $RM $removelist
22691f0ac6a5Smrg	exit $EXIT_FAILURE
22701f0ac6a5Smrg      fi
22711f0ac6a5Smrg
22721f0ac6a5Smrg      # Just move the object if needed
22731f0ac6a5Smrg      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
22749c9ff80cSmrg	func_show_eval '$MV "$output_obj" "$obj"' \
22759c9ff80cSmrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
22761f0ac6a5Smrg      fi
22771f0ac6a5Smrg    fi
22781f0ac6a5Smrg
22799c9ff80cSmrg    $opt_dry_run || {
22809c9ff80cSmrg      func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
22811f0ac6a5Smrg
22829c9ff80cSmrg      # Unlock the critical section if it was locked
22839c9ff80cSmrg      if test "$need_locks" != no; then
22849c9ff80cSmrg	removelist=$lockfile
22859c9ff80cSmrg        $RM "$lockfile"
22869c9ff80cSmrg      fi
22879c9ff80cSmrg    }
22881f0ac6a5Smrg
22891f0ac6a5Smrg    exit $EXIT_SUCCESS
22909c9ff80cSmrg}
22911f0ac6a5Smrg
22929c9ff80cSmrg$opt_help || {
22936fae4e5dSmrg  test "$opt_mode" = compile && func_mode_compile ${1+"$@"}
22949c9ff80cSmrg}
22951f0ac6a5Smrg
22969c9ff80cSmrgfunc_mode_help ()
22979c9ff80cSmrg{
22989c9ff80cSmrg    # We need to display help for each of the modes.
22996fae4e5dSmrg    case $opt_mode in
23009c9ff80cSmrg      "")
23019c9ff80cSmrg        # Generic help is extracted from the usage comments
23029c9ff80cSmrg        # at the start of this file.
23039c9ff80cSmrg        func_help
23049c9ff80cSmrg        ;;
23051f0ac6a5Smrg
23069c9ff80cSmrg      clean)
23079c9ff80cSmrg        $ECHO \
23089c9ff80cSmrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
23091f0ac6a5Smrg
23109c9ff80cSmrgRemove files from the build directory.
23111f0ac6a5Smrg
23129c9ff80cSmrgRM is the name of the program to use to delete files associated with each FILE
23139c9ff80cSmrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
23149c9ff80cSmrgto RM.
23151f0ac6a5Smrg
23169c9ff80cSmrgIf FILE is a libtool library, object or program, all the files associated
23179c9ff80cSmrgwith it are deleted. Otherwise, only FILE itself is deleted using RM."
23189c9ff80cSmrg        ;;
23191f0ac6a5Smrg
23209c9ff80cSmrg      compile)
23219c9ff80cSmrg      $ECHO \
23229c9ff80cSmrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
23231f0ac6a5Smrg
23249c9ff80cSmrgCompile a source file into a libtool library object.
23251f0ac6a5Smrg
23269c9ff80cSmrgThis mode accepts the following additional options:
23271f0ac6a5Smrg
23289c9ff80cSmrg  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
23299c9ff80cSmrg  -no-suppress      do not suppress compiler output for multiple passes
23306fae4e5dSmrg  -prefer-pic       try to build PIC objects only
23316fae4e5dSmrg  -prefer-non-pic   try to build non-PIC objects only
23329c9ff80cSmrg  -shared           do not build a \`.o' file suitable for static linking
23339c9ff80cSmrg  -static           only build a \`.o' file suitable for static linking
23346fae4e5dSmrg  -Wc,FLAG          pass FLAG directly to the compiler
23351f0ac6a5Smrg
23369c9ff80cSmrgCOMPILE-COMMAND is a command to be used in creating a \`standard' object file
23379c9ff80cSmrgfrom the given SOURCEFILE.
23381f0ac6a5Smrg
23399c9ff80cSmrgThe output file name is determined by removing the directory component from
23409c9ff80cSmrgSOURCEFILE, then substituting the C source code suffix \`.c' with the
23419c9ff80cSmrglibrary object suffix, \`.lo'."
23429c9ff80cSmrg        ;;
23431f0ac6a5Smrg
23449c9ff80cSmrg      execute)
23459c9ff80cSmrg        $ECHO \
23469c9ff80cSmrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
23471f0ac6a5Smrg
23489c9ff80cSmrgAutomatically set library path, then run a program.
23491f0ac6a5Smrg
23509c9ff80cSmrgThis mode accepts the following additional options:
23511f0ac6a5Smrg
23529c9ff80cSmrg  -dlopen FILE      add the directory containing FILE to the library path
23531f0ac6a5Smrg
23549c9ff80cSmrgThis mode sets the library path environment variable according to \`-dlopen'
23559c9ff80cSmrgflags.
23561f0ac6a5Smrg
23579c9ff80cSmrgIf any of the ARGS are libtool executable wrappers, then they are translated
23589c9ff80cSmrginto their corresponding uninstalled binary, and any of their required library
23599c9ff80cSmrgdirectories are added to the library path.
23601f0ac6a5Smrg
23619c9ff80cSmrgThen, COMMAND is executed, with ARGS as arguments."
23629c9ff80cSmrg        ;;
23631f0ac6a5Smrg
23649c9ff80cSmrg      finish)
23659c9ff80cSmrg        $ECHO \
23669c9ff80cSmrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
23671f0ac6a5Smrg
23689c9ff80cSmrgComplete the installation of libtool libraries.
23691f0ac6a5Smrg
23709c9ff80cSmrgEach LIBDIR is a directory that contains libtool libraries.
23711f0ac6a5Smrg
23729c9ff80cSmrgThe commands that this mode executes may require superuser privileges.  Use
23739c9ff80cSmrgthe \`--dry-run' option if you just want to see what would be executed."
23749c9ff80cSmrg        ;;
23751f0ac6a5Smrg
23769c9ff80cSmrg      install)
23779c9ff80cSmrg        $ECHO \
23789c9ff80cSmrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
23791f0ac6a5Smrg
23809c9ff80cSmrgInstall executables or libraries.
23811f0ac6a5Smrg
23829c9ff80cSmrgINSTALL-COMMAND is the installation command.  The first component should be
23839c9ff80cSmrgeither the \`install' or \`cp' program.
23841f0ac6a5Smrg
23859c9ff80cSmrgThe following components of INSTALL-COMMAND are treated specially:
23861f0ac6a5Smrg
23876fae4e5dSmrg  -inst-prefix-dir PREFIX-DIR  Use PREFIX-DIR as a staging area for installation
23881f0ac6a5Smrg
23899c9ff80cSmrgThe rest of the components are interpreted as arguments to that command (only
23909c9ff80cSmrgBSD-compatible install options are recognized)."
23919c9ff80cSmrg        ;;
23921f0ac6a5Smrg
23939c9ff80cSmrg      link)
23949c9ff80cSmrg        $ECHO \
23959c9ff80cSmrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
23961f0ac6a5Smrg
23979c9ff80cSmrgLink object files or libraries together to form another library, or to
23989c9ff80cSmrgcreate an executable program.
23991f0ac6a5Smrg
24009c9ff80cSmrgLINK-COMMAND is a command using the C compiler that you would use to create
24019c9ff80cSmrga program from several object files.
24021f0ac6a5Smrg
24039c9ff80cSmrgThe following components of LINK-COMMAND are treated specially:
24041f0ac6a5Smrg
24059c9ff80cSmrg  -all-static       do not do any dynamic linking at all
24069c9ff80cSmrg  -avoid-version    do not add a version suffix if possible
24076fae4e5dSmrg  -bindir BINDIR    specify path to binaries directory (for systems where
24086fae4e5dSmrg                    libraries must be found in the PATH setting at runtime)
24099c9ff80cSmrg  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
24109c9ff80cSmrg  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
24119c9ff80cSmrg  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
24129c9ff80cSmrg  -export-symbols SYMFILE
24139c9ff80cSmrg                    try to export only the symbols listed in SYMFILE
24149c9ff80cSmrg  -export-symbols-regex REGEX
24159c9ff80cSmrg                    try to export only the symbols matching REGEX
24169c9ff80cSmrg  -LLIBDIR          search LIBDIR for required installed libraries
24179c9ff80cSmrg  -lNAME            OUTPUT-FILE requires the installed library libNAME
24189c9ff80cSmrg  -module           build a library that can dlopened
24199c9ff80cSmrg  -no-fast-install  disable the fast-install mode
24209c9ff80cSmrg  -no-install       link a not-installable executable
24219c9ff80cSmrg  -no-undefined     declare that a library does not refer to external symbols
24229c9ff80cSmrg  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
24239c9ff80cSmrg  -objectlist FILE  Use a list of object files found in FILE to specify objects
24249c9ff80cSmrg  -precious-files-regex REGEX
24259c9ff80cSmrg                    don't remove output files matching REGEX
24269c9ff80cSmrg  -release RELEASE  specify package release information
24279c9ff80cSmrg  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
24289c9ff80cSmrg  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
24299c9ff80cSmrg  -shared           only do dynamic linking of libtool libraries
24309c9ff80cSmrg  -shrext SUFFIX    override the standard shared library file extension
24319c9ff80cSmrg  -static           do not do any dynamic linking of uninstalled libtool libraries
24329c9ff80cSmrg  -static-libtool-libs
24339c9ff80cSmrg                    do not do any dynamic linking of libtool libraries
24349c9ff80cSmrg  -version-info CURRENT[:REVISION[:AGE]]
24359c9ff80cSmrg                    specify library version info [each variable defaults to 0]
24369c9ff80cSmrg  -weak LIBNAME     declare that the target provides the LIBNAME interface
24376fae4e5dSmrg  -Wc,FLAG
24386fae4e5dSmrg  -Xcompiler FLAG   pass linker-specific FLAG directly to the compiler
24396fae4e5dSmrg  -Wl,FLAG
24406fae4e5dSmrg  -Xlinker FLAG     pass linker-specific FLAG directly to the linker
24416fae4e5dSmrg  -XCClinker FLAG   pass link-specific FLAG to the compiler driver (CC)
24421f0ac6a5Smrg
24439c9ff80cSmrgAll other options (arguments beginning with \`-') are ignored.
2444e5410a46Smrg
24459c9ff80cSmrgEvery other argument is treated as a filename.  Files ending in \`.la' are
24469c9ff80cSmrgtreated as uninstalled libtool libraries, other files are standard or library
24479c9ff80cSmrgobject files.
24481f0ac6a5Smrg
24499c9ff80cSmrgIf the OUTPUT-FILE ends in \`.la', then a libtool library is created,
24509c9ff80cSmrgonly library objects (\`.lo' files) may be specified, and \`-rpath' is
24519c9ff80cSmrgrequired, except when creating a convenience library.
24521f0ac6a5Smrg
24539c9ff80cSmrgIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
24549c9ff80cSmrgusing \`ar' and \`ranlib', or on Windows using \`lib'.
24551f0ac6a5Smrg
24569c9ff80cSmrgIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
24579c9ff80cSmrgis created, otherwise an executable program is created."
24581f0ac6a5Smrg        ;;
24591f0ac6a5Smrg
24609c9ff80cSmrg      uninstall)
24619c9ff80cSmrg        $ECHO \
24629c9ff80cSmrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
24631f0ac6a5Smrg
24649c9ff80cSmrgRemove libraries from an installation directory.
24651f0ac6a5Smrg
24669c9ff80cSmrgRM is the name of the program to use to delete files associated with each FILE
24679c9ff80cSmrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
24689c9ff80cSmrgto RM.
24691f0ac6a5Smrg
24709c9ff80cSmrgIf FILE is a libtool library, all the files associated with it are deleted.
24719c9ff80cSmrgOtherwise, only FILE itself is deleted using RM."
24729c9ff80cSmrg        ;;
24731f0ac6a5Smrg
24749c9ff80cSmrg      *)
24756fae4e5dSmrg        func_fatal_help "invalid operation mode \`$opt_mode'"
24769c9ff80cSmrg        ;;
24779c9ff80cSmrg    esac
24781f0ac6a5Smrg
24796fae4e5dSmrg    echo
24809c9ff80cSmrg    $ECHO "Try \`$progname --help' for more information about other modes."
24819c9ff80cSmrg}
24821f0ac6a5Smrg
24836fae4e5dSmrg# Now that we've collected a possible --mode arg, show help if necessary
24846fae4e5dSmrgif $opt_help; then
24856fae4e5dSmrg  if test "$opt_help" = :; then
24866fae4e5dSmrg    func_mode_help
24876fae4e5dSmrg  else
24886fae4e5dSmrg    {
24896fae4e5dSmrg      func_help noexit
24906fae4e5dSmrg      for opt_mode in compile link execute install finish uninstall clean; do
24916fae4e5dSmrg	func_mode_help
24926fae4e5dSmrg      done
24936fae4e5dSmrg    } | sed -n '1p; 2,$s/^Usage:/  or: /p'
24946fae4e5dSmrg    {
24956fae4e5dSmrg      func_help noexit
24966fae4e5dSmrg      for opt_mode in compile link execute install finish uninstall clean; do
24976fae4e5dSmrg	echo
24986fae4e5dSmrg	func_mode_help
24996fae4e5dSmrg      done
25006fae4e5dSmrg    } |
25016fae4e5dSmrg    sed '1d
25026fae4e5dSmrg      /^When reporting/,/^Report/{
25036fae4e5dSmrg	H
25046fae4e5dSmrg	d
25056fae4e5dSmrg      }
25066fae4e5dSmrg      $x
25076fae4e5dSmrg      /information about other modes/d
25086fae4e5dSmrg      /more detailed .*MODE/d
25096fae4e5dSmrg      s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
25106fae4e5dSmrg  fi
25116fae4e5dSmrg  exit $?
25126fae4e5dSmrgfi
25131f0ac6a5Smrg
25141f0ac6a5Smrg
25159c9ff80cSmrg# func_mode_execute arg...
25169c9ff80cSmrgfunc_mode_execute ()
25179c9ff80cSmrg{
25189c9ff80cSmrg    $opt_debug
25199c9ff80cSmrg    # The first argument is the command name.
25209c9ff80cSmrg    cmd="$nonopt"
25219c9ff80cSmrg    test -z "$cmd" && \
25229c9ff80cSmrg      func_fatal_help "you must specify a COMMAND"
25231f0ac6a5Smrg
25249c9ff80cSmrg    # Handle -dlopen flags immediately.
25256fae4e5dSmrg    for file in $opt_dlopen; do
25269c9ff80cSmrg      test -f "$file" \
25279c9ff80cSmrg	|| func_fatal_help "\`$file' is not a file"
25281f0ac6a5Smrg
25299c9ff80cSmrg      dir=
25309c9ff80cSmrg      case $file in
25319c9ff80cSmrg      *.la)
25326fae4e5dSmrg	func_resolve_sysroot "$file"
25336fae4e5dSmrg	file=$func_resolve_sysroot_result
25346fae4e5dSmrg
25359c9ff80cSmrg	# Check to see that this really is a libtool archive.
25369c9ff80cSmrg	func_lalib_unsafe_p "$file" \
25379c9ff80cSmrg	  || func_fatal_help "\`$lib' is not a valid libtool archive"
25381f0ac6a5Smrg
25399c9ff80cSmrg	# Read the libtool library.
25409c9ff80cSmrg	dlname=
25419c9ff80cSmrg	library_names=
25429c9ff80cSmrg	func_source "$file"
25431f0ac6a5Smrg
25449c9ff80cSmrg	# Skip this library if it cannot be dlopened.
25459c9ff80cSmrg	if test -z "$dlname"; then
25469c9ff80cSmrg	  # Warn if it was a shared library.
25479c9ff80cSmrg	  test -n "$library_names" && \
25489c9ff80cSmrg	    func_warning "\`$file' was not linked with \`-export-dynamic'"
25499c9ff80cSmrg	  continue
25509c9ff80cSmrg	fi
25511f0ac6a5Smrg
25529c9ff80cSmrg	func_dirname "$file" "" "."
25539c9ff80cSmrg	dir="$func_dirname_result"
25541f0ac6a5Smrg
25559c9ff80cSmrg	if test -f "$dir/$objdir/$dlname"; then
25566fae4e5dSmrg	  func_append dir "/$objdir"
25579c9ff80cSmrg	else
25589c9ff80cSmrg	  if test ! -f "$dir/$dlname"; then
25599c9ff80cSmrg	    func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'"
25609c9ff80cSmrg	  fi
25619c9ff80cSmrg	fi
25621f0ac6a5Smrg	;;
25631f0ac6a5Smrg
25649c9ff80cSmrg      *.lo)
25659c9ff80cSmrg	# Just add the directory containing the .lo file.
25669c9ff80cSmrg	func_dirname "$file" "" "."
25679c9ff80cSmrg	dir="$func_dirname_result"
25681f0ac6a5Smrg	;;
25691f0ac6a5Smrg
25709c9ff80cSmrg      *)
25719c9ff80cSmrg	func_warning "\`-dlopen' is ignored for non-libtool libraries and objects"
25721f0ac6a5Smrg	continue
25731f0ac6a5Smrg	;;
25749c9ff80cSmrg      esac
25751f0ac6a5Smrg
25769c9ff80cSmrg      # Get the absolute pathname.
25779c9ff80cSmrg      absdir=`cd "$dir" && pwd`
25789c9ff80cSmrg      test -n "$absdir" && dir="$absdir"
25791f0ac6a5Smrg
25809c9ff80cSmrg      # Now add the directory to shlibpath_var.
25819c9ff80cSmrg      if eval "test -z \"\$$shlibpath_var\""; then
25829c9ff80cSmrg	eval "$shlibpath_var=\"\$dir\""
25839c9ff80cSmrg      else
25849c9ff80cSmrg	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
25859c9ff80cSmrg      fi
25869c9ff80cSmrg    done
25871f0ac6a5Smrg
25889c9ff80cSmrg    # This variable tells wrapper scripts just to set shlibpath_var
25899c9ff80cSmrg    # rather than running their programs.
25909c9ff80cSmrg    libtool_execute_magic="$magic"
25911f0ac6a5Smrg
25929c9ff80cSmrg    # Check if any of the arguments is a wrapper script.
25939c9ff80cSmrg    args=
25949c9ff80cSmrg    for file
25959c9ff80cSmrg    do
25969c9ff80cSmrg      case $file in
25976fae4e5dSmrg      -* | *.la | *.lo ) ;;
25989c9ff80cSmrg      *)
25999c9ff80cSmrg	# Do a test to see if this is really a libtool program.
26009c9ff80cSmrg	if func_ltwrapper_script_p "$file"; then
26019c9ff80cSmrg	  func_source "$file"
26029c9ff80cSmrg	  # Transform arg to wrapped name.
26039c9ff80cSmrg	  file="$progdir/$program"
26049c9ff80cSmrg	elif func_ltwrapper_executable_p "$file"; then
26059c9ff80cSmrg	  func_ltwrapper_scriptname "$file"
26069c9ff80cSmrg	  func_source "$func_ltwrapper_scriptname_result"
26079c9ff80cSmrg	  # Transform arg to wrapped name.
26089c9ff80cSmrg	  file="$progdir/$program"
26099c9ff80cSmrg	fi
26109c9ff80cSmrg	;;
26119c9ff80cSmrg      esac
26129c9ff80cSmrg      # Quote arguments (to preserve shell metacharacters).
26136fae4e5dSmrg      func_append_quoted args "$file"
26149c9ff80cSmrg    done
26151f0ac6a5Smrg
26169c9ff80cSmrg    if test "X$opt_dry_run" = Xfalse; then
26179c9ff80cSmrg      if test -n "$shlibpath_var"; then
26189c9ff80cSmrg	# Export the shlibpath_var.
26199c9ff80cSmrg	eval "export $shlibpath_var"
26209c9ff80cSmrg      fi
26211f0ac6a5Smrg
26229c9ff80cSmrg      # Restore saved environment variables
26239c9ff80cSmrg      for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
26249c9ff80cSmrg      do
26259c9ff80cSmrg	eval "if test \"\${save_$lt_var+set}\" = set; then
26269c9ff80cSmrg                $lt_var=\$save_$lt_var; export $lt_var
26271f0ac6a5Smrg	      else
26289c9ff80cSmrg		$lt_unset $lt_var
26299c9ff80cSmrg	      fi"
26309c9ff80cSmrg      done
26311f0ac6a5Smrg
26329c9ff80cSmrg      # Now prepare to actually exec the command.
26339c9ff80cSmrg      exec_cmd="\$cmd$args"
26349c9ff80cSmrg    else
26359c9ff80cSmrg      # Display what would be done.
26369c9ff80cSmrg      if test -n "$shlibpath_var"; then
26379c9ff80cSmrg	eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
26386fae4e5dSmrg	echo "export $shlibpath_var"
26399c9ff80cSmrg      fi
26409c9ff80cSmrg      $ECHO "$cmd$args"
26419c9ff80cSmrg      exit $EXIT_SUCCESS
26429c9ff80cSmrg    fi
26439c9ff80cSmrg}
26441f0ac6a5Smrg
26456fae4e5dSmrgtest "$opt_mode" = execute && func_mode_execute ${1+"$@"}
26466fae4e5dSmrg
26476fae4e5dSmrg
26486fae4e5dSmrg# func_mode_finish arg...
26496fae4e5dSmrgfunc_mode_finish ()
26506fae4e5dSmrg{
26516fae4e5dSmrg    $opt_debug
26526fae4e5dSmrg    libs=
26536fae4e5dSmrg    libdirs=
26546fae4e5dSmrg    admincmds=
26556fae4e5dSmrg
26566fae4e5dSmrg    for opt in "$nonopt" ${1+"$@"}
26576fae4e5dSmrg    do
26586fae4e5dSmrg      if test -d "$opt"; then
26596fae4e5dSmrg	func_append libdirs " $opt"
26606fae4e5dSmrg
26616fae4e5dSmrg      elif test -f "$opt"; then
26626fae4e5dSmrg	if func_lalib_unsafe_p "$opt"; then
26636fae4e5dSmrg	  func_append libs " $opt"
26646fae4e5dSmrg	else
26656fae4e5dSmrg	  func_warning "\`$opt' is not a valid libtool archive"
26666fae4e5dSmrg	fi
26676fae4e5dSmrg
26686fae4e5dSmrg      else
26696fae4e5dSmrg	func_fatal_error "invalid argument \`$opt'"
26706fae4e5dSmrg      fi
26716fae4e5dSmrg    done
26721f0ac6a5Smrg
26736fae4e5dSmrg    if test -n "$libs"; then
26746fae4e5dSmrg      if test -n "$lt_sysroot"; then
26756fae4e5dSmrg        sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"`
26766fae4e5dSmrg        sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;"
26776fae4e5dSmrg      else
26786fae4e5dSmrg        sysroot_cmd=
26796fae4e5dSmrg      fi
26801f0ac6a5Smrg
26816fae4e5dSmrg      # Remove sysroot references
26826fae4e5dSmrg      if $opt_dry_run; then
26836fae4e5dSmrg        for lib in $libs; do
26846fae4e5dSmrg          echo "removing references to $lt_sysroot and \`=' prefixes from $lib"
26856fae4e5dSmrg        done
26866fae4e5dSmrg      else
26876fae4e5dSmrg        tmpdir=`func_mktempdir`
26886fae4e5dSmrg        for lib in $libs; do
26896fae4e5dSmrg	  sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
26906fae4e5dSmrg	    > $tmpdir/tmp-la
26916fae4e5dSmrg	  mv -f $tmpdir/tmp-la $lib
26926fae4e5dSmrg	done
26936fae4e5dSmrg        ${RM}r "$tmpdir"
26946fae4e5dSmrg      fi
26956fae4e5dSmrg    fi
26961f0ac6a5Smrg
26979c9ff80cSmrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
26989c9ff80cSmrg      for libdir in $libdirs; do
26999c9ff80cSmrg	if test -n "$finish_cmds"; then
27009c9ff80cSmrg	  # Do each command in the finish commands.
27019c9ff80cSmrg	  func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
27029c9ff80cSmrg'"$cmd"'"'
27031f0ac6a5Smrg	fi
27049c9ff80cSmrg	if test -n "$finish_eval"; then
27059c9ff80cSmrg	  # Do the single finish_eval.
27069c9ff80cSmrg	  eval cmds=\"$finish_eval\"
27076fae4e5dSmrg	  $opt_dry_run || eval "$cmds" || func_append admincmds "
27089c9ff80cSmrg       $cmds"
27099c9ff80cSmrg	fi
27109c9ff80cSmrg      done
27119c9ff80cSmrg    fi
27121f0ac6a5Smrg
27139c9ff80cSmrg    # Exit here if they wanted silent mode.
27149c9ff80cSmrg    $opt_silent && exit $EXIT_SUCCESS
27151f0ac6a5Smrg
27166fae4e5dSmrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
27176fae4e5dSmrg      echo "----------------------------------------------------------------------"
27186fae4e5dSmrg      echo "Libraries have been installed in:"
27196fae4e5dSmrg      for libdir in $libdirs; do
27206fae4e5dSmrg	$ECHO "   $libdir"
27216fae4e5dSmrg      done
27226fae4e5dSmrg      echo
27236fae4e5dSmrg      echo "If you ever happen to want to link against installed libraries"
27246fae4e5dSmrg      echo "in a given directory, LIBDIR, you must either use libtool, and"
27256fae4e5dSmrg      echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
27266fae4e5dSmrg      echo "flag during linking and do at least one of the following:"
27276fae4e5dSmrg      if test -n "$shlibpath_var"; then
27286fae4e5dSmrg	echo "   - add LIBDIR to the \`$shlibpath_var' environment variable"
27296fae4e5dSmrg	echo "     during execution"
27306fae4e5dSmrg      fi
27316fae4e5dSmrg      if test -n "$runpath_var"; then
27326fae4e5dSmrg	echo "   - add LIBDIR to the \`$runpath_var' environment variable"
27336fae4e5dSmrg	echo "     during linking"
27346fae4e5dSmrg      fi
27356fae4e5dSmrg      if test -n "$hardcode_libdir_flag_spec"; then
27366fae4e5dSmrg	libdir=LIBDIR
27376fae4e5dSmrg	eval flag=\"$hardcode_libdir_flag_spec\"
27389c9ff80cSmrg
27396fae4e5dSmrg	$ECHO "   - use the \`$flag' linker flag"
27406fae4e5dSmrg      fi
27416fae4e5dSmrg      if test -n "$admincmds"; then
27426fae4e5dSmrg	$ECHO "   - have your system administrator run these commands:$admincmds"
27436fae4e5dSmrg      fi
27446fae4e5dSmrg      if test -f /etc/ld.so.conf; then
27456fae4e5dSmrg	echo "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
27466fae4e5dSmrg      fi
27476fae4e5dSmrg      echo
27489c9ff80cSmrg
27496fae4e5dSmrg      echo "See any operating system documentation about shared libraries for"
27506fae4e5dSmrg      case $host in
27516fae4e5dSmrg	solaris2.[6789]|solaris2.1[0-9])
27526fae4e5dSmrg	  echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
27536fae4e5dSmrg	  echo "pages."
27546fae4e5dSmrg	  ;;
27556fae4e5dSmrg	*)
27566fae4e5dSmrg	  echo "more information, such as the ld(1) and ld.so(8) manual pages."
27576fae4e5dSmrg	  ;;
27586fae4e5dSmrg      esac
27596fae4e5dSmrg      echo "----------------------------------------------------------------------"
27606fae4e5dSmrg    fi
27619c9ff80cSmrg    exit $EXIT_SUCCESS
27629c9ff80cSmrg}
27639c9ff80cSmrg
27646fae4e5dSmrgtest "$opt_mode" = finish && func_mode_finish ${1+"$@"}
27659c9ff80cSmrg
27669c9ff80cSmrg
27679c9ff80cSmrg# func_mode_install arg...
27689c9ff80cSmrgfunc_mode_install ()
27699c9ff80cSmrg{
27709c9ff80cSmrg    $opt_debug
27719c9ff80cSmrg    # There may be an optional sh(1) argument at the beginning of
27729c9ff80cSmrg    # install_prog (especially on Windows NT).
27739c9ff80cSmrg    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
27749c9ff80cSmrg       # Allow the use of GNU shtool's install command.
27756fae4e5dSmrg       case $nonopt in *shtool*) :;; *) false;; esac; then
27769c9ff80cSmrg      # Aesthetically quote it.
27779c9ff80cSmrg      func_quote_for_eval "$nonopt"
27789c9ff80cSmrg      install_prog="$func_quote_for_eval_result "
27799c9ff80cSmrg      arg=$1
27809c9ff80cSmrg      shift
27819c9ff80cSmrg    else
27829c9ff80cSmrg      install_prog=
27839c9ff80cSmrg      arg=$nonopt
27849c9ff80cSmrg    fi
27859c9ff80cSmrg
27869c9ff80cSmrg    # The real first argument should be the name of the installation program.
27879c9ff80cSmrg    # Aesthetically quote it.
27889c9ff80cSmrg    func_quote_for_eval "$arg"
27896fae4e5dSmrg    func_append install_prog "$func_quote_for_eval_result"
27906fae4e5dSmrg    install_shared_prog=$install_prog
27916fae4e5dSmrg    case " $install_prog " in
27926fae4e5dSmrg      *[\\\ /]cp\ *) install_cp=: ;;
27936fae4e5dSmrg      *) install_cp=false ;;
27946fae4e5dSmrg    esac
27959c9ff80cSmrg
27969c9ff80cSmrg    # We need to accept at least all the BSD install flags.
27979c9ff80cSmrg    dest=
27989c9ff80cSmrg    files=
27999c9ff80cSmrg    opts=
28009c9ff80cSmrg    prev=
28019c9ff80cSmrg    install_type=
28029c9ff80cSmrg    isdir=no
28039c9ff80cSmrg    stripme=
28046fae4e5dSmrg    no_mode=:
28059c9ff80cSmrg    for arg
28069c9ff80cSmrg    do
28076fae4e5dSmrg      arg2=
28089c9ff80cSmrg      if test -n "$dest"; then
28096fae4e5dSmrg	func_append files " $dest"
28109c9ff80cSmrg	dest=$arg
28119c9ff80cSmrg	continue
28129c9ff80cSmrg      fi
28139c9ff80cSmrg
28149c9ff80cSmrg      case $arg in
28159c9ff80cSmrg      -d) isdir=yes ;;
28169c9ff80cSmrg      -f)
28176fae4e5dSmrg	if $install_cp; then :; else
28186fae4e5dSmrg	  prev=$arg
28196fae4e5dSmrg	fi
28209c9ff80cSmrg	;;
28219c9ff80cSmrg      -g | -m | -o)
28229c9ff80cSmrg	prev=$arg
28239c9ff80cSmrg	;;
28249c9ff80cSmrg      -s)
28259c9ff80cSmrg	stripme=" -s"
28269c9ff80cSmrg	continue
28279c9ff80cSmrg	;;
28289c9ff80cSmrg      -*)
28299c9ff80cSmrg	;;
28309c9ff80cSmrg      *)
28319c9ff80cSmrg	# If the previous option needed an argument, then skip it.
28329c9ff80cSmrg	if test -n "$prev"; then
28336fae4e5dSmrg	  if test "x$prev" = x-m && test -n "$install_override_mode"; then
28346fae4e5dSmrg	    arg2=$install_override_mode
28356fae4e5dSmrg	    no_mode=false
28366fae4e5dSmrg	  fi
28371f0ac6a5Smrg	  prev=
28381f0ac6a5Smrg	else
28399c9ff80cSmrg	  dest=$arg
28409c9ff80cSmrg	  continue
28411f0ac6a5Smrg	fi
28421f0ac6a5Smrg	;;
28439c9ff80cSmrg      esac
28441f0ac6a5Smrg
28459c9ff80cSmrg      # Aesthetically quote the argument.
28469c9ff80cSmrg      func_quote_for_eval "$arg"
28476fae4e5dSmrg      func_append install_prog " $func_quote_for_eval_result"
28486fae4e5dSmrg      if test -n "$arg2"; then
28496fae4e5dSmrg	func_quote_for_eval "$arg2"
28506fae4e5dSmrg      fi
28516fae4e5dSmrg      func_append install_shared_prog " $func_quote_for_eval_result"
28529c9ff80cSmrg    done
28531f0ac6a5Smrg
28549c9ff80cSmrg    test -z "$install_prog" && \
28559c9ff80cSmrg      func_fatal_help "you must specify an install program"
28561f0ac6a5Smrg
28579c9ff80cSmrg    test -n "$prev" && \
28589c9ff80cSmrg      func_fatal_help "the \`$prev' option requires an argument"
28591f0ac6a5Smrg
28606fae4e5dSmrg    if test -n "$install_override_mode" && $no_mode; then
28616fae4e5dSmrg      if $install_cp; then :; else
28626fae4e5dSmrg	func_quote_for_eval "$install_override_mode"
28636fae4e5dSmrg	func_append install_shared_prog " -m $func_quote_for_eval_result"
28646fae4e5dSmrg      fi
28656fae4e5dSmrg    fi
28666fae4e5dSmrg
28679c9ff80cSmrg    if test -z "$files"; then
28689c9ff80cSmrg      if test -z "$dest"; then
28699c9ff80cSmrg	func_fatal_help "no file or destination specified"
28709c9ff80cSmrg      else
28719c9ff80cSmrg	func_fatal_help "you must specify a destination"
28729c9ff80cSmrg      fi
28731f0ac6a5Smrg    fi
28741f0ac6a5Smrg
28759c9ff80cSmrg    # Strip any trailing slash from the destination.
28769c9ff80cSmrg    func_stripname '' '/' "$dest"
28779c9ff80cSmrg    dest=$func_stripname_result
28781f0ac6a5Smrg
28799c9ff80cSmrg    # Check to see that the destination is a directory.
28809c9ff80cSmrg    test -d "$dest" && isdir=yes
28819c9ff80cSmrg    if test "$isdir" = yes; then
28829c9ff80cSmrg      destdir="$dest"
28839c9ff80cSmrg      destname=
28841f0ac6a5Smrg    else
28859c9ff80cSmrg      func_dirname_and_basename "$dest" "" "."
28869c9ff80cSmrg      destdir="$func_dirname_result"
28879c9ff80cSmrg      destname="$func_basename_result"
28881f0ac6a5Smrg
28899c9ff80cSmrg      # Not a directory, so check to see that there is only one file specified.
28909c9ff80cSmrg      set dummy $files; shift
28919c9ff80cSmrg      test "$#" -gt 1 && \
28929c9ff80cSmrg	func_fatal_help "\`$dest' is not a directory"
28931f0ac6a5Smrg    fi
28949c9ff80cSmrg    case $destdir in
28959c9ff80cSmrg    [\\/]* | [A-Za-z]:[\\/]*) ;;
28961f0ac6a5Smrg    *)
28979c9ff80cSmrg      for file in $files; do
28989c9ff80cSmrg	case $file in
28999c9ff80cSmrg	*.lo) ;;
29009c9ff80cSmrg	*)
29019c9ff80cSmrg	  func_fatal_help "\`$destdir' must be an absolute directory name"
29029c9ff80cSmrg	  ;;
29039c9ff80cSmrg	esac
29049c9ff80cSmrg      done
29051f0ac6a5Smrg      ;;
29061f0ac6a5Smrg    esac
29071f0ac6a5Smrg
29089c9ff80cSmrg    # This variable tells wrapper scripts just to set variables rather
29099c9ff80cSmrg    # than running their programs.
29109c9ff80cSmrg    libtool_install_magic="$magic"
29111f0ac6a5Smrg
29129c9ff80cSmrg    staticlibs=
29139c9ff80cSmrg    future_libdirs=
29149c9ff80cSmrg    current_libdirs=
29159c9ff80cSmrg    for file in $files; do
29161f0ac6a5Smrg
29179c9ff80cSmrg      # Do each installation.
29189c9ff80cSmrg      case $file in
29199c9ff80cSmrg      *.$libext)
29209c9ff80cSmrg	# Do the static libraries later.
29216fae4e5dSmrg	func_append staticlibs " $file"
29229c9ff80cSmrg	;;
29239c9ff80cSmrg
29249c9ff80cSmrg      *.la)
29256fae4e5dSmrg	func_resolve_sysroot "$file"
29266fae4e5dSmrg	file=$func_resolve_sysroot_result
29276fae4e5dSmrg
29289c9ff80cSmrg	# Check to see that this really is a libtool archive.
29299c9ff80cSmrg	func_lalib_unsafe_p "$file" \
29309c9ff80cSmrg	  || func_fatal_help "\`$file' is not a valid libtool archive"
29319c9ff80cSmrg
29329c9ff80cSmrg	library_names=
29339c9ff80cSmrg	old_library=
29349c9ff80cSmrg	relink_command=
29359c9ff80cSmrg	func_source "$file"
29369c9ff80cSmrg
29379c9ff80cSmrg	# Add the libdir to current_libdirs if it is the destination.
29389c9ff80cSmrg	if test "X$destdir" = "X$libdir"; then
29399c9ff80cSmrg	  case "$current_libdirs " in
29409c9ff80cSmrg	  *" $libdir "*) ;;
29416fae4e5dSmrg	  *) func_append current_libdirs " $libdir" ;;
29421f0ac6a5Smrg	  esac
29439c9ff80cSmrg	else
29449c9ff80cSmrg	  # Note the libdir as a future libdir.
29459c9ff80cSmrg	  case "$future_libdirs " in
29469c9ff80cSmrg	  *" $libdir "*) ;;
29476fae4e5dSmrg	  *) func_append future_libdirs " $libdir" ;;
29489c9ff80cSmrg	  esac
29499c9ff80cSmrg	fi
29501f0ac6a5Smrg
29519c9ff80cSmrg	func_dirname "$file" "/" ""
29529c9ff80cSmrg	dir="$func_dirname_result"
29536fae4e5dSmrg	func_append dir "$objdir"
29549c9ff80cSmrg
29559c9ff80cSmrg	if test -n "$relink_command"; then
29569c9ff80cSmrg	  # Determine the prefix the user has applied to our future dir.
29576fae4e5dSmrg	  inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
29589c9ff80cSmrg
29599c9ff80cSmrg	  # Don't allow the user to place us outside of our expected
29609c9ff80cSmrg	  # location b/c this prevents finding dependent libraries that
29619c9ff80cSmrg	  # are installed to the same prefix.
29629c9ff80cSmrg	  # At present, this check doesn't affect windows .dll's that
29639c9ff80cSmrg	  # are installed into $libdir/../bin (currently, that works fine)
29649c9ff80cSmrg	  # but it's something to keep an eye on.
29659c9ff80cSmrg	  test "$inst_prefix_dir" = "$destdir" && \
29669c9ff80cSmrg	    func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
29679c9ff80cSmrg
29689c9ff80cSmrg	  if test -n "$inst_prefix_dir"; then
29699c9ff80cSmrg	    # Stick the inst_prefix_dir data into the link command.
29706fae4e5dSmrg	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
29719c9ff80cSmrg	  else
29726fae4e5dSmrg	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
29739c9ff80cSmrg	  fi
29749c9ff80cSmrg
29759c9ff80cSmrg	  func_warning "relinking \`$file'"
29769c9ff80cSmrg	  func_show_eval "$relink_command" \
29779c9ff80cSmrg	    'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
29789c9ff80cSmrg	fi
29799c9ff80cSmrg
29809c9ff80cSmrg	# See the names of the shared library.
29819c9ff80cSmrg	set dummy $library_names; shift
29829c9ff80cSmrg	if test -n "$1"; then
29839c9ff80cSmrg	  realname="$1"
29849c9ff80cSmrg	  shift
29859c9ff80cSmrg
29869c9ff80cSmrg	  srcname="$realname"
29879c9ff80cSmrg	  test -n "$relink_command" && srcname="$realname"T
29889c9ff80cSmrg
29899c9ff80cSmrg	  # Install the shared library and build the symlinks.
29906fae4e5dSmrg	  func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
29919c9ff80cSmrg	      'exit $?'
29929c9ff80cSmrg	  tstripme="$stripme"
29939c9ff80cSmrg	  case $host_os in
29949c9ff80cSmrg	  cygwin* | mingw* | pw32* | cegcc*)
29959c9ff80cSmrg	    case $realname in
29969c9ff80cSmrg	    *.dll.a)
29979c9ff80cSmrg	      tstripme=""
29989c9ff80cSmrg	      ;;
29999c9ff80cSmrg	    esac
30001f0ac6a5Smrg	    ;;
30011f0ac6a5Smrg	  esac
30029c9ff80cSmrg	  if test -n "$tstripme" && test -n "$striplib"; then
30039c9ff80cSmrg	    func_show_eval "$striplib $destdir/$realname" 'exit $?'
30041f0ac6a5Smrg	  fi
30059c9ff80cSmrg
30069c9ff80cSmrg	  if test "$#" -gt 0; then
30079c9ff80cSmrg	    # Delete the old symlinks, and create new ones.
30089c9ff80cSmrg	    # Try `ln -sf' first, because the `ln' binary might depend on
30099c9ff80cSmrg	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
30109c9ff80cSmrg	    # so we also need to try rm && ln -s.
30119c9ff80cSmrg	    for linkname
30129c9ff80cSmrg	    do
30139c9ff80cSmrg	      test "$linkname" != "$realname" \
30149c9ff80cSmrg		&& func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
30151f0ac6a5Smrg	    done
30161f0ac6a5Smrg	  fi
30171f0ac6a5Smrg
30189c9ff80cSmrg	  # Do each command in the postinstall commands.
30199c9ff80cSmrg	  lib="$destdir/$realname"
30209c9ff80cSmrg	  func_execute_cmds "$postinstall_cmds" 'exit $?'
30211f0ac6a5Smrg	fi
30221f0ac6a5Smrg
30239c9ff80cSmrg	# Install the pseudo-library for information purposes.
30249c9ff80cSmrg	func_basename "$file"
30259c9ff80cSmrg	name="$func_basename_result"
30269c9ff80cSmrg	instname="$dir/$name"i
30279c9ff80cSmrg	func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
30281f0ac6a5Smrg
30299c9ff80cSmrg	# Maybe install the static library, too.
30306fae4e5dSmrg	test -n "$old_library" && func_append staticlibs " $dir/$old_library"
30319c9ff80cSmrg	;;
30321f0ac6a5Smrg
30339c9ff80cSmrg      *.lo)
30349c9ff80cSmrg	# Install (i.e. copy) a libtool object.
30351f0ac6a5Smrg
30369c9ff80cSmrg	# Figure out destination file name, if it wasn't already specified.
30379c9ff80cSmrg	if test -n "$destname"; then
30389c9ff80cSmrg	  destfile="$destdir/$destname"
30399c9ff80cSmrg	else
30409c9ff80cSmrg	  func_basename "$file"
30419c9ff80cSmrg	  destfile="$func_basename_result"
30429c9ff80cSmrg	  destfile="$destdir/$destfile"
30431f0ac6a5Smrg	fi
30441f0ac6a5Smrg
30459c9ff80cSmrg	# Deduce the name of the destination old-style object file.
30469c9ff80cSmrg	case $destfile in
30479c9ff80cSmrg	*.lo)
30489c9ff80cSmrg	  func_lo2o "$destfile"
30499c9ff80cSmrg	  staticdest=$func_lo2o_result
30509c9ff80cSmrg	  ;;
30519c9ff80cSmrg	*.$objext)
30529c9ff80cSmrg	  staticdest="$destfile"
30539c9ff80cSmrg	  destfile=
30549c9ff80cSmrg	  ;;
30559c9ff80cSmrg	*)
30569c9ff80cSmrg	  func_fatal_help "cannot copy a libtool object to \`$destfile'"
30579c9ff80cSmrg	  ;;
30589c9ff80cSmrg	esac
30591f0ac6a5Smrg
30609c9ff80cSmrg	# Install the libtool object if requested.
30619c9ff80cSmrg	test -n "$destfile" && \
30629c9ff80cSmrg	  func_show_eval "$install_prog $file $destfile" 'exit $?'
30631f0ac6a5Smrg
30649c9ff80cSmrg	# Install the old object if enabled.
30659c9ff80cSmrg	if test "$build_old_libs" = yes; then
30669c9ff80cSmrg	  # Deduce the name of the old-style object file.
30679c9ff80cSmrg	  func_lo2o "$file"
30689c9ff80cSmrg	  staticobj=$func_lo2o_result
30699c9ff80cSmrg	  func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
30701f0ac6a5Smrg	fi
30719c9ff80cSmrg	exit $EXIT_SUCCESS
30729c9ff80cSmrg	;;
30731f0ac6a5Smrg
30749c9ff80cSmrg      *)
30759c9ff80cSmrg	# Figure out destination file name, if it wasn't already specified.
30769c9ff80cSmrg	if test -n "$destname"; then
30779c9ff80cSmrg	  destfile="$destdir/$destname"
30789c9ff80cSmrg	else
30799c9ff80cSmrg	  func_basename "$file"
30809c9ff80cSmrg	  destfile="$func_basename_result"
30819c9ff80cSmrg	  destfile="$destdir/$destfile"
30829c9ff80cSmrg	fi
30831f0ac6a5Smrg
30849c9ff80cSmrg	# If the file is missing, and there is a .exe on the end, strip it
30859c9ff80cSmrg	# because it is most likely a libtool script we actually want to
30869c9ff80cSmrg	# install
30879c9ff80cSmrg	stripped_ext=""
30889c9ff80cSmrg	case $file in
30899c9ff80cSmrg	  *.exe)
30909c9ff80cSmrg	    if test ! -f "$file"; then
30919c9ff80cSmrg	      func_stripname '' '.exe' "$file"
30929c9ff80cSmrg	      file=$func_stripname_result
30939c9ff80cSmrg	      stripped_ext=".exe"
30949c9ff80cSmrg	    fi
30959c9ff80cSmrg	    ;;
30969c9ff80cSmrg	esac
30979c9ff80cSmrg
30989c9ff80cSmrg	# Do a test to see if this is really a libtool program.
30999c9ff80cSmrg	case $host in
31009c9ff80cSmrg	*cygwin* | *mingw*)
31019c9ff80cSmrg	    if func_ltwrapper_executable_p "$file"; then
31029c9ff80cSmrg	      func_ltwrapper_scriptname "$file"
31039c9ff80cSmrg	      wrapper=$func_ltwrapper_scriptname_result
31049c9ff80cSmrg	    else
31059c9ff80cSmrg	      func_stripname '' '.exe' "$file"
31069c9ff80cSmrg	      wrapper=$func_stripname_result
31079c9ff80cSmrg	    fi
31089c9ff80cSmrg	    ;;
31091f0ac6a5Smrg	*)
31109c9ff80cSmrg	    wrapper=$file
31119c9ff80cSmrg	    ;;
31129c9ff80cSmrg	esac
31139c9ff80cSmrg	if func_ltwrapper_script_p "$wrapper"; then
31149c9ff80cSmrg	  notinst_deplibs=
31159c9ff80cSmrg	  relink_command=
31169c9ff80cSmrg
31179c9ff80cSmrg	  func_source "$wrapper"
31189c9ff80cSmrg
31199c9ff80cSmrg	  # Check the variables that should have been set.
31209c9ff80cSmrg	  test -z "$generated_by_libtool_version" && \
31219c9ff80cSmrg	    func_fatal_error "invalid libtool wrapper script \`$wrapper'"
31229c9ff80cSmrg
31239c9ff80cSmrg	  finalize=yes
31249c9ff80cSmrg	  for lib in $notinst_deplibs; do
31259c9ff80cSmrg	    # Check to see that each library is installed.
31269c9ff80cSmrg	    libdir=
31279c9ff80cSmrg	    if test -f "$lib"; then
31289c9ff80cSmrg	      func_source "$lib"
31299c9ff80cSmrg	    fi
31306fae4e5dSmrg	    libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test
31319c9ff80cSmrg	    if test -n "$libdir" && test ! -f "$libfile"; then
31329c9ff80cSmrg	      func_warning "\`$lib' has not been installed in \`$libdir'"
31339c9ff80cSmrg	      finalize=no
31349c9ff80cSmrg	    fi
31359c9ff80cSmrg	  done
31369c9ff80cSmrg
31379c9ff80cSmrg	  relink_command=
31389c9ff80cSmrg	  func_source "$wrapper"
31399c9ff80cSmrg
31409c9ff80cSmrg	  outputname=
31419c9ff80cSmrg	  if test "$fast_install" = no && test -n "$relink_command"; then
31429c9ff80cSmrg	    $opt_dry_run || {
31439c9ff80cSmrg	      if test "$finalize" = yes; then
31449c9ff80cSmrg	        tmpdir=`func_mktempdir`
31459c9ff80cSmrg		func_basename "$file$stripped_ext"
31469c9ff80cSmrg		file="$func_basename_result"
31479c9ff80cSmrg	        outputname="$tmpdir/$file"
31489c9ff80cSmrg	        # Replace the output file specification.
31496fae4e5dSmrg	        relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
31509c9ff80cSmrg
31519c9ff80cSmrg	        $opt_silent || {
31529c9ff80cSmrg	          func_quote_for_expand "$relink_command"
31539c9ff80cSmrg		  eval "func_echo $func_quote_for_expand_result"
31549c9ff80cSmrg	        }
31559c9ff80cSmrg	        if eval "$relink_command"; then :
31569c9ff80cSmrg	          else
31579c9ff80cSmrg		  func_error "error: relink \`$file' with the above command before installing it"
31589c9ff80cSmrg		  $opt_dry_run || ${RM}r "$tmpdir"
31599c9ff80cSmrg		  continue
31609c9ff80cSmrg	        fi
31619c9ff80cSmrg	        file="$outputname"
31629c9ff80cSmrg	      else
31639c9ff80cSmrg	        func_warning "cannot relink \`$file'"
31649c9ff80cSmrg	      fi
31659c9ff80cSmrg	    }
31669c9ff80cSmrg	  else
31679c9ff80cSmrg	    # Install the binary that we compiled earlier.
31686fae4e5dSmrg	    file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
31691f0ac6a5Smrg	  fi
31709c9ff80cSmrg	fi
31719c9ff80cSmrg
31729c9ff80cSmrg	# remove .exe since cygwin /usr/bin/install will append another
31739c9ff80cSmrg	# one anyway
31749c9ff80cSmrg	case $install_prog,$host in
31759c9ff80cSmrg	*/usr/bin/install*,*cygwin*)
31769c9ff80cSmrg	  case $file:$destfile in
31779c9ff80cSmrg	  *.exe:*.exe)
31789c9ff80cSmrg	    # this is ok
31799c9ff80cSmrg	    ;;
31809c9ff80cSmrg	  *.exe:*)
31819c9ff80cSmrg	    destfile=$destfile.exe
31829c9ff80cSmrg	    ;;
31839c9ff80cSmrg	  *:*.exe)
31849c9ff80cSmrg	    func_stripname '' '.exe' "$destfile"
31859c9ff80cSmrg	    destfile=$func_stripname_result
31869c9ff80cSmrg	    ;;
31879c9ff80cSmrg	  esac
31881f0ac6a5Smrg	  ;;
31891f0ac6a5Smrg	esac
31909c9ff80cSmrg	func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
31919c9ff80cSmrg	$opt_dry_run || if test -n "$outputname"; then
31929c9ff80cSmrg	  ${RM}r "$tmpdir"
31939c9ff80cSmrg	fi
31949c9ff80cSmrg	;;
31959c9ff80cSmrg      esac
31969c9ff80cSmrg    done
31971f0ac6a5Smrg
31989c9ff80cSmrg    for file in $staticlibs; do
31999c9ff80cSmrg      func_basename "$file"
32009c9ff80cSmrg      name="$func_basename_result"
32019c9ff80cSmrg
32029c9ff80cSmrg      # Set up the ranlib parameters.
32039c9ff80cSmrg      oldlib="$destdir/$name"
32049c9ff80cSmrg
32059c9ff80cSmrg      func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
32069c9ff80cSmrg
32079c9ff80cSmrg      if test -n "$stripme" && test -n "$old_striplib"; then
32089c9ff80cSmrg	func_show_eval "$old_striplib $oldlib" 'exit $?'
32099c9ff80cSmrg      fi
32109c9ff80cSmrg
32119c9ff80cSmrg      # Do each command in the postinstall commands.
32129c9ff80cSmrg      func_execute_cmds "$old_postinstall_cmds" 'exit $?'
32139c9ff80cSmrg    done
32149c9ff80cSmrg
32159c9ff80cSmrg    test -n "$future_libdirs" && \
32169c9ff80cSmrg      func_warning "remember to run \`$progname --finish$future_libdirs'"
32179c9ff80cSmrg
32189c9ff80cSmrg    if test -n "$current_libdirs"; then
32199c9ff80cSmrg      # Maybe just do a dry run.
32209c9ff80cSmrg      $opt_dry_run && current_libdirs=" -n$current_libdirs"
32219c9ff80cSmrg      exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
32229c9ff80cSmrg    else
32239c9ff80cSmrg      exit $EXIT_SUCCESS
32249c9ff80cSmrg    fi
32259c9ff80cSmrg}
32269c9ff80cSmrg
32276fae4e5dSmrgtest "$opt_mode" = install && func_mode_install ${1+"$@"}
32289c9ff80cSmrg
32299c9ff80cSmrg
32309c9ff80cSmrg# func_generate_dlsyms outputname originator pic_p
32319c9ff80cSmrg# Extract symbols from dlprefiles and create ${outputname}S.o with
32329c9ff80cSmrg# a dlpreopen symbol table.
32339c9ff80cSmrgfunc_generate_dlsyms ()
32349c9ff80cSmrg{
32359c9ff80cSmrg    $opt_debug
32369c9ff80cSmrg    my_outputname="$1"
32379c9ff80cSmrg    my_originator="$2"
32389c9ff80cSmrg    my_pic_p="${3-no}"
32399c9ff80cSmrg    my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'`
32409c9ff80cSmrg    my_dlsyms=
32419c9ff80cSmrg
32429c9ff80cSmrg    if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
32439c9ff80cSmrg      if test -n "$NM" && test -n "$global_symbol_pipe"; then
32449c9ff80cSmrg	my_dlsyms="${my_outputname}S.c"
32459c9ff80cSmrg      else
32469c9ff80cSmrg	func_error "not configured to extract global symbols from dlpreopened files"
32479c9ff80cSmrg      fi
32489c9ff80cSmrg    fi
32499c9ff80cSmrg
32509c9ff80cSmrg    if test -n "$my_dlsyms"; then
32519c9ff80cSmrg      case $my_dlsyms in
32529c9ff80cSmrg      "") ;;
32539c9ff80cSmrg      *.c)
32549c9ff80cSmrg	# Discover the nlist of each of the dlfiles.
32559c9ff80cSmrg	nlist="$output_objdir/${my_outputname}.nm"
32569c9ff80cSmrg
32579c9ff80cSmrg	func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
32589c9ff80cSmrg
32599c9ff80cSmrg	# Parse the name list into a source file.
32609c9ff80cSmrg	func_verbose "creating $output_objdir/$my_dlsyms"
32619c9ff80cSmrg
32629c9ff80cSmrg	$opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
32639c9ff80cSmrg/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */
32649c9ff80cSmrg/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */
32659c9ff80cSmrg
32669c9ff80cSmrg#ifdef __cplusplus
32679c9ff80cSmrgextern \"C\" {
32689c9ff80cSmrg#endif
32699c9ff80cSmrg
32706fae4e5dSmrg#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
32716fae4e5dSmrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
32726fae4e5dSmrg#endif
32736fae4e5dSmrg
32746fae4e5dSmrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
32756fae4e5dSmrg#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
32766fae4e5dSmrg/* DATA imports from DLLs on WIN32 con't be const, because runtime
32776fae4e5dSmrg   relocations are performed -- see ld's documentation on pseudo-relocs.  */
32786fae4e5dSmrg# define LT_DLSYM_CONST
32796fae4e5dSmrg#elif defined(__osf__)
32806fae4e5dSmrg/* This system does not cope well with relocations in const data.  */
32816fae4e5dSmrg# define LT_DLSYM_CONST
32826fae4e5dSmrg#else
32836fae4e5dSmrg# define LT_DLSYM_CONST const
32846fae4e5dSmrg#endif
32856fae4e5dSmrg
32869c9ff80cSmrg/* External symbol declarations for the compiler. */\
32879c9ff80cSmrg"
32889c9ff80cSmrg
32899c9ff80cSmrg	if test "$dlself" = yes; then
32909c9ff80cSmrg	  func_verbose "generating symbol list for \`$output'"
32919c9ff80cSmrg
32929c9ff80cSmrg	  $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
32939c9ff80cSmrg
32949c9ff80cSmrg	  # Add our own program objects to the symbol list.
32956fae4e5dSmrg	  progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
32969c9ff80cSmrg	  for progfile in $progfiles; do
32976fae4e5dSmrg	    func_to_tool_file "$progfile" func_convert_file_msys_to_w32
32986fae4e5dSmrg	    func_verbose "extracting global C symbols from \`$func_to_tool_file_result'"
32996fae4e5dSmrg	    $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
33009c9ff80cSmrg	  done
33019c9ff80cSmrg
33029c9ff80cSmrg	  if test -n "$exclude_expsyms"; then
33039c9ff80cSmrg	    $opt_dry_run || {
33049c9ff80cSmrg	      eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
33059c9ff80cSmrg	      eval '$MV "$nlist"T "$nlist"'
33069c9ff80cSmrg	    }
33071f0ac6a5Smrg	  fi
33089c9ff80cSmrg
33099c9ff80cSmrg	  if test -n "$export_symbols_regex"; then
33109c9ff80cSmrg	    $opt_dry_run || {
33119c9ff80cSmrg	      eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
33129c9ff80cSmrg	      eval '$MV "$nlist"T "$nlist"'
33139c9ff80cSmrg	    }
33149c9ff80cSmrg	  fi
33159c9ff80cSmrg
33169c9ff80cSmrg	  # Prepare the list of exported symbols
33179c9ff80cSmrg	  if test -z "$export_symbols"; then
33189c9ff80cSmrg	    export_symbols="$output_objdir/$outputname.exp"
33199c9ff80cSmrg	    $opt_dry_run || {
33209c9ff80cSmrg	      $RM $export_symbols
33219c9ff80cSmrg	      eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
33229c9ff80cSmrg	      case $host in
33239c9ff80cSmrg	      *cygwin* | *mingw* | *cegcc* )
33249c9ff80cSmrg                eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
33259c9ff80cSmrg                eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
33269c9ff80cSmrg	        ;;
33279c9ff80cSmrg	      esac
33289c9ff80cSmrg	    }
33291f0ac6a5Smrg	  else
33309c9ff80cSmrg	    $opt_dry_run || {
33319c9ff80cSmrg	      eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
33329c9ff80cSmrg	      eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
33339c9ff80cSmrg	      eval '$MV "$nlist"T "$nlist"'
33349c9ff80cSmrg	      case $host in
33356fae4e5dSmrg	        *cygwin* | *mingw* | *cegcc* )
33369c9ff80cSmrg	          eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
33379c9ff80cSmrg	          eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
33389c9ff80cSmrg	          ;;
33399c9ff80cSmrg	      esac
33409c9ff80cSmrg	    }
33411f0ac6a5Smrg	  fi
33429c9ff80cSmrg	fi
33431f0ac6a5Smrg
33449c9ff80cSmrg	for dlprefile in $dlprefiles; do
33459c9ff80cSmrg	  func_verbose "extracting global C symbols from \`$dlprefile'"
33469c9ff80cSmrg	  func_basename "$dlprefile"
33479c9ff80cSmrg	  name="$func_basename_result"
33486fae4e5dSmrg          case $host in
33496fae4e5dSmrg	    *cygwin* | *mingw* | *cegcc* )
33506fae4e5dSmrg	      # if an import library, we need to obtain dlname
33516fae4e5dSmrg	      if func_win32_import_lib_p "$dlprefile"; then
33526fae4e5dSmrg	        func_tr_sh "$dlprefile"
33536fae4e5dSmrg	        eval "curr_lafile=\$libfile_$func_tr_sh_result"
33546fae4e5dSmrg	        dlprefile_dlbasename=""
33556fae4e5dSmrg	        if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
33566fae4e5dSmrg	          # Use subshell, to avoid clobbering current variable values
33576fae4e5dSmrg	          dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
33586fae4e5dSmrg	          if test -n "$dlprefile_dlname" ; then
33596fae4e5dSmrg	            func_basename "$dlprefile_dlname"
33606fae4e5dSmrg	            dlprefile_dlbasename="$func_basename_result"
33616fae4e5dSmrg	          else
33626fae4e5dSmrg	            # no lafile. user explicitly requested -dlpreopen <import library>.
33636fae4e5dSmrg	            $sharedlib_from_linklib_cmd "$dlprefile"
33646fae4e5dSmrg	            dlprefile_dlbasename=$sharedlib_from_linklib_result
33656fae4e5dSmrg	          fi
33666fae4e5dSmrg	        fi
33676fae4e5dSmrg	        $opt_dry_run || {
33686fae4e5dSmrg	          if test -n "$dlprefile_dlbasename" ; then
33696fae4e5dSmrg	            eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
33706fae4e5dSmrg	          else
33716fae4e5dSmrg	            func_warning "Could not compute DLL name from $name"
33726fae4e5dSmrg	            eval '$ECHO ": $name " >> "$nlist"'
33736fae4e5dSmrg	          fi
33746fae4e5dSmrg	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
33756fae4e5dSmrg	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe |
33766fae4e5dSmrg	            $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'"
33776fae4e5dSmrg	        }
33786fae4e5dSmrg	      else # not an import lib
33796fae4e5dSmrg	        $opt_dry_run || {
33806fae4e5dSmrg	          eval '$ECHO ": $name " >> "$nlist"'
33816fae4e5dSmrg	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
33826fae4e5dSmrg	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
33836fae4e5dSmrg	        }
33846fae4e5dSmrg	      fi
33856fae4e5dSmrg	    ;;
33866fae4e5dSmrg	    *)
33876fae4e5dSmrg	      $opt_dry_run || {
33886fae4e5dSmrg	        eval '$ECHO ": $name " >> "$nlist"'
33896fae4e5dSmrg	        func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
33906fae4e5dSmrg	        eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
33916fae4e5dSmrg	      }
33926fae4e5dSmrg	    ;;
33936fae4e5dSmrg          esac
33949c9ff80cSmrg	done
33959c9ff80cSmrg
33969c9ff80cSmrg	$opt_dry_run || {
33979c9ff80cSmrg	  # Make sure we have at least an empty file.
33989c9ff80cSmrg	  test -f "$nlist" || : > "$nlist"
33999c9ff80cSmrg
34009c9ff80cSmrg	  if test -n "$exclude_expsyms"; then
34019c9ff80cSmrg	    $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
34029c9ff80cSmrg	    $MV "$nlist"T "$nlist"
34031f0ac6a5Smrg	  fi
34049c9ff80cSmrg
34059c9ff80cSmrg	  # Try sorting and uniquifying the output.
34069c9ff80cSmrg	  if $GREP -v "^: " < "$nlist" |
34079c9ff80cSmrg	      if sort -k 3 </dev/null >/dev/null 2>&1; then
34089c9ff80cSmrg		sort -k 3
34099c9ff80cSmrg	      else
34109c9ff80cSmrg		sort +2
34119c9ff80cSmrg	      fi |
34129c9ff80cSmrg	      uniq > "$nlist"S; then
34139c9ff80cSmrg	    :
34141f0ac6a5Smrg	  else
34159c9ff80cSmrg	    $GREP -v "^: " < "$nlist" > "$nlist"S
34161f0ac6a5Smrg	  fi
34171f0ac6a5Smrg
34189c9ff80cSmrg	  if test -f "$nlist"S; then
34199c9ff80cSmrg	    eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
34201f0ac6a5Smrg	  else
34216fae4e5dSmrg	    echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
34221f0ac6a5Smrg	  fi
34231f0ac6a5Smrg
34246fae4e5dSmrg	  echo >> "$output_objdir/$my_dlsyms" "\
34251f0ac6a5Smrg
34269c9ff80cSmrg/* The mapping between symbol names and symbols.  */
34279c9ff80cSmrgtypedef struct {
34289c9ff80cSmrg  const char *name;
34299c9ff80cSmrg  void *address;
34309c9ff80cSmrg} lt_dlsymlist;
34316fae4e5dSmrgextern LT_DLSYM_CONST lt_dlsymlist
34329c9ff80cSmrglt_${my_prefix}_LTX_preloaded_symbols[];
34336fae4e5dSmrgLT_DLSYM_CONST lt_dlsymlist
34349c9ff80cSmrglt_${my_prefix}_LTX_preloaded_symbols[] =
34359c9ff80cSmrg{\
34369c9ff80cSmrg  { \"$my_originator\", (void *) 0 },"
34371f0ac6a5Smrg
34389c9ff80cSmrg	  case $need_lib_prefix in
34399c9ff80cSmrg	  no)
34409c9ff80cSmrg	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
34419c9ff80cSmrg	    ;;
34429c9ff80cSmrg	  *)
34439c9ff80cSmrg	    eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
34449c9ff80cSmrg	    ;;
34459c9ff80cSmrg	  esac
34466fae4e5dSmrg	  echo >> "$output_objdir/$my_dlsyms" "\
34479c9ff80cSmrg  {0, (void *) 0}
34489c9ff80cSmrg};
34491f0ac6a5Smrg
34509c9ff80cSmrg/* This works around a problem in FreeBSD linker */
34519c9ff80cSmrg#ifdef FREEBSD_WORKAROUND
34529c9ff80cSmrgstatic const void *lt_preloaded_setup() {
34539c9ff80cSmrg  return lt_${my_prefix}_LTX_preloaded_symbols;
34549c9ff80cSmrg}
34559c9ff80cSmrg#endif
34569c9ff80cSmrg
34579c9ff80cSmrg#ifdef __cplusplus
34589c9ff80cSmrg}
34599c9ff80cSmrg#endif\
34609c9ff80cSmrg"
34619c9ff80cSmrg	} # !$opt_dry_run
34629c9ff80cSmrg
34639c9ff80cSmrg	pic_flag_for_symtable=
34649c9ff80cSmrg	case "$compile_command " in
34659c9ff80cSmrg	*" -static "*) ;;
34669c9ff80cSmrg	*)
34679c9ff80cSmrg	  case $host in
34689c9ff80cSmrg	  # compiling the symbol table file with pic_flag works around
34699c9ff80cSmrg	  # a FreeBSD bug that causes programs to crash when -lm is
34709c9ff80cSmrg	  # linked before any other PIC object.  But we must not use
34719c9ff80cSmrg	  # pic_flag when linking with -static.  The problem exists in
34729c9ff80cSmrg	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
34739c9ff80cSmrg	  *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
34749c9ff80cSmrg	    pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
34759c9ff80cSmrg	  *-*-hpux*)
34769c9ff80cSmrg	    pic_flag_for_symtable=" $pic_flag"  ;;
34779c9ff80cSmrg	  *)
34789c9ff80cSmrg	    if test "X$my_pic_p" != Xno; then
34799c9ff80cSmrg	      pic_flag_for_symtable=" $pic_flag"
34801f0ac6a5Smrg	    fi
34819c9ff80cSmrg	    ;;
34829c9ff80cSmrg	  esac
34839c9ff80cSmrg	  ;;
34849c9ff80cSmrg	esac
34859c9ff80cSmrg	symtab_cflags=
34869c9ff80cSmrg	for arg in $LTCFLAGS; do
34879c9ff80cSmrg	  case $arg in
34889c9ff80cSmrg	  -pie | -fpie | -fPIE) ;;
34896fae4e5dSmrg	  *) func_append symtab_cflags " $arg" ;;
34909c9ff80cSmrg	  esac
34919c9ff80cSmrg	done
34921f0ac6a5Smrg
34939c9ff80cSmrg	# Now compile the dynamic symbol file.
34949c9ff80cSmrg	func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
34951f0ac6a5Smrg
34969c9ff80cSmrg	# Clean up the generated files.
34979c9ff80cSmrg	func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"'
34981f0ac6a5Smrg
34999c9ff80cSmrg	# Transform the symbol file into the correct name.
35009c9ff80cSmrg	symfileobj="$output_objdir/${my_outputname}S.$objext"
35019c9ff80cSmrg	case $host in
35029c9ff80cSmrg	*cygwin* | *mingw* | *cegcc* )
35039c9ff80cSmrg	  if test -f "$output_objdir/$my_outputname.def"; then
35046fae4e5dSmrg	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
35056fae4e5dSmrg	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
35069c9ff80cSmrg	  else
35076fae4e5dSmrg	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
35086fae4e5dSmrg	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
35091f0ac6a5Smrg	  fi
35109c9ff80cSmrg	  ;;
35119c9ff80cSmrg	*)
35126fae4e5dSmrg	  compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
35136fae4e5dSmrg	  finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
35149c9ff80cSmrg	  ;;
35159c9ff80cSmrg	esac
35169c9ff80cSmrg	;;
35179c9ff80cSmrg      *)
35189c9ff80cSmrg	func_fatal_error "unknown suffix for \`$my_dlsyms'"
35199c9ff80cSmrg	;;
35209c9ff80cSmrg      esac
35219c9ff80cSmrg    else
35229c9ff80cSmrg      # We keep going just in case the user didn't refer to
35239c9ff80cSmrg      # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
35249c9ff80cSmrg      # really was required.
35251f0ac6a5Smrg
35269c9ff80cSmrg      # Nullify the symbol file.
35276fae4e5dSmrg      compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
35286fae4e5dSmrg      finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
35299c9ff80cSmrg    fi
35309c9ff80cSmrg}
35311f0ac6a5Smrg
35329c9ff80cSmrg# func_win32_libid arg
35339c9ff80cSmrg# return the library type of file 'arg'
35349c9ff80cSmrg#
35359c9ff80cSmrg# Need a lot of goo to handle *both* DLLs and import libs
35369c9ff80cSmrg# Has to be a shell function in order to 'eat' the argument
35379c9ff80cSmrg# that is supplied when $file_magic_command is called.
35386fae4e5dSmrg# Despite the name, also deal with 64 bit binaries.
35399c9ff80cSmrgfunc_win32_libid ()
35409c9ff80cSmrg{
35419c9ff80cSmrg  $opt_debug
35429c9ff80cSmrg  win32_libid_type="unknown"
35439c9ff80cSmrg  win32_fileres=`file -L $1 2>/dev/null`
35449c9ff80cSmrg  case $win32_fileres in
35459c9ff80cSmrg  *ar\ archive\ import\ library*) # definitely import
35469c9ff80cSmrg    win32_libid_type="x86 archive import"
35479c9ff80cSmrg    ;;
35489c9ff80cSmrg  *ar\ archive*) # could be an import, or static
35496fae4e5dSmrg    # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
35509c9ff80cSmrg    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
35516fae4e5dSmrg       $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
35526fae4e5dSmrg      func_to_tool_file "$1" func_convert_file_msys_to_w32
35536fae4e5dSmrg      win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
35549c9ff80cSmrg	$SED -n -e '
35559c9ff80cSmrg	    1,100{
35569c9ff80cSmrg		/ I /{
35579c9ff80cSmrg		    s,.*,import,
35589c9ff80cSmrg		    p
35599c9ff80cSmrg		    q
35609c9ff80cSmrg		}
35619c9ff80cSmrg	    }'`
35629c9ff80cSmrg      case $win32_nmres in
35639c9ff80cSmrg      import*)  win32_libid_type="x86 archive import";;
35649c9ff80cSmrg      *)        win32_libid_type="x86 archive static";;
35659c9ff80cSmrg      esac
35669c9ff80cSmrg    fi
35679c9ff80cSmrg    ;;
35689c9ff80cSmrg  *DLL*)
35699c9ff80cSmrg    win32_libid_type="x86 DLL"
35709c9ff80cSmrg    ;;
35719c9ff80cSmrg  *executable*) # but shell scripts are "executable" too...
35729c9ff80cSmrg    case $win32_fileres in
35739c9ff80cSmrg    *MS\ Windows\ PE\ Intel*)
35749c9ff80cSmrg      win32_libid_type="x86 DLL"
35759c9ff80cSmrg      ;;
35769c9ff80cSmrg    esac
35779c9ff80cSmrg    ;;
35789c9ff80cSmrg  esac
35799c9ff80cSmrg  $ECHO "$win32_libid_type"
35809c9ff80cSmrg}
35811f0ac6a5Smrg
35826fae4e5dSmrg# func_cygming_dll_for_implib ARG
35836fae4e5dSmrg#
35846fae4e5dSmrg# Platform-specific function to extract the
35856fae4e5dSmrg# name of the DLL associated with the specified
35866fae4e5dSmrg# import library ARG.
35876fae4e5dSmrg# Invoked by eval'ing the libtool variable
35886fae4e5dSmrg#    $sharedlib_from_linklib_cmd
35896fae4e5dSmrg# Result is available in the variable
35906fae4e5dSmrg#    $sharedlib_from_linklib_result
35916fae4e5dSmrgfunc_cygming_dll_for_implib ()
35926fae4e5dSmrg{
35936fae4e5dSmrg  $opt_debug
35946fae4e5dSmrg  sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
35956fae4e5dSmrg}
35966fae4e5dSmrg
35976fae4e5dSmrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs
35986fae4e5dSmrg#
35996fae4e5dSmrg# The is the core of a fallback implementation of a
36006fae4e5dSmrg# platform-specific function to extract the name of the
36016fae4e5dSmrg# DLL associated with the specified import library LIBNAME.
36026fae4e5dSmrg#
36036fae4e5dSmrg# SECTION_NAME is either .idata$6 or .idata$7, depending
36046fae4e5dSmrg# on the platform and compiler that created the implib.
36056fae4e5dSmrg#
36066fae4e5dSmrg# Echos the name of the DLL associated with the
36076fae4e5dSmrg# specified import library.
36086fae4e5dSmrgfunc_cygming_dll_for_implib_fallback_core ()
36096fae4e5dSmrg{
36106fae4e5dSmrg  $opt_debug
36116fae4e5dSmrg  match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
36126fae4e5dSmrg  $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
36136fae4e5dSmrg    $SED '/^Contents of section '"$match_literal"':/{
36146fae4e5dSmrg      # Place marker at beginning of archive member dllname section
36156fae4e5dSmrg      s/.*/====MARK====/
36166fae4e5dSmrg      p
36176fae4e5dSmrg      d
36186fae4e5dSmrg    }
36196fae4e5dSmrg    # These lines can sometimes be longer than 43 characters, but
36206fae4e5dSmrg    # are always uninteresting
36216fae4e5dSmrg    /:[	 ]*file format pe[i]\{,1\}-/d
36226fae4e5dSmrg    /^In archive [^:]*:/d
36236fae4e5dSmrg    # Ensure marker is printed
36246fae4e5dSmrg    /^====MARK====/p
36256fae4e5dSmrg    # Remove all lines with less than 43 characters
36266fae4e5dSmrg    /^.\{43\}/!d
36276fae4e5dSmrg    # From remaining lines, remove first 43 characters
36286fae4e5dSmrg    s/^.\{43\}//' |
36296fae4e5dSmrg    $SED -n '
36306fae4e5dSmrg      # Join marker and all lines until next marker into a single line
36316fae4e5dSmrg      /^====MARK====/ b para
36326fae4e5dSmrg      H
36336fae4e5dSmrg      $ b para
36346fae4e5dSmrg      b
36356fae4e5dSmrg      :para
36366fae4e5dSmrg      x
36376fae4e5dSmrg      s/\n//g
36386fae4e5dSmrg      # Remove the marker
36396fae4e5dSmrg      s/^====MARK====//
36406fae4e5dSmrg      # Remove trailing dots and whitespace
36416fae4e5dSmrg      s/[\. \t]*$//
36426fae4e5dSmrg      # Print
36436fae4e5dSmrg      /./p' |
36446fae4e5dSmrg    # we now have a list, one entry per line, of the stringified
36456fae4e5dSmrg    # contents of the appropriate section of all members of the
36466fae4e5dSmrg    # archive which possess that section. Heuristic: eliminate
36476fae4e5dSmrg    # all those which have a first or second character that is
36486fae4e5dSmrg    # a '.' (that is, objdump's representation of an unprintable
36496fae4e5dSmrg    # character.) This should work for all archives with less than
36506fae4e5dSmrg    # 0x302f exports -- but will fail for DLLs whose name actually
36516fae4e5dSmrg    # begins with a literal '.' or a single character followed by
36526fae4e5dSmrg    # a '.'.
36536fae4e5dSmrg    #
36546fae4e5dSmrg    # Of those that remain, print the first one.
36556fae4e5dSmrg    $SED -e '/^\./d;/^.\./d;q'
36566fae4e5dSmrg}
36576fae4e5dSmrg
36586fae4e5dSmrg# func_cygming_gnu_implib_p ARG
36596fae4e5dSmrg# This predicate returns with zero status (TRUE) if
36606fae4e5dSmrg# ARG is a GNU/binutils-style import library. Returns
36616fae4e5dSmrg# with nonzero status (FALSE) otherwise.
36626fae4e5dSmrgfunc_cygming_gnu_implib_p ()
36636fae4e5dSmrg{
36646fae4e5dSmrg  $opt_debug
36656fae4e5dSmrg  func_to_tool_file "$1" func_convert_file_msys_to_w32
36666fae4e5dSmrg  func_cygming_gnu_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'`
36676fae4e5dSmrg  test -n "$func_cygming_gnu_implib_tmp"
36686fae4e5dSmrg}
36696fae4e5dSmrg
36706fae4e5dSmrg# func_cygming_ms_implib_p ARG
36716fae4e5dSmrg# This predicate returns with zero status (TRUE) if
36726fae4e5dSmrg# ARG is an MS-style import library. Returns
36736fae4e5dSmrg# with nonzero status (FALSE) otherwise.
36746fae4e5dSmrgfunc_cygming_ms_implib_p ()
36756fae4e5dSmrg{
36766fae4e5dSmrg  $opt_debug
36776fae4e5dSmrg  func_to_tool_file "$1" func_convert_file_msys_to_w32
36786fae4e5dSmrg  func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
36796fae4e5dSmrg  test -n "$func_cygming_ms_implib_tmp"
36806fae4e5dSmrg}
36816fae4e5dSmrg
36826fae4e5dSmrg# func_cygming_dll_for_implib_fallback ARG
36836fae4e5dSmrg# Platform-specific function to extract the
36846fae4e5dSmrg# name of the DLL associated with the specified
36856fae4e5dSmrg# import library ARG.
36866fae4e5dSmrg#
36876fae4e5dSmrg# This fallback implementation is for use when $DLLTOOL
36886fae4e5dSmrg# does not support the --identify-strict option.
36896fae4e5dSmrg# Invoked by eval'ing the libtool variable
36906fae4e5dSmrg#    $sharedlib_from_linklib_cmd
36916fae4e5dSmrg# Result is available in the variable
36926fae4e5dSmrg#    $sharedlib_from_linklib_result
36936fae4e5dSmrgfunc_cygming_dll_for_implib_fallback ()
36946fae4e5dSmrg{
36956fae4e5dSmrg  $opt_debug
36966fae4e5dSmrg  if func_cygming_gnu_implib_p "$1" ; then
36976fae4e5dSmrg    # binutils import library
36986fae4e5dSmrg    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
36996fae4e5dSmrg  elif func_cygming_ms_implib_p "$1" ; then
37006fae4e5dSmrg    # ms-generated import library
37016fae4e5dSmrg    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
37026fae4e5dSmrg  else
37036fae4e5dSmrg    # unknown
37046fae4e5dSmrg    sharedlib_from_linklib_result=""
37056fae4e5dSmrg  fi
37066fae4e5dSmrg}
37071f0ac6a5Smrg
37081f0ac6a5Smrg
37099c9ff80cSmrg# func_extract_an_archive dir oldlib
37109c9ff80cSmrgfunc_extract_an_archive ()
37119c9ff80cSmrg{
37129c9ff80cSmrg    $opt_debug
37139c9ff80cSmrg    f_ex_an_ar_dir="$1"; shift
37149c9ff80cSmrg    f_ex_an_ar_oldlib="$1"
37156fae4e5dSmrg    if test "$lock_old_archive_extraction" = yes; then
37166fae4e5dSmrg      lockfile=$f_ex_an_ar_oldlib.lock
37176fae4e5dSmrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
37186fae4e5dSmrg	func_echo "Waiting for $lockfile to be removed"
37196fae4e5dSmrg	sleep 2
37206fae4e5dSmrg      done
37216fae4e5dSmrg    fi
37226fae4e5dSmrg    func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
37236fae4e5dSmrg		   'stat=$?; rm -f "$lockfile"; exit $stat'
37246fae4e5dSmrg    if test "$lock_old_archive_extraction" = yes; then
37256fae4e5dSmrg      $opt_dry_run || rm -f "$lockfile"
37266fae4e5dSmrg    fi
37279c9ff80cSmrg    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
37289c9ff80cSmrg     :
37299c9ff80cSmrg    else
37309c9ff80cSmrg      func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
37319c9ff80cSmrg    fi
37329c9ff80cSmrg}
37331f0ac6a5Smrg
37341f0ac6a5Smrg
37359c9ff80cSmrg# func_extract_archives gentop oldlib ...
37369c9ff80cSmrgfunc_extract_archives ()
37379c9ff80cSmrg{
37389c9ff80cSmrg    $opt_debug
37399c9ff80cSmrg    my_gentop="$1"; shift
37409c9ff80cSmrg    my_oldlibs=${1+"$@"}
37419c9ff80cSmrg    my_oldobjs=""
37429c9ff80cSmrg    my_xlib=""
37439c9ff80cSmrg    my_xabs=""
37449c9ff80cSmrg    my_xdir=""
37451f0ac6a5Smrg
37469c9ff80cSmrg    for my_xlib in $my_oldlibs; do
37479c9ff80cSmrg      # Extract the objects.
37489c9ff80cSmrg      case $my_xlib in
37499c9ff80cSmrg	[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
37509c9ff80cSmrg	*) my_xabs=`pwd`"/$my_xlib" ;;
37519c9ff80cSmrg      esac
37529c9ff80cSmrg      func_basename "$my_xlib"
37539c9ff80cSmrg      my_xlib="$func_basename_result"
37549c9ff80cSmrg      my_xlib_u=$my_xlib
37559c9ff80cSmrg      while :; do
37569c9ff80cSmrg        case " $extracted_archives " in
37579c9ff80cSmrg	*" $my_xlib_u "*)
37589c9ff80cSmrg	  func_arith $extracted_serial + 1
37599c9ff80cSmrg	  extracted_serial=$func_arith_result
37609c9ff80cSmrg	  my_xlib_u=lt$extracted_serial-$my_xlib ;;
37619c9ff80cSmrg	*) break ;;
37629c9ff80cSmrg	esac
37639c9ff80cSmrg      done
37649c9ff80cSmrg      extracted_archives="$extracted_archives $my_xlib_u"
37659c9ff80cSmrg      my_xdir="$my_gentop/$my_xlib_u"
37661f0ac6a5Smrg
37679c9ff80cSmrg      func_mkdir_p "$my_xdir"
37681f0ac6a5Smrg
37699c9ff80cSmrg      case $host in
37709c9ff80cSmrg      *-darwin*)
37719c9ff80cSmrg	func_verbose "Extracting $my_xabs"
37729c9ff80cSmrg	# Do not bother doing anything if just a dry run
37739c9ff80cSmrg	$opt_dry_run || {
37749c9ff80cSmrg	  darwin_orig_dir=`pwd`
37759c9ff80cSmrg	  cd $my_xdir || exit $?
37769c9ff80cSmrg	  darwin_archive=$my_xabs
37779c9ff80cSmrg	  darwin_curdir=`pwd`
37789c9ff80cSmrg	  darwin_base_archive=`basename "$darwin_archive"`
37799c9ff80cSmrg	  darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
37809c9ff80cSmrg	  if test -n "$darwin_arches"; then
37819c9ff80cSmrg	    darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
37829c9ff80cSmrg	    darwin_arch=
37839c9ff80cSmrg	    func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
37849c9ff80cSmrg	    for darwin_arch in  $darwin_arches ; do
37859c9ff80cSmrg	      func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
37869c9ff80cSmrg	      $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
37879c9ff80cSmrg	      cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
37889c9ff80cSmrg	      func_extract_an_archive "`pwd`" "${darwin_base_archive}"
37899c9ff80cSmrg	      cd "$darwin_curdir"
37909c9ff80cSmrg	      $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
37919c9ff80cSmrg	    done # $darwin_arches
37929c9ff80cSmrg            ## Okay now we've a bunch of thin objects, gotta fatten them up :)
37939c9ff80cSmrg	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u`
37949c9ff80cSmrg	    darwin_file=
37959c9ff80cSmrg	    darwin_files=
37969c9ff80cSmrg	    for darwin_file in $darwin_filelist; do
37976fae4e5dSmrg	      darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`
37989c9ff80cSmrg	      $LIPO -create -output "$darwin_file" $darwin_files
37999c9ff80cSmrg	    done # $darwin_filelist
38009c9ff80cSmrg	    $RM -rf unfat-$$
38019c9ff80cSmrg	    cd "$darwin_orig_dir"
38021f0ac6a5Smrg	  else
38039c9ff80cSmrg	    cd $darwin_orig_dir
38049c9ff80cSmrg	    func_extract_an_archive "$my_xdir" "$my_xabs"
38059c9ff80cSmrg	  fi # $darwin_arches
38069c9ff80cSmrg	} # !$opt_dry_run
38079c9ff80cSmrg	;;
38089c9ff80cSmrg      *)
38099c9ff80cSmrg        func_extract_an_archive "$my_xdir" "$my_xabs"
38109c9ff80cSmrg	;;
38119c9ff80cSmrg      esac
38126fae4e5dSmrg      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
38139c9ff80cSmrg    done
38141f0ac6a5Smrg
38159c9ff80cSmrg    func_extract_archives_result="$my_oldobjs"
38169c9ff80cSmrg}
38171f0ac6a5Smrg
38181f0ac6a5Smrg
38196fae4e5dSmrg# func_emit_wrapper [arg=no]
38206fae4e5dSmrg#
38216fae4e5dSmrg# Emit a libtool wrapper script on stdout.
38226fae4e5dSmrg# Don't directly open a file because we may want to
38236fae4e5dSmrg# incorporate the script contents within a cygwin/mingw
38246fae4e5dSmrg# wrapper executable.  Must ONLY be called from within
38256fae4e5dSmrg# func_mode_link because it depends on a number of variables
38266fae4e5dSmrg# set therein.
38279c9ff80cSmrg#
38286fae4e5dSmrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
38296fae4e5dSmrg# variable will take.  If 'yes', then the emitted script
38306fae4e5dSmrg# will assume that the directory in which it is stored is
38316fae4e5dSmrg# the $objdir directory.  This is a cygwin/mingw-specific
38326fae4e5dSmrg# behavior.
38336fae4e5dSmrgfunc_emit_wrapper ()
38349c9ff80cSmrg{
38356fae4e5dSmrg	func_emit_wrapper_arg1=${1-no}
38361f0ac6a5Smrg
38379c9ff80cSmrg	$ECHO "\
38389c9ff80cSmrg#! $SHELL
38391f0ac6a5Smrg
38409c9ff80cSmrg# $output - temporary wrapper script for $objdir/$outputname
38419c9ff80cSmrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
38429c9ff80cSmrg#
38439c9ff80cSmrg# The $output program cannot be directly executed until all the libtool
38449c9ff80cSmrg# libraries that it depends on are installed.
38459c9ff80cSmrg#
38469c9ff80cSmrg# This wrapper script should never be moved out of the build directory.
38479c9ff80cSmrg# If it is, it will not operate correctly.
38481f0ac6a5Smrg
38499c9ff80cSmrg# Sed substitution that helps us do robust quoting.  It backslashifies
38509c9ff80cSmrg# metacharacters that are still active within double-quoted strings.
38519c9ff80cSmrgsed_quote_subst='$sed_quote_subst'
38521f0ac6a5Smrg
38539c9ff80cSmrg# Be Bourne compatible
38549c9ff80cSmrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
38559c9ff80cSmrg  emulate sh
38569c9ff80cSmrg  NULLCMD=:
38579c9ff80cSmrg  # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
38589c9ff80cSmrg  # is contrary to our usage.  Disable this feature.
38599c9ff80cSmrg  alias -g '\${1+\"\$@\"}'='\"\$@\"'
38609c9ff80cSmrg  setopt NO_GLOB_SUBST
38619c9ff80cSmrgelse
38629c9ff80cSmrg  case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
38639c9ff80cSmrgfi
38649c9ff80cSmrgBIN_SH=xpg4; export BIN_SH # for Tru64
38659c9ff80cSmrgDUALCASE=1; export DUALCASE # for MKS sh
38661f0ac6a5Smrg
38679c9ff80cSmrg# The HP-UX ksh and POSIX shell print the target directory to stdout
38689c9ff80cSmrg# if CDPATH is set.
38699c9ff80cSmrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
38701f0ac6a5Smrg
38719c9ff80cSmrgrelink_command=\"$relink_command\"
38721f0ac6a5Smrg
38739c9ff80cSmrg# This environment variable determines our operation mode.
38749c9ff80cSmrgif test \"\$libtool_install_magic\" = \"$magic\"; then
38759c9ff80cSmrg  # install mode needs the following variables:
38769c9ff80cSmrg  generated_by_libtool_version='$macro_version'
38779c9ff80cSmrg  notinst_deplibs='$notinst_deplibs'
38789c9ff80cSmrgelse
38799c9ff80cSmrg  # When we are sourced in execute mode, \$file and \$ECHO are already set.
38809c9ff80cSmrg  if test \"\$libtool_execute_magic\" != \"$magic\"; then
38816fae4e5dSmrg    file=\"\$0\""
38826fae4e5dSmrg
38836fae4e5dSmrg    qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"`
38846fae4e5dSmrg    $ECHO "\
38856fae4e5dSmrg
38866fae4e5dSmrg# A function that is used when there is no print builtin or printf.
38876fae4e5dSmrgfunc_fallback_echo ()
38886fae4e5dSmrg{
38896fae4e5dSmrg  eval 'cat <<_LTECHO_EOF
38906fae4e5dSmrg\$1
38916fae4e5dSmrg_LTECHO_EOF'
38926fae4e5dSmrg}
38936fae4e5dSmrg    ECHO=\"$qECHO\"
38946fae4e5dSmrg  fi
38956fae4e5dSmrg
38966fae4e5dSmrg# Very basic option parsing. These options are (a) specific to
38976fae4e5dSmrg# the libtool wrapper, (b) are identical between the wrapper
38986fae4e5dSmrg# /script/ and the wrapper /executable/ which is used only on
38996fae4e5dSmrg# windows platforms, and (c) all begin with the string "--lt-"
39006fae4e5dSmrg# (application programs are unlikely to have options which match
39016fae4e5dSmrg# this pattern).
39026fae4e5dSmrg#
39036fae4e5dSmrg# There are only two supported options: --lt-debug and
39046fae4e5dSmrg# --lt-dump-script. There is, deliberately, no --lt-help.
39056fae4e5dSmrg#
39066fae4e5dSmrg# The first argument to this parsing function should be the
39076fae4e5dSmrg# script's $0 value, followed by "$@".
39086fae4e5dSmrglt_option_debug=
39096fae4e5dSmrgfunc_parse_lt_options ()
39106fae4e5dSmrg{
39116fae4e5dSmrg  lt_script_arg0=\$0
39126fae4e5dSmrg  shift
39136fae4e5dSmrg  for lt_opt
39146fae4e5dSmrg  do
39156fae4e5dSmrg    case \"\$lt_opt\" in
39166fae4e5dSmrg    --lt-debug) lt_option_debug=1 ;;
39176fae4e5dSmrg    --lt-dump-script)
39186fae4e5dSmrg        lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
39196fae4e5dSmrg        test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
39206fae4e5dSmrg        lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
39216fae4e5dSmrg        cat \"\$lt_dump_D/\$lt_dump_F\"
39226fae4e5dSmrg        exit 0
39236fae4e5dSmrg      ;;
39246fae4e5dSmrg    --lt-*)
39256fae4e5dSmrg        \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
39266fae4e5dSmrg        exit 1
39276fae4e5dSmrg      ;;
39286fae4e5dSmrg    esac
39296fae4e5dSmrg  done
39306fae4e5dSmrg
39316fae4e5dSmrg  # Print the debug banner immediately:
39326fae4e5dSmrg  if test -n \"\$lt_option_debug\"; then
39336fae4e5dSmrg    echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2
39346fae4e5dSmrg  fi
39356fae4e5dSmrg}
39366fae4e5dSmrg
39376fae4e5dSmrg# Used when --lt-debug. Prints its arguments to stdout
39386fae4e5dSmrg# (redirection is the responsibility of the caller)
39396fae4e5dSmrgfunc_lt_dump_args ()
39406fae4e5dSmrg{
39416fae4e5dSmrg  lt_dump_args_N=1;
39426fae4e5dSmrg  for lt_arg
39436fae4e5dSmrg  do
39446fae4e5dSmrg    \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\"
39456fae4e5dSmrg    lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
39466fae4e5dSmrg  done
39476fae4e5dSmrg}
39486fae4e5dSmrg
39496fae4e5dSmrg# Core function for launching the target application
39506fae4e5dSmrgfunc_exec_program_core ()
39516fae4e5dSmrg{
39529c9ff80cSmrg"
39536fae4e5dSmrg  case $host in
39546fae4e5dSmrg  # Backslashes separate directories on plain windows
39556fae4e5dSmrg  *-*-mingw | *-*-os2* | *-cegcc*)
39566fae4e5dSmrg    $ECHO "\
39576fae4e5dSmrg      if test -n \"\$lt_option_debug\"; then
39586fae4e5dSmrg        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2
39596fae4e5dSmrg        func_lt_dump_args \${1+\"\$@\"} 1>&2
39606fae4e5dSmrg      fi
39616fae4e5dSmrg      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
39626fae4e5dSmrg"
39636fae4e5dSmrg    ;;
39646fae4e5dSmrg
39656fae4e5dSmrg  *)
39666fae4e5dSmrg    $ECHO "\
39676fae4e5dSmrg      if test -n \"\$lt_option_debug\"; then
39686fae4e5dSmrg        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2
39696fae4e5dSmrg        func_lt_dump_args \${1+\"\$@\"} 1>&2
39706fae4e5dSmrg      fi
39716fae4e5dSmrg      exec \"\$progdir/\$program\" \${1+\"\$@\"}
39726fae4e5dSmrg"
39736fae4e5dSmrg    ;;
39746fae4e5dSmrg  esac
39756fae4e5dSmrg  $ECHO "\
39766fae4e5dSmrg      \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
39776fae4e5dSmrg      exit 1
39786fae4e5dSmrg}
39796fae4e5dSmrg
39806fae4e5dSmrg# A function to encapsulate launching the target application
39816fae4e5dSmrg# Strips options in the --lt-* namespace from \$@ and
39826fae4e5dSmrg# launches target application with the remaining arguments.
39836fae4e5dSmrgfunc_exec_program ()
39846fae4e5dSmrg{
39856fae4e5dSmrg  for lt_wr_arg
39866fae4e5dSmrg  do
39876fae4e5dSmrg    case \$lt_wr_arg in
39886fae4e5dSmrg    --lt-*) ;;
39896fae4e5dSmrg    *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
39906fae4e5dSmrg    esac
39916fae4e5dSmrg    shift
39926fae4e5dSmrg  done
39936fae4e5dSmrg  func_exec_program_core \${1+\"\$@\"}
39946fae4e5dSmrg}
39956fae4e5dSmrg
39966fae4e5dSmrg  # Parse options
39976fae4e5dSmrg  func_parse_lt_options \"\$0\" \${1+\"\$@\"}
39981f0ac6a5Smrg
39999c9ff80cSmrg  # Find the directory that this script lives in.
40006fae4e5dSmrg  thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
40019c9ff80cSmrg  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
40021f0ac6a5Smrg
40039c9ff80cSmrg  # Follow symbolic links until we get to the real thisdir.
40046fae4e5dSmrg  file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
40059c9ff80cSmrg  while test -n \"\$file\"; do
40066fae4e5dSmrg    destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
40071f0ac6a5Smrg
40089c9ff80cSmrg    # If there was a directory component, then change thisdir.
40099c9ff80cSmrg    if test \"x\$destdir\" != \"x\$file\"; then
40109c9ff80cSmrg      case \"\$destdir\" in
40119c9ff80cSmrg      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
40129c9ff80cSmrg      *) thisdir=\"\$thisdir/\$destdir\" ;;
40131f0ac6a5Smrg      esac
40149c9ff80cSmrg    fi
40151f0ac6a5Smrg
40166fae4e5dSmrg    file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
40176fae4e5dSmrg    file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
40189c9ff80cSmrg  done
40191f0ac6a5Smrg
40209c9ff80cSmrg  # Usually 'no', except on cygwin/mingw when embedded into
40219c9ff80cSmrg  # the cwrapper.
40226fae4e5dSmrg  WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
40239c9ff80cSmrg  if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
40249c9ff80cSmrg    # special case for '.'
40259c9ff80cSmrg    if test \"\$thisdir\" = \".\"; then
40269c9ff80cSmrg      thisdir=\`pwd\`
40279c9ff80cSmrg    fi
40289c9ff80cSmrg    # remove .libs from thisdir
40299c9ff80cSmrg    case \"\$thisdir\" in
40306fae4e5dSmrg    *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
40319c9ff80cSmrg    $objdir )   thisdir=. ;;
40329c9ff80cSmrg    esac
40339c9ff80cSmrg  fi
40349c9ff80cSmrg
40359c9ff80cSmrg  # Try to get the absolute directory name.
40369c9ff80cSmrg  absdir=\`cd \"\$thisdir\" && pwd\`
40379c9ff80cSmrg  test -n \"\$absdir\" && thisdir=\"\$absdir\"
40389c9ff80cSmrg"
40399c9ff80cSmrg
40409c9ff80cSmrg	if test "$fast_install" = yes; then
40419c9ff80cSmrg	  $ECHO "\
40429c9ff80cSmrg  program=lt-'$outputname'$exeext
40439c9ff80cSmrg  progdir=\"\$thisdir/$objdir\"
40449c9ff80cSmrg
40459c9ff80cSmrg  if test ! -f \"\$progdir/\$program\" ||
40469c9ff80cSmrg     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
40479c9ff80cSmrg       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
40489c9ff80cSmrg
40499c9ff80cSmrg    file=\"\$\$-\$program\"
40509c9ff80cSmrg
40519c9ff80cSmrg    if test ! -d \"\$progdir\"; then
40529c9ff80cSmrg      $MKDIR \"\$progdir\"
40539c9ff80cSmrg    else
40549c9ff80cSmrg      $RM \"\$progdir/\$file\"
40559c9ff80cSmrg    fi"
40569c9ff80cSmrg
40579c9ff80cSmrg	  $ECHO "\
40589c9ff80cSmrg
40599c9ff80cSmrg    # relink executable if necessary
40609c9ff80cSmrg    if test -n \"\$relink_command\"; then
40619c9ff80cSmrg      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
40629c9ff80cSmrg      else
40639c9ff80cSmrg	$ECHO \"\$relink_command_output\" >&2
40649c9ff80cSmrg	$RM \"\$progdir/\$file\"
40659c9ff80cSmrg	exit 1
40661f0ac6a5Smrg      fi
40679c9ff80cSmrg    fi
40681f0ac6a5Smrg
40699c9ff80cSmrg    $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
40709c9ff80cSmrg    { $RM \"\$progdir/\$program\";
40719c9ff80cSmrg      $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
40729c9ff80cSmrg    $RM \"\$progdir/\$file\"
40739c9ff80cSmrg  fi"
40749c9ff80cSmrg	else
40759c9ff80cSmrg	  $ECHO "\
40769c9ff80cSmrg  program='$outputname'
40779c9ff80cSmrg  progdir=\"\$thisdir/$objdir\"
40789c9ff80cSmrg"
40791f0ac6a5Smrg	fi
40801f0ac6a5Smrg
40819c9ff80cSmrg	$ECHO "\
40821f0ac6a5Smrg
40839c9ff80cSmrg  if test -f \"\$progdir/\$program\"; then"
40841f0ac6a5Smrg
40856fae4e5dSmrg	# fixup the dll searchpath if we need to.
40866fae4e5dSmrg	#
40876fae4e5dSmrg	# Fix the DLL searchpath if we need to.  Do this before prepending
40886fae4e5dSmrg	# to shlibpath, because on Windows, both are PATH and uninstalled
40896fae4e5dSmrg	# libraries must come first.
40906fae4e5dSmrg	if test -n "$dllsearchpath"; then
40916fae4e5dSmrg	  $ECHO "\
40926fae4e5dSmrg    # Add the dll search path components to the executable PATH
40936fae4e5dSmrg    PATH=$dllsearchpath:\$PATH
40946fae4e5dSmrg"
40956fae4e5dSmrg	fi
40966fae4e5dSmrg
40979c9ff80cSmrg	# Export our shlibpath_var if we have one.
40989c9ff80cSmrg	if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
40999c9ff80cSmrg	  $ECHO "\
41009c9ff80cSmrg    # Add our own library path to $shlibpath_var
41019c9ff80cSmrg    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
41029c9ff80cSmrg
41039c9ff80cSmrg    # Some systems cannot cope with colon-terminated $shlibpath_var
41049c9ff80cSmrg    # The second colon is a workaround for a bug in BeOS R4 sed
41056fae4e5dSmrg    $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
41061f0ac6a5Smrg
41079c9ff80cSmrg    export $shlibpath_var
41089c9ff80cSmrg"
41091f0ac6a5Smrg	fi
41101f0ac6a5Smrg
41119c9ff80cSmrg	$ECHO "\
41129c9ff80cSmrg    if test \"\$libtool_execute_magic\" != \"$magic\"; then
41139c9ff80cSmrg      # Run the actual program with our arguments.
41146fae4e5dSmrg      func_exec_program \${1+\"\$@\"}
41159c9ff80cSmrg    fi
41169c9ff80cSmrg  else
41179c9ff80cSmrg    # The program doesn't exist.
41189c9ff80cSmrg    \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
41199c9ff80cSmrg    \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
41206fae4e5dSmrg    \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
41219c9ff80cSmrg    exit 1
41229c9ff80cSmrg  fi
41239c9ff80cSmrgfi\
41249c9ff80cSmrg"
41259c9ff80cSmrg}
41261f0ac6a5Smrg
41271f0ac6a5Smrg
41289c9ff80cSmrg# func_emit_cwrapperexe_src
41299c9ff80cSmrg# emit the source code for a wrapper executable on stdout
41309c9ff80cSmrg# Must ONLY be called from within func_mode_link because
41319c9ff80cSmrg# it depends on a number of variable set therein.
41329c9ff80cSmrgfunc_emit_cwrapperexe_src ()
41339c9ff80cSmrg{
41349c9ff80cSmrg	cat <<EOF
41351f0ac6a5Smrg
41369c9ff80cSmrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
41379c9ff80cSmrg   Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
41381f0ac6a5Smrg
41399c9ff80cSmrg   The $output program cannot be directly executed until all the libtool
41409c9ff80cSmrg   libraries that it depends on are installed.
41411f0ac6a5Smrg
41429c9ff80cSmrg   This wrapper executable should never be moved out of the build directory.
41439c9ff80cSmrg   If it is, it will not operate correctly.
41449c9ff80cSmrg*/
41459c9ff80cSmrgEOF
41469c9ff80cSmrg	    cat <<"EOF"
41476fae4e5dSmrg#ifdef _MSC_VER
41486fae4e5dSmrg# define _CRT_SECURE_NO_DEPRECATE 1
41496fae4e5dSmrg#endif
41509c9ff80cSmrg#include <stdio.h>
41519c9ff80cSmrg#include <stdlib.h>
41529c9ff80cSmrg#ifdef _MSC_VER
41539c9ff80cSmrg# include <direct.h>
41549c9ff80cSmrg# include <process.h>
41559c9ff80cSmrg# include <io.h>
41569c9ff80cSmrg#else
41579c9ff80cSmrg# include <unistd.h>
41589c9ff80cSmrg# include <stdint.h>
41599c9ff80cSmrg# ifdef __CYGWIN__
41609c9ff80cSmrg#  include <io.h>
41619c9ff80cSmrg# endif
41629c9ff80cSmrg#endif
41639c9ff80cSmrg#include <malloc.h>
41649c9ff80cSmrg#include <stdarg.h>
41659c9ff80cSmrg#include <assert.h>
41669c9ff80cSmrg#include <string.h>
41679c9ff80cSmrg#include <ctype.h>
41689c9ff80cSmrg#include <errno.h>
41699c9ff80cSmrg#include <fcntl.h>
41709c9ff80cSmrg#include <sys/stat.h>
41711f0ac6a5Smrg
41726fae4e5dSmrg/* declarations of non-ANSI functions */
41736fae4e5dSmrg#if defined(__MINGW32__)
41746fae4e5dSmrg# ifdef __STRICT_ANSI__
41756fae4e5dSmrgint _putenv (const char *);
41766fae4e5dSmrg# endif
41776fae4e5dSmrg#elif defined(__CYGWIN__)
41786fae4e5dSmrg# ifdef __STRICT_ANSI__
41796fae4e5dSmrgchar *realpath (const char *, char *);
41806fae4e5dSmrgint putenv (char *);
41816fae4e5dSmrgint setenv (const char *, const char *, int);
41826fae4e5dSmrg# endif
41836fae4e5dSmrg/* #elif defined (other platforms) ... */
41846fae4e5dSmrg#endif
41856fae4e5dSmrg
41866fae4e5dSmrg/* portability defines, excluding path handling macros */
41876fae4e5dSmrg#if defined(_MSC_VER)
41886fae4e5dSmrg# define setmode _setmode
41896fae4e5dSmrg# define stat    _stat
41906fae4e5dSmrg# define chmod   _chmod
41916fae4e5dSmrg# define getcwd  _getcwd
41926fae4e5dSmrg# define putenv  _putenv
41936fae4e5dSmrg# define S_IXUSR _S_IEXEC
41946fae4e5dSmrg# ifndef _INTPTR_T_DEFINED
41956fae4e5dSmrg#  define _INTPTR_T_DEFINED
41966fae4e5dSmrg#  define intptr_t int
41976fae4e5dSmrg# endif
41986fae4e5dSmrg#elif defined(__MINGW32__)
41996fae4e5dSmrg# define setmode _setmode
42006fae4e5dSmrg# define stat    _stat
42016fae4e5dSmrg# define chmod   _chmod
42026fae4e5dSmrg# define getcwd  _getcwd
42036fae4e5dSmrg# define putenv  _putenv
42046fae4e5dSmrg#elif defined(__CYGWIN__)
42056fae4e5dSmrg# define HAVE_SETENV
42066fae4e5dSmrg# define FOPEN_WB "wb"
42076fae4e5dSmrg/* #elif defined (other platforms) ... */
42086fae4e5dSmrg#endif
42096fae4e5dSmrg
42109c9ff80cSmrg#if defined(PATH_MAX)
42119c9ff80cSmrg# define LT_PATHMAX PATH_MAX
42129c9ff80cSmrg#elif defined(MAXPATHLEN)
42139c9ff80cSmrg# define LT_PATHMAX MAXPATHLEN
42149c9ff80cSmrg#else
42159c9ff80cSmrg# define LT_PATHMAX 1024
42169c9ff80cSmrg#endif
42171f0ac6a5Smrg
42189c9ff80cSmrg#ifndef S_IXOTH
42199c9ff80cSmrg# define S_IXOTH 0
42209c9ff80cSmrg#endif
42219c9ff80cSmrg#ifndef S_IXGRP
42229c9ff80cSmrg# define S_IXGRP 0
42239c9ff80cSmrg#endif
42241f0ac6a5Smrg
42256fae4e5dSmrg/* path handling portability macros */
42269c9ff80cSmrg#ifndef DIR_SEPARATOR
42279c9ff80cSmrg# define DIR_SEPARATOR '/'
42289c9ff80cSmrg# define PATH_SEPARATOR ':'
42299c9ff80cSmrg#endif
42301f0ac6a5Smrg
42319c9ff80cSmrg#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
42329c9ff80cSmrg  defined (__OS2__)
42339c9ff80cSmrg# define HAVE_DOS_BASED_FILE_SYSTEM
42349c9ff80cSmrg# define FOPEN_WB "wb"
42359c9ff80cSmrg# ifndef DIR_SEPARATOR_2
42369c9ff80cSmrg#  define DIR_SEPARATOR_2 '\\'
42379c9ff80cSmrg# endif
42389c9ff80cSmrg# ifndef PATH_SEPARATOR_2
42399c9ff80cSmrg#  define PATH_SEPARATOR_2 ';'
42409c9ff80cSmrg# endif
42419c9ff80cSmrg#endif
42421f0ac6a5Smrg
42439c9ff80cSmrg#ifndef DIR_SEPARATOR_2
42449c9ff80cSmrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
42459c9ff80cSmrg#else /* DIR_SEPARATOR_2 */
42469c9ff80cSmrg# define IS_DIR_SEPARATOR(ch) \
42479c9ff80cSmrg	(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
42489c9ff80cSmrg#endif /* DIR_SEPARATOR_2 */
42491f0ac6a5Smrg
42509c9ff80cSmrg#ifndef PATH_SEPARATOR_2
42519c9ff80cSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
42529c9ff80cSmrg#else /* PATH_SEPARATOR_2 */
42539c9ff80cSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
42549c9ff80cSmrg#endif /* PATH_SEPARATOR_2 */
42551f0ac6a5Smrg
42569c9ff80cSmrg#ifndef FOPEN_WB
42579c9ff80cSmrg# define FOPEN_WB "w"
42589c9ff80cSmrg#endif
42599c9ff80cSmrg#ifndef _O_BINARY
42609c9ff80cSmrg# define _O_BINARY 0
42619c9ff80cSmrg#endif
42621f0ac6a5Smrg
42639c9ff80cSmrg#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
42649c9ff80cSmrg#define XFREE(stale) do { \
42659c9ff80cSmrg  if (stale) { free ((void *) stale); stale = 0; } \
42669c9ff80cSmrg} while (0)
42671f0ac6a5Smrg
42686fae4e5dSmrg#if defined(LT_DEBUGWRAPPER)
42696fae4e5dSmrgstatic int lt_debug = 1;
42709c9ff80cSmrg#else
42716fae4e5dSmrgstatic int lt_debug = 0;
42729c9ff80cSmrg#endif
42731f0ac6a5Smrg
42746fae4e5dSmrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */
42751f0ac6a5Smrg
42769c9ff80cSmrgvoid *xmalloc (size_t num);
42779c9ff80cSmrgchar *xstrdup (const char *string);
42789c9ff80cSmrgconst char *base_name (const char *name);
42799c9ff80cSmrgchar *find_executable (const char *wrapper);
42809c9ff80cSmrgchar *chase_symlinks (const char *pathspec);
42819c9ff80cSmrgint make_executable (const char *path);
42829c9ff80cSmrgint check_executable (const char *path);
42839c9ff80cSmrgchar *strendzap (char *str, const char *pat);
42846fae4e5dSmrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...);
42856fae4e5dSmrgvoid lt_fatal (const char *file, int line, const char *message, ...);
42866fae4e5dSmrgstatic const char *nonnull (const char *s);
42876fae4e5dSmrgstatic const char *nonempty (const char *s);
42889c9ff80cSmrgvoid lt_setenv (const char *name, const char *value);
42899c9ff80cSmrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end);
42909c9ff80cSmrgvoid lt_update_exe_path (const char *name, const char *value);
42919c9ff80cSmrgvoid lt_update_lib_path (const char *name, const char *value);
42926fae4e5dSmrgchar **prepare_spawn (char **argv);
42936fae4e5dSmrgvoid lt_dump_script (FILE *f);
42949c9ff80cSmrgEOF
42959c9ff80cSmrg
42969c9ff80cSmrg	    cat <<EOF
42976fae4e5dSmrgvolatile const char * MAGIC_EXE = "$magic_exe";
42989c9ff80cSmrgconst char * LIB_PATH_VARNAME = "$shlibpath_var";
42999c9ff80cSmrgEOF
43001f0ac6a5Smrg
43019c9ff80cSmrg	    if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
43026fae4e5dSmrg              func_to_host_path "$temp_rpath"
43039c9ff80cSmrg	      cat <<EOF
43046fae4e5dSmrgconst char * LIB_PATH_VALUE   = "$func_to_host_path_result";
43059c9ff80cSmrgEOF
43069c9ff80cSmrg	    else
43079c9ff80cSmrg	      cat <<"EOF"
43089c9ff80cSmrgconst char * LIB_PATH_VALUE   = "";
43099c9ff80cSmrgEOF
43101f0ac6a5Smrg	    fi
43111f0ac6a5Smrg
43129c9ff80cSmrg	    if test -n "$dllsearchpath"; then
43136fae4e5dSmrg              func_to_host_path "$dllsearchpath:"
43149c9ff80cSmrg	      cat <<EOF
43159c9ff80cSmrgconst char * EXE_PATH_VARNAME = "PATH";
43166fae4e5dSmrgconst char * EXE_PATH_VALUE   = "$func_to_host_path_result";
43171f0ac6a5SmrgEOF
43181f0ac6a5Smrg	    else
43199c9ff80cSmrg	      cat <<"EOF"
43209c9ff80cSmrgconst char * EXE_PATH_VARNAME = "";
43219c9ff80cSmrgconst char * EXE_PATH_VALUE   = "";
43229c9ff80cSmrgEOF
43231f0ac6a5Smrg	    fi
43249c9ff80cSmrg
43259c9ff80cSmrg	    if test "$fast_install" = yes; then
43269c9ff80cSmrg	      cat <<EOF
43279c9ff80cSmrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
43289c9ff80cSmrgEOF
43291f0ac6a5Smrg	    else
43309c9ff80cSmrg	      cat <<EOF
43319c9ff80cSmrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
43329c9ff80cSmrgEOF
43331f0ac6a5Smrg	    fi
43341f0ac6a5Smrg
43351f0ac6a5Smrg
43369c9ff80cSmrg	    cat <<"EOF"
43371f0ac6a5Smrg
43389c9ff80cSmrg#define LTWRAPPER_OPTION_PREFIX         "--lt-"
43391f0ac6a5Smrg
43409c9ff80cSmrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
43419c9ff80cSmrgstatic const char *dumpscript_opt       = LTWRAPPER_OPTION_PREFIX "dump-script";
43426fae4e5dSmrgstatic const char *debug_opt            = LTWRAPPER_OPTION_PREFIX "debug";
43431f0ac6a5Smrg
43449c9ff80cSmrgint
43459c9ff80cSmrgmain (int argc, char *argv[])
43469c9ff80cSmrg{
43479c9ff80cSmrg  char **newargz;
43489c9ff80cSmrg  int  newargc;
43499c9ff80cSmrg  char *tmp_pathspec;
43509c9ff80cSmrg  char *actual_cwrapper_path;
43519c9ff80cSmrg  char *actual_cwrapper_name;
43529c9ff80cSmrg  char *target_name;
43539c9ff80cSmrg  char *lt_argv_zero;
43549c9ff80cSmrg  intptr_t rval = 127;
43551f0ac6a5Smrg
43569c9ff80cSmrg  int i;
43571f0ac6a5Smrg
43589c9ff80cSmrg  program_name = (char *) xstrdup (base_name (argv[0]));
43596fae4e5dSmrg  newargz = XMALLOC (char *, argc + 1);
43601f0ac6a5Smrg
43616fae4e5dSmrg  /* very simple arg parsing; don't want to rely on getopt
43626fae4e5dSmrg   * also, copy all non cwrapper options to newargz, except
43636fae4e5dSmrg   * argz[0], which is handled differently
43646fae4e5dSmrg   */
43656fae4e5dSmrg  newargc=0;
43669c9ff80cSmrg  for (i = 1; i < argc; i++)
43679c9ff80cSmrg    {
43689c9ff80cSmrg      if (strcmp (argv[i], dumpscript_opt) == 0)
43699c9ff80cSmrg	{
43709c9ff80cSmrgEOF
43719c9ff80cSmrg	    case "$host" in
43729c9ff80cSmrg	      *mingw* | *cygwin* )
43739c9ff80cSmrg		# make stdout use "unix" line endings
43749c9ff80cSmrg		echo "          setmode(1,_O_BINARY);"
43759c9ff80cSmrg		;;
43769c9ff80cSmrg	      esac
43771f0ac6a5Smrg
43789c9ff80cSmrg	    cat <<"EOF"
43796fae4e5dSmrg	  lt_dump_script (stdout);
43809c9ff80cSmrg	  return 0;
43819c9ff80cSmrg	}
43826fae4e5dSmrg      if (strcmp (argv[i], debug_opt) == 0)
43836fae4e5dSmrg	{
43846fae4e5dSmrg          lt_debug = 1;
43856fae4e5dSmrg          continue;
43866fae4e5dSmrg	}
43876fae4e5dSmrg      if (strcmp (argv[i], ltwrapper_option_prefix) == 0)
43886fae4e5dSmrg        {
43896fae4e5dSmrg          /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
43906fae4e5dSmrg             namespace, but it is not one of the ones we know about and
43916fae4e5dSmrg             have already dealt with, above (inluding dump-script), then
43926fae4e5dSmrg             report an error. Otherwise, targets might begin to believe
43936fae4e5dSmrg             they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
43946fae4e5dSmrg             namespace. The first time any user complains about this, we'll
43956fae4e5dSmrg             need to make LTWRAPPER_OPTION_PREFIX a configure-time option
43966fae4e5dSmrg             or a configure.ac-settable value.
43976fae4e5dSmrg           */
43986fae4e5dSmrg          lt_fatal (__FILE__, __LINE__,
43996fae4e5dSmrg		    "unrecognized %s option: '%s'",
44006fae4e5dSmrg                    ltwrapper_option_prefix, argv[i]);
44016fae4e5dSmrg        }
44026fae4e5dSmrg      /* otherwise ... */
44036fae4e5dSmrg      newargz[++newargc] = xstrdup (argv[i]);
44049c9ff80cSmrg    }
44056fae4e5dSmrg  newargz[++newargc] = NULL;
44066fae4e5dSmrg
44076fae4e5dSmrgEOF
44086fae4e5dSmrg	    cat <<EOF
44096fae4e5dSmrg  /* The GNU banner must be the first non-error debug message */
44106fae4e5dSmrg  lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\n");
44116fae4e5dSmrgEOF
44126fae4e5dSmrg	    cat <<"EOF"
44136fae4e5dSmrg  lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
44146fae4e5dSmrg  lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name);
44151f0ac6a5Smrg
44169c9ff80cSmrg  tmp_pathspec = find_executable (argv[0]);
44179c9ff80cSmrg  if (tmp_pathspec == NULL)
44186fae4e5dSmrg    lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]);
44196fae4e5dSmrg  lt_debugprintf (__FILE__, __LINE__,
44206fae4e5dSmrg                  "(main) found exe (before symlink chase) at: %s\n",
44216fae4e5dSmrg		  tmp_pathspec);
44229c9ff80cSmrg
44239c9ff80cSmrg  actual_cwrapper_path = chase_symlinks (tmp_pathspec);
44246fae4e5dSmrg  lt_debugprintf (__FILE__, __LINE__,
44256fae4e5dSmrg                  "(main) found exe (after symlink chase) at: %s\n",
44266fae4e5dSmrg		  actual_cwrapper_path);
44279c9ff80cSmrg  XFREE (tmp_pathspec);
44289c9ff80cSmrg
44296fae4e5dSmrg  actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));
44309c9ff80cSmrg  strendzap (actual_cwrapper_path, actual_cwrapper_name);
44319c9ff80cSmrg
44329c9ff80cSmrg  /* wrapper name transforms */
44339c9ff80cSmrg  strendzap (actual_cwrapper_name, ".exe");
44349c9ff80cSmrg  tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
44359c9ff80cSmrg  XFREE (actual_cwrapper_name);
44369c9ff80cSmrg  actual_cwrapper_name = tmp_pathspec;
44379c9ff80cSmrg  tmp_pathspec = 0;
44389c9ff80cSmrg
44399c9ff80cSmrg  /* target_name transforms -- use actual target program name; might have lt- prefix */
44409c9ff80cSmrg  target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
44419c9ff80cSmrg  strendzap (target_name, ".exe");
44429c9ff80cSmrg  tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
44439c9ff80cSmrg  XFREE (target_name);
44449c9ff80cSmrg  target_name = tmp_pathspec;
44459c9ff80cSmrg  tmp_pathspec = 0;
44469c9ff80cSmrg
44476fae4e5dSmrg  lt_debugprintf (__FILE__, __LINE__,
44486fae4e5dSmrg		  "(main) libtool target name: %s\n",
44496fae4e5dSmrg		  target_name);
44509c9ff80cSmrgEOF
44511f0ac6a5Smrg
44529c9ff80cSmrg	    cat <<EOF
44539c9ff80cSmrg  newargz[0] =
44549c9ff80cSmrg    XMALLOC (char, (strlen (actual_cwrapper_path) +
44559c9ff80cSmrg		    strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
44569c9ff80cSmrg  strcpy (newargz[0], actual_cwrapper_path);
44579c9ff80cSmrg  strcat (newargz[0], "$objdir");
44589c9ff80cSmrg  strcat (newargz[0], "/");
44599c9ff80cSmrgEOF
44601f0ac6a5Smrg
44619c9ff80cSmrg	    cat <<"EOF"
44629c9ff80cSmrg  /* stop here, and copy so we don't have to do this twice */
44639c9ff80cSmrg  tmp_pathspec = xstrdup (newargz[0]);
44641f0ac6a5Smrg
44659c9ff80cSmrg  /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
44669c9ff80cSmrg  strcat (newargz[0], actual_cwrapper_name);
44671f0ac6a5Smrg
44689c9ff80cSmrg  /* DO want the lt- prefix here if it exists, so use target_name */
44699c9ff80cSmrg  lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
44709c9ff80cSmrg  XFREE (tmp_pathspec);
44719c9ff80cSmrg  tmp_pathspec = NULL;
44729c9ff80cSmrgEOF
44731f0ac6a5Smrg
44749c9ff80cSmrg	    case $host_os in
44759c9ff80cSmrg	      mingw*)
44769c9ff80cSmrg	    cat <<"EOF"
44779c9ff80cSmrg  {
44789c9ff80cSmrg    char* p;
44799c9ff80cSmrg    while ((p = strchr (newargz[0], '\\')) != NULL)
44809c9ff80cSmrg      {
44819c9ff80cSmrg	*p = '/';
44829c9ff80cSmrg      }
44839c9ff80cSmrg    while ((p = strchr (lt_argv_zero, '\\')) != NULL)
44849c9ff80cSmrg      {
44859c9ff80cSmrg	*p = '/';
44869c9ff80cSmrg      }
44879c9ff80cSmrg  }
44889c9ff80cSmrgEOF
44899c9ff80cSmrg	    ;;
44909c9ff80cSmrg	    esac
44911f0ac6a5Smrg
44929c9ff80cSmrg	    cat <<"EOF"
44939c9ff80cSmrg  XFREE (target_name);
44949c9ff80cSmrg  XFREE (actual_cwrapper_path);
44959c9ff80cSmrg  XFREE (actual_cwrapper_name);
44961f0ac6a5Smrg
44979c9ff80cSmrg  lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
44989c9ff80cSmrg  lt_setenv ("DUALCASE", "1");  /* for MSK sh */
44996fae4e5dSmrg  /* Update the DLL searchpath.  EXE_PATH_VALUE ($dllsearchpath) must
45006fae4e5dSmrg     be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath)
45016fae4e5dSmrg     because on Windows, both *_VARNAMEs are PATH but uninstalled
45026fae4e5dSmrg     libraries must come first. */
45039c9ff80cSmrg  lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
45046fae4e5dSmrg  lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
45051f0ac6a5Smrg
45066fae4e5dSmrg  lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",
45076fae4e5dSmrg		  nonnull (lt_argv_zero));
45089c9ff80cSmrg  for (i = 0; i < newargc; i++)
45099c9ff80cSmrg    {
45106fae4e5dSmrg      lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n",
45116fae4e5dSmrg		      i, nonnull (newargz[i]));
45129c9ff80cSmrg    }
45131f0ac6a5Smrg
45149c9ff80cSmrgEOF
45151f0ac6a5Smrg
45169c9ff80cSmrg	    case $host_os in
45179c9ff80cSmrg	      mingw*)
45189c9ff80cSmrg		cat <<"EOF"
45199c9ff80cSmrg  /* execv doesn't actually work on mingw as expected on unix */
45206fae4e5dSmrg  newargz = prepare_spawn (newargz);
45219c9ff80cSmrg  rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
45229c9ff80cSmrg  if (rval == -1)
45239c9ff80cSmrg    {
45249c9ff80cSmrg      /* failed to start process */
45256fae4e5dSmrg      lt_debugprintf (__FILE__, __LINE__,
45266fae4e5dSmrg		      "(main) failed to launch target \"%s\": %s\n",
45276fae4e5dSmrg		      lt_argv_zero, nonnull (strerror (errno)));
45289c9ff80cSmrg      return 127;
45299c9ff80cSmrg    }
45309c9ff80cSmrg  return rval;
45319c9ff80cSmrgEOF
45329c9ff80cSmrg		;;
45339c9ff80cSmrg	      *)
45349c9ff80cSmrg		cat <<"EOF"
45359c9ff80cSmrg  execv (lt_argv_zero, newargz);
45369c9ff80cSmrg  return rval; /* =127, but avoids unused variable warning */
45379c9ff80cSmrgEOF
45389c9ff80cSmrg		;;
45399c9ff80cSmrg	    esac
45401f0ac6a5Smrg
45419c9ff80cSmrg	    cat <<"EOF"
45429c9ff80cSmrg}
45431f0ac6a5Smrg
45449c9ff80cSmrgvoid *
45459c9ff80cSmrgxmalloc (size_t num)
45469c9ff80cSmrg{
45479c9ff80cSmrg  void *p = (void *) malloc (num);
45489c9ff80cSmrg  if (!p)
45496fae4e5dSmrg    lt_fatal (__FILE__, __LINE__, "memory exhausted");
45501f0ac6a5Smrg
45519c9ff80cSmrg  return p;
45529c9ff80cSmrg}
45531f0ac6a5Smrg
45549c9ff80cSmrgchar *
45559c9ff80cSmrgxstrdup (const char *string)
45569c9ff80cSmrg{
45579c9ff80cSmrg  return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
45589c9ff80cSmrg			  string) : NULL;
45599c9ff80cSmrg}
45601f0ac6a5Smrg
45619c9ff80cSmrgconst char *
45629c9ff80cSmrgbase_name (const char *name)
45639c9ff80cSmrg{
45649c9ff80cSmrg  const char *base;
45651f0ac6a5Smrg
45669c9ff80cSmrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
45679c9ff80cSmrg  /* Skip over the disk name in MSDOS pathnames. */
45689c9ff80cSmrg  if (isalpha ((unsigned char) name[0]) && name[1] == ':')
45699c9ff80cSmrg    name += 2;
45709c9ff80cSmrg#endif
45711f0ac6a5Smrg
45729c9ff80cSmrg  for (base = name; *name; name++)
45739c9ff80cSmrg    if (IS_DIR_SEPARATOR (*name))
45749c9ff80cSmrg      base = name + 1;
45759c9ff80cSmrg  return base;
45769c9ff80cSmrg}
45771f0ac6a5Smrg
45789c9ff80cSmrgint
45799c9ff80cSmrgcheck_executable (const char *path)
45809c9ff80cSmrg{
45819c9ff80cSmrg  struct stat st;
45821f0ac6a5Smrg
45836fae4e5dSmrg  lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n",
45846fae4e5dSmrg                  nonempty (path));
45859c9ff80cSmrg  if ((!path) || (!*path))
45869c9ff80cSmrg    return 0;
45871f0ac6a5Smrg
45889c9ff80cSmrg  if ((stat (path, &st) >= 0)
45899c9ff80cSmrg      && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
45909c9ff80cSmrg    return 1;
45919c9ff80cSmrg  else
45929c9ff80cSmrg    return 0;
45939c9ff80cSmrg}
45941f0ac6a5Smrg
45959c9ff80cSmrgint
45969c9ff80cSmrgmake_executable (const char *path)
45979c9ff80cSmrg{
45989c9ff80cSmrg  int rval = 0;
45999c9ff80cSmrg  struct stat st;
46001f0ac6a5Smrg
46016fae4e5dSmrg  lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n",
46026fae4e5dSmrg                  nonempty (path));
46039c9ff80cSmrg  if ((!path) || (!*path))
46049c9ff80cSmrg    return 0;
46051f0ac6a5Smrg
46069c9ff80cSmrg  if (stat (path, &st) >= 0)
46079c9ff80cSmrg    {
46089c9ff80cSmrg      rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
46099c9ff80cSmrg    }
46109c9ff80cSmrg  return rval;
46119c9ff80cSmrg}
46121f0ac6a5Smrg
46139c9ff80cSmrg/* Searches for the full path of the wrapper.  Returns
46149c9ff80cSmrg   newly allocated full path name if found, NULL otherwise
46159c9ff80cSmrg   Does not chase symlinks, even on platforms that support them.
46169c9ff80cSmrg*/
46179c9ff80cSmrgchar *
46189c9ff80cSmrgfind_executable (const char *wrapper)
46199c9ff80cSmrg{
46209c9ff80cSmrg  int has_slash = 0;
46219c9ff80cSmrg  const char *p;
46229c9ff80cSmrg  const char *p_next;
46239c9ff80cSmrg  /* static buffer for getcwd */
46249c9ff80cSmrg  char tmp[LT_PATHMAX + 1];
46259c9ff80cSmrg  int tmp_len;
46269c9ff80cSmrg  char *concat_name;
46271f0ac6a5Smrg
46286fae4e5dSmrg  lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
46296fae4e5dSmrg                  nonempty (wrapper));
46301f0ac6a5Smrg
46319c9ff80cSmrg  if ((wrapper == NULL) || (*wrapper == '\0'))
46329c9ff80cSmrg    return NULL;
46331f0ac6a5Smrg
46349c9ff80cSmrg  /* Absolute path? */
46359c9ff80cSmrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
46369c9ff80cSmrg  if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
46379c9ff80cSmrg    {
46389c9ff80cSmrg      concat_name = xstrdup (wrapper);
46399c9ff80cSmrg      if (check_executable (concat_name))
46409c9ff80cSmrg	return concat_name;
46419c9ff80cSmrg      XFREE (concat_name);
46429c9ff80cSmrg    }
46439c9ff80cSmrg  else
46449c9ff80cSmrg    {
46459c9ff80cSmrg#endif
46469c9ff80cSmrg      if (IS_DIR_SEPARATOR (wrapper[0]))
46479c9ff80cSmrg	{
46489c9ff80cSmrg	  concat_name = xstrdup (wrapper);
46499c9ff80cSmrg	  if (check_executable (concat_name))
46509c9ff80cSmrg	    return concat_name;
46519c9ff80cSmrg	  XFREE (concat_name);
46529c9ff80cSmrg	}
46539c9ff80cSmrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
46549c9ff80cSmrg    }
46559c9ff80cSmrg#endif
46561f0ac6a5Smrg
46579c9ff80cSmrg  for (p = wrapper; *p; p++)
46589c9ff80cSmrg    if (*p == '/')
46599c9ff80cSmrg      {
46609c9ff80cSmrg	has_slash = 1;
46619c9ff80cSmrg	break;
46629c9ff80cSmrg      }
46639c9ff80cSmrg  if (!has_slash)
46649c9ff80cSmrg    {
46659c9ff80cSmrg      /* no slashes; search PATH */
46669c9ff80cSmrg      const char *path = getenv ("PATH");
46679c9ff80cSmrg      if (path != NULL)
46689c9ff80cSmrg	{
46699c9ff80cSmrg	  for (p = path; *p; p = p_next)
46709c9ff80cSmrg	    {
46719c9ff80cSmrg	      const char *q;
46729c9ff80cSmrg	      size_t p_len;
46739c9ff80cSmrg	      for (q = p; *q; q++)
46749c9ff80cSmrg		if (IS_PATH_SEPARATOR (*q))
46759c9ff80cSmrg		  break;
46769c9ff80cSmrg	      p_len = q - p;
46779c9ff80cSmrg	      p_next = (*q == '\0' ? q : q + 1);
46789c9ff80cSmrg	      if (p_len == 0)
46799c9ff80cSmrg		{
46809c9ff80cSmrg		  /* empty path: current directory */
46819c9ff80cSmrg		  if (getcwd (tmp, LT_PATHMAX) == NULL)
46826fae4e5dSmrg		    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
46836fae4e5dSmrg                              nonnull (strerror (errno)));
46849c9ff80cSmrg		  tmp_len = strlen (tmp);
46859c9ff80cSmrg		  concat_name =
46869c9ff80cSmrg		    XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
46879c9ff80cSmrg		  memcpy (concat_name, tmp, tmp_len);
46889c9ff80cSmrg		  concat_name[tmp_len] = '/';
46899c9ff80cSmrg		  strcpy (concat_name + tmp_len + 1, wrapper);
46909c9ff80cSmrg		}
46919c9ff80cSmrg	      else
46929c9ff80cSmrg		{
46939c9ff80cSmrg		  concat_name =
46949c9ff80cSmrg		    XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
46959c9ff80cSmrg		  memcpy (concat_name, p, p_len);
46969c9ff80cSmrg		  concat_name[p_len] = '/';
46979c9ff80cSmrg		  strcpy (concat_name + p_len + 1, wrapper);
46989c9ff80cSmrg		}
46999c9ff80cSmrg	      if (check_executable (concat_name))
47009c9ff80cSmrg		return concat_name;
47019c9ff80cSmrg	      XFREE (concat_name);
47029c9ff80cSmrg	    }
47039c9ff80cSmrg	}
47049c9ff80cSmrg      /* not found in PATH; assume curdir */
47059c9ff80cSmrg    }
47069c9ff80cSmrg  /* Relative path | not found in path: prepend cwd */
47079c9ff80cSmrg  if (getcwd (tmp, LT_PATHMAX) == NULL)
47086fae4e5dSmrg    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
47096fae4e5dSmrg              nonnull (strerror (errno)));
47109c9ff80cSmrg  tmp_len = strlen (tmp);
47119c9ff80cSmrg  concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
47129c9ff80cSmrg  memcpy (concat_name, tmp, tmp_len);
47139c9ff80cSmrg  concat_name[tmp_len] = '/';
47149c9ff80cSmrg  strcpy (concat_name + tmp_len + 1, wrapper);
47151f0ac6a5Smrg
47169c9ff80cSmrg  if (check_executable (concat_name))
47179c9ff80cSmrg    return concat_name;
47189c9ff80cSmrg  XFREE (concat_name);
47199c9ff80cSmrg  return NULL;
47209c9ff80cSmrg}
47211f0ac6a5Smrg
47229c9ff80cSmrgchar *
47239c9ff80cSmrgchase_symlinks (const char *pathspec)
47249c9ff80cSmrg{
47259c9ff80cSmrg#ifndef S_ISLNK
47269c9ff80cSmrg  return xstrdup (pathspec);
47279c9ff80cSmrg#else
47289c9ff80cSmrg  char buf[LT_PATHMAX];
47299c9ff80cSmrg  struct stat s;
47309c9ff80cSmrg  char *tmp_pathspec = xstrdup (pathspec);
47319c9ff80cSmrg  char *p;
47329c9ff80cSmrg  int has_symlinks = 0;
47339c9ff80cSmrg  while (strlen (tmp_pathspec) && !has_symlinks)
47349c9ff80cSmrg    {
47356fae4e5dSmrg      lt_debugprintf (__FILE__, __LINE__,
47366fae4e5dSmrg		      "checking path component for symlinks: %s\n",
47376fae4e5dSmrg		      tmp_pathspec);
47389c9ff80cSmrg      if (lstat (tmp_pathspec, &s) == 0)
47399c9ff80cSmrg	{
47409c9ff80cSmrg	  if (S_ISLNK (s.st_mode) != 0)
47419c9ff80cSmrg	    {
47429c9ff80cSmrg	      has_symlinks = 1;
47439c9ff80cSmrg	      break;
47449c9ff80cSmrg	    }
47451f0ac6a5Smrg
47469c9ff80cSmrg	  /* search backwards for last DIR_SEPARATOR */
47479c9ff80cSmrg	  p = tmp_pathspec + strlen (tmp_pathspec) - 1;
47489c9ff80cSmrg	  while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
47499c9ff80cSmrg	    p--;
47509c9ff80cSmrg	  if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
47519c9ff80cSmrg	    {
47529c9ff80cSmrg	      /* no more DIR_SEPARATORS left */
47539c9ff80cSmrg	      break;
47549c9ff80cSmrg	    }
47559c9ff80cSmrg	  *p = '\0';
47569c9ff80cSmrg	}
47579c9ff80cSmrg      else
47589c9ff80cSmrg	{
47596fae4e5dSmrg	  lt_fatal (__FILE__, __LINE__,
47606fae4e5dSmrg		    "error accessing file \"%s\": %s",
47616fae4e5dSmrg		    tmp_pathspec, nonnull (strerror (errno)));
47629c9ff80cSmrg	}
47639c9ff80cSmrg    }
47649c9ff80cSmrg  XFREE (tmp_pathspec);
47651f0ac6a5Smrg
47669c9ff80cSmrg  if (!has_symlinks)
47679c9ff80cSmrg    {
47689c9ff80cSmrg      return xstrdup (pathspec);
47699c9ff80cSmrg    }
47701f0ac6a5Smrg
47719c9ff80cSmrg  tmp_pathspec = realpath (pathspec, buf);
47729c9ff80cSmrg  if (tmp_pathspec == 0)
47739c9ff80cSmrg    {
47746fae4e5dSmrg      lt_fatal (__FILE__, __LINE__,
47756fae4e5dSmrg		"could not follow symlinks for %s", pathspec);
47769c9ff80cSmrg    }
47779c9ff80cSmrg  return xstrdup (tmp_pathspec);
47789c9ff80cSmrg#endif
47799c9ff80cSmrg}
47801f0ac6a5Smrg
47819c9ff80cSmrgchar *
47829c9ff80cSmrgstrendzap (char *str, const char *pat)
47839c9ff80cSmrg{
47849c9ff80cSmrg  size_t len, patlen;
47851f0ac6a5Smrg
47869c9ff80cSmrg  assert (str != NULL);
47879c9ff80cSmrg  assert (pat != NULL);
47881f0ac6a5Smrg
47899c9ff80cSmrg  len = strlen (str);
47909c9ff80cSmrg  patlen = strlen (pat);
47911f0ac6a5Smrg
47929c9ff80cSmrg  if (patlen <= len)
47939c9ff80cSmrg    {
47949c9ff80cSmrg      str += len - patlen;
47959c9ff80cSmrg      if (strcmp (str, pat) == 0)
47969c9ff80cSmrg	*str = '\0';
47979c9ff80cSmrg    }
47989c9ff80cSmrg  return str;
47999c9ff80cSmrg}
48001f0ac6a5Smrg
48016fae4e5dSmrgvoid
48026fae4e5dSmrglt_debugprintf (const char *file, int line, const char *fmt, ...)
48036fae4e5dSmrg{
48046fae4e5dSmrg  va_list args;
48056fae4e5dSmrg  if (lt_debug)
48066fae4e5dSmrg    {
48076fae4e5dSmrg      (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line);
48086fae4e5dSmrg      va_start (args, fmt);
48096fae4e5dSmrg      (void) vfprintf (stderr, fmt, args);
48106fae4e5dSmrg      va_end (args);
48116fae4e5dSmrg    }
48126fae4e5dSmrg}
48136fae4e5dSmrg
48149c9ff80cSmrgstatic void
48156fae4e5dSmrglt_error_core (int exit_status, const char *file,
48166fae4e5dSmrg	       int line, const char *mode,
48179c9ff80cSmrg	       const char *message, va_list ap)
48189c9ff80cSmrg{
48196fae4e5dSmrg  fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode);
48209c9ff80cSmrg  vfprintf (stderr, message, ap);
48219c9ff80cSmrg  fprintf (stderr, ".\n");
48221f0ac6a5Smrg
48239c9ff80cSmrg  if (exit_status >= 0)
48249c9ff80cSmrg    exit (exit_status);
48259c9ff80cSmrg}
48261f0ac6a5Smrg
48279c9ff80cSmrgvoid
48286fae4e5dSmrglt_fatal (const char *file, int line, const char *message, ...)
48299c9ff80cSmrg{
48309c9ff80cSmrg  va_list ap;
48319c9ff80cSmrg  va_start (ap, message);
48326fae4e5dSmrg  lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap);
48339c9ff80cSmrg  va_end (ap);
48349c9ff80cSmrg}
48351f0ac6a5Smrg
48366fae4e5dSmrgstatic const char *
48376fae4e5dSmrgnonnull (const char *s)
48386fae4e5dSmrg{
48396fae4e5dSmrg  return s ? s : "(null)";
48406fae4e5dSmrg}
48416fae4e5dSmrg
48426fae4e5dSmrgstatic const char *
48436fae4e5dSmrgnonempty (const char *s)
48446fae4e5dSmrg{
48456fae4e5dSmrg  return (s && !*s) ? "(empty)" : nonnull (s);
48466fae4e5dSmrg}
48476fae4e5dSmrg
48489c9ff80cSmrgvoid
48499c9ff80cSmrglt_setenv (const char *name, const char *value)
48509c9ff80cSmrg{
48516fae4e5dSmrg  lt_debugprintf (__FILE__, __LINE__,
48526fae4e5dSmrg		  "(lt_setenv) setting '%s' to '%s'\n",
48536fae4e5dSmrg                  nonnull (name), nonnull (value));
48549c9ff80cSmrg  {
48559c9ff80cSmrg#ifdef HAVE_SETENV
48569c9ff80cSmrg    /* always make a copy, for consistency with !HAVE_SETENV */
48579c9ff80cSmrg    char *str = xstrdup (value);
48589c9ff80cSmrg    setenv (name, str, 1);
48599c9ff80cSmrg#else
48609c9ff80cSmrg    int len = strlen (name) + 1 + strlen (value) + 1;
48619c9ff80cSmrg    char *str = XMALLOC (char, len);
48629c9ff80cSmrg    sprintf (str, "%s=%s", name, value);
48639c9ff80cSmrg    if (putenv (str) != EXIT_SUCCESS)
48649c9ff80cSmrg      {
48659c9ff80cSmrg        XFREE (str);
48669c9ff80cSmrg      }
48679c9ff80cSmrg#endif
48689c9ff80cSmrg  }
48699c9ff80cSmrg}
48701f0ac6a5Smrg
48719c9ff80cSmrgchar *
48729c9ff80cSmrglt_extend_str (const char *orig_value, const char *add, int to_end)
48739c9ff80cSmrg{
48749c9ff80cSmrg  char *new_value;
48759c9ff80cSmrg  if (orig_value && *orig_value)
48769c9ff80cSmrg    {
48779c9ff80cSmrg      int orig_value_len = strlen (orig_value);
48789c9ff80cSmrg      int add_len = strlen (add);
48799c9ff80cSmrg      new_value = XMALLOC (char, add_len + orig_value_len + 1);
48809c9ff80cSmrg      if (to_end)
48819c9ff80cSmrg        {
48829c9ff80cSmrg          strcpy (new_value, orig_value);
48839c9ff80cSmrg          strcpy (new_value + orig_value_len, add);
48849c9ff80cSmrg        }
48859c9ff80cSmrg      else
48869c9ff80cSmrg        {
48879c9ff80cSmrg          strcpy (new_value, add);
48889c9ff80cSmrg          strcpy (new_value + add_len, orig_value);
48899c9ff80cSmrg        }
48909c9ff80cSmrg    }
48919c9ff80cSmrg  else
48929c9ff80cSmrg    {
48939c9ff80cSmrg      new_value = xstrdup (add);
48949c9ff80cSmrg    }
48959c9ff80cSmrg  return new_value;
48969c9ff80cSmrg}
48971f0ac6a5Smrg
48989c9ff80cSmrgvoid
48999c9ff80cSmrglt_update_exe_path (const char *name, const char *value)
49009c9ff80cSmrg{
49016fae4e5dSmrg  lt_debugprintf (__FILE__, __LINE__,
49026fae4e5dSmrg		  "(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
49036fae4e5dSmrg                  nonnull (name), nonnull (value));
49041f0ac6a5Smrg
49059c9ff80cSmrg  if (name && *name && value && *value)
49069c9ff80cSmrg    {
49079c9ff80cSmrg      char *new_value = lt_extend_str (getenv (name), value, 0);
49089c9ff80cSmrg      /* some systems can't cope with a ':'-terminated path #' */
49099c9ff80cSmrg      int len = strlen (new_value);
49109c9ff80cSmrg      while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
49119c9ff80cSmrg        {
49129c9ff80cSmrg          new_value[len-1] = '\0';
49139c9ff80cSmrg        }
49149c9ff80cSmrg      lt_setenv (name, new_value);
49159c9ff80cSmrg      XFREE (new_value);
49169c9ff80cSmrg    }
49179c9ff80cSmrg}
49181f0ac6a5Smrg
49199c9ff80cSmrgvoid
49209c9ff80cSmrglt_update_lib_path (const char *name, const char *value)
49219c9ff80cSmrg{
49226fae4e5dSmrg  lt_debugprintf (__FILE__, __LINE__,
49236fae4e5dSmrg		  "(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
49246fae4e5dSmrg                  nonnull (name), nonnull (value));
49251f0ac6a5Smrg
49269c9ff80cSmrg  if (name && *name && value && *value)
49279c9ff80cSmrg    {
49289c9ff80cSmrg      char *new_value = lt_extend_str (getenv (name), value, 0);
49299c9ff80cSmrg      lt_setenv (name, new_value);
49309c9ff80cSmrg      XFREE (new_value);
49319c9ff80cSmrg    }
49329c9ff80cSmrg}
49331f0ac6a5Smrg
49346fae4e5dSmrgEOF
49356fae4e5dSmrg	    case $host_os in
49366fae4e5dSmrg	      mingw*)
49376fae4e5dSmrg		cat <<"EOF"
49386fae4e5dSmrg
49396fae4e5dSmrg/* Prepares an argument vector before calling spawn().
49406fae4e5dSmrg   Note that spawn() does not by itself call the command interpreter
49416fae4e5dSmrg     (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
49426fae4e5dSmrg      ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
49436fae4e5dSmrg         GetVersionEx(&v);
49446fae4e5dSmrg         v.dwPlatformId == VER_PLATFORM_WIN32_NT;
49456fae4e5dSmrg      }) ? "cmd.exe" : "command.com").
49466fae4e5dSmrg   Instead it simply concatenates the arguments, separated by ' ', and calls
49476fae4e5dSmrg   CreateProcess().  We must quote the arguments since Win32 CreateProcess()
49486fae4e5dSmrg   interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
49496fae4e5dSmrg   special way:
49506fae4e5dSmrg   - Space and tab are interpreted as delimiters. They are not treated as
49516fae4e5dSmrg     delimiters if they are surrounded by double quotes: "...".
49526fae4e5dSmrg   - Unescaped double quotes are removed from the input. Their only effect is
49536fae4e5dSmrg     that within double quotes, space and tab are treated like normal
49546fae4e5dSmrg     characters.
49556fae4e5dSmrg   - Backslashes not followed by double quotes are not special.
49566fae4e5dSmrg   - But 2*n+1 backslashes followed by a double quote become
49576fae4e5dSmrg     n backslashes followed by a double quote (n >= 0):
49586fae4e5dSmrg       \" -> "
49596fae4e5dSmrg       \\\" -> \"
49606fae4e5dSmrg       \\\\\" -> \\"
49616fae4e5dSmrg */
49626fae4e5dSmrg#define SHELL_SPECIAL_CHARS "\"\\ \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037"
49636fae4e5dSmrg#define SHELL_SPACE_CHARS " \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037"
49646fae4e5dSmrgchar **
49656fae4e5dSmrgprepare_spawn (char **argv)
49666fae4e5dSmrg{
49676fae4e5dSmrg  size_t argc;
49686fae4e5dSmrg  char **new_argv;
49696fae4e5dSmrg  size_t i;
49706fae4e5dSmrg
49716fae4e5dSmrg  /* Count number of arguments.  */
49726fae4e5dSmrg  for (argc = 0; argv[argc] != NULL; argc++)
49736fae4e5dSmrg    ;
49746fae4e5dSmrg
49756fae4e5dSmrg  /* Allocate new argument vector.  */
49766fae4e5dSmrg  new_argv = XMALLOC (char *, argc + 1);
49776fae4e5dSmrg
49786fae4e5dSmrg  /* Put quoted arguments into the new argument vector.  */
49796fae4e5dSmrg  for (i = 0; i < argc; i++)
49806fae4e5dSmrg    {
49816fae4e5dSmrg      const char *string = argv[i];
49826fae4e5dSmrg
49836fae4e5dSmrg      if (string[0] == '\0')
49846fae4e5dSmrg	new_argv[i] = xstrdup ("\"\"");
49856fae4e5dSmrg      else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
49866fae4e5dSmrg	{
49876fae4e5dSmrg	  int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
49886fae4e5dSmrg	  size_t length;
49896fae4e5dSmrg	  unsigned int backslashes;
49906fae4e5dSmrg	  const char *s;
49916fae4e5dSmrg	  char *quoted_string;
49926fae4e5dSmrg	  char *p;
49936fae4e5dSmrg
49946fae4e5dSmrg	  length = 0;
49956fae4e5dSmrg	  backslashes = 0;
49966fae4e5dSmrg	  if (quote_around)
49976fae4e5dSmrg	    length++;
49986fae4e5dSmrg	  for (s = string; *s != '\0'; s++)
49996fae4e5dSmrg	    {
50006fae4e5dSmrg	      char c = *s;
50016fae4e5dSmrg	      if (c == '"')
50026fae4e5dSmrg		length += backslashes + 1;
50036fae4e5dSmrg	      length++;
50046fae4e5dSmrg	      if (c == '\\')
50056fae4e5dSmrg		backslashes++;
50066fae4e5dSmrg	      else
50076fae4e5dSmrg		backslashes = 0;
50086fae4e5dSmrg	    }
50096fae4e5dSmrg	  if (quote_around)
50106fae4e5dSmrg	    length += backslashes + 1;
50116fae4e5dSmrg
50126fae4e5dSmrg	  quoted_string = XMALLOC (char, length + 1);
50136fae4e5dSmrg
50146fae4e5dSmrg	  p = quoted_string;
50156fae4e5dSmrg	  backslashes = 0;
50166fae4e5dSmrg	  if (quote_around)
50176fae4e5dSmrg	    *p++ = '"';
50186fae4e5dSmrg	  for (s = string; *s != '\0'; s++)
50196fae4e5dSmrg	    {
50206fae4e5dSmrg	      char c = *s;
50216fae4e5dSmrg	      if (c == '"')
50226fae4e5dSmrg		{
50236fae4e5dSmrg		  unsigned int j;
50246fae4e5dSmrg		  for (j = backslashes + 1; j > 0; j--)
50256fae4e5dSmrg		    *p++ = '\\';
50266fae4e5dSmrg		}
50276fae4e5dSmrg	      *p++ = c;
50286fae4e5dSmrg	      if (c == '\\')
50296fae4e5dSmrg		backslashes++;
50306fae4e5dSmrg	      else
50316fae4e5dSmrg		backslashes = 0;
50326fae4e5dSmrg	    }
50336fae4e5dSmrg	  if (quote_around)
50346fae4e5dSmrg	    {
50356fae4e5dSmrg	      unsigned int j;
50366fae4e5dSmrg	      for (j = backslashes; j > 0; j--)
50376fae4e5dSmrg		*p++ = '\\';
50386fae4e5dSmrg	      *p++ = '"';
50396fae4e5dSmrg	    }
50406fae4e5dSmrg	  *p = '\0';
50416fae4e5dSmrg
50426fae4e5dSmrg	  new_argv[i] = quoted_string;
50436fae4e5dSmrg	}
50446fae4e5dSmrg      else
50456fae4e5dSmrg	new_argv[i] = (char *) string;
50466fae4e5dSmrg    }
50476fae4e5dSmrg  new_argv[argc] = NULL;
50486fae4e5dSmrg
50496fae4e5dSmrg  return new_argv;
50506fae4e5dSmrg}
50516fae4e5dSmrgEOF
50526fae4e5dSmrg		;;
50536fae4e5dSmrg	    esac
50546fae4e5dSmrg
50556fae4e5dSmrg            cat <<"EOF"
50566fae4e5dSmrgvoid lt_dump_script (FILE* f)
50576fae4e5dSmrg{
50586fae4e5dSmrgEOF
50596fae4e5dSmrg	    func_emit_wrapper yes |
50606fae4e5dSmrg              $SED -e 's/\([\\"]\)/\\\1/g' \
50616fae4e5dSmrg	           -e 's/^/  fputs ("/' -e 's/$/\\n", f);/'
50621f0ac6a5Smrg
50636fae4e5dSmrg            cat <<"EOF"
50646fae4e5dSmrg}
50659c9ff80cSmrgEOF
50669c9ff80cSmrg}
50679c9ff80cSmrg# end: func_emit_cwrapperexe_src
50681f0ac6a5Smrg
50696fae4e5dSmrg# func_win32_import_lib_p ARG
50706fae4e5dSmrg# True if ARG is an import lib, as indicated by $file_magic_cmd
50716fae4e5dSmrgfunc_win32_import_lib_p ()
50726fae4e5dSmrg{
50736fae4e5dSmrg    $opt_debug
50746fae4e5dSmrg    case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
50756fae4e5dSmrg    *import*) : ;;
50766fae4e5dSmrg    *) false ;;
50776fae4e5dSmrg    esac
50786fae4e5dSmrg}
50796fae4e5dSmrg
50809c9ff80cSmrg# func_mode_link arg...
50819c9ff80cSmrgfunc_mode_link ()
50829c9ff80cSmrg{
50839c9ff80cSmrg    $opt_debug
50849c9ff80cSmrg    case $host in
50859c9ff80cSmrg    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
50869c9ff80cSmrg      # It is impossible to link a dll without this setting, and
50879c9ff80cSmrg      # we shouldn't force the makefile maintainer to figure out
50889c9ff80cSmrg      # which system we are compiling for in order to pass an extra
50899c9ff80cSmrg      # flag for every libtool invocation.
50909c9ff80cSmrg      # allow_undefined=no
50911f0ac6a5Smrg
50929c9ff80cSmrg      # FIXME: Unfortunately, there are problems with the above when trying
50939c9ff80cSmrg      # to make a dll which has undefined symbols, in which case not
50949c9ff80cSmrg      # even a static library is built.  For now, we need to specify
50959c9ff80cSmrg      # -no-undefined on the libtool link line when we can be certain
50969c9ff80cSmrg      # that all symbols are satisfied, otherwise we get a static library.
50979c9ff80cSmrg      allow_undefined=yes
50989c9ff80cSmrg      ;;
50999c9ff80cSmrg    *)
51009c9ff80cSmrg      allow_undefined=yes
51019c9ff80cSmrg      ;;
51029c9ff80cSmrg    esac
51039c9ff80cSmrg    libtool_args=$nonopt
51049c9ff80cSmrg    base_compile="$nonopt $@"
51059c9ff80cSmrg    compile_command=$nonopt
51069c9ff80cSmrg    finalize_command=$nonopt
51071f0ac6a5Smrg
51089c9ff80cSmrg    compile_rpath=
51099c9ff80cSmrg    finalize_rpath=
51109c9ff80cSmrg    compile_shlibpath=
51119c9ff80cSmrg    finalize_shlibpath=
51129c9ff80cSmrg    convenience=
51139c9ff80cSmrg    old_convenience=
51149c9ff80cSmrg    deplibs=
51159c9ff80cSmrg    old_deplibs=
51169c9ff80cSmrg    compiler_flags=
51179c9ff80cSmrg    linker_flags=
51189c9ff80cSmrg    dllsearchpath=
51199c9ff80cSmrg    lib_search_path=`pwd`
51209c9ff80cSmrg    inst_prefix_dir=
51219c9ff80cSmrg    new_inherited_linker_flags=
51221f0ac6a5Smrg
51239c9ff80cSmrg    avoid_version=no
51246fae4e5dSmrg    bindir=
51259c9ff80cSmrg    dlfiles=
51269c9ff80cSmrg    dlprefiles=
51279c9ff80cSmrg    dlself=no
51289c9ff80cSmrg    export_dynamic=no
51299c9ff80cSmrg    export_symbols=
51309c9ff80cSmrg    export_symbols_regex=
51319c9ff80cSmrg    generated=
51329c9ff80cSmrg    libobjs=
51339c9ff80cSmrg    ltlibs=
51349c9ff80cSmrg    module=no
51359c9ff80cSmrg    no_install=no
51369c9ff80cSmrg    objs=
51379c9ff80cSmrg    non_pic_objects=
51389c9ff80cSmrg    precious_files_regex=
51399c9ff80cSmrg    prefer_static_libs=no
51409c9ff80cSmrg    preload=no
51419c9ff80cSmrg    prev=
51429c9ff80cSmrg    prevarg=
51439c9ff80cSmrg    release=
51449c9ff80cSmrg    rpath=
51459c9ff80cSmrg    xrpath=
51469c9ff80cSmrg    perm_rpath=
51479c9ff80cSmrg    temp_rpath=
51489c9ff80cSmrg    thread_safe=no
51499c9ff80cSmrg    vinfo=
51509c9ff80cSmrg    vinfo_number=no
51519c9ff80cSmrg    weak_libs=
51529c9ff80cSmrg    single_module="${wl}-single_module"
51539c9ff80cSmrg    func_infer_tag $base_compile
51549c9ff80cSmrg
51559c9ff80cSmrg    # We need to know -static, to get the right output filenames.
51569c9ff80cSmrg    for arg
51579c9ff80cSmrg    do
51589c9ff80cSmrg      case $arg in
51599c9ff80cSmrg      -shared)
51609c9ff80cSmrg	test "$build_libtool_libs" != yes && \
51619c9ff80cSmrg	  func_fatal_configuration "can not build a shared library"
51629c9ff80cSmrg	build_old_libs=no
51639c9ff80cSmrg	break
51649c9ff80cSmrg	;;
51659c9ff80cSmrg      -all-static | -static | -static-libtool-libs)
51669c9ff80cSmrg	case $arg in
51679c9ff80cSmrg	-all-static)
51689c9ff80cSmrg	  if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
51699c9ff80cSmrg	    func_warning "complete static linking is impossible in this configuration"
51709c9ff80cSmrg	  fi
51719c9ff80cSmrg	  if test -n "$link_static_flag"; then
51729c9ff80cSmrg	    dlopen_self=$dlopen_self_static
51739c9ff80cSmrg	  fi
51749c9ff80cSmrg	  prefer_static_libs=yes
51759c9ff80cSmrg	  ;;
51769c9ff80cSmrg	-static)
51779c9ff80cSmrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
51789c9ff80cSmrg	    dlopen_self=$dlopen_self_static
51799c9ff80cSmrg	  fi
51809c9ff80cSmrg	  prefer_static_libs=built
51819c9ff80cSmrg	  ;;
51829c9ff80cSmrg	-static-libtool-libs)
51839c9ff80cSmrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
51849c9ff80cSmrg	    dlopen_self=$dlopen_self_static
51851f0ac6a5Smrg	  fi
51869c9ff80cSmrg	  prefer_static_libs=yes
51879c9ff80cSmrg	  ;;
51889c9ff80cSmrg	esac
51899c9ff80cSmrg	build_libtool_libs=no
51909c9ff80cSmrg	build_old_libs=yes
51919c9ff80cSmrg	break
51929c9ff80cSmrg	;;
51939c9ff80cSmrg      esac
51949c9ff80cSmrg    done
51951f0ac6a5Smrg
51969c9ff80cSmrg    # See if our shared archives depend on static archives.
51979c9ff80cSmrg    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
51981f0ac6a5Smrg
51999c9ff80cSmrg    # Go through the arguments, transforming them on the way.
52009c9ff80cSmrg    while test "$#" -gt 0; do
52019c9ff80cSmrg      arg="$1"
52029c9ff80cSmrg      shift
52039c9ff80cSmrg      func_quote_for_eval "$arg"
52049c9ff80cSmrg      qarg=$func_quote_for_eval_unquoted_result
52059c9ff80cSmrg      func_append libtool_args " $func_quote_for_eval_result"
52061f0ac6a5Smrg
52079c9ff80cSmrg      # If the previous option needs an argument, assign it.
52089c9ff80cSmrg      if test -n "$prev"; then
52099c9ff80cSmrg	case $prev in
52109c9ff80cSmrg	output)
52119c9ff80cSmrg	  func_append compile_command " @OUTPUT@"
52129c9ff80cSmrg	  func_append finalize_command " @OUTPUT@"
52139c9ff80cSmrg	  ;;
52149c9ff80cSmrg	esac
52151f0ac6a5Smrg
52169c9ff80cSmrg	case $prev in
52176fae4e5dSmrg	bindir)
52186fae4e5dSmrg	  bindir="$arg"
52196fae4e5dSmrg	  prev=
52206fae4e5dSmrg	  continue
52216fae4e5dSmrg	  ;;
52229c9ff80cSmrg	dlfiles|dlprefiles)
52239c9ff80cSmrg	  if test "$preload" = no; then
52249c9ff80cSmrg	    # Add the symbol object into the linking commands.
52259c9ff80cSmrg	    func_append compile_command " @SYMFILE@"
52269c9ff80cSmrg	    func_append finalize_command " @SYMFILE@"
52279c9ff80cSmrg	    preload=yes
52289c9ff80cSmrg	  fi
52299c9ff80cSmrg	  case $arg in
52309c9ff80cSmrg	  *.la | *.lo) ;;  # We handle these cases below.
52319c9ff80cSmrg	  force)
52329c9ff80cSmrg	    if test "$dlself" = no; then
52339c9ff80cSmrg	      dlself=needless
52349c9ff80cSmrg	      export_dynamic=yes
52359c9ff80cSmrg	    fi
52369c9ff80cSmrg	    prev=
52379c9ff80cSmrg	    continue
52389c9ff80cSmrg	    ;;
52399c9ff80cSmrg	  self)
52409c9ff80cSmrg	    if test "$prev" = dlprefiles; then
52419c9ff80cSmrg	      dlself=yes
52429c9ff80cSmrg	    elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
52439c9ff80cSmrg	      dlself=yes
52441f0ac6a5Smrg	    else
52459c9ff80cSmrg	      dlself=needless
52469c9ff80cSmrg	      export_dynamic=yes
52471f0ac6a5Smrg	    fi
52489c9ff80cSmrg	    prev=
52499c9ff80cSmrg	    continue
52509c9ff80cSmrg	    ;;
52519c9ff80cSmrg	  *)
52529c9ff80cSmrg	    if test "$prev" = dlfiles; then
52536fae4e5dSmrg	      func_append dlfiles " $arg"
52541f0ac6a5Smrg	    else
52556fae4e5dSmrg	      func_append dlprefiles " $arg"
52561f0ac6a5Smrg	    fi
52579c9ff80cSmrg	    prev=
52589c9ff80cSmrg	    continue
52599c9ff80cSmrg	    ;;
52609c9ff80cSmrg	  esac
52619c9ff80cSmrg	  ;;
52629c9ff80cSmrg	expsyms)
52639c9ff80cSmrg	  export_symbols="$arg"
52649c9ff80cSmrg	  test -f "$arg" \
52659c9ff80cSmrg	    || func_fatal_error "symbol file \`$arg' does not exist"
52669c9ff80cSmrg	  prev=
52679c9ff80cSmrg	  continue
52689c9ff80cSmrg	  ;;
52699c9ff80cSmrg	expsyms_regex)
52709c9ff80cSmrg	  export_symbols_regex="$arg"
52719c9ff80cSmrg	  prev=
52729c9ff80cSmrg	  continue
52739c9ff80cSmrg	  ;;
52749c9ff80cSmrg	framework)
52751f0ac6a5Smrg	  case $host in
52769c9ff80cSmrg	    *-*-darwin*)
52779c9ff80cSmrg	      case "$deplibs " in
52789c9ff80cSmrg		*" $qarg.ltframework "*) ;;
52796fae4e5dSmrg		*) func_append deplibs " $qarg.ltframework" # this is fixed later
52809c9ff80cSmrg		   ;;
52819c9ff80cSmrg	      esac
52829c9ff80cSmrg	      ;;
52831f0ac6a5Smrg	  esac
52849c9ff80cSmrg	  prev=
52859c9ff80cSmrg	  continue
52861f0ac6a5Smrg	  ;;
52879c9ff80cSmrg	inst_prefix)
52889c9ff80cSmrg	  inst_prefix_dir="$arg"
52899c9ff80cSmrg	  prev=
52909c9ff80cSmrg	  continue
52911f0ac6a5Smrg	  ;;
52929c9ff80cSmrg	objectlist)
52939c9ff80cSmrg	  if test -f "$arg"; then
52949c9ff80cSmrg	    save_arg=$arg
52959c9ff80cSmrg	    moreargs=
52969c9ff80cSmrg	    for fil in `cat "$save_arg"`
52979c9ff80cSmrg	    do
52986fae4e5dSmrg#	      func_append moreargs " $fil"
52999c9ff80cSmrg	      arg=$fil
53009c9ff80cSmrg	      # A libtool-controlled object.
53011f0ac6a5Smrg
53029c9ff80cSmrg	      # Check to see that this really is a libtool object.
53039c9ff80cSmrg	      if func_lalib_unsafe_p "$arg"; then
53049c9ff80cSmrg		pic_object=
53059c9ff80cSmrg		non_pic_object=
53061f0ac6a5Smrg
53079c9ff80cSmrg		# Read the .lo file
53089c9ff80cSmrg		func_source "$arg"
53091f0ac6a5Smrg
53109c9ff80cSmrg		if test -z "$pic_object" ||
53119c9ff80cSmrg		   test -z "$non_pic_object" ||
53129c9ff80cSmrg		   test "$pic_object" = none &&
53139c9ff80cSmrg		   test "$non_pic_object" = none; then
53149c9ff80cSmrg		  func_fatal_error "cannot find name of object for \`$arg'"
53159c9ff80cSmrg		fi
53161f0ac6a5Smrg
53179c9ff80cSmrg		# Extract subdirectory from the argument.
53189c9ff80cSmrg		func_dirname "$arg" "/" ""
53199c9ff80cSmrg		xdir="$func_dirname_result"
53201f0ac6a5Smrg
53219c9ff80cSmrg		if test "$pic_object" != none; then
53229c9ff80cSmrg		  # Prepend the subdirectory the object is found in.
53239c9ff80cSmrg		  pic_object="$xdir$pic_object"
53241f0ac6a5Smrg
53259c9ff80cSmrg		  if test "$prev" = dlfiles; then
53269c9ff80cSmrg		    if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
53276fae4e5dSmrg		      func_append dlfiles " $pic_object"
53289c9ff80cSmrg		      prev=
53299c9ff80cSmrg		      continue
53309c9ff80cSmrg		    else
53319c9ff80cSmrg		      # If libtool objects are unsupported, then we need to preload.
53329c9ff80cSmrg		      prev=dlprefiles
53339c9ff80cSmrg		    fi
53349c9ff80cSmrg		  fi
53351f0ac6a5Smrg
53369c9ff80cSmrg		  # CHECK ME:  I think I busted this.  -Ossama
53379c9ff80cSmrg		  if test "$prev" = dlprefiles; then
53389c9ff80cSmrg		    # Preload the old-style object.
53396fae4e5dSmrg		    func_append dlprefiles " $pic_object"
53409c9ff80cSmrg		    prev=
53419c9ff80cSmrg		  fi
53421f0ac6a5Smrg
53439c9ff80cSmrg		  # A PIC object.
53449c9ff80cSmrg		  func_append libobjs " $pic_object"
53459c9ff80cSmrg		  arg="$pic_object"
53469c9ff80cSmrg		fi
53471f0ac6a5Smrg
53489c9ff80cSmrg		# Non-PIC object.
53499c9ff80cSmrg		if test "$non_pic_object" != none; then
53509c9ff80cSmrg		  # Prepend the subdirectory the object is found in.
53519c9ff80cSmrg		  non_pic_object="$xdir$non_pic_object"
53521f0ac6a5Smrg
53539c9ff80cSmrg		  # A standard non-PIC object
53549c9ff80cSmrg		  func_append non_pic_objects " $non_pic_object"
53559c9ff80cSmrg		  if test -z "$pic_object" || test "$pic_object" = none ; then
53569c9ff80cSmrg		    arg="$non_pic_object"
53579c9ff80cSmrg		  fi
53589c9ff80cSmrg		else
53599c9ff80cSmrg		  # If the PIC object exists, use it instead.
53609c9ff80cSmrg		  # $xdir was prepended to $pic_object above.
53619c9ff80cSmrg		  non_pic_object="$pic_object"
53629c9ff80cSmrg		  func_append non_pic_objects " $non_pic_object"
53639c9ff80cSmrg		fi
53649c9ff80cSmrg	      else
53659c9ff80cSmrg		# Only an error if not doing a dry-run.
53669c9ff80cSmrg		if $opt_dry_run; then
53679c9ff80cSmrg		  # Extract subdirectory from the argument.
53689c9ff80cSmrg		  func_dirname "$arg" "/" ""
53699c9ff80cSmrg		  xdir="$func_dirname_result"
53709c9ff80cSmrg
53719c9ff80cSmrg		  func_lo2o "$arg"
53729c9ff80cSmrg		  pic_object=$xdir$objdir/$func_lo2o_result
53739c9ff80cSmrg		  non_pic_object=$xdir$func_lo2o_result
53749c9ff80cSmrg		  func_append libobjs " $pic_object"
53759c9ff80cSmrg		  func_append non_pic_objects " $non_pic_object"
53769c9ff80cSmrg	        else
53779c9ff80cSmrg		  func_fatal_error "\`$arg' is not a valid libtool object"
53789c9ff80cSmrg		fi
53799c9ff80cSmrg	      fi
53809c9ff80cSmrg	    done
53811f0ac6a5Smrg	  else
53829c9ff80cSmrg	    func_fatal_error "link input file \`$arg' does not exist"
53831f0ac6a5Smrg	  fi
53849c9ff80cSmrg	  arg=$save_arg
53859c9ff80cSmrg	  prev=
53869c9ff80cSmrg	  continue
53879c9ff80cSmrg	  ;;
53889c9ff80cSmrg	precious_regex)
53899c9ff80cSmrg	  precious_files_regex="$arg"
53909c9ff80cSmrg	  prev=
53919c9ff80cSmrg	  continue
53929c9ff80cSmrg	  ;;
53939c9ff80cSmrg	release)
53949c9ff80cSmrg	  release="-$arg"
53959c9ff80cSmrg	  prev=
53969c9ff80cSmrg	  continue
53979c9ff80cSmrg	  ;;
53989c9ff80cSmrg	rpath | xrpath)
53999c9ff80cSmrg	  # We need an absolute path.
54009c9ff80cSmrg	  case $arg in
54019c9ff80cSmrg	  [\\/]* | [A-Za-z]:[\\/]*) ;;
54029c9ff80cSmrg	  *)
54039c9ff80cSmrg	    func_fatal_error "only absolute run-paths are allowed"
54049c9ff80cSmrg	    ;;
54059c9ff80cSmrg	  esac
54069c9ff80cSmrg	  if test "$prev" = rpath; then
54079c9ff80cSmrg	    case "$rpath " in
54089c9ff80cSmrg	    *" $arg "*) ;;
54096fae4e5dSmrg	    *) func_append rpath " $arg" ;;
54109c9ff80cSmrg	    esac
54111f0ac6a5Smrg	  else
54129c9ff80cSmrg	    case "$xrpath " in
54139c9ff80cSmrg	    *" $arg "*) ;;
54146fae4e5dSmrg	    *) func_append xrpath " $arg" ;;
54159c9ff80cSmrg	    esac
54161f0ac6a5Smrg	  fi
54179c9ff80cSmrg	  prev=
54189c9ff80cSmrg	  continue
54199c9ff80cSmrg	  ;;
54209c9ff80cSmrg	shrext)
54219c9ff80cSmrg	  shrext_cmds="$arg"
54229c9ff80cSmrg	  prev=
54239c9ff80cSmrg	  continue
54249c9ff80cSmrg	  ;;
54259c9ff80cSmrg	weak)
54266fae4e5dSmrg	  func_append weak_libs " $arg"
54279c9ff80cSmrg	  prev=
54289c9ff80cSmrg	  continue
54299c9ff80cSmrg	  ;;
54309c9ff80cSmrg	xcclinker)
54316fae4e5dSmrg	  func_append linker_flags " $qarg"
54326fae4e5dSmrg	  func_append compiler_flags " $qarg"
54339c9ff80cSmrg	  prev=
54349c9ff80cSmrg	  func_append compile_command " $qarg"
54359c9ff80cSmrg	  func_append finalize_command " $qarg"
54369c9ff80cSmrg	  continue
54379c9ff80cSmrg	  ;;
54389c9ff80cSmrg	xcompiler)
54396fae4e5dSmrg	  func_append compiler_flags " $qarg"
54409c9ff80cSmrg	  prev=
54419c9ff80cSmrg	  func_append compile_command " $qarg"
54429c9ff80cSmrg	  func_append finalize_command " $qarg"
54439c9ff80cSmrg	  continue
54449c9ff80cSmrg	  ;;
54459c9ff80cSmrg	xlinker)
54466fae4e5dSmrg	  func_append linker_flags " $qarg"
54476fae4e5dSmrg	  func_append compiler_flags " $wl$qarg"
54489c9ff80cSmrg	  prev=
54499c9ff80cSmrg	  func_append compile_command " $wl$qarg"
54509c9ff80cSmrg	  func_append finalize_command " $wl$qarg"
54519c9ff80cSmrg	  continue
54529c9ff80cSmrg	  ;;
54539c9ff80cSmrg	*)
54549c9ff80cSmrg	  eval "$prev=\"\$arg\""
54559c9ff80cSmrg	  prev=
54569c9ff80cSmrg	  continue
54579c9ff80cSmrg	  ;;
54581f0ac6a5Smrg	esac
54599c9ff80cSmrg      fi # test -n "$prev"
54601f0ac6a5Smrg
54619c9ff80cSmrg      prevarg="$arg"
54621f0ac6a5Smrg
54639c9ff80cSmrg      case $arg in
54649c9ff80cSmrg      -all-static)
54659c9ff80cSmrg	if test -n "$link_static_flag"; then
54669c9ff80cSmrg	  # See comment for -static flag below, for more details.
54679c9ff80cSmrg	  func_append compile_command " $link_static_flag"
54689c9ff80cSmrg	  func_append finalize_command " $link_static_flag"
54699c9ff80cSmrg	fi
54709c9ff80cSmrg	continue
54719c9ff80cSmrg	;;
54721f0ac6a5Smrg
54739c9ff80cSmrg      -allow-undefined)
54749c9ff80cSmrg	# FIXME: remove this flag sometime in the future.
54759c9ff80cSmrg	func_fatal_error "\`-allow-undefined' must not be used because it is the default"
54769c9ff80cSmrg	;;
54771f0ac6a5Smrg
54789c9ff80cSmrg      -avoid-version)
54799c9ff80cSmrg	avoid_version=yes
54809c9ff80cSmrg	continue
54819c9ff80cSmrg	;;
54821f0ac6a5Smrg
54836fae4e5dSmrg      -bindir)
54846fae4e5dSmrg	prev=bindir
54856fae4e5dSmrg	continue
54866fae4e5dSmrg	;;
54876fae4e5dSmrg
54889c9ff80cSmrg      -dlopen)
54899c9ff80cSmrg	prev=dlfiles
54909c9ff80cSmrg	continue
54919c9ff80cSmrg	;;
54921f0ac6a5Smrg
54939c9ff80cSmrg      -dlpreopen)
54949c9ff80cSmrg	prev=dlprefiles
54959c9ff80cSmrg	continue
54969c9ff80cSmrg	;;
54971f0ac6a5Smrg
54989c9ff80cSmrg      -export-dynamic)
54999c9ff80cSmrg	export_dynamic=yes
55009c9ff80cSmrg	continue
55019c9ff80cSmrg	;;
55021f0ac6a5Smrg
55039c9ff80cSmrg      -export-symbols | -export-symbols-regex)
55049c9ff80cSmrg	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
55059c9ff80cSmrg	  func_fatal_error "more than one -exported-symbols argument is not allowed"
55069c9ff80cSmrg	fi
55079c9ff80cSmrg	if test "X$arg" = "X-export-symbols"; then
55089c9ff80cSmrg	  prev=expsyms
55099c9ff80cSmrg	else
55109c9ff80cSmrg	  prev=expsyms_regex
55119c9ff80cSmrg	fi
55129c9ff80cSmrg	continue
55139c9ff80cSmrg	;;
55141f0ac6a5Smrg
55159c9ff80cSmrg      -framework)
55169c9ff80cSmrg	prev=framework
55179c9ff80cSmrg	continue
55189c9ff80cSmrg	;;
55191f0ac6a5Smrg
55209c9ff80cSmrg      -inst-prefix-dir)
55219c9ff80cSmrg	prev=inst_prefix
55229c9ff80cSmrg	continue
55239c9ff80cSmrg	;;
55241f0ac6a5Smrg
55259c9ff80cSmrg      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
55269c9ff80cSmrg      # so, if we see these flags be careful not to treat them like -L
55279c9ff80cSmrg      -L[A-Z][A-Z]*:*)
55289c9ff80cSmrg	case $with_gcc/$host in
55299c9ff80cSmrg	no/*-*-irix* | /*-*-irix*)
55309c9ff80cSmrg	  func_append compile_command " $arg"
55319c9ff80cSmrg	  func_append finalize_command " $arg"
55329c9ff80cSmrg	  ;;
55339c9ff80cSmrg	esac
55349c9ff80cSmrg	continue
55359c9ff80cSmrg	;;
55361f0ac6a5Smrg
55379c9ff80cSmrg      -L*)
55386fae4e5dSmrg	func_stripname "-L" '' "$arg"
55396fae4e5dSmrg	if test -z "$func_stripname_result"; then
55409c9ff80cSmrg	  if test "$#" -gt 0; then
55419c9ff80cSmrg	    func_fatal_error "require no space between \`-L' and \`$1'"
55429c9ff80cSmrg	  else
55439c9ff80cSmrg	    func_fatal_error "need path for \`-L' option"
55449c9ff80cSmrg	  fi
55459c9ff80cSmrg	fi
55466fae4e5dSmrg	func_resolve_sysroot "$func_stripname_result"
55476fae4e5dSmrg	dir=$func_resolve_sysroot_result
55489c9ff80cSmrg	# We need an absolute path.
55499c9ff80cSmrg	case $dir in
55509c9ff80cSmrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
55519c9ff80cSmrg	*)
55529c9ff80cSmrg	  absdir=`cd "$dir" && pwd`
55539c9ff80cSmrg	  test -z "$absdir" && \
55549c9ff80cSmrg	    func_fatal_error "cannot determine absolute directory name of \`$dir'"
55559c9ff80cSmrg	  dir="$absdir"
55569c9ff80cSmrg	  ;;
55579c9ff80cSmrg	esac
55589c9ff80cSmrg	case "$deplibs " in
55596fae4e5dSmrg	*" -L$dir "* | *" $arg "*)
55606fae4e5dSmrg	  # Will only happen for absolute or sysroot arguments
55616fae4e5dSmrg	  ;;
55629c9ff80cSmrg	*)
55636fae4e5dSmrg	  # Preserve sysroot, but never include relative directories
55646fae4e5dSmrg	  case $dir in
55656fae4e5dSmrg	    [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;;
55666fae4e5dSmrg	    *) func_append deplibs " -L$dir" ;;
55676fae4e5dSmrg	  esac
55686fae4e5dSmrg	  func_append lib_search_path " $dir"
55699c9ff80cSmrg	  ;;
55709c9ff80cSmrg	esac
55719c9ff80cSmrg	case $host in
55729c9ff80cSmrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
55736fae4e5dSmrg	  testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
55749c9ff80cSmrg	  case :$dllsearchpath: in
55759c9ff80cSmrg	  *":$dir:"*) ;;
55769c9ff80cSmrg	  ::) dllsearchpath=$dir;;
55776fae4e5dSmrg	  *) func_append dllsearchpath ":$dir";;
55789c9ff80cSmrg	  esac
55799c9ff80cSmrg	  case :$dllsearchpath: in
55809c9ff80cSmrg	  *":$testbindir:"*) ;;
55819c9ff80cSmrg	  ::) dllsearchpath=$testbindir;;
55826fae4e5dSmrg	  *) func_append dllsearchpath ":$testbindir";;
55839c9ff80cSmrg	  esac
55849c9ff80cSmrg	  ;;
55859c9ff80cSmrg	esac
55869c9ff80cSmrg	continue
55879c9ff80cSmrg	;;
55881f0ac6a5Smrg
55899c9ff80cSmrg      -l*)
55909c9ff80cSmrg	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
55919c9ff80cSmrg	  case $host in
55926fae4e5dSmrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
55939c9ff80cSmrg	    # These systems don't actually have a C or math library (as such)
55949c9ff80cSmrg	    continue
55959c9ff80cSmrg	    ;;
55969c9ff80cSmrg	  *-*-os2*)
55979c9ff80cSmrg	    # These systems don't actually have a C library (as such)
55989c9ff80cSmrg	    test "X$arg" = "X-lc" && continue
55999c9ff80cSmrg	    ;;
56009c9ff80cSmrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
56019c9ff80cSmrg	    # Do not include libc due to us having libc/libc_r.
56029c9ff80cSmrg	    test "X$arg" = "X-lc" && continue
56039c9ff80cSmrg	    ;;
56049c9ff80cSmrg	  *-*-rhapsody* | *-*-darwin1.[012])
56059c9ff80cSmrg	    # Rhapsody C and math libraries are in the System framework
56066fae4e5dSmrg	    func_append deplibs " System.ltframework"
56079c9ff80cSmrg	    continue
56089c9ff80cSmrg	    ;;
56099c9ff80cSmrg	  *-*-sco3.2v5* | *-*-sco5v6*)
56109c9ff80cSmrg	    # Causes problems with __ctype
56119c9ff80cSmrg	    test "X$arg" = "X-lc" && continue
56129c9ff80cSmrg	    ;;
56139c9ff80cSmrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
56149c9ff80cSmrg	    # Compiler inserts libc in the correct place for threads to work
56159c9ff80cSmrg	    test "X$arg" = "X-lc" && continue
56169c9ff80cSmrg	    ;;
56179c9ff80cSmrg	  esac
56189c9ff80cSmrg	elif test "X$arg" = "X-lc_r"; then
56199c9ff80cSmrg	 case $host in
56209c9ff80cSmrg	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
56219c9ff80cSmrg	   # Do not include libc_r directly, use -pthread flag.
56229c9ff80cSmrg	   continue
56239c9ff80cSmrg	   ;;
56249c9ff80cSmrg	 esac
56259c9ff80cSmrg	fi
56266fae4e5dSmrg	func_append deplibs " $arg"
56279c9ff80cSmrg	continue
56289c9ff80cSmrg	;;
56291f0ac6a5Smrg
56309c9ff80cSmrg      -module)
56319c9ff80cSmrg	module=yes
56329c9ff80cSmrg	continue
56339c9ff80cSmrg	;;
56341f0ac6a5Smrg
56359c9ff80cSmrg      # Tru64 UNIX uses -model [arg] to determine the layout of C++
56369c9ff80cSmrg      # classes, name mangling, and exception handling.
56379c9ff80cSmrg      # Darwin uses the -arch flag to determine output architecture.
56386fae4e5dSmrg      -model|-arch|-isysroot|--sysroot)
56396fae4e5dSmrg	func_append compiler_flags " $arg"
56409c9ff80cSmrg	func_append compile_command " $arg"
56419c9ff80cSmrg	func_append finalize_command " $arg"
56429c9ff80cSmrg	prev=xcompiler
56439c9ff80cSmrg	continue
56449c9ff80cSmrg	;;
56451f0ac6a5Smrg
56469c9ff80cSmrg      -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
56476fae4e5dSmrg	func_append compiler_flags " $arg"
56489c9ff80cSmrg	func_append compile_command " $arg"
56499c9ff80cSmrg	func_append finalize_command " $arg"
56509c9ff80cSmrg	case "$new_inherited_linker_flags " in
56519c9ff80cSmrg	    *" $arg "*) ;;
56526fae4e5dSmrg	    * ) func_append new_inherited_linker_flags " $arg" ;;
56539c9ff80cSmrg	esac
56549c9ff80cSmrg	continue
56559c9ff80cSmrg	;;
56561f0ac6a5Smrg
56579c9ff80cSmrg      -multi_module)
56589c9ff80cSmrg	single_module="${wl}-multi_module"
56599c9ff80cSmrg	continue
56609c9ff80cSmrg	;;
56611f0ac6a5Smrg
56629c9ff80cSmrg      -no-fast-install)
56639c9ff80cSmrg	fast_install=no
56649c9ff80cSmrg	continue
56659c9ff80cSmrg	;;
56661f0ac6a5Smrg
56679c9ff80cSmrg      -no-install)
56689c9ff80cSmrg	case $host in
56699c9ff80cSmrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
56709c9ff80cSmrg	  # The PATH hackery in wrapper scripts is required on Windows
56719c9ff80cSmrg	  # and Darwin in order for the loader to find any dlls it needs.
56729c9ff80cSmrg	  func_warning "\`-no-install' is ignored for $host"
56739c9ff80cSmrg	  func_warning "assuming \`-no-fast-install' instead"
56749c9ff80cSmrg	  fast_install=no
56759c9ff80cSmrg	  ;;
56769c9ff80cSmrg	*) no_install=yes ;;
56779c9ff80cSmrg	esac
56789c9ff80cSmrg	continue
56799c9ff80cSmrg	;;
56801f0ac6a5Smrg
56819c9ff80cSmrg      -no-undefined)
56829c9ff80cSmrg	allow_undefined=no
56839c9ff80cSmrg	continue
56849c9ff80cSmrg	;;
56851f0ac6a5Smrg
56869c9ff80cSmrg      -objectlist)
56879c9ff80cSmrg	prev=objectlist
56889c9ff80cSmrg	continue
56899c9ff80cSmrg	;;
56901f0ac6a5Smrg
56919c9ff80cSmrg      -o) prev=output ;;
56921f0ac6a5Smrg
56939c9ff80cSmrg      -precious-files-regex)
56949c9ff80cSmrg	prev=precious_regex
56959c9ff80cSmrg	continue
56969c9ff80cSmrg	;;
56971f0ac6a5Smrg
56989c9ff80cSmrg      -release)
56999c9ff80cSmrg	prev=release
57009c9ff80cSmrg	continue
57019c9ff80cSmrg	;;
57021f0ac6a5Smrg
57039c9ff80cSmrg      -rpath)
57049c9ff80cSmrg	prev=rpath
57059c9ff80cSmrg	continue
57069c9ff80cSmrg	;;
57071f0ac6a5Smrg
57089c9ff80cSmrg      -R)
57099c9ff80cSmrg	prev=xrpath
57109c9ff80cSmrg	continue
57119c9ff80cSmrg	;;
57121f0ac6a5Smrg
57139c9ff80cSmrg      -R*)
57149c9ff80cSmrg	func_stripname '-R' '' "$arg"
57159c9ff80cSmrg	dir=$func_stripname_result
57169c9ff80cSmrg	# We need an absolute path.
57179c9ff80cSmrg	case $dir in
57189c9ff80cSmrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
57196fae4e5dSmrg	=*)
57206fae4e5dSmrg	  func_stripname '=' '' "$dir"
57216fae4e5dSmrg	  dir=$lt_sysroot$func_stripname_result
57226fae4e5dSmrg	  ;;
57239c9ff80cSmrg	*)
57249c9ff80cSmrg	  func_fatal_error "only absolute run-paths are allowed"
57259c9ff80cSmrg	  ;;
57269c9ff80cSmrg	esac
57279c9ff80cSmrg	case "$xrpath " in
57289c9ff80cSmrg	*" $dir "*) ;;
57296fae4e5dSmrg	*) func_append xrpath " $dir" ;;
57309c9ff80cSmrg	esac
57319c9ff80cSmrg	continue
57329c9ff80cSmrg	;;
57331f0ac6a5Smrg
57349c9ff80cSmrg      -shared)
57359c9ff80cSmrg	# The effects of -shared are defined in a previous loop.
57369c9ff80cSmrg	continue
57379c9ff80cSmrg	;;
57381f0ac6a5Smrg
57399c9ff80cSmrg      -shrext)
57409c9ff80cSmrg	prev=shrext
57419c9ff80cSmrg	continue
57429c9ff80cSmrg	;;
57431f0ac6a5Smrg
57449c9ff80cSmrg      -static | -static-libtool-libs)
57459c9ff80cSmrg	# The effects of -static are defined in a previous loop.
57469c9ff80cSmrg	# We used to do the same as -all-static on platforms that
57479c9ff80cSmrg	# didn't have a PIC flag, but the assumption that the effects
57489c9ff80cSmrg	# would be equivalent was wrong.  It would break on at least
57499c9ff80cSmrg	# Digital Unix and AIX.
57509c9ff80cSmrg	continue
57519c9ff80cSmrg	;;
57521f0ac6a5Smrg
57539c9ff80cSmrg      -thread-safe)
57549c9ff80cSmrg	thread_safe=yes
57559c9ff80cSmrg	continue
57569c9ff80cSmrg	;;
57571f0ac6a5Smrg
57589c9ff80cSmrg      -version-info)
57599c9ff80cSmrg	prev=vinfo
57609c9ff80cSmrg	continue
57619c9ff80cSmrg	;;
57621f0ac6a5Smrg
57639c9ff80cSmrg      -version-number)
57649c9ff80cSmrg	prev=vinfo
57659c9ff80cSmrg	vinfo_number=yes
57669c9ff80cSmrg	continue
57679c9ff80cSmrg	;;
57681f0ac6a5Smrg
57699c9ff80cSmrg      -weak)
57709c9ff80cSmrg        prev=weak
57719c9ff80cSmrg	continue
57729c9ff80cSmrg	;;
57731f0ac6a5Smrg
57749c9ff80cSmrg      -Wc,*)
57759c9ff80cSmrg	func_stripname '-Wc,' '' "$arg"
57769c9ff80cSmrg	args=$func_stripname_result
57779c9ff80cSmrg	arg=
57789c9ff80cSmrg	save_ifs="$IFS"; IFS=','
57799c9ff80cSmrg	for flag in $args; do
57809c9ff80cSmrg	  IFS="$save_ifs"
57819c9ff80cSmrg          func_quote_for_eval "$flag"
57826fae4e5dSmrg	  func_append arg " $func_quote_for_eval_result"
57836fae4e5dSmrg	  func_append compiler_flags " $func_quote_for_eval_result"
57849c9ff80cSmrg	done
57859c9ff80cSmrg	IFS="$save_ifs"
57869c9ff80cSmrg	func_stripname ' ' '' "$arg"
57879c9ff80cSmrg	arg=$func_stripname_result
57889c9ff80cSmrg	;;
57891f0ac6a5Smrg
57909c9ff80cSmrg      -Wl,*)
57919c9ff80cSmrg	func_stripname '-Wl,' '' "$arg"
57929c9ff80cSmrg	args=$func_stripname_result
57939c9ff80cSmrg	arg=
57949c9ff80cSmrg	save_ifs="$IFS"; IFS=','
57959c9ff80cSmrg	for flag in $args; do
57969c9ff80cSmrg	  IFS="$save_ifs"
57979c9ff80cSmrg          func_quote_for_eval "$flag"
57986fae4e5dSmrg	  func_append arg " $wl$func_quote_for_eval_result"
57996fae4e5dSmrg	  func_append compiler_flags " $wl$func_quote_for_eval_result"
58006fae4e5dSmrg	  func_append linker_flags " $func_quote_for_eval_result"
58019c9ff80cSmrg	done
58029c9ff80cSmrg	IFS="$save_ifs"
58039c9ff80cSmrg	func_stripname ' ' '' "$arg"
58049c9ff80cSmrg	arg=$func_stripname_result
58059c9ff80cSmrg	;;
58061f0ac6a5Smrg
58079c9ff80cSmrg      -Xcompiler)
58089c9ff80cSmrg	prev=xcompiler
58099c9ff80cSmrg	continue
58109c9ff80cSmrg	;;
58111f0ac6a5Smrg
58129c9ff80cSmrg      -Xlinker)
58139c9ff80cSmrg	prev=xlinker
58149c9ff80cSmrg	continue
58159c9ff80cSmrg	;;
58161f0ac6a5Smrg
58179c9ff80cSmrg      -XCClinker)
58189c9ff80cSmrg	prev=xcclinker
58199c9ff80cSmrg	continue
58209c9ff80cSmrg	;;
58211f0ac6a5Smrg
58229c9ff80cSmrg      # -msg_* for osf cc
58239c9ff80cSmrg      -msg_*)
58249c9ff80cSmrg	func_quote_for_eval "$arg"
58259c9ff80cSmrg	arg="$func_quote_for_eval_result"
58269c9ff80cSmrg	;;
58271f0ac6a5Smrg
58286fae4e5dSmrg      # Flags to be passed through unchanged, with rationale:
58296fae4e5dSmrg      # -64, -mips[0-9]      enable 64-bit mode for the SGI compiler
58306fae4e5dSmrg      # -r[0-9][0-9]*        specify processor for the SGI compiler
58316fae4e5dSmrg      # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler
58326fae4e5dSmrg      # +DA*, +DD*           enable 64-bit mode for the HP compiler
58336fae4e5dSmrg      # -q*                  compiler args for the IBM compiler
58346fae4e5dSmrg      # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
58356fae4e5dSmrg      # -F/path              path to uninstalled frameworks, gcc on darwin
58366fae4e5dSmrg      # -p, -pg, --coverage, -fprofile-*  profiling flags for GCC
58376fae4e5dSmrg      # @file                GCC response files
58386fae4e5dSmrg      # -tp=*                Portland pgcc target processor selection
58396fae4e5dSmrg      # --sysroot=*          for sysroot support
58406fae4e5dSmrg      # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
58419c9ff80cSmrg      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
58426fae4e5dSmrg      -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
58436fae4e5dSmrg      -O*|-flto*|-fwhopr*|-fuse-linker-plugin)
58449c9ff80cSmrg        func_quote_for_eval "$arg"
58459c9ff80cSmrg	arg="$func_quote_for_eval_result"
58469c9ff80cSmrg        func_append compile_command " $arg"
58479c9ff80cSmrg        func_append finalize_command " $arg"
58486fae4e5dSmrg        func_append compiler_flags " $arg"
58499c9ff80cSmrg        continue
58509c9ff80cSmrg        ;;
58511f0ac6a5Smrg
58529c9ff80cSmrg      # Some other compiler flag.
58539c9ff80cSmrg      -* | +*)
58549c9ff80cSmrg        func_quote_for_eval "$arg"
58559c9ff80cSmrg	arg="$func_quote_for_eval_result"
58569c9ff80cSmrg	;;
58571f0ac6a5Smrg
58589c9ff80cSmrg      *.$objext)
58599c9ff80cSmrg	# A standard object.
58606fae4e5dSmrg	func_append objs " $arg"
58619c9ff80cSmrg	;;
58621f0ac6a5Smrg
58639c9ff80cSmrg      *.lo)
58649c9ff80cSmrg	# A libtool-controlled object.
58651f0ac6a5Smrg
58669c9ff80cSmrg	# Check to see that this really is a libtool object.
58679c9ff80cSmrg	if func_lalib_unsafe_p "$arg"; then
58689c9ff80cSmrg	  pic_object=
58699c9ff80cSmrg	  non_pic_object=
58701f0ac6a5Smrg
58719c9ff80cSmrg	  # Read the .lo file
58729c9ff80cSmrg	  func_source "$arg"
58731f0ac6a5Smrg
58749c9ff80cSmrg	  if test -z "$pic_object" ||
58759c9ff80cSmrg	     test -z "$non_pic_object" ||
58769c9ff80cSmrg	     test "$pic_object" = none &&
58779c9ff80cSmrg	     test "$non_pic_object" = none; then
58789c9ff80cSmrg	    func_fatal_error "cannot find name of object for \`$arg'"
58799c9ff80cSmrg	  fi
58801f0ac6a5Smrg
58819c9ff80cSmrg	  # Extract subdirectory from the argument.
58829c9ff80cSmrg	  func_dirname "$arg" "/" ""
58839c9ff80cSmrg	  xdir="$func_dirname_result"
5884e5410a46Smrg
58859c9ff80cSmrg	  if test "$pic_object" != none; then
58869c9ff80cSmrg	    # Prepend the subdirectory the object is found in.
58879c9ff80cSmrg	    pic_object="$xdir$pic_object"
58881f0ac6a5Smrg
58899c9ff80cSmrg	    if test "$prev" = dlfiles; then
58909c9ff80cSmrg	      if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
58916fae4e5dSmrg		func_append dlfiles " $pic_object"
58929c9ff80cSmrg		prev=
58939c9ff80cSmrg		continue
58949c9ff80cSmrg	      else
58959c9ff80cSmrg		# If libtool objects are unsupported, then we need to preload.
58969c9ff80cSmrg		prev=dlprefiles
58979c9ff80cSmrg	      fi
58989c9ff80cSmrg	    fi
58991f0ac6a5Smrg
59009c9ff80cSmrg	    # CHECK ME:  I think I busted this.  -Ossama
59019c9ff80cSmrg	    if test "$prev" = dlprefiles; then
59029c9ff80cSmrg	      # Preload the old-style object.
59036fae4e5dSmrg	      func_append dlprefiles " $pic_object"
59049c9ff80cSmrg	      prev=
59059c9ff80cSmrg	    fi
59061f0ac6a5Smrg
59079c9ff80cSmrg	    # A PIC object.
59089c9ff80cSmrg	    func_append libobjs " $pic_object"
59099c9ff80cSmrg	    arg="$pic_object"
59109c9ff80cSmrg	  fi
59111f0ac6a5Smrg
59129c9ff80cSmrg	  # Non-PIC object.
59139c9ff80cSmrg	  if test "$non_pic_object" != none; then
59149c9ff80cSmrg	    # Prepend the subdirectory the object is found in.
59159c9ff80cSmrg	    non_pic_object="$xdir$non_pic_object"
59161f0ac6a5Smrg
59179c9ff80cSmrg	    # A standard non-PIC object
59189c9ff80cSmrg	    func_append non_pic_objects " $non_pic_object"
59199c9ff80cSmrg	    if test -z "$pic_object" || test "$pic_object" = none ; then
59209c9ff80cSmrg	      arg="$non_pic_object"
59219c9ff80cSmrg	    fi
59229c9ff80cSmrg	  else
59239c9ff80cSmrg	    # If the PIC object exists, use it instead.
59249c9ff80cSmrg	    # $xdir was prepended to $pic_object above.
59259c9ff80cSmrg	    non_pic_object="$pic_object"
59269c9ff80cSmrg	    func_append non_pic_objects " $non_pic_object"
59279c9ff80cSmrg	  fi
59289c9ff80cSmrg	else
59299c9ff80cSmrg	  # Only an error if not doing a dry-run.
59309c9ff80cSmrg	  if $opt_dry_run; then
59319c9ff80cSmrg	    # Extract subdirectory from the argument.
59329c9ff80cSmrg	    func_dirname "$arg" "/" ""
59339c9ff80cSmrg	    xdir="$func_dirname_result"
59349c9ff80cSmrg
59359c9ff80cSmrg	    func_lo2o "$arg"
59369c9ff80cSmrg	    pic_object=$xdir$objdir/$func_lo2o_result
59379c9ff80cSmrg	    non_pic_object=$xdir$func_lo2o_result
59389c9ff80cSmrg	    func_append libobjs " $pic_object"
59399c9ff80cSmrg	    func_append non_pic_objects " $non_pic_object"
59409c9ff80cSmrg	  else
59419c9ff80cSmrg	    func_fatal_error "\`$arg' is not a valid libtool object"
59429c9ff80cSmrg	  fi
59439c9ff80cSmrg	fi
59449c9ff80cSmrg	;;
59451f0ac6a5Smrg
59469c9ff80cSmrg      *.$libext)
59479c9ff80cSmrg	# An archive.
59486fae4e5dSmrg	func_append deplibs " $arg"
59496fae4e5dSmrg	func_append old_deplibs " $arg"
59509c9ff80cSmrg	continue
59519c9ff80cSmrg	;;
59529c9ff80cSmrg
59539c9ff80cSmrg      *.la)
59549c9ff80cSmrg	# A libtool-controlled library.
59559c9ff80cSmrg
59566fae4e5dSmrg	func_resolve_sysroot "$arg"
59579c9ff80cSmrg	if test "$prev" = dlfiles; then
59589c9ff80cSmrg	  # This library was specified with -dlopen.
59596fae4e5dSmrg	  func_append dlfiles " $func_resolve_sysroot_result"
59609c9ff80cSmrg	  prev=
59619c9ff80cSmrg	elif test "$prev" = dlprefiles; then
59629c9ff80cSmrg	  # The library was specified with -dlpreopen.
59636fae4e5dSmrg	  func_append dlprefiles " $func_resolve_sysroot_result"
59649c9ff80cSmrg	  prev=
59659c9ff80cSmrg	else
59666fae4e5dSmrg	  func_append deplibs " $func_resolve_sysroot_result"
59679c9ff80cSmrg	fi
59689c9ff80cSmrg	continue
59699c9ff80cSmrg	;;
59709c9ff80cSmrg
59719c9ff80cSmrg      # Some other compiler argument.
59729c9ff80cSmrg      *)
59739c9ff80cSmrg	# Unknown arguments in both finalize_command and compile_command need
59749c9ff80cSmrg	# to be aesthetically quoted because they are evaled later.
59759c9ff80cSmrg	func_quote_for_eval "$arg"
59769c9ff80cSmrg	arg="$func_quote_for_eval_result"
59779c9ff80cSmrg	;;
59789c9ff80cSmrg      esac # arg
59799c9ff80cSmrg
59809c9ff80cSmrg      # Now actually substitute the argument into the commands.
59819c9ff80cSmrg      if test -n "$arg"; then
59829c9ff80cSmrg	func_append compile_command " $arg"
59839c9ff80cSmrg	func_append finalize_command " $arg"
59849c9ff80cSmrg      fi
59859c9ff80cSmrg    done # argument parsing loop
59869c9ff80cSmrg
59879c9ff80cSmrg    test -n "$prev" && \
59889c9ff80cSmrg      func_fatal_help "the \`$prevarg' option requires an argument"
59899c9ff80cSmrg
59909c9ff80cSmrg    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
59919c9ff80cSmrg      eval arg=\"$export_dynamic_flag_spec\"
59929c9ff80cSmrg      func_append compile_command " $arg"
59939c9ff80cSmrg      func_append finalize_command " $arg"
59949c9ff80cSmrg    fi
59959c9ff80cSmrg
59969c9ff80cSmrg    oldlibs=
59979c9ff80cSmrg    # calculate the name of the file, without its directory
59989c9ff80cSmrg    func_basename "$output"
59999c9ff80cSmrg    outputname="$func_basename_result"
60009c9ff80cSmrg    libobjs_save="$libobjs"
60019c9ff80cSmrg
60029c9ff80cSmrg    if test -n "$shlibpath_var"; then
60039c9ff80cSmrg      # get the directories listed in $shlibpath_var
60046fae4e5dSmrg      eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\`
60059c9ff80cSmrg    else
60069c9ff80cSmrg      shlib_search_path=
60079c9ff80cSmrg    fi
60089c9ff80cSmrg    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
60099c9ff80cSmrg    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
60109c9ff80cSmrg
60119c9ff80cSmrg    func_dirname "$output" "/" ""
60129c9ff80cSmrg    output_objdir="$func_dirname_result$objdir"
60136fae4e5dSmrg    func_to_tool_file "$output_objdir/"
60146fae4e5dSmrg    tool_output_objdir=$func_to_tool_file_result
60159c9ff80cSmrg    # Create the object directory.
60169c9ff80cSmrg    func_mkdir_p "$output_objdir"
60179c9ff80cSmrg
60189c9ff80cSmrg    # Determine the type of output
60199c9ff80cSmrg    case $output in
60209c9ff80cSmrg    "")
60219c9ff80cSmrg      func_fatal_help "you must specify an output file"
60229c9ff80cSmrg      ;;
60239c9ff80cSmrg    *.$libext) linkmode=oldlib ;;
60249c9ff80cSmrg    *.lo | *.$objext) linkmode=obj ;;
60259c9ff80cSmrg    *.la) linkmode=lib ;;
60269c9ff80cSmrg    *) linkmode=prog ;; # Anything else should be a program.
60279c9ff80cSmrg    esac
60289c9ff80cSmrg
60299c9ff80cSmrg    specialdeplibs=
60309c9ff80cSmrg
60319c9ff80cSmrg    libs=
60329c9ff80cSmrg    # Find all interdependent deplibs by searching for libraries
60339c9ff80cSmrg    # that are linked more than once (e.g. -la -lb -la)
60349c9ff80cSmrg    for deplib in $deplibs; do
60356fae4e5dSmrg      if $opt_preserve_dup_deps ; then
60369c9ff80cSmrg	case "$libs " in
60376fae4e5dSmrg	*" $deplib "*) func_append specialdeplibs " $deplib" ;;
60389c9ff80cSmrg	esac
60399c9ff80cSmrg      fi
60406fae4e5dSmrg      func_append libs " $deplib"
60419c9ff80cSmrg    done
60429c9ff80cSmrg
60439c9ff80cSmrg    if test "$linkmode" = lib; then
60449c9ff80cSmrg      libs="$predeps $libs $compiler_lib_search_path $postdeps"
60459c9ff80cSmrg
60469c9ff80cSmrg      # Compute libraries that are listed more than once in $predeps
60479c9ff80cSmrg      # $postdeps and mark them as special (i.e., whose duplicates are
60489c9ff80cSmrg      # not to be eliminated).
60499c9ff80cSmrg      pre_post_deps=
60509c9ff80cSmrg      if $opt_duplicate_compiler_generated_deps; then
60519c9ff80cSmrg	for pre_post_dep in $predeps $postdeps; do
60529c9ff80cSmrg	  case "$pre_post_deps " in
60536fae4e5dSmrg	  *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;;
60549c9ff80cSmrg	  esac
60556fae4e5dSmrg	  func_append pre_post_deps " $pre_post_dep"
60569c9ff80cSmrg	done
60579c9ff80cSmrg      fi
60589c9ff80cSmrg      pre_post_deps=
60599c9ff80cSmrg    fi
60609c9ff80cSmrg
60619c9ff80cSmrg    deplibs=
60629c9ff80cSmrg    newdependency_libs=
60639c9ff80cSmrg    newlib_search_path=
60649c9ff80cSmrg    need_relink=no # whether we're linking any uninstalled libtool libraries
60659c9ff80cSmrg    notinst_deplibs= # not-installed libtool libraries
60669c9ff80cSmrg    notinst_path= # paths that contain not-installed libtool libraries
60679c9ff80cSmrg
60689c9ff80cSmrg    case $linkmode in
60699c9ff80cSmrg    lib)
60709c9ff80cSmrg	passes="conv dlpreopen link"
60719c9ff80cSmrg	for file in $dlfiles $dlprefiles; do
60729c9ff80cSmrg	  case $file in
60739c9ff80cSmrg	  *.la) ;;
60749c9ff80cSmrg	  *)
60759c9ff80cSmrg	    func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file"
60769c9ff80cSmrg	    ;;
60779c9ff80cSmrg	  esac
60789c9ff80cSmrg	done
60799c9ff80cSmrg	;;
60809c9ff80cSmrg    prog)
60819c9ff80cSmrg	compile_deplibs=
60829c9ff80cSmrg	finalize_deplibs=
60839c9ff80cSmrg	alldeplibs=no
60849c9ff80cSmrg	newdlfiles=
60859c9ff80cSmrg	newdlprefiles=
60869c9ff80cSmrg	passes="conv scan dlopen dlpreopen link"
60879c9ff80cSmrg	;;
60889c9ff80cSmrg    *)  passes="conv"
60899c9ff80cSmrg	;;
60909c9ff80cSmrg    esac
60919c9ff80cSmrg
60929c9ff80cSmrg    for pass in $passes; do
60939c9ff80cSmrg      # The preopen pass in lib mode reverses $deplibs; put it back here
60949c9ff80cSmrg      # so that -L comes before libs that need it for instance...
60959c9ff80cSmrg      if test "$linkmode,$pass" = "lib,link"; then
60969c9ff80cSmrg	## FIXME: Find the place where the list is rebuilt in the wrong
60979c9ff80cSmrg	##        order, and fix it there properly
60989c9ff80cSmrg        tmp_deplibs=
60999c9ff80cSmrg	for deplib in $deplibs; do
61009c9ff80cSmrg	  tmp_deplibs="$deplib $tmp_deplibs"
61019c9ff80cSmrg	done
61029c9ff80cSmrg	deplibs="$tmp_deplibs"
61039c9ff80cSmrg      fi
61049c9ff80cSmrg
61059c9ff80cSmrg      if test "$linkmode,$pass" = "lib,link" ||
61069c9ff80cSmrg	 test "$linkmode,$pass" = "prog,scan"; then
61079c9ff80cSmrg	libs="$deplibs"
61089c9ff80cSmrg	deplibs=
61099c9ff80cSmrg      fi
61109c9ff80cSmrg      if test "$linkmode" = prog; then
61119c9ff80cSmrg	case $pass in
61129c9ff80cSmrg	dlopen) libs="$dlfiles" ;;
61139c9ff80cSmrg	dlpreopen) libs="$dlprefiles" ;;
61149c9ff80cSmrg	link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
61159c9ff80cSmrg	esac
61169c9ff80cSmrg      fi
61179c9ff80cSmrg      if test "$linkmode,$pass" = "lib,dlpreopen"; then
61189c9ff80cSmrg	# Collect and forward deplibs of preopened libtool libs
61199c9ff80cSmrg	for lib in $dlprefiles; do
61209c9ff80cSmrg	  # Ignore non-libtool-libs
61219c9ff80cSmrg	  dependency_libs=
61226fae4e5dSmrg	  func_resolve_sysroot "$lib"
61239c9ff80cSmrg	  case $lib in
61246fae4e5dSmrg	  *.la)	func_source "$func_resolve_sysroot_result" ;;
61259c9ff80cSmrg	  esac
61269c9ff80cSmrg
61279c9ff80cSmrg	  # Collect preopened libtool deplibs, except any this library
61289c9ff80cSmrg	  # has declared as weak libs
61299c9ff80cSmrg	  for deplib in $dependency_libs; do
61306fae4e5dSmrg	    func_basename "$deplib"
61316fae4e5dSmrg            deplib_base=$func_basename_result
61329c9ff80cSmrg	    case " $weak_libs " in
61339c9ff80cSmrg	    *" $deplib_base "*) ;;
61346fae4e5dSmrg	    *) func_append deplibs " $deplib" ;;
61359c9ff80cSmrg	    esac
61369c9ff80cSmrg	  done
61379c9ff80cSmrg	done
61389c9ff80cSmrg	libs="$dlprefiles"
61399c9ff80cSmrg      fi
61409c9ff80cSmrg      if test "$pass" = dlopen; then
61419c9ff80cSmrg	# Collect dlpreopened libraries
61429c9ff80cSmrg	save_deplibs="$deplibs"
61439c9ff80cSmrg	deplibs=
61449c9ff80cSmrg      fi
61459c9ff80cSmrg
61469c9ff80cSmrg      for deplib in $libs; do
61479c9ff80cSmrg	lib=
61489c9ff80cSmrg	found=no
61499c9ff80cSmrg	case $deplib in
61509c9ff80cSmrg	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
61519c9ff80cSmrg	  if test "$linkmode,$pass" = "prog,link"; then
61529c9ff80cSmrg	    compile_deplibs="$deplib $compile_deplibs"
61539c9ff80cSmrg	    finalize_deplibs="$deplib $finalize_deplibs"
61549c9ff80cSmrg	  else
61556fae4e5dSmrg	    func_append compiler_flags " $deplib"
61569c9ff80cSmrg	    if test "$linkmode" = lib ; then
61579c9ff80cSmrg		case "$new_inherited_linker_flags " in
61589c9ff80cSmrg		    *" $deplib "*) ;;
61596fae4e5dSmrg		    * ) func_append new_inherited_linker_flags " $deplib" ;;
61609c9ff80cSmrg		esac
61619c9ff80cSmrg	    fi
61629c9ff80cSmrg	  fi
61639c9ff80cSmrg	  continue
61649c9ff80cSmrg	  ;;
61659c9ff80cSmrg	-l*)
61669c9ff80cSmrg	  if test "$linkmode" != lib && test "$linkmode" != prog; then
61679c9ff80cSmrg	    func_warning "\`-l' is ignored for archives/objects"
61689c9ff80cSmrg	    continue
61699c9ff80cSmrg	  fi
61709c9ff80cSmrg	  func_stripname '-l' '' "$deplib"
61719c9ff80cSmrg	  name=$func_stripname_result
61729c9ff80cSmrg	  if test "$linkmode" = lib; then
61739c9ff80cSmrg	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
61749c9ff80cSmrg	  else
61759c9ff80cSmrg	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
61769c9ff80cSmrg	  fi
61779c9ff80cSmrg	  for searchdir in $searchdirs; do
61789c9ff80cSmrg	    for search_ext in .la $std_shrext .so .a; do
61799c9ff80cSmrg	      # Search the libtool library
61809c9ff80cSmrg	      lib="$searchdir/lib${name}${search_ext}"
61819c9ff80cSmrg	      if test -f "$lib"; then
61829c9ff80cSmrg		if test "$search_ext" = ".la"; then
61839c9ff80cSmrg		  found=yes
61849c9ff80cSmrg		else
61859c9ff80cSmrg		  found=no
61869c9ff80cSmrg		fi
61879c9ff80cSmrg		break 2
61889c9ff80cSmrg	      fi
61899c9ff80cSmrg	    done
61909c9ff80cSmrg	  done
61919c9ff80cSmrg	  if test "$found" != yes; then
61929c9ff80cSmrg	    # deplib doesn't seem to be a libtool library
61939c9ff80cSmrg	    if test "$linkmode,$pass" = "prog,link"; then
61949c9ff80cSmrg	      compile_deplibs="$deplib $compile_deplibs"
61959c9ff80cSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
61969c9ff80cSmrg	    else
61979c9ff80cSmrg	      deplibs="$deplib $deplibs"
61989c9ff80cSmrg	      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
61999c9ff80cSmrg	    fi
62009c9ff80cSmrg	    continue
62019c9ff80cSmrg	  else # deplib is a libtool library
62029c9ff80cSmrg	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
62039c9ff80cSmrg	    # We need to do some special things here, and not later.
62049c9ff80cSmrg	    if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
62059c9ff80cSmrg	      case " $predeps $postdeps " in
62069c9ff80cSmrg	      *" $deplib "*)
62079c9ff80cSmrg		if func_lalib_p "$lib"; then
62089c9ff80cSmrg		  library_names=
62099c9ff80cSmrg		  old_library=
62109c9ff80cSmrg		  func_source "$lib"
62119c9ff80cSmrg		  for l in $old_library $library_names; do
62129c9ff80cSmrg		    ll="$l"
62139c9ff80cSmrg		  done
62149c9ff80cSmrg		  if test "X$ll" = "X$old_library" ; then # only static version available
62159c9ff80cSmrg		    found=no
62169c9ff80cSmrg		    func_dirname "$lib" "" "."
62179c9ff80cSmrg		    ladir="$func_dirname_result"
62189c9ff80cSmrg		    lib=$ladir/$old_library
62199c9ff80cSmrg		    if test "$linkmode,$pass" = "prog,link"; then
62209c9ff80cSmrg		      compile_deplibs="$deplib $compile_deplibs"
62219c9ff80cSmrg		      finalize_deplibs="$deplib $finalize_deplibs"
62229c9ff80cSmrg		    else
62239c9ff80cSmrg		      deplibs="$deplib $deplibs"
62249c9ff80cSmrg		      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
62259c9ff80cSmrg		    fi
62269c9ff80cSmrg		    continue
62279c9ff80cSmrg		  fi
62289c9ff80cSmrg		fi
62299c9ff80cSmrg		;;
62309c9ff80cSmrg	      *) ;;
62319c9ff80cSmrg	      esac
62329c9ff80cSmrg	    fi
62339c9ff80cSmrg	  fi
62349c9ff80cSmrg	  ;; # -l
62359c9ff80cSmrg	*.ltframework)
62369c9ff80cSmrg	  if test "$linkmode,$pass" = "prog,link"; then
62379c9ff80cSmrg	    compile_deplibs="$deplib $compile_deplibs"
62389c9ff80cSmrg	    finalize_deplibs="$deplib $finalize_deplibs"
62399c9ff80cSmrg	  else
62409c9ff80cSmrg	    deplibs="$deplib $deplibs"
62419c9ff80cSmrg	    if test "$linkmode" = lib ; then
62429c9ff80cSmrg		case "$new_inherited_linker_flags " in
62439c9ff80cSmrg		    *" $deplib "*) ;;
62446fae4e5dSmrg		    * ) func_append new_inherited_linker_flags " $deplib" ;;
62459c9ff80cSmrg		esac
62469c9ff80cSmrg	    fi
62479c9ff80cSmrg	  fi
62489c9ff80cSmrg	  continue
62499c9ff80cSmrg	  ;;
62509c9ff80cSmrg	-L*)
62519c9ff80cSmrg	  case $linkmode in
62529c9ff80cSmrg	  lib)
62539c9ff80cSmrg	    deplibs="$deplib $deplibs"
62549c9ff80cSmrg	    test "$pass" = conv && continue
62559c9ff80cSmrg	    newdependency_libs="$deplib $newdependency_libs"
62569c9ff80cSmrg	    func_stripname '-L' '' "$deplib"
62576fae4e5dSmrg	    func_resolve_sysroot "$func_stripname_result"
62586fae4e5dSmrg	    func_append newlib_search_path " $func_resolve_sysroot_result"
62599c9ff80cSmrg	    ;;
62609c9ff80cSmrg	  prog)
62619c9ff80cSmrg	    if test "$pass" = conv; then
62629c9ff80cSmrg	      deplibs="$deplib $deplibs"
62639c9ff80cSmrg	      continue
62649c9ff80cSmrg	    fi
62659c9ff80cSmrg	    if test "$pass" = scan; then
62669c9ff80cSmrg	      deplibs="$deplib $deplibs"
62679c9ff80cSmrg	    else
62689c9ff80cSmrg	      compile_deplibs="$deplib $compile_deplibs"
62699c9ff80cSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
62709c9ff80cSmrg	    fi
62719c9ff80cSmrg	    func_stripname '-L' '' "$deplib"
62726fae4e5dSmrg	    func_resolve_sysroot "$func_stripname_result"
62736fae4e5dSmrg	    func_append newlib_search_path " $func_resolve_sysroot_result"
62749c9ff80cSmrg	    ;;
62759c9ff80cSmrg	  *)
62769c9ff80cSmrg	    func_warning "\`-L' is ignored for archives/objects"
62779c9ff80cSmrg	    ;;
62789c9ff80cSmrg	  esac # linkmode
62799c9ff80cSmrg	  continue
62809c9ff80cSmrg	  ;; # -L
62819c9ff80cSmrg	-R*)
62829c9ff80cSmrg	  if test "$pass" = link; then
62839c9ff80cSmrg	    func_stripname '-R' '' "$deplib"
62846fae4e5dSmrg	    func_resolve_sysroot "$func_stripname_result"
62856fae4e5dSmrg	    dir=$func_resolve_sysroot_result
62869c9ff80cSmrg	    # Make sure the xrpath contains only unique directories.
62879c9ff80cSmrg	    case "$xrpath " in
62889c9ff80cSmrg	    *" $dir "*) ;;
62896fae4e5dSmrg	    *) func_append xrpath " $dir" ;;
62909c9ff80cSmrg	    esac
62919c9ff80cSmrg	  fi
62929c9ff80cSmrg	  deplibs="$deplib $deplibs"
62939c9ff80cSmrg	  continue
62949c9ff80cSmrg	  ;;
62956fae4e5dSmrg	*.la)
62966fae4e5dSmrg	  func_resolve_sysroot "$deplib"
62976fae4e5dSmrg	  lib=$func_resolve_sysroot_result
62986fae4e5dSmrg	  ;;
62999c9ff80cSmrg	*.$libext)
63009c9ff80cSmrg	  if test "$pass" = conv; then
63019c9ff80cSmrg	    deplibs="$deplib $deplibs"
63029c9ff80cSmrg	    continue
63039c9ff80cSmrg	  fi
63049c9ff80cSmrg	  case $linkmode in
63059c9ff80cSmrg	  lib)
63069c9ff80cSmrg	    # Linking convenience modules into shared libraries is allowed,
63079c9ff80cSmrg	    # but linking other static libraries is non-portable.
63089c9ff80cSmrg	    case " $dlpreconveniencelibs " in
63099c9ff80cSmrg	    *" $deplib "*) ;;
63109c9ff80cSmrg	    *)
63119c9ff80cSmrg	      valid_a_lib=no
63129c9ff80cSmrg	      case $deplibs_check_method in
63139c9ff80cSmrg		match_pattern*)
63149c9ff80cSmrg		  set dummy $deplibs_check_method; shift
63159c9ff80cSmrg		  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
63166fae4e5dSmrg		  if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
63179c9ff80cSmrg		    | $EGREP "$match_pattern_regex" > /dev/null; then
63189c9ff80cSmrg		    valid_a_lib=yes
63199c9ff80cSmrg		  fi
63209c9ff80cSmrg		;;
63219c9ff80cSmrg		pass_all)
63229c9ff80cSmrg		  valid_a_lib=yes
63239c9ff80cSmrg		;;
63249c9ff80cSmrg	      esac
63259c9ff80cSmrg	      if test "$valid_a_lib" != yes; then
63266fae4e5dSmrg		echo
63279c9ff80cSmrg		$ECHO "*** Warning: Trying to link with static lib archive $deplib."
63286fae4e5dSmrg		echo "*** I have the capability to make that library automatically link in when"
63296fae4e5dSmrg		echo "*** you link to this library.  But I can only do this if you have a"
63306fae4e5dSmrg		echo "*** shared version of the library, which you do not appear to have"
63316fae4e5dSmrg		echo "*** because the file extensions .$libext of this argument makes me believe"
63326fae4e5dSmrg		echo "*** that it is just a static archive that I should not use here."
63339c9ff80cSmrg	      else
63346fae4e5dSmrg		echo
63359c9ff80cSmrg		$ECHO "*** Warning: Linking the shared library $output against the"
63369c9ff80cSmrg		$ECHO "*** static library $deplib is not portable!"
63379c9ff80cSmrg		deplibs="$deplib $deplibs"
63389c9ff80cSmrg	      fi
63399c9ff80cSmrg	      ;;
63409c9ff80cSmrg	    esac
63419c9ff80cSmrg	    continue
63429c9ff80cSmrg	    ;;
63439c9ff80cSmrg	  prog)
63449c9ff80cSmrg	    if test "$pass" != link; then
63459c9ff80cSmrg	      deplibs="$deplib $deplibs"
63469c9ff80cSmrg	    else
63479c9ff80cSmrg	      compile_deplibs="$deplib $compile_deplibs"
63489c9ff80cSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
63499c9ff80cSmrg	    fi
63509c9ff80cSmrg	    continue
63519c9ff80cSmrg	    ;;
63529c9ff80cSmrg	  esac # linkmode
63539c9ff80cSmrg	  ;; # *.$libext
63549c9ff80cSmrg	*.lo | *.$objext)
63559c9ff80cSmrg	  if test "$pass" = conv; then
63569c9ff80cSmrg	    deplibs="$deplib $deplibs"
63579c9ff80cSmrg	  elif test "$linkmode" = prog; then
63589c9ff80cSmrg	    if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
63599c9ff80cSmrg	      # If there is no dlopen support or we're linking statically,
63609c9ff80cSmrg	      # we need to preload.
63616fae4e5dSmrg	      func_append newdlprefiles " $deplib"
63629c9ff80cSmrg	      compile_deplibs="$deplib $compile_deplibs"
63639c9ff80cSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
63649c9ff80cSmrg	    else
63656fae4e5dSmrg	      func_append newdlfiles " $deplib"
63669c9ff80cSmrg	    fi
63679c9ff80cSmrg	  fi
63689c9ff80cSmrg	  continue
63699c9ff80cSmrg	  ;;
63709c9ff80cSmrg	%DEPLIBS%)
63719c9ff80cSmrg	  alldeplibs=yes
63729c9ff80cSmrg	  continue
63739c9ff80cSmrg	  ;;
63749c9ff80cSmrg	esac # case $deplib
63759c9ff80cSmrg
63769c9ff80cSmrg	if test "$found" = yes || test -f "$lib"; then :
63779c9ff80cSmrg	else
63789c9ff80cSmrg	  func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'"
63799c9ff80cSmrg	fi
63809c9ff80cSmrg
63819c9ff80cSmrg	# Check to see that this really is a libtool archive.
63829c9ff80cSmrg	func_lalib_unsafe_p "$lib" \
63839c9ff80cSmrg	  || func_fatal_error "\`$lib' is not a valid libtool archive"
63849c9ff80cSmrg
63859c9ff80cSmrg	func_dirname "$lib" "" "."
63869c9ff80cSmrg	ladir="$func_dirname_result"
63879c9ff80cSmrg
63889c9ff80cSmrg	dlname=
63899c9ff80cSmrg	dlopen=
63909c9ff80cSmrg	dlpreopen=
63919c9ff80cSmrg	libdir=
63929c9ff80cSmrg	library_names=
63939c9ff80cSmrg	old_library=
63949c9ff80cSmrg	inherited_linker_flags=
63959c9ff80cSmrg	# If the library was installed with an old release of libtool,
63969c9ff80cSmrg	# it will not redefine variables installed, or shouldnotlink
63979c9ff80cSmrg	installed=yes
63989c9ff80cSmrg	shouldnotlink=no
63999c9ff80cSmrg	avoidtemprpath=
64009c9ff80cSmrg
64019c9ff80cSmrg
64029c9ff80cSmrg	# Read the .la file
64039c9ff80cSmrg	func_source "$lib"
64049c9ff80cSmrg
64059c9ff80cSmrg	# Convert "-framework foo" to "foo.ltframework"
64069c9ff80cSmrg	if test -n "$inherited_linker_flags"; then
64076fae4e5dSmrg	  tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
64089c9ff80cSmrg	  for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
64099c9ff80cSmrg	    case " $new_inherited_linker_flags " in
64109c9ff80cSmrg	      *" $tmp_inherited_linker_flag "*) ;;
64116fae4e5dSmrg	      *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";;
64129c9ff80cSmrg	    esac
64139c9ff80cSmrg	  done
64149c9ff80cSmrg	fi
64156fae4e5dSmrg	dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
64169c9ff80cSmrg	if test "$linkmode,$pass" = "lib,link" ||
64179c9ff80cSmrg	   test "$linkmode,$pass" = "prog,scan" ||
64189c9ff80cSmrg	   { test "$linkmode" != prog && test "$linkmode" != lib; }; then
64196fae4e5dSmrg	  test -n "$dlopen" && func_append dlfiles " $dlopen"
64206fae4e5dSmrg	  test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen"
64219c9ff80cSmrg	fi
64229c9ff80cSmrg
64239c9ff80cSmrg	if test "$pass" = conv; then
64249c9ff80cSmrg	  # Only check for convenience libraries
64259c9ff80cSmrg	  deplibs="$lib $deplibs"
64269c9ff80cSmrg	  if test -z "$libdir"; then
64279c9ff80cSmrg	    if test -z "$old_library"; then
64289c9ff80cSmrg	      func_fatal_error "cannot find name of link library for \`$lib'"
64299c9ff80cSmrg	    fi
64309c9ff80cSmrg	    # It is a libtool convenience library, so add in its objects.
64316fae4e5dSmrg	    func_append convenience " $ladir/$objdir/$old_library"
64326fae4e5dSmrg	    func_append old_convenience " $ladir/$objdir/$old_library"
64339c9ff80cSmrg	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
64349c9ff80cSmrg	    func_fatal_error "\`$lib' is not a convenience library"
64359c9ff80cSmrg	  fi
64369c9ff80cSmrg	  tmp_libs=
64379c9ff80cSmrg	  for deplib in $dependency_libs; do
64389c9ff80cSmrg	    deplibs="$deplib $deplibs"
64396fae4e5dSmrg	    if $opt_preserve_dup_deps ; then
64409c9ff80cSmrg	      case "$tmp_libs " in
64416fae4e5dSmrg	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
64429c9ff80cSmrg	      esac
64439c9ff80cSmrg	    fi
64446fae4e5dSmrg	    func_append tmp_libs " $deplib"
64459c9ff80cSmrg	  done
64469c9ff80cSmrg	  continue
64479c9ff80cSmrg	fi # $pass = conv
64489c9ff80cSmrg
64499c9ff80cSmrg
64509c9ff80cSmrg	# Get the name of the library we link against.
64519c9ff80cSmrg	linklib=
64526fae4e5dSmrg	if test -n "$old_library" &&
64536fae4e5dSmrg	   { test "$prefer_static_libs" = yes ||
64546fae4e5dSmrg	     test "$prefer_static_libs,$installed" = "built,no"; }; then
64556fae4e5dSmrg	  linklib=$old_library
64566fae4e5dSmrg	else
64576fae4e5dSmrg	  for l in $old_library $library_names; do
64586fae4e5dSmrg	    linklib="$l"
64596fae4e5dSmrg	  done
64606fae4e5dSmrg	fi
64619c9ff80cSmrg	if test -z "$linklib"; then
64629c9ff80cSmrg	  func_fatal_error "cannot find name of link library for \`$lib'"
64639c9ff80cSmrg	fi
64649c9ff80cSmrg
64659c9ff80cSmrg	# This library was specified with -dlopen.
64669c9ff80cSmrg	if test "$pass" = dlopen; then
64679c9ff80cSmrg	  if test -z "$libdir"; then
64689c9ff80cSmrg	    func_fatal_error "cannot -dlopen a convenience library: \`$lib'"
64699c9ff80cSmrg	  fi
64709c9ff80cSmrg	  if test -z "$dlname" ||
64719c9ff80cSmrg	     test "$dlopen_support" != yes ||
64729c9ff80cSmrg	     test "$build_libtool_libs" = no; then
64739c9ff80cSmrg	    # If there is no dlname, no dlopen support or we're linking
64749c9ff80cSmrg	    # statically, we need to preload.  We also need to preload any
64759c9ff80cSmrg	    # dependent libraries so libltdl's deplib preloader doesn't
64769c9ff80cSmrg	    # bomb out in the load deplibs phase.
64776fae4e5dSmrg	    func_append dlprefiles " $lib $dependency_libs"
64789c9ff80cSmrg	  else
64796fae4e5dSmrg	    func_append newdlfiles " $lib"
64809c9ff80cSmrg	  fi
64819c9ff80cSmrg	  continue
64829c9ff80cSmrg	fi # $pass = dlopen
64839c9ff80cSmrg
64849c9ff80cSmrg	# We need an absolute path.
64859c9ff80cSmrg	case $ladir in
64869c9ff80cSmrg	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
64879c9ff80cSmrg	*)
64889c9ff80cSmrg	  abs_ladir=`cd "$ladir" && pwd`
64899c9ff80cSmrg	  if test -z "$abs_ladir"; then
64909c9ff80cSmrg	    func_warning "cannot determine absolute directory name of \`$ladir'"
64919c9ff80cSmrg	    func_warning "passing it literally to the linker, although it might fail"
64929c9ff80cSmrg	    abs_ladir="$ladir"
64939c9ff80cSmrg	  fi
64949c9ff80cSmrg	  ;;
64959c9ff80cSmrg	esac
64969c9ff80cSmrg	func_basename "$lib"
64979c9ff80cSmrg	laname="$func_basename_result"
64989c9ff80cSmrg
64999c9ff80cSmrg	# Find the relevant object directory and library name.
65009c9ff80cSmrg	if test "X$installed" = Xyes; then
65016fae4e5dSmrg	  if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
65029c9ff80cSmrg	    func_warning "library \`$lib' was moved."
65039c9ff80cSmrg	    dir="$ladir"
65049c9ff80cSmrg	    absdir="$abs_ladir"
65059c9ff80cSmrg	    libdir="$abs_ladir"
65069c9ff80cSmrg	  else
65076fae4e5dSmrg	    dir="$lt_sysroot$libdir"
65086fae4e5dSmrg	    absdir="$lt_sysroot$libdir"
65099c9ff80cSmrg	  fi
65109c9ff80cSmrg	  test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
65119c9ff80cSmrg	else
65129c9ff80cSmrg	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
65139c9ff80cSmrg	    dir="$ladir"
65149c9ff80cSmrg	    absdir="$abs_ladir"
65159c9ff80cSmrg	    # Remove this search path later
65166fae4e5dSmrg	    func_append notinst_path " $abs_ladir"
65179c9ff80cSmrg	  else
65189c9ff80cSmrg	    dir="$ladir/$objdir"
65199c9ff80cSmrg	    absdir="$abs_ladir/$objdir"
65209c9ff80cSmrg	    # Remove this search path later
65216fae4e5dSmrg	    func_append notinst_path " $abs_ladir"
65229c9ff80cSmrg	  fi
65239c9ff80cSmrg	fi # $installed = yes
65249c9ff80cSmrg	func_stripname 'lib' '.la' "$laname"
65259c9ff80cSmrg	name=$func_stripname_result
65269c9ff80cSmrg
65279c9ff80cSmrg	# This library was specified with -dlpreopen.
65289c9ff80cSmrg	if test "$pass" = dlpreopen; then
65299c9ff80cSmrg	  if test -z "$libdir" && test "$linkmode" = prog; then
65309c9ff80cSmrg	    func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'"
65319c9ff80cSmrg	  fi
65326fae4e5dSmrg	  case "$host" in
65336fae4e5dSmrg	    # special handling for platforms with PE-DLLs.
65346fae4e5dSmrg	    *cygwin* | *mingw* | *cegcc* )
65356fae4e5dSmrg	      # Linker will automatically link against shared library if both
65366fae4e5dSmrg	      # static and shared are present.  Therefore, ensure we extract
65376fae4e5dSmrg	      # symbols from the import library if a shared library is present
65386fae4e5dSmrg	      # (otherwise, the dlopen module name will be incorrect).  We do
65396fae4e5dSmrg	      # this by putting the import library name into $newdlprefiles.
65406fae4e5dSmrg	      # We recover the dlopen module name by 'saving' the la file
65416fae4e5dSmrg	      # name in a special purpose variable, and (later) extracting the
65426fae4e5dSmrg	      # dlname from the la file.
65436fae4e5dSmrg	      if test -n "$dlname"; then
65446fae4e5dSmrg	        func_tr_sh "$dir/$linklib"
65456fae4e5dSmrg	        eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname"
65466fae4e5dSmrg	        func_append newdlprefiles " $dir/$linklib"
65476fae4e5dSmrg	      else
65486fae4e5dSmrg	        func_append newdlprefiles " $dir/$old_library"
65496fae4e5dSmrg	        # Keep a list of preopened convenience libraries to check
65506fae4e5dSmrg	        # that they are being used correctly in the link pass.
65516fae4e5dSmrg	        test -z "$libdir" && \
65526fae4e5dSmrg	          func_append dlpreconveniencelibs " $dir/$old_library"
65536fae4e5dSmrg	      fi
65546fae4e5dSmrg	    ;;
65556fae4e5dSmrg	    * )
65566fae4e5dSmrg	      # Prefer using a static library (so that no silly _DYNAMIC symbols
65576fae4e5dSmrg	      # are required to link).
65586fae4e5dSmrg	      if test -n "$old_library"; then
65596fae4e5dSmrg	        func_append newdlprefiles " $dir/$old_library"
65606fae4e5dSmrg	        # Keep a list of preopened convenience libraries to check
65616fae4e5dSmrg	        # that they are being used correctly in the link pass.
65626fae4e5dSmrg	        test -z "$libdir" && \
65636fae4e5dSmrg	          func_append dlpreconveniencelibs " $dir/$old_library"
65646fae4e5dSmrg	      # Otherwise, use the dlname, so that lt_dlopen finds it.
65656fae4e5dSmrg	      elif test -n "$dlname"; then
65666fae4e5dSmrg	        func_append newdlprefiles " $dir/$dlname"
65676fae4e5dSmrg	      else
65686fae4e5dSmrg	        func_append newdlprefiles " $dir/$linklib"
65696fae4e5dSmrg	      fi
65706fae4e5dSmrg	    ;;
65716fae4e5dSmrg	  esac
65729c9ff80cSmrg	fi # $pass = dlpreopen
65739c9ff80cSmrg
65749c9ff80cSmrg	if test -z "$libdir"; then
65759c9ff80cSmrg	  # Link the convenience library
65769c9ff80cSmrg	  if test "$linkmode" = lib; then
65779c9ff80cSmrg	    deplibs="$dir/$old_library $deplibs"
65789c9ff80cSmrg	  elif test "$linkmode,$pass" = "prog,link"; then
65799c9ff80cSmrg	    compile_deplibs="$dir/$old_library $compile_deplibs"
65809c9ff80cSmrg	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
65819c9ff80cSmrg	  else
65829c9ff80cSmrg	    deplibs="$lib $deplibs" # used for prog,scan pass
65839c9ff80cSmrg	  fi
65849c9ff80cSmrg	  continue
65859c9ff80cSmrg	fi
65869c9ff80cSmrg
65879c9ff80cSmrg
65889c9ff80cSmrg	if test "$linkmode" = prog && test "$pass" != link; then
65896fae4e5dSmrg	  func_append newlib_search_path " $ladir"
65909c9ff80cSmrg	  deplibs="$lib $deplibs"
65919c9ff80cSmrg
65929c9ff80cSmrg	  linkalldeplibs=no
65939c9ff80cSmrg	  if test "$link_all_deplibs" != no || test -z "$library_names" ||
65949c9ff80cSmrg	     test "$build_libtool_libs" = no; then
65959c9ff80cSmrg	    linkalldeplibs=yes
65969c9ff80cSmrg	  fi
65979c9ff80cSmrg
65989c9ff80cSmrg	  tmp_libs=
65999c9ff80cSmrg	  for deplib in $dependency_libs; do
66009c9ff80cSmrg	    case $deplib in
66019c9ff80cSmrg	    -L*) func_stripname '-L' '' "$deplib"
66026fae4e5dSmrg	         func_resolve_sysroot "$func_stripname_result"
66036fae4e5dSmrg	         func_append newlib_search_path " $func_resolve_sysroot_result"
66049c9ff80cSmrg		 ;;
66059c9ff80cSmrg	    esac
66069c9ff80cSmrg	    # Need to link against all dependency_libs?
66079c9ff80cSmrg	    if test "$linkalldeplibs" = yes; then
66089c9ff80cSmrg	      deplibs="$deplib $deplibs"
66099c9ff80cSmrg	    else
66109c9ff80cSmrg	      # Need to hardcode shared library paths
66119c9ff80cSmrg	      # or/and link against static libraries
66129c9ff80cSmrg	      newdependency_libs="$deplib $newdependency_libs"
66139c9ff80cSmrg	    fi
66146fae4e5dSmrg	    if $opt_preserve_dup_deps ; then
66159c9ff80cSmrg	      case "$tmp_libs " in
66166fae4e5dSmrg	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
66179c9ff80cSmrg	      esac
66189c9ff80cSmrg	    fi
66196fae4e5dSmrg	    func_append tmp_libs " $deplib"
66209c9ff80cSmrg	  done # for deplib
66219c9ff80cSmrg	  continue
66229c9ff80cSmrg	fi # $linkmode = prog...
66239c9ff80cSmrg
66249c9ff80cSmrg	if test "$linkmode,$pass" = "prog,link"; then
66259c9ff80cSmrg	  if test -n "$library_names" &&
66269c9ff80cSmrg	     { { test "$prefer_static_libs" = no ||
66279c9ff80cSmrg	         test "$prefer_static_libs,$installed" = "built,yes"; } ||
66289c9ff80cSmrg	       test -z "$old_library"; }; then
66299c9ff80cSmrg	    # We need to hardcode the library path
66309c9ff80cSmrg	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
66319c9ff80cSmrg	      # Make sure the rpath contains only unique directories.
66329c9ff80cSmrg	      case "$temp_rpath:" in
66339c9ff80cSmrg	      *"$absdir:"*) ;;
66346fae4e5dSmrg	      *) func_append temp_rpath "$absdir:" ;;
66359c9ff80cSmrg	      esac
66369c9ff80cSmrg	    fi
66379c9ff80cSmrg
66389c9ff80cSmrg	    # Hardcode the library path.
66399c9ff80cSmrg	    # Skip directories that are in the system default run-time
66409c9ff80cSmrg	    # search path.
66419c9ff80cSmrg	    case " $sys_lib_dlsearch_path " in
66429c9ff80cSmrg	    *" $absdir "*) ;;
66439c9ff80cSmrg	    *)
66449c9ff80cSmrg	      case "$compile_rpath " in
66459c9ff80cSmrg	      *" $absdir "*) ;;
66466fae4e5dSmrg	      *) func_append compile_rpath " $absdir" ;;
66479c9ff80cSmrg	      esac
66489c9ff80cSmrg	      ;;
66499c9ff80cSmrg	    esac
66509c9ff80cSmrg	    case " $sys_lib_dlsearch_path " in
66519c9ff80cSmrg	    *" $libdir "*) ;;
66529c9ff80cSmrg	    *)
66539c9ff80cSmrg	      case "$finalize_rpath " in
66549c9ff80cSmrg	      *" $libdir "*) ;;
66556fae4e5dSmrg	      *) func_append finalize_rpath " $libdir" ;;
66569c9ff80cSmrg	      esac
66579c9ff80cSmrg	      ;;
66589c9ff80cSmrg	    esac
66599c9ff80cSmrg	  fi # $linkmode,$pass = prog,link...
66609c9ff80cSmrg
66619c9ff80cSmrg	  if test "$alldeplibs" = yes &&
66629c9ff80cSmrg	     { test "$deplibs_check_method" = pass_all ||
66639c9ff80cSmrg	       { test "$build_libtool_libs" = yes &&
66649c9ff80cSmrg		 test -n "$library_names"; }; }; then
66659c9ff80cSmrg	    # We only need to search for static libraries
66669c9ff80cSmrg	    continue
66679c9ff80cSmrg	  fi
66689c9ff80cSmrg	fi
66699c9ff80cSmrg
66709c9ff80cSmrg	link_static=no # Whether the deplib will be linked statically
66719c9ff80cSmrg	use_static_libs=$prefer_static_libs
66729c9ff80cSmrg	if test "$use_static_libs" = built && test "$installed" = yes; then
66739c9ff80cSmrg	  use_static_libs=no
66749c9ff80cSmrg	fi
66759c9ff80cSmrg	if test -n "$library_names" &&
66769c9ff80cSmrg	   { test "$use_static_libs" = no || test -z "$old_library"; }; then
66779c9ff80cSmrg	  case $host in
66789c9ff80cSmrg	  *cygwin* | *mingw* | *cegcc*)
66799c9ff80cSmrg	      # No point in relinking DLLs because paths are not encoded
66806fae4e5dSmrg	      func_append notinst_deplibs " $lib"
66819c9ff80cSmrg	      need_relink=no
66829c9ff80cSmrg	    ;;
66839c9ff80cSmrg	  *)
66849c9ff80cSmrg	    if test "$installed" = no; then
66856fae4e5dSmrg	      func_append notinst_deplibs " $lib"
66869c9ff80cSmrg	      need_relink=yes
66879c9ff80cSmrg	    fi
66889c9ff80cSmrg	    ;;
66899c9ff80cSmrg	  esac
66909c9ff80cSmrg	  # This is a shared library
66919c9ff80cSmrg
66929c9ff80cSmrg	  # Warn about portability, can't link against -module's on some
66939c9ff80cSmrg	  # systems (darwin).  Don't bleat about dlopened modules though!
66949c9ff80cSmrg	  dlopenmodule=""
66959c9ff80cSmrg	  for dlpremoduletest in $dlprefiles; do
66969c9ff80cSmrg	    if test "X$dlpremoduletest" = "X$lib"; then
66979c9ff80cSmrg	      dlopenmodule="$dlpremoduletest"
66989c9ff80cSmrg	      break
66999c9ff80cSmrg	    fi
67009c9ff80cSmrg	  done
67019c9ff80cSmrg	  if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then
67026fae4e5dSmrg	    echo
67039c9ff80cSmrg	    if test "$linkmode" = prog; then
67049c9ff80cSmrg	      $ECHO "*** Warning: Linking the executable $output against the loadable module"
67059c9ff80cSmrg	    else
67069c9ff80cSmrg	      $ECHO "*** Warning: Linking the shared library $output against the loadable module"
67079c9ff80cSmrg	    fi
67089c9ff80cSmrg	    $ECHO "*** $linklib is not portable!"
67099c9ff80cSmrg	  fi
67109c9ff80cSmrg	  if test "$linkmode" = lib &&
67119c9ff80cSmrg	     test "$hardcode_into_libs" = yes; then
67129c9ff80cSmrg	    # Hardcode the library path.
67139c9ff80cSmrg	    # Skip directories that are in the system default run-time
67149c9ff80cSmrg	    # search path.
67159c9ff80cSmrg	    case " $sys_lib_dlsearch_path " in
67169c9ff80cSmrg	    *" $absdir "*) ;;
67179c9ff80cSmrg	    *)
67189c9ff80cSmrg	      case "$compile_rpath " in
67199c9ff80cSmrg	      *" $absdir "*) ;;
67206fae4e5dSmrg	      *) func_append compile_rpath " $absdir" ;;
67219c9ff80cSmrg	      esac
67229c9ff80cSmrg	      ;;
67239c9ff80cSmrg	    esac
67249c9ff80cSmrg	    case " $sys_lib_dlsearch_path " in
67259c9ff80cSmrg	    *" $libdir "*) ;;
67269c9ff80cSmrg	    *)
67279c9ff80cSmrg	      case "$finalize_rpath " in
67289c9ff80cSmrg	      *" $libdir "*) ;;
67296fae4e5dSmrg	      *) func_append finalize_rpath " $libdir" ;;
67309c9ff80cSmrg	      esac
67319c9ff80cSmrg	      ;;
67329c9ff80cSmrg	    esac
67339c9ff80cSmrg	  fi
67349c9ff80cSmrg
67359c9ff80cSmrg	  if test -n "$old_archive_from_expsyms_cmds"; then
67369c9ff80cSmrg	    # figure out the soname
67379c9ff80cSmrg	    set dummy $library_names
67389c9ff80cSmrg	    shift
67399c9ff80cSmrg	    realname="$1"
67409c9ff80cSmrg	    shift
67419c9ff80cSmrg	    libname=`eval "\\$ECHO \"$libname_spec\""`
67429c9ff80cSmrg	    # use dlname if we got it. it's perfectly good, no?
67439c9ff80cSmrg	    if test -n "$dlname"; then
67449c9ff80cSmrg	      soname="$dlname"
67459c9ff80cSmrg	    elif test -n "$soname_spec"; then
67469c9ff80cSmrg	      # bleh windows
67479c9ff80cSmrg	      case $host in
67489c9ff80cSmrg	      *cygwin* | mingw* | *cegcc*)
67499c9ff80cSmrg	        func_arith $current - $age
67509c9ff80cSmrg		major=$func_arith_result
67519c9ff80cSmrg		versuffix="-$major"
67529c9ff80cSmrg		;;
67539c9ff80cSmrg	      esac
67549c9ff80cSmrg	      eval soname=\"$soname_spec\"
67559c9ff80cSmrg	    else
67569c9ff80cSmrg	      soname="$realname"
67579c9ff80cSmrg	    fi
67589c9ff80cSmrg
67599c9ff80cSmrg	    # Make a new name for the extract_expsyms_cmds to use
67609c9ff80cSmrg	    soroot="$soname"
67619c9ff80cSmrg	    func_basename "$soroot"
67629c9ff80cSmrg	    soname="$func_basename_result"
67639c9ff80cSmrg	    func_stripname 'lib' '.dll' "$soname"
67649c9ff80cSmrg	    newlib=libimp-$func_stripname_result.a
67659c9ff80cSmrg
67669c9ff80cSmrg	    # If the library has no export list, then create one now
67679c9ff80cSmrg	    if test -f "$output_objdir/$soname-def"; then :
67689c9ff80cSmrg	    else
67699c9ff80cSmrg	      func_verbose "extracting exported symbol list from \`$soname'"
67709c9ff80cSmrg	      func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
67719c9ff80cSmrg	    fi
67729c9ff80cSmrg
67739c9ff80cSmrg	    # Create $newlib
67749c9ff80cSmrg	    if test -f "$output_objdir/$newlib"; then :; else
67759c9ff80cSmrg	      func_verbose "generating import library for \`$soname'"
67769c9ff80cSmrg	      func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
67779c9ff80cSmrg	    fi
67789c9ff80cSmrg	    # make sure the library variables are pointing to the new library
67799c9ff80cSmrg	    dir=$output_objdir
67809c9ff80cSmrg	    linklib=$newlib
67819c9ff80cSmrg	  fi # test -n "$old_archive_from_expsyms_cmds"
67829c9ff80cSmrg
67836fae4e5dSmrg	  if test "$linkmode" = prog || test "$opt_mode" != relink; then
67849c9ff80cSmrg	    add_shlibpath=
67859c9ff80cSmrg	    add_dir=
67869c9ff80cSmrg	    add=
67879c9ff80cSmrg	    lib_linked=yes
67889c9ff80cSmrg	    case $hardcode_action in
67899c9ff80cSmrg	    immediate | unsupported)
67909c9ff80cSmrg	      if test "$hardcode_direct" = no; then
67919c9ff80cSmrg		add="$dir/$linklib"
67929c9ff80cSmrg		case $host in
67939c9ff80cSmrg		  *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
67949c9ff80cSmrg		  *-*-sysv4*uw2*) add_dir="-L$dir" ;;
67959c9ff80cSmrg		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
67969c9ff80cSmrg		    *-*-unixware7*) add_dir="-L$dir" ;;
67979c9ff80cSmrg		  *-*-darwin* )
67989c9ff80cSmrg		    # if the lib is a (non-dlopened) module then we can not
67999c9ff80cSmrg		    # link against it, someone is ignoring the earlier warnings
68009c9ff80cSmrg		    if /usr/bin/file -L $add 2> /dev/null |
68019c9ff80cSmrg			 $GREP ": [^:]* bundle" >/dev/null ; then
68029c9ff80cSmrg		      if test "X$dlopenmodule" != "X$lib"; then
68039c9ff80cSmrg			$ECHO "*** Warning: lib $linklib is a module, not a shared library"
68049c9ff80cSmrg			if test -z "$old_library" ; then
68056fae4e5dSmrg			  echo
68066fae4e5dSmrg			  echo "*** And there doesn't seem to be a static archive available"
68076fae4e5dSmrg			  echo "*** The link will probably fail, sorry"
68089c9ff80cSmrg			else
68099c9ff80cSmrg			  add="$dir/$old_library"
68109c9ff80cSmrg			fi
68119c9ff80cSmrg		      elif test -n "$old_library"; then
68129c9ff80cSmrg			add="$dir/$old_library"
68139c9ff80cSmrg		      fi
68149c9ff80cSmrg		    fi
68159c9ff80cSmrg		esac
68169c9ff80cSmrg	      elif test "$hardcode_minus_L" = no; then
68179c9ff80cSmrg		case $host in
68189c9ff80cSmrg		*-*-sunos*) add_shlibpath="$dir" ;;
68199c9ff80cSmrg		esac
68209c9ff80cSmrg		add_dir="-L$dir"
68219c9ff80cSmrg		add="-l$name"
68229c9ff80cSmrg	      elif test "$hardcode_shlibpath_var" = no; then
68239c9ff80cSmrg		add_shlibpath="$dir"
68249c9ff80cSmrg		add="-l$name"
68259c9ff80cSmrg	      else
68269c9ff80cSmrg		lib_linked=no
68279c9ff80cSmrg	      fi
68289c9ff80cSmrg	      ;;
68299c9ff80cSmrg	    relink)
68309c9ff80cSmrg	      if test "$hardcode_direct" = yes &&
68319c9ff80cSmrg	         test "$hardcode_direct_absolute" = no; then
68329c9ff80cSmrg		add="$dir/$linklib"
68339c9ff80cSmrg	      elif test "$hardcode_minus_L" = yes; then
68349c9ff80cSmrg		add_dir="-L$dir"
68359c9ff80cSmrg		# Try looking first in the location we're being installed to.
68369c9ff80cSmrg		if test -n "$inst_prefix_dir"; then
68379c9ff80cSmrg		  case $libdir in
68389c9ff80cSmrg		    [\\/]*)
68396fae4e5dSmrg		      func_append add_dir " -L$inst_prefix_dir$libdir"
68409c9ff80cSmrg		      ;;
68419c9ff80cSmrg		  esac
68429c9ff80cSmrg		fi
68439c9ff80cSmrg		add="-l$name"
68449c9ff80cSmrg	      elif test "$hardcode_shlibpath_var" = yes; then
68459c9ff80cSmrg		add_shlibpath="$dir"
68469c9ff80cSmrg		add="-l$name"
68479c9ff80cSmrg	      else
68489c9ff80cSmrg		lib_linked=no
68499c9ff80cSmrg	      fi
68509c9ff80cSmrg	      ;;
68519c9ff80cSmrg	    *) lib_linked=no ;;
68529c9ff80cSmrg	    esac
68539c9ff80cSmrg
68549c9ff80cSmrg	    if test "$lib_linked" != yes; then
68559c9ff80cSmrg	      func_fatal_configuration "unsupported hardcode properties"
68569c9ff80cSmrg	    fi
68579c9ff80cSmrg
68589c9ff80cSmrg	    if test -n "$add_shlibpath"; then
68599c9ff80cSmrg	      case :$compile_shlibpath: in
68609c9ff80cSmrg	      *":$add_shlibpath:"*) ;;
68616fae4e5dSmrg	      *) func_append compile_shlibpath "$add_shlibpath:" ;;
68629c9ff80cSmrg	      esac
68639c9ff80cSmrg	    fi
68649c9ff80cSmrg	    if test "$linkmode" = prog; then
68659c9ff80cSmrg	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
68669c9ff80cSmrg	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
68679c9ff80cSmrg	    else
68689c9ff80cSmrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
68699c9ff80cSmrg	      test -n "$add" && deplibs="$add $deplibs"
68709c9ff80cSmrg	      if test "$hardcode_direct" != yes &&
68719c9ff80cSmrg		 test "$hardcode_minus_L" != yes &&
68729c9ff80cSmrg		 test "$hardcode_shlibpath_var" = yes; then
68739c9ff80cSmrg		case :$finalize_shlibpath: in
68749c9ff80cSmrg		*":$libdir:"*) ;;
68756fae4e5dSmrg		*) func_append finalize_shlibpath "$libdir:" ;;
68769c9ff80cSmrg		esac
68779c9ff80cSmrg	      fi
68789c9ff80cSmrg	    fi
68799c9ff80cSmrg	  fi
68809c9ff80cSmrg
68816fae4e5dSmrg	  if test "$linkmode" = prog || test "$opt_mode" = relink; then
68829c9ff80cSmrg	    add_shlibpath=
68839c9ff80cSmrg	    add_dir=
68849c9ff80cSmrg	    add=
68859c9ff80cSmrg	    # Finalize command for both is simple: just hardcode it.
68869c9ff80cSmrg	    if test "$hardcode_direct" = yes &&
68879c9ff80cSmrg	       test "$hardcode_direct_absolute" = no; then
68889c9ff80cSmrg	      add="$libdir/$linklib"
68899c9ff80cSmrg	    elif test "$hardcode_minus_L" = yes; then
68909c9ff80cSmrg	      add_dir="-L$libdir"
68919c9ff80cSmrg	      add="-l$name"
68929c9ff80cSmrg	    elif test "$hardcode_shlibpath_var" = yes; then
68939c9ff80cSmrg	      case :$finalize_shlibpath: in
68949c9ff80cSmrg	      *":$libdir:"*) ;;
68956fae4e5dSmrg	      *) func_append finalize_shlibpath "$libdir:" ;;
68969c9ff80cSmrg	      esac
68979c9ff80cSmrg	      add="-l$name"
68989c9ff80cSmrg	    elif test "$hardcode_automatic" = yes; then
68999c9ff80cSmrg	      if test -n "$inst_prefix_dir" &&
69009c9ff80cSmrg		 test -f "$inst_prefix_dir$libdir/$linklib" ; then
69019c9ff80cSmrg		add="$inst_prefix_dir$libdir/$linklib"
69029c9ff80cSmrg	      else
69039c9ff80cSmrg		add="$libdir/$linklib"
69049c9ff80cSmrg	      fi
69059c9ff80cSmrg	    else
69069c9ff80cSmrg	      # We cannot seem to hardcode it, guess we'll fake it.
69079c9ff80cSmrg	      add_dir="-L$libdir"
69089c9ff80cSmrg	      # Try looking first in the location we're being installed to.
69099c9ff80cSmrg	      if test -n "$inst_prefix_dir"; then
69109c9ff80cSmrg		case $libdir in
69119c9ff80cSmrg		  [\\/]*)
69126fae4e5dSmrg		    func_append add_dir " -L$inst_prefix_dir$libdir"
69139c9ff80cSmrg		    ;;
69149c9ff80cSmrg		esac
69159c9ff80cSmrg	      fi
69169c9ff80cSmrg	      add="-l$name"
69179c9ff80cSmrg	    fi
69189c9ff80cSmrg
69199c9ff80cSmrg	    if test "$linkmode" = prog; then
69209c9ff80cSmrg	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
69219c9ff80cSmrg	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
69229c9ff80cSmrg	    else
69239c9ff80cSmrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
69249c9ff80cSmrg	      test -n "$add" && deplibs="$add $deplibs"
69259c9ff80cSmrg	    fi
69269c9ff80cSmrg	  fi
69279c9ff80cSmrg	elif test "$linkmode" = prog; then
69289c9ff80cSmrg	  # Here we assume that one of hardcode_direct or hardcode_minus_L
69299c9ff80cSmrg	  # is not unsupported.  This is valid on all known static and
69309c9ff80cSmrg	  # shared platforms.
69319c9ff80cSmrg	  if test "$hardcode_direct" != unsupported; then
69329c9ff80cSmrg	    test -n "$old_library" && linklib="$old_library"
69339c9ff80cSmrg	    compile_deplibs="$dir/$linklib $compile_deplibs"
69349c9ff80cSmrg	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
69359c9ff80cSmrg	  else
69369c9ff80cSmrg	    compile_deplibs="-l$name -L$dir $compile_deplibs"
69379c9ff80cSmrg	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
69389c9ff80cSmrg	  fi
69399c9ff80cSmrg	elif test "$build_libtool_libs" = yes; then
69409c9ff80cSmrg	  # Not a shared library
69419c9ff80cSmrg	  if test "$deplibs_check_method" != pass_all; then
69429c9ff80cSmrg	    # We're trying link a shared library against a static one
69439c9ff80cSmrg	    # but the system doesn't support it.
69449c9ff80cSmrg
69459c9ff80cSmrg	    # Just print a warning and add the library to dependency_libs so
69469c9ff80cSmrg	    # that the program can be linked against the static library.
69476fae4e5dSmrg	    echo
69489c9ff80cSmrg	    $ECHO "*** Warning: This system can not link to static lib archive $lib."
69496fae4e5dSmrg	    echo "*** I have the capability to make that library automatically link in when"
69506fae4e5dSmrg	    echo "*** you link to this library.  But I can only do this if you have a"
69516fae4e5dSmrg	    echo "*** shared version of the library, which you do not appear to have."
69529c9ff80cSmrg	    if test "$module" = yes; then
69536fae4e5dSmrg	      echo "*** But as you try to build a module library, libtool will still create "
69546fae4e5dSmrg	      echo "*** a static module, that should work as long as the dlopening application"
69556fae4e5dSmrg	      echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
69569c9ff80cSmrg	      if test -z "$global_symbol_pipe"; then
69576fae4e5dSmrg		echo
69586fae4e5dSmrg		echo "*** However, this would only work if libtool was able to extract symbol"
69596fae4e5dSmrg		echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
69606fae4e5dSmrg		echo "*** not find such a program.  So, this module is probably useless."
69616fae4e5dSmrg		echo "*** \`nm' from GNU binutils and a full rebuild may help."
69629c9ff80cSmrg	      fi
69639c9ff80cSmrg	      if test "$build_old_libs" = no; then
69649c9ff80cSmrg		build_libtool_libs=module
69659c9ff80cSmrg		build_old_libs=yes
69669c9ff80cSmrg	      else
69679c9ff80cSmrg		build_libtool_libs=no
69689c9ff80cSmrg	      fi
69699c9ff80cSmrg	    fi
69709c9ff80cSmrg	  else
69719c9ff80cSmrg	    deplibs="$dir/$old_library $deplibs"
69729c9ff80cSmrg	    link_static=yes
69739c9ff80cSmrg	  fi
69749c9ff80cSmrg	fi # link shared/static library?
69759c9ff80cSmrg
69769c9ff80cSmrg	if test "$linkmode" = lib; then
69779c9ff80cSmrg	  if test -n "$dependency_libs" &&
69789c9ff80cSmrg	     { test "$hardcode_into_libs" != yes ||
69799c9ff80cSmrg	       test "$build_old_libs" = yes ||
69809c9ff80cSmrg	       test "$link_static" = yes; }; then
69819c9ff80cSmrg	    # Extract -R from dependency_libs
69829c9ff80cSmrg	    temp_deplibs=
69839c9ff80cSmrg	    for libdir in $dependency_libs; do
69849c9ff80cSmrg	      case $libdir in
69859c9ff80cSmrg	      -R*) func_stripname '-R' '' "$libdir"
69869c9ff80cSmrg	           temp_xrpath=$func_stripname_result
69879c9ff80cSmrg		   case " $xrpath " in
69889c9ff80cSmrg		   *" $temp_xrpath "*) ;;
69896fae4e5dSmrg		   *) func_append xrpath " $temp_xrpath";;
69909c9ff80cSmrg		   esac;;
69916fae4e5dSmrg	      *) func_append temp_deplibs " $libdir";;
69929c9ff80cSmrg	      esac
69939c9ff80cSmrg	    done
69949c9ff80cSmrg	    dependency_libs="$temp_deplibs"
69959c9ff80cSmrg	  fi
69969c9ff80cSmrg
69976fae4e5dSmrg	  func_append newlib_search_path " $absdir"
69989c9ff80cSmrg	  # Link against this library
69999c9ff80cSmrg	  test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
70009c9ff80cSmrg	  # ... and its dependency_libs
70019c9ff80cSmrg	  tmp_libs=
70029c9ff80cSmrg	  for deplib in $dependency_libs; do
70039c9ff80cSmrg	    newdependency_libs="$deplib $newdependency_libs"
70046fae4e5dSmrg	    case $deplib in
70056fae4e5dSmrg              -L*) func_stripname '-L' '' "$deplib"
70066fae4e5dSmrg                   func_resolve_sysroot "$func_stripname_result";;
70076fae4e5dSmrg              *) func_resolve_sysroot "$deplib" ;;
70086fae4e5dSmrg            esac
70096fae4e5dSmrg	    if $opt_preserve_dup_deps ; then
70109c9ff80cSmrg	      case "$tmp_libs " in
70116fae4e5dSmrg	      *" $func_resolve_sysroot_result "*)
70126fae4e5dSmrg                func_append specialdeplibs " $func_resolve_sysroot_result" ;;
70139c9ff80cSmrg	      esac
70149c9ff80cSmrg	    fi
70156fae4e5dSmrg	    func_append tmp_libs " $func_resolve_sysroot_result"
70169c9ff80cSmrg	  done
70179c9ff80cSmrg
70189c9ff80cSmrg	  if test "$link_all_deplibs" != no; then
70199c9ff80cSmrg	    # Add the search paths of all dependency libraries
70209c9ff80cSmrg	    for deplib in $dependency_libs; do
70216fae4e5dSmrg	      path=
70229c9ff80cSmrg	      case $deplib in
70239c9ff80cSmrg	      -L*) path="$deplib" ;;
70249c9ff80cSmrg	      *.la)
70256fae4e5dSmrg	        func_resolve_sysroot "$deplib"
70266fae4e5dSmrg	        deplib=$func_resolve_sysroot_result
70279c9ff80cSmrg	        func_dirname "$deplib" "" "."
70286fae4e5dSmrg		dir=$func_dirname_result
70299c9ff80cSmrg		# We need an absolute path.
70309c9ff80cSmrg		case $dir in
70319c9ff80cSmrg		[\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
70329c9ff80cSmrg		*)
70339c9ff80cSmrg		  absdir=`cd "$dir" && pwd`
70349c9ff80cSmrg		  if test -z "$absdir"; then
70359c9ff80cSmrg		    func_warning "cannot determine absolute directory name of \`$dir'"
70369c9ff80cSmrg		    absdir="$dir"
70379c9ff80cSmrg		  fi
70389c9ff80cSmrg		  ;;
70399c9ff80cSmrg		esac
70409c9ff80cSmrg		if $GREP "^installed=no" $deplib > /dev/null; then
70419c9ff80cSmrg		case $host in
70429c9ff80cSmrg		*-*-darwin*)
70439c9ff80cSmrg		  depdepl=
70449c9ff80cSmrg		  eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
70459c9ff80cSmrg		  if test -n "$deplibrary_names" ; then
70469c9ff80cSmrg		    for tmp in $deplibrary_names ; do
70479c9ff80cSmrg		      depdepl=$tmp
70489c9ff80cSmrg		    done
70499c9ff80cSmrg		    if test -f "$absdir/$objdir/$depdepl" ; then
70509c9ff80cSmrg		      depdepl="$absdir/$objdir/$depdepl"
70519c9ff80cSmrg		      darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
70529c9ff80cSmrg                      if test -z "$darwin_install_name"; then
70539c9ff80cSmrg                          darwin_install_name=`${OTOOL64} -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
70549c9ff80cSmrg                      fi
70556fae4e5dSmrg		      func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}"
70566fae4e5dSmrg		      func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}"
70579c9ff80cSmrg		      path=
70589c9ff80cSmrg		    fi
70599c9ff80cSmrg		  fi
70609c9ff80cSmrg		  ;;
70619c9ff80cSmrg		*)
70629c9ff80cSmrg		  path="-L$absdir/$objdir"
70639c9ff80cSmrg		  ;;
70649c9ff80cSmrg		esac
70659c9ff80cSmrg		else
70669c9ff80cSmrg		  eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
70679c9ff80cSmrg		  test -z "$libdir" && \
70689c9ff80cSmrg		    func_fatal_error "\`$deplib' is not a valid libtool archive"
70699c9ff80cSmrg		  test "$absdir" != "$libdir" && \
70709c9ff80cSmrg		    func_warning "\`$deplib' seems to be moved"
70719c9ff80cSmrg
70729c9ff80cSmrg		  path="-L$absdir"
70739c9ff80cSmrg		fi
70749c9ff80cSmrg		;;
70759c9ff80cSmrg	      esac
70769c9ff80cSmrg	      case " $deplibs " in
70779c9ff80cSmrg	      *" $path "*) ;;
70789c9ff80cSmrg	      *) deplibs="$path $deplibs" ;;
70799c9ff80cSmrg	      esac
70809c9ff80cSmrg	    done
70819c9ff80cSmrg	  fi # link_all_deplibs != no
70829c9ff80cSmrg	fi # linkmode = lib
70839c9ff80cSmrg      done # for deplib in $libs
70849c9ff80cSmrg      if test "$pass" = link; then
70859c9ff80cSmrg	if test "$linkmode" = "prog"; then
70869c9ff80cSmrg	  compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
70879c9ff80cSmrg	  finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
70889c9ff80cSmrg	else
70896fae4e5dSmrg	  compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
70909c9ff80cSmrg	fi
70919c9ff80cSmrg      fi
70929c9ff80cSmrg      dependency_libs="$newdependency_libs"
70939c9ff80cSmrg      if test "$pass" = dlpreopen; then
70949c9ff80cSmrg	# Link the dlpreopened libraries before other libraries
70959c9ff80cSmrg	for deplib in $save_deplibs; do
70969c9ff80cSmrg	  deplibs="$deplib $deplibs"
70979c9ff80cSmrg	done
70989c9ff80cSmrg      fi
70999c9ff80cSmrg      if test "$pass" != dlopen; then
71009c9ff80cSmrg	if test "$pass" != conv; then
71019c9ff80cSmrg	  # Make sure lib_search_path contains only unique directories.
71029c9ff80cSmrg	  lib_search_path=
71039c9ff80cSmrg	  for dir in $newlib_search_path; do
71049c9ff80cSmrg	    case "$lib_search_path " in
71059c9ff80cSmrg	    *" $dir "*) ;;
71066fae4e5dSmrg	    *) func_append lib_search_path " $dir" ;;
71079c9ff80cSmrg	    esac
71089c9ff80cSmrg	  done
71099c9ff80cSmrg	  newlib_search_path=
71109c9ff80cSmrg	fi
71119c9ff80cSmrg
71129c9ff80cSmrg	if test "$linkmode,$pass" != "prog,link"; then
71139c9ff80cSmrg	  vars="deplibs"
71149c9ff80cSmrg	else
71159c9ff80cSmrg	  vars="compile_deplibs finalize_deplibs"
71169c9ff80cSmrg	fi
71179c9ff80cSmrg	for var in $vars dependency_libs; do
71189c9ff80cSmrg	  # Add libraries to $var in reverse order
71199c9ff80cSmrg	  eval tmp_libs=\"\$$var\"
71209c9ff80cSmrg	  new_libs=
71219c9ff80cSmrg	  for deplib in $tmp_libs; do
71229c9ff80cSmrg	    # FIXME: Pedantically, this is the right thing to do, so
71239c9ff80cSmrg	    #        that some nasty dependency loop isn't accidentally
71249c9ff80cSmrg	    #        broken:
71259c9ff80cSmrg	    #new_libs="$deplib $new_libs"
71269c9ff80cSmrg	    # Pragmatically, this seems to cause very few problems in
71279c9ff80cSmrg	    # practice:
71289c9ff80cSmrg	    case $deplib in
71299c9ff80cSmrg	    -L*) new_libs="$deplib $new_libs" ;;
71309c9ff80cSmrg	    -R*) ;;
71319c9ff80cSmrg	    *)
71329c9ff80cSmrg	      # And here is the reason: when a library appears more
71339c9ff80cSmrg	      # than once as an explicit dependence of a library, or
71349c9ff80cSmrg	      # is implicitly linked in more than once by the
71359c9ff80cSmrg	      # compiler, it is considered special, and multiple
71369c9ff80cSmrg	      # occurrences thereof are not removed.  Compare this
71379c9ff80cSmrg	      # with having the same library being listed as a
71389c9ff80cSmrg	      # dependency of multiple other libraries: in this case,
71399c9ff80cSmrg	      # we know (pedantically, we assume) the library does not
71409c9ff80cSmrg	      # need to be listed more than once, so we keep only the
71419c9ff80cSmrg	      # last copy.  This is not always right, but it is rare
71429c9ff80cSmrg	      # enough that we require users that really mean to play
71439c9ff80cSmrg	      # such unportable linking tricks to link the library
71449c9ff80cSmrg	      # using -Wl,-lname, so that libtool does not consider it
71459c9ff80cSmrg	      # for duplicate removal.
71469c9ff80cSmrg	      case " $specialdeplibs " in
71479c9ff80cSmrg	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
71489c9ff80cSmrg	      *)
71499c9ff80cSmrg		case " $new_libs " in
71509c9ff80cSmrg		*" $deplib "*) ;;
71519c9ff80cSmrg		*) new_libs="$deplib $new_libs" ;;
71529c9ff80cSmrg		esac
71539c9ff80cSmrg		;;
71549c9ff80cSmrg	      esac
71559c9ff80cSmrg	      ;;
71569c9ff80cSmrg	    esac
71579c9ff80cSmrg	  done
71589c9ff80cSmrg	  tmp_libs=
71599c9ff80cSmrg	  for deplib in $new_libs; do
71609c9ff80cSmrg	    case $deplib in
71619c9ff80cSmrg	    -L*)
71629c9ff80cSmrg	      case " $tmp_libs " in
71639c9ff80cSmrg	      *" $deplib "*) ;;
71646fae4e5dSmrg	      *) func_append tmp_libs " $deplib" ;;
71659c9ff80cSmrg	      esac
71669c9ff80cSmrg	      ;;
71676fae4e5dSmrg	    *) func_append tmp_libs " $deplib" ;;
71689c9ff80cSmrg	    esac
71699c9ff80cSmrg	  done
71709c9ff80cSmrg	  eval $var=\"$tmp_libs\"
71719c9ff80cSmrg	done # for var
71729c9ff80cSmrg      fi
71739c9ff80cSmrg      # Last step: remove runtime libs from dependency_libs
71749c9ff80cSmrg      # (they stay in deplibs)
71759c9ff80cSmrg      tmp_libs=
71769c9ff80cSmrg      for i in $dependency_libs ; do
71779c9ff80cSmrg	case " $predeps $postdeps $compiler_lib_search_path " in
71789c9ff80cSmrg	*" $i "*)
71799c9ff80cSmrg	  i=""
71809c9ff80cSmrg	  ;;
71819c9ff80cSmrg	esac
71829c9ff80cSmrg	if test -n "$i" ; then
71836fae4e5dSmrg	  func_append tmp_libs " $i"
71849c9ff80cSmrg	fi
71859c9ff80cSmrg      done
71869c9ff80cSmrg      dependency_libs=$tmp_libs
71879c9ff80cSmrg    done # for pass
71889c9ff80cSmrg    if test "$linkmode" = prog; then
71899c9ff80cSmrg      dlfiles="$newdlfiles"
71909c9ff80cSmrg    fi
71919c9ff80cSmrg    if test "$linkmode" = prog || test "$linkmode" = lib; then
71929c9ff80cSmrg      dlprefiles="$newdlprefiles"
71939c9ff80cSmrg    fi
71949c9ff80cSmrg
71959c9ff80cSmrg    case $linkmode in
71969c9ff80cSmrg    oldlib)
71979c9ff80cSmrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
71989c9ff80cSmrg	func_warning "\`-dlopen' is ignored for archives"
71999c9ff80cSmrg      fi
72009c9ff80cSmrg
72019c9ff80cSmrg      case " $deplibs" in
72029c9ff80cSmrg      *\ -l* | *\ -L*)
72039c9ff80cSmrg	func_warning "\`-l' and \`-L' are ignored for archives" ;;
72049c9ff80cSmrg      esac
72059c9ff80cSmrg
72069c9ff80cSmrg      test -n "$rpath" && \
72079c9ff80cSmrg	func_warning "\`-rpath' is ignored for archives"
72089c9ff80cSmrg
72099c9ff80cSmrg      test -n "$xrpath" && \
72109c9ff80cSmrg	func_warning "\`-R' is ignored for archives"
72119c9ff80cSmrg
72129c9ff80cSmrg      test -n "$vinfo" && \
72139c9ff80cSmrg	func_warning "\`-version-info/-version-number' is ignored for archives"
72149c9ff80cSmrg
72159c9ff80cSmrg      test -n "$release" && \
72169c9ff80cSmrg	func_warning "\`-release' is ignored for archives"
72179c9ff80cSmrg
72189c9ff80cSmrg      test -n "$export_symbols$export_symbols_regex" && \
72199c9ff80cSmrg	func_warning "\`-export-symbols' is ignored for archives"
72209c9ff80cSmrg
72219c9ff80cSmrg      # Now set the variables for building old libraries.
72229c9ff80cSmrg      build_libtool_libs=no
72239c9ff80cSmrg      oldlibs="$output"
72246fae4e5dSmrg      func_append objs "$old_deplibs"
72259c9ff80cSmrg      ;;
72269c9ff80cSmrg
72279c9ff80cSmrg    lib)
72289c9ff80cSmrg      # Make sure we only generate libraries of the form `libNAME.la'.
72299c9ff80cSmrg      case $outputname in
72309c9ff80cSmrg      lib*)
72319c9ff80cSmrg	func_stripname 'lib' '.la' "$outputname"
72329c9ff80cSmrg	name=$func_stripname_result
72339c9ff80cSmrg	eval shared_ext=\"$shrext_cmds\"
72349c9ff80cSmrg	eval libname=\"$libname_spec\"
72359c9ff80cSmrg	;;
72369c9ff80cSmrg      *)
72379c9ff80cSmrg	test "$module" = no && \
72389c9ff80cSmrg	  func_fatal_help "libtool library \`$output' must begin with \`lib'"
72399c9ff80cSmrg
72409c9ff80cSmrg	if test "$need_lib_prefix" != no; then
72419c9ff80cSmrg	  # Add the "lib" prefix for modules if required
72429c9ff80cSmrg	  func_stripname '' '.la' "$outputname"
72439c9ff80cSmrg	  name=$func_stripname_result
72449c9ff80cSmrg	  eval shared_ext=\"$shrext_cmds\"
72459c9ff80cSmrg	  eval libname=\"$libname_spec\"
72469c9ff80cSmrg	else
72479c9ff80cSmrg	  func_stripname '' '.la' "$outputname"
72489c9ff80cSmrg	  libname=$func_stripname_result
72499c9ff80cSmrg	fi
72509c9ff80cSmrg	;;
72519c9ff80cSmrg      esac
72529c9ff80cSmrg
72539c9ff80cSmrg      if test -n "$objs"; then
72549c9ff80cSmrg	if test "$deplibs_check_method" != pass_all; then
72559c9ff80cSmrg	  func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs"
72569c9ff80cSmrg	else
72576fae4e5dSmrg	  echo
72589c9ff80cSmrg	  $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
72599c9ff80cSmrg	  $ECHO "*** objects $objs is not portable!"
72606fae4e5dSmrg	  func_append libobjs " $objs"
72619c9ff80cSmrg	fi
72629c9ff80cSmrg      fi
72639c9ff80cSmrg
72649c9ff80cSmrg      test "$dlself" != no && \
72659c9ff80cSmrg	func_warning "\`-dlopen self' is ignored for libtool libraries"
72669c9ff80cSmrg
72679c9ff80cSmrg      set dummy $rpath
72689c9ff80cSmrg      shift
72699c9ff80cSmrg      test "$#" -gt 1 && \
72709c9ff80cSmrg	func_warning "ignoring multiple \`-rpath's for a libtool library"
72719c9ff80cSmrg
72729c9ff80cSmrg      install_libdir="$1"
72739c9ff80cSmrg
72749c9ff80cSmrg      oldlibs=
72759c9ff80cSmrg      if test -z "$rpath"; then
72769c9ff80cSmrg	if test "$build_libtool_libs" = yes; then
72779c9ff80cSmrg	  # Building a libtool convenience library.
72789c9ff80cSmrg	  # Some compilers have problems with a `.al' extension so
72799c9ff80cSmrg	  # convenience libraries should have the same extension an
72809c9ff80cSmrg	  # archive normally would.
72819c9ff80cSmrg	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
72829c9ff80cSmrg	  build_libtool_libs=convenience
72839c9ff80cSmrg	  build_old_libs=yes
72849c9ff80cSmrg	fi
72859c9ff80cSmrg
72869c9ff80cSmrg	test -n "$vinfo" && \
72879c9ff80cSmrg	  func_warning "\`-version-info/-version-number' is ignored for convenience libraries"
72889c9ff80cSmrg
72899c9ff80cSmrg	test -n "$release" && \
72909c9ff80cSmrg	  func_warning "\`-release' is ignored for convenience libraries"
72919c9ff80cSmrg      else
72929c9ff80cSmrg
72939c9ff80cSmrg	# Parse the version information argument.
72949c9ff80cSmrg	save_ifs="$IFS"; IFS=':'
72959c9ff80cSmrg	set dummy $vinfo 0 0 0
72969c9ff80cSmrg	shift
72979c9ff80cSmrg	IFS="$save_ifs"
72989c9ff80cSmrg
72999c9ff80cSmrg	test -n "$7" && \
73009c9ff80cSmrg	  func_fatal_help "too many parameters to \`-version-info'"
73019c9ff80cSmrg
73029c9ff80cSmrg	# convert absolute version numbers to libtool ages
73039c9ff80cSmrg	# this retains compatibility with .la files and attempts
73049c9ff80cSmrg	# to make the code below a bit more comprehensible
73059c9ff80cSmrg
73069c9ff80cSmrg	case $vinfo_number in
73079c9ff80cSmrg	yes)
73089c9ff80cSmrg	  number_major="$1"
73099c9ff80cSmrg	  number_minor="$2"
73109c9ff80cSmrg	  number_revision="$3"
73119c9ff80cSmrg	  #
73129c9ff80cSmrg	  # There are really only two kinds -- those that
73139c9ff80cSmrg	  # use the current revision as the major version
73149c9ff80cSmrg	  # and those that subtract age and use age as
73159c9ff80cSmrg	  # a minor version.  But, then there is irix
73169c9ff80cSmrg	  # which has an extra 1 added just for fun
73179c9ff80cSmrg	  #
73189c9ff80cSmrg	  case $version_type in
73199c9ff80cSmrg	  darwin|linux|osf|windows|none)
73209c9ff80cSmrg	    func_arith $number_major + $number_minor
73219c9ff80cSmrg	    current=$func_arith_result
73229c9ff80cSmrg	    age="$number_minor"
73239c9ff80cSmrg	    revision="$number_revision"
73249c9ff80cSmrg	    ;;
73256fae4e5dSmrg	  freebsd-aout|freebsd-elf|qnx|sunos)
73269c9ff80cSmrg	    current="$number_major"
73279c9ff80cSmrg	    revision="$number_minor"
73289c9ff80cSmrg	    age="0"
73299c9ff80cSmrg	    ;;
73309c9ff80cSmrg	  irix|nonstopux)
73319c9ff80cSmrg	    func_arith $number_major + $number_minor
73329c9ff80cSmrg	    current=$func_arith_result
73339c9ff80cSmrg	    age="$number_minor"
73349c9ff80cSmrg	    revision="$number_minor"
73359c9ff80cSmrg	    lt_irix_increment=no
73369c9ff80cSmrg	    ;;
73379c9ff80cSmrg	  esac
73389c9ff80cSmrg	  ;;
73399c9ff80cSmrg	no)
73409c9ff80cSmrg	  current="$1"
73419c9ff80cSmrg	  revision="$2"
73429c9ff80cSmrg	  age="$3"
73439c9ff80cSmrg	  ;;
73449c9ff80cSmrg	esac
73459c9ff80cSmrg
73469c9ff80cSmrg	# Check that each of the things are valid numbers.
73479c9ff80cSmrg	case $current in
73489c9ff80cSmrg	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]) ;;
73499c9ff80cSmrg	*)
73509c9ff80cSmrg	  func_error "CURRENT \`$current' must be a nonnegative integer"
73519c9ff80cSmrg	  func_fatal_error "\`$vinfo' is not valid version information"
73529c9ff80cSmrg	  ;;
73539c9ff80cSmrg	esac
73549c9ff80cSmrg
73559c9ff80cSmrg	case $revision in
73569c9ff80cSmrg	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]) ;;
73579c9ff80cSmrg	*)
73589c9ff80cSmrg	  func_error "REVISION \`$revision' must be a nonnegative integer"
73599c9ff80cSmrg	  func_fatal_error "\`$vinfo' is not valid version information"
73609c9ff80cSmrg	  ;;
73619c9ff80cSmrg	esac
73629c9ff80cSmrg
73639c9ff80cSmrg	case $age in
73649c9ff80cSmrg	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]) ;;
73659c9ff80cSmrg	*)
73669c9ff80cSmrg	  func_error "AGE \`$age' must be a nonnegative integer"
73679c9ff80cSmrg	  func_fatal_error "\`$vinfo' is not valid version information"
73689c9ff80cSmrg	  ;;
73699c9ff80cSmrg	esac
73709c9ff80cSmrg
73719c9ff80cSmrg	if test "$age" -gt "$current"; then
73729c9ff80cSmrg	  func_error "AGE \`$age' is greater than the current interface number \`$current'"
73739c9ff80cSmrg	  func_fatal_error "\`$vinfo' is not valid version information"
73749c9ff80cSmrg	fi
73759c9ff80cSmrg
73769c9ff80cSmrg	# Calculate the version variables.
73779c9ff80cSmrg	major=
73789c9ff80cSmrg	versuffix=
73799c9ff80cSmrg	verstring=
73809c9ff80cSmrg	case $version_type in
73819c9ff80cSmrg	none) ;;
73829c9ff80cSmrg
73839c9ff80cSmrg	darwin)
73849c9ff80cSmrg	  # Like Linux, but with the current version available in
73859c9ff80cSmrg	  # verstring for coding it into the library header
73869c9ff80cSmrg	  func_arith $current - $age
73879c9ff80cSmrg	  major=.$func_arith_result
73889c9ff80cSmrg	  versuffix="$major.$age.$revision"
73899c9ff80cSmrg	  # Darwin ld doesn't like 0 for these options...
73909c9ff80cSmrg	  func_arith $current + 1
73919c9ff80cSmrg	  minor_current=$func_arith_result
73929c9ff80cSmrg	  xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
73939c9ff80cSmrg	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
73949c9ff80cSmrg	  ;;
73959c9ff80cSmrg
73969c9ff80cSmrg	freebsd-aout)
73979c9ff80cSmrg	  major=".$current"
73989c9ff80cSmrg	  versuffix=".$current.$revision";
73999c9ff80cSmrg	  ;;
74009c9ff80cSmrg
74019c9ff80cSmrg	freebsd-elf)
74029c9ff80cSmrg	  major=".$current"
74039c9ff80cSmrg	  versuffix=".$current"
74049c9ff80cSmrg	  ;;
74059c9ff80cSmrg
74069c9ff80cSmrg	irix | nonstopux)
74079c9ff80cSmrg	  if test "X$lt_irix_increment" = "Xno"; then
74089c9ff80cSmrg	    func_arith $current - $age
74099c9ff80cSmrg	  else
74109c9ff80cSmrg	    func_arith $current - $age + 1
74119c9ff80cSmrg	  fi
74129c9ff80cSmrg	  major=$func_arith_result
74139c9ff80cSmrg
74149c9ff80cSmrg	  case $version_type in
74159c9ff80cSmrg	    nonstopux) verstring_prefix=nonstopux ;;
74169c9ff80cSmrg	    *)         verstring_prefix=sgi ;;
74179c9ff80cSmrg	  esac
74189c9ff80cSmrg	  verstring="$verstring_prefix$major.$revision"
74199c9ff80cSmrg
74209c9ff80cSmrg	  # Add in all the interfaces that we are compatible with.
74219c9ff80cSmrg	  loop=$revision
74229c9ff80cSmrg	  while test "$loop" -ne 0; do
74239c9ff80cSmrg	    func_arith $revision - $loop
74249c9ff80cSmrg	    iface=$func_arith_result
74259c9ff80cSmrg	    func_arith $loop - 1
74269c9ff80cSmrg	    loop=$func_arith_result
74279c9ff80cSmrg	    verstring="$verstring_prefix$major.$iface:$verstring"
74289c9ff80cSmrg	  done
74299c9ff80cSmrg
74309c9ff80cSmrg	  # Before this point, $major must not contain `.'.
74319c9ff80cSmrg	  major=.$major
74329c9ff80cSmrg	  versuffix="$major.$revision"
74339c9ff80cSmrg	  ;;
74349c9ff80cSmrg
74359c9ff80cSmrg	linux)
74369c9ff80cSmrg	  func_arith $current - $age
74379c9ff80cSmrg	  major=.$func_arith_result
74389c9ff80cSmrg	  versuffix="$major.$age.$revision"
74399c9ff80cSmrg	  ;;
74409c9ff80cSmrg
74419c9ff80cSmrg	osf)
74429c9ff80cSmrg	  func_arith $current - $age
74439c9ff80cSmrg	  major=.$func_arith_result
74449c9ff80cSmrg	  versuffix=".$current.$age.$revision"
74459c9ff80cSmrg	  verstring="$current.$age.$revision"
74469c9ff80cSmrg
74479c9ff80cSmrg	  # Add in all the interfaces that we are compatible with.
74489c9ff80cSmrg	  loop=$age
74499c9ff80cSmrg	  while test "$loop" -ne 0; do
74509c9ff80cSmrg	    func_arith $current - $loop
74519c9ff80cSmrg	    iface=$func_arith_result
74529c9ff80cSmrg	    func_arith $loop - 1
74539c9ff80cSmrg	    loop=$func_arith_result
74549c9ff80cSmrg	    verstring="$verstring:${iface}.0"
74559c9ff80cSmrg	  done
74569c9ff80cSmrg
74579c9ff80cSmrg	  # Make executables depend on our current version.
74586fae4e5dSmrg	  func_append verstring ":${current}.0"
74599c9ff80cSmrg	  ;;
74609c9ff80cSmrg
74619c9ff80cSmrg	qnx)
74629c9ff80cSmrg	  major=".$current"
74639c9ff80cSmrg	  versuffix=".$current"
74649c9ff80cSmrg	  ;;
74659c9ff80cSmrg
74669c9ff80cSmrg	sunos)
74679c9ff80cSmrg	  major=".$current"
74689c9ff80cSmrg	  versuffix=".$current.$revision"
74699c9ff80cSmrg	  ;;
74709c9ff80cSmrg
74719c9ff80cSmrg	windows)
74729c9ff80cSmrg	  # Use '-' rather than '.', since we only want one
74739c9ff80cSmrg	  # extension on DOS 8.3 filesystems.
74749c9ff80cSmrg	  func_arith $current - $age
74759c9ff80cSmrg	  major=$func_arith_result
74769c9ff80cSmrg	  versuffix="-$major"
74779c9ff80cSmrg	  ;;
74789c9ff80cSmrg
74799c9ff80cSmrg	*)
74809c9ff80cSmrg	  func_fatal_configuration "unknown library version type \`$version_type'"
74819c9ff80cSmrg	  ;;
74829c9ff80cSmrg	esac
74839c9ff80cSmrg
74849c9ff80cSmrg	# Clear the version info if we defaulted, and they specified a release.
74859c9ff80cSmrg	if test -z "$vinfo" && test -n "$release"; then
74869c9ff80cSmrg	  major=
74879c9ff80cSmrg	  case $version_type in
74889c9ff80cSmrg	  darwin)
74899c9ff80cSmrg	    # we can't check for "0.0" in archive_cmds due to quoting
74909c9ff80cSmrg	    # problems, so we reset it completely
74919c9ff80cSmrg	    verstring=
74929c9ff80cSmrg	    ;;
74939c9ff80cSmrg	  *)
74949c9ff80cSmrg	    verstring="0.0"
74959c9ff80cSmrg	    ;;
74969c9ff80cSmrg	  esac
74979c9ff80cSmrg	  if test "$need_version" = no; then
74989c9ff80cSmrg	    versuffix=
74999c9ff80cSmrg	  else
75009c9ff80cSmrg	    versuffix=".0.0"
75019c9ff80cSmrg	  fi
75029c9ff80cSmrg	fi
75039c9ff80cSmrg
75049c9ff80cSmrg	# Remove version info from name if versioning should be avoided
75059c9ff80cSmrg	if test "$avoid_version" = yes && test "$need_version" = no; then
75069c9ff80cSmrg	  major=
75079c9ff80cSmrg	  versuffix=
75089c9ff80cSmrg	  verstring=""
75099c9ff80cSmrg	fi
75109c9ff80cSmrg
75119c9ff80cSmrg	# Check to see if the archive will have undefined symbols.
75129c9ff80cSmrg	if test "$allow_undefined" = yes; then
75139c9ff80cSmrg	  if test "$allow_undefined_flag" = unsupported; then
75149c9ff80cSmrg	    func_warning "undefined symbols not allowed in $host shared libraries"
75159c9ff80cSmrg	    build_libtool_libs=no
75169c9ff80cSmrg	    build_old_libs=yes
75179c9ff80cSmrg	  fi
75189c9ff80cSmrg	else
75199c9ff80cSmrg	  # Don't allow undefined symbols.
75209c9ff80cSmrg	  allow_undefined_flag="$no_undefined_flag"
75219c9ff80cSmrg	fi
75229c9ff80cSmrg
75239c9ff80cSmrg      fi
75249c9ff80cSmrg
75259c9ff80cSmrg      func_generate_dlsyms "$libname" "$libname" "yes"
75266fae4e5dSmrg      func_append libobjs " $symfileobj"
75279c9ff80cSmrg      test "X$libobjs" = "X " && libobjs=
75289c9ff80cSmrg
75296fae4e5dSmrg      if test "$opt_mode" != relink; then
75309c9ff80cSmrg	# Remove our outputs, but don't remove object files since they
75319c9ff80cSmrg	# may have been created when compiling PIC objects.
75329c9ff80cSmrg	removelist=
75339c9ff80cSmrg	tempremovelist=`$ECHO "$output_objdir/*"`
75349c9ff80cSmrg	for p in $tempremovelist; do
75359c9ff80cSmrg	  case $p in
75369c9ff80cSmrg	    *.$objext | *.gcno)
75379c9ff80cSmrg	       ;;
75389c9ff80cSmrg	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
75399c9ff80cSmrg	       if test "X$precious_files_regex" != "X"; then
75409c9ff80cSmrg		 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
75419c9ff80cSmrg		 then
75429c9ff80cSmrg		   continue
75439c9ff80cSmrg		 fi
75449c9ff80cSmrg	       fi
75456fae4e5dSmrg	       func_append removelist " $p"
75469c9ff80cSmrg	       ;;
75479c9ff80cSmrg	    *) ;;
75489c9ff80cSmrg	  esac
75499c9ff80cSmrg	done
75509c9ff80cSmrg	test -n "$removelist" && \
75519c9ff80cSmrg	  func_show_eval "${RM}r \$removelist"
75529c9ff80cSmrg      fi
75539c9ff80cSmrg
75549c9ff80cSmrg      # Now set the variables for building old libraries.
75559c9ff80cSmrg      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
75566fae4e5dSmrg	func_append oldlibs " $output_objdir/$libname.$libext"
75579c9ff80cSmrg
75589c9ff80cSmrg	# Transform .lo files to .o files.
75596fae4e5dSmrg	oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP`
75609c9ff80cSmrg      fi
75619c9ff80cSmrg
75629c9ff80cSmrg      # Eliminate all temporary directories.
75639c9ff80cSmrg      #for path in $notinst_path; do
75646fae4e5dSmrg      #	lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
75656fae4e5dSmrg      #	deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
75666fae4e5dSmrg      #	dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
75679c9ff80cSmrg      #done
75689c9ff80cSmrg
75699c9ff80cSmrg      if test -n "$xrpath"; then
75709c9ff80cSmrg	# If the user specified any rpath flags, then add them.
75719c9ff80cSmrg	temp_xrpath=
75729c9ff80cSmrg	for libdir in $xrpath; do
75736fae4e5dSmrg	  func_replace_sysroot "$libdir"
75746fae4e5dSmrg	  func_append temp_xrpath " -R$func_replace_sysroot_result"
75759c9ff80cSmrg	  case "$finalize_rpath " in
75769c9ff80cSmrg	  *" $libdir "*) ;;
75776fae4e5dSmrg	  *) func_append finalize_rpath " $libdir" ;;
75789c9ff80cSmrg	  esac
75799c9ff80cSmrg	done
75809c9ff80cSmrg	if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
75819c9ff80cSmrg	  dependency_libs="$temp_xrpath $dependency_libs"
75829c9ff80cSmrg	fi
75839c9ff80cSmrg      fi
75849c9ff80cSmrg
75859c9ff80cSmrg      # Make sure dlfiles contains only unique files that won't be dlpreopened
75869c9ff80cSmrg      old_dlfiles="$dlfiles"
75879c9ff80cSmrg      dlfiles=
75889c9ff80cSmrg      for lib in $old_dlfiles; do
75899c9ff80cSmrg	case " $dlprefiles $dlfiles " in
75909c9ff80cSmrg	*" $lib "*) ;;
75916fae4e5dSmrg	*) func_append dlfiles " $lib" ;;
75929c9ff80cSmrg	esac
75939c9ff80cSmrg      done
75949c9ff80cSmrg
75959c9ff80cSmrg      # Make sure dlprefiles contains only unique files
75969c9ff80cSmrg      old_dlprefiles="$dlprefiles"
75979c9ff80cSmrg      dlprefiles=
75989c9ff80cSmrg      for lib in $old_dlprefiles; do
75999c9ff80cSmrg	case "$dlprefiles " in
76009c9ff80cSmrg	*" $lib "*) ;;
76016fae4e5dSmrg	*) func_append dlprefiles " $lib" ;;
76029c9ff80cSmrg	esac
76039c9ff80cSmrg      done
76049c9ff80cSmrg
76059c9ff80cSmrg      if test "$build_libtool_libs" = yes; then
76069c9ff80cSmrg	if test -n "$rpath"; then
76079c9ff80cSmrg	  case $host in
76086fae4e5dSmrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
76099c9ff80cSmrg	    # these systems don't actually have a c library (as such)!
76109c9ff80cSmrg	    ;;
76119c9ff80cSmrg	  *-*-rhapsody* | *-*-darwin1.[012])
76129c9ff80cSmrg	    # Rhapsody C library is in the System framework
76136fae4e5dSmrg	    func_append deplibs " System.ltframework"
76149c9ff80cSmrg	    ;;
76159c9ff80cSmrg	  *-*-netbsd*)
76169c9ff80cSmrg	    # Don't link with libc until the a.out ld.so is fixed.
76179c9ff80cSmrg	    ;;
76189c9ff80cSmrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
76199c9ff80cSmrg	    # Do not include libc due to us having libc/libc_r.
76209c9ff80cSmrg	    ;;
76219c9ff80cSmrg	  *-*-sco3.2v5* | *-*-sco5v6*)
76229c9ff80cSmrg	    # Causes problems with __ctype
76239c9ff80cSmrg	    ;;
76249c9ff80cSmrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
76259c9ff80cSmrg	    # Compiler inserts libc in the correct place for threads to work
76269c9ff80cSmrg	    ;;
76279c9ff80cSmrg	  *)
76289c9ff80cSmrg	    # Add libc to deplibs on all other systems if necessary.
76299c9ff80cSmrg	    if test "$build_libtool_need_lc" = "yes"; then
76306fae4e5dSmrg	      func_append deplibs " -lc"
76319c9ff80cSmrg	    fi
76329c9ff80cSmrg	    ;;
76339c9ff80cSmrg	  esac
76349c9ff80cSmrg	fi
76359c9ff80cSmrg
76369c9ff80cSmrg	# Transform deplibs into only deplibs that can be linked in shared.
76379c9ff80cSmrg	name_save=$name
76389c9ff80cSmrg	libname_save=$libname
76399c9ff80cSmrg	release_save=$release
76409c9ff80cSmrg	versuffix_save=$versuffix
76419c9ff80cSmrg	major_save=$major
76429c9ff80cSmrg	# I'm not sure if I'm treating the release correctly.  I think
76439c9ff80cSmrg	# release should show up in the -l (ie -lgmp5) so we don't want to
76449c9ff80cSmrg	# add it in twice.  Is that correct?
76459c9ff80cSmrg	release=""
76469c9ff80cSmrg	versuffix=""
76479c9ff80cSmrg	major=""
76489c9ff80cSmrg	newdeplibs=
76499c9ff80cSmrg	droppeddeps=no
76509c9ff80cSmrg	case $deplibs_check_method in
76519c9ff80cSmrg	pass_all)
76529c9ff80cSmrg	  # Don't check for shared/static.  Everything works.
76539c9ff80cSmrg	  # This might be a little naive.  We might want to check
76549c9ff80cSmrg	  # whether the library exists or not.  But this is on
76559c9ff80cSmrg	  # osf3 & osf4 and I'm not really sure... Just
76569c9ff80cSmrg	  # implementing what was already the behavior.
76579c9ff80cSmrg	  newdeplibs=$deplibs
76589c9ff80cSmrg	  ;;
76599c9ff80cSmrg	test_compile)
76609c9ff80cSmrg	  # This code stresses the "libraries are programs" paradigm to its
76619c9ff80cSmrg	  # limits. Maybe even breaks it.  We compile a program, linking it
76629c9ff80cSmrg	  # against the deplibs as a proxy for the library.  Then we can check
76639c9ff80cSmrg	  # whether they linked in statically or dynamically with ldd.
76649c9ff80cSmrg	  $opt_dry_run || $RM conftest.c
76659c9ff80cSmrg	  cat > conftest.c <<EOF
76669c9ff80cSmrg	  int main() { return 0; }
76679c9ff80cSmrgEOF
76689c9ff80cSmrg	  $opt_dry_run || $RM conftest
76699c9ff80cSmrg	  if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
76709c9ff80cSmrg	    ldd_output=`ldd conftest`
76719c9ff80cSmrg	    for i in $deplibs; do
76729c9ff80cSmrg	      case $i in
76739c9ff80cSmrg	      -l*)
76749c9ff80cSmrg		func_stripname -l '' "$i"
76759c9ff80cSmrg		name=$func_stripname_result
76769c9ff80cSmrg		if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
76779c9ff80cSmrg		  case " $predeps $postdeps " in
76789c9ff80cSmrg		  *" $i "*)
76796fae4e5dSmrg		    func_append newdeplibs " $i"
76809c9ff80cSmrg		    i=""
76819c9ff80cSmrg		    ;;
76829c9ff80cSmrg		  esac
76839c9ff80cSmrg		fi
76849c9ff80cSmrg		if test -n "$i" ; then
76859c9ff80cSmrg		  libname=`eval "\\$ECHO \"$libname_spec\""`
76869c9ff80cSmrg		  deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
76879c9ff80cSmrg		  set dummy $deplib_matches; shift
76889c9ff80cSmrg		  deplib_match=$1
76899c9ff80cSmrg		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
76906fae4e5dSmrg		    func_append newdeplibs " $i"
76919c9ff80cSmrg		  else
76929c9ff80cSmrg		    droppeddeps=yes
76936fae4e5dSmrg		    echo
76949c9ff80cSmrg		    $ECHO "*** Warning: dynamic linker does not accept needed library $i."
76956fae4e5dSmrg		    echo "*** I have the capability to make that library automatically link in when"
76966fae4e5dSmrg		    echo "*** you link to this library.  But I can only do this if you have a"
76976fae4e5dSmrg		    echo "*** shared version of the library, which I believe you do not have"
76986fae4e5dSmrg		    echo "*** because a test_compile did reveal that the linker did not use it for"
76996fae4e5dSmrg		    echo "*** its dynamic dependency list that programs get resolved with at runtime."
77009c9ff80cSmrg		  fi
77019c9ff80cSmrg		fi
77029c9ff80cSmrg		;;
77039c9ff80cSmrg	      *)
77046fae4e5dSmrg		func_append newdeplibs " $i"
77059c9ff80cSmrg		;;
77069c9ff80cSmrg	      esac
77079c9ff80cSmrg	    done
77089c9ff80cSmrg	  else
77099c9ff80cSmrg	    # Error occurred in the first compile.  Let's try to salvage
77109c9ff80cSmrg	    # the situation: Compile a separate program for each library.
77119c9ff80cSmrg	    for i in $deplibs; do
77129c9ff80cSmrg	      case $i in
77139c9ff80cSmrg	      -l*)
77149c9ff80cSmrg		func_stripname -l '' "$i"
77159c9ff80cSmrg		name=$func_stripname_result
77169c9ff80cSmrg		$opt_dry_run || $RM conftest
77179c9ff80cSmrg		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
77189c9ff80cSmrg		  ldd_output=`ldd conftest`
77199c9ff80cSmrg		  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
77209c9ff80cSmrg		    case " $predeps $postdeps " in
77219c9ff80cSmrg		    *" $i "*)
77226fae4e5dSmrg		      func_append newdeplibs " $i"
77239c9ff80cSmrg		      i=""
77249c9ff80cSmrg		      ;;
77259c9ff80cSmrg		    esac
77269c9ff80cSmrg		  fi
77279c9ff80cSmrg		  if test -n "$i" ; then
77289c9ff80cSmrg		    libname=`eval "\\$ECHO \"$libname_spec\""`
77299c9ff80cSmrg		    deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
77309c9ff80cSmrg		    set dummy $deplib_matches; shift
77319c9ff80cSmrg		    deplib_match=$1
77329c9ff80cSmrg		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
77336fae4e5dSmrg		      func_append newdeplibs " $i"
77349c9ff80cSmrg		    else
77359c9ff80cSmrg		      droppeddeps=yes
77366fae4e5dSmrg		      echo
77379c9ff80cSmrg		      $ECHO "*** Warning: dynamic linker does not accept needed library $i."
77386fae4e5dSmrg		      echo "*** I have the capability to make that library automatically link in when"
77396fae4e5dSmrg		      echo "*** you link to this library.  But I can only do this if you have a"
77406fae4e5dSmrg		      echo "*** shared version of the library, which you do not appear to have"
77416fae4e5dSmrg		      echo "*** because a test_compile did reveal that the linker did not use this one"
77426fae4e5dSmrg		      echo "*** as a dynamic dependency that programs can get resolved with at runtime."
77439c9ff80cSmrg		    fi
77449c9ff80cSmrg		  fi
77459c9ff80cSmrg		else
77469c9ff80cSmrg		  droppeddeps=yes
77476fae4e5dSmrg		  echo
77489c9ff80cSmrg		  $ECHO "*** Warning!  Library $i is needed by this library but I was not able to"
77496fae4e5dSmrg		  echo "*** make it link in!  You will probably need to install it or some"
77506fae4e5dSmrg		  echo "*** library that it depends on before this library will be fully"
77516fae4e5dSmrg		  echo "*** functional.  Installing it before continuing would be even better."
77529c9ff80cSmrg		fi
77539c9ff80cSmrg		;;
77549c9ff80cSmrg	      *)
77556fae4e5dSmrg		func_append newdeplibs " $i"
77569c9ff80cSmrg		;;
77579c9ff80cSmrg	      esac
77589c9ff80cSmrg	    done
77599c9ff80cSmrg	  fi
77609c9ff80cSmrg	  ;;
77619c9ff80cSmrg	file_magic*)
77629c9ff80cSmrg	  set dummy $deplibs_check_method; shift
77639c9ff80cSmrg	  file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
77649c9ff80cSmrg	  for a_deplib in $deplibs; do
77659c9ff80cSmrg	    case $a_deplib in
77669c9ff80cSmrg	    -l*)
77679c9ff80cSmrg	      func_stripname -l '' "$a_deplib"
77689c9ff80cSmrg	      name=$func_stripname_result
77699c9ff80cSmrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
77709c9ff80cSmrg		case " $predeps $postdeps " in
77719c9ff80cSmrg		*" $a_deplib "*)
77726fae4e5dSmrg		  func_append newdeplibs " $a_deplib"
77739c9ff80cSmrg		  a_deplib=""
77749c9ff80cSmrg		  ;;
77759c9ff80cSmrg		esac
77769c9ff80cSmrg	      fi
77779c9ff80cSmrg	      if test -n "$a_deplib" ; then
77789c9ff80cSmrg		libname=`eval "\\$ECHO \"$libname_spec\""`
77796fae4e5dSmrg		if test -n "$file_magic_glob"; then
77806fae4e5dSmrg		  libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob`
77816fae4e5dSmrg		else
77826fae4e5dSmrg		  libnameglob=$libname
77836fae4e5dSmrg		fi
77846fae4e5dSmrg		test "$want_nocaseglob" = yes && nocaseglob=`shopt -p nocaseglob`
77859c9ff80cSmrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
77866fae4e5dSmrg		  if test "$want_nocaseglob" = yes; then
77876fae4e5dSmrg		    shopt -s nocaseglob
77886fae4e5dSmrg		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
77896fae4e5dSmrg		    $nocaseglob
77906fae4e5dSmrg		  else
77916fae4e5dSmrg		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
77926fae4e5dSmrg		  fi
77939c9ff80cSmrg		  for potent_lib in $potential_libs; do
77949c9ff80cSmrg		      # Follow soft links.
77959c9ff80cSmrg		      if ls -lLd "$potent_lib" 2>/dev/null |
77969c9ff80cSmrg			 $GREP " -> " >/dev/null; then
77979c9ff80cSmrg			continue
77989c9ff80cSmrg		      fi
77999c9ff80cSmrg		      # The statement above tries to avoid entering an
78009c9ff80cSmrg		      # endless loop below, in case of cyclic links.
78019c9ff80cSmrg		      # We might still enter an endless loop, since a link
78029c9ff80cSmrg		      # loop can be closed while we follow links,
78039c9ff80cSmrg		      # but so what?
78049c9ff80cSmrg		      potlib="$potent_lib"
78059c9ff80cSmrg		      while test -h "$potlib" 2>/dev/null; do
78069c9ff80cSmrg			potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
78079c9ff80cSmrg			case $potliblink in
78089c9ff80cSmrg			[\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
78096fae4e5dSmrg			*) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";;
78109c9ff80cSmrg			esac
78119c9ff80cSmrg		      done
78129c9ff80cSmrg		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
78139c9ff80cSmrg			 $SED -e 10q |
78149c9ff80cSmrg			 $EGREP "$file_magic_regex" > /dev/null; then
78156fae4e5dSmrg			func_append newdeplibs " $a_deplib"
78169c9ff80cSmrg			a_deplib=""
78179c9ff80cSmrg			break 2
78189c9ff80cSmrg		      fi
78199c9ff80cSmrg		  done
78209c9ff80cSmrg		done
78219c9ff80cSmrg	      fi
78229c9ff80cSmrg	      if test -n "$a_deplib" ; then
78239c9ff80cSmrg		droppeddeps=yes
78246fae4e5dSmrg		echo
78259c9ff80cSmrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
78266fae4e5dSmrg		echo "*** I have the capability to make that library automatically link in when"
78276fae4e5dSmrg		echo "*** you link to this library.  But I can only do this if you have a"
78286fae4e5dSmrg		echo "*** shared version of the library, which you do not appear to have"
78296fae4e5dSmrg		echo "*** because I did check the linker path looking for a file starting"
78309c9ff80cSmrg		if test -z "$potlib" ; then
78319c9ff80cSmrg		  $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
78329c9ff80cSmrg		else
78339c9ff80cSmrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
78349c9ff80cSmrg		  $ECHO "*** using a file magic. Last file checked: $potlib"
78359c9ff80cSmrg		fi
78369c9ff80cSmrg	      fi
78379c9ff80cSmrg	      ;;
78389c9ff80cSmrg	    *)
78399c9ff80cSmrg	      # Add a -L argument.
78406fae4e5dSmrg	      func_append newdeplibs " $a_deplib"
78419c9ff80cSmrg	      ;;
78429c9ff80cSmrg	    esac
78439c9ff80cSmrg	  done # Gone through all deplibs.
78449c9ff80cSmrg	  ;;
78459c9ff80cSmrg	match_pattern*)
78469c9ff80cSmrg	  set dummy $deplibs_check_method; shift
78479c9ff80cSmrg	  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
78489c9ff80cSmrg	  for a_deplib in $deplibs; do
78499c9ff80cSmrg	    case $a_deplib in
78509c9ff80cSmrg	    -l*)
78519c9ff80cSmrg	      func_stripname -l '' "$a_deplib"
78529c9ff80cSmrg	      name=$func_stripname_result
78539c9ff80cSmrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
78549c9ff80cSmrg		case " $predeps $postdeps " in
78559c9ff80cSmrg		*" $a_deplib "*)
78566fae4e5dSmrg		  func_append newdeplibs " $a_deplib"
78579c9ff80cSmrg		  a_deplib=""
78589c9ff80cSmrg		  ;;
78599c9ff80cSmrg		esac
78609c9ff80cSmrg	      fi
78619c9ff80cSmrg	      if test -n "$a_deplib" ; then
78629c9ff80cSmrg		libname=`eval "\\$ECHO \"$libname_spec\""`
78639c9ff80cSmrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
78649c9ff80cSmrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
78659c9ff80cSmrg		  for potent_lib in $potential_libs; do
78669c9ff80cSmrg		    potlib="$potent_lib" # see symlink-check above in file_magic test
78676fae4e5dSmrg		    if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
78689c9ff80cSmrg		       $EGREP "$match_pattern_regex" > /dev/null; then
78696fae4e5dSmrg		      func_append newdeplibs " $a_deplib"
78709c9ff80cSmrg		      a_deplib=""
78719c9ff80cSmrg		      break 2
78729c9ff80cSmrg		    fi
78739c9ff80cSmrg		  done
78749c9ff80cSmrg		done
78759c9ff80cSmrg	      fi
78769c9ff80cSmrg	      if test -n "$a_deplib" ; then
78779c9ff80cSmrg		droppeddeps=yes
78786fae4e5dSmrg		echo
78799c9ff80cSmrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
78806fae4e5dSmrg		echo "*** I have the capability to make that library automatically link in when"
78816fae4e5dSmrg		echo "*** you link to this library.  But I can only do this if you have a"
78826fae4e5dSmrg		echo "*** shared version of the library, which you do not appear to have"
78836fae4e5dSmrg		echo "*** because I did check the linker path looking for a file starting"
78849c9ff80cSmrg		if test -z "$potlib" ; then
78859c9ff80cSmrg		  $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
78869c9ff80cSmrg		else
78879c9ff80cSmrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
78889c9ff80cSmrg		  $ECHO "*** using a regex pattern. Last file checked: $potlib"
78899c9ff80cSmrg		fi
78909c9ff80cSmrg	      fi
78919c9ff80cSmrg	      ;;
78929c9ff80cSmrg	    *)
78939c9ff80cSmrg	      # Add a -L argument.
78946fae4e5dSmrg	      func_append newdeplibs " $a_deplib"
78959c9ff80cSmrg	      ;;
78969c9ff80cSmrg	    esac
78979c9ff80cSmrg	  done # Gone through all deplibs.
78989c9ff80cSmrg	  ;;
78999c9ff80cSmrg	none | unknown | *)
79009c9ff80cSmrg	  newdeplibs=""
79016fae4e5dSmrg	  tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
79029c9ff80cSmrg	  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
79039c9ff80cSmrg	    for i in $predeps $postdeps ; do
79049c9ff80cSmrg	      # can't use Xsed below, because $i might contain '/'
79056fae4e5dSmrg	      tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"`
79069c9ff80cSmrg	    done
79079c9ff80cSmrg	  fi
79086fae4e5dSmrg	  case $tmp_deplibs in
79096fae4e5dSmrg	  *[!\	\ ]*)
79106fae4e5dSmrg	    echo
79119c9ff80cSmrg	    if test "X$deplibs_check_method" = "Xnone"; then
79126fae4e5dSmrg	      echo "*** Warning: inter-library dependencies are not supported in this platform."
79139c9ff80cSmrg	    else
79146fae4e5dSmrg	      echo "*** Warning: inter-library dependencies are not known to be supported."
79159c9ff80cSmrg	    fi
79166fae4e5dSmrg	    echo "*** All declared inter-library dependencies are being dropped."
79179c9ff80cSmrg	    droppeddeps=yes
79186fae4e5dSmrg	    ;;
79196fae4e5dSmrg	  esac
79209c9ff80cSmrg	  ;;
79219c9ff80cSmrg	esac
79229c9ff80cSmrg	versuffix=$versuffix_save
79239c9ff80cSmrg	major=$major_save
79249c9ff80cSmrg	release=$release_save
79259c9ff80cSmrg	libname=$libname_save
79269c9ff80cSmrg	name=$name_save
79279c9ff80cSmrg
79289c9ff80cSmrg	case $host in
79299c9ff80cSmrg	*-*-rhapsody* | *-*-darwin1.[012])
79309c9ff80cSmrg	  # On Rhapsody replace the C library with the System framework
79316fae4e5dSmrg	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
79329c9ff80cSmrg	  ;;
79339c9ff80cSmrg	esac
79349c9ff80cSmrg
79359c9ff80cSmrg	if test "$droppeddeps" = yes; then
79369c9ff80cSmrg	  if test "$module" = yes; then
79376fae4e5dSmrg	    echo
79386fae4e5dSmrg	    echo "*** Warning: libtool could not satisfy all declared inter-library"
79399c9ff80cSmrg	    $ECHO "*** dependencies of module $libname.  Therefore, libtool will create"
79406fae4e5dSmrg	    echo "*** a static module, that should work as long as the dlopening"
79416fae4e5dSmrg	    echo "*** application is linked with the -dlopen flag."
79429c9ff80cSmrg	    if test -z "$global_symbol_pipe"; then
79436fae4e5dSmrg	      echo
79446fae4e5dSmrg	      echo "*** However, this would only work if libtool was able to extract symbol"
79456fae4e5dSmrg	      echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
79466fae4e5dSmrg	      echo "*** not find such a program.  So, this module is probably useless."
79476fae4e5dSmrg	      echo "*** \`nm' from GNU binutils and a full rebuild may help."
79489c9ff80cSmrg	    fi
79499c9ff80cSmrg	    if test "$build_old_libs" = no; then
79509c9ff80cSmrg	      oldlibs="$output_objdir/$libname.$libext"
79519c9ff80cSmrg	      build_libtool_libs=module
79529c9ff80cSmrg	      build_old_libs=yes
79539c9ff80cSmrg	    else
79549c9ff80cSmrg	      build_libtool_libs=no
79559c9ff80cSmrg	    fi
79569c9ff80cSmrg	  else
79576fae4e5dSmrg	    echo "*** The inter-library dependencies that have been dropped here will be"
79586fae4e5dSmrg	    echo "*** automatically added whenever a program is linked with this library"
79596fae4e5dSmrg	    echo "*** or is declared to -dlopen it."
79609c9ff80cSmrg
79619c9ff80cSmrg	    if test "$allow_undefined" = no; then
79626fae4e5dSmrg	      echo
79636fae4e5dSmrg	      echo "*** Since this library must not contain undefined symbols,"
79646fae4e5dSmrg	      echo "*** because either the platform does not support them or"
79656fae4e5dSmrg	      echo "*** it was explicitly requested with -no-undefined,"
79666fae4e5dSmrg	      echo "*** libtool will only create a static version of it."
79679c9ff80cSmrg	      if test "$build_old_libs" = no; then
79689c9ff80cSmrg		oldlibs="$output_objdir/$libname.$libext"
79699c9ff80cSmrg		build_libtool_libs=module
79709c9ff80cSmrg		build_old_libs=yes
79719c9ff80cSmrg	      else
79729c9ff80cSmrg		build_libtool_libs=no
79739c9ff80cSmrg	      fi
79749c9ff80cSmrg	    fi
79759c9ff80cSmrg	  fi
79769c9ff80cSmrg	fi
79779c9ff80cSmrg	# Done checking deplibs!
79789c9ff80cSmrg	deplibs=$newdeplibs
79799c9ff80cSmrg      fi
79809c9ff80cSmrg      # Time to change all our "foo.ltframework" stuff back to "-framework foo"
79819c9ff80cSmrg      case $host in
79829c9ff80cSmrg	*-*-darwin*)
79836fae4e5dSmrg	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
79846fae4e5dSmrg	  new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
79856fae4e5dSmrg	  deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
79869c9ff80cSmrg	  ;;
79879c9ff80cSmrg      esac
79889c9ff80cSmrg
79899c9ff80cSmrg      # move library search paths that coincide with paths to not yet
79909c9ff80cSmrg      # installed libraries to the beginning of the library search list
79919c9ff80cSmrg      new_libs=
79929c9ff80cSmrg      for path in $notinst_path; do
79939c9ff80cSmrg	case " $new_libs " in
79949c9ff80cSmrg	*" -L$path/$objdir "*) ;;
79959c9ff80cSmrg	*)
79969c9ff80cSmrg	  case " $deplibs " in
79979c9ff80cSmrg	  *" -L$path/$objdir "*)
79986fae4e5dSmrg	    func_append new_libs " -L$path/$objdir" ;;
79999c9ff80cSmrg	  esac
80009c9ff80cSmrg	  ;;
80019c9ff80cSmrg	esac
80029c9ff80cSmrg      done
80039c9ff80cSmrg      for deplib in $deplibs; do
80049c9ff80cSmrg	case $deplib in
80059c9ff80cSmrg	-L*)
80069c9ff80cSmrg	  case " $new_libs " in
80079c9ff80cSmrg	  *" $deplib "*) ;;
80086fae4e5dSmrg	  *) func_append new_libs " $deplib" ;;
80099c9ff80cSmrg	  esac
80109c9ff80cSmrg	  ;;
80116fae4e5dSmrg	*) func_append new_libs " $deplib" ;;
80129c9ff80cSmrg	esac
80139c9ff80cSmrg      done
80149c9ff80cSmrg      deplibs="$new_libs"
80159c9ff80cSmrg
80169c9ff80cSmrg      # All the library-specific variables (install_libdir is set above).
80179c9ff80cSmrg      library_names=
80189c9ff80cSmrg      old_library=
80199c9ff80cSmrg      dlname=
80209c9ff80cSmrg
80219c9ff80cSmrg      # Test again, we may have decided not to build it any more
80229c9ff80cSmrg      if test "$build_libtool_libs" = yes; then
80239c9ff80cSmrg	if test "$hardcode_into_libs" = yes; then
80249c9ff80cSmrg	  # Hardcode the library paths
80259c9ff80cSmrg	  hardcode_libdirs=
80269c9ff80cSmrg	  dep_rpath=
80279c9ff80cSmrg	  rpath="$finalize_rpath"
80286fae4e5dSmrg	  test "$opt_mode" != relink && rpath="$compile_rpath$rpath"
80299c9ff80cSmrg	  for libdir in $rpath; do
80309c9ff80cSmrg	    if test -n "$hardcode_libdir_flag_spec"; then
80319c9ff80cSmrg	      if test -n "$hardcode_libdir_separator"; then
80326fae4e5dSmrg		func_replace_sysroot "$libdir"
80336fae4e5dSmrg		libdir=$func_replace_sysroot_result
80349c9ff80cSmrg		if test -z "$hardcode_libdirs"; then
80359c9ff80cSmrg		  hardcode_libdirs="$libdir"
80369c9ff80cSmrg		else
80379c9ff80cSmrg		  # Just accumulate the unique libdirs.
80389c9ff80cSmrg		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
80399c9ff80cSmrg		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
80409c9ff80cSmrg		    ;;
80419c9ff80cSmrg		  *)
80426fae4e5dSmrg		    func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
80439c9ff80cSmrg		    ;;
80449c9ff80cSmrg		  esac
80459c9ff80cSmrg		fi
80469c9ff80cSmrg	      else
80479c9ff80cSmrg		eval flag=\"$hardcode_libdir_flag_spec\"
80486fae4e5dSmrg		func_append dep_rpath " $flag"
80499c9ff80cSmrg	      fi
80509c9ff80cSmrg	    elif test -n "$runpath_var"; then
80519c9ff80cSmrg	      case "$perm_rpath " in
80529c9ff80cSmrg	      *" $libdir "*) ;;
80536fae4e5dSmrg	      *) func_apped perm_rpath " $libdir" ;;
80549c9ff80cSmrg	      esac
80559c9ff80cSmrg	    fi
80569c9ff80cSmrg	  done
80579c9ff80cSmrg	  # Substitute the hardcoded libdirs into the rpath.
80589c9ff80cSmrg	  if test -n "$hardcode_libdir_separator" &&
80599c9ff80cSmrg	     test -n "$hardcode_libdirs"; then
80609c9ff80cSmrg	    libdir="$hardcode_libdirs"
80619c9ff80cSmrg	    if test -n "$hardcode_libdir_flag_spec_ld"; then
80629c9ff80cSmrg	      eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\"
80639c9ff80cSmrg	    else
80649c9ff80cSmrg	      eval dep_rpath=\"$hardcode_libdir_flag_spec\"
80659c9ff80cSmrg	    fi
80669c9ff80cSmrg	  fi
80679c9ff80cSmrg	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
80689c9ff80cSmrg	    # We should set the runpath_var.
80699c9ff80cSmrg	    rpath=
80709c9ff80cSmrg	    for dir in $perm_rpath; do
80716fae4e5dSmrg	      func_append rpath "$dir:"
80729c9ff80cSmrg	    done
80739c9ff80cSmrg	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
80749c9ff80cSmrg	  fi
80759c9ff80cSmrg	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
80769c9ff80cSmrg	fi
80771f0ac6a5Smrg
80789c9ff80cSmrg	shlibpath="$finalize_shlibpath"
80796fae4e5dSmrg	test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
80809c9ff80cSmrg	if test -n "$shlibpath"; then
80819c9ff80cSmrg	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
80829c9ff80cSmrg	fi
80831f0ac6a5Smrg
80849c9ff80cSmrg	# Get the real and link names of the library.
80859c9ff80cSmrg	eval shared_ext=\"$shrext_cmds\"
80869c9ff80cSmrg	eval library_names=\"$library_names_spec\"
80879c9ff80cSmrg	set dummy $library_names
80889c9ff80cSmrg	shift
80899c9ff80cSmrg	realname="$1"
80909c9ff80cSmrg	shift
80911f0ac6a5Smrg
80929c9ff80cSmrg	if test -n "$soname_spec"; then
80939c9ff80cSmrg	  eval soname=\"$soname_spec\"
80949c9ff80cSmrg	else
80959c9ff80cSmrg	  soname="$realname"
80969c9ff80cSmrg	fi
80979c9ff80cSmrg	if test -z "$dlname"; then
80989c9ff80cSmrg	  dlname=$soname
80999c9ff80cSmrg	fi
81001f0ac6a5Smrg
81019c9ff80cSmrg	lib="$output_objdir/$realname"
81029c9ff80cSmrg	linknames=
81039c9ff80cSmrg	for link
81049c9ff80cSmrg	do
81056fae4e5dSmrg	  func_append linknames " $link"
81069c9ff80cSmrg	done
81071f0ac6a5Smrg
81089c9ff80cSmrg	# Use standard objects if they are pic
81096fae4e5dSmrg	test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
81109c9ff80cSmrg	test "X$libobjs" = "X " && libobjs=
81111f0ac6a5Smrg
81129c9ff80cSmrg	delfiles=
81139c9ff80cSmrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
81149c9ff80cSmrg	  $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
81159c9ff80cSmrg	  export_symbols="$output_objdir/$libname.uexp"
81166fae4e5dSmrg	  func_append delfiles " $export_symbols"
81179c9ff80cSmrg	fi
81181f0ac6a5Smrg
81199c9ff80cSmrg	orig_export_symbols=
81209c9ff80cSmrg	case $host_os in
81219c9ff80cSmrg	cygwin* | mingw* | cegcc*)
81229c9ff80cSmrg	  if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
81239c9ff80cSmrg	    # exporting using user supplied symfile
81249c9ff80cSmrg	    if test "x`$SED 1q $export_symbols`" != xEXPORTS; then
81259c9ff80cSmrg	      # and it's NOT already a .def file. Must figure out
81269c9ff80cSmrg	      # which of the given symbols are data symbols and tag
81279c9ff80cSmrg	      # them as such. So, trigger use of export_symbols_cmds.
81289c9ff80cSmrg	      # export_symbols gets reassigned inside the "prepare
81299c9ff80cSmrg	      # the list of exported symbols" if statement, so the
81309c9ff80cSmrg	      # include_expsyms logic still works.
81319c9ff80cSmrg	      orig_export_symbols="$export_symbols"
81329c9ff80cSmrg	      export_symbols=
81339c9ff80cSmrg	      always_export_symbols=yes
81349c9ff80cSmrg	    fi
81359c9ff80cSmrg	  fi
81369c9ff80cSmrg	  ;;
81379c9ff80cSmrg	esac
81381f0ac6a5Smrg
81399c9ff80cSmrg	# Prepare the list of exported symbols
81409c9ff80cSmrg	if test -z "$export_symbols"; then
81419c9ff80cSmrg	  if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
81429c9ff80cSmrg	    func_verbose "generating symbol list for \`$libname.la'"
81439c9ff80cSmrg	    export_symbols="$output_objdir/$libname.exp"
81449c9ff80cSmrg	    $opt_dry_run || $RM $export_symbols
81459c9ff80cSmrg	    cmds=$export_symbols_cmds
81469c9ff80cSmrg	    save_ifs="$IFS"; IFS='~'
81476fae4e5dSmrg	    for cmd1 in $cmds; do
81489c9ff80cSmrg	      IFS="$save_ifs"
81496fae4e5dSmrg	      # Take the normal branch if the nm_file_list_spec branch
81506fae4e5dSmrg	      # doesn't work or if tool conversion is not needed.
81516fae4e5dSmrg	      case $nm_file_list_spec~$to_tool_file_cmd in
81526fae4e5dSmrg		*~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*)
81536fae4e5dSmrg		  try_normal_branch=yes
81546fae4e5dSmrg		  eval cmd=\"$cmd1\"
81556fae4e5dSmrg		  func_len " $cmd"
81566fae4e5dSmrg		  len=$func_len_result
81576fae4e5dSmrg		  ;;
81586fae4e5dSmrg		*)
81596fae4e5dSmrg		  try_normal_branch=no
81606fae4e5dSmrg		  ;;
81616fae4e5dSmrg	      esac
81626fae4e5dSmrg	      if test "$try_normal_branch" = yes \
81636fae4e5dSmrg		 && { test "$len" -lt "$max_cmd_len" \
81646fae4e5dSmrg		      || test "$max_cmd_len" -le -1; }
81656fae4e5dSmrg	      then
81666fae4e5dSmrg		func_show_eval "$cmd" 'exit $?'
81676fae4e5dSmrg		skipped_export=false
81686fae4e5dSmrg	      elif test -n "$nm_file_list_spec"; then
81696fae4e5dSmrg		func_basename "$output"
81706fae4e5dSmrg		output_la=$func_basename_result
81716fae4e5dSmrg		save_libobjs=$libobjs
81726fae4e5dSmrg		save_output=$output
81736fae4e5dSmrg		output=${output_objdir}/${output_la}.nm
81746fae4e5dSmrg		func_to_tool_file "$output"
81756fae4e5dSmrg		libobjs=$nm_file_list_spec$func_to_tool_file_result
81766fae4e5dSmrg		func_append delfiles " $output"
81776fae4e5dSmrg		func_verbose "creating $NM input file list: $output"
81786fae4e5dSmrg		for obj in $save_libobjs; do
81796fae4e5dSmrg		  func_to_tool_file "$obj"
81806fae4e5dSmrg		  $ECHO "$func_to_tool_file_result"
81816fae4e5dSmrg		done > "$output"
81826fae4e5dSmrg		eval cmd=\"$cmd1\"
81839c9ff80cSmrg		func_show_eval "$cmd" 'exit $?'
81846fae4e5dSmrg		output=$save_output
81856fae4e5dSmrg		libobjs=$save_libobjs
81869c9ff80cSmrg		skipped_export=false
81879c9ff80cSmrg	      else
81889c9ff80cSmrg		# The command line is too long to execute in one step.
81899c9ff80cSmrg		func_verbose "using reloadable object file for export list..."
81909c9ff80cSmrg		skipped_export=:
81919c9ff80cSmrg		# Break out early, otherwise skipped_export may be
81929c9ff80cSmrg		# set to false by a later but shorter cmd.
81939c9ff80cSmrg		break
81949c9ff80cSmrg	      fi
81959c9ff80cSmrg	    done
81969c9ff80cSmrg	    IFS="$save_ifs"
81979c9ff80cSmrg	    if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then
81989c9ff80cSmrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
81999c9ff80cSmrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
82009c9ff80cSmrg	    fi
82019c9ff80cSmrg	  fi
82021f0ac6a5Smrg	fi
82031f0ac6a5Smrg
82049c9ff80cSmrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
82059c9ff80cSmrg	  tmp_export_symbols="$export_symbols"
82069c9ff80cSmrg	  test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
82076fae4e5dSmrg	  $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
82089c9ff80cSmrg	fi
82091f0ac6a5Smrg
82109c9ff80cSmrg	if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then
82119c9ff80cSmrg	  # The given exports_symbols file has to be filtered, so filter it.
82129c9ff80cSmrg	  func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
82139c9ff80cSmrg	  # FIXME: $output_objdir/$libname.filter potentially contains lots of
82149c9ff80cSmrg	  # 's' commands which not all seds can handle. GNU sed should be fine
82159c9ff80cSmrg	  # though. Also, the filter scales superlinearly with the number of
82169c9ff80cSmrg	  # global variables. join(1) would be nice here, but unfortunately
82179c9ff80cSmrg	  # isn't a blessed tool.
82189c9ff80cSmrg	  $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
82196fae4e5dSmrg	  func_append delfiles " $export_symbols $output_objdir/$libname.filter"
82209c9ff80cSmrg	  export_symbols=$output_objdir/$libname.def
82219c9ff80cSmrg	  $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
82229c9ff80cSmrg	fi
82231f0ac6a5Smrg
82249c9ff80cSmrg	tmp_deplibs=
82259c9ff80cSmrg	for test_deplib in $deplibs; do
82269c9ff80cSmrg	  case " $convenience " in
82279c9ff80cSmrg	  *" $test_deplib "*) ;;
82289c9ff80cSmrg	  *)
82296fae4e5dSmrg	    func_append tmp_deplibs " $test_deplib"
82309c9ff80cSmrg	    ;;
82319c9ff80cSmrg	  esac
82329c9ff80cSmrg	done
82339c9ff80cSmrg	deplibs="$tmp_deplibs"
82341f0ac6a5Smrg
82359c9ff80cSmrg	if test -n "$convenience"; then
82369c9ff80cSmrg	  if test -n "$whole_archive_flag_spec" &&
82379c9ff80cSmrg	    test "$compiler_needs_object" = yes &&
82389c9ff80cSmrg	    test -z "$libobjs"; then
82399c9ff80cSmrg	    # extract the archives, so we have objects to list.
82409c9ff80cSmrg	    # TODO: could optimize this to just extract one archive.
82419c9ff80cSmrg	    whole_archive_flag_spec=
82429c9ff80cSmrg	  fi
82439c9ff80cSmrg	  if test -n "$whole_archive_flag_spec"; then
82449c9ff80cSmrg	    save_libobjs=$libobjs
82459c9ff80cSmrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
82469c9ff80cSmrg	    test "X$libobjs" = "X " && libobjs=
82479c9ff80cSmrg	  else
82489c9ff80cSmrg	    gentop="$output_objdir/${outputname}x"
82496fae4e5dSmrg	    func_append generated " $gentop"
82501f0ac6a5Smrg
82519c9ff80cSmrg	    func_extract_archives $gentop $convenience
82526fae4e5dSmrg	    func_append libobjs " $func_extract_archives_result"
82539c9ff80cSmrg	    test "X$libobjs" = "X " && libobjs=
82549c9ff80cSmrg	  fi
82551f0ac6a5Smrg	fi
82561f0ac6a5Smrg
82579c9ff80cSmrg	if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
82589c9ff80cSmrg	  eval flag=\"$thread_safe_flag_spec\"
82596fae4e5dSmrg	  func_append linker_flags " $flag"
82601f0ac6a5Smrg	fi
82611f0ac6a5Smrg
82629c9ff80cSmrg	# Make a backup of the uninstalled library when relinking
82636fae4e5dSmrg	if test "$opt_mode" = relink; then
82649c9ff80cSmrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
82659c9ff80cSmrg	fi
82661f0ac6a5Smrg
82679c9ff80cSmrg	# Do each of the archive commands.
82689c9ff80cSmrg	if test "$module" = yes && test -n "$module_cmds" ; then
82699c9ff80cSmrg	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
82709c9ff80cSmrg	    eval test_cmds=\"$module_expsym_cmds\"
82719c9ff80cSmrg	    cmds=$module_expsym_cmds
82729c9ff80cSmrg	  else
82739c9ff80cSmrg	    eval test_cmds=\"$module_cmds\"
82749c9ff80cSmrg	    cmds=$module_cmds
82759c9ff80cSmrg	  fi
82761f0ac6a5Smrg	else
82779c9ff80cSmrg	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
82789c9ff80cSmrg	    eval test_cmds=\"$archive_expsym_cmds\"
82799c9ff80cSmrg	    cmds=$archive_expsym_cmds
82809c9ff80cSmrg	  else
82819c9ff80cSmrg	    eval test_cmds=\"$archive_cmds\"
82829c9ff80cSmrg	    cmds=$archive_cmds
82839c9ff80cSmrg	  fi
82841f0ac6a5Smrg	fi
82851f0ac6a5Smrg
82869c9ff80cSmrg	if test "X$skipped_export" != "X:" &&
82879c9ff80cSmrg	   func_len " $test_cmds" &&
82889c9ff80cSmrg	   len=$func_len_result &&
82899c9ff80cSmrg	   test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
82909c9ff80cSmrg	  :
82919c9ff80cSmrg	else
82929c9ff80cSmrg	  # The command line is too long to link in one step, link piecewise
82939c9ff80cSmrg	  # or, if using GNU ld and skipped_export is not :, use a linker
82949c9ff80cSmrg	  # script.
82951f0ac6a5Smrg
82969c9ff80cSmrg	  # Save the value of $output and $libobjs because we want to
82979c9ff80cSmrg	  # use them later.  If we have whole_archive_flag_spec, we
82989c9ff80cSmrg	  # want to use save_libobjs as it was before
82999c9ff80cSmrg	  # whole_archive_flag_spec was expanded, because we can't
83009c9ff80cSmrg	  # assume the linker understands whole_archive_flag_spec.
83019c9ff80cSmrg	  # This may have to be revisited, in case too many
83029c9ff80cSmrg	  # convenience libraries get linked in and end up exceeding
83039c9ff80cSmrg	  # the spec.
83049c9ff80cSmrg	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
83059c9ff80cSmrg	    save_libobjs=$libobjs
83069c9ff80cSmrg	  fi
83079c9ff80cSmrg	  save_output=$output
83086fae4e5dSmrg	  func_basename "$output"
83096fae4e5dSmrg	  output_la=$func_basename_result
83101f0ac6a5Smrg
83119c9ff80cSmrg	  # Clear the reloadable object creation command queue and
83129c9ff80cSmrg	  # initialize k to one.
83139c9ff80cSmrg	  test_cmds=
83149c9ff80cSmrg	  concat_cmds=
83159c9ff80cSmrg	  objlist=
83169c9ff80cSmrg	  last_robj=
83179c9ff80cSmrg	  k=1
83189c9ff80cSmrg
83199c9ff80cSmrg	  if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
83209c9ff80cSmrg	    output=${output_objdir}/${output_la}.lnkscript
83219c9ff80cSmrg	    func_verbose "creating GNU ld script: $output"
83226fae4e5dSmrg	    echo 'INPUT (' > $output
83239c9ff80cSmrg	    for obj in $save_libobjs
83241f0ac6a5Smrg	    do
83256fae4e5dSmrg	      func_to_tool_file "$obj"
83266fae4e5dSmrg	      $ECHO "$func_to_tool_file_result" >> $output
83279c9ff80cSmrg	    done
83286fae4e5dSmrg	    echo ')' >> $output
83296fae4e5dSmrg	    func_append delfiles " $output"
83306fae4e5dSmrg	    func_to_tool_file "$output"
83316fae4e5dSmrg	    output=$func_to_tool_file_result
83329c9ff80cSmrg	  elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then
83339c9ff80cSmrg	    output=${output_objdir}/${output_la}.lnk
83349c9ff80cSmrg	    func_verbose "creating linker input file list: $output"
83359c9ff80cSmrg	    : > $output
83369c9ff80cSmrg	    set x $save_libobjs
83379c9ff80cSmrg	    shift
83389c9ff80cSmrg	    firstobj=
83399c9ff80cSmrg	    if test "$compiler_needs_object" = yes; then
83409c9ff80cSmrg	      firstobj="$1 "
83419c9ff80cSmrg	      shift
83429c9ff80cSmrg	    fi
83439c9ff80cSmrg	    for obj
83449c9ff80cSmrg	    do
83456fae4e5dSmrg	      func_to_tool_file "$obj"
83466fae4e5dSmrg	      $ECHO "$func_to_tool_file_result" >> $output
83479c9ff80cSmrg	    done
83486fae4e5dSmrg	    func_append delfiles " $output"
83496fae4e5dSmrg	    func_to_tool_file "$output"
83506fae4e5dSmrg	    output=$firstobj\"$file_list_spec$func_to_tool_file_result\"
83519c9ff80cSmrg	  else
83529c9ff80cSmrg	    if test -n "$save_libobjs"; then
83539c9ff80cSmrg	      func_verbose "creating reloadable object files..."
83549c9ff80cSmrg	      output=$output_objdir/$output_la-${k}.$objext
83559c9ff80cSmrg	      eval test_cmds=\"$reload_cmds\"
83569c9ff80cSmrg	      func_len " $test_cmds"
83579c9ff80cSmrg	      len0=$func_len_result
83589c9ff80cSmrg	      len=$len0
83599c9ff80cSmrg
83609c9ff80cSmrg	      # Loop over the list of objects to be linked.
83619c9ff80cSmrg	      for obj in $save_libobjs
83629c9ff80cSmrg	      do
83639c9ff80cSmrg		func_len " $obj"
83649c9ff80cSmrg		func_arith $len + $func_len_result
83659c9ff80cSmrg		len=$func_arith_result
83669c9ff80cSmrg		if test "X$objlist" = X ||
83679c9ff80cSmrg		   test "$len" -lt "$max_cmd_len"; then
83689c9ff80cSmrg		  func_append objlist " $obj"
83699c9ff80cSmrg		else
83709c9ff80cSmrg		  # The command $test_cmds is almost too long, add a
83719c9ff80cSmrg		  # command to the queue.
83729c9ff80cSmrg		  if test "$k" -eq 1 ; then
83739c9ff80cSmrg		    # The first file doesn't have a previous command to add.
83746fae4e5dSmrg		    reload_objs=$objlist
83756fae4e5dSmrg		    eval concat_cmds=\"$reload_cmds\"
83769c9ff80cSmrg		  else
83779c9ff80cSmrg		    # All subsequent reloadable object files will link in
83789c9ff80cSmrg		    # the last one created.
83796fae4e5dSmrg		    reload_objs="$objlist $last_robj"
83806fae4e5dSmrg		    eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
83819c9ff80cSmrg		  fi
83829c9ff80cSmrg		  last_robj=$output_objdir/$output_la-${k}.$objext
83839c9ff80cSmrg		  func_arith $k + 1
83849c9ff80cSmrg		  k=$func_arith_result
83859c9ff80cSmrg		  output=$output_objdir/$output_la-${k}.$objext
83866fae4e5dSmrg		  objlist=" $obj"
83879c9ff80cSmrg		  func_len " $last_robj"
83889c9ff80cSmrg		  func_arith $len0 + $func_len_result
83899c9ff80cSmrg		  len=$func_arith_result
83909c9ff80cSmrg		fi
83919c9ff80cSmrg	      done
83929c9ff80cSmrg	      # Handle the remaining objects by creating one last
83939c9ff80cSmrg	      # reloadable object file.  All subsequent reloadable object
83949c9ff80cSmrg	      # files will link in the last one created.
83959c9ff80cSmrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
83966fae4e5dSmrg	      reload_objs="$objlist $last_robj"
83976fae4e5dSmrg	      eval concat_cmds=\"\${concat_cmds}$reload_cmds\"
83989c9ff80cSmrg	      if test -n "$last_robj"; then
83999c9ff80cSmrg	        eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\"
84009c9ff80cSmrg	      fi
84016fae4e5dSmrg	      func_append delfiles " $output"
84021f0ac6a5Smrg
84039c9ff80cSmrg	    else
84049c9ff80cSmrg	      output=
84059c9ff80cSmrg	    fi
84061f0ac6a5Smrg
84079c9ff80cSmrg	    if ${skipped_export-false}; then
84089c9ff80cSmrg	      func_verbose "generating symbol list for \`$libname.la'"
84099c9ff80cSmrg	      export_symbols="$output_objdir/$libname.exp"
84109c9ff80cSmrg	      $opt_dry_run || $RM $export_symbols
84119c9ff80cSmrg	      libobjs=$output
84129c9ff80cSmrg	      # Append the command to create the export file.
84139c9ff80cSmrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
84149c9ff80cSmrg	      eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
84159c9ff80cSmrg	      if test -n "$last_robj"; then
84169c9ff80cSmrg		eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
84179c9ff80cSmrg	      fi
84181f0ac6a5Smrg	    fi
84191f0ac6a5Smrg
84209c9ff80cSmrg	    test -n "$save_libobjs" &&
84219c9ff80cSmrg	      func_verbose "creating a temporary reloadable object file: $output"
84221f0ac6a5Smrg
84239c9ff80cSmrg	    # Loop through the commands generated above and execute them.
84249c9ff80cSmrg	    save_ifs="$IFS"; IFS='~'
84259c9ff80cSmrg	    for cmd in $concat_cmds; do
84269c9ff80cSmrg	      IFS="$save_ifs"
84279c9ff80cSmrg	      $opt_silent || {
84289c9ff80cSmrg		  func_quote_for_expand "$cmd"
84299c9ff80cSmrg		  eval "func_echo $func_quote_for_expand_result"
84309c9ff80cSmrg	      }
84319c9ff80cSmrg	      $opt_dry_run || eval "$cmd" || {
84329c9ff80cSmrg		lt_exit=$?
84339c9ff80cSmrg
84349c9ff80cSmrg		# Restore the uninstalled library and exit
84356fae4e5dSmrg		if test "$opt_mode" = relink; then
84369c9ff80cSmrg		  ( cd "$output_objdir" && \
84379c9ff80cSmrg		    $RM "${realname}T" && \
84389c9ff80cSmrg		    $MV "${realname}U" "$realname" )
84399c9ff80cSmrg		fi
84401f0ac6a5Smrg
84419c9ff80cSmrg		exit $lt_exit
84429c9ff80cSmrg	      }
84439c9ff80cSmrg	    done
84449c9ff80cSmrg	    IFS="$save_ifs"
84451f0ac6a5Smrg
84469c9ff80cSmrg	    if test -n "$export_symbols_regex" && ${skipped_export-false}; then
84479c9ff80cSmrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
84489c9ff80cSmrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
84491f0ac6a5Smrg	    fi
84501f0ac6a5Smrg	  fi
84511f0ac6a5Smrg
84529c9ff80cSmrg          if ${skipped_export-false}; then
84539c9ff80cSmrg	    if test -n "$export_symbols" && test -n "$include_expsyms"; then
84549c9ff80cSmrg	      tmp_export_symbols="$export_symbols"
84559c9ff80cSmrg	      test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
84566fae4e5dSmrg	      $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
84579c9ff80cSmrg	    fi
84581f0ac6a5Smrg
84599c9ff80cSmrg	    if test -n "$orig_export_symbols"; then
84609c9ff80cSmrg	      # The given exports_symbols file has to be filtered, so filter it.
84619c9ff80cSmrg	      func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
84629c9ff80cSmrg	      # FIXME: $output_objdir/$libname.filter potentially contains lots of
84639c9ff80cSmrg	      # 's' commands which not all seds can handle. GNU sed should be fine
84649c9ff80cSmrg	      # though. Also, the filter scales superlinearly with the number of
84659c9ff80cSmrg	      # global variables. join(1) would be nice here, but unfortunately
84669c9ff80cSmrg	      # isn't a blessed tool.
84679c9ff80cSmrg	      $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
84686fae4e5dSmrg	      func_append delfiles " $export_symbols $output_objdir/$libname.filter"
84699c9ff80cSmrg	      export_symbols=$output_objdir/$libname.def
84709c9ff80cSmrg	      $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
84719c9ff80cSmrg	    fi
84729c9ff80cSmrg	  fi
84731f0ac6a5Smrg
84749c9ff80cSmrg	  libobjs=$output
84759c9ff80cSmrg	  # Restore the value of output.
84769c9ff80cSmrg	  output=$save_output
84771f0ac6a5Smrg
84789c9ff80cSmrg	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
84799c9ff80cSmrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
84809c9ff80cSmrg	    test "X$libobjs" = "X " && libobjs=
84819c9ff80cSmrg	  fi
84829c9ff80cSmrg	  # Expand the library linking commands again to reset the
84839c9ff80cSmrg	  # value of $libobjs for piecewise linking.
84841f0ac6a5Smrg
84859c9ff80cSmrg	  # Do each of the archive commands.
84869c9ff80cSmrg	  if test "$module" = yes && test -n "$module_cmds" ; then
84879c9ff80cSmrg	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
84889c9ff80cSmrg	      cmds=$module_expsym_cmds
84899c9ff80cSmrg	    else
84909c9ff80cSmrg	      cmds=$module_cmds
84911f0ac6a5Smrg	    fi
84921f0ac6a5Smrg	  else
84939c9ff80cSmrg	    if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
84949c9ff80cSmrg	      cmds=$archive_expsym_cmds
84959c9ff80cSmrg	    else
84969c9ff80cSmrg	      cmds=$archive_cmds
84979c9ff80cSmrg	    fi
84981f0ac6a5Smrg	  fi
84999c9ff80cSmrg	fi
85001f0ac6a5Smrg
85019c9ff80cSmrg	if test -n "$delfiles"; then
85029c9ff80cSmrg	  # Append the command to remove temporary files to $cmds.
85039c9ff80cSmrg	  eval cmds=\"\$cmds~\$RM $delfiles\"
85049c9ff80cSmrg	fi
85051f0ac6a5Smrg
85069c9ff80cSmrg	# Add any objects from preloaded convenience libraries
85079c9ff80cSmrg	if test -n "$dlprefiles"; then
85089c9ff80cSmrg	  gentop="$output_objdir/${outputname}x"
85096fae4e5dSmrg	  func_append generated " $gentop"
85101f0ac6a5Smrg
85119c9ff80cSmrg	  func_extract_archives $gentop $dlprefiles
85126fae4e5dSmrg	  func_append libobjs " $func_extract_archives_result"
85139c9ff80cSmrg	  test "X$libobjs" = "X " && libobjs=
85149c9ff80cSmrg	fi
85151f0ac6a5Smrg
85169c9ff80cSmrg	save_ifs="$IFS"; IFS='~'
85179c9ff80cSmrg	for cmd in $cmds; do
85189c9ff80cSmrg	  IFS="$save_ifs"
85199c9ff80cSmrg	  eval cmd=\"$cmd\"
85209c9ff80cSmrg	  $opt_silent || {
85219c9ff80cSmrg	    func_quote_for_expand "$cmd"
85229c9ff80cSmrg	    eval "func_echo $func_quote_for_expand_result"
85239c9ff80cSmrg	  }
85249c9ff80cSmrg	  $opt_dry_run || eval "$cmd" || {
85259c9ff80cSmrg	    lt_exit=$?
85261f0ac6a5Smrg
85279c9ff80cSmrg	    # Restore the uninstalled library and exit
85286fae4e5dSmrg	    if test "$opt_mode" = relink; then
85299c9ff80cSmrg	      ( cd "$output_objdir" && \
85309c9ff80cSmrg	        $RM "${realname}T" && \
85319c9ff80cSmrg		$MV "${realname}U" "$realname" )
85329c9ff80cSmrg	    fi
85331f0ac6a5Smrg
85349c9ff80cSmrg	    exit $lt_exit
85359c9ff80cSmrg	  }
85369c9ff80cSmrg	done
85379c9ff80cSmrg	IFS="$save_ifs"
85381f0ac6a5Smrg
85399c9ff80cSmrg	# Restore the uninstalled library and exit
85406fae4e5dSmrg	if test "$opt_mode" = relink; then
85419c9ff80cSmrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
85421f0ac6a5Smrg
85439c9ff80cSmrg	  if test -n "$convenience"; then
85449c9ff80cSmrg	    if test -z "$whole_archive_flag_spec"; then
85459c9ff80cSmrg	      func_show_eval '${RM}r "$gentop"'
85469c9ff80cSmrg	    fi
85479c9ff80cSmrg	  fi
85481f0ac6a5Smrg
85499c9ff80cSmrg	  exit $EXIT_SUCCESS
85509c9ff80cSmrg	fi
85519c9ff80cSmrg
85529c9ff80cSmrg	# Create links to the real library.
85539c9ff80cSmrg	for linkname in $linknames; do
85549c9ff80cSmrg	  if test "$realname" != "$linkname"; then
85559c9ff80cSmrg	    func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
85561f0ac6a5Smrg	  fi
85571f0ac6a5Smrg	done
85581f0ac6a5Smrg
85599c9ff80cSmrg	# If -module or -export-dynamic was specified, set the dlname.
85609c9ff80cSmrg	if test "$module" = yes || test "$export_dynamic" = yes; then
85619c9ff80cSmrg	  # On all known operating systems, these are identical.
85629c9ff80cSmrg	  dlname="$soname"
85639c9ff80cSmrg	fi
85649c9ff80cSmrg      fi
85651f0ac6a5Smrg      ;;
85661f0ac6a5Smrg
85679c9ff80cSmrg    obj)
85689c9ff80cSmrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
85699c9ff80cSmrg	func_warning "\`-dlopen' is ignored for objects"
85709c9ff80cSmrg      fi
85711f0ac6a5Smrg
85729c9ff80cSmrg      case " $deplibs" in
85739c9ff80cSmrg      *\ -l* | *\ -L*)
85749c9ff80cSmrg	func_warning "\`-l' and \`-L' are ignored for objects" ;;
85751f0ac6a5Smrg      esac
85761f0ac6a5Smrg
85779c9ff80cSmrg      test -n "$rpath" && \
85789c9ff80cSmrg	func_warning "\`-rpath' is ignored for objects"
85799c9ff80cSmrg
85809c9ff80cSmrg      test -n "$xrpath" && \
85819c9ff80cSmrg	func_warning "\`-R' is ignored for objects"
85821f0ac6a5Smrg
85839c9ff80cSmrg      test -n "$vinfo" && \
85849c9ff80cSmrg	func_warning "\`-version-info' is ignored for objects"
85851f0ac6a5Smrg
85869c9ff80cSmrg      test -n "$release" && \
85879c9ff80cSmrg	func_warning "\`-release' is ignored for objects"
85889c9ff80cSmrg
85899c9ff80cSmrg      case $output in
85909c9ff80cSmrg      *.lo)
85919c9ff80cSmrg	test -n "$objs$old_deplibs" && \
85929c9ff80cSmrg	  func_fatal_error "cannot build library object \`$output' from non-libtool objects"
85939c9ff80cSmrg
85949c9ff80cSmrg	libobj=$output
85959c9ff80cSmrg	func_lo2o "$libobj"
85969c9ff80cSmrg	obj=$func_lo2o_result
85971f0ac6a5Smrg	;;
85981f0ac6a5Smrg      *)
85999c9ff80cSmrg	libobj=
86009c9ff80cSmrg	obj="$output"
86011f0ac6a5Smrg	;;
86021f0ac6a5Smrg      esac
86031f0ac6a5Smrg
86049c9ff80cSmrg      # Delete the old objects.
86059c9ff80cSmrg      $opt_dry_run || $RM $obj $libobj
86061f0ac6a5Smrg
86079c9ff80cSmrg      # Objects from convenience libraries.  This assumes
86089c9ff80cSmrg      # single-version convenience libraries.  Whenever we create
86099c9ff80cSmrg      # different ones for PIC/non-PIC, this we'll have to duplicate
86109c9ff80cSmrg      # the extraction.
86119c9ff80cSmrg      reload_conv_objs=
86129c9ff80cSmrg      gentop=
86139c9ff80cSmrg      # reload_cmds runs $LD directly, so let us get rid of
86149c9ff80cSmrg      # -Wl from whole_archive_flag_spec and hope we can get by with
86159c9ff80cSmrg      # turning comma into space..
86169c9ff80cSmrg      wl=
86171f0ac6a5Smrg
86189c9ff80cSmrg      if test -n "$convenience"; then
86199c9ff80cSmrg	if test -n "$whole_archive_flag_spec"; then
86209c9ff80cSmrg	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
86216fae4e5dSmrg	  reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
86229c9ff80cSmrg	else
86239c9ff80cSmrg	  gentop="$output_objdir/${obj}x"
86246fae4e5dSmrg	  func_append generated " $gentop"
86251f0ac6a5Smrg
86269c9ff80cSmrg	  func_extract_archives $gentop $convenience
86279c9ff80cSmrg	  reload_conv_objs="$reload_objs $func_extract_archives_result"
86289c9ff80cSmrg	fi
86291f0ac6a5Smrg      fi
86301f0ac6a5Smrg
86316fae4e5dSmrg      # If we're not building shared, we need to use non_pic_objs
86326fae4e5dSmrg      test "$build_libtool_libs" != yes && libobjs="$non_pic_objects"
86336fae4e5dSmrg
86349c9ff80cSmrg      # Create the old-style object.
86356fae4e5dSmrg      reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
86361f0ac6a5Smrg
86379c9ff80cSmrg      output="$obj"
86389c9ff80cSmrg      func_execute_cmds "$reload_cmds" 'exit $?'
86391f0ac6a5Smrg
86409c9ff80cSmrg      # Exit if we aren't doing a library object file.
86419c9ff80cSmrg      if test -z "$libobj"; then
86429c9ff80cSmrg	if test -n "$gentop"; then
86439c9ff80cSmrg	  func_show_eval '${RM}r "$gentop"'
86449c9ff80cSmrg	fi
86459c9ff80cSmrg
86469c9ff80cSmrg	exit $EXIT_SUCCESS
86471f0ac6a5Smrg      fi
86489c9ff80cSmrg
86499c9ff80cSmrg      if test "$build_libtool_libs" != yes; then
86509c9ff80cSmrg	if test -n "$gentop"; then
86519c9ff80cSmrg	  func_show_eval '${RM}r "$gentop"'
86529c9ff80cSmrg	fi
86539c9ff80cSmrg
86549c9ff80cSmrg	# Create an invalid libtool object if no PIC, so that we don't
86559c9ff80cSmrg	# accidentally link it into a program.
86569c9ff80cSmrg	# $show "echo timestamp > $libobj"
86579c9ff80cSmrg	# $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
86589c9ff80cSmrg	exit $EXIT_SUCCESS
86599c9ff80cSmrg      fi
86609c9ff80cSmrg
86619c9ff80cSmrg      if test -n "$pic_flag" || test "$pic_mode" != default; then
86629c9ff80cSmrg	# Only do commands if we really have different PIC objects.
86639c9ff80cSmrg	reload_objs="$libobjs $reload_conv_objs"
86649c9ff80cSmrg	output="$libobj"
86659c9ff80cSmrg	func_execute_cmds "$reload_cmds" 'exit $?'
86669c9ff80cSmrg      fi
86679c9ff80cSmrg
86689c9ff80cSmrg      if test -n "$gentop"; then
86699c9ff80cSmrg	func_show_eval '${RM}r "$gentop"'
86709c9ff80cSmrg      fi
86719c9ff80cSmrg
86729c9ff80cSmrg      exit $EXIT_SUCCESS
86731f0ac6a5Smrg      ;;
86741f0ac6a5Smrg
86759c9ff80cSmrg    prog)
86769c9ff80cSmrg      case $host in
86779c9ff80cSmrg	*cygwin*) func_stripname '' '.exe' "$output"
86789c9ff80cSmrg	          output=$func_stripname_result.exe;;
86799c9ff80cSmrg      esac
86809c9ff80cSmrg      test -n "$vinfo" && \
86819c9ff80cSmrg	func_warning "\`-version-info' is ignored for programs"
86821f0ac6a5Smrg
86839c9ff80cSmrg      test -n "$release" && \
86849c9ff80cSmrg	func_warning "\`-release' is ignored for programs"
86851f0ac6a5Smrg
86869c9ff80cSmrg      test "$preload" = yes \
86879c9ff80cSmrg        && test "$dlopen_support" = unknown \
86889c9ff80cSmrg	&& test "$dlopen_self" = unknown \
86899c9ff80cSmrg	&& test "$dlopen_self_static" = unknown && \
86909c9ff80cSmrg	  func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support."
86919c9ff80cSmrg
86929c9ff80cSmrg      case $host in
86939c9ff80cSmrg      *-*-rhapsody* | *-*-darwin1.[012])
86949c9ff80cSmrg	# On Rhapsody replace the C library is the System framework
86956fae4e5dSmrg	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
86966fae4e5dSmrg	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
86971f0ac6a5Smrg	;;
86989c9ff80cSmrg      esac
86991f0ac6a5Smrg
87009c9ff80cSmrg      case $host in
87019c9ff80cSmrg      *-*-darwin*)
87029c9ff80cSmrg	# Don't allow lazy linking, it breaks C++ global constructors
87039c9ff80cSmrg	# But is supposedly fixed on 10.4 or later (yay!).
87049c9ff80cSmrg	if test "$tagname" = CXX ; then
87059c9ff80cSmrg	  case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
87069c9ff80cSmrg	    10.[0123])
87076fae4e5dSmrg	      func_append compile_command " ${wl}-bind_at_load"
87086fae4e5dSmrg	      func_append finalize_command " ${wl}-bind_at_load"
87099c9ff80cSmrg	    ;;
87109c9ff80cSmrg	  esac
87111f0ac6a5Smrg	fi
87129c9ff80cSmrg	# Time to change all our "foo.ltframework" stuff back to "-framework foo"
87136fae4e5dSmrg	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
87146fae4e5dSmrg	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
87159c9ff80cSmrg	;;
87169c9ff80cSmrg      esac
87171f0ac6a5Smrg
87181f0ac6a5Smrg
87199c9ff80cSmrg      # move library search paths that coincide with paths to not yet
87209c9ff80cSmrg      # installed libraries to the beginning of the library search list
87219c9ff80cSmrg      new_libs=
87229c9ff80cSmrg      for path in $notinst_path; do
87239c9ff80cSmrg	case " $new_libs " in
87249c9ff80cSmrg	*" -L$path/$objdir "*) ;;
87259c9ff80cSmrg	*)
87269c9ff80cSmrg	  case " $compile_deplibs " in
87279c9ff80cSmrg	  *" -L$path/$objdir "*)
87286fae4e5dSmrg	    func_append new_libs " -L$path/$objdir" ;;
87291f0ac6a5Smrg	  esac
87309c9ff80cSmrg	  ;;
87319c9ff80cSmrg	esac
87329c9ff80cSmrg      done
87339c9ff80cSmrg      for deplib in $compile_deplibs; do
87349c9ff80cSmrg	case $deplib in
87359c9ff80cSmrg	-L*)
87369c9ff80cSmrg	  case " $new_libs " in
87379c9ff80cSmrg	  *" $deplib "*) ;;
87386fae4e5dSmrg	  *) func_append new_libs " $deplib" ;;
87391f0ac6a5Smrg	  esac
87409c9ff80cSmrg	  ;;
87416fae4e5dSmrg	*) func_append new_libs " $deplib" ;;
87429c9ff80cSmrg	esac
87439c9ff80cSmrg      done
87449c9ff80cSmrg      compile_deplibs="$new_libs"
87451f0ac6a5Smrg
87461f0ac6a5Smrg
87476fae4e5dSmrg      func_append compile_command " $compile_deplibs"
87486fae4e5dSmrg      func_append finalize_command " $finalize_deplibs"
87491f0ac6a5Smrg
87509c9ff80cSmrg      if test -n "$rpath$xrpath"; then
87519c9ff80cSmrg	# If the user specified any rpath flags, then add them.
87529c9ff80cSmrg	for libdir in $rpath $xrpath; do
87539c9ff80cSmrg	  # This is the magic to use -rpath.
87549c9ff80cSmrg	  case "$finalize_rpath " in
87559c9ff80cSmrg	  *" $libdir "*) ;;
87566fae4e5dSmrg	  *) func_append finalize_rpath " $libdir" ;;
87579c9ff80cSmrg	  esac
87589c9ff80cSmrg	done
87599c9ff80cSmrg      fi
87601f0ac6a5Smrg
87619c9ff80cSmrg      # Now hardcode the library paths
87629c9ff80cSmrg      rpath=
87639c9ff80cSmrg      hardcode_libdirs=
87649c9ff80cSmrg      for libdir in $compile_rpath $finalize_rpath; do
87659c9ff80cSmrg	if test -n "$hardcode_libdir_flag_spec"; then
87669c9ff80cSmrg	  if test -n "$hardcode_libdir_separator"; then
87679c9ff80cSmrg	    if test -z "$hardcode_libdirs"; then
87689c9ff80cSmrg	      hardcode_libdirs="$libdir"
87699c9ff80cSmrg	    else
87709c9ff80cSmrg	      # Just accumulate the unique libdirs.
87719c9ff80cSmrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
87729c9ff80cSmrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
87739c9ff80cSmrg		;;
87749c9ff80cSmrg	      *)
87756fae4e5dSmrg		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
87769c9ff80cSmrg		;;
87779c9ff80cSmrg	      esac
87789c9ff80cSmrg	    fi
87791f0ac6a5Smrg	  else
87809c9ff80cSmrg	    eval flag=\"$hardcode_libdir_flag_spec\"
87816fae4e5dSmrg	    func_append rpath " $flag"
87821f0ac6a5Smrg	  fi
87839c9ff80cSmrg	elif test -n "$runpath_var"; then
87849c9ff80cSmrg	  case "$perm_rpath " in
87859c9ff80cSmrg	  *" $libdir "*) ;;
87866fae4e5dSmrg	  *) func_append perm_rpath " $libdir" ;;
87879c9ff80cSmrg	  esac
87889c9ff80cSmrg	fi
87899c9ff80cSmrg	case $host in
87909c9ff80cSmrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
87919c9ff80cSmrg	  testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'`
87929c9ff80cSmrg	  case :$dllsearchpath: in
87939c9ff80cSmrg	  *":$libdir:"*) ;;
87949c9ff80cSmrg	  ::) dllsearchpath=$libdir;;
87956fae4e5dSmrg	  *) func_append dllsearchpath ":$libdir";;
87969c9ff80cSmrg	  esac
87979c9ff80cSmrg	  case :$dllsearchpath: in
87989c9ff80cSmrg	  *":$testbindir:"*) ;;
87999c9ff80cSmrg	  ::) dllsearchpath=$testbindir;;
88006fae4e5dSmrg	  *) func_append dllsearchpath ":$testbindir";;
88019c9ff80cSmrg	  esac
88029c9ff80cSmrg	  ;;
88039c9ff80cSmrg	esac
88049c9ff80cSmrg      done
88059c9ff80cSmrg      # Substitute the hardcoded libdirs into the rpath.
88069c9ff80cSmrg      if test -n "$hardcode_libdir_separator" &&
88079c9ff80cSmrg	 test -n "$hardcode_libdirs"; then
88089c9ff80cSmrg	libdir="$hardcode_libdirs"
88099c9ff80cSmrg	eval rpath=\" $hardcode_libdir_flag_spec\"
88109c9ff80cSmrg      fi
88119c9ff80cSmrg      compile_rpath="$rpath"
88121f0ac6a5Smrg
88139c9ff80cSmrg      rpath=
88149c9ff80cSmrg      hardcode_libdirs=
88159c9ff80cSmrg      for libdir in $finalize_rpath; do
88169c9ff80cSmrg	if test -n "$hardcode_libdir_flag_spec"; then
88179c9ff80cSmrg	  if test -n "$hardcode_libdir_separator"; then
88189c9ff80cSmrg	    if test -z "$hardcode_libdirs"; then
88199c9ff80cSmrg	      hardcode_libdirs="$libdir"
88209c9ff80cSmrg	    else
88219c9ff80cSmrg	      # Just accumulate the unique libdirs.
88229c9ff80cSmrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
88239c9ff80cSmrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
88249c9ff80cSmrg		;;
88259c9ff80cSmrg	      *)
88266fae4e5dSmrg		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
88279c9ff80cSmrg		;;
88289c9ff80cSmrg	      esac
88299c9ff80cSmrg	    fi
88301f0ac6a5Smrg	  else
88319c9ff80cSmrg	    eval flag=\"$hardcode_libdir_flag_spec\"
88326fae4e5dSmrg	    func_append rpath " $flag"
88331f0ac6a5Smrg	  fi
88349c9ff80cSmrg	elif test -n "$runpath_var"; then
88359c9ff80cSmrg	  case "$finalize_perm_rpath " in
88369c9ff80cSmrg	  *" $libdir "*) ;;
88376fae4e5dSmrg	  *) func_append finalize_perm_rpath " $libdir" ;;
88389c9ff80cSmrg	  esac
88391f0ac6a5Smrg	fi
88409c9ff80cSmrg      done
88419c9ff80cSmrg      # Substitute the hardcoded libdirs into the rpath.
88429c9ff80cSmrg      if test -n "$hardcode_libdir_separator" &&
88439c9ff80cSmrg	 test -n "$hardcode_libdirs"; then
88449c9ff80cSmrg	libdir="$hardcode_libdirs"
88459c9ff80cSmrg	eval rpath=\" $hardcode_libdir_flag_spec\"
88469c9ff80cSmrg      fi
88479c9ff80cSmrg      finalize_rpath="$rpath"
88481f0ac6a5Smrg
88499c9ff80cSmrg      if test -n "$libobjs" && test "$build_old_libs" = yes; then
88509c9ff80cSmrg	# Transform all the library objects into standard objects.
88516fae4e5dSmrg	compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
88526fae4e5dSmrg	finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
88539c9ff80cSmrg      fi
88541f0ac6a5Smrg
88559c9ff80cSmrg      func_generate_dlsyms "$outputname" "@PROGRAM@" "no"
88561f0ac6a5Smrg
88579c9ff80cSmrg      # template prelinking step
88589c9ff80cSmrg      if test -n "$prelink_cmds"; then
88599c9ff80cSmrg	func_execute_cmds "$prelink_cmds" 'exit $?'
88609c9ff80cSmrg      fi
88611f0ac6a5Smrg
88629c9ff80cSmrg      wrappers_required=yes
88639c9ff80cSmrg      case $host in
88646fae4e5dSmrg      *cegcc* | *mingw32ce*)
88656fae4e5dSmrg        # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
88666fae4e5dSmrg        wrappers_required=no
88676fae4e5dSmrg        ;;
88689c9ff80cSmrg      *cygwin* | *mingw* )
88699c9ff80cSmrg        if test "$build_libtool_libs" != yes; then
88709c9ff80cSmrg          wrappers_required=no
88719c9ff80cSmrg        fi
88729c9ff80cSmrg        ;;
88739c9ff80cSmrg      *)
88749c9ff80cSmrg        if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
88759c9ff80cSmrg          wrappers_required=no
88769c9ff80cSmrg        fi
88779c9ff80cSmrg        ;;
88789c9ff80cSmrg      esac
88799c9ff80cSmrg      if test "$wrappers_required" = no; then
88809c9ff80cSmrg	# Replace the output file specification.
88816fae4e5dSmrg	compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
88829c9ff80cSmrg	link_command="$compile_command$compile_rpath"
88831f0ac6a5Smrg
88849c9ff80cSmrg	# We have no uninstalled library dependencies, so finalize right now.
88859c9ff80cSmrg	exit_status=0
88869c9ff80cSmrg	func_show_eval "$link_command" 'exit_status=$?'
88871f0ac6a5Smrg
88886fae4e5dSmrg	if test -n "$postlink_cmds"; then
88896fae4e5dSmrg	  func_to_tool_file "$output"
88906fae4e5dSmrg	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
88916fae4e5dSmrg	  func_execute_cmds "$postlink_cmds" 'exit $?'
88926fae4e5dSmrg	fi
88936fae4e5dSmrg
88949c9ff80cSmrg	# Delete the generated files.
88959c9ff80cSmrg	if test -f "$output_objdir/${outputname}S.${objext}"; then
88969c9ff80cSmrg	  func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"'
88971f0ac6a5Smrg	fi
88981f0ac6a5Smrg
88999c9ff80cSmrg	exit $exit_status
89009c9ff80cSmrg      fi
89011f0ac6a5Smrg
89029c9ff80cSmrg      if test -n "$compile_shlibpath$finalize_shlibpath"; then
89039c9ff80cSmrg	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
89049c9ff80cSmrg      fi
89059c9ff80cSmrg      if test -n "$finalize_shlibpath"; then
89069c9ff80cSmrg	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
89079c9ff80cSmrg      fi
89081f0ac6a5Smrg
89099c9ff80cSmrg      compile_var=
89109c9ff80cSmrg      finalize_var=
89119c9ff80cSmrg      if test -n "$runpath_var"; then
89129c9ff80cSmrg	if test -n "$perm_rpath"; then
89139c9ff80cSmrg	  # We should set the runpath_var.
89149c9ff80cSmrg	  rpath=
89159c9ff80cSmrg	  for dir in $perm_rpath; do
89166fae4e5dSmrg	    func_append rpath "$dir:"
89179c9ff80cSmrg	  done
89189c9ff80cSmrg	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
89191f0ac6a5Smrg	fi
89209c9ff80cSmrg	if test -n "$finalize_perm_rpath"; then
89219c9ff80cSmrg	  # We should set the runpath_var.
89229c9ff80cSmrg	  rpath=
89239c9ff80cSmrg	  for dir in $finalize_perm_rpath; do
89246fae4e5dSmrg	    func_append rpath "$dir:"
89259c9ff80cSmrg	  done
89269c9ff80cSmrg	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
89271f0ac6a5Smrg	fi
89289c9ff80cSmrg      fi
89291f0ac6a5Smrg
89309c9ff80cSmrg      if test "$no_install" = yes; then
89319c9ff80cSmrg	# We don't need to create a wrapper script.
89329c9ff80cSmrg	link_command="$compile_var$compile_command$compile_rpath"
89339c9ff80cSmrg	# Replace the output file specification.
89346fae4e5dSmrg	link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
89359c9ff80cSmrg	# Delete the old output file.
89369c9ff80cSmrg	$opt_dry_run || $RM $output
89379c9ff80cSmrg	# Link the executable and exit
89389c9ff80cSmrg	func_show_eval "$link_command" 'exit $?'
89396fae4e5dSmrg
89406fae4e5dSmrg	if test -n "$postlink_cmds"; then
89416fae4e5dSmrg	  func_to_tool_file "$output"
89426fae4e5dSmrg	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
89436fae4e5dSmrg	  func_execute_cmds "$postlink_cmds" 'exit $?'
89446fae4e5dSmrg	fi
89456fae4e5dSmrg
89461f0ac6a5Smrg	exit $EXIT_SUCCESS
89479c9ff80cSmrg      fi
89481f0ac6a5Smrg
89499c9ff80cSmrg      if test "$hardcode_action" = relink; then
89509c9ff80cSmrg	# Fast installation is not supported
89519c9ff80cSmrg	link_command="$compile_var$compile_command$compile_rpath"
89529c9ff80cSmrg	relink_command="$finalize_var$finalize_command$finalize_rpath"
89539c9ff80cSmrg
89549c9ff80cSmrg	func_warning "this platform does not like uninstalled shared libraries"
89559c9ff80cSmrg	func_warning "\`$output' will be relinked during installation"
89569c9ff80cSmrg      else
89579c9ff80cSmrg	if test "$fast_install" != no; then
89589c9ff80cSmrg	  link_command="$finalize_var$compile_command$finalize_rpath"
89599c9ff80cSmrg	  if test "$fast_install" = yes; then
89606fae4e5dSmrg	    relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
89619c9ff80cSmrg	  else
89629c9ff80cSmrg	    # fast_install is set to needless
89639c9ff80cSmrg	    relink_command=
89649c9ff80cSmrg	  fi
89651f0ac6a5Smrg	else
89669c9ff80cSmrg	  link_command="$compile_var$compile_command$compile_rpath"
89679c9ff80cSmrg	  relink_command="$finalize_var$finalize_command$finalize_rpath"
89681f0ac6a5Smrg	fi
89699c9ff80cSmrg      fi
89701f0ac6a5Smrg
89719c9ff80cSmrg      # Replace the output file specification.
89726fae4e5dSmrg      link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
89731f0ac6a5Smrg
89749c9ff80cSmrg      # Delete the old output files.
89759c9ff80cSmrg      $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
89761f0ac6a5Smrg
89779c9ff80cSmrg      func_show_eval "$link_command" 'exit $?'
89781f0ac6a5Smrg
89796fae4e5dSmrg      if test -n "$postlink_cmds"; then
89806fae4e5dSmrg	func_to_tool_file "$output_objdir/$outputname"
89816fae4e5dSmrg	postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
89826fae4e5dSmrg	func_execute_cmds "$postlink_cmds" 'exit $?'
89836fae4e5dSmrg      fi
89846fae4e5dSmrg
89859c9ff80cSmrg      # Now create the wrapper script.
89869c9ff80cSmrg      func_verbose "creating $output"
89871f0ac6a5Smrg
89889c9ff80cSmrg      # Quote the relink command for shipping.
89899c9ff80cSmrg      if test -n "$relink_command"; then
89909c9ff80cSmrg	# Preserve any variables that may affect compiler behavior
89919c9ff80cSmrg	for var in $variables_saved_for_relink; do
89929c9ff80cSmrg	  if eval test -z \"\${$var+set}\"; then
89939c9ff80cSmrg	    relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
89949c9ff80cSmrg	  elif eval var_value=\$$var; test -z "$var_value"; then
89959c9ff80cSmrg	    relink_command="$var=; export $var; $relink_command"
89961f0ac6a5Smrg	  else
89979c9ff80cSmrg	    func_quote_for_eval "$var_value"
89989c9ff80cSmrg	    relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
89991f0ac6a5Smrg	  fi
90009c9ff80cSmrg	done
90019c9ff80cSmrg	relink_command="(cd `pwd`; $relink_command)"
90026fae4e5dSmrg	relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
90039c9ff80cSmrg      fi
90049c9ff80cSmrg
90059c9ff80cSmrg      # Only actually do things if not in dry run mode.
90069c9ff80cSmrg      $opt_dry_run || {
90079c9ff80cSmrg	# win32 will think the script is a binary if it has
90089c9ff80cSmrg	# a .exe suffix, so we strip it off here.
90099c9ff80cSmrg	case $output in
90109c9ff80cSmrg	  *.exe) func_stripname '' '.exe' "$output"
90119c9ff80cSmrg	         output=$func_stripname_result ;;
90129c9ff80cSmrg	esac
90139c9ff80cSmrg	# test for cygwin because mv fails w/o .exe extensions
90149c9ff80cSmrg	case $host in
90159c9ff80cSmrg	  *cygwin*)
90169c9ff80cSmrg	    exeext=.exe
90179c9ff80cSmrg	    func_stripname '' '.exe' "$outputname"
90189c9ff80cSmrg	    outputname=$func_stripname_result ;;
90199c9ff80cSmrg	  *) exeext= ;;
90201f0ac6a5Smrg	esac
90219c9ff80cSmrg	case $host in
90229c9ff80cSmrg	  *cygwin* | *mingw* )
90239c9ff80cSmrg	    func_dirname_and_basename "$output" "" "."
90249c9ff80cSmrg	    output_name=$func_basename_result
90259c9ff80cSmrg	    output_path=$func_dirname_result
90269c9ff80cSmrg	    cwrappersource="$output_path/$objdir/lt-$output_name.c"
90279c9ff80cSmrg	    cwrapper="$output_path/$output_name.exe"
90289c9ff80cSmrg	    $RM $cwrappersource $cwrapper
90299c9ff80cSmrg	    trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
90309c9ff80cSmrg
90319c9ff80cSmrg	    func_emit_cwrapperexe_src > $cwrappersource
90329c9ff80cSmrg
90339c9ff80cSmrg	    # The wrapper executable is built using the $host compiler,
90349c9ff80cSmrg	    # because it contains $host paths and files. If cross-
90359c9ff80cSmrg	    # compiling, it, like the target executable, must be
90369c9ff80cSmrg	    # executed on the $host or under an emulation environment.
90379c9ff80cSmrg	    $opt_dry_run || {
90389c9ff80cSmrg	      $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
90399c9ff80cSmrg	      $STRIP $cwrapper
90409c9ff80cSmrg	    }
90411f0ac6a5Smrg
90429c9ff80cSmrg	    # Now, create the wrapper script for func_source use:
90439c9ff80cSmrg	    func_ltwrapper_scriptname $cwrapper
90449c9ff80cSmrg	    $RM $func_ltwrapper_scriptname_result
90459c9ff80cSmrg	    trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
90469c9ff80cSmrg	    $opt_dry_run || {
90479c9ff80cSmrg	      # note: this script will not be executed, so do not chmod.
90489c9ff80cSmrg	      if test "x$build" = "x$host" ; then
90499c9ff80cSmrg		$cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
90509c9ff80cSmrg	      else
90519c9ff80cSmrg		func_emit_wrapper no > $func_ltwrapper_scriptname_result
90529c9ff80cSmrg	      fi
90539c9ff80cSmrg	    }
90549c9ff80cSmrg	  ;;
90559c9ff80cSmrg	  * )
90569c9ff80cSmrg	    $RM $output
90579c9ff80cSmrg	    trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
90581f0ac6a5Smrg
90599c9ff80cSmrg	    func_emit_wrapper no > $output
90609c9ff80cSmrg	    chmod +x $output
90619c9ff80cSmrg	  ;;
90629c9ff80cSmrg	esac
90639c9ff80cSmrg      }
90649c9ff80cSmrg      exit $EXIT_SUCCESS
90659c9ff80cSmrg      ;;
90669c9ff80cSmrg    esac
90671f0ac6a5Smrg
90689c9ff80cSmrg    # See if we need to build an old-fashioned archive.
90699c9ff80cSmrg    for oldlib in $oldlibs; do
90701f0ac6a5Smrg
90719c9ff80cSmrg      if test "$build_libtool_libs" = convenience; then
90729c9ff80cSmrg	oldobjs="$libobjs_save $symfileobj"
90739c9ff80cSmrg	addlibs="$convenience"
90749c9ff80cSmrg	build_libtool_libs=no
90759c9ff80cSmrg      else
90769c9ff80cSmrg	if test "$build_libtool_libs" = module; then
90779c9ff80cSmrg	  oldobjs="$libobjs_save"
90789c9ff80cSmrg	  build_libtool_libs=no
90799c9ff80cSmrg	else
90809c9ff80cSmrg	  oldobjs="$old_deplibs $non_pic_objects"
90819c9ff80cSmrg	  if test "$preload" = yes && test -f "$symfileobj"; then
90826fae4e5dSmrg	    func_append oldobjs " $symfileobj"
90839c9ff80cSmrg	  fi
90849c9ff80cSmrg	fi
90859c9ff80cSmrg	addlibs="$old_convenience"
90861f0ac6a5Smrg      fi
90871f0ac6a5Smrg
90889c9ff80cSmrg      if test -n "$addlibs"; then
90899c9ff80cSmrg	gentop="$output_objdir/${outputname}x"
90906fae4e5dSmrg	func_append generated " $gentop"
90911f0ac6a5Smrg
90929c9ff80cSmrg	func_extract_archives $gentop $addlibs
90936fae4e5dSmrg	func_append oldobjs " $func_extract_archives_result"
90949c9ff80cSmrg      fi
90951f0ac6a5Smrg
90969c9ff80cSmrg      # Do each command in the archive commands.
90979c9ff80cSmrg      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
90989c9ff80cSmrg	cmds=$old_archive_from_new_cmds
90999c9ff80cSmrg      else
91001f0ac6a5Smrg
91019c9ff80cSmrg	# Add any objects from preloaded convenience libraries
91029c9ff80cSmrg	if test -n "$dlprefiles"; then
91039c9ff80cSmrg	  gentop="$output_objdir/${outputname}x"
91046fae4e5dSmrg	  func_append generated " $gentop"
91051f0ac6a5Smrg
91069c9ff80cSmrg	  func_extract_archives $gentop $dlprefiles
91076fae4e5dSmrg	  func_append oldobjs " $func_extract_archives_result"
91089c9ff80cSmrg	fi
91091f0ac6a5Smrg
91109c9ff80cSmrg	# POSIX demands no paths to be encoded in archives.  We have
91119c9ff80cSmrg	# to avoid creating archives with duplicate basenames if we
91129c9ff80cSmrg	# might have to extract them afterwards, e.g., when creating a
91139c9ff80cSmrg	# static archive out of a convenience library, or when linking
91149c9ff80cSmrg	# the entirety of a libtool archive into another (currently
91159c9ff80cSmrg	# not supported by libtool).
91169c9ff80cSmrg	if (for obj in $oldobjs
91179c9ff80cSmrg	    do
91189c9ff80cSmrg	      func_basename "$obj"
91199c9ff80cSmrg	      $ECHO "$func_basename_result"
91209c9ff80cSmrg	    done | sort | sort -uc >/dev/null 2>&1); then
91219c9ff80cSmrg	  :
91229c9ff80cSmrg	else
91236fae4e5dSmrg	  echo "copying selected object files to avoid basename conflicts..."
91249c9ff80cSmrg	  gentop="$output_objdir/${outputname}x"
91256fae4e5dSmrg	  func_append generated " $gentop"
91269c9ff80cSmrg	  func_mkdir_p "$gentop"
91279c9ff80cSmrg	  save_oldobjs=$oldobjs
91289c9ff80cSmrg	  oldobjs=
91299c9ff80cSmrg	  counter=1
91309c9ff80cSmrg	  for obj in $save_oldobjs
91319c9ff80cSmrg	  do
91329c9ff80cSmrg	    func_basename "$obj"
91339c9ff80cSmrg	    objbase="$func_basename_result"
91349c9ff80cSmrg	    case " $oldobjs " in
91359c9ff80cSmrg	    " ") oldobjs=$obj ;;
91369c9ff80cSmrg	    *[\ /]"$objbase "*)
91379c9ff80cSmrg	      while :; do
91389c9ff80cSmrg		# Make sure we don't pick an alternate name that also
91399c9ff80cSmrg		# overlaps.
91409c9ff80cSmrg		newobj=lt$counter-$objbase
91419c9ff80cSmrg		func_arith $counter + 1
91429c9ff80cSmrg		counter=$func_arith_result
91439c9ff80cSmrg		case " $oldobjs " in
91449c9ff80cSmrg		*[\ /]"$newobj "*) ;;
91459c9ff80cSmrg		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
91469c9ff80cSmrg		esac
91479c9ff80cSmrg	      done
91489c9ff80cSmrg	      func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
91496fae4e5dSmrg	      func_append oldobjs " $gentop/$newobj"
91509c9ff80cSmrg	      ;;
91516fae4e5dSmrg	    *) func_append oldobjs " $obj" ;;
91529c9ff80cSmrg	    esac
91531f0ac6a5Smrg	  done
91541f0ac6a5Smrg	fi
91559c9ff80cSmrg	eval cmds=\"$old_archive_cmds\"
91561f0ac6a5Smrg
91579c9ff80cSmrg	func_len " $cmds"
91589c9ff80cSmrg	len=$func_len_result
91599c9ff80cSmrg	if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
91609c9ff80cSmrg	  cmds=$old_archive_cmds
91616fae4e5dSmrg	elif test -n "$archiver_list_spec"; then
91626fae4e5dSmrg	  func_verbose "using command file archive linking..."
91636fae4e5dSmrg	  for obj in $oldobjs
91646fae4e5dSmrg	  do
91656fae4e5dSmrg	    func_to_tool_file "$obj"
91666fae4e5dSmrg	    $ECHO "$func_to_tool_file_result"
91676fae4e5dSmrg	  done > $output_objdir/$libname.libcmd
91686fae4e5dSmrg	  func_to_tool_file "$output_objdir/$libname.libcmd"
91696fae4e5dSmrg	  oldobjs=" $archiver_list_spec$func_to_tool_file_result"
91706fae4e5dSmrg	  cmds=$old_archive_cmds
91719c9ff80cSmrg	else
91729c9ff80cSmrg	  # the command line is too long to link in one step, link in parts
91739c9ff80cSmrg	  func_verbose "using piecewise archive linking..."
91749c9ff80cSmrg	  save_RANLIB=$RANLIB
91759c9ff80cSmrg	  RANLIB=:
91769c9ff80cSmrg	  objlist=
91779c9ff80cSmrg	  concat_cmds=
91789c9ff80cSmrg	  save_oldobjs=$oldobjs
91799c9ff80cSmrg	  oldobjs=
91809c9ff80cSmrg	  # Is there a better way of finding the last object in the list?
91819c9ff80cSmrg	  for obj in $save_oldobjs
91829c9ff80cSmrg	  do
91839c9ff80cSmrg	    last_oldobj=$obj
91849c9ff80cSmrg	  done
91859c9ff80cSmrg	  eval test_cmds=\"$old_archive_cmds\"
91869c9ff80cSmrg	  func_len " $test_cmds"
91879c9ff80cSmrg	  len0=$func_len_result
91889c9ff80cSmrg	  len=$len0
91899c9ff80cSmrg	  for obj in $save_oldobjs
91909c9ff80cSmrg	  do
91919c9ff80cSmrg	    func_len " $obj"
91929c9ff80cSmrg	    func_arith $len + $func_len_result
91939c9ff80cSmrg	    len=$func_arith_result
91949c9ff80cSmrg	    func_append objlist " $obj"
91959c9ff80cSmrg	    if test "$len" -lt "$max_cmd_len"; then
91969c9ff80cSmrg	      :
91979c9ff80cSmrg	    else
91989c9ff80cSmrg	      # the above command should be used before it gets too long
91999c9ff80cSmrg	      oldobjs=$objlist
92009c9ff80cSmrg	      if test "$obj" = "$last_oldobj" ; then
92019c9ff80cSmrg		RANLIB=$save_RANLIB
92029c9ff80cSmrg	      fi
92039c9ff80cSmrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
92049c9ff80cSmrg	      eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
92059c9ff80cSmrg	      objlist=
92069c9ff80cSmrg	      len=$len0
92079c9ff80cSmrg	    fi
92089c9ff80cSmrg	  done
92099c9ff80cSmrg	  RANLIB=$save_RANLIB
92109c9ff80cSmrg	  oldobjs=$objlist
92119c9ff80cSmrg	  if test "X$oldobjs" = "X" ; then
92129c9ff80cSmrg	    eval cmds=\"\$concat_cmds\"
92139c9ff80cSmrg	  else
92149c9ff80cSmrg	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
92159c9ff80cSmrg	  fi
92169c9ff80cSmrg	fi
92179c9ff80cSmrg      fi
92189c9ff80cSmrg      func_execute_cmds "$cmds" 'exit $?'
92191f0ac6a5Smrg    done
92201f0ac6a5Smrg
92219c9ff80cSmrg    test -n "$generated" && \
92229c9ff80cSmrg      func_show_eval "${RM}r$generated"
92231f0ac6a5Smrg
92249c9ff80cSmrg    # Now create the libtool archive.
92259c9ff80cSmrg    case $output in
92269c9ff80cSmrg    *.la)
92279c9ff80cSmrg      old_library=
92289c9ff80cSmrg      test "$build_old_libs" = yes && old_library="$libname.$libext"
92299c9ff80cSmrg      func_verbose "creating $output"
92301f0ac6a5Smrg
92319c9ff80cSmrg      # Preserve any variables that may affect compiler behavior
92329c9ff80cSmrg      for var in $variables_saved_for_relink; do
92339c9ff80cSmrg	if eval test -z \"\${$var+set}\"; then
92349c9ff80cSmrg	  relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
92359c9ff80cSmrg	elif eval var_value=\$$var; test -z "$var_value"; then
92369c9ff80cSmrg	  relink_command="$var=; export $var; $relink_command"
92371f0ac6a5Smrg	else
92389c9ff80cSmrg	  func_quote_for_eval "$var_value"
92399c9ff80cSmrg	  relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
92401f0ac6a5Smrg	fi
92419c9ff80cSmrg      done
92429c9ff80cSmrg      # Quote the link command for shipping.
92439c9ff80cSmrg      relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
92446fae4e5dSmrg      relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
92459c9ff80cSmrg      if test "$hardcode_automatic" = yes ; then
92469c9ff80cSmrg	relink_command=
92479c9ff80cSmrg      fi
92481f0ac6a5Smrg
92499c9ff80cSmrg      # Only create the output if not a dry run.
92509c9ff80cSmrg      $opt_dry_run || {
92519c9ff80cSmrg	for installed in no yes; do
92529c9ff80cSmrg	  if test "$installed" = yes; then
92539c9ff80cSmrg	    if test -z "$install_libdir"; then
92549c9ff80cSmrg	      break
92559c9ff80cSmrg	    fi
92569c9ff80cSmrg	    output="$output_objdir/$outputname"i
92579c9ff80cSmrg	    # Replace all uninstalled libtool libraries with the installed ones
92589c9ff80cSmrg	    newdependency_libs=
92599c9ff80cSmrg	    for deplib in $dependency_libs; do
92609c9ff80cSmrg	      case $deplib in
92619c9ff80cSmrg	      *.la)
92629c9ff80cSmrg		func_basename "$deplib"
92639c9ff80cSmrg		name="$func_basename_result"
92649c9ff80cSmrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
92659c9ff80cSmrg		test -z "$libdir" && \
92669c9ff80cSmrg		  func_fatal_error "\`$deplib' is not a valid libtool archive"
92676fae4e5dSmrg		func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"
92686fae4e5dSmrg		;;
92696fae4e5dSmrg	      -L*)
92706fae4e5dSmrg		func_stripname -L '' "$deplib"
92716fae4e5dSmrg		func_replace_sysroot "$func_stripname_result"
92726fae4e5dSmrg		func_append newdependency_libs " -L$func_replace_sysroot_result"
92739c9ff80cSmrg		;;
92746fae4e5dSmrg	      -R*)
92756fae4e5dSmrg		func_stripname -R '' "$deplib"
92766fae4e5dSmrg		func_replace_sysroot "$func_stripname_result"
92776fae4e5dSmrg		func_append newdependency_libs " -R$func_replace_sysroot_result"
92786fae4e5dSmrg		;;
92796fae4e5dSmrg	      *) func_append newdependency_libs " $deplib" ;;
92809c9ff80cSmrg	      esac
92819c9ff80cSmrg	    done
92829c9ff80cSmrg	    dependency_libs="$newdependency_libs"
92839c9ff80cSmrg	    newdlfiles=
92849c9ff80cSmrg
92859c9ff80cSmrg	    for lib in $dlfiles; do
92869c9ff80cSmrg	      case $lib in
92879c9ff80cSmrg	      *.la)
92889c9ff80cSmrg	        func_basename "$lib"
92899c9ff80cSmrg		name="$func_basename_result"
92909c9ff80cSmrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
92919c9ff80cSmrg		test -z "$libdir" && \
92929c9ff80cSmrg		  func_fatal_error "\`$lib' is not a valid libtool archive"
92936fae4e5dSmrg		func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name"
92949c9ff80cSmrg		;;
92956fae4e5dSmrg	      *) func_append newdlfiles " $lib" ;;
92969c9ff80cSmrg	      esac
92979c9ff80cSmrg	    done
92989c9ff80cSmrg	    dlfiles="$newdlfiles"
92999c9ff80cSmrg	    newdlprefiles=
93009c9ff80cSmrg	    for lib in $dlprefiles; do
93019c9ff80cSmrg	      case $lib in
93029c9ff80cSmrg	      *.la)
93039c9ff80cSmrg		# Only pass preopened files to the pseudo-archive (for
93049c9ff80cSmrg		# eventual linking with the app. that links it) if we
93059c9ff80cSmrg		# didn't already link the preopened objects directly into
93069c9ff80cSmrg		# the library:
93079c9ff80cSmrg		func_basename "$lib"
93089c9ff80cSmrg		name="$func_basename_result"
93099c9ff80cSmrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
93109c9ff80cSmrg		test -z "$libdir" && \
93119c9ff80cSmrg		  func_fatal_error "\`$lib' is not a valid libtool archive"
93126fae4e5dSmrg		func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name"
93139c9ff80cSmrg		;;
93149c9ff80cSmrg	      esac
93159c9ff80cSmrg	    done
93169c9ff80cSmrg	    dlprefiles="$newdlprefiles"
93179c9ff80cSmrg	  else
93189c9ff80cSmrg	    newdlfiles=
93199c9ff80cSmrg	    for lib in $dlfiles; do
93209c9ff80cSmrg	      case $lib in
93219c9ff80cSmrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
93229c9ff80cSmrg		*) abs=`pwd`"/$lib" ;;
93239c9ff80cSmrg	      esac
93246fae4e5dSmrg	      func_append newdlfiles " $abs"
93259c9ff80cSmrg	    done
93269c9ff80cSmrg	    dlfiles="$newdlfiles"
93279c9ff80cSmrg	    newdlprefiles=
93289c9ff80cSmrg	    for lib in $dlprefiles; do
93299c9ff80cSmrg	      case $lib in
93309c9ff80cSmrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
93319c9ff80cSmrg		*) abs=`pwd`"/$lib" ;;
93329c9ff80cSmrg	      esac
93336fae4e5dSmrg	      func_append newdlprefiles " $abs"
93349c9ff80cSmrg	    done
93359c9ff80cSmrg	    dlprefiles="$newdlprefiles"
93369c9ff80cSmrg	  fi
93379c9ff80cSmrg	  $RM $output
93389c9ff80cSmrg	  # place dlname in correct position for cygwin
93396fae4e5dSmrg	  # In fact, it would be nice if we could use this code for all target
93406fae4e5dSmrg	  # systems that can't hard-code library paths into their executables
93416fae4e5dSmrg	  # and that have no shared library path variable independent of PATH,
93426fae4e5dSmrg	  # but it turns out we can't easily determine that from inspecting
93436fae4e5dSmrg	  # libtool variables, so we have to hard-code the OSs to which it
93446fae4e5dSmrg	  # applies here; at the moment, that means platforms that use the PE
93456fae4e5dSmrg	  # object format with DLL files.  See the long comment at the top of
93466fae4e5dSmrg	  # tests/bindir.at for full details.
93479c9ff80cSmrg	  tdlname=$dlname
93489c9ff80cSmrg	  case $host,$output,$installed,$module,$dlname in
93496fae4e5dSmrg	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
93506fae4e5dSmrg	      # If a -bindir argument was supplied, place the dll there.
93516fae4e5dSmrg	      if test "x$bindir" != x ;
93526fae4e5dSmrg	      then
93536fae4e5dSmrg		func_relative_path "$install_libdir" "$bindir"
93546fae4e5dSmrg		tdlname=$func_relative_path_result$dlname
93556fae4e5dSmrg	      else
93566fae4e5dSmrg		# Otherwise fall back on heuristic.
93576fae4e5dSmrg		tdlname=../bin/$dlname
93586fae4e5dSmrg	      fi
93596fae4e5dSmrg	      ;;
93609c9ff80cSmrg	  esac
93619c9ff80cSmrg	  $ECHO > $output "\
93629c9ff80cSmrg# $outputname - a libtool library file
93639c9ff80cSmrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
93649c9ff80cSmrg#
93659c9ff80cSmrg# Please DO NOT delete this file!
93669c9ff80cSmrg# It is necessary for linking the library.
93671f0ac6a5Smrg
93689c9ff80cSmrg# The name that we can dlopen(3).
93699c9ff80cSmrgdlname='$tdlname'
93701f0ac6a5Smrg
93719c9ff80cSmrg# Names of this library.
93729c9ff80cSmrglibrary_names='$library_names'
93731f0ac6a5Smrg
93749c9ff80cSmrg# The name of the static archive.
93759c9ff80cSmrgold_library='$old_library'
93761f0ac6a5Smrg
93779c9ff80cSmrg# Linker flags that can not go in dependency_libs.
93789c9ff80cSmrginherited_linker_flags='$new_inherited_linker_flags'
93791f0ac6a5Smrg
93809c9ff80cSmrg# Libraries that this one depends upon.
93819c9ff80cSmrgdependency_libs='$dependency_libs'
93821f0ac6a5Smrg
93839c9ff80cSmrg# Names of additional weak libraries provided by this library
93849c9ff80cSmrgweak_library_names='$weak_libs'
93851f0ac6a5Smrg
93869c9ff80cSmrg# Version information for $libname.
93879c9ff80cSmrgcurrent=$current
93889c9ff80cSmrgage=$age
93899c9ff80cSmrgrevision=$revision
93901f0ac6a5Smrg
93919c9ff80cSmrg# Is this an already installed library?
93929c9ff80cSmrginstalled=$installed
93931f0ac6a5Smrg
93949c9ff80cSmrg# Should we warn about portability when linking against -modules?
93959c9ff80cSmrgshouldnotlink=$module
93961f0ac6a5Smrg
93979c9ff80cSmrg# Files to dlopen/dlpreopen
93989c9ff80cSmrgdlopen='$dlfiles'
93999c9ff80cSmrgdlpreopen='$dlprefiles'
94001f0ac6a5Smrg
94019c9ff80cSmrg# Directory that this library needs to be installed in:
94029c9ff80cSmrglibdir='$install_libdir'"
94039c9ff80cSmrg	  if test "$installed" = no && test "$need_relink" = yes; then
94049c9ff80cSmrg	    $ECHO >> $output "\
94059c9ff80cSmrgrelink_command=\"$relink_command\""
94069c9ff80cSmrg	  fi
94079c9ff80cSmrg	done
94089c9ff80cSmrg      }
94091f0ac6a5Smrg
94109c9ff80cSmrg      # Do a symbolic link so that the libtool archive can be found in
94119c9ff80cSmrg      # LD_LIBRARY_PATH before the program is installed.
94129c9ff80cSmrg      func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
94139c9ff80cSmrg      ;;
94149c9ff80cSmrg    esac
94159c9ff80cSmrg    exit $EXIT_SUCCESS
94169c9ff80cSmrg}
94171f0ac6a5Smrg
94186fae4e5dSmrg{ test "$opt_mode" = link || test "$opt_mode" = relink; } &&
94199c9ff80cSmrg    func_mode_link ${1+"$@"}
94201f0ac6a5Smrg
94211f0ac6a5Smrg
94229c9ff80cSmrg# func_mode_uninstall arg...
94239c9ff80cSmrgfunc_mode_uninstall ()
94249c9ff80cSmrg{
94259c9ff80cSmrg    $opt_debug
94269c9ff80cSmrg    RM="$nonopt"
94271f0ac6a5Smrg    files=
94281f0ac6a5Smrg    rmforce=
94291f0ac6a5Smrg    exit_status=0
94301f0ac6a5Smrg
94311f0ac6a5Smrg    # This variable tells wrapper scripts just to set variables rather
94321f0ac6a5Smrg    # than running their programs.
94331f0ac6a5Smrg    libtool_install_magic="$magic"
94341f0ac6a5Smrg
94351f0ac6a5Smrg    for arg
94361f0ac6a5Smrg    do
94371f0ac6a5Smrg      case $arg in
94386fae4e5dSmrg      -f) func_append RM " $arg"; rmforce=yes ;;
94396fae4e5dSmrg      -*) func_append RM " $arg" ;;
94406fae4e5dSmrg      *) func_append files " $arg" ;;
94411f0ac6a5Smrg      esac
94421f0ac6a5Smrg    done
94431f0ac6a5Smrg
94449c9ff80cSmrg    test -z "$RM" && \
94459c9ff80cSmrg      func_fatal_help "you must specify an RM program"
94461f0ac6a5Smrg
94471f0ac6a5Smrg    rmdirs=
94481f0ac6a5Smrg
94491f0ac6a5Smrg    for file in $files; do
94509c9ff80cSmrg      func_dirname "$file" "" "."
94519c9ff80cSmrg      dir="$func_dirname_result"
94529c9ff80cSmrg      if test "X$dir" = X.; then
94536fae4e5dSmrg	odir="$objdir"
94541f0ac6a5Smrg      else
94556fae4e5dSmrg	odir="$dir/$objdir"
94561f0ac6a5Smrg      fi
94579c9ff80cSmrg      func_basename "$file"
94589c9ff80cSmrg      name="$func_basename_result"
94596fae4e5dSmrg      test "$opt_mode" = uninstall && odir="$dir"
94601f0ac6a5Smrg
94616fae4e5dSmrg      # Remember odir for removal later, being careful to avoid duplicates
94626fae4e5dSmrg      if test "$opt_mode" = clean; then
94631f0ac6a5Smrg	case " $rmdirs " in
94646fae4e5dSmrg	  *" $odir "*) ;;
94656fae4e5dSmrg	  *) func_append rmdirs " $odir" ;;
94661f0ac6a5Smrg	esac
94671f0ac6a5Smrg      fi
94681f0ac6a5Smrg
94691f0ac6a5Smrg      # Don't error if the file doesn't exist and rm -f was used.
94709c9ff80cSmrg      if { test -L "$file"; } >/dev/null 2>&1 ||
94719c9ff80cSmrg	 { test -h "$file"; } >/dev/null 2>&1 ||
94729c9ff80cSmrg	 test -f "$file"; then
94731f0ac6a5Smrg	:
94741f0ac6a5Smrg      elif test -d "$file"; then
94751f0ac6a5Smrg	exit_status=1
94761f0ac6a5Smrg	continue
94771f0ac6a5Smrg      elif test "$rmforce" = yes; then
94781f0ac6a5Smrg	continue
94791f0ac6a5Smrg      fi
94801f0ac6a5Smrg
94811f0ac6a5Smrg      rmfiles="$file"
94821f0ac6a5Smrg
94831f0ac6a5Smrg      case $name in
94841f0ac6a5Smrg      *.la)
94851f0ac6a5Smrg	# Possibly a libtool archive, so verify it.
94869c9ff80cSmrg	if func_lalib_p "$file"; then
94879c9ff80cSmrg	  func_source $dir/$name
94881f0ac6a5Smrg
94891f0ac6a5Smrg	  # Delete the libtool libraries and symlinks.
94901f0ac6a5Smrg	  for n in $library_names; do
94916fae4e5dSmrg	    func_append rmfiles " $odir/$n"
94921f0ac6a5Smrg	  done
94936fae4e5dSmrg	  test -n "$old_library" && func_append rmfiles " $odir/$old_library"
94941f0ac6a5Smrg
94956fae4e5dSmrg	  case "$opt_mode" in
94961f0ac6a5Smrg	  clean)
94976fae4e5dSmrg	    case " $library_names " in
94981f0ac6a5Smrg	    *" $dlname "*) ;;
94996fae4e5dSmrg	    *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;;
95001f0ac6a5Smrg	    esac
95016fae4e5dSmrg	    test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i"
95021f0ac6a5Smrg	    ;;
95031f0ac6a5Smrg	  uninstall)
95041f0ac6a5Smrg	    if test -n "$library_names"; then
95051f0ac6a5Smrg	      # Do each command in the postuninstall commands.
95069c9ff80cSmrg	      func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
95071f0ac6a5Smrg	    fi
95081f0ac6a5Smrg
95091f0ac6a5Smrg	    if test -n "$old_library"; then
95101f0ac6a5Smrg	      # Do each command in the old_postuninstall commands.
95119c9ff80cSmrg	      func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
95121f0ac6a5Smrg	    fi
95131f0ac6a5Smrg	    # FIXME: should reinstall the best remaining shared library.
95141f0ac6a5Smrg	    ;;
95151f0ac6a5Smrg	  esac
95161f0ac6a5Smrg	fi
95171f0ac6a5Smrg	;;
95181f0ac6a5Smrg
95191f0ac6a5Smrg      *.lo)
95201f0ac6a5Smrg	# Possibly a libtool object, so verify it.
95219c9ff80cSmrg	if func_lalib_p "$file"; then
95221f0ac6a5Smrg
95231f0ac6a5Smrg	  # Read the .lo file
95249c9ff80cSmrg	  func_source $dir/$name
95251f0ac6a5Smrg
95261f0ac6a5Smrg	  # Add PIC object to the list of files to remove.
95279c9ff80cSmrg	  if test -n "$pic_object" &&
95289c9ff80cSmrg	     test "$pic_object" != none; then
95296fae4e5dSmrg	    func_append rmfiles " $dir/$pic_object"
95301f0ac6a5Smrg	  fi
95311f0ac6a5Smrg
95321f0ac6a5Smrg	  # Add non-PIC object to the list of files to remove.
95339c9ff80cSmrg	  if test -n "$non_pic_object" &&
95349c9ff80cSmrg	     test "$non_pic_object" != none; then
95356fae4e5dSmrg	    func_append rmfiles " $dir/$non_pic_object"
95361f0ac6a5Smrg	  fi
95371f0ac6a5Smrg	fi
95381f0ac6a5Smrg	;;
95391f0ac6a5Smrg
95401f0ac6a5Smrg      *)
95416fae4e5dSmrg	if test "$opt_mode" = clean ; then
95421f0ac6a5Smrg	  noexename=$name
95431f0ac6a5Smrg	  case $file in
95441f0ac6a5Smrg	  *.exe)
95459c9ff80cSmrg	    func_stripname '' '.exe' "$file"
95469c9ff80cSmrg	    file=$func_stripname_result
95479c9ff80cSmrg	    func_stripname '' '.exe' "$name"
95489c9ff80cSmrg	    noexename=$func_stripname_result
95491f0ac6a5Smrg	    # $file with .exe has already been added to rmfiles,
95501f0ac6a5Smrg	    # add $file without .exe
95516fae4e5dSmrg	    func_append rmfiles " $file"
95521f0ac6a5Smrg	    ;;
95531f0ac6a5Smrg	  esac
95541f0ac6a5Smrg	  # Do a test to see if this is a libtool program.
95559c9ff80cSmrg	  if func_ltwrapper_p "$file"; then
95569c9ff80cSmrg	    if func_ltwrapper_executable_p "$file"; then
95579c9ff80cSmrg	      func_ltwrapper_scriptname "$file"
95589c9ff80cSmrg	      relink_command=
95599c9ff80cSmrg	      func_source $func_ltwrapper_scriptname_result
95606fae4e5dSmrg	      func_append rmfiles " $func_ltwrapper_scriptname_result"
95619c9ff80cSmrg	    else
95629c9ff80cSmrg	      relink_command=
95639c9ff80cSmrg	      func_source $dir/$noexename
95649c9ff80cSmrg	    fi
95651f0ac6a5Smrg
95661f0ac6a5Smrg	    # note $name still contains .exe if it was in $file originally
95671f0ac6a5Smrg	    # as does the version of $file that was added into $rmfiles
95686fae4e5dSmrg	    func_append rmfiles " $odir/$name $odir/${name}S.${objext}"
95691f0ac6a5Smrg	    if test "$fast_install" = yes && test -n "$relink_command"; then
95706fae4e5dSmrg	      func_append rmfiles " $odir/lt-$name"
95711f0ac6a5Smrg	    fi
95721f0ac6a5Smrg	    if test "X$noexename" != "X$name" ; then
95736fae4e5dSmrg	      func_append rmfiles " $odir/lt-${noexename}.c"
95741f0ac6a5Smrg	    fi
95751f0ac6a5Smrg	  fi
95761f0ac6a5Smrg	fi
95771f0ac6a5Smrg	;;
95781f0ac6a5Smrg      esac
95799c9ff80cSmrg      func_show_eval "$RM $rmfiles" 'exit_status=1'
95801f0ac6a5Smrg    done
95811f0ac6a5Smrg
95821f0ac6a5Smrg    # Try to remove the ${objdir}s in the directories where we deleted files
95831f0ac6a5Smrg    for dir in $rmdirs; do
95841f0ac6a5Smrg      if test -d "$dir"; then
95859c9ff80cSmrg	func_show_eval "rmdir $dir >/dev/null 2>&1"
95861f0ac6a5Smrg      fi
95871f0ac6a5Smrg    done
95881f0ac6a5Smrg
95891f0ac6a5Smrg    exit $exit_status
95909c9ff80cSmrg}
95911f0ac6a5Smrg
95926fae4e5dSmrg{ test "$opt_mode" = uninstall || test "$opt_mode" = clean; } &&
95939c9ff80cSmrg    func_mode_uninstall ${1+"$@"}
95941f0ac6a5Smrg
95956fae4e5dSmrgtest -z "$opt_mode" && {
95969c9ff80cSmrg  help="$generic_help"
95979c9ff80cSmrg  func_fatal_help "you must specify a MODE"
95989c9ff80cSmrg}
95999c9ff80cSmrg
96009c9ff80cSmrgtest -z "$exec_cmd" && \
96016fae4e5dSmrg  func_fatal_help "invalid operation mode \`$opt_mode'"
96021f0ac6a5Smrg
96031f0ac6a5Smrgif test -n "$exec_cmd"; then
96049c9ff80cSmrg  eval exec "$exec_cmd"
96051f0ac6a5Smrg  exit $EXIT_FAILURE
96061f0ac6a5Smrgfi
96071f0ac6a5Smrg
96089c9ff80cSmrgexit $exit_status
96091f0ac6a5Smrg
96101f0ac6a5Smrg
96111f0ac6a5Smrg# The TAGs below are defined such that we never get into a situation
96121f0ac6a5Smrg# in which we disable both kinds of libraries.  Given conflicting
96131f0ac6a5Smrg# choices, we go for a static library, that is the most portable,
96141f0ac6a5Smrg# since we can't tell whether shared libraries were disabled because
96151f0ac6a5Smrg# the user asked for that or because the platform doesn't support
96161f0ac6a5Smrg# them.  This is particularly important on AIX, because we don't
96171f0ac6a5Smrg# support having both static and shared libraries enabled at the same
96181f0ac6a5Smrg# time on that platform, so we default to a shared-only configuration.
96191f0ac6a5Smrg# If a disable-shared tag is given, we'll fallback to a static-only
96201f0ac6a5Smrg# configuration.  But we'll never go from static-only to shared-only.
96211f0ac6a5Smrg
96221f0ac6a5Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
96239c9ff80cSmrgbuild_libtool_libs=no
96249c9ff80cSmrgbuild_old_libs=yes
96251f0ac6a5Smrg# ### END LIBTOOL TAG CONFIG: disable-shared
96261f0ac6a5Smrg
96271f0ac6a5Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static
96289c9ff80cSmrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
96291f0ac6a5Smrg# ### END LIBTOOL TAG CONFIG: disable-static
96301f0ac6a5Smrg
96311f0ac6a5Smrg# Local Variables:
96321f0ac6a5Smrg# mode:shell-script
96331f0ac6a5Smrg# sh-indentation:2
96341f0ac6a5Smrg# End:
96359c9ff80cSmrg# vi:sw=2
96369c9ff80cSmrg
9637