ltmain.sh revision 14330f12
12378475aSmrg
214330f12Smrg# libtool (GNU libtool) 2.4
32378475aSmrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
42378475aSmrg
514330f12Smrg# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006,
614330f12Smrg# 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
72378475aSmrg# This is free software; see the source for copying conditions.  There is NO
82378475aSmrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
92378475aSmrg
102378475aSmrg# GNU Libtool is free software; you can redistribute it and/or modify
1195b296d0Smrg# it under the terms of the GNU General Public License as published by
1295b296d0Smrg# the Free Software Foundation; either version 2 of the License, or
1395b296d0Smrg# (at your option) any later version.
1495b296d0Smrg#
152378475aSmrg# As a special exception to the GNU General Public License,
162378475aSmrg# if you distribute this file as part of a program or library that
172378475aSmrg# is built using GNU Libtool, you may include this file under the
182378475aSmrg# same distribution terms that you use for the rest of that program.
192378475aSmrg#
202378475aSmrg# GNU Libtool is distributed in the hope that it will be useful, but
2195b296d0Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of
2295b296d0Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
2395b296d0Smrg# General Public License for more details.
2495b296d0Smrg#
2595b296d0Smrg# You should have received a copy of the GNU General Public License
262378475aSmrg# along with GNU Libtool; see the file COPYING.  If not, a copy
272378475aSmrg# can be downloaded from http://www.gnu.org/licenses/gpl.html,
282378475aSmrg# or obtained by writing to the Free Software Foundation, Inc.,
292378475aSmrg# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
30e6f085baSmrg
312378475aSmrg# Usage: $progname [OPTION]... [MODE-ARG]...
322378475aSmrg#
332378475aSmrg# Provide generalized library-building support services.
342378475aSmrg#
3514330f12Smrg#       --config             show all configuration variables
3614330f12Smrg#       --debug              enable verbose shell tracing
3714330f12Smrg#   -n, --dry-run            display commands without modifying any files
3814330f12Smrg#       --features           display basic configuration information and exit
3914330f12Smrg#       --mode=MODE          use operation mode MODE
4014330f12Smrg#       --preserve-dup-deps  don't remove duplicate dependency libraries
4114330f12Smrg#       --quiet, --silent    don't print informational messages
4214330f12Smrg#       --no-quiet, --no-silent
4314330f12Smrg#                            print informational messages (default)
4414330f12Smrg#       --tag=TAG            use configuration variables from tag TAG
4514330f12Smrg#   -v, --verbose            print more informational messages than default
4614330f12Smrg#       --no-verbose         don't print the extra informational messages
4714330f12Smrg#       --version            print version information
4814330f12Smrg#   -h, --help, --help-all   print short, long, or detailed help message
492378475aSmrg#
502378475aSmrg# MODE must be one of the following:
512378475aSmrg#
5214330f12Smrg#         clean              remove files from the build directory
5314330f12Smrg#         compile            compile a source file into a libtool object
5414330f12Smrg#         execute            automatically set library path, then run a program
5514330f12Smrg#         finish             complete the installation of libtool libraries
5614330f12Smrg#         install            install libraries or executables
5714330f12Smrg#         link               create a library or an executable
5814330f12Smrg#         uninstall          remove libraries from an installed directory
592378475aSmrg#
6014330f12Smrg# MODE-ARGS vary depending on the MODE.  When passed as first option,
6114330f12Smrg# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that.
622378475aSmrg# Try `$progname --help --mode=MODE' for a more detailed description of MODE.
632378475aSmrg#
642378475aSmrg# When reporting a bug, please describe a test case to reproduce it and
652378475aSmrg# include the following information:
662378475aSmrg#
6714330f12Smrg#         host-triplet:	$host
6814330f12Smrg#         shell:		$SHELL
6914330f12Smrg#         compiler:		$LTCC
7014330f12Smrg#         compiler flags:		$LTCFLAGS
7114330f12Smrg#         linker:		$LD (gnu? $with_gnu_ld)
7214330f12Smrg#         $progname:	(GNU libtool) 2.4
7314330f12Smrg#         automake:	$automake_version
7414330f12Smrg#         autoconf:	$autoconf_version
752378475aSmrg#
762378475aSmrg# Report bugs to <bug-libtool@gnu.org>.
7714330f12Smrg# GNU libtool home page: <http://www.gnu.org/software/libtool/>.
7814330f12Smrg# General help using GNU software: <http://www.gnu.org/gethelp/>.
7995b296d0Smrg
8014330f12SmrgPROGRAM=libtool
8195b296d0SmrgPACKAGE=libtool
8214330f12SmrgVERSION=2.4
832378475aSmrgTIMESTAMP=""
8414330f12Smrgpackage_revision=1.3293
85ff89ac2bSmrg
862378475aSmrg# Be Bourne compatible
87ff89ac2bSmrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
88ff89ac2bSmrg  emulate sh
89ff89ac2bSmrg  NULLCMD=:
90ff89ac2bSmrg  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
91ff89ac2bSmrg  # is contrary to our usage.  Disable this feature.
92ff89ac2bSmrg  alias -g '${1+"$@"}'='"$@"'
9395b296d0Smrg  setopt NO_GLOB_SUBST
94ff89ac2bSmrgelse
95ff89ac2bSmrg  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
9695b296d0Smrgfi
97ff89ac2bSmrgBIN_SH=xpg4; export BIN_SH # for Tru64
98ff89ac2bSmrgDUALCASE=1; export DUALCASE # for MKS sh
9995b296d0Smrg
10014330f12Smrg# A function that is used when there is no print builtin or printf.
10114330f12Smrgfunc_fallback_echo ()
10214330f12Smrg{
10314330f12Smrg  eval 'cat <<_LTECHO_EOF
10414330f12Smrg$1
10514330f12Smrg_LTECHO_EOF'
10614330f12Smrg}
10714330f12Smrg
1082378475aSmrg# NLS nuisances: We save the old values to restore during execute mode.
1092378475aSmrglt_user_locale=
1102378475aSmrglt_safe_locale=
111ff89ac2bSmrgfor lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
112ff89ac2bSmrgdo
113ff89ac2bSmrg  eval "if test \"\${$lt_var+set}\" = set; then
1142378475aSmrg          save_$lt_var=\$$lt_var
1152378475aSmrg          $lt_var=C
116ff89ac2bSmrg	  export $lt_var
1172378475aSmrg	  lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\"
1182378475aSmrg	  lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
119ff89ac2bSmrg	fi"
120ff89ac2bSmrgdone
12114330f12SmrgLC_ALL=C
12214330f12SmrgLANGUAGE=C
12314330f12Smrgexport LANGUAGE LC_ALL
124ff89ac2bSmrg
1252378475aSmrg$lt_unset CDPATH
1262378475aSmrg
1272378475aSmrg
12814330f12Smrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
12914330f12Smrg# is ksh but when the shell is invoked as "sh" and the current value of
13014330f12Smrg# the _XPG environment variable is not equal to 1 (one), the special
13114330f12Smrg# positional parameter $0, within a function call, is the name of the
13214330f12Smrg# function.
13314330f12Smrgprogpath="$0"
1342378475aSmrg
1352378475aSmrg
1362378475aSmrg
1372378475aSmrg: ${CP="cp -f"}
13814330f12Smrgtest "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'}
13914330f12Smrg: ${EGREP="grep -E"}
14014330f12Smrg: ${FGREP="grep -F"}
14114330f12Smrg: ${GREP="grep"}
1422378475aSmrg: ${LN_S="ln -s"}
1432378475aSmrg: ${MAKE="make"}
1442378475aSmrg: ${MKDIR="mkdir"}
1452378475aSmrg: ${MV="mv -f"}
1462378475aSmrg: ${RM="rm -f"}
14714330f12Smrg: ${SED="sed"}
1482378475aSmrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
1492378475aSmrg: ${Xsed="$SED -e 1s/^X//"}
1502378475aSmrg
1512378475aSmrg# Global variables:
1522378475aSmrgEXIT_SUCCESS=0
1532378475aSmrgEXIT_FAILURE=1
1542378475aSmrgEXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
1552378475aSmrgEXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
1562378475aSmrg
1572378475aSmrgexit_status=$EXIT_SUCCESS
15895b296d0Smrg
15995b296d0Smrg# Make sure IFS has a sensible default
16095b296d0Smrglt_nl='
16195b296d0Smrg'
16295b296d0SmrgIFS=" 	$lt_nl"
16395b296d0Smrg
1642378475aSmrgdirname="s,/[^/]*$,,"
1652378475aSmrgbasename="s,^.*/,,"
1662378475aSmrg
16714330f12Smrg# func_dirname file append nondir_replacement
16814330f12Smrg# Compute the dirname of FILE.  If nonempty, add APPEND to the result,
16914330f12Smrg# otherwise set result to NONDIR_REPLACEMENT.
17014330f12Smrgfunc_dirname ()
17114330f12Smrg{
17214330f12Smrg    func_dirname_result=`$ECHO "${1}" | $SED "$dirname"`
17314330f12Smrg    if test "X$func_dirname_result" = "X${1}"; then
17414330f12Smrg      func_dirname_result="${3}"
17514330f12Smrg    else
17614330f12Smrg      func_dirname_result="$func_dirname_result${2}"
17714330f12Smrg    fi
17814330f12Smrg} # func_dirname may be replaced by extended shell implementation
17914330f12Smrg
18014330f12Smrg
18114330f12Smrg# func_basename file
18214330f12Smrgfunc_basename ()
18314330f12Smrg{
18414330f12Smrg    func_basename_result=`$ECHO "${1}" | $SED "$basename"`
18514330f12Smrg} # func_basename may be replaced by extended shell implementation
18614330f12Smrg
18714330f12Smrg
1882378475aSmrg# func_dirname_and_basename file append nondir_replacement
1892378475aSmrg# perform func_basename and func_dirname in a single function
1902378475aSmrg# call:
1912378475aSmrg#   dirname:  Compute the dirname of FILE.  If nonempty,
1922378475aSmrg#             add APPEND to the result, otherwise set result
1932378475aSmrg#             to NONDIR_REPLACEMENT.
1942378475aSmrg#             value returned in "$func_dirname_result"
1952378475aSmrg#   basename: Compute filename of FILE.
1962378475aSmrg#             value retuned in "$func_basename_result"
1972378475aSmrg# Implementation must be kept synchronized with func_dirname
1982378475aSmrg# and func_basename. For efficiency, we do not delegate to
1992378475aSmrg# those functions but instead duplicate the functionality here.
2002378475aSmrgfunc_dirname_and_basename ()
2012378475aSmrg{
20214330f12Smrg    # Extract subdirectory from the argument.
20314330f12Smrg    func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"`
20414330f12Smrg    if test "X$func_dirname_result" = "X${1}"; then
20514330f12Smrg      func_dirname_result="${3}"
20614330f12Smrg    else
20714330f12Smrg      func_dirname_result="$func_dirname_result${2}"
20814330f12Smrg    fi
20914330f12Smrg    func_basename_result=`$ECHO "${1}" | $SED -e "$basename"`
21014330f12Smrg} # func_dirname_and_basename may be replaced by extended shell implementation
21114330f12Smrg
21214330f12Smrg
21314330f12Smrg# func_stripname prefix suffix name
21414330f12Smrg# strip PREFIX and SUFFIX off of NAME.
21514330f12Smrg# PREFIX and SUFFIX must not contain globbing or regex special
21614330f12Smrg# characters, hashes, percent signs, but SUFFIX may contain a leading
21714330f12Smrg# dot (in which case that matches only a dot).
21814330f12Smrg# func_strip_suffix prefix name
21914330f12Smrgfunc_stripname ()
22014330f12Smrg{
22114330f12Smrg    case ${2} in
22214330f12Smrg      .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;;
22314330f12Smrg      *)  func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;;
22414330f12Smrg    esac
22514330f12Smrg} # func_stripname may be replaced by extended shell implementation
22614330f12Smrg
22714330f12Smrg
22814330f12Smrg# These SED scripts presuppose an absolute path with a trailing slash.
22914330f12Smrgpathcar='s,^/\([^/]*\).*$,\1,'
23014330f12Smrgpathcdr='s,^/[^/]*,,'
23114330f12Smrgremovedotparts=':dotsl
23214330f12Smrg		s@/\./@/@g
23314330f12Smrg		t dotsl
23414330f12Smrg		s,/\.$,/,'
23514330f12Smrgcollapseslashes='s@/\{1,\}@/@g'
23614330f12Smrgfinalslash='s,/*$,/,'
23714330f12Smrg
23814330f12Smrg# func_normal_abspath PATH
23914330f12Smrg# Remove doubled-up and trailing slashes, "." path components,
24014330f12Smrg# and cancel out any ".." path components in PATH after making
24114330f12Smrg# it an absolute path.
24214330f12Smrg#             value returned in "$func_normal_abspath_result"
24314330f12Smrgfunc_normal_abspath ()
24414330f12Smrg{
24514330f12Smrg  # Start from root dir and reassemble the path.
24614330f12Smrg  func_normal_abspath_result=
24714330f12Smrg  func_normal_abspath_tpath=$1
24814330f12Smrg  func_normal_abspath_altnamespace=
24914330f12Smrg  case $func_normal_abspath_tpath in
25014330f12Smrg    "")
25114330f12Smrg      # Empty path, that just means $cwd.
25214330f12Smrg      func_stripname '' '/' "`pwd`"
25314330f12Smrg      func_normal_abspath_result=$func_stripname_result
25414330f12Smrg      return
25514330f12Smrg    ;;
25614330f12Smrg    # The next three entries are used to spot a run of precisely
25714330f12Smrg    # two leading slashes without using negated character classes;
25814330f12Smrg    # we take advantage of case's first-match behaviour.
25914330f12Smrg    ///*)
26014330f12Smrg      # Unusual form of absolute path, do nothing.
26114330f12Smrg    ;;
26214330f12Smrg    //*)
26314330f12Smrg      # Not necessarily an ordinary path; POSIX reserves leading '//'
26414330f12Smrg      # and for example Cygwin uses it to access remote file shares
26514330f12Smrg      # over CIFS/SMB, so we conserve a leading double slash if found.
26614330f12Smrg      func_normal_abspath_altnamespace=/
26714330f12Smrg    ;;
26814330f12Smrg    /*)
26914330f12Smrg      # Absolute path, do nothing.
27014330f12Smrg    ;;
27114330f12Smrg    *)
27214330f12Smrg      # Relative path, prepend $cwd.
27314330f12Smrg      func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
27414330f12Smrg    ;;
27514330f12Smrg  esac
27614330f12Smrg  # Cancel out all the simple stuff to save iterations.  We also want
27714330f12Smrg  # the path to end with a slash for ease of parsing, so make sure
27814330f12Smrg  # there is one (and only one) here.
27914330f12Smrg  func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
28014330f12Smrg        -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"`
28114330f12Smrg  while :; do
28214330f12Smrg    # Processed it all yet?
28314330f12Smrg    if test "$func_normal_abspath_tpath" = / ; then
28414330f12Smrg      # If we ascended to the root using ".." the result may be empty now.
28514330f12Smrg      if test -z "$func_normal_abspath_result" ; then
28614330f12Smrg        func_normal_abspath_result=/
28714330f12Smrg      fi
28814330f12Smrg      break
28914330f12Smrg    fi
29014330f12Smrg    func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
29114330f12Smrg        -e "$pathcar"`
29214330f12Smrg    func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
29314330f12Smrg        -e "$pathcdr"`
29414330f12Smrg    # Figure out what to do with it
29514330f12Smrg    case $func_normal_abspath_tcomponent in
29614330f12Smrg      "")
29714330f12Smrg        # Trailing empty path component, ignore it.
29814330f12Smrg      ;;
29914330f12Smrg      ..)
30014330f12Smrg        # Parent dir; strip last assembled component from result.
30114330f12Smrg        func_dirname "$func_normal_abspath_result"
30214330f12Smrg        func_normal_abspath_result=$func_dirname_result
30314330f12Smrg      ;;
30414330f12Smrg      *)
30514330f12Smrg        # Actual path component, append it.
30614330f12Smrg        func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent
30714330f12Smrg      ;;
30814330f12Smrg    esac
30914330f12Smrg  done
31014330f12Smrg  # Restore leading double-slash if one was found on entry.
31114330f12Smrg  func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
3122378475aSmrg}
31339713583Smrg
31414330f12Smrg# func_relative_path SRCDIR DSTDIR
31514330f12Smrg# generates a relative path from SRCDIR to DSTDIR, with a trailing
31614330f12Smrg# slash if non-empty, suitable for immediately appending a filename
31714330f12Smrg# without needing to append a separator.
31814330f12Smrg#             value returned in "$func_relative_path_result"
31914330f12Smrgfunc_relative_path ()
32014330f12Smrg{
32114330f12Smrg  func_relative_path_result=
32214330f12Smrg  func_normal_abspath "$1"
32314330f12Smrg  func_relative_path_tlibdir=$func_normal_abspath_result
32414330f12Smrg  func_normal_abspath "$2"
32514330f12Smrg  func_relative_path_tbindir=$func_normal_abspath_result
32614330f12Smrg
32714330f12Smrg  # Ascend the tree starting from libdir
32814330f12Smrg  while :; do
32914330f12Smrg    # check if we have found a prefix of bindir
33014330f12Smrg    case $func_relative_path_tbindir in
33114330f12Smrg      $func_relative_path_tlibdir)
33214330f12Smrg        # found an exact match
33314330f12Smrg        func_relative_path_tcancelled=
33414330f12Smrg        break
33514330f12Smrg        ;;
33614330f12Smrg      $func_relative_path_tlibdir*)
33714330f12Smrg        # found a matching prefix
33814330f12Smrg        func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
33914330f12Smrg        func_relative_path_tcancelled=$func_stripname_result
34014330f12Smrg        if test -z "$func_relative_path_result"; then
34114330f12Smrg          func_relative_path_result=.
34214330f12Smrg        fi
34314330f12Smrg        break
34414330f12Smrg        ;;
34514330f12Smrg      *)
34614330f12Smrg        func_dirname $func_relative_path_tlibdir
34714330f12Smrg        func_relative_path_tlibdir=${func_dirname_result}
34814330f12Smrg        if test "x$func_relative_path_tlibdir" = x ; then
34914330f12Smrg          # Have to descend all the way to the root!
35014330f12Smrg          func_relative_path_result=../$func_relative_path_result
35114330f12Smrg          func_relative_path_tcancelled=$func_relative_path_tbindir
35214330f12Smrg          break
35314330f12Smrg        fi
35414330f12Smrg        func_relative_path_result=../$func_relative_path_result
35514330f12Smrg        ;;
35614330f12Smrg    esac
35714330f12Smrg  done
3582378475aSmrg
35914330f12Smrg  # Now calculate path; take care to avoid doubling-up slashes.
36014330f12Smrg  func_stripname '' '/' "$func_relative_path_result"
36114330f12Smrg  func_relative_path_result=$func_stripname_result
36214330f12Smrg  func_stripname '/' '/' "$func_relative_path_tcancelled"
36314330f12Smrg  if test "x$func_stripname_result" != x ; then
36414330f12Smrg    func_relative_path_result=${func_relative_path_result}/${func_stripname_result}
36514330f12Smrg  fi
36614330f12Smrg
36714330f12Smrg  # Normalisation. If bindir is libdir, return empty string,
36814330f12Smrg  # else relative path ending with a slash; either way, target
36914330f12Smrg  # file name can be directly appended.
37014330f12Smrg  if test ! -z "$func_relative_path_result"; then
37114330f12Smrg    func_stripname './' '' "$func_relative_path_result/"
37214330f12Smrg    func_relative_path_result=$func_stripname_result
37314330f12Smrg  fi
37414330f12Smrg}
3752378475aSmrg
3762378475aSmrg# The name of this program:
3772378475aSmrgfunc_dirname_and_basename "$progpath"
3782378475aSmrgprogname=$func_basename_result
3792378475aSmrg
3802378475aSmrg# Make sure we have an absolute path for reexecution:
3812378475aSmrgcase $progpath in
3822378475aSmrg  [\\/]*|[A-Za-z]:\\*) ;;
3832378475aSmrg  *[\\/]*)
3842378475aSmrg     progdir=$func_dirname_result
3852378475aSmrg     progdir=`cd "$progdir" && pwd`
3862378475aSmrg     progpath="$progdir/$progname"
3872378475aSmrg     ;;
3882378475aSmrg  *)
3892378475aSmrg     save_IFS="$IFS"
3902378475aSmrg     IFS=:
3912378475aSmrg     for progdir in $PATH; do
3922378475aSmrg       IFS="$save_IFS"
3932378475aSmrg       test -x "$progdir/$progname" && break
3942378475aSmrg     done
3952378475aSmrg     IFS="$save_IFS"
3962378475aSmrg     test -n "$progdir" || progdir=`pwd`
3972378475aSmrg     progpath="$progdir/$progname"
3982378475aSmrg     ;;
3992378475aSmrgesac
4002378475aSmrg
4012378475aSmrg# Sed substitution that helps us do robust quoting.  It backslashifies
4022378475aSmrg# metacharacters that are still active within double-quoted strings.
4032378475aSmrgXsed="${SED}"' -e 1s/^X//'
4042378475aSmrgsed_quote_subst='s/\([`"$\\]\)/\\\1/g'
4052378475aSmrg
4062378475aSmrg# Same as above, but do not quote variable references.
4072378475aSmrgdouble_quote_subst='s/\(["`\\]\)/\\\1/g'
4082378475aSmrg
40914330f12Smrg# Sed substitution that turns a string into a regex matching for the
41014330f12Smrg# string literally.
41114330f12Smrgsed_make_literal_regex='s,[].[^$\\*\/],\\&,g'
41214330f12Smrg
41314330f12Smrg# Sed substitution that converts a w32 file name or path
41414330f12Smrg# which contains forward slashes, into one that contains
41514330f12Smrg# (escaped) backslashes.  A very naive implementation.
41614330f12Smrglt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
41714330f12Smrg
4182378475aSmrg# Re-`\' parameter expansions in output of double_quote_subst that were
4192378475aSmrg# `\'-ed in input to the same.  If an odd number of `\' preceded a '$'
4202378475aSmrg# in input to double_quote_subst, that '$' was protected from expansion.
4212378475aSmrg# Since each input `\' is now two `\'s, look for any number of runs of
4222378475aSmrg# four `\'s followed by two `\'s and then a '$'.  `\' that '$'.
4232378475aSmrgbs='\\'
4242378475aSmrgbs2='\\\\'
4252378475aSmrgbs4='\\\\\\\\'
4262378475aSmrgdollar='\$'
4272378475aSmrgsed_double_backslash="\
4282378475aSmrg  s/$bs4/&\\
4292378475aSmrg/g
4302378475aSmrg  s/^$bs2$dollar/$bs&/
4312378475aSmrg  s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
4322378475aSmrg  s/\n//g"
4332378475aSmrg
4342378475aSmrg# Standard options:
4352378475aSmrgopt_dry_run=false
4362378475aSmrgopt_help=false
4372378475aSmrgopt_quiet=false
4382378475aSmrgopt_verbose=false
4392378475aSmrgopt_warning=:
4402378475aSmrg
4412378475aSmrg# func_echo arg...
4422378475aSmrg# Echo program name prefixed message, along with the current mode
4432378475aSmrg# name if it has been set yet.
4442378475aSmrgfunc_echo ()
4452378475aSmrg{
44614330f12Smrg    $ECHO "$progname: ${opt_mode+$opt_mode: }$*"
4472378475aSmrg}
4482378475aSmrg
4492378475aSmrg# func_verbose arg...
4502378475aSmrg# Echo program name prefixed message in verbose mode only.
4512378475aSmrgfunc_verbose ()
4522378475aSmrg{
4532378475aSmrg    $opt_verbose && func_echo ${1+"$@"}
4542378475aSmrg
4552378475aSmrg    # A bug in bash halts the script if the last line of a function
4562378475aSmrg    # fails when set -e is in force, so we need another command to
4572378475aSmrg    # work around that:
4582378475aSmrg    :
4592378475aSmrg}
4602378475aSmrg
46114330f12Smrg# func_echo_all arg...
46214330f12Smrg# Invoke $ECHO with all args, space-separated.
46314330f12Smrgfunc_echo_all ()
46414330f12Smrg{
46514330f12Smrg    $ECHO "$*"
46614330f12Smrg}
46714330f12Smrg
4682378475aSmrg# func_error arg...
4692378475aSmrg# Echo program name prefixed message to standard error.
4702378475aSmrgfunc_error ()
4712378475aSmrg{
47214330f12Smrg    $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2
4732378475aSmrg}
4742378475aSmrg
4752378475aSmrg# func_warning arg...
4762378475aSmrg# Echo program name prefixed warning message to standard error.
4772378475aSmrgfunc_warning ()
4782378475aSmrg{
47914330f12Smrg    $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2
4802378475aSmrg
4812378475aSmrg    # bash bug again:
4822378475aSmrg    :
4832378475aSmrg}
4842378475aSmrg
4852378475aSmrg# func_fatal_error arg...
4862378475aSmrg# Echo program name prefixed message to standard error, and exit.
4872378475aSmrgfunc_fatal_error ()
4882378475aSmrg{
4892378475aSmrg    func_error ${1+"$@"}
4902378475aSmrg    exit $EXIT_FAILURE
4912378475aSmrg}
4922378475aSmrg
4932378475aSmrg# func_fatal_help arg...
4942378475aSmrg# Echo program name prefixed message to standard error, followed by
4952378475aSmrg# a help hint, and exit.
4962378475aSmrgfunc_fatal_help ()
4972378475aSmrg{
4982378475aSmrg    func_error ${1+"$@"}
4992378475aSmrg    func_fatal_error "$help"
5002378475aSmrg}
5012378475aSmrghelp="Try \`$progname --help' for more information."  ## default
5022378475aSmrg
5032378475aSmrg
5042378475aSmrg# func_grep expression filename
5052378475aSmrg# Check whether EXPRESSION matches any line of FILENAME, without output.
5062378475aSmrgfunc_grep ()
5072378475aSmrg{
5082378475aSmrg    $GREP "$1" "$2" >/dev/null 2>&1
5092378475aSmrg}
5102378475aSmrg
5112378475aSmrg
5122378475aSmrg# func_mkdir_p directory-path
5132378475aSmrg# Make sure the entire path to DIRECTORY-PATH is available.
5142378475aSmrgfunc_mkdir_p ()
5152378475aSmrg{
5162378475aSmrg    my_directory_path="$1"
5172378475aSmrg    my_dir_list=
5182378475aSmrg
5192378475aSmrg    if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
5202378475aSmrg
5212378475aSmrg      # Protect directory names starting with `-'
5222378475aSmrg      case $my_directory_path in
5232378475aSmrg        -*) my_directory_path="./$my_directory_path" ;;
5242378475aSmrg      esac
5252378475aSmrg
5262378475aSmrg      # While some portion of DIR does not yet exist...
5272378475aSmrg      while test ! -d "$my_directory_path"; do
5282378475aSmrg        # ...make a list in topmost first order.  Use a colon delimited
5292378475aSmrg	# list incase some portion of path contains whitespace.
5302378475aSmrg        my_dir_list="$my_directory_path:$my_dir_list"
5312378475aSmrg
5322378475aSmrg        # If the last portion added has no slash in it, the list is done
5332378475aSmrg        case $my_directory_path in */*) ;; *) break ;; esac
5342378475aSmrg
5352378475aSmrg        # ...otherwise throw away the child directory and loop
53614330f12Smrg        my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"`
5372378475aSmrg      done
53814330f12Smrg      my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'`
5392378475aSmrg
5402378475aSmrg      save_mkdir_p_IFS="$IFS"; IFS=':'
5412378475aSmrg      for my_dir in $my_dir_list; do
5422378475aSmrg	IFS="$save_mkdir_p_IFS"
5432378475aSmrg        # mkdir can fail with a `File exist' error if two processes
5442378475aSmrg        # try to create one of the directories concurrently.  Don't
5452378475aSmrg        # stop in that case!
5462378475aSmrg        $MKDIR "$my_dir" 2>/dev/null || :
5472378475aSmrg      done
5482378475aSmrg      IFS="$save_mkdir_p_IFS"
5492378475aSmrg
5502378475aSmrg      # Bail out if we (or some other process) failed to create a directory.
5512378475aSmrg      test -d "$my_directory_path" || \
5522378475aSmrg        func_fatal_error "Failed to create \`$1'"
5532378475aSmrg    fi
5542378475aSmrg}
55595b296d0Smrg
55695b296d0Smrg
55795b296d0Smrg# func_mktempdir [string]
55895b296d0Smrg# Make a temporary directory that won't clash with other running
55995b296d0Smrg# libtool processes, and avoids race conditions if possible.  If
56095b296d0Smrg# given, STRING is the basename for that directory.
56195b296d0Smrgfunc_mktempdir ()
56295b296d0Smrg{
56395b296d0Smrg    my_template="${TMPDIR-/tmp}/${1-$progname}"
56495b296d0Smrg
5652378475aSmrg    if test "$opt_dry_run" = ":"; then
56695b296d0Smrg      # Return a directory name, but don't create it in dry-run mode
56795b296d0Smrg      my_tmpdir="${my_template}-$$"
56895b296d0Smrg    else
56995b296d0Smrg
57095b296d0Smrg      # If mktemp works, use that first and foremost
57195b296d0Smrg      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
57295b296d0Smrg
57395b296d0Smrg      if test ! -d "$my_tmpdir"; then
5742378475aSmrg        # Failing that, at least try and use $RANDOM to avoid a race
5752378475aSmrg        my_tmpdir="${my_template}-${RANDOM-0}$$"
57695b296d0Smrg
5772378475aSmrg        save_mktempdir_umask=`umask`
5782378475aSmrg        umask 0077
5792378475aSmrg        $MKDIR "$my_tmpdir"
5802378475aSmrg        umask $save_mktempdir_umask
58195b296d0Smrg      fi
58295b296d0Smrg
58395b296d0Smrg      # If we're not in dry-run mode, bomb out on failure
5842378475aSmrg      test -d "$my_tmpdir" || \
5852378475aSmrg        func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
58695b296d0Smrg    fi
58795b296d0Smrg
58814330f12Smrg    $ECHO "$my_tmpdir"
58995b296d0Smrg}
59095b296d0Smrg
59195b296d0Smrg
5922378475aSmrg# func_quote_for_eval arg
5932378475aSmrg# Aesthetically quote ARG to be evaled later.
5942378475aSmrg# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
5952378475aSmrg# is double-quoted, suitable for a subsequent eval, whereas
5962378475aSmrg# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
5972378475aSmrg# which are still active within double quotes backslashified.
5982378475aSmrgfunc_quote_for_eval ()
59995b296d0Smrg{
6002378475aSmrg    case $1 in
6012378475aSmrg      *[\\\`\"\$]*)
60214330f12Smrg	func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;;
6032378475aSmrg      *)
6042378475aSmrg        func_quote_for_eval_unquoted_result="$1" ;;
6052378475aSmrg    esac
6062378475aSmrg
6072378475aSmrg    case $func_quote_for_eval_unquoted_result in
6082378475aSmrg      # Double-quote args containing shell metacharacters to delay
6092378475aSmrg      # word splitting, command substitution and and variable
6102378475aSmrg      # expansion for a subsequent eval.
6112378475aSmrg      # Many Bourne shells cannot handle close brackets correctly
6122378475aSmrg      # in scan sets, so we specify it separately.
6132378475aSmrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
6142378475aSmrg        func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
6152378475aSmrg        ;;
6162378475aSmrg      *)
6172378475aSmrg        func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
61895b296d0Smrg    esac
61995b296d0Smrg}
62095b296d0Smrg
62195b296d0Smrg
6222378475aSmrg# func_quote_for_expand arg
6232378475aSmrg# Aesthetically quote ARG to be evaled later; same as above,
6242378475aSmrg# but do not quote variable references.
6252378475aSmrgfunc_quote_for_expand ()
62695b296d0Smrg{
6272378475aSmrg    case $1 in
6282378475aSmrg      *[\\\`\"]*)
62914330f12Smrg	my_arg=`$ECHO "$1" | $SED \
6302378475aSmrg	    -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
63195b296d0Smrg      *)
6322378475aSmrg        my_arg="$1" ;;
6332378475aSmrg    esac
6342378475aSmrg
6352378475aSmrg    case $my_arg in
6362378475aSmrg      # Double-quote args containing shell metacharacters to delay
6372378475aSmrg      # word splitting and command substitution for a subsequent eval.
6382378475aSmrg      # Many Bourne shells cannot handle close brackets correctly
6392378475aSmrg      # in scan sets, so we specify it separately.
6402378475aSmrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
6412378475aSmrg        my_arg="\"$my_arg\""
6422378475aSmrg        ;;
6432378475aSmrg    esac
6442378475aSmrg
6452378475aSmrg    func_quote_for_expand_result="$my_arg"
64695b296d0Smrg}
64795b296d0Smrg
64895b296d0Smrg
6492378475aSmrg# func_show_eval cmd [fail_exp]
6502378475aSmrg# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
6512378475aSmrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
6522378475aSmrg# is given, then evaluate it.
6532378475aSmrgfunc_show_eval ()
65495b296d0Smrg{
6552378475aSmrg    my_cmd="$1"
6562378475aSmrg    my_fail_exp="${2-:}"
65739713583Smrg
6582378475aSmrg    ${opt_silent-false} || {
6592378475aSmrg      func_quote_for_expand "$my_cmd"
6602378475aSmrg      eval "func_echo $func_quote_for_expand_result"
6612378475aSmrg    }
6622378475aSmrg
6632378475aSmrg    if ${opt_dry_run-false}; then :; else
6642378475aSmrg      eval "$my_cmd"
6652378475aSmrg      my_status=$?
6662378475aSmrg      if test "$my_status" -eq 0; then :; else
6672378475aSmrg	eval "(exit $my_status); $my_fail_exp"
6682378475aSmrg      fi
66995b296d0Smrg    fi
67095b296d0Smrg}
67195b296d0Smrg
6722378475aSmrg
6732378475aSmrg# func_show_eval_locale cmd [fail_exp]
6742378475aSmrg# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
6752378475aSmrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
6762378475aSmrg# is given, then evaluate it.  Use the saved locale for evaluation.
6772378475aSmrgfunc_show_eval_locale ()
67895b296d0Smrg{
6792378475aSmrg    my_cmd="$1"
6802378475aSmrg    my_fail_exp="${2-:}"
6812378475aSmrg
6822378475aSmrg    ${opt_silent-false} || {
6832378475aSmrg      func_quote_for_expand "$my_cmd"
6842378475aSmrg      eval "func_echo $func_quote_for_expand_result"
6852378475aSmrg    }
6862378475aSmrg
6872378475aSmrg    if ${opt_dry_run-false}; then :; else
6882378475aSmrg      eval "$lt_user_locale
6892378475aSmrg	    $my_cmd"
6902378475aSmrg      my_status=$?
6912378475aSmrg      eval "$lt_safe_locale"
6922378475aSmrg      if test "$my_status" -eq 0; then :; else
6932378475aSmrg	eval "(exit $my_status); $my_fail_exp"
6942378475aSmrg      fi
69595b296d0Smrg    fi
6962378475aSmrg}
69795b296d0Smrg
69814330f12Smrg# func_tr_sh
69914330f12Smrg# Turn $1 into a string suitable for a shell variable name.
70014330f12Smrg# Result is stored in $func_tr_sh_result.  All characters
70114330f12Smrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further,
70214330f12Smrg# if $1 begins with a digit, a '_' is prepended as well.
70314330f12Smrgfunc_tr_sh ()
70414330f12Smrg{
70514330f12Smrg  case $1 in
70614330f12Smrg  [0-9]* | *[!a-zA-Z0-9_]*)
70714330f12Smrg    func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'`
70814330f12Smrg    ;;
70914330f12Smrg  * )
71014330f12Smrg    func_tr_sh_result=$1
71114330f12Smrg    ;;
71214330f12Smrg  esac
71314330f12Smrg}
7142378475aSmrg
7152378475aSmrg
7162378475aSmrg# func_version
7172378475aSmrg# Echo version message to standard output and exit.
7182378475aSmrgfunc_version ()
7192378475aSmrg{
72014330f12Smrg    $opt_debug
72114330f12Smrg
72214330f12Smrg    $SED -n '/(C)/!b go
72314330f12Smrg	:more
72414330f12Smrg	/\./!{
72514330f12Smrg	  N
72614330f12Smrg	  s/\n# / /
72714330f12Smrg	  b more
72814330f12Smrg	}
72914330f12Smrg	:go
73014330f12Smrg	/^# '$PROGRAM' (GNU /,/# warranty; / {
7312378475aSmrg        s/^# //
7322378475aSmrg	s/^# *$//
7332378475aSmrg        s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
7342378475aSmrg        p
7352378475aSmrg     }' < "$progpath"
7362378475aSmrg     exit $?
7372378475aSmrg}
7382378475aSmrg
7392378475aSmrg# func_usage
7402378475aSmrg# Echo short help message to standard output and exit.
7412378475aSmrgfunc_usage ()
7422378475aSmrg{
74314330f12Smrg    $opt_debug
74414330f12Smrg
74514330f12Smrg    $SED -n '/^# Usage:/,/^#  *.*--help/ {
7462378475aSmrg        s/^# //
7472378475aSmrg	s/^# *$//
7482378475aSmrg	s/\$progname/'$progname'/
7492378475aSmrg	p
7502378475aSmrg    }' < "$progpath"
75114330f12Smrg    echo
7522378475aSmrg    $ECHO "run \`$progname --help | more' for full usage"
7532378475aSmrg    exit $?
7542378475aSmrg}
7552378475aSmrg
75614330f12Smrg# func_help [NOEXIT]
75714330f12Smrg# Echo long help message to standard output and exit,
75814330f12Smrg# unless 'noexit' is passed as argument.
7592378475aSmrgfunc_help ()
7602378475aSmrg{
76114330f12Smrg    $opt_debug
76214330f12Smrg
7632378475aSmrg    $SED -n '/^# Usage:/,/# Report bugs to/ {
76414330f12Smrg	:print
7652378475aSmrg        s/^# //
7662378475aSmrg	s/^# *$//
7672378475aSmrg	s*\$progname*'$progname'*
7682378475aSmrg	s*\$host*'"$host"'*
7692378475aSmrg	s*\$SHELL*'"$SHELL"'*
7702378475aSmrg	s*\$LTCC*'"$LTCC"'*
7712378475aSmrg	s*\$LTCFLAGS*'"$LTCFLAGS"'*
7722378475aSmrg	s*\$LD*'"$LD"'*
7732378475aSmrg	s/\$with_gnu_ld/'"$with_gnu_ld"'/
7742378475aSmrg	s/\$automake_version/'"`(automake --version) 2>/dev/null |$SED 1q`"'/
7752378475aSmrg	s/\$autoconf_version/'"`(autoconf --version) 2>/dev/null |$SED 1q`"'/
7762378475aSmrg	p
77714330f12Smrg	d
77814330f12Smrg     }
77914330f12Smrg     /^# .* home page:/b print
78014330f12Smrg     /^# General help using/b print
78114330f12Smrg     ' < "$progpath"
78214330f12Smrg    ret=$?
78314330f12Smrg    if test -z "$1"; then
78414330f12Smrg      exit $ret
78514330f12Smrg    fi
7862378475aSmrg}
7872378475aSmrg
7882378475aSmrg# func_missing_arg argname
7892378475aSmrg# Echo program name prefixed message to standard error and set global
7902378475aSmrg# exit_cmd.
7912378475aSmrgfunc_missing_arg ()
7922378475aSmrg{
79314330f12Smrg    $opt_debug
79414330f12Smrg
79514330f12Smrg    func_error "missing argument for $1."
7962378475aSmrg    exit_cmd=exit
79795b296d0Smrg}
79895b296d0Smrg
79939713583Smrg
80014330f12Smrg# func_split_short_opt shortopt
80114330f12Smrg# Set func_split_short_opt_name and func_split_short_opt_arg shell
80214330f12Smrg# variables after splitting SHORTOPT after the 2nd character.
80314330f12Smrgfunc_split_short_opt ()
80414330f12Smrg{
80514330f12Smrg    my_sed_short_opt='1s/^\(..\).*$/\1/;q'
80614330f12Smrg    my_sed_short_rest='1s/^..\(.*\)$/\1/;q'
80739713583Smrg
80814330f12Smrg    func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"`
80914330f12Smrg    func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"`
81014330f12Smrg} # func_split_short_opt may be replaced by extended shell implementation
81114330f12Smrg
81214330f12Smrg
81314330f12Smrg# func_split_long_opt longopt
81414330f12Smrg# Set func_split_long_opt_name and func_split_long_opt_arg shell
81514330f12Smrg# variables after splitting LONGOPT at the `=' sign.
81614330f12Smrgfunc_split_long_opt ()
81714330f12Smrg{
81814330f12Smrg    my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q'
81914330f12Smrg    my_sed_long_arg='1s/^--[^=]*=//'
82014330f12Smrg
82114330f12Smrg    func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"`
82214330f12Smrg    func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"`
82314330f12Smrg} # func_split_long_opt may be replaced by extended shell implementation
82414330f12Smrg
82514330f12Smrgexit_cmd=:
8262378475aSmrg
8272378475aSmrg
8282378475aSmrg
82995b296d0Smrg
83095b296d0Smrg
8312378475aSmrgmagic="%%%MAGIC variable%%%"
8322378475aSmrgmagic_exe="%%%MAGIC EXE variable%%%"
83395b296d0Smrg
8342378475aSmrg# Global variables.
8352378475aSmrgnonopt=
8362378475aSmrgpreserve_args=
8372378475aSmrglo2o="s/\\.lo\$/.${objext}/"
8382378475aSmrgo2lo="s/\\.${objext}\$/.lo/"
8392378475aSmrgextracted_archives=
8402378475aSmrgextracted_serial=0
84139713583Smrg
8422378475aSmrg# If this variable is set in any of the actions, the command in it
8432378475aSmrg# will be execed at the end.  This prevents here-documents from being
8442378475aSmrg# left over by shells.
8452378475aSmrgexec_cmd=
8462378475aSmrg
84714330f12Smrg# func_append var value
84814330f12Smrg# Append VALUE to the end of shell variable VAR.
84914330f12Smrgfunc_append ()
85014330f12Smrg{
85114330f12Smrg    eval "${1}=\$${1}\${2}"
85214330f12Smrg} # func_append may be replaced by extended shell implementation
85314330f12Smrg
85414330f12Smrg# func_append_quoted var value
85514330f12Smrg# Quote VALUE and append to the end of shell variable VAR, separated
85614330f12Smrg# by a space.
85714330f12Smrgfunc_append_quoted ()
85814330f12Smrg{
85914330f12Smrg    func_quote_for_eval "${2}"
86014330f12Smrg    eval "${1}=\$${1}\\ \$func_quote_for_eval_result"
86114330f12Smrg} # func_append_quoted may be replaced by extended shell implementation
86214330f12Smrg
86314330f12Smrg
86414330f12Smrg# func_arith arithmetic-term...
86514330f12Smrgfunc_arith ()
86614330f12Smrg{
86714330f12Smrg    func_arith_result=`expr "${@}"`
86814330f12Smrg} # func_arith may be replaced by extended shell implementation
86914330f12Smrg
87014330f12Smrg
87114330f12Smrg# func_len string
87214330f12Smrg# STRING may not start with a hyphen.
87314330f12Smrgfunc_len ()
87414330f12Smrg{
87514330f12Smrg    func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len`
87614330f12Smrg} # func_len may be replaced by extended shell implementation
87714330f12Smrg
87814330f12Smrg
87914330f12Smrg# func_lo2o object
88014330f12Smrgfunc_lo2o ()
88114330f12Smrg{
88214330f12Smrg    func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"`
88314330f12Smrg} # func_lo2o may be replaced by extended shell implementation
88414330f12Smrg
88514330f12Smrg
88614330f12Smrg# func_xform libobj-or-source
88714330f12Smrgfunc_xform ()
88814330f12Smrg{
88914330f12Smrg    func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'`
89014330f12Smrg} # func_xform may be replaced by extended shell implementation
89114330f12Smrg
89214330f12Smrg
8932378475aSmrg# func_fatal_configuration arg...
8942378475aSmrg# Echo program name prefixed message to standard error, followed by
8952378475aSmrg# a configuration failure hint, and exit.
8962378475aSmrgfunc_fatal_configuration ()
8972378475aSmrg{
8982378475aSmrg    func_error ${1+"$@"}
8992378475aSmrg    func_error "See the $PACKAGE documentation for more information."
9002378475aSmrg    func_fatal_error "Fatal configuration error."
9012378475aSmrg}
902ff89ac2bSmrg
90339713583Smrg
9042378475aSmrg# func_config
9052378475aSmrg# Display the configuration for all the tags in this script.
9062378475aSmrgfunc_config ()
9072378475aSmrg{
9082378475aSmrg    re_begincf='^# ### BEGIN LIBTOOL'
9092378475aSmrg    re_endcf='^# ### END LIBTOOL'
9102378475aSmrg
9112378475aSmrg    # Default configuration.
9122378475aSmrg    $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
91395b296d0Smrg
91495b296d0Smrg    # Now print the configurations for the tags.
91595b296d0Smrg    for tagname in $taglist; do
9162378475aSmrg      $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
91795b296d0Smrg    done
918e6f085baSmrg
9192378475aSmrg    exit $?
9202378475aSmrg}
921e6f085baSmrg
9222378475aSmrg# func_features
9232378475aSmrg# Display the features supported by this script.
9242378475aSmrgfunc_features ()
9252378475aSmrg{
92614330f12Smrg    echo "host: $host"
92795b296d0Smrg    if test "$build_libtool_libs" = yes; then
92814330f12Smrg      echo "enable shared libraries"
92995b296d0Smrg    else
93014330f12Smrg      echo "disable shared libraries"
93195b296d0Smrg    fi
93295b296d0Smrg    if test "$build_old_libs" = yes; then
93314330f12Smrg      echo "enable static libraries"
93495b296d0Smrg    else
93514330f12Smrg      echo "disable static libraries"
93695b296d0Smrg    fi
9372378475aSmrg
93895b296d0Smrg    exit $?
9392378475aSmrg}
94095b296d0Smrg
9412378475aSmrg# func_enable_tag tagname
9422378475aSmrg# Verify that TAGNAME is valid, and either flag an error and exit, or
9432378475aSmrg# enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
9442378475aSmrg# variable here.
9452378475aSmrgfunc_enable_tag ()
9462378475aSmrg{
9472378475aSmrg  # Global variable:
9482378475aSmrg  tagname="$1"
94995b296d0Smrg
9502378475aSmrg  re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
9512378475aSmrg  re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
9522378475aSmrg  sed_extractcf="/$re_begincf/,/$re_endcf/p"
95339713583Smrg
9542378475aSmrg  # Validate tagname.
9552378475aSmrg  case $tagname in
9562378475aSmrg    *[!-_A-Za-z0-9,/]*)
9572378475aSmrg      func_fatal_error "invalid tag name: $tagname"
9582378475aSmrg      ;;
9592378475aSmrg  esac
96095b296d0Smrg
9612378475aSmrg  # Don't test for the "default" C tag, as we know it's
9622378475aSmrg  # there but not specially marked.
9632378475aSmrg  case $tagname in
9642378475aSmrg    CC) ;;
9652378475aSmrg    *)
9662378475aSmrg      if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
9672378475aSmrg	taglist="$taglist $tagname"
9682378475aSmrg
9692378475aSmrg	# Evaluate the configuration.  Be careful to quote the path
9702378475aSmrg	# and the sed script, to avoid splitting on whitespace, but
9712378475aSmrg	# also don't use non-portable quotes within backquotes within
9722378475aSmrg	# quotes we have to do it in 2 steps:
9732378475aSmrg	extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
9742378475aSmrg	eval "$extractedcf"
9752378475aSmrg      else
9762378475aSmrg	func_error "ignoring unknown tag $tagname"
9772378475aSmrg      fi
9782378475aSmrg      ;;
9792378475aSmrg  esac
9802378475aSmrg}
9812378475aSmrg
98214330f12Smrg# func_check_version_match
98314330f12Smrg# Ensure that we are using m4 macros, and libtool script from the same
98414330f12Smrg# release of libtool.
98514330f12Smrgfunc_check_version_match ()
9862378475aSmrg{
98714330f12Smrg  if test "$package_revision" != "$macro_revision"; then
98814330f12Smrg    if test "$VERSION" != "$macro_version"; then
98914330f12Smrg      if test -z "$macro_version"; then
99014330f12Smrg        cat >&2 <<_LT_EOF
99114330f12Smrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
99214330f12Smrg$progname: definition of this LT_INIT comes from an older release.
99314330f12Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
99414330f12Smrg$progname: and run autoconf again.
99514330f12Smrg_LT_EOF
99614330f12Smrg      else
99714330f12Smrg        cat >&2 <<_LT_EOF
99814330f12Smrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
99914330f12Smrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
100014330f12Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
100114330f12Smrg$progname: and run autoconf again.
100214330f12Smrg_LT_EOF
100314330f12Smrg      fi
100414330f12Smrg    else
100514330f12Smrg      cat >&2 <<_LT_EOF
100614330f12Smrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
100714330f12Smrg$progname: but the definition of this LT_INIT comes from revision $macro_revision.
100814330f12Smrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision
100914330f12Smrg$progname: of $PACKAGE $VERSION and run autoconf again.
101014330f12Smrg_LT_EOF
101114330f12Smrg    fi
1012e6f085baSmrg
101314330f12Smrg    exit $EXIT_MISMATCH
101414330f12Smrg  fi
101514330f12Smrg}
101614330f12Smrg
101714330f12Smrg
101814330f12Smrg# Shorthand for --mode=foo, only valid as the first argument
101914330f12Smrgcase $1 in
102014330f12Smrgclean|clea|cle|cl)
102114330f12Smrg  shift; set dummy --mode clean ${1+"$@"}; shift
102214330f12Smrg  ;;
102314330f12Smrgcompile|compil|compi|comp|com|co|c)
102414330f12Smrg  shift; set dummy --mode compile ${1+"$@"}; shift
102514330f12Smrg  ;;
102614330f12Smrgexecute|execut|execu|exec|exe|ex|e)
102714330f12Smrg  shift; set dummy --mode execute ${1+"$@"}; shift
102814330f12Smrg  ;;
102914330f12Smrgfinish|finis|fini|fin|fi|f)
103014330f12Smrg  shift; set dummy --mode finish ${1+"$@"}; shift
103114330f12Smrg  ;;
103214330f12Smrginstall|instal|insta|inst|ins|in|i)
103314330f12Smrg  shift; set dummy --mode install ${1+"$@"}; shift
103414330f12Smrg  ;;
103514330f12Smrglink|lin|li|l)
103614330f12Smrg  shift; set dummy --mode link ${1+"$@"}; shift
103714330f12Smrg  ;;
103814330f12Smrguninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
103914330f12Smrg  shift; set dummy --mode uninstall ${1+"$@"}; shift
104014330f12Smrg  ;;
104114330f12Smrgesac
104214330f12Smrg
104314330f12Smrg
104414330f12Smrg
104514330f12Smrg# Option defaults:
104614330f12Smrgopt_debug=:
104714330f12Smrgopt_dry_run=false
104814330f12Smrgopt_config=false
104914330f12Smrgopt_preserve_dup_deps=false
105014330f12Smrgopt_features=false
105114330f12Smrgopt_finish=false
105214330f12Smrgopt_help=false
105314330f12Smrgopt_help_all=false
105414330f12Smrgopt_silent=:
105514330f12Smrgopt_verbose=:
105614330f12Smrgopt_silent=false
105714330f12Smrgopt_verbose=false
105895b296d0Smrg
105914330f12Smrg
106014330f12Smrg# Parse options once, thoroughly.  This comes as soon as possible in the
106114330f12Smrg# script to make things like `--version' happen as quickly as we can.
106214330f12Smrg{
106314330f12Smrg  # this just eases exit handling
106414330f12Smrg  while test $# -gt 0; do
10652378475aSmrg    opt="$1"
10662378475aSmrg    shift
10672378475aSmrg    case $opt in
106814330f12Smrg      --debug|-x)	opt_debug='set -x'
10692378475aSmrg			func_echo "enabling shell trace mode"
10702378475aSmrg			$opt_debug
10712378475aSmrg			;;
107214330f12Smrg      --dry-run|--dryrun|-n)
107314330f12Smrg			opt_dry_run=:
10742378475aSmrg			;;
107514330f12Smrg      --config)
107614330f12Smrg			opt_config=:
107714330f12Smrgfunc_config
107814330f12Smrg			;;
107914330f12Smrg      --dlopen|-dlopen)
108014330f12Smrg			optarg="$1"
108114330f12Smrg			opt_dlopen="${opt_dlopen+$opt_dlopen
108214330f12Smrg}$optarg"
10832378475aSmrg			shift
10842378475aSmrg			;;
10852378475aSmrg      --preserve-dup-deps)
108614330f12Smrg			opt_preserve_dup_deps=:
10872378475aSmrg			;;
108814330f12Smrg      --features)
108914330f12Smrg			opt_features=:
109014330f12Smrgfunc_features
109114330f12Smrg			;;
109214330f12Smrg      --finish)
109314330f12Smrg			opt_finish=:
109414330f12Smrgset dummy --mode finish ${1+"$@"}; shift
109514330f12Smrg			;;
109614330f12Smrg      --help)
109714330f12Smrg			opt_help=:
109814330f12Smrg			;;
109914330f12Smrg      --help-all)
110014330f12Smrg			opt_help_all=:
110114330f12Smrgopt_help=': help-all'
110214330f12Smrg			;;
110314330f12Smrg      --mode)
110414330f12Smrg			test $# = 0 && func_missing_arg $opt && break
110514330f12Smrg			optarg="$1"
110614330f12Smrg			opt_mode="$optarg"
110714330f12Smrgcase $optarg in
110814330f12Smrg  # Valid mode arguments:
110914330f12Smrg  clean|compile|execute|finish|install|link|relink|uninstall) ;;
111014330f12Smrg
111114330f12Smrg  # Catch anything else as an error
111214330f12Smrg  *) func_error "invalid argument for $opt"
111314330f12Smrg     exit_cmd=exit
111414330f12Smrg     break
111514330f12Smrg     ;;
111614330f12Smrgesac
111714330f12Smrg			shift
111814330f12Smrg			;;
111914330f12Smrg      --no-silent|--no-quiet)
11202378475aSmrg			opt_silent=false
112114330f12Smrgfunc_append preserve_args " $opt"
11222378475aSmrg			;;
112314330f12Smrg      --no-verbose)
112414330f12Smrg			opt_verbose=false
112514330f12Smrgfunc_append preserve_args " $opt"
112614330f12Smrg			;;
112714330f12Smrg      --silent|--quiet)
112814330f12Smrg			opt_silent=:
112914330f12Smrgfunc_append preserve_args " $opt"
113014330f12Smrg        opt_verbose=false
113114330f12Smrg			;;
113214330f12Smrg      --verbose|-v)
113314330f12Smrg			opt_verbose=:
113414330f12Smrgfunc_append preserve_args " $opt"
113514330f12Smrgopt_silent=false
113614330f12Smrg			;;
113714330f12Smrg      --tag)
113814330f12Smrg			test $# = 0 && func_missing_arg $opt && break
113914330f12Smrg			optarg="$1"
114014330f12Smrg			opt_tag="$optarg"
114114330f12Smrgfunc_append preserve_args " $opt $optarg"
114214330f12Smrgfunc_enable_tag "$optarg"
11432378475aSmrg			shift
11442378475aSmrg			;;
11452378475aSmrg
114614330f12Smrg      -\?|-h)		func_usage				;;
114714330f12Smrg      --help)		func_help				;;
114814330f12Smrg      --version)	func_version				;;
114914330f12Smrg
11502378475aSmrg      # Separate optargs to long options:
115114330f12Smrg      --*=*)
115214330f12Smrg			func_split_long_opt "$opt"
115314330f12Smrg			set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"}
11542378475aSmrg			shift
11552378475aSmrg			;;
11562378475aSmrg
115714330f12Smrg      # Separate non-argument short options:
115814330f12Smrg      -\?*|-h*|-n*|-v*)
115914330f12Smrg			func_split_short_opt "$opt"
116014330f12Smrg			set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"}
116114330f12Smrg			shift
11622378475aSmrg			;;
116314330f12Smrg
116414330f12Smrg      --)		break					;;
116514330f12Smrg      -*)		func_fatal_help "unrecognized option \`$opt'" ;;
116614330f12Smrg      *)		set dummy "$opt" ${1+"$@"};	shift; break  ;;
11672378475aSmrg    esac
11682378475aSmrg  done
11692378475aSmrg
117014330f12Smrg  # Validate options:
117114330f12Smrg
117214330f12Smrg  # save first non-option argument
117314330f12Smrg  if test "$#" -gt 0; then
117414330f12Smrg    nonopt="$opt"
117514330f12Smrg    shift
117614330f12Smrg  fi
117714330f12Smrg
117814330f12Smrg  # preserve --debug
117914330f12Smrg  test "$opt_debug" = : || func_append preserve_args " --debug"
11802378475aSmrg
11812378475aSmrg  case $host in
11822378475aSmrg    *cygwin* | *mingw* | *pw32* | *cegcc*)
11832378475aSmrg      # don't eliminate duplications in $postdeps and $predeps
11842378475aSmrg      opt_duplicate_compiler_generated_deps=:
1185e6f085baSmrg      ;;
1186e6f085baSmrg    *)
118714330f12Smrg      opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
11882378475aSmrg      ;;
11892378475aSmrg  esac
119039713583Smrg
119114330f12Smrg  $opt_help || {
119214330f12Smrg    # Sanity checks first:
119314330f12Smrg    func_check_version_match
11942378475aSmrg
119514330f12Smrg    if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
119614330f12Smrg      func_fatal_configuration "not configured to build any kind of library"
11972378475aSmrg    fi
11982378475aSmrg
119914330f12Smrg    # Darwin sucks
120014330f12Smrg    eval std_shrext=\"$shrext_cmds\"
12012378475aSmrg
120214330f12Smrg    # Only execute mode is allowed to have -dlopen flags.
120314330f12Smrg    if test -n "$opt_dlopen" && test "$opt_mode" != execute; then
120414330f12Smrg      func_error "unrecognized option \`-dlopen'"
120514330f12Smrg      $ECHO "$help" 1>&2
120614330f12Smrg      exit $EXIT_FAILURE
120714330f12Smrg    fi
120895b296d0Smrg
120914330f12Smrg    # Change the help message to a mode-specific one.
121014330f12Smrg    generic_help="$help"
121114330f12Smrg    help="Try \`$progname --help --mode=$opt_mode' for more information."
121214330f12Smrg  }
12132378475aSmrg
12142378475aSmrg
121514330f12Smrg  # Bail if the options were screwed
121614330f12Smrg  $exit_cmd $EXIT_FAILURE
121714330f12Smrg}
12182378475aSmrg
12192378475aSmrg
122095b296d0Smrg
122195b296d0Smrg
122214330f12Smrg## ----------- ##
122314330f12Smrg##    Main.    ##
122414330f12Smrg## ----------- ##
122595b296d0Smrg
12262378475aSmrg# func_lalib_p file
12272378475aSmrg# True iff FILE is a libtool `.la' library or `.lo' object file.
12282378475aSmrg# This function is only a basic sanity check; it will hardly flush out
12292378475aSmrg# determined imposters.
12302378475aSmrgfunc_lalib_p ()
12312378475aSmrg{
12322378475aSmrg    test -f "$1" &&
12332378475aSmrg      $SED -e 4q "$1" 2>/dev/null \
12342378475aSmrg        | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
12352378475aSmrg}
123695b296d0Smrg
12372378475aSmrg# func_lalib_unsafe_p file
12382378475aSmrg# True iff FILE is a libtool `.la' library or `.lo' object file.
12392378475aSmrg# This function implements the same check as func_lalib_p without
12402378475aSmrg# resorting to external programs.  To this end, it redirects stdin and
12412378475aSmrg# closes it afterwards, without saving the original file descriptor.
12422378475aSmrg# As a safety measure, use it only where a negative result would be
12432378475aSmrg# fatal anyway.  Works if `file' does not exist.
12442378475aSmrgfunc_lalib_unsafe_p ()
12452378475aSmrg{
12462378475aSmrg    lalib_p=no
12472378475aSmrg    if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
12482378475aSmrg	for lalib_p_l in 1 2 3 4
12492378475aSmrg	do
12502378475aSmrg	    read lalib_p_line
12512378475aSmrg	    case "$lalib_p_line" in
12522378475aSmrg		\#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
12532378475aSmrg	    esac
12542378475aSmrg	done
12552378475aSmrg	exec 0<&5 5<&-
12562378475aSmrg    fi
12572378475aSmrg    test "$lalib_p" = yes
12582378475aSmrg}
125995b296d0Smrg
12602378475aSmrg# func_ltwrapper_script_p file
12612378475aSmrg# True iff FILE is a libtool wrapper script
12622378475aSmrg# This function is only a basic sanity check; it will hardly flush out
12632378475aSmrg# determined imposters.
12642378475aSmrgfunc_ltwrapper_script_p ()
12652378475aSmrg{
12662378475aSmrg    func_lalib_p "$1"
12672378475aSmrg}
126895b296d0Smrg
12692378475aSmrg# func_ltwrapper_executable_p file
12702378475aSmrg# True iff FILE is a libtool wrapper executable
12712378475aSmrg# This function is only a basic sanity check; it will hardly flush out
12722378475aSmrg# determined imposters.
12732378475aSmrgfunc_ltwrapper_executable_p ()
12742378475aSmrg{
12752378475aSmrg    func_ltwrapper_exec_suffix=
12762378475aSmrg    case $1 in
12772378475aSmrg    *.exe) ;;
12782378475aSmrg    *) func_ltwrapper_exec_suffix=.exe ;;
12792378475aSmrg    esac
12802378475aSmrg    $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
12812378475aSmrg}
128239713583Smrg
12832378475aSmrg# func_ltwrapper_scriptname file
12842378475aSmrg# Assumes file is an ltwrapper_executable
12852378475aSmrg# uses $file to determine the appropriate filename for a
12862378475aSmrg# temporary ltwrapper_script.
12872378475aSmrgfunc_ltwrapper_scriptname ()
12882378475aSmrg{
128914330f12Smrg    func_dirname_and_basename "$1" "" "."
129014330f12Smrg    func_stripname '' '.exe' "$func_basename_result"
129114330f12Smrg    func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper"
12922378475aSmrg}
12932378475aSmrg
12942378475aSmrg# func_ltwrapper_p file
12952378475aSmrg# True iff FILE is a libtool wrapper script or wrapper executable
12962378475aSmrg# This function is only a basic sanity check; it will hardly flush out
12972378475aSmrg# determined imposters.
12982378475aSmrgfunc_ltwrapper_p ()
12992378475aSmrg{
13002378475aSmrg    func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
13012378475aSmrg}
13022378475aSmrg
13032378475aSmrg
13042378475aSmrg# func_execute_cmds commands fail_cmd
13052378475aSmrg# Execute tilde-delimited COMMANDS.
13062378475aSmrg# If FAIL_CMD is given, eval that upon failure.
13072378475aSmrg# FAIL_CMD may read-access the current command in variable CMD!
13082378475aSmrgfunc_execute_cmds ()
13092378475aSmrg{
13102378475aSmrg    $opt_debug
13112378475aSmrg    save_ifs=$IFS; IFS='~'
13122378475aSmrg    for cmd in $1; do
13132378475aSmrg      IFS=$save_ifs
13142378475aSmrg      eval cmd=\"$cmd\"
13152378475aSmrg      func_show_eval "$cmd" "${2-:}"
13162378475aSmrg    done
13172378475aSmrg    IFS=$save_ifs
13182378475aSmrg}
13192378475aSmrg
13202378475aSmrg
13212378475aSmrg# func_source file
13222378475aSmrg# Source FILE, adding directory component if necessary.
13232378475aSmrg# Note that it is not necessary on cygwin/mingw to append a dot to
13242378475aSmrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe
13252378475aSmrg# behavior happens only for exec(3), not for open(2)!  Also, sourcing
13262378475aSmrg# `FILE.' does not work on cygwin managed mounts.
13272378475aSmrgfunc_source ()
13282378475aSmrg{
13292378475aSmrg    $opt_debug
13302378475aSmrg    case $1 in
13312378475aSmrg    */* | *\\*)	. "$1" ;;
13322378475aSmrg    *)		. "./$1" ;;
13332378475aSmrg    esac
13342378475aSmrg}
13352378475aSmrg
13362378475aSmrg
133714330f12Smrg# func_resolve_sysroot PATH
133814330f12Smrg# Replace a leading = in PATH with a sysroot.  Store the result into
133914330f12Smrg# func_resolve_sysroot_result
134014330f12Smrgfunc_resolve_sysroot ()
134114330f12Smrg{
134214330f12Smrg  func_resolve_sysroot_result=$1
134314330f12Smrg  case $func_resolve_sysroot_result in
134414330f12Smrg  =*)
134514330f12Smrg    func_stripname '=' '' "$func_resolve_sysroot_result"
134614330f12Smrg    func_resolve_sysroot_result=$lt_sysroot$func_stripname_result
134714330f12Smrg    ;;
134814330f12Smrg  esac
134914330f12Smrg}
135014330f12Smrg
135114330f12Smrg# func_replace_sysroot PATH
135214330f12Smrg# If PATH begins with the sysroot, replace it with = and
135314330f12Smrg# store the result into func_replace_sysroot_result.
135414330f12Smrgfunc_replace_sysroot ()
135514330f12Smrg{
135614330f12Smrg  case "$lt_sysroot:$1" in
135714330f12Smrg  ?*:"$lt_sysroot"*)
135814330f12Smrg    func_stripname "$lt_sysroot" '' "$1"
135914330f12Smrg    func_replace_sysroot_result="=$func_stripname_result"
136014330f12Smrg    ;;
136114330f12Smrg  *)
136214330f12Smrg    # Including no sysroot.
136314330f12Smrg    func_replace_sysroot_result=$1
136414330f12Smrg    ;;
136514330f12Smrg  esac
136614330f12Smrg}
136714330f12Smrg
13682378475aSmrg# func_infer_tag arg
13692378475aSmrg# Infer tagged configuration to use if any are available and
13702378475aSmrg# if one wasn't chosen via the "--tag" command line option.
13712378475aSmrg# Only attempt this if the compiler in the base compile
13722378475aSmrg# command doesn't match the default compiler.
13732378475aSmrg# arg is usually of the form 'gcc ...'
13742378475aSmrgfunc_infer_tag ()
13752378475aSmrg{
13762378475aSmrg    $opt_debug
13772378475aSmrg    if test -n "$available_tags" && test -z "$tagname"; then
13782378475aSmrg      CC_quoted=
13792378475aSmrg      for arg in $CC; do
138014330f12Smrg	func_append_quoted CC_quoted "$arg"
13812378475aSmrg      done
138214330f12Smrg      CC_expanded=`func_echo_all $CC`
138314330f12Smrg      CC_quoted_expanded=`func_echo_all $CC_quoted`
13842378475aSmrg      case $@ in
13852378475aSmrg      # Blanks in the command may have been stripped by the calling shell,
13862378475aSmrg      # but not from the CC environment variable when configure was run.
138714330f12Smrg      " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
138814330f12Smrg      " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
13892378475aSmrg      # Blanks at the start of $base_compile will cause this to fail
13902378475aSmrg      # if we don't check for them as well.
13912378475aSmrg      *)
13922378475aSmrg	for z in $available_tags; do
13932378475aSmrg	  if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
13942378475aSmrg	    # Evaluate the configuration.
13952378475aSmrg	    eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
13962378475aSmrg	    CC_quoted=
13972378475aSmrg	    for arg in $CC; do
13982378475aSmrg	      # Double-quote args containing other shell metacharacters.
139914330f12Smrg	      func_append_quoted CC_quoted "$arg"
14002378475aSmrg	    done
140114330f12Smrg	    CC_expanded=`func_echo_all $CC`
140214330f12Smrg	    CC_quoted_expanded=`func_echo_all $CC_quoted`
14032378475aSmrg	    case "$@ " in
140414330f12Smrg	    " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
140514330f12Smrg	    " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
14062378475aSmrg	      # The compiler in the base compile command matches
14072378475aSmrg	      # the one in the tagged configuration.
14082378475aSmrg	      # Assume this is the tagged configuration we want.
14092378475aSmrg	      tagname=$z
14102378475aSmrg	      break
14112378475aSmrg	      ;;
14122378475aSmrg	    esac
14132378475aSmrg	  fi
14142378475aSmrg	done
14152378475aSmrg	# If $tagname still isn't set, then no tagged configuration
14162378475aSmrg	# was found and let the user know that the "--tag" command
14172378475aSmrg	# line option must be used.
14182378475aSmrg	if test -z "$tagname"; then
14192378475aSmrg	  func_echo "unable to infer tagged configuration"
14202378475aSmrg	  func_fatal_error "specify a tag with \`--tag'"
14212378475aSmrg#	else
14222378475aSmrg#	  func_verbose "using $tagname tagged configuration"
14232378475aSmrg	fi
14242378475aSmrg	;;
14252378475aSmrg      esac
14262378475aSmrg    fi
14272378475aSmrg}
14282378475aSmrg
14292378475aSmrg
14302378475aSmrg
14312378475aSmrg# func_write_libtool_object output_name pic_name nonpic_name
14322378475aSmrg# Create a libtool object file (analogous to a ".la" file),
14332378475aSmrg# but don't create it if we're doing a dry run.
14342378475aSmrgfunc_write_libtool_object ()
14352378475aSmrg{
14362378475aSmrg    write_libobj=${1}
14372378475aSmrg    if test "$build_libtool_libs" = yes; then
14382378475aSmrg      write_lobj=\'${2}\'
14392378475aSmrg    else
14402378475aSmrg      write_lobj=none
14412378475aSmrg    fi
14422378475aSmrg
14432378475aSmrg    if test "$build_old_libs" = yes; then
14442378475aSmrg      write_oldobj=\'${3}\'
14452378475aSmrg    else
14462378475aSmrg      write_oldobj=none
14472378475aSmrg    fi
14482378475aSmrg
14492378475aSmrg    $opt_dry_run || {
14502378475aSmrg      cat >${write_libobj}T <<EOF
14512378475aSmrg# $write_libobj - a libtool object file
14522378475aSmrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
14532378475aSmrg#
14542378475aSmrg# Please DO NOT delete this file!
14552378475aSmrg# It is necessary for linking the library.
14562378475aSmrg
14572378475aSmrg# Name of the PIC object.
14582378475aSmrgpic_object=$write_lobj
14592378475aSmrg
14602378475aSmrg# Name of the non-PIC object
14612378475aSmrgnon_pic_object=$write_oldobj
14622378475aSmrg
14632378475aSmrgEOF
14642378475aSmrg      $MV "${write_libobj}T" "${write_libobj}"
14652378475aSmrg    }
14662378475aSmrg}
14672378475aSmrg
146814330f12Smrg
146914330f12Smrg##################################################
147014330f12Smrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS #
147114330f12Smrg##################################################
147214330f12Smrg
147314330f12Smrg# func_convert_core_file_wine_to_w32 ARG
147414330f12Smrg# Helper function used by file name conversion functions when $build is *nix,
147514330f12Smrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a
147614330f12Smrg# correctly configured wine environment available, with the winepath program
147714330f12Smrg# in $build's $PATH.
147814330f12Smrg#
147914330f12Smrg# ARG is the $build file name to be converted to w32 format.
148014330f12Smrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will
148114330f12Smrg# be empty on error (or when ARG is empty)
148214330f12Smrgfunc_convert_core_file_wine_to_w32 ()
148314330f12Smrg{
148414330f12Smrg  $opt_debug
148514330f12Smrg  func_convert_core_file_wine_to_w32_result="$1"
148614330f12Smrg  if test -n "$1"; then
148714330f12Smrg    # Unfortunately, winepath does not exit with a non-zero error code, so we
148814330f12Smrg    # are forced to check the contents of stdout. On the other hand, if the
148914330f12Smrg    # command is not found, the shell will set an exit code of 127 and print
149014330f12Smrg    # *an error message* to stdout. So we must check for both error code of
149114330f12Smrg    # zero AND non-empty stdout, which explains the odd construction:
149214330f12Smrg    func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
149314330f12Smrg    if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then
149414330f12Smrg      func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
149514330f12Smrg        $SED -e "$lt_sed_naive_backslashify"`
149614330f12Smrg    else
149714330f12Smrg      func_convert_core_file_wine_to_w32_result=
149814330f12Smrg    fi
149914330f12Smrg  fi
150014330f12Smrg}
150114330f12Smrg# end: func_convert_core_file_wine_to_w32
150214330f12Smrg
150314330f12Smrg
150414330f12Smrg# func_convert_core_path_wine_to_w32 ARG
150514330f12Smrg# Helper function used by path conversion functions when $build is *nix, and
150614330f12Smrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly
150714330f12Smrg# configured wine environment available, with the winepath program in $build's
150814330f12Smrg# $PATH. Assumes ARG has no leading or trailing path separator characters.
150914330f12Smrg#
151014330f12Smrg# ARG is path to be converted from $build format to win32.
151114330f12Smrg# Result is available in $func_convert_core_path_wine_to_w32_result.
151214330f12Smrg# Unconvertible file (directory) names in ARG are skipped; if no directory names
151314330f12Smrg# are convertible, then the result may be empty.
151414330f12Smrgfunc_convert_core_path_wine_to_w32 ()
151514330f12Smrg{
151614330f12Smrg  $opt_debug
151714330f12Smrg  # unfortunately, winepath doesn't convert paths, only file names
151814330f12Smrg  func_convert_core_path_wine_to_w32_result=""
151914330f12Smrg  if test -n "$1"; then
152014330f12Smrg    oldIFS=$IFS
152114330f12Smrg    IFS=:
152214330f12Smrg    for func_convert_core_path_wine_to_w32_f in $1; do
152314330f12Smrg      IFS=$oldIFS
152414330f12Smrg      func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
152514330f12Smrg      if test -n "$func_convert_core_file_wine_to_w32_result" ; then
152614330f12Smrg        if test -z "$func_convert_core_path_wine_to_w32_result"; then
152714330f12Smrg          func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result"
152814330f12Smrg        else
152914330f12Smrg          func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
153014330f12Smrg        fi
153114330f12Smrg      fi
153214330f12Smrg    done
153314330f12Smrg    IFS=$oldIFS
153414330f12Smrg  fi
153514330f12Smrg}
153614330f12Smrg# end: func_convert_core_path_wine_to_w32
153714330f12Smrg
153814330f12Smrg
153914330f12Smrg# func_cygpath ARGS...
154014330f12Smrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when
154114330f12Smrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2)
154214330f12Smrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or
154314330f12Smrg# (2), returns the Cygwin file name or path in func_cygpath_result (input
154414330f12Smrg# file name or path is assumed to be in w32 format, as previously converted
154514330f12Smrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name
154614330f12Smrg# or path in func_cygpath_result (input file name or path is assumed to be in
154714330f12Smrg# Cygwin format). Returns an empty string on error.
154814330f12Smrg#
154914330f12Smrg# ARGS are passed to cygpath, with the last one being the file name or path to
155014330f12Smrg# be converted.
155114330f12Smrg#
155214330f12Smrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH
155314330f12Smrg# environment variable; do not put it in $PATH.
155414330f12Smrgfunc_cygpath ()
155514330f12Smrg{
155614330f12Smrg  $opt_debug
155714330f12Smrg  if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
155814330f12Smrg    func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
155914330f12Smrg    if test "$?" -ne 0; then
156014330f12Smrg      # on failure, ensure result is empty
156114330f12Smrg      func_cygpath_result=
156214330f12Smrg    fi
156314330f12Smrg  else
156414330f12Smrg    func_cygpath_result=
156514330f12Smrg    func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'"
156614330f12Smrg  fi
156714330f12Smrg}
156814330f12Smrg#end: func_cygpath
156914330f12Smrg
157014330f12Smrg
157114330f12Smrg# func_convert_core_msys_to_w32 ARG
157214330f12Smrg# Convert file name or path ARG from MSYS format to w32 format.  Return
157314330f12Smrg# result in func_convert_core_msys_to_w32_result.
157414330f12Smrgfunc_convert_core_msys_to_w32 ()
157514330f12Smrg{
157614330f12Smrg  $opt_debug
157714330f12Smrg  # awkward: cmd appends spaces to result
157814330f12Smrg  func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
157914330f12Smrg    $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"`
158014330f12Smrg}
158114330f12Smrg#end: func_convert_core_msys_to_w32
158214330f12Smrg
158314330f12Smrg
158414330f12Smrg# func_convert_file_check ARG1 ARG2
158514330f12Smrg# Verify that ARG1 (a file name in $build format) was converted to $host
158614330f12Smrg# format in ARG2. Otherwise, emit an error message, but continue (resetting
158714330f12Smrg# func_to_host_file_result to ARG1).
158814330f12Smrgfunc_convert_file_check ()
158914330f12Smrg{
159014330f12Smrg  $opt_debug
159114330f12Smrg  if test -z "$2" && test -n "$1" ; then
159214330f12Smrg    func_error "Could not determine host file name corresponding to"
159314330f12Smrg    func_error "  \`$1'"
159414330f12Smrg    func_error "Continuing, but uninstalled executables may not work."
159514330f12Smrg    # Fallback:
159614330f12Smrg    func_to_host_file_result="$1"
159714330f12Smrg  fi
159814330f12Smrg}
159914330f12Smrg# end func_convert_file_check
160014330f12Smrg
160114330f12Smrg
160214330f12Smrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH
160314330f12Smrg# Verify that FROM_PATH (a path in $build format) was converted to $host
160414330f12Smrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting
160514330f12Smrg# func_to_host_file_result to a simplistic fallback value (see below).
160614330f12Smrgfunc_convert_path_check ()
160714330f12Smrg{
160814330f12Smrg  $opt_debug
160914330f12Smrg  if test -z "$4" && test -n "$3"; then
161014330f12Smrg    func_error "Could not determine the host path corresponding to"
161114330f12Smrg    func_error "  \`$3'"
161214330f12Smrg    func_error "Continuing, but uninstalled executables may not work."
161314330f12Smrg    # Fallback.  This is a deliberately simplistic "conversion" and
161414330f12Smrg    # should not be "improved".  See libtool.info.
161514330f12Smrg    if test "x$1" != "x$2"; then
161614330f12Smrg      lt_replace_pathsep_chars="s|$1|$2|g"
161714330f12Smrg      func_to_host_path_result=`echo "$3" |
161814330f12Smrg        $SED -e "$lt_replace_pathsep_chars"`
161914330f12Smrg    else
162014330f12Smrg      func_to_host_path_result="$3"
162114330f12Smrg    fi
162214330f12Smrg  fi
162314330f12Smrg}
162414330f12Smrg# end func_convert_path_check
162514330f12Smrg
162614330f12Smrg
162714330f12Smrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG
162814330f12Smrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT
162914330f12Smrg# and appending REPL if ORIG matches BACKPAT.
163014330f12Smrgfunc_convert_path_front_back_pathsep ()
163114330f12Smrg{
163214330f12Smrg  $opt_debug
163314330f12Smrg  case $4 in
163414330f12Smrg  $1 ) func_to_host_path_result="$3$func_to_host_path_result"
163514330f12Smrg    ;;
163614330f12Smrg  esac
163714330f12Smrg  case $4 in
163814330f12Smrg  $2 ) func_append func_to_host_path_result "$3"
163914330f12Smrg    ;;
164014330f12Smrg  esac
164114330f12Smrg}
164214330f12Smrg# end func_convert_path_front_back_pathsep
164314330f12Smrg
164414330f12Smrg
164514330f12Smrg##################################################
164614330f12Smrg# $build to $host FILE NAME CONVERSION FUNCTIONS #
164714330f12Smrg##################################################
164814330f12Smrg# invoked via `$to_host_file_cmd ARG'
164914330f12Smrg#
165014330f12Smrg# In each case, ARG is the path to be converted from $build to $host format.
165114330f12Smrg# Result will be available in $func_to_host_file_result.
165214330f12Smrg
165314330f12Smrg
165414330f12Smrg# func_to_host_file ARG
165514330f12Smrg# Converts the file name ARG from $build format to $host format. Return result
165614330f12Smrg# in func_to_host_file_result.
165714330f12Smrgfunc_to_host_file ()
165814330f12Smrg{
165914330f12Smrg  $opt_debug
166014330f12Smrg  $to_host_file_cmd "$1"
166114330f12Smrg}
166214330f12Smrg# end func_to_host_file
166314330f12Smrg
166414330f12Smrg
166514330f12Smrg# func_to_tool_file ARG LAZY
166614330f12Smrg# converts the file name ARG from $build format to toolchain format. Return
166714330f12Smrg# result in func_to_tool_file_result.  If the conversion in use is listed
166814330f12Smrg# in (the comma separated) LAZY, no conversion takes place.
166914330f12Smrgfunc_to_tool_file ()
167014330f12Smrg{
167114330f12Smrg  $opt_debug
167214330f12Smrg  case ,$2, in
167314330f12Smrg    *,"$to_tool_file_cmd",*)
167414330f12Smrg      func_to_tool_file_result=$1
167514330f12Smrg      ;;
167614330f12Smrg    *)
167714330f12Smrg      $to_tool_file_cmd "$1"
167814330f12Smrg      func_to_tool_file_result=$func_to_host_file_result
167914330f12Smrg      ;;
168014330f12Smrg  esac
168114330f12Smrg}
168214330f12Smrg# end func_to_tool_file
168314330f12Smrg
168414330f12Smrg
168514330f12Smrg# func_convert_file_noop ARG
168614330f12Smrg# Copy ARG to func_to_host_file_result.
168714330f12Smrgfunc_convert_file_noop ()
168814330f12Smrg{
168914330f12Smrg  func_to_host_file_result="$1"
169014330f12Smrg}
169114330f12Smrg# end func_convert_file_noop
169214330f12Smrg
169314330f12Smrg
169414330f12Smrg# func_convert_file_msys_to_w32 ARG
169514330f12Smrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic
169614330f12Smrg# conversion to w32 is not available inside the cwrapper.  Returns result in
169714330f12Smrg# func_to_host_file_result.
169814330f12Smrgfunc_convert_file_msys_to_w32 ()
169914330f12Smrg{
170014330f12Smrg  $opt_debug
170114330f12Smrg  func_to_host_file_result="$1"
170214330f12Smrg  if test -n "$1"; then
170314330f12Smrg    func_convert_core_msys_to_w32 "$1"
170414330f12Smrg    func_to_host_file_result="$func_convert_core_msys_to_w32_result"
170514330f12Smrg  fi
170614330f12Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
170714330f12Smrg}
170814330f12Smrg# end func_convert_file_msys_to_w32
170914330f12Smrg
171014330f12Smrg
171114330f12Smrg# func_convert_file_cygwin_to_w32 ARG
171214330f12Smrg# Convert file name ARG from Cygwin to w32 format.  Returns result in
171314330f12Smrg# func_to_host_file_result.
171414330f12Smrgfunc_convert_file_cygwin_to_w32 ()
171514330f12Smrg{
171614330f12Smrg  $opt_debug
171714330f12Smrg  func_to_host_file_result="$1"
171814330f12Smrg  if test -n "$1"; then
171914330f12Smrg    # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
172014330f12Smrg    # LT_CYGPATH in this case.
172114330f12Smrg    func_to_host_file_result=`cygpath -m "$1"`
172214330f12Smrg  fi
172314330f12Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
172414330f12Smrg}
172514330f12Smrg# end func_convert_file_cygwin_to_w32
172614330f12Smrg
172714330f12Smrg
172814330f12Smrg# func_convert_file_nix_to_w32 ARG
172914330f12Smrg# Convert file name ARG from *nix to w32 format.  Requires a wine environment
173014330f12Smrg# and a working winepath. Returns result in func_to_host_file_result.
173114330f12Smrgfunc_convert_file_nix_to_w32 ()
173214330f12Smrg{
173314330f12Smrg  $opt_debug
173414330f12Smrg  func_to_host_file_result="$1"
173514330f12Smrg  if test -n "$1"; then
173614330f12Smrg    func_convert_core_file_wine_to_w32 "$1"
173714330f12Smrg    func_to_host_file_result="$func_convert_core_file_wine_to_w32_result"
173814330f12Smrg  fi
173914330f12Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
174014330f12Smrg}
174114330f12Smrg# end func_convert_file_nix_to_w32
174214330f12Smrg
174314330f12Smrg
174414330f12Smrg# func_convert_file_msys_to_cygwin ARG
174514330f12Smrg# Convert file name ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
174614330f12Smrg# Returns result in func_to_host_file_result.
174714330f12Smrgfunc_convert_file_msys_to_cygwin ()
174814330f12Smrg{
174914330f12Smrg  $opt_debug
175014330f12Smrg  func_to_host_file_result="$1"
175114330f12Smrg  if test -n "$1"; then
175214330f12Smrg    func_convert_core_msys_to_w32 "$1"
175314330f12Smrg    func_cygpath -u "$func_convert_core_msys_to_w32_result"
175414330f12Smrg    func_to_host_file_result="$func_cygpath_result"
175514330f12Smrg  fi
175614330f12Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
175714330f12Smrg}
175814330f12Smrg# end func_convert_file_msys_to_cygwin
175914330f12Smrg
176014330f12Smrg
176114330f12Smrg# func_convert_file_nix_to_cygwin ARG
176214330f12Smrg# Convert file name ARG from *nix to Cygwin format.  Requires Cygwin installed
176314330f12Smrg# in a wine environment, working winepath, and LT_CYGPATH set.  Returns result
176414330f12Smrg# in func_to_host_file_result.
176514330f12Smrgfunc_convert_file_nix_to_cygwin ()
176614330f12Smrg{
176714330f12Smrg  $opt_debug
176814330f12Smrg  func_to_host_file_result="$1"
176914330f12Smrg  if test -n "$1"; then
177014330f12Smrg    # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
177114330f12Smrg    func_convert_core_file_wine_to_w32 "$1"
177214330f12Smrg    func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
177314330f12Smrg    func_to_host_file_result="$func_cygpath_result"
177414330f12Smrg  fi
177514330f12Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
177614330f12Smrg}
177714330f12Smrg# end func_convert_file_nix_to_cygwin
177814330f12Smrg
177914330f12Smrg
178014330f12Smrg#############################################
178114330f12Smrg# $build to $host PATH CONVERSION FUNCTIONS #
178214330f12Smrg#############################################
178314330f12Smrg# invoked via `$to_host_path_cmd ARG'
178414330f12Smrg#
178514330f12Smrg# In each case, ARG is the path to be converted from $build to $host format.
178614330f12Smrg# The result will be available in $func_to_host_path_result.
178714330f12Smrg#
178814330f12Smrg# Path separators are also converted from $build format to $host format.  If
178914330f12Smrg# ARG begins or ends with a path separator character, it is preserved (but
179014330f12Smrg# converted to $host format) on output.
179114330f12Smrg#
179214330f12Smrg# All path conversion functions are named using the following convention:
179314330f12Smrg#   file name conversion function    : func_convert_file_X_to_Y ()
179414330f12Smrg#   path conversion function         : func_convert_path_X_to_Y ()
179514330f12Smrg# where, for any given $build/$host combination the 'X_to_Y' value is the
179614330f12Smrg# same.  If conversion functions are added for new $build/$host combinations,
179714330f12Smrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd
179814330f12Smrg# will break.
179914330f12Smrg
180014330f12Smrg
180114330f12Smrg# func_init_to_host_path_cmd
180214330f12Smrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the
180314330f12Smrg# appropriate value, based on the value of $to_host_file_cmd.
180414330f12Smrgto_host_path_cmd=
180514330f12Smrgfunc_init_to_host_path_cmd ()
180614330f12Smrg{
180714330f12Smrg  $opt_debug
180814330f12Smrg  if test -z "$to_host_path_cmd"; then
180914330f12Smrg    func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
181014330f12Smrg    to_host_path_cmd="func_convert_path_${func_stripname_result}"
181114330f12Smrg  fi
181214330f12Smrg}
181314330f12Smrg
181414330f12Smrg
181514330f12Smrg# func_to_host_path ARG
181614330f12Smrg# Converts the path ARG from $build format to $host format. Return result
181714330f12Smrg# in func_to_host_path_result.
181814330f12Smrgfunc_to_host_path ()
181914330f12Smrg{
182014330f12Smrg  $opt_debug
182114330f12Smrg  func_init_to_host_path_cmd
182214330f12Smrg  $to_host_path_cmd "$1"
182314330f12Smrg}
182414330f12Smrg# end func_to_host_path
182514330f12Smrg
182614330f12Smrg
182714330f12Smrg# func_convert_path_noop ARG
182814330f12Smrg# Copy ARG to func_to_host_path_result.
182914330f12Smrgfunc_convert_path_noop ()
183014330f12Smrg{
183114330f12Smrg  func_to_host_path_result="$1"
183214330f12Smrg}
183314330f12Smrg# end func_convert_path_noop
183414330f12Smrg
183514330f12Smrg
183614330f12Smrg# func_convert_path_msys_to_w32 ARG
183714330f12Smrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic
183814330f12Smrg# conversion to w32 is not available inside the cwrapper.  Returns result in
183914330f12Smrg# func_to_host_path_result.
184014330f12Smrgfunc_convert_path_msys_to_w32 ()
184114330f12Smrg{
184214330f12Smrg  $opt_debug
184314330f12Smrg  func_to_host_path_result="$1"
184414330f12Smrg  if test -n "$1"; then
184514330f12Smrg    # Remove leading and trailing path separator characters from ARG.  MSYS
184614330f12Smrg    # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
184714330f12Smrg    # and winepath ignores them completely.
184814330f12Smrg    func_stripname : : "$1"
184914330f12Smrg    func_to_host_path_tmp1=$func_stripname_result
185014330f12Smrg    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
185114330f12Smrg    func_to_host_path_result="$func_convert_core_msys_to_w32_result"
185214330f12Smrg    func_convert_path_check : ";" \
185314330f12Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
185414330f12Smrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
185514330f12Smrg  fi
185614330f12Smrg}
185714330f12Smrg# end func_convert_path_msys_to_w32
185814330f12Smrg
185914330f12Smrg
186014330f12Smrg# func_convert_path_cygwin_to_w32 ARG
186114330f12Smrg# Convert path ARG from Cygwin to w32 format.  Returns result in
186214330f12Smrg# func_to_host_file_result.
186314330f12Smrgfunc_convert_path_cygwin_to_w32 ()
186414330f12Smrg{
186514330f12Smrg  $opt_debug
186614330f12Smrg  func_to_host_path_result="$1"
186714330f12Smrg  if test -n "$1"; then
186814330f12Smrg    # See func_convert_path_msys_to_w32:
186914330f12Smrg    func_stripname : : "$1"
187014330f12Smrg    func_to_host_path_tmp1=$func_stripname_result
187114330f12Smrg    func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"`
187214330f12Smrg    func_convert_path_check : ";" \
187314330f12Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
187414330f12Smrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
187514330f12Smrg  fi
187614330f12Smrg}
187714330f12Smrg# end func_convert_path_cygwin_to_w32
187814330f12Smrg
187914330f12Smrg
188014330f12Smrg# func_convert_path_nix_to_w32 ARG
188114330f12Smrg# Convert path ARG from *nix to w32 format.  Requires a wine environment and
188214330f12Smrg# a working winepath.  Returns result in func_to_host_file_result.
188314330f12Smrgfunc_convert_path_nix_to_w32 ()
188414330f12Smrg{
188514330f12Smrg  $opt_debug
188614330f12Smrg  func_to_host_path_result="$1"
188714330f12Smrg  if test -n "$1"; then
188814330f12Smrg    # See func_convert_path_msys_to_w32:
188914330f12Smrg    func_stripname : : "$1"
189014330f12Smrg    func_to_host_path_tmp1=$func_stripname_result
189114330f12Smrg    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
189214330f12Smrg    func_to_host_path_result="$func_convert_core_path_wine_to_w32_result"
189314330f12Smrg    func_convert_path_check : ";" \
189414330f12Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
189514330f12Smrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
189614330f12Smrg  fi
189714330f12Smrg}
189814330f12Smrg# end func_convert_path_nix_to_w32
189914330f12Smrg
190014330f12Smrg
190114330f12Smrg# func_convert_path_msys_to_cygwin ARG
190214330f12Smrg# Convert path ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
190314330f12Smrg# Returns result in func_to_host_file_result.
190414330f12Smrgfunc_convert_path_msys_to_cygwin ()
190514330f12Smrg{
190614330f12Smrg  $opt_debug
190714330f12Smrg  func_to_host_path_result="$1"
190814330f12Smrg  if test -n "$1"; then
190914330f12Smrg    # See func_convert_path_msys_to_w32:
191014330f12Smrg    func_stripname : : "$1"
191114330f12Smrg    func_to_host_path_tmp1=$func_stripname_result
191214330f12Smrg    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
191314330f12Smrg    func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
191414330f12Smrg    func_to_host_path_result="$func_cygpath_result"
191514330f12Smrg    func_convert_path_check : : \
191614330f12Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
191714330f12Smrg    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
191814330f12Smrg  fi
191914330f12Smrg}
192014330f12Smrg# end func_convert_path_msys_to_cygwin
192114330f12Smrg
192214330f12Smrg
192314330f12Smrg# func_convert_path_nix_to_cygwin ARG
192414330f12Smrg# Convert path ARG from *nix to Cygwin format.  Requires Cygwin installed in a
192514330f12Smrg# a wine environment, working winepath, and LT_CYGPATH set.  Returns result in
192614330f12Smrg# func_to_host_file_result.
192714330f12Smrgfunc_convert_path_nix_to_cygwin ()
192814330f12Smrg{
192914330f12Smrg  $opt_debug
193014330f12Smrg  func_to_host_path_result="$1"
193114330f12Smrg  if test -n "$1"; then
193214330f12Smrg    # Remove leading and trailing path separator characters from
193314330f12Smrg    # ARG. msys behavior is inconsistent here, cygpath turns them
193414330f12Smrg    # into '.;' and ';.', and winepath ignores them completely.
193514330f12Smrg    func_stripname : : "$1"
193614330f12Smrg    func_to_host_path_tmp1=$func_stripname_result
193714330f12Smrg    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
193814330f12Smrg    func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
193914330f12Smrg    func_to_host_path_result="$func_cygpath_result"
194014330f12Smrg    func_convert_path_check : : \
194114330f12Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
194214330f12Smrg    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
194314330f12Smrg  fi
194414330f12Smrg}
194514330f12Smrg# end func_convert_path_nix_to_cygwin
194614330f12Smrg
194714330f12Smrg
19482378475aSmrg# func_mode_compile arg...
19492378475aSmrgfunc_mode_compile ()
19502378475aSmrg{
19512378475aSmrg    $opt_debug
19522378475aSmrg    # Get the compilation command and the source file.
19532378475aSmrg    base_compile=
19542378475aSmrg    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
19552378475aSmrg    suppress_opt=yes
19562378475aSmrg    suppress_output=
19572378475aSmrg    arg_mode=normal
19582378475aSmrg    libobj=
19592378475aSmrg    later=
19602378475aSmrg    pie_flag=
19612378475aSmrg
19622378475aSmrg    for arg
19632378475aSmrg    do
19642378475aSmrg      case $arg_mode in
19652378475aSmrg      arg  )
19662378475aSmrg	# do not "continue".  Instead, add this to base_compile
19672378475aSmrg	lastarg="$arg"
19682378475aSmrg	arg_mode=normal
19692378475aSmrg	;;
19702378475aSmrg
19712378475aSmrg      target )
19722378475aSmrg	libobj="$arg"
19732378475aSmrg	arg_mode=normal
19742378475aSmrg	continue
19752378475aSmrg	;;
19762378475aSmrg
19772378475aSmrg      normal )
19782378475aSmrg	# Accept any command-line options.
19792378475aSmrg	case $arg in
19802378475aSmrg	-o)
19812378475aSmrg	  test -n "$libobj" && \
19822378475aSmrg	    func_fatal_error "you cannot specify \`-o' more than once"
19832378475aSmrg	  arg_mode=target
19842378475aSmrg	  continue
19852378475aSmrg	  ;;
19862378475aSmrg
19872378475aSmrg	-pie | -fpie | -fPIE)
198814330f12Smrg          func_append pie_flag " $arg"
19892378475aSmrg	  continue
19902378475aSmrg	  ;;
19912378475aSmrg
19922378475aSmrg	-shared | -static | -prefer-pic | -prefer-non-pic)
199314330f12Smrg	  func_append later " $arg"
19942378475aSmrg	  continue
19952378475aSmrg	  ;;
19962378475aSmrg
19972378475aSmrg	-no-suppress)
199895b296d0Smrg	  suppress_opt=no
199995b296d0Smrg	  continue
200095b296d0Smrg	  ;;
200195b296d0Smrg
200295b296d0Smrg	-Xcompiler)
200395b296d0Smrg	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
200495b296d0Smrg	  continue      #  The current "srcfile" will either be retained or
200595b296d0Smrg	  ;;            #  replaced later.  I would guess that would be a bug.
200695b296d0Smrg
200795b296d0Smrg	-Wc,*)
20082378475aSmrg	  func_stripname '-Wc,' '' "$arg"
20092378475aSmrg	  args=$func_stripname_result
201095b296d0Smrg	  lastarg=
201195b296d0Smrg	  save_ifs="$IFS"; IFS=','
20122378475aSmrg	  for arg in $args; do
201395b296d0Smrg	    IFS="$save_ifs"
201414330f12Smrg	    func_append_quoted lastarg "$arg"
201595b296d0Smrg	  done
201695b296d0Smrg	  IFS="$save_ifs"
20172378475aSmrg	  func_stripname ' ' '' "$lastarg"
20182378475aSmrg	  lastarg=$func_stripname_result
201995b296d0Smrg
202095b296d0Smrg	  # Add the arguments to base_compile.
202114330f12Smrg	  func_append base_compile " $lastarg"
202295b296d0Smrg	  continue
202395b296d0Smrg	  ;;
202495b296d0Smrg
20252378475aSmrg	*)
202695b296d0Smrg	  # Accept the current argument as the source file.
202795b296d0Smrg	  # The previous "srcfile" becomes the current argument.
202895b296d0Smrg	  #
202995b296d0Smrg	  lastarg="$srcfile"
203095b296d0Smrg	  srcfile="$arg"
203195b296d0Smrg	  ;;
203295b296d0Smrg	esac  #  case $arg
203395b296d0Smrg	;;
203495b296d0Smrg      esac    #  case $arg_mode
203595b296d0Smrg
203695b296d0Smrg      # Aesthetically quote the previous argument.
203714330f12Smrg      func_append_quoted base_compile "$lastarg"
203895b296d0Smrg    done # for arg
203995b296d0Smrg
204095b296d0Smrg    case $arg_mode in
204195b296d0Smrg    arg)
20422378475aSmrg      func_fatal_error "you must specify an argument for -Xcompile"
204395b296d0Smrg      ;;
204495b296d0Smrg    target)
20452378475aSmrg      func_fatal_error "you must specify a target with \`-o'"
204695b296d0Smrg      ;;
204795b296d0Smrg    *)
204895b296d0Smrg      # Get the name of the library object.
20492378475aSmrg      test -z "$libobj" && {
20502378475aSmrg	func_basename "$srcfile"
20512378475aSmrg	libobj="$func_basename_result"
20522378475aSmrg      }
205395b296d0Smrg      ;;
205495b296d0Smrg    esac
205595b296d0Smrg
205695b296d0Smrg    # Recognize several different file suffixes.
205795b296d0Smrg    # If the user specifies -o file.o, it is replaced with file.lo
205895b296d0Smrg    case $libobj in
20592378475aSmrg    *.[cCFSifmso] | \
20602378475aSmrg    *.ada | *.adb | *.ads | *.asm | \
20612378475aSmrg    *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
206214330f12Smrg    *.[fF][09]? | *.for | *.java | *.obj | *.sx | *.cu | *.cup)
20632378475aSmrg      func_xform "$libobj"
20642378475aSmrg      libobj=$func_xform_result
20652378475aSmrg      ;;
206695b296d0Smrg    esac
206795b296d0Smrg
206895b296d0Smrg    case $libobj in
20692378475aSmrg    *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
207095b296d0Smrg    *)
20712378475aSmrg      func_fatal_error "cannot determine name of library object from \`$libobj'"
207295b296d0Smrg      ;;
207395b296d0Smrg    esac
207495b296d0Smrg
207595b296d0Smrg    func_infer_tag $base_compile
207695b296d0Smrg
207795b296d0Smrg    for arg in $later; do
207895b296d0Smrg      case $arg in
20792378475aSmrg      -shared)
20802378475aSmrg	test "$build_libtool_libs" != yes && \
20812378475aSmrg	  func_fatal_configuration "can not build a shared library"
20822378475aSmrg	build_old_libs=no
20832378475aSmrg	continue
20842378475aSmrg	;;
20852378475aSmrg
208695b296d0Smrg      -static)
20872378475aSmrg	build_libtool_libs=no
208895b296d0Smrg	build_old_libs=yes
208995b296d0Smrg	continue
209095b296d0Smrg	;;
209195b296d0Smrg
209295b296d0Smrg      -prefer-pic)
209395b296d0Smrg	pic_mode=yes
209495b296d0Smrg	continue
209595b296d0Smrg	;;
209695b296d0Smrg
209795b296d0Smrg      -prefer-non-pic)
209895b296d0Smrg	pic_mode=no
209995b296d0Smrg	continue
210095b296d0Smrg	;;
210195b296d0Smrg      esac
210295b296d0Smrg    done
210395b296d0Smrg
21042378475aSmrg    func_quote_for_eval "$libobj"
21052378475aSmrg    test "X$libobj" != "X$func_quote_for_eval_result" \
21062378475aSmrg      && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'	 &()|`$[]' \
21072378475aSmrg      && func_warning "libobj name \`$libobj' may not contain shell special characters."
21082378475aSmrg    func_dirname_and_basename "$obj" "/" ""
21092378475aSmrg    objname="$func_basename_result"
21102378475aSmrg    xdir="$func_dirname_result"
211195b296d0Smrg    lobj=${xdir}$objdir/$objname
211295b296d0Smrg
21132378475aSmrg    test -z "$base_compile" && \
21142378475aSmrg      func_fatal_help "you must specify a compilation command"
211595b296d0Smrg
211695b296d0Smrg    # Delete any leftover library objects.
211795b296d0Smrg    if test "$build_old_libs" = yes; then
211895b296d0Smrg      removelist="$obj $lobj $libobj ${libobj}T"
211995b296d0Smrg    else
212095b296d0Smrg      removelist="$lobj $libobj ${libobj}T"
212195b296d0Smrg    fi
212295b296d0Smrg
212395b296d0Smrg    # On Cygwin there's no "real" PIC flag so we must build both object types
212495b296d0Smrg    case $host_os in
21252378475aSmrg    cygwin* | mingw* | pw32* | os2* | cegcc*)
212695b296d0Smrg      pic_mode=default
212795b296d0Smrg      ;;
212895b296d0Smrg    esac
212995b296d0Smrg    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
213095b296d0Smrg      # non-PIC code in shared libraries is not supported
213195b296d0Smrg      pic_mode=default
213295b296d0Smrg    fi
213395b296d0Smrg
213495b296d0Smrg    # Calculate the filename of the output object if compiler does
213595b296d0Smrg    # not support -o with -c
213695b296d0Smrg    if test "$compiler_c_o" = no; then
213714330f12Smrg      output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext}
213895b296d0Smrg      lockfile="$output_obj.lock"
213995b296d0Smrg    else
214095b296d0Smrg      output_obj=
214195b296d0Smrg      need_locks=no
214295b296d0Smrg      lockfile=
214395b296d0Smrg    fi
214495b296d0Smrg
214595b296d0Smrg    # Lock this critical section if it is needed
214695b296d0Smrg    # We use this script file to make the link, it avoids creating a new file
214795b296d0Smrg    if test "$need_locks" = yes; then
21482378475aSmrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
21492378475aSmrg	func_echo "Waiting for $lockfile to be removed"
215095b296d0Smrg	sleep 2
215195b296d0Smrg      done
215295b296d0Smrg    elif test "$need_locks" = warn; then
215395b296d0Smrg      if test -f "$lockfile"; then
21542378475aSmrg	$ECHO "\
215595b296d0Smrg*** ERROR, $lockfile exists and contains:
215695b296d0Smrg`cat $lockfile 2>/dev/null`
215795b296d0Smrg
215895b296d0SmrgThis indicates that another process is trying to use the same
215995b296d0Smrgtemporary object file, and libtool could not work around it because
216095b296d0Smrgyour compiler does not support \`-c' and \`-o' together.  If you
216195b296d0Smrgrepeat this compilation, it may succeed, by chance, but you had better
216295b296d0Smrgavoid parallel builds (make -j) in this platform, or get a better
216395b296d0Smrgcompiler."
216495b296d0Smrg
21652378475aSmrg	$opt_dry_run || $RM $removelist
216695b296d0Smrg	exit $EXIT_FAILURE
216795b296d0Smrg      fi
216814330f12Smrg      func_append removelist " $output_obj"
21692378475aSmrg      $ECHO "$srcfile" > "$lockfile"
217095b296d0Smrg    fi
217195b296d0Smrg
21722378475aSmrg    $opt_dry_run || $RM $removelist
217314330f12Smrg    func_append removelist " $lockfile"
21742378475aSmrg    trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
21752378475aSmrg
217614330f12Smrg    func_to_tool_file "$srcfile" func_convert_file_msys_to_w32
217714330f12Smrg    srcfile=$func_to_tool_file_result
21782378475aSmrg    func_quote_for_eval "$srcfile"
21792378475aSmrg    qsrcfile=$func_quote_for_eval_result
218095b296d0Smrg
218195b296d0Smrg    # Only build a PIC object if we are building libtool libraries.
218295b296d0Smrg    if test "$build_libtool_libs" = yes; then
218395b296d0Smrg      # Without this assignment, base_compile gets emptied.
218495b296d0Smrg      fbsd_hideous_sh_bug=$base_compile
218595b296d0Smrg
218695b296d0Smrg      if test "$pic_mode" != no; then
218795b296d0Smrg	command="$base_compile $qsrcfile $pic_flag"
218895b296d0Smrg      else
218995b296d0Smrg	# Don't build PIC code
219095b296d0Smrg	command="$base_compile $qsrcfile"
219195b296d0Smrg      fi
219295b296d0Smrg
21932378475aSmrg      func_mkdir_p "$xdir$objdir"
219495b296d0Smrg
219595b296d0Smrg      if test -z "$output_obj"; then
219695b296d0Smrg	# Place PIC objects in $objdir
219714330f12Smrg	func_append command " -o $lobj"
219895b296d0Smrg      fi
219995b296d0Smrg
22002378475aSmrg      func_show_eval_locale "$command"	\
22012378475aSmrg          'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
220295b296d0Smrg
220395b296d0Smrg      if test "$need_locks" = warn &&
220495b296d0Smrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
22052378475aSmrg	$ECHO "\
220695b296d0Smrg*** ERROR, $lockfile contains:
220795b296d0Smrg`cat $lockfile 2>/dev/null`
220895b296d0Smrg
220995b296d0Smrgbut it should contain:
221095b296d0Smrg$srcfile
221195b296d0Smrg
221295b296d0SmrgThis indicates that another process is trying to use the same
221395b296d0Smrgtemporary object file, and libtool could not work around it because
221495b296d0Smrgyour compiler does not support \`-c' and \`-o' together.  If you
221595b296d0Smrgrepeat this compilation, it may succeed, by chance, but you had better
221695b296d0Smrgavoid parallel builds (make -j) in this platform, or get a better
221795b296d0Smrgcompiler."
221895b296d0Smrg
22192378475aSmrg	$opt_dry_run || $RM $removelist
222095b296d0Smrg	exit $EXIT_FAILURE
222195b296d0Smrg      fi
222295b296d0Smrg
222395b296d0Smrg      # Just move the object if needed, then go on to compile the next one
222495b296d0Smrg      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
22252378475aSmrg	func_show_eval '$MV "$output_obj" "$lobj"' \
22262378475aSmrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
222795b296d0Smrg      fi
222895b296d0Smrg
222995b296d0Smrg      # Allow error messages only from the first compilation.
223095b296d0Smrg      if test "$suppress_opt" = yes; then
22312378475aSmrg	suppress_output=' >/dev/null 2>&1'
223295b296d0Smrg      fi
223395b296d0Smrg    fi
223495b296d0Smrg
223595b296d0Smrg    # Only build a position-dependent object if we build old libraries.
223695b296d0Smrg    if test "$build_old_libs" = yes; then
223795b296d0Smrg      if test "$pic_mode" != yes; then
223895b296d0Smrg	# Don't build PIC code
22392378475aSmrg	command="$base_compile $qsrcfile$pie_flag"
224095b296d0Smrg      else
224195b296d0Smrg	command="$base_compile $qsrcfile $pic_flag"
224295b296d0Smrg      fi
224395b296d0Smrg      if test "$compiler_c_o" = yes; then
224414330f12Smrg	func_append command " -o $obj"
224595b296d0Smrg      fi
224695b296d0Smrg
224795b296d0Smrg      # Suppress compiler output if we already did a PIC compilation.
224814330f12Smrg      func_append command "$suppress_output"
22492378475aSmrg      func_show_eval_locale "$command" \
22502378475aSmrg        '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
225195b296d0Smrg
225295b296d0Smrg      if test "$need_locks" = warn &&
225395b296d0Smrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
22542378475aSmrg	$ECHO "\
225595b296d0Smrg*** ERROR, $lockfile contains:
225695b296d0Smrg`cat $lockfile 2>/dev/null`
225795b296d0Smrg
225895b296d0Smrgbut it should contain:
225995b296d0Smrg$srcfile
226095b296d0Smrg
226195b296d0SmrgThis indicates that another process is trying to use the same
226295b296d0Smrgtemporary object file, and libtool could not work around it because
226395b296d0Smrgyour compiler does not support \`-c' and \`-o' together.  If you
226495b296d0Smrgrepeat this compilation, it may succeed, by chance, but you had better
226595b296d0Smrgavoid parallel builds (make -j) in this platform, or get a better
226695b296d0Smrgcompiler."
226795b296d0Smrg
22682378475aSmrg	$opt_dry_run || $RM $removelist
226995b296d0Smrg	exit $EXIT_FAILURE
227095b296d0Smrg      fi
227195b296d0Smrg
227295b296d0Smrg      # Just move the object if needed
227395b296d0Smrg      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
22742378475aSmrg	func_show_eval '$MV "$output_obj" "$obj"' \
22752378475aSmrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
227695b296d0Smrg      fi
227795b296d0Smrg    fi
227895b296d0Smrg
22792378475aSmrg    $opt_dry_run || {
22802378475aSmrg      func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
228195b296d0Smrg
22822378475aSmrg      # Unlock the critical section if it was locked
22832378475aSmrg      if test "$need_locks" != no; then
22842378475aSmrg	removelist=$lockfile
22852378475aSmrg        $RM "$lockfile"
22862378475aSmrg      fi
22872378475aSmrg    }
228895b296d0Smrg
228995b296d0Smrg    exit $EXIT_SUCCESS
22902378475aSmrg}
229195b296d0Smrg
22922378475aSmrg$opt_help || {
229314330f12Smrg  test "$opt_mode" = compile && func_mode_compile ${1+"$@"}
22942378475aSmrg}
229595b296d0Smrg
22962378475aSmrgfunc_mode_help ()
22972378475aSmrg{
22982378475aSmrg    # We need to display help for each of the modes.
229914330f12Smrg    case $opt_mode in
23002378475aSmrg      "")
23012378475aSmrg        # Generic help is extracted from the usage comments
23022378475aSmrg        # at the start of this file.
23032378475aSmrg        func_help
23042378475aSmrg        ;;
230595b296d0Smrg
23062378475aSmrg      clean)
23072378475aSmrg        $ECHO \
23082378475aSmrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
230995b296d0Smrg
23102378475aSmrgRemove files from the build directory.
231195b296d0Smrg
23122378475aSmrgRM is the name of the program to use to delete files associated with each FILE
23132378475aSmrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
23142378475aSmrgto RM.
231595b296d0Smrg
23162378475aSmrgIf FILE is a libtool library, object or program, all the files associated
23172378475aSmrgwith it are deleted. Otherwise, only FILE itself is deleted using RM."
23182378475aSmrg        ;;
231995b296d0Smrg
23202378475aSmrg      compile)
23212378475aSmrg      $ECHO \
23222378475aSmrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
232395b296d0Smrg
23242378475aSmrgCompile a source file into a libtool library object.
232595b296d0Smrg
23262378475aSmrgThis mode accepts the following additional options:
232795b296d0Smrg
23282378475aSmrg  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
23292378475aSmrg  -no-suppress      do not suppress compiler output for multiple passes
233014330f12Smrg  -prefer-pic       try to build PIC objects only
233114330f12Smrg  -prefer-non-pic   try to build non-PIC objects only
23322378475aSmrg  -shared           do not build a \`.o' file suitable for static linking
23332378475aSmrg  -static           only build a \`.o' file suitable for static linking
233414330f12Smrg  -Wc,FLAG          pass FLAG directly to the compiler
233595b296d0Smrg
23362378475aSmrgCOMPILE-COMMAND is a command to be used in creating a \`standard' object file
23372378475aSmrgfrom the given SOURCEFILE.
233895b296d0Smrg
23392378475aSmrgThe output file name is determined by removing the directory component from
23402378475aSmrgSOURCEFILE, then substituting the C source code suffix \`.c' with the
23412378475aSmrglibrary object suffix, \`.lo'."
23422378475aSmrg        ;;
234395b296d0Smrg
23442378475aSmrg      execute)
23452378475aSmrg        $ECHO \
23462378475aSmrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
234795b296d0Smrg
23482378475aSmrgAutomatically set library path, then run a program.
234995b296d0Smrg
23502378475aSmrgThis mode accepts the following additional options:
235195b296d0Smrg
23522378475aSmrg  -dlopen FILE      add the directory containing FILE to the library path
235395b296d0Smrg
23542378475aSmrgThis mode sets the library path environment variable according to \`-dlopen'
23552378475aSmrgflags.
235695b296d0Smrg
23572378475aSmrgIf any of the ARGS are libtool executable wrappers, then they are translated
23582378475aSmrginto their corresponding uninstalled binary, and any of their required library
23592378475aSmrgdirectories are added to the library path.
236095b296d0Smrg
23612378475aSmrgThen, COMMAND is executed, with ARGS as arguments."
23622378475aSmrg        ;;
236395b296d0Smrg
23642378475aSmrg      finish)
23652378475aSmrg        $ECHO \
23662378475aSmrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
236795b296d0Smrg
23682378475aSmrgComplete the installation of libtool libraries.
236995b296d0Smrg
23702378475aSmrgEach LIBDIR is a directory that contains libtool libraries.
237195b296d0Smrg
23722378475aSmrgThe commands that this mode executes may require superuser privileges.  Use
23732378475aSmrgthe \`--dry-run' option if you just want to see what would be executed."
23742378475aSmrg        ;;
237595b296d0Smrg
23762378475aSmrg      install)
23772378475aSmrg        $ECHO \
23782378475aSmrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
237995b296d0Smrg
23802378475aSmrgInstall executables or libraries.
238195b296d0Smrg
23822378475aSmrgINSTALL-COMMAND is the installation command.  The first component should be
23832378475aSmrgeither the \`install' or \`cp' program.
238495b296d0Smrg
23852378475aSmrgThe following components of INSTALL-COMMAND are treated specially:
238695b296d0Smrg
238714330f12Smrg  -inst-prefix-dir PREFIX-DIR  Use PREFIX-DIR as a staging area for installation
238895b296d0Smrg
23892378475aSmrgThe rest of the components are interpreted as arguments to that command (only
23902378475aSmrgBSD-compatible install options are recognized)."
23912378475aSmrg        ;;
239295b296d0Smrg
23932378475aSmrg      link)
23942378475aSmrg        $ECHO \
23952378475aSmrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
239695b296d0Smrg
23972378475aSmrgLink object files or libraries together to form another library, or to
23982378475aSmrgcreate an executable program.
239995b296d0Smrg
24002378475aSmrgLINK-COMMAND is a command using the C compiler that you would use to create
24012378475aSmrga program from several object files.
240295b296d0Smrg
24032378475aSmrgThe following components of LINK-COMMAND are treated specially:
240495b296d0Smrg
24052378475aSmrg  -all-static       do not do any dynamic linking at all
24062378475aSmrg  -avoid-version    do not add a version suffix if possible
240714330f12Smrg  -bindir BINDIR    specify path to binaries directory (for systems where
240814330f12Smrg                    libraries must be found in the PATH setting at runtime)
24092378475aSmrg  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
24102378475aSmrg  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
24112378475aSmrg  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
24122378475aSmrg  -export-symbols SYMFILE
24132378475aSmrg                    try to export only the symbols listed in SYMFILE
24142378475aSmrg  -export-symbols-regex REGEX
24152378475aSmrg                    try to export only the symbols matching REGEX
24162378475aSmrg  -LLIBDIR          search LIBDIR for required installed libraries
24172378475aSmrg  -lNAME            OUTPUT-FILE requires the installed library libNAME
24182378475aSmrg  -module           build a library that can dlopened
24192378475aSmrg  -no-fast-install  disable the fast-install mode
24202378475aSmrg  -no-install       link a not-installable executable
24212378475aSmrg  -no-undefined     declare that a library does not refer to external symbols
24222378475aSmrg  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
24232378475aSmrg  -objectlist FILE  Use a list of object files found in FILE to specify objects
24242378475aSmrg  -precious-files-regex REGEX
24252378475aSmrg                    don't remove output files matching REGEX
24262378475aSmrg  -release RELEASE  specify package release information
24272378475aSmrg  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
24282378475aSmrg  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
24292378475aSmrg  -shared           only do dynamic linking of libtool libraries
24302378475aSmrg  -shrext SUFFIX    override the standard shared library file extension
24312378475aSmrg  -static           do not do any dynamic linking of uninstalled libtool libraries
24322378475aSmrg  -static-libtool-libs
24332378475aSmrg                    do not do any dynamic linking of libtool libraries
24342378475aSmrg  -version-info CURRENT[:REVISION[:AGE]]
24352378475aSmrg                    specify library version info [each variable defaults to 0]
24362378475aSmrg  -weak LIBNAME     declare that the target provides the LIBNAME interface
243714330f12Smrg  -Wc,FLAG
243814330f12Smrg  -Xcompiler FLAG   pass linker-specific FLAG directly to the compiler
243914330f12Smrg  -Wl,FLAG
244014330f12Smrg  -Xlinker FLAG     pass linker-specific FLAG directly to the linker
244114330f12Smrg  -XCClinker FLAG   pass link-specific FLAG to the compiler driver (CC)
244295b296d0Smrg
24432378475aSmrgAll other options (arguments beginning with \`-') are ignored.
244495b296d0Smrg
24452378475aSmrgEvery other argument is treated as a filename.  Files ending in \`.la' are
24462378475aSmrgtreated as uninstalled libtool libraries, other files are standard or library
24472378475aSmrgobject files.
244895b296d0Smrg
24492378475aSmrgIf the OUTPUT-FILE ends in \`.la', then a libtool library is created,
24502378475aSmrgonly library objects (\`.lo' files) may be specified, and \`-rpath' is
24512378475aSmrgrequired, except when creating a convenience library.
245295b296d0Smrg
24532378475aSmrgIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
24542378475aSmrgusing \`ar' and \`ranlib', or on Windows using \`lib'.
245595b296d0Smrg
24562378475aSmrgIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
24572378475aSmrgis created, otherwise an executable program is created."
2458e6f085baSmrg        ;;
245995b296d0Smrg
24602378475aSmrg      uninstall)
24612378475aSmrg        $ECHO \
24622378475aSmrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
246395b296d0Smrg
24642378475aSmrgRemove libraries from an installation directory.
246595b296d0Smrg
24662378475aSmrgRM is the name of the program to use to delete files associated with each FILE
24672378475aSmrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
24682378475aSmrgto RM.
246939713583Smrg
24702378475aSmrgIf FILE is a libtool library, all the files associated with it are deleted.
24712378475aSmrgOtherwise, only FILE itself is deleted using RM."
24722378475aSmrg        ;;
247339713583Smrg
24742378475aSmrg      *)
247514330f12Smrg        func_fatal_help "invalid operation mode \`$opt_mode'"
24762378475aSmrg        ;;
24772378475aSmrg    esac
247839713583Smrg
247914330f12Smrg    echo
24802378475aSmrg    $ECHO "Try \`$progname --help' for more information about other modes."
24812378475aSmrg}
248239713583Smrg
248314330f12Smrg# Now that we've collected a possible --mode arg, show help if necessary
248414330f12Smrgif $opt_help; then
248514330f12Smrg  if test "$opt_help" = :; then
248614330f12Smrg    func_mode_help
248714330f12Smrg  else
248814330f12Smrg    {
248914330f12Smrg      func_help noexit
249014330f12Smrg      for opt_mode in compile link execute install finish uninstall clean; do
249114330f12Smrg	func_mode_help
249214330f12Smrg      done
249314330f12Smrg    } | sed -n '1p; 2,$s/^Usage:/  or: /p'
249414330f12Smrg    {
249514330f12Smrg      func_help noexit
249614330f12Smrg      for opt_mode in compile link execute install finish uninstall clean; do
249714330f12Smrg	echo
249814330f12Smrg	func_mode_help
249914330f12Smrg      done
250014330f12Smrg    } |
250114330f12Smrg    sed '1d
250214330f12Smrg      /^When reporting/,/^Report/{
250314330f12Smrg	H
250414330f12Smrg	d
250514330f12Smrg      }
250614330f12Smrg      $x
250714330f12Smrg      /information about other modes/d
250814330f12Smrg      /more detailed .*MODE/d
250914330f12Smrg      s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
251014330f12Smrg  fi
251114330f12Smrg  exit $?
251214330f12Smrgfi
251339713583Smrg
251439713583Smrg
25152378475aSmrg# func_mode_execute arg...
25162378475aSmrgfunc_mode_execute ()
25172378475aSmrg{
25182378475aSmrg    $opt_debug
25192378475aSmrg    # The first argument is the command name.
25202378475aSmrg    cmd="$nonopt"
25212378475aSmrg    test -z "$cmd" && \
25222378475aSmrg      func_fatal_help "you must specify a COMMAND"
2523e6f085baSmrg
25242378475aSmrg    # Handle -dlopen flags immediately.
252514330f12Smrg    for file in $opt_dlopen; do
25262378475aSmrg      test -f "$file" \
25272378475aSmrg	|| func_fatal_help "\`$file' is not a file"
2528e6f085baSmrg
25292378475aSmrg      dir=
25302378475aSmrg      case $file in
25312378475aSmrg      *.la)
253214330f12Smrg	func_resolve_sysroot "$file"
253314330f12Smrg	file=$func_resolve_sysroot_result
253414330f12Smrg
25352378475aSmrg	# Check to see that this really is a libtool archive.
25362378475aSmrg	func_lalib_unsafe_p "$file" \
25372378475aSmrg	  || func_fatal_help "\`$lib' is not a valid libtool archive"
2538e6f085baSmrg
25392378475aSmrg	# Read the libtool library.
25402378475aSmrg	dlname=
25412378475aSmrg	library_names=
25422378475aSmrg	func_source "$file"
254395b296d0Smrg
25442378475aSmrg	# Skip this library if it cannot be dlopened.
25452378475aSmrg	if test -z "$dlname"; then
25462378475aSmrg	  # Warn if it was a shared library.
25472378475aSmrg	  test -n "$library_names" && \
25482378475aSmrg	    func_warning "\`$file' was not linked with \`-export-dynamic'"
25492378475aSmrg	  continue
25502378475aSmrg	fi
255195b296d0Smrg
25522378475aSmrg	func_dirname "$file" "" "."
25532378475aSmrg	dir="$func_dirname_result"
255495b296d0Smrg
25552378475aSmrg	if test -f "$dir/$objdir/$dlname"; then
255614330f12Smrg	  func_append dir "/$objdir"
25572378475aSmrg	else
25582378475aSmrg	  if test ! -f "$dir/$dlname"; then
25592378475aSmrg	    func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'"
25602378475aSmrg	  fi
25612378475aSmrg	fi
2562e6f085baSmrg	;;
256395b296d0Smrg
25642378475aSmrg      *.lo)
25652378475aSmrg	# Just add the directory containing the .lo file.
25662378475aSmrg	func_dirname "$file" "" "."
25672378475aSmrg	dir="$func_dirname_result"
2568e6f085baSmrg	;;
256995b296d0Smrg
25702378475aSmrg      *)
25712378475aSmrg	func_warning "\`-dlopen' is ignored for non-libtool libraries and objects"
2572e6f085baSmrg	continue
2573e6f085baSmrg	;;
25742378475aSmrg      esac
257595b296d0Smrg
25762378475aSmrg      # Get the absolute pathname.
25772378475aSmrg      absdir=`cd "$dir" && pwd`
25782378475aSmrg      test -n "$absdir" && dir="$absdir"
257939713583Smrg
25802378475aSmrg      # Now add the directory to shlibpath_var.
25812378475aSmrg      if eval "test -z \"\$$shlibpath_var\""; then
25822378475aSmrg	eval "$shlibpath_var=\"\$dir\""
25832378475aSmrg      else
25842378475aSmrg	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
25852378475aSmrg      fi
25862378475aSmrg    done
258739713583Smrg
25882378475aSmrg    # This variable tells wrapper scripts just to set shlibpath_var
25892378475aSmrg    # rather than running their programs.
25902378475aSmrg    libtool_execute_magic="$magic"
259139713583Smrg
25922378475aSmrg    # Check if any of the arguments is a wrapper script.
25932378475aSmrg    args=
25942378475aSmrg    for file
25952378475aSmrg    do
25962378475aSmrg      case $file in
259714330f12Smrg      -* | *.la | *.lo ) ;;
25982378475aSmrg      *)
25992378475aSmrg	# Do a test to see if this is really a libtool program.
26002378475aSmrg	if func_ltwrapper_script_p "$file"; then
26012378475aSmrg	  func_source "$file"
26022378475aSmrg	  # Transform arg to wrapped name.
26032378475aSmrg	  file="$progdir/$program"
26042378475aSmrg	elif func_ltwrapper_executable_p "$file"; then
26052378475aSmrg	  func_ltwrapper_scriptname "$file"
26062378475aSmrg	  func_source "$func_ltwrapper_scriptname_result"
26072378475aSmrg	  # Transform arg to wrapped name.
26082378475aSmrg	  file="$progdir/$program"
26092378475aSmrg	fi
26102378475aSmrg	;;
26112378475aSmrg      esac
26122378475aSmrg      # Quote arguments (to preserve shell metacharacters).
261314330f12Smrg      func_append_quoted args "$file"
26142378475aSmrg    done
261539713583Smrg
26162378475aSmrg    if test "X$opt_dry_run" = Xfalse; then
26172378475aSmrg      if test -n "$shlibpath_var"; then
26182378475aSmrg	# Export the shlibpath_var.
26192378475aSmrg	eval "export $shlibpath_var"
26202378475aSmrg      fi
262139713583Smrg
26222378475aSmrg      # Restore saved environment variables
26232378475aSmrg      for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
26242378475aSmrg      do
26252378475aSmrg	eval "if test \"\${save_$lt_var+set}\" = set; then
26262378475aSmrg                $lt_var=\$save_$lt_var; export $lt_var
2627e6f085baSmrg	      else
26282378475aSmrg		$lt_unset $lt_var
26292378475aSmrg	      fi"
26302378475aSmrg      done
263139713583Smrg
26322378475aSmrg      # Now prepare to actually exec the command.
26332378475aSmrg      exec_cmd="\$cmd$args"
26342378475aSmrg    else
26352378475aSmrg      # Display what would be done.
26362378475aSmrg      if test -n "$shlibpath_var"; then
26372378475aSmrg	eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
263814330f12Smrg	echo "export $shlibpath_var"
26392378475aSmrg      fi
26402378475aSmrg      $ECHO "$cmd$args"
26412378475aSmrg      exit $EXIT_SUCCESS
26422378475aSmrg    fi
26432378475aSmrg}
264439713583Smrg
264514330f12Smrgtest "$opt_mode" = execute && func_mode_execute ${1+"$@"}
264614330f12Smrg
264714330f12Smrg
264814330f12Smrg# func_mode_finish arg...
264914330f12Smrgfunc_mode_finish ()
265014330f12Smrg{
265114330f12Smrg    $opt_debug
265214330f12Smrg    libs=
265314330f12Smrg    libdirs=
265414330f12Smrg    admincmds=
265514330f12Smrg
265614330f12Smrg    for opt in "$nonopt" ${1+"$@"}
265714330f12Smrg    do
265814330f12Smrg      if test -d "$opt"; then
265914330f12Smrg	func_append libdirs " $opt"
266014330f12Smrg
266114330f12Smrg      elif test -f "$opt"; then
266214330f12Smrg	if func_lalib_unsafe_p "$opt"; then
266314330f12Smrg	  func_append libs " $opt"
266414330f12Smrg	else
266514330f12Smrg	  func_warning "\`$opt' is not a valid libtool archive"
266614330f12Smrg	fi
266714330f12Smrg
266814330f12Smrg      else
266914330f12Smrg	func_fatal_error "invalid argument \`$opt'"
267014330f12Smrg      fi
267114330f12Smrg    done
267239713583Smrg
267314330f12Smrg    if test -n "$libs"; then
267414330f12Smrg      if test -n "$lt_sysroot"; then
267514330f12Smrg        sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"`
267614330f12Smrg        sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;"
267714330f12Smrg      else
267814330f12Smrg        sysroot_cmd=
267914330f12Smrg      fi
2680e6f085baSmrg
268114330f12Smrg      # Remove sysroot references
268214330f12Smrg      if $opt_dry_run; then
268314330f12Smrg        for lib in $libs; do
268414330f12Smrg          echo "removing references to $lt_sysroot and \`=' prefixes from $lib"
268514330f12Smrg        done
268614330f12Smrg      else
268714330f12Smrg        tmpdir=`func_mktempdir`
268814330f12Smrg        for lib in $libs; do
268914330f12Smrg	  sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
269014330f12Smrg	    > $tmpdir/tmp-la
269114330f12Smrg	  mv -f $tmpdir/tmp-la $lib
269214330f12Smrg	done
269314330f12Smrg        ${RM}r "$tmpdir"
269414330f12Smrg      fi
269514330f12Smrg    fi
269695b296d0Smrg
26972378475aSmrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
26982378475aSmrg      for libdir in $libdirs; do
26992378475aSmrg	if test -n "$finish_cmds"; then
27002378475aSmrg	  # Do each command in the finish commands.
27012378475aSmrg	  func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
27022378475aSmrg'"$cmd"'"'
2703e6f085baSmrg	fi
27042378475aSmrg	if test -n "$finish_eval"; then
27052378475aSmrg	  # Do the single finish_eval.
27062378475aSmrg	  eval cmds=\"$finish_eval\"
270714330f12Smrg	  $opt_dry_run || eval "$cmds" || func_append admincmds "
27082378475aSmrg       $cmds"
27092378475aSmrg	fi
27102378475aSmrg      done
27112378475aSmrg    fi
271295b296d0Smrg
27132378475aSmrg    # Exit here if they wanted silent mode.
27142378475aSmrg    $opt_silent && exit $EXIT_SUCCESS
271595b296d0Smrg
271614330f12Smrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
271714330f12Smrg      echo "----------------------------------------------------------------------"
271814330f12Smrg      echo "Libraries have been installed in:"
271914330f12Smrg      for libdir in $libdirs; do
272014330f12Smrg	$ECHO "   $libdir"
272114330f12Smrg      done
272214330f12Smrg      echo
272314330f12Smrg      echo "If you ever happen to want to link against installed libraries"
272414330f12Smrg      echo "in a given directory, LIBDIR, you must either use libtool, and"
272514330f12Smrg      echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
272614330f12Smrg      echo "flag during linking and do at least one of the following:"
272714330f12Smrg      if test -n "$shlibpath_var"; then
272814330f12Smrg	echo "   - add LIBDIR to the \`$shlibpath_var' environment variable"
272914330f12Smrg	echo "     during execution"
273014330f12Smrg      fi
273114330f12Smrg      if test -n "$runpath_var"; then
273214330f12Smrg	echo "   - add LIBDIR to the \`$runpath_var' environment variable"
273314330f12Smrg	echo "     during linking"
273414330f12Smrg      fi
273514330f12Smrg      if test -n "$hardcode_libdir_flag_spec"; then
273614330f12Smrg	libdir=LIBDIR
273714330f12Smrg	eval flag=\"$hardcode_libdir_flag_spec\"
27382378475aSmrg
273914330f12Smrg	$ECHO "   - use the \`$flag' linker flag"
274014330f12Smrg      fi
274114330f12Smrg      if test -n "$admincmds"; then
274214330f12Smrg	$ECHO "   - have your system administrator run these commands:$admincmds"
274314330f12Smrg      fi
274414330f12Smrg      if test -f /etc/ld.so.conf; then
274514330f12Smrg	echo "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
274614330f12Smrg      fi
274714330f12Smrg      echo
27482378475aSmrg
274914330f12Smrg      echo "See any operating system documentation about shared libraries for"
275014330f12Smrg      case $host in
275114330f12Smrg	solaris2.[6789]|solaris2.1[0-9])
275214330f12Smrg	  echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
275314330f12Smrg	  echo "pages."
275414330f12Smrg	  ;;
275514330f12Smrg	*)
275614330f12Smrg	  echo "more information, such as the ld(1) and ld.so(8) manual pages."
275714330f12Smrg	  ;;
275814330f12Smrg      esac
275914330f12Smrg      echo "----------------------------------------------------------------------"
276014330f12Smrg    fi
27612378475aSmrg    exit $EXIT_SUCCESS
27622378475aSmrg}
27632378475aSmrg
276414330f12Smrgtest "$opt_mode" = finish && func_mode_finish ${1+"$@"}
27652378475aSmrg
27662378475aSmrg
27672378475aSmrg# func_mode_install arg...
27682378475aSmrgfunc_mode_install ()
27692378475aSmrg{
27702378475aSmrg    $opt_debug
27712378475aSmrg    # There may be an optional sh(1) argument at the beginning of
27722378475aSmrg    # install_prog (especially on Windows NT).
27732378475aSmrg    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
27742378475aSmrg       # Allow the use of GNU shtool's install command.
277514330f12Smrg       case $nonopt in *shtool*) :;; *) false;; esac; then
27762378475aSmrg      # Aesthetically quote it.
27772378475aSmrg      func_quote_for_eval "$nonopt"
27782378475aSmrg      install_prog="$func_quote_for_eval_result "
27792378475aSmrg      arg=$1
27802378475aSmrg      shift
27812378475aSmrg    else
27822378475aSmrg      install_prog=
27832378475aSmrg      arg=$nonopt
27842378475aSmrg    fi
27852378475aSmrg
27862378475aSmrg    # The real first argument should be the name of the installation program.
27872378475aSmrg    # Aesthetically quote it.
27882378475aSmrg    func_quote_for_eval "$arg"
278914330f12Smrg    func_append install_prog "$func_quote_for_eval_result"
279014330f12Smrg    install_shared_prog=$install_prog
279114330f12Smrg    case " $install_prog " in
279214330f12Smrg      *[\\\ /]cp\ *) install_cp=: ;;
279314330f12Smrg      *) install_cp=false ;;
279414330f12Smrg    esac
27952378475aSmrg
27962378475aSmrg    # We need to accept at least all the BSD install flags.
27972378475aSmrg    dest=
27982378475aSmrg    files=
27992378475aSmrg    opts=
28002378475aSmrg    prev=
28012378475aSmrg    install_type=
28022378475aSmrg    isdir=no
28032378475aSmrg    stripme=
280414330f12Smrg    no_mode=:
28052378475aSmrg    for arg
28062378475aSmrg    do
280714330f12Smrg      arg2=
28082378475aSmrg      if test -n "$dest"; then
280914330f12Smrg	func_append files " $dest"
28102378475aSmrg	dest=$arg
28112378475aSmrg	continue
28122378475aSmrg      fi
28132378475aSmrg
28142378475aSmrg      case $arg in
28152378475aSmrg      -d) isdir=yes ;;
28162378475aSmrg      -f)
281714330f12Smrg	if $install_cp; then :; else
281814330f12Smrg	  prev=$arg
281914330f12Smrg	fi
28202378475aSmrg	;;
28212378475aSmrg      -g | -m | -o)
28222378475aSmrg	prev=$arg
28232378475aSmrg	;;
28242378475aSmrg      -s)
28252378475aSmrg	stripme=" -s"
28262378475aSmrg	continue
28272378475aSmrg	;;
28282378475aSmrg      -*)
28292378475aSmrg	;;
28302378475aSmrg      *)
28312378475aSmrg	# If the previous option needed an argument, then skip it.
28322378475aSmrg	if test -n "$prev"; then
283314330f12Smrg	  if test "x$prev" = x-m && test -n "$install_override_mode"; then
283414330f12Smrg	    arg2=$install_override_mode
283514330f12Smrg	    no_mode=false
283614330f12Smrg	  fi
2837e6f085baSmrg	  prev=
283839713583Smrg	else
28392378475aSmrg	  dest=$arg
28402378475aSmrg	  continue
284195b296d0Smrg	fi
2842e6f085baSmrg	;;
28432378475aSmrg      esac
284495b296d0Smrg
28452378475aSmrg      # Aesthetically quote the argument.
28462378475aSmrg      func_quote_for_eval "$arg"
284714330f12Smrg      func_append install_prog " $func_quote_for_eval_result"
284814330f12Smrg      if test -n "$arg2"; then
284914330f12Smrg	func_quote_for_eval "$arg2"
285014330f12Smrg      fi
285114330f12Smrg      func_append install_shared_prog " $func_quote_for_eval_result"
28522378475aSmrg    done
285395b296d0Smrg
28542378475aSmrg    test -z "$install_prog" && \
28552378475aSmrg      func_fatal_help "you must specify an install program"
285695b296d0Smrg
28572378475aSmrg    test -n "$prev" && \
28582378475aSmrg      func_fatal_help "the \`$prev' option requires an argument"
285939713583Smrg
286014330f12Smrg    if test -n "$install_override_mode" && $no_mode; then
286114330f12Smrg      if $install_cp; then :; else
286214330f12Smrg	func_quote_for_eval "$install_override_mode"
286314330f12Smrg	func_append install_shared_prog " -m $func_quote_for_eval_result"
286414330f12Smrg      fi
286514330f12Smrg    fi
286614330f12Smrg
28672378475aSmrg    if test -z "$files"; then
28682378475aSmrg      if test -z "$dest"; then
28692378475aSmrg	func_fatal_help "no file or destination specified"
28702378475aSmrg      else
28712378475aSmrg	func_fatal_help "you must specify a destination"
28722378475aSmrg      fi
2873e6f085baSmrg    fi
287439713583Smrg
28752378475aSmrg    # Strip any trailing slash from the destination.
28762378475aSmrg    func_stripname '' '/' "$dest"
28772378475aSmrg    dest=$func_stripname_result
287839713583Smrg
28792378475aSmrg    # Check to see that the destination is a directory.
28802378475aSmrg    test -d "$dest" && isdir=yes
28812378475aSmrg    if test "$isdir" = yes; then
28822378475aSmrg      destdir="$dest"
28832378475aSmrg      destname=
2884e6f085baSmrg    else
28852378475aSmrg      func_dirname_and_basename "$dest" "" "."
28862378475aSmrg      destdir="$func_dirname_result"
28872378475aSmrg      destname="$func_basename_result"
288839713583Smrg
28892378475aSmrg      # Not a directory, so check to see that there is only one file specified.
28902378475aSmrg      set dummy $files; shift
28912378475aSmrg      test "$#" -gt 1 && \
28922378475aSmrg	func_fatal_help "\`$dest' is not a directory"
289339713583Smrg    fi
28942378475aSmrg    case $destdir in
28952378475aSmrg    [\\/]* | [A-Za-z]:[\\/]*) ;;
2896e6f085baSmrg    *)
28972378475aSmrg      for file in $files; do
28982378475aSmrg	case $file in
28992378475aSmrg	*.lo) ;;
29002378475aSmrg	*)
29012378475aSmrg	  func_fatal_help "\`$destdir' must be an absolute directory name"
29022378475aSmrg	  ;;
29032378475aSmrg	esac
29042378475aSmrg      done
2905e6f085baSmrg      ;;
2906e6f085baSmrg    esac
290795b296d0Smrg
29082378475aSmrg    # This variable tells wrapper scripts just to set variables rather
29092378475aSmrg    # than running their programs.
29102378475aSmrg    libtool_install_magic="$magic"
291195b296d0Smrg
29122378475aSmrg    staticlibs=
29132378475aSmrg    future_libdirs=
29142378475aSmrg    current_libdirs=
29152378475aSmrg    for file in $files; do
291695b296d0Smrg
29172378475aSmrg      # Do each installation.
29182378475aSmrg      case $file in
29192378475aSmrg      *.$libext)
29202378475aSmrg	# Do the static libraries later.
292114330f12Smrg	func_append staticlibs " $file"
29222378475aSmrg	;;
29232378475aSmrg
29242378475aSmrg      *.la)
292514330f12Smrg	func_resolve_sysroot "$file"
292614330f12Smrg	file=$func_resolve_sysroot_result
292714330f12Smrg
29282378475aSmrg	# Check to see that this really is a libtool archive.
29292378475aSmrg	func_lalib_unsafe_p "$file" \
29302378475aSmrg	  || func_fatal_help "\`$file' is not a valid libtool archive"
29312378475aSmrg
29322378475aSmrg	library_names=
29332378475aSmrg	old_library=
29342378475aSmrg	relink_command=
29352378475aSmrg	func_source "$file"
29362378475aSmrg
29372378475aSmrg	# Add the libdir to current_libdirs if it is the destination.
29382378475aSmrg	if test "X$destdir" = "X$libdir"; then
29392378475aSmrg	  case "$current_libdirs " in
29402378475aSmrg	  *" $libdir "*) ;;
294114330f12Smrg	  *) func_append current_libdirs " $libdir" ;;
294239713583Smrg	  esac
29432378475aSmrg	else
29442378475aSmrg	  # Note the libdir as a future libdir.
29452378475aSmrg	  case "$future_libdirs " in
29462378475aSmrg	  *" $libdir "*) ;;
294714330f12Smrg	  *) func_append future_libdirs " $libdir" ;;
29482378475aSmrg	  esac
29492378475aSmrg	fi
295039713583Smrg
29512378475aSmrg	func_dirname "$file" "/" ""
29522378475aSmrg	dir="$func_dirname_result"
295314330f12Smrg	func_append dir "$objdir"
29542378475aSmrg
29552378475aSmrg	if test -n "$relink_command"; then
29562378475aSmrg	  # Determine the prefix the user has applied to our future dir.
295714330f12Smrg	  inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
29582378475aSmrg
29592378475aSmrg	  # Don't allow the user to place us outside of our expected
29602378475aSmrg	  # location b/c this prevents finding dependent libraries that
29612378475aSmrg	  # are installed to the same prefix.
29622378475aSmrg	  # At present, this check doesn't affect windows .dll's that
29632378475aSmrg	  # are installed into $libdir/../bin (currently, that works fine)
29642378475aSmrg	  # but it's something to keep an eye on.
29652378475aSmrg	  test "$inst_prefix_dir" = "$destdir" && \
29662378475aSmrg	    func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
29672378475aSmrg
29682378475aSmrg	  if test -n "$inst_prefix_dir"; then
29692378475aSmrg	    # Stick the inst_prefix_dir data into the link command.
297014330f12Smrg	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
29712378475aSmrg	  else
297214330f12Smrg	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
29732378475aSmrg	  fi
29742378475aSmrg
29752378475aSmrg	  func_warning "relinking \`$file'"
29762378475aSmrg	  func_show_eval "$relink_command" \
29772378475aSmrg	    'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
29782378475aSmrg	fi
29792378475aSmrg
29802378475aSmrg	# See the names of the shared library.
29812378475aSmrg	set dummy $library_names; shift
29822378475aSmrg	if test -n "$1"; then
29832378475aSmrg	  realname="$1"
29842378475aSmrg	  shift
29852378475aSmrg
29862378475aSmrg	  srcname="$realname"
29872378475aSmrg	  test -n "$relink_command" && srcname="$realname"T
29882378475aSmrg
29892378475aSmrg	  # Install the shared library and build the symlinks.
299014330f12Smrg	  func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
29912378475aSmrg	      'exit $?'
29922378475aSmrg	  tstripme="$stripme"
29932378475aSmrg	  case $host_os in
29942378475aSmrg	  cygwin* | mingw* | pw32* | cegcc*)
29952378475aSmrg	    case $realname in
29962378475aSmrg	    *.dll.a)
29972378475aSmrg	      tstripme=""
29982378475aSmrg	      ;;
29992378475aSmrg	    esac
300039713583Smrg	    ;;
300139713583Smrg	  esac
30022378475aSmrg	  if test -n "$tstripme" && test -n "$striplib"; then
30032378475aSmrg	    func_show_eval "$striplib $destdir/$realname" 'exit $?'
3004e6f085baSmrg	  fi
30052378475aSmrg
30062378475aSmrg	  if test "$#" -gt 0; then
30072378475aSmrg	    # Delete the old symlinks, and create new ones.
30082378475aSmrg	    # Try `ln -sf' first, because the `ln' binary might depend on
30092378475aSmrg	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
30102378475aSmrg	    # so we also need to try rm && ln -s.
30112378475aSmrg	    for linkname
30122378475aSmrg	    do
30132378475aSmrg	      test "$linkname" != "$realname" \
30142378475aSmrg		&& func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
3015e6f085baSmrg	    done
3016e6f085baSmrg	  fi
301795b296d0Smrg
30182378475aSmrg	  # Do each command in the postinstall commands.
30192378475aSmrg	  lib="$destdir/$realname"
30202378475aSmrg	  func_execute_cmds "$postinstall_cmds" 'exit $?'
3021e6f085baSmrg	fi
302295b296d0Smrg
30232378475aSmrg	# Install the pseudo-library for information purposes.
30242378475aSmrg	func_basename "$file"
30252378475aSmrg	name="$func_basename_result"
30262378475aSmrg	instname="$dir/$name"i
30272378475aSmrg	func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
302895b296d0Smrg
30292378475aSmrg	# Maybe install the static library, too.
303014330f12Smrg	test -n "$old_library" && func_append staticlibs " $dir/$old_library"
30312378475aSmrg	;;
303295b296d0Smrg
30332378475aSmrg      *.lo)
30342378475aSmrg	# Install (i.e. copy) a libtool object.
303595b296d0Smrg
30362378475aSmrg	# Figure out destination file name, if it wasn't already specified.
30372378475aSmrg	if test -n "$destname"; then
30382378475aSmrg	  destfile="$destdir/$destname"
30392378475aSmrg	else
30402378475aSmrg	  func_basename "$file"
30412378475aSmrg	  destfile="$func_basename_result"
30422378475aSmrg	  destfile="$destdir/$destfile"
3043e6f085baSmrg	fi
304495b296d0Smrg
30452378475aSmrg	# Deduce the name of the destination old-style object file.
30462378475aSmrg	case $destfile in
30472378475aSmrg	*.lo)
30482378475aSmrg	  func_lo2o "$destfile"
30492378475aSmrg	  staticdest=$func_lo2o_result
30502378475aSmrg	  ;;
30512378475aSmrg	*.$objext)
30522378475aSmrg	  staticdest="$destfile"
30532378475aSmrg	  destfile=
30542378475aSmrg	  ;;
30552378475aSmrg	*)
30562378475aSmrg	  func_fatal_help "cannot copy a libtool object to \`$destfile'"
30572378475aSmrg	  ;;
30582378475aSmrg	esac
305995b296d0Smrg
30602378475aSmrg	# Install the libtool object if requested.
30612378475aSmrg	test -n "$destfile" && \
30622378475aSmrg	  func_show_eval "$install_prog $file $destfile" 'exit $?'
306395b296d0Smrg
30642378475aSmrg	# Install the old object if enabled.
30652378475aSmrg	if test "$build_old_libs" = yes; then
30662378475aSmrg	  # Deduce the name of the old-style object file.
30672378475aSmrg	  func_lo2o "$file"
30682378475aSmrg	  staticobj=$func_lo2o_result
30692378475aSmrg	  func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
307095b296d0Smrg	fi
30712378475aSmrg	exit $EXIT_SUCCESS
30722378475aSmrg	;;
307395b296d0Smrg
30742378475aSmrg      *)
30752378475aSmrg	# Figure out destination file name, if it wasn't already specified.
30762378475aSmrg	if test -n "$destname"; then
30772378475aSmrg	  destfile="$destdir/$destname"
30782378475aSmrg	else
30792378475aSmrg	  func_basename "$file"
30802378475aSmrg	  destfile="$func_basename_result"
30812378475aSmrg	  destfile="$destdir/$destfile"
30822378475aSmrg	fi
308395b296d0Smrg
30842378475aSmrg	# If the file is missing, and there is a .exe on the end, strip it
30852378475aSmrg	# because it is most likely a libtool script we actually want to
30862378475aSmrg	# install
30872378475aSmrg	stripped_ext=""
30882378475aSmrg	case $file in
30892378475aSmrg	  *.exe)
30902378475aSmrg	    if test ! -f "$file"; then
30912378475aSmrg	      func_stripname '' '.exe' "$file"
30922378475aSmrg	      file=$func_stripname_result
30932378475aSmrg	      stripped_ext=".exe"
30942378475aSmrg	    fi
30952378475aSmrg	    ;;
30962378475aSmrg	esac
30972378475aSmrg
30982378475aSmrg	# Do a test to see if this is really a libtool program.
30992378475aSmrg	case $host in
31002378475aSmrg	*cygwin* | *mingw*)
31012378475aSmrg	    if func_ltwrapper_executable_p "$file"; then
31022378475aSmrg	      func_ltwrapper_scriptname "$file"
31032378475aSmrg	      wrapper=$func_ltwrapper_scriptname_result
31042378475aSmrg	    else
31052378475aSmrg	      func_stripname '' '.exe' "$file"
31062378475aSmrg	      wrapper=$func_stripname_result
31072378475aSmrg	    fi
31082378475aSmrg	    ;;
3109e6f085baSmrg	*)
31102378475aSmrg	    wrapper=$file
31112378475aSmrg	    ;;
31122378475aSmrg	esac
31132378475aSmrg	if func_ltwrapper_script_p "$wrapper"; then
31142378475aSmrg	  notinst_deplibs=
31152378475aSmrg	  relink_command=
31162378475aSmrg
31172378475aSmrg	  func_source "$wrapper"
31182378475aSmrg
31192378475aSmrg	  # Check the variables that should have been set.
31202378475aSmrg	  test -z "$generated_by_libtool_version" && \
31212378475aSmrg	    func_fatal_error "invalid libtool wrapper script \`$wrapper'"
31222378475aSmrg
31232378475aSmrg	  finalize=yes
31242378475aSmrg	  for lib in $notinst_deplibs; do
31252378475aSmrg	    # Check to see that each library is installed.
31262378475aSmrg	    libdir=
31272378475aSmrg	    if test -f "$lib"; then
31282378475aSmrg	      func_source "$lib"
31292378475aSmrg	    fi
313014330f12Smrg	    libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test
31312378475aSmrg	    if test -n "$libdir" && test ! -f "$libfile"; then
31322378475aSmrg	      func_warning "\`$lib' has not been installed in \`$libdir'"
31332378475aSmrg	      finalize=no
31342378475aSmrg	    fi
31352378475aSmrg	  done
31362378475aSmrg
31372378475aSmrg	  relink_command=
31382378475aSmrg	  func_source "$wrapper"
31392378475aSmrg
31402378475aSmrg	  outputname=
31412378475aSmrg	  if test "$fast_install" = no && test -n "$relink_command"; then
31422378475aSmrg	    $opt_dry_run || {
31432378475aSmrg	      if test "$finalize" = yes; then
31442378475aSmrg	        tmpdir=`func_mktempdir`
31452378475aSmrg		func_basename "$file$stripped_ext"
31462378475aSmrg		file="$func_basename_result"
31472378475aSmrg	        outputname="$tmpdir/$file"
31482378475aSmrg	        # Replace the output file specification.
314914330f12Smrg	        relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
31502378475aSmrg
31512378475aSmrg	        $opt_silent || {
31522378475aSmrg	          func_quote_for_expand "$relink_command"
31532378475aSmrg		  eval "func_echo $func_quote_for_expand_result"
31542378475aSmrg	        }
31552378475aSmrg	        if eval "$relink_command"; then :
31562378475aSmrg	          else
31572378475aSmrg		  func_error "error: relink \`$file' with the above command before installing it"
31582378475aSmrg		  $opt_dry_run || ${RM}r "$tmpdir"
31592378475aSmrg		  continue
31602378475aSmrg	        fi
31612378475aSmrg	        file="$outputname"
31622378475aSmrg	      else
31632378475aSmrg	        func_warning "cannot relink \`$file'"
31642378475aSmrg	      fi
31652378475aSmrg	    }
31662378475aSmrg	  else
31672378475aSmrg	    # Install the binary that we compiled earlier.
316814330f12Smrg	    file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
3169e6f085baSmrg	  fi
31702378475aSmrg	fi
31712378475aSmrg
31722378475aSmrg	# remove .exe since cygwin /usr/bin/install will append another
31732378475aSmrg	# one anyway
31742378475aSmrg	case $install_prog,$host in
31752378475aSmrg	*/usr/bin/install*,*cygwin*)
31762378475aSmrg	  case $file:$destfile in
31772378475aSmrg	  *.exe:*.exe)
31782378475aSmrg	    # this is ok
31792378475aSmrg	    ;;
31802378475aSmrg	  *.exe:*)
31812378475aSmrg	    destfile=$destfile.exe
31822378475aSmrg	    ;;
31832378475aSmrg	  *:*.exe)
31842378475aSmrg	    func_stripname '' '.exe' "$destfile"
31852378475aSmrg	    destfile=$func_stripname_result
31862378475aSmrg	    ;;
31872378475aSmrg	  esac
3188e6f085baSmrg	  ;;
3189e6f085baSmrg	esac
31902378475aSmrg	func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
31912378475aSmrg	$opt_dry_run || if test -n "$outputname"; then
31922378475aSmrg	  ${RM}r "$tmpdir"
31932378475aSmrg	fi
31942378475aSmrg	;;
31952378475aSmrg      esac
31962378475aSmrg    done
319795b296d0Smrg
31982378475aSmrg    for file in $staticlibs; do
31992378475aSmrg      func_basename "$file"
32002378475aSmrg      name="$func_basename_result"
32012378475aSmrg
32022378475aSmrg      # Set up the ranlib parameters.
32032378475aSmrg      oldlib="$destdir/$name"
32042378475aSmrg
32052378475aSmrg      func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
32062378475aSmrg
32072378475aSmrg      if test -n "$stripme" && test -n "$old_striplib"; then
32082378475aSmrg	func_show_eval "$old_striplib $oldlib" 'exit $?'
32092378475aSmrg      fi
32102378475aSmrg
32112378475aSmrg      # Do each command in the postinstall commands.
32122378475aSmrg      func_execute_cmds "$old_postinstall_cmds" 'exit $?'
32132378475aSmrg    done
32142378475aSmrg
32152378475aSmrg    test -n "$future_libdirs" && \
32162378475aSmrg      func_warning "remember to run \`$progname --finish$future_libdirs'"
32172378475aSmrg
32182378475aSmrg    if test -n "$current_libdirs"; then
32192378475aSmrg      # Maybe just do a dry run.
32202378475aSmrg      $opt_dry_run && current_libdirs=" -n$current_libdirs"
32212378475aSmrg      exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
32222378475aSmrg    else
32232378475aSmrg      exit $EXIT_SUCCESS
32242378475aSmrg    fi
32252378475aSmrg}
32262378475aSmrg
322714330f12Smrgtest "$opt_mode" = install && func_mode_install ${1+"$@"}
32282378475aSmrg
32292378475aSmrg
32302378475aSmrg# func_generate_dlsyms outputname originator pic_p
32312378475aSmrg# Extract symbols from dlprefiles and create ${outputname}S.o with
32322378475aSmrg# a dlpreopen symbol table.
32332378475aSmrgfunc_generate_dlsyms ()
32342378475aSmrg{
32352378475aSmrg    $opt_debug
32362378475aSmrg    my_outputname="$1"
32372378475aSmrg    my_originator="$2"
32382378475aSmrg    my_pic_p="${3-no}"
32392378475aSmrg    my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'`
32402378475aSmrg    my_dlsyms=
32412378475aSmrg
32422378475aSmrg    if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
32432378475aSmrg      if test -n "$NM" && test -n "$global_symbol_pipe"; then
32442378475aSmrg	my_dlsyms="${my_outputname}S.c"
32452378475aSmrg      else
32462378475aSmrg	func_error "not configured to extract global symbols from dlpreopened files"
32472378475aSmrg      fi
32482378475aSmrg    fi
32492378475aSmrg
32502378475aSmrg    if test -n "$my_dlsyms"; then
32512378475aSmrg      case $my_dlsyms in
32522378475aSmrg      "") ;;
32532378475aSmrg      *.c)
32542378475aSmrg	# Discover the nlist of each of the dlfiles.
32552378475aSmrg	nlist="$output_objdir/${my_outputname}.nm"
32562378475aSmrg
32572378475aSmrg	func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
32582378475aSmrg
32592378475aSmrg	# Parse the name list into a source file.
32602378475aSmrg	func_verbose "creating $output_objdir/$my_dlsyms"
32612378475aSmrg
32622378475aSmrg	$opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
32632378475aSmrg/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */
32642378475aSmrg/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */
32652378475aSmrg
32662378475aSmrg#ifdef __cplusplus
32672378475aSmrgextern \"C\" {
32682378475aSmrg#endif
32692378475aSmrg
327014330f12Smrg#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
327114330f12Smrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
327214330f12Smrg#endif
327314330f12Smrg
327414330f12Smrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
327514330f12Smrg#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
327614330f12Smrg/* DATA imports from DLLs on WIN32 con't be const, because runtime
327714330f12Smrg   relocations are performed -- see ld's documentation on pseudo-relocs.  */
327814330f12Smrg# define LT_DLSYM_CONST
327914330f12Smrg#elif defined(__osf__)
328014330f12Smrg/* This system does not cope well with relocations in const data.  */
328114330f12Smrg# define LT_DLSYM_CONST
328214330f12Smrg#else
328314330f12Smrg# define LT_DLSYM_CONST const
328414330f12Smrg#endif
328514330f12Smrg
32862378475aSmrg/* External symbol declarations for the compiler. */\
32872378475aSmrg"
32882378475aSmrg
32892378475aSmrg	if test "$dlself" = yes; then
32902378475aSmrg	  func_verbose "generating symbol list for \`$output'"
32912378475aSmrg
32922378475aSmrg	  $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
32932378475aSmrg
32942378475aSmrg	  # Add our own program objects to the symbol list.
329514330f12Smrg	  progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
32962378475aSmrg	  for progfile in $progfiles; do
329714330f12Smrg	    func_to_tool_file "$progfile" func_convert_file_msys_to_w32
329814330f12Smrg	    func_verbose "extracting global C symbols from \`$func_to_tool_file_result'"
329914330f12Smrg	    $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
33002378475aSmrg	  done
33012378475aSmrg
33022378475aSmrg	  if test -n "$exclude_expsyms"; then
33032378475aSmrg	    $opt_dry_run || {
33042378475aSmrg	      eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
33052378475aSmrg	      eval '$MV "$nlist"T "$nlist"'
33062378475aSmrg	    }
3307e6f085baSmrg	  fi
33082378475aSmrg
33092378475aSmrg	  if test -n "$export_symbols_regex"; then
33102378475aSmrg	    $opt_dry_run || {
33112378475aSmrg	      eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
33122378475aSmrg	      eval '$MV "$nlist"T "$nlist"'
33132378475aSmrg	    }
33142378475aSmrg	  fi
33152378475aSmrg
33162378475aSmrg	  # Prepare the list of exported symbols
33172378475aSmrg	  if test -z "$export_symbols"; then
33182378475aSmrg	    export_symbols="$output_objdir/$outputname.exp"
33192378475aSmrg	    $opt_dry_run || {
33202378475aSmrg	      $RM $export_symbols
33212378475aSmrg	      eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
33222378475aSmrg	      case $host in
33232378475aSmrg	      *cygwin* | *mingw* | *cegcc* )
33242378475aSmrg                eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
33252378475aSmrg                eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
33262378475aSmrg	        ;;
33272378475aSmrg	      esac
33282378475aSmrg	    }
3329e6f085baSmrg	  else
33302378475aSmrg	    $opt_dry_run || {
33312378475aSmrg	      eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
33322378475aSmrg	      eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
33332378475aSmrg	      eval '$MV "$nlist"T "$nlist"'
33342378475aSmrg	      case $host in
333514330f12Smrg	        *cygwin* | *mingw* | *cegcc* )
33362378475aSmrg	          eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
33372378475aSmrg	          eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
33382378475aSmrg	          ;;
33392378475aSmrg	      esac
33402378475aSmrg	    }
3341e6f085baSmrg	  fi
33422378475aSmrg	fi
334395b296d0Smrg
33442378475aSmrg	for dlprefile in $dlprefiles; do
33452378475aSmrg	  func_verbose "extracting global C symbols from \`$dlprefile'"
33462378475aSmrg	  func_basename "$dlprefile"
33472378475aSmrg	  name="$func_basename_result"
334814330f12Smrg          case $host in
334914330f12Smrg	    *cygwin* | *mingw* | *cegcc* )
335014330f12Smrg	      # if an import library, we need to obtain dlname
335114330f12Smrg	      if func_win32_import_lib_p "$dlprefile"; then
335214330f12Smrg	        func_tr_sh "$dlprefile"
335314330f12Smrg	        eval "curr_lafile=\$libfile_$func_tr_sh_result"
335414330f12Smrg	        dlprefile_dlbasename=""
335514330f12Smrg	        if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
335614330f12Smrg	          # Use subshell, to avoid clobbering current variable values
335714330f12Smrg	          dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
335814330f12Smrg	          if test -n "$dlprefile_dlname" ; then
335914330f12Smrg	            func_basename "$dlprefile_dlname"
336014330f12Smrg	            dlprefile_dlbasename="$func_basename_result"
336114330f12Smrg	          else
336214330f12Smrg	            # no lafile. user explicitly requested -dlpreopen <import library>.
336314330f12Smrg	            $sharedlib_from_linklib_cmd "$dlprefile"
336414330f12Smrg	            dlprefile_dlbasename=$sharedlib_from_linklib_result
336514330f12Smrg	          fi
336614330f12Smrg	        fi
336714330f12Smrg	        $opt_dry_run || {
336814330f12Smrg	          if test -n "$dlprefile_dlbasename" ; then
336914330f12Smrg	            eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
337014330f12Smrg	          else
337114330f12Smrg	            func_warning "Could not compute DLL name from $name"
337214330f12Smrg	            eval '$ECHO ": $name " >> "$nlist"'
337314330f12Smrg	          fi
337414330f12Smrg	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
337514330f12Smrg	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe |
337614330f12Smrg	            $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'"
337714330f12Smrg	        }
337814330f12Smrg	      else # not an import lib
337914330f12Smrg	        $opt_dry_run || {
338014330f12Smrg	          eval '$ECHO ": $name " >> "$nlist"'
338114330f12Smrg	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
338214330f12Smrg	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
338314330f12Smrg	        }
338414330f12Smrg	      fi
338514330f12Smrg	    ;;
338614330f12Smrg	    *)
338714330f12Smrg	      $opt_dry_run || {
338814330f12Smrg	        eval '$ECHO ": $name " >> "$nlist"'
338914330f12Smrg	        func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
339014330f12Smrg	        eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
339114330f12Smrg	      }
339214330f12Smrg	    ;;
339314330f12Smrg          esac
33942378475aSmrg	done
33952378475aSmrg
33962378475aSmrg	$opt_dry_run || {
33972378475aSmrg	  # Make sure we have at least an empty file.
33982378475aSmrg	  test -f "$nlist" || : > "$nlist"
33992378475aSmrg
34002378475aSmrg	  if test -n "$exclude_expsyms"; then
34012378475aSmrg	    $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
34022378475aSmrg	    $MV "$nlist"T "$nlist"
3403e6f085baSmrg	  fi
34042378475aSmrg
34052378475aSmrg	  # Try sorting and uniquifying the output.
34062378475aSmrg	  if $GREP -v "^: " < "$nlist" |
34072378475aSmrg	      if sort -k 3 </dev/null >/dev/null 2>&1; then
34082378475aSmrg		sort -k 3
34092378475aSmrg	      else
34102378475aSmrg		sort +2
34112378475aSmrg	      fi |
34122378475aSmrg	      uniq > "$nlist"S; then
34132378475aSmrg	    :
3414e6f085baSmrg	  else
34152378475aSmrg	    $GREP -v "^: " < "$nlist" > "$nlist"S
3416e6f085baSmrg	  fi
341795b296d0Smrg
34182378475aSmrg	  if test -f "$nlist"S; then
34192378475aSmrg	    eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
3420e6f085baSmrg	  else
342114330f12Smrg	    echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
3422e6f085baSmrg	  fi
342395b296d0Smrg
342414330f12Smrg	  echo >> "$output_objdir/$my_dlsyms" "\
342595b296d0Smrg
34262378475aSmrg/* The mapping between symbol names and symbols.  */
34272378475aSmrgtypedef struct {
34282378475aSmrg  const char *name;
34292378475aSmrg  void *address;
34302378475aSmrg} lt_dlsymlist;
343114330f12Smrgextern LT_DLSYM_CONST lt_dlsymlist
34322378475aSmrglt_${my_prefix}_LTX_preloaded_symbols[];
343314330f12SmrgLT_DLSYM_CONST lt_dlsymlist
34342378475aSmrglt_${my_prefix}_LTX_preloaded_symbols[] =
34352378475aSmrg{\
34362378475aSmrg  { \"$my_originator\", (void *) 0 },"
343795b296d0Smrg
34382378475aSmrg	  case $need_lib_prefix in
34392378475aSmrg	  no)
34402378475aSmrg	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
34412378475aSmrg	    ;;
34422378475aSmrg	  *)
34432378475aSmrg	    eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
34442378475aSmrg	    ;;
34452378475aSmrg	  esac
344614330f12Smrg	  echo >> "$output_objdir/$my_dlsyms" "\
34472378475aSmrg  {0, (void *) 0}
34482378475aSmrg};
344995b296d0Smrg
34502378475aSmrg/* This works around a problem in FreeBSD linker */
34512378475aSmrg#ifdef FREEBSD_WORKAROUND
34522378475aSmrgstatic const void *lt_preloaded_setup() {
34532378475aSmrg  return lt_${my_prefix}_LTX_preloaded_symbols;
34542378475aSmrg}
34552378475aSmrg#endif
34562378475aSmrg
34572378475aSmrg#ifdef __cplusplus
34582378475aSmrg}
34592378475aSmrg#endif\
34602378475aSmrg"
34612378475aSmrg	} # !$opt_dry_run
34622378475aSmrg
34632378475aSmrg	pic_flag_for_symtable=
34642378475aSmrg	case "$compile_command " in
34652378475aSmrg	*" -static "*) ;;
34662378475aSmrg	*)
34672378475aSmrg	  case $host in
34682378475aSmrg	  # compiling the symbol table file with pic_flag works around
34692378475aSmrg	  # a FreeBSD bug that causes programs to crash when -lm is
34702378475aSmrg	  # linked before any other PIC object.  But we must not use
34712378475aSmrg	  # pic_flag when linking with -static.  The problem exists in
34722378475aSmrg	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
34732378475aSmrg	  *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
34742378475aSmrg	    pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
34752378475aSmrg	  *-*-hpux*)
34762378475aSmrg	    pic_flag_for_symtable=" $pic_flag"  ;;
34772378475aSmrg	  *)
34782378475aSmrg	    if test "X$my_pic_p" != Xno; then
34792378475aSmrg	      pic_flag_for_symtable=" $pic_flag"
3480e6f085baSmrg	    fi
34812378475aSmrg	    ;;
34822378475aSmrg	  esac
34832378475aSmrg	  ;;
34842378475aSmrg	esac
34852378475aSmrg	symtab_cflags=
34862378475aSmrg	for arg in $LTCFLAGS; do
34872378475aSmrg	  case $arg in
34882378475aSmrg	  -pie | -fpie | -fPIE) ;;
348914330f12Smrg	  *) func_append symtab_cflags " $arg" ;;
34902378475aSmrg	  esac
34912378475aSmrg	done
349295b296d0Smrg
34932378475aSmrg	# Now compile the dynamic symbol file.
34942378475aSmrg	func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
349539713583Smrg
34962378475aSmrg	# Clean up the generated files.
34972378475aSmrg	func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"'
349895b296d0Smrg
34992378475aSmrg	# Transform the symbol file into the correct name.
35002378475aSmrg	symfileobj="$output_objdir/${my_outputname}S.$objext"
35012378475aSmrg	case $host in
35022378475aSmrg	*cygwin* | *mingw* | *cegcc* )
35032378475aSmrg	  if test -f "$output_objdir/$my_outputname.def"; then
350414330f12Smrg	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
350514330f12Smrg	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
35062378475aSmrg	  else
350714330f12Smrg	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
350814330f12Smrg	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3509e6f085baSmrg	  fi
35102378475aSmrg	  ;;
35112378475aSmrg	*)
351214330f12Smrg	  compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
351314330f12Smrg	  finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
35142378475aSmrg	  ;;
35152378475aSmrg	esac
35162378475aSmrg	;;
35172378475aSmrg      *)
35182378475aSmrg	func_fatal_error "unknown suffix for \`$my_dlsyms'"
35192378475aSmrg	;;
35202378475aSmrg      esac
35212378475aSmrg    else
35222378475aSmrg      # We keep going just in case the user didn't refer to
35232378475aSmrg      # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
35242378475aSmrg      # really was required.
352595b296d0Smrg
35262378475aSmrg      # Nullify the symbol file.
352714330f12Smrg      compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
352814330f12Smrg      finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
35292378475aSmrg    fi
35302378475aSmrg}
353139713583Smrg
35322378475aSmrg# func_win32_libid arg
35332378475aSmrg# return the library type of file 'arg'
35342378475aSmrg#
35352378475aSmrg# Need a lot of goo to handle *both* DLLs and import libs
35362378475aSmrg# Has to be a shell function in order to 'eat' the argument
35372378475aSmrg# that is supplied when $file_magic_command is called.
353814330f12Smrg# Despite the name, also deal with 64 bit binaries.
35392378475aSmrgfunc_win32_libid ()
35402378475aSmrg{
35412378475aSmrg  $opt_debug
35422378475aSmrg  win32_libid_type="unknown"
35432378475aSmrg  win32_fileres=`file -L $1 2>/dev/null`
35442378475aSmrg  case $win32_fileres in
35452378475aSmrg  *ar\ archive\ import\ library*) # definitely import
35462378475aSmrg    win32_libid_type="x86 archive import"
35472378475aSmrg    ;;
35482378475aSmrg  *ar\ archive*) # could be an import, or static
354914330f12Smrg    # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
35502378475aSmrg    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
355114330f12Smrg       $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
355214330f12Smrg      func_to_tool_file "$1" func_convert_file_msys_to_w32
355314330f12Smrg      win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
35542378475aSmrg	$SED -n -e '
35552378475aSmrg	    1,100{
35562378475aSmrg		/ I /{
35572378475aSmrg		    s,.*,import,
35582378475aSmrg		    p
35592378475aSmrg		    q
35602378475aSmrg		}
35612378475aSmrg	    }'`
35622378475aSmrg      case $win32_nmres in
35632378475aSmrg      import*)  win32_libid_type="x86 archive import";;
35642378475aSmrg      *)        win32_libid_type="x86 archive static";;
35652378475aSmrg      esac
35662378475aSmrg    fi
35672378475aSmrg    ;;
35682378475aSmrg  *DLL*)
35692378475aSmrg    win32_libid_type="x86 DLL"
35702378475aSmrg    ;;
35712378475aSmrg  *executable*) # but shell scripts are "executable" too...
35722378475aSmrg    case $win32_fileres in
35732378475aSmrg    *MS\ Windows\ PE\ Intel*)
35742378475aSmrg      win32_libid_type="x86 DLL"
35752378475aSmrg      ;;
35762378475aSmrg    esac
35772378475aSmrg    ;;
35782378475aSmrg  esac
35792378475aSmrg  $ECHO "$win32_libid_type"
35802378475aSmrg}
358139713583Smrg
358214330f12Smrg# func_cygming_dll_for_implib ARG
358314330f12Smrg#
358414330f12Smrg# Platform-specific function to extract the
358514330f12Smrg# name of the DLL associated with the specified
358614330f12Smrg# import library ARG.
358714330f12Smrg# Invoked by eval'ing the libtool variable
358814330f12Smrg#    $sharedlib_from_linklib_cmd
358914330f12Smrg# Result is available in the variable
359014330f12Smrg#    $sharedlib_from_linklib_result
359114330f12Smrgfunc_cygming_dll_for_implib ()
359214330f12Smrg{
359314330f12Smrg  $opt_debug
359414330f12Smrg  sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
359514330f12Smrg}
359614330f12Smrg
359714330f12Smrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs
359814330f12Smrg#
359914330f12Smrg# The is the core of a fallback implementation of a
360014330f12Smrg# platform-specific function to extract the name of the
360114330f12Smrg# DLL associated with the specified import library LIBNAME.
360214330f12Smrg#
360314330f12Smrg# SECTION_NAME is either .idata$6 or .idata$7, depending
360414330f12Smrg# on the platform and compiler that created the implib.
360514330f12Smrg#
360614330f12Smrg# Echos the name of the DLL associated with the
360714330f12Smrg# specified import library.
360814330f12Smrgfunc_cygming_dll_for_implib_fallback_core ()
360914330f12Smrg{
361014330f12Smrg  $opt_debug
361114330f12Smrg  match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
361214330f12Smrg  $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
361314330f12Smrg    $SED '/^Contents of section '"$match_literal"':/{
361414330f12Smrg      # Place marker at beginning of archive member dllname section
361514330f12Smrg      s/.*/====MARK====/
361614330f12Smrg      p
361714330f12Smrg      d
361814330f12Smrg    }
361914330f12Smrg    # These lines can sometimes be longer than 43 characters, but
362014330f12Smrg    # are always uninteresting
362114330f12Smrg    /:[	 ]*file format pe[i]\{,1\}-/d
362214330f12Smrg    /^In archive [^:]*:/d
362314330f12Smrg    # Ensure marker is printed
362414330f12Smrg    /^====MARK====/p
362514330f12Smrg    # Remove all lines with less than 43 characters
362614330f12Smrg    /^.\{43\}/!d
362714330f12Smrg    # From remaining lines, remove first 43 characters
362814330f12Smrg    s/^.\{43\}//' |
362914330f12Smrg    $SED -n '
363014330f12Smrg      # Join marker and all lines until next marker into a single line
363114330f12Smrg      /^====MARK====/ b para
363214330f12Smrg      H
363314330f12Smrg      $ b para
363414330f12Smrg      b
363514330f12Smrg      :para
363614330f12Smrg      x
363714330f12Smrg      s/\n//g
363814330f12Smrg      # Remove the marker
363914330f12Smrg      s/^====MARK====//
364014330f12Smrg      # Remove trailing dots and whitespace
364114330f12Smrg      s/[\. \t]*$//
364214330f12Smrg      # Print
364314330f12Smrg      /./p' |
364414330f12Smrg    # we now have a list, one entry per line, of the stringified
364514330f12Smrg    # contents of the appropriate section of all members of the
364614330f12Smrg    # archive which possess that section. Heuristic: eliminate
364714330f12Smrg    # all those which have a first or second character that is
364814330f12Smrg    # a '.' (that is, objdump's representation of an unprintable
364914330f12Smrg    # character.) This should work for all archives with less than
365014330f12Smrg    # 0x302f exports -- but will fail for DLLs whose name actually
365114330f12Smrg    # begins with a literal '.' or a single character followed by
365214330f12Smrg    # a '.'.
365314330f12Smrg    #
365414330f12Smrg    # Of those that remain, print the first one.
365514330f12Smrg    $SED -e '/^\./d;/^.\./d;q'
365614330f12Smrg}
365714330f12Smrg
365814330f12Smrg# func_cygming_gnu_implib_p ARG
365914330f12Smrg# This predicate returns with zero status (TRUE) if
366014330f12Smrg# ARG is a GNU/binutils-style import library. Returns
366114330f12Smrg# with nonzero status (FALSE) otherwise.
366214330f12Smrgfunc_cygming_gnu_implib_p ()
366314330f12Smrg{
366414330f12Smrg  $opt_debug
366514330f12Smrg  func_to_tool_file "$1" func_convert_file_msys_to_w32
366614330f12Smrg  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)$'`
366714330f12Smrg  test -n "$func_cygming_gnu_implib_tmp"
366814330f12Smrg}
366914330f12Smrg
367014330f12Smrg# func_cygming_ms_implib_p ARG
367114330f12Smrg# This predicate returns with zero status (TRUE) if
367214330f12Smrg# ARG is an MS-style import library. Returns
367314330f12Smrg# with nonzero status (FALSE) otherwise.
367414330f12Smrgfunc_cygming_ms_implib_p ()
367514330f12Smrg{
367614330f12Smrg  $opt_debug
367714330f12Smrg  func_to_tool_file "$1" func_convert_file_msys_to_w32
367814330f12Smrg  func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
367914330f12Smrg  test -n "$func_cygming_ms_implib_tmp"
368014330f12Smrg}
368114330f12Smrg
368214330f12Smrg# func_cygming_dll_for_implib_fallback ARG
368314330f12Smrg# Platform-specific function to extract the
368414330f12Smrg# name of the DLL associated with the specified
368514330f12Smrg# import library ARG.
368614330f12Smrg#
368714330f12Smrg# This fallback implementation is for use when $DLLTOOL
368814330f12Smrg# does not support the --identify-strict option.
368914330f12Smrg# Invoked by eval'ing the libtool variable
369014330f12Smrg#    $sharedlib_from_linklib_cmd
369114330f12Smrg# Result is available in the variable
369214330f12Smrg#    $sharedlib_from_linklib_result
369314330f12Smrgfunc_cygming_dll_for_implib_fallback ()
369414330f12Smrg{
369514330f12Smrg  $opt_debug
369614330f12Smrg  if func_cygming_gnu_implib_p "$1" ; then
369714330f12Smrg    # binutils import library
369814330f12Smrg    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
369914330f12Smrg  elif func_cygming_ms_implib_p "$1" ; then
370014330f12Smrg    # ms-generated import library
370114330f12Smrg    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
370214330f12Smrg  else
370314330f12Smrg    # unknown
370414330f12Smrg    sharedlib_from_linklib_result=""
370514330f12Smrg  fi
370614330f12Smrg}
370739713583Smrg
370839713583Smrg
37092378475aSmrg# func_extract_an_archive dir oldlib
37102378475aSmrgfunc_extract_an_archive ()
37112378475aSmrg{
37122378475aSmrg    $opt_debug
37132378475aSmrg    f_ex_an_ar_dir="$1"; shift
37142378475aSmrg    f_ex_an_ar_oldlib="$1"
371514330f12Smrg    if test "$lock_old_archive_extraction" = yes; then
371614330f12Smrg      lockfile=$f_ex_an_ar_oldlib.lock
371714330f12Smrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
371814330f12Smrg	func_echo "Waiting for $lockfile to be removed"
371914330f12Smrg	sleep 2
372014330f12Smrg      done
372114330f12Smrg    fi
372214330f12Smrg    func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
372314330f12Smrg		   'stat=$?; rm -f "$lockfile"; exit $stat'
372414330f12Smrg    if test "$lock_old_archive_extraction" = yes; then
372514330f12Smrg      $opt_dry_run || rm -f "$lockfile"
372614330f12Smrg    fi
37272378475aSmrg    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
37282378475aSmrg     :
37292378475aSmrg    else
37302378475aSmrg      func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
37312378475aSmrg    fi
37322378475aSmrg}
373395b296d0Smrg
373495b296d0Smrg
37352378475aSmrg# func_extract_archives gentop oldlib ...
37362378475aSmrgfunc_extract_archives ()
37372378475aSmrg{
37382378475aSmrg    $opt_debug
37392378475aSmrg    my_gentop="$1"; shift
37402378475aSmrg    my_oldlibs=${1+"$@"}
37412378475aSmrg    my_oldobjs=""
37422378475aSmrg    my_xlib=""
37432378475aSmrg    my_xabs=""
37442378475aSmrg    my_xdir=""
374595b296d0Smrg
37462378475aSmrg    for my_xlib in $my_oldlibs; do
37472378475aSmrg      # Extract the objects.
37482378475aSmrg      case $my_xlib in
37492378475aSmrg	[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
37502378475aSmrg	*) my_xabs=`pwd`"/$my_xlib" ;;
37512378475aSmrg      esac
37522378475aSmrg      func_basename "$my_xlib"
37532378475aSmrg      my_xlib="$func_basename_result"
37542378475aSmrg      my_xlib_u=$my_xlib
37552378475aSmrg      while :; do
37562378475aSmrg        case " $extracted_archives " in
37572378475aSmrg	*" $my_xlib_u "*)
37582378475aSmrg	  func_arith $extracted_serial + 1
37592378475aSmrg	  extracted_serial=$func_arith_result
37602378475aSmrg	  my_xlib_u=lt$extracted_serial-$my_xlib ;;
37612378475aSmrg	*) break ;;
37622378475aSmrg	esac
37632378475aSmrg      done
37642378475aSmrg      extracted_archives="$extracted_archives $my_xlib_u"
37652378475aSmrg      my_xdir="$my_gentop/$my_xlib_u"
376695b296d0Smrg
37672378475aSmrg      func_mkdir_p "$my_xdir"
376839713583Smrg
37692378475aSmrg      case $host in
37702378475aSmrg      *-darwin*)
37712378475aSmrg	func_verbose "Extracting $my_xabs"
37722378475aSmrg	# Do not bother doing anything if just a dry run
37732378475aSmrg	$opt_dry_run || {
37742378475aSmrg	  darwin_orig_dir=`pwd`
37752378475aSmrg	  cd $my_xdir || exit $?
37762378475aSmrg	  darwin_archive=$my_xabs
37772378475aSmrg	  darwin_curdir=`pwd`
37782378475aSmrg	  darwin_base_archive=`basename "$darwin_archive"`
37792378475aSmrg	  darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
37802378475aSmrg	  if test -n "$darwin_arches"; then
37812378475aSmrg	    darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
37822378475aSmrg	    darwin_arch=
37832378475aSmrg	    func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
37842378475aSmrg	    for darwin_arch in  $darwin_arches ; do
37852378475aSmrg	      func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
37862378475aSmrg	      $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
37872378475aSmrg	      cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
37882378475aSmrg	      func_extract_an_archive "`pwd`" "${darwin_base_archive}"
37892378475aSmrg	      cd "$darwin_curdir"
37902378475aSmrg	      $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
37912378475aSmrg	    done # $darwin_arches
37922378475aSmrg            ## Okay now we've a bunch of thin objects, gotta fatten them up :)
37932378475aSmrg	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u`
37942378475aSmrg	    darwin_file=
37952378475aSmrg	    darwin_files=
37962378475aSmrg	    for darwin_file in $darwin_filelist; do
379714330f12Smrg	      darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`
37982378475aSmrg	      $LIPO -create -output "$darwin_file" $darwin_files
37992378475aSmrg	    done # $darwin_filelist
38002378475aSmrg	    $RM -rf unfat-$$
38012378475aSmrg	    cd "$darwin_orig_dir"
3802e6f085baSmrg	  else
38032378475aSmrg	    cd $darwin_orig_dir
38042378475aSmrg	    func_extract_an_archive "$my_xdir" "$my_xabs"
38052378475aSmrg	  fi # $darwin_arches
38062378475aSmrg	} # !$opt_dry_run
38072378475aSmrg	;;
38082378475aSmrg      *)
38092378475aSmrg        func_extract_an_archive "$my_xdir" "$my_xabs"
38102378475aSmrg	;;
38112378475aSmrg      esac
381214330f12Smrg      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
38132378475aSmrg    done
381495b296d0Smrg
38152378475aSmrg    func_extract_archives_result="$my_oldobjs"
38162378475aSmrg}
381795b296d0Smrg
381895b296d0Smrg
381914330f12Smrg# func_emit_wrapper [arg=no]
382014330f12Smrg#
382114330f12Smrg# Emit a libtool wrapper script on stdout.
382214330f12Smrg# Don't directly open a file because we may want to
382314330f12Smrg# incorporate the script contents within a cygwin/mingw
382414330f12Smrg# wrapper executable.  Must ONLY be called from within
382514330f12Smrg# func_mode_link because it depends on a number of variables
382614330f12Smrg# set therein.
38272378475aSmrg#
382814330f12Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
382914330f12Smrg# variable will take.  If 'yes', then the emitted script
383014330f12Smrg# will assume that the directory in which it is stored is
383114330f12Smrg# the $objdir directory.  This is a cygwin/mingw-specific
383214330f12Smrg# behavior.
383314330f12Smrgfunc_emit_wrapper ()
38342378475aSmrg{
383514330f12Smrg	func_emit_wrapper_arg1=${1-no}
3836e6f085baSmrg
38372378475aSmrg	$ECHO "\
38382378475aSmrg#! $SHELL
383995b296d0Smrg
38402378475aSmrg# $output - temporary wrapper script for $objdir/$outputname
38412378475aSmrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
38422378475aSmrg#
38432378475aSmrg# The $output program cannot be directly executed until all the libtool
38442378475aSmrg# libraries that it depends on are installed.
38452378475aSmrg#
38462378475aSmrg# This wrapper script should never be moved out of the build directory.
38472378475aSmrg# If it is, it will not operate correctly.
384895b296d0Smrg
38492378475aSmrg# Sed substitution that helps us do robust quoting.  It backslashifies
38502378475aSmrg# metacharacters that are still active within double-quoted strings.
38512378475aSmrgsed_quote_subst='$sed_quote_subst'
385295b296d0Smrg
38532378475aSmrg# Be Bourne compatible
38542378475aSmrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
38552378475aSmrg  emulate sh
38562378475aSmrg  NULLCMD=:
38572378475aSmrg  # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
38582378475aSmrg  # is contrary to our usage.  Disable this feature.
38592378475aSmrg  alias -g '\${1+\"\$@\"}'='\"\$@\"'
38602378475aSmrg  setopt NO_GLOB_SUBST
38612378475aSmrgelse
38622378475aSmrg  case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
38632378475aSmrgfi
38642378475aSmrgBIN_SH=xpg4; export BIN_SH # for Tru64
38652378475aSmrgDUALCASE=1; export DUALCASE # for MKS sh
386695b296d0Smrg
38672378475aSmrg# The HP-UX ksh and POSIX shell print the target directory to stdout
38682378475aSmrg# if CDPATH is set.
38692378475aSmrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
387095b296d0Smrg
38712378475aSmrgrelink_command=\"$relink_command\"
387295b296d0Smrg
38732378475aSmrg# This environment variable determines our operation mode.
38742378475aSmrgif test \"\$libtool_install_magic\" = \"$magic\"; then
38752378475aSmrg  # install mode needs the following variables:
38762378475aSmrg  generated_by_libtool_version='$macro_version'
38772378475aSmrg  notinst_deplibs='$notinst_deplibs'
38782378475aSmrgelse
38792378475aSmrg  # When we are sourced in execute mode, \$file and \$ECHO are already set.
38802378475aSmrg  if test \"\$libtool_execute_magic\" != \"$magic\"; then
388114330f12Smrg    file=\"\$0\""
388214330f12Smrg
388314330f12Smrg    qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"`
388414330f12Smrg    $ECHO "\
388514330f12Smrg
388614330f12Smrg# A function that is used when there is no print builtin or printf.
388714330f12Smrgfunc_fallback_echo ()
388814330f12Smrg{
388914330f12Smrg  eval 'cat <<_LTECHO_EOF
389014330f12Smrg\$1
389114330f12Smrg_LTECHO_EOF'
389214330f12Smrg}
389314330f12Smrg    ECHO=\"$qECHO\"
389414330f12Smrg  fi
389514330f12Smrg
389614330f12Smrg# Very basic option parsing. These options are (a) specific to
389714330f12Smrg# the libtool wrapper, (b) are identical between the wrapper
389814330f12Smrg# /script/ and the wrapper /executable/ which is used only on
389914330f12Smrg# windows platforms, and (c) all begin with the string "--lt-"
390014330f12Smrg# (application programs are unlikely to have options which match
390114330f12Smrg# this pattern).
390214330f12Smrg#
390314330f12Smrg# There are only two supported options: --lt-debug and
390414330f12Smrg# --lt-dump-script. There is, deliberately, no --lt-help.
390514330f12Smrg#
390614330f12Smrg# The first argument to this parsing function should be the
390714330f12Smrg# script's $0 value, followed by "$@".
390814330f12Smrglt_option_debug=
390914330f12Smrgfunc_parse_lt_options ()
391014330f12Smrg{
391114330f12Smrg  lt_script_arg0=\$0
391214330f12Smrg  shift
391314330f12Smrg  for lt_opt
391414330f12Smrg  do
391514330f12Smrg    case \"\$lt_opt\" in
391614330f12Smrg    --lt-debug) lt_option_debug=1 ;;
391714330f12Smrg    --lt-dump-script)
391814330f12Smrg        lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
391914330f12Smrg        test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
392014330f12Smrg        lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
392114330f12Smrg        cat \"\$lt_dump_D/\$lt_dump_F\"
392214330f12Smrg        exit 0
392314330f12Smrg      ;;
392414330f12Smrg    --lt-*)
392514330f12Smrg        \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
392614330f12Smrg        exit 1
392714330f12Smrg      ;;
392814330f12Smrg    esac
392914330f12Smrg  done
393014330f12Smrg
393114330f12Smrg  # Print the debug banner immediately:
393214330f12Smrg  if test -n \"\$lt_option_debug\"; then
393314330f12Smrg    echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2
393414330f12Smrg  fi
393514330f12Smrg}
393614330f12Smrg
393714330f12Smrg# Used when --lt-debug. Prints its arguments to stdout
393814330f12Smrg# (redirection is the responsibility of the caller)
393914330f12Smrgfunc_lt_dump_args ()
394014330f12Smrg{
394114330f12Smrg  lt_dump_args_N=1;
394214330f12Smrg  for lt_arg
394314330f12Smrg  do
394414330f12Smrg    \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\"
394514330f12Smrg    lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
394614330f12Smrg  done
394714330f12Smrg}
394814330f12Smrg
394914330f12Smrg# Core function for launching the target application
395014330f12Smrgfunc_exec_program_core ()
395114330f12Smrg{
39522378475aSmrg"
395314330f12Smrg  case $host in
395414330f12Smrg  # Backslashes separate directories on plain windows
395514330f12Smrg  *-*-mingw | *-*-os2* | *-cegcc*)
395614330f12Smrg    $ECHO "\
395714330f12Smrg      if test -n \"\$lt_option_debug\"; then
395814330f12Smrg        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2
395914330f12Smrg        func_lt_dump_args \${1+\"\$@\"} 1>&2
396014330f12Smrg      fi
396114330f12Smrg      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
396214330f12Smrg"
396314330f12Smrg    ;;
396414330f12Smrg
396514330f12Smrg  *)
396614330f12Smrg    $ECHO "\
396714330f12Smrg      if test -n \"\$lt_option_debug\"; then
396814330f12Smrg        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2
396914330f12Smrg        func_lt_dump_args \${1+\"\$@\"} 1>&2
397014330f12Smrg      fi
397114330f12Smrg      exec \"\$progdir/\$program\" \${1+\"\$@\"}
397214330f12Smrg"
397314330f12Smrg    ;;
397414330f12Smrg  esac
397514330f12Smrg  $ECHO "\
397614330f12Smrg      \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
397714330f12Smrg      exit 1
397814330f12Smrg}
397914330f12Smrg
398014330f12Smrg# A function to encapsulate launching the target application
398114330f12Smrg# Strips options in the --lt-* namespace from \$@ and
398214330f12Smrg# launches target application with the remaining arguments.
398314330f12Smrgfunc_exec_program ()
398414330f12Smrg{
398514330f12Smrg  for lt_wr_arg
398614330f12Smrg  do
398714330f12Smrg    case \$lt_wr_arg in
398814330f12Smrg    --lt-*) ;;
398914330f12Smrg    *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
399014330f12Smrg    esac
399114330f12Smrg    shift
399214330f12Smrg  done
399314330f12Smrg  func_exec_program_core \${1+\"\$@\"}
399414330f12Smrg}
399514330f12Smrg
399614330f12Smrg  # Parse options
399714330f12Smrg  func_parse_lt_options \"\$0\" \${1+\"\$@\"}
399895b296d0Smrg
39992378475aSmrg  # Find the directory that this script lives in.
400014330f12Smrg  thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
40012378475aSmrg  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
400295b296d0Smrg
40032378475aSmrg  # Follow symbolic links until we get to the real thisdir.
400414330f12Smrg  file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
40052378475aSmrg  while test -n \"\$file\"; do
400614330f12Smrg    destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
400795b296d0Smrg
40082378475aSmrg    # If there was a directory component, then change thisdir.
40092378475aSmrg    if test \"x\$destdir\" != \"x\$file\"; then
40102378475aSmrg      case \"\$destdir\" in
40112378475aSmrg      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
40122378475aSmrg      *) thisdir=\"\$thisdir/\$destdir\" ;;
4013e6f085baSmrg      esac
40142378475aSmrg    fi
401595b296d0Smrg
401614330f12Smrg    file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
401714330f12Smrg    file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
40182378475aSmrg  done
401995b296d0Smrg
40202378475aSmrg  # Usually 'no', except on cygwin/mingw when embedded into
40212378475aSmrg  # the cwrapper.
402214330f12Smrg  WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
40232378475aSmrg  if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
40242378475aSmrg    # special case for '.'
40252378475aSmrg    if test \"\$thisdir\" = \".\"; then
40262378475aSmrg      thisdir=\`pwd\`
40272378475aSmrg    fi
40282378475aSmrg    # remove .libs from thisdir
40292378475aSmrg    case \"\$thisdir\" in
403014330f12Smrg    *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
40312378475aSmrg    $objdir )   thisdir=. ;;
40322378475aSmrg    esac
40332378475aSmrg  fi
40342378475aSmrg
40352378475aSmrg  # Try to get the absolute directory name.
40362378475aSmrg  absdir=\`cd \"\$thisdir\" && pwd\`
40372378475aSmrg  test -n \"\$absdir\" && thisdir=\"\$absdir\"
40382378475aSmrg"
40392378475aSmrg
40402378475aSmrg	if test "$fast_install" = yes; then
40412378475aSmrg	  $ECHO "\
40422378475aSmrg  program=lt-'$outputname'$exeext
40432378475aSmrg  progdir=\"\$thisdir/$objdir\"
40442378475aSmrg
40452378475aSmrg  if test ! -f \"\$progdir/\$program\" ||
40462378475aSmrg     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
40472378475aSmrg       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
40482378475aSmrg
40492378475aSmrg    file=\"\$\$-\$program\"
40502378475aSmrg
40512378475aSmrg    if test ! -d \"\$progdir\"; then
40522378475aSmrg      $MKDIR \"\$progdir\"
40532378475aSmrg    else
40542378475aSmrg      $RM \"\$progdir/\$file\"
40552378475aSmrg    fi"
40562378475aSmrg
40572378475aSmrg	  $ECHO "\
40582378475aSmrg
40592378475aSmrg    # relink executable if necessary
40602378475aSmrg    if test -n \"\$relink_command\"; then
40612378475aSmrg      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
40622378475aSmrg      else
40632378475aSmrg	$ECHO \"\$relink_command_output\" >&2
40642378475aSmrg	$RM \"\$progdir/\$file\"
40652378475aSmrg	exit 1
4066e6f085baSmrg      fi
40672378475aSmrg    fi
406895b296d0Smrg
40692378475aSmrg    $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
40702378475aSmrg    { $RM \"\$progdir/\$program\";
40712378475aSmrg      $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
40722378475aSmrg    $RM \"\$progdir/\$file\"
40732378475aSmrg  fi"
40742378475aSmrg	else
40752378475aSmrg	  $ECHO "\
40762378475aSmrg  program='$outputname'
40772378475aSmrg  progdir=\"\$thisdir/$objdir\"
40782378475aSmrg"
4079e6f085baSmrg	fi
408095b296d0Smrg
40812378475aSmrg	$ECHO "\
408295b296d0Smrg
40832378475aSmrg  if test -f \"\$progdir/\$program\"; then"
408495b296d0Smrg
408514330f12Smrg	# fixup the dll searchpath if we need to.
408614330f12Smrg	#
408714330f12Smrg	# Fix the DLL searchpath if we need to.  Do this before prepending
408814330f12Smrg	# to shlibpath, because on Windows, both are PATH and uninstalled
408914330f12Smrg	# libraries must come first.
409014330f12Smrg	if test -n "$dllsearchpath"; then
409114330f12Smrg	  $ECHO "\
409214330f12Smrg    # Add the dll search path components to the executable PATH
409314330f12Smrg    PATH=$dllsearchpath:\$PATH
409414330f12Smrg"
409514330f12Smrg	fi
409614330f12Smrg
40972378475aSmrg	# Export our shlibpath_var if we have one.
40982378475aSmrg	if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
40992378475aSmrg	  $ECHO "\
41002378475aSmrg    # Add our own library path to $shlibpath_var
41012378475aSmrg    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
41022378475aSmrg
41032378475aSmrg    # Some systems cannot cope with colon-terminated $shlibpath_var
41042378475aSmrg    # The second colon is a workaround for a bug in BeOS R4 sed
410514330f12Smrg    $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
410695b296d0Smrg
41072378475aSmrg    export $shlibpath_var
41082378475aSmrg"
4109e6f085baSmrg	fi
411095b296d0Smrg
41112378475aSmrg	$ECHO "\
41122378475aSmrg    if test \"\$libtool_execute_magic\" != \"$magic\"; then
41132378475aSmrg      # Run the actual program with our arguments.
411414330f12Smrg      func_exec_program \${1+\"\$@\"}
41152378475aSmrg    fi
41162378475aSmrg  else
41172378475aSmrg    # The program doesn't exist.
41182378475aSmrg    \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
41192378475aSmrg    \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
412014330f12Smrg    \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
41212378475aSmrg    exit 1
41222378475aSmrg  fi
41232378475aSmrgfi\
41242378475aSmrg"
41252378475aSmrg}
412695b296d0Smrg
412739713583Smrg
41282378475aSmrg# func_emit_cwrapperexe_src
41292378475aSmrg# emit the source code for a wrapper executable on stdout
41302378475aSmrg# Must ONLY be called from within func_mode_link because
41312378475aSmrg# it depends on a number of variable set therein.
41322378475aSmrgfunc_emit_cwrapperexe_src ()
41332378475aSmrg{
41342378475aSmrg	cat <<EOF
413595b296d0Smrg
41362378475aSmrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
41372378475aSmrg   Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
413895b296d0Smrg
41392378475aSmrg   The $output program cannot be directly executed until all the libtool
41402378475aSmrg   libraries that it depends on are installed.
414195b296d0Smrg
41422378475aSmrg   This wrapper executable should never be moved out of the build directory.
41432378475aSmrg   If it is, it will not operate correctly.
41442378475aSmrg*/
41452378475aSmrgEOF
41462378475aSmrg	    cat <<"EOF"
414714330f12Smrg#ifdef _MSC_VER
414814330f12Smrg# define _CRT_SECURE_NO_DEPRECATE 1
414914330f12Smrg#endif
41502378475aSmrg#include <stdio.h>
41512378475aSmrg#include <stdlib.h>
41522378475aSmrg#ifdef _MSC_VER
41532378475aSmrg# include <direct.h>
41542378475aSmrg# include <process.h>
41552378475aSmrg# include <io.h>
41562378475aSmrg#else
41572378475aSmrg# include <unistd.h>
41582378475aSmrg# include <stdint.h>
41592378475aSmrg# ifdef __CYGWIN__
41602378475aSmrg#  include <io.h>
41612378475aSmrg# endif
41622378475aSmrg#endif
41632378475aSmrg#include <malloc.h>
41642378475aSmrg#include <stdarg.h>
41652378475aSmrg#include <assert.h>
41662378475aSmrg#include <string.h>
41672378475aSmrg#include <ctype.h>
41682378475aSmrg#include <errno.h>
41692378475aSmrg#include <fcntl.h>
41702378475aSmrg#include <sys/stat.h>
417195b296d0Smrg
417214330f12Smrg/* declarations of non-ANSI functions */
417314330f12Smrg#if defined(__MINGW32__)
417414330f12Smrg# ifdef __STRICT_ANSI__
417514330f12Smrgint _putenv (const char *);
417614330f12Smrg# endif
417714330f12Smrg#elif defined(__CYGWIN__)
417814330f12Smrg# ifdef __STRICT_ANSI__
417914330f12Smrgchar *realpath (const char *, char *);
418014330f12Smrgint putenv (char *);
418114330f12Smrgint setenv (const char *, const char *, int);
418214330f12Smrg# endif
418314330f12Smrg/* #elif defined (other platforms) ... */
418414330f12Smrg#endif
418514330f12Smrg
418614330f12Smrg/* portability defines, excluding path handling macros */
418714330f12Smrg#if defined(_MSC_VER)
418814330f12Smrg# define setmode _setmode
418914330f12Smrg# define stat    _stat
419014330f12Smrg# define chmod   _chmod
419114330f12Smrg# define getcwd  _getcwd
419214330f12Smrg# define putenv  _putenv
419314330f12Smrg# define S_IXUSR _S_IEXEC
419414330f12Smrg# ifndef _INTPTR_T_DEFINED
419514330f12Smrg#  define _INTPTR_T_DEFINED
419614330f12Smrg#  define intptr_t int
419714330f12Smrg# endif
419814330f12Smrg#elif defined(__MINGW32__)
419914330f12Smrg# define setmode _setmode
420014330f12Smrg# define stat    _stat
420114330f12Smrg# define chmod   _chmod
420214330f12Smrg# define getcwd  _getcwd
420314330f12Smrg# define putenv  _putenv
420414330f12Smrg#elif defined(__CYGWIN__)
420514330f12Smrg# define HAVE_SETENV
420614330f12Smrg# define FOPEN_WB "wb"
420714330f12Smrg/* #elif defined (other platforms) ... */
420814330f12Smrg#endif
420914330f12Smrg
42102378475aSmrg#if defined(PATH_MAX)
42112378475aSmrg# define LT_PATHMAX PATH_MAX
42122378475aSmrg#elif defined(MAXPATHLEN)
42132378475aSmrg# define LT_PATHMAX MAXPATHLEN
42142378475aSmrg#else
42152378475aSmrg# define LT_PATHMAX 1024
42162378475aSmrg#endif
421795b296d0Smrg
42182378475aSmrg#ifndef S_IXOTH
42192378475aSmrg# define S_IXOTH 0
42202378475aSmrg#endif
42212378475aSmrg#ifndef S_IXGRP
42222378475aSmrg# define S_IXGRP 0
42232378475aSmrg#endif
422495b296d0Smrg
422514330f12Smrg/* path handling portability macros */
42262378475aSmrg#ifndef DIR_SEPARATOR
42272378475aSmrg# define DIR_SEPARATOR '/'
42282378475aSmrg# define PATH_SEPARATOR ':'
42292378475aSmrg#endif
423095b296d0Smrg
42312378475aSmrg#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
42322378475aSmrg  defined (__OS2__)
42332378475aSmrg# define HAVE_DOS_BASED_FILE_SYSTEM
42342378475aSmrg# define FOPEN_WB "wb"
42352378475aSmrg# ifndef DIR_SEPARATOR_2
42362378475aSmrg#  define DIR_SEPARATOR_2 '\\'
42372378475aSmrg# endif
42382378475aSmrg# ifndef PATH_SEPARATOR_2
42392378475aSmrg#  define PATH_SEPARATOR_2 ';'
42402378475aSmrg# endif
42412378475aSmrg#endif
424295b296d0Smrg
42432378475aSmrg#ifndef DIR_SEPARATOR_2
42442378475aSmrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
42452378475aSmrg#else /* DIR_SEPARATOR_2 */
42462378475aSmrg# define IS_DIR_SEPARATOR(ch) \
42472378475aSmrg	(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
42482378475aSmrg#endif /* DIR_SEPARATOR_2 */
424995b296d0Smrg
42502378475aSmrg#ifndef PATH_SEPARATOR_2
42512378475aSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
42522378475aSmrg#else /* PATH_SEPARATOR_2 */
42532378475aSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
42542378475aSmrg#endif /* PATH_SEPARATOR_2 */
425595b296d0Smrg
42562378475aSmrg#ifndef FOPEN_WB
42572378475aSmrg# define FOPEN_WB "w"
42582378475aSmrg#endif
42592378475aSmrg#ifndef _O_BINARY
42602378475aSmrg# define _O_BINARY 0
42612378475aSmrg#endif
426295b296d0Smrg
42632378475aSmrg#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
42642378475aSmrg#define XFREE(stale) do { \
42652378475aSmrg  if (stale) { free ((void *) stale); stale = 0; } \
42662378475aSmrg} while (0)
426795b296d0Smrg
426814330f12Smrg#if defined(LT_DEBUGWRAPPER)
426914330f12Smrgstatic int lt_debug = 1;
42702378475aSmrg#else
427114330f12Smrgstatic int lt_debug = 0;
42722378475aSmrg#endif
427395b296d0Smrg
427414330f12Smrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */
427595b296d0Smrg
42762378475aSmrgvoid *xmalloc (size_t num);
42772378475aSmrgchar *xstrdup (const char *string);
42782378475aSmrgconst char *base_name (const char *name);
42792378475aSmrgchar *find_executable (const char *wrapper);
42802378475aSmrgchar *chase_symlinks (const char *pathspec);
42812378475aSmrgint make_executable (const char *path);
42822378475aSmrgint check_executable (const char *path);
42832378475aSmrgchar *strendzap (char *str, const char *pat);
428414330f12Smrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...);
428514330f12Smrgvoid lt_fatal (const char *file, int line, const char *message, ...);
428614330f12Smrgstatic const char *nonnull (const char *s);
428714330f12Smrgstatic const char *nonempty (const char *s);
42882378475aSmrgvoid lt_setenv (const char *name, const char *value);
42892378475aSmrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end);
42902378475aSmrgvoid lt_update_exe_path (const char *name, const char *value);
42912378475aSmrgvoid lt_update_lib_path (const char *name, const char *value);
429214330f12Smrgchar **prepare_spawn (char **argv);
429314330f12Smrgvoid lt_dump_script (FILE *f);
42942378475aSmrgEOF
42952378475aSmrg
42962378475aSmrg	    cat <<EOF
429714330f12Smrgvolatile const char * MAGIC_EXE = "$magic_exe";
42982378475aSmrgconst char * LIB_PATH_VARNAME = "$shlibpath_var";
42992378475aSmrgEOF
430095b296d0Smrg
43012378475aSmrg	    if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
430214330f12Smrg              func_to_host_path "$temp_rpath"
43032378475aSmrg	      cat <<EOF
430414330f12Smrgconst char * LIB_PATH_VALUE   = "$func_to_host_path_result";
43052378475aSmrgEOF
43062378475aSmrg	    else
43072378475aSmrg	      cat <<"EOF"
43082378475aSmrgconst char * LIB_PATH_VALUE   = "";
43092378475aSmrgEOF
4310e6f085baSmrg	    fi
431195b296d0Smrg
43122378475aSmrg	    if test -n "$dllsearchpath"; then
431314330f12Smrg              func_to_host_path "$dllsearchpath:"
43142378475aSmrg	      cat <<EOF
43152378475aSmrgconst char * EXE_PATH_VARNAME = "PATH";
431614330f12Smrgconst char * EXE_PATH_VALUE   = "$func_to_host_path_result";
4317e6f085baSmrgEOF
4318e6f085baSmrg	    else
43192378475aSmrg	      cat <<"EOF"
43202378475aSmrgconst char * EXE_PATH_VARNAME = "";
43212378475aSmrgconst char * EXE_PATH_VALUE   = "";
43222378475aSmrgEOF
4323e6f085baSmrg	    fi
43242378475aSmrg
43252378475aSmrg	    if test "$fast_install" = yes; then
43262378475aSmrg	      cat <<EOF
43272378475aSmrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
43282378475aSmrgEOF
4329e6f085baSmrg	    else
43302378475aSmrg	      cat <<EOF
43312378475aSmrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
43322378475aSmrgEOF
4333e6f085baSmrg	    fi
433495b296d0Smrg
433595b296d0Smrg
43362378475aSmrg	    cat <<"EOF"
433795b296d0Smrg
43382378475aSmrg#define LTWRAPPER_OPTION_PREFIX         "--lt-"
433995b296d0Smrg
43402378475aSmrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
43412378475aSmrgstatic const char *dumpscript_opt       = LTWRAPPER_OPTION_PREFIX "dump-script";
434214330f12Smrgstatic const char *debug_opt            = LTWRAPPER_OPTION_PREFIX "debug";
434395b296d0Smrg
43442378475aSmrgint
43452378475aSmrgmain (int argc, char *argv[])
43462378475aSmrg{
43472378475aSmrg  char **newargz;
43482378475aSmrg  int  newargc;
43492378475aSmrg  char *tmp_pathspec;
43502378475aSmrg  char *actual_cwrapper_path;
43512378475aSmrg  char *actual_cwrapper_name;
43522378475aSmrg  char *target_name;
43532378475aSmrg  char *lt_argv_zero;
43542378475aSmrg  intptr_t rval = 127;
435595b296d0Smrg
43562378475aSmrg  int i;
435795b296d0Smrg
43582378475aSmrg  program_name = (char *) xstrdup (base_name (argv[0]));
435914330f12Smrg  newargz = XMALLOC (char *, argc + 1);
436095b296d0Smrg
436114330f12Smrg  /* very simple arg parsing; don't want to rely on getopt
436214330f12Smrg   * also, copy all non cwrapper options to newargz, except
436314330f12Smrg   * argz[0], which is handled differently
436414330f12Smrg   */
436514330f12Smrg  newargc=0;
43662378475aSmrg  for (i = 1; i < argc; i++)
43672378475aSmrg    {
43682378475aSmrg      if (strcmp (argv[i], dumpscript_opt) == 0)
43692378475aSmrg	{
43702378475aSmrgEOF
43712378475aSmrg	    case "$host" in
43722378475aSmrg	      *mingw* | *cygwin* )
43732378475aSmrg		# make stdout use "unix" line endings
43742378475aSmrg		echo "          setmode(1,_O_BINARY);"
43752378475aSmrg		;;
43762378475aSmrg	      esac
437795b296d0Smrg
43782378475aSmrg	    cat <<"EOF"
437914330f12Smrg	  lt_dump_script (stdout);
43802378475aSmrg	  return 0;
43812378475aSmrg	}
438214330f12Smrg      if (strcmp (argv[i], debug_opt) == 0)
438314330f12Smrg	{
438414330f12Smrg          lt_debug = 1;
438514330f12Smrg          continue;
438614330f12Smrg	}
438714330f12Smrg      if (strcmp (argv[i], ltwrapper_option_prefix) == 0)
438814330f12Smrg        {
438914330f12Smrg          /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
439014330f12Smrg             namespace, but it is not one of the ones we know about and
439114330f12Smrg             have already dealt with, above (inluding dump-script), then
439214330f12Smrg             report an error. Otherwise, targets might begin to believe
439314330f12Smrg             they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
439414330f12Smrg             namespace. The first time any user complains about this, we'll
439514330f12Smrg             need to make LTWRAPPER_OPTION_PREFIX a configure-time option
439614330f12Smrg             or a configure.ac-settable value.
439714330f12Smrg           */
439814330f12Smrg          lt_fatal (__FILE__, __LINE__,
439914330f12Smrg		    "unrecognized %s option: '%s'",
440014330f12Smrg                    ltwrapper_option_prefix, argv[i]);
440114330f12Smrg        }
440214330f12Smrg      /* otherwise ... */
440314330f12Smrg      newargz[++newargc] = xstrdup (argv[i]);
44042378475aSmrg    }
440514330f12Smrg  newargz[++newargc] = NULL;
440614330f12Smrg
440714330f12SmrgEOF
440814330f12Smrg	    cat <<EOF
440914330f12Smrg  /* The GNU banner must be the first non-error debug message */
441014330f12Smrg  lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\n");
441114330f12SmrgEOF
441214330f12Smrg	    cat <<"EOF"
441314330f12Smrg  lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
441414330f12Smrg  lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name);
441595b296d0Smrg
44162378475aSmrg  tmp_pathspec = find_executable (argv[0]);
44172378475aSmrg  if (tmp_pathspec == NULL)
441814330f12Smrg    lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]);
441914330f12Smrg  lt_debugprintf (__FILE__, __LINE__,
442014330f12Smrg                  "(main) found exe (before symlink chase) at: %s\n",
442114330f12Smrg		  tmp_pathspec);
44222378475aSmrg
44232378475aSmrg  actual_cwrapper_path = chase_symlinks (tmp_pathspec);
442414330f12Smrg  lt_debugprintf (__FILE__, __LINE__,
442514330f12Smrg                  "(main) found exe (after symlink chase) at: %s\n",
442614330f12Smrg		  actual_cwrapper_path);
44272378475aSmrg  XFREE (tmp_pathspec);
44282378475aSmrg
442914330f12Smrg  actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));
44302378475aSmrg  strendzap (actual_cwrapper_path, actual_cwrapper_name);
44312378475aSmrg
44322378475aSmrg  /* wrapper name transforms */
44332378475aSmrg  strendzap (actual_cwrapper_name, ".exe");
44342378475aSmrg  tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
44352378475aSmrg  XFREE (actual_cwrapper_name);
44362378475aSmrg  actual_cwrapper_name = tmp_pathspec;
44372378475aSmrg  tmp_pathspec = 0;
44382378475aSmrg
44392378475aSmrg  /* target_name transforms -- use actual target program name; might have lt- prefix */
44402378475aSmrg  target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
44412378475aSmrg  strendzap (target_name, ".exe");
44422378475aSmrg  tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
44432378475aSmrg  XFREE (target_name);
44442378475aSmrg  target_name = tmp_pathspec;
44452378475aSmrg  tmp_pathspec = 0;
44462378475aSmrg
444714330f12Smrg  lt_debugprintf (__FILE__, __LINE__,
444814330f12Smrg		  "(main) libtool target name: %s\n",
444914330f12Smrg		  target_name);
44502378475aSmrgEOF
445195b296d0Smrg
44522378475aSmrg	    cat <<EOF
44532378475aSmrg  newargz[0] =
44542378475aSmrg    XMALLOC (char, (strlen (actual_cwrapper_path) +
44552378475aSmrg		    strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
44562378475aSmrg  strcpy (newargz[0], actual_cwrapper_path);
44572378475aSmrg  strcat (newargz[0], "$objdir");
44582378475aSmrg  strcat (newargz[0], "/");
44592378475aSmrgEOF
446095b296d0Smrg
44612378475aSmrg	    cat <<"EOF"
44622378475aSmrg  /* stop here, and copy so we don't have to do this twice */
44632378475aSmrg  tmp_pathspec = xstrdup (newargz[0]);
446495b296d0Smrg
44652378475aSmrg  /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
44662378475aSmrg  strcat (newargz[0], actual_cwrapper_name);
446795b296d0Smrg
44682378475aSmrg  /* DO want the lt- prefix here if it exists, so use target_name */
44692378475aSmrg  lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
44702378475aSmrg  XFREE (tmp_pathspec);
44712378475aSmrg  tmp_pathspec = NULL;
44722378475aSmrgEOF
447395b296d0Smrg
44742378475aSmrg	    case $host_os in
44752378475aSmrg	      mingw*)
44762378475aSmrg	    cat <<"EOF"
44772378475aSmrg  {
44782378475aSmrg    char* p;
44792378475aSmrg    while ((p = strchr (newargz[0], '\\')) != NULL)
44802378475aSmrg      {
44812378475aSmrg	*p = '/';
44822378475aSmrg      }
44832378475aSmrg    while ((p = strchr (lt_argv_zero, '\\')) != NULL)
44842378475aSmrg      {
44852378475aSmrg	*p = '/';
44862378475aSmrg      }
44872378475aSmrg  }
44882378475aSmrgEOF
44892378475aSmrg	    ;;
44902378475aSmrg	    esac
449195b296d0Smrg
44922378475aSmrg	    cat <<"EOF"
44932378475aSmrg  XFREE (target_name);
44942378475aSmrg  XFREE (actual_cwrapper_path);
44952378475aSmrg  XFREE (actual_cwrapper_name);
449695b296d0Smrg
44972378475aSmrg  lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
44982378475aSmrg  lt_setenv ("DUALCASE", "1");  /* for MSK sh */
449914330f12Smrg  /* Update the DLL searchpath.  EXE_PATH_VALUE ($dllsearchpath) must
450014330f12Smrg     be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath)
450114330f12Smrg     because on Windows, both *_VARNAMEs are PATH but uninstalled
450214330f12Smrg     libraries must come first. */
45032378475aSmrg  lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
450414330f12Smrg  lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
450595b296d0Smrg
450614330f12Smrg  lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",
450714330f12Smrg		  nonnull (lt_argv_zero));
45082378475aSmrg  for (i = 0; i < newargc; i++)
45092378475aSmrg    {
451014330f12Smrg      lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n",
451114330f12Smrg		      i, nonnull (newargz[i]));
45122378475aSmrg    }
451395b296d0Smrg
45142378475aSmrgEOF
451595b296d0Smrg
45162378475aSmrg	    case $host_os in
45172378475aSmrg	      mingw*)
45182378475aSmrg		cat <<"EOF"
45192378475aSmrg  /* execv doesn't actually work on mingw as expected on unix */
452014330f12Smrg  newargz = prepare_spawn (newargz);
45212378475aSmrg  rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
45222378475aSmrg  if (rval == -1)
45232378475aSmrg    {
45242378475aSmrg      /* failed to start process */
452514330f12Smrg      lt_debugprintf (__FILE__, __LINE__,
452614330f12Smrg		      "(main) failed to launch target \"%s\": %s\n",
452714330f12Smrg		      lt_argv_zero, nonnull (strerror (errno)));
45282378475aSmrg      return 127;
45292378475aSmrg    }
45302378475aSmrg  return rval;
45312378475aSmrgEOF
45322378475aSmrg		;;
45332378475aSmrg	      *)
45342378475aSmrg		cat <<"EOF"
45352378475aSmrg  execv (lt_argv_zero, newargz);
45362378475aSmrg  return rval; /* =127, but avoids unused variable warning */
45372378475aSmrgEOF
45382378475aSmrg		;;
45392378475aSmrg	    esac
454095b296d0Smrg
45412378475aSmrg	    cat <<"EOF"
45422378475aSmrg}
454395b296d0Smrg
45442378475aSmrgvoid *
45452378475aSmrgxmalloc (size_t num)
45462378475aSmrg{
45472378475aSmrg  void *p = (void *) malloc (num);
45482378475aSmrg  if (!p)
454914330f12Smrg    lt_fatal (__FILE__, __LINE__, "memory exhausted");
455095b296d0Smrg
45512378475aSmrg  return p;
45522378475aSmrg}
455395b296d0Smrg
45542378475aSmrgchar *
45552378475aSmrgxstrdup (const char *string)
45562378475aSmrg{
45572378475aSmrg  return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
45582378475aSmrg			  string) : NULL;
45592378475aSmrg}
456095b296d0Smrg
45612378475aSmrgconst char *
45622378475aSmrgbase_name (const char *name)
45632378475aSmrg{
45642378475aSmrg  const char *base;
4565e6f085baSmrg
45662378475aSmrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
45672378475aSmrg  /* Skip over the disk name in MSDOS pathnames. */
45682378475aSmrg  if (isalpha ((unsigned char) name[0]) && name[1] == ':')
45692378475aSmrg    name += 2;
45702378475aSmrg#endif
4571e6f085baSmrg
45722378475aSmrg  for (base = name; *name; name++)
45732378475aSmrg    if (IS_DIR_SEPARATOR (*name))
45742378475aSmrg      base = name + 1;
45752378475aSmrg  return base;
45762378475aSmrg}
4577e6f085baSmrg
45782378475aSmrgint
45792378475aSmrgcheck_executable (const char *path)
45802378475aSmrg{
45812378475aSmrg  struct stat st;
4582e6f085baSmrg
458314330f12Smrg  lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n",
458414330f12Smrg                  nonempty (path));
45852378475aSmrg  if ((!path) || (!*path))
45862378475aSmrg    return 0;
4587e6f085baSmrg
45882378475aSmrg  if ((stat (path, &st) >= 0)
45892378475aSmrg      && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
45902378475aSmrg    return 1;
45912378475aSmrg  else
45922378475aSmrg    return 0;
45932378475aSmrg}
459495b296d0Smrg
45952378475aSmrgint
45962378475aSmrgmake_executable (const char *path)
45972378475aSmrg{
45982378475aSmrg  int rval = 0;
45992378475aSmrg  struct stat st;
460095b296d0Smrg
460114330f12Smrg  lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n",
460214330f12Smrg                  nonempty (path));
46032378475aSmrg  if ((!path) || (!*path))
46042378475aSmrg    return 0;
460539713583Smrg
46062378475aSmrg  if (stat (path, &st) >= 0)
46072378475aSmrg    {
46082378475aSmrg      rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
46092378475aSmrg    }
46102378475aSmrg  return rval;
46112378475aSmrg}
4612e6f085baSmrg
46132378475aSmrg/* Searches for the full path of the wrapper.  Returns
46142378475aSmrg   newly allocated full path name if found, NULL otherwise
46152378475aSmrg   Does not chase symlinks, even on platforms that support them.
46162378475aSmrg*/
46172378475aSmrgchar *
46182378475aSmrgfind_executable (const char *wrapper)
46192378475aSmrg{
46202378475aSmrg  int has_slash = 0;
46212378475aSmrg  const char *p;
46222378475aSmrg  const char *p_next;
46232378475aSmrg  /* static buffer for getcwd */
46242378475aSmrg  char tmp[LT_PATHMAX + 1];
46252378475aSmrg  int tmp_len;
46262378475aSmrg  char *concat_name;
4627e6f085baSmrg
462814330f12Smrg  lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
462914330f12Smrg                  nonempty (wrapper));
4630e6f085baSmrg
46312378475aSmrg  if ((wrapper == NULL) || (*wrapper == '\0'))
46322378475aSmrg    return NULL;
4633e6f085baSmrg
46342378475aSmrg  /* Absolute path? */
46352378475aSmrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
46362378475aSmrg  if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
46372378475aSmrg    {
46382378475aSmrg      concat_name = xstrdup (wrapper);
46392378475aSmrg      if (check_executable (concat_name))
46402378475aSmrg	return concat_name;
46412378475aSmrg      XFREE (concat_name);
46422378475aSmrg    }
46432378475aSmrg  else
46442378475aSmrg    {
46452378475aSmrg#endif
46462378475aSmrg      if (IS_DIR_SEPARATOR (wrapper[0]))
46472378475aSmrg	{
46482378475aSmrg	  concat_name = xstrdup (wrapper);
46492378475aSmrg	  if (check_executable (concat_name))
46502378475aSmrg	    return concat_name;
46512378475aSmrg	  XFREE (concat_name);
46522378475aSmrg	}
46532378475aSmrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
46542378475aSmrg    }
46552378475aSmrg#endif
465695b296d0Smrg
46572378475aSmrg  for (p = wrapper; *p; p++)
46582378475aSmrg    if (*p == '/')
46592378475aSmrg      {
46602378475aSmrg	has_slash = 1;
46612378475aSmrg	break;
46622378475aSmrg      }
46632378475aSmrg  if (!has_slash)
46642378475aSmrg    {
46652378475aSmrg      /* no slashes; search PATH */
46662378475aSmrg      const char *path = getenv ("PATH");
46672378475aSmrg      if (path != NULL)
46682378475aSmrg	{
46692378475aSmrg	  for (p = path; *p; p = p_next)
46702378475aSmrg	    {
46712378475aSmrg	      const char *q;
46722378475aSmrg	      size_t p_len;
46732378475aSmrg	      for (q = p; *q; q++)
46742378475aSmrg		if (IS_PATH_SEPARATOR (*q))
46752378475aSmrg		  break;
46762378475aSmrg	      p_len = q - p;
46772378475aSmrg	      p_next = (*q == '\0' ? q : q + 1);
46782378475aSmrg	      if (p_len == 0)
46792378475aSmrg		{
46802378475aSmrg		  /* empty path: current directory */
46812378475aSmrg		  if (getcwd (tmp, LT_PATHMAX) == NULL)
468214330f12Smrg		    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
468314330f12Smrg                              nonnull (strerror (errno)));
46842378475aSmrg		  tmp_len = strlen (tmp);
46852378475aSmrg		  concat_name =
46862378475aSmrg		    XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
46872378475aSmrg		  memcpy (concat_name, tmp, tmp_len);
46882378475aSmrg		  concat_name[tmp_len] = '/';
46892378475aSmrg		  strcpy (concat_name + tmp_len + 1, wrapper);
46902378475aSmrg		}
46912378475aSmrg	      else
46922378475aSmrg		{
46932378475aSmrg		  concat_name =
46942378475aSmrg		    XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
46952378475aSmrg		  memcpy (concat_name, p, p_len);
46962378475aSmrg		  concat_name[p_len] = '/';
46972378475aSmrg		  strcpy (concat_name + p_len + 1, wrapper);
46982378475aSmrg		}
46992378475aSmrg	      if (check_executable (concat_name))
47002378475aSmrg		return concat_name;
47012378475aSmrg	      XFREE (concat_name);
47022378475aSmrg	    }
47032378475aSmrg	}
47042378475aSmrg      /* not found in PATH; assume curdir */
47052378475aSmrg    }
47062378475aSmrg  /* Relative path | not found in path: prepend cwd */
47072378475aSmrg  if (getcwd (tmp, LT_PATHMAX) == NULL)
470814330f12Smrg    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
470914330f12Smrg              nonnull (strerror (errno)));
47102378475aSmrg  tmp_len = strlen (tmp);
47112378475aSmrg  concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
47122378475aSmrg  memcpy (concat_name, tmp, tmp_len);
47132378475aSmrg  concat_name[tmp_len] = '/';
47142378475aSmrg  strcpy (concat_name + tmp_len + 1, wrapper);
471595b296d0Smrg
47162378475aSmrg  if (check_executable (concat_name))
47172378475aSmrg    return concat_name;
47182378475aSmrg  XFREE (concat_name);
47192378475aSmrg  return NULL;
47202378475aSmrg}
472195b296d0Smrg
47222378475aSmrgchar *
47232378475aSmrgchase_symlinks (const char *pathspec)
47242378475aSmrg{
47252378475aSmrg#ifndef S_ISLNK
47262378475aSmrg  return xstrdup (pathspec);
47272378475aSmrg#else
47282378475aSmrg  char buf[LT_PATHMAX];
47292378475aSmrg  struct stat s;
47302378475aSmrg  char *tmp_pathspec = xstrdup (pathspec);
47312378475aSmrg  char *p;
47322378475aSmrg  int has_symlinks = 0;
47332378475aSmrg  while (strlen (tmp_pathspec) && !has_symlinks)
47342378475aSmrg    {
473514330f12Smrg      lt_debugprintf (__FILE__, __LINE__,
473614330f12Smrg		      "checking path component for symlinks: %s\n",
473714330f12Smrg		      tmp_pathspec);
47382378475aSmrg      if (lstat (tmp_pathspec, &s) == 0)
47392378475aSmrg	{
47402378475aSmrg	  if (S_ISLNK (s.st_mode) != 0)
47412378475aSmrg	    {
47422378475aSmrg	      has_symlinks = 1;
47432378475aSmrg	      break;
47442378475aSmrg	    }
474595b296d0Smrg
47462378475aSmrg	  /* search backwards for last DIR_SEPARATOR */
47472378475aSmrg	  p = tmp_pathspec + strlen (tmp_pathspec) - 1;
47482378475aSmrg	  while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
47492378475aSmrg	    p--;
47502378475aSmrg	  if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
47512378475aSmrg	    {
47522378475aSmrg	      /* no more DIR_SEPARATORS left */
47532378475aSmrg	      break;
47542378475aSmrg	    }
47552378475aSmrg	  *p = '\0';
47562378475aSmrg	}
47572378475aSmrg      else
47582378475aSmrg	{
475914330f12Smrg	  lt_fatal (__FILE__, __LINE__,
476014330f12Smrg		    "error accessing file \"%s\": %s",
476114330f12Smrg		    tmp_pathspec, nonnull (strerror (errno)));
47622378475aSmrg	}
47632378475aSmrg    }
47642378475aSmrg  XFREE (tmp_pathspec);
476595b296d0Smrg
47662378475aSmrg  if (!has_symlinks)
47672378475aSmrg    {
47682378475aSmrg      return xstrdup (pathspec);
47692378475aSmrg    }
477095b296d0Smrg
47712378475aSmrg  tmp_pathspec = realpath (pathspec, buf);
47722378475aSmrg  if (tmp_pathspec == 0)
47732378475aSmrg    {
477414330f12Smrg      lt_fatal (__FILE__, __LINE__,
477514330f12Smrg		"could not follow symlinks for %s", pathspec);
47762378475aSmrg    }
47772378475aSmrg  return xstrdup (tmp_pathspec);
47782378475aSmrg#endif
47792378475aSmrg}
478095b296d0Smrg
47812378475aSmrgchar *
47822378475aSmrgstrendzap (char *str, const char *pat)
47832378475aSmrg{
47842378475aSmrg  size_t len, patlen;
478595b296d0Smrg
47862378475aSmrg  assert (str != NULL);
47872378475aSmrg  assert (pat != NULL);
478895b296d0Smrg
47892378475aSmrg  len = strlen (str);
47902378475aSmrg  patlen = strlen (pat);
479195b296d0Smrg
47922378475aSmrg  if (patlen <= len)
47932378475aSmrg    {
47942378475aSmrg      str += len - patlen;
47952378475aSmrg      if (strcmp (str, pat) == 0)
47962378475aSmrg	*str = '\0';
47972378475aSmrg    }
47982378475aSmrg  return str;
47992378475aSmrg}
480095b296d0Smrg
480114330f12Smrgvoid
480214330f12Smrglt_debugprintf (const char *file, int line, const char *fmt, ...)
480314330f12Smrg{
480414330f12Smrg  va_list args;
480514330f12Smrg  if (lt_debug)
480614330f12Smrg    {
480714330f12Smrg      (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line);
480814330f12Smrg      va_start (args, fmt);
480914330f12Smrg      (void) vfprintf (stderr, fmt, args);
481014330f12Smrg      va_end (args);
481114330f12Smrg    }
481214330f12Smrg}
481314330f12Smrg
48142378475aSmrgstatic void
481514330f12Smrglt_error_core (int exit_status, const char *file,
481614330f12Smrg	       int line, const char *mode,
48172378475aSmrg	       const char *message, va_list ap)
48182378475aSmrg{
481914330f12Smrg  fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode);
48202378475aSmrg  vfprintf (stderr, message, ap);
48212378475aSmrg  fprintf (stderr, ".\n");
482295b296d0Smrg
48232378475aSmrg  if (exit_status >= 0)
48242378475aSmrg    exit (exit_status);
48252378475aSmrg}
482695b296d0Smrg
48272378475aSmrgvoid
482814330f12Smrglt_fatal (const char *file, int line, const char *message, ...)
48292378475aSmrg{
48302378475aSmrg  va_list ap;
48312378475aSmrg  va_start (ap, message);
483214330f12Smrg  lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap);
48332378475aSmrg  va_end (ap);
48342378475aSmrg}
483595b296d0Smrg
483614330f12Smrgstatic const char *
483714330f12Smrgnonnull (const char *s)
483814330f12Smrg{
483914330f12Smrg  return s ? s : "(null)";
484014330f12Smrg}
484114330f12Smrg
484214330f12Smrgstatic const char *
484314330f12Smrgnonempty (const char *s)
484414330f12Smrg{
484514330f12Smrg  return (s && !*s) ? "(empty)" : nonnull (s);
484614330f12Smrg}
484714330f12Smrg
48482378475aSmrgvoid
48492378475aSmrglt_setenv (const char *name, const char *value)
48502378475aSmrg{
485114330f12Smrg  lt_debugprintf (__FILE__, __LINE__,
485214330f12Smrg		  "(lt_setenv) setting '%s' to '%s'\n",
485314330f12Smrg                  nonnull (name), nonnull (value));
48542378475aSmrg  {
48552378475aSmrg#ifdef HAVE_SETENV
48562378475aSmrg    /* always make a copy, for consistency with !HAVE_SETENV */
48572378475aSmrg    char *str = xstrdup (value);
48582378475aSmrg    setenv (name, str, 1);
48592378475aSmrg#else
48602378475aSmrg    int len = strlen (name) + 1 + strlen (value) + 1;
48612378475aSmrg    char *str = XMALLOC (char, len);
48622378475aSmrg    sprintf (str, "%s=%s", name, value);
48632378475aSmrg    if (putenv (str) != EXIT_SUCCESS)
48642378475aSmrg      {
48652378475aSmrg        XFREE (str);
48662378475aSmrg      }
48672378475aSmrg#endif
48682378475aSmrg  }
48692378475aSmrg}
487095b296d0Smrg
48712378475aSmrgchar *
48722378475aSmrglt_extend_str (const char *orig_value, const char *add, int to_end)
48732378475aSmrg{
48742378475aSmrg  char *new_value;
48752378475aSmrg  if (orig_value && *orig_value)
48762378475aSmrg    {
48772378475aSmrg      int orig_value_len = strlen (orig_value);
48782378475aSmrg      int add_len = strlen (add);
48792378475aSmrg      new_value = XMALLOC (char, add_len + orig_value_len + 1);
48802378475aSmrg      if (to_end)
48812378475aSmrg        {
48822378475aSmrg          strcpy (new_value, orig_value);
48832378475aSmrg          strcpy (new_value + orig_value_len, add);
48842378475aSmrg        }
48852378475aSmrg      else
48862378475aSmrg        {
48872378475aSmrg          strcpy (new_value, add);
48882378475aSmrg          strcpy (new_value + add_len, orig_value);
48892378475aSmrg        }
48902378475aSmrg    }
48912378475aSmrg  else
48922378475aSmrg    {
48932378475aSmrg      new_value = xstrdup (add);
48942378475aSmrg    }
48952378475aSmrg  return new_value;
48962378475aSmrg}
489795b296d0Smrg
48982378475aSmrgvoid
48992378475aSmrglt_update_exe_path (const char *name, const char *value)
49002378475aSmrg{
490114330f12Smrg  lt_debugprintf (__FILE__, __LINE__,
490214330f12Smrg		  "(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
490314330f12Smrg                  nonnull (name), nonnull (value));
490495b296d0Smrg
49052378475aSmrg  if (name && *name && value && *value)
49062378475aSmrg    {
49072378475aSmrg      char *new_value = lt_extend_str (getenv (name), value, 0);
49082378475aSmrg      /* some systems can't cope with a ':'-terminated path #' */
49092378475aSmrg      int len = strlen (new_value);
49102378475aSmrg      while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
49112378475aSmrg        {
49122378475aSmrg          new_value[len-1] = '\0';
49132378475aSmrg        }
49142378475aSmrg      lt_setenv (name, new_value);
49152378475aSmrg      XFREE (new_value);
49162378475aSmrg    }
49172378475aSmrg}
491895b296d0Smrg
49192378475aSmrgvoid
49202378475aSmrglt_update_lib_path (const char *name, const char *value)
49212378475aSmrg{
492214330f12Smrg  lt_debugprintf (__FILE__, __LINE__,
492314330f12Smrg		  "(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
492414330f12Smrg                  nonnull (name), nonnull (value));
492595b296d0Smrg
49262378475aSmrg  if (name && *name && value && *value)
49272378475aSmrg    {
49282378475aSmrg      char *new_value = lt_extend_str (getenv (name), value, 0);
49292378475aSmrg      lt_setenv (name, new_value);
49302378475aSmrg      XFREE (new_value);
49312378475aSmrg    }
49322378475aSmrg}
493395b296d0Smrg
493414330f12SmrgEOF
493514330f12Smrg	    case $host_os in
493614330f12Smrg	      mingw*)
493714330f12Smrg		cat <<"EOF"
493814330f12Smrg
493914330f12Smrg/* Prepares an argument vector before calling spawn().
494014330f12Smrg   Note that spawn() does not by itself call the command interpreter
494114330f12Smrg     (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
494214330f12Smrg      ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
494314330f12Smrg         GetVersionEx(&v);
494414330f12Smrg         v.dwPlatformId == VER_PLATFORM_WIN32_NT;
494514330f12Smrg      }) ? "cmd.exe" : "command.com").
494614330f12Smrg   Instead it simply concatenates the arguments, separated by ' ', and calls
494714330f12Smrg   CreateProcess().  We must quote the arguments since Win32 CreateProcess()
494814330f12Smrg   interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
494914330f12Smrg   special way:
495014330f12Smrg   - Space and tab are interpreted as delimiters. They are not treated as
495114330f12Smrg     delimiters if they are surrounded by double quotes: "...".
495214330f12Smrg   - Unescaped double quotes are removed from the input. Their only effect is
495314330f12Smrg     that within double quotes, space and tab are treated like normal
495414330f12Smrg     characters.
495514330f12Smrg   - Backslashes not followed by double quotes are not special.
495614330f12Smrg   - But 2*n+1 backslashes followed by a double quote become
495714330f12Smrg     n backslashes followed by a double quote (n >= 0):
495814330f12Smrg       \" -> "
495914330f12Smrg       \\\" -> \"
496014330f12Smrg       \\\\\" -> \\"
496114330f12Smrg */
496214330f12Smrg#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"
496314330f12Smrg#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"
496414330f12Smrgchar **
496514330f12Smrgprepare_spawn (char **argv)
496614330f12Smrg{
496714330f12Smrg  size_t argc;
496814330f12Smrg  char **new_argv;
496914330f12Smrg  size_t i;
497014330f12Smrg
497114330f12Smrg  /* Count number of arguments.  */
497214330f12Smrg  for (argc = 0; argv[argc] != NULL; argc++)
497314330f12Smrg    ;
497414330f12Smrg
497514330f12Smrg  /* Allocate new argument vector.  */
497614330f12Smrg  new_argv = XMALLOC (char *, argc + 1);
497714330f12Smrg
497814330f12Smrg  /* Put quoted arguments into the new argument vector.  */
497914330f12Smrg  for (i = 0; i < argc; i++)
498014330f12Smrg    {
498114330f12Smrg      const char *string = argv[i];
498214330f12Smrg
498314330f12Smrg      if (string[0] == '\0')
498414330f12Smrg	new_argv[i] = xstrdup ("\"\"");
498514330f12Smrg      else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
498614330f12Smrg	{
498714330f12Smrg	  int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
498814330f12Smrg	  size_t length;
498914330f12Smrg	  unsigned int backslashes;
499014330f12Smrg	  const char *s;
499114330f12Smrg	  char *quoted_string;
499214330f12Smrg	  char *p;
499314330f12Smrg
499414330f12Smrg	  length = 0;
499514330f12Smrg	  backslashes = 0;
499614330f12Smrg	  if (quote_around)
499714330f12Smrg	    length++;
499814330f12Smrg	  for (s = string; *s != '\0'; s++)
499914330f12Smrg	    {
500014330f12Smrg	      char c = *s;
500114330f12Smrg	      if (c == '"')
500214330f12Smrg		length += backslashes + 1;
500314330f12Smrg	      length++;
500414330f12Smrg	      if (c == '\\')
500514330f12Smrg		backslashes++;
500614330f12Smrg	      else
500714330f12Smrg		backslashes = 0;
500814330f12Smrg	    }
500914330f12Smrg	  if (quote_around)
501014330f12Smrg	    length += backslashes + 1;
501114330f12Smrg
501214330f12Smrg	  quoted_string = XMALLOC (char, length + 1);
501314330f12Smrg
501414330f12Smrg	  p = quoted_string;
501514330f12Smrg	  backslashes = 0;
501614330f12Smrg	  if (quote_around)
501714330f12Smrg	    *p++ = '"';
501814330f12Smrg	  for (s = string; *s != '\0'; s++)
501914330f12Smrg	    {
502014330f12Smrg	      char c = *s;
502114330f12Smrg	      if (c == '"')
502214330f12Smrg		{
502314330f12Smrg		  unsigned int j;
502414330f12Smrg		  for (j = backslashes + 1; j > 0; j--)
502514330f12Smrg		    *p++ = '\\';
502614330f12Smrg		}
502714330f12Smrg	      *p++ = c;
502814330f12Smrg	      if (c == '\\')
502914330f12Smrg		backslashes++;
503014330f12Smrg	      else
503114330f12Smrg		backslashes = 0;
503214330f12Smrg	    }
503314330f12Smrg	  if (quote_around)
503414330f12Smrg	    {
503514330f12Smrg	      unsigned int j;
503614330f12Smrg	      for (j = backslashes; j > 0; j--)
503714330f12Smrg		*p++ = '\\';
503814330f12Smrg	      *p++ = '"';
503914330f12Smrg	    }
504014330f12Smrg	  *p = '\0';
504114330f12Smrg
504214330f12Smrg	  new_argv[i] = quoted_string;
504314330f12Smrg	}
504414330f12Smrg      else
504514330f12Smrg	new_argv[i] = (char *) string;
504614330f12Smrg    }
504714330f12Smrg  new_argv[argc] = NULL;
504814330f12Smrg
504914330f12Smrg  return new_argv;
505014330f12Smrg}
505114330f12SmrgEOF
505214330f12Smrg		;;
505314330f12Smrg	    esac
505414330f12Smrg
505514330f12Smrg            cat <<"EOF"
505614330f12Smrgvoid lt_dump_script (FILE* f)
505714330f12Smrg{
505814330f12SmrgEOF
505914330f12Smrg	    func_emit_wrapper yes |
506014330f12Smrg              $SED -e 's/\([\\"]\)/\\\1/g' \
506114330f12Smrg	           -e 's/^/  fputs ("/' -e 's/$/\\n", f);/'
506295b296d0Smrg
506314330f12Smrg            cat <<"EOF"
506414330f12Smrg}
50652378475aSmrgEOF
50662378475aSmrg}
50672378475aSmrg# end: func_emit_cwrapperexe_src
506895b296d0Smrg
506914330f12Smrg# func_win32_import_lib_p ARG
507014330f12Smrg# True if ARG is an import lib, as indicated by $file_magic_cmd
507114330f12Smrgfunc_win32_import_lib_p ()
507214330f12Smrg{
507314330f12Smrg    $opt_debug
507414330f12Smrg    case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
507514330f12Smrg    *import*) : ;;
507614330f12Smrg    *) false ;;
507714330f12Smrg    esac
507814330f12Smrg}
507914330f12Smrg
50802378475aSmrg# func_mode_link arg...
50812378475aSmrgfunc_mode_link ()
50822378475aSmrg{
50832378475aSmrg    $opt_debug
50842378475aSmrg    case $host in
50852378475aSmrg    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
50862378475aSmrg      # It is impossible to link a dll without this setting, and
50872378475aSmrg      # we shouldn't force the makefile maintainer to figure out
50882378475aSmrg      # which system we are compiling for in order to pass an extra
50892378475aSmrg      # flag for every libtool invocation.
50902378475aSmrg      # allow_undefined=no
509195b296d0Smrg
50922378475aSmrg      # FIXME: Unfortunately, there are problems with the above when trying
50932378475aSmrg      # to make a dll which has undefined symbols, in which case not
50942378475aSmrg      # even a static library is built.  For now, we need to specify
50952378475aSmrg      # -no-undefined on the libtool link line when we can be certain
50962378475aSmrg      # that all symbols are satisfied, otherwise we get a static library.
50972378475aSmrg      allow_undefined=yes
50982378475aSmrg      ;;
50992378475aSmrg    *)
51002378475aSmrg      allow_undefined=yes
51012378475aSmrg      ;;
51022378475aSmrg    esac
51032378475aSmrg    libtool_args=$nonopt
51042378475aSmrg    base_compile="$nonopt $@"
51052378475aSmrg    compile_command=$nonopt
51062378475aSmrg    finalize_command=$nonopt
510795b296d0Smrg
51082378475aSmrg    compile_rpath=
51092378475aSmrg    finalize_rpath=
51102378475aSmrg    compile_shlibpath=
51112378475aSmrg    finalize_shlibpath=
51122378475aSmrg    convenience=
51132378475aSmrg    old_convenience=
51142378475aSmrg    deplibs=
51152378475aSmrg    old_deplibs=
51162378475aSmrg    compiler_flags=
51172378475aSmrg    linker_flags=
51182378475aSmrg    dllsearchpath=
51192378475aSmrg    lib_search_path=`pwd`
51202378475aSmrg    inst_prefix_dir=
51212378475aSmrg    new_inherited_linker_flags=
512295b296d0Smrg
51232378475aSmrg    avoid_version=no
512414330f12Smrg    bindir=
51252378475aSmrg    dlfiles=
51262378475aSmrg    dlprefiles=
51272378475aSmrg    dlself=no
51282378475aSmrg    export_dynamic=no
51292378475aSmrg    export_symbols=
51302378475aSmrg    export_symbols_regex=
51312378475aSmrg    generated=
51322378475aSmrg    libobjs=
51332378475aSmrg    ltlibs=
51342378475aSmrg    module=no
51352378475aSmrg    no_install=no
51362378475aSmrg    objs=
51372378475aSmrg    non_pic_objects=
51382378475aSmrg    precious_files_regex=
51392378475aSmrg    prefer_static_libs=no
51402378475aSmrg    preload=no
51412378475aSmrg    prev=
51422378475aSmrg    prevarg=
51432378475aSmrg    release=
51442378475aSmrg    rpath=
51452378475aSmrg    xrpath=
51462378475aSmrg    perm_rpath=
51472378475aSmrg    temp_rpath=
51482378475aSmrg    thread_safe=no
51492378475aSmrg    vinfo=
51502378475aSmrg    vinfo_number=no
51512378475aSmrg    weak_libs=
51522378475aSmrg    single_module="${wl}-single_module"
51532378475aSmrg    func_infer_tag $base_compile
51542378475aSmrg
51552378475aSmrg    # We need to know -static, to get the right output filenames.
51562378475aSmrg    for arg
51572378475aSmrg    do
51582378475aSmrg      case $arg in
51592378475aSmrg      -shared)
51602378475aSmrg	test "$build_libtool_libs" != yes && \
51612378475aSmrg	  func_fatal_configuration "can not build a shared library"
51622378475aSmrg	build_old_libs=no
51632378475aSmrg	break
51642378475aSmrg	;;
51652378475aSmrg      -all-static | -static | -static-libtool-libs)
51662378475aSmrg	case $arg in
51672378475aSmrg	-all-static)
51682378475aSmrg	  if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
51692378475aSmrg	    func_warning "complete static linking is impossible in this configuration"
51702378475aSmrg	  fi
51712378475aSmrg	  if test -n "$link_static_flag"; then
51722378475aSmrg	    dlopen_self=$dlopen_self_static
51732378475aSmrg	  fi
51742378475aSmrg	  prefer_static_libs=yes
51752378475aSmrg	  ;;
51762378475aSmrg	-static)
51772378475aSmrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
51782378475aSmrg	    dlopen_self=$dlopen_self_static
51792378475aSmrg	  fi
51802378475aSmrg	  prefer_static_libs=built
51812378475aSmrg	  ;;
51822378475aSmrg	-static-libtool-libs)
51832378475aSmrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
51842378475aSmrg	    dlopen_self=$dlopen_self_static
5185e6f085baSmrg	  fi
51862378475aSmrg	  prefer_static_libs=yes
51872378475aSmrg	  ;;
51882378475aSmrg	esac
51892378475aSmrg	build_libtool_libs=no
51902378475aSmrg	build_old_libs=yes
51912378475aSmrg	break
51922378475aSmrg	;;
51932378475aSmrg      esac
51942378475aSmrg    done
519595b296d0Smrg
51962378475aSmrg    # See if our shared archives depend on static archives.
51972378475aSmrg    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
519895b296d0Smrg
51992378475aSmrg    # Go through the arguments, transforming them on the way.
52002378475aSmrg    while test "$#" -gt 0; do
52012378475aSmrg      arg="$1"
52022378475aSmrg      shift
52032378475aSmrg      func_quote_for_eval "$arg"
52042378475aSmrg      qarg=$func_quote_for_eval_unquoted_result
52052378475aSmrg      func_append libtool_args " $func_quote_for_eval_result"
520695b296d0Smrg
52072378475aSmrg      # If the previous option needs an argument, assign it.
52082378475aSmrg      if test -n "$prev"; then
52092378475aSmrg	case $prev in
52102378475aSmrg	output)
52112378475aSmrg	  func_append compile_command " @OUTPUT@"
52122378475aSmrg	  func_append finalize_command " @OUTPUT@"
52132378475aSmrg	  ;;
52142378475aSmrg	esac
521595b296d0Smrg
52162378475aSmrg	case $prev in
521714330f12Smrg	bindir)
521814330f12Smrg	  bindir="$arg"
521914330f12Smrg	  prev=
522014330f12Smrg	  continue
522114330f12Smrg	  ;;
52222378475aSmrg	dlfiles|dlprefiles)
52232378475aSmrg	  if test "$preload" = no; then
52242378475aSmrg	    # Add the symbol object into the linking commands.
52252378475aSmrg	    func_append compile_command " @SYMFILE@"
52262378475aSmrg	    func_append finalize_command " @SYMFILE@"
52272378475aSmrg	    preload=yes
52282378475aSmrg	  fi
52292378475aSmrg	  case $arg in
52302378475aSmrg	  *.la | *.lo) ;;  # We handle these cases below.
52312378475aSmrg	  force)
52322378475aSmrg	    if test "$dlself" = no; then
52332378475aSmrg	      dlself=needless
52342378475aSmrg	      export_dynamic=yes
52352378475aSmrg	    fi
52362378475aSmrg	    prev=
52372378475aSmrg	    continue
52382378475aSmrg	    ;;
52392378475aSmrg	  self)
52402378475aSmrg	    if test "$prev" = dlprefiles; then
52412378475aSmrg	      dlself=yes
52422378475aSmrg	    elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
52432378475aSmrg	      dlself=yes
5244e6f085baSmrg	    else
52452378475aSmrg	      dlself=needless
52462378475aSmrg	      export_dynamic=yes
5247e6f085baSmrg	    fi
52482378475aSmrg	    prev=
52492378475aSmrg	    continue
52502378475aSmrg	    ;;
52512378475aSmrg	  *)
52522378475aSmrg	    if test "$prev" = dlfiles; then
525314330f12Smrg	      func_append dlfiles " $arg"
5254e6f085baSmrg	    else
525514330f12Smrg	      func_append dlprefiles " $arg"
5256e6f085baSmrg	    fi
52572378475aSmrg	    prev=
52582378475aSmrg	    continue
52592378475aSmrg	    ;;
52602378475aSmrg	  esac
52612378475aSmrg	  ;;
52622378475aSmrg	expsyms)
52632378475aSmrg	  export_symbols="$arg"
52642378475aSmrg	  test -f "$arg" \
52652378475aSmrg	    || func_fatal_error "symbol file \`$arg' does not exist"
52662378475aSmrg	  prev=
52672378475aSmrg	  continue
52682378475aSmrg	  ;;
52692378475aSmrg	expsyms_regex)
52702378475aSmrg	  export_symbols_regex="$arg"
52712378475aSmrg	  prev=
52722378475aSmrg	  continue
52732378475aSmrg	  ;;
52742378475aSmrg	framework)
5275e6f085baSmrg	  case $host in
52762378475aSmrg	    *-*-darwin*)
52772378475aSmrg	      case "$deplibs " in
52782378475aSmrg		*" $qarg.ltframework "*) ;;
527914330f12Smrg		*) func_append deplibs " $qarg.ltframework" # this is fixed later
52802378475aSmrg		   ;;
52812378475aSmrg	      esac
52822378475aSmrg	      ;;
5283e6f085baSmrg	  esac
52842378475aSmrg	  prev=
52852378475aSmrg	  continue
5286e6f085baSmrg	  ;;
52872378475aSmrg	inst_prefix)
52882378475aSmrg	  inst_prefix_dir="$arg"
52892378475aSmrg	  prev=
52902378475aSmrg	  continue
5291e6f085baSmrg	  ;;
52922378475aSmrg	objectlist)
52932378475aSmrg	  if test -f "$arg"; then
52942378475aSmrg	    save_arg=$arg
52952378475aSmrg	    moreargs=
52962378475aSmrg	    for fil in `cat "$save_arg"`
52972378475aSmrg	    do
529814330f12Smrg#	      func_append moreargs " $fil"
52992378475aSmrg	      arg=$fil
53002378475aSmrg	      # A libtool-controlled object.
530195b296d0Smrg
53022378475aSmrg	      # Check to see that this really is a libtool object.
53032378475aSmrg	      if func_lalib_unsafe_p "$arg"; then
53042378475aSmrg		pic_object=
53052378475aSmrg		non_pic_object=
530639713583Smrg
53072378475aSmrg		# Read the .lo file
53082378475aSmrg		func_source "$arg"
530939713583Smrg
53102378475aSmrg		if test -z "$pic_object" ||
53112378475aSmrg		   test -z "$non_pic_object" ||
53122378475aSmrg		   test "$pic_object" = none &&
53132378475aSmrg		   test "$non_pic_object" = none; then
53142378475aSmrg		  func_fatal_error "cannot find name of object for \`$arg'"
53152378475aSmrg		fi
531639713583Smrg
53172378475aSmrg		# Extract subdirectory from the argument.
53182378475aSmrg		func_dirname "$arg" "/" ""
53192378475aSmrg		xdir="$func_dirname_result"
532039713583Smrg
53212378475aSmrg		if test "$pic_object" != none; then
53222378475aSmrg		  # Prepend the subdirectory the object is found in.
53232378475aSmrg		  pic_object="$xdir$pic_object"
532439713583Smrg
53252378475aSmrg		  if test "$prev" = dlfiles; then
53262378475aSmrg		    if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
532714330f12Smrg		      func_append dlfiles " $pic_object"
53282378475aSmrg		      prev=
53292378475aSmrg		      continue
53302378475aSmrg		    else
53312378475aSmrg		      # If libtool objects are unsupported, then we need to preload.
53322378475aSmrg		      prev=dlprefiles
53332378475aSmrg		    fi
53342378475aSmrg		  fi
533539713583Smrg
53362378475aSmrg		  # CHECK ME:  I think I busted this.  -Ossama
53372378475aSmrg		  if test "$prev" = dlprefiles; then
53382378475aSmrg		    # Preload the old-style object.
533914330f12Smrg		    func_append dlprefiles " $pic_object"
53402378475aSmrg		    prev=
53412378475aSmrg		  fi
534239713583Smrg
53432378475aSmrg		  # A PIC object.
53442378475aSmrg		  func_append libobjs " $pic_object"
53452378475aSmrg		  arg="$pic_object"
53462378475aSmrg		fi
534739713583Smrg
53482378475aSmrg		# Non-PIC object.
53492378475aSmrg		if test "$non_pic_object" != none; then
53502378475aSmrg		  # Prepend the subdirectory the object is found in.
53512378475aSmrg		  non_pic_object="$xdir$non_pic_object"
535239713583Smrg
53532378475aSmrg		  # A standard non-PIC object
53542378475aSmrg		  func_append non_pic_objects " $non_pic_object"
53552378475aSmrg		  if test -z "$pic_object" || test "$pic_object" = none ; then
53562378475aSmrg		    arg="$non_pic_object"
53572378475aSmrg		  fi
53582378475aSmrg		else
53592378475aSmrg		  # If the PIC object exists, use it instead.
53602378475aSmrg		  # $xdir was prepended to $pic_object above.
53612378475aSmrg		  non_pic_object="$pic_object"
53622378475aSmrg		  func_append non_pic_objects " $non_pic_object"
53632378475aSmrg		fi
53642378475aSmrg	      else
53652378475aSmrg		# Only an error if not doing a dry-run.
53662378475aSmrg		if $opt_dry_run; then
53672378475aSmrg		  # Extract subdirectory from the argument.
53682378475aSmrg		  func_dirname "$arg" "/" ""
53692378475aSmrg		  xdir="$func_dirname_result"
53702378475aSmrg
53712378475aSmrg		  func_lo2o "$arg"
53722378475aSmrg		  pic_object=$xdir$objdir/$func_lo2o_result
53732378475aSmrg		  non_pic_object=$xdir$func_lo2o_result
53742378475aSmrg		  func_append libobjs " $pic_object"
53752378475aSmrg		  func_append non_pic_objects " $non_pic_object"
53762378475aSmrg	        else
53772378475aSmrg		  func_fatal_error "\`$arg' is not a valid libtool object"
53782378475aSmrg		fi
53792378475aSmrg	      fi
53802378475aSmrg	    done
5381e6f085baSmrg	  else
53822378475aSmrg	    func_fatal_error "link input file \`$arg' does not exist"
5383e6f085baSmrg	  fi
53842378475aSmrg	  arg=$save_arg
53852378475aSmrg	  prev=
53862378475aSmrg	  continue
53872378475aSmrg	  ;;
53882378475aSmrg	precious_regex)
53892378475aSmrg	  precious_files_regex="$arg"
53902378475aSmrg	  prev=
53912378475aSmrg	  continue
53922378475aSmrg	  ;;
53932378475aSmrg	release)
53942378475aSmrg	  release="-$arg"
53952378475aSmrg	  prev=
53962378475aSmrg	  continue
53972378475aSmrg	  ;;
53982378475aSmrg	rpath | xrpath)
53992378475aSmrg	  # We need an absolute path.
54002378475aSmrg	  case $arg in
54012378475aSmrg	  [\\/]* | [A-Za-z]:[\\/]*) ;;
54022378475aSmrg	  *)
54032378475aSmrg	    func_fatal_error "only absolute run-paths are allowed"
54042378475aSmrg	    ;;
54052378475aSmrg	  esac
54062378475aSmrg	  if test "$prev" = rpath; then
54072378475aSmrg	    case "$rpath " in
54082378475aSmrg	    *" $arg "*) ;;
540914330f12Smrg	    *) func_append rpath " $arg" ;;
54102378475aSmrg	    esac
5411e6f085baSmrg	  else
54122378475aSmrg	    case "$xrpath " in
54132378475aSmrg	    *" $arg "*) ;;
541414330f12Smrg	    *) func_append xrpath " $arg" ;;
54152378475aSmrg	    esac
5416e6f085baSmrg	  fi
54172378475aSmrg	  prev=
54182378475aSmrg	  continue
54192378475aSmrg	  ;;
54202378475aSmrg	shrext)
54212378475aSmrg	  shrext_cmds="$arg"
54222378475aSmrg	  prev=
54232378475aSmrg	  continue
54242378475aSmrg	  ;;
54252378475aSmrg	weak)
542614330f12Smrg	  func_append weak_libs " $arg"
54272378475aSmrg	  prev=
54282378475aSmrg	  continue
54292378475aSmrg	  ;;
54302378475aSmrg	xcclinker)
543114330f12Smrg	  func_append linker_flags " $qarg"
543214330f12Smrg	  func_append compiler_flags " $qarg"
54332378475aSmrg	  prev=
54342378475aSmrg	  func_append compile_command " $qarg"
54352378475aSmrg	  func_append finalize_command " $qarg"
54362378475aSmrg	  continue
54372378475aSmrg	  ;;
54382378475aSmrg	xcompiler)
543914330f12Smrg	  func_append compiler_flags " $qarg"
54402378475aSmrg	  prev=
54412378475aSmrg	  func_append compile_command " $qarg"
54422378475aSmrg	  func_append finalize_command " $qarg"
54432378475aSmrg	  continue
54442378475aSmrg	  ;;
54452378475aSmrg	xlinker)
544614330f12Smrg	  func_append linker_flags " $qarg"
544714330f12Smrg	  func_append compiler_flags " $wl$qarg"
54482378475aSmrg	  prev=
54492378475aSmrg	  func_append compile_command " $wl$qarg"
54502378475aSmrg	  func_append finalize_command " $wl$qarg"
54512378475aSmrg	  continue
54522378475aSmrg	  ;;
54532378475aSmrg	*)
54542378475aSmrg	  eval "$prev=\"\$arg\""
54552378475aSmrg	  prev=
54562378475aSmrg	  continue
54572378475aSmrg	  ;;
545839713583Smrg	esac
54592378475aSmrg      fi # test -n "$prev"
546039713583Smrg
54612378475aSmrg      prevarg="$arg"
546239713583Smrg
54632378475aSmrg      case $arg in
54642378475aSmrg      -all-static)
54652378475aSmrg	if test -n "$link_static_flag"; then
54662378475aSmrg	  # See comment for -static flag below, for more details.
54672378475aSmrg	  func_append compile_command " $link_static_flag"
54682378475aSmrg	  func_append finalize_command " $link_static_flag"
54692378475aSmrg	fi
54702378475aSmrg	continue
54712378475aSmrg	;;
547239713583Smrg
54732378475aSmrg      -allow-undefined)
54742378475aSmrg	# FIXME: remove this flag sometime in the future.
54752378475aSmrg	func_fatal_error "\`-allow-undefined' must not be used because it is the default"
54762378475aSmrg	;;
547739713583Smrg
54782378475aSmrg      -avoid-version)
54792378475aSmrg	avoid_version=yes
54802378475aSmrg	continue
54812378475aSmrg	;;
548239713583Smrg
548314330f12Smrg      -bindir)
548414330f12Smrg	prev=bindir
548514330f12Smrg	continue
548614330f12Smrg	;;
548714330f12Smrg
54882378475aSmrg      -dlopen)
54892378475aSmrg	prev=dlfiles
54902378475aSmrg	continue
54912378475aSmrg	;;
549239713583Smrg
54932378475aSmrg      -dlpreopen)
54942378475aSmrg	prev=dlprefiles
54952378475aSmrg	continue
54962378475aSmrg	;;
549739713583Smrg
54982378475aSmrg      -export-dynamic)
54992378475aSmrg	export_dynamic=yes
55002378475aSmrg	continue
55012378475aSmrg	;;
550239713583Smrg
55032378475aSmrg      -export-symbols | -export-symbols-regex)
55042378475aSmrg	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
55052378475aSmrg	  func_fatal_error "more than one -exported-symbols argument is not allowed"
55062378475aSmrg	fi
55072378475aSmrg	if test "X$arg" = "X-export-symbols"; then
55082378475aSmrg	  prev=expsyms
55092378475aSmrg	else
55102378475aSmrg	  prev=expsyms_regex
55112378475aSmrg	fi
55122378475aSmrg	continue
55132378475aSmrg	;;
551439713583Smrg
55152378475aSmrg      -framework)
55162378475aSmrg	prev=framework
55172378475aSmrg	continue
55182378475aSmrg	;;
551939713583Smrg
55202378475aSmrg      -inst-prefix-dir)
55212378475aSmrg	prev=inst_prefix
55222378475aSmrg	continue
55232378475aSmrg	;;
552439713583Smrg
55252378475aSmrg      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
55262378475aSmrg      # so, if we see these flags be careful not to treat them like -L
55272378475aSmrg      -L[A-Z][A-Z]*:*)
55282378475aSmrg	case $with_gcc/$host in
55292378475aSmrg	no/*-*-irix* | /*-*-irix*)
55302378475aSmrg	  func_append compile_command " $arg"
55312378475aSmrg	  func_append finalize_command " $arg"
55322378475aSmrg	  ;;
55332378475aSmrg	esac
55342378475aSmrg	continue
55352378475aSmrg	;;
553639713583Smrg
55372378475aSmrg      -L*)
553814330f12Smrg	func_stripname "-L" '' "$arg"
553914330f12Smrg	if test -z "$func_stripname_result"; then
55402378475aSmrg	  if test "$#" -gt 0; then
55412378475aSmrg	    func_fatal_error "require no space between \`-L' and \`$1'"
55422378475aSmrg	  else
55432378475aSmrg	    func_fatal_error "need path for \`-L' option"
55442378475aSmrg	  fi
55452378475aSmrg	fi
554614330f12Smrg	func_resolve_sysroot "$func_stripname_result"
554714330f12Smrg	dir=$func_resolve_sysroot_result
55482378475aSmrg	# We need an absolute path.
55492378475aSmrg	case $dir in
55502378475aSmrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
55512378475aSmrg	*)
55522378475aSmrg	  absdir=`cd "$dir" && pwd`
55532378475aSmrg	  test -z "$absdir" && \
55542378475aSmrg	    func_fatal_error "cannot determine absolute directory name of \`$dir'"
55552378475aSmrg	  dir="$absdir"
55562378475aSmrg	  ;;
55572378475aSmrg	esac
55582378475aSmrg	case "$deplibs " in
555914330f12Smrg	*" -L$dir "* | *" $arg "*)
556014330f12Smrg	  # Will only happen for absolute or sysroot arguments
556114330f12Smrg	  ;;
55622378475aSmrg	*)
556314330f12Smrg	  # Preserve sysroot, but never include relative directories
556414330f12Smrg	  case $dir in
556514330f12Smrg	    [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;;
556614330f12Smrg	    *) func_append deplibs " -L$dir" ;;
556714330f12Smrg	  esac
556814330f12Smrg	  func_append lib_search_path " $dir"
55692378475aSmrg	  ;;
55702378475aSmrg	esac
55712378475aSmrg	case $host in
55722378475aSmrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
557314330f12Smrg	  testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
55742378475aSmrg	  case :$dllsearchpath: in
55752378475aSmrg	  *":$dir:"*) ;;
55762378475aSmrg	  ::) dllsearchpath=$dir;;
557714330f12Smrg	  *) func_append dllsearchpath ":$dir";;
55782378475aSmrg	  esac
55792378475aSmrg	  case :$dllsearchpath: in
55802378475aSmrg	  *":$testbindir:"*) ;;
55812378475aSmrg	  ::) dllsearchpath=$testbindir;;
558214330f12Smrg	  *) func_append dllsearchpath ":$testbindir";;
55832378475aSmrg	  esac
55842378475aSmrg	  ;;
55852378475aSmrg	esac
55862378475aSmrg	continue
55872378475aSmrg	;;
558839713583Smrg
55892378475aSmrg      -l*)
55902378475aSmrg	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
55912378475aSmrg	  case $host in
559214330f12Smrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
55932378475aSmrg	    # These systems don't actually have a C or math library (as such)
55942378475aSmrg	    continue
55952378475aSmrg	    ;;
55962378475aSmrg	  *-*-os2*)
55972378475aSmrg	    # These systems don't actually have a C library (as such)
55982378475aSmrg	    test "X$arg" = "X-lc" && continue
55992378475aSmrg	    ;;
56002378475aSmrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
56012378475aSmrg	    # Do not include libc due to us having libc/libc_r.
56022378475aSmrg	    test "X$arg" = "X-lc" && continue
56032378475aSmrg	    ;;
56042378475aSmrg	  *-*-rhapsody* | *-*-darwin1.[012])
56052378475aSmrg	    # Rhapsody C and math libraries are in the System framework
560614330f12Smrg	    func_append deplibs " System.ltframework"
56072378475aSmrg	    continue
56082378475aSmrg	    ;;
56092378475aSmrg	  *-*-sco3.2v5* | *-*-sco5v6*)
56102378475aSmrg	    # Causes problems with __ctype
56112378475aSmrg	    test "X$arg" = "X-lc" && continue
56122378475aSmrg	    ;;
56132378475aSmrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
56142378475aSmrg	    # Compiler inserts libc in the correct place for threads to work
56152378475aSmrg	    test "X$arg" = "X-lc" && continue
56162378475aSmrg	    ;;
56172378475aSmrg	  esac
56182378475aSmrg	elif test "X$arg" = "X-lc_r"; then
56192378475aSmrg	 case $host in
56202378475aSmrg	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
56212378475aSmrg	   # Do not include libc_r directly, use -pthread flag.
56222378475aSmrg	   continue
56232378475aSmrg	   ;;
56242378475aSmrg	 esac
56252378475aSmrg	fi
562614330f12Smrg	func_append deplibs " $arg"
56272378475aSmrg	continue
56282378475aSmrg	;;
562939713583Smrg
56302378475aSmrg      -module)
56312378475aSmrg	module=yes
56322378475aSmrg	continue
56332378475aSmrg	;;
563439713583Smrg
56352378475aSmrg      # Tru64 UNIX uses -model [arg] to determine the layout of C++
56362378475aSmrg      # classes, name mangling, and exception handling.
56372378475aSmrg      # Darwin uses the -arch flag to determine output architecture.
563814330f12Smrg      -model|-arch|-isysroot|--sysroot)
563914330f12Smrg	func_append compiler_flags " $arg"
56402378475aSmrg	func_append compile_command " $arg"
56412378475aSmrg	func_append finalize_command " $arg"
56422378475aSmrg	prev=xcompiler
56432378475aSmrg	continue
56442378475aSmrg	;;
564539713583Smrg
56462378475aSmrg      -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
564714330f12Smrg	func_append compiler_flags " $arg"
56482378475aSmrg	func_append compile_command " $arg"
56492378475aSmrg	func_append finalize_command " $arg"
56502378475aSmrg	case "$new_inherited_linker_flags " in
56512378475aSmrg	    *" $arg "*) ;;
565214330f12Smrg	    * ) func_append new_inherited_linker_flags " $arg" ;;
56532378475aSmrg	esac
56542378475aSmrg	continue
56552378475aSmrg	;;
565639713583Smrg
56572378475aSmrg      -multi_module)
56582378475aSmrg	single_module="${wl}-multi_module"
56592378475aSmrg	continue
56602378475aSmrg	;;
566139713583Smrg
56622378475aSmrg      -no-fast-install)
56632378475aSmrg	fast_install=no
56642378475aSmrg	continue
56652378475aSmrg	;;
566639713583Smrg
56672378475aSmrg      -no-install)
56682378475aSmrg	case $host in
56692378475aSmrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
56702378475aSmrg	  # The PATH hackery in wrapper scripts is required on Windows
56712378475aSmrg	  # and Darwin in order for the loader to find any dlls it needs.
56722378475aSmrg	  func_warning "\`-no-install' is ignored for $host"
56732378475aSmrg	  func_warning "assuming \`-no-fast-install' instead"
56742378475aSmrg	  fast_install=no
56752378475aSmrg	  ;;
56762378475aSmrg	*) no_install=yes ;;
56772378475aSmrg	esac
56782378475aSmrg	continue
56792378475aSmrg	;;
568039713583Smrg
56812378475aSmrg      -no-undefined)
56822378475aSmrg	allow_undefined=no
56832378475aSmrg	continue
56842378475aSmrg	;;
568539713583Smrg
56862378475aSmrg      -objectlist)
56872378475aSmrg	prev=objectlist
56882378475aSmrg	continue
56892378475aSmrg	;;
569039713583Smrg
56912378475aSmrg      -o) prev=output ;;
569239713583Smrg
56932378475aSmrg      -precious-files-regex)
56942378475aSmrg	prev=precious_regex
56952378475aSmrg	continue
56962378475aSmrg	;;
569739713583Smrg
56982378475aSmrg      -release)
56992378475aSmrg	prev=release
57002378475aSmrg	continue
57012378475aSmrg	;;
570239713583Smrg
57032378475aSmrg      -rpath)
57042378475aSmrg	prev=rpath
57052378475aSmrg	continue
57062378475aSmrg	;;
570739713583Smrg
57082378475aSmrg      -R)
57092378475aSmrg	prev=xrpath
57102378475aSmrg	continue
57112378475aSmrg	;;
571239713583Smrg
57132378475aSmrg      -R*)
57142378475aSmrg	func_stripname '-R' '' "$arg"
57152378475aSmrg	dir=$func_stripname_result
57162378475aSmrg	# We need an absolute path.
57172378475aSmrg	case $dir in
57182378475aSmrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
571914330f12Smrg	=*)
572014330f12Smrg	  func_stripname '=' '' "$dir"
572114330f12Smrg	  dir=$lt_sysroot$func_stripname_result
572214330f12Smrg	  ;;
57232378475aSmrg	*)
57242378475aSmrg	  func_fatal_error "only absolute run-paths are allowed"
57252378475aSmrg	  ;;
57262378475aSmrg	esac
57272378475aSmrg	case "$xrpath " in
57282378475aSmrg	*" $dir "*) ;;
572914330f12Smrg	*) func_append xrpath " $dir" ;;
57302378475aSmrg	esac
57312378475aSmrg	continue
57322378475aSmrg	;;
573339713583Smrg
57342378475aSmrg      -shared)
57352378475aSmrg	# The effects of -shared are defined in a previous loop.
57362378475aSmrg	continue
57372378475aSmrg	;;
573839713583Smrg
57392378475aSmrg      -shrext)
57402378475aSmrg	prev=shrext
57412378475aSmrg	continue
57422378475aSmrg	;;
574339713583Smrg
57442378475aSmrg      -static | -static-libtool-libs)
57452378475aSmrg	# The effects of -static are defined in a previous loop.
57462378475aSmrg	# We used to do the same as -all-static on platforms that
57472378475aSmrg	# didn't have a PIC flag, but the assumption that the effects
57482378475aSmrg	# would be equivalent was wrong.  It would break on at least
57492378475aSmrg	# Digital Unix and AIX.
57502378475aSmrg	continue
57512378475aSmrg	;;
575239713583Smrg
57532378475aSmrg      -thread-safe)
57542378475aSmrg	thread_safe=yes
57552378475aSmrg	continue
57562378475aSmrg	;;
575739713583Smrg
57582378475aSmrg      -version-info)
57592378475aSmrg	prev=vinfo
57602378475aSmrg	continue
57612378475aSmrg	;;
576239713583Smrg
57632378475aSmrg      -version-number)
57642378475aSmrg	prev=vinfo
57652378475aSmrg	vinfo_number=yes
57662378475aSmrg	continue
57672378475aSmrg	;;
576839713583Smrg
57692378475aSmrg      -weak)
57702378475aSmrg        prev=weak
57712378475aSmrg	continue
57722378475aSmrg	;;
577395b296d0Smrg
57742378475aSmrg      -Wc,*)
57752378475aSmrg	func_stripname '-Wc,' '' "$arg"
57762378475aSmrg	args=$func_stripname_result
57772378475aSmrg	arg=
57782378475aSmrg	save_ifs="$IFS"; IFS=','
57792378475aSmrg	for flag in $args; do
57802378475aSmrg	  IFS="$save_ifs"
57812378475aSmrg          func_quote_for_eval "$flag"
578214330f12Smrg	  func_append arg " $func_quote_for_eval_result"
578314330f12Smrg	  func_append compiler_flags " $func_quote_for_eval_result"
57842378475aSmrg	done
57852378475aSmrg	IFS="$save_ifs"
57862378475aSmrg	func_stripname ' ' '' "$arg"
57872378475aSmrg	arg=$func_stripname_result
57882378475aSmrg	;;
5789e6f085baSmrg
57902378475aSmrg      -Wl,*)
57912378475aSmrg	func_stripname '-Wl,' '' "$arg"
57922378475aSmrg	args=$func_stripname_result
57932378475aSmrg	arg=
57942378475aSmrg	save_ifs="$IFS"; IFS=','
57952378475aSmrg	for flag in $args; do
57962378475aSmrg	  IFS="$save_ifs"
57972378475aSmrg          func_quote_for_eval "$flag"
579814330f12Smrg	  func_append arg " $wl$func_quote_for_eval_result"
579914330f12Smrg	  func_append compiler_flags " $wl$func_quote_for_eval_result"
580014330f12Smrg	  func_append linker_flags " $func_quote_for_eval_result"
58012378475aSmrg	done
58022378475aSmrg	IFS="$save_ifs"
58032378475aSmrg	func_stripname ' ' '' "$arg"
58042378475aSmrg	arg=$func_stripname_result
58052378475aSmrg	;;
5806e6f085baSmrg
58072378475aSmrg      -Xcompiler)
58082378475aSmrg	prev=xcompiler
58092378475aSmrg	continue
58102378475aSmrg	;;
5811e6f085baSmrg
58122378475aSmrg      -Xlinker)
58132378475aSmrg	prev=xlinker
58142378475aSmrg	continue
58152378475aSmrg	;;
5816e6f085baSmrg
58172378475aSmrg      -XCClinker)
58182378475aSmrg	prev=xcclinker
58192378475aSmrg	continue
58202378475aSmrg	;;
5821e6f085baSmrg
58222378475aSmrg      # -msg_* for osf cc
58232378475aSmrg      -msg_*)
58242378475aSmrg	func_quote_for_eval "$arg"
58252378475aSmrg	arg="$func_quote_for_eval_result"
58262378475aSmrg	;;
5827e6f085baSmrg
582814330f12Smrg      # Flags to be passed through unchanged, with rationale:
582914330f12Smrg      # -64, -mips[0-9]      enable 64-bit mode for the SGI compiler
583014330f12Smrg      # -r[0-9][0-9]*        specify processor for the SGI compiler
583114330f12Smrg      # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler
583214330f12Smrg      # +DA*, +DD*           enable 64-bit mode for the HP compiler
583314330f12Smrg      # -q*                  compiler args for the IBM compiler
583414330f12Smrg      # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
583514330f12Smrg      # -F/path              path to uninstalled frameworks, gcc on darwin
583614330f12Smrg      # -p, -pg, --coverage, -fprofile-*  profiling flags for GCC
583714330f12Smrg      # @file                GCC response files
583814330f12Smrg      # -tp=*                Portland pgcc target processor selection
583914330f12Smrg      # --sysroot=*          for sysroot support
584014330f12Smrg      # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
58412378475aSmrg      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
584214330f12Smrg      -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
584314330f12Smrg      -O*|-flto*|-fwhopr*|-fuse-linker-plugin)
58442378475aSmrg        func_quote_for_eval "$arg"
58452378475aSmrg	arg="$func_quote_for_eval_result"
58462378475aSmrg        func_append compile_command " $arg"
58472378475aSmrg        func_append finalize_command " $arg"
584814330f12Smrg        func_append compiler_flags " $arg"
58492378475aSmrg        continue
58502378475aSmrg        ;;
5851e6f085baSmrg
58522378475aSmrg      # Some other compiler flag.
58532378475aSmrg      -* | +*)
58542378475aSmrg        func_quote_for_eval "$arg"
58552378475aSmrg	arg="$func_quote_for_eval_result"
58562378475aSmrg	;;
5857e6f085baSmrg
58582378475aSmrg      *.$objext)
58592378475aSmrg	# A standard object.
586014330f12Smrg	func_append objs " $arg"
58612378475aSmrg	;;
5862e6f085baSmrg
58632378475aSmrg      *.lo)
58642378475aSmrg	# A libtool-controlled object.
5865e6f085baSmrg
58662378475aSmrg	# Check to see that this really is a libtool object.
58672378475aSmrg	if func_lalib_unsafe_p "$arg"; then
58682378475aSmrg	  pic_object=
58692378475aSmrg	  non_pic_object=
5870e6f085baSmrg
58712378475aSmrg	  # Read the .lo file
58722378475aSmrg	  func_source "$arg"
5873e6f085baSmrg
58742378475aSmrg	  if test -z "$pic_object" ||
58752378475aSmrg	     test -z "$non_pic_object" ||
58762378475aSmrg	     test "$pic_object" = none &&
58772378475aSmrg	     test "$non_pic_object" = none; then
58782378475aSmrg	    func_fatal_error "cannot find name of object for \`$arg'"
58792378475aSmrg	  fi
5880e6f085baSmrg
58812378475aSmrg	  # Extract subdirectory from the argument.
58822378475aSmrg	  func_dirname "$arg" "/" ""
58832378475aSmrg	  xdir="$func_dirname_result"
5884e6f085baSmrg
58852378475aSmrg	  if test "$pic_object" != none; then
58862378475aSmrg	    # Prepend the subdirectory the object is found in.
58872378475aSmrg	    pic_object="$xdir$pic_object"
5888e6f085baSmrg
58892378475aSmrg	    if test "$prev" = dlfiles; then
58902378475aSmrg	      if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
589114330f12Smrg		func_append dlfiles " $pic_object"
58922378475aSmrg		prev=
58932378475aSmrg		continue
58942378475aSmrg	      else
58952378475aSmrg		# If libtool objects are unsupported, then we need to preload.
58962378475aSmrg		prev=dlprefiles
58972378475aSmrg	      fi
58982378475aSmrg	    fi
5899e6f085baSmrg
59002378475aSmrg	    # CHECK ME:  I think I busted this.  -Ossama
59012378475aSmrg	    if test "$prev" = dlprefiles; then
59022378475aSmrg	      # Preload the old-style object.
590314330f12Smrg	      func_append dlprefiles " $pic_object"
59042378475aSmrg	      prev=
59052378475aSmrg	    fi
590695b296d0Smrg
59072378475aSmrg	    # A PIC object.
59082378475aSmrg	    func_append libobjs " $pic_object"
59092378475aSmrg	    arg="$pic_object"
59102378475aSmrg	  fi
591195b296d0Smrg
59122378475aSmrg	  # Non-PIC object.
59132378475aSmrg	  if test "$non_pic_object" != none; then
59142378475aSmrg	    # Prepend the subdirectory the object is found in.
59152378475aSmrg	    non_pic_object="$xdir$non_pic_object"
591695b296d0Smrg
59172378475aSmrg	    # A standard non-PIC object
59182378475aSmrg	    func_append non_pic_objects " $non_pic_object"
59192378475aSmrg	    if test -z "$pic_object" || test "$pic_object" = none ; then
59202378475aSmrg	      arg="$non_pic_object"
59212378475aSmrg	    fi
59222378475aSmrg	  else
59232378475aSmrg	    # If the PIC object exists, use it instead.
59242378475aSmrg	    # $xdir was prepended to $pic_object above.
59252378475aSmrg	    non_pic_object="$pic_object"
59262378475aSmrg	    func_append non_pic_objects " $non_pic_object"
59272378475aSmrg	  fi
59282378475aSmrg	else
59292378475aSmrg	  # Only an error if not doing a dry-run.
59302378475aSmrg	  if $opt_dry_run; then
59312378475aSmrg	    # Extract subdirectory from the argument.
59322378475aSmrg	    func_dirname "$arg" "/" ""
59332378475aSmrg	    xdir="$func_dirname_result"
59342378475aSmrg
59352378475aSmrg	    func_lo2o "$arg"
59362378475aSmrg	    pic_object=$xdir$objdir/$func_lo2o_result
59372378475aSmrg	    non_pic_object=$xdir$func_lo2o_result
59382378475aSmrg	    func_append libobjs " $pic_object"
59392378475aSmrg	    func_append non_pic_objects " $non_pic_object"
59402378475aSmrg	  else
59412378475aSmrg	    func_fatal_error "\`$arg' is not a valid libtool object"
59422378475aSmrg	  fi
59432378475aSmrg	fi
59442378475aSmrg	;;
594595b296d0Smrg
59462378475aSmrg      *.$libext)
59472378475aSmrg	# An archive.
594814330f12Smrg	func_append deplibs " $arg"
594914330f12Smrg	func_append old_deplibs " $arg"
59502378475aSmrg	continue
59512378475aSmrg	;;
59522378475aSmrg
59532378475aSmrg      *.la)
59542378475aSmrg	# A libtool-controlled library.
59552378475aSmrg
595614330f12Smrg	func_resolve_sysroot "$arg"
59572378475aSmrg	if test "$prev" = dlfiles; then
59582378475aSmrg	  # This library was specified with -dlopen.
595914330f12Smrg	  func_append dlfiles " $func_resolve_sysroot_result"
59602378475aSmrg	  prev=
59612378475aSmrg	elif test "$prev" = dlprefiles; then
59622378475aSmrg	  # The library was specified with -dlpreopen.
596314330f12Smrg	  func_append dlprefiles " $func_resolve_sysroot_result"
59642378475aSmrg	  prev=
59652378475aSmrg	else
596614330f12Smrg	  func_append deplibs " $func_resolve_sysroot_result"
59672378475aSmrg	fi
59682378475aSmrg	continue
59692378475aSmrg	;;
59702378475aSmrg
59712378475aSmrg      # Some other compiler argument.
59722378475aSmrg      *)
59732378475aSmrg	# Unknown arguments in both finalize_command and compile_command need
59742378475aSmrg	# to be aesthetically quoted because they are evaled later.
59752378475aSmrg	func_quote_for_eval "$arg"
59762378475aSmrg	arg="$func_quote_for_eval_result"
59772378475aSmrg	;;
59782378475aSmrg      esac # arg
59792378475aSmrg
59802378475aSmrg      # Now actually substitute the argument into the commands.
59812378475aSmrg      if test -n "$arg"; then
59822378475aSmrg	func_append compile_command " $arg"
59832378475aSmrg	func_append finalize_command " $arg"
59842378475aSmrg      fi
59852378475aSmrg    done # argument parsing loop
59862378475aSmrg
59872378475aSmrg    test -n "$prev" && \
59882378475aSmrg      func_fatal_help "the \`$prevarg' option requires an argument"
59892378475aSmrg
59902378475aSmrg    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
59912378475aSmrg      eval arg=\"$export_dynamic_flag_spec\"
59922378475aSmrg      func_append compile_command " $arg"
59932378475aSmrg      func_append finalize_command " $arg"
59942378475aSmrg    fi
59952378475aSmrg
59962378475aSmrg    oldlibs=
59972378475aSmrg    # calculate the name of the file, without its directory
59982378475aSmrg    func_basename "$output"
59992378475aSmrg    outputname="$func_basename_result"
60002378475aSmrg    libobjs_save="$libobjs"
60012378475aSmrg
60022378475aSmrg    if test -n "$shlibpath_var"; then
60032378475aSmrg      # get the directories listed in $shlibpath_var
600414330f12Smrg      eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\`
60052378475aSmrg    else
60062378475aSmrg      shlib_search_path=
60072378475aSmrg    fi
60082378475aSmrg    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
60092378475aSmrg    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
60102378475aSmrg
60112378475aSmrg    func_dirname "$output" "/" ""
60122378475aSmrg    output_objdir="$func_dirname_result$objdir"
601314330f12Smrg    func_to_tool_file "$output_objdir/"
601414330f12Smrg    tool_output_objdir=$func_to_tool_file_result
60152378475aSmrg    # Create the object directory.
60162378475aSmrg    func_mkdir_p "$output_objdir"
60172378475aSmrg
60182378475aSmrg    # Determine the type of output
60192378475aSmrg    case $output in
60202378475aSmrg    "")
60212378475aSmrg      func_fatal_help "you must specify an output file"
60222378475aSmrg      ;;
60232378475aSmrg    *.$libext) linkmode=oldlib ;;
60242378475aSmrg    *.lo | *.$objext) linkmode=obj ;;
60252378475aSmrg    *.la) linkmode=lib ;;
60262378475aSmrg    *) linkmode=prog ;; # Anything else should be a program.
60272378475aSmrg    esac
60282378475aSmrg
60292378475aSmrg    specialdeplibs=
60302378475aSmrg
60312378475aSmrg    libs=
60322378475aSmrg    # Find all interdependent deplibs by searching for libraries
60332378475aSmrg    # that are linked more than once (e.g. -la -lb -la)
60342378475aSmrg    for deplib in $deplibs; do
603514330f12Smrg      if $opt_preserve_dup_deps ; then
60362378475aSmrg	case "$libs " in
603714330f12Smrg	*" $deplib "*) func_append specialdeplibs " $deplib" ;;
60382378475aSmrg	esac
60392378475aSmrg      fi
604014330f12Smrg      func_append libs " $deplib"
60412378475aSmrg    done
60422378475aSmrg
60432378475aSmrg    if test "$linkmode" = lib; then
60442378475aSmrg      libs="$predeps $libs $compiler_lib_search_path $postdeps"
60452378475aSmrg
60462378475aSmrg      # Compute libraries that are listed more than once in $predeps
60472378475aSmrg      # $postdeps and mark them as special (i.e., whose duplicates are
60482378475aSmrg      # not to be eliminated).
60492378475aSmrg      pre_post_deps=
60502378475aSmrg      if $opt_duplicate_compiler_generated_deps; then
60512378475aSmrg	for pre_post_dep in $predeps $postdeps; do
60522378475aSmrg	  case "$pre_post_deps " in
605314330f12Smrg	  *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;;
60542378475aSmrg	  esac
605514330f12Smrg	  func_append pre_post_deps " $pre_post_dep"
60562378475aSmrg	done
60572378475aSmrg      fi
60582378475aSmrg      pre_post_deps=
60592378475aSmrg    fi
60602378475aSmrg
60612378475aSmrg    deplibs=
60622378475aSmrg    newdependency_libs=
60632378475aSmrg    newlib_search_path=
60642378475aSmrg    need_relink=no # whether we're linking any uninstalled libtool libraries
60652378475aSmrg    notinst_deplibs= # not-installed libtool libraries
60662378475aSmrg    notinst_path= # paths that contain not-installed libtool libraries
60672378475aSmrg
60682378475aSmrg    case $linkmode in
60692378475aSmrg    lib)
60702378475aSmrg	passes="conv dlpreopen link"
60712378475aSmrg	for file in $dlfiles $dlprefiles; do
60722378475aSmrg	  case $file in
60732378475aSmrg	  *.la) ;;
60742378475aSmrg	  *)
60752378475aSmrg	    func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file"
60762378475aSmrg	    ;;
60772378475aSmrg	  esac
60782378475aSmrg	done
60792378475aSmrg	;;
60802378475aSmrg    prog)
60812378475aSmrg	compile_deplibs=
60822378475aSmrg	finalize_deplibs=
60832378475aSmrg	alldeplibs=no
60842378475aSmrg	newdlfiles=
60852378475aSmrg	newdlprefiles=
60862378475aSmrg	passes="conv scan dlopen dlpreopen link"
60872378475aSmrg	;;
60882378475aSmrg    *)  passes="conv"
60892378475aSmrg	;;
60902378475aSmrg    esac
60912378475aSmrg
60922378475aSmrg    for pass in $passes; do
60932378475aSmrg      # The preopen pass in lib mode reverses $deplibs; put it back here
60942378475aSmrg      # so that -L comes before libs that need it for instance...
60952378475aSmrg      if test "$linkmode,$pass" = "lib,link"; then
60962378475aSmrg	## FIXME: Find the place where the list is rebuilt in the wrong
60972378475aSmrg	##        order, and fix it there properly
60982378475aSmrg        tmp_deplibs=
60992378475aSmrg	for deplib in $deplibs; do
61002378475aSmrg	  tmp_deplibs="$deplib $tmp_deplibs"
61012378475aSmrg	done
61022378475aSmrg	deplibs="$tmp_deplibs"
61032378475aSmrg      fi
61042378475aSmrg
61052378475aSmrg      if test "$linkmode,$pass" = "lib,link" ||
61062378475aSmrg	 test "$linkmode,$pass" = "prog,scan"; then
61072378475aSmrg	libs="$deplibs"
61082378475aSmrg	deplibs=
61092378475aSmrg      fi
61102378475aSmrg      if test "$linkmode" = prog; then
61112378475aSmrg	case $pass in
61122378475aSmrg	dlopen) libs="$dlfiles" ;;
61132378475aSmrg	dlpreopen) libs="$dlprefiles" ;;
61142378475aSmrg	link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
61152378475aSmrg	esac
61162378475aSmrg      fi
61172378475aSmrg      if test "$linkmode,$pass" = "lib,dlpreopen"; then
61182378475aSmrg	# Collect and forward deplibs of preopened libtool libs
61192378475aSmrg	for lib in $dlprefiles; do
61202378475aSmrg	  # Ignore non-libtool-libs
61212378475aSmrg	  dependency_libs=
612214330f12Smrg	  func_resolve_sysroot "$lib"
61232378475aSmrg	  case $lib in
612414330f12Smrg	  *.la)	func_source "$func_resolve_sysroot_result" ;;
61252378475aSmrg	  esac
61262378475aSmrg
61272378475aSmrg	  # Collect preopened libtool deplibs, except any this library
61282378475aSmrg	  # has declared as weak libs
61292378475aSmrg	  for deplib in $dependency_libs; do
613014330f12Smrg	    func_basename "$deplib"
613114330f12Smrg            deplib_base=$func_basename_result
61322378475aSmrg	    case " $weak_libs " in
61332378475aSmrg	    *" $deplib_base "*) ;;
613414330f12Smrg	    *) func_append deplibs " $deplib" ;;
61352378475aSmrg	    esac
61362378475aSmrg	  done
61372378475aSmrg	done
61382378475aSmrg	libs="$dlprefiles"
61392378475aSmrg      fi
61402378475aSmrg      if test "$pass" = dlopen; then
61412378475aSmrg	# Collect dlpreopened libraries
61422378475aSmrg	save_deplibs="$deplibs"
61432378475aSmrg	deplibs=
61442378475aSmrg      fi
61452378475aSmrg
61462378475aSmrg      for deplib in $libs; do
61472378475aSmrg	lib=
61482378475aSmrg	found=no
61492378475aSmrg	case $deplib in
61502378475aSmrg	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
61512378475aSmrg	  if test "$linkmode,$pass" = "prog,link"; then
61522378475aSmrg	    compile_deplibs="$deplib $compile_deplibs"
61532378475aSmrg	    finalize_deplibs="$deplib $finalize_deplibs"
61542378475aSmrg	  else
615514330f12Smrg	    func_append compiler_flags " $deplib"
61562378475aSmrg	    if test "$linkmode" = lib ; then
61572378475aSmrg		case "$new_inherited_linker_flags " in
61582378475aSmrg		    *" $deplib "*) ;;
615914330f12Smrg		    * ) func_append new_inherited_linker_flags " $deplib" ;;
61602378475aSmrg		esac
61612378475aSmrg	    fi
61622378475aSmrg	  fi
61632378475aSmrg	  continue
61642378475aSmrg	  ;;
61652378475aSmrg	-l*)
61662378475aSmrg	  if test "$linkmode" != lib && test "$linkmode" != prog; then
61672378475aSmrg	    func_warning "\`-l' is ignored for archives/objects"
61682378475aSmrg	    continue
61692378475aSmrg	  fi
61702378475aSmrg	  func_stripname '-l' '' "$deplib"
61712378475aSmrg	  name=$func_stripname_result
61722378475aSmrg	  if test "$linkmode" = lib; then
61732378475aSmrg	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
61742378475aSmrg	  else
61752378475aSmrg	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
61762378475aSmrg	  fi
61772378475aSmrg	  for searchdir in $searchdirs; do
61782378475aSmrg	    for search_ext in .la $std_shrext .so .a; do
61792378475aSmrg	      # Search the libtool library
61802378475aSmrg	      lib="$searchdir/lib${name}${search_ext}"
61812378475aSmrg	      if test -f "$lib"; then
61822378475aSmrg		if test "$search_ext" = ".la"; then
61832378475aSmrg		  found=yes
61842378475aSmrg		else
61852378475aSmrg		  found=no
61862378475aSmrg		fi
61872378475aSmrg		break 2
61882378475aSmrg	      fi
61892378475aSmrg	    done
61902378475aSmrg	  done
61912378475aSmrg	  if test "$found" != yes; then
61922378475aSmrg	    # deplib doesn't seem to be a libtool library
61932378475aSmrg	    if test "$linkmode,$pass" = "prog,link"; then
61942378475aSmrg	      compile_deplibs="$deplib $compile_deplibs"
61952378475aSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
61962378475aSmrg	    else
61972378475aSmrg	      deplibs="$deplib $deplibs"
61982378475aSmrg	      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
61992378475aSmrg	    fi
62002378475aSmrg	    continue
62012378475aSmrg	  else # deplib is a libtool library
62022378475aSmrg	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
62032378475aSmrg	    # We need to do some special things here, and not later.
62042378475aSmrg	    if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
62052378475aSmrg	      case " $predeps $postdeps " in
62062378475aSmrg	      *" $deplib "*)
62072378475aSmrg		if func_lalib_p "$lib"; then
62082378475aSmrg		  library_names=
62092378475aSmrg		  old_library=
62102378475aSmrg		  func_source "$lib"
62112378475aSmrg		  for l in $old_library $library_names; do
62122378475aSmrg		    ll="$l"
62132378475aSmrg		  done
62142378475aSmrg		  if test "X$ll" = "X$old_library" ; then # only static version available
62152378475aSmrg		    found=no
62162378475aSmrg		    func_dirname "$lib" "" "."
62172378475aSmrg		    ladir="$func_dirname_result"
62182378475aSmrg		    lib=$ladir/$old_library
62192378475aSmrg		    if test "$linkmode,$pass" = "prog,link"; then
62202378475aSmrg		      compile_deplibs="$deplib $compile_deplibs"
62212378475aSmrg		      finalize_deplibs="$deplib $finalize_deplibs"
62222378475aSmrg		    else
62232378475aSmrg		      deplibs="$deplib $deplibs"
62242378475aSmrg		      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
62252378475aSmrg		    fi
62262378475aSmrg		    continue
62272378475aSmrg		  fi
62282378475aSmrg		fi
62292378475aSmrg		;;
62302378475aSmrg	      *) ;;
62312378475aSmrg	      esac
62322378475aSmrg	    fi
62332378475aSmrg	  fi
62342378475aSmrg	  ;; # -l
62352378475aSmrg	*.ltframework)
62362378475aSmrg	  if test "$linkmode,$pass" = "prog,link"; then
62372378475aSmrg	    compile_deplibs="$deplib $compile_deplibs"
62382378475aSmrg	    finalize_deplibs="$deplib $finalize_deplibs"
62392378475aSmrg	  else
62402378475aSmrg	    deplibs="$deplib $deplibs"
62412378475aSmrg	    if test "$linkmode" = lib ; then
62422378475aSmrg		case "$new_inherited_linker_flags " in
62432378475aSmrg		    *" $deplib "*) ;;
624414330f12Smrg		    * ) func_append new_inherited_linker_flags " $deplib" ;;
62452378475aSmrg		esac
62462378475aSmrg	    fi
62472378475aSmrg	  fi
62482378475aSmrg	  continue
62492378475aSmrg	  ;;
62502378475aSmrg	-L*)
62512378475aSmrg	  case $linkmode in
62522378475aSmrg	  lib)
62532378475aSmrg	    deplibs="$deplib $deplibs"
62542378475aSmrg	    test "$pass" = conv && continue
62552378475aSmrg	    newdependency_libs="$deplib $newdependency_libs"
62562378475aSmrg	    func_stripname '-L' '' "$deplib"
625714330f12Smrg	    func_resolve_sysroot "$func_stripname_result"
625814330f12Smrg	    func_append newlib_search_path " $func_resolve_sysroot_result"
62592378475aSmrg	    ;;
62602378475aSmrg	  prog)
62612378475aSmrg	    if test "$pass" = conv; then
62622378475aSmrg	      deplibs="$deplib $deplibs"
62632378475aSmrg	      continue
62642378475aSmrg	    fi
62652378475aSmrg	    if test "$pass" = scan; then
62662378475aSmrg	      deplibs="$deplib $deplibs"
62672378475aSmrg	    else
62682378475aSmrg	      compile_deplibs="$deplib $compile_deplibs"
62692378475aSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
62702378475aSmrg	    fi
62712378475aSmrg	    func_stripname '-L' '' "$deplib"
627214330f12Smrg	    func_resolve_sysroot "$func_stripname_result"
627314330f12Smrg	    func_append newlib_search_path " $func_resolve_sysroot_result"
62742378475aSmrg	    ;;
62752378475aSmrg	  *)
62762378475aSmrg	    func_warning "\`-L' is ignored for archives/objects"
62772378475aSmrg	    ;;
62782378475aSmrg	  esac # linkmode
62792378475aSmrg	  continue
62802378475aSmrg	  ;; # -L
62812378475aSmrg	-R*)
62822378475aSmrg	  if test "$pass" = link; then
62832378475aSmrg	    func_stripname '-R' '' "$deplib"
628414330f12Smrg	    func_resolve_sysroot "$func_stripname_result"
628514330f12Smrg	    dir=$func_resolve_sysroot_result
62862378475aSmrg	    # Make sure the xrpath contains only unique directories.
62872378475aSmrg	    case "$xrpath " in
62882378475aSmrg	    *" $dir "*) ;;
628914330f12Smrg	    *) func_append xrpath " $dir" ;;
62902378475aSmrg	    esac
62912378475aSmrg	  fi
62922378475aSmrg	  deplibs="$deplib $deplibs"
62932378475aSmrg	  continue
62942378475aSmrg	  ;;
629514330f12Smrg	*.la)
629614330f12Smrg	  func_resolve_sysroot "$deplib"
629714330f12Smrg	  lib=$func_resolve_sysroot_result
629814330f12Smrg	  ;;
62992378475aSmrg	*.$libext)
63002378475aSmrg	  if test "$pass" = conv; then
63012378475aSmrg	    deplibs="$deplib $deplibs"
63022378475aSmrg	    continue
63032378475aSmrg	  fi
63042378475aSmrg	  case $linkmode in
63052378475aSmrg	  lib)
63062378475aSmrg	    # Linking convenience modules into shared libraries is allowed,
63072378475aSmrg	    # but linking other static libraries is non-portable.
63082378475aSmrg	    case " $dlpreconveniencelibs " in
63092378475aSmrg	    *" $deplib "*) ;;
63102378475aSmrg	    *)
63112378475aSmrg	      valid_a_lib=no
63122378475aSmrg	      case $deplibs_check_method in
63132378475aSmrg		match_pattern*)
63142378475aSmrg		  set dummy $deplibs_check_method; shift
63152378475aSmrg		  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
631614330f12Smrg		  if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
63172378475aSmrg		    | $EGREP "$match_pattern_regex" > /dev/null; then
63182378475aSmrg		    valid_a_lib=yes
63192378475aSmrg		  fi
63202378475aSmrg		;;
63212378475aSmrg		pass_all)
63222378475aSmrg		  valid_a_lib=yes
63232378475aSmrg		;;
63242378475aSmrg	      esac
63252378475aSmrg	      if test "$valid_a_lib" != yes; then
632614330f12Smrg		echo
63272378475aSmrg		$ECHO "*** Warning: Trying to link with static lib archive $deplib."
632814330f12Smrg		echo "*** I have the capability to make that library automatically link in when"
632914330f12Smrg		echo "*** you link to this library.  But I can only do this if you have a"
633014330f12Smrg		echo "*** shared version of the library, which you do not appear to have"
633114330f12Smrg		echo "*** because the file extensions .$libext of this argument makes me believe"
633214330f12Smrg		echo "*** that it is just a static archive that I should not use here."
63332378475aSmrg	      else
633414330f12Smrg		echo
63352378475aSmrg		$ECHO "*** Warning: Linking the shared library $output against the"
63362378475aSmrg		$ECHO "*** static library $deplib is not portable!"
63372378475aSmrg		deplibs="$deplib $deplibs"
63382378475aSmrg	      fi
63392378475aSmrg	      ;;
63402378475aSmrg	    esac
63412378475aSmrg	    continue
63422378475aSmrg	    ;;
63432378475aSmrg	  prog)
63442378475aSmrg	    if test "$pass" != link; then
63452378475aSmrg	      deplibs="$deplib $deplibs"
63462378475aSmrg	    else
63472378475aSmrg	      compile_deplibs="$deplib $compile_deplibs"
63482378475aSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
63492378475aSmrg	    fi
63502378475aSmrg	    continue
63512378475aSmrg	    ;;
63522378475aSmrg	  esac # linkmode
63532378475aSmrg	  ;; # *.$libext
63542378475aSmrg	*.lo | *.$objext)
63552378475aSmrg	  if test "$pass" = conv; then
63562378475aSmrg	    deplibs="$deplib $deplibs"
63572378475aSmrg	  elif test "$linkmode" = prog; then
63582378475aSmrg	    if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
63592378475aSmrg	      # If there is no dlopen support or we're linking statically,
63602378475aSmrg	      # we need to preload.
636114330f12Smrg	      func_append newdlprefiles " $deplib"
63622378475aSmrg	      compile_deplibs="$deplib $compile_deplibs"
63632378475aSmrg	      finalize_deplibs="$deplib $finalize_deplibs"
63642378475aSmrg	    else
636514330f12Smrg	      func_append newdlfiles " $deplib"
63662378475aSmrg	    fi
63672378475aSmrg	  fi
63682378475aSmrg	  continue
63692378475aSmrg	  ;;
63702378475aSmrg	%DEPLIBS%)
63712378475aSmrg	  alldeplibs=yes
63722378475aSmrg	  continue
63732378475aSmrg	  ;;
63742378475aSmrg	esac # case $deplib
63752378475aSmrg
63762378475aSmrg	if test "$found" = yes || test -f "$lib"; then :
63772378475aSmrg	else
63782378475aSmrg	  func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'"
63792378475aSmrg	fi
63802378475aSmrg
63812378475aSmrg	# Check to see that this really is a libtool archive.
63822378475aSmrg	func_lalib_unsafe_p "$lib" \
63832378475aSmrg	  || func_fatal_error "\`$lib' is not a valid libtool archive"
63842378475aSmrg
63852378475aSmrg	func_dirname "$lib" "" "."
63862378475aSmrg	ladir="$func_dirname_result"
63872378475aSmrg
63882378475aSmrg	dlname=
63892378475aSmrg	dlopen=
63902378475aSmrg	dlpreopen=
63912378475aSmrg	libdir=
63922378475aSmrg	library_names=
63932378475aSmrg	old_library=
63942378475aSmrg	inherited_linker_flags=
63952378475aSmrg	# If the library was installed with an old release of libtool,
63962378475aSmrg	# it will not redefine variables installed, or shouldnotlink
63972378475aSmrg	installed=yes
63982378475aSmrg	shouldnotlink=no
63992378475aSmrg	avoidtemprpath=
64002378475aSmrg
64012378475aSmrg
64022378475aSmrg	# Read the .la file
64032378475aSmrg	func_source "$lib"
64042378475aSmrg
64052378475aSmrg	# Convert "-framework foo" to "foo.ltframework"
64062378475aSmrg	if test -n "$inherited_linker_flags"; then
640714330f12Smrg	  tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
64082378475aSmrg	  for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
64092378475aSmrg	    case " $new_inherited_linker_flags " in
64102378475aSmrg	      *" $tmp_inherited_linker_flag "*) ;;
641114330f12Smrg	      *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";;
64122378475aSmrg	    esac
64132378475aSmrg	  done
64142378475aSmrg	fi
641514330f12Smrg	dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
64162378475aSmrg	if test "$linkmode,$pass" = "lib,link" ||
64172378475aSmrg	   test "$linkmode,$pass" = "prog,scan" ||
64182378475aSmrg	   { test "$linkmode" != prog && test "$linkmode" != lib; }; then
641914330f12Smrg	  test -n "$dlopen" && func_append dlfiles " $dlopen"
642014330f12Smrg	  test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen"
64212378475aSmrg	fi
64222378475aSmrg
64232378475aSmrg	if test "$pass" = conv; then
64242378475aSmrg	  # Only check for convenience libraries
64252378475aSmrg	  deplibs="$lib $deplibs"
64262378475aSmrg	  if test -z "$libdir"; then
64272378475aSmrg	    if test -z "$old_library"; then
64282378475aSmrg	      func_fatal_error "cannot find name of link library for \`$lib'"
64292378475aSmrg	    fi
64302378475aSmrg	    # It is a libtool convenience library, so add in its objects.
643114330f12Smrg	    func_append convenience " $ladir/$objdir/$old_library"
643214330f12Smrg	    func_append old_convenience " $ladir/$objdir/$old_library"
64332378475aSmrg	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
64342378475aSmrg	    func_fatal_error "\`$lib' is not a convenience library"
64352378475aSmrg	  fi
64362378475aSmrg	  tmp_libs=
64372378475aSmrg	  for deplib in $dependency_libs; do
64382378475aSmrg	    deplibs="$deplib $deplibs"
643914330f12Smrg	    if $opt_preserve_dup_deps ; then
64402378475aSmrg	      case "$tmp_libs " in
644114330f12Smrg	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
64422378475aSmrg	      esac
64432378475aSmrg	    fi
644414330f12Smrg	    func_append tmp_libs " $deplib"
64452378475aSmrg	  done
64462378475aSmrg	  continue
64472378475aSmrg	fi # $pass = conv
64482378475aSmrg
64492378475aSmrg
64502378475aSmrg	# Get the name of the library we link against.
64512378475aSmrg	linklib=
645214330f12Smrg	if test -n "$old_library" &&
645314330f12Smrg	   { test "$prefer_static_libs" = yes ||
645414330f12Smrg	     test "$prefer_static_libs,$installed" = "built,no"; }; then
645514330f12Smrg	  linklib=$old_library
645614330f12Smrg	else
645714330f12Smrg	  for l in $old_library $library_names; do
645814330f12Smrg	    linklib="$l"
645914330f12Smrg	  done
646014330f12Smrg	fi
64612378475aSmrg	if test -z "$linklib"; then
64622378475aSmrg	  func_fatal_error "cannot find name of link library for \`$lib'"
64632378475aSmrg	fi
64642378475aSmrg
64652378475aSmrg	# This library was specified with -dlopen.
64662378475aSmrg	if test "$pass" = dlopen; then
64672378475aSmrg	  if test -z "$libdir"; then
64682378475aSmrg	    func_fatal_error "cannot -dlopen a convenience library: \`$lib'"
64692378475aSmrg	  fi
64702378475aSmrg	  if test -z "$dlname" ||
64712378475aSmrg	     test "$dlopen_support" != yes ||
64722378475aSmrg	     test "$build_libtool_libs" = no; then
64732378475aSmrg	    # If there is no dlname, no dlopen support or we're linking
64742378475aSmrg	    # statically, we need to preload.  We also need to preload any
64752378475aSmrg	    # dependent libraries so libltdl's deplib preloader doesn't
64762378475aSmrg	    # bomb out in the load deplibs phase.
647714330f12Smrg	    func_append dlprefiles " $lib $dependency_libs"
64782378475aSmrg	  else
647914330f12Smrg	    func_append newdlfiles " $lib"
64802378475aSmrg	  fi
64812378475aSmrg	  continue
64822378475aSmrg	fi # $pass = dlopen
64832378475aSmrg
64842378475aSmrg	# We need an absolute path.
64852378475aSmrg	case $ladir in
64862378475aSmrg	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
64872378475aSmrg	*)
64882378475aSmrg	  abs_ladir=`cd "$ladir" && pwd`
64892378475aSmrg	  if test -z "$abs_ladir"; then
64902378475aSmrg	    func_warning "cannot determine absolute directory name of \`$ladir'"
64912378475aSmrg	    func_warning "passing it literally to the linker, although it might fail"
64922378475aSmrg	    abs_ladir="$ladir"
64932378475aSmrg	  fi
64942378475aSmrg	  ;;
64952378475aSmrg	esac
64962378475aSmrg	func_basename "$lib"
64972378475aSmrg	laname="$func_basename_result"
64982378475aSmrg
64992378475aSmrg	# Find the relevant object directory and library name.
65002378475aSmrg	if test "X$installed" = Xyes; then
650114330f12Smrg	  if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
65022378475aSmrg	    func_warning "library \`$lib' was moved."
65032378475aSmrg	    dir="$ladir"
65042378475aSmrg	    absdir="$abs_ladir"
65052378475aSmrg	    libdir="$abs_ladir"
65062378475aSmrg	  else
650714330f12Smrg	    dir="$lt_sysroot$libdir"
650814330f12Smrg	    absdir="$lt_sysroot$libdir"
65092378475aSmrg	  fi
65102378475aSmrg	  test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
65112378475aSmrg	else
65122378475aSmrg	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
65132378475aSmrg	    dir="$ladir"
65142378475aSmrg	    absdir="$abs_ladir"
65152378475aSmrg	    # Remove this search path later
651614330f12Smrg	    func_append notinst_path " $abs_ladir"
65172378475aSmrg	  else
65182378475aSmrg	    dir="$ladir/$objdir"
65192378475aSmrg	    absdir="$abs_ladir/$objdir"
65202378475aSmrg	    # Remove this search path later
652114330f12Smrg	    func_append notinst_path " $abs_ladir"
65222378475aSmrg	  fi
65232378475aSmrg	fi # $installed = yes
65242378475aSmrg	func_stripname 'lib' '.la' "$laname"
65252378475aSmrg	name=$func_stripname_result
65262378475aSmrg
65272378475aSmrg	# This library was specified with -dlpreopen.
65282378475aSmrg	if test "$pass" = dlpreopen; then
65292378475aSmrg	  if test -z "$libdir" && test "$linkmode" = prog; then
65302378475aSmrg	    func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'"
65312378475aSmrg	  fi
653214330f12Smrg	  case "$host" in
653314330f12Smrg	    # special handling for platforms with PE-DLLs.
653414330f12Smrg	    *cygwin* | *mingw* | *cegcc* )
653514330f12Smrg	      # Linker will automatically link against shared library if both
653614330f12Smrg	      # static and shared are present.  Therefore, ensure we extract
653714330f12Smrg	      # symbols from the import library if a shared library is present
653814330f12Smrg	      # (otherwise, the dlopen module name will be incorrect).  We do
653914330f12Smrg	      # this by putting the import library name into $newdlprefiles.
654014330f12Smrg	      # We recover the dlopen module name by 'saving' the la file
654114330f12Smrg	      # name in a special purpose variable, and (later) extracting the
654214330f12Smrg	      # dlname from the la file.
654314330f12Smrg	      if test -n "$dlname"; then
654414330f12Smrg	        func_tr_sh "$dir/$linklib"
654514330f12Smrg	        eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname"
654614330f12Smrg	        func_append newdlprefiles " $dir/$linklib"
654714330f12Smrg	      else
654814330f12Smrg	        func_append newdlprefiles " $dir/$old_library"
654914330f12Smrg	        # Keep a list of preopened convenience libraries to check
655014330f12Smrg	        # that they are being used correctly in the link pass.
655114330f12Smrg	        test -z "$libdir" && \
655214330f12Smrg	          func_append dlpreconveniencelibs " $dir/$old_library"
655314330f12Smrg	      fi
655414330f12Smrg	    ;;
655514330f12Smrg	    * )
655614330f12Smrg	      # Prefer using a static library (so that no silly _DYNAMIC symbols
655714330f12Smrg	      # are required to link).
655814330f12Smrg	      if test -n "$old_library"; then
655914330f12Smrg	        func_append newdlprefiles " $dir/$old_library"
656014330f12Smrg	        # Keep a list of preopened convenience libraries to check
656114330f12Smrg	        # that they are being used correctly in the link pass.
656214330f12Smrg	        test -z "$libdir" && \
656314330f12Smrg	          func_append dlpreconveniencelibs " $dir/$old_library"
656414330f12Smrg	      # Otherwise, use the dlname, so that lt_dlopen finds it.
656514330f12Smrg	      elif test -n "$dlname"; then
656614330f12Smrg	        func_append newdlprefiles " $dir/$dlname"
656714330f12Smrg	      else
656814330f12Smrg	        func_append newdlprefiles " $dir/$linklib"
656914330f12Smrg	      fi
657014330f12Smrg	    ;;
657114330f12Smrg	  esac
65722378475aSmrg	fi # $pass = dlpreopen
65732378475aSmrg
65742378475aSmrg	if test -z "$libdir"; then
65752378475aSmrg	  # Link the convenience library
65762378475aSmrg	  if test "$linkmode" = lib; then
65772378475aSmrg	    deplibs="$dir/$old_library $deplibs"
65782378475aSmrg	  elif test "$linkmode,$pass" = "prog,link"; then
65792378475aSmrg	    compile_deplibs="$dir/$old_library $compile_deplibs"
65802378475aSmrg	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
65812378475aSmrg	  else
65822378475aSmrg	    deplibs="$lib $deplibs" # used for prog,scan pass
65832378475aSmrg	  fi
65842378475aSmrg	  continue
65852378475aSmrg	fi
65862378475aSmrg
65872378475aSmrg
65882378475aSmrg	if test "$linkmode" = prog && test "$pass" != link; then
658914330f12Smrg	  func_append newlib_search_path " $ladir"
65902378475aSmrg	  deplibs="$lib $deplibs"
65912378475aSmrg
65922378475aSmrg	  linkalldeplibs=no
65932378475aSmrg	  if test "$link_all_deplibs" != no || test -z "$library_names" ||
65942378475aSmrg	     test "$build_libtool_libs" = no; then
65952378475aSmrg	    linkalldeplibs=yes
65962378475aSmrg	  fi
65972378475aSmrg
65982378475aSmrg	  tmp_libs=
65992378475aSmrg	  for deplib in $dependency_libs; do
66002378475aSmrg	    case $deplib in
66012378475aSmrg	    -L*) func_stripname '-L' '' "$deplib"
660214330f12Smrg	         func_resolve_sysroot "$func_stripname_result"
660314330f12Smrg	         func_append newlib_search_path " $func_resolve_sysroot_result"
66042378475aSmrg		 ;;
66052378475aSmrg	    esac
66062378475aSmrg	    # Need to link against all dependency_libs?
66072378475aSmrg	    if test "$linkalldeplibs" = yes; then
66082378475aSmrg	      deplibs="$deplib $deplibs"
66092378475aSmrg	    else
66102378475aSmrg	      # Need to hardcode shared library paths
66112378475aSmrg	      # or/and link against static libraries
66122378475aSmrg	      newdependency_libs="$deplib $newdependency_libs"
66132378475aSmrg	    fi
661414330f12Smrg	    if $opt_preserve_dup_deps ; then
66152378475aSmrg	      case "$tmp_libs " in
661614330f12Smrg	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
66172378475aSmrg	      esac
66182378475aSmrg	    fi
661914330f12Smrg	    func_append tmp_libs " $deplib"
66202378475aSmrg	  done # for deplib
66212378475aSmrg	  continue
66222378475aSmrg	fi # $linkmode = prog...
66232378475aSmrg
66242378475aSmrg	if test "$linkmode,$pass" = "prog,link"; then
66252378475aSmrg	  if test -n "$library_names" &&
66262378475aSmrg	     { { test "$prefer_static_libs" = no ||
66272378475aSmrg	         test "$prefer_static_libs,$installed" = "built,yes"; } ||
66282378475aSmrg	       test -z "$old_library"; }; then
66292378475aSmrg	    # We need to hardcode the library path
66302378475aSmrg	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
66312378475aSmrg	      # Make sure the rpath contains only unique directories.
66322378475aSmrg	      case "$temp_rpath:" in
66332378475aSmrg	      *"$absdir:"*) ;;
663414330f12Smrg	      *) func_append temp_rpath "$absdir:" ;;
66352378475aSmrg	      esac
66362378475aSmrg	    fi
66372378475aSmrg
66382378475aSmrg	    # Hardcode the library path.
66392378475aSmrg	    # Skip directories that are in the system default run-time
66402378475aSmrg	    # search path.
66412378475aSmrg	    case " $sys_lib_dlsearch_path " in
66422378475aSmrg	    *" $absdir "*) ;;
66432378475aSmrg	    *)
66442378475aSmrg	      case "$compile_rpath " in
66452378475aSmrg	      *" $absdir "*) ;;
664614330f12Smrg	      *) func_append compile_rpath " $absdir" ;;
66472378475aSmrg	      esac
66482378475aSmrg	      ;;
66492378475aSmrg	    esac
66502378475aSmrg	    case " $sys_lib_dlsearch_path " in
66512378475aSmrg	    *" $libdir "*) ;;
66522378475aSmrg	    *)
66532378475aSmrg	      case "$finalize_rpath " in
66542378475aSmrg	      *" $libdir "*) ;;
665514330f12Smrg	      *) func_append finalize_rpath " $libdir" ;;
66562378475aSmrg	      esac
66572378475aSmrg	      ;;
66582378475aSmrg	    esac
66592378475aSmrg	  fi # $linkmode,$pass = prog,link...
66602378475aSmrg
66612378475aSmrg	  if test "$alldeplibs" = yes &&
66622378475aSmrg	     { test "$deplibs_check_method" = pass_all ||
66632378475aSmrg	       { test "$build_libtool_libs" = yes &&
66642378475aSmrg		 test -n "$library_names"; }; }; then
66652378475aSmrg	    # We only need to search for static libraries
66662378475aSmrg	    continue
66672378475aSmrg	  fi
66682378475aSmrg	fi
66692378475aSmrg
66702378475aSmrg	link_static=no # Whether the deplib will be linked statically
66712378475aSmrg	use_static_libs=$prefer_static_libs
66722378475aSmrg	if test "$use_static_libs" = built && test "$installed" = yes; then
66732378475aSmrg	  use_static_libs=no
66742378475aSmrg	fi
66752378475aSmrg	if test -n "$library_names" &&
66762378475aSmrg	   { test "$use_static_libs" = no || test -z "$old_library"; }; then
66772378475aSmrg	  case $host in
66782378475aSmrg	  *cygwin* | *mingw* | *cegcc*)
66792378475aSmrg	      # No point in relinking DLLs because paths are not encoded
668014330f12Smrg	      func_append notinst_deplibs " $lib"
66812378475aSmrg	      need_relink=no
66822378475aSmrg	    ;;
66832378475aSmrg	  *)
66842378475aSmrg	    if test "$installed" = no; then
668514330f12Smrg	      func_append notinst_deplibs " $lib"
66862378475aSmrg	      need_relink=yes
66872378475aSmrg	    fi
66882378475aSmrg	    ;;
66892378475aSmrg	  esac
66902378475aSmrg	  # This is a shared library
66912378475aSmrg
66922378475aSmrg	  # Warn about portability, can't link against -module's on some
66932378475aSmrg	  # systems (darwin).  Don't bleat about dlopened modules though!
66942378475aSmrg	  dlopenmodule=""
66952378475aSmrg	  for dlpremoduletest in $dlprefiles; do
66962378475aSmrg	    if test "X$dlpremoduletest" = "X$lib"; then
66972378475aSmrg	      dlopenmodule="$dlpremoduletest"
66982378475aSmrg	      break
66992378475aSmrg	    fi
67002378475aSmrg	  done
67012378475aSmrg	  if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then
670214330f12Smrg	    echo
67032378475aSmrg	    if test "$linkmode" = prog; then
67042378475aSmrg	      $ECHO "*** Warning: Linking the executable $output against the loadable module"
67052378475aSmrg	    else
67062378475aSmrg	      $ECHO "*** Warning: Linking the shared library $output against the loadable module"
67072378475aSmrg	    fi
67082378475aSmrg	    $ECHO "*** $linklib is not portable!"
67092378475aSmrg	  fi
67102378475aSmrg	  if test "$linkmode" = lib &&
67112378475aSmrg	     test "$hardcode_into_libs" = yes; then
67122378475aSmrg	    # Hardcode the library path.
67132378475aSmrg	    # Skip directories that are in the system default run-time
67142378475aSmrg	    # search path.
67152378475aSmrg	    case " $sys_lib_dlsearch_path " in
67162378475aSmrg	    *" $absdir "*) ;;
67172378475aSmrg	    *)
67182378475aSmrg	      case "$compile_rpath " in
67192378475aSmrg	      *" $absdir "*) ;;
672014330f12Smrg	      *) func_append compile_rpath " $absdir" ;;
67212378475aSmrg	      esac
67222378475aSmrg	      ;;
67232378475aSmrg	    esac
67242378475aSmrg	    case " $sys_lib_dlsearch_path " in
67252378475aSmrg	    *" $libdir "*) ;;
67262378475aSmrg	    *)
67272378475aSmrg	      case "$finalize_rpath " in
67282378475aSmrg	      *" $libdir "*) ;;
672914330f12Smrg	      *) func_append finalize_rpath " $libdir" ;;
67302378475aSmrg	      esac
67312378475aSmrg	      ;;
67322378475aSmrg	    esac
67332378475aSmrg	  fi
67342378475aSmrg
67352378475aSmrg	  if test -n "$old_archive_from_expsyms_cmds"; then
67362378475aSmrg	    # figure out the soname
67372378475aSmrg	    set dummy $library_names
67382378475aSmrg	    shift
67392378475aSmrg	    realname="$1"
67402378475aSmrg	    shift
67412378475aSmrg	    libname=`eval "\\$ECHO \"$libname_spec\""`
67422378475aSmrg	    # use dlname if we got it. it's perfectly good, no?
67432378475aSmrg	    if test -n "$dlname"; then
67442378475aSmrg	      soname="$dlname"
67452378475aSmrg	    elif test -n "$soname_spec"; then
67462378475aSmrg	      # bleh windows
67472378475aSmrg	      case $host in
67482378475aSmrg	      *cygwin* | mingw* | *cegcc*)
67492378475aSmrg	        func_arith $current - $age
67502378475aSmrg		major=$func_arith_result
67512378475aSmrg		versuffix="-$major"
67522378475aSmrg		;;
67532378475aSmrg	      esac
67542378475aSmrg	      eval soname=\"$soname_spec\"
67552378475aSmrg	    else
67562378475aSmrg	      soname="$realname"
67572378475aSmrg	    fi
67582378475aSmrg
67592378475aSmrg	    # Make a new name for the extract_expsyms_cmds to use
67602378475aSmrg	    soroot="$soname"
67612378475aSmrg	    func_basename "$soroot"
67622378475aSmrg	    soname="$func_basename_result"
67632378475aSmrg	    func_stripname 'lib' '.dll' "$soname"
67642378475aSmrg	    newlib=libimp-$func_stripname_result.a
67652378475aSmrg
67662378475aSmrg	    # If the library has no export list, then create one now
67672378475aSmrg	    if test -f "$output_objdir/$soname-def"; then :
67682378475aSmrg	    else
67692378475aSmrg	      func_verbose "extracting exported symbol list from \`$soname'"
67702378475aSmrg	      func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
67712378475aSmrg	    fi
67722378475aSmrg
67732378475aSmrg	    # Create $newlib
67742378475aSmrg	    if test -f "$output_objdir/$newlib"; then :; else
67752378475aSmrg	      func_verbose "generating import library for \`$soname'"
67762378475aSmrg	      func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
67772378475aSmrg	    fi
67782378475aSmrg	    # make sure the library variables are pointing to the new library
67792378475aSmrg	    dir=$output_objdir
67802378475aSmrg	    linklib=$newlib
67812378475aSmrg	  fi # test -n "$old_archive_from_expsyms_cmds"
67822378475aSmrg
678314330f12Smrg	  if test "$linkmode" = prog || test "$opt_mode" != relink; then
67842378475aSmrg	    add_shlibpath=
67852378475aSmrg	    add_dir=
67862378475aSmrg	    add=
67872378475aSmrg	    lib_linked=yes
67882378475aSmrg	    case $hardcode_action in
67892378475aSmrg	    immediate | unsupported)
67902378475aSmrg	      if test "$hardcode_direct" = no; then
67912378475aSmrg		add="$dir/$linklib"
67922378475aSmrg		case $host in
67932378475aSmrg		  *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
67942378475aSmrg		  *-*-sysv4*uw2*) add_dir="-L$dir" ;;
67952378475aSmrg		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
67962378475aSmrg		    *-*-unixware7*) add_dir="-L$dir" ;;
67972378475aSmrg		  *-*-darwin* )
67982378475aSmrg		    # if the lib is a (non-dlopened) module then we can not
67992378475aSmrg		    # link against it, someone is ignoring the earlier warnings
68002378475aSmrg		    if /usr/bin/file -L $add 2> /dev/null |
68012378475aSmrg			 $GREP ": [^:]* bundle" >/dev/null ; then
68022378475aSmrg		      if test "X$dlopenmodule" != "X$lib"; then
68032378475aSmrg			$ECHO "*** Warning: lib $linklib is a module, not a shared library"
68042378475aSmrg			if test -z "$old_library" ; then
680514330f12Smrg			  echo
680614330f12Smrg			  echo "*** And there doesn't seem to be a static archive available"
680714330f12Smrg			  echo "*** The link will probably fail, sorry"
68082378475aSmrg			else
68092378475aSmrg			  add="$dir/$old_library"
68102378475aSmrg			fi
68112378475aSmrg		      elif test -n "$old_library"; then
68122378475aSmrg			add="$dir/$old_library"
68132378475aSmrg		      fi
68142378475aSmrg		    fi
68152378475aSmrg		esac
68162378475aSmrg	      elif test "$hardcode_minus_L" = no; then
68172378475aSmrg		case $host in
68182378475aSmrg		*-*-sunos*) add_shlibpath="$dir" ;;
68192378475aSmrg		esac
68202378475aSmrg		add_dir="-L$dir"
68212378475aSmrg		add="-l$name"
68222378475aSmrg	      elif test "$hardcode_shlibpath_var" = no; then
68232378475aSmrg		add_shlibpath="$dir"
68242378475aSmrg		add="-l$name"
68252378475aSmrg	      else
68262378475aSmrg		lib_linked=no
68272378475aSmrg	      fi
68282378475aSmrg	      ;;
68292378475aSmrg	    relink)
68302378475aSmrg	      if test "$hardcode_direct" = yes &&
68312378475aSmrg	         test "$hardcode_direct_absolute" = no; then
68322378475aSmrg		add="$dir/$linklib"
68332378475aSmrg	      elif test "$hardcode_minus_L" = yes; then
68342378475aSmrg		add_dir="-L$dir"
68352378475aSmrg		# Try looking first in the location we're being installed to.
68362378475aSmrg		if test -n "$inst_prefix_dir"; then
68372378475aSmrg		  case $libdir in
68382378475aSmrg		    [\\/]*)
683914330f12Smrg		      func_append add_dir " -L$inst_prefix_dir$libdir"
68402378475aSmrg		      ;;
68412378475aSmrg		  esac
68422378475aSmrg		fi
68432378475aSmrg		add="-l$name"
68442378475aSmrg	      elif test "$hardcode_shlibpath_var" = yes; then
68452378475aSmrg		add_shlibpath="$dir"
68462378475aSmrg		add="-l$name"
68472378475aSmrg	      else
68482378475aSmrg		lib_linked=no
68492378475aSmrg	      fi
68502378475aSmrg	      ;;
68512378475aSmrg	    *) lib_linked=no ;;
68522378475aSmrg	    esac
68532378475aSmrg
68542378475aSmrg	    if test "$lib_linked" != yes; then
68552378475aSmrg	      func_fatal_configuration "unsupported hardcode properties"
68562378475aSmrg	    fi
68572378475aSmrg
68582378475aSmrg	    if test -n "$add_shlibpath"; then
68592378475aSmrg	      case :$compile_shlibpath: in
68602378475aSmrg	      *":$add_shlibpath:"*) ;;
686114330f12Smrg	      *) func_append compile_shlibpath "$add_shlibpath:" ;;
68622378475aSmrg	      esac
68632378475aSmrg	    fi
68642378475aSmrg	    if test "$linkmode" = prog; then
68652378475aSmrg	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
68662378475aSmrg	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
68672378475aSmrg	    else
68682378475aSmrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
68692378475aSmrg	      test -n "$add" && deplibs="$add $deplibs"
68702378475aSmrg	      if test "$hardcode_direct" != yes &&
68712378475aSmrg		 test "$hardcode_minus_L" != yes &&
68722378475aSmrg		 test "$hardcode_shlibpath_var" = yes; then
68732378475aSmrg		case :$finalize_shlibpath: in
68742378475aSmrg		*":$libdir:"*) ;;
687514330f12Smrg		*) func_append finalize_shlibpath "$libdir:" ;;
68762378475aSmrg		esac
68772378475aSmrg	      fi
68782378475aSmrg	    fi
68792378475aSmrg	  fi
68802378475aSmrg
688114330f12Smrg	  if test "$linkmode" = prog || test "$opt_mode" = relink; then
68822378475aSmrg	    add_shlibpath=
68832378475aSmrg	    add_dir=
68842378475aSmrg	    add=
68852378475aSmrg	    # Finalize command for both is simple: just hardcode it.
68862378475aSmrg	    if test "$hardcode_direct" = yes &&
68872378475aSmrg	       test "$hardcode_direct_absolute" = no; then
68882378475aSmrg	      add="$libdir/$linklib"
68892378475aSmrg	    elif test "$hardcode_minus_L" = yes; then
68902378475aSmrg	      add_dir="-L$libdir"
68912378475aSmrg	      add="-l$name"
68922378475aSmrg	    elif test "$hardcode_shlibpath_var" = yes; then
68932378475aSmrg	      case :$finalize_shlibpath: in
68942378475aSmrg	      *":$libdir:"*) ;;
689514330f12Smrg	      *) func_append finalize_shlibpath "$libdir:" ;;
68962378475aSmrg	      esac
68972378475aSmrg	      add="-l$name"
68982378475aSmrg	    elif test "$hardcode_automatic" = yes; then
68992378475aSmrg	      if test -n "$inst_prefix_dir" &&
69002378475aSmrg		 test -f "$inst_prefix_dir$libdir/$linklib" ; then
69012378475aSmrg		add="$inst_prefix_dir$libdir/$linklib"
69022378475aSmrg	      else
69032378475aSmrg		add="$libdir/$linklib"
69042378475aSmrg	      fi
69052378475aSmrg	    else
69062378475aSmrg	      # We cannot seem to hardcode it, guess we'll fake it.
69072378475aSmrg	      add_dir="-L$libdir"
69082378475aSmrg	      # Try looking first in the location we're being installed to.
69092378475aSmrg	      if test -n "$inst_prefix_dir"; then
69102378475aSmrg		case $libdir in
69112378475aSmrg		  [\\/]*)
691214330f12Smrg		    func_append add_dir " -L$inst_prefix_dir$libdir"
69132378475aSmrg		    ;;
69142378475aSmrg		esac
69152378475aSmrg	      fi
69162378475aSmrg	      add="-l$name"
69172378475aSmrg	    fi
69182378475aSmrg
69192378475aSmrg	    if test "$linkmode" = prog; then
69202378475aSmrg	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
69212378475aSmrg	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
69222378475aSmrg	    else
69232378475aSmrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
69242378475aSmrg	      test -n "$add" && deplibs="$add $deplibs"
69252378475aSmrg	    fi
69262378475aSmrg	  fi
69272378475aSmrg	elif test "$linkmode" = prog; then
69282378475aSmrg	  # Here we assume that one of hardcode_direct or hardcode_minus_L
69292378475aSmrg	  # is not unsupported.  This is valid on all known static and
69302378475aSmrg	  # shared platforms.
69312378475aSmrg	  if test "$hardcode_direct" != unsupported; then
69322378475aSmrg	    test -n "$old_library" && linklib="$old_library"
69332378475aSmrg	    compile_deplibs="$dir/$linklib $compile_deplibs"
69342378475aSmrg	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
69352378475aSmrg	  else
69362378475aSmrg	    compile_deplibs="-l$name -L$dir $compile_deplibs"
69372378475aSmrg	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
69382378475aSmrg	  fi
69392378475aSmrg	elif test "$build_libtool_libs" = yes; then
69402378475aSmrg	  # Not a shared library
69412378475aSmrg	  if test "$deplibs_check_method" != pass_all; then
69422378475aSmrg	    # We're trying link a shared library against a static one
69432378475aSmrg	    # but the system doesn't support it.
69442378475aSmrg
69452378475aSmrg	    # Just print a warning and add the library to dependency_libs so
69462378475aSmrg	    # that the program can be linked against the static library.
694714330f12Smrg	    echo
69482378475aSmrg	    $ECHO "*** Warning: This system can not link to static lib archive $lib."
694914330f12Smrg	    echo "*** I have the capability to make that library automatically link in when"
695014330f12Smrg	    echo "*** you link to this library.  But I can only do this if you have a"
695114330f12Smrg	    echo "*** shared version of the library, which you do not appear to have."
69522378475aSmrg	    if test "$module" = yes; then
695314330f12Smrg	      echo "*** But as you try to build a module library, libtool will still create "
695414330f12Smrg	      echo "*** a static module, that should work as long as the dlopening application"
695514330f12Smrg	      echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
69562378475aSmrg	      if test -z "$global_symbol_pipe"; then
695714330f12Smrg		echo
695814330f12Smrg		echo "*** However, this would only work if libtool was able to extract symbol"
695914330f12Smrg		echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
696014330f12Smrg		echo "*** not find such a program.  So, this module is probably useless."
696114330f12Smrg		echo "*** \`nm' from GNU binutils and a full rebuild may help."
69622378475aSmrg	      fi
69632378475aSmrg	      if test "$build_old_libs" = no; then
69642378475aSmrg		build_libtool_libs=module
69652378475aSmrg		build_old_libs=yes
69662378475aSmrg	      else
69672378475aSmrg		build_libtool_libs=no
69682378475aSmrg	      fi
69692378475aSmrg	    fi
69702378475aSmrg	  else
69712378475aSmrg	    deplibs="$dir/$old_library $deplibs"
69722378475aSmrg	    link_static=yes
69732378475aSmrg	  fi
69742378475aSmrg	fi # link shared/static library?
69752378475aSmrg
69762378475aSmrg	if test "$linkmode" = lib; then
69772378475aSmrg	  if test -n "$dependency_libs" &&
69782378475aSmrg	     { test "$hardcode_into_libs" != yes ||
69792378475aSmrg	       test "$build_old_libs" = yes ||
69802378475aSmrg	       test "$link_static" = yes; }; then
69812378475aSmrg	    # Extract -R from dependency_libs
69822378475aSmrg	    temp_deplibs=
69832378475aSmrg	    for libdir in $dependency_libs; do
69842378475aSmrg	      case $libdir in
69852378475aSmrg	      -R*) func_stripname '-R' '' "$libdir"
69862378475aSmrg	           temp_xrpath=$func_stripname_result
69872378475aSmrg		   case " $xrpath " in
69882378475aSmrg		   *" $temp_xrpath "*) ;;
698914330f12Smrg		   *) func_append xrpath " $temp_xrpath";;
69902378475aSmrg		   esac;;
699114330f12Smrg	      *) func_append temp_deplibs " $libdir";;
69922378475aSmrg	      esac
69932378475aSmrg	    done
69942378475aSmrg	    dependency_libs="$temp_deplibs"
69952378475aSmrg	  fi
69962378475aSmrg
699714330f12Smrg	  func_append newlib_search_path " $absdir"
69982378475aSmrg	  # Link against this library
69992378475aSmrg	  test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
70002378475aSmrg	  # ... and its dependency_libs
70012378475aSmrg	  tmp_libs=
70022378475aSmrg	  for deplib in $dependency_libs; do
70032378475aSmrg	    newdependency_libs="$deplib $newdependency_libs"
700414330f12Smrg	    case $deplib in
700514330f12Smrg              -L*) func_stripname '-L' '' "$deplib"
700614330f12Smrg                   func_resolve_sysroot "$func_stripname_result";;
700714330f12Smrg              *) func_resolve_sysroot "$deplib" ;;
700814330f12Smrg            esac
700914330f12Smrg	    if $opt_preserve_dup_deps ; then
70102378475aSmrg	      case "$tmp_libs " in
701114330f12Smrg	      *" $func_resolve_sysroot_result "*)
701214330f12Smrg                func_append specialdeplibs " $func_resolve_sysroot_result" ;;
70132378475aSmrg	      esac
70142378475aSmrg	    fi
701514330f12Smrg	    func_append tmp_libs " $func_resolve_sysroot_result"
70162378475aSmrg	  done
70172378475aSmrg
70182378475aSmrg	  if test "$link_all_deplibs" != no; then
70192378475aSmrg	    # Add the search paths of all dependency libraries
70202378475aSmrg	    for deplib in $dependency_libs; do
702114330f12Smrg	      path=
70222378475aSmrg	      case $deplib in
70232378475aSmrg	      -L*) path="$deplib" ;;
70242378475aSmrg	      *.la)
702514330f12Smrg	        func_resolve_sysroot "$deplib"
702614330f12Smrg	        deplib=$func_resolve_sysroot_result
70272378475aSmrg	        func_dirname "$deplib" "" "."
702814330f12Smrg		dir=$func_dirname_result
70292378475aSmrg		# We need an absolute path.
70302378475aSmrg		case $dir in
70312378475aSmrg		[\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
70322378475aSmrg		*)
70332378475aSmrg		  absdir=`cd "$dir" && pwd`
70342378475aSmrg		  if test -z "$absdir"; then
70352378475aSmrg		    func_warning "cannot determine absolute directory name of \`$dir'"
70362378475aSmrg		    absdir="$dir"
70372378475aSmrg		  fi
70382378475aSmrg		  ;;
70392378475aSmrg		esac
70402378475aSmrg		if $GREP "^installed=no" $deplib > /dev/null; then
70412378475aSmrg		case $host in
70422378475aSmrg		*-*-darwin*)
70432378475aSmrg		  depdepl=
70442378475aSmrg		  eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
70452378475aSmrg		  if test -n "$deplibrary_names" ; then
70462378475aSmrg		    for tmp in $deplibrary_names ; do
70472378475aSmrg		      depdepl=$tmp
70482378475aSmrg		    done
70492378475aSmrg		    if test -f "$absdir/$objdir/$depdepl" ; then
70502378475aSmrg		      depdepl="$absdir/$objdir/$depdepl"
70512378475aSmrg		      darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
70522378475aSmrg                      if test -z "$darwin_install_name"; then
70532378475aSmrg                          darwin_install_name=`${OTOOL64} -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
70542378475aSmrg                      fi
705514330f12Smrg		      func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}"
705614330f12Smrg		      func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}"
70572378475aSmrg		      path=
70582378475aSmrg		    fi
70592378475aSmrg		  fi
70602378475aSmrg		  ;;
70612378475aSmrg		*)
70622378475aSmrg		  path="-L$absdir/$objdir"
70632378475aSmrg		  ;;
70642378475aSmrg		esac
70652378475aSmrg		else
70662378475aSmrg		  eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
70672378475aSmrg		  test -z "$libdir" && \
70682378475aSmrg		    func_fatal_error "\`$deplib' is not a valid libtool archive"
70692378475aSmrg		  test "$absdir" != "$libdir" && \
70702378475aSmrg		    func_warning "\`$deplib' seems to be moved"
70712378475aSmrg
70722378475aSmrg		  path="-L$absdir"
70732378475aSmrg		fi
70742378475aSmrg		;;
70752378475aSmrg	      esac
70762378475aSmrg	      case " $deplibs " in
70772378475aSmrg	      *" $path "*) ;;
70782378475aSmrg	      *) deplibs="$path $deplibs" ;;
70792378475aSmrg	      esac
70802378475aSmrg	    done
70812378475aSmrg	  fi # link_all_deplibs != no
70822378475aSmrg	fi # linkmode = lib
70832378475aSmrg      done # for deplib in $libs
70842378475aSmrg      if test "$pass" = link; then
70852378475aSmrg	if test "$linkmode" = "prog"; then
70862378475aSmrg	  compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
70872378475aSmrg	  finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
70882378475aSmrg	else
708914330f12Smrg	  compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
70902378475aSmrg	fi
70912378475aSmrg      fi
70922378475aSmrg      dependency_libs="$newdependency_libs"
70932378475aSmrg      if test "$pass" = dlpreopen; then
70942378475aSmrg	# Link the dlpreopened libraries before other libraries
70952378475aSmrg	for deplib in $save_deplibs; do
70962378475aSmrg	  deplibs="$deplib $deplibs"
70972378475aSmrg	done
70982378475aSmrg      fi
70992378475aSmrg      if test "$pass" != dlopen; then
71002378475aSmrg	if test "$pass" != conv; then
71012378475aSmrg	  # Make sure lib_search_path contains only unique directories.
71022378475aSmrg	  lib_search_path=
71032378475aSmrg	  for dir in $newlib_search_path; do
71042378475aSmrg	    case "$lib_search_path " in
71052378475aSmrg	    *" $dir "*) ;;
710614330f12Smrg	    *) func_append lib_search_path " $dir" ;;
71072378475aSmrg	    esac
71082378475aSmrg	  done
71092378475aSmrg	  newlib_search_path=
71102378475aSmrg	fi
71112378475aSmrg
71122378475aSmrg	if test "$linkmode,$pass" != "prog,link"; then
71132378475aSmrg	  vars="deplibs"
71142378475aSmrg	else
71152378475aSmrg	  vars="compile_deplibs finalize_deplibs"
71162378475aSmrg	fi
71172378475aSmrg	for var in $vars dependency_libs; do
71182378475aSmrg	  # Add libraries to $var in reverse order
71192378475aSmrg	  eval tmp_libs=\"\$$var\"
71202378475aSmrg	  new_libs=
71212378475aSmrg	  for deplib in $tmp_libs; do
71222378475aSmrg	    # FIXME: Pedantically, this is the right thing to do, so
71232378475aSmrg	    #        that some nasty dependency loop isn't accidentally
71242378475aSmrg	    #        broken:
71252378475aSmrg	    #new_libs="$deplib $new_libs"
71262378475aSmrg	    # Pragmatically, this seems to cause very few problems in
71272378475aSmrg	    # practice:
71282378475aSmrg	    case $deplib in
71292378475aSmrg	    -L*) new_libs="$deplib $new_libs" ;;
71302378475aSmrg	    -R*) ;;
71312378475aSmrg	    *)
71322378475aSmrg	      # And here is the reason: when a library appears more
71332378475aSmrg	      # than once as an explicit dependence of a library, or
71342378475aSmrg	      # is implicitly linked in more than once by the
71352378475aSmrg	      # compiler, it is considered special, and multiple
71362378475aSmrg	      # occurrences thereof are not removed.  Compare this
71372378475aSmrg	      # with having the same library being listed as a
71382378475aSmrg	      # dependency of multiple other libraries: in this case,
71392378475aSmrg	      # we know (pedantically, we assume) the library does not
71402378475aSmrg	      # need to be listed more than once, so we keep only the
71412378475aSmrg	      # last copy.  This is not always right, but it is rare
71422378475aSmrg	      # enough that we require users that really mean to play
71432378475aSmrg	      # such unportable linking tricks to link the library
71442378475aSmrg	      # using -Wl,-lname, so that libtool does not consider it
71452378475aSmrg	      # for duplicate removal.
71462378475aSmrg	      case " $specialdeplibs " in
71472378475aSmrg	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
71482378475aSmrg	      *)
71492378475aSmrg		case " $new_libs " in
71502378475aSmrg		*" $deplib "*) ;;
71512378475aSmrg		*) new_libs="$deplib $new_libs" ;;
71522378475aSmrg		esac
71532378475aSmrg		;;
71542378475aSmrg	      esac
71552378475aSmrg	      ;;
71562378475aSmrg	    esac
71572378475aSmrg	  done
71582378475aSmrg	  tmp_libs=
71592378475aSmrg	  for deplib in $new_libs; do
71602378475aSmrg	    case $deplib in
71612378475aSmrg	    -L*)
71622378475aSmrg	      case " $tmp_libs " in
71632378475aSmrg	      *" $deplib "*) ;;
716414330f12Smrg	      *) func_append tmp_libs " $deplib" ;;
71652378475aSmrg	      esac
71662378475aSmrg	      ;;
716714330f12Smrg	    *) func_append tmp_libs " $deplib" ;;
71682378475aSmrg	    esac
71692378475aSmrg	  done
71702378475aSmrg	  eval $var=\"$tmp_libs\"
71712378475aSmrg	done # for var
71722378475aSmrg      fi
71732378475aSmrg      # Last step: remove runtime libs from dependency_libs
71742378475aSmrg      # (they stay in deplibs)
71752378475aSmrg      tmp_libs=
71762378475aSmrg      for i in $dependency_libs ; do
71772378475aSmrg	case " $predeps $postdeps $compiler_lib_search_path " in
71782378475aSmrg	*" $i "*)
71792378475aSmrg	  i=""
71802378475aSmrg	  ;;
71812378475aSmrg	esac
71822378475aSmrg	if test -n "$i" ; then
718314330f12Smrg	  func_append tmp_libs " $i"
71842378475aSmrg	fi
71852378475aSmrg      done
71862378475aSmrg      dependency_libs=$tmp_libs
71872378475aSmrg    done # for pass
71882378475aSmrg    if test "$linkmode" = prog; then
71892378475aSmrg      dlfiles="$newdlfiles"
71902378475aSmrg    fi
71912378475aSmrg    if test "$linkmode" = prog || test "$linkmode" = lib; then
71922378475aSmrg      dlprefiles="$newdlprefiles"
71932378475aSmrg    fi
71942378475aSmrg
71952378475aSmrg    case $linkmode in
71962378475aSmrg    oldlib)
71972378475aSmrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
71982378475aSmrg	func_warning "\`-dlopen' is ignored for archives"
71992378475aSmrg      fi
72002378475aSmrg
72012378475aSmrg      case " $deplibs" in
72022378475aSmrg      *\ -l* | *\ -L*)
72032378475aSmrg	func_warning "\`-l' and \`-L' are ignored for archives" ;;
72042378475aSmrg      esac
72052378475aSmrg
72062378475aSmrg      test -n "$rpath" && \
72072378475aSmrg	func_warning "\`-rpath' is ignored for archives"
72082378475aSmrg
72092378475aSmrg      test -n "$xrpath" && \
72102378475aSmrg	func_warning "\`-R' is ignored for archives"
72112378475aSmrg
72122378475aSmrg      test -n "$vinfo" && \
72132378475aSmrg	func_warning "\`-version-info/-version-number' is ignored for archives"
72142378475aSmrg
72152378475aSmrg      test -n "$release" && \
72162378475aSmrg	func_warning "\`-release' is ignored for archives"
72172378475aSmrg
72182378475aSmrg      test -n "$export_symbols$export_symbols_regex" && \
72192378475aSmrg	func_warning "\`-export-symbols' is ignored for archives"
72202378475aSmrg
72212378475aSmrg      # Now set the variables for building old libraries.
72222378475aSmrg      build_libtool_libs=no
72232378475aSmrg      oldlibs="$output"
722414330f12Smrg      func_append objs "$old_deplibs"
72252378475aSmrg      ;;
72262378475aSmrg
72272378475aSmrg    lib)
72282378475aSmrg      # Make sure we only generate libraries of the form `libNAME.la'.
72292378475aSmrg      case $outputname in
72302378475aSmrg      lib*)
72312378475aSmrg	func_stripname 'lib' '.la' "$outputname"
72322378475aSmrg	name=$func_stripname_result
72332378475aSmrg	eval shared_ext=\"$shrext_cmds\"
72342378475aSmrg	eval libname=\"$libname_spec\"
72352378475aSmrg	;;
72362378475aSmrg      *)
72372378475aSmrg	test "$module" = no && \
72382378475aSmrg	  func_fatal_help "libtool library \`$output' must begin with \`lib'"
72392378475aSmrg
72402378475aSmrg	if test "$need_lib_prefix" != no; then
72412378475aSmrg	  # Add the "lib" prefix for modules if required
72422378475aSmrg	  func_stripname '' '.la' "$outputname"
72432378475aSmrg	  name=$func_stripname_result
72442378475aSmrg	  eval shared_ext=\"$shrext_cmds\"
72452378475aSmrg	  eval libname=\"$libname_spec\"
72462378475aSmrg	else
72472378475aSmrg	  func_stripname '' '.la' "$outputname"
72482378475aSmrg	  libname=$func_stripname_result
72492378475aSmrg	fi
72502378475aSmrg	;;
72512378475aSmrg      esac
72522378475aSmrg
72532378475aSmrg      if test -n "$objs"; then
72542378475aSmrg	if test "$deplibs_check_method" != pass_all; then
72552378475aSmrg	  func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs"
72562378475aSmrg	else
725714330f12Smrg	  echo
72582378475aSmrg	  $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
72592378475aSmrg	  $ECHO "*** objects $objs is not portable!"
726014330f12Smrg	  func_append libobjs " $objs"
72612378475aSmrg	fi
72622378475aSmrg      fi
72632378475aSmrg
72642378475aSmrg      test "$dlself" != no && \
72652378475aSmrg	func_warning "\`-dlopen self' is ignored for libtool libraries"
72662378475aSmrg
72672378475aSmrg      set dummy $rpath
72682378475aSmrg      shift
72692378475aSmrg      test "$#" -gt 1 && \
72702378475aSmrg	func_warning "ignoring multiple \`-rpath's for a libtool library"
72712378475aSmrg
72722378475aSmrg      install_libdir="$1"
72732378475aSmrg
72742378475aSmrg      oldlibs=
72752378475aSmrg      if test -z "$rpath"; then
72762378475aSmrg	if test "$build_libtool_libs" = yes; then
72772378475aSmrg	  # Building a libtool convenience library.
72782378475aSmrg	  # Some compilers have problems with a `.al' extension so
72792378475aSmrg	  # convenience libraries should have the same extension an
72802378475aSmrg	  # archive normally would.
72812378475aSmrg	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
72822378475aSmrg	  build_libtool_libs=convenience
72832378475aSmrg	  build_old_libs=yes
72842378475aSmrg	fi
72852378475aSmrg
72862378475aSmrg	test -n "$vinfo" && \
72872378475aSmrg	  func_warning "\`-version-info/-version-number' is ignored for convenience libraries"
72882378475aSmrg
72892378475aSmrg	test -n "$release" && \
72902378475aSmrg	  func_warning "\`-release' is ignored for convenience libraries"
72912378475aSmrg      else
72922378475aSmrg
72932378475aSmrg	# Parse the version information argument.
72942378475aSmrg	save_ifs="$IFS"; IFS=':'
72952378475aSmrg	set dummy $vinfo 0 0 0
72962378475aSmrg	shift
72972378475aSmrg	IFS="$save_ifs"
72982378475aSmrg
72992378475aSmrg	test -n "$7" && \
73002378475aSmrg	  func_fatal_help "too many parameters to \`-version-info'"
73012378475aSmrg
73022378475aSmrg	# convert absolute version numbers to libtool ages
73032378475aSmrg	# this retains compatibility with .la files and attempts
73042378475aSmrg	# to make the code below a bit more comprehensible
73052378475aSmrg
73062378475aSmrg	case $vinfo_number in
73072378475aSmrg	yes)
73082378475aSmrg	  number_major="$1"
73092378475aSmrg	  number_minor="$2"
73102378475aSmrg	  number_revision="$3"
73112378475aSmrg	  #
73122378475aSmrg	  # There are really only two kinds -- those that
73132378475aSmrg	  # use the current revision as the major version
73142378475aSmrg	  # and those that subtract age and use age as
73152378475aSmrg	  # a minor version.  But, then there is irix
73162378475aSmrg	  # which has an extra 1 added just for fun
73172378475aSmrg	  #
73182378475aSmrg	  case $version_type in
73192378475aSmrg	  darwin|linux|osf|windows|none)
73202378475aSmrg	    func_arith $number_major + $number_minor
73212378475aSmrg	    current=$func_arith_result
73222378475aSmrg	    age="$number_minor"
73232378475aSmrg	    revision="$number_revision"
73242378475aSmrg	    ;;
732514330f12Smrg	  freebsd-aout|freebsd-elf|qnx|sunos)
73262378475aSmrg	    current="$number_major"
73272378475aSmrg	    revision="$number_minor"
73282378475aSmrg	    age="0"
73292378475aSmrg	    ;;
73302378475aSmrg	  irix|nonstopux)
73312378475aSmrg	    func_arith $number_major + $number_minor
73322378475aSmrg	    current=$func_arith_result
73332378475aSmrg	    age="$number_minor"
73342378475aSmrg	    revision="$number_minor"
73352378475aSmrg	    lt_irix_increment=no
73362378475aSmrg	    ;;
73372378475aSmrg	  esac
73382378475aSmrg	  ;;
73392378475aSmrg	no)
73402378475aSmrg	  current="$1"
73412378475aSmrg	  revision="$2"
73422378475aSmrg	  age="$3"
73432378475aSmrg	  ;;
73442378475aSmrg	esac
73452378475aSmrg
73462378475aSmrg	# Check that each of the things are valid numbers.
73472378475aSmrg	case $current in
73482378475aSmrg	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]) ;;
73492378475aSmrg	*)
73502378475aSmrg	  func_error "CURRENT \`$current' must be a nonnegative integer"
73512378475aSmrg	  func_fatal_error "\`$vinfo' is not valid version information"
73522378475aSmrg	  ;;
73532378475aSmrg	esac
73542378475aSmrg
73552378475aSmrg	case $revision in
73562378475aSmrg	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]) ;;
73572378475aSmrg	*)
73582378475aSmrg	  func_error "REVISION \`$revision' must be a nonnegative integer"
73592378475aSmrg	  func_fatal_error "\`$vinfo' is not valid version information"
73602378475aSmrg	  ;;
73612378475aSmrg	esac
73622378475aSmrg
73632378475aSmrg	case $age in
73642378475aSmrg	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]) ;;
73652378475aSmrg	*)
73662378475aSmrg	  func_error "AGE \`$age' must be a nonnegative integer"
73672378475aSmrg	  func_fatal_error "\`$vinfo' is not valid version information"
73682378475aSmrg	  ;;
73692378475aSmrg	esac
73702378475aSmrg
73712378475aSmrg	if test "$age" -gt "$current"; then
73722378475aSmrg	  func_error "AGE \`$age' is greater than the current interface number \`$current'"
73732378475aSmrg	  func_fatal_error "\`$vinfo' is not valid version information"
73742378475aSmrg	fi
73752378475aSmrg
73762378475aSmrg	# Calculate the version variables.
73772378475aSmrg	major=
73782378475aSmrg	versuffix=
73792378475aSmrg	verstring=
73802378475aSmrg	case $version_type in
73812378475aSmrg	none) ;;
73822378475aSmrg
73832378475aSmrg	darwin)
73842378475aSmrg	  # Like Linux, but with the current version available in
73852378475aSmrg	  # verstring for coding it into the library header
73862378475aSmrg	  func_arith $current - $age
73872378475aSmrg	  major=.$func_arith_result
73882378475aSmrg	  versuffix="$major.$age.$revision"
73892378475aSmrg	  # Darwin ld doesn't like 0 for these options...
73902378475aSmrg	  func_arith $current + 1
73912378475aSmrg	  minor_current=$func_arith_result
73922378475aSmrg	  xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
73932378475aSmrg	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
73942378475aSmrg	  ;;
73952378475aSmrg
73962378475aSmrg	freebsd-aout)
73972378475aSmrg	  major=".$current"
73982378475aSmrg	  versuffix=".$current.$revision";
73992378475aSmrg	  ;;
74002378475aSmrg
74012378475aSmrg	freebsd-elf)
74022378475aSmrg	  major=".$current"
74032378475aSmrg	  versuffix=".$current"
74042378475aSmrg	  ;;
74052378475aSmrg
74062378475aSmrg	irix | nonstopux)
74072378475aSmrg	  if test "X$lt_irix_increment" = "Xno"; then
74082378475aSmrg	    func_arith $current - $age
74092378475aSmrg	  else
74102378475aSmrg	    func_arith $current - $age + 1
74112378475aSmrg	  fi
74122378475aSmrg	  major=$func_arith_result
74132378475aSmrg
74142378475aSmrg	  case $version_type in
74152378475aSmrg	    nonstopux) verstring_prefix=nonstopux ;;
74162378475aSmrg	    *)         verstring_prefix=sgi ;;
74172378475aSmrg	  esac
74182378475aSmrg	  verstring="$verstring_prefix$major.$revision"
74192378475aSmrg
74202378475aSmrg	  # Add in all the interfaces that we are compatible with.
74212378475aSmrg	  loop=$revision
74222378475aSmrg	  while test "$loop" -ne 0; do
74232378475aSmrg	    func_arith $revision - $loop
74242378475aSmrg	    iface=$func_arith_result
74252378475aSmrg	    func_arith $loop - 1
74262378475aSmrg	    loop=$func_arith_result
74272378475aSmrg	    verstring="$verstring_prefix$major.$iface:$verstring"
74282378475aSmrg	  done
74292378475aSmrg
74302378475aSmrg	  # Before this point, $major must not contain `.'.
74312378475aSmrg	  major=.$major
74322378475aSmrg	  versuffix="$major.$revision"
74332378475aSmrg	  ;;
74342378475aSmrg
74352378475aSmrg	linux)
74362378475aSmrg	  func_arith $current - $age
74372378475aSmrg	  major=.$func_arith_result
74382378475aSmrg	  versuffix="$major.$age.$revision"
74392378475aSmrg	  ;;
74402378475aSmrg
74412378475aSmrg	osf)
74422378475aSmrg	  func_arith $current - $age
74432378475aSmrg	  major=.$func_arith_result
74442378475aSmrg	  versuffix=".$current.$age.$revision"
74452378475aSmrg	  verstring="$current.$age.$revision"
74462378475aSmrg
74472378475aSmrg	  # Add in all the interfaces that we are compatible with.
74482378475aSmrg	  loop=$age
74492378475aSmrg	  while test "$loop" -ne 0; do
74502378475aSmrg	    func_arith $current - $loop
74512378475aSmrg	    iface=$func_arith_result
74522378475aSmrg	    func_arith $loop - 1
74532378475aSmrg	    loop=$func_arith_result
74542378475aSmrg	    verstring="$verstring:${iface}.0"
74552378475aSmrg	  done
74562378475aSmrg
74572378475aSmrg	  # Make executables depend on our current version.
745814330f12Smrg	  func_append verstring ":${current}.0"
74592378475aSmrg	  ;;
74602378475aSmrg
74612378475aSmrg	qnx)
74622378475aSmrg	  major=".$current"
74632378475aSmrg	  versuffix=".$current"
74642378475aSmrg	  ;;
74652378475aSmrg
74662378475aSmrg	sunos)
74672378475aSmrg	  major=".$current"
74682378475aSmrg	  versuffix=".$current.$revision"
74692378475aSmrg	  ;;
74702378475aSmrg
74712378475aSmrg	windows)
74722378475aSmrg	  # Use '-' rather than '.', since we only want one
74732378475aSmrg	  # extension on DOS 8.3 filesystems.
74742378475aSmrg	  func_arith $current - $age
74752378475aSmrg	  major=$func_arith_result
74762378475aSmrg	  versuffix="-$major"
74772378475aSmrg	  ;;
74782378475aSmrg
74792378475aSmrg	*)
74802378475aSmrg	  func_fatal_configuration "unknown library version type \`$version_type'"
74812378475aSmrg	  ;;
74822378475aSmrg	esac
74832378475aSmrg
74842378475aSmrg	# Clear the version info if we defaulted, and they specified a release.
74852378475aSmrg	if test -z "$vinfo" && test -n "$release"; then
74862378475aSmrg	  major=
74872378475aSmrg	  case $version_type in
74882378475aSmrg	  darwin)
74892378475aSmrg	    # we can't check for "0.0" in archive_cmds due to quoting
74902378475aSmrg	    # problems, so we reset it completely
74912378475aSmrg	    verstring=
74922378475aSmrg	    ;;
74932378475aSmrg	  *)
74942378475aSmrg	    verstring="0.0"
74952378475aSmrg	    ;;
74962378475aSmrg	  esac
74972378475aSmrg	  if test "$need_version" = no; then
74982378475aSmrg	    versuffix=
74992378475aSmrg	  else
75002378475aSmrg	    versuffix=".0.0"
75012378475aSmrg	  fi
75022378475aSmrg	fi
75032378475aSmrg
75042378475aSmrg	# Remove version info from name if versioning should be avoided
75052378475aSmrg	if test "$avoid_version" = yes && test "$need_version" = no; then
75062378475aSmrg	  major=
75072378475aSmrg	  versuffix=
75082378475aSmrg	  verstring=""
75092378475aSmrg	fi
75102378475aSmrg
75112378475aSmrg	# Check to see if the archive will have undefined symbols.
75122378475aSmrg	if test "$allow_undefined" = yes; then
75132378475aSmrg	  if test "$allow_undefined_flag" = unsupported; then
75142378475aSmrg	    func_warning "undefined symbols not allowed in $host shared libraries"
75152378475aSmrg	    build_libtool_libs=no
75162378475aSmrg	    build_old_libs=yes
75172378475aSmrg	  fi
75182378475aSmrg	else
75192378475aSmrg	  # Don't allow undefined symbols.
75202378475aSmrg	  allow_undefined_flag="$no_undefined_flag"
75212378475aSmrg	fi
75222378475aSmrg
75232378475aSmrg      fi
75242378475aSmrg
75252378475aSmrg      func_generate_dlsyms "$libname" "$libname" "yes"
752614330f12Smrg      func_append libobjs " $symfileobj"
75272378475aSmrg      test "X$libobjs" = "X " && libobjs=
75282378475aSmrg
752914330f12Smrg      if test "$opt_mode" != relink; then
75302378475aSmrg	# Remove our outputs, but don't remove object files since they
75312378475aSmrg	# may have been created when compiling PIC objects.
75322378475aSmrg	removelist=
75332378475aSmrg	tempremovelist=`$ECHO "$output_objdir/*"`
75342378475aSmrg	for p in $tempremovelist; do
75352378475aSmrg	  case $p in
75362378475aSmrg	    *.$objext | *.gcno)
75372378475aSmrg	       ;;
75382378475aSmrg	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
75392378475aSmrg	       if test "X$precious_files_regex" != "X"; then
75402378475aSmrg		 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
75412378475aSmrg		 then
75422378475aSmrg		   continue
75432378475aSmrg		 fi
75442378475aSmrg	       fi
754514330f12Smrg	       func_append removelist " $p"
75462378475aSmrg	       ;;
75472378475aSmrg	    *) ;;
75482378475aSmrg	  esac
75492378475aSmrg	done
75502378475aSmrg	test -n "$removelist" && \
75512378475aSmrg	  func_show_eval "${RM}r \$removelist"
75522378475aSmrg      fi
75532378475aSmrg
75542378475aSmrg      # Now set the variables for building old libraries.
75552378475aSmrg      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
755614330f12Smrg	func_append oldlibs " $output_objdir/$libname.$libext"
75572378475aSmrg
75582378475aSmrg	# Transform .lo files to .o files.
755914330f12Smrg	oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP`
75602378475aSmrg      fi
75612378475aSmrg
75622378475aSmrg      # Eliminate all temporary directories.
75632378475aSmrg      #for path in $notinst_path; do
756414330f12Smrg      #	lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
756514330f12Smrg      #	deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
756614330f12Smrg      #	dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
75672378475aSmrg      #done
75682378475aSmrg
75692378475aSmrg      if test -n "$xrpath"; then
75702378475aSmrg	# If the user specified any rpath flags, then add them.
75712378475aSmrg	temp_xrpath=
75722378475aSmrg	for libdir in $xrpath; do
757314330f12Smrg	  func_replace_sysroot "$libdir"
757414330f12Smrg	  func_append temp_xrpath " -R$func_replace_sysroot_result"
75752378475aSmrg	  case "$finalize_rpath " in
75762378475aSmrg	  *" $libdir "*) ;;
757714330f12Smrg	  *) func_append finalize_rpath " $libdir" ;;
75782378475aSmrg	  esac
75792378475aSmrg	done
75802378475aSmrg	if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
75812378475aSmrg	  dependency_libs="$temp_xrpath $dependency_libs"
75822378475aSmrg	fi
75832378475aSmrg      fi
75842378475aSmrg
75852378475aSmrg      # Make sure dlfiles contains only unique files that won't be dlpreopened
75862378475aSmrg      old_dlfiles="$dlfiles"
75872378475aSmrg      dlfiles=
75882378475aSmrg      for lib in $old_dlfiles; do
75892378475aSmrg	case " $dlprefiles $dlfiles " in
75902378475aSmrg	*" $lib "*) ;;
759114330f12Smrg	*) func_append dlfiles " $lib" ;;
75922378475aSmrg	esac
75932378475aSmrg      done
75942378475aSmrg
75952378475aSmrg      # Make sure dlprefiles contains only unique files
75962378475aSmrg      old_dlprefiles="$dlprefiles"
75972378475aSmrg      dlprefiles=
75982378475aSmrg      for lib in $old_dlprefiles; do
75992378475aSmrg	case "$dlprefiles " in
76002378475aSmrg	*" $lib "*) ;;
760114330f12Smrg	*) func_append dlprefiles " $lib" ;;
76022378475aSmrg	esac
76032378475aSmrg      done
76042378475aSmrg
76052378475aSmrg      if test "$build_libtool_libs" = yes; then
76062378475aSmrg	if test -n "$rpath"; then
76072378475aSmrg	  case $host in
760814330f12Smrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
76092378475aSmrg	    # these systems don't actually have a c library (as such)!
76102378475aSmrg	    ;;
76112378475aSmrg	  *-*-rhapsody* | *-*-darwin1.[012])
76122378475aSmrg	    # Rhapsody C library is in the System framework
761314330f12Smrg	    func_append deplibs " System.ltframework"
76142378475aSmrg	    ;;
76152378475aSmrg	  *-*-netbsd*)
76162378475aSmrg	    # Don't link with libc until the a.out ld.so is fixed.
76172378475aSmrg	    ;;
76182378475aSmrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
76192378475aSmrg	    # Do not include libc due to us having libc/libc_r.
76202378475aSmrg	    ;;
76212378475aSmrg	  *-*-sco3.2v5* | *-*-sco5v6*)
76222378475aSmrg	    # Causes problems with __ctype
76232378475aSmrg	    ;;
76242378475aSmrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
76252378475aSmrg	    # Compiler inserts libc in the correct place for threads to work
76262378475aSmrg	    ;;
76272378475aSmrg	  *)
76282378475aSmrg	    # Add libc to deplibs on all other systems if necessary.
76292378475aSmrg	    if test "$build_libtool_need_lc" = "yes"; then
763014330f12Smrg	      func_append deplibs " -lc"
76312378475aSmrg	    fi
76322378475aSmrg	    ;;
76332378475aSmrg	  esac
76342378475aSmrg	fi
76352378475aSmrg
76362378475aSmrg	# Transform deplibs into only deplibs that can be linked in shared.
76372378475aSmrg	name_save=$name
76382378475aSmrg	libname_save=$libname
76392378475aSmrg	release_save=$release
76402378475aSmrg	versuffix_save=$versuffix
76412378475aSmrg	major_save=$major
76422378475aSmrg	# I'm not sure if I'm treating the release correctly.  I think
76432378475aSmrg	# release should show up in the -l (ie -lgmp5) so we don't want to
76442378475aSmrg	# add it in twice.  Is that correct?
76452378475aSmrg	release=""
76462378475aSmrg	versuffix=""
76472378475aSmrg	major=""
76482378475aSmrg	newdeplibs=
76492378475aSmrg	droppeddeps=no
76502378475aSmrg	case $deplibs_check_method in
76512378475aSmrg	pass_all)
76522378475aSmrg	  # Don't check for shared/static.  Everything works.
76532378475aSmrg	  # This might be a little naive.  We might want to check
76542378475aSmrg	  # whether the library exists or not.  But this is on
76552378475aSmrg	  # osf3 & osf4 and I'm not really sure... Just
76562378475aSmrg	  # implementing what was already the behavior.
76572378475aSmrg	  newdeplibs=$deplibs
76582378475aSmrg	  ;;
76592378475aSmrg	test_compile)
76602378475aSmrg	  # This code stresses the "libraries are programs" paradigm to its
76612378475aSmrg	  # limits. Maybe even breaks it.  We compile a program, linking it
76622378475aSmrg	  # against the deplibs as a proxy for the library.  Then we can check
76632378475aSmrg	  # whether they linked in statically or dynamically with ldd.
76642378475aSmrg	  $opt_dry_run || $RM conftest.c
76652378475aSmrg	  cat > conftest.c <<EOF
76662378475aSmrg	  int main() { return 0; }
76672378475aSmrgEOF
76682378475aSmrg	  $opt_dry_run || $RM conftest
76692378475aSmrg	  if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
76702378475aSmrg	    ldd_output=`ldd conftest`
76712378475aSmrg	    for i in $deplibs; do
76722378475aSmrg	      case $i in
76732378475aSmrg	      -l*)
76742378475aSmrg		func_stripname -l '' "$i"
76752378475aSmrg		name=$func_stripname_result
76762378475aSmrg		if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
76772378475aSmrg		  case " $predeps $postdeps " in
76782378475aSmrg		  *" $i "*)
767914330f12Smrg		    func_append newdeplibs " $i"
76802378475aSmrg		    i=""
76812378475aSmrg		    ;;
76822378475aSmrg		  esac
76832378475aSmrg		fi
76842378475aSmrg		if test -n "$i" ; then
76852378475aSmrg		  libname=`eval "\\$ECHO \"$libname_spec\""`
76862378475aSmrg		  deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
76872378475aSmrg		  set dummy $deplib_matches; shift
76882378475aSmrg		  deplib_match=$1
76892378475aSmrg		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
769014330f12Smrg		    func_append newdeplibs " $i"
76912378475aSmrg		  else
76922378475aSmrg		    droppeddeps=yes
769314330f12Smrg		    echo
76942378475aSmrg		    $ECHO "*** Warning: dynamic linker does not accept needed library $i."
769514330f12Smrg		    echo "*** I have the capability to make that library automatically link in when"
769614330f12Smrg		    echo "*** you link to this library.  But I can only do this if you have a"
769714330f12Smrg		    echo "*** shared version of the library, which I believe you do not have"
769814330f12Smrg		    echo "*** because a test_compile did reveal that the linker did not use it for"
769914330f12Smrg		    echo "*** its dynamic dependency list that programs get resolved with at runtime."
77002378475aSmrg		  fi
77012378475aSmrg		fi
77022378475aSmrg		;;
77032378475aSmrg	      *)
770414330f12Smrg		func_append newdeplibs " $i"
77052378475aSmrg		;;
77062378475aSmrg	      esac
77072378475aSmrg	    done
77082378475aSmrg	  else
77092378475aSmrg	    # Error occurred in the first compile.  Let's try to salvage
77102378475aSmrg	    # the situation: Compile a separate program for each library.
77112378475aSmrg	    for i in $deplibs; do
77122378475aSmrg	      case $i in
77132378475aSmrg	      -l*)
77142378475aSmrg		func_stripname -l '' "$i"
77152378475aSmrg		name=$func_stripname_result
77162378475aSmrg		$opt_dry_run || $RM conftest
77172378475aSmrg		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
77182378475aSmrg		  ldd_output=`ldd conftest`
77192378475aSmrg		  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
77202378475aSmrg		    case " $predeps $postdeps " in
77212378475aSmrg		    *" $i "*)
772214330f12Smrg		      func_append newdeplibs " $i"
77232378475aSmrg		      i=""
77242378475aSmrg		      ;;
77252378475aSmrg		    esac
77262378475aSmrg		  fi
77272378475aSmrg		  if test -n "$i" ; then
77282378475aSmrg		    libname=`eval "\\$ECHO \"$libname_spec\""`
77292378475aSmrg		    deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
77302378475aSmrg		    set dummy $deplib_matches; shift
77312378475aSmrg		    deplib_match=$1
77322378475aSmrg		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
773314330f12Smrg		      func_append newdeplibs " $i"
77342378475aSmrg		    else
77352378475aSmrg		      droppeddeps=yes
773614330f12Smrg		      echo
77372378475aSmrg		      $ECHO "*** Warning: dynamic linker does not accept needed library $i."
773814330f12Smrg		      echo "*** I have the capability to make that library automatically link in when"
773914330f12Smrg		      echo "*** you link to this library.  But I can only do this if you have a"
774014330f12Smrg		      echo "*** shared version of the library, which you do not appear to have"
774114330f12Smrg		      echo "*** because a test_compile did reveal that the linker did not use this one"
774214330f12Smrg		      echo "*** as a dynamic dependency that programs can get resolved with at runtime."
77432378475aSmrg		    fi
77442378475aSmrg		  fi
77452378475aSmrg		else
77462378475aSmrg		  droppeddeps=yes
774714330f12Smrg		  echo
77482378475aSmrg		  $ECHO "*** Warning!  Library $i is needed by this library but I was not able to"
774914330f12Smrg		  echo "*** make it link in!  You will probably need to install it or some"
775014330f12Smrg		  echo "*** library that it depends on before this library will be fully"
775114330f12Smrg		  echo "*** functional.  Installing it before continuing would be even better."
77522378475aSmrg		fi
77532378475aSmrg		;;
77542378475aSmrg	      *)
775514330f12Smrg		func_append newdeplibs " $i"
77562378475aSmrg		;;
77572378475aSmrg	      esac
77582378475aSmrg	    done
77592378475aSmrg	  fi
77602378475aSmrg	  ;;
77612378475aSmrg	file_magic*)
77622378475aSmrg	  set dummy $deplibs_check_method; shift
77632378475aSmrg	  file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
77642378475aSmrg	  for a_deplib in $deplibs; do
77652378475aSmrg	    case $a_deplib in
77662378475aSmrg	    -l*)
77672378475aSmrg	      func_stripname -l '' "$a_deplib"
77682378475aSmrg	      name=$func_stripname_result
77692378475aSmrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
77702378475aSmrg		case " $predeps $postdeps " in
77712378475aSmrg		*" $a_deplib "*)
777214330f12Smrg		  func_append newdeplibs " $a_deplib"
77732378475aSmrg		  a_deplib=""
77742378475aSmrg		  ;;
77752378475aSmrg		esac
77762378475aSmrg	      fi
77772378475aSmrg	      if test -n "$a_deplib" ; then
77782378475aSmrg		libname=`eval "\\$ECHO \"$libname_spec\""`
777914330f12Smrg		if test -n "$file_magic_glob"; then
778014330f12Smrg		  libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob`
778114330f12Smrg		else
778214330f12Smrg		  libnameglob=$libname
778314330f12Smrg		fi
778414330f12Smrg		test "$want_nocaseglob" = yes && nocaseglob=`shopt -p nocaseglob`
77852378475aSmrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
778614330f12Smrg		  if test "$want_nocaseglob" = yes; then
778714330f12Smrg		    shopt -s nocaseglob
778814330f12Smrg		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
778914330f12Smrg		    $nocaseglob
779014330f12Smrg		  else
779114330f12Smrg		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
779214330f12Smrg		  fi
77932378475aSmrg		  for potent_lib in $potential_libs; do
77942378475aSmrg		      # Follow soft links.
77952378475aSmrg		      if ls -lLd "$potent_lib" 2>/dev/null |
77962378475aSmrg			 $GREP " -> " >/dev/null; then
77972378475aSmrg			continue
77982378475aSmrg		      fi
77992378475aSmrg		      # The statement above tries to avoid entering an
78002378475aSmrg		      # endless loop below, in case of cyclic links.
78012378475aSmrg		      # We might still enter an endless loop, since a link
78022378475aSmrg		      # loop can be closed while we follow links,
78032378475aSmrg		      # but so what?
78042378475aSmrg		      potlib="$potent_lib"
78052378475aSmrg		      while test -h "$potlib" 2>/dev/null; do
78062378475aSmrg			potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
78072378475aSmrg			case $potliblink in
78082378475aSmrg			[\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
780914330f12Smrg			*) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";;
78102378475aSmrg			esac
78112378475aSmrg		      done
78122378475aSmrg		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
78132378475aSmrg			 $SED -e 10q |
78142378475aSmrg			 $EGREP "$file_magic_regex" > /dev/null; then
781514330f12Smrg			func_append newdeplibs " $a_deplib"
78162378475aSmrg			a_deplib=""
78172378475aSmrg			break 2
78182378475aSmrg		      fi
78192378475aSmrg		  done
78202378475aSmrg		done
78212378475aSmrg	      fi
78222378475aSmrg	      if test -n "$a_deplib" ; then
78232378475aSmrg		droppeddeps=yes
782414330f12Smrg		echo
78252378475aSmrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
782614330f12Smrg		echo "*** I have the capability to make that library automatically link in when"
782714330f12Smrg		echo "*** you link to this library.  But I can only do this if you have a"
782814330f12Smrg		echo "*** shared version of the library, which you do not appear to have"
782914330f12Smrg		echo "*** because I did check the linker path looking for a file starting"
78302378475aSmrg		if test -z "$potlib" ; then
78312378475aSmrg		  $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
78322378475aSmrg		else
78332378475aSmrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
78342378475aSmrg		  $ECHO "*** using a file magic. Last file checked: $potlib"
78352378475aSmrg		fi
78362378475aSmrg	      fi
78372378475aSmrg	      ;;
78382378475aSmrg	    *)
78392378475aSmrg	      # Add a -L argument.
784014330f12Smrg	      func_append newdeplibs " $a_deplib"
78412378475aSmrg	      ;;
78422378475aSmrg	    esac
78432378475aSmrg	  done # Gone through all deplibs.
78442378475aSmrg	  ;;
78452378475aSmrg	match_pattern*)
78462378475aSmrg	  set dummy $deplibs_check_method; shift
78472378475aSmrg	  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
78482378475aSmrg	  for a_deplib in $deplibs; do
78492378475aSmrg	    case $a_deplib in
78502378475aSmrg	    -l*)
78512378475aSmrg	      func_stripname -l '' "$a_deplib"
78522378475aSmrg	      name=$func_stripname_result
78532378475aSmrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
78542378475aSmrg		case " $predeps $postdeps " in
78552378475aSmrg		*" $a_deplib "*)
785614330f12Smrg		  func_append newdeplibs " $a_deplib"
78572378475aSmrg		  a_deplib=""
78582378475aSmrg		  ;;
78592378475aSmrg		esac
78602378475aSmrg	      fi
78612378475aSmrg	      if test -n "$a_deplib" ; then
78622378475aSmrg		libname=`eval "\\$ECHO \"$libname_spec\""`
78632378475aSmrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
78642378475aSmrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
78652378475aSmrg		  for potent_lib in $potential_libs; do
78662378475aSmrg		    potlib="$potent_lib" # see symlink-check above in file_magic test
786714330f12Smrg		    if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
78682378475aSmrg		       $EGREP "$match_pattern_regex" > /dev/null; then
786914330f12Smrg		      func_append newdeplibs " $a_deplib"
78702378475aSmrg		      a_deplib=""
78712378475aSmrg		      break 2
78722378475aSmrg		    fi
78732378475aSmrg		  done
78742378475aSmrg		done
78752378475aSmrg	      fi
78762378475aSmrg	      if test -n "$a_deplib" ; then
78772378475aSmrg		droppeddeps=yes
787814330f12Smrg		echo
78792378475aSmrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
788014330f12Smrg		echo "*** I have the capability to make that library automatically link in when"
788114330f12Smrg		echo "*** you link to this library.  But I can only do this if you have a"
788214330f12Smrg		echo "*** shared version of the library, which you do not appear to have"
788314330f12Smrg		echo "*** because I did check the linker path looking for a file starting"
78842378475aSmrg		if test -z "$potlib" ; then
78852378475aSmrg		  $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
78862378475aSmrg		else
78872378475aSmrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
78882378475aSmrg		  $ECHO "*** using a regex pattern. Last file checked: $potlib"
78892378475aSmrg		fi
78902378475aSmrg	      fi
78912378475aSmrg	      ;;
78922378475aSmrg	    *)
78932378475aSmrg	      # Add a -L argument.
789414330f12Smrg	      func_append newdeplibs " $a_deplib"
78952378475aSmrg	      ;;
78962378475aSmrg	    esac
78972378475aSmrg	  done # Gone through all deplibs.
78982378475aSmrg	  ;;
78992378475aSmrg	none | unknown | *)
79002378475aSmrg	  newdeplibs=""
790114330f12Smrg	  tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
79022378475aSmrg	  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
79032378475aSmrg	    for i in $predeps $postdeps ; do
79042378475aSmrg	      # can't use Xsed below, because $i might contain '/'
790514330f12Smrg	      tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"`
79062378475aSmrg	    done
79072378475aSmrg	  fi
790814330f12Smrg	  case $tmp_deplibs in
790914330f12Smrg	  *[!\	\ ]*)
791014330f12Smrg	    echo
79112378475aSmrg	    if test "X$deplibs_check_method" = "Xnone"; then
791214330f12Smrg	      echo "*** Warning: inter-library dependencies are not supported in this platform."
79132378475aSmrg	    else
791414330f12Smrg	      echo "*** Warning: inter-library dependencies are not known to be supported."
79152378475aSmrg	    fi
791614330f12Smrg	    echo "*** All declared inter-library dependencies are being dropped."
79172378475aSmrg	    droppeddeps=yes
791814330f12Smrg	    ;;
791914330f12Smrg	  esac
79202378475aSmrg	  ;;
79212378475aSmrg	esac
79222378475aSmrg	versuffix=$versuffix_save
79232378475aSmrg	major=$major_save
79242378475aSmrg	release=$release_save
79252378475aSmrg	libname=$libname_save
79262378475aSmrg	name=$name_save
79272378475aSmrg
79282378475aSmrg	case $host in
79292378475aSmrg	*-*-rhapsody* | *-*-darwin1.[012])
79302378475aSmrg	  # On Rhapsody replace the C library with the System framework
793114330f12Smrg	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
79322378475aSmrg	  ;;
79332378475aSmrg	esac
79342378475aSmrg
79352378475aSmrg	if test "$droppeddeps" = yes; then
79362378475aSmrg	  if test "$module" = yes; then
793714330f12Smrg	    echo
793814330f12Smrg	    echo "*** Warning: libtool could not satisfy all declared inter-library"
79392378475aSmrg	    $ECHO "*** dependencies of module $libname.  Therefore, libtool will create"
794014330f12Smrg	    echo "*** a static module, that should work as long as the dlopening"
794114330f12Smrg	    echo "*** application is linked with the -dlopen flag."
79422378475aSmrg	    if test -z "$global_symbol_pipe"; then
794314330f12Smrg	      echo
794414330f12Smrg	      echo "*** However, this would only work if libtool was able to extract symbol"
794514330f12Smrg	      echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
794614330f12Smrg	      echo "*** not find such a program.  So, this module is probably useless."
794714330f12Smrg	      echo "*** \`nm' from GNU binutils and a full rebuild may help."
79482378475aSmrg	    fi
79492378475aSmrg	    if test "$build_old_libs" = no; then
79502378475aSmrg	      oldlibs="$output_objdir/$libname.$libext"
79512378475aSmrg	      build_libtool_libs=module
79522378475aSmrg	      build_old_libs=yes
79532378475aSmrg	    else
79542378475aSmrg	      build_libtool_libs=no
79552378475aSmrg	    fi
79562378475aSmrg	  else
795714330f12Smrg	    echo "*** The inter-library dependencies that have been dropped here will be"
795814330f12Smrg	    echo "*** automatically added whenever a program is linked with this library"
795914330f12Smrg	    echo "*** or is declared to -dlopen it."
79602378475aSmrg
79612378475aSmrg	    if test "$allow_undefined" = no; then
796214330f12Smrg	      echo
796314330f12Smrg	      echo "*** Since this library must not contain undefined symbols,"
796414330f12Smrg	      echo "*** because either the platform does not support them or"
796514330f12Smrg	      echo "*** it was explicitly requested with -no-undefined,"
796614330f12Smrg	      echo "*** libtool will only create a static version of it."
79672378475aSmrg	      if test "$build_old_libs" = no; then
79682378475aSmrg		oldlibs="$output_objdir/$libname.$libext"
79692378475aSmrg		build_libtool_libs=module
79702378475aSmrg		build_old_libs=yes
79712378475aSmrg	      else
79722378475aSmrg		build_libtool_libs=no
79732378475aSmrg	      fi
79742378475aSmrg	    fi
79752378475aSmrg	  fi
79762378475aSmrg	fi
79772378475aSmrg	# Done checking deplibs!
79782378475aSmrg	deplibs=$newdeplibs
79792378475aSmrg      fi
79802378475aSmrg      # Time to change all our "foo.ltframework" stuff back to "-framework foo"
79812378475aSmrg      case $host in
79822378475aSmrg	*-*-darwin*)
798314330f12Smrg	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
798414330f12Smrg	  new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
798514330f12Smrg	  deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
79862378475aSmrg	  ;;
79872378475aSmrg      esac
79882378475aSmrg
79892378475aSmrg      # move library search paths that coincide with paths to not yet
79902378475aSmrg      # installed libraries to the beginning of the library search list
79912378475aSmrg      new_libs=
79922378475aSmrg      for path in $notinst_path; do
79932378475aSmrg	case " $new_libs " in
79942378475aSmrg	*" -L$path/$objdir "*) ;;
79952378475aSmrg	*)
79962378475aSmrg	  case " $deplibs " in
79972378475aSmrg	  *" -L$path/$objdir "*)
799814330f12Smrg	    func_append new_libs " -L$path/$objdir" ;;
79992378475aSmrg	  esac
80002378475aSmrg	  ;;
80012378475aSmrg	esac
80022378475aSmrg      done
80032378475aSmrg      for deplib in $deplibs; do
80042378475aSmrg	case $deplib in
80052378475aSmrg	-L*)
80062378475aSmrg	  case " $new_libs " in
80072378475aSmrg	  *" $deplib "*) ;;
800814330f12Smrg	  *) func_append new_libs " $deplib" ;;
80092378475aSmrg	  esac
80102378475aSmrg	  ;;
801114330f12Smrg	*) func_append new_libs " $deplib" ;;
80122378475aSmrg	esac
80132378475aSmrg      done
80142378475aSmrg      deplibs="$new_libs"
80152378475aSmrg
80162378475aSmrg      # All the library-specific variables (install_libdir is set above).
80172378475aSmrg      library_names=
80182378475aSmrg      old_library=
80192378475aSmrg      dlname=
80202378475aSmrg
80212378475aSmrg      # Test again, we may have decided not to build it any more
80222378475aSmrg      if test "$build_libtool_libs" = yes; then
80232378475aSmrg	if test "$hardcode_into_libs" = yes; then
80242378475aSmrg	  # Hardcode the library paths
80252378475aSmrg	  hardcode_libdirs=
80262378475aSmrg	  dep_rpath=
80272378475aSmrg	  rpath="$finalize_rpath"
802814330f12Smrg	  test "$opt_mode" != relink && rpath="$compile_rpath$rpath"
80292378475aSmrg	  for libdir in $rpath; do
80302378475aSmrg	    if test -n "$hardcode_libdir_flag_spec"; then
80312378475aSmrg	      if test -n "$hardcode_libdir_separator"; then
803214330f12Smrg		func_replace_sysroot "$libdir"
803314330f12Smrg		libdir=$func_replace_sysroot_result
80342378475aSmrg		if test -z "$hardcode_libdirs"; then
80352378475aSmrg		  hardcode_libdirs="$libdir"
80362378475aSmrg		else
80372378475aSmrg		  # Just accumulate the unique libdirs.
80382378475aSmrg		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
80392378475aSmrg		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
80402378475aSmrg		    ;;
80412378475aSmrg		  *)
804214330f12Smrg		    func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
80432378475aSmrg		    ;;
80442378475aSmrg		  esac
80452378475aSmrg		fi
80462378475aSmrg	      else
80472378475aSmrg		eval flag=\"$hardcode_libdir_flag_spec\"
804814330f12Smrg		func_append dep_rpath " $flag"
80492378475aSmrg	      fi
80502378475aSmrg	    elif test -n "$runpath_var"; then
80512378475aSmrg	      case "$perm_rpath " in
80522378475aSmrg	      *" $libdir "*) ;;
805314330f12Smrg	      *) func_apped perm_rpath " $libdir" ;;
80542378475aSmrg	      esac
80552378475aSmrg	    fi
80562378475aSmrg	  done
80572378475aSmrg	  # Substitute the hardcoded libdirs into the rpath.
80582378475aSmrg	  if test -n "$hardcode_libdir_separator" &&
80592378475aSmrg	     test -n "$hardcode_libdirs"; then
80602378475aSmrg	    libdir="$hardcode_libdirs"
80612378475aSmrg	    if test -n "$hardcode_libdir_flag_spec_ld"; then
80622378475aSmrg	      eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\"
80632378475aSmrg	    else
80642378475aSmrg	      eval dep_rpath=\"$hardcode_libdir_flag_spec\"
80652378475aSmrg	    fi
80662378475aSmrg	  fi
80672378475aSmrg	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
80682378475aSmrg	    # We should set the runpath_var.
80692378475aSmrg	    rpath=
80702378475aSmrg	    for dir in $perm_rpath; do
807114330f12Smrg	      func_append rpath "$dir:"
80722378475aSmrg	    done
80732378475aSmrg	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
80742378475aSmrg	  fi
80752378475aSmrg	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
80762378475aSmrg	fi
807795b296d0Smrg
80782378475aSmrg	shlibpath="$finalize_shlibpath"
807914330f12Smrg	test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
80802378475aSmrg	if test -n "$shlibpath"; then
80812378475aSmrg	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
80822378475aSmrg	fi
808395b296d0Smrg
80842378475aSmrg	# Get the real and link names of the library.
80852378475aSmrg	eval shared_ext=\"$shrext_cmds\"
80862378475aSmrg	eval library_names=\"$library_names_spec\"
80872378475aSmrg	set dummy $library_names
80882378475aSmrg	shift
80892378475aSmrg	realname="$1"
80902378475aSmrg	shift
809195b296d0Smrg
80922378475aSmrg	if test -n "$soname_spec"; then
80932378475aSmrg	  eval soname=\"$soname_spec\"
80942378475aSmrg	else
80952378475aSmrg	  soname="$realname"
80962378475aSmrg	fi
80972378475aSmrg	if test -z "$dlname"; then
80982378475aSmrg	  dlname=$soname
80992378475aSmrg	fi
810095b296d0Smrg
81012378475aSmrg	lib="$output_objdir/$realname"
81022378475aSmrg	linknames=
81032378475aSmrg	for link
81042378475aSmrg	do
810514330f12Smrg	  func_append linknames " $link"
81062378475aSmrg	done
810795b296d0Smrg
81082378475aSmrg	# Use standard objects if they are pic
810914330f12Smrg	test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
81102378475aSmrg	test "X$libobjs" = "X " && libobjs=
811195b296d0Smrg
81122378475aSmrg	delfiles=
81132378475aSmrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
81142378475aSmrg	  $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
81152378475aSmrg	  export_symbols="$output_objdir/$libname.uexp"
811614330f12Smrg	  func_append delfiles " $export_symbols"
81172378475aSmrg	fi
811895b296d0Smrg
81192378475aSmrg	orig_export_symbols=
81202378475aSmrg	case $host_os in
81212378475aSmrg	cygwin* | mingw* | cegcc*)
81222378475aSmrg	  if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
81232378475aSmrg	    # exporting using user supplied symfile
81242378475aSmrg	    if test "x`$SED 1q $export_symbols`" != xEXPORTS; then
81252378475aSmrg	      # and it's NOT already a .def file. Must figure out
81262378475aSmrg	      # which of the given symbols are data symbols and tag
81272378475aSmrg	      # them as such. So, trigger use of export_symbols_cmds.
81282378475aSmrg	      # export_symbols gets reassigned inside the "prepare
81292378475aSmrg	      # the list of exported symbols" if statement, so the
81302378475aSmrg	      # include_expsyms logic still works.
81312378475aSmrg	      orig_export_symbols="$export_symbols"
81322378475aSmrg	      export_symbols=
81332378475aSmrg	      always_export_symbols=yes
81342378475aSmrg	    fi
81352378475aSmrg	  fi
81362378475aSmrg	  ;;
81372378475aSmrg	esac
813895b296d0Smrg
81392378475aSmrg	# Prepare the list of exported symbols
81402378475aSmrg	if test -z "$export_symbols"; then
81412378475aSmrg	  if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
81422378475aSmrg	    func_verbose "generating symbol list for \`$libname.la'"
81432378475aSmrg	    export_symbols="$output_objdir/$libname.exp"
81442378475aSmrg	    $opt_dry_run || $RM $export_symbols
81452378475aSmrg	    cmds=$export_symbols_cmds
81462378475aSmrg	    save_ifs="$IFS"; IFS='~'
814714330f12Smrg	    for cmd1 in $cmds; do
81482378475aSmrg	      IFS="$save_ifs"
814914330f12Smrg	      # Take the normal branch if the nm_file_list_spec branch
815014330f12Smrg	      # doesn't work or if tool conversion is not needed.
815114330f12Smrg	      case $nm_file_list_spec~$to_tool_file_cmd in
815214330f12Smrg		*~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*)
815314330f12Smrg		  try_normal_branch=yes
815414330f12Smrg		  eval cmd=\"$cmd1\"
815514330f12Smrg		  func_len " $cmd"
815614330f12Smrg		  len=$func_len_result
815714330f12Smrg		  ;;
815814330f12Smrg		*)
815914330f12Smrg		  try_normal_branch=no
816014330f12Smrg		  ;;
816114330f12Smrg	      esac
816214330f12Smrg	      if test "$try_normal_branch" = yes \
816314330f12Smrg		 && { test "$len" -lt "$max_cmd_len" \
816414330f12Smrg		      || test "$max_cmd_len" -le -1; }
816514330f12Smrg	      then
816614330f12Smrg		func_show_eval "$cmd" 'exit $?'
816714330f12Smrg		skipped_export=false
816814330f12Smrg	      elif test -n "$nm_file_list_spec"; then
816914330f12Smrg		func_basename "$output"
817014330f12Smrg		output_la=$func_basename_result
817114330f12Smrg		save_libobjs=$libobjs
817214330f12Smrg		save_output=$output
817314330f12Smrg		output=${output_objdir}/${output_la}.nm
817414330f12Smrg		func_to_tool_file "$output"
817514330f12Smrg		libobjs=$nm_file_list_spec$func_to_tool_file_result
817614330f12Smrg		func_append delfiles " $output"
817714330f12Smrg		func_verbose "creating $NM input file list: $output"
817814330f12Smrg		for obj in $save_libobjs; do
817914330f12Smrg		  func_to_tool_file "$obj"
818014330f12Smrg		  $ECHO "$func_to_tool_file_result"
818114330f12Smrg		done > "$output"
818214330f12Smrg		eval cmd=\"$cmd1\"
81832378475aSmrg		func_show_eval "$cmd" 'exit $?'
818414330f12Smrg		output=$save_output
818514330f12Smrg		libobjs=$save_libobjs
81862378475aSmrg		skipped_export=false
81872378475aSmrg	      else
81882378475aSmrg		# The command line is too long to execute in one step.
81892378475aSmrg		func_verbose "using reloadable object file for export list..."
81902378475aSmrg		skipped_export=:
81912378475aSmrg		# Break out early, otherwise skipped_export may be
81922378475aSmrg		# set to false by a later but shorter cmd.
81932378475aSmrg		break
81942378475aSmrg	      fi
81952378475aSmrg	    done
81962378475aSmrg	    IFS="$save_ifs"
81972378475aSmrg	    if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then
81982378475aSmrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
81992378475aSmrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
82002378475aSmrg	    fi
82012378475aSmrg	  fi
820295b296d0Smrg	fi
820395b296d0Smrg
82042378475aSmrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
82052378475aSmrg	  tmp_export_symbols="$export_symbols"
82062378475aSmrg	  test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
820714330f12Smrg	  $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
82082378475aSmrg	fi
820995b296d0Smrg
82102378475aSmrg	if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then
82112378475aSmrg	  # The given exports_symbols file has to be filtered, so filter it.
82122378475aSmrg	  func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
82132378475aSmrg	  # FIXME: $output_objdir/$libname.filter potentially contains lots of
82142378475aSmrg	  # 's' commands which not all seds can handle. GNU sed should be fine
82152378475aSmrg	  # though. Also, the filter scales superlinearly with the number of
82162378475aSmrg	  # global variables. join(1) would be nice here, but unfortunately
82172378475aSmrg	  # isn't a blessed tool.
82182378475aSmrg	  $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
821914330f12Smrg	  func_append delfiles " $export_symbols $output_objdir/$libname.filter"
82202378475aSmrg	  export_symbols=$output_objdir/$libname.def
82212378475aSmrg	  $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
82222378475aSmrg	fi
822395b296d0Smrg
82242378475aSmrg	tmp_deplibs=
82252378475aSmrg	for test_deplib in $deplibs; do
82262378475aSmrg	  case " $convenience " in
82272378475aSmrg	  *" $test_deplib "*) ;;
82282378475aSmrg	  *)
822914330f12Smrg	    func_append tmp_deplibs " $test_deplib"
82302378475aSmrg	    ;;
82312378475aSmrg	  esac
82322378475aSmrg	done
82332378475aSmrg	deplibs="$tmp_deplibs"
823495b296d0Smrg
82352378475aSmrg	if test -n "$convenience"; then
82362378475aSmrg	  if test -n "$whole_archive_flag_spec" &&
82372378475aSmrg	    test "$compiler_needs_object" = yes &&
82382378475aSmrg	    test -z "$libobjs"; then
82392378475aSmrg	    # extract the archives, so we have objects to list.
82402378475aSmrg	    # TODO: could optimize this to just extract one archive.
82412378475aSmrg	    whole_archive_flag_spec=
82422378475aSmrg	  fi
82432378475aSmrg	  if test -n "$whole_archive_flag_spec"; then
82442378475aSmrg	    save_libobjs=$libobjs
82452378475aSmrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
82462378475aSmrg	    test "X$libobjs" = "X " && libobjs=
82472378475aSmrg	  else
82482378475aSmrg	    gentop="$output_objdir/${outputname}x"
824914330f12Smrg	    func_append generated " $gentop"
825095b296d0Smrg
82512378475aSmrg	    func_extract_archives $gentop $convenience
825214330f12Smrg	    func_append libobjs " $func_extract_archives_result"
82532378475aSmrg	    test "X$libobjs" = "X " && libobjs=
82542378475aSmrg	  fi
8255e6f085baSmrg	fi
825695b296d0Smrg
82572378475aSmrg	if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
82582378475aSmrg	  eval flag=\"$thread_safe_flag_spec\"
825914330f12Smrg	  func_append linker_flags " $flag"
8260e6f085baSmrg	fi
826139713583Smrg
82622378475aSmrg	# Make a backup of the uninstalled library when relinking
826314330f12Smrg	if test "$opt_mode" = relink; then
82642378475aSmrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
82652378475aSmrg	fi
826695b296d0Smrg
82672378475aSmrg	# Do each of the archive commands.
82682378475aSmrg	if test "$module" = yes && test -n "$module_cmds" ; then
82692378475aSmrg	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
82702378475aSmrg	    eval test_cmds=\"$module_expsym_cmds\"
82712378475aSmrg	    cmds=$module_expsym_cmds
82722378475aSmrg	  else
82732378475aSmrg	    eval test_cmds=\"$module_cmds\"
82742378475aSmrg	    cmds=$module_cmds
82752378475aSmrg	  fi
8276e6f085baSmrg	else
82772378475aSmrg	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
82782378475aSmrg	    eval test_cmds=\"$archive_expsym_cmds\"
82792378475aSmrg	    cmds=$archive_expsym_cmds
82802378475aSmrg	  else
82812378475aSmrg	    eval test_cmds=\"$archive_cmds\"
82822378475aSmrg	    cmds=$archive_cmds
82832378475aSmrg	  fi
8284e6f085baSmrg	fi
828595b296d0Smrg
82862378475aSmrg	if test "X$skipped_export" != "X:" &&
82872378475aSmrg	   func_len " $test_cmds" &&
82882378475aSmrg	   len=$func_len_result &&
82892378475aSmrg	   test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
82902378475aSmrg	  :
82912378475aSmrg	else
82922378475aSmrg	  # The command line is too long to link in one step, link piecewise
82932378475aSmrg	  # or, if using GNU ld and skipped_export is not :, use a linker
82942378475aSmrg	  # script.
829595b296d0Smrg
82962378475aSmrg	  # Save the value of $output and $libobjs because we want to
82972378475aSmrg	  # use them later.  If we have whole_archive_flag_spec, we
82982378475aSmrg	  # want to use save_libobjs as it was before
82992378475aSmrg	  # whole_archive_flag_spec was expanded, because we can't
83002378475aSmrg	  # assume the linker understands whole_archive_flag_spec.
83012378475aSmrg	  # This may have to be revisited, in case too many
83022378475aSmrg	  # convenience libraries get linked in and end up exceeding
83032378475aSmrg	  # the spec.
83042378475aSmrg	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
83052378475aSmrg	    save_libobjs=$libobjs
83062378475aSmrg	  fi
83072378475aSmrg	  save_output=$output
830814330f12Smrg	  func_basename "$output"
830914330f12Smrg	  output_la=$func_basename_result
831095b296d0Smrg
83112378475aSmrg	  # Clear the reloadable object creation command queue and
83122378475aSmrg	  # initialize k to one.
83132378475aSmrg	  test_cmds=
83142378475aSmrg	  concat_cmds=
83152378475aSmrg	  objlist=
83162378475aSmrg	  last_robj=
83172378475aSmrg	  k=1
83182378475aSmrg
83192378475aSmrg	  if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
83202378475aSmrg	    output=${output_objdir}/${output_la}.lnkscript
83212378475aSmrg	    func_verbose "creating GNU ld script: $output"
832214330f12Smrg	    echo 'INPUT (' > $output
83232378475aSmrg	    for obj in $save_libobjs
8324e6f085baSmrg	    do
832514330f12Smrg	      func_to_tool_file "$obj"
832614330f12Smrg	      $ECHO "$func_to_tool_file_result" >> $output
83272378475aSmrg	    done
832814330f12Smrg	    echo ')' >> $output
832914330f12Smrg	    func_append delfiles " $output"
833014330f12Smrg	    func_to_tool_file "$output"
833114330f12Smrg	    output=$func_to_tool_file_result
83322378475aSmrg	  elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then
83332378475aSmrg	    output=${output_objdir}/${output_la}.lnk
83342378475aSmrg	    func_verbose "creating linker input file list: $output"
83352378475aSmrg	    : > $output
83362378475aSmrg	    set x $save_libobjs
83372378475aSmrg	    shift
83382378475aSmrg	    firstobj=
83392378475aSmrg	    if test "$compiler_needs_object" = yes; then
83402378475aSmrg	      firstobj="$1 "
83412378475aSmrg	      shift
83422378475aSmrg	    fi
83432378475aSmrg	    for obj
83442378475aSmrg	    do
834514330f12Smrg	      func_to_tool_file "$obj"
834614330f12Smrg	      $ECHO "$func_to_tool_file_result" >> $output
83472378475aSmrg	    done
834814330f12Smrg	    func_append delfiles " $output"
834914330f12Smrg	    func_to_tool_file "$output"
835014330f12Smrg	    output=$firstobj\"$file_list_spec$func_to_tool_file_result\"
83512378475aSmrg	  else
83522378475aSmrg	    if test -n "$save_libobjs"; then
83532378475aSmrg	      func_verbose "creating reloadable object files..."
83542378475aSmrg	      output=$output_objdir/$output_la-${k}.$objext
83552378475aSmrg	      eval test_cmds=\"$reload_cmds\"
83562378475aSmrg	      func_len " $test_cmds"
83572378475aSmrg	      len0=$func_len_result
83582378475aSmrg	      len=$len0
83592378475aSmrg
83602378475aSmrg	      # Loop over the list of objects to be linked.
83612378475aSmrg	      for obj in $save_libobjs
83622378475aSmrg	      do
83632378475aSmrg		func_len " $obj"
83642378475aSmrg		func_arith $len + $func_len_result
83652378475aSmrg		len=$func_arith_result
83662378475aSmrg		if test "X$objlist" = X ||
83672378475aSmrg		   test "$len" -lt "$max_cmd_len"; then
83682378475aSmrg		  func_append objlist " $obj"
83692378475aSmrg		else
83702378475aSmrg		  # The command $test_cmds is almost too long, add a
83712378475aSmrg		  # command to the queue.
83722378475aSmrg		  if test "$k" -eq 1 ; then
83732378475aSmrg		    # The first file doesn't have a previous command to add.
837414330f12Smrg		    reload_objs=$objlist
837514330f12Smrg		    eval concat_cmds=\"$reload_cmds\"
83762378475aSmrg		  else
83772378475aSmrg		    # All subsequent reloadable object files will link in
83782378475aSmrg		    # the last one created.
837914330f12Smrg		    reload_objs="$objlist $last_robj"
838014330f12Smrg		    eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
83812378475aSmrg		  fi
83822378475aSmrg		  last_robj=$output_objdir/$output_la-${k}.$objext
83832378475aSmrg		  func_arith $k + 1
83842378475aSmrg		  k=$func_arith_result
83852378475aSmrg		  output=$output_objdir/$output_la-${k}.$objext
838614330f12Smrg		  objlist=" $obj"
83872378475aSmrg		  func_len " $last_robj"
83882378475aSmrg		  func_arith $len0 + $func_len_result
83892378475aSmrg		  len=$func_arith_result
83902378475aSmrg		fi
83912378475aSmrg	      done
83922378475aSmrg	      # Handle the remaining objects by creating one last
83932378475aSmrg	      # reloadable object file.  All subsequent reloadable object
83942378475aSmrg	      # files will link in the last one created.
83952378475aSmrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
839614330f12Smrg	      reload_objs="$objlist $last_robj"
839714330f12Smrg	      eval concat_cmds=\"\${concat_cmds}$reload_cmds\"
83982378475aSmrg	      if test -n "$last_robj"; then
83992378475aSmrg	        eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\"
84002378475aSmrg	      fi
840114330f12Smrg	      func_append delfiles " $output"
840295b296d0Smrg
84032378475aSmrg	    else
84042378475aSmrg	      output=
84052378475aSmrg	    fi
840695b296d0Smrg
84072378475aSmrg	    if ${skipped_export-false}; then
84082378475aSmrg	      func_verbose "generating symbol list for \`$libname.la'"
84092378475aSmrg	      export_symbols="$output_objdir/$libname.exp"
84102378475aSmrg	      $opt_dry_run || $RM $export_symbols
84112378475aSmrg	      libobjs=$output
84122378475aSmrg	      # Append the command to create the export file.
84132378475aSmrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
84142378475aSmrg	      eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
84152378475aSmrg	      if test -n "$last_robj"; then
84162378475aSmrg		eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
84172378475aSmrg	      fi
841839713583Smrg	    fi
841995b296d0Smrg
84202378475aSmrg	    test -n "$save_libobjs" &&
84212378475aSmrg	      func_verbose "creating a temporary reloadable object file: $output"
842295b296d0Smrg
84232378475aSmrg	    # Loop through the commands generated above and execute them.
84242378475aSmrg	    save_ifs="$IFS"; IFS='~'
84252378475aSmrg	    for cmd in $concat_cmds; do
84262378475aSmrg	      IFS="$save_ifs"
84272378475aSmrg	      $opt_silent || {
84282378475aSmrg		  func_quote_for_expand "$cmd"
84292378475aSmrg		  eval "func_echo $func_quote_for_expand_result"
84302378475aSmrg	      }
84312378475aSmrg	      $opt_dry_run || eval "$cmd" || {
84322378475aSmrg		lt_exit=$?
84332378475aSmrg
84342378475aSmrg		# Restore the uninstalled library and exit
843514330f12Smrg		if test "$opt_mode" = relink; then
84362378475aSmrg		  ( cd "$output_objdir" && \
84372378475aSmrg		    $RM "${realname}T" && \
84382378475aSmrg		    $MV "${realname}U" "$realname" )
84392378475aSmrg		fi
844095b296d0Smrg
84412378475aSmrg		exit $lt_exit
84422378475aSmrg	      }
84432378475aSmrg	    done
84442378475aSmrg	    IFS="$save_ifs"
8445e6f085baSmrg
84462378475aSmrg	    if test -n "$export_symbols_regex" && ${skipped_export-false}; then
84472378475aSmrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
84482378475aSmrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
844995b296d0Smrg	    fi
845095b296d0Smrg	  fi
845195b296d0Smrg
84522378475aSmrg          if ${skipped_export-false}; then
84532378475aSmrg	    if test -n "$export_symbols" && test -n "$include_expsyms"; then
84542378475aSmrg	      tmp_export_symbols="$export_symbols"
84552378475aSmrg	      test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
845614330f12Smrg	      $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
84572378475aSmrg	    fi
845839713583Smrg
84592378475aSmrg	    if test -n "$orig_export_symbols"; then
84602378475aSmrg	      # The given exports_symbols file has to be filtered, so filter it.
84612378475aSmrg	      func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
84622378475aSmrg	      # FIXME: $output_objdir/$libname.filter potentially contains lots of
84632378475aSmrg	      # 's' commands which not all seds can handle. GNU sed should be fine
84642378475aSmrg	      # though. Also, the filter scales superlinearly with the number of
84652378475aSmrg	      # global variables. join(1) would be nice here, but unfortunately
84662378475aSmrg	      # isn't a blessed tool.
84672378475aSmrg	      $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
846814330f12Smrg	      func_append delfiles " $export_symbols $output_objdir/$libname.filter"
84692378475aSmrg	      export_symbols=$output_objdir/$libname.def
84702378475aSmrg	      $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
84712378475aSmrg	    fi
84722378475aSmrg	  fi
847395b296d0Smrg
84742378475aSmrg	  libobjs=$output
84752378475aSmrg	  # Restore the value of output.
84762378475aSmrg	  output=$save_output
847795b296d0Smrg
84782378475aSmrg	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
84792378475aSmrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
84802378475aSmrg	    test "X$libobjs" = "X " && libobjs=
84812378475aSmrg	  fi
84822378475aSmrg	  # Expand the library linking commands again to reset the
84832378475aSmrg	  # value of $libobjs for piecewise linking.
848495b296d0Smrg
84852378475aSmrg	  # Do each of the archive commands.
84862378475aSmrg	  if test "$module" = yes && test -n "$module_cmds" ; then
84872378475aSmrg	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
84882378475aSmrg	      cmds=$module_expsym_cmds
84892378475aSmrg	    else
84902378475aSmrg	      cmds=$module_cmds
8491e6f085baSmrg	    fi
8492e6f085baSmrg	  else
84932378475aSmrg	    if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
84942378475aSmrg	      cmds=$archive_expsym_cmds
84952378475aSmrg	    else
84962378475aSmrg	      cmds=$archive_cmds
84972378475aSmrg	    fi
8498e6f085baSmrg	  fi
84992378475aSmrg	fi
850095b296d0Smrg
85012378475aSmrg	if test -n "$delfiles"; then
85022378475aSmrg	  # Append the command to remove temporary files to $cmds.
85032378475aSmrg	  eval cmds=\"\$cmds~\$RM $delfiles\"
85042378475aSmrg	fi
850595b296d0Smrg
85062378475aSmrg	# Add any objects from preloaded convenience libraries
85072378475aSmrg	if test -n "$dlprefiles"; then
85082378475aSmrg	  gentop="$output_objdir/${outputname}x"
850914330f12Smrg	  func_append generated " $gentop"
851095b296d0Smrg
85112378475aSmrg	  func_extract_archives $gentop $dlprefiles
851214330f12Smrg	  func_append libobjs " $func_extract_archives_result"
85132378475aSmrg	  test "X$libobjs" = "X " && libobjs=
85142378475aSmrg	fi
851595b296d0Smrg
85162378475aSmrg	save_ifs="$IFS"; IFS='~'
85172378475aSmrg	for cmd in $cmds; do
85182378475aSmrg	  IFS="$save_ifs"
85192378475aSmrg	  eval cmd=\"$cmd\"
85202378475aSmrg	  $opt_silent || {
85212378475aSmrg	    func_quote_for_expand "$cmd"
85222378475aSmrg	    eval "func_echo $func_quote_for_expand_result"
85232378475aSmrg	  }
85242378475aSmrg	  $opt_dry_run || eval "$cmd" || {
85252378475aSmrg	    lt_exit=$?
852639713583Smrg
85272378475aSmrg	    # Restore the uninstalled library and exit
852814330f12Smrg	    if test "$opt_mode" = relink; then
85292378475aSmrg	      ( cd "$output_objdir" && \
85302378475aSmrg	        $RM "${realname}T" && \
85312378475aSmrg		$MV "${realname}U" "$realname" )
85322378475aSmrg	    fi
853339713583Smrg
85342378475aSmrg	    exit $lt_exit
85352378475aSmrg	  }
85362378475aSmrg	done
85372378475aSmrg	IFS="$save_ifs"
853839713583Smrg
85392378475aSmrg	# Restore the uninstalled library and exit
854014330f12Smrg	if test "$opt_mode" = relink; then
85412378475aSmrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
854239713583Smrg
85432378475aSmrg	  if test -n "$convenience"; then
85442378475aSmrg	    if test -z "$whole_archive_flag_spec"; then
85452378475aSmrg	      func_show_eval '${RM}r "$gentop"'
85462378475aSmrg	    fi
85472378475aSmrg	  fi
854839713583Smrg
85492378475aSmrg	  exit $EXIT_SUCCESS
85502378475aSmrg	fi
85512378475aSmrg
85522378475aSmrg	# Create links to the real library.
85532378475aSmrg	for linkname in $linknames; do
85542378475aSmrg	  if test "$realname" != "$linkname"; then
85552378475aSmrg	    func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
8556e6f085baSmrg	  fi
8557e6f085baSmrg	done
855839713583Smrg
85592378475aSmrg	# If -module or -export-dynamic was specified, set the dlname.
85602378475aSmrg	if test "$module" = yes || test "$export_dynamic" = yes; then
85612378475aSmrg	  # On all known operating systems, these are identical.
85622378475aSmrg	  dlname="$soname"
85632378475aSmrg	fi
85642378475aSmrg      fi
856595b296d0Smrg      ;;
856695b296d0Smrg
85672378475aSmrg    obj)
85682378475aSmrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
85692378475aSmrg	func_warning "\`-dlopen' is ignored for objects"
85702378475aSmrg      fi
8571e6f085baSmrg
85722378475aSmrg      case " $deplibs" in
85732378475aSmrg      *\ -l* | *\ -L*)
85742378475aSmrg	func_warning "\`-l' and \`-L' are ignored for objects" ;;
857539713583Smrg      esac
857695b296d0Smrg
85772378475aSmrg      test -n "$rpath" && \
85782378475aSmrg	func_warning "\`-rpath' is ignored for objects"
85792378475aSmrg
85802378475aSmrg      test -n "$xrpath" && \
85812378475aSmrg	func_warning "\`-R' is ignored for objects"
858295b296d0Smrg
85832378475aSmrg      test -n "$vinfo" && \
85842378475aSmrg	func_warning "\`-version-info' is ignored for objects"
858539713583Smrg
85862378475aSmrg      test -n "$release" && \
85872378475aSmrg	func_warning "\`-release' is ignored for objects"
85882378475aSmrg
85892378475aSmrg      case $output in
85902378475aSmrg      *.lo)
85912378475aSmrg	test -n "$objs$old_deplibs" && \
85922378475aSmrg	  func_fatal_error "cannot build library object \`$output' from non-libtool objects"
85932378475aSmrg
85942378475aSmrg	libobj=$output
85952378475aSmrg	func_lo2o "$libobj"
85962378475aSmrg	obj=$func_lo2o_result
8597e6f085baSmrg	;;
8598e6f085baSmrg      *)
85992378475aSmrg	libobj=
86002378475aSmrg	obj="$output"
860195b296d0Smrg	;;
860239713583Smrg      esac
860395b296d0Smrg
86042378475aSmrg      # Delete the old objects.
86052378475aSmrg      $opt_dry_run || $RM $obj $libobj
860695b296d0Smrg
86072378475aSmrg      # Objects from convenience libraries.  This assumes
86082378475aSmrg      # single-version convenience libraries.  Whenever we create
86092378475aSmrg      # different ones for PIC/non-PIC, this we'll have to duplicate
86102378475aSmrg      # the extraction.
86112378475aSmrg      reload_conv_objs=
86122378475aSmrg      gentop=
86132378475aSmrg      # reload_cmds runs $LD directly, so let us get rid of
86142378475aSmrg      # -Wl from whole_archive_flag_spec and hope we can get by with
86152378475aSmrg      # turning comma into space..
86162378475aSmrg      wl=
861795b296d0Smrg
86182378475aSmrg      if test -n "$convenience"; then
86192378475aSmrg	if test -n "$whole_archive_flag_spec"; then
86202378475aSmrg	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
862114330f12Smrg	  reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
86222378475aSmrg	else
86232378475aSmrg	  gentop="$output_objdir/${obj}x"
862414330f12Smrg	  func_append generated " $gentop"
8625e6f085baSmrg
86262378475aSmrg	  func_extract_archives $gentop $convenience
86272378475aSmrg	  reload_conv_objs="$reload_objs $func_extract_archives_result"
86282378475aSmrg	fi
8629e6f085baSmrg      fi
8630e6f085baSmrg
863114330f12Smrg      # If we're not building shared, we need to use non_pic_objs
863214330f12Smrg      test "$build_libtool_libs" != yes && libobjs="$non_pic_objects"
863314330f12Smrg
86342378475aSmrg      # Create the old-style object.
863514330f12Smrg      reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
8636e6f085baSmrg
86372378475aSmrg      output="$obj"
86382378475aSmrg      func_execute_cmds "$reload_cmds" 'exit $?'
8639e6f085baSmrg
86402378475aSmrg      # Exit if we aren't doing a library object file.
86412378475aSmrg      if test -z "$libobj"; then
86422378475aSmrg	if test -n "$gentop"; then
86432378475aSmrg	  func_show_eval '${RM}r "$gentop"'
86442378475aSmrg	fi
86452378475aSmrg
86462378475aSmrg	exit $EXIT_SUCCESS
8647e6f085baSmrg      fi
86482378475aSmrg
86492378475aSmrg      if test "$build_libtool_libs" != yes; then
86502378475aSmrg	if test -n "$gentop"; then
86512378475aSmrg	  func_show_eval '${RM}r "$gentop"'
86522378475aSmrg	fi
86532378475aSmrg
86542378475aSmrg	# Create an invalid libtool object if no PIC, so that we don't
86552378475aSmrg	# accidentally link it into a program.
86562378475aSmrg	# $show "echo timestamp > $libobj"
86572378475aSmrg	# $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
86582378475aSmrg	exit $EXIT_SUCCESS
86592378475aSmrg      fi
86602378475aSmrg
86612378475aSmrg      if test -n "$pic_flag" || test "$pic_mode" != default; then
86622378475aSmrg	# Only do commands if we really have different PIC objects.
86632378475aSmrg	reload_objs="$libobjs $reload_conv_objs"
86642378475aSmrg	output="$libobj"
86652378475aSmrg	func_execute_cmds "$reload_cmds" 'exit $?'
86662378475aSmrg      fi
86672378475aSmrg
86682378475aSmrg      if test -n "$gentop"; then
86692378475aSmrg	func_show_eval '${RM}r "$gentop"'
86702378475aSmrg      fi
86712378475aSmrg
86722378475aSmrg      exit $EXIT_SUCCESS
8673e6f085baSmrg      ;;
867495b296d0Smrg
86752378475aSmrg    prog)
86762378475aSmrg      case $host in
86772378475aSmrg	*cygwin*) func_stripname '' '.exe' "$output"
86782378475aSmrg	          output=$func_stripname_result.exe;;
86792378475aSmrg      esac
86802378475aSmrg      test -n "$vinfo" && \
86812378475aSmrg	func_warning "\`-version-info' is ignored for programs"
868295b296d0Smrg
86832378475aSmrg      test -n "$release" && \
86842378475aSmrg	func_warning "\`-release' is ignored for programs"
868595b296d0Smrg
86862378475aSmrg      test "$preload" = yes \
86872378475aSmrg        && test "$dlopen_support" = unknown \
86882378475aSmrg	&& test "$dlopen_self" = unknown \
86892378475aSmrg	&& test "$dlopen_self_static" = unknown && \
86902378475aSmrg	  func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support."
86912378475aSmrg
86922378475aSmrg      case $host in
86932378475aSmrg      *-*-rhapsody* | *-*-darwin1.[012])
86942378475aSmrg	# On Rhapsody replace the C library is the System framework
869514330f12Smrg	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
869614330f12Smrg	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
8697e6f085baSmrg	;;
86982378475aSmrg      esac
8699e6f085baSmrg
87002378475aSmrg      case $host in
87012378475aSmrg      *-*-darwin*)
87022378475aSmrg	# Don't allow lazy linking, it breaks C++ global constructors
87032378475aSmrg	# But is supposedly fixed on 10.4 or later (yay!).
87042378475aSmrg	if test "$tagname" = CXX ; then
87052378475aSmrg	  case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
87062378475aSmrg	    10.[0123])
870714330f12Smrg	      func_append compile_command " ${wl}-bind_at_load"
870814330f12Smrg	      func_append finalize_command " ${wl}-bind_at_load"
87092378475aSmrg	    ;;
87102378475aSmrg	  esac
8711e6f085baSmrg	fi
87122378475aSmrg	# Time to change all our "foo.ltframework" stuff back to "-framework foo"
871314330f12Smrg	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
871414330f12Smrg	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
87152378475aSmrg	;;
87162378475aSmrg      esac
8717e6f085baSmrg
8718e6f085baSmrg
87192378475aSmrg      # move library search paths that coincide with paths to not yet
87202378475aSmrg      # installed libraries to the beginning of the library search list
87212378475aSmrg      new_libs=
87222378475aSmrg      for path in $notinst_path; do
87232378475aSmrg	case " $new_libs " in
87242378475aSmrg	*" -L$path/$objdir "*) ;;
87252378475aSmrg	*)
87262378475aSmrg	  case " $compile_deplibs " in
87272378475aSmrg	  *" -L$path/$objdir "*)
872814330f12Smrg	    func_append new_libs " -L$path/$objdir" ;;
872939713583Smrg	  esac
87302378475aSmrg	  ;;
87312378475aSmrg	esac
87322378475aSmrg      done
87332378475aSmrg      for deplib in $compile_deplibs; do
87342378475aSmrg	case $deplib in
87352378475aSmrg	-L*)
87362378475aSmrg	  case " $new_libs " in
87372378475aSmrg	  *" $deplib "*) ;;
873814330f12Smrg	  *) func_append new_libs " $deplib" ;;
873939713583Smrg	  esac
87402378475aSmrg	  ;;
874114330f12Smrg	*) func_append new_libs " $deplib" ;;
87422378475aSmrg	esac
87432378475aSmrg      done
87442378475aSmrg      compile_deplibs="$new_libs"
874595b296d0Smrg
8746e6f085baSmrg
874714330f12Smrg      func_append compile_command " $compile_deplibs"
874814330f12Smrg      func_append finalize_command " $finalize_deplibs"
8749e6f085baSmrg
87502378475aSmrg      if test -n "$rpath$xrpath"; then
87512378475aSmrg	# If the user specified any rpath flags, then add them.
87522378475aSmrg	for libdir in $rpath $xrpath; do
87532378475aSmrg	  # This is the magic to use -rpath.
87542378475aSmrg	  case "$finalize_rpath " in
87552378475aSmrg	  *" $libdir "*) ;;
875614330f12Smrg	  *) func_append finalize_rpath " $libdir" ;;
87572378475aSmrg	  esac
87582378475aSmrg	done
87592378475aSmrg      fi
8760e6f085baSmrg
87612378475aSmrg      # Now hardcode the library paths
87622378475aSmrg      rpath=
87632378475aSmrg      hardcode_libdirs=
87642378475aSmrg      for libdir in $compile_rpath $finalize_rpath; do
87652378475aSmrg	if test -n "$hardcode_libdir_flag_spec"; then
87662378475aSmrg	  if test -n "$hardcode_libdir_separator"; then
87672378475aSmrg	    if test -z "$hardcode_libdirs"; then
87682378475aSmrg	      hardcode_libdirs="$libdir"
87692378475aSmrg	    else
87702378475aSmrg	      # Just accumulate the unique libdirs.
87712378475aSmrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
87722378475aSmrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
87732378475aSmrg		;;
87742378475aSmrg	      *)
877514330f12Smrg		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
87762378475aSmrg		;;
87772378475aSmrg	      esac
87782378475aSmrg	    fi
8779e6f085baSmrg	  else
87802378475aSmrg	    eval flag=\"$hardcode_libdir_flag_spec\"
878114330f12Smrg	    func_append rpath " $flag"
8782e6f085baSmrg	  fi
87832378475aSmrg	elif test -n "$runpath_var"; then
87842378475aSmrg	  case "$perm_rpath " in
87852378475aSmrg	  *" $libdir "*) ;;
878614330f12Smrg	  *) func_append perm_rpath " $libdir" ;;
87872378475aSmrg	  esac
87882378475aSmrg	fi
87892378475aSmrg	case $host in
87902378475aSmrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
87912378475aSmrg	  testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'`
87922378475aSmrg	  case :$dllsearchpath: in
87932378475aSmrg	  *":$libdir:"*) ;;
87942378475aSmrg	  ::) dllsearchpath=$libdir;;
879514330f12Smrg	  *) func_append dllsearchpath ":$libdir";;
87962378475aSmrg	  esac
87972378475aSmrg	  case :$dllsearchpath: in
87982378475aSmrg	  *":$testbindir:"*) ;;
87992378475aSmrg	  ::) dllsearchpath=$testbindir;;
880014330f12Smrg	  *) func_append dllsearchpath ":$testbindir";;
88012378475aSmrg	  esac
88022378475aSmrg	  ;;
88032378475aSmrg	esac
88042378475aSmrg      done
88052378475aSmrg      # Substitute the hardcoded libdirs into the rpath.
88062378475aSmrg      if test -n "$hardcode_libdir_separator" &&
88072378475aSmrg	 test -n "$hardcode_libdirs"; then
88082378475aSmrg	libdir="$hardcode_libdirs"
88092378475aSmrg	eval rpath=\" $hardcode_libdir_flag_spec\"
88102378475aSmrg      fi
88112378475aSmrg      compile_rpath="$rpath"
8812e6f085baSmrg
88132378475aSmrg      rpath=
88142378475aSmrg      hardcode_libdirs=
88152378475aSmrg      for libdir in $finalize_rpath; do
88162378475aSmrg	if test -n "$hardcode_libdir_flag_spec"; then
88172378475aSmrg	  if test -n "$hardcode_libdir_separator"; then
88182378475aSmrg	    if test -z "$hardcode_libdirs"; then
88192378475aSmrg	      hardcode_libdirs="$libdir"
88202378475aSmrg	    else
88212378475aSmrg	      # Just accumulate the unique libdirs.
88222378475aSmrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
88232378475aSmrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
88242378475aSmrg		;;
88252378475aSmrg	      *)
882614330f12Smrg		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
88272378475aSmrg		;;
88282378475aSmrg	      esac
88292378475aSmrg	    fi
883095b296d0Smrg	  else
88312378475aSmrg	    eval flag=\"$hardcode_libdir_flag_spec\"
883214330f12Smrg	    func_append rpath " $flag"
883395b296d0Smrg	  fi
88342378475aSmrg	elif test -n "$runpath_var"; then
88352378475aSmrg	  case "$finalize_perm_rpath " in
88362378475aSmrg	  *" $libdir "*) ;;
883714330f12Smrg	  *) func_append finalize_perm_rpath " $libdir" ;;
88382378475aSmrg	  esac
883995b296d0Smrg	fi
88402378475aSmrg      done
88412378475aSmrg      # Substitute the hardcoded libdirs into the rpath.
88422378475aSmrg      if test -n "$hardcode_libdir_separator" &&
88432378475aSmrg	 test -n "$hardcode_libdirs"; then
88442378475aSmrg	libdir="$hardcode_libdirs"
88452378475aSmrg	eval rpath=\" $hardcode_libdir_flag_spec\"
88462378475aSmrg      fi
88472378475aSmrg      finalize_rpath="$rpath"
884895b296d0Smrg
88492378475aSmrg      if test -n "$libobjs" && test "$build_old_libs" = yes; then
88502378475aSmrg	# Transform all the library objects into standard objects.
885114330f12Smrg	compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
885214330f12Smrg	finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
88532378475aSmrg      fi
885495b296d0Smrg
88552378475aSmrg      func_generate_dlsyms "$outputname" "@PROGRAM@" "no"
885695b296d0Smrg
88572378475aSmrg      # template prelinking step
88582378475aSmrg      if test -n "$prelink_cmds"; then
88592378475aSmrg	func_execute_cmds "$prelink_cmds" 'exit $?'
88602378475aSmrg      fi
886195b296d0Smrg
88622378475aSmrg      wrappers_required=yes
88632378475aSmrg      case $host in
886414330f12Smrg      *cegcc* | *mingw32ce*)
886514330f12Smrg        # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
886614330f12Smrg        wrappers_required=no
886714330f12Smrg        ;;
88682378475aSmrg      *cygwin* | *mingw* )
88692378475aSmrg        if test "$build_libtool_libs" != yes; then
88702378475aSmrg          wrappers_required=no
88712378475aSmrg        fi
88722378475aSmrg        ;;
88732378475aSmrg      *)
88742378475aSmrg        if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
88752378475aSmrg          wrappers_required=no
88762378475aSmrg        fi
88772378475aSmrg        ;;
88782378475aSmrg      esac
88792378475aSmrg      if test "$wrappers_required" = no; then
88802378475aSmrg	# Replace the output file specification.
888114330f12Smrg	compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
88822378475aSmrg	link_command="$compile_command$compile_rpath"
888395b296d0Smrg
88842378475aSmrg	# We have no uninstalled library dependencies, so finalize right now.
88852378475aSmrg	exit_status=0
88862378475aSmrg	func_show_eval "$link_command" 'exit_status=$?'
888795b296d0Smrg
888814330f12Smrg	if test -n "$postlink_cmds"; then
888914330f12Smrg	  func_to_tool_file "$output"
889014330f12Smrg	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
889114330f12Smrg	  func_execute_cmds "$postlink_cmds" 'exit $?'
889214330f12Smrg	fi
889314330f12Smrg
88942378475aSmrg	# Delete the generated files.
88952378475aSmrg	if test -f "$output_objdir/${outputname}S.${objext}"; then
88962378475aSmrg	  func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"'
889795b296d0Smrg	fi
889895b296d0Smrg
88992378475aSmrg	exit $exit_status
89002378475aSmrg      fi
890195b296d0Smrg
89022378475aSmrg      if test -n "$compile_shlibpath$finalize_shlibpath"; then
89032378475aSmrg	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
89042378475aSmrg      fi
89052378475aSmrg      if test -n "$finalize_shlibpath"; then
89062378475aSmrg	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
89072378475aSmrg      fi
8908e6f085baSmrg
89092378475aSmrg      compile_var=
89102378475aSmrg      finalize_var=
89112378475aSmrg      if test -n "$runpath_var"; then
89122378475aSmrg	if test -n "$perm_rpath"; then
89132378475aSmrg	  # We should set the runpath_var.
89142378475aSmrg	  rpath=
89152378475aSmrg	  for dir in $perm_rpath; do
891614330f12Smrg	    func_append rpath "$dir:"
89172378475aSmrg	  done
89182378475aSmrg	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
891995b296d0Smrg	fi
89202378475aSmrg	if test -n "$finalize_perm_rpath"; then
89212378475aSmrg	  # We should set the runpath_var.
89222378475aSmrg	  rpath=
89232378475aSmrg	  for dir in $finalize_perm_rpath; do
892414330f12Smrg	    func_append rpath "$dir:"
89252378475aSmrg	  done
89262378475aSmrg	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
892795b296d0Smrg	fi
89282378475aSmrg      fi
892995b296d0Smrg
89302378475aSmrg      if test "$no_install" = yes; then
89312378475aSmrg	# We don't need to create a wrapper script.
89322378475aSmrg	link_command="$compile_var$compile_command$compile_rpath"
89332378475aSmrg	# Replace the output file specification.
893414330f12Smrg	link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
89352378475aSmrg	# Delete the old output file.
89362378475aSmrg	$opt_dry_run || $RM $output
89372378475aSmrg	# Link the executable and exit
89382378475aSmrg	func_show_eval "$link_command" 'exit $?'
893914330f12Smrg
894014330f12Smrg	if test -n "$postlink_cmds"; then
894114330f12Smrg	  func_to_tool_file "$output"
894214330f12Smrg	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
894314330f12Smrg	  func_execute_cmds "$postlink_cmds" 'exit $?'
894414330f12Smrg	fi
894514330f12Smrg
8946e6f085baSmrg	exit $EXIT_SUCCESS
89472378475aSmrg      fi
894839713583Smrg
89492378475aSmrg      if test "$hardcode_action" = relink; then
89502378475aSmrg	# Fast installation is not supported
89512378475aSmrg	link_command="$compile_var$compile_command$compile_rpath"
89522378475aSmrg	relink_command="$finalize_var$finalize_command$finalize_rpath"
89532378475aSmrg
89542378475aSmrg	func_warning "this platform does not like uninstalled shared libraries"
89552378475aSmrg	func_warning "\`$output' will be relinked during installation"
89562378475aSmrg      else
89572378475aSmrg	if test "$fast_install" != no; then
89582378475aSmrg	  link_command="$finalize_var$compile_command$finalize_rpath"
89592378475aSmrg	  if test "$fast_install" = yes; then
896014330f12Smrg	    relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
89612378475aSmrg	  else
89622378475aSmrg	    # fast_install is set to needless
89632378475aSmrg	    relink_command=
89642378475aSmrg	  fi
896595b296d0Smrg	else
89662378475aSmrg	  link_command="$compile_var$compile_command$compile_rpath"
89672378475aSmrg	  relink_command="$finalize_var$finalize_command$finalize_rpath"
896895b296d0Smrg	fi
89692378475aSmrg      fi
897095b296d0Smrg
89712378475aSmrg      # Replace the output file specification.
897214330f12Smrg      link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
897395b296d0Smrg
89742378475aSmrg      # Delete the old output files.
89752378475aSmrg      $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
897695b296d0Smrg
89772378475aSmrg      func_show_eval "$link_command" 'exit $?'
8978e6f085baSmrg
897914330f12Smrg      if test -n "$postlink_cmds"; then
898014330f12Smrg	func_to_tool_file "$output_objdir/$outputname"
898114330f12Smrg	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'`
898214330f12Smrg	func_execute_cmds "$postlink_cmds" 'exit $?'
898314330f12Smrg      fi
898414330f12Smrg
89852378475aSmrg      # Now create the wrapper script.
89862378475aSmrg      func_verbose "creating $output"
8987e6f085baSmrg
89882378475aSmrg      # Quote the relink command for shipping.
89892378475aSmrg      if test -n "$relink_command"; then
89902378475aSmrg	# Preserve any variables that may affect compiler behavior
89912378475aSmrg	for var in $variables_saved_for_relink; do
89922378475aSmrg	  if eval test -z \"\${$var+set}\"; then
89932378475aSmrg	    relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
89942378475aSmrg	  elif eval var_value=\$$var; test -z "$var_value"; then
89952378475aSmrg	    relink_command="$var=; export $var; $relink_command"
899695b296d0Smrg	  else
89972378475aSmrg	    func_quote_for_eval "$var_value"
89982378475aSmrg	    relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
899995b296d0Smrg	  fi
90002378475aSmrg	done
90012378475aSmrg	relink_command="(cd `pwd`; $relink_command)"
900214330f12Smrg	relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
90032378475aSmrg      fi
90042378475aSmrg
90052378475aSmrg      # Only actually do things if not in dry run mode.
90062378475aSmrg      $opt_dry_run || {
90072378475aSmrg	# win32 will think the script is a binary if it has
90082378475aSmrg	# a .exe suffix, so we strip it off here.
90092378475aSmrg	case $output in
90102378475aSmrg	  *.exe) func_stripname '' '.exe' "$output"
90112378475aSmrg	         output=$func_stripname_result ;;
90122378475aSmrg	esac
90132378475aSmrg	# test for cygwin because mv fails w/o .exe extensions
90142378475aSmrg	case $host in
90152378475aSmrg	  *cygwin*)
90162378475aSmrg	    exeext=.exe
90172378475aSmrg	    func_stripname '' '.exe' "$outputname"
90182378475aSmrg	    outputname=$func_stripname_result ;;
90192378475aSmrg	  *) exeext= ;;
902095b296d0Smrg	esac
90212378475aSmrg	case $host in
90222378475aSmrg	  *cygwin* | *mingw* )
90232378475aSmrg	    func_dirname_and_basename "$output" "" "."
90242378475aSmrg	    output_name=$func_basename_result
90252378475aSmrg	    output_path=$func_dirname_result
90262378475aSmrg	    cwrappersource="$output_path/$objdir/lt-$output_name.c"
90272378475aSmrg	    cwrapper="$output_path/$output_name.exe"
90282378475aSmrg	    $RM $cwrappersource $cwrapper
90292378475aSmrg	    trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
90302378475aSmrg
90312378475aSmrg	    func_emit_cwrapperexe_src > $cwrappersource
90322378475aSmrg
90332378475aSmrg	    # The wrapper executable is built using the $host compiler,
90342378475aSmrg	    # because it contains $host paths and files. If cross-
90352378475aSmrg	    # compiling, it, like the target executable, must be
90362378475aSmrg	    # executed on the $host or under an emulation environment.
90372378475aSmrg	    $opt_dry_run || {
90382378475aSmrg	      $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
90392378475aSmrg	      $STRIP $cwrapper
90402378475aSmrg	    }
904195b296d0Smrg
90422378475aSmrg	    # Now, create the wrapper script for func_source use:
90432378475aSmrg	    func_ltwrapper_scriptname $cwrapper
90442378475aSmrg	    $RM $func_ltwrapper_scriptname_result
90452378475aSmrg	    trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
90462378475aSmrg	    $opt_dry_run || {
90472378475aSmrg	      # note: this script will not be executed, so do not chmod.
90482378475aSmrg	      if test "x$build" = "x$host" ; then
90492378475aSmrg		$cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
90502378475aSmrg	      else
90512378475aSmrg		func_emit_wrapper no > $func_ltwrapper_scriptname_result
90522378475aSmrg	      fi
90532378475aSmrg	    }
90542378475aSmrg	  ;;
90552378475aSmrg	  * )
90562378475aSmrg	    $RM $output
90572378475aSmrg	    trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
905895b296d0Smrg
90592378475aSmrg	    func_emit_wrapper no > $output
90602378475aSmrg	    chmod +x $output
90612378475aSmrg	  ;;
90622378475aSmrg	esac
90632378475aSmrg      }
90642378475aSmrg      exit $EXIT_SUCCESS
90652378475aSmrg      ;;
90662378475aSmrg    esac
906795b296d0Smrg
90682378475aSmrg    # See if we need to build an old-fashioned archive.
90692378475aSmrg    for oldlib in $oldlibs; do
907095b296d0Smrg
90712378475aSmrg      if test "$build_libtool_libs" = convenience; then
90722378475aSmrg	oldobjs="$libobjs_save $symfileobj"
90732378475aSmrg	addlibs="$convenience"
90742378475aSmrg	build_libtool_libs=no
90752378475aSmrg      else
90762378475aSmrg	if test "$build_libtool_libs" = module; then
90772378475aSmrg	  oldobjs="$libobjs_save"
90782378475aSmrg	  build_libtool_libs=no
90792378475aSmrg	else
90802378475aSmrg	  oldobjs="$old_deplibs $non_pic_objects"
90812378475aSmrg	  if test "$preload" = yes && test -f "$symfileobj"; then
908214330f12Smrg	    func_append oldobjs " $symfileobj"
90832378475aSmrg	  fi
90842378475aSmrg	fi
90852378475aSmrg	addlibs="$old_convenience"
908695b296d0Smrg      fi
908795b296d0Smrg
90882378475aSmrg      if test -n "$addlibs"; then
90892378475aSmrg	gentop="$output_objdir/${outputname}x"
909014330f12Smrg	func_append generated " $gentop"
909195b296d0Smrg
90922378475aSmrg	func_extract_archives $gentop $addlibs
909314330f12Smrg	func_append oldobjs " $func_extract_archives_result"
90942378475aSmrg      fi
909595b296d0Smrg
90962378475aSmrg      # Do each command in the archive commands.
90972378475aSmrg      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
90982378475aSmrg	cmds=$old_archive_from_new_cmds
90992378475aSmrg      else
910095b296d0Smrg
91012378475aSmrg	# Add any objects from preloaded convenience libraries
91022378475aSmrg	if test -n "$dlprefiles"; then
91032378475aSmrg	  gentop="$output_objdir/${outputname}x"
910414330f12Smrg	  func_append generated " $gentop"
910595b296d0Smrg
91062378475aSmrg	  func_extract_archives $gentop $dlprefiles
910714330f12Smrg	  func_append oldobjs " $func_extract_archives_result"
91082378475aSmrg	fi
910995b296d0Smrg
91102378475aSmrg	# POSIX demands no paths to be encoded in archives.  We have
91112378475aSmrg	# to avoid creating archives with duplicate basenames if we
91122378475aSmrg	# might have to extract them afterwards, e.g., when creating a
91132378475aSmrg	# static archive out of a convenience library, or when linking
91142378475aSmrg	# the entirety of a libtool archive into another (currently
91152378475aSmrg	# not supported by libtool).
91162378475aSmrg	if (for obj in $oldobjs
91172378475aSmrg	    do
91182378475aSmrg	      func_basename "$obj"
91192378475aSmrg	      $ECHO "$func_basename_result"
91202378475aSmrg	    done | sort | sort -uc >/dev/null 2>&1); then
91212378475aSmrg	  :
91222378475aSmrg	else
912314330f12Smrg	  echo "copying selected object files to avoid basename conflicts..."
91242378475aSmrg	  gentop="$output_objdir/${outputname}x"
912514330f12Smrg	  func_append generated " $gentop"
91262378475aSmrg	  func_mkdir_p "$gentop"
91272378475aSmrg	  save_oldobjs=$oldobjs
91282378475aSmrg	  oldobjs=
91292378475aSmrg	  counter=1
91302378475aSmrg	  for obj in $save_oldobjs
91312378475aSmrg	  do
91322378475aSmrg	    func_basename "$obj"
91332378475aSmrg	    objbase="$func_basename_result"
91342378475aSmrg	    case " $oldobjs " in
91352378475aSmrg	    " ") oldobjs=$obj ;;
91362378475aSmrg	    *[\ /]"$objbase "*)
91372378475aSmrg	      while :; do
91382378475aSmrg		# Make sure we don't pick an alternate name that also
91392378475aSmrg		# overlaps.
91402378475aSmrg		newobj=lt$counter-$objbase
91412378475aSmrg		func_arith $counter + 1
91422378475aSmrg		counter=$func_arith_result
91432378475aSmrg		case " $oldobjs " in
91442378475aSmrg		*[\ /]"$newobj "*) ;;
91452378475aSmrg		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
91462378475aSmrg		esac
91472378475aSmrg	      done
91482378475aSmrg	      func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
914914330f12Smrg	      func_append oldobjs " $gentop/$newobj"
91502378475aSmrg	      ;;
915114330f12Smrg	    *) func_append oldobjs " $obj" ;;
91522378475aSmrg	    esac
915395b296d0Smrg	  done
915439713583Smrg	fi
91552378475aSmrg	eval cmds=\"$old_archive_cmds\"
9156e6f085baSmrg
91572378475aSmrg	func_len " $cmds"
91582378475aSmrg	len=$func_len_result
91592378475aSmrg	if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
91602378475aSmrg	  cmds=$old_archive_cmds
916114330f12Smrg	elif test -n "$archiver_list_spec"; then
916214330f12Smrg	  func_verbose "using command file archive linking..."
916314330f12Smrg	  for obj in $oldobjs
916414330f12Smrg	  do
916514330f12Smrg	    func_to_tool_file "$obj"
916614330f12Smrg	    $ECHO "$func_to_tool_file_result"
916714330f12Smrg	  done > $output_objdir/$libname.libcmd
916814330f12Smrg	  func_to_tool_file "$output_objdir/$libname.libcmd"
916914330f12Smrg	  oldobjs=" $archiver_list_spec$func_to_tool_file_result"
917014330f12Smrg	  cmds=$old_archive_cmds
91712378475aSmrg	else
91722378475aSmrg	  # the command line is too long to link in one step, link in parts
91732378475aSmrg	  func_verbose "using piecewise archive linking..."
91742378475aSmrg	  save_RANLIB=$RANLIB
91752378475aSmrg	  RANLIB=:
91762378475aSmrg	  objlist=
91772378475aSmrg	  concat_cmds=
91782378475aSmrg	  save_oldobjs=$oldobjs
91792378475aSmrg	  oldobjs=
91802378475aSmrg	  # Is there a better way of finding the last object in the list?
91812378475aSmrg	  for obj in $save_oldobjs
91822378475aSmrg	  do
91832378475aSmrg	    last_oldobj=$obj
91842378475aSmrg	  done
91852378475aSmrg	  eval test_cmds=\"$old_archive_cmds\"
91862378475aSmrg	  func_len " $test_cmds"
91872378475aSmrg	  len0=$func_len_result
91882378475aSmrg	  len=$len0
91892378475aSmrg	  for obj in $save_oldobjs
91902378475aSmrg	  do
91912378475aSmrg	    func_len " $obj"
91922378475aSmrg	    func_arith $len + $func_len_result
91932378475aSmrg	    len=$func_arith_result
91942378475aSmrg	    func_append objlist " $obj"
91952378475aSmrg	    if test "$len" -lt "$max_cmd_len"; then
91962378475aSmrg	      :
91972378475aSmrg	    else
91982378475aSmrg	      # the above command should be used before it gets too long
91992378475aSmrg	      oldobjs=$objlist
92002378475aSmrg	      if test "$obj" = "$last_oldobj" ; then
92012378475aSmrg		RANLIB=$save_RANLIB
92022378475aSmrg	      fi
92032378475aSmrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
92042378475aSmrg	      eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
92052378475aSmrg	      objlist=
92062378475aSmrg	      len=$len0
92072378475aSmrg	    fi
92082378475aSmrg	  done
92092378475aSmrg	  RANLIB=$save_RANLIB
92102378475aSmrg	  oldobjs=$objlist
92112378475aSmrg	  if test "X$oldobjs" = "X" ; then
92122378475aSmrg	    eval cmds=\"\$concat_cmds\"
92132378475aSmrg	  else
92142378475aSmrg	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
92152378475aSmrg	  fi
92162378475aSmrg	fi
92172378475aSmrg      fi
92182378475aSmrg      func_execute_cmds "$cmds" 'exit $?'
921995b296d0Smrg    done
922095b296d0Smrg
92212378475aSmrg    test -n "$generated" && \
92222378475aSmrg      func_show_eval "${RM}r$generated"
922395b296d0Smrg
92242378475aSmrg    # Now create the libtool archive.
92252378475aSmrg    case $output in
92262378475aSmrg    *.la)
92272378475aSmrg      old_library=
92282378475aSmrg      test "$build_old_libs" = yes && old_library="$libname.$libext"
92292378475aSmrg      func_verbose "creating $output"
923039713583Smrg
92312378475aSmrg      # Preserve any variables that may affect compiler behavior
92322378475aSmrg      for var in $variables_saved_for_relink; do
92332378475aSmrg	if eval test -z \"\${$var+set}\"; then
92342378475aSmrg	  relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
92352378475aSmrg	elif eval var_value=\$$var; test -z "$var_value"; then
92362378475aSmrg	  relink_command="$var=; export $var; $relink_command"
9237e6f085baSmrg	else
92382378475aSmrg	  func_quote_for_eval "$var_value"
92392378475aSmrg	  relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
9240e6f085baSmrg	fi
92412378475aSmrg      done
92422378475aSmrg      # Quote the link command for shipping.
92432378475aSmrg      relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
924414330f12Smrg      relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
92452378475aSmrg      if test "$hardcode_automatic" = yes ; then
92462378475aSmrg	relink_command=
92472378475aSmrg      fi
924895b296d0Smrg
92492378475aSmrg      # Only create the output if not a dry run.
92502378475aSmrg      $opt_dry_run || {
92512378475aSmrg	for installed in no yes; do
92522378475aSmrg	  if test "$installed" = yes; then
92532378475aSmrg	    if test -z "$install_libdir"; then
92542378475aSmrg	      break
92552378475aSmrg	    fi
92562378475aSmrg	    output="$output_objdir/$outputname"i
92572378475aSmrg	    # Replace all uninstalled libtool libraries with the installed ones
92582378475aSmrg	    newdependency_libs=
92592378475aSmrg	    for deplib in $dependency_libs; do
92602378475aSmrg	      case $deplib in
92612378475aSmrg	      *.la)
92622378475aSmrg		func_basename "$deplib"
92632378475aSmrg		name="$func_basename_result"
92642378475aSmrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
92652378475aSmrg		test -z "$libdir" && \
92662378475aSmrg		  func_fatal_error "\`$deplib' is not a valid libtool archive"
926714330f12Smrg		func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"
926814330f12Smrg		;;
926914330f12Smrg	      -L*)
927014330f12Smrg		func_stripname -L '' "$deplib"
927114330f12Smrg		func_replace_sysroot "$func_stripname_result"
927214330f12Smrg		func_append newdependency_libs " -L$func_replace_sysroot_result"
92732378475aSmrg		;;
927414330f12Smrg	      -R*)
927514330f12Smrg		func_stripname -R '' "$deplib"
927614330f12Smrg		func_replace_sysroot "$func_stripname_result"
927714330f12Smrg		func_append newdependency_libs " -R$func_replace_sysroot_result"
927814330f12Smrg		;;
927914330f12Smrg	      *) func_append newdependency_libs " $deplib" ;;
92802378475aSmrg	      esac
92812378475aSmrg	    done
92822378475aSmrg	    dependency_libs="$newdependency_libs"
92832378475aSmrg	    newdlfiles=
92842378475aSmrg
92852378475aSmrg	    for lib in $dlfiles; do
92862378475aSmrg	      case $lib in
92872378475aSmrg	      *.la)
92882378475aSmrg	        func_basename "$lib"
92892378475aSmrg		name="$func_basename_result"
92902378475aSmrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
92912378475aSmrg		test -z "$libdir" && \
92922378475aSmrg		  func_fatal_error "\`$lib' is not a valid libtool archive"
929314330f12Smrg		func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name"
92942378475aSmrg		;;
929514330f12Smrg	      *) func_append newdlfiles " $lib" ;;
92962378475aSmrg	      esac
92972378475aSmrg	    done
92982378475aSmrg	    dlfiles="$newdlfiles"
92992378475aSmrg	    newdlprefiles=
93002378475aSmrg	    for lib in $dlprefiles; do
93012378475aSmrg	      case $lib in
93022378475aSmrg	      *.la)
93032378475aSmrg		# Only pass preopened files to the pseudo-archive (for
93042378475aSmrg		# eventual linking with the app. that links it) if we
93052378475aSmrg		# didn't already link the preopened objects directly into
93062378475aSmrg		# the library:
93072378475aSmrg		func_basename "$lib"
93082378475aSmrg		name="$func_basename_result"
93092378475aSmrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
93102378475aSmrg		test -z "$libdir" && \
93112378475aSmrg		  func_fatal_error "\`$lib' is not a valid libtool archive"
931214330f12Smrg		func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name"
93132378475aSmrg		;;
93142378475aSmrg	      esac
93152378475aSmrg	    done
93162378475aSmrg	    dlprefiles="$newdlprefiles"
93172378475aSmrg	  else
93182378475aSmrg	    newdlfiles=
93192378475aSmrg	    for lib in $dlfiles; do
93202378475aSmrg	      case $lib in
93212378475aSmrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
93222378475aSmrg		*) abs=`pwd`"/$lib" ;;
93232378475aSmrg	      esac
932414330f12Smrg	      func_append newdlfiles " $abs"
93252378475aSmrg	    done
93262378475aSmrg	    dlfiles="$newdlfiles"
93272378475aSmrg	    newdlprefiles=
93282378475aSmrg	    for lib in $dlprefiles; do
93292378475aSmrg	      case $lib in
93302378475aSmrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
93312378475aSmrg		*) abs=`pwd`"/$lib" ;;
93322378475aSmrg	      esac
933314330f12Smrg	      func_append newdlprefiles " $abs"
93342378475aSmrg	    done
93352378475aSmrg	    dlprefiles="$newdlprefiles"
93362378475aSmrg	  fi
93372378475aSmrg	  $RM $output
93382378475aSmrg	  # place dlname in correct position for cygwin
933914330f12Smrg	  # In fact, it would be nice if we could use this code for all target
934014330f12Smrg	  # systems that can't hard-code library paths into their executables
934114330f12Smrg	  # and that have no shared library path variable independent of PATH,
934214330f12Smrg	  # but it turns out we can't easily determine that from inspecting
934314330f12Smrg	  # libtool variables, so we have to hard-code the OSs to which it
934414330f12Smrg	  # applies here; at the moment, that means platforms that use the PE
934514330f12Smrg	  # object format with DLL files.  See the long comment at the top of
934614330f12Smrg	  # tests/bindir.at for full details.
93472378475aSmrg	  tdlname=$dlname
93482378475aSmrg	  case $host,$output,$installed,$module,$dlname in
934914330f12Smrg	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
935014330f12Smrg	      # If a -bindir argument was supplied, place the dll there.
935114330f12Smrg	      if test "x$bindir" != x ;
935214330f12Smrg	      then
935314330f12Smrg		func_relative_path "$install_libdir" "$bindir"
935414330f12Smrg		tdlname=$func_relative_path_result$dlname
935514330f12Smrg	      else
935614330f12Smrg		# Otherwise fall back on heuristic.
935714330f12Smrg		tdlname=../bin/$dlname
935814330f12Smrg	      fi
935914330f12Smrg	      ;;
93602378475aSmrg	  esac
93612378475aSmrg	  $ECHO > $output "\
93622378475aSmrg# $outputname - a libtool library file
93632378475aSmrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
93642378475aSmrg#
93652378475aSmrg# Please DO NOT delete this file!
93662378475aSmrg# It is necessary for linking the library.
936795b296d0Smrg
93682378475aSmrg# The name that we can dlopen(3).
93692378475aSmrgdlname='$tdlname'
937095b296d0Smrg
93712378475aSmrg# Names of this library.
93722378475aSmrglibrary_names='$library_names'
937395b296d0Smrg
93742378475aSmrg# The name of the static archive.
93752378475aSmrgold_library='$old_library'
937695b296d0Smrg
93772378475aSmrg# Linker flags that can not go in dependency_libs.
93782378475aSmrginherited_linker_flags='$new_inherited_linker_flags'
937995b296d0Smrg
93802378475aSmrg# Libraries that this one depends upon.
93812378475aSmrgdependency_libs='$dependency_libs'
938295b296d0Smrg
93832378475aSmrg# Names of additional weak libraries provided by this library
93842378475aSmrgweak_library_names='$weak_libs'
938595b296d0Smrg
93862378475aSmrg# Version information for $libname.
93872378475aSmrgcurrent=$current
93882378475aSmrgage=$age
93892378475aSmrgrevision=$revision
939095b296d0Smrg
93912378475aSmrg# Is this an already installed library?
93922378475aSmrginstalled=$installed
939395b296d0Smrg
93942378475aSmrg# Should we warn about portability when linking against -modules?
93952378475aSmrgshouldnotlink=$module
939695b296d0Smrg
93972378475aSmrg# Files to dlopen/dlpreopen
93982378475aSmrgdlopen='$dlfiles'
93992378475aSmrgdlpreopen='$dlprefiles'
940095b296d0Smrg
94012378475aSmrg# Directory that this library needs to be installed in:
94022378475aSmrglibdir='$install_libdir'"
94032378475aSmrg	  if test "$installed" = no && test "$need_relink" = yes; then
94042378475aSmrg	    $ECHO >> $output "\
94052378475aSmrgrelink_command=\"$relink_command\""
94062378475aSmrg	  fi
94072378475aSmrg	done
94082378475aSmrg      }
940995b296d0Smrg
94102378475aSmrg      # Do a symbolic link so that the libtool archive can be found in
94112378475aSmrg      # LD_LIBRARY_PATH before the program is installed.
94122378475aSmrg      func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
94132378475aSmrg      ;;
94142378475aSmrg    esac
94152378475aSmrg    exit $EXIT_SUCCESS
94162378475aSmrg}
9417e6f085baSmrg
941814330f12Smrg{ test "$opt_mode" = link || test "$opt_mode" = relink; } &&
94192378475aSmrg    func_mode_link ${1+"$@"}
942095b296d0Smrg
942195b296d0Smrg
94222378475aSmrg# func_mode_uninstall arg...
94232378475aSmrgfunc_mode_uninstall ()
94242378475aSmrg{
94252378475aSmrg    $opt_debug
94262378475aSmrg    RM="$nonopt"
942795b296d0Smrg    files=
942895b296d0Smrg    rmforce=
942995b296d0Smrg    exit_status=0
943095b296d0Smrg
943195b296d0Smrg    # This variable tells wrapper scripts just to set variables rather
943295b296d0Smrg    # than running their programs.
943395b296d0Smrg    libtool_install_magic="$magic"
943495b296d0Smrg
943595b296d0Smrg    for arg
943695b296d0Smrg    do
943795b296d0Smrg      case $arg in
943814330f12Smrg      -f) func_append RM " $arg"; rmforce=yes ;;
943914330f12Smrg      -*) func_append RM " $arg" ;;
944014330f12Smrg      *) func_append files " $arg" ;;
944195b296d0Smrg      esac
944295b296d0Smrg    done
944395b296d0Smrg
94442378475aSmrg    test -z "$RM" && \
94452378475aSmrg      func_fatal_help "you must specify an RM program"
944695b296d0Smrg
944795b296d0Smrg    rmdirs=
944895b296d0Smrg
944995b296d0Smrg    for file in $files; do
94502378475aSmrg      func_dirname "$file" "" "."
94512378475aSmrg      dir="$func_dirname_result"
94522378475aSmrg      if test "X$dir" = X.; then
945314330f12Smrg	odir="$objdir"
945495b296d0Smrg      else
945514330f12Smrg	odir="$dir/$objdir"
945695b296d0Smrg      fi
94572378475aSmrg      func_basename "$file"
94582378475aSmrg      name="$func_basename_result"
945914330f12Smrg      test "$opt_mode" = uninstall && odir="$dir"
946095b296d0Smrg
946114330f12Smrg      # Remember odir for removal later, being careful to avoid duplicates
946214330f12Smrg      if test "$opt_mode" = clean; then
946395b296d0Smrg	case " $rmdirs " in
946414330f12Smrg	  *" $odir "*) ;;
946514330f12Smrg	  *) func_append rmdirs " $odir" ;;
946695b296d0Smrg	esac
946795b296d0Smrg      fi
946895b296d0Smrg
946995b296d0Smrg      # Don't error if the file doesn't exist and rm -f was used.
94702378475aSmrg      if { test -L "$file"; } >/dev/null 2>&1 ||
94712378475aSmrg	 { test -h "$file"; } >/dev/null 2>&1 ||
94722378475aSmrg	 test -f "$file"; then
947395b296d0Smrg	:
947495b296d0Smrg      elif test -d "$file"; then
947595b296d0Smrg	exit_status=1
947695b296d0Smrg	continue
947795b296d0Smrg      elif test "$rmforce" = yes; then
947895b296d0Smrg	continue
947995b296d0Smrg      fi
948095b296d0Smrg
948195b296d0Smrg      rmfiles="$file"
948295b296d0Smrg
948395b296d0Smrg      case $name in
948495b296d0Smrg      *.la)
948595b296d0Smrg	# Possibly a libtool archive, so verify it.
94862378475aSmrg	if func_lalib_p "$file"; then
94872378475aSmrg	  func_source $dir/$name
948895b296d0Smrg
948995b296d0Smrg	  # Delete the libtool libraries and symlinks.
949095b296d0Smrg	  for n in $library_names; do
949114330f12Smrg	    func_append rmfiles " $odir/$n"
949295b296d0Smrg	  done
949314330f12Smrg	  test -n "$old_library" && func_append rmfiles " $odir/$old_library"
949495b296d0Smrg
949514330f12Smrg	  case "$opt_mode" in
949695b296d0Smrg	  clean)
949714330f12Smrg	    case " $library_names " in
949895b296d0Smrg	    *" $dlname "*) ;;
949914330f12Smrg	    *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;;
950095b296d0Smrg	    esac
950114330f12Smrg	    test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i"
950295b296d0Smrg	    ;;
950395b296d0Smrg	  uninstall)
950495b296d0Smrg	    if test -n "$library_names"; then
950595b296d0Smrg	      # Do each command in the postuninstall commands.
95062378475aSmrg	      func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
950795b296d0Smrg	    fi
950895b296d0Smrg
950995b296d0Smrg	    if test -n "$old_library"; then
951095b296d0Smrg	      # Do each command in the old_postuninstall commands.
95112378475aSmrg	      func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
951295b296d0Smrg	    fi
951395b296d0Smrg	    # FIXME: should reinstall the best remaining shared library.
951495b296d0Smrg	    ;;
951595b296d0Smrg	  esac
951695b296d0Smrg	fi
951795b296d0Smrg	;;
951895b296d0Smrg
951995b296d0Smrg      *.lo)
952095b296d0Smrg	# Possibly a libtool object, so verify it.
95212378475aSmrg	if func_lalib_p "$file"; then
952295b296d0Smrg
952395b296d0Smrg	  # Read the .lo file
95242378475aSmrg	  func_source $dir/$name
952595b296d0Smrg
952695b296d0Smrg	  # Add PIC object to the list of files to remove.
95272378475aSmrg	  if test -n "$pic_object" &&
95282378475aSmrg	     test "$pic_object" != none; then
952914330f12Smrg	    func_append rmfiles " $dir/$pic_object"
953095b296d0Smrg	  fi
953195b296d0Smrg
953295b296d0Smrg	  # Add non-PIC object to the list of files to remove.
95332378475aSmrg	  if test -n "$non_pic_object" &&
95342378475aSmrg	     test "$non_pic_object" != none; then
953514330f12Smrg	    func_append rmfiles " $dir/$non_pic_object"
953695b296d0Smrg	  fi
953795b296d0Smrg	fi
953895b296d0Smrg	;;
953995b296d0Smrg
954095b296d0Smrg      *)
954114330f12Smrg	if test "$opt_mode" = clean ; then
954295b296d0Smrg	  noexename=$name
954395b296d0Smrg	  case $file in
954495b296d0Smrg	  *.exe)
95452378475aSmrg	    func_stripname '' '.exe' "$file"
95462378475aSmrg	    file=$func_stripname_result
95472378475aSmrg	    func_stripname '' '.exe' "$name"
95482378475aSmrg	    noexename=$func_stripname_result
954995b296d0Smrg	    # $file with .exe has already been added to rmfiles,
955095b296d0Smrg	    # add $file without .exe
955114330f12Smrg	    func_append rmfiles " $file"
955295b296d0Smrg	    ;;
955395b296d0Smrg	  esac
955495b296d0Smrg	  # Do a test to see if this is a libtool program.
95552378475aSmrg	  if func_ltwrapper_p "$file"; then
95562378475aSmrg	    if func_ltwrapper_executable_p "$file"; then
95572378475aSmrg	      func_ltwrapper_scriptname "$file"
95582378475aSmrg	      relink_command=
95592378475aSmrg	      func_source $func_ltwrapper_scriptname_result
956014330f12Smrg	      func_append rmfiles " $func_ltwrapper_scriptname_result"
95612378475aSmrg	    else
95622378475aSmrg	      relink_command=
95632378475aSmrg	      func_source $dir/$noexename
95642378475aSmrg	    fi
956595b296d0Smrg
956695b296d0Smrg	    # note $name still contains .exe if it was in $file originally
956795b296d0Smrg	    # as does the version of $file that was added into $rmfiles
956814330f12Smrg	    func_append rmfiles " $odir/$name $odir/${name}S.${objext}"
956995b296d0Smrg	    if test "$fast_install" = yes && test -n "$relink_command"; then
957014330f12Smrg	      func_append rmfiles " $odir/lt-$name"
957195b296d0Smrg	    fi
957295b296d0Smrg	    if test "X$noexename" != "X$name" ; then
957314330f12Smrg	      func_append rmfiles " $odir/lt-${noexename}.c"
957495b296d0Smrg	    fi
957595b296d0Smrg	  fi
957695b296d0Smrg	fi
957795b296d0Smrg	;;
957895b296d0Smrg      esac
95792378475aSmrg      func_show_eval "$RM $rmfiles" 'exit_status=1'
958095b296d0Smrg    done
958195b296d0Smrg
958295b296d0Smrg    # Try to remove the ${objdir}s in the directories where we deleted files
958395b296d0Smrg    for dir in $rmdirs; do
958495b296d0Smrg      if test -d "$dir"; then
95852378475aSmrg	func_show_eval "rmdir $dir >/dev/null 2>&1"
958695b296d0Smrg      fi
958795b296d0Smrg    done
958895b296d0Smrg
958995b296d0Smrg    exit $exit_status
95902378475aSmrg}
959195b296d0Smrg
959214330f12Smrg{ test "$opt_mode" = uninstall || test "$opt_mode" = clean; } &&
95932378475aSmrg    func_mode_uninstall ${1+"$@"}
959439713583Smrg
959514330f12Smrgtest -z "$opt_mode" && {
95962378475aSmrg  help="$generic_help"
95972378475aSmrg  func_fatal_help "you must specify a MODE"
95982378475aSmrg}
95992378475aSmrg
96002378475aSmrgtest -z "$exec_cmd" && \
960114330f12Smrg  func_fatal_help "invalid operation mode \`$opt_mode'"
960295b296d0Smrg
960395b296d0Smrgif test -n "$exec_cmd"; then
96042378475aSmrg  eval exec "$exec_cmd"
960595b296d0Smrg  exit $EXIT_FAILURE
960695b296d0Smrgfi
960795b296d0Smrg
96082378475aSmrgexit $exit_status
960995b296d0Smrg
961095b296d0Smrg
961195b296d0Smrg# The TAGs below are defined such that we never get into a situation
961295b296d0Smrg# in which we disable both kinds of libraries.  Given conflicting
961395b296d0Smrg# choices, we go for a static library, that is the most portable,
961495b296d0Smrg# since we can't tell whether shared libraries were disabled because
961595b296d0Smrg# the user asked for that or because the platform doesn't support
961695b296d0Smrg# them.  This is particularly important on AIX, because we don't
961795b296d0Smrg# support having both static and shared libraries enabled at the same
961895b296d0Smrg# time on that platform, so we default to a shared-only configuration.
961995b296d0Smrg# If a disable-shared tag is given, we'll fallback to a static-only
962095b296d0Smrg# configuration.  But we'll never go from static-only to shared-only.
962195b296d0Smrg
962295b296d0Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
96232378475aSmrgbuild_libtool_libs=no
96242378475aSmrgbuild_old_libs=yes
962595b296d0Smrg# ### END LIBTOOL TAG CONFIG: disable-shared
962695b296d0Smrg
962795b296d0Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static
96282378475aSmrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
962995b296d0Smrg# ### END LIBTOOL TAG CONFIG: disable-static
963095b296d0Smrg
963195b296d0Smrg# Local Variables:
963295b296d0Smrg# mode:shell-script
963395b296d0Smrg# sh-indentation:2
963495b296d0Smrg# End:
96352378475aSmrg# vi:sw=2
96362378475aSmrg
9637