ltmain.sh revision fc544a13
17a3b38f7Smrg
2fc544a13Smrg# libtool (GNU libtool) 2.4.2
37a3b38f7Smrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
47a3b38f7Smrg
544dda7b2Smrg# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006,
6fc544a13Smrg# 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
77a3b38f7Smrg# This is free software; see the source for copying conditions.  There is NO
87a3b38f7Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
97a3b38f7Smrg
107a3b38f7Smrg# GNU Libtool is free software; you can redistribute it and/or modify
11ff559fabSmrg# it under the terms of the GNU General Public License as published by
12ff559fabSmrg# the Free Software Foundation; either version 2 of the License, or
13ff559fabSmrg# (at your option) any later version.
14ff559fabSmrg#
157a3b38f7Smrg# As a special exception to the GNU General Public License,
167a3b38f7Smrg# if you distribute this file as part of a program or library that
177a3b38f7Smrg# is built using GNU Libtool, you may include this file under the
187a3b38f7Smrg# same distribution terms that you use for the rest of that program.
197a3b38f7Smrg#
207a3b38f7Smrg# GNU Libtool is distributed in the hope that it will be useful, but
21ff559fabSmrg# WITHOUT ANY WARRANTY; without even the implied warranty of
22ff559fabSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
23ff559fabSmrg# General Public License for more details.
24ff559fabSmrg#
25ff559fabSmrg# You should have received a copy of the GNU General Public License
267a3b38f7Smrg# along with GNU Libtool; see the file COPYING.  If not, a copy
277a3b38f7Smrg# can be downloaded from http://www.gnu.org/licenses/gpl.html,
287a3b38f7Smrg# or obtained by writing to the Free Software Foundation, Inc.,
297a3b38f7Smrg# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
307a3b38f7Smrg
317a3b38f7Smrg# Usage: $progname [OPTION]... [MODE-ARG]...
327a3b38f7Smrg#
337a3b38f7Smrg# Provide generalized library-building support services.
34ff559fabSmrg#
3544dda7b2Smrg#       --config             show all configuration variables
3644dda7b2Smrg#       --debug              enable verbose shell tracing
3744dda7b2Smrg#   -n, --dry-run            display commands without modifying any files
3844dda7b2Smrg#       --features           display basic configuration information and exit
3944dda7b2Smrg#       --mode=MODE          use operation mode MODE
4044dda7b2Smrg#       --preserve-dup-deps  don't remove duplicate dependency libraries
4144dda7b2Smrg#       --quiet, --silent    don't print informational messages
4244dda7b2Smrg#       --no-quiet, --no-silent
4344dda7b2Smrg#                            print informational messages (default)
44fc544a13Smrg#       --no-warn            don't display warning messages
4544dda7b2Smrg#       --tag=TAG            use configuration variables from tag TAG
4644dda7b2Smrg#   -v, --verbose            print more informational messages than default
4744dda7b2Smrg#       --no-verbose         don't print the extra informational messages
4844dda7b2Smrg#       --version            print version information
4944dda7b2Smrg#   -h, --help, --help-all   print short, long, or detailed help message
507a3b38f7Smrg#
517a3b38f7Smrg# MODE must be one of the following:
527a3b38f7Smrg#
5344dda7b2Smrg#         clean              remove files from the build directory
5444dda7b2Smrg#         compile            compile a source file into a libtool object
5544dda7b2Smrg#         execute            automatically set library path, then run a program
5644dda7b2Smrg#         finish             complete the installation of libtool libraries
5744dda7b2Smrg#         install            install libraries or executables
5844dda7b2Smrg#         link               create a library or an executable
5944dda7b2Smrg#         uninstall          remove libraries from an installed directory
607a3b38f7Smrg#
6144dda7b2Smrg# MODE-ARGS vary depending on the MODE.  When passed as first option,
6244dda7b2Smrg# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that.
637a3b38f7Smrg# Try `$progname --help --mode=MODE' for a more detailed description of MODE.
647a3b38f7Smrg#
657a3b38f7Smrg# When reporting a bug, please describe a test case to reproduce it and
667a3b38f7Smrg# include the following information:
677a3b38f7Smrg#
6844dda7b2Smrg#         host-triplet:	$host
6944dda7b2Smrg#         shell:		$SHELL
7044dda7b2Smrg#         compiler:		$LTCC
7144dda7b2Smrg#         compiler flags:		$LTCFLAGS
7244dda7b2Smrg#         linker:		$LD (gnu? $with_gnu_ld)
73fc544a13Smrg#         $progname:	(GNU libtool) 2.4.2
7444dda7b2Smrg#         automake:	$automake_version
7544dda7b2Smrg#         autoconf:	$autoconf_version
767a3b38f7Smrg#
777a3b38f7Smrg# Report bugs to <bug-libtool@gnu.org>.
78862f5301Smrg# GNU libtool home page: <http://www.gnu.org/software/libtool/>.
79862f5301Smrg# General help using GNU software: <http://www.gnu.org/gethelp/>.
807a3b38f7Smrg
8144dda7b2SmrgPROGRAM=libtool
827a3b38f7SmrgPACKAGE=libtool
83fc544a13SmrgVERSION=2.4.2
847a3b38f7SmrgTIMESTAMP=""
85fc544a13Smrgpackage_revision=1.3337
867a3b38f7Smrg
877a3b38f7Smrg# Be Bourne compatible
887a3b38f7Smrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
897a3b38f7Smrg  emulate sh
907a3b38f7Smrg  NULLCMD=:
917a3b38f7Smrg  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
927a3b38f7Smrg  # is contrary to our usage.  Disable this feature.
937a3b38f7Smrg  alias -g '${1+"$@"}'='"$@"'
947a3b38f7Smrg  setopt NO_GLOB_SUBST
957a3b38f7Smrgelse
967a3b38f7Smrg  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
977a3b38f7Smrgfi
987a3b38f7SmrgBIN_SH=xpg4; export BIN_SH # for Tru64
997a3b38f7SmrgDUALCASE=1; export DUALCASE # for MKS sh
1007a3b38f7Smrg
10144dda7b2Smrg# A function that is used when there is no print builtin or printf.
10244dda7b2Smrgfunc_fallback_echo ()
10344dda7b2Smrg{
10444dda7b2Smrg  eval 'cat <<_LTECHO_EOF
10544dda7b2Smrg$1
10644dda7b2Smrg_LTECHO_EOF'
10744dda7b2Smrg}
10844dda7b2Smrg
1097a3b38f7Smrg# NLS nuisances: We save the old values to restore during execute mode.
1107a3b38f7Smrglt_user_locale=
1117a3b38f7Smrglt_safe_locale=
1127a3b38f7Smrgfor lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
1137a3b38f7Smrgdo
1147a3b38f7Smrg  eval "if test \"\${$lt_var+set}\" = set; then
1157a3b38f7Smrg          save_$lt_var=\$$lt_var
1167a3b38f7Smrg          $lt_var=C
1177a3b38f7Smrg	  export $lt_var
1187a3b38f7Smrg	  lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\"
1197a3b38f7Smrg	  lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
1207a3b38f7Smrg	fi"
1217a3b38f7Smrgdone
12244dda7b2SmrgLC_ALL=C
12344dda7b2SmrgLANGUAGE=C
12444dda7b2Smrgexport LANGUAGE LC_ALL
1257a3b38f7Smrg
1267a3b38f7Smrg$lt_unset CDPATH
1277a3b38f7Smrg
1287a3b38f7Smrg
12944dda7b2Smrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
13044dda7b2Smrg# is ksh but when the shell is invoked as "sh" and the current value of
13144dda7b2Smrg# the _XPG environment variable is not equal to 1 (one), the special
13244dda7b2Smrg# positional parameter $0, within a function call, is the name of the
13344dda7b2Smrg# function.
13444dda7b2Smrgprogpath="$0"
1357a3b38f7Smrg
1367a3b38f7Smrg
1377a3b38f7Smrg
1387a3b38f7Smrg: ${CP="cp -f"}
13944dda7b2Smrgtest "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'}
1407a3b38f7Smrg: ${MAKE="make"}
1417a3b38f7Smrg: ${MKDIR="mkdir"}
1427a3b38f7Smrg: ${MV="mv -f"}
1437a3b38f7Smrg: ${RM="rm -f"}
1447a3b38f7Smrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
1457a3b38f7Smrg: ${Xsed="$SED -e 1s/^X//"}
146ff559fabSmrg
1477a3b38f7Smrg# Global variables:
1487a3b38f7SmrgEXIT_SUCCESS=0
1497a3b38f7SmrgEXIT_FAILURE=1
1507a3b38f7SmrgEXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
1517a3b38f7SmrgEXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
1527a3b38f7Smrg
1537a3b38f7Smrgexit_status=$EXIT_SUCCESS
1547a3b38f7Smrg
1557a3b38f7Smrg# Make sure IFS has a sensible default
1567a3b38f7Smrglt_nl='
1577a3b38f7Smrg'
1587a3b38f7SmrgIFS=" 	$lt_nl"
1597a3b38f7Smrg
1607a3b38f7Smrgdirname="s,/[^/]*$,,"
1617a3b38f7Smrgbasename="s,^.*/,,"
1627a3b38f7Smrg
163862f5301Smrg# func_dirname file append nondir_replacement
164862f5301Smrg# Compute the dirname of FILE.  If nonempty, add APPEND to the result,
165862f5301Smrg# otherwise set result to NONDIR_REPLACEMENT.
166862f5301Smrgfunc_dirname ()
167862f5301Smrg{
168862f5301Smrg    func_dirname_result=`$ECHO "${1}" | $SED "$dirname"`
169862f5301Smrg    if test "X$func_dirname_result" = "X${1}"; then
170862f5301Smrg      func_dirname_result="${3}"
171862f5301Smrg    else
172862f5301Smrg      func_dirname_result="$func_dirname_result${2}"
173862f5301Smrg    fi
174862f5301Smrg} # func_dirname may be replaced by extended shell implementation
175862f5301Smrg
176862f5301Smrg
177862f5301Smrg# func_basename file
178862f5301Smrgfunc_basename ()
179862f5301Smrg{
180862f5301Smrg    func_basename_result=`$ECHO "${1}" | $SED "$basename"`
181862f5301Smrg} # func_basename may be replaced by extended shell implementation
182862f5301Smrg
183862f5301Smrg
1847a3b38f7Smrg# func_dirname_and_basename file append nondir_replacement
1857a3b38f7Smrg# perform func_basename and func_dirname in a single function
1867a3b38f7Smrg# call:
1877a3b38f7Smrg#   dirname:  Compute the dirname of FILE.  If nonempty,
1887a3b38f7Smrg#             add APPEND to the result, otherwise set result
1897a3b38f7Smrg#             to NONDIR_REPLACEMENT.
1907a3b38f7Smrg#             value returned in "$func_dirname_result"
1917a3b38f7Smrg#   basename: Compute filename of FILE.
1927a3b38f7Smrg#             value retuned in "$func_basename_result"
1937a3b38f7Smrg# Implementation must be kept synchronized with func_dirname
1947a3b38f7Smrg# and func_basename. For efficiency, we do not delegate to
1957a3b38f7Smrg# those functions but instead duplicate the functionality here.
1967a3b38f7Smrgfunc_dirname_and_basename ()
1977a3b38f7Smrg{
198862f5301Smrg    # Extract subdirectory from the argument.
199862f5301Smrg    func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"`
200862f5301Smrg    if test "X$func_dirname_result" = "X${1}"; then
201862f5301Smrg      func_dirname_result="${3}"
202862f5301Smrg    else
203862f5301Smrg      func_dirname_result="$func_dirname_result${2}"
204862f5301Smrg    fi
205862f5301Smrg    func_basename_result=`$ECHO "${1}" | $SED -e "$basename"`
206862f5301Smrg} # func_dirname_and_basename may be replaced by extended shell implementation
207862f5301Smrg
208862f5301Smrg
209862f5301Smrg# func_stripname prefix suffix name
210862f5301Smrg# strip PREFIX and SUFFIX off of NAME.
211862f5301Smrg# PREFIX and SUFFIX must not contain globbing or regex special
212862f5301Smrg# characters, hashes, percent signs, but SUFFIX may contain a leading
213862f5301Smrg# dot (in which case that matches only a dot).
214862f5301Smrg# func_strip_suffix prefix name
215862f5301Smrgfunc_stripname ()
216862f5301Smrg{
217862f5301Smrg    case ${2} in
218862f5301Smrg      .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;;
219862f5301Smrg      *)  func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;;
220862f5301Smrg    esac
221862f5301Smrg} # func_stripname may be replaced by extended shell implementation
2227a3b38f7Smrg
223ff559fabSmrg
22444dda7b2Smrg# These SED scripts presuppose an absolute path with a trailing slash.
22544dda7b2Smrgpathcar='s,^/\([^/]*\).*$,\1,'
22644dda7b2Smrgpathcdr='s,^/[^/]*,,'
22744dda7b2Smrgremovedotparts=':dotsl
22844dda7b2Smrg		s@/\./@/@g
22944dda7b2Smrg		t dotsl
23044dda7b2Smrg		s,/\.$,/,'
23144dda7b2Smrgcollapseslashes='s@/\{1,\}@/@g'
23244dda7b2Smrgfinalslash='s,/*$,/,'
23344dda7b2Smrg
23444dda7b2Smrg# func_normal_abspath PATH
23544dda7b2Smrg# Remove doubled-up and trailing slashes, "." path components,
23644dda7b2Smrg# and cancel out any ".." path components in PATH after making
23744dda7b2Smrg# it an absolute path.
23844dda7b2Smrg#             value returned in "$func_normal_abspath_result"
23944dda7b2Smrgfunc_normal_abspath ()
24044dda7b2Smrg{
24144dda7b2Smrg  # Start from root dir and reassemble the path.
24244dda7b2Smrg  func_normal_abspath_result=
24344dda7b2Smrg  func_normal_abspath_tpath=$1
24444dda7b2Smrg  func_normal_abspath_altnamespace=
24544dda7b2Smrg  case $func_normal_abspath_tpath in
24644dda7b2Smrg    "")
24744dda7b2Smrg      # Empty path, that just means $cwd.
24844dda7b2Smrg      func_stripname '' '/' "`pwd`"
24944dda7b2Smrg      func_normal_abspath_result=$func_stripname_result
25044dda7b2Smrg      return
25144dda7b2Smrg    ;;
25244dda7b2Smrg    # The next three entries are used to spot a run of precisely
25344dda7b2Smrg    # two leading slashes without using negated character classes;
25444dda7b2Smrg    # we take advantage of case's first-match behaviour.
25544dda7b2Smrg    ///*)
25644dda7b2Smrg      # Unusual form of absolute path, do nothing.
25744dda7b2Smrg    ;;
25844dda7b2Smrg    //*)
25944dda7b2Smrg      # Not necessarily an ordinary path; POSIX reserves leading '//'
26044dda7b2Smrg      # and for example Cygwin uses it to access remote file shares
26144dda7b2Smrg      # over CIFS/SMB, so we conserve a leading double slash if found.
26244dda7b2Smrg      func_normal_abspath_altnamespace=/
26344dda7b2Smrg    ;;
26444dda7b2Smrg    /*)
26544dda7b2Smrg      # Absolute path, do nothing.
26644dda7b2Smrg    ;;
26744dda7b2Smrg    *)
26844dda7b2Smrg      # Relative path, prepend $cwd.
26944dda7b2Smrg      func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
27044dda7b2Smrg    ;;
27144dda7b2Smrg  esac
27244dda7b2Smrg  # Cancel out all the simple stuff to save iterations.  We also want
27344dda7b2Smrg  # the path to end with a slash for ease of parsing, so make sure
27444dda7b2Smrg  # there is one (and only one) here.
27544dda7b2Smrg  func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
27644dda7b2Smrg        -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"`
27744dda7b2Smrg  while :; do
27844dda7b2Smrg    # Processed it all yet?
27944dda7b2Smrg    if test "$func_normal_abspath_tpath" = / ; then
28044dda7b2Smrg      # If we ascended to the root using ".." the result may be empty now.
28144dda7b2Smrg      if test -z "$func_normal_abspath_result" ; then
28244dda7b2Smrg        func_normal_abspath_result=/
28344dda7b2Smrg      fi
28444dda7b2Smrg      break
28544dda7b2Smrg    fi
28644dda7b2Smrg    func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
28744dda7b2Smrg        -e "$pathcar"`
28844dda7b2Smrg    func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
28944dda7b2Smrg        -e "$pathcdr"`
29044dda7b2Smrg    # Figure out what to do with it
29144dda7b2Smrg    case $func_normal_abspath_tcomponent in
29244dda7b2Smrg      "")
29344dda7b2Smrg        # Trailing empty path component, ignore it.
29444dda7b2Smrg      ;;
29544dda7b2Smrg      ..)
29644dda7b2Smrg        # Parent dir; strip last assembled component from result.
29744dda7b2Smrg        func_dirname "$func_normal_abspath_result"
29844dda7b2Smrg        func_normal_abspath_result=$func_dirname_result
29944dda7b2Smrg      ;;
30044dda7b2Smrg      *)
30144dda7b2Smrg        # Actual path component, append it.
30244dda7b2Smrg        func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent
30344dda7b2Smrg      ;;
30444dda7b2Smrg    esac
30544dda7b2Smrg  done
30644dda7b2Smrg  # Restore leading double-slash if one was found on entry.
30744dda7b2Smrg  func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
30844dda7b2Smrg}
30944dda7b2Smrg
31044dda7b2Smrg# func_relative_path SRCDIR DSTDIR
31144dda7b2Smrg# generates a relative path from SRCDIR to DSTDIR, with a trailing
31244dda7b2Smrg# slash if non-empty, suitable for immediately appending a filename
31344dda7b2Smrg# without needing to append a separator.
31444dda7b2Smrg#             value returned in "$func_relative_path_result"
31544dda7b2Smrgfunc_relative_path ()
31644dda7b2Smrg{
31744dda7b2Smrg  func_relative_path_result=
31844dda7b2Smrg  func_normal_abspath "$1"
31944dda7b2Smrg  func_relative_path_tlibdir=$func_normal_abspath_result
32044dda7b2Smrg  func_normal_abspath "$2"
32144dda7b2Smrg  func_relative_path_tbindir=$func_normal_abspath_result
32244dda7b2Smrg
32344dda7b2Smrg  # Ascend the tree starting from libdir
32444dda7b2Smrg  while :; do
32544dda7b2Smrg    # check if we have found a prefix of bindir
32644dda7b2Smrg    case $func_relative_path_tbindir in
32744dda7b2Smrg      $func_relative_path_tlibdir)
32844dda7b2Smrg        # found an exact match
32944dda7b2Smrg        func_relative_path_tcancelled=
33044dda7b2Smrg        break
33144dda7b2Smrg        ;;
33244dda7b2Smrg      $func_relative_path_tlibdir*)
33344dda7b2Smrg        # found a matching prefix
33444dda7b2Smrg        func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
33544dda7b2Smrg        func_relative_path_tcancelled=$func_stripname_result
33644dda7b2Smrg        if test -z "$func_relative_path_result"; then
33744dda7b2Smrg          func_relative_path_result=.
33844dda7b2Smrg        fi
33944dda7b2Smrg        break
34044dda7b2Smrg        ;;
34144dda7b2Smrg      *)
34244dda7b2Smrg        func_dirname $func_relative_path_tlibdir
34344dda7b2Smrg        func_relative_path_tlibdir=${func_dirname_result}
34444dda7b2Smrg        if test "x$func_relative_path_tlibdir" = x ; then
34544dda7b2Smrg          # Have to descend all the way to the root!
34644dda7b2Smrg          func_relative_path_result=../$func_relative_path_result
34744dda7b2Smrg          func_relative_path_tcancelled=$func_relative_path_tbindir
34844dda7b2Smrg          break
34944dda7b2Smrg        fi
35044dda7b2Smrg        func_relative_path_result=../$func_relative_path_result
35144dda7b2Smrg        ;;
35244dda7b2Smrg    esac
35344dda7b2Smrg  done
35444dda7b2Smrg
35544dda7b2Smrg  # Now calculate path; take care to avoid doubling-up slashes.
35644dda7b2Smrg  func_stripname '' '/' "$func_relative_path_result"
35744dda7b2Smrg  func_relative_path_result=$func_stripname_result
35844dda7b2Smrg  func_stripname '/' '/' "$func_relative_path_tcancelled"
35944dda7b2Smrg  if test "x$func_stripname_result" != x ; then
36044dda7b2Smrg    func_relative_path_result=${func_relative_path_result}/${func_stripname_result}
36144dda7b2Smrg  fi
36244dda7b2Smrg
36344dda7b2Smrg  # Normalisation. If bindir is libdir, return empty string,
36444dda7b2Smrg  # else relative path ending with a slash; either way, target
36544dda7b2Smrg  # file name can be directly appended.
36644dda7b2Smrg  if test ! -z "$func_relative_path_result"; then
36744dda7b2Smrg    func_stripname './' '' "$func_relative_path_result/"
36844dda7b2Smrg    func_relative_path_result=$func_stripname_result
36944dda7b2Smrg  fi
37044dda7b2Smrg}
371ff559fabSmrg
372ff559fabSmrg# The name of this program:
3737a3b38f7Smrgfunc_dirname_and_basename "$progpath"
3747a3b38f7Smrgprogname=$func_basename_result
375ff559fabSmrg
3767a3b38f7Smrg# Make sure we have an absolute path for reexecution:
3777a3b38f7Smrgcase $progpath in
3787a3b38f7Smrg  [\\/]*|[A-Za-z]:\\*) ;;
3797a3b38f7Smrg  *[\\/]*)
3807a3b38f7Smrg     progdir=$func_dirname_result
3817a3b38f7Smrg     progdir=`cd "$progdir" && pwd`
3827a3b38f7Smrg     progpath="$progdir/$progname"
3837a3b38f7Smrg     ;;
3847a3b38f7Smrg  *)
3857a3b38f7Smrg     save_IFS="$IFS"
386fc544a13Smrg     IFS=${PATH_SEPARATOR-:}
3877a3b38f7Smrg     for progdir in $PATH; do
3887a3b38f7Smrg       IFS="$save_IFS"
3897a3b38f7Smrg       test -x "$progdir/$progname" && break
3907a3b38f7Smrg     done
3917a3b38f7Smrg     IFS="$save_IFS"
3927a3b38f7Smrg     test -n "$progdir" || progdir=`pwd`
3937a3b38f7Smrg     progpath="$progdir/$progname"
3947a3b38f7Smrg     ;;
3957a3b38f7Smrgesac
396ff559fabSmrg
3977a3b38f7Smrg# Sed substitution that helps us do robust quoting.  It backslashifies
3987a3b38f7Smrg# metacharacters that are still active within double-quoted strings.
3997a3b38f7SmrgXsed="${SED}"' -e 1s/^X//'
4007a3b38f7Smrgsed_quote_subst='s/\([`"$\\]\)/\\\1/g'
4017a3b38f7Smrg
4027a3b38f7Smrg# Same as above, but do not quote variable references.
4037a3b38f7Smrgdouble_quote_subst='s/\(["`\\]\)/\\\1/g'
4047a3b38f7Smrg
405862f5301Smrg# Sed substitution that turns a string into a regex matching for the
406862f5301Smrg# string literally.
407862f5301Smrgsed_make_literal_regex='s,[].[^$\\*\/],\\&,g'
408862f5301Smrg
409862f5301Smrg# Sed substitution that converts a w32 file name or path
410862f5301Smrg# which contains forward slashes, into one that contains
411862f5301Smrg# (escaped) backslashes.  A very naive implementation.
412862f5301Smrglt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
413862f5301Smrg
4147a3b38f7Smrg# Re-`\' parameter expansions in output of double_quote_subst that were
4157a3b38f7Smrg# `\'-ed in input to the same.  If an odd number of `\' preceded a '$'
4167a3b38f7Smrg# in input to double_quote_subst, that '$' was protected from expansion.
4177a3b38f7Smrg# Since each input `\' is now two `\'s, look for any number of runs of
4187a3b38f7Smrg# four `\'s followed by two `\'s and then a '$'.  `\' that '$'.
4197a3b38f7Smrgbs='\\'
4207a3b38f7Smrgbs2='\\\\'
4217a3b38f7Smrgbs4='\\\\\\\\'
4227a3b38f7Smrgdollar='\$'
4237a3b38f7Smrgsed_double_backslash="\
4247a3b38f7Smrg  s/$bs4/&\\
4257a3b38f7Smrg/g
4267a3b38f7Smrg  s/^$bs2$dollar/$bs&/
4277a3b38f7Smrg  s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
4287a3b38f7Smrg  s/\n//g"
4297a3b38f7Smrg
4307a3b38f7Smrg# Standard options:
4317a3b38f7Smrgopt_dry_run=false
4327a3b38f7Smrgopt_help=false
4337a3b38f7Smrgopt_quiet=false
4347a3b38f7Smrgopt_verbose=false
4357a3b38f7Smrgopt_warning=:
4367a3b38f7Smrg
4377a3b38f7Smrg# func_echo arg...
4387a3b38f7Smrg# Echo program name prefixed message, along with the current mode
4397a3b38f7Smrg# name if it has been set yet.
4407a3b38f7Smrgfunc_echo ()
4417a3b38f7Smrg{
442862f5301Smrg    $ECHO "$progname: ${opt_mode+$opt_mode: }$*"
4437a3b38f7Smrg}
444ff559fabSmrg
4457a3b38f7Smrg# func_verbose arg...
4467a3b38f7Smrg# Echo program name prefixed message in verbose mode only.
4477a3b38f7Smrgfunc_verbose ()
4487a3b38f7Smrg{
4497a3b38f7Smrg    $opt_verbose && func_echo ${1+"$@"}
450ff559fabSmrg
4517a3b38f7Smrg    # A bug in bash halts the script if the last line of a function
4527a3b38f7Smrg    # fails when set -e is in force, so we need another command to
4537a3b38f7Smrg    # work around that:
4547a3b38f7Smrg    :
4557a3b38f7Smrg}
456ff559fabSmrg
45744dda7b2Smrg# func_echo_all arg...
45844dda7b2Smrg# Invoke $ECHO with all args, space-separated.
45944dda7b2Smrgfunc_echo_all ()
46044dda7b2Smrg{
46144dda7b2Smrg    $ECHO "$*"
46244dda7b2Smrg}
46344dda7b2Smrg
4647a3b38f7Smrg# func_error arg...
4657a3b38f7Smrg# Echo program name prefixed message to standard error.
4667a3b38f7Smrgfunc_error ()
4677a3b38f7Smrg{
468862f5301Smrg    $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2
4697a3b38f7Smrg}
470ff559fabSmrg
4717a3b38f7Smrg# func_warning arg...
4727a3b38f7Smrg# Echo program name prefixed warning message to standard error.
4737a3b38f7Smrgfunc_warning ()
4747a3b38f7Smrg{
475862f5301Smrg    $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2
476ff559fabSmrg
4777a3b38f7Smrg    # bash bug again:
4787a3b38f7Smrg    :
4797a3b38f7Smrg}
480ff559fabSmrg
4817a3b38f7Smrg# func_fatal_error arg...
4827a3b38f7Smrg# Echo program name prefixed message to standard error, and exit.
4837a3b38f7Smrgfunc_fatal_error ()
4847a3b38f7Smrg{
4857a3b38f7Smrg    func_error ${1+"$@"}
4867a3b38f7Smrg    exit $EXIT_FAILURE
4877a3b38f7Smrg}
488ff559fabSmrg
4897a3b38f7Smrg# func_fatal_help arg...
4907a3b38f7Smrg# Echo program name prefixed message to standard error, followed by
4917a3b38f7Smrg# a help hint, and exit.
4927a3b38f7Smrgfunc_fatal_help ()
4937a3b38f7Smrg{
4947a3b38f7Smrg    func_error ${1+"$@"}
4957a3b38f7Smrg    func_fatal_error "$help"
4967a3b38f7Smrg}
4977a3b38f7Smrghelp="Try \`$progname --help' for more information."  ## default
498ff559fabSmrg
499ff559fabSmrg
5007a3b38f7Smrg# func_grep expression filename
5017a3b38f7Smrg# Check whether EXPRESSION matches any line of FILENAME, without output.
5027a3b38f7Smrgfunc_grep ()
5037a3b38f7Smrg{
5047a3b38f7Smrg    $GREP "$1" "$2" >/dev/null 2>&1
5057a3b38f7Smrg}
5067a3b38f7Smrg
5077a3b38f7Smrg
5087a3b38f7Smrg# func_mkdir_p directory-path
5097a3b38f7Smrg# Make sure the entire path to DIRECTORY-PATH is available.
5107a3b38f7Smrgfunc_mkdir_p ()
5117a3b38f7Smrg{
5127a3b38f7Smrg    my_directory_path="$1"
5137a3b38f7Smrg    my_dir_list=
5147a3b38f7Smrg
5157a3b38f7Smrg    if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
5167a3b38f7Smrg
5177a3b38f7Smrg      # Protect directory names starting with `-'
5187a3b38f7Smrg      case $my_directory_path in
5197a3b38f7Smrg        -*) my_directory_path="./$my_directory_path" ;;
5207a3b38f7Smrg      esac
5217a3b38f7Smrg
5227a3b38f7Smrg      # While some portion of DIR does not yet exist...
5237a3b38f7Smrg      while test ! -d "$my_directory_path"; do
5247a3b38f7Smrg        # ...make a list in topmost first order.  Use a colon delimited
5257a3b38f7Smrg	# list incase some portion of path contains whitespace.
5267a3b38f7Smrg        my_dir_list="$my_directory_path:$my_dir_list"
5277a3b38f7Smrg
5287a3b38f7Smrg        # If the last portion added has no slash in it, the list is done
5297a3b38f7Smrg        case $my_directory_path in */*) ;; *) break ;; esac
5307a3b38f7Smrg
5317a3b38f7Smrg        # ...otherwise throw away the child directory and loop
53244dda7b2Smrg        my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"`
5337a3b38f7Smrg      done
53444dda7b2Smrg      my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'`
5357a3b38f7Smrg
5367a3b38f7Smrg      save_mkdir_p_IFS="$IFS"; IFS=':'
5377a3b38f7Smrg      for my_dir in $my_dir_list; do
5387a3b38f7Smrg	IFS="$save_mkdir_p_IFS"
5397a3b38f7Smrg        # mkdir can fail with a `File exist' error if two processes
5407a3b38f7Smrg        # try to create one of the directories concurrently.  Don't
5417a3b38f7Smrg        # stop in that case!
5427a3b38f7Smrg        $MKDIR "$my_dir" 2>/dev/null || :
5437a3b38f7Smrg      done
5447a3b38f7Smrg      IFS="$save_mkdir_p_IFS"
5457a3b38f7Smrg
5467a3b38f7Smrg      # Bail out if we (or some other process) failed to create a directory.
5477a3b38f7Smrg      test -d "$my_directory_path" || \
5487a3b38f7Smrg        func_fatal_error "Failed to create \`$1'"
5497a3b38f7Smrg    fi
5507a3b38f7Smrg}
551ff559fabSmrg
552ff559fabSmrg
553ff559fabSmrg# func_mktempdir [string]
554ff559fabSmrg# Make a temporary directory that won't clash with other running
555ff559fabSmrg# libtool processes, and avoids race conditions if possible.  If
556ff559fabSmrg# given, STRING is the basename for that directory.
557ff559fabSmrgfunc_mktempdir ()
558ff559fabSmrg{
559ff559fabSmrg    my_template="${TMPDIR-/tmp}/${1-$progname}"
560ff559fabSmrg
5617a3b38f7Smrg    if test "$opt_dry_run" = ":"; then
562ff559fabSmrg      # Return a directory name, but don't create it in dry-run mode
563ff559fabSmrg      my_tmpdir="${my_template}-$$"
564ff559fabSmrg    else
565ff559fabSmrg
566ff559fabSmrg      # If mktemp works, use that first and foremost
567ff559fabSmrg      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
568ff559fabSmrg
569ff559fabSmrg      if test ! -d "$my_tmpdir"; then
5707a3b38f7Smrg        # Failing that, at least try and use $RANDOM to avoid a race
5717a3b38f7Smrg        my_tmpdir="${my_template}-${RANDOM-0}$$"
572ff559fabSmrg
5737a3b38f7Smrg        save_mktempdir_umask=`umask`
5747a3b38f7Smrg        umask 0077
5757a3b38f7Smrg        $MKDIR "$my_tmpdir"
5767a3b38f7Smrg        umask $save_mktempdir_umask
577ff559fabSmrg      fi
578ff559fabSmrg
579ff559fabSmrg      # If we're not in dry-run mode, bomb out on failure
5807a3b38f7Smrg      test -d "$my_tmpdir" || \
5817a3b38f7Smrg        func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
582ff559fabSmrg    fi
583ff559fabSmrg
58444dda7b2Smrg    $ECHO "$my_tmpdir"
585ff559fabSmrg}
586ff559fabSmrg
587ff559fabSmrg
5887a3b38f7Smrg# func_quote_for_eval arg
5897a3b38f7Smrg# Aesthetically quote ARG to be evaled later.
5907a3b38f7Smrg# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
5917a3b38f7Smrg# is double-quoted, suitable for a subsequent eval, whereas
5927a3b38f7Smrg# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
5937a3b38f7Smrg# which are still active within double quotes backslashified.
5947a3b38f7Smrgfunc_quote_for_eval ()
595ff559fabSmrg{
5967a3b38f7Smrg    case $1 in
5977a3b38f7Smrg      *[\\\`\"\$]*)
59844dda7b2Smrg	func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;;
5997a3b38f7Smrg      *)
6007a3b38f7Smrg        func_quote_for_eval_unquoted_result="$1" ;;
6017a3b38f7Smrg    esac
6027a3b38f7Smrg
6037a3b38f7Smrg    case $func_quote_for_eval_unquoted_result in
6047a3b38f7Smrg      # Double-quote args containing shell metacharacters to delay
6057a3b38f7Smrg      # word splitting, command substitution and and variable
6067a3b38f7Smrg      # expansion for a subsequent eval.
6077a3b38f7Smrg      # Many Bourne shells cannot handle close brackets correctly
6087a3b38f7Smrg      # in scan sets, so we specify it separately.
6097a3b38f7Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
6107a3b38f7Smrg        func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
6117a3b38f7Smrg        ;;
6127a3b38f7Smrg      *)
6137a3b38f7Smrg        func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
614ff559fabSmrg    esac
615ff559fabSmrg}
616ff559fabSmrg
617ff559fabSmrg
6187a3b38f7Smrg# func_quote_for_expand arg
6197a3b38f7Smrg# Aesthetically quote ARG to be evaled later; same as above,
6207a3b38f7Smrg# but do not quote variable references.
6217a3b38f7Smrgfunc_quote_for_expand ()
622ff559fabSmrg{
6237a3b38f7Smrg    case $1 in
6247a3b38f7Smrg      *[\\\`\"]*)
62544dda7b2Smrg	my_arg=`$ECHO "$1" | $SED \
6267a3b38f7Smrg	    -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
627ff559fabSmrg      *)
6287a3b38f7Smrg        my_arg="$1" ;;
6297a3b38f7Smrg    esac
6307a3b38f7Smrg
6317a3b38f7Smrg    case $my_arg in
6327a3b38f7Smrg      # Double-quote args containing shell metacharacters to delay
6337a3b38f7Smrg      # word splitting and command substitution for a subsequent eval.
6347a3b38f7Smrg      # Many Bourne shells cannot handle close brackets correctly
6357a3b38f7Smrg      # in scan sets, so we specify it separately.
6367a3b38f7Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
6377a3b38f7Smrg        my_arg="\"$my_arg\""
6387a3b38f7Smrg        ;;
6397a3b38f7Smrg    esac
6407a3b38f7Smrg
6417a3b38f7Smrg    func_quote_for_expand_result="$my_arg"
642ff559fabSmrg}
643ff559fabSmrg
644ff559fabSmrg
6457a3b38f7Smrg# func_show_eval cmd [fail_exp]
6467a3b38f7Smrg# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
6477a3b38f7Smrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
6487a3b38f7Smrg# is given, then evaluate it.
6497a3b38f7Smrgfunc_show_eval ()
650ff559fabSmrg{
6517a3b38f7Smrg    my_cmd="$1"
6527a3b38f7Smrg    my_fail_exp="${2-:}"
653ff559fabSmrg
6547a3b38f7Smrg    ${opt_silent-false} || {
6557a3b38f7Smrg      func_quote_for_expand "$my_cmd"
6567a3b38f7Smrg      eval "func_echo $func_quote_for_expand_result"
6577a3b38f7Smrg    }
6587a3b38f7Smrg
6597a3b38f7Smrg    if ${opt_dry_run-false}; then :; else
6607a3b38f7Smrg      eval "$my_cmd"
6617a3b38f7Smrg      my_status=$?
6627a3b38f7Smrg      if test "$my_status" -eq 0; then :; else
6637a3b38f7Smrg	eval "(exit $my_status); $my_fail_exp"
6647a3b38f7Smrg      fi
665ff559fabSmrg    fi
666ff559fabSmrg}
667ff559fabSmrg
6687a3b38f7Smrg
6697a3b38f7Smrg# func_show_eval_locale cmd [fail_exp]
6707a3b38f7Smrg# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
6717a3b38f7Smrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
6727a3b38f7Smrg# is given, then evaluate it.  Use the saved locale for evaluation.
6737a3b38f7Smrgfunc_show_eval_locale ()
674ff559fabSmrg{
6757a3b38f7Smrg    my_cmd="$1"
6767a3b38f7Smrg    my_fail_exp="${2-:}"
677ff559fabSmrg
6787a3b38f7Smrg    ${opt_silent-false} || {
6797a3b38f7Smrg      func_quote_for_expand "$my_cmd"
6807a3b38f7Smrg      eval "func_echo $func_quote_for_expand_result"
6817a3b38f7Smrg    }
6827a3b38f7Smrg
6837a3b38f7Smrg    if ${opt_dry_run-false}; then :; else
6847a3b38f7Smrg      eval "$lt_user_locale
6857a3b38f7Smrg	    $my_cmd"
6867a3b38f7Smrg      my_status=$?
6877a3b38f7Smrg      eval "$lt_safe_locale"
6887a3b38f7Smrg      if test "$my_status" -eq 0; then :; else
6897a3b38f7Smrg	eval "(exit $my_status); $my_fail_exp"
690ff559fabSmrg      fi
6917a3b38f7Smrg    fi
692ff559fabSmrg}
693ff559fabSmrg
694862f5301Smrg# func_tr_sh
695862f5301Smrg# Turn $1 into a string suitable for a shell variable name.
696862f5301Smrg# Result is stored in $func_tr_sh_result.  All characters
697862f5301Smrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further,
698862f5301Smrg# if $1 begins with a digit, a '_' is prepended as well.
699862f5301Smrgfunc_tr_sh ()
700862f5301Smrg{
701862f5301Smrg  case $1 in
702862f5301Smrg  [0-9]* | *[!a-zA-Z0-9_]*)
703862f5301Smrg    func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'`
704862f5301Smrg    ;;
705862f5301Smrg  * )
706862f5301Smrg    func_tr_sh_result=$1
707862f5301Smrg    ;;
708862f5301Smrg  esac
709862f5301Smrg}
710862f5301Smrg
711ff559fabSmrg
7127a3b38f7Smrg# func_version
7137a3b38f7Smrg# Echo version message to standard output and exit.
7147a3b38f7Smrgfunc_version ()
7157a3b38f7Smrg{
716862f5301Smrg    $opt_debug
717862f5301Smrg
71844dda7b2Smrg    $SED -n '/(C)/!b go
71944dda7b2Smrg	:more
72044dda7b2Smrg	/\./!{
72144dda7b2Smrg	  N
72244dda7b2Smrg	  s/\n# / /
72344dda7b2Smrg	  b more
72444dda7b2Smrg	}
72544dda7b2Smrg	:go
72644dda7b2Smrg	/^# '$PROGRAM' (GNU /,/# warranty; / {
7277a3b38f7Smrg        s/^# //
7287a3b38f7Smrg	s/^# *$//
7297a3b38f7Smrg        s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
7307a3b38f7Smrg        p
7317a3b38f7Smrg     }' < "$progpath"
7327a3b38f7Smrg     exit $?
7337a3b38f7Smrg}
7347a3b38f7Smrg
7357a3b38f7Smrg# func_usage
7367a3b38f7Smrg# Echo short help message to standard output and exit.
7377a3b38f7Smrgfunc_usage ()
7387a3b38f7Smrg{
739862f5301Smrg    $opt_debug
740862f5301Smrg
74144dda7b2Smrg    $SED -n '/^# Usage:/,/^#  *.*--help/ {
7427a3b38f7Smrg        s/^# //
7437a3b38f7Smrg	s/^# *$//
7447a3b38f7Smrg	s/\$progname/'$progname'/
7457a3b38f7Smrg	p
7467a3b38f7Smrg    }' < "$progpath"
74744dda7b2Smrg    echo
7487a3b38f7Smrg    $ECHO "run \`$progname --help | more' for full usage"
7497a3b38f7Smrg    exit $?
7507a3b38f7Smrg}
7517a3b38f7Smrg
75244dda7b2Smrg# func_help [NOEXIT]
75344dda7b2Smrg# Echo long help message to standard output and exit,
75444dda7b2Smrg# unless 'noexit' is passed as argument.
7557a3b38f7Smrgfunc_help ()
7567a3b38f7Smrg{
757862f5301Smrg    $opt_debug
758862f5301Smrg
7597a3b38f7Smrg    $SED -n '/^# Usage:/,/# Report bugs to/ {
760862f5301Smrg	:print
7617a3b38f7Smrg        s/^# //
7627a3b38f7Smrg	s/^# *$//
7637a3b38f7Smrg	s*\$progname*'$progname'*
7647a3b38f7Smrg	s*\$host*'"$host"'*
7657a3b38f7Smrg	s*\$SHELL*'"$SHELL"'*
7667a3b38f7Smrg	s*\$LTCC*'"$LTCC"'*
7677a3b38f7Smrg	s*\$LTCFLAGS*'"$LTCFLAGS"'*
7687a3b38f7Smrg	s*\$LD*'"$LD"'*
7697a3b38f7Smrg	s/\$with_gnu_ld/'"$with_gnu_ld"'/
770fc544a13Smrg	s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/
771fc544a13Smrg	s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/
7727a3b38f7Smrg	p
773862f5301Smrg	d
774862f5301Smrg     }
775862f5301Smrg     /^# .* home page:/b print
776862f5301Smrg     /^# General help using/b print
777862f5301Smrg     ' < "$progpath"
77844dda7b2Smrg    ret=$?
77944dda7b2Smrg    if test -z "$1"; then
78044dda7b2Smrg      exit $ret
78144dda7b2Smrg    fi
7827a3b38f7Smrg}
7837a3b38f7Smrg
7847a3b38f7Smrg# func_missing_arg argname
7857a3b38f7Smrg# Echo program name prefixed message to standard error and set global
7867a3b38f7Smrg# exit_cmd.
7877a3b38f7Smrgfunc_missing_arg ()
7887a3b38f7Smrg{
789862f5301Smrg    $opt_debug
790862f5301Smrg
79144dda7b2Smrg    func_error "missing argument for $1."
7927a3b38f7Smrg    exit_cmd=exit
7937a3b38f7Smrg}
7947a3b38f7Smrg
7957a3b38f7Smrg
796862f5301Smrg# func_split_short_opt shortopt
797862f5301Smrg# Set func_split_short_opt_name and func_split_short_opt_arg shell
798862f5301Smrg# variables after splitting SHORTOPT after the 2nd character.
799862f5301Smrgfunc_split_short_opt ()
800862f5301Smrg{
801862f5301Smrg    my_sed_short_opt='1s/^\(..\).*$/\1/;q'
802862f5301Smrg    my_sed_short_rest='1s/^..\(.*\)$/\1/;q'
803862f5301Smrg
804862f5301Smrg    func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"`
805862f5301Smrg    func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"`
806862f5301Smrg} # func_split_short_opt may be replaced by extended shell implementation
807862f5301Smrg
808862f5301Smrg
809862f5301Smrg# func_split_long_opt longopt
810862f5301Smrg# Set func_split_long_opt_name and func_split_long_opt_arg shell
811862f5301Smrg# variables after splitting LONGOPT at the `=' sign.
812862f5301Smrgfunc_split_long_opt ()
813862f5301Smrg{
814862f5301Smrg    my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q'
815862f5301Smrg    my_sed_long_arg='1s/^--[^=]*=//'
816862f5301Smrg
817862f5301Smrg    func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"`
818862f5301Smrg    func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"`
819862f5301Smrg} # func_split_long_opt may be replaced by extended shell implementation
820862f5301Smrg
821862f5301Smrgexit_cmd=:
8227a3b38f7Smrg
8237a3b38f7Smrg
8247a3b38f7Smrg
8257a3b38f7Smrg
826ff559fabSmrg
8277a3b38f7Smrgmagic="%%%MAGIC variable%%%"
8287a3b38f7Smrgmagic_exe="%%%MAGIC EXE variable%%%"
829ff559fabSmrg
8307a3b38f7Smrg# Global variables.
8317a3b38f7Smrgnonopt=
8327a3b38f7Smrgpreserve_args=
8337a3b38f7Smrglo2o="s/\\.lo\$/.${objext}/"
8347a3b38f7Smrgo2lo="s/\\.${objext}\$/.lo/"
8357a3b38f7Smrgextracted_archives=
8367a3b38f7Smrgextracted_serial=0
837ff559fabSmrg
8387a3b38f7Smrg# If this variable is set in any of the actions, the command in it
8397a3b38f7Smrg# will be execed at the end.  This prevents here-documents from being
8407a3b38f7Smrg# left over by shells.
8417a3b38f7Smrgexec_cmd=
842ff559fabSmrg
843862f5301Smrg# func_append var value
844862f5301Smrg# Append VALUE to the end of shell variable VAR.
845862f5301Smrgfunc_append ()
846862f5301Smrg{
847862f5301Smrg    eval "${1}=\$${1}\${2}"
848862f5301Smrg} # func_append may be replaced by extended shell implementation
849862f5301Smrg
850862f5301Smrg# func_append_quoted var value
851862f5301Smrg# Quote VALUE and append to the end of shell variable VAR, separated
852862f5301Smrg# by a space.
853862f5301Smrgfunc_append_quoted ()
854862f5301Smrg{
855862f5301Smrg    func_quote_for_eval "${2}"
856862f5301Smrg    eval "${1}=\$${1}\\ \$func_quote_for_eval_result"
857862f5301Smrg} # func_append_quoted may be replaced by extended shell implementation
858862f5301Smrg
859862f5301Smrg
860862f5301Smrg# func_arith arithmetic-term...
861862f5301Smrgfunc_arith ()
862862f5301Smrg{
863862f5301Smrg    func_arith_result=`expr "${@}"`
864862f5301Smrg} # func_arith may be replaced by extended shell implementation
865862f5301Smrg
866862f5301Smrg
867862f5301Smrg# func_len string
868862f5301Smrg# STRING may not start with a hyphen.
869862f5301Smrgfunc_len ()
870862f5301Smrg{
871862f5301Smrg    func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len`
872862f5301Smrg} # func_len may be replaced by extended shell implementation
873862f5301Smrg
874862f5301Smrg
875862f5301Smrg# func_lo2o object
876862f5301Smrgfunc_lo2o ()
877862f5301Smrg{
878862f5301Smrg    func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"`
879862f5301Smrg} # func_lo2o may be replaced by extended shell implementation
880862f5301Smrg
881862f5301Smrg
882862f5301Smrg# func_xform libobj-or-source
883862f5301Smrgfunc_xform ()
884862f5301Smrg{
885862f5301Smrg    func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'`
886862f5301Smrg} # func_xform may be replaced by extended shell implementation
887862f5301Smrg
888862f5301Smrg
8897a3b38f7Smrg# func_fatal_configuration arg...
8907a3b38f7Smrg# Echo program name prefixed message to standard error, followed by
8917a3b38f7Smrg# a configuration failure hint, and exit.
8927a3b38f7Smrgfunc_fatal_configuration ()
8937a3b38f7Smrg{
8947a3b38f7Smrg    func_error ${1+"$@"}
8957a3b38f7Smrg    func_error "See the $PACKAGE documentation for more information."
8967a3b38f7Smrg    func_fatal_error "Fatal configuration error."
8977a3b38f7Smrg}
8987a3b38f7Smrg
8997a3b38f7Smrg
9007a3b38f7Smrg# func_config
9017a3b38f7Smrg# Display the configuration for all the tags in this script.
9027a3b38f7Smrgfunc_config ()
9037a3b38f7Smrg{
9047a3b38f7Smrg    re_begincf='^# ### BEGIN LIBTOOL'
9057a3b38f7Smrg    re_endcf='^# ### END LIBTOOL'
9067a3b38f7Smrg
9077a3b38f7Smrg    # Default configuration.
9087a3b38f7Smrg    $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
909ff559fabSmrg
910ff559fabSmrg    # Now print the configurations for the tags.
911ff559fabSmrg    for tagname in $taglist; do
9127a3b38f7Smrg      $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
913ff559fabSmrg    done
914ff559fabSmrg
9157a3b38f7Smrg    exit $?
9167a3b38f7Smrg}
917ff559fabSmrg
9187a3b38f7Smrg# func_features
9197a3b38f7Smrg# Display the features supported by this script.
9207a3b38f7Smrgfunc_features ()
9217a3b38f7Smrg{
92244dda7b2Smrg    echo "host: $host"
923ff559fabSmrg    if test "$build_libtool_libs" = yes; then
92444dda7b2Smrg      echo "enable shared libraries"
925ff559fabSmrg    else
92644dda7b2Smrg      echo "disable shared libraries"
927ff559fabSmrg    fi
928ff559fabSmrg    if test "$build_old_libs" = yes; then
92944dda7b2Smrg      echo "enable static libraries"
930ff559fabSmrg    else
93144dda7b2Smrg      echo "disable static libraries"
932ff559fabSmrg    fi
9337a3b38f7Smrg
934ff559fabSmrg    exit $?
9357a3b38f7Smrg}
9367a3b38f7Smrg
9377a3b38f7Smrg# func_enable_tag tagname
9387a3b38f7Smrg# Verify that TAGNAME is valid, and either flag an error and exit, or
9397a3b38f7Smrg# enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
9407a3b38f7Smrg# variable here.
9417a3b38f7Smrgfunc_enable_tag ()
9427a3b38f7Smrg{
9437a3b38f7Smrg  # Global variable:
9447a3b38f7Smrg  tagname="$1"
945ff559fabSmrg
9467a3b38f7Smrg  re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
9477a3b38f7Smrg  re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
9487a3b38f7Smrg  sed_extractcf="/$re_begincf/,/$re_endcf/p"
949ff559fabSmrg
9507a3b38f7Smrg  # Validate tagname.
9517a3b38f7Smrg  case $tagname in
9527a3b38f7Smrg    *[!-_A-Za-z0-9,/]*)
9537a3b38f7Smrg      func_fatal_error "invalid tag name: $tagname"
9547a3b38f7Smrg      ;;
9557a3b38f7Smrg  esac
956ff559fabSmrg
9577a3b38f7Smrg  # Don't test for the "default" C tag, as we know it's
9587a3b38f7Smrg  # there but not specially marked.
9597a3b38f7Smrg  case $tagname in
9607a3b38f7Smrg    CC) ;;
9617a3b38f7Smrg    *)
9627a3b38f7Smrg      if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
9637a3b38f7Smrg	taglist="$taglist $tagname"
9647a3b38f7Smrg
9657a3b38f7Smrg	# Evaluate the configuration.  Be careful to quote the path
9667a3b38f7Smrg	# and the sed script, to avoid splitting on whitespace, but
9677a3b38f7Smrg	# also don't use non-portable quotes within backquotes within
9687a3b38f7Smrg	# quotes we have to do it in 2 steps:
9697a3b38f7Smrg	extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
9707a3b38f7Smrg	eval "$extractedcf"
9717a3b38f7Smrg      else
9727a3b38f7Smrg	func_error "ignoring unknown tag $tagname"
9737a3b38f7Smrg      fi
9747a3b38f7Smrg      ;;
9757a3b38f7Smrg  esac
9767a3b38f7Smrg}
977ff559fabSmrg
978862f5301Smrg# func_check_version_match
979862f5301Smrg# Ensure that we are using m4 macros, and libtool script from the same
980862f5301Smrg# release of libtool.
981862f5301Smrgfunc_check_version_match ()
9827a3b38f7Smrg{
983862f5301Smrg  if test "$package_revision" != "$macro_revision"; then
984862f5301Smrg    if test "$VERSION" != "$macro_version"; then
985862f5301Smrg      if test -z "$macro_version"; then
986862f5301Smrg        cat >&2 <<_LT_EOF
987862f5301Smrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
988862f5301Smrg$progname: definition of this LT_INIT comes from an older release.
989862f5301Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
990862f5301Smrg$progname: and run autoconf again.
991862f5301Smrg_LT_EOF
992862f5301Smrg      else
993862f5301Smrg        cat >&2 <<_LT_EOF
994862f5301Smrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
995862f5301Smrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
996862f5301Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
997862f5301Smrg$progname: and run autoconf again.
998862f5301Smrg_LT_EOF
999862f5301Smrg      fi
1000862f5301Smrg    else
1001862f5301Smrg      cat >&2 <<_LT_EOF
1002862f5301Smrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
1003862f5301Smrg$progname: but the definition of this LT_INIT comes from revision $macro_revision.
1004862f5301Smrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision
1005862f5301Smrg$progname: of $PACKAGE $VERSION and run autoconf again.
1006862f5301Smrg_LT_EOF
1007862f5301Smrg    fi
1008ff559fabSmrg
1009862f5301Smrg    exit $EXIT_MISMATCH
1010862f5301Smrg  fi
1011862f5301Smrg}
1012862f5301Smrg
1013862f5301Smrg
1014862f5301Smrg# Shorthand for --mode=foo, only valid as the first argument
1015862f5301Smrgcase $1 in
1016862f5301Smrgclean|clea|cle|cl)
1017862f5301Smrg  shift; set dummy --mode clean ${1+"$@"}; shift
1018862f5301Smrg  ;;
1019862f5301Smrgcompile|compil|compi|comp|com|co|c)
1020862f5301Smrg  shift; set dummy --mode compile ${1+"$@"}; shift
1021862f5301Smrg  ;;
1022862f5301Smrgexecute|execut|execu|exec|exe|ex|e)
1023862f5301Smrg  shift; set dummy --mode execute ${1+"$@"}; shift
1024862f5301Smrg  ;;
1025862f5301Smrgfinish|finis|fini|fin|fi|f)
1026862f5301Smrg  shift; set dummy --mode finish ${1+"$@"}; shift
1027862f5301Smrg  ;;
1028862f5301Smrginstall|instal|insta|inst|ins|in|i)
1029862f5301Smrg  shift; set dummy --mode install ${1+"$@"}; shift
1030862f5301Smrg  ;;
1031862f5301Smrglink|lin|li|l)
1032862f5301Smrg  shift; set dummy --mode link ${1+"$@"}; shift
1033862f5301Smrg  ;;
1034862f5301Smrguninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
1035862f5301Smrg  shift; set dummy --mode uninstall ${1+"$@"}; shift
1036862f5301Smrg  ;;
1037862f5301Smrgesac
1038ff559fabSmrg
1039862f5301Smrg
1040862f5301Smrg
1041862f5301Smrg# Option defaults:
1042862f5301Smrgopt_debug=:
1043862f5301Smrgopt_dry_run=false
1044862f5301Smrgopt_config=false
1045862f5301Smrgopt_preserve_dup_deps=false
1046862f5301Smrgopt_features=false
1047862f5301Smrgopt_finish=false
1048862f5301Smrgopt_help=false
1049862f5301Smrgopt_help_all=false
1050862f5301Smrgopt_silent=:
1051fc544a13Smrgopt_warning=:
1052862f5301Smrgopt_verbose=:
1053862f5301Smrgopt_silent=false
1054862f5301Smrgopt_verbose=false
1055862f5301Smrg
1056862f5301Smrg
1057862f5301Smrg# Parse options once, thoroughly.  This comes as soon as possible in the
1058862f5301Smrg# script to make things like `--version' happen as quickly as we can.
1059862f5301Smrg{
1060862f5301Smrg  # this just eases exit handling
1061862f5301Smrg  while test $# -gt 0; do
10627a3b38f7Smrg    opt="$1"
10637a3b38f7Smrg    shift
10647a3b38f7Smrg    case $opt in
1065862f5301Smrg      --debug|-x)	opt_debug='set -x'
10667a3b38f7Smrg			func_echo "enabling shell trace mode"
10677a3b38f7Smrg			$opt_debug
10687a3b38f7Smrg			;;
1069862f5301Smrg      --dry-run|--dryrun|-n)
1070862f5301Smrg			opt_dry_run=:
10717a3b38f7Smrg			;;
1072862f5301Smrg      --config)
1073862f5301Smrg			opt_config=:
1074862f5301Smrgfunc_config
1075862f5301Smrg			;;
1076862f5301Smrg      --dlopen|-dlopen)
1077862f5301Smrg			optarg="$1"
1078862f5301Smrg			opt_dlopen="${opt_dlopen+$opt_dlopen
1079862f5301Smrg}$optarg"
10807a3b38f7Smrg			shift
10817a3b38f7Smrg			;;
10827a3b38f7Smrg      --preserve-dup-deps)
1083862f5301Smrg			opt_preserve_dup_deps=:
108444dda7b2Smrg			;;
1085862f5301Smrg      --features)
1086862f5301Smrg			opt_features=:
1087862f5301Smrgfunc_features
10887a3b38f7Smrg			;;
1089862f5301Smrg      --finish)
1090862f5301Smrg			opt_finish=:
1091862f5301Smrgset dummy --mode finish ${1+"$@"}; shift
1092862f5301Smrg			;;
1093862f5301Smrg      --help)
1094862f5301Smrg			opt_help=:
1095862f5301Smrg			;;
1096862f5301Smrg      --help-all)
1097862f5301Smrg			opt_help_all=:
1098862f5301Smrgopt_help=': help-all'
1099862f5301Smrg			;;
1100862f5301Smrg      --mode)
1101862f5301Smrg			test $# = 0 && func_missing_arg $opt && break
1102862f5301Smrg			optarg="$1"
1103862f5301Smrg			opt_mode="$optarg"
1104862f5301Smrgcase $optarg in
1105862f5301Smrg  # Valid mode arguments:
1106862f5301Smrg  clean|compile|execute|finish|install|link|relink|uninstall) ;;
1107862f5301Smrg
1108862f5301Smrg  # Catch anything else as an error
1109862f5301Smrg  *) func_error "invalid argument for $opt"
1110862f5301Smrg     exit_cmd=exit
1111862f5301Smrg     break
1112862f5301Smrg     ;;
1113862f5301Smrgesac
1114862f5301Smrg			shift
1115862f5301Smrg			;;
1116862f5301Smrg      --no-silent|--no-quiet)
11177a3b38f7Smrg			opt_silent=false
1118fc544a13Smrgfunc_append preserve_args " $opt"
1119fc544a13Smrg			;;
1120fc544a13Smrg      --no-warning|--no-warn)
1121fc544a13Smrg			opt_warning=false
1122862f5301Smrgfunc_append preserve_args " $opt"
112344dda7b2Smrg			;;
1124862f5301Smrg      --no-verbose)
112544dda7b2Smrg			opt_verbose=false
1126862f5301Smrgfunc_append preserve_args " $opt"
11277a3b38f7Smrg			;;
1128862f5301Smrg      --silent|--quiet)
1129862f5301Smrg			opt_silent=:
1130862f5301Smrgfunc_append preserve_args " $opt"
1131862f5301Smrg        opt_verbose=false
1132862f5301Smrg			;;
1133862f5301Smrg      --verbose|-v)
1134862f5301Smrg			opt_verbose=:
1135862f5301Smrgfunc_append preserve_args " $opt"
1136862f5301Smrgopt_silent=false
1137862f5301Smrg			;;
1138862f5301Smrg      --tag)
1139862f5301Smrg			test $# = 0 && func_missing_arg $opt && break
1140862f5301Smrg			optarg="$1"
1141862f5301Smrg			opt_tag="$optarg"
1142862f5301Smrgfunc_append preserve_args " $opt $optarg"
1143862f5301Smrgfunc_enable_tag "$optarg"
11447a3b38f7Smrg			shift
11457a3b38f7Smrg			;;
11467a3b38f7Smrg
1147862f5301Smrg      -\?|-h)		func_usage				;;
1148862f5301Smrg      --help)		func_help				;;
1149862f5301Smrg      --version)	func_version				;;
1150862f5301Smrg
11517a3b38f7Smrg      # Separate optargs to long options:
1152862f5301Smrg      --*=*)
1153862f5301Smrg			func_split_long_opt "$opt"
1154862f5301Smrg			set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"}
11557a3b38f7Smrg			shift
11567a3b38f7Smrg			;;
11577a3b38f7Smrg
1158862f5301Smrg      # Separate non-argument short options:
1159862f5301Smrg      -\?*|-h*|-n*|-v*)
1160862f5301Smrg			func_split_short_opt "$opt"
1161862f5301Smrg			set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"}
1162862f5301Smrg			shift
11637a3b38f7Smrg			;;
1164862f5301Smrg
1165862f5301Smrg      --)		break					;;
1166862f5301Smrg      -*)		func_fatal_help "unrecognized option \`$opt'" ;;
1167862f5301Smrg      *)		set dummy "$opt" ${1+"$@"};	shift; break  ;;
11687a3b38f7Smrg    esac
11697a3b38f7Smrg  done
11707a3b38f7Smrg
1171862f5301Smrg  # Validate options:
1172862f5301Smrg
1173862f5301Smrg  # save first non-option argument
1174862f5301Smrg  if test "$#" -gt 0; then
1175862f5301Smrg    nonopt="$opt"
1176862f5301Smrg    shift
1177862f5301Smrg  fi
1178862f5301Smrg
1179862f5301Smrg  # preserve --debug
1180862f5301Smrg  test "$opt_debug" = : || func_append preserve_args " --debug"
11817a3b38f7Smrg
11827a3b38f7Smrg  case $host in
11837a3b38f7Smrg    *cygwin* | *mingw* | *pw32* | *cegcc*)
11847a3b38f7Smrg      # don't eliminate duplications in $postdeps and $predeps
11857a3b38f7Smrg      opt_duplicate_compiler_generated_deps=:
1186ff559fabSmrg      ;;
1187ff559fabSmrg    *)
1188862f5301Smrg      opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
11897a3b38f7Smrg      ;;
11907a3b38f7Smrg  esac
1191ff559fabSmrg
1192862f5301Smrg  $opt_help || {
1193862f5301Smrg    # Sanity checks first:
1194862f5301Smrg    func_check_version_match
11957a3b38f7Smrg
1196862f5301Smrg    if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
1197862f5301Smrg      func_fatal_configuration "not configured to build any kind of library"
11987a3b38f7Smrg    fi
11997a3b38f7Smrg
1200862f5301Smrg    # Darwin sucks
1201862f5301Smrg    eval std_shrext=\"$shrext_cmds\"
12027a3b38f7Smrg
1203862f5301Smrg    # Only execute mode is allowed to have -dlopen flags.
1204862f5301Smrg    if test -n "$opt_dlopen" && test "$opt_mode" != execute; then
1205862f5301Smrg      func_error "unrecognized option \`-dlopen'"
1206862f5301Smrg      $ECHO "$help" 1>&2
1207862f5301Smrg      exit $EXIT_FAILURE
1208862f5301Smrg    fi
12097a3b38f7Smrg
1210862f5301Smrg    # Change the help message to a mode-specific one.
1211862f5301Smrg    generic_help="$help"
1212862f5301Smrg    help="Try \`$progname --help --mode=$opt_mode' for more information."
1213862f5301Smrg  }
12147a3b38f7Smrg
12157a3b38f7Smrg
1216862f5301Smrg  # Bail if the options were screwed
1217862f5301Smrg  $exit_cmd $EXIT_FAILURE
1218862f5301Smrg}
12197a3b38f7Smrg
12207a3b38f7Smrg
1221ff559fabSmrg
1222ff559fabSmrg
1223862f5301Smrg## ----------- ##
1224862f5301Smrg##    Main.    ##
1225862f5301Smrg## ----------- ##
1226ff559fabSmrg
12277a3b38f7Smrg# func_lalib_p file
12287a3b38f7Smrg# True iff FILE is a libtool `.la' library or `.lo' object file.
12297a3b38f7Smrg# This function is only a basic sanity check; it will hardly flush out
12307a3b38f7Smrg# determined imposters.
12317a3b38f7Smrgfunc_lalib_p ()
12327a3b38f7Smrg{
12337a3b38f7Smrg    test -f "$1" &&
12347a3b38f7Smrg      $SED -e 4q "$1" 2>/dev/null \
12357a3b38f7Smrg        | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
12367a3b38f7Smrg}
1237ff559fabSmrg
12387a3b38f7Smrg# func_lalib_unsafe_p file
12397a3b38f7Smrg# True iff FILE is a libtool `.la' library or `.lo' object file.
12407a3b38f7Smrg# This function implements the same check as func_lalib_p without
12417a3b38f7Smrg# resorting to external programs.  To this end, it redirects stdin and
12427a3b38f7Smrg# closes it afterwards, without saving the original file descriptor.
12437a3b38f7Smrg# As a safety measure, use it only where a negative result would be
12447a3b38f7Smrg# fatal anyway.  Works if `file' does not exist.
12457a3b38f7Smrgfunc_lalib_unsafe_p ()
12467a3b38f7Smrg{
12477a3b38f7Smrg    lalib_p=no
12487a3b38f7Smrg    if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
12497a3b38f7Smrg	for lalib_p_l in 1 2 3 4
12507a3b38f7Smrg	do
12517a3b38f7Smrg	    read lalib_p_line
12527a3b38f7Smrg	    case "$lalib_p_line" in
12537a3b38f7Smrg		\#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
12547a3b38f7Smrg	    esac
12557a3b38f7Smrg	done
12567a3b38f7Smrg	exec 0<&5 5<&-
12577a3b38f7Smrg    fi
12587a3b38f7Smrg    test "$lalib_p" = yes
12597a3b38f7Smrg}
1260ff559fabSmrg
12617a3b38f7Smrg# func_ltwrapper_script_p file
12627a3b38f7Smrg# True iff FILE is a libtool wrapper script
12637a3b38f7Smrg# This function is only a basic sanity check; it will hardly flush out
12647a3b38f7Smrg# determined imposters.
12657a3b38f7Smrgfunc_ltwrapper_script_p ()
12667a3b38f7Smrg{
12677a3b38f7Smrg    func_lalib_p "$1"
12687a3b38f7Smrg}
1269ff559fabSmrg
12707a3b38f7Smrg# func_ltwrapper_executable_p file
12717a3b38f7Smrg# True iff FILE is a libtool wrapper executable
12727a3b38f7Smrg# This function is only a basic sanity check; it will hardly flush out
12737a3b38f7Smrg# determined imposters.
12747a3b38f7Smrgfunc_ltwrapper_executable_p ()
12757a3b38f7Smrg{
12767a3b38f7Smrg    func_ltwrapper_exec_suffix=
12777a3b38f7Smrg    case $1 in
12787a3b38f7Smrg    *.exe) ;;
12797a3b38f7Smrg    *) func_ltwrapper_exec_suffix=.exe ;;
12807a3b38f7Smrg    esac
12817a3b38f7Smrg    $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
12827a3b38f7Smrg}
1283ff559fabSmrg
12847a3b38f7Smrg# func_ltwrapper_scriptname file
12857a3b38f7Smrg# Assumes file is an ltwrapper_executable
12867a3b38f7Smrg# uses $file to determine the appropriate filename for a
12877a3b38f7Smrg# temporary ltwrapper_script.
12887a3b38f7Smrgfunc_ltwrapper_scriptname ()
12897a3b38f7Smrg{
1290862f5301Smrg    func_dirname_and_basename "$1" "" "."
1291862f5301Smrg    func_stripname '' '.exe' "$func_basename_result"
1292862f5301Smrg    func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper"
12937a3b38f7Smrg}
1294ff559fabSmrg
12957a3b38f7Smrg# func_ltwrapper_p file
12967a3b38f7Smrg# True iff FILE is a libtool wrapper script or wrapper executable
12977a3b38f7Smrg# This function is only a basic sanity check; it will hardly flush out
12987a3b38f7Smrg# determined imposters.
12997a3b38f7Smrgfunc_ltwrapper_p ()
13007a3b38f7Smrg{
13017a3b38f7Smrg    func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
13027a3b38f7Smrg}
1303ff559fabSmrg
1304ff559fabSmrg
13057a3b38f7Smrg# func_execute_cmds commands fail_cmd
13067a3b38f7Smrg# Execute tilde-delimited COMMANDS.
13077a3b38f7Smrg# If FAIL_CMD is given, eval that upon failure.
13087a3b38f7Smrg# FAIL_CMD may read-access the current command in variable CMD!
13097a3b38f7Smrgfunc_execute_cmds ()
13107a3b38f7Smrg{
13117a3b38f7Smrg    $opt_debug
13127a3b38f7Smrg    save_ifs=$IFS; IFS='~'
13137a3b38f7Smrg    for cmd in $1; do
13147a3b38f7Smrg      IFS=$save_ifs
13157a3b38f7Smrg      eval cmd=\"$cmd\"
13167a3b38f7Smrg      func_show_eval "$cmd" "${2-:}"
13177a3b38f7Smrg    done
13187a3b38f7Smrg    IFS=$save_ifs
13197a3b38f7Smrg}
13207a3b38f7Smrg
13217a3b38f7Smrg
13227a3b38f7Smrg# func_source file
13237a3b38f7Smrg# Source FILE, adding directory component if necessary.
13247a3b38f7Smrg# Note that it is not necessary on cygwin/mingw to append a dot to
13257a3b38f7Smrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe
13267a3b38f7Smrg# behavior happens only for exec(3), not for open(2)!  Also, sourcing
13277a3b38f7Smrg# `FILE.' does not work on cygwin managed mounts.
13287a3b38f7Smrgfunc_source ()
13297a3b38f7Smrg{
13307a3b38f7Smrg    $opt_debug
13317a3b38f7Smrg    case $1 in
13327a3b38f7Smrg    */* | *\\*)	. "$1" ;;
13337a3b38f7Smrg    *)		. "./$1" ;;
13347a3b38f7Smrg    esac
13357a3b38f7Smrg}
13367a3b38f7Smrg
13377a3b38f7Smrg
1338862f5301Smrg# func_resolve_sysroot PATH
1339862f5301Smrg# Replace a leading = in PATH with a sysroot.  Store the result into
1340862f5301Smrg# func_resolve_sysroot_result
1341862f5301Smrgfunc_resolve_sysroot ()
1342862f5301Smrg{
1343862f5301Smrg  func_resolve_sysroot_result=$1
1344862f5301Smrg  case $func_resolve_sysroot_result in
1345862f5301Smrg  =*)
1346862f5301Smrg    func_stripname '=' '' "$func_resolve_sysroot_result"
1347862f5301Smrg    func_resolve_sysroot_result=$lt_sysroot$func_stripname_result
1348862f5301Smrg    ;;
1349862f5301Smrg  esac
1350862f5301Smrg}
1351862f5301Smrg
1352862f5301Smrg# func_replace_sysroot PATH
1353862f5301Smrg# If PATH begins with the sysroot, replace it with = and
1354862f5301Smrg# store the result into func_replace_sysroot_result.
1355862f5301Smrgfunc_replace_sysroot ()
1356862f5301Smrg{
1357862f5301Smrg  case "$lt_sysroot:$1" in
1358862f5301Smrg  ?*:"$lt_sysroot"*)
1359862f5301Smrg    func_stripname "$lt_sysroot" '' "$1"
1360862f5301Smrg    func_replace_sysroot_result="=$func_stripname_result"
1361862f5301Smrg    ;;
1362862f5301Smrg  *)
1363862f5301Smrg    # Including no sysroot.
1364862f5301Smrg    func_replace_sysroot_result=$1
1365862f5301Smrg    ;;
1366862f5301Smrg  esac
1367862f5301Smrg}
1368862f5301Smrg
13697a3b38f7Smrg# func_infer_tag arg
13707a3b38f7Smrg# Infer tagged configuration to use if any are available and
13717a3b38f7Smrg# if one wasn't chosen via the "--tag" command line option.
13727a3b38f7Smrg# Only attempt this if the compiler in the base compile
13737a3b38f7Smrg# command doesn't match the default compiler.
13747a3b38f7Smrg# arg is usually of the form 'gcc ...'
13757a3b38f7Smrgfunc_infer_tag ()
13767a3b38f7Smrg{
13777a3b38f7Smrg    $opt_debug
13787a3b38f7Smrg    if test -n "$available_tags" && test -z "$tagname"; then
13797a3b38f7Smrg      CC_quoted=
13807a3b38f7Smrg      for arg in $CC; do
1381862f5301Smrg	func_append_quoted CC_quoted "$arg"
13827a3b38f7Smrg      done
138344dda7b2Smrg      CC_expanded=`func_echo_all $CC`
138444dda7b2Smrg      CC_quoted_expanded=`func_echo_all $CC_quoted`
13857a3b38f7Smrg      case $@ in
13867a3b38f7Smrg      # Blanks in the command may have been stripped by the calling shell,
13877a3b38f7Smrg      # but not from the CC environment variable when configure was run.
138844dda7b2Smrg      " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
138944dda7b2Smrg      " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
13907a3b38f7Smrg      # Blanks at the start of $base_compile will cause this to fail
13917a3b38f7Smrg      # if we don't check for them as well.
13927a3b38f7Smrg      *)
13937a3b38f7Smrg	for z in $available_tags; do
13947a3b38f7Smrg	  if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
13957a3b38f7Smrg	    # Evaluate the configuration.
13967a3b38f7Smrg	    eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
13977a3b38f7Smrg	    CC_quoted=
13987a3b38f7Smrg	    for arg in $CC; do
13997a3b38f7Smrg	      # Double-quote args containing other shell metacharacters.
1400862f5301Smrg	      func_append_quoted CC_quoted "$arg"
14017a3b38f7Smrg	    done
140244dda7b2Smrg	    CC_expanded=`func_echo_all $CC`
140344dda7b2Smrg	    CC_quoted_expanded=`func_echo_all $CC_quoted`
14047a3b38f7Smrg	    case "$@ " in
140544dda7b2Smrg	    " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
140644dda7b2Smrg	    " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
14077a3b38f7Smrg	      # The compiler in the base compile command matches
14087a3b38f7Smrg	      # the one in the tagged configuration.
14097a3b38f7Smrg	      # Assume this is the tagged configuration we want.
14107a3b38f7Smrg	      tagname=$z
14117a3b38f7Smrg	      break
14127a3b38f7Smrg	      ;;
1413ff559fabSmrg	    esac
14147a3b38f7Smrg	  fi
14157a3b38f7Smrg	done
14167a3b38f7Smrg	# If $tagname still isn't set, then no tagged configuration
14177a3b38f7Smrg	# was found and let the user know that the "--tag" command
14187a3b38f7Smrg	# line option must be used.
14197a3b38f7Smrg	if test -z "$tagname"; then
14207a3b38f7Smrg	  func_echo "unable to infer tagged configuration"
14217a3b38f7Smrg	  func_fatal_error "specify a tag with \`--tag'"
14227a3b38f7Smrg#	else
14237a3b38f7Smrg#	  func_verbose "using $tagname tagged configuration"
14247a3b38f7Smrg	fi
14257a3b38f7Smrg	;;
14267a3b38f7Smrg      esac
14277a3b38f7Smrg    fi
14287a3b38f7Smrg}
14297a3b38f7Smrg
14307a3b38f7Smrg
14317a3b38f7Smrg
1432862f5301Smrg# func_write_libtool_object output_name pic_name nonpic_name
1433862f5301Smrg# Create a libtool object file (analogous to a ".la" file),
1434862f5301Smrg# but don't create it if we're doing a dry run.
1435862f5301Smrgfunc_write_libtool_object ()
1436862f5301Smrg{
1437862f5301Smrg    write_libobj=${1}
1438862f5301Smrg    if test "$build_libtool_libs" = yes; then
1439862f5301Smrg      write_lobj=\'${2}\'
1440862f5301Smrg    else
1441862f5301Smrg      write_lobj=none
1442862f5301Smrg    fi
1443862f5301Smrg
1444862f5301Smrg    if test "$build_old_libs" = yes; then
1445862f5301Smrg      write_oldobj=\'${3}\'
1446862f5301Smrg    else
1447862f5301Smrg      write_oldobj=none
1448862f5301Smrg    fi
1449862f5301Smrg
1450862f5301Smrg    $opt_dry_run || {
1451862f5301Smrg      cat >${write_libobj}T <<EOF
1452862f5301Smrg# $write_libobj - a libtool object file
1453862f5301Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
1454862f5301Smrg#
1455862f5301Smrg# Please DO NOT delete this file!
1456862f5301Smrg# It is necessary for linking the library.
1457862f5301Smrg
1458862f5301Smrg# Name of the PIC object.
1459862f5301Smrgpic_object=$write_lobj
1460862f5301Smrg
1461862f5301Smrg# Name of the non-PIC object
1462862f5301Smrgnon_pic_object=$write_oldobj
1463862f5301Smrg
1464862f5301SmrgEOF
1465862f5301Smrg      $MV "${write_libobj}T" "${write_libobj}"
1466862f5301Smrg    }
1467862f5301Smrg}
1468862f5301Smrg
1469862f5301Smrg
1470862f5301Smrg##################################################
1471862f5301Smrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS #
1472862f5301Smrg##################################################
1473862f5301Smrg
1474862f5301Smrg# func_convert_core_file_wine_to_w32 ARG
1475862f5301Smrg# Helper function used by file name conversion functions when $build is *nix,
1476862f5301Smrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a
1477862f5301Smrg# correctly configured wine environment available, with the winepath program
1478862f5301Smrg# in $build's $PATH.
1479862f5301Smrg#
1480862f5301Smrg# ARG is the $build file name to be converted to w32 format.
1481862f5301Smrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will
1482862f5301Smrg# be empty on error (or when ARG is empty)
1483862f5301Smrgfunc_convert_core_file_wine_to_w32 ()
1484862f5301Smrg{
1485862f5301Smrg  $opt_debug
1486862f5301Smrg  func_convert_core_file_wine_to_w32_result="$1"
1487862f5301Smrg  if test -n "$1"; then
1488862f5301Smrg    # Unfortunately, winepath does not exit with a non-zero error code, so we
1489862f5301Smrg    # are forced to check the contents of stdout. On the other hand, if the
1490862f5301Smrg    # command is not found, the shell will set an exit code of 127 and print
1491862f5301Smrg    # *an error message* to stdout. So we must check for both error code of
1492862f5301Smrg    # zero AND non-empty stdout, which explains the odd construction:
1493862f5301Smrg    func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
1494862f5301Smrg    if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then
1495862f5301Smrg      func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
1496862f5301Smrg        $SED -e "$lt_sed_naive_backslashify"`
1497862f5301Smrg    else
1498862f5301Smrg      func_convert_core_file_wine_to_w32_result=
1499862f5301Smrg    fi
1500862f5301Smrg  fi
1501862f5301Smrg}
1502862f5301Smrg# end: func_convert_core_file_wine_to_w32
1503862f5301Smrg
1504862f5301Smrg
1505862f5301Smrg# func_convert_core_path_wine_to_w32 ARG
1506862f5301Smrg# Helper function used by path conversion functions when $build is *nix, and
1507862f5301Smrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly
1508862f5301Smrg# configured wine environment available, with the winepath program in $build's
1509862f5301Smrg# $PATH. Assumes ARG has no leading or trailing path separator characters.
1510862f5301Smrg#
1511862f5301Smrg# ARG is path to be converted from $build format to win32.
1512862f5301Smrg# Result is available in $func_convert_core_path_wine_to_w32_result.
1513862f5301Smrg# Unconvertible file (directory) names in ARG are skipped; if no directory names
1514862f5301Smrg# are convertible, then the result may be empty.
1515862f5301Smrgfunc_convert_core_path_wine_to_w32 ()
1516862f5301Smrg{
1517862f5301Smrg  $opt_debug
1518862f5301Smrg  # unfortunately, winepath doesn't convert paths, only file names
1519862f5301Smrg  func_convert_core_path_wine_to_w32_result=""
1520862f5301Smrg  if test -n "$1"; then
1521862f5301Smrg    oldIFS=$IFS
1522862f5301Smrg    IFS=:
1523862f5301Smrg    for func_convert_core_path_wine_to_w32_f in $1; do
1524862f5301Smrg      IFS=$oldIFS
1525862f5301Smrg      func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
1526862f5301Smrg      if test -n "$func_convert_core_file_wine_to_w32_result" ; then
1527862f5301Smrg        if test -z "$func_convert_core_path_wine_to_w32_result"; then
1528862f5301Smrg          func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result"
1529862f5301Smrg        else
1530862f5301Smrg          func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
1531862f5301Smrg        fi
1532862f5301Smrg      fi
1533862f5301Smrg    done
1534862f5301Smrg    IFS=$oldIFS
1535862f5301Smrg  fi
1536862f5301Smrg}
1537862f5301Smrg# end: func_convert_core_path_wine_to_w32
1538862f5301Smrg
1539862f5301Smrg
1540862f5301Smrg# func_cygpath ARGS...
1541862f5301Smrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when
1542862f5301Smrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2)
1543862f5301Smrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or
1544862f5301Smrg# (2), returns the Cygwin file name or path in func_cygpath_result (input
1545862f5301Smrg# file name or path is assumed to be in w32 format, as previously converted
1546862f5301Smrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name
1547862f5301Smrg# or path in func_cygpath_result (input file name or path is assumed to be in
1548862f5301Smrg# Cygwin format). Returns an empty string on error.
1549862f5301Smrg#
1550862f5301Smrg# ARGS are passed to cygpath, with the last one being the file name or path to
1551862f5301Smrg# be converted.
1552862f5301Smrg#
1553862f5301Smrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH
1554862f5301Smrg# environment variable; do not put it in $PATH.
1555862f5301Smrgfunc_cygpath ()
1556862f5301Smrg{
1557862f5301Smrg  $opt_debug
1558862f5301Smrg  if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
1559862f5301Smrg    func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
1560862f5301Smrg    if test "$?" -ne 0; then
1561862f5301Smrg      # on failure, ensure result is empty
1562862f5301Smrg      func_cygpath_result=
1563862f5301Smrg    fi
1564862f5301Smrg  else
1565862f5301Smrg    func_cygpath_result=
1566862f5301Smrg    func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'"
1567862f5301Smrg  fi
1568862f5301Smrg}
1569862f5301Smrg#end: func_cygpath
1570862f5301Smrg
1571862f5301Smrg
1572862f5301Smrg# func_convert_core_msys_to_w32 ARG
1573862f5301Smrg# Convert file name or path ARG from MSYS format to w32 format.  Return
1574862f5301Smrg# result in func_convert_core_msys_to_w32_result.
1575862f5301Smrgfunc_convert_core_msys_to_w32 ()
1576862f5301Smrg{
1577862f5301Smrg  $opt_debug
1578862f5301Smrg  # awkward: cmd appends spaces to result
1579862f5301Smrg  func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
1580862f5301Smrg    $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"`
1581862f5301Smrg}
1582862f5301Smrg#end: func_convert_core_msys_to_w32
1583862f5301Smrg
1584862f5301Smrg
1585862f5301Smrg# func_convert_file_check ARG1 ARG2
1586862f5301Smrg# Verify that ARG1 (a file name in $build format) was converted to $host
1587862f5301Smrg# format in ARG2. Otherwise, emit an error message, but continue (resetting
1588862f5301Smrg# func_to_host_file_result to ARG1).
1589862f5301Smrgfunc_convert_file_check ()
1590862f5301Smrg{
1591862f5301Smrg  $opt_debug
1592862f5301Smrg  if test -z "$2" && test -n "$1" ; then
1593862f5301Smrg    func_error "Could not determine host file name corresponding to"
1594862f5301Smrg    func_error "  \`$1'"
1595862f5301Smrg    func_error "Continuing, but uninstalled executables may not work."
1596862f5301Smrg    # Fallback:
1597862f5301Smrg    func_to_host_file_result="$1"
1598862f5301Smrg  fi
1599862f5301Smrg}
1600862f5301Smrg# end func_convert_file_check
1601862f5301Smrg
1602862f5301Smrg
1603862f5301Smrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH
1604862f5301Smrg# Verify that FROM_PATH (a path in $build format) was converted to $host
1605862f5301Smrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting
1606862f5301Smrg# func_to_host_file_result to a simplistic fallback value (see below).
1607862f5301Smrgfunc_convert_path_check ()
1608862f5301Smrg{
1609862f5301Smrg  $opt_debug
1610862f5301Smrg  if test -z "$4" && test -n "$3"; then
1611862f5301Smrg    func_error "Could not determine the host path corresponding to"
1612862f5301Smrg    func_error "  \`$3'"
1613862f5301Smrg    func_error "Continuing, but uninstalled executables may not work."
1614862f5301Smrg    # Fallback.  This is a deliberately simplistic "conversion" and
1615862f5301Smrg    # should not be "improved".  See libtool.info.
1616862f5301Smrg    if test "x$1" != "x$2"; then
1617862f5301Smrg      lt_replace_pathsep_chars="s|$1|$2|g"
1618862f5301Smrg      func_to_host_path_result=`echo "$3" |
1619862f5301Smrg        $SED -e "$lt_replace_pathsep_chars"`
1620862f5301Smrg    else
1621862f5301Smrg      func_to_host_path_result="$3"
1622862f5301Smrg    fi
1623862f5301Smrg  fi
1624862f5301Smrg}
1625862f5301Smrg# end func_convert_path_check
1626862f5301Smrg
1627862f5301Smrg
1628862f5301Smrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG
1629862f5301Smrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT
1630862f5301Smrg# and appending REPL if ORIG matches BACKPAT.
1631862f5301Smrgfunc_convert_path_front_back_pathsep ()
1632862f5301Smrg{
1633862f5301Smrg  $opt_debug
1634862f5301Smrg  case $4 in
1635862f5301Smrg  $1 ) func_to_host_path_result="$3$func_to_host_path_result"
1636862f5301Smrg    ;;
1637862f5301Smrg  esac
1638862f5301Smrg  case $4 in
1639862f5301Smrg  $2 ) func_append func_to_host_path_result "$3"
1640862f5301Smrg    ;;
1641862f5301Smrg  esac
1642862f5301Smrg}
1643862f5301Smrg# end func_convert_path_front_back_pathsep
1644862f5301Smrg
1645862f5301Smrg
1646862f5301Smrg##################################################
1647862f5301Smrg# $build to $host FILE NAME CONVERSION FUNCTIONS #
1648862f5301Smrg##################################################
1649862f5301Smrg# invoked via `$to_host_file_cmd ARG'
1650862f5301Smrg#
1651862f5301Smrg# In each case, ARG is the path to be converted from $build to $host format.
1652862f5301Smrg# Result will be available in $func_to_host_file_result.
1653862f5301Smrg
1654862f5301Smrg
1655862f5301Smrg# func_to_host_file ARG
1656862f5301Smrg# Converts the file name ARG from $build format to $host format. Return result
1657862f5301Smrg# in func_to_host_file_result.
1658862f5301Smrgfunc_to_host_file ()
1659862f5301Smrg{
1660862f5301Smrg  $opt_debug
1661862f5301Smrg  $to_host_file_cmd "$1"
1662862f5301Smrg}
1663862f5301Smrg# end func_to_host_file
1664862f5301Smrg
1665862f5301Smrg
1666862f5301Smrg# func_to_tool_file ARG LAZY
1667862f5301Smrg# converts the file name ARG from $build format to toolchain format. Return
1668862f5301Smrg# result in func_to_tool_file_result.  If the conversion in use is listed
1669862f5301Smrg# in (the comma separated) LAZY, no conversion takes place.
1670862f5301Smrgfunc_to_tool_file ()
1671862f5301Smrg{
1672862f5301Smrg  $opt_debug
1673862f5301Smrg  case ,$2, in
1674862f5301Smrg    *,"$to_tool_file_cmd",*)
1675862f5301Smrg      func_to_tool_file_result=$1
1676862f5301Smrg      ;;
1677862f5301Smrg    *)
1678862f5301Smrg      $to_tool_file_cmd "$1"
1679862f5301Smrg      func_to_tool_file_result=$func_to_host_file_result
1680862f5301Smrg      ;;
1681862f5301Smrg  esac
1682862f5301Smrg}
1683862f5301Smrg# end func_to_tool_file
1684862f5301Smrg
1685862f5301Smrg
1686862f5301Smrg# func_convert_file_noop ARG
1687862f5301Smrg# Copy ARG to func_to_host_file_result.
1688862f5301Smrgfunc_convert_file_noop ()
1689862f5301Smrg{
1690862f5301Smrg  func_to_host_file_result="$1"
1691862f5301Smrg}
1692862f5301Smrg# end func_convert_file_noop
1693862f5301Smrg
1694862f5301Smrg
1695862f5301Smrg# func_convert_file_msys_to_w32 ARG
1696862f5301Smrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic
1697862f5301Smrg# conversion to w32 is not available inside the cwrapper.  Returns result in
1698862f5301Smrg# func_to_host_file_result.
1699862f5301Smrgfunc_convert_file_msys_to_w32 ()
1700862f5301Smrg{
1701862f5301Smrg  $opt_debug
1702862f5301Smrg  func_to_host_file_result="$1"
1703862f5301Smrg  if test -n "$1"; then
1704862f5301Smrg    func_convert_core_msys_to_w32 "$1"
1705862f5301Smrg    func_to_host_file_result="$func_convert_core_msys_to_w32_result"
1706862f5301Smrg  fi
1707862f5301Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
1708862f5301Smrg}
1709862f5301Smrg# end func_convert_file_msys_to_w32
1710862f5301Smrg
1711862f5301Smrg
1712862f5301Smrg# func_convert_file_cygwin_to_w32 ARG
1713862f5301Smrg# Convert file name ARG from Cygwin to w32 format.  Returns result in
1714862f5301Smrg# func_to_host_file_result.
1715862f5301Smrgfunc_convert_file_cygwin_to_w32 ()
1716862f5301Smrg{
1717862f5301Smrg  $opt_debug
1718862f5301Smrg  func_to_host_file_result="$1"
1719862f5301Smrg  if test -n "$1"; then
1720862f5301Smrg    # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
1721862f5301Smrg    # LT_CYGPATH in this case.
1722862f5301Smrg    func_to_host_file_result=`cygpath -m "$1"`
1723862f5301Smrg  fi
1724862f5301Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
1725862f5301Smrg}
1726862f5301Smrg# end func_convert_file_cygwin_to_w32
1727862f5301Smrg
1728862f5301Smrg
1729862f5301Smrg# func_convert_file_nix_to_w32 ARG
1730862f5301Smrg# Convert file name ARG from *nix to w32 format.  Requires a wine environment
1731862f5301Smrg# and a working winepath. Returns result in func_to_host_file_result.
1732862f5301Smrgfunc_convert_file_nix_to_w32 ()
1733862f5301Smrg{
1734862f5301Smrg  $opt_debug
1735862f5301Smrg  func_to_host_file_result="$1"
1736862f5301Smrg  if test -n "$1"; then
1737862f5301Smrg    func_convert_core_file_wine_to_w32 "$1"
1738862f5301Smrg    func_to_host_file_result="$func_convert_core_file_wine_to_w32_result"
1739862f5301Smrg  fi
1740862f5301Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
1741862f5301Smrg}
1742862f5301Smrg# end func_convert_file_nix_to_w32
1743862f5301Smrg
1744862f5301Smrg
1745862f5301Smrg# func_convert_file_msys_to_cygwin ARG
1746862f5301Smrg# Convert file name ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
1747862f5301Smrg# Returns result in func_to_host_file_result.
1748862f5301Smrgfunc_convert_file_msys_to_cygwin ()
1749862f5301Smrg{
1750862f5301Smrg  $opt_debug
1751862f5301Smrg  func_to_host_file_result="$1"
1752862f5301Smrg  if test -n "$1"; then
1753862f5301Smrg    func_convert_core_msys_to_w32 "$1"
1754862f5301Smrg    func_cygpath -u "$func_convert_core_msys_to_w32_result"
1755862f5301Smrg    func_to_host_file_result="$func_cygpath_result"
1756862f5301Smrg  fi
1757862f5301Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
1758862f5301Smrg}
1759862f5301Smrg# end func_convert_file_msys_to_cygwin
1760862f5301Smrg
1761862f5301Smrg
1762862f5301Smrg# func_convert_file_nix_to_cygwin ARG
1763862f5301Smrg# Convert file name ARG from *nix to Cygwin format.  Requires Cygwin installed
1764862f5301Smrg# in a wine environment, working winepath, and LT_CYGPATH set.  Returns result
1765862f5301Smrg# in func_to_host_file_result.
1766862f5301Smrgfunc_convert_file_nix_to_cygwin ()
1767862f5301Smrg{
1768862f5301Smrg  $opt_debug
1769862f5301Smrg  func_to_host_file_result="$1"
1770862f5301Smrg  if test -n "$1"; then
1771862f5301Smrg    # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
1772862f5301Smrg    func_convert_core_file_wine_to_w32 "$1"
1773862f5301Smrg    func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
1774862f5301Smrg    func_to_host_file_result="$func_cygpath_result"
1775862f5301Smrg  fi
1776862f5301Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
1777862f5301Smrg}
1778862f5301Smrg# end func_convert_file_nix_to_cygwin
1779862f5301Smrg
1780862f5301Smrg
1781862f5301Smrg#############################################
1782862f5301Smrg# $build to $host PATH CONVERSION FUNCTIONS #
1783862f5301Smrg#############################################
1784862f5301Smrg# invoked via `$to_host_path_cmd ARG'
1785862f5301Smrg#
1786862f5301Smrg# In each case, ARG is the path to be converted from $build to $host format.
1787862f5301Smrg# The result will be available in $func_to_host_path_result.
1788862f5301Smrg#
1789862f5301Smrg# Path separators are also converted from $build format to $host format.  If
1790862f5301Smrg# ARG begins or ends with a path separator character, it is preserved (but
1791862f5301Smrg# converted to $host format) on output.
1792862f5301Smrg#
1793862f5301Smrg# All path conversion functions are named using the following convention:
1794862f5301Smrg#   file name conversion function    : func_convert_file_X_to_Y ()
1795862f5301Smrg#   path conversion function         : func_convert_path_X_to_Y ()
1796862f5301Smrg# where, for any given $build/$host combination the 'X_to_Y' value is the
1797862f5301Smrg# same.  If conversion functions are added for new $build/$host combinations,
1798862f5301Smrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd
1799862f5301Smrg# will break.
1800862f5301Smrg
1801862f5301Smrg
1802862f5301Smrg# func_init_to_host_path_cmd
1803862f5301Smrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the
1804862f5301Smrg# appropriate value, based on the value of $to_host_file_cmd.
1805862f5301Smrgto_host_path_cmd=
1806862f5301Smrgfunc_init_to_host_path_cmd ()
1807862f5301Smrg{
1808862f5301Smrg  $opt_debug
1809862f5301Smrg  if test -z "$to_host_path_cmd"; then
1810862f5301Smrg    func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
1811862f5301Smrg    to_host_path_cmd="func_convert_path_${func_stripname_result}"
1812862f5301Smrg  fi
1813862f5301Smrg}
1814862f5301Smrg
1815862f5301Smrg
1816862f5301Smrg# func_to_host_path ARG
1817862f5301Smrg# Converts the path ARG from $build format to $host format. Return result
1818862f5301Smrg# in func_to_host_path_result.
1819862f5301Smrgfunc_to_host_path ()
1820862f5301Smrg{
1821862f5301Smrg  $opt_debug
1822862f5301Smrg  func_init_to_host_path_cmd
1823862f5301Smrg  $to_host_path_cmd "$1"
1824862f5301Smrg}
1825862f5301Smrg# end func_to_host_path
1826862f5301Smrg
1827862f5301Smrg
1828862f5301Smrg# func_convert_path_noop ARG
1829862f5301Smrg# Copy ARG to func_to_host_path_result.
1830862f5301Smrgfunc_convert_path_noop ()
1831862f5301Smrg{
1832862f5301Smrg  func_to_host_path_result="$1"
1833862f5301Smrg}
1834862f5301Smrg# end func_convert_path_noop
1835862f5301Smrg
1836862f5301Smrg
1837862f5301Smrg# func_convert_path_msys_to_w32 ARG
1838862f5301Smrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic
1839862f5301Smrg# conversion to w32 is not available inside the cwrapper.  Returns result in
1840862f5301Smrg# func_to_host_path_result.
1841862f5301Smrgfunc_convert_path_msys_to_w32 ()
18427a3b38f7Smrg{
1843862f5301Smrg  $opt_debug
1844862f5301Smrg  func_to_host_path_result="$1"
1845862f5301Smrg  if test -n "$1"; then
1846862f5301Smrg    # Remove leading and trailing path separator characters from ARG.  MSYS
1847862f5301Smrg    # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
1848862f5301Smrg    # and winepath ignores them completely.
1849862f5301Smrg    func_stripname : : "$1"
1850862f5301Smrg    func_to_host_path_tmp1=$func_stripname_result
1851862f5301Smrg    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
1852862f5301Smrg    func_to_host_path_result="$func_convert_core_msys_to_w32_result"
1853862f5301Smrg    func_convert_path_check : ";" \
1854862f5301Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1855862f5301Smrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
1856862f5301Smrg  fi
1857862f5301Smrg}
1858862f5301Smrg# end func_convert_path_msys_to_w32
18597a3b38f7Smrg
18607a3b38f7Smrg
1861862f5301Smrg# func_convert_path_cygwin_to_w32 ARG
1862862f5301Smrg# Convert path ARG from Cygwin to w32 format.  Returns result in
1863862f5301Smrg# func_to_host_file_result.
1864862f5301Smrgfunc_convert_path_cygwin_to_w32 ()
1865862f5301Smrg{
1866862f5301Smrg  $opt_debug
1867862f5301Smrg  func_to_host_path_result="$1"
1868862f5301Smrg  if test -n "$1"; then
1869862f5301Smrg    # See func_convert_path_msys_to_w32:
1870862f5301Smrg    func_stripname : : "$1"
1871862f5301Smrg    func_to_host_path_tmp1=$func_stripname_result
1872862f5301Smrg    func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"`
1873862f5301Smrg    func_convert_path_check : ";" \
1874862f5301Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1875862f5301Smrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
1876862f5301Smrg  fi
1877862f5301Smrg}
1878862f5301Smrg# end func_convert_path_cygwin_to_w32
18797a3b38f7Smrg
18807a3b38f7Smrg
1881862f5301Smrg# func_convert_path_nix_to_w32 ARG
1882862f5301Smrg# Convert path ARG from *nix to w32 format.  Requires a wine environment and
1883862f5301Smrg# a working winepath.  Returns result in func_to_host_file_result.
1884862f5301Smrgfunc_convert_path_nix_to_w32 ()
1885862f5301Smrg{
1886862f5301Smrg  $opt_debug
1887862f5301Smrg  func_to_host_path_result="$1"
1888862f5301Smrg  if test -n "$1"; then
1889862f5301Smrg    # See func_convert_path_msys_to_w32:
1890862f5301Smrg    func_stripname : : "$1"
1891862f5301Smrg    func_to_host_path_tmp1=$func_stripname_result
1892862f5301Smrg    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
1893862f5301Smrg    func_to_host_path_result="$func_convert_core_path_wine_to_w32_result"
1894862f5301Smrg    func_convert_path_check : ";" \
1895862f5301Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1896862f5301Smrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
1897862f5301Smrg  fi
1898862f5301Smrg}
1899862f5301Smrg# end func_convert_path_nix_to_w32
19007a3b38f7Smrg
1901862f5301Smrg
1902862f5301Smrg# func_convert_path_msys_to_cygwin ARG
1903862f5301Smrg# Convert path ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
1904862f5301Smrg# Returns result in func_to_host_file_result.
1905862f5301Smrgfunc_convert_path_msys_to_cygwin ()
1906862f5301Smrg{
1907862f5301Smrg  $opt_debug
1908862f5301Smrg  func_to_host_path_result="$1"
1909862f5301Smrg  if test -n "$1"; then
1910862f5301Smrg    # See func_convert_path_msys_to_w32:
1911862f5301Smrg    func_stripname : : "$1"
1912862f5301Smrg    func_to_host_path_tmp1=$func_stripname_result
1913862f5301Smrg    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
1914862f5301Smrg    func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
1915862f5301Smrg    func_to_host_path_result="$func_cygpath_result"
1916862f5301Smrg    func_convert_path_check : : \
1917862f5301Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1918862f5301Smrg    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
1919862f5301Smrg  fi
1920862f5301Smrg}
1921862f5301Smrg# end func_convert_path_msys_to_cygwin
1922862f5301Smrg
1923862f5301Smrg
1924862f5301Smrg# func_convert_path_nix_to_cygwin ARG
1925862f5301Smrg# Convert path ARG from *nix to Cygwin format.  Requires Cygwin installed in a
1926862f5301Smrg# a wine environment, working winepath, and LT_CYGPATH set.  Returns result in
1927862f5301Smrg# func_to_host_file_result.
1928862f5301Smrgfunc_convert_path_nix_to_cygwin ()
1929862f5301Smrg{
1930862f5301Smrg  $opt_debug
1931862f5301Smrg  func_to_host_path_result="$1"
1932862f5301Smrg  if test -n "$1"; then
1933862f5301Smrg    # Remove leading and trailing path separator characters from
1934862f5301Smrg    # ARG. msys behavior is inconsistent here, cygpath turns them
1935862f5301Smrg    # into '.;' and ';.', and winepath ignores them completely.
1936862f5301Smrg    func_stripname : : "$1"
1937862f5301Smrg    func_to_host_path_tmp1=$func_stripname_result
1938862f5301Smrg    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
1939862f5301Smrg    func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
1940862f5301Smrg    func_to_host_path_result="$func_cygpath_result"
1941862f5301Smrg    func_convert_path_check : : \
1942862f5301Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1943862f5301Smrg    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
1944862f5301Smrg  fi
19457a3b38f7Smrg}
1946862f5301Smrg# end func_convert_path_nix_to_cygwin
1947862f5301Smrg
19487a3b38f7Smrg
19497a3b38f7Smrg# func_mode_compile arg...
19507a3b38f7Smrgfunc_mode_compile ()
19517a3b38f7Smrg{
19527a3b38f7Smrg    $opt_debug
19537a3b38f7Smrg    # Get the compilation command and the source file.
19547a3b38f7Smrg    base_compile=
19557a3b38f7Smrg    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
19567a3b38f7Smrg    suppress_opt=yes
19577a3b38f7Smrg    suppress_output=
19587a3b38f7Smrg    arg_mode=normal
19597a3b38f7Smrg    libobj=
19607a3b38f7Smrg    later=
19617a3b38f7Smrg    pie_flag=
19627a3b38f7Smrg
19637a3b38f7Smrg    for arg
19647a3b38f7Smrg    do
19657a3b38f7Smrg      case $arg_mode in
19667a3b38f7Smrg      arg  )
19677a3b38f7Smrg	# do not "continue".  Instead, add this to base_compile
19687a3b38f7Smrg	lastarg="$arg"
19697a3b38f7Smrg	arg_mode=normal
19707a3b38f7Smrg	;;
19717a3b38f7Smrg
19727a3b38f7Smrg      target )
19737a3b38f7Smrg	libobj="$arg"
19747a3b38f7Smrg	arg_mode=normal
19757a3b38f7Smrg	continue
19767a3b38f7Smrg	;;
19777a3b38f7Smrg
19787a3b38f7Smrg      normal )
19797a3b38f7Smrg	# Accept any command-line options.
19807a3b38f7Smrg	case $arg in
19817a3b38f7Smrg	-o)
19827a3b38f7Smrg	  test -n "$libobj" && \
19837a3b38f7Smrg	    func_fatal_error "you cannot specify \`-o' more than once"
19847a3b38f7Smrg	  arg_mode=target
19857a3b38f7Smrg	  continue
19867a3b38f7Smrg	  ;;
19877a3b38f7Smrg
19887a3b38f7Smrg	-pie | -fpie | -fPIE)
1989862f5301Smrg          func_append pie_flag " $arg"
19907a3b38f7Smrg	  continue
19917a3b38f7Smrg	  ;;
19927a3b38f7Smrg
19937a3b38f7Smrg	-shared | -static | -prefer-pic | -prefer-non-pic)
1994862f5301Smrg	  func_append later " $arg"
19957a3b38f7Smrg	  continue
19967a3b38f7Smrg	  ;;
19977a3b38f7Smrg
19987a3b38f7Smrg	-no-suppress)
19997a3b38f7Smrg	  suppress_opt=no
20007a3b38f7Smrg	  continue
20017a3b38f7Smrg	  ;;
20027a3b38f7Smrg
20037a3b38f7Smrg	-Xcompiler)
20047a3b38f7Smrg	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
20057a3b38f7Smrg	  continue      #  The current "srcfile" will either be retained or
20067a3b38f7Smrg	  ;;            #  replaced later.  I would guess that would be a bug.
20077a3b38f7Smrg
20087a3b38f7Smrg	-Wc,*)
20097a3b38f7Smrg	  func_stripname '-Wc,' '' "$arg"
20107a3b38f7Smrg	  args=$func_stripname_result
20117a3b38f7Smrg	  lastarg=
20127a3b38f7Smrg	  save_ifs="$IFS"; IFS=','
20137a3b38f7Smrg	  for arg in $args; do
20147a3b38f7Smrg	    IFS="$save_ifs"
2015862f5301Smrg	    func_append_quoted lastarg "$arg"
2016ff559fabSmrg	  done
2017ff559fabSmrg	  IFS="$save_ifs"
20187a3b38f7Smrg	  func_stripname ' ' '' "$lastarg"
20197a3b38f7Smrg	  lastarg=$func_stripname_result
2020ff559fabSmrg
2021ff559fabSmrg	  # Add the arguments to base_compile.
2022862f5301Smrg	  func_append base_compile " $lastarg"
2023ff559fabSmrg	  continue
2024ff559fabSmrg	  ;;
2025ff559fabSmrg
20267a3b38f7Smrg	*)
2027ff559fabSmrg	  # Accept the current argument as the source file.
2028ff559fabSmrg	  # The previous "srcfile" becomes the current argument.
2029ff559fabSmrg	  #
2030ff559fabSmrg	  lastarg="$srcfile"
2031ff559fabSmrg	  srcfile="$arg"
2032ff559fabSmrg	  ;;
2033ff559fabSmrg	esac  #  case $arg
2034ff559fabSmrg	;;
2035ff559fabSmrg      esac    #  case $arg_mode
2036ff559fabSmrg
2037ff559fabSmrg      # Aesthetically quote the previous argument.
2038862f5301Smrg      func_append_quoted base_compile "$lastarg"
2039ff559fabSmrg    done # for arg
2040ff559fabSmrg
2041ff559fabSmrg    case $arg_mode in
2042ff559fabSmrg    arg)
20437a3b38f7Smrg      func_fatal_error "you must specify an argument for -Xcompile"
2044ff559fabSmrg      ;;
2045ff559fabSmrg    target)
20467a3b38f7Smrg      func_fatal_error "you must specify a target with \`-o'"
2047ff559fabSmrg      ;;
2048ff559fabSmrg    *)
2049ff559fabSmrg      # Get the name of the library object.
20507a3b38f7Smrg      test -z "$libobj" && {
20517a3b38f7Smrg	func_basename "$srcfile"
20527a3b38f7Smrg	libobj="$func_basename_result"
20537a3b38f7Smrg      }
2054ff559fabSmrg      ;;
2055ff559fabSmrg    esac
2056ff559fabSmrg
2057ff559fabSmrg    # Recognize several different file suffixes.
2058ff559fabSmrg    # If the user specifies -o file.o, it is replaced with file.lo
2059ff559fabSmrg    case $libobj in
20607a3b38f7Smrg    *.[cCFSifmso] | \
20617a3b38f7Smrg    *.ada | *.adb | *.ads | *.asm | \
20627a3b38f7Smrg    *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
2063fc544a13Smrg    *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup)
20647a3b38f7Smrg      func_xform "$libobj"
20657a3b38f7Smrg      libobj=$func_xform_result
20667a3b38f7Smrg      ;;
2067ff559fabSmrg    esac
2068ff559fabSmrg
2069ff559fabSmrg    case $libobj in
20707a3b38f7Smrg    *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
2071ff559fabSmrg    *)
20727a3b38f7Smrg      func_fatal_error "cannot determine name of library object from \`$libobj'"
2073ff559fabSmrg      ;;
2074ff559fabSmrg    esac
2075ff559fabSmrg
2076ff559fabSmrg    func_infer_tag $base_compile
2077ff559fabSmrg
2078ff559fabSmrg    for arg in $later; do
2079ff559fabSmrg      case $arg in
20807a3b38f7Smrg      -shared)
20817a3b38f7Smrg	test "$build_libtool_libs" != yes && \
20827a3b38f7Smrg	  func_fatal_configuration "can not build a shared library"
20837a3b38f7Smrg	build_old_libs=no
20847a3b38f7Smrg	continue
20857a3b38f7Smrg	;;
20867a3b38f7Smrg
2087ff559fabSmrg      -static)
20887a3b38f7Smrg	build_libtool_libs=no
2089ff559fabSmrg	build_old_libs=yes
2090ff559fabSmrg	continue
2091ff559fabSmrg	;;
2092ff559fabSmrg
2093ff559fabSmrg      -prefer-pic)
2094ff559fabSmrg	pic_mode=yes
2095ff559fabSmrg	continue
2096ff559fabSmrg	;;
2097ff559fabSmrg
2098ff559fabSmrg      -prefer-non-pic)
2099ff559fabSmrg	pic_mode=no
2100ff559fabSmrg	continue
2101ff559fabSmrg	;;
2102ff559fabSmrg      esac
2103ff559fabSmrg    done
2104ff559fabSmrg
21057a3b38f7Smrg    func_quote_for_eval "$libobj"
21067a3b38f7Smrg    test "X$libobj" != "X$func_quote_for_eval_result" \
21077a3b38f7Smrg      && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'	 &()|`$[]' \
21087a3b38f7Smrg      && func_warning "libobj name \`$libobj' may not contain shell special characters."
21097a3b38f7Smrg    func_dirname_and_basename "$obj" "/" ""
21107a3b38f7Smrg    objname="$func_basename_result"
21117a3b38f7Smrg    xdir="$func_dirname_result"
2112ff559fabSmrg    lobj=${xdir}$objdir/$objname
2113ff559fabSmrg
21147a3b38f7Smrg    test -z "$base_compile" && \
21157a3b38f7Smrg      func_fatal_help "you must specify a compilation command"
2116ff559fabSmrg
2117ff559fabSmrg    # Delete any leftover library objects.
2118ff559fabSmrg    if test "$build_old_libs" = yes; then
2119ff559fabSmrg      removelist="$obj $lobj $libobj ${libobj}T"
2120ff559fabSmrg    else
2121ff559fabSmrg      removelist="$lobj $libobj ${libobj}T"
2122ff559fabSmrg    fi
2123ff559fabSmrg
2124ff559fabSmrg    # On Cygwin there's no "real" PIC flag so we must build both object types
2125ff559fabSmrg    case $host_os in
21267a3b38f7Smrg    cygwin* | mingw* | pw32* | os2* | cegcc*)
2127ff559fabSmrg      pic_mode=default
2128ff559fabSmrg      ;;
2129ff559fabSmrg    esac
2130ff559fabSmrg    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
2131ff559fabSmrg      # non-PIC code in shared libraries is not supported
2132ff559fabSmrg      pic_mode=default
2133ff559fabSmrg    fi
2134ff559fabSmrg
2135ff559fabSmrg    # Calculate the filename of the output object if compiler does
2136ff559fabSmrg    # not support -o with -c
2137ff559fabSmrg    if test "$compiler_c_o" = no; then
213844dda7b2Smrg      output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext}
2139ff559fabSmrg      lockfile="$output_obj.lock"
2140ff559fabSmrg    else
2141ff559fabSmrg      output_obj=
2142ff559fabSmrg      need_locks=no
2143ff559fabSmrg      lockfile=
2144ff559fabSmrg    fi
2145ff559fabSmrg
2146ff559fabSmrg    # Lock this critical section if it is needed
2147ff559fabSmrg    # We use this script file to make the link, it avoids creating a new file
2148ff559fabSmrg    if test "$need_locks" = yes; then
21497a3b38f7Smrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
21507a3b38f7Smrg	func_echo "Waiting for $lockfile to be removed"
2151ff559fabSmrg	sleep 2
2152ff559fabSmrg      done
2153ff559fabSmrg    elif test "$need_locks" = warn; then
2154ff559fabSmrg      if test -f "$lockfile"; then
21557a3b38f7Smrg	$ECHO "\
2156ff559fabSmrg*** ERROR, $lockfile exists and contains:
2157ff559fabSmrg`cat $lockfile 2>/dev/null`
2158ff559fabSmrg
2159ff559fabSmrgThis indicates that another process is trying to use the same
2160ff559fabSmrgtemporary object file, and libtool could not work around it because
2161ff559fabSmrgyour compiler does not support \`-c' and \`-o' together.  If you
2162ff559fabSmrgrepeat this compilation, it may succeed, by chance, but you had better
2163ff559fabSmrgavoid parallel builds (make -j) in this platform, or get a better
2164ff559fabSmrgcompiler."
2165ff559fabSmrg
21667a3b38f7Smrg	$opt_dry_run || $RM $removelist
2167ff559fabSmrg	exit $EXIT_FAILURE
2168ff559fabSmrg      fi
2169862f5301Smrg      func_append removelist " $output_obj"
21707a3b38f7Smrg      $ECHO "$srcfile" > "$lockfile"
2171ff559fabSmrg    fi
2172ff559fabSmrg
21737a3b38f7Smrg    $opt_dry_run || $RM $removelist
2174862f5301Smrg    func_append removelist " $lockfile"
21757a3b38f7Smrg    trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
21767a3b38f7Smrg
2177862f5301Smrg    func_to_tool_file "$srcfile" func_convert_file_msys_to_w32
2178862f5301Smrg    srcfile=$func_to_tool_file_result
21797a3b38f7Smrg    func_quote_for_eval "$srcfile"
21807a3b38f7Smrg    qsrcfile=$func_quote_for_eval_result
2181ff559fabSmrg
2182ff559fabSmrg    # Only build a PIC object if we are building libtool libraries.
2183ff559fabSmrg    if test "$build_libtool_libs" = yes; then
2184ff559fabSmrg      # Without this assignment, base_compile gets emptied.
2185ff559fabSmrg      fbsd_hideous_sh_bug=$base_compile
2186ff559fabSmrg
2187ff559fabSmrg      if test "$pic_mode" != no; then
2188ff559fabSmrg	command="$base_compile $qsrcfile $pic_flag"
2189ff559fabSmrg      else
2190ff559fabSmrg	# Don't build PIC code
2191ff559fabSmrg	command="$base_compile $qsrcfile"
2192ff559fabSmrg      fi
2193ff559fabSmrg
21947a3b38f7Smrg      func_mkdir_p "$xdir$objdir"
2195ff559fabSmrg
2196ff559fabSmrg      if test -z "$output_obj"; then
2197ff559fabSmrg	# Place PIC objects in $objdir
2198862f5301Smrg	func_append command " -o $lobj"
2199ff559fabSmrg      fi
2200ff559fabSmrg
22017a3b38f7Smrg      func_show_eval_locale "$command"	\
22027a3b38f7Smrg          'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
2203ff559fabSmrg
2204ff559fabSmrg      if test "$need_locks" = warn &&
2205ff559fabSmrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
22067a3b38f7Smrg	$ECHO "\
2207ff559fabSmrg*** ERROR, $lockfile contains:
2208ff559fabSmrg`cat $lockfile 2>/dev/null`
2209ff559fabSmrg
2210ff559fabSmrgbut it should contain:
2211ff559fabSmrg$srcfile
2212ff559fabSmrg
2213ff559fabSmrgThis indicates that another process is trying to use the same
2214ff559fabSmrgtemporary object file, and libtool could not work around it because
2215ff559fabSmrgyour compiler does not support \`-c' and \`-o' together.  If you
2216ff559fabSmrgrepeat this compilation, it may succeed, by chance, but you had better
2217ff559fabSmrgavoid parallel builds (make -j) in this platform, or get a better
2218ff559fabSmrgcompiler."
2219ff559fabSmrg
22207a3b38f7Smrg	$opt_dry_run || $RM $removelist
2221ff559fabSmrg	exit $EXIT_FAILURE
2222ff559fabSmrg      fi
2223ff559fabSmrg
2224ff559fabSmrg      # Just move the object if needed, then go on to compile the next one
2225ff559fabSmrg      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
22267a3b38f7Smrg	func_show_eval '$MV "$output_obj" "$lobj"' \
22277a3b38f7Smrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
2228ff559fabSmrg      fi
2229ff559fabSmrg
2230ff559fabSmrg      # Allow error messages only from the first compilation.
2231ff559fabSmrg      if test "$suppress_opt" = yes; then
22327a3b38f7Smrg	suppress_output=' >/dev/null 2>&1'
2233ff559fabSmrg      fi
2234ff559fabSmrg    fi
2235ff559fabSmrg
2236ff559fabSmrg    # Only build a position-dependent object if we build old libraries.
2237ff559fabSmrg    if test "$build_old_libs" = yes; then
2238ff559fabSmrg      if test "$pic_mode" != yes; then
2239ff559fabSmrg	# Don't build PIC code
22407a3b38f7Smrg	command="$base_compile $qsrcfile$pie_flag"
2241ff559fabSmrg      else
2242ff559fabSmrg	command="$base_compile $qsrcfile $pic_flag"
2243ff559fabSmrg      fi
2244ff559fabSmrg      if test "$compiler_c_o" = yes; then
2245862f5301Smrg	func_append command " -o $obj"
2246ff559fabSmrg      fi
2247ff559fabSmrg
2248ff559fabSmrg      # Suppress compiler output if we already did a PIC compilation.
2249862f5301Smrg      func_append command "$suppress_output"
22507a3b38f7Smrg      func_show_eval_locale "$command" \
22517a3b38f7Smrg        '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
2252ff559fabSmrg
2253ff559fabSmrg      if test "$need_locks" = warn &&
2254ff559fabSmrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
22557a3b38f7Smrg	$ECHO "\
2256ff559fabSmrg*** ERROR, $lockfile contains:
2257ff559fabSmrg`cat $lockfile 2>/dev/null`
2258ff559fabSmrg
2259ff559fabSmrgbut it should contain:
2260ff559fabSmrg$srcfile
2261ff559fabSmrg
2262ff559fabSmrgThis indicates that another process is trying to use the same
2263ff559fabSmrgtemporary object file, and libtool could not work around it because
2264ff559fabSmrgyour compiler does not support \`-c' and \`-o' together.  If you
2265ff559fabSmrgrepeat this compilation, it may succeed, by chance, but you had better
2266ff559fabSmrgavoid parallel builds (make -j) in this platform, or get a better
2267ff559fabSmrgcompiler."
2268ff559fabSmrg
22697a3b38f7Smrg	$opt_dry_run || $RM $removelist
2270ff559fabSmrg	exit $EXIT_FAILURE
2271ff559fabSmrg      fi
2272ff559fabSmrg
2273ff559fabSmrg      # Just move the object if needed
2274ff559fabSmrg      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
22757a3b38f7Smrg	func_show_eval '$MV "$output_obj" "$obj"' \
22767a3b38f7Smrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
2277ff559fabSmrg      fi
2278ff559fabSmrg    fi
2279ff559fabSmrg
22807a3b38f7Smrg    $opt_dry_run || {
22817a3b38f7Smrg      func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
2282ff559fabSmrg
22837a3b38f7Smrg      # Unlock the critical section if it was locked
22847a3b38f7Smrg      if test "$need_locks" != no; then
22857a3b38f7Smrg	removelist=$lockfile
22867a3b38f7Smrg        $RM "$lockfile"
22877a3b38f7Smrg      fi
22887a3b38f7Smrg    }
2289ff559fabSmrg
2290ff559fabSmrg    exit $EXIT_SUCCESS
22917a3b38f7Smrg}
2292ff559fabSmrg
22937a3b38f7Smrg$opt_help || {
2294862f5301Smrg  test "$opt_mode" = compile && func_mode_compile ${1+"$@"}
22957a3b38f7Smrg}
2296ff559fabSmrg
22977a3b38f7Smrgfunc_mode_help ()
22987a3b38f7Smrg{
22997a3b38f7Smrg    # We need to display help for each of the modes.
2300862f5301Smrg    case $opt_mode in
23017a3b38f7Smrg      "")
23027a3b38f7Smrg        # Generic help is extracted from the usage comments
23037a3b38f7Smrg        # at the start of this file.
23047a3b38f7Smrg        func_help
23057a3b38f7Smrg        ;;
2306ff559fabSmrg
23077a3b38f7Smrg      clean)
23087a3b38f7Smrg        $ECHO \
23097a3b38f7Smrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
2310ff559fabSmrg
23117a3b38f7SmrgRemove files from the build directory.
2312ff559fabSmrg
23137a3b38f7SmrgRM is the name of the program to use to delete files associated with each FILE
23147a3b38f7Smrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
23157a3b38f7Smrgto RM.
2316ff559fabSmrg
23177a3b38f7SmrgIf FILE is a libtool library, object or program, all the files associated
23187a3b38f7Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM."
23197a3b38f7Smrg        ;;
2320ff559fabSmrg
23217a3b38f7Smrg      compile)
23227a3b38f7Smrg      $ECHO \
23237a3b38f7Smrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
2324ff559fabSmrg
23257a3b38f7SmrgCompile a source file into a libtool library object.
2326ff559fabSmrg
23277a3b38f7SmrgThis mode accepts the following additional options:
2328ff559fabSmrg
23297a3b38f7Smrg  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
23307a3b38f7Smrg  -no-suppress      do not suppress compiler output for multiple passes
233144dda7b2Smrg  -prefer-pic       try to build PIC objects only
233244dda7b2Smrg  -prefer-non-pic   try to build non-PIC objects only
23337a3b38f7Smrg  -shared           do not build a \`.o' file suitable for static linking
23347a3b38f7Smrg  -static           only build a \`.o' file suitable for static linking
233544dda7b2Smrg  -Wc,FLAG          pass FLAG directly to the compiler
2336ff559fabSmrg
23377a3b38f7SmrgCOMPILE-COMMAND is a command to be used in creating a \`standard' object file
23387a3b38f7Smrgfrom the given SOURCEFILE.
2339ff559fabSmrg
23407a3b38f7SmrgThe output file name is determined by removing the directory component from
23417a3b38f7SmrgSOURCEFILE, then substituting the C source code suffix \`.c' with the
23427a3b38f7Smrglibrary object suffix, \`.lo'."
23437a3b38f7Smrg        ;;
2344ff559fabSmrg
23457a3b38f7Smrg      execute)
23467a3b38f7Smrg        $ECHO \
23477a3b38f7Smrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
2348ff559fabSmrg
23497a3b38f7SmrgAutomatically set library path, then run a program.
2350ff559fabSmrg
23517a3b38f7SmrgThis mode accepts the following additional options:
2352ff559fabSmrg
23537a3b38f7Smrg  -dlopen FILE      add the directory containing FILE to the library path
2354ff559fabSmrg
23557a3b38f7SmrgThis mode sets the library path environment variable according to \`-dlopen'
23567a3b38f7Smrgflags.
2357ff559fabSmrg
23587a3b38f7SmrgIf any of the ARGS are libtool executable wrappers, then they are translated
23597a3b38f7Smrginto their corresponding uninstalled binary, and any of their required library
23607a3b38f7Smrgdirectories are added to the library path.
2361ff559fabSmrg
23627a3b38f7SmrgThen, COMMAND is executed, with ARGS as arguments."
23637a3b38f7Smrg        ;;
2364ff559fabSmrg
23657a3b38f7Smrg      finish)
23667a3b38f7Smrg        $ECHO \
23677a3b38f7Smrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
2368ff559fabSmrg
23697a3b38f7SmrgComplete the installation of libtool libraries.
2370ff559fabSmrg
23717a3b38f7SmrgEach LIBDIR is a directory that contains libtool libraries.
2372ff559fabSmrg
23737a3b38f7SmrgThe commands that this mode executes may require superuser privileges.  Use
23747a3b38f7Smrgthe \`--dry-run' option if you just want to see what would be executed."
23757a3b38f7Smrg        ;;
2376ff559fabSmrg
23777a3b38f7Smrg      install)
23787a3b38f7Smrg        $ECHO \
23797a3b38f7Smrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
2380ff559fabSmrg
23817a3b38f7SmrgInstall executables or libraries.
2382ff559fabSmrg
23837a3b38f7SmrgINSTALL-COMMAND is the installation command.  The first component should be
23847a3b38f7Smrgeither the \`install' or \`cp' program.
2385ff559fabSmrg
23867a3b38f7SmrgThe following components of INSTALL-COMMAND are treated specially:
2387ff559fabSmrg
238844dda7b2Smrg  -inst-prefix-dir PREFIX-DIR  Use PREFIX-DIR as a staging area for installation
2389ff559fabSmrg
23907a3b38f7SmrgThe rest of the components are interpreted as arguments to that command (only
23917a3b38f7SmrgBSD-compatible install options are recognized)."
23927a3b38f7Smrg        ;;
2393ff559fabSmrg
23947a3b38f7Smrg      link)
23957a3b38f7Smrg        $ECHO \
23967a3b38f7Smrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
2397ff559fabSmrg
23987a3b38f7SmrgLink object files or libraries together to form another library, or to
23997a3b38f7Smrgcreate an executable program.
2400ff559fabSmrg
24017a3b38f7SmrgLINK-COMMAND is a command using the C compiler that you would use to create
24027a3b38f7Smrga program from several object files.
2403ff559fabSmrg
24047a3b38f7SmrgThe following components of LINK-COMMAND are treated specially:
2405ff559fabSmrg
24067a3b38f7Smrg  -all-static       do not do any dynamic linking at all
24077a3b38f7Smrg  -avoid-version    do not add a version suffix if possible
240844dda7b2Smrg  -bindir BINDIR    specify path to binaries directory (for systems where
240944dda7b2Smrg                    libraries must be found in the PATH setting at runtime)
24107a3b38f7Smrg  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
24117a3b38f7Smrg  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
24127a3b38f7Smrg  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
24137a3b38f7Smrg  -export-symbols SYMFILE
24147a3b38f7Smrg                    try to export only the symbols listed in SYMFILE
24157a3b38f7Smrg  -export-symbols-regex REGEX
24167a3b38f7Smrg                    try to export only the symbols matching REGEX
24177a3b38f7Smrg  -LLIBDIR          search LIBDIR for required installed libraries
24187a3b38f7Smrg  -lNAME            OUTPUT-FILE requires the installed library libNAME
24197a3b38f7Smrg  -module           build a library that can dlopened
24207a3b38f7Smrg  -no-fast-install  disable the fast-install mode
24217a3b38f7Smrg  -no-install       link a not-installable executable
24227a3b38f7Smrg  -no-undefined     declare that a library does not refer to external symbols
24237a3b38f7Smrg  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
24247a3b38f7Smrg  -objectlist FILE  Use a list of object files found in FILE to specify objects
24257a3b38f7Smrg  -precious-files-regex REGEX
24267a3b38f7Smrg                    don't remove output files matching REGEX
24277a3b38f7Smrg  -release RELEASE  specify package release information
24287a3b38f7Smrg  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
24297a3b38f7Smrg  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
24307a3b38f7Smrg  -shared           only do dynamic linking of libtool libraries
24317a3b38f7Smrg  -shrext SUFFIX    override the standard shared library file extension
24327a3b38f7Smrg  -static           do not do any dynamic linking of uninstalled libtool libraries
24337a3b38f7Smrg  -static-libtool-libs
24347a3b38f7Smrg                    do not do any dynamic linking of libtool libraries
24357a3b38f7Smrg  -version-info CURRENT[:REVISION[:AGE]]
24367a3b38f7Smrg                    specify library version info [each variable defaults to 0]
24377a3b38f7Smrg  -weak LIBNAME     declare that the target provides the LIBNAME interface
243844dda7b2Smrg  -Wc,FLAG
243944dda7b2Smrg  -Xcompiler FLAG   pass linker-specific FLAG directly to the compiler
244044dda7b2Smrg  -Wl,FLAG
244144dda7b2Smrg  -Xlinker FLAG     pass linker-specific FLAG directly to the linker
244244dda7b2Smrg  -XCClinker FLAG   pass link-specific FLAG to the compiler driver (CC)
2443ff559fabSmrg
24447a3b38f7SmrgAll other options (arguments beginning with \`-') are ignored.
2445ff559fabSmrg
24467a3b38f7SmrgEvery other argument is treated as a filename.  Files ending in \`.la' are
24477a3b38f7Smrgtreated as uninstalled libtool libraries, other files are standard or library
24487a3b38f7Smrgobject files.
2449ff559fabSmrg
24507a3b38f7SmrgIf the OUTPUT-FILE ends in \`.la', then a libtool library is created,
24517a3b38f7Smrgonly library objects (\`.lo' files) may be specified, and \`-rpath' is
24527a3b38f7Smrgrequired, except when creating a convenience library.
2453ff559fabSmrg
24547a3b38f7SmrgIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
24557a3b38f7Smrgusing \`ar' and \`ranlib', or on Windows using \`lib'.
2456ff559fabSmrg
24577a3b38f7SmrgIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
24587a3b38f7Smrgis created, otherwise an executable program is created."
2459ff559fabSmrg        ;;
2460ff559fabSmrg
24617a3b38f7Smrg      uninstall)
24627a3b38f7Smrg        $ECHO \
24637a3b38f7Smrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
2464ff559fabSmrg
24657a3b38f7SmrgRemove libraries from an installation directory.
2466ff559fabSmrg
24677a3b38f7SmrgRM is the name of the program to use to delete files associated with each FILE
24687a3b38f7Smrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
24697a3b38f7Smrgto RM.
2470ff559fabSmrg
24717a3b38f7SmrgIf FILE is a libtool library, all the files associated with it are deleted.
24727a3b38f7SmrgOtherwise, only FILE itself is deleted using RM."
24737a3b38f7Smrg        ;;
2474ff559fabSmrg
24757a3b38f7Smrg      *)
2476862f5301Smrg        func_fatal_help "invalid operation mode \`$opt_mode'"
24777a3b38f7Smrg        ;;
24787a3b38f7Smrg    esac
2479ff559fabSmrg
248044dda7b2Smrg    echo
24817a3b38f7Smrg    $ECHO "Try \`$progname --help' for more information about other modes."
24827a3b38f7Smrg}
2483ff559fabSmrg
248444dda7b2Smrg# Now that we've collected a possible --mode arg, show help if necessary
248544dda7b2Smrgif $opt_help; then
248644dda7b2Smrg  if test "$opt_help" = :; then
248744dda7b2Smrg    func_mode_help
248844dda7b2Smrg  else
248944dda7b2Smrg    {
249044dda7b2Smrg      func_help noexit
2491862f5301Smrg      for opt_mode in compile link execute install finish uninstall clean; do
249244dda7b2Smrg	func_mode_help
249344dda7b2Smrg      done
249444dda7b2Smrg    } | sed -n '1p; 2,$s/^Usage:/  or: /p'
249544dda7b2Smrg    {
249644dda7b2Smrg      func_help noexit
2497862f5301Smrg      for opt_mode in compile link execute install finish uninstall clean; do
249844dda7b2Smrg	echo
249944dda7b2Smrg	func_mode_help
250044dda7b2Smrg      done
250144dda7b2Smrg    } |
250244dda7b2Smrg    sed '1d
250344dda7b2Smrg      /^When reporting/,/^Report/{
250444dda7b2Smrg	H
250544dda7b2Smrg	d
250644dda7b2Smrg      }
250744dda7b2Smrg      $x
250844dda7b2Smrg      /information about other modes/d
250944dda7b2Smrg      /more detailed .*MODE/d
251044dda7b2Smrg      s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
251144dda7b2Smrg  fi
251244dda7b2Smrg  exit $?
251344dda7b2Smrgfi
2514ff559fabSmrg
2515ff559fabSmrg
25167a3b38f7Smrg# func_mode_execute arg...
25177a3b38f7Smrgfunc_mode_execute ()
25187a3b38f7Smrg{
25197a3b38f7Smrg    $opt_debug
25207a3b38f7Smrg    # The first argument is the command name.
25217a3b38f7Smrg    cmd="$nonopt"
25227a3b38f7Smrg    test -z "$cmd" && \
25237a3b38f7Smrg      func_fatal_help "you must specify a COMMAND"
2524ff559fabSmrg
25257a3b38f7Smrg    # Handle -dlopen flags immediately.
2526862f5301Smrg    for file in $opt_dlopen; do
25277a3b38f7Smrg      test -f "$file" \
25287a3b38f7Smrg	|| func_fatal_help "\`$file' is not a file"
2529ff559fabSmrg
25307a3b38f7Smrg      dir=
25317a3b38f7Smrg      case $file in
25327a3b38f7Smrg      *.la)
2533862f5301Smrg	func_resolve_sysroot "$file"
2534862f5301Smrg	file=$func_resolve_sysroot_result
2535862f5301Smrg
25367a3b38f7Smrg	# Check to see that this really is a libtool archive.
25377a3b38f7Smrg	func_lalib_unsafe_p "$file" \
25387a3b38f7Smrg	  || func_fatal_help "\`$lib' is not a valid libtool archive"
2539ff559fabSmrg
25407a3b38f7Smrg	# Read the libtool library.
25417a3b38f7Smrg	dlname=
25427a3b38f7Smrg	library_names=
25437a3b38f7Smrg	func_source "$file"
2544ff559fabSmrg
25457a3b38f7Smrg	# Skip this library if it cannot be dlopened.
25467a3b38f7Smrg	if test -z "$dlname"; then
25477a3b38f7Smrg	  # Warn if it was a shared library.
25487a3b38f7Smrg	  test -n "$library_names" && \
25497a3b38f7Smrg	    func_warning "\`$file' was not linked with \`-export-dynamic'"
25507a3b38f7Smrg	  continue
25517a3b38f7Smrg	fi
2552ff559fabSmrg
25537a3b38f7Smrg	func_dirname "$file" "" "."
25547a3b38f7Smrg	dir="$func_dirname_result"
2555ff559fabSmrg
25567a3b38f7Smrg	if test -f "$dir/$objdir/$dlname"; then
2557862f5301Smrg	  func_append dir "/$objdir"
25587a3b38f7Smrg	else
25597a3b38f7Smrg	  if test ! -f "$dir/$dlname"; then
25607a3b38f7Smrg	    func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'"
25617a3b38f7Smrg	  fi
25627a3b38f7Smrg	fi
2563ff559fabSmrg	;;
2564ff559fabSmrg
25657a3b38f7Smrg      *.lo)
25667a3b38f7Smrg	# Just add the directory containing the .lo file.
25677a3b38f7Smrg	func_dirname "$file" "" "."
25687a3b38f7Smrg	dir="$func_dirname_result"
2569ff559fabSmrg	;;
2570ff559fabSmrg
25717a3b38f7Smrg      *)
25727a3b38f7Smrg	func_warning "\`-dlopen' is ignored for non-libtool libraries and objects"
2573ff559fabSmrg	continue
2574ff559fabSmrg	;;
25757a3b38f7Smrg      esac
2576ff559fabSmrg
25777a3b38f7Smrg      # Get the absolute pathname.
25787a3b38f7Smrg      absdir=`cd "$dir" && pwd`
25797a3b38f7Smrg      test -n "$absdir" && dir="$absdir"
2580ff559fabSmrg
25817a3b38f7Smrg      # Now add the directory to shlibpath_var.
25827a3b38f7Smrg      if eval "test -z \"\$$shlibpath_var\""; then
25837a3b38f7Smrg	eval "$shlibpath_var=\"\$dir\""
25847a3b38f7Smrg      else
25857a3b38f7Smrg	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
25867a3b38f7Smrg      fi
25877a3b38f7Smrg    done
2588ff559fabSmrg
25897a3b38f7Smrg    # This variable tells wrapper scripts just to set shlibpath_var
25907a3b38f7Smrg    # rather than running their programs.
25917a3b38f7Smrg    libtool_execute_magic="$magic"
2592ff559fabSmrg
25937a3b38f7Smrg    # Check if any of the arguments is a wrapper script.
25947a3b38f7Smrg    args=
25957a3b38f7Smrg    for file
25967a3b38f7Smrg    do
25977a3b38f7Smrg      case $file in
259844dda7b2Smrg      -* | *.la | *.lo ) ;;
25997a3b38f7Smrg      *)
26007a3b38f7Smrg	# Do a test to see if this is really a libtool program.
26017a3b38f7Smrg	if func_ltwrapper_script_p "$file"; then
26027a3b38f7Smrg	  func_source "$file"
26037a3b38f7Smrg	  # Transform arg to wrapped name.
26047a3b38f7Smrg	  file="$progdir/$program"
26057a3b38f7Smrg	elif func_ltwrapper_executable_p "$file"; then
26067a3b38f7Smrg	  func_ltwrapper_scriptname "$file"
26077a3b38f7Smrg	  func_source "$func_ltwrapper_scriptname_result"
26087a3b38f7Smrg	  # Transform arg to wrapped name.
26097a3b38f7Smrg	  file="$progdir/$program"
26107a3b38f7Smrg	fi
26117a3b38f7Smrg	;;
26127a3b38f7Smrg      esac
26137a3b38f7Smrg      # Quote arguments (to preserve shell metacharacters).
2614862f5301Smrg      func_append_quoted args "$file"
26157a3b38f7Smrg    done
2616ff559fabSmrg
26177a3b38f7Smrg    if test "X$opt_dry_run" = Xfalse; then
26187a3b38f7Smrg      if test -n "$shlibpath_var"; then
26197a3b38f7Smrg	# Export the shlibpath_var.
26207a3b38f7Smrg	eval "export $shlibpath_var"
26217a3b38f7Smrg      fi
2622ff559fabSmrg
26237a3b38f7Smrg      # Restore saved environment variables
26247a3b38f7Smrg      for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
26257a3b38f7Smrg      do
26267a3b38f7Smrg	eval "if test \"\${save_$lt_var+set}\" = set; then
26277a3b38f7Smrg                $lt_var=\$save_$lt_var; export $lt_var
26287a3b38f7Smrg	      else
26297a3b38f7Smrg		$lt_unset $lt_var
26307a3b38f7Smrg	      fi"
26317a3b38f7Smrg      done
2632ff559fabSmrg
26337a3b38f7Smrg      # Now prepare to actually exec the command.
26347a3b38f7Smrg      exec_cmd="\$cmd$args"
26357a3b38f7Smrg    else
26367a3b38f7Smrg      # Display what would be done.
26377a3b38f7Smrg      if test -n "$shlibpath_var"; then
26387a3b38f7Smrg	eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
263944dda7b2Smrg	echo "export $shlibpath_var"
26407a3b38f7Smrg      fi
26417a3b38f7Smrg      $ECHO "$cmd$args"
26427a3b38f7Smrg      exit $EXIT_SUCCESS
26437a3b38f7Smrg    fi
26447a3b38f7Smrg}
2645ff559fabSmrg
2646862f5301Smrgtest "$opt_mode" = execute && func_mode_execute ${1+"$@"}
2647ff559fabSmrg
2648ff559fabSmrg
26497a3b38f7Smrg# func_mode_finish arg...
26507a3b38f7Smrgfunc_mode_finish ()
26517a3b38f7Smrg{
26527a3b38f7Smrg    $opt_debug
2653862f5301Smrg    libs=
2654862f5301Smrg    libdirs=
26557a3b38f7Smrg    admincmds=
2656ff559fabSmrg
2657862f5301Smrg    for opt in "$nonopt" ${1+"$@"}
2658862f5301Smrg    do
2659862f5301Smrg      if test -d "$opt"; then
2660862f5301Smrg	func_append libdirs " $opt"
2661862f5301Smrg
2662862f5301Smrg      elif test -f "$opt"; then
2663862f5301Smrg	if func_lalib_unsafe_p "$opt"; then
2664862f5301Smrg	  func_append libs " $opt"
2665862f5301Smrg	else
2666862f5301Smrg	  func_warning "\`$opt' is not a valid libtool archive"
2667862f5301Smrg	fi
2668862f5301Smrg
2669862f5301Smrg      else
2670862f5301Smrg	func_fatal_error "invalid argument \`$opt'"
2671862f5301Smrg      fi
2672862f5301Smrg    done
2673862f5301Smrg
2674862f5301Smrg    if test -n "$libs"; then
2675862f5301Smrg      if test -n "$lt_sysroot"; then
2676862f5301Smrg        sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"`
2677862f5301Smrg        sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;"
2678862f5301Smrg      else
2679862f5301Smrg        sysroot_cmd=
2680862f5301Smrg      fi
2681862f5301Smrg
2682862f5301Smrg      # Remove sysroot references
2683862f5301Smrg      if $opt_dry_run; then
2684862f5301Smrg        for lib in $libs; do
2685862f5301Smrg          echo "removing references to $lt_sysroot and \`=' prefixes from $lib"
2686862f5301Smrg        done
2687862f5301Smrg      else
2688862f5301Smrg        tmpdir=`func_mktempdir`
2689862f5301Smrg        for lib in $libs; do
2690862f5301Smrg	  sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
2691862f5301Smrg	    > $tmpdir/tmp-la
2692862f5301Smrg	  mv -f $tmpdir/tmp-la $lib
2693862f5301Smrg	done
2694862f5301Smrg        ${RM}r "$tmpdir"
2695862f5301Smrg      fi
2696862f5301Smrg    fi
2697ff559fabSmrg
2698862f5301Smrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
26997a3b38f7Smrg      for libdir in $libdirs; do
27007a3b38f7Smrg	if test -n "$finish_cmds"; then
27017a3b38f7Smrg	  # Do each command in the finish commands.
27027a3b38f7Smrg	  func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
27037a3b38f7Smrg'"$cmd"'"'
27047a3b38f7Smrg	fi
27057a3b38f7Smrg	if test -n "$finish_eval"; then
27067a3b38f7Smrg	  # Do the single finish_eval.
27077a3b38f7Smrg	  eval cmds=\"$finish_eval\"
2708862f5301Smrg	  $opt_dry_run || eval "$cmds" || func_append admincmds "
27097a3b38f7Smrg       $cmds"
27107a3b38f7Smrg	fi
27117a3b38f7Smrg      done
27127a3b38f7Smrg    fi
2713ff559fabSmrg
27147a3b38f7Smrg    # Exit here if they wanted silent mode.
27157a3b38f7Smrg    $opt_silent && exit $EXIT_SUCCESS
2716ff559fabSmrg
2717862f5301Smrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
2718862f5301Smrg      echo "----------------------------------------------------------------------"
2719862f5301Smrg      echo "Libraries have been installed in:"
2720862f5301Smrg      for libdir in $libdirs; do
2721862f5301Smrg	$ECHO "   $libdir"
2722862f5301Smrg      done
2723862f5301Smrg      echo
2724862f5301Smrg      echo "If you ever happen to want to link against installed libraries"
2725862f5301Smrg      echo "in a given directory, LIBDIR, you must either use libtool, and"
2726862f5301Smrg      echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
2727862f5301Smrg      echo "flag during linking and do at least one of the following:"
2728862f5301Smrg      if test -n "$shlibpath_var"; then
2729862f5301Smrg	echo "   - add LIBDIR to the \`$shlibpath_var' environment variable"
2730862f5301Smrg	echo "     during execution"
2731862f5301Smrg      fi
2732862f5301Smrg      if test -n "$runpath_var"; then
2733862f5301Smrg	echo "   - add LIBDIR to the \`$runpath_var' environment variable"
2734862f5301Smrg	echo "     during linking"
2735862f5301Smrg      fi
2736862f5301Smrg      if test -n "$hardcode_libdir_flag_spec"; then
2737862f5301Smrg	libdir=LIBDIR
2738862f5301Smrg	eval flag=\"$hardcode_libdir_flag_spec\"
2739ff559fabSmrg
2740862f5301Smrg	$ECHO "   - use the \`$flag' linker flag"
2741862f5301Smrg      fi
2742862f5301Smrg      if test -n "$admincmds"; then
2743862f5301Smrg	$ECHO "   - have your system administrator run these commands:$admincmds"
2744862f5301Smrg      fi
2745862f5301Smrg      if test -f /etc/ld.so.conf; then
2746862f5301Smrg	echo "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
2747862f5301Smrg      fi
2748862f5301Smrg      echo
2749ff559fabSmrg
2750862f5301Smrg      echo "See any operating system documentation about shared libraries for"
2751862f5301Smrg      case $host in
2752862f5301Smrg	solaris2.[6789]|solaris2.1[0-9])
2753862f5301Smrg	  echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
2754862f5301Smrg	  echo "pages."
2755862f5301Smrg	  ;;
2756862f5301Smrg	*)
2757862f5301Smrg	  echo "more information, such as the ld(1) and ld.so(8) manual pages."
2758862f5301Smrg	  ;;
2759862f5301Smrg      esac
2760862f5301Smrg      echo "----------------------------------------------------------------------"
2761862f5301Smrg    fi
27627a3b38f7Smrg    exit $EXIT_SUCCESS
27637a3b38f7Smrg}
2764ff559fabSmrg
2765862f5301Smrgtest "$opt_mode" = finish && func_mode_finish ${1+"$@"}
2766ff559fabSmrg
2767ff559fabSmrg
27687a3b38f7Smrg# func_mode_install arg...
27697a3b38f7Smrgfunc_mode_install ()
27707a3b38f7Smrg{
27717a3b38f7Smrg    $opt_debug
27727a3b38f7Smrg    # There may be an optional sh(1) argument at the beginning of
27737a3b38f7Smrg    # install_prog (especially on Windows NT).
27747a3b38f7Smrg    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
27757a3b38f7Smrg       # Allow the use of GNU shtool's install command.
277644dda7b2Smrg       case $nonopt in *shtool*) :;; *) false;; esac; then
27777a3b38f7Smrg      # Aesthetically quote it.
27787a3b38f7Smrg      func_quote_for_eval "$nonopt"
27797a3b38f7Smrg      install_prog="$func_quote_for_eval_result "
27807a3b38f7Smrg      arg=$1
27817a3b38f7Smrg      shift
27827a3b38f7Smrg    else
27837a3b38f7Smrg      install_prog=
27847a3b38f7Smrg      arg=$nonopt
27857a3b38f7Smrg    fi
2786ff559fabSmrg
27877a3b38f7Smrg    # The real first argument should be the name of the installation program.
27887a3b38f7Smrg    # Aesthetically quote it.
27897a3b38f7Smrg    func_quote_for_eval "$arg"
2790862f5301Smrg    func_append install_prog "$func_quote_for_eval_result"
279144dda7b2Smrg    install_shared_prog=$install_prog
279244dda7b2Smrg    case " $install_prog " in
279344dda7b2Smrg      *[\\\ /]cp\ *) install_cp=: ;;
279444dda7b2Smrg      *) install_cp=false ;;
279544dda7b2Smrg    esac
27967a3b38f7Smrg
27977a3b38f7Smrg    # We need to accept at least all the BSD install flags.
27987a3b38f7Smrg    dest=
27997a3b38f7Smrg    files=
28007a3b38f7Smrg    opts=
28017a3b38f7Smrg    prev=
28027a3b38f7Smrg    install_type=
28037a3b38f7Smrg    isdir=no
28047a3b38f7Smrg    stripme=
280544dda7b2Smrg    no_mode=:
28067a3b38f7Smrg    for arg
28077a3b38f7Smrg    do
280844dda7b2Smrg      arg2=
28097a3b38f7Smrg      if test -n "$dest"; then
2810862f5301Smrg	func_append files " $dest"
28117a3b38f7Smrg	dest=$arg
28127a3b38f7Smrg	continue
2813ff559fabSmrg      fi
2814ff559fabSmrg
28157a3b38f7Smrg      case $arg in
28167a3b38f7Smrg      -d) isdir=yes ;;
28177a3b38f7Smrg      -f)
281844dda7b2Smrg	if $install_cp; then :; else
281944dda7b2Smrg	  prev=$arg
282044dda7b2Smrg	fi
28217a3b38f7Smrg	;;
28227a3b38f7Smrg      -g | -m | -o)
28237a3b38f7Smrg	prev=$arg
28247a3b38f7Smrg	;;
28257a3b38f7Smrg      -s)
28267a3b38f7Smrg	stripme=" -s"
28277a3b38f7Smrg	continue
28287a3b38f7Smrg	;;
28297a3b38f7Smrg      -*)
28307a3b38f7Smrg	;;
28317a3b38f7Smrg      *)
28327a3b38f7Smrg	# If the previous option needed an argument, then skip it.
28337a3b38f7Smrg	if test -n "$prev"; then
283444dda7b2Smrg	  if test "x$prev" = x-m && test -n "$install_override_mode"; then
283544dda7b2Smrg	    arg2=$install_override_mode
283644dda7b2Smrg	    no_mode=false
283744dda7b2Smrg	  fi
28387a3b38f7Smrg	  prev=
28397a3b38f7Smrg	else
28407a3b38f7Smrg	  dest=$arg
28417a3b38f7Smrg	  continue
28427a3b38f7Smrg	fi
28437a3b38f7Smrg	;;
28447a3b38f7Smrg      esac
2845ff559fabSmrg
28467a3b38f7Smrg      # Aesthetically quote the argument.
28477a3b38f7Smrg      func_quote_for_eval "$arg"
2848862f5301Smrg      func_append install_prog " $func_quote_for_eval_result"
284944dda7b2Smrg      if test -n "$arg2"; then
285044dda7b2Smrg	func_quote_for_eval "$arg2"
285144dda7b2Smrg      fi
2852862f5301Smrg      func_append install_shared_prog " $func_quote_for_eval_result"
28537a3b38f7Smrg    done
2854ff559fabSmrg
28557a3b38f7Smrg    test -z "$install_prog" && \
28567a3b38f7Smrg      func_fatal_help "you must specify an install program"
2857ff559fabSmrg
28587a3b38f7Smrg    test -n "$prev" && \
28597a3b38f7Smrg      func_fatal_help "the \`$prev' option requires an argument"
2860ff559fabSmrg
286144dda7b2Smrg    if test -n "$install_override_mode" && $no_mode; then
286244dda7b2Smrg      if $install_cp; then :; else
286344dda7b2Smrg	func_quote_for_eval "$install_override_mode"
2864862f5301Smrg	func_append install_shared_prog " -m $func_quote_for_eval_result"
286544dda7b2Smrg      fi
286644dda7b2Smrg    fi
286744dda7b2Smrg
28687a3b38f7Smrg    if test -z "$files"; then
28697a3b38f7Smrg      if test -z "$dest"; then
28707a3b38f7Smrg	func_fatal_help "no file or destination specified"
28717a3b38f7Smrg      else
28727a3b38f7Smrg	func_fatal_help "you must specify a destination"
2873ff559fabSmrg      fi
2874ff559fabSmrg    fi
2875ff559fabSmrg
28767a3b38f7Smrg    # Strip any trailing slash from the destination.
28777a3b38f7Smrg    func_stripname '' '/' "$dest"
28787a3b38f7Smrg    dest=$func_stripname_result
2879ff559fabSmrg
28807a3b38f7Smrg    # Check to see that the destination is a directory.
28817a3b38f7Smrg    test -d "$dest" && isdir=yes
28827a3b38f7Smrg    if test "$isdir" = yes; then
28837a3b38f7Smrg      destdir="$dest"
28847a3b38f7Smrg      destname=
28857a3b38f7Smrg    else
28867a3b38f7Smrg      func_dirname_and_basename "$dest" "" "."
28877a3b38f7Smrg      destdir="$func_dirname_result"
28887a3b38f7Smrg      destname="$func_basename_result"
28897a3b38f7Smrg
28907a3b38f7Smrg      # Not a directory, so check to see that there is only one file specified.
28917a3b38f7Smrg      set dummy $files; shift
28927a3b38f7Smrg      test "$#" -gt 1 && \
28937a3b38f7Smrg	func_fatal_help "\`$dest' is not a directory"
28947a3b38f7Smrg    fi
28957a3b38f7Smrg    case $destdir in
28967a3b38f7Smrg    [\\/]* | [A-Za-z]:[\\/]*) ;;
2897ff559fabSmrg    *)
28987a3b38f7Smrg      for file in $files; do
28997a3b38f7Smrg	case $file in
29007a3b38f7Smrg	*.lo) ;;
29017a3b38f7Smrg	*)
29027a3b38f7Smrg	  func_fatal_help "\`$destdir' must be an absolute directory name"
29037a3b38f7Smrg	  ;;
29047a3b38f7Smrg	esac
29057a3b38f7Smrg      done
2906ff559fabSmrg      ;;
2907ff559fabSmrg    esac
2908ff559fabSmrg
29097a3b38f7Smrg    # This variable tells wrapper scripts just to set variables rather
29107a3b38f7Smrg    # than running their programs.
29117a3b38f7Smrg    libtool_install_magic="$magic"
2912ff559fabSmrg
29137a3b38f7Smrg    staticlibs=
29147a3b38f7Smrg    future_libdirs=
29157a3b38f7Smrg    current_libdirs=
29167a3b38f7Smrg    for file in $files; do
2917ff559fabSmrg
29187a3b38f7Smrg      # Do each installation.
29197a3b38f7Smrg      case $file in
29207a3b38f7Smrg      *.$libext)
29217a3b38f7Smrg	# Do the static libraries later.
2922862f5301Smrg	func_append staticlibs " $file"
29237a3b38f7Smrg	;;
29247a3b38f7Smrg
29257a3b38f7Smrg      *.la)
2926862f5301Smrg	func_resolve_sysroot "$file"
2927862f5301Smrg	file=$func_resolve_sysroot_result
2928862f5301Smrg
29297a3b38f7Smrg	# Check to see that this really is a libtool archive.
29307a3b38f7Smrg	func_lalib_unsafe_p "$file" \
29317a3b38f7Smrg	  || func_fatal_help "\`$file' is not a valid libtool archive"
29327a3b38f7Smrg
29337a3b38f7Smrg	library_names=
29347a3b38f7Smrg	old_library=
29357a3b38f7Smrg	relink_command=
29367a3b38f7Smrg	func_source "$file"
29377a3b38f7Smrg
29387a3b38f7Smrg	# Add the libdir to current_libdirs if it is the destination.
29397a3b38f7Smrg	if test "X$destdir" = "X$libdir"; then
29407a3b38f7Smrg	  case "$current_libdirs " in
29417a3b38f7Smrg	  *" $libdir "*) ;;
2942862f5301Smrg	  *) func_append current_libdirs " $libdir" ;;
2943ff559fabSmrg	  esac
29447a3b38f7Smrg	else
29457a3b38f7Smrg	  # Note the libdir as a future libdir.
29467a3b38f7Smrg	  case "$future_libdirs " in
29477a3b38f7Smrg	  *" $libdir "*) ;;
2948862f5301Smrg	  *) func_append future_libdirs " $libdir" ;;
29497a3b38f7Smrg	  esac
29507a3b38f7Smrg	fi
2951ff559fabSmrg
29527a3b38f7Smrg	func_dirname "$file" "/" ""
29537a3b38f7Smrg	dir="$func_dirname_result"
2954862f5301Smrg	func_append dir "$objdir"
29557a3b38f7Smrg
29567a3b38f7Smrg	if test -n "$relink_command"; then
29577a3b38f7Smrg	  # Determine the prefix the user has applied to our future dir.
295844dda7b2Smrg	  inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
29597a3b38f7Smrg
29607a3b38f7Smrg	  # Don't allow the user to place us outside of our expected
29617a3b38f7Smrg	  # location b/c this prevents finding dependent libraries that
29627a3b38f7Smrg	  # are installed to the same prefix.
29637a3b38f7Smrg	  # At present, this check doesn't affect windows .dll's that
29647a3b38f7Smrg	  # are installed into $libdir/../bin (currently, that works fine)
29657a3b38f7Smrg	  # but it's something to keep an eye on.
29667a3b38f7Smrg	  test "$inst_prefix_dir" = "$destdir" && \
29677a3b38f7Smrg	    func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
29687a3b38f7Smrg
29697a3b38f7Smrg	  if test -n "$inst_prefix_dir"; then
29707a3b38f7Smrg	    # Stick the inst_prefix_dir data into the link command.
297144dda7b2Smrg	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
29727a3b38f7Smrg	  else
297344dda7b2Smrg	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
29747a3b38f7Smrg	  fi
29757a3b38f7Smrg
29767a3b38f7Smrg	  func_warning "relinking \`$file'"
29777a3b38f7Smrg	  func_show_eval "$relink_command" \
29787a3b38f7Smrg	    'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
29797a3b38f7Smrg	fi
29807a3b38f7Smrg
29817a3b38f7Smrg	# See the names of the shared library.
29827a3b38f7Smrg	set dummy $library_names; shift
29837a3b38f7Smrg	if test -n "$1"; then
29847a3b38f7Smrg	  realname="$1"
29857a3b38f7Smrg	  shift
29867a3b38f7Smrg
29877a3b38f7Smrg	  srcname="$realname"
29887a3b38f7Smrg	  test -n "$relink_command" && srcname="$realname"T
29897a3b38f7Smrg
29907a3b38f7Smrg	  # Install the shared library and build the symlinks.
299144dda7b2Smrg	  func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
29927a3b38f7Smrg	      'exit $?'
29937a3b38f7Smrg	  tstripme="$stripme"
29947a3b38f7Smrg	  case $host_os in
29957a3b38f7Smrg	  cygwin* | mingw* | pw32* | cegcc*)
29967a3b38f7Smrg	    case $realname in
29977a3b38f7Smrg	    *.dll.a)
29987a3b38f7Smrg	      tstripme=""
29997a3b38f7Smrg	      ;;
30007a3b38f7Smrg	    esac
3001ff559fabSmrg	    ;;
3002ff559fabSmrg	  esac
30037a3b38f7Smrg	  if test -n "$tstripme" && test -n "$striplib"; then
30047a3b38f7Smrg	    func_show_eval "$striplib $destdir/$realname" 'exit $?'
3005ff559fabSmrg	  fi
30067a3b38f7Smrg
30077a3b38f7Smrg	  if test "$#" -gt 0; then
30087a3b38f7Smrg	    # Delete the old symlinks, and create new ones.
30097a3b38f7Smrg	    # Try `ln -sf' first, because the `ln' binary might depend on
30107a3b38f7Smrg	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
30117a3b38f7Smrg	    # so we also need to try rm && ln -s.
30127a3b38f7Smrg	    for linkname
30137a3b38f7Smrg	    do
30147a3b38f7Smrg	      test "$linkname" != "$realname" \
30157a3b38f7Smrg		&& func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
3016ff559fabSmrg	    done
3017ff559fabSmrg	  fi
3018ff559fabSmrg
30197a3b38f7Smrg	  # Do each command in the postinstall commands.
30207a3b38f7Smrg	  lib="$destdir/$realname"
30217a3b38f7Smrg	  func_execute_cmds "$postinstall_cmds" 'exit $?'
3022ff559fabSmrg	fi
3023ff559fabSmrg
30247a3b38f7Smrg	# Install the pseudo-library for information purposes.
30257a3b38f7Smrg	func_basename "$file"
30267a3b38f7Smrg	name="$func_basename_result"
30277a3b38f7Smrg	instname="$dir/$name"i
30287a3b38f7Smrg	func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
3029ff559fabSmrg
30307a3b38f7Smrg	# Maybe install the static library, too.
3031862f5301Smrg	test -n "$old_library" && func_append staticlibs " $dir/$old_library"
30327a3b38f7Smrg	;;
3033ff559fabSmrg
30347a3b38f7Smrg      *.lo)
30357a3b38f7Smrg	# Install (i.e. copy) a libtool object.
3036ff559fabSmrg
30377a3b38f7Smrg	# Figure out destination file name, if it wasn't already specified.
30387a3b38f7Smrg	if test -n "$destname"; then
30397a3b38f7Smrg	  destfile="$destdir/$destname"
30407a3b38f7Smrg	else
30417a3b38f7Smrg	  func_basename "$file"
30427a3b38f7Smrg	  destfile="$func_basename_result"
30437a3b38f7Smrg	  destfile="$destdir/$destfile"
30447a3b38f7Smrg	fi
30457a3b38f7Smrg
30467a3b38f7Smrg	# Deduce the name of the destination old-style object file.
30477a3b38f7Smrg	case $destfile in
30487a3b38f7Smrg	*.lo)
30497a3b38f7Smrg	  func_lo2o "$destfile"
30507a3b38f7Smrg	  staticdest=$func_lo2o_result
30517a3b38f7Smrg	  ;;
30527a3b38f7Smrg	*.$objext)
30537a3b38f7Smrg	  staticdest="$destfile"
30547a3b38f7Smrg	  destfile=
30557a3b38f7Smrg	  ;;
30567a3b38f7Smrg	*)
30577a3b38f7Smrg	  func_fatal_help "cannot copy a libtool object to \`$destfile'"
30587a3b38f7Smrg	  ;;
3059ff559fabSmrg	esac
3060ff559fabSmrg
30617a3b38f7Smrg	# Install the libtool object if requested.
30627a3b38f7Smrg	test -n "$destfile" && \
30637a3b38f7Smrg	  func_show_eval "$install_prog $file $destfile" 'exit $?'
30647a3b38f7Smrg
30657a3b38f7Smrg	# Install the old object if enabled.
30667a3b38f7Smrg	if test "$build_old_libs" = yes; then
30677a3b38f7Smrg	  # Deduce the name of the old-style object file.
30687a3b38f7Smrg	  func_lo2o "$file"
30697a3b38f7Smrg	  staticobj=$func_lo2o_result
30707a3b38f7Smrg	  func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
3071ff559fabSmrg	fi
30727a3b38f7Smrg	exit $EXIT_SUCCESS
30737a3b38f7Smrg	;;
3074ff559fabSmrg
30757a3b38f7Smrg      *)
30767a3b38f7Smrg	# Figure out destination file name, if it wasn't already specified.
30777a3b38f7Smrg	if test -n "$destname"; then
30787a3b38f7Smrg	  destfile="$destdir/$destname"
30797a3b38f7Smrg	else
30807a3b38f7Smrg	  func_basename "$file"
30817a3b38f7Smrg	  destfile="$func_basename_result"
30827a3b38f7Smrg	  destfile="$destdir/$destfile"
30837a3b38f7Smrg	fi
30847a3b38f7Smrg
30857a3b38f7Smrg	# If the file is missing, and there is a .exe on the end, strip it
30867a3b38f7Smrg	# because it is most likely a libtool script we actually want to
30877a3b38f7Smrg	# install
30887a3b38f7Smrg	stripped_ext=""
30897a3b38f7Smrg	case $file in
30907a3b38f7Smrg	  *.exe)
30917a3b38f7Smrg	    if test ! -f "$file"; then
30927a3b38f7Smrg	      func_stripname '' '.exe' "$file"
30937a3b38f7Smrg	      file=$func_stripname_result
30947a3b38f7Smrg	      stripped_ext=".exe"
3095ff559fabSmrg	    fi
30967a3b38f7Smrg	    ;;
30977a3b38f7Smrg	esac
3098ff559fabSmrg
30997a3b38f7Smrg	# Do a test to see if this is really a libtool program.
31007a3b38f7Smrg	case $host in
31017a3b38f7Smrg	*cygwin* | *mingw*)
31027a3b38f7Smrg	    if func_ltwrapper_executable_p "$file"; then
31037a3b38f7Smrg	      func_ltwrapper_scriptname "$file"
31047a3b38f7Smrg	      wrapper=$func_ltwrapper_scriptname_result
31057a3b38f7Smrg	    else
31067a3b38f7Smrg	      func_stripname '' '.exe' "$file"
31077a3b38f7Smrg	      wrapper=$func_stripname_result
31087a3b38f7Smrg	    fi
31097a3b38f7Smrg	    ;;
31107a3b38f7Smrg	*)
31117a3b38f7Smrg	    wrapper=$file
31127a3b38f7Smrg	    ;;
31137a3b38f7Smrg	esac
31147a3b38f7Smrg	if func_ltwrapper_script_p "$wrapper"; then
31157a3b38f7Smrg	  notinst_deplibs=
31167a3b38f7Smrg	  relink_command=
3117ff559fabSmrg
31187a3b38f7Smrg	  func_source "$wrapper"
3119ff559fabSmrg
31207a3b38f7Smrg	  # Check the variables that should have been set.
31217a3b38f7Smrg	  test -z "$generated_by_libtool_version" && \
31227a3b38f7Smrg	    func_fatal_error "invalid libtool wrapper script \`$wrapper'"
31237a3b38f7Smrg
31247a3b38f7Smrg	  finalize=yes
31257a3b38f7Smrg	  for lib in $notinst_deplibs; do
31267a3b38f7Smrg	    # Check to see that each library is installed.
31277a3b38f7Smrg	    libdir=
31287a3b38f7Smrg	    if test -f "$lib"; then
31297a3b38f7Smrg	      func_source "$lib"
31307a3b38f7Smrg	    fi
313144dda7b2Smrg	    libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test
31327a3b38f7Smrg	    if test -n "$libdir" && test ! -f "$libfile"; then
31337a3b38f7Smrg	      func_warning "\`$lib' has not been installed in \`$libdir'"
31347a3b38f7Smrg	      finalize=no
31357a3b38f7Smrg	    fi
31367a3b38f7Smrg	  done
31377a3b38f7Smrg
31387a3b38f7Smrg	  relink_command=
31397a3b38f7Smrg	  func_source "$wrapper"
31407a3b38f7Smrg
31417a3b38f7Smrg	  outputname=
31427a3b38f7Smrg	  if test "$fast_install" = no && test -n "$relink_command"; then
31437a3b38f7Smrg	    $opt_dry_run || {
31447a3b38f7Smrg	      if test "$finalize" = yes; then
31457a3b38f7Smrg	        tmpdir=`func_mktempdir`
31467a3b38f7Smrg		func_basename "$file$stripped_ext"
31477a3b38f7Smrg		file="$func_basename_result"
31487a3b38f7Smrg	        outputname="$tmpdir/$file"
31497a3b38f7Smrg	        # Replace the output file specification.
315044dda7b2Smrg	        relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
31517a3b38f7Smrg
31527a3b38f7Smrg	        $opt_silent || {
31537a3b38f7Smrg	          func_quote_for_expand "$relink_command"
31547a3b38f7Smrg		  eval "func_echo $func_quote_for_expand_result"
31557a3b38f7Smrg	        }
31567a3b38f7Smrg	        if eval "$relink_command"; then :
31577a3b38f7Smrg	          else
31587a3b38f7Smrg		  func_error "error: relink \`$file' with the above command before installing it"
31597a3b38f7Smrg		  $opt_dry_run || ${RM}r "$tmpdir"
31607a3b38f7Smrg		  continue
31617a3b38f7Smrg	        fi
31627a3b38f7Smrg	        file="$outputname"
31637a3b38f7Smrg	      else
31647a3b38f7Smrg	        func_warning "cannot relink \`$file'"
31657a3b38f7Smrg	      fi
31667a3b38f7Smrg	    }
3167ff559fabSmrg	  else
31687a3b38f7Smrg	    # Install the binary that we compiled earlier.
316944dda7b2Smrg	    file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
3170ff559fabSmrg	  fi
31717a3b38f7Smrg	fi
3172ff559fabSmrg
31737a3b38f7Smrg	# remove .exe since cygwin /usr/bin/install will append another
31747a3b38f7Smrg	# one anyway
31757a3b38f7Smrg	case $install_prog,$host in
31767a3b38f7Smrg	*/usr/bin/install*,*cygwin*)
31777a3b38f7Smrg	  case $file:$destfile in
31787a3b38f7Smrg	  *.exe:*.exe)
31797a3b38f7Smrg	    # this is ok
31807a3b38f7Smrg	    ;;
31817a3b38f7Smrg	  *.exe:*)
31827a3b38f7Smrg	    destfile=$destfile.exe
31837a3b38f7Smrg	    ;;
31847a3b38f7Smrg	  *:*.exe)
31857a3b38f7Smrg	    func_stripname '' '.exe' "$destfile"
31867a3b38f7Smrg	    destfile=$func_stripname_result
31877a3b38f7Smrg	    ;;
31887a3b38f7Smrg	  esac
3189ff559fabSmrg	  ;;
3190ff559fabSmrg	esac
31917a3b38f7Smrg	func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
31927a3b38f7Smrg	$opt_dry_run || if test -n "$outputname"; then
31937a3b38f7Smrg	  ${RM}r "$tmpdir"
31947a3b38f7Smrg	fi
31957a3b38f7Smrg	;;
31967a3b38f7Smrg      esac
31977a3b38f7Smrg    done
3198ff559fabSmrg
31997a3b38f7Smrg    for file in $staticlibs; do
32007a3b38f7Smrg      func_basename "$file"
32017a3b38f7Smrg      name="$func_basename_result"
3202ff559fabSmrg
32037a3b38f7Smrg      # Set up the ranlib parameters.
32047a3b38f7Smrg      oldlib="$destdir/$name"
3205fc544a13Smrg      func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
3206fc544a13Smrg      tool_oldlib=$func_to_tool_file_result
3207ff559fabSmrg
32087a3b38f7Smrg      func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
3209ff559fabSmrg
32107a3b38f7Smrg      if test -n "$stripme" && test -n "$old_striplib"; then
3211fc544a13Smrg	func_show_eval "$old_striplib $tool_oldlib" 'exit $?'
32127a3b38f7Smrg      fi
3213ff559fabSmrg
32147a3b38f7Smrg      # Do each command in the postinstall commands.
32157a3b38f7Smrg      func_execute_cmds "$old_postinstall_cmds" 'exit $?'
32167a3b38f7Smrg    done
3217ff559fabSmrg
32187a3b38f7Smrg    test -n "$future_libdirs" && \
32197a3b38f7Smrg      func_warning "remember to run \`$progname --finish$future_libdirs'"
3220ff559fabSmrg
32217a3b38f7Smrg    if test -n "$current_libdirs"; then
32227a3b38f7Smrg      # Maybe just do a dry run.
32237a3b38f7Smrg      $opt_dry_run && current_libdirs=" -n$current_libdirs"
32247a3b38f7Smrg      exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
32257a3b38f7Smrg    else
32267a3b38f7Smrg      exit $EXIT_SUCCESS
32277a3b38f7Smrg    fi
32287a3b38f7Smrg}
3229ff559fabSmrg
3230862f5301Smrgtest "$opt_mode" = install && func_mode_install ${1+"$@"}
3231ff559fabSmrg
3232ff559fabSmrg
32337a3b38f7Smrg# func_generate_dlsyms outputname originator pic_p
32347a3b38f7Smrg# Extract symbols from dlprefiles and create ${outputname}S.o with
32357a3b38f7Smrg# a dlpreopen symbol table.
32367a3b38f7Smrgfunc_generate_dlsyms ()
32377a3b38f7Smrg{
32387a3b38f7Smrg    $opt_debug
32397a3b38f7Smrg    my_outputname="$1"
32407a3b38f7Smrg    my_originator="$2"
32417a3b38f7Smrg    my_pic_p="${3-no}"
32427a3b38f7Smrg    my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'`
32437a3b38f7Smrg    my_dlsyms=
32447a3b38f7Smrg
32457a3b38f7Smrg    if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
32467a3b38f7Smrg      if test -n "$NM" && test -n "$global_symbol_pipe"; then
32477a3b38f7Smrg	my_dlsyms="${my_outputname}S.c"
32487a3b38f7Smrg      else
32497a3b38f7Smrg	func_error "not configured to extract global symbols from dlpreopened files"
32507a3b38f7Smrg      fi
32517a3b38f7Smrg    fi
3252ff559fabSmrg
32537a3b38f7Smrg    if test -n "$my_dlsyms"; then
32547a3b38f7Smrg      case $my_dlsyms in
32557a3b38f7Smrg      "") ;;
32567a3b38f7Smrg      *.c)
32577a3b38f7Smrg	# Discover the nlist of each of the dlfiles.
32587a3b38f7Smrg	nlist="$output_objdir/${my_outputname}.nm"
32597a3b38f7Smrg
32607a3b38f7Smrg	func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
32617a3b38f7Smrg
32627a3b38f7Smrg	# Parse the name list into a source file.
32637a3b38f7Smrg	func_verbose "creating $output_objdir/$my_dlsyms"
32647a3b38f7Smrg
32657a3b38f7Smrg	$opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
32667a3b38f7Smrg/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */
32677a3b38f7Smrg/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */
32687a3b38f7Smrg
32697a3b38f7Smrg#ifdef __cplusplus
32707a3b38f7Smrgextern \"C\" {
32717a3b38f7Smrg#endif
32727a3b38f7Smrg
327344dda7b2Smrg#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
327444dda7b2Smrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
327544dda7b2Smrg#endif
327644dda7b2Smrg
3277862f5301Smrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
3278862f5301Smrg#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
3279862f5301Smrg/* DATA imports from DLLs on WIN32 con't be const, because runtime
3280862f5301Smrg   relocations are performed -- see ld's documentation on pseudo-relocs.  */
3281862f5301Smrg# define LT_DLSYM_CONST
3282862f5301Smrg#elif defined(__osf__)
3283862f5301Smrg/* This system does not cope well with relocations in const data.  */
3284862f5301Smrg# define LT_DLSYM_CONST
3285862f5301Smrg#else
3286862f5301Smrg# define LT_DLSYM_CONST const
3287862f5301Smrg#endif
3288862f5301Smrg
32897a3b38f7Smrg/* External symbol declarations for the compiler. */\
32907a3b38f7Smrg"
32917a3b38f7Smrg
32927a3b38f7Smrg	if test "$dlself" = yes; then
32937a3b38f7Smrg	  func_verbose "generating symbol list for \`$output'"
32947a3b38f7Smrg
32957a3b38f7Smrg	  $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
32967a3b38f7Smrg
32977a3b38f7Smrg	  # Add our own program objects to the symbol list.
329844dda7b2Smrg	  progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
32997a3b38f7Smrg	  for progfile in $progfiles; do
3300862f5301Smrg	    func_to_tool_file "$progfile" func_convert_file_msys_to_w32
3301862f5301Smrg	    func_verbose "extracting global C symbols from \`$func_to_tool_file_result'"
3302862f5301Smrg	    $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
33037a3b38f7Smrg	  done
33047a3b38f7Smrg
33057a3b38f7Smrg	  if test -n "$exclude_expsyms"; then
33067a3b38f7Smrg	    $opt_dry_run || {
33077a3b38f7Smrg	      eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
33087a3b38f7Smrg	      eval '$MV "$nlist"T "$nlist"'
33097a3b38f7Smrg	    }
3310ff559fabSmrg	  fi
3311ff559fabSmrg
33127a3b38f7Smrg	  if test -n "$export_symbols_regex"; then
33137a3b38f7Smrg	    $opt_dry_run || {
33147a3b38f7Smrg	      eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
33157a3b38f7Smrg	      eval '$MV "$nlist"T "$nlist"'
33167a3b38f7Smrg	    }
3317ff559fabSmrg	  fi
33187a3b38f7Smrg
33197a3b38f7Smrg	  # Prepare the list of exported symbols
33207a3b38f7Smrg	  if test -z "$export_symbols"; then
33217a3b38f7Smrg	    export_symbols="$output_objdir/$outputname.exp"
33227a3b38f7Smrg	    $opt_dry_run || {
33237a3b38f7Smrg	      $RM $export_symbols
33247a3b38f7Smrg	      eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
33257a3b38f7Smrg	      case $host in
33267a3b38f7Smrg	      *cygwin* | *mingw* | *cegcc* )
33277a3b38f7Smrg                eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
33287a3b38f7Smrg                eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
33297a3b38f7Smrg	        ;;
3330ff559fabSmrg	      esac
33317a3b38f7Smrg	    }
33327a3b38f7Smrg	  else
33337a3b38f7Smrg	    $opt_dry_run || {
33347a3b38f7Smrg	      eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
33357a3b38f7Smrg	      eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
33367a3b38f7Smrg	      eval '$MV "$nlist"T "$nlist"'
33377a3b38f7Smrg	      case $host in
333844dda7b2Smrg	        *cygwin* | *mingw* | *cegcc* )
33397a3b38f7Smrg	          eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
33407a3b38f7Smrg	          eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
33417a3b38f7Smrg	          ;;
3342ff559fabSmrg	      esac
33437a3b38f7Smrg	    }
3344ff559fabSmrg	  fi
33457a3b38f7Smrg	fi
3346ff559fabSmrg
33477a3b38f7Smrg	for dlprefile in $dlprefiles; do
33487a3b38f7Smrg	  func_verbose "extracting global C symbols from \`$dlprefile'"
33497a3b38f7Smrg	  func_basename "$dlprefile"
33507a3b38f7Smrg	  name="$func_basename_result"
3351862f5301Smrg          case $host in
3352862f5301Smrg	    *cygwin* | *mingw* | *cegcc* )
3353862f5301Smrg	      # if an import library, we need to obtain dlname
3354862f5301Smrg	      if func_win32_import_lib_p "$dlprefile"; then
3355862f5301Smrg	        func_tr_sh "$dlprefile"
3356862f5301Smrg	        eval "curr_lafile=\$libfile_$func_tr_sh_result"
3357862f5301Smrg	        dlprefile_dlbasename=""
3358862f5301Smrg	        if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
3359862f5301Smrg	          # Use subshell, to avoid clobbering current variable values
3360862f5301Smrg	          dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
3361862f5301Smrg	          if test -n "$dlprefile_dlname" ; then
3362862f5301Smrg	            func_basename "$dlprefile_dlname"
3363862f5301Smrg	            dlprefile_dlbasename="$func_basename_result"
3364862f5301Smrg	          else
3365862f5301Smrg	            # no lafile. user explicitly requested -dlpreopen <import library>.
3366862f5301Smrg	            $sharedlib_from_linklib_cmd "$dlprefile"
3367862f5301Smrg	            dlprefile_dlbasename=$sharedlib_from_linklib_result
3368862f5301Smrg	          fi
3369862f5301Smrg	        fi
3370862f5301Smrg	        $opt_dry_run || {
3371862f5301Smrg	          if test -n "$dlprefile_dlbasename" ; then
3372862f5301Smrg	            eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
3373862f5301Smrg	          else
3374862f5301Smrg	            func_warning "Could not compute DLL name from $name"
3375862f5301Smrg	            eval '$ECHO ": $name " >> "$nlist"'
3376862f5301Smrg	          fi
3377862f5301Smrg	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
3378862f5301Smrg	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe |
3379862f5301Smrg	            $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'"
3380862f5301Smrg	        }
3381862f5301Smrg	      else # not an import lib
3382862f5301Smrg	        $opt_dry_run || {
3383862f5301Smrg	          eval '$ECHO ": $name " >> "$nlist"'
3384862f5301Smrg	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
3385862f5301Smrg	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
3386862f5301Smrg	        }
3387862f5301Smrg	      fi
3388862f5301Smrg	    ;;
3389862f5301Smrg	    *)
3390862f5301Smrg	      $opt_dry_run || {
3391862f5301Smrg	        eval '$ECHO ": $name " >> "$nlist"'
3392862f5301Smrg	        func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
3393862f5301Smrg	        eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
3394862f5301Smrg	      }
3395862f5301Smrg	    ;;
3396862f5301Smrg          esac
33977a3b38f7Smrg	done
3398ff559fabSmrg
33997a3b38f7Smrg	$opt_dry_run || {
34007a3b38f7Smrg	  # Make sure we have at least an empty file.
34017a3b38f7Smrg	  test -f "$nlist" || : > "$nlist"
3402ff559fabSmrg
34037a3b38f7Smrg	  if test -n "$exclude_expsyms"; then
34047a3b38f7Smrg	    $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
34057a3b38f7Smrg	    $MV "$nlist"T "$nlist"
3406ff559fabSmrg	  fi
3407ff559fabSmrg
34087a3b38f7Smrg	  # Try sorting and uniquifying the output.
34097a3b38f7Smrg	  if $GREP -v "^: " < "$nlist" |
34107a3b38f7Smrg	      if sort -k 3 </dev/null >/dev/null 2>&1; then
34117a3b38f7Smrg		sort -k 3
3412ff559fabSmrg	      else
34137a3b38f7Smrg		sort +2
34147a3b38f7Smrg	      fi |
34157a3b38f7Smrg	      uniq > "$nlist"S; then
34167a3b38f7Smrg	    :
3417ff559fabSmrg	  else
34187a3b38f7Smrg	    $GREP -v "^: " < "$nlist" > "$nlist"S
3419ff559fabSmrg	  fi
3420ff559fabSmrg
34217a3b38f7Smrg	  if test -f "$nlist"S; then
34227a3b38f7Smrg	    eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
3423ff559fabSmrg	  else
342444dda7b2Smrg	    echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
3425ff559fabSmrg	  fi
3426ff559fabSmrg
342744dda7b2Smrg	  echo >> "$output_objdir/$my_dlsyms" "\
3428ff559fabSmrg
34297a3b38f7Smrg/* The mapping between symbol names and symbols.  */
34307a3b38f7Smrgtypedef struct {
34317a3b38f7Smrg  const char *name;
34327a3b38f7Smrg  void *address;
34337a3b38f7Smrg} lt_dlsymlist;
3434862f5301Smrgextern LT_DLSYM_CONST lt_dlsymlist
34357a3b38f7Smrglt_${my_prefix}_LTX_preloaded_symbols[];
3436862f5301SmrgLT_DLSYM_CONST lt_dlsymlist
34377a3b38f7Smrglt_${my_prefix}_LTX_preloaded_symbols[] =
34387a3b38f7Smrg{\
34397a3b38f7Smrg  { \"$my_originator\", (void *) 0 },"
34407a3b38f7Smrg
34417a3b38f7Smrg	  case $need_lib_prefix in
34427a3b38f7Smrg	  no)
34437a3b38f7Smrg	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
34447a3b38f7Smrg	    ;;
34457a3b38f7Smrg	  *)
34467a3b38f7Smrg	    eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
34477a3b38f7Smrg	    ;;
34487a3b38f7Smrg	  esac
344944dda7b2Smrg	  echo >> "$output_objdir/$my_dlsyms" "\
34507a3b38f7Smrg  {0, (void *) 0}
34517a3b38f7Smrg};
34527a3b38f7Smrg
34537a3b38f7Smrg/* This works around a problem in FreeBSD linker */
34547a3b38f7Smrg#ifdef FREEBSD_WORKAROUND
34557a3b38f7Smrgstatic const void *lt_preloaded_setup() {
34567a3b38f7Smrg  return lt_${my_prefix}_LTX_preloaded_symbols;
34577a3b38f7Smrg}
34587a3b38f7Smrg#endif
34597a3b38f7Smrg
34607a3b38f7Smrg#ifdef __cplusplus
34617a3b38f7Smrg}
34627a3b38f7Smrg#endif\
34637a3b38f7Smrg"
34647a3b38f7Smrg	} # !$opt_dry_run
34657a3b38f7Smrg
34667a3b38f7Smrg	pic_flag_for_symtable=
34677a3b38f7Smrg	case "$compile_command " in
34687a3b38f7Smrg	*" -static "*) ;;
34697a3b38f7Smrg	*)
34707a3b38f7Smrg	  case $host in
34717a3b38f7Smrg	  # compiling the symbol table file with pic_flag works around
34727a3b38f7Smrg	  # a FreeBSD bug that causes programs to crash when -lm is
34737a3b38f7Smrg	  # linked before any other PIC object.  But we must not use
34747a3b38f7Smrg	  # pic_flag when linking with -static.  The problem exists in
34757a3b38f7Smrg	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
3476fc544a13Smrg	  *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
34777a3b38f7Smrg	    pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
34787a3b38f7Smrg	  *-*-hpux*)
34797a3b38f7Smrg	    pic_flag_for_symtable=" $pic_flag"  ;;
34807a3b38f7Smrg	  *)
34817a3b38f7Smrg	    if test "X$my_pic_p" != Xno; then
34827a3b38f7Smrg	      pic_flag_for_symtable=" $pic_flag"
3483ff559fabSmrg	    fi
34847a3b38f7Smrg	    ;;
34857a3b38f7Smrg	  esac
34867a3b38f7Smrg	  ;;
34877a3b38f7Smrg	esac
34887a3b38f7Smrg	symtab_cflags=
34897a3b38f7Smrg	for arg in $LTCFLAGS; do
34907a3b38f7Smrg	  case $arg in
34917a3b38f7Smrg	  -pie | -fpie | -fPIE) ;;
3492862f5301Smrg	  *) func_append symtab_cflags " $arg" ;;
34937a3b38f7Smrg	  esac
34947a3b38f7Smrg	done
3495ff559fabSmrg
34967a3b38f7Smrg	# Now compile the dynamic symbol file.
34977a3b38f7Smrg	func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
3498ff559fabSmrg
34997a3b38f7Smrg	# Clean up the generated files.
35007a3b38f7Smrg	func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"'
35017a3b38f7Smrg
35027a3b38f7Smrg	# Transform the symbol file into the correct name.
35037a3b38f7Smrg	symfileobj="$output_objdir/${my_outputname}S.$objext"
35047a3b38f7Smrg	case $host in
35057a3b38f7Smrg	*cygwin* | *mingw* | *cegcc* )
35067a3b38f7Smrg	  if test -f "$output_objdir/$my_outputname.def"; then
350744dda7b2Smrg	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
350844dda7b2Smrg	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
35097a3b38f7Smrg	  else
351044dda7b2Smrg	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
351144dda7b2Smrg	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
35127a3b38f7Smrg	  fi
35137a3b38f7Smrg	  ;;
35147a3b38f7Smrg	*)
351544dda7b2Smrg	  compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
351644dda7b2Smrg	  finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3517ff559fabSmrg	  ;;
3518ff559fabSmrg	esac
35197a3b38f7Smrg	;;
35207a3b38f7Smrg      *)
35217a3b38f7Smrg	func_fatal_error "unknown suffix for \`$my_dlsyms'"
35227a3b38f7Smrg	;;
35237a3b38f7Smrg      esac
35247a3b38f7Smrg    else
35257a3b38f7Smrg      # We keep going just in case the user didn't refer to
35267a3b38f7Smrg      # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
35277a3b38f7Smrg      # really was required.
35287a3b38f7Smrg
35297a3b38f7Smrg      # Nullify the symbol file.
353044dda7b2Smrg      compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
353144dda7b2Smrg      finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
3532ff559fabSmrg    fi
35337a3b38f7Smrg}
3534ff559fabSmrg
35357a3b38f7Smrg# func_win32_libid arg
35367a3b38f7Smrg# return the library type of file 'arg'
35377a3b38f7Smrg#
35387a3b38f7Smrg# Need a lot of goo to handle *both* DLLs and import libs
35397a3b38f7Smrg# Has to be a shell function in order to 'eat' the argument
35407a3b38f7Smrg# that is supplied when $file_magic_command is called.
354144dda7b2Smrg# Despite the name, also deal with 64 bit binaries.
35427a3b38f7Smrgfunc_win32_libid ()
35437a3b38f7Smrg{
35447a3b38f7Smrg  $opt_debug
35457a3b38f7Smrg  win32_libid_type="unknown"
35467a3b38f7Smrg  win32_fileres=`file -L $1 2>/dev/null`
35477a3b38f7Smrg  case $win32_fileres in
35487a3b38f7Smrg  *ar\ archive\ import\ library*) # definitely import
35497a3b38f7Smrg    win32_libid_type="x86 archive import"
35507a3b38f7Smrg    ;;
35517a3b38f7Smrg  *ar\ archive*) # could be an import, or static
355244dda7b2Smrg    # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
35537a3b38f7Smrg    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
355444dda7b2Smrg       $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
3555862f5301Smrg      func_to_tool_file "$1" func_convert_file_msys_to_w32
3556862f5301Smrg      win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
35577a3b38f7Smrg	$SED -n -e '
35587a3b38f7Smrg	    1,100{
35597a3b38f7Smrg		/ I /{
35607a3b38f7Smrg		    s,.*,import,
35617a3b38f7Smrg		    p
35627a3b38f7Smrg		    q
35637a3b38f7Smrg		}
35647a3b38f7Smrg	    }'`
35657a3b38f7Smrg      case $win32_nmres in
35667a3b38f7Smrg      import*)  win32_libid_type="x86 archive import";;
35677a3b38f7Smrg      *)        win32_libid_type="x86 archive static";;
35687a3b38f7Smrg      esac
35697a3b38f7Smrg    fi
35707a3b38f7Smrg    ;;
35717a3b38f7Smrg  *DLL*)
35727a3b38f7Smrg    win32_libid_type="x86 DLL"
35737a3b38f7Smrg    ;;
35747a3b38f7Smrg  *executable*) # but shell scripts are "executable" too...
35757a3b38f7Smrg    case $win32_fileres in
35767a3b38f7Smrg    *MS\ Windows\ PE\ Intel*)
35777a3b38f7Smrg      win32_libid_type="x86 DLL"
35787a3b38f7Smrg      ;;
35797a3b38f7Smrg    esac
35807a3b38f7Smrg    ;;
35817a3b38f7Smrg  esac
35827a3b38f7Smrg  $ECHO "$win32_libid_type"
35837a3b38f7Smrg}
3584ff559fabSmrg
3585862f5301Smrg# func_cygming_dll_for_implib ARG
3586862f5301Smrg#
3587862f5301Smrg# Platform-specific function to extract the
3588862f5301Smrg# name of the DLL associated with the specified
3589862f5301Smrg# import library ARG.
3590862f5301Smrg# Invoked by eval'ing the libtool variable
3591862f5301Smrg#    $sharedlib_from_linklib_cmd
3592862f5301Smrg# Result is available in the variable
3593862f5301Smrg#    $sharedlib_from_linklib_result
3594862f5301Smrgfunc_cygming_dll_for_implib ()
3595862f5301Smrg{
3596862f5301Smrg  $opt_debug
3597862f5301Smrg  sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
3598862f5301Smrg}
3599862f5301Smrg
3600862f5301Smrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs
3601862f5301Smrg#
3602862f5301Smrg# The is the core of a fallback implementation of a
3603862f5301Smrg# platform-specific function to extract the name of the
3604862f5301Smrg# DLL associated with the specified import library LIBNAME.
3605862f5301Smrg#
3606862f5301Smrg# SECTION_NAME is either .idata$6 or .idata$7, depending
3607862f5301Smrg# on the platform and compiler that created the implib.
3608862f5301Smrg#
3609862f5301Smrg# Echos the name of the DLL associated with the
3610862f5301Smrg# specified import library.
3611862f5301Smrgfunc_cygming_dll_for_implib_fallback_core ()
3612862f5301Smrg{
3613862f5301Smrg  $opt_debug
3614862f5301Smrg  match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
3615862f5301Smrg  $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
3616862f5301Smrg    $SED '/^Contents of section '"$match_literal"':/{
3617862f5301Smrg      # Place marker at beginning of archive member dllname section
3618862f5301Smrg      s/.*/====MARK====/
3619862f5301Smrg      p
3620862f5301Smrg      d
3621862f5301Smrg    }
3622862f5301Smrg    # These lines can sometimes be longer than 43 characters, but
3623862f5301Smrg    # are always uninteresting
3624862f5301Smrg    /:[	 ]*file format pe[i]\{,1\}-/d
3625862f5301Smrg    /^In archive [^:]*:/d
3626862f5301Smrg    # Ensure marker is printed
3627862f5301Smrg    /^====MARK====/p
3628862f5301Smrg    # Remove all lines with less than 43 characters
3629862f5301Smrg    /^.\{43\}/!d
3630862f5301Smrg    # From remaining lines, remove first 43 characters
3631862f5301Smrg    s/^.\{43\}//' |
3632862f5301Smrg    $SED -n '
3633862f5301Smrg      # Join marker and all lines until next marker into a single line
3634862f5301Smrg      /^====MARK====/ b para
3635862f5301Smrg      H
3636862f5301Smrg      $ b para
3637862f5301Smrg      b
3638862f5301Smrg      :para
3639862f5301Smrg      x
3640862f5301Smrg      s/\n//g
3641862f5301Smrg      # Remove the marker
3642862f5301Smrg      s/^====MARK====//
3643862f5301Smrg      # Remove trailing dots and whitespace
3644862f5301Smrg      s/[\. \t]*$//
3645862f5301Smrg      # Print
3646862f5301Smrg      /./p' |
3647862f5301Smrg    # we now have a list, one entry per line, of the stringified
3648862f5301Smrg    # contents of the appropriate section of all members of the
3649862f5301Smrg    # archive which possess that section. Heuristic: eliminate
3650862f5301Smrg    # all those which have a first or second character that is
3651862f5301Smrg    # a '.' (that is, objdump's representation of an unprintable
3652862f5301Smrg    # character.) This should work for all archives with less than
3653862f5301Smrg    # 0x302f exports -- but will fail for DLLs whose name actually
3654862f5301Smrg    # begins with a literal '.' or a single character followed by
3655862f5301Smrg    # a '.'.
3656862f5301Smrg    #
3657862f5301Smrg    # Of those that remain, print the first one.
3658862f5301Smrg    $SED -e '/^\./d;/^.\./d;q'
3659862f5301Smrg}
3660862f5301Smrg
3661862f5301Smrg# func_cygming_gnu_implib_p ARG
3662862f5301Smrg# This predicate returns with zero status (TRUE) if
3663862f5301Smrg# ARG is a GNU/binutils-style import library. Returns
3664862f5301Smrg# with nonzero status (FALSE) otherwise.
3665862f5301Smrgfunc_cygming_gnu_implib_p ()
3666862f5301Smrg{
3667862f5301Smrg  $opt_debug
3668862f5301Smrg  func_to_tool_file "$1" func_convert_file_msys_to_w32
3669862f5301Smrg  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)$'`
3670862f5301Smrg  test -n "$func_cygming_gnu_implib_tmp"
3671862f5301Smrg}
3672862f5301Smrg
3673862f5301Smrg# func_cygming_ms_implib_p ARG
3674862f5301Smrg# This predicate returns with zero status (TRUE) if
3675862f5301Smrg# ARG is an MS-style import library. Returns
3676862f5301Smrg# with nonzero status (FALSE) otherwise.
3677862f5301Smrgfunc_cygming_ms_implib_p ()
3678862f5301Smrg{
3679862f5301Smrg  $opt_debug
3680862f5301Smrg  func_to_tool_file "$1" func_convert_file_msys_to_w32
3681862f5301Smrg  func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
3682862f5301Smrg  test -n "$func_cygming_ms_implib_tmp"
3683862f5301Smrg}
3684862f5301Smrg
3685862f5301Smrg# func_cygming_dll_for_implib_fallback ARG
3686862f5301Smrg# Platform-specific function to extract the
3687862f5301Smrg# name of the DLL associated with the specified
3688862f5301Smrg# import library ARG.
3689862f5301Smrg#
3690862f5301Smrg# This fallback implementation is for use when $DLLTOOL
3691862f5301Smrg# does not support the --identify-strict option.
3692862f5301Smrg# Invoked by eval'ing the libtool variable
3693862f5301Smrg#    $sharedlib_from_linklib_cmd
3694862f5301Smrg# Result is available in the variable
3695862f5301Smrg#    $sharedlib_from_linklib_result
3696862f5301Smrgfunc_cygming_dll_for_implib_fallback ()
3697862f5301Smrg{
3698862f5301Smrg  $opt_debug
3699862f5301Smrg  if func_cygming_gnu_implib_p "$1" ; then
3700862f5301Smrg    # binutils import library
3701862f5301Smrg    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
3702862f5301Smrg  elif func_cygming_ms_implib_p "$1" ; then
3703862f5301Smrg    # ms-generated import library
3704862f5301Smrg    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
3705862f5301Smrg  else
3706862f5301Smrg    # unknown
3707862f5301Smrg    sharedlib_from_linklib_result=""
3708862f5301Smrg  fi
3709862f5301Smrg}
3710ff559fabSmrg
3711ff559fabSmrg
37127a3b38f7Smrg# func_extract_an_archive dir oldlib
37137a3b38f7Smrgfunc_extract_an_archive ()
37147a3b38f7Smrg{
37157a3b38f7Smrg    $opt_debug
37167a3b38f7Smrg    f_ex_an_ar_dir="$1"; shift
37177a3b38f7Smrg    f_ex_an_ar_oldlib="$1"
371844dda7b2Smrg    if test "$lock_old_archive_extraction" = yes; then
371944dda7b2Smrg      lockfile=$f_ex_an_ar_oldlib.lock
372044dda7b2Smrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
372144dda7b2Smrg	func_echo "Waiting for $lockfile to be removed"
372244dda7b2Smrg	sleep 2
372344dda7b2Smrg      done
372444dda7b2Smrg    fi
372544dda7b2Smrg    func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
372644dda7b2Smrg		   'stat=$?; rm -f "$lockfile"; exit $stat'
372744dda7b2Smrg    if test "$lock_old_archive_extraction" = yes; then
372844dda7b2Smrg      $opt_dry_run || rm -f "$lockfile"
372944dda7b2Smrg    fi
37307a3b38f7Smrg    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
37317a3b38f7Smrg     :
37327a3b38f7Smrg    else
37337a3b38f7Smrg      func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
37347a3b38f7Smrg    fi
37357a3b38f7Smrg}
3736ff559fabSmrg
3737ff559fabSmrg
37387a3b38f7Smrg# func_extract_archives gentop oldlib ...
37397a3b38f7Smrgfunc_extract_archives ()
37407a3b38f7Smrg{
37417a3b38f7Smrg    $opt_debug
37427a3b38f7Smrg    my_gentop="$1"; shift
37437a3b38f7Smrg    my_oldlibs=${1+"$@"}
37447a3b38f7Smrg    my_oldobjs=""
37457a3b38f7Smrg    my_xlib=""
37467a3b38f7Smrg    my_xabs=""
37477a3b38f7Smrg    my_xdir=""
3748ff559fabSmrg
37497a3b38f7Smrg    for my_xlib in $my_oldlibs; do
37507a3b38f7Smrg      # Extract the objects.
37517a3b38f7Smrg      case $my_xlib in
37527a3b38f7Smrg	[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
37537a3b38f7Smrg	*) my_xabs=`pwd`"/$my_xlib" ;;
37547a3b38f7Smrg      esac
37557a3b38f7Smrg      func_basename "$my_xlib"
37567a3b38f7Smrg      my_xlib="$func_basename_result"
37577a3b38f7Smrg      my_xlib_u=$my_xlib
37587a3b38f7Smrg      while :; do
37597a3b38f7Smrg        case " $extracted_archives " in
37607a3b38f7Smrg	*" $my_xlib_u "*)
37617a3b38f7Smrg	  func_arith $extracted_serial + 1
37627a3b38f7Smrg	  extracted_serial=$func_arith_result
37637a3b38f7Smrg	  my_xlib_u=lt$extracted_serial-$my_xlib ;;
37647a3b38f7Smrg	*) break ;;
37657a3b38f7Smrg	esac
37667a3b38f7Smrg      done
37677a3b38f7Smrg      extracted_archives="$extracted_archives $my_xlib_u"
37687a3b38f7Smrg      my_xdir="$my_gentop/$my_xlib_u"
3769ff559fabSmrg
37707a3b38f7Smrg      func_mkdir_p "$my_xdir"
3771ff559fabSmrg
37727a3b38f7Smrg      case $host in
37737a3b38f7Smrg      *-darwin*)
37747a3b38f7Smrg	func_verbose "Extracting $my_xabs"
37757a3b38f7Smrg	# Do not bother doing anything if just a dry run
37767a3b38f7Smrg	$opt_dry_run || {
37777a3b38f7Smrg	  darwin_orig_dir=`pwd`
37787a3b38f7Smrg	  cd $my_xdir || exit $?
37797a3b38f7Smrg	  darwin_archive=$my_xabs
37807a3b38f7Smrg	  darwin_curdir=`pwd`
37817a3b38f7Smrg	  darwin_base_archive=`basename "$darwin_archive"`
37827a3b38f7Smrg	  darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
37837a3b38f7Smrg	  if test -n "$darwin_arches"; then
37847a3b38f7Smrg	    darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
37857a3b38f7Smrg	    darwin_arch=
37867a3b38f7Smrg	    func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
37877a3b38f7Smrg	    for darwin_arch in  $darwin_arches ; do
37887a3b38f7Smrg	      func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
37897a3b38f7Smrg	      $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
37907a3b38f7Smrg	      cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
37917a3b38f7Smrg	      func_extract_an_archive "`pwd`" "${darwin_base_archive}"
37927a3b38f7Smrg	      cd "$darwin_curdir"
37937a3b38f7Smrg	      $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
37947a3b38f7Smrg	    done # $darwin_arches
37957a3b38f7Smrg            ## Okay now we've a bunch of thin objects, gotta fatten them up :)
37967a3b38f7Smrg	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u`
37977a3b38f7Smrg	    darwin_file=
37987a3b38f7Smrg	    darwin_files=
37997a3b38f7Smrg	    for darwin_file in $darwin_filelist; do
380044dda7b2Smrg	      darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`
38017a3b38f7Smrg	      $LIPO -create -output "$darwin_file" $darwin_files
38027a3b38f7Smrg	    done # $darwin_filelist
38037a3b38f7Smrg	    $RM -rf unfat-$$
38047a3b38f7Smrg	    cd "$darwin_orig_dir"
38057a3b38f7Smrg	  else
38067a3b38f7Smrg	    cd $darwin_orig_dir
38077a3b38f7Smrg	    func_extract_an_archive "$my_xdir" "$my_xabs"
38087a3b38f7Smrg	  fi # $darwin_arches
38097a3b38f7Smrg	} # !$opt_dry_run
38107a3b38f7Smrg	;;
38117a3b38f7Smrg      *)
38127a3b38f7Smrg        func_extract_an_archive "$my_xdir" "$my_xabs"
38137a3b38f7Smrg	;;
3814ff559fabSmrg      esac
381544dda7b2Smrg      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
38167a3b38f7Smrg    done
3817ff559fabSmrg
38187a3b38f7Smrg    func_extract_archives_result="$my_oldobjs"
38197a3b38f7Smrg}
3820ff559fabSmrg
3821ff559fabSmrg
382244dda7b2Smrg# func_emit_wrapper [arg=no]
382344dda7b2Smrg#
382444dda7b2Smrg# Emit a libtool wrapper script on stdout.
382544dda7b2Smrg# Don't directly open a file because we may want to
382644dda7b2Smrg# incorporate the script contents within a cygwin/mingw
382744dda7b2Smrg# wrapper executable.  Must ONLY be called from within
382844dda7b2Smrg# func_mode_link because it depends on a number of variables
382944dda7b2Smrg# set therein.
38307a3b38f7Smrg#
383144dda7b2Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
383244dda7b2Smrg# variable will take.  If 'yes', then the emitted script
383344dda7b2Smrg# will assume that the directory in which it is stored is
383444dda7b2Smrg# the $objdir directory.  This is a cygwin/mingw-specific
383544dda7b2Smrg# behavior.
383644dda7b2Smrgfunc_emit_wrapper ()
38377a3b38f7Smrg{
383844dda7b2Smrg	func_emit_wrapper_arg1=${1-no}
3839ff559fabSmrg
38407a3b38f7Smrg	$ECHO "\
38417a3b38f7Smrg#! $SHELL
3842ff559fabSmrg
38437a3b38f7Smrg# $output - temporary wrapper script for $objdir/$outputname
38447a3b38f7Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
38457a3b38f7Smrg#
38467a3b38f7Smrg# The $output program cannot be directly executed until all the libtool
38477a3b38f7Smrg# libraries that it depends on are installed.
38487a3b38f7Smrg#
38497a3b38f7Smrg# This wrapper script should never be moved out of the build directory.
38507a3b38f7Smrg# If it is, it will not operate correctly.
3851ff559fabSmrg
38527a3b38f7Smrg# Sed substitution that helps us do robust quoting.  It backslashifies
38537a3b38f7Smrg# metacharacters that are still active within double-quoted strings.
38547a3b38f7Smrgsed_quote_subst='$sed_quote_subst'
3855ff559fabSmrg
38567a3b38f7Smrg# Be Bourne compatible
38577a3b38f7Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
38587a3b38f7Smrg  emulate sh
38597a3b38f7Smrg  NULLCMD=:
38607a3b38f7Smrg  # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
38617a3b38f7Smrg  # is contrary to our usage.  Disable this feature.
38627a3b38f7Smrg  alias -g '\${1+\"\$@\"}'='\"\$@\"'
38637a3b38f7Smrg  setopt NO_GLOB_SUBST
38647a3b38f7Smrgelse
38657a3b38f7Smrg  case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
38667a3b38f7Smrgfi
38677a3b38f7SmrgBIN_SH=xpg4; export BIN_SH # for Tru64
38687a3b38f7SmrgDUALCASE=1; export DUALCASE # for MKS sh
3869ff559fabSmrg
38707a3b38f7Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout
38717a3b38f7Smrg# if CDPATH is set.
38727a3b38f7Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
3873ff559fabSmrg
38747a3b38f7Smrgrelink_command=\"$relink_command\"
3875ff559fabSmrg
38767a3b38f7Smrg# This environment variable determines our operation mode.
38777a3b38f7Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then
38787a3b38f7Smrg  # install mode needs the following variables:
38797a3b38f7Smrg  generated_by_libtool_version='$macro_version'
38807a3b38f7Smrg  notinst_deplibs='$notinst_deplibs'
38817a3b38f7Smrgelse
38827a3b38f7Smrg  # When we are sourced in execute mode, \$file and \$ECHO are already set.
38837a3b38f7Smrg  if test \"\$libtool_execute_magic\" != \"$magic\"; then
388444dda7b2Smrg    file=\"\$0\""
388544dda7b2Smrg
388644dda7b2Smrg    qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"`
388744dda7b2Smrg    $ECHO "\
388844dda7b2Smrg
388944dda7b2Smrg# A function that is used when there is no print builtin or printf.
389044dda7b2Smrgfunc_fallback_echo ()
389144dda7b2Smrg{
389244dda7b2Smrg  eval 'cat <<_LTECHO_EOF
389344dda7b2Smrg\$1
389444dda7b2Smrg_LTECHO_EOF'
389544dda7b2Smrg}
389644dda7b2Smrg    ECHO=\"$qECHO\"
389744dda7b2Smrg  fi
389844dda7b2Smrg
389944dda7b2Smrg# Very basic option parsing. These options are (a) specific to
390044dda7b2Smrg# the libtool wrapper, (b) are identical between the wrapper
390144dda7b2Smrg# /script/ and the wrapper /executable/ which is used only on
390244dda7b2Smrg# windows platforms, and (c) all begin with the string "--lt-"
390344dda7b2Smrg# (application programs are unlikely to have options which match
390444dda7b2Smrg# this pattern).
390544dda7b2Smrg#
390644dda7b2Smrg# There are only two supported options: --lt-debug and
390744dda7b2Smrg# --lt-dump-script. There is, deliberately, no --lt-help.
390844dda7b2Smrg#
390944dda7b2Smrg# The first argument to this parsing function should be the
391044dda7b2Smrg# script's $0 value, followed by "$@".
391144dda7b2Smrglt_option_debug=
391244dda7b2Smrgfunc_parse_lt_options ()
391344dda7b2Smrg{
391444dda7b2Smrg  lt_script_arg0=\$0
391544dda7b2Smrg  shift
391644dda7b2Smrg  for lt_opt
391744dda7b2Smrg  do
391844dda7b2Smrg    case \"\$lt_opt\" in
391944dda7b2Smrg    --lt-debug) lt_option_debug=1 ;;
392044dda7b2Smrg    --lt-dump-script)
392144dda7b2Smrg        lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
392244dda7b2Smrg        test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
392344dda7b2Smrg        lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
392444dda7b2Smrg        cat \"\$lt_dump_D/\$lt_dump_F\"
392544dda7b2Smrg        exit 0
392644dda7b2Smrg      ;;
392744dda7b2Smrg    --lt-*)
392844dda7b2Smrg        \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
392944dda7b2Smrg        exit 1
393044dda7b2Smrg      ;;
393144dda7b2Smrg    esac
393244dda7b2Smrg  done
393344dda7b2Smrg
393444dda7b2Smrg  # Print the debug banner immediately:
393544dda7b2Smrg  if test -n \"\$lt_option_debug\"; then
393644dda7b2Smrg    echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2
393744dda7b2Smrg  fi
393844dda7b2Smrg}
393944dda7b2Smrg
394044dda7b2Smrg# Used when --lt-debug. Prints its arguments to stdout
394144dda7b2Smrg# (redirection is the responsibility of the caller)
394244dda7b2Smrgfunc_lt_dump_args ()
394344dda7b2Smrg{
394444dda7b2Smrg  lt_dump_args_N=1;
394544dda7b2Smrg  for lt_arg
394644dda7b2Smrg  do
394744dda7b2Smrg    \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\"
394844dda7b2Smrg    lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
394944dda7b2Smrg  done
395044dda7b2Smrg}
395144dda7b2Smrg
395244dda7b2Smrg# Core function for launching the target application
395344dda7b2Smrgfunc_exec_program_core ()
395444dda7b2Smrg{
39557a3b38f7Smrg"
395644dda7b2Smrg  case $host in
395744dda7b2Smrg  # Backslashes separate directories on plain windows
395844dda7b2Smrg  *-*-mingw | *-*-os2* | *-cegcc*)
395944dda7b2Smrg    $ECHO "\
396044dda7b2Smrg      if test -n \"\$lt_option_debug\"; then
396144dda7b2Smrg        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2
396244dda7b2Smrg        func_lt_dump_args \${1+\"\$@\"} 1>&2
396344dda7b2Smrg      fi
396444dda7b2Smrg      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
396544dda7b2Smrg"
396644dda7b2Smrg    ;;
396744dda7b2Smrg
396844dda7b2Smrg  *)
396944dda7b2Smrg    $ECHO "\
397044dda7b2Smrg      if test -n \"\$lt_option_debug\"; then
397144dda7b2Smrg        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2
397244dda7b2Smrg        func_lt_dump_args \${1+\"\$@\"} 1>&2
397344dda7b2Smrg      fi
397444dda7b2Smrg      exec \"\$progdir/\$program\" \${1+\"\$@\"}
397544dda7b2Smrg"
397644dda7b2Smrg    ;;
397744dda7b2Smrg  esac
397844dda7b2Smrg  $ECHO "\
397944dda7b2Smrg      \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
398044dda7b2Smrg      exit 1
398144dda7b2Smrg}
398244dda7b2Smrg
398344dda7b2Smrg# A function to encapsulate launching the target application
398444dda7b2Smrg# Strips options in the --lt-* namespace from \$@ and
398544dda7b2Smrg# launches target application with the remaining arguments.
398644dda7b2Smrgfunc_exec_program ()
398744dda7b2Smrg{
3988fc544a13Smrg  case \" \$* \" in
3989fc544a13Smrg  *\\ --lt-*)
3990fc544a13Smrg    for lt_wr_arg
3991fc544a13Smrg    do
3992fc544a13Smrg      case \$lt_wr_arg in
3993fc544a13Smrg      --lt-*) ;;
3994fc544a13Smrg      *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
3995fc544a13Smrg      esac
3996fc544a13Smrg      shift
3997fc544a13Smrg    done ;;
3998fc544a13Smrg  esac
399944dda7b2Smrg  func_exec_program_core \${1+\"\$@\"}
400044dda7b2Smrg}
400144dda7b2Smrg
400244dda7b2Smrg  # Parse options
400344dda7b2Smrg  func_parse_lt_options \"\$0\" \${1+\"\$@\"}
4004ff559fabSmrg
40057a3b38f7Smrg  # Find the directory that this script lives in.
400644dda7b2Smrg  thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
40077a3b38f7Smrg  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
4008ff559fabSmrg
40097a3b38f7Smrg  # Follow symbolic links until we get to the real thisdir.
401044dda7b2Smrg  file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
40117a3b38f7Smrg  while test -n \"\$file\"; do
401244dda7b2Smrg    destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
4013ff559fabSmrg
40147a3b38f7Smrg    # If there was a directory component, then change thisdir.
40157a3b38f7Smrg    if test \"x\$destdir\" != \"x\$file\"; then
40167a3b38f7Smrg      case \"\$destdir\" in
40177a3b38f7Smrg      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
40187a3b38f7Smrg      *) thisdir=\"\$thisdir/\$destdir\" ;;
40197a3b38f7Smrg      esac
40207a3b38f7Smrg    fi
4021ff559fabSmrg
402244dda7b2Smrg    file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
402344dda7b2Smrg    file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
40247a3b38f7Smrg  done
4025ff559fabSmrg
40267a3b38f7Smrg  # Usually 'no', except on cygwin/mingw when embedded into
40277a3b38f7Smrg  # the cwrapper.
402844dda7b2Smrg  WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
40297a3b38f7Smrg  if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
40307a3b38f7Smrg    # special case for '.'
40317a3b38f7Smrg    if test \"\$thisdir\" = \".\"; then
40327a3b38f7Smrg      thisdir=\`pwd\`
40337a3b38f7Smrg    fi
40347a3b38f7Smrg    # remove .libs from thisdir
40357a3b38f7Smrg    case \"\$thisdir\" in
403644dda7b2Smrg    *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
40377a3b38f7Smrg    $objdir )   thisdir=. ;;
40387a3b38f7Smrg    esac
40397a3b38f7Smrg  fi
4040ff559fabSmrg
40417a3b38f7Smrg  # Try to get the absolute directory name.
40427a3b38f7Smrg  absdir=\`cd \"\$thisdir\" && pwd\`
40437a3b38f7Smrg  test -n \"\$absdir\" && thisdir=\"\$absdir\"
40447a3b38f7Smrg"
4045ff559fabSmrg
40467a3b38f7Smrg	if test "$fast_install" = yes; then
40477a3b38f7Smrg	  $ECHO "\
40487a3b38f7Smrg  program=lt-'$outputname'$exeext
40497a3b38f7Smrg  progdir=\"\$thisdir/$objdir\"
4050ff559fabSmrg
40517a3b38f7Smrg  if test ! -f \"\$progdir/\$program\" ||
40527a3b38f7Smrg     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
40537a3b38f7Smrg       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
4054ff559fabSmrg
40557a3b38f7Smrg    file=\"\$\$-\$program\"
4056ff559fabSmrg
40577a3b38f7Smrg    if test ! -d \"\$progdir\"; then
40587a3b38f7Smrg      $MKDIR \"\$progdir\"
40597a3b38f7Smrg    else
40607a3b38f7Smrg      $RM \"\$progdir/\$file\"
40617a3b38f7Smrg    fi"
4062ff559fabSmrg
40637a3b38f7Smrg	  $ECHO "\
4064ff559fabSmrg
40657a3b38f7Smrg    # relink executable if necessary
40667a3b38f7Smrg    if test -n \"\$relink_command\"; then
40677a3b38f7Smrg      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
40687a3b38f7Smrg      else
40697a3b38f7Smrg	$ECHO \"\$relink_command_output\" >&2
40707a3b38f7Smrg	$RM \"\$progdir/\$file\"
40717a3b38f7Smrg	exit 1
40727a3b38f7Smrg      fi
40737a3b38f7Smrg    fi
4074ff559fabSmrg
40757a3b38f7Smrg    $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
40767a3b38f7Smrg    { $RM \"\$progdir/\$program\";
40777a3b38f7Smrg      $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
40787a3b38f7Smrg    $RM \"\$progdir/\$file\"
40797a3b38f7Smrg  fi"
40807a3b38f7Smrg	else
40817a3b38f7Smrg	  $ECHO "\
40827a3b38f7Smrg  program='$outputname'
40837a3b38f7Smrg  progdir=\"\$thisdir/$objdir\"
40847a3b38f7Smrg"
40857a3b38f7Smrg	fi
4086ff559fabSmrg
40877a3b38f7Smrg	$ECHO "\
4088ff559fabSmrg
40897a3b38f7Smrg  if test -f \"\$progdir/\$program\"; then"
4090ff559fabSmrg
4091862f5301Smrg	# fixup the dll searchpath if we need to.
4092862f5301Smrg	#
4093862f5301Smrg	# Fix the DLL searchpath if we need to.  Do this before prepending
4094862f5301Smrg	# to shlibpath, because on Windows, both are PATH and uninstalled
4095862f5301Smrg	# libraries must come first.
4096862f5301Smrg	if test -n "$dllsearchpath"; then
4097862f5301Smrg	  $ECHO "\
4098862f5301Smrg    # Add the dll search path components to the executable PATH
4099862f5301Smrg    PATH=$dllsearchpath:\$PATH
4100862f5301Smrg"
4101862f5301Smrg	fi
4102862f5301Smrg
41037a3b38f7Smrg	# Export our shlibpath_var if we have one.
41047a3b38f7Smrg	if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
41057a3b38f7Smrg	  $ECHO "\
41067a3b38f7Smrg    # Add our own library path to $shlibpath_var
41077a3b38f7Smrg    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
4108ff559fabSmrg
41097a3b38f7Smrg    # Some systems cannot cope with colon-terminated $shlibpath_var
41107a3b38f7Smrg    # The second colon is a workaround for a bug in BeOS R4 sed
411144dda7b2Smrg    $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
4112ff559fabSmrg
41137a3b38f7Smrg    export $shlibpath_var
41147a3b38f7Smrg"
4115ff559fabSmrg	fi
4116ff559fabSmrg
41177a3b38f7Smrg	$ECHO "\
41187a3b38f7Smrg    if test \"\$libtool_execute_magic\" != \"$magic\"; then
41197a3b38f7Smrg      # Run the actual program with our arguments.
412044dda7b2Smrg      func_exec_program \${1+\"\$@\"}
41217a3b38f7Smrg    fi
41227a3b38f7Smrg  else
41237a3b38f7Smrg    # The program doesn't exist.
41247a3b38f7Smrg    \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
41257a3b38f7Smrg    \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
412644dda7b2Smrg    \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
41277a3b38f7Smrg    exit 1
41287a3b38f7Smrg  fi
41297a3b38f7Smrgfi\
41307a3b38f7Smrg"
41317a3b38f7Smrg}
4132ff559fabSmrg
4133ff559fabSmrg
41347a3b38f7Smrg# func_emit_cwrapperexe_src
41357a3b38f7Smrg# emit the source code for a wrapper executable on stdout
41367a3b38f7Smrg# Must ONLY be called from within func_mode_link because
41377a3b38f7Smrg# it depends on a number of variable set therein.
41387a3b38f7Smrgfunc_emit_cwrapperexe_src ()
41397a3b38f7Smrg{
41407a3b38f7Smrg	cat <<EOF
4141ff559fabSmrg
41427a3b38f7Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
41437a3b38f7Smrg   Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
4144ff559fabSmrg
41457a3b38f7Smrg   The $output program cannot be directly executed until all the libtool
41467a3b38f7Smrg   libraries that it depends on are installed.
4147ff559fabSmrg
41487a3b38f7Smrg   This wrapper executable should never be moved out of the build directory.
41497a3b38f7Smrg   If it is, it will not operate correctly.
41507a3b38f7Smrg*/
41517a3b38f7SmrgEOF
41527a3b38f7Smrg	    cat <<"EOF"
415344dda7b2Smrg#ifdef _MSC_VER
415444dda7b2Smrg# define _CRT_SECURE_NO_DEPRECATE 1
415544dda7b2Smrg#endif
41567a3b38f7Smrg#include <stdio.h>
41577a3b38f7Smrg#include <stdlib.h>
41587a3b38f7Smrg#ifdef _MSC_VER
41597a3b38f7Smrg# include <direct.h>
41607a3b38f7Smrg# include <process.h>
41617a3b38f7Smrg# include <io.h>
41627a3b38f7Smrg#else
41637a3b38f7Smrg# include <unistd.h>
41647a3b38f7Smrg# include <stdint.h>
41657a3b38f7Smrg# ifdef __CYGWIN__
41667a3b38f7Smrg#  include <io.h>
41677a3b38f7Smrg# endif
41687a3b38f7Smrg#endif
41697a3b38f7Smrg#include <malloc.h>
41707a3b38f7Smrg#include <stdarg.h>
41717a3b38f7Smrg#include <assert.h>
41727a3b38f7Smrg#include <string.h>
41737a3b38f7Smrg#include <ctype.h>
41747a3b38f7Smrg#include <errno.h>
41757a3b38f7Smrg#include <fcntl.h>
41767a3b38f7Smrg#include <sys/stat.h>
41777a3b38f7Smrg
417844dda7b2Smrg/* declarations of non-ANSI functions */
417944dda7b2Smrg#if defined(__MINGW32__)
418044dda7b2Smrg# ifdef __STRICT_ANSI__
418144dda7b2Smrgint _putenv (const char *);
418244dda7b2Smrg# endif
418344dda7b2Smrg#elif defined(__CYGWIN__)
418444dda7b2Smrg# ifdef __STRICT_ANSI__
418544dda7b2Smrgchar *realpath (const char *, char *);
418644dda7b2Smrgint putenv (char *);
418744dda7b2Smrgint setenv (const char *, const char *, int);
418844dda7b2Smrg# endif
418944dda7b2Smrg/* #elif defined (other platforms) ... */
419044dda7b2Smrg#endif
419144dda7b2Smrg
419244dda7b2Smrg/* portability defines, excluding path handling macros */
419344dda7b2Smrg#if defined(_MSC_VER)
419444dda7b2Smrg# define setmode _setmode
419544dda7b2Smrg# define stat    _stat
419644dda7b2Smrg# define chmod   _chmod
419744dda7b2Smrg# define getcwd  _getcwd
419844dda7b2Smrg# define putenv  _putenv
419944dda7b2Smrg# define S_IXUSR _S_IEXEC
420044dda7b2Smrg# ifndef _INTPTR_T_DEFINED
420144dda7b2Smrg#  define _INTPTR_T_DEFINED
420244dda7b2Smrg#  define intptr_t int
420344dda7b2Smrg# endif
420444dda7b2Smrg#elif defined(__MINGW32__)
420544dda7b2Smrg# define setmode _setmode
420644dda7b2Smrg# define stat    _stat
420744dda7b2Smrg# define chmod   _chmod
420844dda7b2Smrg# define getcwd  _getcwd
420944dda7b2Smrg# define putenv  _putenv
421044dda7b2Smrg#elif defined(__CYGWIN__)
421144dda7b2Smrg# define HAVE_SETENV
421244dda7b2Smrg# define FOPEN_WB "wb"
421344dda7b2Smrg/* #elif defined (other platforms) ... */
421444dda7b2Smrg#endif
421544dda7b2Smrg
42167a3b38f7Smrg#if defined(PATH_MAX)
42177a3b38f7Smrg# define LT_PATHMAX PATH_MAX
42187a3b38f7Smrg#elif defined(MAXPATHLEN)
42197a3b38f7Smrg# define LT_PATHMAX MAXPATHLEN
42207a3b38f7Smrg#else
42217a3b38f7Smrg# define LT_PATHMAX 1024
42227a3b38f7Smrg#endif
42237a3b38f7Smrg
42247a3b38f7Smrg#ifndef S_IXOTH
42257a3b38f7Smrg# define S_IXOTH 0
42267a3b38f7Smrg#endif
42277a3b38f7Smrg#ifndef S_IXGRP
42287a3b38f7Smrg# define S_IXGRP 0
42297a3b38f7Smrg#endif
42307a3b38f7Smrg
423144dda7b2Smrg/* path handling portability macros */
42327a3b38f7Smrg#ifndef DIR_SEPARATOR
42337a3b38f7Smrg# define DIR_SEPARATOR '/'
42347a3b38f7Smrg# define PATH_SEPARATOR ':'
42357a3b38f7Smrg#endif
42367a3b38f7Smrg
42377a3b38f7Smrg#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
42387a3b38f7Smrg  defined (__OS2__)
42397a3b38f7Smrg# define HAVE_DOS_BASED_FILE_SYSTEM
42407a3b38f7Smrg# define FOPEN_WB "wb"
42417a3b38f7Smrg# ifndef DIR_SEPARATOR_2
42427a3b38f7Smrg#  define DIR_SEPARATOR_2 '\\'
42437a3b38f7Smrg# endif
42447a3b38f7Smrg# ifndef PATH_SEPARATOR_2
42457a3b38f7Smrg#  define PATH_SEPARATOR_2 ';'
42467a3b38f7Smrg# endif
42477a3b38f7Smrg#endif
42487a3b38f7Smrg
42497a3b38f7Smrg#ifndef DIR_SEPARATOR_2
42507a3b38f7Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
42517a3b38f7Smrg#else /* DIR_SEPARATOR_2 */
42527a3b38f7Smrg# define IS_DIR_SEPARATOR(ch) \
42537a3b38f7Smrg	(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
42547a3b38f7Smrg#endif /* DIR_SEPARATOR_2 */
42557a3b38f7Smrg
42567a3b38f7Smrg#ifndef PATH_SEPARATOR_2
42577a3b38f7Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
42587a3b38f7Smrg#else /* PATH_SEPARATOR_2 */
42597a3b38f7Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
42607a3b38f7Smrg#endif /* PATH_SEPARATOR_2 */
42617a3b38f7Smrg
42627a3b38f7Smrg#ifndef FOPEN_WB
42637a3b38f7Smrg# define FOPEN_WB "w"
42647a3b38f7Smrg#endif
42657a3b38f7Smrg#ifndef _O_BINARY
42667a3b38f7Smrg# define _O_BINARY 0
42677a3b38f7Smrg#endif
42687a3b38f7Smrg
42697a3b38f7Smrg#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
42707a3b38f7Smrg#define XFREE(stale) do { \
42717a3b38f7Smrg  if (stale) { free ((void *) stale); stale = 0; } \
42727a3b38f7Smrg} while (0)
42737a3b38f7Smrg
427444dda7b2Smrg#if defined(LT_DEBUGWRAPPER)
427544dda7b2Smrgstatic int lt_debug = 1;
42767a3b38f7Smrg#else
427744dda7b2Smrgstatic int lt_debug = 0;
42787a3b38f7Smrg#endif
42797a3b38f7Smrg
428044dda7b2Smrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */
42817a3b38f7Smrg
42827a3b38f7Smrgvoid *xmalloc (size_t num);
42837a3b38f7Smrgchar *xstrdup (const char *string);
42847a3b38f7Smrgconst char *base_name (const char *name);
42857a3b38f7Smrgchar *find_executable (const char *wrapper);
42867a3b38f7Smrgchar *chase_symlinks (const char *pathspec);
42877a3b38f7Smrgint make_executable (const char *path);
42887a3b38f7Smrgint check_executable (const char *path);
42897a3b38f7Smrgchar *strendzap (char *str, const char *pat);
429044dda7b2Smrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...);
429144dda7b2Smrgvoid lt_fatal (const char *file, int line, const char *message, ...);
429244dda7b2Smrgstatic const char *nonnull (const char *s);
429344dda7b2Smrgstatic const char *nonempty (const char *s);
42947a3b38f7Smrgvoid lt_setenv (const char *name, const char *value);
42957a3b38f7Smrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end);
42967a3b38f7Smrgvoid lt_update_exe_path (const char *name, const char *value);
42977a3b38f7Smrgvoid lt_update_lib_path (const char *name, const char *value);
429844dda7b2Smrgchar **prepare_spawn (char **argv);
429944dda7b2Smrgvoid lt_dump_script (FILE *f);
43007a3b38f7SmrgEOF
43017a3b38f7Smrg
43027a3b38f7Smrg	    cat <<EOF
4303862f5301Smrgvolatile const char * MAGIC_EXE = "$magic_exe";
43047a3b38f7Smrgconst char * LIB_PATH_VARNAME = "$shlibpath_var";
43057a3b38f7SmrgEOF
43067a3b38f7Smrg
43077a3b38f7Smrg	    if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
4308862f5301Smrg              func_to_host_path "$temp_rpath"
43097a3b38f7Smrg	      cat <<EOF
4310862f5301Smrgconst char * LIB_PATH_VALUE   = "$func_to_host_path_result";
4311ff559fabSmrgEOF
4312ff559fabSmrg	    else
43137a3b38f7Smrg	      cat <<"EOF"
43147a3b38f7Smrgconst char * LIB_PATH_VALUE   = "";
43157a3b38f7SmrgEOF
4316ff559fabSmrg	    fi
43177a3b38f7Smrg
43187a3b38f7Smrg	    if test -n "$dllsearchpath"; then
4319862f5301Smrg              func_to_host_path "$dllsearchpath:"
43207a3b38f7Smrg	      cat <<EOF
43217a3b38f7Smrgconst char * EXE_PATH_VARNAME = "PATH";
4322862f5301Smrgconst char * EXE_PATH_VALUE   = "$func_to_host_path_result";
43237a3b38f7SmrgEOF
4324ff559fabSmrg	    else
43257a3b38f7Smrg	      cat <<"EOF"
43267a3b38f7Smrgconst char * EXE_PATH_VARNAME = "";
43277a3b38f7Smrgconst char * EXE_PATH_VALUE   = "";
43287a3b38f7SmrgEOF
4329ff559fabSmrg	    fi
43307a3b38f7Smrg
43317a3b38f7Smrg	    if test "$fast_install" = yes; then
43327a3b38f7Smrg	      cat <<EOF
43337a3b38f7Smrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
43347a3b38f7SmrgEOF
4335ff559fabSmrg	    else
43367a3b38f7Smrg	      cat <<EOF
43377a3b38f7Smrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
43387a3b38f7SmrgEOF
4339ff559fabSmrg	    fi
4340ff559fabSmrg
4341ff559fabSmrg
43427a3b38f7Smrg	    cat <<"EOF"
4343ff559fabSmrg
43447a3b38f7Smrg#define LTWRAPPER_OPTION_PREFIX         "--lt-"
4345ff559fabSmrg
43467a3b38f7Smrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
43477a3b38f7Smrgstatic const char *dumpscript_opt       = LTWRAPPER_OPTION_PREFIX "dump-script";
434844dda7b2Smrgstatic const char *debug_opt            = LTWRAPPER_OPTION_PREFIX "debug";
4349ff559fabSmrg
43507a3b38f7Smrgint
43517a3b38f7Smrgmain (int argc, char *argv[])
43527a3b38f7Smrg{
43537a3b38f7Smrg  char **newargz;
43547a3b38f7Smrg  int  newargc;
43557a3b38f7Smrg  char *tmp_pathspec;
43567a3b38f7Smrg  char *actual_cwrapper_path;
43577a3b38f7Smrg  char *actual_cwrapper_name;
43587a3b38f7Smrg  char *target_name;
43597a3b38f7Smrg  char *lt_argv_zero;
43607a3b38f7Smrg  intptr_t rval = 127;
4361ff559fabSmrg
43627a3b38f7Smrg  int i;
4363ff559fabSmrg
43647a3b38f7Smrg  program_name = (char *) xstrdup (base_name (argv[0]));
436544dda7b2Smrg  newargz = XMALLOC (char *, argc + 1);
4366ff559fabSmrg
436744dda7b2Smrg  /* very simple arg parsing; don't want to rely on getopt
436844dda7b2Smrg   * also, copy all non cwrapper options to newargz, except
436944dda7b2Smrg   * argz[0], which is handled differently
437044dda7b2Smrg   */
437144dda7b2Smrg  newargc=0;
43727a3b38f7Smrg  for (i = 1; i < argc; i++)
43737a3b38f7Smrg    {
43747a3b38f7Smrg      if (strcmp (argv[i], dumpscript_opt) == 0)
43757a3b38f7Smrg	{
43767a3b38f7SmrgEOF
43777a3b38f7Smrg	    case "$host" in
43787a3b38f7Smrg	      *mingw* | *cygwin* )
43797a3b38f7Smrg		# make stdout use "unix" line endings
43807a3b38f7Smrg		echo "          setmode(1,_O_BINARY);"
43817a3b38f7Smrg		;;
43827a3b38f7Smrg	      esac
4383ff559fabSmrg
43847a3b38f7Smrg	    cat <<"EOF"
438544dda7b2Smrg	  lt_dump_script (stdout);
43867a3b38f7Smrg	  return 0;
43877a3b38f7Smrg	}
438844dda7b2Smrg      if (strcmp (argv[i], debug_opt) == 0)
438944dda7b2Smrg	{
439044dda7b2Smrg          lt_debug = 1;
439144dda7b2Smrg          continue;
439244dda7b2Smrg	}
439344dda7b2Smrg      if (strcmp (argv[i], ltwrapper_option_prefix) == 0)
439444dda7b2Smrg        {
439544dda7b2Smrg          /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
439644dda7b2Smrg             namespace, but it is not one of the ones we know about and
439744dda7b2Smrg             have already dealt with, above (inluding dump-script), then
439844dda7b2Smrg             report an error. Otherwise, targets might begin to believe
439944dda7b2Smrg             they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
440044dda7b2Smrg             namespace. The first time any user complains about this, we'll
440144dda7b2Smrg             need to make LTWRAPPER_OPTION_PREFIX a configure-time option
440244dda7b2Smrg             or a configure.ac-settable value.
440344dda7b2Smrg           */
440444dda7b2Smrg          lt_fatal (__FILE__, __LINE__,
440544dda7b2Smrg		    "unrecognized %s option: '%s'",
440644dda7b2Smrg                    ltwrapper_option_prefix, argv[i]);
440744dda7b2Smrg        }
440844dda7b2Smrg      /* otherwise ... */
440944dda7b2Smrg      newargz[++newargc] = xstrdup (argv[i]);
44107a3b38f7Smrg    }
441144dda7b2Smrg  newargz[++newargc] = NULL;
441244dda7b2Smrg
441344dda7b2SmrgEOF
441444dda7b2Smrg	    cat <<EOF
441544dda7b2Smrg  /* The GNU banner must be the first non-error debug message */
441644dda7b2Smrg  lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\n");
441744dda7b2SmrgEOF
441844dda7b2Smrg	    cat <<"EOF"
441944dda7b2Smrg  lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
442044dda7b2Smrg  lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name);
4421ff559fabSmrg
44227a3b38f7Smrg  tmp_pathspec = find_executable (argv[0]);
44237a3b38f7Smrg  if (tmp_pathspec == NULL)
442444dda7b2Smrg    lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]);
442544dda7b2Smrg  lt_debugprintf (__FILE__, __LINE__,
442644dda7b2Smrg                  "(main) found exe (before symlink chase) at: %s\n",
442744dda7b2Smrg		  tmp_pathspec);
44287a3b38f7Smrg
44297a3b38f7Smrg  actual_cwrapper_path = chase_symlinks (tmp_pathspec);
443044dda7b2Smrg  lt_debugprintf (__FILE__, __LINE__,
443144dda7b2Smrg                  "(main) found exe (after symlink chase) at: %s\n",
443244dda7b2Smrg		  actual_cwrapper_path);
44337a3b38f7Smrg  XFREE (tmp_pathspec);
44347a3b38f7Smrg
443544dda7b2Smrg  actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));
44367a3b38f7Smrg  strendzap (actual_cwrapper_path, actual_cwrapper_name);
44377a3b38f7Smrg
44387a3b38f7Smrg  /* wrapper name transforms */
44397a3b38f7Smrg  strendzap (actual_cwrapper_name, ".exe");
44407a3b38f7Smrg  tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
44417a3b38f7Smrg  XFREE (actual_cwrapper_name);
44427a3b38f7Smrg  actual_cwrapper_name = tmp_pathspec;
44437a3b38f7Smrg  tmp_pathspec = 0;
44447a3b38f7Smrg
44457a3b38f7Smrg  /* target_name transforms -- use actual target program name; might have lt- prefix */
44467a3b38f7Smrg  target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
44477a3b38f7Smrg  strendzap (target_name, ".exe");
44487a3b38f7Smrg  tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
44497a3b38f7Smrg  XFREE (target_name);
44507a3b38f7Smrg  target_name = tmp_pathspec;
44517a3b38f7Smrg  tmp_pathspec = 0;
44527a3b38f7Smrg
445344dda7b2Smrg  lt_debugprintf (__FILE__, __LINE__,
445444dda7b2Smrg		  "(main) libtool target name: %s\n",
445544dda7b2Smrg		  target_name);
44567a3b38f7SmrgEOF
4457ff559fabSmrg
44587a3b38f7Smrg	    cat <<EOF
44597a3b38f7Smrg  newargz[0] =
44607a3b38f7Smrg    XMALLOC (char, (strlen (actual_cwrapper_path) +
44617a3b38f7Smrg		    strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
44627a3b38f7Smrg  strcpy (newargz[0], actual_cwrapper_path);
44637a3b38f7Smrg  strcat (newargz[0], "$objdir");
44647a3b38f7Smrg  strcat (newargz[0], "/");
44657a3b38f7SmrgEOF
4466ff559fabSmrg
44677a3b38f7Smrg	    cat <<"EOF"
44687a3b38f7Smrg  /* stop here, and copy so we don't have to do this twice */
44697a3b38f7Smrg  tmp_pathspec = xstrdup (newargz[0]);
4470ff559fabSmrg
44717a3b38f7Smrg  /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
44727a3b38f7Smrg  strcat (newargz[0], actual_cwrapper_name);
4473ff559fabSmrg
44747a3b38f7Smrg  /* DO want the lt- prefix here if it exists, so use target_name */
44757a3b38f7Smrg  lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
44767a3b38f7Smrg  XFREE (tmp_pathspec);
44777a3b38f7Smrg  tmp_pathspec = NULL;
44787a3b38f7SmrgEOF
4479ff559fabSmrg
44807a3b38f7Smrg	    case $host_os in
44817a3b38f7Smrg	      mingw*)
44827a3b38f7Smrg	    cat <<"EOF"
44837a3b38f7Smrg  {
44847a3b38f7Smrg    char* p;
44857a3b38f7Smrg    while ((p = strchr (newargz[0], '\\')) != NULL)
44867a3b38f7Smrg      {
44877a3b38f7Smrg	*p = '/';
44887a3b38f7Smrg      }
44897a3b38f7Smrg    while ((p = strchr (lt_argv_zero, '\\')) != NULL)
44907a3b38f7Smrg      {
44917a3b38f7Smrg	*p = '/';
44927a3b38f7Smrg      }
44937a3b38f7Smrg  }
44947a3b38f7SmrgEOF
44957a3b38f7Smrg	    ;;
44967a3b38f7Smrg	    esac
4497ff559fabSmrg
44987a3b38f7Smrg	    cat <<"EOF"
44997a3b38f7Smrg  XFREE (target_name);
45007a3b38f7Smrg  XFREE (actual_cwrapper_path);
45017a3b38f7Smrg  XFREE (actual_cwrapper_name);
4502ff559fabSmrg
45037a3b38f7Smrg  lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
45047a3b38f7Smrg  lt_setenv ("DUALCASE", "1");  /* for MSK sh */
4505862f5301Smrg  /* Update the DLL searchpath.  EXE_PATH_VALUE ($dllsearchpath) must
4506862f5301Smrg     be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath)
4507862f5301Smrg     because on Windows, both *_VARNAMEs are PATH but uninstalled
4508862f5301Smrg     libraries must come first. */
45097a3b38f7Smrg  lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
4510862f5301Smrg  lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
4511ff559fabSmrg
451244dda7b2Smrg  lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",
451344dda7b2Smrg		  nonnull (lt_argv_zero));
45147a3b38f7Smrg  for (i = 0; i < newargc; i++)
45157a3b38f7Smrg    {
451644dda7b2Smrg      lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n",
451744dda7b2Smrg		      i, nonnull (newargz[i]));
45187a3b38f7Smrg    }
4519ff559fabSmrg
45207a3b38f7SmrgEOF
4521ff559fabSmrg
45227a3b38f7Smrg	    case $host_os in
45237a3b38f7Smrg	      mingw*)
45247a3b38f7Smrg		cat <<"EOF"
45257a3b38f7Smrg  /* execv doesn't actually work on mingw as expected on unix */
452644dda7b2Smrg  newargz = prepare_spawn (newargz);
45277a3b38f7Smrg  rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
45287a3b38f7Smrg  if (rval == -1)
45297a3b38f7Smrg    {
45307a3b38f7Smrg      /* failed to start process */
453144dda7b2Smrg      lt_debugprintf (__FILE__, __LINE__,
453244dda7b2Smrg		      "(main) failed to launch target \"%s\": %s\n",
453344dda7b2Smrg		      lt_argv_zero, nonnull (strerror (errno)));
45347a3b38f7Smrg      return 127;
45357a3b38f7Smrg    }
45367a3b38f7Smrg  return rval;
45377a3b38f7SmrgEOF
45387a3b38f7Smrg		;;
45397a3b38f7Smrg	      *)
45407a3b38f7Smrg		cat <<"EOF"
45417a3b38f7Smrg  execv (lt_argv_zero, newargz);
45427a3b38f7Smrg  return rval; /* =127, but avoids unused variable warning */
45437a3b38f7SmrgEOF
45447a3b38f7Smrg		;;
45457a3b38f7Smrg	    esac
4546ff559fabSmrg
45477a3b38f7Smrg	    cat <<"EOF"
45487a3b38f7Smrg}
4549ff559fabSmrg
45507a3b38f7Smrgvoid *
45517a3b38f7Smrgxmalloc (size_t num)
45527a3b38f7Smrg{
45537a3b38f7Smrg  void *p = (void *) malloc (num);
45547a3b38f7Smrg  if (!p)
455544dda7b2Smrg    lt_fatal (__FILE__, __LINE__, "memory exhausted");
4556ff559fabSmrg
45577a3b38f7Smrg  return p;
45587a3b38f7Smrg}
4559ff559fabSmrg
45607a3b38f7Smrgchar *
45617a3b38f7Smrgxstrdup (const char *string)
45627a3b38f7Smrg{
45637a3b38f7Smrg  return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
45647a3b38f7Smrg			  string) : NULL;
45657a3b38f7Smrg}
4566ff559fabSmrg
45677a3b38f7Smrgconst char *
45687a3b38f7Smrgbase_name (const char *name)
45697a3b38f7Smrg{
45707a3b38f7Smrg  const char *base;
4571ff559fabSmrg
45727a3b38f7Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
45737a3b38f7Smrg  /* Skip over the disk name in MSDOS pathnames. */
45747a3b38f7Smrg  if (isalpha ((unsigned char) name[0]) && name[1] == ':')
45757a3b38f7Smrg    name += 2;
45767a3b38f7Smrg#endif
4577ff559fabSmrg
45787a3b38f7Smrg  for (base = name; *name; name++)
45797a3b38f7Smrg    if (IS_DIR_SEPARATOR (*name))
45807a3b38f7Smrg      base = name + 1;
45817a3b38f7Smrg  return base;
45827a3b38f7Smrg}
4583ff559fabSmrg
45847a3b38f7Smrgint
45857a3b38f7Smrgcheck_executable (const char *path)
45867a3b38f7Smrg{
45877a3b38f7Smrg  struct stat st;
4588ff559fabSmrg
458944dda7b2Smrg  lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n",
459044dda7b2Smrg                  nonempty (path));
45917a3b38f7Smrg  if ((!path) || (!*path))
45927a3b38f7Smrg    return 0;
4593ff559fabSmrg
45947a3b38f7Smrg  if ((stat (path, &st) >= 0)
45957a3b38f7Smrg      && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
45967a3b38f7Smrg    return 1;
45977a3b38f7Smrg  else
45987a3b38f7Smrg    return 0;
45997a3b38f7Smrg}
4600ff559fabSmrg
46017a3b38f7Smrgint
46027a3b38f7Smrgmake_executable (const char *path)
46037a3b38f7Smrg{
46047a3b38f7Smrg  int rval = 0;
46057a3b38f7Smrg  struct stat st;
4606ff559fabSmrg
460744dda7b2Smrg  lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n",
460844dda7b2Smrg                  nonempty (path));
46097a3b38f7Smrg  if ((!path) || (!*path))
46107a3b38f7Smrg    return 0;
4611ff559fabSmrg
46127a3b38f7Smrg  if (stat (path, &st) >= 0)
46137a3b38f7Smrg    {
46147a3b38f7Smrg      rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
46157a3b38f7Smrg    }
46167a3b38f7Smrg  return rval;
46177a3b38f7Smrg}
4618ff559fabSmrg
46197a3b38f7Smrg/* Searches for the full path of the wrapper.  Returns
46207a3b38f7Smrg   newly allocated full path name if found, NULL otherwise
46217a3b38f7Smrg   Does not chase symlinks, even on platforms that support them.
46227a3b38f7Smrg*/
46237a3b38f7Smrgchar *
46247a3b38f7Smrgfind_executable (const char *wrapper)
46257a3b38f7Smrg{
46267a3b38f7Smrg  int has_slash = 0;
46277a3b38f7Smrg  const char *p;
46287a3b38f7Smrg  const char *p_next;
46297a3b38f7Smrg  /* static buffer for getcwd */
46307a3b38f7Smrg  char tmp[LT_PATHMAX + 1];
46317a3b38f7Smrg  int tmp_len;
46327a3b38f7Smrg  char *concat_name;
4633ff559fabSmrg
463444dda7b2Smrg  lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
463544dda7b2Smrg                  nonempty (wrapper));
4636ff559fabSmrg
46377a3b38f7Smrg  if ((wrapper == NULL) || (*wrapper == '\0'))
46387a3b38f7Smrg    return NULL;
4639ff559fabSmrg
46407a3b38f7Smrg  /* Absolute path? */
46417a3b38f7Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
46427a3b38f7Smrg  if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
46437a3b38f7Smrg    {
46447a3b38f7Smrg      concat_name = xstrdup (wrapper);
46457a3b38f7Smrg      if (check_executable (concat_name))
46467a3b38f7Smrg	return concat_name;
46477a3b38f7Smrg      XFREE (concat_name);
46487a3b38f7Smrg    }
46497a3b38f7Smrg  else
46507a3b38f7Smrg    {
46517a3b38f7Smrg#endif
46527a3b38f7Smrg      if (IS_DIR_SEPARATOR (wrapper[0]))
46537a3b38f7Smrg	{
46547a3b38f7Smrg	  concat_name = xstrdup (wrapper);
46557a3b38f7Smrg	  if (check_executable (concat_name))
46567a3b38f7Smrg	    return concat_name;
46577a3b38f7Smrg	  XFREE (concat_name);
46587a3b38f7Smrg	}
46597a3b38f7Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
46607a3b38f7Smrg    }
46617a3b38f7Smrg#endif
4662ff559fabSmrg
46637a3b38f7Smrg  for (p = wrapper; *p; p++)
46647a3b38f7Smrg    if (*p == '/')
46657a3b38f7Smrg      {
46667a3b38f7Smrg	has_slash = 1;
46677a3b38f7Smrg	break;
46687a3b38f7Smrg      }
46697a3b38f7Smrg  if (!has_slash)
46707a3b38f7Smrg    {
46717a3b38f7Smrg      /* no slashes; search PATH */
46727a3b38f7Smrg      const char *path = getenv ("PATH");
46737a3b38f7Smrg      if (path != NULL)
46747a3b38f7Smrg	{
46757a3b38f7Smrg	  for (p = path; *p; p = p_next)
46767a3b38f7Smrg	    {
46777a3b38f7Smrg	      const char *q;
46787a3b38f7Smrg	      size_t p_len;
46797a3b38f7Smrg	      for (q = p; *q; q++)
46807a3b38f7Smrg		if (IS_PATH_SEPARATOR (*q))
46817a3b38f7Smrg		  break;
46827a3b38f7Smrg	      p_len = q - p;
46837a3b38f7Smrg	      p_next = (*q == '\0' ? q : q + 1);
46847a3b38f7Smrg	      if (p_len == 0)
46857a3b38f7Smrg		{
46867a3b38f7Smrg		  /* empty path: current directory */
46877a3b38f7Smrg		  if (getcwd (tmp, LT_PATHMAX) == NULL)
468844dda7b2Smrg		    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
468944dda7b2Smrg                              nonnull (strerror (errno)));
46907a3b38f7Smrg		  tmp_len = strlen (tmp);
46917a3b38f7Smrg		  concat_name =
46927a3b38f7Smrg		    XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
46937a3b38f7Smrg		  memcpy (concat_name, tmp, tmp_len);
46947a3b38f7Smrg		  concat_name[tmp_len] = '/';
46957a3b38f7Smrg		  strcpy (concat_name + tmp_len + 1, wrapper);
46967a3b38f7Smrg		}
46977a3b38f7Smrg	      else
46987a3b38f7Smrg		{
46997a3b38f7Smrg		  concat_name =
47007a3b38f7Smrg		    XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
47017a3b38f7Smrg		  memcpy (concat_name, p, p_len);
47027a3b38f7Smrg		  concat_name[p_len] = '/';
47037a3b38f7Smrg		  strcpy (concat_name + p_len + 1, wrapper);
47047a3b38f7Smrg		}
47057a3b38f7Smrg	      if (check_executable (concat_name))
47067a3b38f7Smrg		return concat_name;
47077a3b38f7Smrg	      XFREE (concat_name);
47087a3b38f7Smrg	    }
47097a3b38f7Smrg	}
47107a3b38f7Smrg      /* not found in PATH; assume curdir */
47117a3b38f7Smrg    }
47127a3b38f7Smrg  /* Relative path | not found in path: prepend cwd */
47137a3b38f7Smrg  if (getcwd (tmp, LT_PATHMAX) == NULL)
471444dda7b2Smrg    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
471544dda7b2Smrg              nonnull (strerror (errno)));
47167a3b38f7Smrg  tmp_len = strlen (tmp);
47177a3b38f7Smrg  concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
47187a3b38f7Smrg  memcpy (concat_name, tmp, tmp_len);
47197a3b38f7Smrg  concat_name[tmp_len] = '/';
47207a3b38f7Smrg  strcpy (concat_name + tmp_len + 1, wrapper);
4721ff559fabSmrg
47227a3b38f7Smrg  if (check_executable (concat_name))
47237a3b38f7Smrg    return concat_name;
47247a3b38f7Smrg  XFREE (concat_name);
47257a3b38f7Smrg  return NULL;
47267a3b38f7Smrg}
4727ff559fabSmrg
47287a3b38f7Smrgchar *
47297a3b38f7Smrgchase_symlinks (const char *pathspec)
47307a3b38f7Smrg{
47317a3b38f7Smrg#ifndef S_ISLNK
47327a3b38f7Smrg  return xstrdup (pathspec);
47337a3b38f7Smrg#else
47347a3b38f7Smrg  char buf[LT_PATHMAX];
47357a3b38f7Smrg  struct stat s;
47367a3b38f7Smrg  char *tmp_pathspec = xstrdup (pathspec);
47377a3b38f7Smrg  char *p;
47387a3b38f7Smrg  int has_symlinks = 0;
47397a3b38f7Smrg  while (strlen (tmp_pathspec) && !has_symlinks)
47407a3b38f7Smrg    {
474144dda7b2Smrg      lt_debugprintf (__FILE__, __LINE__,
474244dda7b2Smrg		      "checking path component for symlinks: %s\n",
474344dda7b2Smrg		      tmp_pathspec);
47447a3b38f7Smrg      if (lstat (tmp_pathspec, &s) == 0)
47457a3b38f7Smrg	{
47467a3b38f7Smrg	  if (S_ISLNK (s.st_mode) != 0)
47477a3b38f7Smrg	    {
47487a3b38f7Smrg	      has_symlinks = 1;
47497a3b38f7Smrg	      break;
47507a3b38f7Smrg	    }
4751ff559fabSmrg
47527a3b38f7Smrg	  /* search backwards for last DIR_SEPARATOR */
47537a3b38f7Smrg	  p = tmp_pathspec + strlen (tmp_pathspec) - 1;
47547a3b38f7Smrg	  while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
47557a3b38f7Smrg	    p--;
47567a3b38f7Smrg	  if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
47577a3b38f7Smrg	    {
47587a3b38f7Smrg	      /* no more DIR_SEPARATORS left */
47597a3b38f7Smrg	      break;
47607a3b38f7Smrg	    }
47617a3b38f7Smrg	  *p = '\0';
47627a3b38f7Smrg	}
47637a3b38f7Smrg      else
47647a3b38f7Smrg	{
476544dda7b2Smrg	  lt_fatal (__FILE__, __LINE__,
476644dda7b2Smrg		    "error accessing file \"%s\": %s",
476744dda7b2Smrg		    tmp_pathspec, nonnull (strerror (errno)));
47687a3b38f7Smrg	}
47697a3b38f7Smrg    }
47707a3b38f7Smrg  XFREE (tmp_pathspec);
4771ff559fabSmrg
47727a3b38f7Smrg  if (!has_symlinks)
47737a3b38f7Smrg    {
47747a3b38f7Smrg      return xstrdup (pathspec);
47757a3b38f7Smrg    }
4776ff559fabSmrg
47777a3b38f7Smrg  tmp_pathspec = realpath (pathspec, buf);
47787a3b38f7Smrg  if (tmp_pathspec == 0)
47797a3b38f7Smrg    {
478044dda7b2Smrg      lt_fatal (__FILE__, __LINE__,
478144dda7b2Smrg		"could not follow symlinks for %s", pathspec);
47827a3b38f7Smrg    }
47837a3b38f7Smrg  return xstrdup (tmp_pathspec);
47847a3b38f7Smrg#endif
47857a3b38f7Smrg}
4786ff559fabSmrg
47877a3b38f7Smrgchar *
47887a3b38f7Smrgstrendzap (char *str, const char *pat)
47897a3b38f7Smrg{
47907a3b38f7Smrg  size_t len, patlen;
4791ff559fabSmrg
47927a3b38f7Smrg  assert (str != NULL);
47937a3b38f7Smrg  assert (pat != NULL);
4794ff559fabSmrg
47957a3b38f7Smrg  len = strlen (str);
47967a3b38f7Smrg  patlen = strlen (pat);
4797ff559fabSmrg
47987a3b38f7Smrg  if (patlen <= len)
47997a3b38f7Smrg    {
48007a3b38f7Smrg      str += len - patlen;
48017a3b38f7Smrg      if (strcmp (str, pat) == 0)
48027a3b38f7Smrg	*str = '\0';
48037a3b38f7Smrg    }
48047a3b38f7Smrg  return str;
48057a3b38f7Smrg}
4806ff559fabSmrg
480744dda7b2Smrgvoid
480844dda7b2Smrglt_debugprintf (const char *file, int line, const char *fmt, ...)
480944dda7b2Smrg{
481044dda7b2Smrg  va_list args;
481144dda7b2Smrg  if (lt_debug)
481244dda7b2Smrg    {
481344dda7b2Smrg      (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line);
481444dda7b2Smrg      va_start (args, fmt);
481544dda7b2Smrg      (void) vfprintf (stderr, fmt, args);
481644dda7b2Smrg      va_end (args);
481744dda7b2Smrg    }
481844dda7b2Smrg}
481944dda7b2Smrg
48207a3b38f7Smrgstatic void
482144dda7b2Smrglt_error_core (int exit_status, const char *file,
482244dda7b2Smrg	       int line, const char *mode,
48237a3b38f7Smrg	       const char *message, va_list ap)
48247a3b38f7Smrg{
482544dda7b2Smrg  fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode);
48267a3b38f7Smrg  vfprintf (stderr, message, ap);
48277a3b38f7Smrg  fprintf (stderr, ".\n");
4828ff559fabSmrg
48297a3b38f7Smrg  if (exit_status >= 0)
48307a3b38f7Smrg    exit (exit_status);
48317a3b38f7Smrg}
4832ff559fabSmrg
48337a3b38f7Smrgvoid
483444dda7b2Smrglt_fatal (const char *file, int line, const char *message, ...)
48357a3b38f7Smrg{
48367a3b38f7Smrg  va_list ap;
48377a3b38f7Smrg  va_start (ap, message);
483844dda7b2Smrg  lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap);
48397a3b38f7Smrg  va_end (ap);
48407a3b38f7Smrg}
4841ff559fabSmrg
484244dda7b2Smrgstatic const char *
484344dda7b2Smrgnonnull (const char *s)
484444dda7b2Smrg{
484544dda7b2Smrg  return s ? s : "(null)";
484644dda7b2Smrg}
484744dda7b2Smrg
484844dda7b2Smrgstatic const char *
484944dda7b2Smrgnonempty (const char *s)
485044dda7b2Smrg{
485144dda7b2Smrg  return (s && !*s) ? "(empty)" : nonnull (s);
485244dda7b2Smrg}
485344dda7b2Smrg
48547a3b38f7Smrgvoid
48557a3b38f7Smrglt_setenv (const char *name, const char *value)
48567a3b38f7Smrg{
485744dda7b2Smrg  lt_debugprintf (__FILE__, __LINE__,
485844dda7b2Smrg		  "(lt_setenv) setting '%s' to '%s'\n",
485944dda7b2Smrg                  nonnull (name), nonnull (value));
48607a3b38f7Smrg  {
48617a3b38f7Smrg#ifdef HAVE_SETENV
48627a3b38f7Smrg    /* always make a copy, for consistency with !HAVE_SETENV */
48637a3b38f7Smrg    char *str = xstrdup (value);
48647a3b38f7Smrg    setenv (name, str, 1);
48657a3b38f7Smrg#else
48667a3b38f7Smrg    int len = strlen (name) + 1 + strlen (value) + 1;
48677a3b38f7Smrg    char *str = XMALLOC (char, len);
48687a3b38f7Smrg    sprintf (str, "%s=%s", name, value);
48697a3b38f7Smrg    if (putenv (str) != EXIT_SUCCESS)
48707a3b38f7Smrg      {
48717a3b38f7Smrg        XFREE (str);
48727a3b38f7Smrg      }
48737a3b38f7Smrg#endif
48747a3b38f7Smrg  }
48757a3b38f7Smrg}
4876ff559fabSmrg
48777a3b38f7Smrgchar *
48787a3b38f7Smrglt_extend_str (const char *orig_value, const char *add, int to_end)
48797a3b38f7Smrg{
48807a3b38f7Smrg  char *new_value;
48817a3b38f7Smrg  if (orig_value && *orig_value)
48827a3b38f7Smrg    {
48837a3b38f7Smrg      int orig_value_len = strlen (orig_value);
48847a3b38f7Smrg      int add_len = strlen (add);
48857a3b38f7Smrg      new_value = XMALLOC (char, add_len + orig_value_len + 1);
48867a3b38f7Smrg      if (to_end)
48877a3b38f7Smrg        {
48887a3b38f7Smrg          strcpy (new_value, orig_value);
48897a3b38f7Smrg          strcpy (new_value + orig_value_len, add);
48907a3b38f7Smrg        }
48917a3b38f7Smrg      else
48927a3b38f7Smrg        {
48937a3b38f7Smrg          strcpy (new_value, add);
48947a3b38f7Smrg          strcpy (new_value + add_len, orig_value);
48957a3b38f7Smrg        }
48967a3b38f7Smrg    }
48977a3b38f7Smrg  else
48987a3b38f7Smrg    {
48997a3b38f7Smrg      new_value = xstrdup (add);
49007a3b38f7Smrg    }
49017a3b38f7Smrg  return new_value;
49027a3b38f7Smrg}
4903ff559fabSmrg
49047a3b38f7Smrgvoid
49057a3b38f7Smrglt_update_exe_path (const char *name, const char *value)
49067a3b38f7Smrg{
490744dda7b2Smrg  lt_debugprintf (__FILE__, __LINE__,
490844dda7b2Smrg		  "(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
490944dda7b2Smrg                  nonnull (name), nonnull (value));
4910ff559fabSmrg
49117a3b38f7Smrg  if (name && *name && value && *value)
49127a3b38f7Smrg    {
49137a3b38f7Smrg      char *new_value = lt_extend_str (getenv (name), value, 0);
49147a3b38f7Smrg      /* some systems can't cope with a ':'-terminated path #' */
49157a3b38f7Smrg      int len = strlen (new_value);
49167a3b38f7Smrg      while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
49177a3b38f7Smrg        {
49187a3b38f7Smrg          new_value[len-1] = '\0';
49197a3b38f7Smrg        }
49207a3b38f7Smrg      lt_setenv (name, new_value);
49217a3b38f7Smrg      XFREE (new_value);
49227a3b38f7Smrg    }
49237a3b38f7Smrg}
4924ff559fabSmrg
49257a3b38f7Smrgvoid
49267a3b38f7Smrglt_update_lib_path (const char *name, const char *value)
49277a3b38f7Smrg{
492844dda7b2Smrg  lt_debugprintf (__FILE__, __LINE__,
492944dda7b2Smrg		  "(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
493044dda7b2Smrg                  nonnull (name), nonnull (value));
4931ff559fabSmrg
49327a3b38f7Smrg  if (name && *name && value && *value)
49337a3b38f7Smrg    {
49347a3b38f7Smrg      char *new_value = lt_extend_str (getenv (name), value, 0);
49357a3b38f7Smrg      lt_setenv (name, new_value);
49367a3b38f7Smrg      XFREE (new_value);
49377a3b38f7Smrg    }
49387a3b38f7Smrg}
4939ff559fabSmrg
494044dda7b2SmrgEOF
494144dda7b2Smrg	    case $host_os in
494244dda7b2Smrg	      mingw*)
494344dda7b2Smrg		cat <<"EOF"
494444dda7b2Smrg
494544dda7b2Smrg/* Prepares an argument vector before calling spawn().
494644dda7b2Smrg   Note that spawn() does not by itself call the command interpreter
494744dda7b2Smrg     (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
494844dda7b2Smrg      ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
494944dda7b2Smrg         GetVersionEx(&v);
495044dda7b2Smrg         v.dwPlatformId == VER_PLATFORM_WIN32_NT;
495144dda7b2Smrg      }) ? "cmd.exe" : "command.com").
495244dda7b2Smrg   Instead it simply concatenates the arguments, separated by ' ', and calls
495344dda7b2Smrg   CreateProcess().  We must quote the arguments since Win32 CreateProcess()
495444dda7b2Smrg   interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
495544dda7b2Smrg   special way:
495644dda7b2Smrg   - Space and tab are interpreted as delimiters. They are not treated as
495744dda7b2Smrg     delimiters if they are surrounded by double quotes: "...".
495844dda7b2Smrg   - Unescaped double quotes are removed from the input. Their only effect is
495944dda7b2Smrg     that within double quotes, space and tab are treated like normal
496044dda7b2Smrg     characters.
496144dda7b2Smrg   - Backslashes not followed by double quotes are not special.
496244dda7b2Smrg   - But 2*n+1 backslashes followed by a double quote become
496344dda7b2Smrg     n backslashes followed by a double quote (n >= 0):
496444dda7b2Smrg       \" -> "
496544dda7b2Smrg       \\\" -> \"
496644dda7b2Smrg       \\\\\" -> \\"
496744dda7b2Smrg */
496844dda7b2Smrg#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"
496944dda7b2Smrg#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"
497044dda7b2Smrgchar **
497144dda7b2Smrgprepare_spawn (char **argv)
497244dda7b2Smrg{
497344dda7b2Smrg  size_t argc;
497444dda7b2Smrg  char **new_argv;
497544dda7b2Smrg  size_t i;
497644dda7b2Smrg
497744dda7b2Smrg  /* Count number of arguments.  */
497844dda7b2Smrg  for (argc = 0; argv[argc] != NULL; argc++)
497944dda7b2Smrg    ;
498044dda7b2Smrg
498144dda7b2Smrg  /* Allocate new argument vector.  */
498244dda7b2Smrg  new_argv = XMALLOC (char *, argc + 1);
498344dda7b2Smrg
498444dda7b2Smrg  /* Put quoted arguments into the new argument vector.  */
498544dda7b2Smrg  for (i = 0; i < argc; i++)
498644dda7b2Smrg    {
498744dda7b2Smrg      const char *string = argv[i];
498844dda7b2Smrg
498944dda7b2Smrg      if (string[0] == '\0')
499044dda7b2Smrg	new_argv[i] = xstrdup ("\"\"");
499144dda7b2Smrg      else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
499244dda7b2Smrg	{
499344dda7b2Smrg	  int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
499444dda7b2Smrg	  size_t length;
499544dda7b2Smrg	  unsigned int backslashes;
499644dda7b2Smrg	  const char *s;
499744dda7b2Smrg	  char *quoted_string;
499844dda7b2Smrg	  char *p;
499944dda7b2Smrg
500044dda7b2Smrg	  length = 0;
500144dda7b2Smrg	  backslashes = 0;
500244dda7b2Smrg	  if (quote_around)
500344dda7b2Smrg	    length++;
500444dda7b2Smrg	  for (s = string; *s != '\0'; s++)
500544dda7b2Smrg	    {
500644dda7b2Smrg	      char c = *s;
500744dda7b2Smrg	      if (c == '"')
500844dda7b2Smrg		length += backslashes + 1;
500944dda7b2Smrg	      length++;
501044dda7b2Smrg	      if (c == '\\')
501144dda7b2Smrg		backslashes++;
501244dda7b2Smrg	      else
501344dda7b2Smrg		backslashes = 0;
501444dda7b2Smrg	    }
501544dda7b2Smrg	  if (quote_around)
501644dda7b2Smrg	    length += backslashes + 1;
501744dda7b2Smrg
501844dda7b2Smrg	  quoted_string = XMALLOC (char, length + 1);
501944dda7b2Smrg
502044dda7b2Smrg	  p = quoted_string;
502144dda7b2Smrg	  backslashes = 0;
502244dda7b2Smrg	  if (quote_around)
502344dda7b2Smrg	    *p++ = '"';
502444dda7b2Smrg	  for (s = string; *s != '\0'; s++)
502544dda7b2Smrg	    {
502644dda7b2Smrg	      char c = *s;
502744dda7b2Smrg	      if (c == '"')
502844dda7b2Smrg		{
502944dda7b2Smrg		  unsigned int j;
503044dda7b2Smrg		  for (j = backslashes + 1; j > 0; j--)
503144dda7b2Smrg		    *p++ = '\\';
503244dda7b2Smrg		}
503344dda7b2Smrg	      *p++ = c;
503444dda7b2Smrg	      if (c == '\\')
503544dda7b2Smrg		backslashes++;
503644dda7b2Smrg	      else
503744dda7b2Smrg		backslashes = 0;
503844dda7b2Smrg	    }
503944dda7b2Smrg	  if (quote_around)
504044dda7b2Smrg	    {
504144dda7b2Smrg	      unsigned int j;
504244dda7b2Smrg	      for (j = backslashes; j > 0; j--)
504344dda7b2Smrg		*p++ = '\\';
504444dda7b2Smrg	      *p++ = '"';
504544dda7b2Smrg	    }
504644dda7b2Smrg	  *p = '\0';
504744dda7b2Smrg
504844dda7b2Smrg	  new_argv[i] = quoted_string;
504944dda7b2Smrg	}
505044dda7b2Smrg      else
505144dda7b2Smrg	new_argv[i] = (char *) string;
505244dda7b2Smrg    }
505344dda7b2Smrg  new_argv[argc] = NULL;
505444dda7b2Smrg
505544dda7b2Smrg  return new_argv;
505644dda7b2Smrg}
505744dda7b2SmrgEOF
505844dda7b2Smrg		;;
505944dda7b2Smrg	    esac
506044dda7b2Smrg
506144dda7b2Smrg            cat <<"EOF"
506244dda7b2Smrgvoid lt_dump_script (FILE* f)
506344dda7b2Smrg{
506444dda7b2SmrgEOF
506544dda7b2Smrg	    func_emit_wrapper yes |
5066fc544a13Smrg	      $SED -n -e '
5067fc544a13Smrgs/^\(.\{79\}\)\(..*\)/\1\
5068fc544a13Smrg\2/
5069fc544a13Smrgh
5070fc544a13Smrgs/\([\\"]\)/\\\1/g
5071fc544a13Smrgs/$/\\n/
5072fc544a13Smrgs/\([^\n]*\).*/  fputs ("\1", f);/p
5073fc544a13Smrgg
5074fc544a13SmrgD'
507544dda7b2Smrg            cat <<"EOF"
507644dda7b2Smrg}
50777a3b38f7SmrgEOF
50787a3b38f7Smrg}
50797a3b38f7Smrg# end: func_emit_cwrapperexe_src
5080ff559fabSmrg
508144dda7b2Smrg# func_win32_import_lib_p ARG
508244dda7b2Smrg# True if ARG is an import lib, as indicated by $file_magic_cmd
508344dda7b2Smrgfunc_win32_import_lib_p ()
508444dda7b2Smrg{
508544dda7b2Smrg    $opt_debug
508644dda7b2Smrg    case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
508744dda7b2Smrg    *import*) : ;;
508844dda7b2Smrg    *) false ;;
508944dda7b2Smrg    esac
509044dda7b2Smrg}
509144dda7b2Smrg
50927a3b38f7Smrg# func_mode_link arg...
50937a3b38f7Smrgfunc_mode_link ()
50947a3b38f7Smrg{
50957a3b38f7Smrg    $opt_debug
50967a3b38f7Smrg    case $host in
50977a3b38f7Smrg    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
50987a3b38f7Smrg      # It is impossible to link a dll without this setting, and
50997a3b38f7Smrg      # we shouldn't force the makefile maintainer to figure out
51007a3b38f7Smrg      # which system we are compiling for in order to pass an extra
51017a3b38f7Smrg      # flag for every libtool invocation.
51027a3b38f7Smrg      # allow_undefined=no
5103ff559fabSmrg
51047a3b38f7Smrg      # FIXME: Unfortunately, there are problems with the above when trying
51057a3b38f7Smrg      # to make a dll which has undefined symbols, in which case not
51067a3b38f7Smrg      # even a static library is built.  For now, we need to specify
51077a3b38f7Smrg      # -no-undefined on the libtool link line when we can be certain
51087a3b38f7Smrg      # that all symbols are satisfied, otherwise we get a static library.
51097a3b38f7Smrg      allow_undefined=yes
51107a3b38f7Smrg      ;;
51117a3b38f7Smrg    *)
51127a3b38f7Smrg      allow_undefined=yes
51137a3b38f7Smrg      ;;
51147a3b38f7Smrg    esac
51157a3b38f7Smrg    libtool_args=$nonopt
51167a3b38f7Smrg    base_compile="$nonopt $@"
51177a3b38f7Smrg    compile_command=$nonopt
51187a3b38f7Smrg    finalize_command=$nonopt
5119ff559fabSmrg
51207a3b38f7Smrg    compile_rpath=
51217a3b38f7Smrg    finalize_rpath=
51227a3b38f7Smrg    compile_shlibpath=
51237a3b38f7Smrg    finalize_shlibpath=
51247a3b38f7Smrg    convenience=
51257a3b38f7Smrg    old_convenience=
51267a3b38f7Smrg    deplibs=
51277a3b38f7Smrg    old_deplibs=
51287a3b38f7Smrg    compiler_flags=
51297a3b38f7Smrg    linker_flags=
51307a3b38f7Smrg    dllsearchpath=
51317a3b38f7Smrg    lib_search_path=`pwd`
51327a3b38f7Smrg    inst_prefix_dir=
51337a3b38f7Smrg    new_inherited_linker_flags=
5134ff559fabSmrg
51357a3b38f7Smrg    avoid_version=no
513644dda7b2Smrg    bindir=
51377a3b38f7Smrg    dlfiles=
51387a3b38f7Smrg    dlprefiles=
51397a3b38f7Smrg    dlself=no
51407a3b38f7Smrg    export_dynamic=no
51417a3b38f7Smrg    export_symbols=
51427a3b38f7Smrg    export_symbols_regex=
51437a3b38f7Smrg    generated=
51447a3b38f7Smrg    libobjs=
51457a3b38f7Smrg    ltlibs=
51467a3b38f7Smrg    module=no
51477a3b38f7Smrg    no_install=no
51487a3b38f7Smrg    objs=
51497a3b38f7Smrg    non_pic_objects=
51507a3b38f7Smrg    precious_files_regex=
51517a3b38f7Smrg    prefer_static_libs=no
51527a3b38f7Smrg    preload=no
51537a3b38f7Smrg    prev=
51547a3b38f7Smrg    prevarg=
51557a3b38f7Smrg    release=
51567a3b38f7Smrg    rpath=
51577a3b38f7Smrg    xrpath=
51587a3b38f7Smrg    perm_rpath=
51597a3b38f7Smrg    temp_rpath=
51607a3b38f7Smrg    thread_safe=no
51617a3b38f7Smrg    vinfo=
51627a3b38f7Smrg    vinfo_number=no
51637a3b38f7Smrg    weak_libs=
51647a3b38f7Smrg    single_module="${wl}-single_module"
51657a3b38f7Smrg    func_infer_tag $base_compile
5166ff559fabSmrg
51677a3b38f7Smrg    # We need to know -static, to get the right output filenames.
51687a3b38f7Smrg    for arg
51697a3b38f7Smrg    do
51707a3b38f7Smrg      case $arg in
51717a3b38f7Smrg      -shared)
51727a3b38f7Smrg	test "$build_libtool_libs" != yes && \
51737a3b38f7Smrg	  func_fatal_configuration "can not build a shared library"
51747a3b38f7Smrg	build_old_libs=no
51757a3b38f7Smrg	break
51767a3b38f7Smrg	;;
51777a3b38f7Smrg      -all-static | -static | -static-libtool-libs)
51787a3b38f7Smrg	case $arg in
51797a3b38f7Smrg	-all-static)
51807a3b38f7Smrg	  if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
51817a3b38f7Smrg	    func_warning "complete static linking is impossible in this configuration"
5182ff559fabSmrg	  fi
51837a3b38f7Smrg	  if test -n "$link_static_flag"; then
51847a3b38f7Smrg	    dlopen_self=$dlopen_self_static
5185ff559fabSmrg	  fi
51867a3b38f7Smrg	  prefer_static_libs=yes
5187ff559fabSmrg	  ;;
51887a3b38f7Smrg	-static)
51897a3b38f7Smrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
51907a3b38f7Smrg	    dlopen_self=$dlopen_self_static
51917a3b38f7Smrg	  fi
51927a3b38f7Smrg	  prefer_static_libs=built
51937a3b38f7Smrg	  ;;
51947a3b38f7Smrg	-static-libtool-libs)
51957a3b38f7Smrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
51967a3b38f7Smrg	    dlopen_self=$dlopen_self_static
51977a3b38f7Smrg	  fi
51987a3b38f7Smrg	  prefer_static_libs=yes
5199ff559fabSmrg	  ;;
5200ff559fabSmrg	esac
52017a3b38f7Smrg	build_libtool_libs=no
52027a3b38f7Smrg	build_old_libs=yes
52037a3b38f7Smrg	break
52047a3b38f7Smrg	;;
52057a3b38f7Smrg      esac
52067a3b38f7Smrg    done
5207ff559fabSmrg
52087a3b38f7Smrg    # See if our shared archives depend on static archives.
52097a3b38f7Smrg    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
5210ff559fabSmrg
52117a3b38f7Smrg    # Go through the arguments, transforming them on the way.
52127a3b38f7Smrg    while test "$#" -gt 0; do
52137a3b38f7Smrg      arg="$1"
52147a3b38f7Smrg      shift
52157a3b38f7Smrg      func_quote_for_eval "$arg"
52167a3b38f7Smrg      qarg=$func_quote_for_eval_unquoted_result
52177a3b38f7Smrg      func_append libtool_args " $func_quote_for_eval_result"
5218ff559fabSmrg
52197a3b38f7Smrg      # If the previous option needs an argument, assign it.
52207a3b38f7Smrg      if test -n "$prev"; then
52217a3b38f7Smrg	case $prev in
52227a3b38f7Smrg	output)
52237a3b38f7Smrg	  func_append compile_command " @OUTPUT@"
52247a3b38f7Smrg	  func_append finalize_command " @OUTPUT@"
52257a3b38f7Smrg	  ;;
52267a3b38f7Smrg	esac
5227ff559fabSmrg
52287a3b38f7Smrg	case $prev in
522944dda7b2Smrg	bindir)
523044dda7b2Smrg	  bindir="$arg"
523144dda7b2Smrg	  prev=
523244dda7b2Smrg	  continue
523344dda7b2Smrg	  ;;
52347a3b38f7Smrg	dlfiles|dlprefiles)
52357a3b38f7Smrg	  if test "$preload" = no; then
52367a3b38f7Smrg	    # Add the symbol object into the linking commands.
52377a3b38f7Smrg	    func_append compile_command " @SYMFILE@"
52387a3b38f7Smrg	    func_append finalize_command " @SYMFILE@"
52397a3b38f7Smrg	    preload=yes
52407a3b38f7Smrg	  fi
52417a3b38f7Smrg	  case $arg in
52427a3b38f7Smrg	  *.la | *.lo) ;;  # We handle these cases below.
52437a3b38f7Smrg	  force)
52447a3b38f7Smrg	    if test "$dlself" = no; then
52457a3b38f7Smrg	      dlself=needless
52467a3b38f7Smrg	      export_dynamic=yes
52477a3b38f7Smrg	    fi
52487a3b38f7Smrg	    prev=
52497a3b38f7Smrg	    continue
52507a3b38f7Smrg	    ;;
52517a3b38f7Smrg	  self)
52527a3b38f7Smrg	    if test "$prev" = dlprefiles; then
52537a3b38f7Smrg	      dlself=yes
52547a3b38f7Smrg	    elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
52557a3b38f7Smrg	      dlself=yes
52567a3b38f7Smrg	    else
52577a3b38f7Smrg	      dlself=needless
52587a3b38f7Smrg	      export_dynamic=yes
52597a3b38f7Smrg	    fi
52607a3b38f7Smrg	    prev=
52617a3b38f7Smrg	    continue
5262ff559fabSmrg	    ;;
5263ff559fabSmrg	  *)
52647a3b38f7Smrg	    if test "$prev" = dlfiles; then
5265862f5301Smrg	      func_append dlfiles " $arg"
52667a3b38f7Smrg	    else
5267862f5301Smrg	      func_append dlprefiles " $arg"
52687a3b38f7Smrg	    fi
52697a3b38f7Smrg	    prev=
52707a3b38f7Smrg	    continue
5271ff559fabSmrg	    ;;
5272ff559fabSmrg	  esac
52737a3b38f7Smrg	  ;;
52747a3b38f7Smrg	expsyms)
52757a3b38f7Smrg	  export_symbols="$arg"
52767a3b38f7Smrg	  test -f "$arg" \
52777a3b38f7Smrg	    || func_fatal_error "symbol file \`$arg' does not exist"
52787a3b38f7Smrg	  prev=
52797a3b38f7Smrg	  continue
52807a3b38f7Smrg	  ;;
52817a3b38f7Smrg	expsyms_regex)
52827a3b38f7Smrg	  export_symbols_regex="$arg"
52837a3b38f7Smrg	  prev=
52847a3b38f7Smrg	  continue
52857a3b38f7Smrg	  ;;
52867a3b38f7Smrg	framework)
52877a3b38f7Smrg	  case $host in
52887a3b38f7Smrg	    *-*-darwin*)
52897a3b38f7Smrg	      case "$deplibs " in
52907a3b38f7Smrg		*" $qarg.ltframework "*) ;;
5291862f5301Smrg		*) func_append deplibs " $qarg.ltframework" # this is fixed later
52927a3b38f7Smrg		   ;;
52937a3b38f7Smrg	      esac
52947a3b38f7Smrg	      ;;
52957a3b38f7Smrg	  esac
52967a3b38f7Smrg	  prev=
52977a3b38f7Smrg	  continue
52987a3b38f7Smrg	  ;;
52997a3b38f7Smrg	inst_prefix)
53007a3b38f7Smrg	  inst_prefix_dir="$arg"
53017a3b38f7Smrg	  prev=
53027a3b38f7Smrg	  continue
53037a3b38f7Smrg	  ;;
53047a3b38f7Smrg	objectlist)
53057a3b38f7Smrg	  if test -f "$arg"; then
53067a3b38f7Smrg	    save_arg=$arg
53077a3b38f7Smrg	    moreargs=
53087a3b38f7Smrg	    for fil in `cat "$save_arg"`
53097a3b38f7Smrg	    do
5310862f5301Smrg#	      func_append moreargs " $fil"
53117a3b38f7Smrg	      arg=$fil
53127a3b38f7Smrg	      # A libtool-controlled object.
5313ff559fabSmrg
53147a3b38f7Smrg	      # Check to see that this really is a libtool object.
53157a3b38f7Smrg	      if func_lalib_unsafe_p "$arg"; then
53167a3b38f7Smrg		pic_object=
53177a3b38f7Smrg		non_pic_object=
5318ff559fabSmrg
53197a3b38f7Smrg		# Read the .lo file
53207a3b38f7Smrg		func_source "$arg"
5321ff559fabSmrg
53227a3b38f7Smrg		if test -z "$pic_object" ||
53237a3b38f7Smrg		   test -z "$non_pic_object" ||
53247a3b38f7Smrg		   test "$pic_object" = none &&
53257a3b38f7Smrg		   test "$non_pic_object" = none; then
53267a3b38f7Smrg		  func_fatal_error "cannot find name of object for \`$arg'"
53277a3b38f7Smrg		fi
5328ff559fabSmrg
53297a3b38f7Smrg		# Extract subdirectory from the argument.
53307a3b38f7Smrg		func_dirname "$arg" "/" ""
53317a3b38f7Smrg		xdir="$func_dirname_result"
5332ff559fabSmrg
53337a3b38f7Smrg		if test "$pic_object" != none; then
53347a3b38f7Smrg		  # Prepend the subdirectory the object is found in.
53357a3b38f7Smrg		  pic_object="$xdir$pic_object"
5336ff559fabSmrg
53377a3b38f7Smrg		  if test "$prev" = dlfiles; then
53387a3b38f7Smrg		    if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
5339862f5301Smrg		      func_append dlfiles " $pic_object"
53407a3b38f7Smrg		      prev=
53417a3b38f7Smrg		      continue
53427a3b38f7Smrg		    else
53437a3b38f7Smrg		      # If libtool objects are unsupported, then we need to preload.
53447a3b38f7Smrg		      prev=dlprefiles
53457a3b38f7Smrg		    fi
53467a3b38f7Smrg		  fi
5347ff559fabSmrg
53487a3b38f7Smrg		  # CHECK ME:  I think I busted this.  -Ossama
53497a3b38f7Smrg		  if test "$prev" = dlprefiles; then
53507a3b38f7Smrg		    # Preload the old-style object.
5351862f5301Smrg		    func_append dlprefiles " $pic_object"
53527a3b38f7Smrg		    prev=
53537a3b38f7Smrg		  fi
5354ff559fabSmrg
53557a3b38f7Smrg		  # A PIC object.
53567a3b38f7Smrg		  func_append libobjs " $pic_object"
53577a3b38f7Smrg		  arg="$pic_object"
53587a3b38f7Smrg		fi
5359ff559fabSmrg
53607a3b38f7Smrg		# Non-PIC object.
53617a3b38f7Smrg		if test "$non_pic_object" != none; then
53627a3b38f7Smrg		  # Prepend the subdirectory the object is found in.
53637a3b38f7Smrg		  non_pic_object="$xdir$non_pic_object"
5364ff559fabSmrg
53657a3b38f7Smrg		  # A standard non-PIC object
53667a3b38f7Smrg		  func_append non_pic_objects " $non_pic_object"
53677a3b38f7Smrg		  if test -z "$pic_object" || test "$pic_object" = none ; then
53687a3b38f7Smrg		    arg="$non_pic_object"
53697a3b38f7Smrg		  fi
53707a3b38f7Smrg		else
53717a3b38f7Smrg		  # If the PIC object exists, use it instead.
53727a3b38f7Smrg		  # $xdir was prepended to $pic_object above.
53737a3b38f7Smrg		  non_pic_object="$pic_object"
53747a3b38f7Smrg		  func_append non_pic_objects " $non_pic_object"
53757a3b38f7Smrg		fi
53767a3b38f7Smrg	      else
53777a3b38f7Smrg		# Only an error if not doing a dry-run.
53787a3b38f7Smrg		if $opt_dry_run; then
53797a3b38f7Smrg		  # Extract subdirectory from the argument.
53807a3b38f7Smrg		  func_dirname "$arg" "/" ""
53817a3b38f7Smrg		  xdir="$func_dirname_result"
53827a3b38f7Smrg
53837a3b38f7Smrg		  func_lo2o "$arg"
53847a3b38f7Smrg		  pic_object=$xdir$objdir/$func_lo2o_result
53857a3b38f7Smrg		  non_pic_object=$xdir$func_lo2o_result
53867a3b38f7Smrg		  func_append libobjs " $pic_object"
53877a3b38f7Smrg		  func_append non_pic_objects " $non_pic_object"
53887a3b38f7Smrg	        else
53897a3b38f7Smrg		  func_fatal_error "\`$arg' is not a valid libtool object"
53907a3b38f7Smrg		fi
53917a3b38f7Smrg	      fi
53927a3b38f7Smrg	    done
53937a3b38f7Smrg	  else
53947a3b38f7Smrg	    func_fatal_error "link input file \`$arg' does not exist"
53957a3b38f7Smrg	  fi
53967a3b38f7Smrg	  arg=$save_arg
53977a3b38f7Smrg	  prev=
53987a3b38f7Smrg	  continue
53997a3b38f7Smrg	  ;;
54007a3b38f7Smrg	precious_regex)
54017a3b38f7Smrg	  precious_files_regex="$arg"
54027a3b38f7Smrg	  prev=
54037a3b38f7Smrg	  continue
54047a3b38f7Smrg	  ;;
54057a3b38f7Smrg	release)
54067a3b38f7Smrg	  release="-$arg"
54077a3b38f7Smrg	  prev=
54087a3b38f7Smrg	  continue
54097a3b38f7Smrg	  ;;
54107a3b38f7Smrg	rpath | xrpath)
54117a3b38f7Smrg	  # We need an absolute path.
54127a3b38f7Smrg	  case $arg in
54137a3b38f7Smrg	  [\\/]* | [A-Za-z]:[\\/]*) ;;
54147a3b38f7Smrg	  *)
54157a3b38f7Smrg	    func_fatal_error "only absolute run-paths are allowed"
54167a3b38f7Smrg	    ;;
54177a3b38f7Smrg	  esac
54187a3b38f7Smrg	  if test "$prev" = rpath; then
54197a3b38f7Smrg	    case "$rpath " in
54207a3b38f7Smrg	    *" $arg "*) ;;
5421862f5301Smrg	    *) func_append rpath " $arg" ;;
54227a3b38f7Smrg	    esac
54237a3b38f7Smrg	  else
54247a3b38f7Smrg	    case "$xrpath " in
54257a3b38f7Smrg	    *" $arg "*) ;;
5426862f5301Smrg	    *) func_append xrpath " $arg" ;;
54277a3b38f7Smrg	    esac
54287a3b38f7Smrg	  fi
54297a3b38f7Smrg	  prev=
54307a3b38f7Smrg	  continue
54317a3b38f7Smrg	  ;;
54327a3b38f7Smrg	shrext)
54337a3b38f7Smrg	  shrext_cmds="$arg"
54347a3b38f7Smrg	  prev=
54357a3b38f7Smrg	  continue
54367a3b38f7Smrg	  ;;
54377a3b38f7Smrg	weak)
5438862f5301Smrg	  func_append weak_libs " $arg"
54397a3b38f7Smrg	  prev=
54407a3b38f7Smrg	  continue
54417a3b38f7Smrg	  ;;
54427a3b38f7Smrg	xcclinker)
5443862f5301Smrg	  func_append linker_flags " $qarg"
5444862f5301Smrg	  func_append compiler_flags " $qarg"
54457a3b38f7Smrg	  prev=
54467a3b38f7Smrg	  func_append compile_command " $qarg"
54477a3b38f7Smrg	  func_append finalize_command " $qarg"
54487a3b38f7Smrg	  continue
54497a3b38f7Smrg	  ;;
54507a3b38f7Smrg	xcompiler)
5451862f5301Smrg	  func_append compiler_flags " $qarg"
54527a3b38f7Smrg	  prev=
54537a3b38f7Smrg	  func_append compile_command " $qarg"
54547a3b38f7Smrg	  func_append finalize_command " $qarg"
54557a3b38f7Smrg	  continue
54567a3b38f7Smrg	  ;;
54577a3b38f7Smrg	xlinker)
5458862f5301Smrg	  func_append linker_flags " $qarg"
5459862f5301Smrg	  func_append compiler_flags " $wl$qarg"
54607a3b38f7Smrg	  prev=
54617a3b38f7Smrg	  func_append compile_command " $wl$qarg"
54627a3b38f7Smrg	  func_append finalize_command " $wl$qarg"
54637a3b38f7Smrg	  continue
54647a3b38f7Smrg	  ;;
54657a3b38f7Smrg	*)
54667a3b38f7Smrg	  eval "$prev=\"\$arg\""
54677a3b38f7Smrg	  prev=
54687a3b38f7Smrg	  continue
54697a3b38f7Smrg	  ;;
5470ff559fabSmrg	esac
54717a3b38f7Smrg      fi # test -n "$prev"
5472ff559fabSmrg
54737a3b38f7Smrg      prevarg="$arg"
5474ff559fabSmrg
54757a3b38f7Smrg      case $arg in
54767a3b38f7Smrg      -all-static)
54777a3b38f7Smrg	if test -n "$link_static_flag"; then
54787a3b38f7Smrg	  # See comment for -static flag below, for more details.
54797a3b38f7Smrg	  func_append compile_command " $link_static_flag"
54807a3b38f7Smrg	  func_append finalize_command " $link_static_flag"
54817a3b38f7Smrg	fi
54827a3b38f7Smrg	continue
54837a3b38f7Smrg	;;
5484ff559fabSmrg
54857a3b38f7Smrg      -allow-undefined)
54867a3b38f7Smrg	# FIXME: remove this flag sometime in the future.
54877a3b38f7Smrg	func_fatal_error "\`-allow-undefined' must not be used because it is the default"
54887a3b38f7Smrg	;;
5489ff559fabSmrg
54907a3b38f7Smrg      -avoid-version)
54917a3b38f7Smrg	avoid_version=yes
54927a3b38f7Smrg	continue
54937a3b38f7Smrg	;;
5494ff559fabSmrg
549544dda7b2Smrg      -bindir)
549644dda7b2Smrg	prev=bindir
549744dda7b2Smrg	continue
549844dda7b2Smrg	;;
549944dda7b2Smrg
55007a3b38f7Smrg      -dlopen)
55017a3b38f7Smrg	prev=dlfiles
55027a3b38f7Smrg	continue
55037a3b38f7Smrg	;;
5504ff559fabSmrg
55057a3b38f7Smrg      -dlpreopen)
55067a3b38f7Smrg	prev=dlprefiles
55077a3b38f7Smrg	continue
55087a3b38f7Smrg	;;
5509ff559fabSmrg
55107a3b38f7Smrg      -export-dynamic)
55117a3b38f7Smrg	export_dynamic=yes
55127a3b38f7Smrg	continue
55137a3b38f7Smrg	;;
5514ff559fabSmrg
55157a3b38f7Smrg      -export-symbols | -export-symbols-regex)
55167a3b38f7Smrg	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
55177a3b38f7Smrg	  func_fatal_error "more than one -exported-symbols argument is not allowed"
55187a3b38f7Smrg	fi
55197a3b38f7Smrg	if test "X$arg" = "X-export-symbols"; then
55207a3b38f7Smrg	  prev=expsyms
55217a3b38f7Smrg	else
55227a3b38f7Smrg	  prev=expsyms_regex
55237a3b38f7Smrg	fi
55247a3b38f7Smrg	continue
55257a3b38f7Smrg	;;
5526ff559fabSmrg
55277a3b38f7Smrg      -framework)
55287a3b38f7Smrg	prev=framework
55297a3b38f7Smrg	continue
55307a3b38f7Smrg	;;
5531ff559fabSmrg
55327a3b38f7Smrg      -inst-prefix-dir)
55337a3b38f7Smrg	prev=inst_prefix
55347a3b38f7Smrg	continue
55357a3b38f7Smrg	;;
5536ff559fabSmrg
55377a3b38f7Smrg      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
55387a3b38f7Smrg      # so, if we see these flags be careful not to treat them like -L
55397a3b38f7Smrg      -L[A-Z][A-Z]*:*)
55407a3b38f7Smrg	case $with_gcc/$host in
55417a3b38f7Smrg	no/*-*-irix* | /*-*-irix*)
55427a3b38f7Smrg	  func_append compile_command " $arg"
55437a3b38f7Smrg	  func_append finalize_command " $arg"
55447a3b38f7Smrg	  ;;
55457a3b38f7Smrg	esac
55467a3b38f7Smrg	continue
55477a3b38f7Smrg	;;
5548ff559fabSmrg
55497a3b38f7Smrg      -L*)
5550862f5301Smrg	func_stripname "-L" '' "$arg"
5551862f5301Smrg	if test -z "$func_stripname_result"; then
55527a3b38f7Smrg	  if test "$#" -gt 0; then
55537a3b38f7Smrg	    func_fatal_error "require no space between \`-L' and \`$1'"
55547a3b38f7Smrg	  else
55557a3b38f7Smrg	    func_fatal_error "need path for \`-L' option"
55567a3b38f7Smrg	  fi
55577a3b38f7Smrg	fi
5558862f5301Smrg	func_resolve_sysroot "$func_stripname_result"
5559862f5301Smrg	dir=$func_resolve_sysroot_result
55607a3b38f7Smrg	# We need an absolute path.
55617a3b38f7Smrg	case $dir in
55627a3b38f7Smrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
55637a3b38f7Smrg	*)
55647a3b38f7Smrg	  absdir=`cd "$dir" && pwd`
55657a3b38f7Smrg	  test -z "$absdir" && \
55667a3b38f7Smrg	    func_fatal_error "cannot determine absolute directory name of \`$dir'"
55677a3b38f7Smrg	  dir="$absdir"
55687a3b38f7Smrg	  ;;
55697a3b38f7Smrg	esac
55707a3b38f7Smrg	case "$deplibs " in
5571862f5301Smrg	*" -L$dir "* | *" $arg "*)
5572862f5301Smrg	  # Will only happen for absolute or sysroot arguments
5573862f5301Smrg	  ;;
55747a3b38f7Smrg	*)
5575862f5301Smrg	  # Preserve sysroot, but never include relative directories
5576862f5301Smrg	  case $dir in
5577862f5301Smrg	    [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;;
5578862f5301Smrg	    *) func_append deplibs " -L$dir" ;;
5579862f5301Smrg	  esac
5580862f5301Smrg	  func_append lib_search_path " $dir"
55817a3b38f7Smrg	  ;;
55827a3b38f7Smrg	esac
55837a3b38f7Smrg	case $host in
55847a3b38f7Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
558544dda7b2Smrg	  testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
55867a3b38f7Smrg	  case :$dllsearchpath: in
55877a3b38f7Smrg	  *":$dir:"*) ;;
55887a3b38f7Smrg	  ::) dllsearchpath=$dir;;
5589862f5301Smrg	  *) func_append dllsearchpath ":$dir";;
55907a3b38f7Smrg	  esac
55917a3b38f7Smrg	  case :$dllsearchpath: in
55927a3b38f7Smrg	  *":$testbindir:"*) ;;
55937a3b38f7Smrg	  ::) dllsearchpath=$testbindir;;
5594862f5301Smrg	  *) func_append dllsearchpath ":$testbindir";;
55957a3b38f7Smrg	  esac
55967a3b38f7Smrg	  ;;
55977a3b38f7Smrg	esac
55987a3b38f7Smrg	continue
55997a3b38f7Smrg	;;
5600ff559fabSmrg
56017a3b38f7Smrg      -l*)
56027a3b38f7Smrg	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
56037a3b38f7Smrg	  case $host in
560444dda7b2Smrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
56057a3b38f7Smrg	    # These systems don't actually have a C or math library (as such)
56067a3b38f7Smrg	    continue
56077a3b38f7Smrg	    ;;
56087a3b38f7Smrg	  *-*-os2*)
56097a3b38f7Smrg	    # These systems don't actually have a C library (as such)
56107a3b38f7Smrg	    test "X$arg" = "X-lc" && continue
56117a3b38f7Smrg	    ;;
56127a3b38f7Smrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
56137a3b38f7Smrg	    # Do not include libc due to us having libc/libc_r.
56147a3b38f7Smrg	    test "X$arg" = "X-lc" && continue
56157a3b38f7Smrg	    ;;
56167a3b38f7Smrg	  *-*-rhapsody* | *-*-darwin1.[012])
56177a3b38f7Smrg	    # Rhapsody C and math libraries are in the System framework
5618862f5301Smrg	    func_append deplibs " System.ltframework"
56197a3b38f7Smrg	    continue
56207a3b38f7Smrg	    ;;
56217a3b38f7Smrg	  *-*-sco3.2v5* | *-*-sco5v6*)
56227a3b38f7Smrg	    # Causes problems with __ctype
56237a3b38f7Smrg	    test "X$arg" = "X-lc" && continue
56247a3b38f7Smrg	    ;;
56257a3b38f7Smrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
56267a3b38f7Smrg	    # Compiler inserts libc in the correct place for threads to work
56277a3b38f7Smrg	    test "X$arg" = "X-lc" && continue
56287a3b38f7Smrg	    ;;
56297a3b38f7Smrg	  esac
56307a3b38f7Smrg	elif test "X$arg" = "X-lc_r"; then
56317a3b38f7Smrg	 case $host in
56327a3b38f7Smrg	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
56337a3b38f7Smrg	   # Do not include libc_r directly, use -pthread flag.
56347a3b38f7Smrg	   continue
56357a3b38f7Smrg	   ;;
56367a3b38f7Smrg	 esac
56377a3b38f7Smrg	fi
5638862f5301Smrg	func_append deplibs " $arg"
56397a3b38f7Smrg	continue
56407a3b38f7Smrg	;;
5641ff559fabSmrg
56427a3b38f7Smrg      -module)
56437a3b38f7Smrg	module=yes
56447a3b38f7Smrg	continue
56457a3b38f7Smrg	;;
5646ff559fabSmrg
56477a3b38f7Smrg      # Tru64 UNIX uses -model [arg] to determine the layout of C++
56487a3b38f7Smrg      # classes, name mangling, and exception handling.
56497a3b38f7Smrg      # Darwin uses the -arch flag to determine output architecture.
5650862f5301Smrg      -model|-arch|-isysroot|--sysroot)
5651862f5301Smrg	func_append compiler_flags " $arg"
56527a3b38f7Smrg	func_append compile_command " $arg"
56537a3b38f7Smrg	func_append finalize_command " $arg"
56547a3b38f7Smrg	prev=xcompiler
56557a3b38f7Smrg	continue
56567a3b38f7Smrg	;;
5657ff559fabSmrg
5658fc544a13Smrg      -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
5659fc544a13Smrg      |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
5660862f5301Smrg	func_append compiler_flags " $arg"
56617a3b38f7Smrg	func_append compile_command " $arg"
56627a3b38f7Smrg	func_append finalize_command " $arg"
56637a3b38f7Smrg	case "$new_inherited_linker_flags " in
56647a3b38f7Smrg	    *" $arg "*) ;;
5665862f5301Smrg	    * ) func_append new_inherited_linker_flags " $arg" ;;
56667a3b38f7Smrg	esac
56677a3b38f7Smrg	continue
56687a3b38f7Smrg	;;
5669ff559fabSmrg
56707a3b38f7Smrg      -multi_module)
56717a3b38f7Smrg	single_module="${wl}-multi_module"
56727a3b38f7Smrg	continue
56737a3b38f7Smrg	;;
5674ff559fabSmrg
56757a3b38f7Smrg      -no-fast-install)
56767a3b38f7Smrg	fast_install=no
56777a3b38f7Smrg	continue
56787a3b38f7Smrg	;;
5679ff559fabSmrg
56807a3b38f7Smrg      -no-install)
56817a3b38f7Smrg	case $host in
56827a3b38f7Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
56837a3b38f7Smrg	  # The PATH hackery in wrapper scripts is required on Windows
56847a3b38f7Smrg	  # and Darwin in order for the loader to find any dlls it needs.
56857a3b38f7Smrg	  func_warning "\`-no-install' is ignored for $host"
56867a3b38f7Smrg	  func_warning "assuming \`-no-fast-install' instead"
56877a3b38f7Smrg	  fast_install=no
56887a3b38f7Smrg	  ;;
56897a3b38f7Smrg	*) no_install=yes ;;
56907a3b38f7Smrg	esac
56917a3b38f7Smrg	continue
56927a3b38f7Smrg	;;
5693ff559fabSmrg
56947a3b38f7Smrg      -no-undefined)
56957a3b38f7Smrg	allow_undefined=no
56967a3b38f7Smrg	continue
56977a3b38f7Smrg	;;
5698ff559fabSmrg
56997a3b38f7Smrg      -objectlist)
57007a3b38f7Smrg	prev=objectlist
57017a3b38f7Smrg	continue
57027a3b38f7Smrg	;;
5703ff559fabSmrg
57047a3b38f7Smrg      -o) prev=output ;;
5705ff559fabSmrg
57067a3b38f7Smrg      -precious-files-regex)
57077a3b38f7Smrg	prev=precious_regex
57087a3b38f7Smrg	continue
57097a3b38f7Smrg	;;
5710ff559fabSmrg
57117a3b38f7Smrg      -release)
57127a3b38f7Smrg	prev=release
57137a3b38f7Smrg	continue
57147a3b38f7Smrg	;;
5715ff559fabSmrg
57167a3b38f7Smrg      -rpath)
57177a3b38f7Smrg	prev=rpath
57187a3b38f7Smrg	continue
57197a3b38f7Smrg	;;
5720ff559fabSmrg
57217a3b38f7Smrg      -R)
57227a3b38f7Smrg	prev=xrpath
57237a3b38f7Smrg	continue
57247a3b38f7Smrg	;;
5725ff559fabSmrg
57267a3b38f7Smrg      -R*)
57277a3b38f7Smrg	func_stripname '-R' '' "$arg"
57287a3b38f7Smrg	dir=$func_stripname_result
57297a3b38f7Smrg	# We need an absolute path.
57307a3b38f7Smrg	case $dir in
57317a3b38f7Smrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
5732862f5301Smrg	=*)
5733862f5301Smrg	  func_stripname '=' '' "$dir"
5734862f5301Smrg	  dir=$lt_sysroot$func_stripname_result
5735862f5301Smrg	  ;;
57367a3b38f7Smrg	*)
57377a3b38f7Smrg	  func_fatal_error "only absolute run-paths are allowed"
57387a3b38f7Smrg	  ;;
57397a3b38f7Smrg	esac
57407a3b38f7Smrg	case "$xrpath " in
57417a3b38f7Smrg	*" $dir "*) ;;
5742862f5301Smrg	*) func_append xrpath " $dir" ;;
57437a3b38f7Smrg	esac
57447a3b38f7Smrg	continue
57457a3b38f7Smrg	;;
5746ff559fabSmrg
57477a3b38f7Smrg      -shared)
57487a3b38f7Smrg	# The effects of -shared are defined in a previous loop.
57497a3b38f7Smrg	continue
57507a3b38f7Smrg	;;
5751ff559fabSmrg
57527a3b38f7Smrg      -shrext)
57537a3b38f7Smrg	prev=shrext
57547a3b38f7Smrg	continue
57557a3b38f7Smrg	;;
5756ff559fabSmrg
57577a3b38f7Smrg      -static | -static-libtool-libs)
57587a3b38f7Smrg	# The effects of -static are defined in a previous loop.
57597a3b38f7Smrg	# We used to do the same as -all-static on platforms that
57607a3b38f7Smrg	# didn't have a PIC flag, but the assumption that the effects
57617a3b38f7Smrg	# would be equivalent was wrong.  It would break on at least
57627a3b38f7Smrg	# Digital Unix and AIX.
57637a3b38f7Smrg	continue
57647a3b38f7Smrg	;;
5765ff559fabSmrg
57667a3b38f7Smrg      -thread-safe)
57677a3b38f7Smrg	thread_safe=yes
57687a3b38f7Smrg	continue
57697a3b38f7Smrg	;;
5770ff559fabSmrg
57717a3b38f7Smrg      -version-info)
57727a3b38f7Smrg	prev=vinfo
57737a3b38f7Smrg	continue
57747a3b38f7Smrg	;;
5775ff559fabSmrg
57767a3b38f7Smrg      -version-number)
57777a3b38f7Smrg	prev=vinfo
57787a3b38f7Smrg	vinfo_number=yes
57797a3b38f7Smrg	continue
57807a3b38f7Smrg	;;
5781ff559fabSmrg
57827a3b38f7Smrg      -weak)
57837a3b38f7Smrg        prev=weak
57847a3b38f7Smrg	continue
57857a3b38f7Smrg	;;
5786ff559fabSmrg
57877a3b38f7Smrg      -Wc,*)
57887a3b38f7Smrg	func_stripname '-Wc,' '' "$arg"
57897a3b38f7Smrg	args=$func_stripname_result
57907a3b38f7Smrg	arg=
57917a3b38f7Smrg	save_ifs="$IFS"; IFS=','
57927a3b38f7Smrg	for flag in $args; do
57937a3b38f7Smrg	  IFS="$save_ifs"
57947a3b38f7Smrg          func_quote_for_eval "$flag"
5795862f5301Smrg	  func_append arg " $func_quote_for_eval_result"
5796862f5301Smrg	  func_append compiler_flags " $func_quote_for_eval_result"
57977a3b38f7Smrg	done
57987a3b38f7Smrg	IFS="$save_ifs"
57997a3b38f7Smrg	func_stripname ' ' '' "$arg"
58007a3b38f7Smrg	arg=$func_stripname_result
58017a3b38f7Smrg	;;
5802ff559fabSmrg
58037a3b38f7Smrg      -Wl,*)
58047a3b38f7Smrg	func_stripname '-Wl,' '' "$arg"
58057a3b38f7Smrg	args=$func_stripname_result
58067a3b38f7Smrg	arg=
58077a3b38f7Smrg	save_ifs="$IFS"; IFS=','
58087a3b38f7Smrg	for flag in $args; do
58097a3b38f7Smrg	  IFS="$save_ifs"
58107a3b38f7Smrg          func_quote_for_eval "$flag"
5811862f5301Smrg	  func_append arg " $wl$func_quote_for_eval_result"
5812862f5301Smrg	  func_append compiler_flags " $wl$func_quote_for_eval_result"
5813862f5301Smrg	  func_append linker_flags " $func_quote_for_eval_result"
58147a3b38f7Smrg	done
58157a3b38f7Smrg	IFS="$save_ifs"
58167a3b38f7Smrg	func_stripname ' ' '' "$arg"
58177a3b38f7Smrg	arg=$func_stripname_result
58187a3b38f7Smrg	;;
5819ff559fabSmrg
58207a3b38f7Smrg      -Xcompiler)
58217a3b38f7Smrg	prev=xcompiler
58227a3b38f7Smrg	continue
58237a3b38f7Smrg	;;
5824ff559fabSmrg
58257a3b38f7Smrg      -Xlinker)
58267a3b38f7Smrg	prev=xlinker
58277a3b38f7Smrg	continue
58287a3b38f7Smrg	;;
5829ff559fabSmrg
58307a3b38f7Smrg      -XCClinker)
58317a3b38f7Smrg	prev=xcclinker
58327a3b38f7Smrg	continue
58337a3b38f7Smrg	;;
5834ff559fabSmrg
58357a3b38f7Smrg      # -msg_* for osf cc
58367a3b38f7Smrg      -msg_*)
58377a3b38f7Smrg	func_quote_for_eval "$arg"
58387a3b38f7Smrg	arg="$func_quote_for_eval_result"
58397a3b38f7Smrg	;;
5840ff559fabSmrg
584144dda7b2Smrg      # Flags to be passed through unchanged, with rationale:
584244dda7b2Smrg      # -64, -mips[0-9]      enable 64-bit mode for the SGI compiler
584344dda7b2Smrg      # -r[0-9][0-9]*        specify processor for the SGI compiler
584444dda7b2Smrg      # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler
584544dda7b2Smrg      # +DA*, +DD*           enable 64-bit mode for the HP compiler
584644dda7b2Smrg      # -q*                  compiler args for the IBM compiler
584744dda7b2Smrg      # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
584844dda7b2Smrg      # -F/path              path to uninstalled frameworks, gcc on darwin
584944dda7b2Smrg      # -p, -pg, --coverage, -fprofile-*  profiling flags for GCC
585044dda7b2Smrg      # @file                GCC response files
585144dda7b2Smrg      # -tp=*                Portland pgcc target processor selection
5852862f5301Smrg      # --sysroot=*          for sysroot support
5853862f5301Smrg      # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
58547a3b38f7Smrg      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
5855862f5301Smrg      -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
5856862f5301Smrg      -O*|-flto*|-fwhopr*|-fuse-linker-plugin)
58577a3b38f7Smrg        func_quote_for_eval "$arg"
58587a3b38f7Smrg	arg="$func_quote_for_eval_result"
58597a3b38f7Smrg        func_append compile_command " $arg"
58607a3b38f7Smrg        func_append finalize_command " $arg"
5861862f5301Smrg        func_append compiler_flags " $arg"
58627a3b38f7Smrg        continue
58637a3b38f7Smrg        ;;
5864ff559fabSmrg
58657a3b38f7Smrg      # Some other compiler flag.
58667a3b38f7Smrg      -* | +*)
58677a3b38f7Smrg        func_quote_for_eval "$arg"
58687a3b38f7Smrg	arg="$func_quote_for_eval_result"
58697a3b38f7Smrg	;;
5870ff559fabSmrg
58717a3b38f7Smrg      *.$objext)
58727a3b38f7Smrg	# A standard object.
5873862f5301Smrg	func_append objs " $arg"
58747a3b38f7Smrg	;;
58757a3b38f7Smrg
58767a3b38f7Smrg      *.lo)
58777a3b38f7Smrg	# A libtool-controlled object.
58787a3b38f7Smrg
58797a3b38f7Smrg	# Check to see that this really is a libtool object.
58807a3b38f7Smrg	if func_lalib_unsafe_p "$arg"; then
58817a3b38f7Smrg	  pic_object=
58827a3b38f7Smrg	  non_pic_object=
58837a3b38f7Smrg
58847a3b38f7Smrg	  # Read the .lo file
58857a3b38f7Smrg	  func_source "$arg"
58867a3b38f7Smrg
58877a3b38f7Smrg	  if test -z "$pic_object" ||
58887a3b38f7Smrg	     test -z "$non_pic_object" ||
58897a3b38f7Smrg	     test "$pic_object" = none &&
58907a3b38f7Smrg	     test "$non_pic_object" = none; then
58917a3b38f7Smrg	    func_fatal_error "cannot find name of object for \`$arg'"
58927a3b38f7Smrg	  fi
58937a3b38f7Smrg
58947a3b38f7Smrg	  # Extract subdirectory from the argument.
58957a3b38f7Smrg	  func_dirname "$arg" "/" ""
58967a3b38f7Smrg	  xdir="$func_dirname_result"
58977a3b38f7Smrg
58987a3b38f7Smrg	  if test "$pic_object" != none; then
58997a3b38f7Smrg	    # Prepend the subdirectory the object is found in.
59007a3b38f7Smrg	    pic_object="$xdir$pic_object"
59017a3b38f7Smrg
59027a3b38f7Smrg	    if test "$prev" = dlfiles; then
59037a3b38f7Smrg	      if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
5904862f5301Smrg		func_append dlfiles " $pic_object"
59057a3b38f7Smrg		prev=
59067a3b38f7Smrg		continue
59077a3b38f7Smrg	      else
59087a3b38f7Smrg		# If libtool objects are unsupported, then we need to preload.
59097a3b38f7Smrg		prev=dlprefiles
59107a3b38f7Smrg	      fi
59117a3b38f7Smrg	    fi
59127a3b38f7Smrg
59137a3b38f7Smrg	    # CHECK ME:  I think I busted this.  -Ossama
59147a3b38f7Smrg	    if test "$prev" = dlprefiles; then
59157a3b38f7Smrg	      # Preload the old-style object.
5916862f5301Smrg	      func_append dlprefiles " $pic_object"
59177a3b38f7Smrg	      prev=
59187a3b38f7Smrg	    fi
59197a3b38f7Smrg
59207a3b38f7Smrg	    # A PIC object.
59217a3b38f7Smrg	    func_append libobjs " $pic_object"
59227a3b38f7Smrg	    arg="$pic_object"
59237a3b38f7Smrg	  fi
59247a3b38f7Smrg
59257a3b38f7Smrg	  # Non-PIC object.
59267a3b38f7Smrg	  if test "$non_pic_object" != none; then
59277a3b38f7Smrg	    # Prepend the subdirectory the object is found in.
59287a3b38f7Smrg	    non_pic_object="$xdir$non_pic_object"
59297a3b38f7Smrg
59307a3b38f7Smrg	    # A standard non-PIC object
59317a3b38f7Smrg	    func_append non_pic_objects " $non_pic_object"
59327a3b38f7Smrg	    if test -z "$pic_object" || test "$pic_object" = none ; then
59337a3b38f7Smrg	      arg="$non_pic_object"
59347a3b38f7Smrg	    fi
59357a3b38f7Smrg	  else
59367a3b38f7Smrg	    # If the PIC object exists, use it instead.
59377a3b38f7Smrg	    # $xdir was prepended to $pic_object above.
59387a3b38f7Smrg	    non_pic_object="$pic_object"
59397a3b38f7Smrg	    func_append non_pic_objects " $non_pic_object"
59407a3b38f7Smrg	  fi
59417a3b38f7Smrg	else
59427a3b38f7Smrg	  # Only an error if not doing a dry-run.
59437a3b38f7Smrg	  if $opt_dry_run; then
59447a3b38f7Smrg	    # Extract subdirectory from the argument.
59457a3b38f7Smrg	    func_dirname "$arg" "/" ""
59467a3b38f7Smrg	    xdir="$func_dirname_result"
59477a3b38f7Smrg
59487a3b38f7Smrg	    func_lo2o "$arg"
59497a3b38f7Smrg	    pic_object=$xdir$objdir/$func_lo2o_result
59507a3b38f7Smrg	    non_pic_object=$xdir$func_lo2o_result
59517a3b38f7Smrg	    func_append libobjs " $pic_object"
59527a3b38f7Smrg	    func_append non_pic_objects " $non_pic_object"
59537a3b38f7Smrg	  else
59547a3b38f7Smrg	    func_fatal_error "\`$arg' is not a valid libtool object"
59557a3b38f7Smrg	  fi
59567a3b38f7Smrg	fi
59577a3b38f7Smrg	;;
59587a3b38f7Smrg
59597a3b38f7Smrg      *.$libext)
59607a3b38f7Smrg	# An archive.
5961862f5301Smrg	func_append deplibs " $arg"
5962862f5301Smrg	func_append old_deplibs " $arg"
59637a3b38f7Smrg	continue
59647a3b38f7Smrg	;;
59657a3b38f7Smrg
59667a3b38f7Smrg      *.la)
59677a3b38f7Smrg	# A libtool-controlled library.
59687a3b38f7Smrg
5969862f5301Smrg	func_resolve_sysroot "$arg"
59707a3b38f7Smrg	if test "$prev" = dlfiles; then
59717a3b38f7Smrg	  # This library was specified with -dlopen.
5972862f5301Smrg	  func_append dlfiles " $func_resolve_sysroot_result"
59737a3b38f7Smrg	  prev=
59747a3b38f7Smrg	elif test "$prev" = dlprefiles; then
59757a3b38f7Smrg	  # The library was specified with -dlpreopen.
5976862f5301Smrg	  func_append dlprefiles " $func_resolve_sysroot_result"
59777a3b38f7Smrg	  prev=
59787a3b38f7Smrg	else
5979862f5301Smrg	  func_append deplibs " $func_resolve_sysroot_result"
59807a3b38f7Smrg	fi
59817a3b38f7Smrg	continue
59827a3b38f7Smrg	;;
59837a3b38f7Smrg
59847a3b38f7Smrg      # Some other compiler argument.
59857a3b38f7Smrg      *)
59867a3b38f7Smrg	# Unknown arguments in both finalize_command and compile_command need
59877a3b38f7Smrg	# to be aesthetically quoted because they are evaled later.
59887a3b38f7Smrg	func_quote_for_eval "$arg"
59897a3b38f7Smrg	arg="$func_quote_for_eval_result"
59907a3b38f7Smrg	;;
59917a3b38f7Smrg      esac # arg
59927a3b38f7Smrg
59937a3b38f7Smrg      # Now actually substitute the argument into the commands.
59947a3b38f7Smrg      if test -n "$arg"; then
59957a3b38f7Smrg	func_append compile_command " $arg"
59967a3b38f7Smrg	func_append finalize_command " $arg"
59977a3b38f7Smrg      fi
59987a3b38f7Smrg    done # argument parsing loop
59997a3b38f7Smrg
60007a3b38f7Smrg    test -n "$prev" && \
60017a3b38f7Smrg      func_fatal_help "the \`$prevarg' option requires an argument"
60027a3b38f7Smrg
60037a3b38f7Smrg    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
60047a3b38f7Smrg      eval arg=\"$export_dynamic_flag_spec\"
60057a3b38f7Smrg      func_append compile_command " $arg"
60067a3b38f7Smrg      func_append finalize_command " $arg"
60077a3b38f7Smrg    fi
60087a3b38f7Smrg
60097a3b38f7Smrg    oldlibs=
60107a3b38f7Smrg    # calculate the name of the file, without its directory
60117a3b38f7Smrg    func_basename "$output"
60127a3b38f7Smrg    outputname="$func_basename_result"
60137a3b38f7Smrg    libobjs_save="$libobjs"
60147a3b38f7Smrg
60157a3b38f7Smrg    if test -n "$shlibpath_var"; then
60167a3b38f7Smrg      # get the directories listed in $shlibpath_var
601744dda7b2Smrg      eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\`
6018ff559fabSmrg    else
60197a3b38f7Smrg      shlib_search_path=
6020ff559fabSmrg    fi
60217a3b38f7Smrg    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
60227a3b38f7Smrg    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
6023ff559fabSmrg
60247a3b38f7Smrg    func_dirname "$output" "/" ""
60257a3b38f7Smrg    output_objdir="$func_dirname_result$objdir"
6026862f5301Smrg    func_to_tool_file "$output_objdir/"
6027862f5301Smrg    tool_output_objdir=$func_to_tool_file_result
60287a3b38f7Smrg    # Create the object directory.
60297a3b38f7Smrg    func_mkdir_p "$output_objdir"
6030ff559fabSmrg
60317a3b38f7Smrg    # Determine the type of output
60327a3b38f7Smrg    case $output in
60337a3b38f7Smrg    "")
60347a3b38f7Smrg      func_fatal_help "you must specify an output file"
60357a3b38f7Smrg      ;;
60367a3b38f7Smrg    *.$libext) linkmode=oldlib ;;
60377a3b38f7Smrg    *.lo | *.$objext) linkmode=obj ;;
60387a3b38f7Smrg    *.la) linkmode=lib ;;
60397a3b38f7Smrg    *) linkmode=prog ;; # Anything else should be a program.
60407a3b38f7Smrg    esac
60417a3b38f7Smrg
60427a3b38f7Smrg    specialdeplibs=
60437a3b38f7Smrg
60447a3b38f7Smrg    libs=
60457a3b38f7Smrg    # Find all interdependent deplibs by searching for libraries
60467a3b38f7Smrg    # that are linked more than once (e.g. -la -lb -la)
60477a3b38f7Smrg    for deplib in $deplibs; do
6048862f5301Smrg      if $opt_preserve_dup_deps ; then
60497a3b38f7Smrg	case "$libs " in
6050862f5301Smrg	*" $deplib "*) func_append specialdeplibs " $deplib" ;;
60517a3b38f7Smrg	esac
60527a3b38f7Smrg      fi
6053862f5301Smrg      func_append libs " $deplib"
60547a3b38f7Smrg    done
60557a3b38f7Smrg
60567a3b38f7Smrg    if test "$linkmode" = lib; then
60577a3b38f7Smrg      libs="$predeps $libs $compiler_lib_search_path $postdeps"
60587a3b38f7Smrg
60597a3b38f7Smrg      # Compute libraries that are listed more than once in $predeps
60607a3b38f7Smrg      # $postdeps and mark them as special (i.e., whose duplicates are
60617a3b38f7Smrg      # not to be eliminated).
60627a3b38f7Smrg      pre_post_deps=
60637a3b38f7Smrg      if $opt_duplicate_compiler_generated_deps; then
60647a3b38f7Smrg	for pre_post_dep in $predeps $postdeps; do
60657a3b38f7Smrg	  case "$pre_post_deps " in
6066862f5301Smrg	  *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;;
60677a3b38f7Smrg	  esac
6068862f5301Smrg	  func_append pre_post_deps " $pre_post_dep"
60697a3b38f7Smrg	done
60707a3b38f7Smrg      fi
60717a3b38f7Smrg      pre_post_deps=
60727a3b38f7Smrg    fi
60737a3b38f7Smrg
60747a3b38f7Smrg    deplibs=
60757a3b38f7Smrg    newdependency_libs=
60767a3b38f7Smrg    newlib_search_path=
60777a3b38f7Smrg    need_relink=no # whether we're linking any uninstalled libtool libraries
60787a3b38f7Smrg    notinst_deplibs= # not-installed libtool libraries
60797a3b38f7Smrg    notinst_path= # paths that contain not-installed libtool libraries
60807a3b38f7Smrg
60817a3b38f7Smrg    case $linkmode in
60827a3b38f7Smrg    lib)
60837a3b38f7Smrg	passes="conv dlpreopen link"
60847a3b38f7Smrg	for file in $dlfiles $dlprefiles; do
60857a3b38f7Smrg	  case $file in
60867a3b38f7Smrg	  *.la) ;;
60877a3b38f7Smrg	  *)
60887a3b38f7Smrg	    func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file"
60897a3b38f7Smrg	    ;;
60907a3b38f7Smrg	  esac
60917a3b38f7Smrg	done
60927a3b38f7Smrg	;;
60937a3b38f7Smrg    prog)
60947a3b38f7Smrg	compile_deplibs=
60957a3b38f7Smrg	finalize_deplibs=
60967a3b38f7Smrg	alldeplibs=no
60977a3b38f7Smrg	newdlfiles=
60987a3b38f7Smrg	newdlprefiles=
60997a3b38f7Smrg	passes="conv scan dlopen dlpreopen link"
61007a3b38f7Smrg	;;
61017a3b38f7Smrg    *)  passes="conv"
61027a3b38f7Smrg	;;
61037a3b38f7Smrg    esac
61047a3b38f7Smrg
61057a3b38f7Smrg    for pass in $passes; do
61067a3b38f7Smrg      # The preopen pass in lib mode reverses $deplibs; put it back here
61077a3b38f7Smrg      # so that -L comes before libs that need it for instance...
61087a3b38f7Smrg      if test "$linkmode,$pass" = "lib,link"; then
61097a3b38f7Smrg	## FIXME: Find the place where the list is rebuilt in the wrong
61107a3b38f7Smrg	##        order, and fix it there properly
61117a3b38f7Smrg        tmp_deplibs=
61127a3b38f7Smrg	for deplib in $deplibs; do
61137a3b38f7Smrg	  tmp_deplibs="$deplib $tmp_deplibs"
61147a3b38f7Smrg	done
61157a3b38f7Smrg	deplibs="$tmp_deplibs"
61167a3b38f7Smrg      fi
61177a3b38f7Smrg
61187a3b38f7Smrg      if test "$linkmode,$pass" = "lib,link" ||
61197a3b38f7Smrg	 test "$linkmode,$pass" = "prog,scan"; then
61207a3b38f7Smrg	libs="$deplibs"
61217a3b38f7Smrg	deplibs=
61227a3b38f7Smrg      fi
61237a3b38f7Smrg      if test "$linkmode" = prog; then
61247a3b38f7Smrg	case $pass in
61257a3b38f7Smrg	dlopen) libs="$dlfiles" ;;
61267a3b38f7Smrg	dlpreopen) libs="$dlprefiles" ;;
61277a3b38f7Smrg	link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
61287a3b38f7Smrg	esac
61297a3b38f7Smrg      fi
61307a3b38f7Smrg      if test "$linkmode,$pass" = "lib,dlpreopen"; then
61317a3b38f7Smrg	# Collect and forward deplibs of preopened libtool libs
61327a3b38f7Smrg	for lib in $dlprefiles; do
61337a3b38f7Smrg	  # Ignore non-libtool-libs
61347a3b38f7Smrg	  dependency_libs=
6135862f5301Smrg	  func_resolve_sysroot "$lib"
61367a3b38f7Smrg	  case $lib in
6137862f5301Smrg	  *.la)	func_source "$func_resolve_sysroot_result" ;;
61387a3b38f7Smrg	  esac
61397a3b38f7Smrg
61407a3b38f7Smrg	  # Collect preopened libtool deplibs, except any this library
61417a3b38f7Smrg	  # has declared as weak libs
61427a3b38f7Smrg	  for deplib in $dependency_libs; do
614344dda7b2Smrg	    func_basename "$deplib"
614444dda7b2Smrg            deplib_base=$func_basename_result
61457a3b38f7Smrg	    case " $weak_libs " in
61467a3b38f7Smrg	    *" $deplib_base "*) ;;
6147862f5301Smrg	    *) func_append deplibs " $deplib" ;;
61487a3b38f7Smrg	    esac
61497a3b38f7Smrg	  done
61507a3b38f7Smrg	done
61517a3b38f7Smrg	libs="$dlprefiles"
61527a3b38f7Smrg      fi
61537a3b38f7Smrg      if test "$pass" = dlopen; then
61547a3b38f7Smrg	# Collect dlpreopened libraries
61557a3b38f7Smrg	save_deplibs="$deplibs"
61567a3b38f7Smrg	deplibs=
61577a3b38f7Smrg      fi
61587a3b38f7Smrg
61597a3b38f7Smrg      for deplib in $libs; do
61607a3b38f7Smrg	lib=
61617a3b38f7Smrg	found=no
61627a3b38f7Smrg	case $deplib in
6163fc544a13Smrg	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
6164fc544a13Smrg        |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
61657a3b38f7Smrg	  if test "$linkmode,$pass" = "prog,link"; then
61667a3b38f7Smrg	    compile_deplibs="$deplib $compile_deplibs"
61677a3b38f7Smrg	    finalize_deplibs="$deplib $finalize_deplibs"
61687a3b38f7Smrg	  else
6169862f5301Smrg	    func_append compiler_flags " $deplib"
61707a3b38f7Smrg	    if test "$linkmode" = lib ; then
61717a3b38f7Smrg		case "$new_inherited_linker_flags " in
61727a3b38f7Smrg		    *" $deplib "*) ;;
6173862f5301Smrg		    * ) func_append new_inherited_linker_flags " $deplib" ;;
61747a3b38f7Smrg		esac
61757a3b38f7Smrg	    fi
61767a3b38f7Smrg	  fi
61777a3b38f7Smrg	  continue
61787a3b38f7Smrg	  ;;
61797a3b38f7Smrg	-l*)
61807a3b38f7Smrg	  if test "$linkmode" != lib && test "$linkmode" != prog; then
61817a3b38f7Smrg	    func_warning "\`-l' is ignored for archives/objects"
61827a3b38f7Smrg	    continue
61837a3b38f7Smrg	  fi
61847a3b38f7Smrg	  func_stripname '-l' '' "$deplib"
61857a3b38f7Smrg	  name=$func_stripname_result
61867a3b38f7Smrg	  if test "$linkmode" = lib; then
61877a3b38f7Smrg	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
61887a3b38f7Smrg	  else
61897a3b38f7Smrg	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
61907a3b38f7Smrg	  fi
61917a3b38f7Smrg	  for searchdir in $searchdirs; do
61927a3b38f7Smrg	    for search_ext in .la $std_shrext .so .a; do
61937a3b38f7Smrg	      # Search the libtool library
61947a3b38f7Smrg	      lib="$searchdir/lib${name}${search_ext}"
61957a3b38f7Smrg	      if test -f "$lib"; then
61967a3b38f7Smrg		if test "$search_ext" = ".la"; then
61977a3b38f7Smrg		  found=yes
61987a3b38f7Smrg		else
61997a3b38f7Smrg		  found=no
62007a3b38f7Smrg		fi
62017a3b38f7Smrg		break 2
62027a3b38f7Smrg	      fi
62037a3b38f7Smrg	    done
62047a3b38f7Smrg	  done
62057a3b38f7Smrg	  if test "$found" != yes; then
62067a3b38f7Smrg	    # deplib doesn't seem to be a libtool library
62077a3b38f7Smrg	    if test "$linkmode,$pass" = "prog,link"; then
62087a3b38f7Smrg	      compile_deplibs="$deplib $compile_deplibs"
62097a3b38f7Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
62107a3b38f7Smrg	    else
62117a3b38f7Smrg	      deplibs="$deplib $deplibs"
62127a3b38f7Smrg	      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
62137a3b38f7Smrg	    fi
62147a3b38f7Smrg	    continue
62157a3b38f7Smrg	  else # deplib is a libtool library
62167a3b38f7Smrg	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
62177a3b38f7Smrg	    # We need to do some special things here, and not later.
62187a3b38f7Smrg	    if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
62197a3b38f7Smrg	      case " $predeps $postdeps " in
62207a3b38f7Smrg	      *" $deplib "*)
62217a3b38f7Smrg		if func_lalib_p "$lib"; then
62227a3b38f7Smrg		  library_names=
62237a3b38f7Smrg		  old_library=
62247a3b38f7Smrg		  func_source "$lib"
62257a3b38f7Smrg		  for l in $old_library $library_names; do
62267a3b38f7Smrg		    ll="$l"
62277a3b38f7Smrg		  done
62287a3b38f7Smrg		  if test "X$ll" = "X$old_library" ; then # only static version available
62297a3b38f7Smrg		    found=no
62307a3b38f7Smrg		    func_dirname "$lib" "" "."
62317a3b38f7Smrg		    ladir="$func_dirname_result"
62327a3b38f7Smrg		    lib=$ladir/$old_library
62337a3b38f7Smrg		    if test "$linkmode,$pass" = "prog,link"; then
62347a3b38f7Smrg		      compile_deplibs="$deplib $compile_deplibs"
62357a3b38f7Smrg		      finalize_deplibs="$deplib $finalize_deplibs"
62367a3b38f7Smrg		    else
62377a3b38f7Smrg		      deplibs="$deplib $deplibs"
62387a3b38f7Smrg		      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
62397a3b38f7Smrg		    fi
62407a3b38f7Smrg		    continue
62417a3b38f7Smrg		  fi
62427a3b38f7Smrg		fi
62437a3b38f7Smrg		;;
62447a3b38f7Smrg	      *) ;;
62457a3b38f7Smrg	      esac
62467a3b38f7Smrg	    fi
62477a3b38f7Smrg	  fi
62487a3b38f7Smrg	  ;; # -l
62497a3b38f7Smrg	*.ltframework)
62507a3b38f7Smrg	  if test "$linkmode,$pass" = "prog,link"; then
62517a3b38f7Smrg	    compile_deplibs="$deplib $compile_deplibs"
62527a3b38f7Smrg	    finalize_deplibs="$deplib $finalize_deplibs"
62537a3b38f7Smrg	  else
62547a3b38f7Smrg	    deplibs="$deplib $deplibs"
62557a3b38f7Smrg	    if test "$linkmode" = lib ; then
62567a3b38f7Smrg		case "$new_inherited_linker_flags " in
62577a3b38f7Smrg		    *" $deplib "*) ;;
6258862f5301Smrg		    * ) func_append new_inherited_linker_flags " $deplib" ;;
62597a3b38f7Smrg		esac
62607a3b38f7Smrg	    fi
62617a3b38f7Smrg	  fi
62627a3b38f7Smrg	  continue
62637a3b38f7Smrg	  ;;
62647a3b38f7Smrg	-L*)
62657a3b38f7Smrg	  case $linkmode in
62667a3b38f7Smrg	  lib)
62677a3b38f7Smrg	    deplibs="$deplib $deplibs"
62687a3b38f7Smrg	    test "$pass" = conv && continue
62697a3b38f7Smrg	    newdependency_libs="$deplib $newdependency_libs"
62707a3b38f7Smrg	    func_stripname '-L' '' "$deplib"
6271862f5301Smrg	    func_resolve_sysroot "$func_stripname_result"
6272862f5301Smrg	    func_append newlib_search_path " $func_resolve_sysroot_result"
62737a3b38f7Smrg	    ;;
62747a3b38f7Smrg	  prog)
62757a3b38f7Smrg	    if test "$pass" = conv; then
62767a3b38f7Smrg	      deplibs="$deplib $deplibs"
62777a3b38f7Smrg	      continue
62787a3b38f7Smrg	    fi
62797a3b38f7Smrg	    if test "$pass" = scan; then
62807a3b38f7Smrg	      deplibs="$deplib $deplibs"
62817a3b38f7Smrg	    else
62827a3b38f7Smrg	      compile_deplibs="$deplib $compile_deplibs"
62837a3b38f7Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
62847a3b38f7Smrg	    fi
62857a3b38f7Smrg	    func_stripname '-L' '' "$deplib"
6286862f5301Smrg	    func_resolve_sysroot "$func_stripname_result"
6287862f5301Smrg	    func_append newlib_search_path " $func_resolve_sysroot_result"
62887a3b38f7Smrg	    ;;
62897a3b38f7Smrg	  *)
62907a3b38f7Smrg	    func_warning "\`-L' is ignored for archives/objects"
62917a3b38f7Smrg	    ;;
62927a3b38f7Smrg	  esac # linkmode
62937a3b38f7Smrg	  continue
62947a3b38f7Smrg	  ;; # -L
62957a3b38f7Smrg	-R*)
62967a3b38f7Smrg	  if test "$pass" = link; then
62977a3b38f7Smrg	    func_stripname '-R' '' "$deplib"
6298862f5301Smrg	    func_resolve_sysroot "$func_stripname_result"
6299862f5301Smrg	    dir=$func_resolve_sysroot_result
63007a3b38f7Smrg	    # Make sure the xrpath contains only unique directories.
63017a3b38f7Smrg	    case "$xrpath " in
63027a3b38f7Smrg	    *" $dir "*) ;;
6303862f5301Smrg	    *) func_append xrpath " $dir" ;;
63047a3b38f7Smrg	    esac
63057a3b38f7Smrg	  fi
63067a3b38f7Smrg	  deplibs="$deplib $deplibs"
63077a3b38f7Smrg	  continue
63087a3b38f7Smrg	  ;;
6309862f5301Smrg	*.la)
6310862f5301Smrg	  func_resolve_sysroot "$deplib"
6311862f5301Smrg	  lib=$func_resolve_sysroot_result
6312862f5301Smrg	  ;;
63137a3b38f7Smrg	*.$libext)
63147a3b38f7Smrg	  if test "$pass" = conv; then
63157a3b38f7Smrg	    deplibs="$deplib $deplibs"
63167a3b38f7Smrg	    continue
63177a3b38f7Smrg	  fi
63187a3b38f7Smrg	  case $linkmode in
63197a3b38f7Smrg	  lib)
63207a3b38f7Smrg	    # Linking convenience modules into shared libraries is allowed,
63217a3b38f7Smrg	    # but linking other static libraries is non-portable.
63227a3b38f7Smrg	    case " $dlpreconveniencelibs " in
63237a3b38f7Smrg	    *" $deplib "*) ;;
63247a3b38f7Smrg	    *)
63257a3b38f7Smrg	      valid_a_lib=no
63267a3b38f7Smrg	      case $deplibs_check_method in
63277a3b38f7Smrg		match_pattern*)
63287a3b38f7Smrg		  set dummy $deplibs_check_method; shift
63297a3b38f7Smrg		  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
633044dda7b2Smrg		  if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
63317a3b38f7Smrg		    | $EGREP "$match_pattern_regex" > /dev/null; then
63327a3b38f7Smrg		    valid_a_lib=yes
63337a3b38f7Smrg		  fi
63347a3b38f7Smrg		;;
63357a3b38f7Smrg		pass_all)
63367a3b38f7Smrg		  valid_a_lib=yes
63377a3b38f7Smrg		;;
63387a3b38f7Smrg	      esac
63397a3b38f7Smrg	      if test "$valid_a_lib" != yes; then
634044dda7b2Smrg		echo
63417a3b38f7Smrg		$ECHO "*** Warning: Trying to link with static lib archive $deplib."
634244dda7b2Smrg		echo "*** I have the capability to make that library automatically link in when"
634344dda7b2Smrg		echo "*** you link to this library.  But I can only do this if you have a"
634444dda7b2Smrg		echo "*** shared version of the library, which you do not appear to have"
634544dda7b2Smrg		echo "*** because the file extensions .$libext of this argument makes me believe"
634644dda7b2Smrg		echo "*** that it is just a static archive that I should not use here."
63477a3b38f7Smrg	      else
634844dda7b2Smrg		echo
63497a3b38f7Smrg		$ECHO "*** Warning: Linking the shared library $output against the"
63507a3b38f7Smrg		$ECHO "*** static library $deplib is not portable!"
63517a3b38f7Smrg		deplibs="$deplib $deplibs"
63527a3b38f7Smrg	      fi
63537a3b38f7Smrg	      ;;
63547a3b38f7Smrg	    esac
63557a3b38f7Smrg	    continue
63567a3b38f7Smrg	    ;;
63577a3b38f7Smrg	  prog)
63587a3b38f7Smrg	    if test "$pass" != link; then
63597a3b38f7Smrg	      deplibs="$deplib $deplibs"
63607a3b38f7Smrg	    else
63617a3b38f7Smrg	      compile_deplibs="$deplib $compile_deplibs"
63627a3b38f7Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
63637a3b38f7Smrg	    fi
63647a3b38f7Smrg	    continue
63657a3b38f7Smrg	    ;;
63667a3b38f7Smrg	  esac # linkmode
63677a3b38f7Smrg	  ;; # *.$libext
63687a3b38f7Smrg	*.lo | *.$objext)
63697a3b38f7Smrg	  if test "$pass" = conv; then
63707a3b38f7Smrg	    deplibs="$deplib $deplibs"
63717a3b38f7Smrg	  elif test "$linkmode" = prog; then
63727a3b38f7Smrg	    if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
63737a3b38f7Smrg	      # If there is no dlopen support or we're linking statically,
63747a3b38f7Smrg	      # we need to preload.
6375862f5301Smrg	      func_append newdlprefiles " $deplib"
63767a3b38f7Smrg	      compile_deplibs="$deplib $compile_deplibs"
63777a3b38f7Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
63787a3b38f7Smrg	    else
6379862f5301Smrg	      func_append newdlfiles " $deplib"
63807a3b38f7Smrg	    fi
63817a3b38f7Smrg	  fi
63827a3b38f7Smrg	  continue
63837a3b38f7Smrg	  ;;
63847a3b38f7Smrg	%DEPLIBS%)
63857a3b38f7Smrg	  alldeplibs=yes
63867a3b38f7Smrg	  continue
63877a3b38f7Smrg	  ;;
63887a3b38f7Smrg	esac # case $deplib
63897a3b38f7Smrg
63907a3b38f7Smrg	if test "$found" = yes || test -f "$lib"; then :
63917a3b38f7Smrg	else
63927a3b38f7Smrg	  func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'"
63937a3b38f7Smrg	fi
63947a3b38f7Smrg
63957a3b38f7Smrg	# Check to see that this really is a libtool archive.
63967a3b38f7Smrg	func_lalib_unsafe_p "$lib" \
63977a3b38f7Smrg	  || func_fatal_error "\`$lib' is not a valid libtool archive"
63987a3b38f7Smrg
63997a3b38f7Smrg	func_dirname "$lib" "" "."
64007a3b38f7Smrg	ladir="$func_dirname_result"
64017a3b38f7Smrg
64027a3b38f7Smrg	dlname=
64037a3b38f7Smrg	dlopen=
64047a3b38f7Smrg	dlpreopen=
64057a3b38f7Smrg	libdir=
64067a3b38f7Smrg	library_names=
64077a3b38f7Smrg	old_library=
64087a3b38f7Smrg	inherited_linker_flags=
64097a3b38f7Smrg	# If the library was installed with an old release of libtool,
64107a3b38f7Smrg	# it will not redefine variables installed, or shouldnotlink
64117a3b38f7Smrg	installed=yes
64127a3b38f7Smrg	shouldnotlink=no
64137a3b38f7Smrg	avoidtemprpath=
64147a3b38f7Smrg
64157a3b38f7Smrg
64167a3b38f7Smrg	# Read the .la file
64177a3b38f7Smrg	func_source "$lib"
64187a3b38f7Smrg
64197a3b38f7Smrg	# Convert "-framework foo" to "foo.ltframework"
64207a3b38f7Smrg	if test -n "$inherited_linker_flags"; then
642144dda7b2Smrg	  tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
64227a3b38f7Smrg	  for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
64237a3b38f7Smrg	    case " $new_inherited_linker_flags " in
64247a3b38f7Smrg	      *" $tmp_inherited_linker_flag "*) ;;
6425862f5301Smrg	      *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";;
64267a3b38f7Smrg	    esac
64277a3b38f7Smrg	  done
64287a3b38f7Smrg	fi
642944dda7b2Smrg	dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
64307a3b38f7Smrg	if test "$linkmode,$pass" = "lib,link" ||
64317a3b38f7Smrg	   test "$linkmode,$pass" = "prog,scan" ||
64327a3b38f7Smrg	   { test "$linkmode" != prog && test "$linkmode" != lib; }; then
6433862f5301Smrg	  test -n "$dlopen" && func_append dlfiles " $dlopen"
6434862f5301Smrg	  test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen"
64357a3b38f7Smrg	fi
64367a3b38f7Smrg
64377a3b38f7Smrg	if test "$pass" = conv; then
64387a3b38f7Smrg	  # Only check for convenience libraries
64397a3b38f7Smrg	  deplibs="$lib $deplibs"
64407a3b38f7Smrg	  if test -z "$libdir"; then
64417a3b38f7Smrg	    if test -z "$old_library"; then
64427a3b38f7Smrg	      func_fatal_error "cannot find name of link library for \`$lib'"
64437a3b38f7Smrg	    fi
64447a3b38f7Smrg	    # It is a libtool convenience library, so add in its objects.
6445862f5301Smrg	    func_append convenience " $ladir/$objdir/$old_library"
6446862f5301Smrg	    func_append old_convenience " $ladir/$objdir/$old_library"
64477a3b38f7Smrg	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
64487a3b38f7Smrg	    func_fatal_error "\`$lib' is not a convenience library"
64497a3b38f7Smrg	  fi
64507a3b38f7Smrg	  tmp_libs=
64517a3b38f7Smrg	  for deplib in $dependency_libs; do
64527a3b38f7Smrg	    deplibs="$deplib $deplibs"
6453862f5301Smrg	    if $opt_preserve_dup_deps ; then
64547a3b38f7Smrg	      case "$tmp_libs " in
6455862f5301Smrg	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
64567a3b38f7Smrg	      esac
64577a3b38f7Smrg	    fi
6458862f5301Smrg	    func_append tmp_libs " $deplib"
64597a3b38f7Smrg	  done
64607a3b38f7Smrg	  continue
64617a3b38f7Smrg	fi # $pass = conv
64627a3b38f7Smrg
64637a3b38f7Smrg
64647a3b38f7Smrg	# Get the name of the library we link against.
64657a3b38f7Smrg	linklib=
6466862f5301Smrg	if test -n "$old_library" &&
6467862f5301Smrg	   { test "$prefer_static_libs" = yes ||
6468862f5301Smrg	     test "$prefer_static_libs,$installed" = "built,no"; }; then
6469862f5301Smrg	  linklib=$old_library
6470862f5301Smrg	else
6471862f5301Smrg	  for l in $old_library $library_names; do
6472862f5301Smrg	    linklib="$l"
6473862f5301Smrg	  done
6474862f5301Smrg	fi
64757a3b38f7Smrg	if test -z "$linklib"; then
64767a3b38f7Smrg	  func_fatal_error "cannot find name of link library for \`$lib'"
64777a3b38f7Smrg	fi
64787a3b38f7Smrg
64797a3b38f7Smrg	# This library was specified with -dlopen.
64807a3b38f7Smrg	if test "$pass" = dlopen; then
64817a3b38f7Smrg	  if test -z "$libdir"; then
64827a3b38f7Smrg	    func_fatal_error "cannot -dlopen a convenience library: \`$lib'"
64837a3b38f7Smrg	  fi
64847a3b38f7Smrg	  if test -z "$dlname" ||
64857a3b38f7Smrg	     test "$dlopen_support" != yes ||
64867a3b38f7Smrg	     test "$build_libtool_libs" = no; then
64877a3b38f7Smrg	    # If there is no dlname, no dlopen support or we're linking
64887a3b38f7Smrg	    # statically, we need to preload.  We also need to preload any
64897a3b38f7Smrg	    # dependent libraries so libltdl's deplib preloader doesn't
64907a3b38f7Smrg	    # bomb out in the load deplibs phase.
6491862f5301Smrg	    func_append dlprefiles " $lib $dependency_libs"
64927a3b38f7Smrg	  else
6493862f5301Smrg	    func_append newdlfiles " $lib"
64947a3b38f7Smrg	  fi
64957a3b38f7Smrg	  continue
64967a3b38f7Smrg	fi # $pass = dlopen
64977a3b38f7Smrg
64987a3b38f7Smrg	# We need an absolute path.
64997a3b38f7Smrg	case $ladir in
65007a3b38f7Smrg	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
65017a3b38f7Smrg	*)
65027a3b38f7Smrg	  abs_ladir=`cd "$ladir" && pwd`
65037a3b38f7Smrg	  if test -z "$abs_ladir"; then
65047a3b38f7Smrg	    func_warning "cannot determine absolute directory name of \`$ladir'"
65057a3b38f7Smrg	    func_warning "passing it literally to the linker, although it might fail"
65067a3b38f7Smrg	    abs_ladir="$ladir"
65077a3b38f7Smrg	  fi
65087a3b38f7Smrg	  ;;
65097a3b38f7Smrg	esac
65107a3b38f7Smrg	func_basename "$lib"
65117a3b38f7Smrg	laname="$func_basename_result"
65127a3b38f7Smrg
65137a3b38f7Smrg	# Find the relevant object directory and library name.
65147a3b38f7Smrg	if test "X$installed" = Xyes; then
6515862f5301Smrg	  if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
65167a3b38f7Smrg	    func_warning "library \`$lib' was moved."
65177a3b38f7Smrg	    dir="$ladir"
65187a3b38f7Smrg	    absdir="$abs_ladir"
65197a3b38f7Smrg	    libdir="$abs_ladir"
65207a3b38f7Smrg	  else
6521862f5301Smrg	    dir="$lt_sysroot$libdir"
6522862f5301Smrg	    absdir="$lt_sysroot$libdir"
65237a3b38f7Smrg	  fi
65247a3b38f7Smrg	  test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
65257a3b38f7Smrg	else
65267a3b38f7Smrg	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
65277a3b38f7Smrg	    dir="$ladir"
65287a3b38f7Smrg	    absdir="$abs_ladir"
65297a3b38f7Smrg	    # Remove this search path later
6530862f5301Smrg	    func_append notinst_path " $abs_ladir"
65317a3b38f7Smrg	  else
65327a3b38f7Smrg	    dir="$ladir/$objdir"
65337a3b38f7Smrg	    absdir="$abs_ladir/$objdir"
65347a3b38f7Smrg	    # Remove this search path later
6535862f5301Smrg	    func_append notinst_path " $abs_ladir"
65367a3b38f7Smrg	  fi
65377a3b38f7Smrg	fi # $installed = yes
65387a3b38f7Smrg	func_stripname 'lib' '.la' "$laname"
65397a3b38f7Smrg	name=$func_stripname_result
65407a3b38f7Smrg
65417a3b38f7Smrg	# This library was specified with -dlpreopen.
65427a3b38f7Smrg	if test "$pass" = dlpreopen; then
65437a3b38f7Smrg	  if test -z "$libdir" && test "$linkmode" = prog; then
65447a3b38f7Smrg	    func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'"
65457a3b38f7Smrg	  fi
6546862f5301Smrg	  case "$host" in
6547862f5301Smrg	    # special handling for platforms with PE-DLLs.
6548862f5301Smrg	    *cygwin* | *mingw* | *cegcc* )
6549862f5301Smrg	      # Linker will automatically link against shared library if both
6550862f5301Smrg	      # static and shared are present.  Therefore, ensure we extract
6551862f5301Smrg	      # symbols from the import library if a shared library is present
6552862f5301Smrg	      # (otherwise, the dlopen module name will be incorrect).  We do
6553862f5301Smrg	      # this by putting the import library name into $newdlprefiles.
6554862f5301Smrg	      # We recover the dlopen module name by 'saving' the la file
6555862f5301Smrg	      # name in a special purpose variable, and (later) extracting the
6556862f5301Smrg	      # dlname from the la file.
6557862f5301Smrg	      if test -n "$dlname"; then
6558862f5301Smrg	        func_tr_sh "$dir/$linklib"
6559862f5301Smrg	        eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname"
6560862f5301Smrg	        func_append newdlprefiles " $dir/$linklib"
6561862f5301Smrg	      else
6562862f5301Smrg	        func_append newdlprefiles " $dir/$old_library"
6563862f5301Smrg	        # Keep a list of preopened convenience libraries to check
6564862f5301Smrg	        # that they are being used correctly in the link pass.
6565862f5301Smrg	        test -z "$libdir" && \
6566862f5301Smrg	          func_append dlpreconveniencelibs " $dir/$old_library"
6567862f5301Smrg	      fi
6568862f5301Smrg	    ;;
6569862f5301Smrg	    * )
6570862f5301Smrg	      # Prefer using a static library (so that no silly _DYNAMIC symbols
6571862f5301Smrg	      # are required to link).
6572862f5301Smrg	      if test -n "$old_library"; then
6573862f5301Smrg	        func_append newdlprefiles " $dir/$old_library"
6574862f5301Smrg	        # Keep a list of preopened convenience libraries to check
6575862f5301Smrg	        # that they are being used correctly in the link pass.
6576862f5301Smrg	        test -z "$libdir" && \
6577862f5301Smrg	          func_append dlpreconveniencelibs " $dir/$old_library"
6578862f5301Smrg	      # Otherwise, use the dlname, so that lt_dlopen finds it.
6579862f5301Smrg	      elif test -n "$dlname"; then
6580862f5301Smrg	        func_append newdlprefiles " $dir/$dlname"
6581862f5301Smrg	      else
6582862f5301Smrg	        func_append newdlprefiles " $dir/$linklib"
6583862f5301Smrg	      fi
6584862f5301Smrg	    ;;
6585862f5301Smrg	  esac
65867a3b38f7Smrg	fi # $pass = dlpreopen
65877a3b38f7Smrg
65887a3b38f7Smrg	if test -z "$libdir"; then
65897a3b38f7Smrg	  # Link the convenience library
65907a3b38f7Smrg	  if test "$linkmode" = lib; then
65917a3b38f7Smrg	    deplibs="$dir/$old_library $deplibs"
65927a3b38f7Smrg	  elif test "$linkmode,$pass" = "prog,link"; then
65937a3b38f7Smrg	    compile_deplibs="$dir/$old_library $compile_deplibs"
65947a3b38f7Smrg	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
65957a3b38f7Smrg	  else
65967a3b38f7Smrg	    deplibs="$lib $deplibs" # used for prog,scan pass
65977a3b38f7Smrg	  fi
65987a3b38f7Smrg	  continue
65997a3b38f7Smrg	fi
66007a3b38f7Smrg
66017a3b38f7Smrg
66027a3b38f7Smrg	if test "$linkmode" = prog && test "$pass" != link; then
6603862f5301Smrg	  func_append newlib_search_path " $ladir"
66047a3b38f7Smrg	  deplibs="$lib $deplibs"
66057a3b38f7Smrg
66067a3b38f7Smrg	  linkalldeplibs=no
66077a3b38f7Smrg	  if test "$link_all_deplibs" != no || test -z "$library_names" ||
66087a3b38f7Smrg	     test "$build_libtool_libs" = no; then
66097a3b38f7Smrg	    linkalldeplibs=yes
66107a3b38f7Smrg	  fi
66117a3b38f7Smrg
66127a3b38f7Smrg	  tmp_libs=
66137a3b38f7Smrg	  for deplib in $dependency_libs; do
66147a3b38f7Smrg	    case $deplib in
66157a3b38f7Smrg	    -L*) func_stripname '-L' '' "$deplib"
6616862f5301Smrg	         func_resolve_sysroot "$func_stripname_result"
6617862f5301Smrg	         func_append newlib_search_path " $func_resolve_sysroot_result"
66187a3b38f7Smrg		 ;;
66197a3b38f7Smrg	    esac
66207a3b38f7Smrg	    # Need to link against all dependency_libs?
66217a3b38f7Smrg	    if test "$linkalldeplibs" = yes; then
66227a3b38f7Smrg	      deplibs="$deplib $deplibs"
66237a3b38f7Smrg	    else
66247a3b38f7Smrg	      # Need to hardcode shared library paths
66257a3b38f7Smrg	      # or/and link against static libraries
66267a3b38f7Smrg	      newdependency_libs="$deplib $newdependency_libs"
66277a3b38f7Smrg	    fi
6628862f5301Smrg	    if $opt_preserve_dup_deps ; then
66297a3b38f7Smrg	      case "$tmp_libs " in
6630862f5301Smrg	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
66317a3b38f7Smrg	      esac
66327a3b38f7Smrg	    fi
6633862f5301Smrg	    func_append tmp_libs " $deplib"
66347a3b38f7Smrg	  done # for deplib
66357a3b38f7Smrg	  continue
66367a3b38f7Smrg	fi # $linkmode = prog...
66377a3b38f7Smrg
66387a3b38f7Smrg	if test "$linkmode,$pass" = "prog,link"; then
66397a3b38f7Smrg	  if test -n "$library_names" &&
66407a3b38f7Smrg	     { { test "$prefer_static_libs" = no ||
66417a3b38f7Smrg	         test "$prefer_static_libs,$installed" = "built,yes"; } ||
66427a3b38f7Smrg	       test -z "$old_library"; }; then
66437a3b38f7Smrg	    # We need to hardcode the library path
66447a3b38f7Smrg	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
66457a3b38f7Smrg	      # Make sure the rpath contains only unique directories.
66467a3b38f7Smrg	      case "$temp_rpath:" in
66477a3b38f7Smrg	      *"$absdir:"*) ;;
6648862f5301Smrg	      *) func_append temp_rpath "$absdir:" ;;
66497a3b38f7Smrg	      esac
66507a3b38f7Smrg	    fi
66517a3b38f7Smrg
66527a3b38f7Smrg	    # Hardcode the library path.
66537a3b38f7Smrg	    # Skip directories that are in the system default run-time
66547a3b38f7Smrg	    # search path.
66557a3b38f7Smrg	    case " $sys_lib_dlsearch_path " in
66567a3b38f7Smrg	    *" $absdir "*) ;;
66577a3b38f7Smrg	    *)
66587a3b38f7Smrg	      case "$compile_rpath " in
66597a3b38f7Smrg	      *" $absdir "*) ;;
6660862f5301Smrg	      *) func_append compile_rpath " $absdir" ;;
66617a3b38f7Smrg	      esac
66627a3b38f7Smrg	      ;;
66637a3b38f7Smrg	    esac
66647a3b38f7Smrg	    case " $sys_lib_dlsearch_path " in
66657a3b38f7Smrg	    *" $libdir "*) ;;
66667a3b38f7Smrg	    *)
66677a3b38f7Smrg	      case "$finalize_rpath " in
66687a3b38f7Smrg	      *" $libdir "*) ;;
6669862f5301Smrg	      *) func_append finalize_rpath " $libdir" ;;
66707a3b38f7Smrg	      esac
66717a3b38f7Smrg	      ;;
66727a3b38f7Smrg	    esac
66737a3b38f7Smrg	  fi # $linkmode,$pass = prog,link...
66747a3b38f7Smrg
66757a3b38f7Smrg	  if test "$alldeplibs" = yes &&
66767a3b38f7Smrg	     { test "$deplibs_check_method" = pass_all ||
66777a3b38f7Smrg	       { test "$build_libtool_libs" = yes &&
66787a3b38f7Smrg		 test -n "$library_names"; }; }; then
66797a3b38f7Smrg	    # We only need to search for static libraries
66807a3b38f7Smrg	    continue
66817a3b38f7Smrg	  fi
66827a3b38f7Smrg	fi
66837a3b38f7Smrg
66847a3b38f7Smrg	link_static=no # Whether the deplib will be linked statically
66857a3b38f7Smrg	use_static_libs=$prefer_static_libs
66867a3b38f7Smrg	if test "$use_static_libs" = built && test "$installed" = yes; then
66877a3b38f7Smrg	  use_static_libs=no
66887a3b38f7Smrg	fi
66897a3b38f7Smrg	if test -n "$library_names" &&
66907a3b38f7Smrg	   { test "$use_static_libs" = no || test -z "$old_library"; }; then
66917a3b38f7Smrg	  case $host in
66927a3b38f7Smrg	  *cygwin* | *mingw* | *cegcc*)
66937a3b38f7Smrg	      # No point in relinking DLLs because paths are not encoded
6694862f5301Smrg	      func_append notinst_deplibs " $lib"
66957a3b38f7Smrg	      need_relink=no
66967a3b38f7Smrg	    ;;
66977a3b38f7Smrg	  *)
66987a3b38f7Smrg	    if test "$installed" = no; then
6699862f5301Smrg	      func_append notinst_deplibs " $lib"
67007a3b38f7Smrg	      need_relink=yes
67017a3b38f7Smrg	    fi
67027a3b38f7Smrg	    ;;
67037a3b38f7Smrg	  esac
67047a3b38f7Smrg	  # This is a shared library
67057a3b38f7Smrg
67067a3b38f7Smrg	  # Warn about portability, can't link against -module's on some
67077a3b38f7Smrg	  # systems (darwin).  Don't bleat about dlopened modules though!
67087a3b38f7Smrg	  dlopenmodule=""
67097a3b38f7Smrg	  for dlpremoduletest in $dlprefiles; do
67107a3b38f7Smrg	    if test "X$dlpremoduletest" = "X$lib"; then
67117a3b38f7Smrg	      dlopenmodule="$dlpremoduletest"
67127a3b38f7Smrg	      break
67137a3b38f7Smrg	    fi
67147a3b38f7Smrg	  done
67157a3b38f7Smrg	  if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then
671644dda7b2Smrg	    echo
67177a3b38f7Smrg	    if test "$linkmode" = prog; then
67187a3b38f7Smrg	      $ECHO "*** Warning: Linking the executable $output against the loadable module"
67197a3b38f7Smrg	    else
67207a3b38f7Smrg	      $ECHO "*** Warning: Linking the shared library $output against the loadable module"
67217a3b38f7Smrg	    fi
67227a3b38f7Smrg	    $ECHO "*** $linklib is not portable!"
67237a3b38f7Smrg	  fi
67247a3b38f7Smrg	  if test "$linkmode" = lib &&
67257a3b38f7Smrg	     test "$hardcode_into_libs" = yes; then
67267a3b38f7Smrg	    # Hardcode the library path.
67277a3b38f7Smrg	    # Skip directories that are in the system default run-time
67287a3b38f7Smrg	    # search path.
67297a3b38f7Smrg	    case " $sys_lib_dlsearch_path " in
67307a3b38f7Smrg	    *" $absdir "*) ;;
67317a3b38f7Smrg	    *)
67327a3b38f7Smrg	      case "$compile_rpath " in
67337a3b38f7Smrg	      *" $absdir "*) ;;
6734862f5301Smrg	      *) func_append compile_rpath " $absdir" ;;
67357a3b38f7Smrg	      esac
67367a3b38f7Smrg	      ;;
67377a3b38f7Smrg	    esac
67387a3b38f7Smrg	    case " $sys_lib_dlsearch_path " in
67397a3b38f7Smrg	    *" $libdir "*) ;;
67407a3b38f7Smrg	    *)
67417a3b38f7Smrg	      case "$finalize_rpath " in
67427a3b38f7Smrg	      *" $libdir "*) ;;
6743862f5301Smrg	      *) func_append finalize_rpath " $libdir" ;;
67447a3b38f7Smrg	      esac
67457a3b38f7Smrg	      ;;
67467a3b38f7Smrg	    esac
67477a3b38f7Smrg	  fi
67487a3b38f7Smrg
67497a3b38f7Smrg	  if test -n "$old_archive_from_expsyms_cmds"; then
67507a3b38f7Smrg	    # figure out the soname
67517a3b38f7Smrg	    set dummy $library_names
67527a3b38f7Smrg	    shift
67537a3b38f7Smrg	    realname="$1"
67547a3b38f7Smrg	    shift
67557a3b38f7Smrg	    libname=`eval "\\$ECHO \"$libname_spec\""`
67567a3b38f7Smrg	    # use dlname if we got it. it's perfectly good, no?
67577a3b38f7Smrg	    if test -n "$dlname"; then
67587a3b38f7Smrg	      soname="$dlname"
67597a3b38f7Smrg	    elif test -n "$soname_spec"; then
67607a3b38f7Smrg	      # bleh windows
67617a3b38f7Smrg	      case $host in
67627a3b38f7Smrg	      *cygwin* | mingw* | *cegcc*)
67637a3b38f7Smrg	        func_arith $current - $age
67647a3b38f7Smrg		major=$func_arith_result
67657a3b38f7Smrg		versuffix="-$major"
67667a3b38f7Smrg		;;
67677a3b38f7Smrg	      esac
67687a3b38f7Smrg	      eval soname=\"$soname_spec\"
67697a3b38f7Smrg	    else
67707a3b38f7Smrg	      soname="$realname"
67717a3b38f7Smrg	    fi
67727a3b38f7Smrg
67737a3b38f7Smrg	    # Make a new name for the extract_expsyms_cmds to use
67747a3b38f7Smrg	    soroot="$soname"
67757a3b38f7Smrg	    func_basename "$soroot"
67767a3b38f7Smrg	    soname="$func_basename_result"
67777a3b38f7Smrg	    func_stripname 'lib' '.dll' "$soname"
67787a3b38f7Smrg	    newlib=libimp-$func_stripname_result.a
67797a3b38f7Smrg
67807a3b38f7Smrg	    # If the library has no export list, then create one now
67817a3b38f7Smrg	    if test -f "$output_objdir/$soname-def"; then :
67827a3b38f7Smrg	    else
67837a3b38f7Smrg	      func_verbose "extracting exported symbol list from \`$soname'"
67847a3b38f7Smrg	      func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
67857a3b38f7Smrg	    fi
67867a3b38f7Smrg
67877a3b38f7Smrg	    # Create $newlib
67887a3b38f7Smrg	    if test -f "$output_objdir/$newlib"; then :; else
67897a3b38f7Smrg	      func_verbose "generating import library for \`$soname'"
67907a3b38f7Smrg	      func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
67917a3b38f7Smrg	    fi
67927a3b38f7Smrg	    # make sure the library variables are pointing to the new library
67937a3b38f7Smrg	    dir=$output_objdir
67947a3b38f7Smrg	    linklib=$newlib
67957a3b38f7Smrg	  fi # test -n "$old_archive_from_expsyms_cmds"
67967a3b38f7Smrg
6797862f5301Smrg	  if test "$linkmode" = prog || test "$opt_mode" != relink; then
67987a3b38f7Smrg	    add_shlibpath=
67997a3b38f7Smrg	    add_dir=
68007a3b38f7Smrg	    add=
68017a3b38f7Smrg	    lib_linked=yes
68027a3b38f7Smrg	    case $hardcode_action in
68037a3b38f7Smrg	    immediate | unsupported)
68047a3b38f7Smrg	      if test "$hardcode_direct" = no; then
68057a3b38f7Smrg		add="$dir/$linklib"
68067a3b38f7Smrg		case $host in
68077a3b38f7Smrg		  *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
68087a3b38f7Smrg		  *-*-sysv4*uw2*) add_dir="-L$dir" ;;
68097a3b38f7Smrg		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
68107a3b38f7Smrg		    *-*-unixware7*) add_dir="-L$dir" ;;
68117a3b38f7Smrg		  *-*-darwin* )
68127a3b38f7Smrg		    # if the lib is a (non-dlopened) module then we can not
68137a3b38f7Smrg		    # link against it, someone is ignoring the earlier warnings
68147a3b38f7Smrg		    if /usr/bin/file -L $add 2> /dev/null |
68157a3b38f7Smrg			 $GREP ": [^:]* bundle" >/dev/null ; then
68167a3b38f7Smrg		      if test "X$dlopenmodule" != "X$lib"; then
68177a3b38f7Smrg			$ECHO "*** Warning: lib $linklib is a module, not a shared library"
68187a3b38f7Smrg			if test -z "$old_library" ; then
681944dda7b2Smrg			  echo
682044dda7b2Smrg			  echo "*** And there doesn't seem to be a static archive available"
682144dda7b2Smrg			  echo "*** The link will probably fail, sorry"
68227a3b38f7Smrg			else
68237a3b38f7Smrg			  add="$dir/$old_library"
68247a3b38f7Smrg			fi
68257a3b38f7Smrg		      elif test -n "$old_library"; then
68267a3b38f7Smrg			add="$dir/$old_library"
68277a3b38f7Smrg		      fi
68287a3b38f7Smrg		    fi
68297a3b38f7Smrg		esac
68307a3b38f7Smrg	      elif test "$hardcode_minus_L" = no; then
68317a3b38f7Smrg		case $host in
68327a3b38f7Smrg		*-*-sunos*) add_shlibpath="$dir" ;;
68337a3b38f7Smrg		esac
68347a3b38f7Smrg		add_dir="-L$dir"
68357a3b38f7Smrg		add="-l$name"
68367a3b38f7Smrg	      elif test "$hardcode_shlibpath_var" = no; then
68377a3b38f7Smrg		add_shlibpath="$dir"
68387a3b38f7Smrg		add="-l$name"
68397a3b38f7Smrg	      else
68407a3b38f7Smrg		lib_linked=no
68417a3b38f7Smrg	      fi
68427a3b38f7Smrg	      ;;
68437a3b38f7Smrg	    relink)
68447a3b38f7Smrg	      if test "$hardcode_direct" = yes &&
68457a3b38f7Smrg	         test "$hardcode_direct_absolute" = no; then
68467a3b38f7Smrg		add="$dir/$linklib"
68477a3b38f7Smrg	      elif test "$hardcode_minus_L" = yes; then
6848fc544a13Smrg		add_dir="-L$absdir"
68497a3b38f7Smrg		# Try looking first in the location we're being installed to.
68507a3b38f7Smrg		if test -n "$inst_prefix_dir"; then
68517a3b38f7Smrg		  case $libdir in
68527a3b38f7Smrg		    [\\/]*)
6853862f5301Smrg		      func_append add_dir " -L$inst_prefix_dir$libdir"
68547a3b38f7Smrg		      ;;
68557a3b38f7Smrg		  esac
68567a3b38f7Smrg		fi
68577a3b38f7Smrg		add="-l$name"
68587a3b38f7Smrg	      elif test "$hardcode_shlibpath_var" = yes; then
68597a3b38f7Smrg		add_shlibpath="$dir"
68607a3b38f7Smrg		add="-l$name"
68617a3b38f7Smrg	      else
68627a3b38f7Smrg		lib_linked=no
68637a3b38f7Smrg	      fi
68647a3b38f7Smrg	      ;;
68657a3b38f7Smrg	    *) lib_linked=no ;;
68667a3b38f7Smrg	    esac
68677a3b38f7Smrg
68687a3b38f7Smrg	    if test "$lib_linked" != yes; then
68697a3b38f7Smrg	      func_fatal_configuration "unsupported hardcode properties"
68707a3b38f7Smrg	    fi
68717a3b38f7Smrg
68727a3b38f7Smrg	    if test -n "$add_shlibpath"; then
68737a3b38f7Smrg	      case :$compile_shlibpath: in
68747a3b38f7Smrg	      *":$add_shlibpath:"*) ;;
6875862f5301Smrg	      *) func_append compile_shlibpath "$add_shlibpath:" ;;
68767a3b38f7Smrg	      esac
68777a3b38f7Smrg	    fi
68787a3b38f7Smrg	    if test "$linkmode" = prog; then
68797a3b38f7Smrg	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
68807a3b38f7Smrg	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
68817a3b38f7Smrg	    else
68827a3b38f7Smrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
68837a3b38f7Smrg	      test -n "$add" && deplibs="$add $deplibs"
68847a3b38f7Smrg	      if test "$hardcode_direct" != yes &&
68857a3b38f7Smrg		 test "$hardcode_minus_L" != yes &&
68867a3b38f7Smrg		 test "$hardcode_shlibpath_var" = yes; then
68877a3b38f7Smrg		case :$finalize_shlibpath: in
68887a3b38f7Smrg		*":$libdir:"*) ;;
6889862f5301Smrg		*) func_append finalize_shlibpath "$libdir:" ;;
68907a3b38f7Smrg		esac
68917a3b38f7Smrg	      fi
68927a3b38f7Smrg	    fi
68937a3b38f7Smrg	  fi
68947a3b38f7Smrg
6895862f5301Smrg	  if test "$linkmode" = prog || test "$opt_mode" = relink; then
68967a3b38f7Smrg	    add_shlibpath=
68977a3b38f7Smrg	    add_dir=
68987a3b38f7Smrg	    add=
68997a3b38f7Smrg	    # Finalize command for both is simple: just hardcode it.
69007a3b38f7Smrg	    if test "$hardcode_direct" = yes &&
69017a3b38f7Smrg	       test "$hardcode_direct_absolute" = no; then
69027a3b38f7Smrg	      add="$libdir/$linklib"
69037a3b38f7Smrg	    elif test "$hardcode_minus_L" = yes; then
69047a3b38f7Smrg	      add_dir="-L$libdir"
69057a3b38f7Smrg	      add="-l$name"
69067a3b38f7Smrg	    elif test "$hardcode_shlibpath_var" = yes; then
69077a3b38f7Smrg	      case :$finalize_shlibpath: in
69087a3b38f7Smrg	      *":$libdir:"*) ;;
6909862f5301Smrg	      *) func_append finalize_shlibpath "$libdir:" ;;
69107a3b38f7Smrg	      esac
69117a3b38f7Smrg	      add="-l$name"
69127a3b38f7Smrg	    elif test "$hardcode_automatic" = yes; then
69137a3b38f7Smrg	      if test -n "$inst_prefix_dir" &&
69147a3b38f7Smrg		 test -f "$inst_prefix_dir$libdir/$linklib" ; then
69157a3b38f7Smrg		add="$inst_prefix_dir$libdir/$linklib"
69167a3b38f7Smrg	      else
69177a3b38f7Smrg		add="$libdir/$linklib"
69187a3b38f7Smrg	      fi
69197a3b38f7Smrg	    else
69207a3b38f7Smrg	      # We cannot seem to hardcode it, guess we'll fake it.
69217a3b38f7Smrg	      add_dir="-L$libdir"
69227a3b38f7Smrg	      # Try looking first in the location we're being installed to.
69237a3b38f7Smrg	      if test -n "$inst_prefix_dir"; then
69247a3b38f7Smrg		case $libdir in
69257a3b38f7Smrg		  [\\/]*)
6926862f5301Smrg		    func_append add_dir " -L$inst_prefix_dir$libdir"
69277a3b38f7Smrg		    ;;
69287a3b38f7Smrg		esac
69297a3b38f7Smrg	      fi
69307a3b38f7Smrg	      add="-l$name"
69317a3b38f7Smrg	    fi
69327a3b38f7Smrg
69337a3b38f7Smrg	    if test "$linkmode" = prog; then
69347a3b38f7Smrg	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
69357a3b38f7Smrg	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
69367a3b38f7Smrg	    else
69377a3b38f7Smrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
69387a3b38f7Smrg	      test -n "$add" && deplibs="$add $deplibs"
69397a3b38f7Smrg	    fi
69407a3b38f7Smrg	  fi
69417a3b38f7Smrg	elif test "$linkmode" = prog; then
69427a3b38f7Smrg	  # Here we assume that one of hardcode_direct or hardcode_minus_L
69437a3b38f7Smrg	  # is not unsupported.  This is valid on all known static and
69447a3b38f7Smrg	  # shared platforms.
69457a3b38f7Smrg	  if test "$hardcode_direct" != unsupported; then
69467a3b38f7Smrg	    test -n "$old_library" && linklib="$old_library"
69477a3b38f7Smrg	    compile_deplibs="$dir/$linklib $compile_deplibs"
69487a3b38f7Smrg	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
69497a3b38f7Smrg	  else
69507a3b38f7Smrg	    compile_deplibs="-l$name -L$dir $compile_deplibs"
69517a3b38f7Smrg	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
69527a3b38f7Smrg	  fi
69537a3b38f7Smrg	elif test "$build_libtool_libs" = yes; then
69547a3b38f7Smrg	  # Not a shared library
69557a3b38f7Smrg	  if test "$deplibs_check_method" != pass_all; then
69567a3b38f7Smrg	    # We're trying link a shared library against a static one
69577a3b38f7Smrg	    # but the system doesn't support it.
69587a3b38f7Smrg
69597a3b38f7Smrg	    # Just print a warning and add the library to dependency_libs so
69607a3b38f7Smrg	    # that the program can be linked against the static library.
696144dda7b2Smrg	    echo
69627a3b38f7Smrg	    $ECHO "*** Warning: This system can not link to static lib archive $lib."
696344dda7b2Smrg	    echo "*** I have the capability to make that library automatically link in when"
696444dda7b2Smrg	    echo "*** you link to this library.  But I can only do this if you have a"
696544dda7b2Smrg	    echo "*** shared version of the library, which you do not appear to have."
69667a3b38f7Smrg	    if test "$module" = yes; then
696744dda7b2Smrg	      echo "*** But as you try to build a module library, libtool will still create "
696844dda7b2Smrg	      echo "*** a static module, that should work as long as the dlopening application"
696944dda7b2Smrg	      echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
69707a3b38f7Smrg	      if test -z "$global_symbol_pipe"; then
697144dda7b2Smrg		echo
697244dda7b2Smrg		echo "*** However, this would only work if libtool was able to extract symbol"
697344dda7b2Smrg		echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
697444dda7b2Smrg		echo "*** not find such a program.  So, this module is probably useless."
697544dda7b2Smrg		echo "*** \`nm' from GNU binutils and a full rebuild may help."
69767a3b38f7Smrg	      fi
69777a3b38f7Smrg	      if test "$build_old_libs" = no; then
69787a3b38f7Smrg		build_libtool_libs=module
69797a3b38f7Smrg		build_old_libs=yes
69807a3b38f7Smrg	      else
69817a3b38f7Smrg		build_libtool_libs=no
69827a3b38f7Smrg	      fi
69837a3b38f7Smrg	    fi
69847a3b38f7Smrg	  else
69857a3b38f7Smrg	    deplibs="$dir/$old_library $deplibs"
69867a3b38f7Smrg	    link_static=yes
69877a3b38f7Smrg	  fi
69887a3b38f7Smrg	fi # link shared/static library?
69897a3b38f7Smrg
69907a3b38f7Smrg	if test "$linkmode" = lib; then
69917a3b38f7Smrg	  if test -n "$dependency_libs" &&
69927a3b38f7Smrg	     { test "$hardcode_into_libs" != yes ||
69937a3b38f7Smrg	       test "$build_old_libs" = yes ||
69947a3b38f7Smrg	       test "$link_static" = yes; }; then
69957a3b38f7Smrg	    # Extract -R from dependency_libs
69967a3b38f7Smrg	    temp_deplibs=
69977a3b38f7Smrg	    for libdir in $dependency_libs; do
69987a3b38f7Smrg	      case $libdir in
69997a3b38f7Smrg	      -R*) func_stripname '-R' '' "$libdir"
70007a3b38f7Smrg	           temp_xrpath=$func_stripname_result
70017a3b38f7Smrg		   case " $xrpath " in
70027a3b38f7Smrg		   *" $temp_xrpath "*) ;;
7003862f5301Smrg		   *) func_append xrpath " $temp_xrpath";;
70047a3b38f7Smrg		   esac;;
7005862f5301Smrg	      *) func_append temp_deplibs " $libdir";;
70067a3b38f7Smrg	      esac
70077a3b38f7Smrg	    done
70087a3b38f7Smrg	    dependency_libs="$temp_deplibs"
70097a3b38f7Smrg	  fi
70107a3b38f7Smrg
7011862f5301Smrg	  func_append newlib_search_path " $absdir"
70127a3b38f7Smrg	  # Link against this library
70137a3b38f7Smrg	  test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
70147a3b38f7Smrg	  # ... and its dependency_libs
70157a3b38f7Smrg	  tmp_libs=
70167a3b38f7Smrg	  for deplib in $dependency_libs; do
70177a3b38f7Smrg	    newdependency_libs="$deplib $newdependency_libs"
7018862f5301Smrg	    case $deplib in
7019862f5301Smrg              -L*) func_stripname '-L' '' "$deplib"
7020862f5301Smrg                   func_resolve_sysroot "$func_stripname_result";;
7021862f5301Smrg              *) func_resolve_sysroot "$deplib" ;;
7022862f5301Smrg            esac
7023862f5301Smrg	    if $opt_preserve_dup_deps ; then
70247a3b38f7Smrg	      case "$tmp_libs " in
7025862f5301Smrg	      *" $func_resolve_sysroot_result "*)
7026862f5301Smrg                func_append specialdeplibs " $func_resolve_sysroot_result" ;;
70277a3b38f7Smrg	      esac
70287a3b38f7Smrg	    fi
7029862f5301Smrg	    func_append tmp_libs " $func_resolve_sysroot_result"
70307a3b38f7Smrg	  done
70317a3b38f7Smrg
70327a3b38f7Smrg	  if test "$link_all_deplibs" != no; then
70337a3b38f7Smrg	    # Add the search paths of all dependency libraries
70347a3b38f7Smrg	    for deplib in $dependency_libs; do
703544dda7b2Smrg	      path=
70367a3b38f7Smrg	      case $deplib in
70377a3b38f7Smrg	      -L*) path="$deplib" ;;
70387a3b38f7Smrg	      *.la)
7039862f5301Smrg	        func_resolve_sysroot "$deplib"
7040862f5301Smrg	        deplib=$func_resolve_sysroot_result
70417a3b38f7Smrg	        func_dirname "$deplib" "" "."
7042862f5301Smrg		dir=$func_dirname_result
70437a3b38f7Smrg		# We need an absolute path.
70447a3b38f7Smrg		case $dir in
70457a3b38f7Smrg		[\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
70467a3b38f7Smrg		*)
70477a3b38f7Smrg		  absdir=`cd "$dir" && pwd`
70487a3b38f7Smrg		  if test -z "$absdir"; then
70497a3b38f7Smrg		    func_warning "cannot determine absolute directory name of \`$dir'"
70507a3b38f7Smrg		    absdir="$dir"
70517a3b38f7Smrg		  fi
70527a3b38f7Smrg		  ;;
70537a3b38f7Smrg		esac
70547a3b38f7Smrg		if $GREP "^installed=no" $deplib > /dev/null; then
70557a3b38f7Smrg		case $host in
70567a3b38f7Smrg		*-*-darwin*)
70577a3b38f7Smrg		  depdepl=
70587a3b38f7Smrg		  eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
70597a3b38f7Smrg		  if test -n "$deplibrary_names" ; then
70607a3b38f7Smrg		    for tmp in $deplibrary_names ; do
70617a3b38f7Smrg		      depdepl=$tmp
70627a3b38f7Smrg		    done
70637a3b38f7Smrg		    if test -f "$absdir/$objdir/$depdepl" ; then
70647a3b38f7Smrg		      depdepl="$absdir/$objdir/$depdepl"
70657a3b38f7Smrg		      darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
70667a3b38f7Smrg                      if test -z "$darwin_install_name"; then
70677a3b38f7Smrg                          darwin_install_name=`${OTOOL64} -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
70687a3b38f7Smrg                      fi
7069862f5301Smrg		      func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}"
7070862f5301Smrg		      func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}"
70717a3b38f7Smrg		      path=
70727a3b38f7Smrg		    fi
70737a3b38f7Smrg		  fi
70747a3b38f7Smrg		  ;;
70757a3b38f7Smrg		*)
70767a3b38f7Smrg		  path="-L$absdir/$objdir"
70777a3b38f7Smrg		  ;;
70787a3b38f7Smrg		esac
70797a3b38f7Smrg		else
70807a3b38f7Smrg		  eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
70817a3b38f7Smrg		  test -z "$libdir" && \
70827a3b38f7Smrg		    func_fatal_error "\`$deplib' is not a valid libtool archive"
70837a3b38f7Smrg		  test "$absdir" != "$libdir" && \
70847a3b38f7Smrg		    func_warning "\`$deplib' seems to be moved"
70857a3b38f7Smrg
70867a3b38f7Smrg		  path="-L$absdir"
70877a3b38f7Smrg		fi
70887a3b38f7Smrg		;;
70897a3b38f7Smrg	      esac
70907a3b38f7Smrg	      case " $deplibs " in
70917a3b38f7Smrg	      *" $path "*) ;;
70927a3b38f7Smrg	      *) deplibs="$path $deplibs" ;;
70937a3b38f7Smrg	      esac
70947a3b38f7Smrg	    done
70957a3b38f7Smrg	  fi # link_all_deplibs != no
70967a3b38f7Smrg	fi # linkmode = lib
70977a3b38f7Smrg      done # for deplib in $libs
70987a3b38f7Smrg      if test "$pass" = link; then
70997a3b38f7Smrg	if test "$linkmode" = "prog"; then
71007a3b38f7Smrg	  compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
71017a3b38f7Smrg	  finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
71027a3b38f7Smrg	else
710344dda7b2Smrg	  compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
71047a3b38f7Smrg	fi
71057a3b38f7Smrg      fi
71067a3b38f7Smrg      dependency_libs="$newdependency_libs"
71077a3b38f7Smrg      if test "$pass" = dlpreopen; then
71087a3b38f7Smrg	# Link the dlpreopened libraries before other libraries
71097a3b38f7Smrg	for deplib in $save_deplibs; do
71107a3b38f7Smrg	  deplibs="$deplib $deplibs"
71117a3b38f7Smrg	done
71127a3b38f7Smrg      fi
71137a3b38f7Smrg      if test "$pass" != dlopen; then
71147a3b38f7Smrg	if test "$pass" != conv; then
71157a3b38f7Smrg	  # Make sure lib_search_path contains only unique directories.
71167a3b38f7Smrg	  lib_search_path=
71177a3b38f7Smrg	  for dir in $newlib_search_path; do
71187a3b38f7Smrg	    case "$lib_search_path " in
71197a3b38f7Smrg	    *" $dir "*) ;;
7120862f5301Smrg	    *) func_append lib_search_path " $dir" ;;
71217a3b38f7Smrg	    esac
71227a3b38f7Smrg	  done
71237a3b38f7Smrg	  newlib_search_path=
71247a3b38f7Smrg	fi
71257a3b38f7Smrg
71267a3b38f7Smrg	if test "$linkmode,$pass" != "prog,link"; then
71277a3b38f7Smrg	  vars="deplibs"
71287a3b38f7Smrg	else
71297a3b38f7Smrg	  vars="compile_deplibs finalize_deplibs"
71307a3b38f7Smrg	fi
71317a3b38f7Smrg	for var in $vars dependency_libs; do
71327a3b38f7Smrg	  # Add libraries to $var in reverse order
71337a3b38f7Smrg	  eval tmp_libs=\"\$$var\"
71347a3b38f7Smrg	  new_libs=
71357a3b38f7Smrg	  for deplib in $tmp_libs; do
71367a3b38f7Smrg	    # FIXME: Pedantically, this is the right thing to do, so
71377a3b38f7Smrg	    #        that some nasty dependency loop isn't accidentally
71387a3b38f7Smrg	    #        broken:
71397a3b38f7Smrg	    #new_libs="$deplib $new_libs"
71407a3b38f7Smrg	    # Pragmatically, this seems to cause very few problems in
71417a3b38f7Smrg	    # practice:
71427a3b38f7Smrg	    case $deplib in
71437a3b38f7Smrg	    -L*) new_libs="$deplib $new_libs" ;;
71447a3b38f7Smrg	    -R*) ;;
71457a3b38f7Smrg	    *)
71467a3b38f7Smrg	      # And here is the reason: when a library appears more
71477a3b38f7Smrg	      # than once as an explicit dependence of a library, or
71487a3b38f7Smrg	      # is implicitly linked in more than once by the
71497a3b38f7Smrg	      # compiler, it is considered special, and multiple
71507a3b38f7Smrg	      # occurrences thereof are not removed.  Compare this
71517a3b38f7Smrg	      # with having the same library being listed as a
71527a3b38f7Smrg	      # dependency of multiple other libraries: in this case,
71537a3b38f7Smrg	      # we know (pedantically, we assume) the library does not
71547a3b38f7Smrg	      # need to be listed more than once, so we keep only the
71557a3b38f7Smrg	      # last copy.  This is not always right, but it is rare
71567a3b38f7Smrg	      # enough that we require users that really mean to play
71577a3b38f7Smrg	      # such unportable linking tricks to link the library
71587a3b38f7Smrg	      # using -Wl,-lname, so that libtool does not consider it
71597a3b38f7Smrg	      # for duplicate removal.
71607a3b38f7Smrg	      case " $specialdeplibs " in
71617a3b38f7Smrg	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
71627a3b38f7Smrg	      *)
71637a3b38f7Smrg		case " $new_libs " in
71647a3b38f7Smrg		*" $deplib "*) ;;
71657a3b38f7Smrg		*) new_libs="$deplib $new_libs" ;;
71667a3b38f7Smrg		esac
71677a3b38f7Smrg		;;
71687a3b38f7Smrg	      esac
71697a3b38f7Smrg	      ;;
71707a3b38f7Smrg	    esac
71717a3b38f7Smrg	  done
71727a3b38f7Smrg	  tmp_libs=
71737a3b38f7Smrg	  for deplib in $new_libs; do
71747a3b38f7Smrg	    case $deplib in
71757a3b38f7Smrg	    -L*)
71767a3b38f7Smrg	      case " $tmp_libs " in
71777a3b38f7Smrg	      *" $deplib "*) ;;
7178862f5301Smrg	      *) func_append tmp_libs " $deplib" ;;
71797a3b38f7Smrg	      esac
71807a3b38f7Smrg	      ;;
7181862f5301Smrg	    *) func_append tmp_libs " $deplib" ;;
71827a3b38f7Smrg	    esac
71837a3b38f7Smrg	  done
71847a3b38f7Smrg	  eval $var=\"$tmp_libs\"
71857a3b38f7Smrg	done # for var
71867a3b38f7Smrg      fi
71877a3b38f7Smrg      # Last step: remove runtime libs from dependency_libs
71887a3b38f7Smrg      # (they stay in deplibs)
71897a3b38f7Smrg      tmp_libs=
71907a3b38f7Smrg      for i in $dependency_libs ; do
71917a3b38f7Smrg	case " $predeps $postdeps $compiler_lib_search_path " in
71927a3b38f7Smrg	*" $i "*)
71937a3b38f7Smrg	  i=""
71947a3b38f7Smrg	  ;;
71957a3b38f7Smrg	esac
71967a3b38f7Smrg	if test -n "$i" ; then
7197862f5301Smrg	  func_append tmp_libs " $i"
71987a3b38f7Smrg	fi
71997a3b38f7Smrg      done
72007a3b38f7Smrg      dependency_libs=$tmp_libs
72017a3b38f7Smrg    done # for pass
72027a3b38f7Smrg    if test "$linkmode" = prog; then
72037a3b38f7Smrg      dlfiles="$newdlfiles"
72047a3b38f7Smrg    fi
72057a3b38f7Smrg    if test "$linkmode" = prog || test "$linkmode" = lib; then
72067a3b38f7Smrg      dlprefiles="$newdlprefiles"
72077a3b38f7Smrg    fi
72087a3b38f7Smrg
72097a3b38f7Smrg    case $linkmode in
72107a3b38f7Smrg    oldlib)
72117a3b38f7Smrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
72127a3b38f7Smrg	func_warning "\`-dlopen' is ignored for archives"
72137a3b38f7Smrg      fi
72147a3b38f7Smrg
72157a3b38f7Smrg      case " $deplibs" in
72167a3b38f7Smrg      *\ -l* | *\ -L*)
72177a3b38f7Smrg	func_warning "\`-l' and \`-L' are ignored for archives" ;;
72187a3b38f7Smrg      esac
72197a3b38f7Smrg
72207a3b38f7Smrg      test -n "$rpath" && \
72217a3b38f7Smrg	func_warning "\`-rpath' is ignored for archives"
72227a3b38f7Smrg
72237a3b38f7Smrg      test -n "$xrpath" && \
72247a3b38f7Smrg	func_warning "\`-R' is ignored for archives"
72257a3b38f7Smrg
72267a3b38f7Smrg      test -n "$vinfo" && \
72277a3b38f7Smrg	func_warning "\`-version-info/-version-number' is ignored for archives"
72287a3b38f7Smrg
72297a3b38f7Smrg      test -n "$release" && \
72307a3b38f7Smrg	func_warning "\`-release' is ignored for archives"
72317a3b38f7Smrg
72327a3b38f7Smrg      test -n "$export_symbols$export_symbols_regex" && \
72337a3b38f7Smrg	func_warning "\`-export-symbols' is ignored for archives"
72347a3b38f7Smrg
72357a3b38f7Smrg      # Now set the variables for building old libraries.
72367a3b38f7Smrg      build_libtool_libs=no
72377a3b38f7Smrg      oldlibs="$output"
7238862f5301Smrg      func_append objs "$old_deplibs"
72397a3b38f7Smrg      ;;
72407a3b38f7Smrg
72417a3b38f7Smrg    lib)
72427a3b38f7Smrg      # Make sure we only generate libraries of the form `libNAME.la'.
72437a3b38f7Smrg      case $outputname in
72447a3b38f7Smrg      lib*)
72457a3b38f7Smrg	func_stripname 'lib' '.la' "$outputname"
72467a3b38f7Smrg	name=$func_stripname_result
72477a3b38f7Smrg	eval shared_ext=\"$shrext_cmds\"
72487a3b38f7Smrg	eval libname=\"$libname_spec\"
72497a3b38f7Smrg	;;
72507a3b38f7Smrg      *)
72517a3b38f7Smrg	test "$module" = no && \
72527a3b38f7Smrg	  func_fatal_help "libtool library \`$output' must begin with \`lib'"
72537a3b38f7Smrg
72547a3b38f7Smrg	if test "$need_lib_prefix" != no; then
72557a3b38f7Smrg	  # Add the "lib" prefix for modules if required
72567a3b38f7Smrg	  func_stripname '' '.la' "$outputname"
72577a3b38f7Smrg	  name=$func_stripname_result
72587a3b38f7Smrg	  eval shared_ext=\"$shrext_cmds\"
72597a3b38f7Smrg	  eval libname=\"$libname_spec\"
72607a3b38f7Smrg	else
72617a3b38f7Smrg	  func_stripname '' '.la' "$outputname"
72627a3b38f7Smrg	  libname=$func_stripname_result
72637a3b38f7Smrg	fi
72647a3b38f7Smrg	;;
72657a3b38f7Smrg      esac
72667a3b38f7Smrg
72677a3b38f7Smrg      if test -n "$objs"; then
72687a3b38f7Smrg	if test "$deplibs_check_method" != pass_all; then
72697a3b38f7Smrg	  func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs"
72707a3b38f7Smrg	else
727144dda7b2Smrg	  echo
72727a3b38f7Smrg	  $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
72737a3b38f7Smrg	  $ECHO "*** objects $objs is not portable!"
7274862f5301Smrg	  func_append libobjs " $objs"
72757a3b38f7Smrg	fi
72767a3b38f7Smrg      fi
72777a3b38f7Smrg
72787a3b38f7Smrg      test "$dlself" != no && \
72797a3b38f7Smrg	func_warning "\`-dlopen self' is ignored for libtool libraries"
72807a3b38f7Smrg
72817a3b38f7Smrg      set dummy $rpath
72827a3b38f7Smrg      shift
72837a3b38f7Smrg      test "$#" -gt 1 && \
72847a3b38f7Smrg	func_warning "ignoring multiple \`-rpath's for a libtool library"
72857a3b38f7Smrg
72867a3b38f7Smrg      install_libdir="$1"
72877a3b38f7Smrg
72887a3b38f7Smrg      oldlibs=
72897a3b38f7Smrg      if test -z "$rpath"; then
72907a3b38f7Smrg	if test "$build_libtool_libs" = yes; then
72917a3b38f7Smrg	  # Building a libtool convenience library.
72927a3b38f7Smrg	  # Some compilers have problems with a `.al' extension so
72937a3b38f7Smrg	  # convenience libraries should have the same extension an
72947a3b38f7Smrg	  # archive normally would.
72957a3b38f7Smrg	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
72967a3b38f7Smrg	  build_libtool_libs=convenience
72977a3b38f7Smrg	  build_old_libs=yes
72987a3b38f7Smrg	fi
72997a3b38f7Smrg
73007a3b38f7Smrg	test -n "$vinfo" && \
73017a3b38f7Smrg	  func_warning "\`-version-info/-version-number' is ignored for convenience libraries"
73027a3b38f7Smrg
73037a3b38f7Smrg	test -n "$release" && \
73047a3b38f7Smrg	  func_warning "\`-release' is ignored for convenience libraries"
73057a3b38f7Smrg      else
73067a3b38f7Smrg
73077a3b38f7Smrg	# Parse the version information argument.
73087a3b38f7Smrg	save_ifs="$IFS"; IFS=':'
73097a3b38f7Smrg	set dummy $vinfo 0 0 0
73107a3b38f7Smrg	shift
73117a3b38f7Smrg	IFS="$save_ifs"
73127a3b38f7Smrg
73137a3b38f7Smrg	test -n "$7" && \
73147a3b38f7Smrg	  func_fatal_help "too many parameters to \`-version-info'"
73157a3b38f7Smrg
73167a3b38f7Smrg	# convert absolute version numbers to libtool ages
73177a3b38f7Smrg	# this retains compatibility with .la files and attempts
73187a3b38f7Smrg	# to make the code below a bit more comprehensible
73197a3b38f7Smrg
73207a3b38f7Smrg	case $vinfo_number in
73217a3b38f7Smrg	yes)
73227a3b38f7Smrg	  number_major="$1"
73237a3b38f7Smrg	  number_minor="$2"
73247a3b38f7Smrg	  number_revision="$3"
73257a3b38f7Smrg	  #
73267a3b38f7Smrg	  # There are really only two kinds -- those that
73277a3b38f7Smrg	  # use the current revision as the major version
73287a3b38f7Smrg	  # and those that subtract age and use age as
73297a3b38f7Smrg	  # a minor version.  But, then there is irix
73307a3b38f7Smrg	  # which has an extra 1 added just for fun
73317a3b38f7Smrg	  #
73327a3b38f7Smrg	  case $version_type in
7333fc544a13Smrg	  # correct linux to gnu/linux during the next big refactor
73347a3b38f7Smrg	  darwin|linux|osf|windows|none)
73357a3b38f7Smrg	    func_arith $number_major + $number_minor
73367a3b38f7Smrg	    current=$func_arith_result
73377a3b38f7Smrg	    age="$number_minor"
73387a3b38f7Smrg	    revision="$number_revision"
73397a3b38f7Smrg	    ;;
734044dda7b2Smrg	  freebsd-aout|freebsd-elf|qnx|sunos)
73417a3b38f7Smrg	    current="$number_major"
73427a3b38f7Smrg	    revision="$number_minor"
73437a3b38f7Smrg	    age="0"
73447a3b38f7Smrg	    ;;
73457a3b38f7Smrg	  irix|nonstopux)
73467a3b38f7Smrg	    func_arith $number_major + $number_minor
73477a3b38f7Smrg	    current=$func_arith_result
73487a3b38f7Smrg	    age="$number_minor"
73497a3b38f7Smrg	    revision="$number_minor"
73507a3b38f7Smrg	    lt_irix_increment=no
73517a3b38f7Smrg	    ;;
73527a3b38f7Smrg	  esac
73537a3b38f7Smrg	  ;;
73547a3b38f7Smrg	no)
73557a3b38f7Smrg	  current="$1"
73567a3b38f7Smrg	  revision="$2"
73577a3b38f7Smrg	  age="$3"
73587a3b38f7Smrg	  ;;
73597a3b38f7Smrg	esac
73607a3b38f7Smrg
73617a3b38f7Smrg	# Check that each of the things are valid numbers.
73627a3b38f7Smrg	case $current in
73637a3b38f7Smrg	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]) ;;
73647a3b38f7Smrg	*)
73657a3b38f7Smrg	  func_error "CURRENT \`$current' must be a nonnegative integer"
73667a3b38f7Smrg	  func_fatal_error "\`$vinfo' is not valid version information"
73677a3b38f7Smrg	  ;;
73687a3b38f7Smrg	esac
73697a3b38f7Smrg
73707a3b38f7Smrg	case $revision in
73717a3b38f7Smrg	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]) ;;
73727a3b38f7Smrg	*)
73737a3b38f7Smrg	  func_error "REVISION \`$revision' must be a nonnegative integer"
73747a3b38f7Smrg	  func_fatal_error "\`$vinfo' is not valid version information"
73757a3b38f7Smrg	  ;;
73767a3b38f7Smrg	esac
73777a3b38f7Smrg
73787a3b38f7Smrg	case $age in
73797a3b38f7Smrg	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]) ;;
73807a3b38f7Smrg	*)
73817a3b38f7Smrg	  func_error "AGE \`$age' must be a nonnegative integer"
73827a3b38f7Smrg	  func_fatal_error "\`$vinfo' is not valid version information"
73837a3b38f7Smrg	  ;;
73847a3b38f7Smrg	esac
73857a3b38f7Smrg
73867a3b38f7Smrg	if test "$age" -gt "$current"; then
73877a3b38f7Smrg	  func_error "AGE \`$age' is greater than the current interface number \`$current'"
73887a3b38f7Smrg	  func_fatal_error "\`$vinfo' is not valid version information"
73897a3b38f7Smrg	fi
73907a3b38f7Smrg
73917a3b38f7Smrg	# Calculate the version variables.
73927a3b38f7Smrg	major=
73937a3b38f7Smrg	versuffix=
73947a3b38f7Smrg	verstring=
73957a3b38f7Smrg	case $version_type in
73967a3b38f7Smrg	none) ;;
73977a3b38f7Smrg
73987a3b38f7Smrg	darwin)
73997a3b38f7Smrg	  # Like Linux, but with the current version available in
74007a3b38f7Smrg	  # verstring for coding it into the library header
74017a3b38f7Smrg	  func_arith $current - $age
74027a3b38f7Smrg	  major=.$func_arith_result
74037a3b38f7Smrg	  versuffix="$major.$age.$revision"
74047a3b38f7Smrg	  # Darwin ld doesn't like 0 for these options...
74057a3b38f7Smrg	  func_arith $current + 1
74067a3b38f7Smrg	  minor_current=$func_arith_result
74077a3b38f7Smrg	  xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
74087a3b38f7Smrg	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
74097a3b38f7Smrg	  ;;
74107a3b38f7Smrg
74117a3b38f7Smrg	freebsd-aout)
74127a3b38f7Smrg	  major=".$current"
74137a3b38f7Smrg	  versuffix=".$current.$revision";
74147a3b38f7Smrg	  ;;
74157a3b38f7Smrg
74167a3b38f7Smrg	freebsd-elf)
74177a3b38f7Smrg	  major=".$current"
74187a3b38f7Smrg	  versuffix=".$current"
74197a3b38f7Smrg	  ;;
74207a3b38f7Smrg
74217a3b38f7Smrg	irix | nonstopux)
74227a3b38f7Smrg	  if test "X$lt_irix_increment" = "Xno"; then
74237a3b38f7Smrg	    func_arith $current - $age
74247a3b38f7Smrg	  else
74257a3b38f7Smrg	    func_arith $current - $age + 1
74267a3b38f7Smrg	  fi
74277a3b38f7Smrg	  major=$func_arith_result
74287a3b38f7Smrg
74297a3b38f7Smrg	  case $version_type in
74307a3b38f7Smrg	    nonstopux) verstring_prefix=nonstopux ;;
74317a3b38f7Smrg	    *)         verstring_prefix=sgi ;;
74327a3b38f7Smrg	  esac
74337a3b38f7Smrg	  verstring="$verstring_prefix$major.$revision"
74347a3b38f7Smrg
74357a3b38f7Smrg	  # Add in all the interfaces that we are compatible with.
74367a3b38f7Smrg	  loop=$revision
74377a3b38f7Smrg	  while test "$loop" -ne 0; do
74387a3b38f7Smrg	    func_arith $revision - $loop
74397a3b38f7Smrg	    iface=$func_arith_result
74407a3b38f7Smrg	    func_arith $loop - 1
74417a3b38f7Smrg	    loop=$func_arith_result
74427a3b38f7Smrg	    verstring="$verstring_prefix$major.$iface:$verstring"
74437a3b38f7Smrg	  done
74447a3b38f7Smrg
74457a3b38f7Smrg	  # Before this point, $major must not contain `.'.
74467a3b38f7Smrg	  major=.$major
74477a3b38f7Smrg	  versuffix="$major.$revision"
74487a3b38f7Smrg	  ;;
74497a3b38f7Smrg
7450fc544a13Smrg	linux) # correct to gnu/linux during the next big refactor
74517a3b38f7Smrg	  func_arith $current - $age
74527a3b38f7Smrg	  major=.$func_arith_result
74537a3b38f7Smrg	  versuffix="$major.$age.$revision"
74547a3b38f7Smrg	  ;;
74557a3b38f7Smrg
74567a3b38f7Smrg	osf)
74577a3b38f7Smrg	  func_arith $current - $age
74587a3b38f7Smrg	  major=.$func_arith_result
74597a3b38f7Smrg	  versuffix=".$current.$age.$revision"
74607a3b38f7Smrg	  verstring="$current.$age.$revision"
74617a3b38f7Smrg
74627a3b38f7Smrg	  # Add in all the interfaces that we are compatible with.
74637a3b38f7Smrg	  loop=$age
74647a3b38f7Smrg	  while test "$loop" -ne 0; do
74657a3b38f7Smrg	    func_arith $current - $loop
74667a3b38f7Smrg	    iface=$func_arith_result
74677a3b38f7Smrg	    func_arith $loop - 1
74687a3b38f7Smrg	    loop=$func_arith_result
74697a3b38f7Smrg	    verstring="$verstring:${iface}.0"
74707a3b38f7Smrg	  done
74717a3b38f7Smrg
74727a3b38f7Smrg	  # Make executables depend on our current version.
7473862f5301Smrg	  func_append verstring ":${current}.0"
74747a3b38f7Smrg	  ;;
74757a3b38f7Smrg
74767a3b38f7Smrg	qnx)
74777a3b38f7Smrg	  major=".$current"
74787a3b38f7Smrg	  versuffix=".$current"
74797a3b38f7Smrg	  ;;
74807a3b38f7Smrg
74817a3b38f7Smrg	sunos)
74827a3b38f7Smrg	  major=".$current"
74837a3b38f7Smrg	  versuffix=".$current.$revision"
74847a3b38f7Smrg	  ;;
74857a3b38f7Smrg
74867a3b38f7Smrg	windows)
74877a3b38f7Smrg	  # Use '-' rather than '.', since we only want one
74887a3b38f7Smrg	  # extension on DOS 8.3 filesystems.
74897a3b38f7Smrg	  func_arith $current - $age
74907a3b38f7Smrg	  major=$func_arith_result
74917a3b38f7Smrg	  versuffix="-$major"
74927a3b38f7Smrg	  ;;
74937a3b38f7Smrg
74947a3b38f7Smrg	*)
74957a3b38f7Smrg	  func_fatal_configuration "unknown library version type \`$version_type'"
74967a3b38f7Smrg	  ;;
74977a3b38f7Smrg	esac
74987a3b38f7Smrg
74997a3b38f7Smrg	# Clear the version info if we defaulted, and they specified a release.
75007a3b38f7Smrg	if test -z "$vinfo" && test -n "$release"; then
75017a3b38f7Smrg	  major=
75027a3b38f7Smrg	  case $version_type in
75037a3b38f7Smrg	  darwin)
75047a3b38f7Smrg	    # we can't check for "0.0" in archive_cmds due to quoting
75057a3b38f7Smrg	    # problems, so we reset it completely
75067a3b38f7Smrg	    verstring=
75077a3b38f7Smrg	    ;;
75087a3b38f7Smrg	  *)
75097a3b38f7Smrg	    verstring="0.0"
75107a3b38f7Smrg	    ;;
75117a3b38f7Smrg	  esac
75127a3b38f7Smrg	  if test "$need_version" = no; then
75137a3b38f7Smrg	    versuffix=
75147a3b38f7Smrg	  else
75157a3b38f7Smrg	    versuffix=".0.0"
75167a3b38f7Smrg	  fi
75177a3b38f7Smrg	fi
75187a3b38f7Smrg
75197a3b38f7Smrg	# Remove version info from name if versioning should be avoided
75207a3b38f7Smrg	if test "$avoid_version" = yes && test "$need_version" = no; then
75217a3b38f7Smrg	  major=
75227a3b38f7Smrg	  versuffix=
75237a3b38f7Smrg	  verstring=""
75247a3b38f7Smrg	fi
75257a3b38f7Smrg
75267a3b38f7Smrg	# Check to see if the archive will have undefined symbols.
75277a3b38f7Smrg	if test "$allow_undefined" = yes; then
75287a3b38f7Smrg	  if test "$allow_undefined_flag" = unsupported; then
75297a3b38f7Smrg	    func_warning "undefined symbols not allowed in $host shared libraries"
75307a3b38f7Smrg	    build_libtool_libs=no
75317a3b38f7Smrg	    build_old_libs=yes
75327a3b38f7Smrg	  fi
75337a3b38f7Smrg	else
75347a3b38f7Smrg	  # Don't allow undefined symbols.
75357a3b38f7Smrg	  allow_undefined_flag="$no_undefined_flag"
75367a3b38f7Smrg	fi
75377a3b38f7Smrg
75387a3b38f7Smrg      fi
75397a3b38f7Smrg
75407a3b38f7Smrg      func_generate_dlsyms "$libname" "$libname" "yes"
7541862f5301Smrg      func_append libobjs " $symfileobj"
75427a3b38f7Smrg      test "X$libobjs" = "X " && libobjs=
75437a3b38f7Smrg
7544862f5301Smrg      if test "$opt_mode" != relink; then
75457a3b38f7Smrg	# Remove our outputs, but don't remove object files since they
75467a3b38f7Smrg	# may have been created when compiling PIC objects.
75477a3b38f7Smrg	removelist=
75487a3b38f7Smrg	tempremovelist=`$ECHO "$output_objdir/*"`
75497a3b38f7Smrg	for p in $tempremovelist; do
75507a3b38f7Smrg	  case $p in
75517a3b38f7Smrg	    *.$objext | *.gcno)
75527a3b38f7Smrg	       ;;
75537a3b38f7Smrg	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
75547a3b38f7Smrg	       if test "X$precious_files_regex" != "X"; then
75557a3b38f7Smrg		 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
75567a3b38f7Smrg		 then
75577a3b38f7Smrg		   continue
75587a3b38f7Smrg		 fi
75597a3b38f7Smrg	       fi
7560862f5301Smrg	       func_append removelist " $p"
75617a3b38f7Smrg	       ;;
75627a3b38f7Smrg	    *) ;;
75637a3b38f7Smrg	  esac
75647a3b38f7Smrg	done
75657a3b38f7Smrg	test -n "$removelist" && \
75667a3b38f7Smrg	  func_show_eval "${RM}r \$removelist"
75677a3b38f7Smrg      fi
75687a3b38f7Smrg
75697a3b38f7Smrg      # Now set the variables for building old libraries.
75707a3b38f7Smrg      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
7571862f5301Smrg	func_append oldlibs " $output_objdir/$libname.$libext"
75727a3b38f7Smrg
75737a3b38f7Smrg	# Transform .lo files to .o files.
757444dda7b2Smrg	oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP`
75757a3b38f7Smrg      fi
75767a3b38f7Smrg
75777a3b38f7Smrg      # Eliminate all temporary directories.
75787a3b38f7Smrg      #for path in $notinst_path; do
757944dda7b2Smrg      #	lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
758044dda7b2Smrg      #	deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
758144dda7b2Smrg      #	dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
75827a3b38f7Smrg      #done
75837a3b38f7Smrg
75847a3b38f7Smrg      if test -n "$xrpath"; then
75857a3b38f7Smrg	# If the user specified any rpath flags, then add them.
75867a3b38f7Smrg	temp_xrpath=
75877a3b38f7Smrg	for libdir in $xrpath; do
7588862f5301Smrg	  func_replace_sysroot "$libdir"
7589862f5301Smrg	  func_append temp_xrpath " -R$func_replace_sysroot_result"
75907a3b38f7Smrg	  case "$finalize_rpath " in
75917a3b38f7Smrg	  *" $libdir "*) ;;
7592862f5301Smrg	  *) func_append finalize_rpath " $libdir" ;;
75937a3b38f7Smrg	  esac
75947a3b38f7Smrg	done
75957a3b38f7Smrg	if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
75967a3b38f7Smrg	  dependency_libs="$temp_xrpath $dependency_libs"
75977a3b38f7Smrg	fi
75987a3b38f7Smrg      fi
75997a3b38f7Smrg
76007a3b38f7Smrg      # Make sure dlfiles contains only unique files that won't be dlpreopened
76017a3b38f7Smrg      old_dlfiles="$dlfiles"
76027a3b38f7Smrg      dlfiles=
76037a3b38f7Smrg      for lib in $old_dlfiles; do
76047a3b38f7Smrg	case " $dlprefiles $dlfiles " in
76057a3b38f7Smrg	*" $lib "*) ;;
7606862f5301Smrg	*) func_append dlfiles " $lib" ;;
76077a3b38f7Smrg	esac
76087a3b38f7Smrg      done
76097a3b38f7Smrg
76107a3b38f7Smrg      # Make sure dlprefiles contains only unique files
76117a3b38f7Smrg      old_dlprefiles="$dlprefiles"
76127a3b38f7Smrg      dlprefiles=
76137a3b38f7Smrg      for lib in $old_dlprefiles; do
76147a3b38f7Smrg	case "$dlprefiles " in
76157a3b38f7Smrg	*" $lib "*) ;;
7616862f5301Smrg	*) func_append dlprefiles " $lib" ;;
76177a3b38f7Smrg	esac
76187a3b38f7Smrg      done
76197a3b38f7Smrg
76207a3b38f7Smrg      if test "$build_libtool_libs" = yes; then
76217a3b38f7Smrg	if test -n "$rpath"; then
76227a3b38f7Smrg	  case $host in
762344dda7b2Smrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
76247a3b38f7Smrg	    # these systems don't actually have a c library (as such)!
76257a3b38f7Smrg	    ;;
76267a3b38f7Smrg	  *-*-rhapsody* | *-*-darwin1.[012])
76277a3b38f7Smrg	    # Rhapsody C library is in the System framework
7628862f5301Smrg	    func_append deplibs " System.ltframework"
76297a3b38f7Smrg	    ;;
76307a3b38f7Smrg	  *-*-netbsd*)
76317a3b38f7Smrg	    # Don't link with libc until the a.out ld.so is fixed.
76327a3b38f7Smrg	    ;;
76337a3b38f7Smrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
76347a3b38f7Smrg	    # Do not include libc due to us having libc/libc_r.
76357a3b38f7Smrg	    ;;
76367a3b38f7Smrg	  *-*-sco3.2v5* | *-*-sco5v6*)
76377a3b38f7Smrg	    # Causes problems with __ctype
76387a3b38f7Smrg	    ;;
76397a3b38f7Smrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
76407a3b38f7Smrg	    # Compiler inserts libc in the correct place for threads to work
76417a3b38f7Smrg	    ;;
76427a3b38f7Smrg	  *)
76437a3b38f7Smrg	    # Add libc to deplibs on all other systems if necessary.
76447a3b38f7Smrg	    if test "$build_libtool_need_lc" = "yes"; then
7645862f5301Smrg	      func_append deplibs " -lc"
76467a3b38f7Smrg	    fi
76477a3b38f7Smrg	    ;;
76487a3b38f7Smrg	  esac
76497a3b38f7Smrg	fi
76507a3b38f7Smrg
76517a3b38f7Smrg	# Transform deplibs into only deplibs that can be linked in shared.
76527a3b38f7Smrg	name_save=$name
76537a3b38f7Smrg	libname_save=$libname
76547a3b38f7Smrg	release_save=$release
76557a3b38f7Smrg	versuffix_save=$versuffix
76567a3b38f7Smrg	major_save=$major
76577a3b38f7Smrg	# I'm not sure if I'm treating the release correctly.  I think
76587a3b38f7Smrg	# release should show up in the -l (ie -lgmp5) so we don't want to
76597a3b38f7Smrg	# add it in twice.  Is that correct?
76607a3b38f7Smrg	release=""
76617a3b38f7Smrg	versuffix=""
76627a3b38f7Smrg	major=""
76637a3b38f7Smrg	newdeplibs=
76647a3b38f7Smrg	droppeddeps=no
76657a3b38f7Smrg	case $deplibs_check_method in
76667a3b38f7Smrg	pass_all)
76677a3b38f7Smrg	  # Don't check for shared/static.  Everything works.
76687a3b38f7Smrg	  # This might be a little naive.  We might want to check
76697a3b38f7Smrg	  # whether the library exists or not.  But this is on
76707a3b38f7Smrg	  # osf3 & osf4 and I'm not really sure... Just
76717a3b38f7Smrg	  # implementing what was already the behavior.
76727a3b38f7Smrg	  newdeplibs=$deplibs
76737a3b38f7Smrg	  ;;
76747a3b38f7Smrg	test_compile)
76757a3b38f7Smrg	  # This code stresses the "libraries are programs" paradigm to its
76767a3b38f7Smrg	  # limits. Maybe even breaks it.  We compile a program, linking it
76777a3b38f7Smrg	  # against the deplibs as a proxy for the library.  Then we can check
76787a3b38f7Smrg	  # whether they linked in statically or dynamically with ldd.
76797a3b38f7Smrg	  $opt_dry_run || $RM conftest.c
76807a3b38f7Smrg	  cat > conftest.c <<EOF
76817a3b38f7Smrg	  int main() { return 0; }
76827a3b38f7SmrgEOF
76837a3b38f7Smrg	  $opt_dry_run || $RM conftest
76847a3b38f7Smrg	  if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
76857a3b38f7Smrg	    ldd_output=`ldd conftest`
76867a3b38f7Smrg	    for i in $deplibs; do
76877a3b38f7Smrg	      case $i in
76887a3b38f7Smrg	      -l*)
76897a3b38f7Smrg		func_stripname -l '' "$i"
76907a3b38f7Smrg		name=$func_stripname_result
76917a3b38f7Smrg		if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
76927a3b38f7Smrg		  case " $predeps $postdeps " in
76937a3b38f7Smrg		  *" $i "*)
7694862f5301Smrg		    func_append newdeplibs " $i"
76957a3b38f7Smrg		    i=""
76967a3b38f7Smrg		    ;;
76977a3b38f7Smrg		  esac
76987a3b38f7Smrg		fi
76997a3b38f7Smrg		if test -n "$i" ; then
77007a3b38f7Smrg		  libname=`eval "\\$ECHO \"$libname_spec\""`
77017a3b38f7Smrg		  deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
77027a3b38f7Smrg		  set dummy $deplib_matches; shift
77037a3b38f7Smrg		  deplib_match=$1
77047a3b38f7Smrg		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
7705862f5301Smrg		    func_append newdeplibs " $i"
77067a3b38f7Smrg		  else
77077a3b38f7Smrg		    droppeddeps=yes
770844dda7b2Smrg		    echo
77097a3b38f7Smrg		    $ECHO "*** Warning: dynamic linker does not accept needed library $i."
771044dda7b2Smrg		    echo "*** I have the capability to make that library automatically link in when"
771144dda7b2Smrg		    echo "*** you link to this library.  But I can only do this if you have a"
771244dda7b2Smrg		    echo "*** shared version of the library, which I believe you do not have"
771344dda7b2Smrg		    echo "*** because a test_compile did reveal that the linker did not use it for"
771444dda7b2Smrg		    echo "*** its dynamic dependency list that programs get resolved with at runtime."
77157a3b38f7Smrg		  fi
77167a3b38f7Smrg		fi
77177a3b38f7Smrg		;;
77187a3b38f7Smrg	      *)
7719862f5301Smrg		func_append newdeplibs " $i"
77207a3b38f7Smrg		;;
77217a3b38f7Smrg	      esac
77227a3b38f7Smrg	    done
77237a3b38f7Smrg	  else
77247a3b38f7Smrg	    # Error occurred in the first compile.  Let's try to salvage
77257a3b38f7Smrg	    # the situation: Compile a separate program for each library.
77267a3b38f7Smrg	    for i in $deplibs; do
77277a3b38f7Smrg	      case $i in
77287a3b38f7Smrg	      -l*)
77297a3b38f7Smrg		func_stripname -l '' "$i"
77307a3b38f7Smrg		name=$func_stripname_result
77317a3b38f7Smrg		$opt_dry_run || $RM conftest
77327a3b38f7Smrg		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
77337a3b38f7Smrg		  ldd_output=`ldd conftest`
77347a3b38f7Smrg		  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
77357a3b38f7Smrg		    case " $predeps $postdeps " in
77367a3b38f7Smrg		    *" $i "*)
7737862f5301Smrg		      func_append newdeplibs " $i"
77387a3b38f7Smrg		      i=""
77397a3b38f7Smrg		      ;;
77407a3b38f7Smrg		    esac
77417a3b38f7Smrg		  fi
77427a3b38f7Smrg		  if test -n "$i" ; then
77437a3b38f7Smrg		    libname=`eval "\\$ECHO \"$libname_spec\""`
77447a3b38f7Smrg		    deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
77457a3b38f7Smrg		    set dummy $deplib_matches; shift
77467a3b38f7Smrg		    deplib_match=$1
77477a3b38f7Smrg		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
7748862f5301Smrg		      func_append newdeplibs " $i"
77497a3b38f7Smrg		    else
77507a3b38f7Smrg		      droppeddeps=yes
775144dda7b2Smrg		      echo
77527a3b38f7Smrg		      $ECHO "*** Warning: dynamic linker does not accept needed library $i."
775344dda7b2Smrg		      echo "*** I have the capability to make that library automatically link in when"
775444dda7b2Smrg		      echo "*** you link to this library.  But I can only do this if you have a"
775544dda7b2Smrg		      echo "*** shared version of the library, which you do not appear to have"
775644dda7b2Smrg		      echo "*** because a test_compile did reveal that the linker did not use this one"
775744dda7b2Smrg		      echo "*** as a dynamic dependency that programs can get resolved with at runtime."
77587a3b38f7Smrg		    fi
77597a3b38f7Smrg		  fi
77607a3b38f7Smrg		else
77617a3b38f7Smrg		  droppeddeps=yes
776244dda7b2Smrg		  echo
77637a3b38f7Smrg		  $ECHO "*** Warning!  Library $i is needed by this library but I was not able to"
776444dda7b2Smrg		  echo "*** make it link in!  You will probably need to install it or some"
776544dda7b2Smrg		  echo "*** library that it depends on before this library will be fully"
776644dda7b2Smrg		  echo "*** functional.  Installing it before continuing would be even better."
77677a3b38f7Smrg		fi
77687a3b38f7Smrg		;;
77697a3b38f7Smrg	      *)
7770862f5301Smrg		func_append newdeplibs " $i"
77717a3b38f7Smrg		;;
77727a3b38f7Smrg	      esac
77737a3b38f7Smrg	    done
77747a3b38f7Smrg	  fi
77757a3b38f7Smrg	  ;;
77767a3b38f7Smrg	file_magic*)
77777a3b38f7Smrg	  set dummy $deplibs_check_method; shift
77787a3b38f7Smrg	  file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
77797a3b38f7Smrg	  for a_deplib in $deplibs; do
77807a3b38f7Smrg	    case $a_deplib in
77817a3b38f7Smrg	    -l*)
77827a3b38f7Smrg	      func_stripname -l '' "$a_deplib"
77837a3b38f7Smrg	      name=$func_stripname_result
77847a3b38f7Smrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
77857a3b38f7Smrg		case " $predeps $postdeps " in
77867a3b38f7Smrg		*" $a_deplib "*)
7787862f5301Smrg		  func_append newdeplibs " $a_deplib"
77887a3b38f7Smrg		  a_deplib=""
77897a3b38f7Smrg		  ;;
77907a3b38f7Smrg		esac
77917a3b38f7Smrg	      fi
77927a3b38f7Smrg	      if test -n "$a_deplib" ; then
77937a3b38f7Smrg		libname=`eval "\\$ECHO \"$libname_spec\""`
7794862f5301Smrg		if test -n "$file_magic_glob"; then
7795862f5301Smrg		  libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob`
7796862f5301Smrg		else
7797862f5301Smrg		  libnameglob=$libname
7798862f5301Smrg		fi
7799862f5301Smrg		test "$want_nocaseglob" = yes && nocaseglob=`shopt -p nocaseglob`
78007a3b38f7Smrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
7801862f5301Smrg		  if test "$want_nocaseglob" = yes; then
7802862f5301Smrg		    shopt -s nocaseglob
7803862f5301Smrg		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
7804862f5301Smrg		    $nocaseglob
7805862f5301Smrg		  else
7806862f5301Smrg		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
7807862f5301Smrg		  fi
78087a3b38f7Smrg		  for potent_lib in $potential_libs; do
78097a3b38f7Smrg		      # Follow soft links.
78107a3b38f7Smrg		      if ls -lLd "$potent_lib" 2>/dev/null |
78117a3b38f7Smrg			 $GREP " -> " >/dev/null; then
78127a3b38f7Smrg			continue
78137a3b38f7Smrg		      fi
78147a3b38f7Smrg		      # The statement above tries to avoid entering an
78157a3b38f7Smrg		      # endless loop below, in case of cyclic links.
78167a3b38f7Smrg		      # We might still enter an endless loop, since a link
78177a3b38f7Smrg		      # loop can be closed while we follow links,
78187a3b38f7Smrg		      # but so what?
78197a3b38f7Smrg		      potlib="$potent_lib"
78207a3b38f7Smrg		      while test -h "$potlib" 2>/dev/null; do
78217a3b38f7Smrg			potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
78227a3b38f7Smrg			case $potliblink in
78237a3b38f7Smrg			[\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
782444dda7b2Smrg			*) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";;
78257a3b38f7Smrg			esac
78267a3b38f7Smrg		      done
78277a3b38f7Smrg		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
78287a3b38f7Smrg			 $SED -e 10q |
78297a3b38f7Smrg			 $EGREP "$file_magic_regex" > /dev/null; then
7830862f5301Smrg			func_append newdeplibs " $a_deplib"
78317a3b38f7Smrg			a_deplib=""
78327a3b38f7Smrg			break 2
78337a3b38f7Smrg		      fi
78347a3b38f7Smrg		  done
78357a3b38f7Smrg		done
78367a3b38f7Smrg	      fi
78377a3b38f7Smrg	      if test -n "$a_deplib" ; then
78387a3b38f7Smrg		droppeddeps=yes
783944dda7b2Smrg		echo
78407a3b38f7Smrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
784144dda7b2Smrg		echo "*** I have the capability to make that library automatically link in when"
784244dda7b2Smrg		echo "*** you link to this library.  But I can only do this if you have a"
784344dda7b2Smrg		echo "*** shared version of the library, which you do not appear to have"
784444dda7b2Smrg		echo "*** because I did check the linker path looking for a file starting"
78457a3b38f7Smrg		if test -z "$potlib" ; then
78467a3b38f7Smrg		  $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
78477a3b38f7Smrg		else
78487a3b38f7Smrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
78497a3b38f7Smrg		  $ECHO "*** using a file magic. Last file checked: $potlib"
78507a3b38f7Smrg		fi
78517a3b38f7Smrg	      fi
78527a3b38f7Smrg	      ;;
78537a3b38f7Smrg	    *)
78547a3b38f7Smrg	      # Add a -L argument.
7855862f5301Smrg	      func_append newdeplibs " $a_deplib"
78567a3b38f7Smrg	      ;;
78577a3b38f7Smrg	    esac
78587a3b38f7Smrg	  done # Gone through all deplibs.
78597a3b38f7Smrg	  ;;
78607a3b38f7Smrg	match_pattern*)
78617a3b38f7Smrg	  set dummy $deplibs_check_method; shift
78627a3b38f7Smrg	  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
78637a3b38f7Smrg	  for a_deplib in $deplibs; do
78647a3b38f7Smrg	    case $a_deplib in
78657a3b38f7Smrg	    -l*)
78667a3b38f7Smrg	      func_stripname -l '' "$a_deplib"
78677a3b38f7Smrg	      name=$func_stripname_result
78687a3b38f7Smrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
78697a3b38f7Smrg		case " $predeps $postdeps " in
78707a3b38f7Smrg		*" $a_deplib "*)
7871862f5301Smrg		  func_append newdeplibs " $a_deplib"
78727a3b38f7Smrg		  a_deplib=""
78737a3b38f7Smrg		  ;;
78747a3b38f7Smrg		esac
78757a3b38f7Smrg	      fi
78767a3b38f7Smrg	      if test -n "$a_deplib" ; then
78777a3b38f7Smrg		libname=`eval "\\$ECHO \"$libname_spec\""`
78787a3b38f7Smrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
78797a3b38f7Smrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
78807a3b38f7Smrg		  for potent_lib in $potential_libs; do
78817a3b38f7Smrg		    potlib="$potent_lib" # see symlink-check above in file_magic test
788244dda7b2Smrg		    if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
78837a3b38f7Smrg		       $EGREP "$match_pattern_regex" > /dev/null; then
7884862f5301Smrg		      func_append newdeplibs " $a_deplib"
78857a3b38f7Smrg		      a_deplib=""
78867a3b38f7Smrg		      break 2
78877a3b38f7Smrg		    fi
78887a3b38f7Smrg		  done
78897a3b38f7Smrg		done
78907a3b38f7Smrg	      fi
78917a3b38f7Smrg	      if test -n "$a_deplib" ; then
78927a3b38f7Smrg		droppeddeps=yes
789344dda7b2Smrg		echo
78947a3b38f7Smrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
789544dda7b2Smrg		echo "*** I have the capability to make that library automatically link in when"
789644dda7b2Smrg		echo "*** you link to this library.  But I can only do this if you have a"
789744dda7b2Smrg		echo "*** shared version of the library, which you do not appear to have"
789844dda7b2Smrg		echo "*** because I did check the linker path looking for a file starting"
78997a3b38f7Smrg		if test -z "$potlib" ; then
79007a3b38f7Smrg		  $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
79017a3b38f7Smrg		else
79027a3b38f7Smrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
79037a3b38f7Smrg		  $ECHO "*** using a regex pattern. Last file checked: $potlib"
79047a3b38f7Smrg		fi
79057a3b38f7Smrg	      fi
79067a3b38f7Smrg	      ;;
79077a3b38f7Smrg	    *)
79087a3b38f7Smrg	      # Add a -L argument.
7909862f5301Smrg	      func_append newdeplibs " $a_deplib"
79107a3b38f7Smrg	      ;;
79117a3b38f7Smrg	    esac
79127a3b38f7Smrg	  done # Gone through all deplibs.
79137a3b38f7Smrg	  ;;
79147a3b38f7Smrg	none | unknown | *)
79157a3b38f7Smrg	  newdeplibs=""
791644dda7b2Smrg	  tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
79177a3b38f7Smrg	  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
79187a3b38f7Smrg	    for i in $predeps $postdeps ; do
79197a3b38f7Smrg	      # can't use Xsed below, because $i might contain '/'
792044dda7b2Smrg	      tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"`
79217a3b38f7Smrg	    done
79227a3b38f7Smrg	  fi
792344dda7b2Smrg	  case $tmp_deplibs in
792444dda7b2Smrg	  *[!\	\ ]*)
792544dda7b2Smrg	    echo
79267a3b38f7Smrg	    if test "X$deplibs_check_method" = "Xnone"; then
792744dda7b2Smrg	      echo "*** Warning: inter-library dependencies are not supported in this platform."
79287a3b38f7Smrg	    else
792944dda7b2Smrg	      echo "*** Warning: inter-library dependencies are not known to be supported."
79307a3b38f7Smrg	    fi
793144dda7b2Smrg	    echo "*** All declared inter-library dependencies are being dropped."
79327a3b38f7Smrg	    droppeddeps=yes
793344dda7b2Smrg	    ;;
793444dda7b2Smrg	  esac
79357a3b38f7Smrg	  ;;
79367a3b38f7Smrg	esac
79377a3b38f7Smrg	versuffix=$versuffix_save
79387a3b38f7Smrg	major=$major_save
79397a3b38f7Smrg	release=$release_save
79407a3b38f7Smrg	libname=$libname_save
79417a3b38f7Smrg	name=$name_save
79427a3b38f7Smrg
79437a3b38f7Smrg	case $host in
79447a3b38f7Smrg	*-*-rhapsody* | *-*-darwin1.[012])
79457a3b38f7Smrg	  # On Rhapsody replace the C library with the System framework
794644dda7b2Smrg	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
79477a3b38f7Smrg	  ;;
79487a3b38f7Smrg	esac
79497a3b38f7Smrg
79507a3b38f7Smrg	if test "$droppeddeps" = yes; then
79517a3b38f7Smrg	  if test "$module" = yes; then
795244dda7b2Smrg	    echo
795344dda7b2Smrg	    echo "*** Warning: libtool could not satisfy all declared inter-library"
79547a3b38f7Smrg	    $ECHO "*** dependencies of module $libname.  Therefore, libtool will create"
795544dda7b2Smrg	    echo "*** a static module, that should work as long as the dlopening"
795644dda7b2Smrg	    echo "*** application is linked with the -dlopen flag."
79577a3b38f7Smrg	    if test -z "$global_symbol_pipe"; then
795844dda7b2Smrg	      echo
795944dda7b2Smrg	      echo "*** However, this would only work if libtool was able to extract symbol"
796044dda7b2Smrg	      echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
796144dda7b2Smrg	      echo "*** not find such a program.  So, this module is probably useless."
796244dda7b2Smrg	      echo "*** \`nm' from GNU binutils and a full rebuild may help."
79637a3b38f7Smrg	    fi
79647a3b38f7Smrg	    if test "$build_old_libs" = no; then
79657a3b38f7Smrg	      oldlibs="$output_objdir/$libname.$libext"
79667a3b38f7Smrg	      build_libtool_libs=module
79677a3b38f7Smrg	      build_old_libs=yes
79687a3b38f7Smrg	    else
79697a3b38f7Smrg	      build_libtool_libs=no
79707a3b38f7Smrg	    fi
79717a3b38f7Smrg	  else
797244dda7b2Smrg	    echo "*** The inter-library dependencies that have been dropped here will be"
797344dda7b2Smrg	    echo "*** automatically added whenever a program is linked with this library"
797444dda7b2Smrg	    echo "*** or is declared to -dlopen it."
79757a3b38f7Smrg
79767a3b38f7Smrg	    if test "$allow_undefined" = no; then
797744dda7b2Smrg	      echo
797844dda7b2Smrg	      echo "*** Since this library must not contain undefined symbols,"
797944dda7b2Smrg	      echo "*** because either the platform does not support them or"
798044dda7b2Smrg	      echo "*** it was explicitly requested with -no-undefined,"
798144dda7b2Smrg	      echo "*** libtool will only create a static version of it."
79827a3b38f7Smrg	      if test "$build_old_libs" = no; then
79837a3b38f7Smrg		oldlibs="$output_objdir/$libname.$libext"
79847a3b38f7Smrg		build_libtool_libs=module
79857a3b38f7Smrg		build_old_libs=yes
79867a3b38f7Smrg	      else
79877a3b38f7Smrg		build_libtool_libs=no
79887a3b38f7Smrg	      fi
79897a3b38f7Smrg	    fi
79907a3b38f7Smrg	  fi
79917a3b38f7Smrg	fi
79927a3b38f7Smrg	# Done checking deplibs!
79937a3b38f7Smrg	deplibs=$newdeplibs
79947a3b38f7Smrg      fi
79957a3b38f7Smrg      # Time to change all our "foo.ltframework" stuff back to "-framework foo"
79967a3b38f7Smrg      case $host in
79977a3b38f7Smrg	*-*-darwin*)
799844dda7b2Smrg	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
799944dda7b2Smrg	  new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
800044dda7b2Smrg	  deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
80017a3b38f7Smrg	  ;;
80027a3b38f7Smrg      esac
80037a3b38f7Smrg
80047a3b38f7Smrg      # move library search paths that coincide with paths to not yet
80057a3b38f7Smrg      # installed libraries to the beginning of the library search list
80067a3b38f7Smrg      new_libs=
80077a3b38f7Smrg      for path in $notinst_path; do
80087a3b38f7Smrg	case " $new_libs " in
80097a3b38f7Smrg	*" -L$path/$objdir "*) ;;
80107a3b38f7Smrg	*)
80117a3b38f7Smrg	  case " $deplibs " in
80127a3b38f7Smrg	  *" -L$path/$objdir "*)
8013862f5301Smrg	    func_append new_libs " -L$path/$objdir" ;;
80147a3b38f7Smrg	  esac
80157a3b38f7Smrg	  ;;
80167a3b38f7Smrg	esac
80177a3b38f7Smrg      done
80187a3b38f7Smrg      for deplib in $deplibs; do
80197a3b38f7Smrg	case $deplib in
80207a3b38f7Smrg	-L*)
80217a3b38f7Smrg	  case " $new_libs " in
80227a3b38f7Smrg	  *" $deplib "*) ;;
8023862f5301Smrg	  *) func_append new_libs " $deplib" ;;
80247a3b38f7Smrg	  esac
80257a3b38f7Smrg	  ;;
8026862f5301Smrg	*) func_append new_libs " $deplib" ;;
80277a3b38f7Smrg	esac
80287a3b38f7Smrg      done
80297a3b38f7Smrg      deplibs="$new_libs"
80307a3b38f7Smrg
80317a3b38f7Smrg      # All the library-specific variables (install_libdir is set above).
80327a3b38f7Smrg      library_names=
80337a3b38f7Smrg      old_library=
80347a3b38f7Smrg      dlname=
80357a3b38f7Smrg
80367a3b38f7Smrg      # Test again, we may have decided not to build it any more
80377a3b38f7Smrg      if test "$build_libtool_libs" = yes; then
8038fc544a13Smrg	# Remove ${wl} instances when linking with ld.
8039fc544a13Smrg	# FIXME: should test the right _cmds variable.
8040fc544a13Smrg	case $archive_cmds in
8041fc544a13Smrg	  *\$LD\ *) wl= ;;
8042fc544a13Smrg        esac
80437a3b38f7Smrg	if test "$hardcode_into_libs" = yes; then
80447a3b38f7Smrg	  # Hardcode the library paths
80457a3b38f7Smrg	  hardcode_libdirs=
80467a3b38f7Smrg	  dep_rpath=
80477a3b38f7Smrg	  rpath="$finalize_rpath"
8048862f5301Smrg	  test "$opt_mode" != relink && rpath="$compile_rpath$rpath"
80497a3b38f7Smrg	  for libdir in $rpath; do
80507a3b38f7Smrg	    if test -n "$hardcode_libdir_flag_spec"; then
80517a3b38f7Smrg	      if test -n "$hardcode_libdir_separator"; then
8052862f5301Smrg		func_replace_sysroot "$libdir"
8053862f5301Smrg		libdir=$func_replace_sysroot_result
80547a3b38f7Smrg		if test -z "$hardcode_libdirs"; then
80557a3b38f7Smrg		  hardcode_libdirs="$libdir"
80567a3b38f7Smrg		else
80577a3b38f7Smrg		  # Just accumulate the unique libdirs.
80587a3b38f7Smrg		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
80597a3b38f7Smrg		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
80607a3b38f7Smrg		    ;;
80617a3b38f7Smrg		  *)
8062862f5301Smrg		    func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
80637a3b38f7Smrg		    ;;
80647a3b38f7Smrg		  esac
80657a3b38f7Smrg		fi
80667a3b38f7Smrg	      else
80677a3b38f7Smrg		eval flag=\"$hardcode_libdir_flag_spec\"
8068862f5301Smrg		func_append dep_rpath " $flag"
80697a3b38f7Smrg	      fi
80707a3b38f7Smrg	    elif test -n "$runpath_var"; then
80717a3b38f7Smrg	      case "$perm_rpath " in
80727a3b38f7Smrg	      *" $libdir "*) ;;
8073fc544a13Smrg	      *) func_append perm_rpath " $libdir" ;;
80747a3b38f7Smrg	      esac
80757a3b38f7Smrg	    fi
80767a3b38f7Smrg	  done
80777a3b38f7Smrg	  # Substitute the hardcoded libdirs into the rpath.
80787a3b38f7Smrg	  if test -n "$hardcode_libdir_separator" &&
80797a3b38f7Smrg	     test -n "$hardcode_libdirs"; then
80807a3b38f7Smrg	    libdir="$hardcode_libdirs"
8081fc544a13Smrg	    eval "dep_rpath=\"$hardcode_libdir_flag_spec\""
80827a3b38f7Smrg	  fi
80837a3b38f7Smrg	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
80847a3b38f7Smrg	    # We should set the runpath_var.
80857a3b38f7Smrg	    rpath=
80867a3b38f7Smrg	    for dir in $perm_rpath; do
8087862f5301Smrg	      func_append rpath "$dir:"
80887a3b38f7Smrg	    done
80897a3b38f7Smrg	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
80907a3b38f7Smrg	  fi
80917a3b38f7Smrg	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
80927a3b38f7Smrg	fi
8093ff559fabSmrg
80947a3b38f7Smrg	shlibpath="$finalize_shlibpath"
8095862f5301Smrg	test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
80967a3b38f7Smrg	if test -n "$shlibpath"; then
80977a3b38f7Smrg	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
80987a3b38f7Smrg	fi
8099ff559fabSmrg
81007a3b38f7Smrg	# Get the real and link names of the library.
81017a3b38f7Smrg	eval shared_ext=\"$shrext_cmds\"
81027a3b38f7Smrg	eval library_names=\"$library_names_spec\"
81037a3b38f7Smrg	set dummy $library_names
81047a3b38f7Smrg	shift
81057a3b38f7Smrg	realname="$1"
81067a3b38f7Smrg	shift
8107ff559fabSmrg
81087a3b38f7Smrg	if test -n "$soname_spec"; then
81097a3b38f7Smrg	  eval soname=\"$soname_spec\"
81107a3b38f7Smrg	else
81117a3b38f7Smrg	  soname="$realname"
81127a3b38f7Smrg	fi
81137a3b38f7Smrg	if test -z "$dlname"; then
81147a3b38f7Smrg	  dlname=$soname
81157a3b38f7Smrg	fi
8116ff559fabSmrg
81177a3b38f7Smrg	lib="$output_objdir/$realname"
81187a3b38f7Smrg	linknames=
81197a3b38f7Smrg	for link
81207a3b38f7Smrg	do
8121862f5301Smrg	  func_append linknames " $link"
81227a3b38f7Smrg	done
8123ff559fabSmrg
81247a3b38f7Smrg	# Use standard objects if they are pic
812544dda7b2Smrg	test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
81267a3b38f7Smrg	test "X$libobjs" = "X " && libobjs=
8127ff559fabSmrg
81287a3b38f7Smrg	delfiles=
81297a3b38f7Smrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
81307a3b38f7Smrg	  $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
81317a3b38f7Smrg	  export_symbols="$output_objdir/$libname.uexp"
8132862f5301Smrg	  func_append delfiles " $export_symbols"
81337a3b38f7Smrg	fi
8134ff559fabSmrg
81357a3b38f7Smrg	orig_export_symbols=
81367a3b38f7Smrg	case $host_os in
81377a3b38f7Smrg	cygwin* | mingw* | cegcc*)
81387a3b38f7Smrg	  if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
81397a3b38f7Smrg	    # exporting using user supplied symfile
81407a3b38f7Smrg	    if test "x`$SED 1q $export_symbols`" != xEXPORTS; then
81417a3b38f7Smrg	      # and it's NOT already a .def file. Must figure out
81427a3b38f7Smrg	      # which of the given symbols are data symbols and tag
81437a3b38f7Smrg	      # them as such. So, trigger use of export_symbols_cmds.
81447a3b38f7Smrg	      # export_symbols gets reassigned inside the "prepare
81457a3b38f7Smrg	      # the list of exported symbols" if statement, so the
81467a3b38f7Smrg	      # include_expsyms logic still works.
81477a3b38f7Smrg	      orig_export_symbols="$export_symbols"
81487a3b38f7Smrg	      export_symbols=
81497a3b38f7Smrg	      always_export_symbols=yes
81507a3b38f7Smrg	    fi
81517a3b38f7Smrg	  fi
81527a3b38f7Smrg	  ;;
81537a3b38f7Smrg	esac
8154ff559fabSmrg
81557a3b38f7Smrg	# Prepare the list of exported symbols
81567a3b38f7Smrg	if test -z "$export_symbols"; then
81577a3b38f7Smrg	  if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
81587a3b38f7Smrg	    func_verbose "generating symbol list for \`$libname.la'"
81597a3b38f7Smrg	    export_symbols="$output_objdir/$libname.exp"
81607a3b38f7Smrg	    $opt_dry_run || $RM $export_symbols
81617a3b38f7Smrg	    cmds=$export_symbols_cmds
81627a3b38f7Smrg	    save_ifs="$IFS"; IFS='~'
8163862f5301Smrg	    for cmd1 in $cmds; do
81647a3b38f7Smrg	      IFS="$save_ifs"
8165862f5301Smrg	      # Take the normal branch if the nm_file_list_spec branch
8166862f5301Smrg	      # doesn't work or if tool conversion is not needed.
8167862f5301Smrg	      case $nm_file_list_spec~$to_tool_file_cmd in
8168862f5301Smrg		*~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*)
8169862f5301Smrg		  try_normal_branch=yes
8170862f5301Smrg		  eval cmd=\"$cmd1\"
8171862f5301Smrg		  func_len " $cmd"
8172862f5301Smrg		  len=$func_len_result
8173862f5301Smrg		  ;;
8174862f5301Smrg		*)
8175862f5301Smrg		  try_normal_branch=no
8176862f5301Smrg		  ;;
8177862f5301Smrg	      esac
8178862f5301Smrg	      if test "$try_normal_branch" = yes \
8179862f5301Smrg		 && { test "$len" -lt "$max_cmd_len" \
8180862f5301Smrg		      || test "$max_cmd_len" -le -1; }
8181862f5301Smrg	      then
8182862f5301Smrg		func_show_eval "$cmd" 'exit $?'
8183862f5301Smrg		skipped_export=false
8184862f5301Smrg	      elif test -n "$nm_file_list_spec"; then
8185862f5301Smrg		func_basename "$output"
8186862f5301Smrg		output_la=$func_basename_result
8187862f5301Smrg		save_libobjs=$libobjs
8188862f5301Smrg		save_output=$output
8189862f5301Smrg		output=${output_objdir}/${output_la}.nm
8190862f5301Smrg		func_to_tool_file "$output"
8191862f5301Smrg		libobjs=$nm_file_list_spec$func_to_tool_file_result
8192862f5301Smrg		func_append delfiles " $output"
8193862f5301Smrg		func_verbose "creating $NM input file list: $output"
8194862f5301Smrg		for obj in $save_libobjs; do
8195862f5301Smrg		  func_to_tool_file "$obj"
8196862f5301Smrg		  $ECHO "$func_to_tool_file_result"
8197862f5301Smrg		done > "$output"
8198862f5301Smrg		eval cmd=\"$cmd1\"
81997a3b38f7Smrg		func_show_eval "$cmd" 'exit $?'
8200862f5301Smrg		output=$save_output
8201862f5301Smrg		libobjs=$save_libobjs
82027a3b38f7Smrg		skipped_export=false
82037a3b38f7Smrg	      else
82047a3b38f7Smrg		# The command line is too long to execute in one step.
82057a3b38f7Smrg		func_verbose "using reloadable object file for export list..."
82067a3b38f7Smrg		skipped_export=:
82077a3b38f7Smrg		# Break out early, otherwise skipped_export may be
82087a3b38f7Smrg		# set to false by a later but shorter cmd.
82097a3b38f7Smrg		break
82107a3b38f7Smrg	      fi
82117a3b38f7Smrg	    done
82127a3b38f7Smrg	    IFS="$save_ifs"
82137a3b38f7Smrg	    if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then
82147a3b38f7Smrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
82157a3b38f7Smrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
82167a3b38f7Smrg	    fi
82177a3b38f7Smrg	  fi
82187a3b38f7Smrg	fi
8219ff559fabSmrg
82207a3b38f7Smrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
82217a3b38f7Smrg	  tmp_export_symbols="$export_symbols"
82227a3b38f7Smrg	  test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
822344dda7b2Smrg	  $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
82247a3b38f7Smrg	fi
8225ff559fabSmrg
82267a3b38f7Smrg	if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then
82277a3b38f7Smrg	  # The given exports_symbols file has to be filtered, so filter it.
82287a3b38f7Smrg	  func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
82297a3b38f7Smrg	  # FIXME: $output_objdir/$libname.filter potentially contains lots of
82307a3b38f7Smrg	  # 's' commands which not all seds can handle. GNU sed should be fine
82317a3b38f7Smrg	  # though. Also, the filter scales superlinearly with the number of
82327a3b38f7Smrg	  # global variables. join(1) would be nice here, but unfortunately
82337a3b38f7Smrg	  # isn't a blessed tool.
82347a3b38f7Smrg	  $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
8235862f5301Smrg	  func_append delfiles " $export_symbols $output_objdir/$libname.filter"
82367a3b38f7Smrg	  export_symbols=$output_objdir/$libname.def
82377a3b38f7Smrg	  $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
8238ff559fabSmrg	fi
8239ff559fabSmrg
82407a3b38f7Smrg	tmp_deplibs=
82417a3b38f7Smrg	for test_deplib in $deplibs; do
82427a3b38f7Smrg	  case " $convenience " in
82437a3b38f7Smrg	  *" $test_deplib "*) ;;
82447a3b38f7Smrg	  *)
8245862f5301Smrg	    func_append tmp_deplibs " $test_deplib"
82467a3b38f7Smrg	    ;;
82477a3b38f7Smrg	  esac
82487a3b38f7Smrg	done
82497a3b38f7Smrg	deplibs="$tmp_deplibs"
8250ff559fabSmrg
82517a3b38f7Smrg	if test -n "$convenience"; then
82527a3b38f7Smrg	  if test -n "$whole_archive_flag_spec" &&
82537a3b38f7Smrg	    test "$compiler_needs_object" = yes &&
82547a3b38f7Smrg	    test -z "$libobjs"; then
82557a3b38f7Smrg	    # extract the archives, so we have objects to list.
82567a3b38f7Smrg	    # TODO: could optimize this to just extract one archive.
82577a3b38f7Smrg	    whole_archive_flag_spec=
82587a3b38f7Smrg	  fi
82597a3b38f7Smrg	  if test -n "$whole_archive_flag_spec"; then
82607a3b38f7Smrg	    save_libobjs=$libobjs
82617a3b38f7Smrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
82627a3b38f7Smrg	    test "X$libobjs" = "X " && libobjs=
82637a3b38f7Smrg	  else
82647a3b38f7Smrg	    gentop="$output_objdir/${outputname}x"
8265862f5301Smrg	    func_append generated " $gentop"
8266ff559fabSmrg
82677a3b38f7Smrg	    func_extract_archives $gentop $convenience
8268862f5301Smrg	    func_append libobjs " $func_extract_archives_result"
82697a3b38f7Smrg	    test "X$libobjs" = "X " && libobjs=
82707a3b38f7Smrg	  fi
82717a3b38f7Smrg	fi
8272ff559fabSmrg
82737a3b38f7Smrg	if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
82747a3b38f7Smrg	  eval flag=\"$thread_safe_flag_spec\"
8275862f5301Smrg	  func_append linker_flags " $flag"
82767a3b38f7Smrg	fi
8277ff559fabSmrg
82787a3b38f7Smrg	# Make a backup of the uninstalled library when relinking
8279862f5301Smrg	if test "$opt_mode" = relink; then
82807a3b38f7Smrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
8281ff559fabSmrg	fi
8282ff559fabSmrg
82837a3b38f7Smrg	# Do each of the archive commands.
82847a3b38f7Smrg	if test "$module" = yes && test -n "$module_cmds" ; then
82857a3b38f7Smrg	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
82867a3b38f7Smrg	    eval test_cmds=\"$module_expsym_cmds\"
82877a3b38f7Smrg	    cmds=$module_expsym_cmds
82887a3b38f7Smrg	  else
82897a3b38f7Smrg	    eval test_cmds=\"$module_cmds\"
82907a3b38f7Smrg	    cmds=$module_cmds
82917a3b38f7Smrg	  fi
82927a3b38f7Smrg	else
82937a3b38f7Smrg	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
82947a3b38f7Smrg	    eval test_cmds=\"$archive_expsym_cmds\"
82957a3b38f7Smrg	    cmds=$archive_expsym_cmds
82967a3b38f7Smrg	  else
82977a3b38f7Smrg	    eval test_cmds=\"$archive_cmds\"
82987a3b38f7Smrg	    cmds=$archive_cmds
82997a3b38f7Smrg	  fi
8300ff559fabSmrg	fi
8301ff559fabSmrg
83027a3b38f7Smrg	if test "X$skipped_export" != "X:" &&
83037a3b38f7Smrg	   func_len " $test_cmds" &&
83047a3b38f7Smrg	   len=$func_len_result &&
83057a3b38f7Smrg	   test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
83067a3b38f7Smrg	  :
83077a3b38f7Smrg	else
83087a3b38f7Smrg	  # The command line is too long to link in one step, link piecewise
83097a3b38f7Smrg	  # or, if using GNU ld and skipped_export is not :, use a linker
83107a3b38f7Smrg	  # script.
8311ff559fabSmrg
83127a3b38f7Smrg	  # Save the value of $output and $libobjs because we want to
83137a3b38f7Smrg	  # use them later.  If we have whole_archive_flag_spec, we
83147a3b38f7Smrg	  # want to use save_libobjs as it was before
83157a3b38f7Smrg	  # whole_archive_flag_spec was expanded, because we can't
83167a3b38f7Smrg	  # assume the linker understands whole_archive_flag_spec.
83177a3b38f7Smrg	  # This may have to be revisited, in case too many
83187a3b38f7Smrg	  # convenience libraries get linked in and end up exceeding
83197a3b38f7Smrg	  # the spec.
83207a3b38f7Smrg	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
83217a3b38f7Smrg	    save_libobjs=$libobjs
83227a3b38f7Smrg	  fi
83237a3b38f7Smrg	  save_output=$output
832444dda7b2Smrg	  func_basename "$output"
832544dda7b2Smrg	  output_la=$func_basename_result
8326ff559fabSmrg
83277a3b38f7Smrg	  # Clear the reloadable object creation command queue and
83287a3b38f7Smrg	  # initialize k to one.
83297a3b38f7Smrg	  test_cmds=
83307a3b38f7Smrg	  concat_cmds=
83317a3b38f7Smrg	  objlist=
83327a3b38f7Smrg	  last_robj=
83337a3b38f7Smrg	  k=1
8334ff559fabSmrg
83357a3b38f7Smrg	  if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
83367a3b38f7Smrg	    output=${output_objdir}/${output_la}.lnkscript
83377a3b38f7Smrg	    func_verbose "creating GNU ld script: $output"
833844dda7b2Smrg	    echo 'INPUT (' > $output
83397a3b38f7Smrg	    for obj in $save_libobjs
83407a3b38f7Smrg	    do
8341862f5301Smrg	      func_to_tool_file "$obj"
8342862f5301Smrg	      $ECHO "$func_to_tool_file_result" >> $output
83437a3b38f7Smrg	    done
834444dda7b2Smrg	    echo ')' >> $output
8345862f5301Smrg	    func_append delfiles " $output"
8346862f5301Smrg	    func_to_tool_file "$output"
8347862f5301Smrg	    output=$func_to_tool_file_result
83487a3b38f7Smrg	  elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then
83497a3b38f7Smrg	    output=${output_objdir}/${output_la}.lnk
83507a3b38f7Smrg	    func_verbose "creating linker input file list: $output"
83517a3b38f7Smrg	    : > $output
83527a3b38f7Smrg	    set x $save_libobjs
83537a3b38f7Smrg	    shift
83547a3b38f7Smrg	    firstobj=
83557a3b38f7Smrg	    if test "$compiler_needs_object" = yes; then
83567a3b38f7Smrg	      firstobj="$1 "
83577a3b38f7Smrg	      shift
83587a3b38f7Smrg	    fi
83597a3b38f7Smrg	    for obj
83607a3b38f7Smrg	    do
8361862f5301Smrg	      func_to_tool_file "$obj"
8362862f5301Smrg	      $ECHO "$func_to_tool_file_result" >> $output
83637a3b38f7Smrg	    done
8364862f5301Smrg	    func_append delfiles " $output"
8365862f5301Smrg	    func_to_tool_file "$output"
8366862f5301Smrg	    output=$firstobj\"$file_list_spec$func_to_tool_file_result\"
83677a3b38f7Smrg	  else
83687a3b38f7Smrg	    if test -n "$save_libobjs"; then
83697a3b38f7Smrg	      func_verbose "creating reloadable object files..."
83707a3b38f7Smrg	      output=$output_objdir/$output_la-${k}.$objext
83717a3b38f7Smrg	      eval test_cmds=\"$reload_cmds\"
83727a3b38f7Smrg	      func_len " $test_cmds"
83737a3b38f7Smrg	      len0=$func_len_result
83747a3b38f7Smrg	      len=$len0
83757a3b38f7Smrg
83767a3b38f7Smrg	      # Loop over the list of objects to be linked.
83777a3b38f7Smrg	      for obj in $save_libobjs
83787a3b38f7Smrg	      do
83797a3b38f7Smrg		func_len " $obj"
83807a3b38f7Smrg		func_arith $len + $func_len_result
83817a3b38f7Smrg		len=$func_arith_result
83827a3b38f7Smrg		if test "X$objlist" = X ||
83837a3b38f7Smrg		   test "$len" -lt "$max_cmd_len"; then
83847a3b38f7Smrg		  func_append objlist " $obj"
83857a3b38f7Smrg		else
83867a3b38f7Smrg		  # The command $test_cmds is almost too long, add a
83877a3b38f7Smrg		  # command to the queue.
83887a3b38f7Smrg		  if test "$k" -eq 1 ; then
83897a3b38f7Smrg		    # The first file doesn't have a previous command to add.
839044dda7b2Smrg		    reload_objs=$objlist
839144dda7b2Smrg		    eval concat_cmds=\"$reload_cmds\"
83927a3b38f7Smrg		  else
83937a3b38f7Smrg		    # All subsequent reloadable object files will link in
83947a3b38f7Smrg		    # the last one created.
839544dda7b2Smrg		    reload_objs="$objlist $last_robj"
839644dda7b2Smrg		    eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
83977a3b38f7Smrg		  fi
83987a3b38f7Smrg		  last_robj=$output_objdir/$output_la-${k}.$objext
83997a3b38f7Smrg		  func_arith $k + 1
84007a3b38f7Smrg		  k=$func_arith_result
84017a3b38f7Smrg		  output=$output_objdir/$output_la-${k}.$objext
840244dda7b2Smrg		  objlist=" $obj"
84037a3b38f7Smrg		  func_len " $last_robj"
84047a3b38f7Smrg		  func_arith $len0 + $func_len_result
84057a3b38f7Smrg		  len=$func_arith_result
84067a3b38f7Smrg		fi
84077a3b38f7Smrg	      done
84087a3b38f7Smrg	      # Handle the remaining objects by creating one last
84097a3b38f7Smrg	      # reloadable object file.  All subsequent reloadable object
84107a3b38f7Smrg	      # files will link in the last one created.
84117a3b38f7Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
841244dda7b2Smrg	      reload_objs="$objlist $last_robj"
841344dda7b2Smrg	      eval concat_cmds=\"\${concat_cmds}$reload_cmds\"
84147a3b38f7Smrg	      if test -n "$last_robj"; then
84157a3b38f7Smrg	        eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\"
84167a3b38f7Smrg	      fi
8417862f5301Smrg	      func_append delfiles " $output"
8418ff559fabSmrg
84197a3b38f7Smrg	    else
84207a3b38f7Smrg	      output=
84217a3b38f7Smrg	    fi
8422ff559fabSmrg
84237a3b38f7Smrg	    if ${skipped_export-false}; then
84247a3b38f7Smrg	      func_verbose "generating symbol list for \`$libname.la'"
84257a3b38f7Smrg	      export_symbols="$output_objdir/$libname.exp"
84267a3b38f7Smrg	      $opt_dry_run || $RM $export_symbols
84277a3b38f7Smrg	      libobjs=$output
84287a3b38f7Smrg	      # Append the command to create the export file.
84297a3b38f7Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
84307a3b38f7Smrg	      eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
84317a3b38f7Smrg	      if test -n "$last_robj"; then
84327a3b38f7Smrg		eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
84337a3b38f7Smrg	      fi
84347a3b38f7Smrg	    fi
8435ff559fabSmrg
84367a3b38f7Smrg	    test -n "$save_libobjs" &&
84377a3b38f7Smrg	      func_verbose "creating a temporary reloadable object file: $output"
8438ff559fabSmrg
84397a3b38f7Smrg	    # Loop through the commands generated above and execute them.
84407a3b38f7Smrg	    save_ifs="$IFS"; IFS='~'
84417a3b38f7Smrg	    for cmd in $concat_cmds; do
84427a3b38f7Smrg	      IFS="$save_ifs"
84437a3b38f7Smrg	      $opt_silent || {
84447a3b38f7Smrg		  func_quote_for_expand "$cmd"
84457a3b38f7Smrg		  eval "func_echo $func_quote_for_expand_result"
84467a3b38f7Smrg	      }
84477a3b38f7Smrg	      $opt_dry_run || eval "$cmd" || {
84487a3b38f7Smrg		lt_exit=$?
84497a3b38f7Smrg
84507a3b38f7Smrg		# Restore the uninstalled library and exit
8451862f5301Smrg		if test "$opt_mode" = relink; then
84527a3b38f7Smrg		  ( cd "$output_objdir" && \
84537a3b38f7Smrg		    $RM "${realname}T" && \
84547a3b38f7Smrg		    $MV "${realname}U" "$realname" )
84557a3b38f7Smrg		fi
8456ff559fabSmrg
84577a3b38f7Smrg		exit $lt_exit
84587a3b38f7Smrg	      }
84597a3b38f7Smrg	    done
84607a3b38f7Smrg	    IFS="$save_ifs"
84617a3b38f7Smrg
84627a3b38f7Smrg	    if test -n "$export_symbols_regex" && ${skipped_export-false}; then
84637a3b38f7Smrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
84647a3b38f7Smrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
8465ff559fabSmrg	    fi
8466ff559fabSmrg	  fi
8467ff559fabSmrg
84687a3b38f7Smrg          if ${skipped_export-false}; then
84697a3b38f7Smrg	    if test -n "$export_symbols" && test -n "$include_expsyms"; then
84707a3b38f7Smrg	      tmp_export_symbols="$export_symbols"
84717a3b38f7Smrg	      test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
847244dda7b2Smrg	      $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
84737a3b38f7Smrg	    fi
8474ff559fabSmrg
84757a3b38f7Smrg	    if test -n "$orig_export_symbols"; then
84767a3b38f7Smrg	      # The given exports_symbols file has to be filtered, so filter it.
84777a3b38f7Smrg	      func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
84787a3b38f7Smrg	      # FIXME: $output_objdir/$libname.filter potentially contains lots of
84797a3b38f7Smrg	      # 's' commands which not all seds can handle. GNU sed should be fine
84807a3b38f7Smrg	      # though. Also, the filter scales superlinearly with the number of
84817a3b38f7Smrg	      # global variables. join(1) would be nice here, but unfortunately
84827a3b38f7Smrg	      # isn't a blessed tool.
84837a3b38f7Smrg	      $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
8484862f5301Smrg	      func_append delfiles " $export_symbols $output_objdir/$libname.filter"
84857a3b38f7Smrg	      export_symbols=$output_objdir/$libname.def
84867a3b38f7Smrg	      $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
84877a3b38f7Smrg	    fi
84887a3b38f7Smrg	  fi
8489ff559fabSmrg
84907a3b38f7Smrg	  libobjs=$output
84917a3b38f7Smrg	  # Restore the value of output.
84927a3b38f7Smrg	  output=$save_output
8493ff559fabSmrg
84947a3b38f7Smrg	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
84957a3b38f7Smrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
84967a3b38f7Smrg	    test "X$libobjs" = "X " && libobjs=
84977a3b38f7Smrg	  fi
84987a3b38f7Smrg	  # Expand the library linking commands again to reset the
84997a3b38f7Smrg	  # value of $libobjs for piecewise linking.
85007a3b38f7Smrg
85017a3b38f7Smrg	  # Do each of the archive commands.
85027a3b38f7Smrg	  if test "$module" = yes && test -n "$module_cmds" ; then
85037a3b38f7Smrg	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
85047a3b38f7Smrg	      cmds=$module_expsym_cmds
8505ff559fabSmrg	    else
85067a3b38f7Smrg	      cmds=$module_cmds
8507ff559fabSmrg	    fi
8508ff559fabSmrg	  else
85097a3b38f7Smrg	    if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
85107a3b38f7Smrg	      cmds=$archive_expsym_cmds
85117a3b38f7Smrg	    else
85127a3b38f7Smrg	      cmds=$archive_cmds
85137a3b38f7Smrg	    fi
8514ff559fabSmrg	  fi
8515ff559fabSmrg	fi
8516ff559fabSmrg
85177a3b38f7Smrg	if test -n "$delfiles"; then
85187a3b38f7Smrg	  # Append the command to remove temporary files to $cmds.
85197a3b38f7Smrg	  eval cmds=\"\$cmds~\$RM $delfiles\"
85207a3b38f7Smrg	fi
8521ff559fabSmrg
85227a3b38f7Smrg	# Add any objects from preloaded convenience libraries
85237a3b38f7Smrg	if test -n "$dlprefiles"; then
85247a3b38f7Smrg	  gentop="$output_objdir/${outputname}x"
8525862f5301Smrg	  func_append generated " $gentop"
8526ff559fabSmrg
85277a3b38f7Smrg	  func_extract_archives $gentop $dlprefiles
8528862f5301Smrg	  func_append libobjs " $func_extract_archives_result"
85297a3b38f7Smrg	  test "X$libobjs" = "X " && libobjs=
8530ff559fabSmrg	fi
8531ff559fabSmrg
85327a3b38f7Smrg	save_ifs="$IFS"; IFS='~'
85337a3b38f7Smrg	for cmd in $cmds; do
85347a3b38f7Smrg	  IFS="$save_ifs"
85357a3b38f7Smrg	  eval cmd=\"$cmd\"
85367a3b38f7Smrg	  $opt_silent || {
85377a3b38f7Smrg	    func_quote_for_expand "$cmd"
85387a3b38f7Smrg	    eval "func_echo $func_quote_for_expand_result"
85397a3b38f7Smrg	  }
85407a3b38f7Smrg	  $opt_dry_run || eval "$cmd" || {
85417a3b38f7Smrg	    lt_exit=$?
8542ff559fabSmrg
85437a3b38f7Smrg	    # Restore the uninstalled library and exit
8544862f5301Smrg	    if test "$opt_mode" = relink; then
85457a3b38f7Smrg	      ( cd "$output_objdir" && \
85467a3b38f7Smrg	        $RM "${realname}T" && \
85477a3b38f7Smrg		$MV "${realname}U" "$realname" )
85487a3b38f7Smrg	    fi
85497a3b38f7Smrg
85507a3b38f7Smrg	    exit $lt_exit
85517a3b38f7Smrg	  }
85527a3b38f7Smrg	done
85537a3b38f7Smrg	IFS="$save_ifs"
85547a3b38f7Smrg
85557a3b38f7Smrg	# Restore the uninstalled library and exit
8556862f5301Smrg	if test "$opt_mode" = relink; then
85577a3b38f7Smrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
85587a3b38f7Smrg
85597a3b38f7Smrg	  if test -n "$convenience"; then
85607a3b38f7Smrg	    if test -z "$whole_archive_flag_spec"; then
85617a3b38f7Smrg	      func_show_eval '${RM}r "$gentop"'
8562ff559fabSmrg	    fi
8563ff559fabSmrg	  fi
8564ff559fabSmrg
85657a3b38f7Smrg	  exit $EXIT_SUCCESS
85667a3b38f7Smrg	fi
8567ff559fabSmrg
85687a3b38f7Smrg	# Create links to the real library.
85697a3b38f7Smrg	for linkname in $linknames; do
85707a3b38f7Smrg	  if test "$realname" != "$linkname"; then
85717a3b38f7Smrg	    func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
85727a3b38f7Smrg	  fi
85737a3b38f7Smrg	done
85747a3b38f7Smrg
85757a3b38f7Smrg	# If -module or -export-dynamic was specified, set the dlname.
85767a3b38f7Smrg	if test "$module" = yes || test "$export_dynamic" = yes; then
85777a3b38f7Smrg	  # On all known operating systems, these are identical.
85787a3b38f7Smrg	  dlname="$soname"
85797a3b38f7Smrg	fi
85807a3b38f7Smrg      fi
85817a3b38f7Smrg      ;;
85827a3b38f7Smrg
85837a3b38f7Smrg    obj)
85847a3b38f7Smrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
85857a3b38f7Smrg	func_warning "\`-dlopen' is ignored for objects"
85867a3b38f7Smrg      fi
85877a3b38f7Smrg
85887a3b38f7Smrg      case " $deplibs" in
85897a3b38f7Smrg      *\ -l* | *\ -L*)
85907a3b38f7Smrg	func_warning "\`-l' and \`-L' are ignored for objects" ;;
85917a3b38f7Smrg      esac
85927a3b38f7Smrg
85937a3b38f7Smrg      test -n "$rpath" && \
85947a3b38f7Smrg	func_warning "\`-rpath' is ignored for objects"
85957a3b38f7Smrg
85967a3b38f7Smrg      test -n "$xrpath" && \
85977a3b38f7Smrg	func_warning "\`-R' is ignored for objects"
85987a3b38f7Smrg
85997a3b38f7Smrg      test -n "$vinfo" && \
86007a3b38f7Smrg	func_warning "\`-version-info' is ignored for objects"
86017a3b38f7Smrg
86027a3b38f7Smrg      test -n "$release" && \
86037a3b38f7Smrg	func_warning "\`-release' is ignored for objects"
86047a3b38f7Smrg
86057a3b38f7Smrg      case $output in
86067a3b38f7Smrg      *.lo)
86077a3b38f7Smrg	test -n "$objs$old_deplibs" && \
86087a3b38f7Smrg	  func_fatal_error "cannot build library object \`$output' from non-libtool objects"
86097a3b38f7Smrg
86107a3b38f7Smrg	libobj=$output
86117a3b38f7Smrg	func_lo2o "$libobj"
86127a3b38f7Smrg	obj=$func_lo2o_result
86137a3b38f7Smrg	;;
86147a3b38f7Smrg      *)
86157a3b38f7Smrg	libobj=
86167a3b38f7Smrg	obj="$output"
86177a3b38f7Smrg	;;
86187a3b38f7Smrg      esac
86197a3b38f7Smrg
86207a3b38f7Smrg      # Delete the old objects.
86217a3b38f7Smrg      $opt_dry_run || $RM $obj $libobj
86227a3b38f7Smrg
86237a3b38f7Smrg      # Objects from convenience libraries.  This assumes
86247a3b38f7Smrg      # single-version convenience libraries.  Whenever we create
86257a3b38f7Smrg      # different ones for PIC/non-PIC, this we'll have to duplicate
86267a3b38f7Smrg      # the extraction.
86277a3b38f7Smrg      reload_conv_objs=
86287a3b38f7Smrg      gentop=
86297a3b38f7Smrg      # reload_cmds runs $LD directly, so let us get rid of
86307a3b38f7Smrg      # -Wl from whole_archive_flag_spec and hope we can get by with
86317a3b38f7Smrg      # turning comma into space..
86327a3b38f7Smrg      wl=
86337a3b38f7Smrg
86347a3b38f7Smrg      if test -n "$convenience"; then
86357a3b38f7Smrg	if test -n "$whole_archive_flag_spec"; then
86367a3b38f7Smrg	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
863744dda7b2Smrg	  reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
86387a3b38f7Smrg	else
86397a3b38f7Smrg	  gentop="$output_objdir/${obj}x"
8640862f5301Smrg	  func_append generated " $gentop"
86417a3b38f7Smrg
86427a3b38f7Smrg	  func_extract_archives $gentop $convenience
86437a3b38f7Smrg	  reload_conv_objs="$reload_objs $func_extract_archives_result"
86447a3b38f7Smrg	fi
86457a3b38f7Smrg      fi
8646ff559fabSmrg
8647862f5301Smrg      # If we're not building shared, we need to use non_pic_objs
8648862f5301Smrg      test "$build_libtool_libs" != yes && libobjs="$non_pic_objects"
8649862f5301Smrg
86507a3b38f7Smrg      # Create the old-style object.
865144dda7b2Smrg      reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
8652ff559fabSmrg
86537a3b38f7Smrg      output="$obj"
86547a3b38f7Smrg      func_execute_cmds "$reload_cmds" 'exit $?'
8655ff559fabSmrg
86567a3b38f7Smrg      # Exit if we aren't doing a library object file.
86577a3b38f7Smrg      if test -z "$libobj"; then
86587a3b38f7Smrg	if test -n "$gentop"; then
86597a3b38f7Smrg	  func_show_eval '${RM}r "$gentop"'
86607a3b38f7Smrg	fi
8661ff559fabSmrg
86627a3b38f7Smrg	exit $EXIT_SUCCESS
86637a3b38f7Smrg      fi
8664ff559fabSmrg
86657a3b38f7Smrg      if test "$build_libtool_libs" != yes; then
86667a3b38f7Smrg	if test -n "$gentop"; then
86677a3b38f7Smrg	  func_show_eval '${RM}r "$gentop"'
86687a3b38f7Smrg	fi
8669ff559fabSmrg
86707a3b38f7Smrg	# Create an invalid libtool object if no PIC, so that we don't
86717a3b38f7Smrg	# accidentally link it into a program.
86727a3b38f7Smrg	# $show "echo timestamp > $libobj"
86737a3b38f7Smrg	# $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
86747a3b38f7Smrg	exit $EXIT_SUCCESS
86757a3b38f7Smrg      fi
8676ff559fabSmrg
86777a3b38f7Smrg      if test -n "$pic_flag" || test "$pic_mode" != default; then
86787a3b38f7Smrg	# Only do commands if we really have different PIC objects.
86797a3b38f7Smrg	reload_objs="$libobjs $reload_conv_objs"
86807a3b38f7Smrg	output="$libobj"
86817a3b38f7Smrg	func_execute_cmds "$reload_cmds" 'exit $?'
8682ff559fabSmrg      fi
8683ff559fabSmrg
86847a3b38f7Smrg      if test -n "$gentop"; then
86857a3b38f7Smrg	func_show_eval '${RM}r "$gentop"'
86867a3b38f7Smrg      fi
8687ff559fabSmrg
86887a3b38f7Smrg      exit $EXIT_SUCCESS
86897a3b38f7Smrg      ;;
8690ff559fabSmrg
86917a3b38f7Smrg    prog)
86927a3b38f7Smrg      case $host in
86937a3b38f7Smrg	*cygwin*) func_stripname '' '.exe' "$output"
86947a3b38f7Smrg	          output=$func_stripname_result.exe;;
8695ff559fabSmrg      esac
86967a3b38f7Smrg      test -n "$vinfo" && \
86977a3b38f7Smrg	func_warning "\`-version-info' is ignored for programs"
8698ff559fabSmrg
86997a3b38f7Smrg      test -n "$release" && \
87007a3b38f7Smrg	func_warning "\`-release' is ignored for programs"
8701ff559fabSmrg
87027a3b38f7Smrg      test "$preload" = yes \
87037a3b38f7Smrg        && test "$dlopen_support" = unknown \
87047a3b38f7Smrg	&& test "$dlopen_self" = unknown \
87057a3b38f7Smrg	&& test "$dlopen_self_static" = unknown && \
87067a3b38f7Smrg	  func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support."
8707ff559fabSmrg
87087a3b38f7Smrg      case $host in
87097a3b38f7Smrg      *-*-rhapsody* | *-*-darwin1.[012])
87107a3b38f7Smrg	# On Rhapsody replace the C library is the System framework
871144dda7b2Smrg	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
871244dda7b2Smrg	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
8713ff559fabSmrg	;;
8714ff559fabSmrg      esac
8715ff559fabSmrg
87167a3b38f7Smrg      case $host in
87177a3b38f7Smrg      *-*-darwin*)
87187a3b38f7Smrg	# Don't allow lazy linking, it breaks C++ global constructors
87197a3b38f7Smrg	# But is supposedly fixed on 10.4 or later (yay!).
87207a3b38f7Smrg	if test "$tagname" = CXX ; then
87217a3b38f7Smrg	  case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
87227a3b38f7Smrg	    10.[0123])
8723862f5301Smrg	      func_append compile_command " ${wl}-bind_at_load"
8724862f5301Smrg	      func_append finalize_command " ${wl}-bind_at_load"
87257a3b38f7Smrg	    ;;
87267a3b38f7Smrg	  esac
87277a3b38f7Smrg	fi
87287a3b38f7Smrg	# Time to change all our "foo.ltframework" stuff back to "-framework foo"
872944dda7b2Smrg	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
873044dda7b2Smrg	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8731ff559fabSmrg	;;
8732ff559fabSmrg      esac
8733ff559fabSmrg
8734ff559fabSmrg
87357a3b38f7Smrg      # move library search paths that coincide with paths to not yet
87367a3b38f7Smrg      # installed libraries to the beginning of the library search list
87377a3b38f7Smrg      new_libs=
87387a3b38f7Smrg      for path in $notinst_path; do
87397a3b38f7Smrg	case " $new_libs " in
87407a3b38f7Smrg	*" -L$path/$objdir "*) ;;
8741ff559fabSmrg	*)
87427a3b38f7Smrg	  case " $compile_deplibs " in
87437a3b38f7Smrg	  *" -L$path/$objdir "*)
8744862f5301Smrg	    func_append new_libs " -L$path/$objdir" ;;
87457a3b38f7Smrg	  esac
8746ff559fabSmrg	  ;;
8747ff559fabSmrg	esac
8748ff559fabSmrg      done
87497a3b38f7Smrg      for deplib in $compile_deplibs; do
87507a3b38f7Smrg	case $deplib in
87517a3b38f7Smrg	-L*)
87527a3b38f7Smrg	  case " $new_libs " in
87537a3b38f7Smrg	  *" $deplib "*) ;;
8754862f5301Smrg	  *) func_append new_libs " $deplib" ;;
87557a3b38f7Smrg	  esac
87567a3b38f7Smrg	  ;;
8757862f5301Smrg	*) func_append new_libs " $deplib" ;;
87587a3b38f7Smrg	esac
87597a3b38f7Smrg      done
87607a3b38f7Smrg      compile_deplibs="$new_libs"
8761ff559fabSmrg
8762ff559fabSmrg
8763862f5301Smrg      func_append compile_command " $compile_deplibs"
8764862f5301Smrg      func_append finalize_command " $finalize_deplibs"
8765ff559fabSmrg
87667a3b38f7Smrg      if test -n "$rpath$xrpath"; then
87677a3b38f7Smrg	# If the user specified any rpath flags, then add them.
87687a3b38f7Smrg	for libdir in $rpath $xrpath; do
87697a3b38f7Smrg	  # This is the magic to use -rpath.
87707a3b38f7Smrg	  case "$finalize_rpath " in
87717a3b38f7Smrg	  *" $libdir "*) ;;
8772862f5301Smrg	  *) func_append finalize_rpath " $libdir" ;;
87737a3b38f7Smrg	  esac
87747a3b38f7Smrg	done
87757a3b38f7Smrg      fi
8776ff559fabSmrg
87777a3b38f7Smrg      # Now hardcode the library paths
87787a3b38f7Smrg      rpath=
87797a3b38f7Smrg      hardcode_libdirs=
87807a3b38f7Smrg      for libdir in $compile_rpath $finalize_rpath; do
87817a3b38f7Smrg	if test -n "$hardcode_libdir_flag_spec"; then
87827a3b38f7Smrg	  if test -n "$hardcode_libdir_separator"; then
87837a3b38f7Smrg	    if test -z "$hardcode_libdirs"; then
87847a3b38f7Smrg	      hardcode_libdirs="$libdir"
87857a3b38f7Smrg	    else
87867a3b38f7Smrg	      # Just accumulate the unique libdirs.
87877a3b38f7Smrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
87887a3b38f7Smrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
87897a3b38f7Smrg		;;
87907a3b38f7Smrg	      *)
8791862f5301Smrg		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
87927a3b38f7Smrg		;;
87937a3b38f7Smrg	      esac
87947a3b38f7Smrg	    fi
87957a3b38f7Smrg	  else
87967a3b38f7Smrg	    eval flag=\"$hardcode_libdir_flag_spec\"
8797862f5301Smrg	    func_append rpath " $flag"
87987a3b38f7Smrg	  fi
87997a3b38f7Smrg	elif test -n "$runpath_var"; then
88007a3b38f7Smrg	  case "$perm_rpath " in
8801ff559fabSmrg	  *" $libdir "*) ;;
8802862f5301Smrg	  *) func_append perm_rpath " $libdir" ;;
8803ff559fabSmrg	  esac
88047a3b38f7Smrg	fi
88057a3b38f7Smrg	case $host in
88067a3b38f7Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
88077a3b38f7Smrg	  testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'`
88087a3b38f7Smrg	  case :$dllsearchpath: in
88097a3b38f7Smrg	  *":$libdir:"*) ;;
88107a3b38f7Smrg	  ::) dllsearchpath=$libdir;;
8811862f5301Smrg	  *) func_append dllsearchpath ":$libdir";;
88127a3b38f7Smrg	  esac
88137a3b38f7Smrg	  case :$dllsearchpath: in
88147a3b38f7Smrg	  *":$testbindir:"*) ;;
88157a3b38f7Smrg	  ::) dllsearchpath=$testbindir;;
8816862f5301Smrg	  *) func_append dllsearchpath ":$testbindir";;
88177a3b38f7Smrg	  esac
88187a3b38f7Smrg	  ;;
88197a3b38f7Smrg	esac
88207a3b38f7Smrg      done
88217a3b38f7Smrg      # Substitute the hardcoded libdirs into the rpath.
88227a3b38f7Smrg      if test -n "$hardcode_libdir_separator" &&
88237a3b38f7Smrg	 test -n "$hardcode_libdirs"; then
88247a3b38f7Smrg	libdir="$hardcode_libdirs"
88257a3b38f7Smrg	eval rpath=\" $hardcode_libdir_flag_spec\"
88267a3b38f7Smrg      fi
88277a3b38f7Smrg      compile_rpath="$rpath"
88287a3b38f7Smrg
88297a3b38f7Smrg      rpath=
88307a3b38f7Smrg      hardcode_libdirs=
88317a3b38f7Smrg      for libdir in $finalize_rpath; do
88327a3b38f7Smrg	if test -n "$hardcode_libdir_flag_spec"; then
88337a3b38f7Smrg	  if test -n "$hardcode_libdir_separator"; then
88347a3b38f7Smrg	    if test -z "$hardcode_libdirs"; then
88357a3b38f7Smrg	      hardcode_libdirs="$libdir"
88367a3b38f7Smrg	    else
88377a3b38f7Smrg	      # Just accumulate the unique libdirs.
88387a3b38f7Smrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
88397a3b38f7Smrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
88407a3b38f7Smrg		;;
88417a3b38f7Smrg	      *)
8842862f5301Smrg		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
88437a3b38f7Smrg		;;
88447a3b38f7Smrg	      esac
88457a3b38f7Smrg	    fi
88467a3b38f7Smrg	  else
88477a3b38f7Smrg	    eval flag=\"$hardcode_libdir_flag_spec\"
8848862f5301Smrg	    func_append rpath " $flag"
88497a3b38f7Smrg	  fi
88507a3b38f7Smrg	elif test -n "$runpath_var"; then
88517a3b38f7Smrg	  case "$finalize_perm_rpath " in
8852ff559fabSmrg	  *" $libdir "*) ;;
8853862f5301Smrg	  *) func_append finalize_perm_rpath " $libdir" ;;
8854ff559fabSmrg	  esac
8855ff559fabSmrg	fi
88567a3b38f7Smrg      done
88577a3b38f7Smrg      # Substitute the hardcoded libdirs into the rpath.
88587a3b38f7Smrg      if test -n "$hardcode_libdir_separator" &&
88597a3b38f7Smrg	 test -n "$hardcode_libdirs"; then
88607a3b38f7Smrg	libdir="$hardcode_libdirs"
88617a3b38f7Smrg	eval rpath=\" $hardcode_libdir_flag_spec\"
88627a3b38f7Smrg      fi
88637a3b38f7Smrg      finalize_rpath="$rpath"
8864ff559fabSmrg
88657a3b38f7Smrg      if test -n "$libobjs" && test "$build_old_libs" = yes; then
88667a3b38f7Smrg	# Transform all the library objects into standard objects.
886744dda7b2Smrg	compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
886844dda7b2Smrg	finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
88697a3b38f7Smrg      fi
8870ff559fabSmrg
88717a3b38f7Smrg      func_generate_dlsyms "$outputname" "@PROGRAM@" "no"
8872ff559fabSmrg
88737a3b38f7Smrg      # template prelinking step
88747a3b38f7Smrg      if test -n "$prelink_cmds"; then
88757a3b38f7Smrg	func_execute_cmds "$prelink_cmds" 'exit $?'
88767a3b38f7Smrg      fi
8877ff559fabSmrg
88787a3b38f7Smrg      wrappers_required=yes
88797a3b38f7Smrg      case $host in
888044dda7b2Smrg      *cegcc* | *mingw32ce*)
888144dda7b2Smrg        # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
888244dda7b2Smrg        wrappers_required=no
888344dda7b2Smrg        ;;
88847a3b38f7Smrg      *cygwin* | *mingw* )
88857a3b38f7Smrg        if test "$build_libtool_libs" != yes; then
88867a3b38f7Smrg          wrappers_required=no
88877a3b38f7Smrg        fi
88887a3b38f7Smrg        ;;
88897a3b38f7Smrg      *)
88907a3b38f7Smrg        if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
88917a3b38f7Smrg          wrappers_required=no
88927a3b38f7Smrg        fi
88937a3b38f7Smrg        ;;
88947a3b38f7Smrg      esac
88957a3b38f7Smrg      if test "$wrappers_required" = no; then
88967a3b38f7Smrg	# Replace the output file specification.
889744dda7b2Smrg	compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
88987a3b38f7Smrg	link_command="$compile_command$compile_rpath"
8899ff559fabSmrg
89007a3b38f7Smrg	# We have no uninstalled library dependencies, so finalize right now.
89017a3b38f7Smrg	exit_status=0
89027a3b38f7Smrg	func_show_eval "$link_command" 'exit_status=$?'
8903ff559fabSmrg
8904862f5301Smrg	if test -n "$postlink_cmds"; then
8905862f5301Smrg	  func_to_tool_file "$output"
8906862f5301Smrg	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
8907862f5301Smrg	  func_execute_cmds "$postlink_cmds" 'exit $?'
8908862f5301Smrg	fi
8909862f5301Smrg
89107a3b38f7Smrg	# Delete the generated files.
89117a3b38f7Smrg	if test -f "$output_objdir/${outputname}S.${objext}"; then
89127a3b38f7Smrg	  func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"'
89137a3b38f7Smrg	fi
8914ff559fabSmrg
89157a3b38f7Smrg	exit $exit_status
89167a3b38f7Smrg      fi
8917ff559fabSmrg
89187a3b38f7Smrg      if test -n "$compile_shlibpath$finalize_shlibpath"; then
89197a3b38f7Smrg	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
89207a3b38f7Smrg      fi
89217a3b38f7Smrg      if test -n "$finalize_shlibpath"; then
89227a3b38f7Smrg	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
89237a3b38f7Smrg      fi
8924ff559fabSmrg
89257a3b38f7Smrg      compile_var=
89267a3b38f7Smrg      finalize_var=
89277a3b38f7Smrg      if test -n "$runpath_var"; then
89287a3b38f7Smrg	if test -n "$perm_rpath"; then
89297a3b38f7Smrg	  # We should set the runpath_var.
89307a3b38f7Smrg	  rpath=
89317a3b38f7Smrg	  for dir in $perm_rpath; do
8932862f5301Smrg	    func_append rpath "$dir:"
8933ff559fabSmrg	  done
89347a3b38f7Smrg	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
8935ff559fabSmrg	fi
89367a3b38f7Smrg	if test -n "$finalize_perm_rpath"; then
89377a3b38f7Smrg	  # We should set the runpath_var.
89387a3b38f7Smrg	  rpath=
89397a3b38f7Smrg	  for dir in $finalize_perm_rpath; do
8940862f5301Smrg	    func_append rpath "$dir:"
89417a3b38f7Smrg	  done
89427a3b38f7Smrg	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
89437a3b38f7Smrg	fi
89447a3b38f7Smrg      fi
8945ff559fabSmrg
89467a3b38f7Smrg      if test "$no_install" = yes; then
89477a3b38f7Smrg	# We don't need to create a wrapper script.
89487a3b38f7Smrg	link_command="$compile_var$compile_command$compile_rpath"
89497a3b38f7Smrg	# Replace the output file specification.
895044dda7b2Smrg	link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
89517a3b38f7Smrg	# Delete the old output file.
89527a3b38f7Smrg	$opt_dry_run || $RM $output
89537a3b38f7Smrg	# Link the executable and exit
89547a3b38f7Smrg	func_show_eval "$link_command" 'exit $?'
8955862f5301Smrg
8956862f5301Smrg	if test -n "$postlink_cmds"; then
8957862f5301Smrg	  func_to_tool_file "$output"
8958862f5301Smrg	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
8959862f5301Smrg	  func_execute_cmds "$postlink_cmds" 'exit $?'
8960862f5301Smrg	fi
8961862f5301Smrg
89627a3b38f7Smrg	exit $EXIT_SUCCESS
89637a3b38f7Smrg      fi
8964ff559fabSmrg
89657a3b38f7Smrg      if test "$hardcode_action" = relink; then
89667a3b38f7Smrg	# Fast installation is not supported
89677a3b38f7Smrg	link_command="$compile_var$compile_command$compile_rpath"
89687a3b38f7Smrg	relink_command="$finalize_var$finalize_command$finalize_rpath"
8969ff559fabSmrg
89707a3b38f7Smrg	func_warning "this platform does not like uninstalled shared libraries"
89717a3b38f7Smrg	func_warning "\`$output' will be relinked during installation"
89727a3b38f7Smrg      else
89737a3b38f7Smrg	if test "$fast_install" != no; then
89747a3b38f7Smrg	  link_command="$finalize_var$compile_command$finalize_rpath"
89757a3b38f7Smrg	  if test "$fast_install" = yes; then
897644dda7b2Smrg	    relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
89777a3b38f7Smrg	  else
89787a3b38f7Smrg	    # fast_install is set to needless
89797a3b38f7Smrg	    relink_command=
89807a3b38f7Smrg	  fi
8981ff559fabSmrg	else
89827a3b38f7Smrg	  link_command="$compile_var$compile_command$compile_rpath"
89837a3b38f7Smrg	  relink_command="$finalize_var$finalize_command$finalize_rpath"
8984ff559fabSmrg	fi
89857a3b38f7Smrg      fi
8986ff559fabSmrg
89877a3b38f7Smrg      # Replace the output file specification.
898844dda7b2Smrg      link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
8989ff559fabSmrg
89907a3b38f7Smrg      # Delete the old output files.
89917a3b38f7Smrg      $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
8992ff559fabSmrg
89937a3b38f7Smrg      func_show_eval "$link_command" 'exit $?'
8994ff559fabSmrg
8995862f5301Smrg      if test -n "$postlink_cmds"; then
8996862f5301Smrg	func_to_tool_file "$output_objdir/$outputname"
8997862f5301Smrg	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'`
8998862f5301Smrg	func_execute_cmds "$postlink_cmds" 'exit $?'
8999862f5301Smrg      fi
9000862f5301Smrg
90017a3b38f7Smrg      # Now create the wrapper script.
90027a3b38f7Smrg      func_verbose "creating $output"
9003ff559fabSmrg
90047a3b38f7Smrg      # Quote the relink command for shipping.
90057a3b38f7Smrg      if test -n "$relink_command"; then
90067a3b38f7Smrg	# Preserve any variables that may affect compiler behavior
90077a3b38f7Smrg	for var in $variables_saved_for_relink; do
90087a3b38f7Smrg	  if eval test -z \"\${$var+set}\"; then
90097a3b38f7Smrg	    relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
90107a3b38f7Smrg	  elif eval var_value=\$$var; test -z "$var_value"; then
90117a3b38f7Smrg	    relink_command="$var=; export $var; $relink_command"
90127a3b38f7Smrg	  else
90137a3b38f7Smrg	    func_quote_for_eval "$var_value"
90147a3b38f7Smrg	    relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
90157a3b38f7Smrg	  fi
90167a3b38f7Smrg	done
90177a3b38f7Smrg	relink_command="(cd `pwd`; $relink_command)"
901844dda7b2Smrg	relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
90197a3b38f7Smrg      fi
9020ff559fabSmrg
90217a3b38f7Smrg      # Only actually do things if not in dry run mode.
90227a3b38f7Smrg      $opt_dry_run || {
90237a3b38f7Smrg	# win32 will think the script is a binary if it has
90247a3b38f7Smrg	# a .exe suffix, so we strip it off here.
90257a3b38f7Smrg	case $output in
90267a3b38f7Smrg	  *.exe) func_stripname '' '.exe' "$output"
90277a3b38f7Smrg	         output=$func_stripname_result ;;
90287a3b38f7Smrg	esac
90297a3b38f7Smrg	# test for cygwin because mv fails w/o .exe extensions
9030ff559fabSmrg	case $host in
90317a3b38f7Smrg	  *cygwin*)
90327a3b38f7Smrg	    exeext=.exe
90337a3b38f7Smrg	    func_stripname '' '.exe' "$outputname"
90347a3b38f7Smrg	    outputname=$func_stripname_result ;;
90357a3b38f7Smrg	  *) exeext= ;;
9036ff559fabSmrg	esac
90377a3b38f7Smrg	case $host in
90387a3b38f7Smrg	  *cygwin* | *mingw* )
90397a3b38f7Smrg	    func_dirname_and_basename "$output" "" "."
90407a3b38f7Smrg	    output_name=$func_basename_result
90417a3b38f7Smrg	    output_path=$func_dirname_result
90427a3b38f7Smrg	    cwrappersource="$output_path/$objdir/lt-$output_name.c"
90437a3b38f7Smrg	    cwrapper="$output_path/$output_name.exe"
90447a3b38f7Smrg	    $RM $cwrappersource $cwrapper
90457a3b38f7Smrg	    trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
90467a3b38f7Smrg
90477a3b38f7Smrg	    func_emit_cwrapperexe_src > $cwrappersource
90487a3b38f7Smrg
90497a3b38f7Smrg	    # The wrapper executable is built using the $host compiler,
90507a3b38f7Smrg	    # because it contains $host paths and files. If cross-
90517a3b38f7Smrg	    # compiling, it, like the target executable, must be
90527a3b38f7Smrg	    # executed on the $host or under an emulation environment.
90537a3b38f7Smrg	    $opt_dry_run || {
90547a3b38f7Smrg	      $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
90557a3b38f7Smrg	      $STRIP $cwrapper
90567a3b38f7Smrg	    }
9057ff559fabSmrg
90587a3b38f7Smrg	    # Now, create the wrapper script for func_source use:
90597a3b38f7Smrg	    func_ltwrapper_scriptname $cwrapper
90607a3b38f7Smrg	    $RM $func_ltwrapper_scriptname_result
90617a3b38f7Smrg	    trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
90627a3b38f7Smrg	    $opt_dry_run || {
90637a3b38f7Smrg	      # note: this script will not be executed, so do not chmod.
90647a3b38f7Smrg	      if test "x$build" = "x$host" ; then
90657a3b38f7Smrg		$cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
9066ff559fabSmrg	      else
90677a3b38f7Smrg		func_emit_wrapper no > $func_ltwrapper_scriptname_result
9068ff559fabSmrg	      fi
90697a3b38f7Smrg	    }
90707a3b38f7Smrg	  ;;
90717a3b38f7Smrg	  * )
90727a3b38f7Smrg	    $RM $output
90737a3b38f7Smrg	    trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
9074ff559fabSmrg
90757a3b38f7Smrg	    func_emit_wrapper no > $output
90767a3b38f7Smrg	    chmod +x $output
9077ff559fabSmrg	  ;;
9078ff559fabSmrg	esac
90797a3b38f7Smrg      }
90807a3b38f7Smrg      exit $EXIT_SUCCESS
90817a3b38f7Smrg      ;;
90827a3b38f7Smrg    esac
9083ff559fabSmrg
90847a3b38f7Smrg    # See if we need to build an old-fashioned archive.
90857a3b38f7Smrg    for oldlib in $oldlibs; do
9086ff559fabSmrg
90877a3b38f7Smrg      if test "$build_libtool_libs" = convenience; then
90887a3b38f7Smrg	oldobjs="$libobjs_save $symfileobj"
90897a3b38f7Smrg	addlibs="$convenience"
90907a3b38f7Smrg	build_libtool_libs=no
90917a3b38f7Smrg      else
90927a3b38f7Smrg	if test "$build_libtool_libs" = module; then
90937a3b38f7Smrg	  oldobjs="$libobjs_save"
90947a3b38f7Smrg	  build_libtool_libs=no
90957a3b38f7Smrg	else
90967a3b38f7Smrg	  oldobjs="$old_deplibs $non_pic_objects"
90977a3b38f7Smrg	  if test "$preload" = yes && test -f "$symfileobj"; then
9098862f5301Smrg	    func_append oldobjs " $symfileobj"
90997a3b38f7Smrg	  fi
91007a3b38f7Smrg	fi
91017a3b38f7Smrg	addlibs="$old_convenience"
9102ff559fabSmrg      fi
9103ff559fabSmrg
91047a3b38f7Smrg      if test -n "$addlibs"; then
91057a3b38f7Smrg	gentop="$output_objdir/${outputname}x"
9106862f5301Smrg	func_append generated " $gentop"
9107ff559fabSmrg
91087a3b38f7Smrg	func_extract_archives $gentop $addlibs
9109862f5301Smrg	func_append oldobjs " $func_extract_archives_result"
91107a3b38f7Smrg      fi
9111ff559fabSmrg
91127a3b38f7Smrg      # Do each command in the archive commands.
91137a3b38f7Smrg      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
91147a3b38f7Smrg	cmds=$old_archive_from_new_cmds
91157a3b38f7Smrg      else
9116ff559fabSmrg
91177a3b38f7Smrg	# Add any objects from preloaded convenience libraries
91187a3b38f7Smrg	if test -n "$dlprefiles"; then
91197a3b38f7Smrg	  gentop="$output_objdir/${outputname}x"
9120862f5301Smrg	  func_append generated " $gentop"
9121ff559fabSmrg
91227a3b38f7Smrg	  func_extract_archives $gentop $dlprefiles
9123862f5301Smrg	  func_append oldobjs " $func_extract_archives_result"
91247a3b38f7Smrg	fi
9125ff559fabSmrg
91267a3b38f7Smrg	# POSIX demands no paths to be encoded in archives.  We have
91277a3b38f7Smrg	# to avoid creating archives with duplicate basenames if we
91287a3b38f7Smrg	# might have to extract them afterwards, e.g., when creating a
91297a3b38f7Smrg	# static archive out of a convenience library, or when linking
91307a3b38f7Smrg	# the entirety of a libtool archive into another (currently
91317a3b38f7Smrg	# not supported by libtool).
91327a3b38f7Smrg	if (for obj in $oldobjs
91337a3b38f7Smrg	    do
91347a3b38f7Smrg	      func_basename "$obj"
91357a3b38f7Smrg	      $ECHO "$func_basename_result"
91367a3b38f7Smrg	    done | sort | sort -uc >/dev/null 2>&1); then
91377a3b38f7Smrg	  :
91387a3b38f7Smrg	else
913944dda7b2Smrg	  echo "copying selected object files to avoid basename conflicts..."
91407a3b38f7Smrg	  gentop="$output_objdir/${outputname}x"
9141862f5301Smrg	  func_append generated " $gentop"
91427a3b38f7Smrg	  func_mkdir_p "$gentop"
91437a3b38f7Smrg	  save_oldobjs=$oldobjs
91447a3b38f7Smrg	  oldobjs=
91457a3b38f7Smrg	  counter=1
91467a3b38f7Smrg	  for obj in $save_oldobjs
91477a3b38f7Smrg	  do
91487a3b38f7Smrg	    func_basename "$obj"
91497a3b38f7Smrg	    objbase="$func_basename_result"
91507a3b38f7Smrg	    case " $oldobjs " in
91517a3b38f7Smrg	    " ") oldobjs=$obj ;;
91527a3b38f7Smrg	    *[\ /]"$objbase "*)
91537a3b38f7Smrg	      while :; do
91547a3b38f7Smrg		# Make sure we don't pick an alternate name that also
91557a3b38f7Smrg		# overlaps.
91567a3b38f7Smrg		newobj=lt$counter-$objbase
91577a3b38f7Smrg		func_arith $counter + 1
91587a3b38f7Smrg		counter=$func_arith_result
91597a3b38f7Smrg		case " $oldobjs " in
91607a3b38f7Smrg		*[\ /]"$newobj "*) ;;
91617a3b38f7Smrg		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
91627a3b38f7Smrg		esac
91637a3b38f7Smrg	      done
91647a3b38f7Smrg	      func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
9165862f5301Smrg	      func_append oldobjs " $gentop/$newobj"
91667a3b38f7Smrg	      ;;
9167862f5301Smrg	    *) func_append oldobjs " $obj" ;;
91687a3b38f7Smrg	    esac
9169ff559fabSmrg	  done
9170ff559fabSmrg	fi
9171fc544a13Smrg	func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
9172fc544a13Smrg	tool_oldlib=$func_to_tool_file_result
91737a3b38f7Smrg	eval cmds=\"$old_archive_cmds\"
9174ff559fabSmrg
91757a3b38f7Smrg	func_len " $cmds"
91767a3b38f7Smrg	len=$func_len_result
91777a3b38f7Smrg	if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
91787a3b38f7Smrg	  cmds=$old_archive_cmds
9179862f5301Smrg	elif test -n "$archiver_list_spec"; then
9180862f5301Smrg	  func_verbose "using command file archive linking..."
9181862f5301Smrg	  for obj in $oldobjs
9182862f5301Smrg	  do
9183862f5301Smrg	    func_to_tool_file "$obj"
9184862f5301Smrg	    $ECHO "$func_to_tool_file_result"
9185862f5301Smrg	  done > $output_objdir/$libname.libcmd
9186862f5301Smrg	  func_to_tool_file "$output_objdir/$libname.libcmd"
9187862f5301Smrg	  oldobjs=" $archiver_list_spec$func_to_tool_file_result"
9188862f5301Smrg	  cmds=$old_archive_cmds
91897a3b38f7Smrg	else
91907a3b38f7Smrg	  # the command line is too long to link in one step, link in parts
91917a3b38f7Smrg	  func_verbose "using piecewise archive linking..."
91927a3b38f7Smrg	  save_RANLIB=$RANLIB
91937a3b38f7Smrg	  RANLIB=:
91947a3b38f7Smrg	  objlist=
91957a3b38f7Smrg	  concat_cmds=
91967a3b38f7Smrg	  save_oldobjs=$oldobjs
91977a3b38f7Smrg	  oldobjs=
91987a3b38f7Smrg	  # Is there a better way of finding the last object in the list?
91997a3b38f7Smrg	  for obj in $save_oldobjs
92007a3b38f7Smrg	  do
92017a3b38f7Smrg	    last_oldobj=$obj
92027a3b38f7Smrg	  done
92037a3b38f7Smrg	  eval test_cmds=\"$old_archive_cmds\"
92047a3b38f7Smrg	  func_len " $test_cmds"
92057a3b38f7Smrg	  len0=$func_len_result
92067a3b38f7Smrg	  len=$len0
92077a3b38f7Smrg	  for obj in $save_oldobjs
92087a3b38f7Smrg	  do
92097a3b38f7Smrg	    func_len " $obj"
92107a3b38f7Smrg	    func_arith $len + $func_len_result
92117a3b38f7Smrg	    len=$func_arith_result
92127a3b38f7Smrg	    func_append objlist " $obj"
92137a3b38f7Smrg	    if test "$len" -lt "$max_cmd_len"; then
92147a3b38f7Smrg	      :
92157a3b38f7Smrg	    else
92167a3b38f7Smrg	      # the above command should be used before it gets too long
92177a3b38f7Smrg	      oldobjs=$objlist
92187a3b38f7Smrg	      if test "$obj" = "$last_oldobj" ; then
92197a3b38f7Smrg		RANLIB=$save_RANLIB
92207a3b38f7Smrg	      fi
92217a3b38f7Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
92227a3b38f7Smrg	      eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
92237a3b38f7Smrg	      objlist=
92247a3b38f7Smrg	      len=$len0
92257a3b38f7Smrg	    fi
92267a3b38f7Smrg	  done
92277a3b38f7Smrg	  RANLIB=$save_RANLIB
92287a3b38f7Smrg	  oldobjs=$objlist
92297a3b38f7Smrg	  if test "X$oldobjs" = "X" ; then
92307a3b38f7Smrg	    eval cmds=\"\$concat_cmds\"
92317a3b38f7Smrg	  else
92327a3b38f7Smrg	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
92337a3b38f7Smrg	  fi
92347a3b38f7Smrg	fi
92357a3b38f7Smrg      fi
92367a3b38f7Smrg      func_execute_cmds "$cmds" 'exit $?'
9237ff559fabSmrg    done
9238ff559fabSmrg
92397a3b38f7Smrg    test -n "$generated" && \
92407a3b38f7Smrg      func_show_eval "${RM}r$generated"
9241ff559fabSmrg
92427a3b38f7Smrg    # Now create the libtool archive.
92437a3b38f7Smrg    case $output in
92447a3b38f7Smrg    *.la)
92457a3b38f7Smrg      old_library=
92467a3b38f7Smrg      test "$build_old_libs" = yes && old_library="$libname.$libext"
92477a3b38f7Smrg      func_verbose "creating $output"
9248ff559fabSmrg
92497a3b38f7Smrg      # Preserve any variables that may affect compiler behavior
92507a3b38f7Smrg      for var in $variables_saved_for_relink; do
92517a3b38f7Smrg	if eval test -z \"\${$var+set}\"; then
92527a3b38f7Smrg	  relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
92537a3b38f7Smrg	elif eval var_value=\$$var; test -z "$var_value"; then
92547a3b38f7Smrg	  relink_command="$var=; export $var; $relink_command"
9255ff559fabSmrg	else
92567a3b38f7Smrg	  func_quote_for_eval "$var_value"
92577a3b38f7Smrg	  relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
9258ff559fabSmrg	fi
92597a3b38f7Smrg      done
92607a3b38f7Smrg      # Quote the link command for shipping.
92617a3b38f7Smrg      relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
926244dda7b2Smrg      relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
92637a3b38f7Smrg      if test "$hardcode_automatic" = yes ; then
92647a3b38f7Smrg	relink_command=
92657a3b38f7Smrg      fi
9266ff559fabSmrg
92677a3b38f7Smrg      # Only create the output if not a dry run.
92687a3b38f7Smrg      $opt_dry_run || {
92697a3b38f7Smrg	for installed in no yes; do
92707a3b38f7Smrg	  if test "$installed" = yes; then
92717a3b38f7Smrg	    if test -z "$install_libdir"; then
92727a3b38f7Smrg	      break
92737a3b38f7Smrg	    fi
92747a3b38f7Smrg	    output="$output_objdir/$outputname"i
92757a3b38f7Smrg	    # Replace all uninstalled libtool libraries with the installed ones
92767a3b38f7Smrg	    newdependency_libs=
92777a3b38f7Smrg	    for deplib in $dependency_libs; do
92787a3b38f7Smrg	      case $deplib in
92797a3b38f7Smrg	      *.la)
92807a3b38f7Smrg		func_basename "$deplib"
92817a3b38f7Smrg		name="$func_basename_result"
9282fc544a13Smrg		func_resolve_sysroot "$deplib"
9283fc544a13Smrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result`
92847a3b38f7Smrg		test -z "$libdir" && \
92857a3b38f7Smrg		  func_fatal_error "\`$deplib' is not a valid libtool archive"
9286862f5301Smrg		func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"
9287862f5301Smrg		;;
9288862f5301Smrg	      -L*)
9289862f5301Smrg		func_stripname -L '' "$deplib"
9290862f5301Smrg		func_replace_sysroot "$func_stripname_result"
9291862f5301Smrg		func_append newdependency_libs " -L$func_replace_sysroot_result"
9292862f5301Smrg		;;
9293862f5301Smrg	      -R*)
9294862f5301Smrg		func_stripname -R '' "$deplib"
9295862f5301Smrg		func_replace_sysroot "$func_stripname_result"
9296862f5301Smrg		func_append newdependency_libs " -R$func_replace_sysroot_result"
92977a3b38f7Smrg		;;
9298862f5301Smrg	      *) func_append newdependency_libs " $deplib" ;;
92997a3b38f7Smrg	      esac
93007a3b38f7Smrg	    done
93017a3b38f7Smrg	    dependency_libs="$newdependency_libs"
93027a3b38f7Smrg	    newdlfiles=
93037a3b38f7Smrg
93047a3b38f7Smrg	    for lib in $dlfiles; do
93057a3b38f7Smrg	      case $lib in
93067a3b38f7Smrg	      *.la)
93077a3b38f7Smrg	        func_basename "$lib"
93087a3b38f7Smrg		name="$func_basename_result"
93097a3b38f7Smrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
93107a3b38f7Smrg		test -z "$libdir" && \
93117a3b38f7Smrg		  func_fatal_error "\`$lib' is not a valid libtool archive"
9312862f5301Smrg		func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name"
93137a3b38f7Smrg		;;
9314862f5301Smrg	      *) func_append newdlfiles " $lib" ;;
93157a3b38f7Smrg	      esac
93167a3b38f7Smrg	    done
93177a3b38f7Smrg	    dlfiles="$newdlfiles"
93187a3b38f7Smrg	    newdlprefiles=
93197a3b38f7Smrg	    for lib in $dlprefiles; do
93207a3b38f7Smrg	      case $lib in
93217a3b38f7Smrg	      *.la)
93227a3b38f7Smrg		# Only pass preopened files to the pseudo-archive (for
93237a3b38f7Smrg		# eventual linking with the app. that links it) if we
93247a3b38f7Smrg		# didn't already link the preopened objects directly into
93257a3b38f7Smrg		# the library:
93267a3b38f7Smrg		func_basename "$lib"
93277a3b38f7Smrg		name="$func_basename_result"
93287a3b38f7Smrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
93297a3b38f7Smrg		test -z "$libdir" && \
93307a3b38f7Smrg		  func_fatal_error "\`$lib' is not a valid libtool archive"
9331862f5301Smrg		func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name"
93327a3b38f7Smrg		;;
93337a3b38f7Smrg	      esac
93347a3b38f7Smrg	    done
93357a3b38f7Smrg	    dlprefiles="$newdlprefiles"
93367a3b38f7Smrg	  else
93377a3b38f7Smrg	    newdlfiles=
93387a3b38f7Smrg	    for lib in $dlfiles; do
93397a3b38f7Smrg	      case $lib in
93407a3b38f7Smrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
93417a3b38f7Smrg		*) abs=`pwd`"/$lib" ;;
93427a3b38f7Smrg	      esac
9343862f5301Smrg	      func_append newdlfiles " $abs"
93447a3b38f7Smrg	    done
93457a3b38f7Smrg	    dlfiles="$newdlfiles"
93467a3b38f7Smrg	    newdlprefiles=
93477a3b38f7Smrg	    for lib in $dlprefiles; do
93487a3b38f7Smrg	      case $lib in
93497a3b38f7Smrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
93507a3b38f7Smrg		*) abs=`pwd`"/$lib" ;;
93517a3b38f7Smrg	      esac
9352862f5301Smrg	      func_append newdlprefiles " $abs"
93537a3b38f7Smrg	    done
93547a3b38f7Smrg	    dlprefiles="$newdlprefiles"
93557a3b38f7Smrg	  fi
93567a3b38f7Smrg	  $RM $output
93577a3b38f7Smrg	  # place dlname in correct position for cygwin
935844dda7b2Smrg	  # In fact, it would be nice if we could use this code for all target
935944dda7b2Smrg	  # systems that can't hard-code library paths into their executables
936044dda7b2Smrg	  # and that have no shared library path variable independent of PATH,
936144dda7b2Smrg	  # but it turns out we can't easily determine that from inspecting
936244dda7b2Smrg	  # libtool variables, so we have to hard-code the OSs to which it
936344dda7b2Smrg	  # applies here; at the moment, that means platforms that use the PE
936444dda7b2Smrg	  # object format with DLL files.  See the long comment at the top of
936544dda7b2Smrg	  # tests/bindir.at for full details.
93667a3b38f7Smrg	  tdlname=$dlname
93677a3b38f7Smrg	  case $host,$output,$installed,$module,$dlname in
936844dda7b2Smrg	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
936944dda7b2Smrg	      # If a -bindir argument was supplied, place the dll there.
937044dda7b2Smrg	      if test "x$bindir" != x ;
937144dda7b2Smrg	      then
937244dda7b2Smrg		func_relative_path "$install_libdir" "$bindir"
937344dda7b2Smrg		tdlname=$func_relative_path_result$dlname
937444dda7b2Smrg	      else
937544dda7b2Smrg		# Otherwise fall back on heuristic.
937644dda7b2Smrg		tdlname=../bin/$dlname
937744dda7b2Smrg	      fi
937844dda7b2Smrg	      ;;
93797a3b38f7Smrg	  esac
93807a3b38f7Smrg	  $ECHO > $output "\
93817a3b38f7Smrg# $outputname - a libtool library file
93827a3b38f7Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
93837a3b38f7Smrg#
93847a3b38f7Smrg# Please DO NOT delete this file!
93857a3b38f7Smrg# It is necessary for linking the library.
9386ff559fabSmrg
93877a3b38f7Smrg# The name that we can dlopen(3).
93887a3b38f7Smrgdlname='$tdlname'
9389ff559fabSmrg
93907a3b38f7Smrg# Names of this library.
93917a3b38f7Smrglibrary_names='$library_names'
9392ff559fabSmrg
93937a3b38f7Smrg# The name of the static archive.
93947a3b38f7Smrgold_library='$old_library'
9395ff559fabSmrg
93967a3b38f7Smrg# Linker flags that can not go in dependency_libs.
93977a3b38f7Smrginherited_linker_flags='$new_inherited_linker_flags'
9398ff559fabSmrg
93997a3b38f7Smrg# Libraries that this one depends upon.
94007a3b38f7Smrgdependency_libs='$dependency_libs'
9401ff559fabSmrg
94027a3b38f7Smrg# Names of additional weak libraries provided by this library
94037a3b38f7Smrgweak_library_names='$weak_libs'
9404ff559fabSmrg
94057a3b38f7Smrg# Version information for $libname.
94067a3b38f7Smrgcurrent=$current
94077a3b38f7Smrgage=$age
94087a3b38f7Smrgrevision=$revision
9409ff559fabSmrg
94107a3b38f7Smrg# Is this an already installed library?
94117a3b38f7Smrginstalled=$installed
9412ff559fabSmrg
94137a3b38f7Smrg# Should we warn about portability when linking against -modules?
94147a3b38f7Smrgshouldnotlink=$module
9415ff559fabSmrg
94167a3b38f7Smrg# Files to dlopen/dlpreopen
94177a3b38f7Smrgdlopen='$dlfiles'
94187a3b38f7Smrgdlpreopen='$dlprefiles'
9419ff559fabSmrg
94207a3b38f7Smrg# Directory that this library needs to be installed in:
94217a3b38f7Smrglibdir='$install_libdir'"
94227a3b38f7Smrg	  if test "$installed" = no && test "$need_relink" = yes; then
94237a3b38f7Smrg	    $ECHO >> $output "\
94247a3b38f7Smrgrelink_command=\"$relink_command\""
94257a3b38f7Smrg	  fi
94267a3b38f7Smrg	done
94277a3b38f7Smrg      }
9428ff559fabSmrg
94297a3b38f7Smrg      # Do a symbolic link so that the libtool archive can be found in
94307a3b38f7Smrg      # LD_LIBRARY_PATH before the program is installed.
94317a3b38f7Smrg      func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
94327a3b38f7Smrg      ;;
94337a3b38f7Smrg    esac
94347a3b38f7Smrg    exit $EXIT_SUCCESS
94357a3b38f7Smrg}
9436ff559fabSmrg
9437862f5301Smrg{ test "$opt_mode" = link || test "$opt_mode" = relink; } &&
94387a3b38f7Smrg    func_mode_link ${1+"$@"}
9439ff559fabSmrg
9440ff559fabSmrg
94417a3b38f7Smrg# func_mode_uninstall arg...
94427a3b38f7Smrgfunc_mode_uninstall ()
94437a3b38f7Smrg{
94447a3b38f7Smrg    $opt_debug
94457a3b38f7Smrg    RM="$nonopt"
9446ff559fabSmrg    files=
9447ff559fabSmrg    rmforce=
9448ff559fabSmrg    exit_status=0
9449ff559fabSmrg
9450ff559fabSmrg    # This variable tells wrapper scripts just to set variables rather
9451ff559fabSmrg    # than running their programs.
9452ff559fabSmrg    libtool_install_magic="$magic"
9453ff559fabSmrg
9454ff559fabSmrg    for arg
9455ff559fabSmrg    do
9456ff559fabSmrg      case $arg in
9457862f5301Smrg      -f) func_append RM " $arg"; rmforce=yes ;;
9458862f5301Smrg      -*) func_append RM " $arg" ;;
9459862f5301Smrg      *) func_append files " $arg" ;;
9460ff559fabSmrg      esac
9461ff559fabSmrg    done
9462ff559fabSmrg
94637a3b38f7Smrg    test -z "$RM" && \
94647a3b38f7Smrg      func_fatal_help "you must specify an RM program"
9465ff559fabSmrg
9466ff559fabSmrg    rmdirs=
9467ff559fabSmrg
9468ff559fabSmrg    for file in $files; do
94697a3b38f7Smrg      func_dirname "$file" "" "."
94707a3b38f7Smrg      dir="$func_dirname_result"
94717a3b38f7Smrg      if test "X$dir" = X.; then
9472862f5301Smrg	odir="$objdir"
9473ff559fabSmrg      else
9474862f5301Smrg	odir="$dir/$objdir"
9475ff559fabSmrg      fi
94767a3b38f7Smrg      func_basename "$file"
94777a3b38f7Smrg      name="$func_basename_result"
9478862f5301Smrg      test "$opt_mode" = uninstall && odir="$dir"
9479ff559fabSmrg
9480862f5301Smrg      # Remember odir for removal later, being careful to avoid duplicates
9481862f5301Smrg      if test "$opt_mode" = clean; then
9482ff559fabSmrg	case " $rmdirs " in
9483862f5301Smrg	  *" $odir "*) ;;
9484862f5301Smrg	  *) func_append rmdirs " $odir" ;;
9485ff559fabSmrg	esac
9486ff559fabSmrg      fi
9487ff559fabSmrg
9488ff559fabSmrg      # Don't error if the file doesn't exist and rm -f was used.
94897a3b38f7Smrg      if { test -L "$file"; } >/dev/null 2>&1 ||
94907a3b38f7Smrg	 { test -h "$file"; } >/dev/null 2>&1 ||
94917a3b38f7Smrg	 test -f "$file"; then
9492ff559fabSmrg	:
9493ff559fabSmrg      elif test -d "$file"; then
9494ff559fabSmrg	exit_status=1
9495ff559fabSmrg	continue
9496ff559fabSmrg      elif test "$rmforce" = yes; then
9497ff559fabSmrg	continue
9498ff559fabSmrg      fi
9499ff559fabSmrg
9500ff559fabSmrg      rmfiles="$file"
9501ff559fabSmrg
9502ff559fabSmrg      case $name in
9503ff559fabSmrg      *.la)
9504ff559fabSmrg	# Possibly a libtool archive, so verify it.
95057a3b38f7Smrg	if func_lalib_p "$file"; then
95067a3b38f7Smrg	  func_source $dir/$name
9507ff559fabSmrg
9508ff559fabSmrg	  # Delete the libtool libraries and symlinks.
9509ff559fabSmrg	  for n in $library_names; do
9510862f5301Smrg	    func_append rmfiles " $odir/$n"
9511ff559fabSmrg	  done
9512862f5301Smrg	  test -n "$old_library" && func_append rmfiles " $odir/$old_library"
9513ff559fabSmrg
9514862f5301Smrg	  case "$opt_mode" in
9515ff559fabSmrg	  clean)
9516862f5301Smrg	    case " $library_names " in
9517ff559fabSmrg	    *" $dlname "*) ;;
9518862f5301Smrg	    *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;;
9519ff559fabSmrg	    esac
9520862f5301Smrg	    test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i"
9521ff559fabSmrg	    ;;
9522ff559fabSmrg	  uninstall)
9523ff559fabSmrg	    if test -n "$library_names"; then
9524ff559fabSmrg	      # Do each command in the postuninstall commands.
95257a3b38f7Smrg	      func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
9526ff559fabSmrg	    fi
9527ff559fabSmrg
9528ff559fabSmrg	    if test -n "$old_library"; then
9529ff559fabSmrg	      # Do each command in the old_postuninstall commands.
95307a3b38f7Smrg	      func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
9531ff559fabSmrg	    fi
9532ff559fabSmrg	    # FIXME: should reinstall the best remaining shared library.
9533ff559fabSmrg	    ;;
9534ff559fabSmrg	  esac
9535ff559fabSmrg	fi
9536ff559fabSmrg	;;
9537ff559fabSmrg
9538ff559fabSmrg      *.lo)
9539ff559fabSmrg	# Possibly a libtool object, so verify it.
95407a3b38f7Smrg	if func_lalib_p "$file"; then
9541ff559fabSmrg
9542ff559fabSmrg	  # Read the .lo file
95437a3b38f7Smrg	  func_source $dir/$name
9544ff559fabSmrg
9545ff559fabSmrg	  # Add PIC object to the list of files to remove.
95467a3b38f7Smrg	  if test -n "$pic_object" &&
95477a3b38f7Smrg	     test "$pic_object" != none; then
9548862f5301Smrg	    func_append rmfiles " $dir/$pic_object"
9549ff559fabSmrg	  fi
9550ff559fabSmrg
9551ff559fabSmrg	  # Add non-PIC object to the list of files to remove.
95527a3b38f7Smrg	  if test -n "$non_pic_object" &&
95537a3b38f7Smrg	     test "$non_pic_object" != none; then
9554862f5301Smrg	    func_append rmfiles " $dir/$non_pic_object"
9555ff559fabSmrg	  fi
9556ff559fabSmrg	fi
9557ff559fabSmrg	;;
9558ff559fabSmrg
9559ff559fabSmrg      *)
9560862f5301Smrg	if test "$opt_mode" = clean ; then
9561ff559fabSmrg	  noexename=$name
9562ff559fabSmrg	  case $file in
9563ff559fabSmrg	  *.exe)
95647a3b38f7Smrg	    func_stripname '' '.exe' "$file"
95657a3b38f7Smrg	    file=$func_stripname_result
95667a3b38f7Smrg	    func_stripname '' '.exe' "$name"
95677a3b38f7Smrg	    noexename=$func_stripname_result
9568ff559fabSmrg	    # $file with .exe has already been added to rmfiles,
9569ff559fabSmrg	    # add $file without .exe
9570862f5301Smrg	    func_append rmfiles " $file"
9571ff559fabSmrg	    ;;
9572ff559fabSmrg	  esac
9573ff559fabSmrg	  # Do a test to see if this is a libtool program.
95747a3b38f7Smrg	  if func_ltwrapper_p "$file"; then
95757a3b38f7Smrg	    if func_ltwrapper_executable_p "$file"; then
95767a3b38f7Smrg	      func_ltwrapper_scriptname "$file"
95777a3b38f7Smrg	      relink_command=
95787a3b38f7Smrg	      func_source $func_ltwrapper_scriptname_result
9579862f5301Smrg	      func_append rmfiles " $func_ltwrapper_scriptname_result"
95807a3b38f7Smrg	    else
95817a3b38f7Smrg	      relink_command=
95827a3b38f7Smrg	      func_source $dir/$noexename
95837a3b38f7Smrg	    fi
9584ff559fabSmrg
9585ff559fabSmrg	    # note $name still contains .exe if it was in $file originally
9586ff559fabSmrg	    # as does the version of $file that was added into $rmfiles
9587862f5301Smrg	    func_append rmfiles " $odir/$name $odir/${name}S.${objext}"
9588ff559fabSmrg	    if test "$fast_install" = yes && test -n "$relink_command"; then
9589862f5301Smrg	      func_append rmfiles " $odir/lt-$name"
9590ff559fabSmrg	    fi
9591ff559fabSmrg	    if test "X$noexename" != "X$name" ; then
9592862f5301Smrg	      func_append rmfiles " $odir/lt-${noexename}.c"
9593ff559fabSmrg	    fi
9594ff559fabSmrg	  fi
9595ff559fabSmrg	fi
9596ff559fabSmrg	;;
9597ff559fabSmrg      esac
95987a3b38f7Smrg      func_show_eval "$RM $rmfiles" 'exit_status=1'
9599ff559fabSmrg    done
9600ff559fabSmrg
9601ff559fabSmrg    # Try to remove the ${objdir}s in the directories where we deleted files
9602ff559fabSmrg    for dir in $rmdirs; do
9603ff559fabSmrg      if test -d "$dir"; then
96047a3b38f7Smrg	func_show_eval "rmdir $dir >/dev/null 2>&1"
9605ff559fabSmrg      fi
9606ff559fabSmrg    done
9607ff559fabSmrg
9608ff559fabSmrg    exit $exit_status
96097a3b38f7Smrg}
9610ff559fabSmrg
9611862f5301Smrg{ test "$opt_mode" = uninstall || test "$opt_mode" = clean; } &&
96127a3b38f7Smrg    func_mode_uninstall ${1+"$@"}
9613ff559fabSmrg
9614862f5301Smrgtest -z "$opt_mode" && {
96157a3b38f7Smrg  help="$generic_help"
96167a3b38f7Smrg  func_fatal_help "you must specify a MODE"
96177a3b38f7Smrg}
96187a3b38f7Smrg
96197a3b38f7Smrgtest -z "$exec_cmd" && \
9620862f5301Smrg  func_fatal_help "invalid operation mode \`$opt_mode'"
9621ff559fabSmrg
9622ff559fabSmrgif test -n "$exec_cmd"; then
96237a3b38f7Smrg  eval exec "$exec_cmd"
9624ff559fabSmrg  exit $EXIT_FAILURE
9625ff559fabSmrgfi
9626ff559fabSmrg
96277a3b38f7Smrgexit $exit_status
9628ff559fabSmrg
9629ff559fabSmrg
9630ff559fabSmrg# The TAGs below are defined such that we never get into a situation
9631ff559fabSmrg# in which we disable both kinds of libraries.  Given conflicting
9632ff559fabSmrg# choices, we go for a static library, that is the most portable,
9633ff559fabSmrg# since we can't tell whether shared libraries were disabled because
9634ff559fabSmrg# the user asked for that or because the platform doesn't support
9635ff559fabSmrg# them.  This is particularly important on AIX, because we don't
9636ff559fabSmrg# support having both static and shared libraries enabled at the same
9637ff559fabSmrg# time on that platform, so we default to a shared-only configuration.
9638ff559fabSmrg# If a disable-shared tag is given, we'll fallback to a static-only
9639ff559fabSmrg# configuration.  But we'll never go from static-only to shared-only.
9640ff559fabSmrg
9641ff559fabSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
96427a3b38f7Smrgbuild_libtool_libs=no
96437a3b38f7Smrgbuild_old_libs=yes
9644ff559fabSmrg# ### END LIBTOOL TAG CONFIG: disable-shared
9645ff559fabSmrg
9646ff559fabSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static
96477a3b38f7Smrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
9648ff559fabSmrg# ### END LIBTOOL TAG CONFIG: disable-static
9649ff559fabSmrg
9650ff559fabSmrg# Local Variables:
9651ff559fabSmrg# mode:shell-script
9652ff559fabSmrg# sh-indentation:2
9653ff559fabSmrg# End:
96547a3b38f7Smrg# vi:sw=2
96557a3b38f7Smrg
9656