ltmain.sh revision 899129b3
147e89262Smrg
2899129b3Smrg# libtool (GNU libtool) 2.4.2
347e89262Smrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
447e89262Smrg
55bcb6992Smrg# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006,
6899129b3Smrg# 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
747e89262Smrg# This is free software; see the source for copying conditions.  There is NO
847e89262Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
947e89262Smrg
1047e89262Smrg# GNU Libtool is free software; you can redistribute it and/or modify
11bd1da9d7Smrg# it under the terms of the GNU General Public License as published by
12bd1da9d7Smrg# the Free Software Foundation; either version 2 of the License, or
13bd1da9d7Smrg# (at your option) any later version.
14bd1da9d7Smrg#
1547e89262Smrg# As a special exception to the GNU General Public License,
1647e89262Smrg# if you distribute this file as part of a program or library that
1747e89262Smrg# is built using GNU Libtool, you may include this file under the
1847e89262Smrg# same distribution terms that you use for the rest of that program.
1947e89262Smrg#
2047e89262Smrg# GNU Libtool is distributed in the hope that it will be useful, but
21bd1da9d7Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of
22bd1da9d7Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
23bd1da9d7Smrg# General Public License for more details.
24bd1da9d7Smrg#
25bd1da9d7Smrg# You should have received a copy of the GNU General Public License
2647e89262Smrg# along with GNU Libtool; see the file COPYING.  If not, a copy
2747e89262Smrg# can be downloaded from http://www.gnu.org/licenses/gpl.html,
2847e89262Smrg# or obtained by writing to the Free Software Foundation, Inc.,
2947e89262Smrg# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
30bd1da9d7Smrg
3147e89262Smrg# Usage: $progname [OPTION]... [MODE-ARG]...
3247e89262Smrg#
3347e89262Smrg# Provide generalized library-building support services.
3447e89262Smrg#
3547e89262Smrg#       --config             show all configuration variables
3647e89262Smrg#       --debug              enable verbose shell tracing
3747e89262Smrg#   -n, --dry-run            display commands without modifying any files
3847e89262Smrg#       --features           display basic configuration information and exit
3947e89262Smrg#       --mode=MODE          use operation mode MODE
4047e89262Smrg#       --preserve-dup-deps  don't remove duplicate dependency libraries
4147e89262Smrg#       --quiet, --silent    don't print informational messages
4247e89262Smrg#       --no-quiet, --no-silent
4347e89262Smrg#                            print informational messages (default)
44899129b3Smrg#       --no-warn            don't display warning messages
4547e89262Smrg#       --tag=TAG            use configuration variables from tag TAG
4647e89262Smrg#   -v, --verbose            print more informational messages than default
4747e89262Smrg#       --no-verbose         don't print the extra informational messages
4847e89262Smrg#       --version            print version information
4947e89262Smrg#   -h, --help, --help-all   print short, long, or detailed help message
5047e89262Smrg#
5147e89262Smrg# MODE must be one of the following:
5247e89262Smrg#
5347e89262Smrg#         clean              remove files from the build directory
5447e89262Smrg#         compile            compile a source file into a libtool object
5547e89262Smrg#         execute            automatically set library path, then run a program
5647e89262Smrg#         finish             complete the installation of libtool libraries
5747e89262Smrg#         install            install libraries or executables
5847e89262Smrg#         link               create a library or an executable
5947e89262Smrg#         uninstall          remove libraries from an installed directory
6047e89262Smrg#
6147e89262Smrg# MODE-ARGS vary depending on the MODE.  When passed as first option,
6247e89262Smrg# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that.
6347e89262Smrg# Try `$progname --help --mode=MODE' for a more detailed description of MODE.
6447e89262Smrg#
6547e89262Smrg# When reporting a bug, please describe a test case to reproduce it and
6647e89262Smrg# include the following information:
6747e89262Smrg#
6847e89262Smrg#         host-triplet:	$host
6947e89262Smrg#         shell:		$SHELL
7047e89262Smrg#         compiler:		$LTCC
7147e89262Smrg#         compiler flags:		$LTCFLAGS
7247e89262Smrg#         linker:		$LD (gnu? $with_gnu_ld)
73899129b3Smrg#         $progname:	(GNU libtool) 2.4.2
7447e89262Smrg#         automake:	$automake_version
7547e89262Smrg#         autoconf:	$autoconf_version
7647e89262Smrg#
7747e89262Smrg# Report bugs to <bug-libtool@gnu.org>.
78899129b3Smrg# GNU libtool home page: <http://www.gnu.org/software/libtool/>.
79899129b3Smrg# General help using GNU software: <http://www.gnu.org/gethelp/>.
80bd1da9d7Smrg
8147e89262SmrgPROGRAM=libtool
82bd1da9d7SmrgPACKAGE=libtool
83899129b3SmrgVERSION=2.4.2
8447e89262SmrgTIMESTAMP=""
85899129b3Smrgpackage_revision=1.3337
865bcb6992Smrg
8747e89262Smrg# Be Bourne compatible
885bcb6992Smrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
895bcb6992Smrg  emulate sh
905bcb6992Smrg  NULLCMD=:
915bcb6992Smrg  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
925bcb6992Smrg  # is contrary to our usage.  Disable this feature.
935bcb6992Smrg  alias -g '${1+"$@"}'='"$@"'
94bd1da9d7Smrg  setopt NO_GLOB_SUBST
955bcb6992Smrgelse
965bcb6992Smrg  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
97bd1da9d7Smrgfi
985bcb6992SmrgBIN_SH=xpg4; export BIN_SH # for Tru64
995bcb6992SmrgDUALCASE=1; export DUALCASE # for MKS sh
100bd1da9d7Smrg
10147e89262Smrg# A function that is used when there is no print builtin or printf.
10247e89262Smrgfunc_fallback_echo ()
10347e89262Smrg{
10447e89262Smrg  eval 'cat <<_LTECHO_EOF
10547e89262Smrg$1
10647e89262Smrg_LTECHO_EOF'
10747e89262Smrg}
108bd1da9d7Smrg
10947e89262Smrg# NLS nuisances: We save the old values to restore during execute mode.
11047e89262Smrglt_user_locale=
11147e89262Smrglt_safe_locale=
1125bcb6992Smrgfor lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
1135bcb6992Smrgdo
1145bcb6992Smrg  eval "if test \"\${$lt_var+set}\" = set; then
11547e89262Smrg          save_$lt_var=\$$lt_var
11647e89262Smrg          $lt_var=C
1175bcb6992Smrg	  export $lt_var
11847e89262Smrg	  lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\"
11947e89262Smrg	  lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
1205bcb6992Smrg	fi"
1215bcb6992Smrgdone
12247e89262SmrgLC_ALL=C
12347e89262SmrgLANGUAGE=C
12447e89262Smrgexport LANGUAGE LC_ALL
1255bcb6992Smrg
12647e89262Smrg$lt_unset CDPATH
12747e89262Smrg
12847e89262Smrg
12947e89262Smrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
13047e89262Smrg# is ksh but when the shell is invoked as "sh" and the current value of
13147e89262Smrg# the _XPG environment variable is not equal to 1 (one), the special
13247e89262Smrg# positional parameter $0, within a function call, is the name of the
13347e89262Smrg# function.
13447e89262Smrgprogpath="$0"
13547e89262Smrg
13647e89262Smrg
13747e89262Smrg
13847e89262Smrg: ${CP="cp -f"}
13947e89262Smrgtest "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'}
14047e89262Smrg: ${MAKE="make"}
14147e89262Smrg: ${MKDIR="mkdir"}
14247e89262Smrg: ${MV="mv -f"}
14347e89262Smrg: ${RM="rm -f"}
14447e89262Smrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
14547e89262Smrg: ${Xsed="$SED -e 1s/^X//"}
14647e89262Smrg
14747e89262Smrg# Global variables:
14847e89262SmrgEXIT_SUCCESS=0
14947e89262SmrgEXIT_FAILURE=1
15047e89262SmrgEXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
15147e89262SmrgEXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
15247e89262Smrg
15347e89262Smrgexit_status=$EXIT_SUCCESS
154bd1da9d7Smrg
155bd1da9d7Smrg# Make sure IFS has a sensible default
156bd1da9d7Smrglt_nl='
157bd1da9d7Smrg'
158bd1da9d7SmrgIFS=" 	$lt_nl"
159bd1da9d7Smrg
16047e89262Smrgdirname="s,/[^/]*$,,"
16147e89262Smrgbasename="s,^.*/,,"
16247e89262Smrg
163899129b3Smrg# func_dirname file append nondir_replacement
164899129b3Smrg# Compute the dirname of FILE.  If nonempty, add APPEND to the result,
165899129b3Smrg# otherwise set result to NONDIR_REPLACEMENT.
166899129b3Smrgfunc_dirname ()
167899129b3Smrg{
168899129b3Smrg    func_dirname_result=`$ECHO "${1}" | $SED "$dirname"`
169899129b3Smrg    if test "X$func_dirname_result" = "X${1}"; then
170899129b3Smrg      func_dirname_result="${3}"
171899129b3Smrg    else
172899129b3Smrg      func_dirname_result="$func_dirname_result${2}"
173899129b3Smrg    fi
174899129b3Smrg} # func_dirname may be replaced by extended shell implementation
175899129b3Smrg
176899129b3Smrg
177899129b3Smrg# func_basename file
178899129b3Smrgfunc_basename ()
179899129b3Smrg{
180899129b3Smrg    func_basename_result=`$ECHO "${1}" | $SED "$basename"`
181899129b3Smrg} # func_basename may be replaced by extended shell implementation
182899129b3Smrg
183899129b3Smrg
18447e89262Smrg# func_dirname_and_basename file append nondir_replacement
18547e89262Smrg# perform func_basename and func_dirname in a single function
18647e89262Smrg# call:
18747e89262Smrg#   dirname:  Compute the dirname of FILE.  If nonempty,
18847e89262Smrg#             add APPEND to the result, otherwise set result
18947e89262Smrg#             to NONDIR_REPLACEMENT.
19047e89262Smrg#             value returned in "$func_dirname_result"
19147e89262Smrg#   basename: Compute filename of FILE.
19247e89262Smrg#             value retuned in "$func_basename_result"
19347e89262Smrg# Implementation must be kept synchronized with func_dirname
19447e89262Smrg# and func_basename. For efficiency, we do not delegate to
19547e89262Smrg# those functions but instead duplicate the functionality here.
19647e89262Smrgfunc_dirname_and_basename ()
19747e89262Smrg{
198899129b3Smrg    # Extract subdirectory from the argument.
199899129b3Smrg    func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"`
200899129b3Smrg    if test "X$func_dirname_result" = "X${1}"; then
201899129b3Smrg      func_dirname_result="${3}"
202899129b3Smrg    else
203899129b3Smrg      func_dirname_result="$func_dirname_result${2}"
204899129b3Smrg    fi
205899129b3Smrg    func_basename_result=`$ECHO "${1}" | $SED -e "$basename"`
206899129b3Smrg} # func_dirname_and_basename may be replaced by extended shell implementation
207899129b3Smrg
208899129b3Smrg
209899129b3Smrg# func_stripname prefix suffix name
210899129b3Smrg# strip PREFIX and SUFFIX off of NAME.
211899129b3Smrg# PREFIX and SUFFIX must not contain globbing or regex special
212899129b3Smrg# characters, hashes, percent signs, but SUFFIX may contain a leading
213899129b3Smrg# dot (in which case that matches only a dot).
214899129b3Smrg# func_strip_suffix prefix name
215899129b3Smrgfunc_stripname ()
216899129b3Smrg{
217899129b3Smrg    case ${2} in
218899129b3Smrg      .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;;
219899129b3Smrg      *)  func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;;
220899129b3Smrg    esac
221899129b3Smrg} # func_stripname may be replaced by extended shell implementation
222bd1da9d7Smrg
22347e89262Smrg
22447e89262Smrg# These SED scripts presuppose an absolute path with a trailing slash.
22547e89262Smrgpathcar='s,^/\([^/]*\).*$,\1,'
22647e89262Smrgpathcdr='s,^/[^/]*,,'
22747e89262Smrgremovedotparts=':dotsl
22847e89262Smrg		s@/\./@/@g
22947e89262Smrg		t dotsl
23047e89262Smrg		s,/\.$,/,'
23147e89262Smrgcollapseslashes='s@/\{1,\}@/@g'
23247e89262Smrgfinalslash='s,/*$,/,'
23347e89262Smrg
23447e89262Smrg# func_normal_abspath PATH
23547e89262Smrg# Remove doubled-up and trailing slashes, "." path components,
23647e89262Smrg# and cancel out any ".." path components in PATH after making
23747e89262Smrg# it an absolute path.
23847e89262Smrg#             value returned in "$func_normal_abspath_result"
23947e89262Smrgfunc_normal_abspath ()
24047e89262Smrg{
24147e89262Smrg  # Start from root dir and reassemble the path.
24247e89262Smrg  func_normal_abspath_result=
24347e89262Smrg  func_normal_abspath_tpath=$1
24447e89262Smrg  func_normal_abspath_altnamespace=
24547e89262Smrg  case $func_normal_abspath_tpath in
24647e89262Smrg    "")
24747e89262Smrg      # Empty path, that just means $cwd.
24847e89262Smrg      func_stripname '' '/' "`pwd`"
24947e89262Smrg      func_normal_abspath_result=$func_stripname_result
25047e89262Smrg      return
25147e89262Smrg    ;;
25247e89262Smrg    # The next three entries are used to spot a run of precisely
25347e89262Smrg    # two leading slashes without using negated character classes;
25447e89262Smrg    # we take advantage of case's first-match behaviour.
25547e89262Smrg    ///*)
25647e89262Smrg      # Unusual form of absolute path, do nothing.
25747e89262Smrg    ;;
25847e89262Smrg    //*)
25947e89262Smrg      # Not necessarily an ordinary path; POSIX reserves leading '//'
26047e89262Smrg      # and for example Cygwin uses it to access remote file shares
26147e89262Smrg      # over CIFS/SMB, so we conserve a leading double slash if found.
26247e89262Smrg      func_normal_abspath_altnamespace=/
26347e89262Smrg    ;;
26447e89262Smrg    /*)
26547e89262Smrg      # Absolute path, do nothing.
26647e89262Smrg    ;;
26747e89262Smrg    *)
26847e89262Smrg      # Relative path, prepend $cwd.
26947e89262Smrg      func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
27047e89262Smrg    ;;
27147e89262Smrg  esac
27247e89262Smrg  # Cancel out all the simple stuff to save iterations.  We also want
27347e89262Smrg  # the path to end with a slash for ease of parsing, so make sure
27447e89262Smrg  # there is one (and only one) here.
27547e89262Smrg  func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
27647e89262Smrg        -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"`
27747e89262Smrg  while :; do
27847e89262Smrg    # Processed it all yet?
27947e89262Smrg    if test "$func_normal_abspath_tpath" = / ; then
28047e89262Smrg      # If we ascended to the root using ".." the result may be empty now.
28147e89262Smrg      if test -z "$func_normal_abspath_result" ; then
28247e89262Smrg        func_normal_abspath_result=/
28347e89262Smrg      fi
28447e89262Smrg      break
28547e89262Smrg    fi
28647e89262Smrg    func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
28747e89262Smrg        -e "$pathcar"`
28847e89262Smrg    func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
28947e89262Smrg        -e "$pathcdr"`
29047e89262Smrg    # Figure out what to do with it
29147e89262Smrg    case $func_normal_abspath_tcomponent in
29247e89262Smrg      "")
29347e89262Smrg        # Trailing empty path component, ignore it.
29447e89262Smrg      ;;
29547e89262Smrg      ..)
29647e89262Smrg        # Parent dir; strip last assembled component from result.
29747e89262Smrg        func_dirname "$func_normal_abspath_result"
29847e89262Smrg        func_normal_abspath_result=$func_dirname_result
29947e89262Smrg      ;;
30047e89262Smrg      *)
30147e89262Smrg        # Actual path component, append it.
30247e89262Smrg        func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent
30347e89262Smrg      ;;
30447e89262Smrg    esac
30547e89262Smrg  done
30647e89262Smrg  # Restore leading double-slash if one was found on entry.
30747e89262Smrg  func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
30847e89262Smrg}
30947e89262Smrg
31047e89262Smrg# func_relative_path SRCDIR DSTDIR
31147e89262Smrg# generates a relative path from SRCDIR to DSTDIR, with a trailing
31247e89262Smrg# slash if non-empty, suitable for immediately appending a filename
31347e89262Smrg# without needing to append a separator.
31447e89262Smrg#             value returned in "$func_relative_path_result"
31547e89262Smrgfunc_relative_path ()
31647e89262Smrg{
31747e89262Smrg  func_relative_path_result=
31847e89262Smrg  func_normal_abspath "$1"
31947e89262Smrg  func_relative_path_tlibdir=$func_normal_abspath_result
32047e89262Smrg  func_normal_abspath "$2"
32147e89262Smrg  func_relative_path_tbindir=$func_normal_abspath_result
32247e89262Smrg
32347e89262Smrg  # Ascend the tree starting from libdir
32447e89262Smrg  while :; do
32547e89262Smrg    # check if we have found a prefix of bindir
32647e89262Smrg    case $func_relative_path_tbindir in
32747e89262Smrg      $func_relative_path_tlibdir)
32847e89262Smrg        # found an exact match
32947e89262Smrg        func_relative_path_tcancelled=
33047e89262Smrg        break
33147e89262Smrg        ;;
33247e89262Smrg      $func_relative_path_tlibdir*)
33347e89262Smrg        # found a matching prefix
33447e89262Smrg        func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
33547e89262Smrg        func_relative_path_tcancelled=$func_stripname_result
33647e89262Smrg        if test -z "$func_relative_path_result"; then
33747e89262Smrg          func_relative_path_result=.
33847e89262Smrg        fi
33947e89262Smrg        break
34047e89262Smrg        ;;
34147e89262Smrg      *)
34247e89262Smrg        func_dirname $func_relative_path_tlibdir
34347e89262Smrg        func_relative_path_tlibdir=${func_dirname_result}
34447e89262Smrg        if test "x$func_relative_path_tlibdir" = x ; then
34547e89262Smrg          # Have to descend all the way to the root!
34647e89262Smrg          func_relative_path_result=../$func_relative_path_result
34747e89262Smrg          func_relative_path_tcancelled=$func_relative_path_tbindir
34847e89262Smrg          break
34947e89262Smrg        fi
35047e89262Smrg        func_relative_path_result=../$func_relative_path_result
35147e89262Smrg        ;;
35247e89262Smrg    esac
35347e89262Smrg  done
35447e89262Smrg
35547e89262Smrg  # Now calculate path; take care to avoid doubling-up slashes.
35647e89262Smrg  func_stripname '' '/' "$func_relative_path_result"
35747e89262Smrg  func_relative_path_result=$func_stripname_result
35847e89262Smrg  func_stripname '/' '/' "$func_relative_path_tcancelled"
35947e89262Smrg  if test "x$func_stripname_result" != x ; then
36047e89262Smrg    func_relative_path_result=${func_relative_path_result}/${func_stripname_result}
36147e89262Smrg  fi
36247e89262Smrg
36347e89262Smrg  # Normalisation. If bindir is libdir, return empty string,
36447e89262Smrg  # else relative path ending with a slash; either way, target
36547e89262Smrg  # file name can be directly appended.
36647e89262Smrg  if test ! -z "$func_relative_path_result"; then
36747e89262Smrg    func_stripname './' '' "$func_relative_path_result/"
36847e89262Smrg    func_relative_path_result=$func_stripname_result
36947e89262Smrg  fi
37047e89262Smrg}
37147e89262Smrg
37247e89262Smrg# The name of this program:
37347e89262Smrgfunc_dirname_and_basename "$progpath"
37447e89262Smrgprogname=$func_basename_result
37547e89262Smrg
37647e89262Smrg# Make sure we have an absolute path for reexecution:
37747e89262Smrgcase $progpath in
37847e89262Smrg  [\\/]*|[A-Za-z]:\\*) ;;
37947e89262Smrg  *[\\/]*)
38047e89262Smrg     progdir=$func_dirname_result
38147e89262Smrg     progdir=`cd "$progdir" && pwd`
38247e89262Smrg     progpath="$progdir/$progname"
38347e89262Smrg     ;;
38447e89262Smrg  *)
38547e89262Smrg     save_IFS="$IFS"
386899129b3Smrg     IFS=${PATH_SEPARATOR-:}
38747e89262Smrg     for progdir in $PATH; do
38847e89262Smrg       IFS="$save_IFS"
38947e89262Smrg       test -x "$progdir/$progname" && break
39047e89262Smrg     done
39147e89262Smrg     IFS="$save_IFS"
39247e89262Smrg     test -n "$progdir" || progdir=`pwd`
39347e89262Smrg     progpath="$progdir/$progname"
39447e89262Smrg     ;;
39547e89262Smrgesac
39647e89262Smrg
39747e89262Smrg# Sed substitution that helps us do robust quoting.  It backslashifies
39847e89262Smrg# metacharacters that are still active within double-quoted strings.
39947e89262SmrgXsed="${SED}"' -e 1s/^X//'
40047e89262Smrgsed_quote_subst='s/\([`"$\\]\)/\\\1/g'
40147e89262Smrg
40247e89262Smrg# Same as above, but do not quote variable references.
40347e89262Smrgdouble_quote_subst='s/\(["`\\]\)/\\\1/g'
40447e89262Smrg
405899129b3Smrg# Sed substitution that turns a string into a regex matching for the
406899129b3Smrg# string literally.
407899129b3Smrgsed_make_literal_regex='s,[].[^$\\*\/],\\&,g'
408899129b3Smrg
409899129b3Smrg# Sed substitution that converts a w32 file name or path
410899129b3Smrg# which contains forward slashes, into one that contains
411899129b3Smrg# (escaped) backslashes.  A very naive implementation.
412899129b3Smrglt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
413899129b3Smrg
41447e89262Smrg# Re-`\' parameter expansions in output of double_quote_subst that were
41547e89262Smrg# `\'-ed in input to the same.  If an odd number of `\' preceded a '$'
41647e89262Smrg# in input to double_quote_subst, that '$' was protected from expansion.
41747e89262Smrg# Since each input `\' is now two `\'s, look for any number of runs of
41847e89262Smrg# four `\'s followed by two `\'s and then a '$'.  `\' that '$'.
41947e89262Smrgbs='\\'
42047e89262Smrgbs2='\\\\'
42147e89262Smrgbs4='\\\\\\\\'
42247e89262Smrgdollar='\$'
42347e89262Smrgsed_double_backslash="\
42447e89262Smrg  s/$bs4/&\\
42547e89262Smrg/g
42647e89262Smrg  s/^$bs2$dollar/$bs&/
42747e89262Smrg  s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
42847e89262Smrg  s/\n//g"
42947e89262Smrg
43047e89262Smrg# Standard options:
43147e89262Smrgopt_dry_run=false
43247e89262Smrgopt_help=false
43347e89262Smrgopt_quiet=false
43447e89262Smrgopt_verbose=false
43547e89262Smrgopt_warning=:
43647e89262Smrg
43747e89262Smrg# func_echo arg...
43847e89262Smrg# Echo program name prefixed message, along with the current mode
43947e89262Smrg# name if it has been set yet.
44047e89262Smrgfunc_echo ()
44147e89262Smrg{
442899129b3Smrg    $ECHO "$progname: ${opt_mode+$opt_mode: }$*"
44347e89262Smrg}
44447e89262Smrg
44547e89262Smrg# func_verbose arg...
44647e89262Smrg# Echo program name prefixed message in verbose mode only.
44747e89262Smrgfunc_verbose ()
44847e89262Smrg{
44947e89262Smrg    $opt_verbose && func_echo ${1+"$@"}
45047e89262Smrg
45147e89262Smrg    # A bug in bash halts the script if the last line of a function
45247e89262Smrg    # fails when set -e is in force, so we need another command to
45347e89262Smrg    # work around that:
45447e89262Smrg    :
45547e89262Smrg}
45647e89262Smrg
45747e89262Smrg# func_echo_all arg...
45847e89262Smrg# Invoke $ECHO with all args, space-separated.
45947e89262Smrgfunc_echo_all ()
46047e89262Smrg{
46147e89262Smrg    $ECHO "$*"
46247e89262Smrg}
46347e89262Smrg
46447e89262Smrg# func_error arg...
46547e89262Smrg# Echo program name prefixed message to standard error.
46647e89262Smrgfunc_error ()
46747e89262Smrg{
468899129b3Smrg    $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2
46947e89262Smrg}
47047e89262Smrg
47147e89262Smrg# func_warning arg...
47247e89262Smrg# Echo program name prefixed warning message to standard error.
47347e89262Smrgfunc_warning ()
47447e89262Smrg{
475899129b3Smrg    $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2
47647e89262Smrg
47747e89262Smrg    # bash bug again:
47847e89262Smrg    :
47947e89262Smrg}
48047e89262Smrg
48147e89262Smrg# func_fatal_error arg...
48247e89262Smrg# Echo program name prefixed message to standard error, and exit.
48347e89262Smrgfunc_fatal_error ()
48447e89262Smrg{
48547e89262Smrg    func_error ${1+"$@"}
48647e89262Smrg    exit $EXIT_FAILURE
48747e89262Smrg}
48847e89262Smrg
48947e89262Smrg# func_fatal_help arg...
49047e89262Smrg# Echo program name prefixed message to standard error, followed by
49147e89262Smrg# a help hint, and exit.
49247e89262Smrgfunc_fatal_help ()
49347e89262Smrg{
49447e89262Smrg    func_error ${1+"$@"}
49547e89262Smrg    func_fatal_error "$help"
49647e89262Smrg}
49747e89262Smrghelp="Try \`$progname --help' for more information."  ## default
49847e89262Smrg
49947e89262Smrg
50047e89262Smrg# func_grep expression filename
50147e89262Smrg# Check whether EXPRESSION matches any line of FILENAME, without output.
50247e89262Smrgfunc_grep ()
50347e89262Smrg{
50447e89262Smrg    $GREP "$1" "$2" >/dev/null 2>&1
50547e89262Smrg}
50647e89262Smrg
50747e89262Smrg
50847e89262Smrg# func_mkdir_p directory-path
50947e89262Smrg# Make sure the entire path to DIRECTORY-PATH is available.
51047e89262Smrgfunc_mkdir_p ()
51147e89262Smrg{
51247e89262Smrg    my_directory_path="$1"
51347e89262Smrg    my_dir_list=
51447e89262Smrg
51547e89262Smrg    if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
51647e89262Smrg
51747e89262Smrg      # Protect directory names starting with `-'
51847e89262Smrg      case $my_directory_path in
51947e89262Smrg        -*) my_directory_path="./$my_directory_path" ;;
52047e89262Smrg      esac
52147e89262Smrg
52247e89262Smrg      # While some portion of DIR does not yet exist...
52347e89262Smrg      while test ! -d "$my_directory_path"; do
52447e89262Smrg        # ...make a list in topmost first order.  Use a colon delimited
52547e89262Smrg	# list incase some portion of path contains whitespace.
52647e89262Smrg        my_dir_list="$my_directory_path:$my_dir_list"
52747e89262Smrg
52847e89262Smrg        # If the last portion added has no slash in it, the list is done
52947e89262Smrg        case $my_directory_path in */*) ;; *) break ;; esac
53047e89262Smrg
53147e89262Smrg        # ...otherwise throw away the child directory and loop
53247e89262Smrg        my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"`
53347e89262Smrg      done
53447e89262Smrg      my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'`
53547e89262Smrg
53647e89262Smrg      save_mkdir_p_IFS="$IFS"; IFS=':'
53747e89262Smrg      for my_dir in $my_dir_list; do
53847e89262Smrg	IFS="$save_mkdir_p_IFS"
53947e89262Smrg        # mkdir can fail with a `File exist' error if two processes
54047e89262Smrg        # try to create one of the directories concurrently.  Don't
54147e89262Smrg        # stop in that case!
54247e89262Smrg        $MKDIR "$my_dir" 2>/dev/null || :
54347e89262Smrg      done
54447e89262Smrg      IFS="$save_mkdir_p_IFS"
54547e89262Smrg
54647e89262Smrg      # Bail out if we (or some other process) failed to create a directory.
54747e89262Smrg      test -d "$my_directory_path" || \
54847e89262Smrg        func_fatal_error "Failed to create \`$1'"
54947e89262Smrg    fi
55047e89262Smrg}
551bd1da9d7Smrg
552bd1da9d7Smrg
553bd1da9d7Smrg# func_mktempdir [string]
554bd1da9d7Smrg# Make a temporary directory that won't clash with other running
555bd1da9d7Smrg# libtool processes, and avoids race conditions if possible.  If
556bd1da9d7Smrg# given, STRING is the basename for that directory.
557bd1da9d7Smrgfunc_mktempdir ()
558bd1da9d7Smrg{
559bd1da9d7Smrg    my_template="${TMPDIR-/tmp}/${1-$progname}"
560bd1da9d7Smrg
56147e89262Smrg    if test "$opt_dry_run" = ":"; then
562bd1da9d7Smrg      # Return a directory name, but don't create it in dry-run mode
563bd1da9d7Smrg      my_tmpdir="${my_template}-$$"
564bd1da9d7Smrg    else
565bd1da9d7Smrg
566bd1da9d7Smrg      # If mktemp works, use that first and foremost
567bd1da9d7Smrg      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
568bd1da9d7Smrg
569bd1da9d7Smrg      if test ! -d "$my_tmpdir"; then
57047e89262Smrg        # Failing that, at least try and use $RANDOM to avoid a race
57147e89262Smrg        my_tmpdir="${my_template}-${RANDOM-0}$$"
572bd1da9d7Smrg
57347e89262Smrg        save_mktempdir_umask=`umask`
57447e89262Smrg        umask 0077
57547e89262Smrg        $MKDIR "$my_tmpdir"
57647e89262Smrg        umask $save_mktempdir_umask
577bd1da9d7Smrg      fi
578bd1da9d7Smrg
579bd1da9d7Smrg      # If we're not in dry-run mode, bomb out on failure
58047e89262Smrg      test -d "$my_tmpdir" || \
58147e89262Smrg        func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
582bd1da9d7Smrg    fi
583bd1da9d7Smrg
58447e89262Smrg    $ECHO "$my_tmpdir"
585bd1da9d7Smrg}
586bd1da9d7Smrg
587bd1da9d7Smrg
58847e89262Smrg# func_quote_for_eval arg
58947e89262Smrg# Aesthetically quote ARG to be evaled later.
59047e89262Smrg# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
59147e89262Smrg# is double-quoted, suitable for a subsequent eval, whereas
59247e89262Smrg# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
59347e89262Smrg# which are still active within double quotes backslashified.
59447e89262Smrgfunc_quote_for_eval ()
595bd1da9d7Smrg{
59647e89262Smrg    case $1 in
59747e89262Smrg      *[\\\`\"\$]*)
59847e89262Smrg	func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;;
59947e89262Smrg      *)
60047e89262Smrg        func_quote_for_eval_unquoted_result="$1" ;;
60147e89262Smrg    esac
60247e89262Smrg
60347e89262Smrg    case $func_quote_for_eval_unquoted_result in
60447e89262Smrg      # Double-quote args containing shell metacharacters to delay
60547e89262Smrg      # word splitting, command substitution and and variable
60647e89262Smrg      # expansion for a subsequent eval.
60747e89262Smrg      # Many Bourne shells cannot handle close brackets correctly
60847e89262Smrg      # in scan sets, so we specify it separately.
60947e89262Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
61047e89262Smrg        func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
61147e89262Smrg        ;;
61247e89262Smrg      *)
61347e89262Smrg        func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
614bd1da9d7Smrg    esac
615bd1da9d7Smrg}
616bd1da9d7Smrg
617bd1da9d7Smrg
61847e89262Smrg# func_quote_for_expand arg
61947e89262Smrg# Aesthetically quote ARG to be evaled later; same as above,
62047e89262Smrg# but do not quote variable references.
62147e89262Smrgfunc_quote_for_expand ()
622bd1da9d7Smrg{
62347e89262Smrg    case $1 in
62447e89262Smrg      *[\\\`\"]*)
62547e89262Smrg	my_arg=`$ECHO "$1" | $SED \
62647e89262Smrg	    -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
627bd1da9d7Smrg      *)
62847e89262Smrg        my_arg="$1" ;;
62947e89262Smrg    esac
63047e89262Smrg
63147e89262Smrg    case $my_arg in
63247e89262Smrg      # Double-quote args containing shell metacharacters to delay
63347e89262Smrg      # word splitting and command substitution for a subsequent eval.
63447e89262Smrg      # Many Bourne shells cannot handle close brackets correctly
63547e89262Smrg      # in scan sets, so we specify it separately.
63647e89262Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
63747e89262Smrg        my_arg="\"$my_arg\""
63847e89262Smrg        ;;
63947e89262Smrg    esac
64047e89262Smrg
64147e89262Smrg    func_quote_for_expand_result="$my_arg"
642bd1da9d7Smrg}
643bd1da9d7Smrg
644bd1da9d7Smrg
64547e89262Smrg# func_show_eval cmd [fail_exp]
64647e89262Smrg# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
64747e89262Smrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
64847e89262Smrg# is given, then evaluate it.
64947e89262Smrgfunc_show_eval ()
650bd1da9d7Smrg{
65147e89262Smrg    my_cmd="$1"
65247e89262Smrg    my_fail_exp="${2-:}"
653bd1da9d7Smrg
65447e89262Smrg    ${opt_silent-false} || {
65547e89262Smrg      func_quote_for_expand "$my_cmd"
65647e89262Smrg      eval "func_echo $func_quote_for_expand_result"
65747e89262Smrg    }
65847e89262Smrg
65947e89262Smrg    if ${opt_dry_run-false}; then :; else
66047e89262Smrg      eval "$my_cmd"
66147e89262Smrg      my_status=$?
66247e89262Smrg      if test "$my_status" -eq 0; then :; else
66347e89262Smrg	eval "(exit $my_status); $my_fail_exp"
66447e89262Smrg      fi
665bd1da9d7Smrg    fi
666bd1da9d7Smrg}
667bd1da9d7Smrg
66847e89262Smrg
66947e89262Smrg# func_show_eval_locale cmd [fail_exp]
67047e89262Smrg# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
67147e89262Smrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
67247e89262Smrg# is given, then evaluate it.  Use the saved locale for evaluation.
67347e89262Smrgfunc_show_eval_locale ()
674bd1da9d7Smrg{
67547e89262Smrg    my_cmd="$1"
67647e89262Smrg    my_fail_exp="${2-:}"
677bd1da9d7Smrg
67847e89262Smrg    ${opt_silent-false} || {
67947e89262Smrg      func_quote_for_expand "$my_cmd"
68047e89262Smrg      eval "func_echo $func_quote_for_expand_result"
68147e89262Smrg    }
682bd1da9d7Smrg
68347e89262Smrg    if ${opt_dry_run-false}; then :; else
68447e89262Smrg      eval "$lt_user_locale
68547e89262Smrg	    $my_cmd"
68647e89262Smrg      my_status=$?
68747e89262Smrg      eval "$lt_safe_locale"
68847e89262Smrg      if test "$my_status" -eq 0; then :; else
68947e89262Smrg	eval "(exit $my_status); $my_fail_exp"
690bd1da9d7Smrg      fi
69147e89262Smrg    fi
692bd1da9d7Smrg}
693bd1da9d7Smrg
694899129b3Smrg# func_tr_sh
695899129b3Smrg# Turn $1 into a string suitable for a shell variable name.
696899129b3Smrg# Result is stored in $func_tr_sh_result.  All characters
697899129b3Smrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further,
698899129b3Smrg# if $1 begins with a digit, a '_' is prepended as well.
699899129b3Smrgfunc_tr_sh ()
700899129b3Smrg{
701899129b3Smrg  case $1 in
702899129b3Smrg  [0-9]* | *[!a-zA-Z0-9_]*)
703899129b3Smrg    func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'`
704899129b3Smrg    ;;
705899129b3Smrg  * )
706899129b3Smrg    func_tr_sh_result=$1
707899129b3Smrg    ;;
708899129b3Smrg  esac
709899129b3Smrg}
710899129b3Smrg
711bd1da9d7Smrg
71247e89262Smrg# func_version
71347e89262Smrg# Echo version message to standard output and exit.
71447e89262Smrgfunc_version ()
71547e89262Smrg{
716899129b3Smrg    $opt_debug
717899129b3Smrg
71847e89262Smrg    $SED -n '/(C)/!b go
71947e89262Smrg	:more
72047e89262Smrg	/\./!{
72147e89262Smrg	  N
72247e89262Smrg	  s/\n# / /
72347e89262Smrg	  b more
72447e89262Smrg	}
72547e89262Smrg	:go
72647e89262Smrg	/^# '$PROGRAM' (GNU /,/# warranty; / {
72747e89262Smrg        s/^# //
72847e89262Smrg	s/^# *$//
72947e89262Smrg        s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
73047e89262Smrg        p
73147e89262Smrg     }' < "$progpath"
73247e89262Smrg     exit $?
73347e89262Smrg}
734bd1da9d7Smrg
73547e89262Smrg# func_usage
73647e89262Smrg# Echo short help message to standard output and exit.
73747e89262Smrgfunc_usage ()
73847e89262Smrg{
739899129b3Smrg    $opt_debug
740899129b3Smrg
74147e89262Smrg    $SED -n '/^# Usage:/,/^#  *.*--help/ {
74247e89262Smrg        s/^# //
74347e89262Smrg	s/^# *$//
74447e89262Smrg	s/\$progname/'$progname'/
74547e89262Smrg	p
74647e89262Smrg    }' < "$progpath"
74747e89262Smrg    echo
74847e89262Smrg    $ECHO "run \`$progname --help | more' for full usage"
74947e89262Smrg    exit $?
75047e89262Smrg}
751bd1da9d7Smrg
75247e89262Smrg# func_help [NOEXIT]
75347e89262Smrg# Echo long help message to standard output and exit,
75447e89262Smrg# unless 'noexit' is passed as argument.
75547e89262Smrgfunc_help ()
75647e89262Smrg{
757899129b3Smrg    $opt_debug
758899129b3Smrg
75947e89262Smrg    $SED -n '/^# Usage:/,/# Report bugs to/ {
760899129b3Smrg	:print
76147e89262Smrg        s/^# //
76247e89262Smrg	s/^# *$//
76347e89262Smrg	s*\$progname*'$progname'*
76447e89262Smrg	s*\$host*'"$host"'*
76547e89262Smrg	s*\$SHELL*'"$SHELL"'*
76647e89262Smrg	s*\$LTCC*'"$LTCC"'*
76747e89262Smrg	s*\$LTCFLAGS*'"$LTCFLAGS"'*
76847e89262Smrg	s*\$LD*'"$LD"'*
76947e89262Smrg	s/\$with_gnu_ld/'"$with_gnu_ld"'/
770899129b3Smrg	s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/
771899129b3Smrg	s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/
77247e89262Smrg	p
773899129b3Smrg	d
774899129b3Smrg     }
775899129b3Smrg     /^# .* home page:/b print
776899129b3Smrg     /^# General help using/b print
777899129b3Smrg     ' < "$progpath"
77847e89262Smrg    ret=$?
77947e89262Smrg    if test -z "$1"; then
78047e89262Smrg      exit $ret
78147e89262Smrg    fi
78247e89262Smrg}
783bd1da9d7Smrg
78447e89262Smrg# func_missing_arg argname
78547e89262Smrg# Echo program name prefixed message to standard error and set global
78647e89262Smrg# exit_cmd.
78747e89262Smrgfunc_missing_arg ()
78847e89262Smrg{
789899129b3Smrg    $opt_debug
790899129b3Smrg
79147e89262Smrg    func_error "missing argument for $1."
79247e89262Smrg    exit_cmd=exit
79347e89262Smrg}
794bd1da9d7Smrg
795bd1da9d7Smrg
796899129b3Smrg# func_split_short_opt shortopt
797899129b3Smrg# Set func_split_short_opt_name and func_split_short_opt_arg shell
798899129b3Smrg# variables after splitting SHORTOPT after the 2nd character.
799899129b3Smrgfunc_split_short_opt ()
800899129b3Smrg{
801899129b3Smrg    my_sed_short_opt='1s/^\(..\).*$/\1/;q'
802899129b3Smrg    my_sed_short_rest='1s/^..\(.*\)$/\1/;q'
803899129b3Smrg
804899129b3Smrg    func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"`
805899129b3Smrg    func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"`
806899129b3Smrg} # func_split_short_opt may be replaced by extended shell implementation
807899129b3Smrg
808899129b3Smrg
809899129b3Smrg# func_split_long_opt longopt
810899129b3Smrg# Set func_split_long_opt_name and func_split_long_opt_arg shell
811899129b3Smrg# variables after splitting LONGOPT at the `=' sign.
812899129b3Smrgfunc_split_long_opt ()
813899129b3Smrg{
814899129b3Smrg    my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q'
815899129b3Smrg    my_sed_long_arg='1s/^--[^=]*=//'
816899129b3Smrg
817899129b3Smrg    func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"`
818899129b3Smrg    func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"`
819899129b3Smrg} # func_split_long_opt may be replaced by extended shell implementation
820899129b3Smrg
821899129b3Smrgexit_cmd=:
822bd1da9d7Smrg
823bd1da9d7Smrg
8245bcb6992Smrg
825bd1da9d7Smrg
82647e89262Smrg
82747e89262Smrgmagic="%%%MAGIC variable%%%"
82847e89262Smrgmagic_exe="%%%MAGIC EXE variable%%%"
82947e89262Smrg
83047e89262Smrg# Global variables.
83147e89262Smrgnonopt=
83247e89262Smrgpreserve_args=
83347e89262Smrglo2o="s/\\.lo\$/.${objext}/"
83447e89262Smrgo2lo="s/\\.${objext}\$/.lo/"
83547e89262Smrgextracted_archives=
83647e89262Smrgextracted_serial=0
83747e89262Smrg
83847e89262Smrg# If this variable is set in any of the actions, the command in it
83947e89262Smrg# will be execed at the end.  This prevents here-documents from being
84047e89262Smrg# left over by shells.
84147e89262Smrgexec_cmd=
84247e89262Smrg
843899129b3Smrg# func_append var value
844899129b3Smrg# Append VALUE to the end of shell variable VAR.
845899129b3Smrgfunc_append ()
846899129b3Smrg{
847899129b3Smrg    eval "${1}=\$${1}\${2}"
848899129b3Smrg} # func_append may be replaced by extended shell implementation
849899129b3Smrg
850899129b3Smrg# func_append_quoted var value
851899129b3Smrg# Quote VALUE and append to the end of shell variable VAR, separated
852899129b3Smrg# by a space.
853899129b3Smrgfunc_append_quoted ()
854899129b3Smrg{
855899129b3Smrg    func_quote_for_eval "${2}"
856899129b3Smrg    eval "${1}=\$${1}\\ \$func_quote_for_eval_result"
857899129b3Smrg} # func_append_quoted may be replaced by extended shell implementation
858899129b3Smrg
859899129b3Smrg
860899129b3Smrg# func_arith arithmetic-term...
861899129b3Smrgfunc_arith ()
862899129b3Smrg{
863899129b3Smrg    func_arith_result=`expr "${@}"`
864899129b3Smrg} # func_arith may be replaced by extended shell implementation
865899129b3Smrg
866899129b3Smrg
867899129b3Smrg# func_len string
868899129b3Smrg# STRING may not start with a hyphen.
869899129b3Smrgfunc_len ()
870899129b3Smrg{
871899129b3Smrg    func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len`
872899129b3Smrg} # func_len may be replaced by extended shell implementation
873899129b3Smrg
874899129b3Smrg
875899129b3Smrg# func_lo2o object
876899129b3Smrgfunc_lo2o ()
877899129b3Smrg{
878899129b3Smrg    func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"`
879899129b3Smrg} # func_lo2o may be replaced by extended shell implementation
880899129b3Smrg
881899129b3Smrg
882899129b3Smrg# func_xform libobj-or-source
883899129b3Smrgfunc_xform ()
884899129b3Smrg{
885899129b3Smrg    func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'`
886899129b3Smrg} # func_xform may be replaced by extended shell implementation
887899129b3Smrg
888899129b3Smrg
88947e89262Smrg# func_fatal_configuration arg...
89047e89262Smrg# Echo program name prefixed message to standard error, followed by
89147e89262Smrg# a configuration failure hint, and exit.
89247e89262Smrgfunc_fatal_configuration ()
89347e89262Smrg{
89447e89262Smrg    func_error ${1+"$@"}
89547e89262Smrg    func_error "See the $PACKAGE documentation for more information."
89647e89262Smrg    func_fatal_error "Fatal configuration error."
89747e89262Smrg}
89847e89262Smrg
89947e89262Smrg
90047e89262Smrg# func_config
90147e89262Smrg# Display the configuration for all the tags in this script.
90247e89262Smrgfunc_config ()
90347e89262Smrg{
90447e89262Smrg    re_begincf='^# ### BEGIN LIBTOOL'
90547e89262Smrg    re_endcf='^# ### END LIBTOOL'
90647e89262Smrg
90747e89262Smrg    # Default configuration.
90847e89262Smrg    $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
90947e89262Smrg
910bd1da9d7Smrg    # Now print the configurations for the tags.
911bd1da9d7Smrg    for tagname in $taglist; do
91247e89262Smrg      $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
913bd1da9d7Smrg    done
914bd1da9d7Smrg
91547e89262Smrg    exit $?
91647e89262Smrg}
917bd1da9d7Smrg
91847e89262Smrg# func_features
91947e89262Smrg# Display the features supported by this script.
92047e89262Smrgfunc_features ()
92147e89262Smrg{
92247e89262Smrg    echo "host: $host"
923bd1da9d7Smrg    if test "$build_libtool_libs" = yes; then
92447e89262Smrg      echo "enable shared libraries"
925bd1da9d7Smrg    else
92647e89262Smrg      echo "disable shared libraries"
927bd1da9d7Smrg    fi
928bd1da9d7Smrg    if test "$build_old_libs" = yes; then
92947e89262Smrg      echo "enable static libraries"
930bd1da9d7Smrg    else
93147e89262Smrg      echo "disable static libraries"
932bd1da9d7Smrg    fi
93347e89262Smrg
934bd1da9d7Smrg    exit $?
93547e89262Smrg}
936bd1da9d7Smrg
93747e89262Smrg# func_enable_tag tagname
93847e89262Smrg# Verify that TAGNAME is valid, and either flag an error and exit, or
93947e89262Smrg# enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
94047e89262Smrg# variable here.
94147e89262Smrgfunc_enable_tag ()
94247e89262Smrg{
94347e89262Smrg  # Global variable:
94447e89262Smrg  tagname="$1"
945bd1da9d7Smrg
94647e89262Smrg  re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
94747e89262Smrg  re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
94847e89262Smrg  sed_extractcf="/$re_begincf/,/$re_endcf/p"
949bd1da9d7Smrg
95047e89262Smrg  # Validate tagname.
95147e89262Smrg  case $tagname in
95247e89262Smrg    *[!-_A-Za-z0-9,/]*)
95347e89262Smrg      func_fatal_error "invalid tag name: $tagname"
95447e89262Smrg      ;;
95547e89262Smrg  esac
956bd1da9d7Smrg
95747e89262Smrg  # Don't test for the "default" C tag, as we know it's
95847e89262Smrg  # there but not specially marked.
95947e89262Smrg  case $tagname in
96047e89262Smrg    CC) ;;
96147e89262Smrg    *)
96247e89262Smrg      if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
96347e89262Smrg	taglist="$taglist $tagname"
96447e89262Smrg
96547e89262Smrg	# Evaluate the configuration.  Be careful to quote the path
96647e89262Smrg	# and the sed script, to avoid splitting on whitespace, but
96747e89262Smrg	# also don't use non-portable quotes within backquotes within
96847e89262Smrg	# quotes we have to do it in 2 steps:
96947e89262Smrg	extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
97047e89262Smrg	eval "$extractedcf"
97147e89262Smrg      else
97247e89262Smrg	func_error "ignoring unknown tag $tagname"
97347e89262Smrg      fi
97447e89262Smrg      ;;
97547e89262Smrg  esac
97647e89262Smrg}
97747e89262Smrg
978899129b3Smrg# func_check_version_match
979899129b3Smrg# Ensure that we are using m4 macros, and libtool script from the same
980899129b3Smrg# release of libtool.
981899129b3Smrgfunc_check_version_match ()
98247e89262Smrg{
983899129b3Smrg  if test "$package_revision" != "$macro_revision"; then
984899129b3Smrg    if test "$VERSION" != "$macro_version"; then
985899129b3Smrg      if test -z "$macro_version"; then
986899129b3Smrg        cat >&2 <<_LT_EOF
987899129b3Smrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
988899129b3Smrg$progname: definition of this LT_INIT comes from an older release.
989899129b3Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
990899129b3Smrg$progname: and run autoconf again.
991899129b3Smrg_LT_EOF
992899129b3Smrg      else
993899129b3Smrg        cat >&2 <<_LT_EOF
994899129b3Smrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
995899129b3Smrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
996899129b3Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
997899129b3Smrg$progname: and run autoconf again.
998899129b3Smrg_LT_EOF
999899129b3Smrg      fi
1000899129b3Smrg    else
1001899129b3Smrg      cat >&2 <<_LT_EOF
1002899129b3Smrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
1003899129b3Smrg$progname: but the definition of this LT_INIT comes from revision $macro_revision.
1004899129b3Smrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision
1005899129b3Smrg$progname: of $PACKAGE $VERSION and run autoconf again.
1006899129b3Smrg_LT_EOF
1007899129b3Smrg    fi
1008899129b3Smrg
1009899129b3Smrg    exit $EXIT_MISMATCH
1010899129b3Smrg  fi
1011899129b3Smrg}
1012899129b3Smrg
1013899129b3Smrg
1014899129b3Smrg# Shorthand for --mode=foo, only valid as the first argument
1015899129b3Smrgcase $1 in
1016899129b3Smrgclean|clea|cle|cl)
1017899129b3Smrg  shift; set dummy --mode clean ${1+"$@"}; shift
1018899129b3Smrg  ;;
1019899129b3Smrgcompile|compil|compi|comp|com|co|c)
1020899129b3Smrg  shift; set dummy --mode compile ${1+"$@"}; shift
1021899129b3Smrg  ;;
1022899129b3Smrgexecute|execut|execu|exec|exe|ex|e)
1023899129b3Smrg  shift; set dummy --mode execute ${1+"$@"}; shift
1024899129b3Smrg  ;;
1025899129b3Smrgfinish|finis|fini|fin|fi|f)
1026899129b3Smrg  shift; set dummy --mode finish ${1+"$@"}; shift
1027899129b3Smrg  ;;
1028899129b3Smrginstall|instal|insta|inst|ins|in|i)
1029899129b3Smrg  shift; set dummy --mode install ${1+"$@"}; shift
1030899129b3Smrg  ;;
1031899129b3Smrglink|lin|li|l)
1032899129b3Smrg  shift; set dummy --mode link ${1+"$@"}; shift
1033899129b3Smrg  ;;
1034899129b3Smrguninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
1035899129b3Smrg  shift; set dummy --mode uninstall ${1+"$@"}; shift
1036899129b3Smrg  ;;
1037899129b3Smrgesac
1038899129b3Smrg
1039899129b3Smrg
1040899129b3Smrg
1041899129b3Smrg# Option defaults:
1042899129b3Smrgopt_debug=:
1043899129b3Smrgopt_dry_run=false
1044899129b3Smrgopt_config=false
1045899129b3Smrgopt_preserve_dup_deps=false
1046899129b3Smrgopt_features=false
1047899129b3Smrgopt_finish=false
1048899129b3Smrgopt_help=false
1049899129b3Smrgopt_help_all=false
1050899129b3Smrgopt_silent=:
1051899129b3Smrgopt_warning=:
1052899129b3Smrgopt_verbose=:
1053899129b3Smrgopt_silent=false
1054899129b3Smrgopt_verbose=false
1055bd1da9d7Smrg
1056bd1da9d7Smrg
1057899129b3Smrg# Parse options once, thoroughly.  This comes as soon as possible in the
1058899129b3Smrg# script to make things like `--version' happen as quickly as we can.
1059899129b3Smrg{
1060899129b3Smrg  # this just eases exit handling
1061899129b3Smrg  while test $# -gt 0; do
106247e89262Smrg    opt="$1"
106347e89262Smrg    shift
106447e89262Smrg    case $opt in
1065899129b3Smrg      --debug|-x)	opt_debug='set -x'
106647e89262Smrg			func_echo "enabling shell trace mode"
106747e89262Smrg			$opt_debug
106847e89262Smrg			;;
1069899129b3Smrg      --dry-run|--dryrun|-n)
1070899129b3Smrg			opt_dry_run=:
107147e89262Smrg			;;
1072899129b3Smrg      --config)
1073899129b3Smrg			opt_config=:
1074899129b3Smrgfunc_config
1075899129b3Smrg			;;
1076899129b3Smrg      --dlopen|-dlopen)
1077899129b3Smrg			optarg="$1"
1078899129b3Smrg			opt_dlopen="${opt_dlopen+$opt_dlopen
1079899129b3Smrg}$optarg"
108047e89262Smrg			shift
108147e89262Smrg			;;
108247e89262Smrg      --preserve-dup-deps)
1083899129b3Smrg			opt_preserve_dup_deps=:
108447e89262Smrg			;;
1085899129b3Smrg      --features)
1086899129b3Smrg			opt_features=:
1087899129b3Smrgfunc_features
108847e89262Smrg			;;
1089899129b3Smrg      --finish)
1090899129b3Smrg			opt_finish=:
1091899129b3Smrgset dummy --mode finish ${1+"$@"}; shift
1092899129b3Smrg			;;
1093899129b3Smrg      --help)
1094899129b3Smrg			opt_help=:
1095899129b3Smrg			;;
1096899129b3Smrg      --help-all)
1097899129b3Smrg			opt_help_all=:
1098899129b3Smrgopt_help=': help-all'
1099899129b3Smrg			;;
1100899129b3Smrg      --mode)
1101899129b3Smrg			test $# = 0 && func_missing_arg $opt && break
1102899129b3Smrg			optarg="$1"
1103899129b3Smrg			opt_mode="$optarg"
1104899129b3Smrgcase $optarg in
1105899129b3Smrg  # Valid mode arguments:
1106899129b3Smrg  clean|compile|execute|finish|install|link|relink|uninstall) ;;
1107899129b3Smrg
1108899129b3Smrg  # Catch anything else as an error
1109899129b3Smrg  *) func_error "invalid argument for $opt"
1110899129b3Smrg     exit_cmd=exit
1111899129b3Smrg     break
1112899129b3Smrg     ;;
1113899129b3Smrgesac
1114899129b3Smrg			shift
1115899129b3Smrg			;;
1116899129b3Smrg      --no-silent|--no-quiet)
111747e89262Smrg			opt_silent=false
1118899129b3Smrgfunc_append preserve_args " $opt"
111947e89262Smrg			;;
1120899129b3Smrg      --no-warning|--no-warn)
1121899129b3Smrg			opt_warning=false
1122899129b3Smrgfunc_append preserve_args " $opt"
1123899129b3Smrg			;;
1124899129b3Smrg      --no-verbose)
112547e89262Smrg			opt_verbose=false
1126899129b3Smrgfunc_append preserve_args " $opt"
112747e89262Smrg			;;
1128899129b3Smrg      --silent|--quiet)
1129899129b3Smrg			opt_silent=:
1130899129b3Smrgfunc_append preserve_args " $opt"
1131899129b3Smrg        opt_verbose=false
1132899129b3Smrg			;;
1133899129b3Smrg      --verbose|-v)
1134899129b3Smrg			opt_verbose=:
1135899129b3Smrgfunc_append preserve_args " $opt"
1136899129b3Smrgopt_silent=false
1137899129b3Smrg			;;
1138899129b3Smrg      --tag)
1139899129b3Smrg			test $# = 0 && func_missing_arg $opt && break
1140899129b3Smrg			optarg="$1"
1141899129b3Smrg			opt_tag="$optarg"
1142899129b3Smrgfunc_append preserve_args " $opt $optarg"
1143899129b3Smrgfunc_enable_tag "$optarg"
114447e89262Smrg			shift
114547e89262Smrg			;;
114647e89262Smrg
1147899129b3Smrg      -\?|-h)		func_usage				;;
1148899129b3Smrg      --help)		func_help				;;
1149899129b3Smrg      --version)	func_version				;;
1150899129b3Smrg
115147e89262Smrg      # Separate optargs to long options:
1152899129b3Smrg      --*=*)
1153899129b3Smrg			func_split_long_opt "$opt"
1154899129b3Smrg			set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"}
115547e89262Smrg			shift
115647e89262Smrg			;;
115747e89262Smrg
1158899129b3Smrg      # Separate non-argument short options:
1159899129b3Smrg      -\?*|-h*|-n*|-v*)
1160899129b3Smrg			func_split_short_opt "$opt"
1161899129b3Smrg			set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"}
1162899129b3Smrg			shift
116347e89262Smrg			;;
1164899129b3Smrg
1165899129b3Smrg      --)		break					;;
1166899129b3Smrg      -*)		func_fatal_help "unrecognized option \`$opt'" ;;
1167899129b3Smrg      *)		set dummy "$opt" ${1+"$@"};	shift; break  ;;
116847e89262Smrg    esac
116947e89262Smrg  done
117047e89262Smrg
1171899129b3Smrg  # Validate options:
1172899129b3Smrg
1173899129b3Smrg  # save first non-option argument
1174899129b3Smrg  if test "$#" -gt 0; then
1175899129b3Smrg    nonopt="$opt"
1176899129b3Smrg    shift
1177899129b3Smrg  fi
1178899129b3Smrg
1179899129b3Smrg  # preserve --debug
1180899129b3Smrg  test "$opt_debug" = : || func_append preserve_args " --debug"
118147e89262Smrg
118247e89262Smrg  case $host in
118347e89262Smrg    *cygwin* | *mingw* | *pw32* | *cegcc*)
118447e89262Smrg      # don't eliminate duplications in $postdeps and $predeps
118547e89262Smrg      opt_duplicate_compiler_generated_deps=:
1186bd1da9d7Smrg      ;;
1187bd1da9d7Smrg    *)
1188899129b3Smrg      opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
118947e89262Smrg      ;;
119047e89262Smrg  esac
1191bd1da9d7Smrg
1192899129b3Smrg  $opt_help || {
1193899129b3Smrg    # Sanity checks first:
1194899129b3Smrg    func_check_version_match
119547e89262Smrg
1196899129b3Smrg    if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
1197899129b3Smrg      func_fatal_configuration "not configured to build any kind of library"
119847e89262Smrg    fi
119947e89262Smrg
1200899129b3Smrg    # Darwin sucks
1201899129b3Smrg    eval std_shrext=\"$shrext_cmds\"
120247e89262Smrg
1203899129b3Smrg    # Only execute mode is allowed to have -dlopen flags.
1204899129b3Smrg    if test -n "$opt_dlopen" && test "$opt_mode" != execute; then
1205899129b3Smrg      func_error "unrecognized option \`-dlopen'"
1206899129b3Smrg      $ECHO "$help" 1>&2
1207899129b3Smrg      exit $EXIT_FAILURE
1208899129b3Smrg    fi
120947e89262Smrg
1210899129b3Smrg    # Change the help message to a mode-specific one.
1211899129b3Smrg    generic_help="$help"
1212899129b3Smrg    help="Try \`$progname --help --mode=$opt_mode' for more information."
1213899129b3Smrg  }
121447e89262Smrg
121547e89262Smrg
1216899129b3Smrg  # Bail if the options were screwed
1217899129b3Smrg  $exit_cmd $EXIT_FAILURE
1218899129b3Smrg}
121947e89262Smrg
122047e89262Smrg
1221bd1da9d7Smrg
1222bd1da9d7Smrg
1223899129b3Smrg## ----------- ##
1224899129b3Smrg##    Main.    ##
1225899129b3Smrg## ----------- ##
1226bd1da9d7Smrg
122747e89262Smrg# func_lalib_p file
122847e89262Smrg# True iff FILE is a libtool `.la' library or `.lo' object file.
122947e89262Smrg# This function is only a basic sanity check; it will hardly flush out
123047e89262Smrg# determined imposters.
123147e89262Smrgfunc_lalib_p ()
123247e89262Smrg{
123347e89262Smrg    test -f "$1" &&
123447e89262Smrg      $SED -e 4q "$1" 2>/dev/null \
123547e89262Smrg        | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
123647e89262Smrg}
1237bd1da9d7Smrg
123847e89262Smrg# func_lalib_unsafe_p file
123947e89262Smrg# True iff FILE is a libtool `.la' library or `.lo' object file.
124047e89262Smrg# This function implements the same check as func_lalib_p without
124147e89262Smrg# resorting to external programs.  To this end, it redirects stdin and
124247e89262Smrg# closes it afterwards, without saving the original file descriptor.
124347e89262Smrg# As a safety measure, use it only where a negative result would be
124447e89262Smrg# fatal anyway.  Works if `file' does not exist.
124547e89262Smrgfunc_lalib_unsafe_p ()
124647e89262Smrg{
124747e89262Smrg    lalib_p=no
124847e89262Smrg    if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
124947e89262Smrg	for lalib_p_l in 1 2 3 4
125047e89262Smrg	do
125147e89262Smrg	    read lalib_p_line
125247e89262Smrg	    case "$lalib_p_line" in
125347e89262Smrg		\#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
125447e89262Smrg	    esac
125547e89262Smrg	done
125647e89262Smrg	exec 0<&5 5<&-
125747e89262Smrg    fi
125847e89262Smrg    test "$lalib_p" = yes
125947e89262Smrg}
1260bd1da9d7Smrg
126147e89262Smrg# func_ltwrapper_script_p file
126247e89262Smrg# True iff FILE is a libtool wrapper script
126347e89262Smrg# This function is only a basic sanity check; it will hardly flush out
126447e89262Smrg# determined imposters.
126547e89262Smrgfunc_ltwrapper_script_p ()
126647e89262Smrg{
126747e89262Smrg    func_lalib_p "$1"
126847e89262Smrg}
1269bd1da9d7Smrg
127047e89262Smrg# func_ltwrapper_executable_p file
127147e89262Smrg# True iff FILE is a libtool wrapper executable
127247e89262Smrg# This function is only a basic sanity check; it will hardly flush out
127347e89262Smrg# determined imposters.
127447e89262Smrgfunc_ltwrapper_executable_p ()
127547e89262Smrg{
127647e89262Smrg    func_ltwrapper_exec_suffix=
127747e89262Smrg    case $1 in
127847e89262Smrg    *.exe) ;;
127947e89262Smrg    *) func_ltwrapper_exec_suffix=.exe ;;
128047e89262Smrg    esac
128147e89262Smrg    $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
128247e89262Smrg}
128347e89262Smrg
128447e89262Smrg# func_ltwrapper_scriptname file
128547e89262Smrg# Assumes file is an ltwrapper_executable
128647e89262Smrg# uses $file to determine the appropriate filename for a
128747e89262Smrg# temporary ltwrapper_script.
128847e89262Smrgfunc_ltwrapper_scriptname ()
128947e89262Smrg{
1290899129b3Smrg    func_dirname_and_basename "$1" "" "."
1291899129b3Smrg    func_stripname '' '.exe' "$func_basename_result"
1292899129b3Smrg    func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper"
129347e89262Smrg}
129447e89262Smrg
129547e89262Smrg# func_ltwrapper_p file
129647e89262Smrg# True iff FILE is a libtool wrapper script or wrapper executable
129747e89262Smrg# This function is only a basic sanity check; it will hardly flush out
129847e89262Smrg# determined imposters.
129947e89262Smrgfunc_ltwrapper_p ()
130047e89262Smrg{
130147e89262Smrg    func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
130247e89262Smrg}
130347e89262Smrg
130447e89262Smrg
130547e89262Smrg# func_execute_cmds commands fail_cmd
130647e89262Smrg# Execute tilde-delimited COMMANDS.
130747e89262Smrg# If FAIL_CMD is given, eval that upon failure.
130847e89262Smrg# FAIL_CMD may read-access the current command in variable CMD!
130947e89262Smrgfunc_execute_cmds ()
131047e89262Smrg{
131147e89262Smrg    $opt_debug
131247e89262Smrg    save_ifs=$IFS; IFS='~'
131347e89262Smrg    for cmd in $1; do
131447e89262Smrg      IFS=$save_ifs
131547e89262Smrg      eval cmd=\"$cmd\"
131647e89262Smrg      func_show_eval "$cmd" "${2-:}"
131747e89262Smrg    done
131847e89262Smrg    IFS=$save_ifs
131947e89262Smrg}
132047e89262Smrg
132147e89262Smrg
132247e89262Smrg# func_source file
132347e89262Smrg# Source FILE, adding directory component if necessary.
132447e89262Smrg# Note that it is not necessary on cygwin/mingw to append a dot to
132547e89262Smrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe
132647e89262Smrg# behavior happens only for exec(3), not for open(2)!  Also, sourcing
132747e89262Smrg# `FILE.' does not work on cygwin managed mounts.
132847e89262Smrgfunc_source ()
132947e89262Smrg{
133047e89262Smrg    $opt_debug
133147e89262Smrg    case $1 in
133247e89262Smrg    */* | *\\*)	. "$1" ;;
133347e89262Smrg    *)		. "./$1" ;;
133447e89262Smrg    esac
133547e89262Smrg}
133647e89262Smrg
133747e89262Smrg
1338899129b3Smrg# func_resolve_sysroot PATH
1339899129b3Smrg# Replace a leading = in PATH with a sysroot.  Store the result into
1340899129b3Smrg# func_resolve_sysroot_result
1341899129b3Smrgfunc_resolve_sysroot ()
1342899129b3Smrg{
1343899129b3Smrg  func_resolve_sysroot_result=$1
1344899129b3Smrg  case $func_resolve_sysroot_result in
1345899129b3Smrg  =*)
1346899129b3Smrg    func_stripname '=' '' "$func_resolve_sysroot_result"
1347899129b3Smrg    func_resolve_sysroot_result=$lt_sysroot$func_stripname_result
1348899129b3Smrg    ;;
1349899129b3Smrg  esac
1350899129b3Smrg}
1351899129b3Smrg
1352899129b3Smrg# func_replace_sysroot PATH
1353899129b3Smrg# If PATH begins with the sysroot, replace it with = and
1354899129b3Smrg# store the result into func_replace_sysroot_result.
1355899129b3Smrgfunc_replace_sysroot ()
1356899129b3Smrg{
1357899129b3Smrg  case "$lt_sysroot:$1" in
1358899129b3Smrg  ?*:"$lt_sysroot"*)
1359899129b3Smrg    func_stripname "$lt_sysroot" '' "$1"
1360899129b3Smrg    func_replace_sysroot_result="=$func_stripname_result"
1361899129b3Smrg    ;;
1362899129b3Smrg  *)
1363899129b3Smrg    # Including no sysroot.
1364899129b3Smrg    func_replace_sysroot_result=$1
1365899129b3Smrg    ;;
1366899129b3Smrg  esac
1367899129b3Smrg}
1368899129b3Smrg
136947e89262Smrg# func_infer_tag arg
137047e89262Smrg# Infer tagged configuration to use if any are available and
137147e89262Smrg# if one wasn't chosen via the "--tag" command line option.
137247e89262Smrg# Only attempt this if the compiler in the base compile
137347e89262Smrg# command doesn't match the default compiler.
137447e89262Smrg# arg is usually of the form 'gcc ...'
137547e89262Smrgfunc_infer_tag ()
137647e89262Smrg{
137747e89262Smrg    $opt_debug
137847e89262Smrg    if test -n "$available_tags" && test -z "$tagname"; then
137947e89262Smrg      CC_quoted=
138047e89262Smrg      for arg in $CC; do
1381899129b3Smrg	func_append_quoted CC_quoted "$arg"
138247e89262Smrg      done
138347e89262Smrg      CC_expanded=`func_echo_all $CC`
138447e89262Smrg      CC_quoted_expanded=`func_echo_all $CC_quoted`
138547e89262Smrg      case $@ in
138647e89262Smrg      # Blanks in the command may have been stripped by the calling shell,
138747e89262Smrg      # but not from the CC environment variable when configure was run.
138847e89262Smrg      " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
138947e89262Smrg      " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
139047e89262Smrg      # Blanks at the start of $base_compile will cause this to fail
139147e89262Smrg      # if we don't check for them as well.
139247e89262Smrg      *)
139347e89262Smrg	for z in $available_tags; do
139447e89262Smrg	  if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
139547e89262Smrg	    # Evaluate the configuration.
139647e89262Smrg	    eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
139747e89262Smrg	    CC_quoted=
139847e89262Smrg	    for arg in $CC; do
139947e89262Smrg	      # Double-quote args containing other shell metacharacters.
1400899129b3Smrg	      func_append_quoted CC_quoted "$arg"
140147e89262Smrg	    done
140247e89262Smrg	    CC_expanded=`func_echo_all $CC`
140347e89262Smrg	    CC_quoted_expanded=`func_echo_all $CC_quoted`
140447e89262Smrg	    case "$@ " in
140547e89262Smrg	    " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
140647e89262Smrg	    " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
140747e89262Smrg	      # The compiler in the base compile command matches
140847e89262Smrg	      # the one in the tagged configuration.
140947e89262Smrg	      # Assume this is the tagged configuration we want.
141047e89262Smrg	      tagname=$z
141147e89262Smrg	      break
141247e89262Smrg	      ;;
141347e89262Smrg	    esac
141447e89262Smrg	  fi
141547e89262Smrg	done
141647e89262Smrg	# If $tagname still isn't set, then no tagged configuration
141747e89262Smrg	# was found and let the user know that the "--tag" command
141847e89262Smrg	# line option must be used.
141947e89262Smrg	if test -z "$tagname"; then
142047e89262Smrg	  func_echo "unable to infer tagged configuration"
142147e89262Smrg	  func_fatal_error "specify a tag with \`--tag'"
142247e89262Smrg#	else
142347e89262Smrg#	  func_verbose "using $tagname tagged configuration"
142447e89262Smrg	fi
142547e89262Smrg	;;
142647e89262Smrg      esac
142747e89262Smrg    fi
142847e89262Smrg}
142947e89262Smrg
143047e89262Smrg
1431899129b3Smrg
1432899129b3Smrg# func_write_libtool_object output_name pic_name nonpic_name
1433899129b3Smrg# Create a libtool object file (analogous to a ".la" file),
1434899129b3Smrg# but don't create it if we're doing a dry run.
1435899129b3Smrgfunc_write_libtool_object ()
1436899129b3Smrg{
1437899129b3Smrg    write_libobj=${1}
1438899129b3Smrg    if test "$build_libtool_libs" = yes; then
1439899129b3Smrg      write_lobj=\'${2}\'
1440899129b3Smrg    else
1441899129b3Smrg      write_lobj=none
1442899129b3Smrg    fi
1443899129b3Smrg
1444899129b3Smrg    if test "$build_old_libs" = yes; then
1445899129b3Smrg      write_oldobj=\'${3}\'
1446899129b3Smrg    else
1447899129b3Smrg      write_oldobj=none
1448899129b3Smrg    fi
1449899129b3Smrg
1450899129b3Smrg    $opt_dry_run || {
1451899129b3Smrg      cat >${write_libobj}T <<EOF
1452899129b3Smrg# $write_libobj - a libtool object file
1453899129b3Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
1454899129b3Smrg#
1455899129b3Smrg# Please DO NOT delete this file!
1456899129b3Smrg# It is necessary for linking the library.
1457899129b3Smrg
1458899129b3Smrg# Name of the PIC object.
1459899129b3Smrgpic_object=$write_lobj
1460899129b3Smrg
1461899129b3Smrg# Name of the non-PIC object
1462899129b3Smrgnon_pic_object=$write_oldobj
1463899129b3Smrg
1464899129b3SmrgEOF
1465899129b3Smrg      $MV "${write_libobj}T" "${write_libobj}"
1466899129b3Smrg    }
1467899129b3Smrg}
1468899129b3Smrg
1469899129b3Smrg
1470899129b3Smrg##################################################
1471899129b3Smrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS #
1472899129b3Smrg##################################################
1473899129b3Smrg
1474899129b3Smrg# func_convert_core_file_wine_to_w32 ARG
1475899129b3Smrg# Helper function used by file name conversion functions when $build is *nix,
1476899129b3Smrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a
1477899129b3Smrg# correctly configured wine environment available, with the winepath program
1478899129b3Smrg# in $build's $PATH.
1479899129b3Smrg#
1480899129b3Smrg# ARG is the $build file name to be converted to w32 format.
1481899129b3Smrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will
1482899129b3Smrg# be empty on error (or when ARG is empty)
1483899129b3Smrgfunc_convert_core_file_wine_to_w32 ()
1484899129b3Smrg{
1485899129b3Smrg  $opt_debug
1486899129b3Smrg  func_convert_core_file_wine_to_w32_result="$1"
1487899129b3Smrg  if test -n "$1"; then
1488899129b3Smrg    # Unfortunately, winepath does not exit with a non-zero error code, so we
1489899129b3Smrg    # are forced to check the contents of stdout. On the other hand, if the
1490899129b3Smrg    # command is not found, the shell will set an exit code of 127 and print
1491899129b3Smrg    # *an error message* to stdout. So we must check for both error code of
1492899129b3Smrg    # zero AND non-empty stdout, which explains the odd construction:
1493899129b3Smrg    func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
1494899129b3Smrg    if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then
1495899129b3Smrg      func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
1496899129b3Smrg        $SED -e "$lt_sed_naive_backslashify"`
1497899129b3Smrg    else
1498899129b3Smrg      func_convert_core_file_wine_to_w32_result=
1499899129b3Smrg    fi
1500899129b3Smrg  fi
1501899129b3Smrg}
1502899129b3Smrg# end: func_convert_core_file_wine_to_w32
1503899129b3Smrg
1504899129b3Smrg
1505899129b3Smrg# func_convert_core_path_wine_to_w32 ARG
1506899129b3Smrg# Helper function used by path conversion functions when $build is *nix, and
1507899129b3Smrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly
1508899129b3Smrg# configured wine environment available, with the winepath program in $build's
1509899129b3Smrg# $PATH. Assumes ARG has no leading or trailing path separator characters.
1510899129b3Smrg#
1511899129b3Smrg# ARG is path to be converted from $build format to win32.
1512899129b3Smrg# Result is available in $func_convert_core_path_wine_to_w32_result.
1513899129b3Smrg# Unconvertible file (directory) names in ARG are skipped; if no directory names
1514899129b3Smrg# are convertible, then the result may be empty.
1515899129b3Smrgfunc_convert_core_path_wine_to_w32 ()
1516899129b3Smrg{
1517899129b3Smrg  $opt_debug
1518899129b3Smrg  # unfortunately, winepath doesn't convert paths, only file names
1519899129b3Smrg  func_convert_core_path_wine_to_w32_result=""
1520899129b3Smrg  if test -n "$1"; then
1521899129b3Smrg    oldIFS=$IFS
1522899129b3Smrg    IFS=:
1523899129b3Smrg    for func_convert_core_path_wine_to_w32_f in $1; do
1524899129b3Smrg      IFS=$oldIFS
1525899129b3Smrg      func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
1526899129b3Smrg      if test -n "$func_convert_core_file_wine_to_w32_result" ; then
1527899129b3Smrg        if test -z "$func_convert_core_path_wine_to_w32_result"; then
1528899129b3Smrg          func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result"
1529899129b3Smrg        else
1530899129b3Smrg          func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
1531899129b3Smrg        fi
1532899129b3Smrg      fi
1533899129b3Smrg    done
1534899129b3Smrg    IFS=$oldIFS
1535899129b3Smrg  fi
1536899129b3Smrg}
1537899129b3Smrg# end: func_convert_core_path_wine_to_w32
1538899129b3Smrg
1539899129b3Smrg
1540899129b3Smrg# func_cygpath ARGS...
1541899129b3Smrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when
1542899129b3Smrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2)
1543899129b3Smrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or
1544899129b3Smrg# (2), returns the Cygwin file name or path in func_cygpath_result (input
1545899129b3Smrg# file name or path is assumed to be in w32 format, as previously converted
1546899129b3Smrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name
1547899129b3Smrg# or path in func_cygpath_result (input file name or path is assumed to be in
1548899129b3Smrg# Cygwin format). Returns an empty string on error.
1549899129b3Smrg#
1550899129b3Smrg# ARGS are passed to cygpath, with the last one being the file name or path to
1551899129b3Smrg# be converted.
1552899129b3Smrg#
1553899129b3Smrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH
1554899129b3Smrg# environment variable; do not put it in $PATH.
1555899129b3Smrgfunc_cygpath ()
1556899129b3Smrg{
1557899129b3Smrg  $opt_debug
1558899129b3Smrg  if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
1559899129b3Smrg    func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
1560899129b3Smrg    if test "$?" -ne 0; then
1561899129b3Smrg      # on failure, ensure result is empty
1562899129b3Smrg      func_cygpath_result=
1563899129b3Smrg    fi
1564899129b3Smrg  else
1565899129b3Smrg    func_cygpath_result=
1566899129b3Smrg    func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'"
1567899129b3Smrg  fi
1568899129b3Smrg}
1569899129b3Smrg#end: func_cygpath
1570899129b3Smrg
1571899129b3Smrg
1572899129b3Smrg# func_convert_core_msys_to_w32 ARG
1573899129b3Smrg# Convert file name or path ARG from MSYS format to w32 format.  Return
1574899129b3Smrg# result in func_convert_core_msys_to_w32_result.
1575899129b3Smrgfunc_convert_core_msys_to_w32 ()
1576899129b3Smrg{
1577899129b3Smrg  $opt_debug
1578899129b3Smrg  # awkward: cmd appends spaces to result
1579899129b3Smrg  func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
1580899129b3Smrg    $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"`
1581899129b3Smrg}
1582899129b3Smrg#end: func_convert_core_msys_to_w32
1583899129b3Smrg
1584899129b3Smrg
1585899129b3Smrg# func_convert_file_check ARG1 ARG2
1586899129b3Smrg# Verify that ARG1 (a file name in $build format) was converted to $host
1587899129b3Smrg# format in ARG2. Otherwise, emit an error message, but continue (resetting
1588899129b3Smrg# func_to_host_file_result to ARG1).
1589899129b3Smrgfunc_convert_file_check ()
1590899129b3Smrg{
1591899129b3Smrg  $opt_debug
1592899129b3Smrg  if test -z "$2" && test -n "$1" ; then
1593899129b3Smrg    func_error "Could not determine host file name corresponding to"
1594899129b3Smrg    func_error "  \`$1'"
1595899129b3Smrg    func_error "Continuing, but uninstalled executables may not work."
1596899129b3Smrg    # Fallback:
1597899129b3Smrg    func_to_host_file_result="$1"
1598899129b3Smrg  fi
1599899129b3Smrg}
1600899129b3Smrg# end func_convert_file_check
1601899129b3Smrg
1602899129b3Smrg
1603899129b3Smrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH
1604899129b3Smrg# Verify that FROM_PATH (a path in $build format) was converted to $host
1605899129b3Smrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting
1606899129b3Smrg# func_to_host_file_result to a simplistic fallback value (see below).
1607899129b3Smrgfunc_convert_path_check ()
1608899129b3Smrg{
1609899129b3Smrg  $opt_debug
1610899129b3Smrg  if test -z "$4" && test -n "$3"; then
1611899129b3Smrg    func_error "Could not determine the host path corresponding to"
1612899129b3Smrg    func_error "  \`$3'"
1613899129b3Smrg    func_error "Continuing, but uninstalled executables may not work."
1614899129b3Smrg    # Fallback.  This is a deliberately simplistic "conversion" and
1615899129b3Smrg    # should not be "improved".  See libtool.info.
1616899129b3Smrg    if test "x$1" != "x$2"; then
1617899129b3Smrg      lt_replace_pathsep_chars="s|$1|$2|g"
1618899129b3Smrg      func_to_host_path_result=`echo "$3" |
1619899129b3Smrg        $SED -e "$lt_replace_pathsep_chars"`
1620899129b3Smrg    else
1621899129b3Smrg      func_to_host_path_result="$3"
1622899129b3Smrg    fi
1623899129b3Smrg  fi
1624899129b3Smrg}
1625899129b3Smrg# end func_convert_path_check
1626899129b3Smrg
1627899129b3Smrg
1628899129b3Smrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG
1629899129b3Smrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT
1630899129b3Smrg# and appending REPL if ORIG matches BACKPAT.
1631899129b3Smrgfunc_convert_path_front_back_pathsep ()
1632899129b3Smrg{
1633899129b3Smrg  $opt_debug
1634899129b3Smrg  case $4 in
1635899129b3Smrg  $1 ) func_to_host_path_result="$3$func_to_host_path_result"
1636899129b3Smrg    ;;
1637899129b3Smrg  esac
1638899129b3Smrg  case $4 in
1639899129b3Smrg  $2 ) func_append func_to_host_path_result "$3"
1640899129b3Smrg    ;;
1641899129b3Smrg  esac
1642899129b3Smrg}
1643899129b3Smrg# end func_convert_path_front_back_pathsep
1644899129b3Smrg
1645899129b3Smrg
1646899129b3Smrg##################################################
1647899129b3Smrg# $build to $host FILE NAME CONVERSION FUNCTIONS #
1648899129b3Smrg##################################################
1649899129b3Smrg# invoked via `$to_host_file_cmd ARG'
1650899129b3Smrg#
1651899129b3Smrg# In each case, ARG is the path to be converted from $build to $host format.
1652899129b3Smrg# Result will be available in $func_to_host_file_result.
1653899129b3Smrg
1654899129b3Smrg
1655899129b3Smrg# func_to_host_file ARG
1656899129b3Smrg# Converts the file name ARG from $build format to $host format. Return result
1657899129b3Smrg# in func_to_host_file_result.
1658899129b3Smrgfunc_to_host_file ()
1659899129b3Smrg{
1660899129b3Smrg  $opt_debug
1661899129b3Smrg  $to_host_file_cmd "$1"
1662899129b3Smrg}
1663899129b3Smrg# end func_to_host_file
1664899129b3Smrg
1665899129b3Smrg
1666899129b3Smrg# func_to_tool_file ARG LAZY
1667899129b3Smrg# converts the file name ARG from $build format to toolchain format. Return
1668899129b3Smrg# result in func_to_tool_file_result.  If the conversion in use is listed
1669899129b3Smrg# in (the comma separated) LAZY, no conversion takes place.
1670899129b3Smrgfunc_to_tool_file ()
1671899129b3Smrg{
1672899129b3Smrg  $opt_debug
1673899129b3Smrg  case ,$2, in
1674899129b3Smrg    *,"$to_tool_file_cmd",*)
1675899129b3Smrg      func_to_tool_file_result=$1
1676899129b3Smrg      ;;
1677899129b3Smrg    *)
1678899129b3Smrg      $to_tool_file_cmd "$1"
1679899129b3Smrg      func_to_tool_file_result=$func_to_host_file_result
1680899129b3Smrg      ;;
1681899129b3Smrg  esac
1682899129b3Smrg}
1683899129b3Smrg# end func_to_tool_file
1684899129b3Smrg
1685899129b3Smrg
1686899129b3Smrg# func_convert_file_noop ARG
1687899129b3Smrg# Copy ARG to func_to_host_file_result.
1688899129b3Smrgfunc_convert_file_noop ()
1689899129b3Smrg{
1690899129b3Smrg  func_to_host_file_result="$1"
1691899129b3Smrg}
1692899129b3Smrg# end func_convert_file_noop
1693899129b3Smrg
1694899129b3Smrg
1695899129b3Smrg# func_convert_file_msys_to_w32 ARG
1696899129b3Smrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic
1697899129b3Smrg# conversion to w32 is not available inside the cwrapper.  Returns result in
1698899129b3Smrg# func_to_host_file_result.
1699899129b3Smrgfunc_convert_file_msys_to_w32 ()
1700899129b3Smrg{
1701899129b3Smrg  $opt_debug
1702899129b3Smrg  func_to_host_file_result="$1"
1703899129b3Smrg  if test -n "$1"; then
1704899129b3Smrg    func_convert_core_msys_to_w32 "$1"
1705899129b3Smrg    func_to_host_file_result="$func_convert_core_msys_to_w32_result"
1706899129b3Smrg  fi
1707899129b3Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
1708899129b3Smrg}
1709899129b3Smrg# end func_convert_file_msys_to_w32
1710899129b3Smrg
1711899129b3Smrg
1712899129b3Smrg# func_convert_file_cygwin_to_w32 ARG
1713899129b3Smrg# Convert file name ARG from Cygwin to w32 format.  Returns result in
1714899129b3Smrg# func_to_host_file_result.
1715899129b3Smrgfunc_convert_file_cygwin_to_w32 ()
1716899129b3Smrg{
1717899129b3Smrg  $opt_debug
1718899129b3Smrg  func_to_host_file_result="$1"
1719899129b3Smrg  if test -n "$1"; then
1720899129b3Smrg    # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
1721899129b3Smrg    # LT_CYGPATH in this case.
1722899129b3Smrg    func_to_host_file_result=`cygpath -m "$1"`
1723899129b3Smrg  fi
1724899129b3Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
1725899129b3Smrg}
1726899129b3Smrg# end func_convert_file_cygwin_to_w32
1727899129b3Smrg
1728899129b3Smrg
1729899129b3Smrg# func_convert_file_nix_to_w32 ARG
1730899129b3Smrg# Convert file name ARG from *nix to w32 format.  Requires a wine environment
1731899129b3Smrg# and a working winepath. Returns result in func_to_host_file_result.
1732899129b3Smrgfunc_convert_file_nix_to_w32 ()
1733899129b3Smrg{
1734899129b3Smrg  $opt_debug
1735899129b3Smrg  func_to_host_file_result="$1"
1736899129b3Smrg  if test -n "$1"; then
1737899129b3Smrg    func_convert_core_file_wine_to_w32 "$1"
1738899129b3Smrg    func_to_host_file_result="$func_convert_core_file_wine_to_w32_result"
1739899129b3Smrg  fi
1740899129b3Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
1741899129b3Smrg}
1742899129b3Smrg# end func_convert_file_nix_to_w32
1743899129b3Smrg
1744899129b3Smrg
1745899129b3Smrg# func_convert_file_msys_to_cygwin ARG
1746899129b3Smrg# Convert file name ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
1747899129b3Smrg# Returns result in func_to_host_file_result.
1748899129b3Smrgfunc_convert_file_msys_to_cygwin ()
1749899129b3Smrg{
1750899129b3Smrg  $opt_debug
1751899129b3Smrg  func_to_host_file_result="$1"
1752899129b3Smrg  if test -n "$1"; then
1753899129b3Smrg    func_convert_core_msys_to_w32 "$1"
1754899129b3Smrg    func_cygpath -u "$func_convert_core_msys_to_w32_result"
1755899129b3Smrg    func_to_host_file_result="$func_cygpath_result"
1756899129b3Smrg  fi
1757899129b3Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
1758899129b3Smrg}
1759899129b3Smrg# end func_convert_file_msys_to_cygwin
1760899129b3Smrg
1761899129b3Smrg
1762899129b3Smrg# func_convert_file_nix_to_cygwin ARG
1763899129b3Smrg# Convert file name ARG from *nix to Cygwin format.  Requires Cygwin installed
1764899129b3Smrg# in a wine environment, working winepath, and LT_CYGPATH set.  Returns result
1765899129b3Smrg# in func_to_host_file_result.
1766899129b3Smrgfunc_convert_file_nix_to_cygwin ()
1767899129b3Smrg{
1768899129b3Smrg  $opt_debug
1769899129b3Smrg  func_to_host_file_result="$1"
1770899129b3Smrg  if test -n "$1"; then
1771899129b3Smrg    # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
1772899129b3Smrg    func_convert_core_file_wine_to_w32 "$1"
1773899129b3Smrg    func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
1774899129b3Smrg    func_to_host_file_result="$func_cygpath_result"
1775899129b3Smrg  fi
1776899129b3Smrg  func_convert_file_check "$1" "$func_to_host_file_result"
1777899129b3Smrg}
1778899129b3Smrg# end func_convert_file_nix_to_cygwin
1779899129b3Smrg
1780899129b3Smrg
1781899129b3Smrg#############################################
1782899129b3Smrg# $build to $host PATH CONVERSION FUNCTIONS #
1783899129b3Smrg#############################################
1784899129b3Smrg# invoked via `$to_host_path_cmd ARG'
1785899129b3Smrg#
1786899129b3Smrg# In each case, ARG is the path to be converted from $build to $host format.
1787899129b3Smrg# The result will be available in $func_to_host_path_result.
1788899129b3Smrg#
1789899129b3Smrg# Path separators are also converted from $build format to $host format.  If
1790899129b3Smrg# ARG begins or ends with a path separator character, it is preserved (but
1791899129b3Smrg# converted to $host format) on output.
1792899129b3Smrg#
1793899129b3Smrg# All path conversion functions are named using the following convention:
1794899129b3Smrg#   file name conversion function    : func_convert_file_X_to_Y ()
1795899129b3Smrg#   path conversion function         : func_convert_path_X_to_Y ()
1796899129b3Smrg# where, for any given $build/$host combination the 'X_to_Y' value is the
1797899129b3Smrg# same.  If conversion functions are added for new $build/$host combinations,
1798899129b3Smrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd
1799899129b3Smrg# will break.
1800899129b3Smrg
1801899129b3Smrg
1802899129b3Smrg# func_init_to_host_path_cmd
1803899129b3Smrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the
1804899129b3Smrg# appropriate value, based on the value of $to_host_file_cmd.
1805899129b3Smrgto_host_path_cmd=
1806899129b3Smrgfunc_init_to_host_path_cmd ()
1807899129b3Smrg{
1808899129b3Smrg  $opt_debug
1809899129b3Smrg  if test -z "$to_host_path_cmd"; then
1810899129b3Smrg    func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
1811899129b3Smrg    to_host_path_cmd="func_convert_path_${func_stripname_result}"
1812899129b3Smrg  fi
1813899129b3Smrg}
1814899129b3Smrg
1815899129b3Smrg
1816899129b3Smrg# func_to_host_path ARG
1817899129b3Smrg# Converts the path ARG from $build format to $host format. Return result
1818899129b3Smrg# in func_to_host_path_result.
1819899129b3Smrgfunc_to_host_path ()
1820899129b3Smrg{
1821899129b3Smrg  $opt_debug
1822899129b3Smrg  func_init_to_host_path_cmd
1823899129b3Smrg  $to_host_path_cmd "$1"
1824899129b3Smrg}
1825899129b3Smrg# end func_to_host_path
1826899129b3Smrg
1827899129b3Smrg
1828899129b3Smrg# func_convert_path_noop ARG
1829899129b3Smrg# Copy ARG to func_to_host_path_result.
1830899129b3Smrgfunc_convert_path_noop ()
1831899129b3Smrg{
1832899129b3Smrg  func_to_host_path_result="$1"
1833899129b3Smrg}
1834899129b3Smrg# end func_convert_path_noop
1835899129b3Smrg
1836899129b3Smrg
1837899129b3Smrg# func_convert_path_msys_to_w32 ARG
1838899129b3Smrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic
1839899129b3Smrg# conversion to w32 is not available inside the cwrapper.  Returns result in
1840899129b3Smrg# func_to_host_path_result.
1841899129b3Smrgfunc_convert_path_msys_to_w32 ()
1842899129b3Smrg{
1843899129b3Smrg  $opt_debug
1844899129b3Smrg  func_to_host_path_result="$1"
1845899129b3Smrg  if test -n "$1"; then
1846899129b3Smrg    # Remove leading and trailing path separator characters from ARG.  MSYS
1847899129b3Smrg    # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
1848899129b3Smrg    # and winepath ignores them completely.
1849899129b3Smrg    func_stripname : : "$1"
1850899129b3Smrg    func_to_host_path_tmp1=$func_stripname_result
1851899129b3Smrg    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
1852899129b3Smrg    func_to_host_path_result="$func_convert_core_msys_to_w32_result"
1853899129b3Smrg    func_convert_path_check : ";" \
1854899129b3Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1855899129b3Smrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
1856899129b3Smrg  fi
1857899129b3Smrg}
1858899129b3Smrg# end func_convert_path_msys_to_w32
1859899129b3Smrg
1860899129b3Smrg
1861899129b3Smrg# func_convert_path_cygwin_to_w32 ARG
1862899129b3Smrg# Convert path ARG from Cygwin to w32 format.  Returns result in
1863899129b3Smrg# func_to_host_file_result.
1864899129b3Smrgfunc_convert_path_cygwin_to_w32 ()
1865899129b3Smrg{
1866899129b3Smrg  $opt_debug
1867899129b3Smrg  func_to_host_path_result="$1"
1868899129b3Smrg  if test -n "$1"; then
1869899129b3Smrg    # See func_convert_path_msys_to_w32:
1870899129b3Smrg    func_stripname : : "$1"
1871899129b3Smrg    func_to_host_path_tmp1=$func_stripname_result
1872899129b3Smrg    func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"`
1873899129b3Smrg    func_convert_path_check : ";" \
1874899129b3Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1875899129b3Smrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
1876899129b3Smrg  fi
1877899129b3Smrg}
1878899129b3Smrg# end func_convert_path_cygwin_to_w32
1879899129b3Smrg
1880899129b3Smrg
1881899129b3Smrg# func_convert_path_nix_to_w32 ARG
1882899129b3Smrg# Convert path ARG from *nix to w32 format.  Requires a wine environment and
1883899129b3Smrg# a working winepath.  Returns result in func_to_host_file_result.
1884899129b3Smrgfunc_convert_path_nix_to_w32 ()
188547e89262Smrg{
1886899129b3Smrg  $opt_debug
1887899129b3Smrg  func_to_host_path_result="$1"
1888899129b3Smrg  if test -n "$1"; then
1889899129b3Smrg    # See func_convert_path_msys_to_w32:
1890899129b3Smrg    func_stripname : : "$1"
1891899129b3Smrg    func_to_host_path_tmp1=$func_stripname_result
1892899129b3Smrg    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
1893899129b3Smrg    func_to_host_path_result="$func_convert_core_path_wine_to_w32_result"
1894899129b3Smrg    func_convert_path_check : ";" \
1895899129b3Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1896899129b3Smrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
1897899129b3Smrg  fi
1898899129b3Smrg}
1899899129b3Smrg# end func_convert_path_nix_to_w32
190047e89262Smrg
190147e89262Smrg
1902899129b3Smrg# func_convert_path_msys_to_cygwin ARG
1903899129b3Smrg# Convert path ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
1904899129b3Smrg# Returns result in func_to_host_file_result.
1905899129b3Smrgfunc_convert_path_msys_to_cygwin ()
1906899129b3Smrg{
1907899129b3Smrg  $opt_debug
1908899129b3Smrg  func_to_host_path_result="$1"
1909899129b3Smrg  if test -n "$1"; then
1910899129b3Smrg    # See func_convert_path_msys_to_w32:
1911899129b3Smrg    func_stripname : : "$1"
1912899129b3Smrg    func_to_host_path_tmp1=$func_stripname_result
1913899129b3Smrg    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
1914899129b3Smrg    func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
1915899129b3Smrg    func_to_host_path_result="$func_cygpath_result"
1916899129b3Smrg    func_convert_path_check : : \
1917899129b3Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1918899129b3Smrg    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
1919899129b3Smrg  fi
1920899129b3Smrg}
1921899129b3Smrg# end func_convert_path_msys_to_cygwin
192247e89262Smrg
192347e89262Smrg
1924899129b3Smrg# func_convert_path_nix_to_cygwin ARG
1925899129b3Smrg# Convert path ARG from *nix to Cygwin format.  Requires Cygwin installed in a
1926899129b3Smrg# a wine environment, working winepath, and LT_CYGPATH set.  Returns result in
1927899129b3Smrg# func_to_host_file_result.
1928899129b3Smrgfunc_convert_path_nix_to_cygwin ()
1929899129b3Smrg{
1930899129b3Smrg  $opt_debug
1931899129b3Smrg  func_to_host_path_result="$1"
1932899129b3Smrg  if test -n "$1"; then
1933899129b3Smrg    # Remove leading and trailing path separator characters from
1934899129b3Smrg    # ARG. msys behavior is inconsistent here, cygpath turns them
1935899129b3Smrg    # into '.;' and ';.', and winepath ignores them completely.
1936899129b3Smrg    func_stripname : : "$1"
1937899129b3Smrg    func_to_host_path_tmp1=$func_stripname_result
1938899129b3Smrg    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
1939899129b3Smrg    func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
1940899129b3Smrg    func_to_host_path_result="$func_cygpath_result"
1941899129b3Smrg    func_convert_path_check : : \
1942899129b3Smrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1943899129b3Smrg    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
1944899129b3Smrg  fi
194547e89262Smrg}
1946899129b3Smrg# end func_convert_path_nix_to_cygwin
1947899129b3Smrg
194847e89262Smrg
194947e89262Smrg# func_mode_compile arg...
195047e89262Smrgfunc_mode_compile ()
195147e89262Smrg{
195247e89262Smrg    $opt_debug
195347e89262Smrg    # Get the compilation command and the source file.
195447e89262Smrg    base_compile=
195547e89262Smrg    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
195647e89262Smrg    suppress_opt=yes
195747e89262Smrg    suppress_output=
195847e89262Smrg    arg_mode=normal
195947e89262Smrg    libobj=
196047e89262Smrg    later=
196147e89262Smrg    pie_flag=
196247e89262Smrg
196347e89262Smrg    for arg
196447e89262Smrg    do
196547e89262Smrg      case $arg_mode in
196647e89262Smrg      arg  )
196747e89262Smrg	# do not "continue".  Instead, add this to base_compile
196847e89262Smrg	lastarg="$arg"
196947e89262Smrg	arg_mode=normal
197047e89262Smrg	;;
197147e89262Smrg
197247e89262Smrg      target )
197347e89262Smrg	libobj="$arg"
197447e89262Smrg	arg_mode=normal
197547e89262Smrg	continue
197647e89262Smrg	;;
197747e89262Smrg
197847e89262Smrg      normal )
197947e89262Smrg	# Accept any command-line options.
198047e89262Smrg	case $arg in
198147e89262Smrg	-o)
198247e89262Smrg	  test -n "$libobj" && \
198347e89262Smrg	    func_fatal_error "you cannot specify \`-o' more than once"
198447e89262Smrg	  arg_mode=target
198547e89262Smrg	  continue
198647e89262Smrg	  ;;
198747e89262Smrg
198847e89262Smrg	-pie | -fpie | -fPIE)
1989899129b3Smrg          func_append pie_flag " $arg"
199047e89262Smrg	  continue
199147e89262Smrg	  ;;
199247e89262Smrg
199347e89262Smrg	-shared | -static | -prefer-pic | -prefer-non-pic)
1994899129b3Smrg	  func_append later " $arg"
199547e89262Smrg	  continue
199647e89262Smrg	  ;;
1997bd1da9d7Smrg
1998bd1da9d7Smrg	-no-suppress)
1999bd1da9d7Smrg	  suppress_opt=no
2000bd1da9d7Smrg	  continue
2001bd1da9d7Smrg	  ;;
2002bd1da9d7Smrg
2003bd1da9d7Smrg	-Xcompiler)
2004bd1da9d7Smrg	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
2005bd1da9d7Smrg	  continue      #  The current "srcfile" will either be retained or
2006bd1da9d7Smrg	  ;;            #  replaced later.  I would guess that would be a bug.
2007bd1da9d7Smrg
2008bd1da9d7Smrg	-Wc,*)
200947e89262Smrg	  func_stripname '-Wc,' '' "$arg"
201047e89262Smrg	  args=$func_stripname_result
2011bd1da9d7Smrg	  lastarg=
2012bd1da9d7Smrg	  save_ifs="$IFS"; IFS=','
201347e89262Smrg	  for arg in $args; do
2014bd1da9d7Smrg	    IFS="$save_ifs"
2015899129b3Smrg	    func_append_quoted lastarg "$arg"
2016bd1da9d7Smrg	  done
2017bd1da9d7Smrg	  IFS="$save_ifs"
201847e89262Smrg	  func_stripname ' ' '' "$lastarg"
201947e89262Smrg	  lastarg=$func_stripname_result
2020bd1da9d7Smrg
2021bd1da9d7Smrg	  # Add the arguments to base_compile.
2022899129b3Smrg	  func_append base_compile " $lastarg"
2023bd1da9d7Smrg	  continue
2024bd1da9d7Smrg	  ;;
2025bd1da9d7Smrg
202647e89262Smrg	*)
2027bd1da9d7Smrg	  # Accept the current argument as the source file.
2028bd1da9d7Smrg	  # The previous "srcfile" becomes the current argument.
2029bd1da9d7Smrg	  #
2030bd1da9d7Smrg	  lastarg="$srcfile"
2031bd1da9d7Smrg	  srcfile="$arg"
2032bd1da9d7Smrg	  ;;
2033bd1da9d7Smrg	esac  #  case $arg
2034bd1da9d7Smrg	;;
2035bd1da9d7Smrg      esac    #  case $arg_mode
2036bd1da9d7Smrg
2037bd1da9d7Smrg      # Aesthetically quote the previous argument.
2038899129b3Smrg      func_append_quoted base_compile "$lastarg"
2039bd1da9d7Smrg    done # for arg
2040bd1da9d7Smrg
2041bd1da9d7Smrg    case $arg_mode in
2042bd1da9d7Smrg    arg)
204347e89262Smrg      func_fatal_error "you must specify an argument for -Xcompile"
2044bd1da9d7Smrg      ;;
2045bd1da9d7Smrg    target)
204647e89262Smrg      func_fatal_error "you must specify a target with \`-o'"
2047bd1da9d7Smrg      ;;
2048bd1da9d7Smrg    *)
2049bd1da9d7Smrg      # Get the name of the library object.
205047e89262Smrg      test -z "$libobj" && {
205147e89262Smrg	func_basename "$srcfile"
205247e89262Smrg	libobj="$func_basename_result"
205347e89262Smrg      }
2054bd1da9d7Smrg      ;;
2055bd1da9d7Smrg    esac
2056bd1da9d7Smrg
2057bd1da9d7Smrg    # Recognize several different file suffixes.
2058bd1da9d7Smrg    # If the user specifies -o file.o, it is replaced with file.lo
2059bd1da9d7Smrg    case $libobj in
206047e89262Smrg    *.[cCFSifmso] | \
206147e89262Smrg    *.ada | *.adb | *.ads | *.asm | \
206247e89262Smrg    *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
2063899129b3Smrg    *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup)
206447e89262Smrg      func_xform "$libobj"
206547e89262Smrg      libobj=$func_xform_result
206647e89262Smrg      ;;
2067bd1da9d7Smrg    esac
2068bd1da9d7Smrg
2069bd1da9d7Smrg    case $libobj in
207047e89262Smrg    *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
2071bd1da9d7Smrg    *)
207247e89262Smrg      func_fatal_error "cannot determine name of library object from \`$libobj'"
2073bd1da9d7Smrg      ;;
2074bd1da9d7Smrg    esac
2075bd1da9d7Smrg
2076bd1da9d7Smrg    func_infer_tag $base_compile
2077bd1da9d7Smrg
2078bd1da9d7Smrg    for arg in $later; do
2079bd1da9d7Smrg      case $arg in
208047e89262Smrg      -shared)
208147e89262Smrg	test "$build_libtool_libs" != yes && \
208247e89262Smrg	  func_fatal_configuration "can not build a shared library"
208347e89262Smrg	build_old_libs=no
208447e89262Smrg	continue
208547e89262Smrg	;;
208647e89262Smrg
2087bd1da9d7Smrg      -static)
208847e89262Smrg	build_libtool_libs=no
2089bd1da9d7Smrg	build_old_libs=yes
2090bd1da9d7Smrg	continue
2091bd1da9d7Smrg	;;
2092bd1da9d7Smrg
2093bd1da9d7Smrg      -prefer-pic)
2094bd1da9d7Smrg	pic_mode=yes
2095bd1da9d7Smrg	continue
2096bd1da9d7Smrg	;;
2097bd1da9d7Smrg
2098bd1da9d7Smrg      -prefer-non-pic)
2099bd1da9d7Smrg	pic_mode=no
2100bd1da9d7Smrg	continue
2101bd1da9d7Smrg	;;
2102bd1da9d7Smrg      esac
2103bd1da9d7Smrg    done
2104bd1da9d7Smrg
210547e89262Smrg    func_quote_for_eval "$libobj"
210647e89262Smrg    test "X$libobj" != "X$func_quote_for_eval_result" \
210747e89262Smrg      && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'	 &()|`$[]' \
210847e89262Smrg      && func_warning "libobj name \`$libobj' may not contain shell special characters."
210947e89262Smrg    func_dirname_and_basename "$obj" "/" ""
211047e89262Smrg    objname="$func_basename_result"
211147e89262Smrg    xdir="$func_dirname_result"
2112bd1da9d7Smrg    lobj=${xdir}$objdir/$objname
2113bd1da9d7Smrg
211447e89262Smrg    test -z "$base_compile" && \
211547e89262Smrg      func_fatal_help "you must specify a compilation command"
2116bd1da9d7Smrg
2117bd1da9d7Smrg    # Delete any leftover library objects.
2118bd1da9d7Smrg    if test "$build_old_libs" = yes; then
2119bd1da9d7Smrg      removelist="$obj $lobj $libobj ${libobj}T"
2120bd1da9d7Smrg    else
2121bd1da9d7Smrg      removelist="$lobj $libobj ${libobj}T"
2122bd1da9d7Smrg    fi
2123bd1da9d7Smrg
2124bd1da9d7Smrg    # On Cygwin there's no "real" PIC flag so we must build both object types
2125bd1da9d7Smrg    case $host_os in
212647e89262Smrg    cygwin* | mingw* | pw32* | os2* | cegcc*)
2127bd1da9d7Smrg      pic_mode=default
2128bd1da9d7Smrg      ;;
2129bd1da9d7Smrg    esac
2130bd1da9d7Smrg    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
2131bd1da9d7Smrg      # non-PIC code in shared libraries is not supported
2132bd1da9d7Smrg      pic_mode=default
2133bd1da9d7Smrg    fi
2134bd1da9d7Smrg
2135bd1da9d7Smrg    # Calculate the filename of the output object if compiler does
2136bd1da9d7Smrg    # not support -o with -c
2137bd1da9d7Smrg    if test "$compiler_c_o" = no; then
213847e89262Smrg      output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext}
2139bd1da9d7Smrg      lockfile="$output_obj.lock"
2140bd1da9d7Smrg    else
2141bd1da9d7Smrg      output_obj=
2142bd1da9d7Smrg      need_locks=no
2143bd1da9d7Smrg      lockfile=
2144bd1da9d7Smrg    fi
2145bd1da9d7Smrg
2146bd1da9d7Smrg    # Lock this critical section if it is needed
2147bd1da9d7Smrg    # We use this script file to make the link, it avoids creating a new file
2148bd1da9d7Smrg    if test "$need_locks" = yes; then
214947e89262Smrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
215047e89262Smrg	func_echo "Waiting for $lockfile to be removed"
2151bd1da9d7Smrg	sleep 2
2152bd1da9d7Smrg      done
2153bd1da9d7Smrg    elif test "$need_locks" = warn; then
2154bd1da9d7Smrg      if test -f "$lockfile"; then
215547e89262Smrg	$ECHO "\
2156bd1da9d7Smrg*** ERROR, $lockfile exists and contains:
2157bd1da9d7Smrg`cat $lockfile 2>/dev/null`
2158bd1da9d7Smrg
2159bd1da9d7SmrgThis indicates that another process is trying to use the same
2160bd1da9d7Smrgtemporary object file, and libtool could not work around it because
2161bd1da9d7Smrgyour compiler does not support \`-c' and \`-o' together.  If you
2162bd1da9d7Smrgrepeat this compilation, it may succeed, by chance, but you had better
2163bd1da9d7Smrgavoid parallel builds (make -j) in this platform, or get a better
2164bd1da9d7Smrgcompiler."
2165bd1da9d7Smrg
216647e89262Smrg	$opt_dry_run || $RM $removelist
2167bd1da9d7Smrg	exit $EXIT_FAILURE
2168bd1da9d7Smrg      fi
2169899129b3Smrg      func_append removelist " $output_obj"
217047e89262Smrg      $ECHO "$srcfile" > "$lockfile"
2171bd1da9d7Smrg    fi
2172bd1da9d7Smrg
217347e89262Smrg    $opt_dry_run || $RM $removelist
2174899129b3Smrg    func_append removelist " $lockfile"
217547e89262Smrg    trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
217647e89262Smrg
2177899129b3Smrg    func_to_tool_file "$srcfile" func_convert_file_msys_to_w32
2178899129b3Smrg    srcfile=$func_to_tool_file_result
217947e89262Smrg    func_quote_for_eval "$srcfile"
218047e89262Smrg    qsrcfile=$func_quote_for_eval_result
2181bd1da9d7Smrg
2182bd1da9d7Smrg    # Only build a PIC object if we are building libtool libraries.
2183bd1da9d7Smrg    if test "$build_libtool_libs" = yes; then
2184bd1da9d7Smrg      # Without this assignment, base_compile gets emptied.
2185bd1da9d7Smrg      fbsd_hideous_sh_bug=$base_compile
2186bd1da9d7Smrg
2187bd1da9d7Smrg      if test "$pic_mode" != no; then
2188bd1da9d7Smrg	command="$base_compile $qsrcfile $pic_flag"
2189bd1da9d7Smrg      else
2190bd1da9d7Smrg	# Don't build PIC code
2191bd1da9d7Smrg	command="$base_compile $qsrcfile"
2192bd1da9d7Smrg      fi
2193bd1da9d7Smrg
219447e89262Smrg      func_mkdir_p "$xdir$objdir"
2195bd1da9d7Smrg
2196bd1da9d7Smrg      if test -z "$output_obj"; then
2197bd1da9d7Smrg	# Place PIC objects in $objdir
2198899129b3Smrg	func_append command " -o $lobj"
2199bd1da9d7Smrg      fi
2200bd1da9d7Smrg
220147e89262Smrg      func_show_eval_locale "$command"	\
220247e89262Smrg          'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
2203bd1da9d7Smrg
2204bd1da9d7Smrg      if test "$need_locks" = warn &&
2205bd1da9d7Smrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
220647e89262Smrg	$ECHO "\
2207bd1da9d7Smrg*** ERROR, $lockfile contains:
2208bd1da9d7Smrg`cat $lockfile 2>/dev/null`
2209bd1da9d7Smrg
2210bd1da9d7Smrgbut it should contain:
2211bd1da9d7Smrg$srcfile
2212bd1da9d7Smrg
2213bd1da9d7SmrgThis indicates that another process is trying to use the same
2214bd1da9d7Smrgtemporary object file, and libtool could not work around it because
2215bd1da9d7Smrgyour compiler does not support \`-c' and \`-o' together.  If you
2216bd1da9d7Smrgrepeat this compilation, it may succeed, by chance, but you had better
2217bd1da9d7Smrgavoid parallel builds (make -j) in this platform, or get a better
2218bd1da9d7Smrgcompiler."
2219bd1da9d7Smrg
222047e89262Smrg	$opt_dry_run || $RM $removelist
2221bd1da9d7Smrg	exit $EXIT_FAILURE
2222bd1da9d7Smrg      fi
2223bd1da9d7Smrg
2224bd1da9d7Smrg      # Just move the object if needed, then go on to compile the next one
2225bd1da9d7Smrg      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
222647e89262Smrg	func_show_eval '$MV "$output_obj" "$lobj"' \
222747e89262Smrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
2228bd1da9d7Smrg      fi
2229bd1da9d7Smrg
2230bd1da9d7Smrg      # Allow error messages only from the first compilation.
2231bd1da9d7Smrg      if test "$suppress_opt" = yes; then
223247e89262Smrg	suppress_output=' >/dev/null 2>&1'
2233bd1da9d7Smrg      fi
2234bd1da9d7Smrg    fi
2235bd1da9d7Smrg
2236bd1da9d7Smrg    # Only build a position-dependent object if we build old libraries.
2237bd1da9d7Smrg    if test "$build_old_libs" = yes; then
2238bd1da9d7Smrg      if test "$pic_mode" != yes; then
2239bd1da9d7Smrg	# Don't build PIC code
224047e89262Smrg	command="$base_compile $qsrcfile$pie_flag"
2241bd1da9d7Smrg      else
2242bd1da9d7Smrg	command="$base_compile $qsrcfile $pic_flag"
2243bd1da9d7Smrg      fi
2244bd1da9d7Smrg      if test "$compiler_c_o" = yes; then
2245899129b3Smrg	func_append command " -o $obj"
2246bd1da9d7Smrg      fi
2247bd1da9d7Smrg
2248bd1da9d7Smrg      # Suppress compiler output if we already did a PIC compilation.
2249899129b3Smrg      func_append command "$suppress_output"
225047e89262Smrg      func_show_eval_locale "$command" \
225147e89262Smrg        '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
2252bd1da9d7Smrg
2253bd1da9d7Smrg      if test "$need_locks" = warn &&
2254bd1da9d7Smrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
225547e89262Smrg	$ECHO "\
2256bd1da9d7Smrg*** ERROR, $lockfile contains:
2257bd1da9d7Smrg`cat $lockfile 2>/dev/null`
2258bd1da9d7Smrg
2259bd1da9d7Smrgbut it should contain:
2260bd1da9d7Smrg$srcfile
2261bd1da9d7Smrg
2262bd1da9d7SmrgThis indicates that another process is trying to use the same
2263bd1da9d7Smrgtemporary object file, and libtool could not work around it because
2264bd1da9d7Smrgyour compiler does not support \`-c' and \`-o' together.  If you
2265bd1da9d7Smrgrepeat this compilation, it may succeed, by chance, but you had better
2266bd1da9d7Smrgavoid parallel builds (make -j) in this platform, or get a better
2267bd1da9d7Smrgcompiler."
2268bd1da9d7Smrg
226947e89262Smrg	$opt_dry_run || $RM $removelist
2270bd1da9d7Smrg	exit $EXIT_FAILURE
2271bd1da9d7Smrg      fi
2272bd1da9d7Smrg
2273bd1da9d7Smrg      # Just move the object if needed
2274bd1da9d7Smrg      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
227547e89262Smrg	func_show_eval '$MV "$output_obj" "$obj"' \
227647e89262Smrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
2277bd1da9d7Smrg      fi
2278bd1da9d7Smrg    fi
2279bd1da9d7Smrg
228047e89262Smrg    $opt_dry_run || {
228147e89262Smrg      func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
2282bd1da9d7Smrg
228347e89262Smrg      # Unlock the critical section if it was locked
228447e89262Smrg      if test "$need_locks" != no; then
228547e89262Smrg	removelist=$lockfile
228647e89262Smrg        $RM "$lockfile"
228747e89262Smrg      fi
228847e89262Smrg    }
2289bd1da9d7Smrg
2290bd1da9d7Smrg    exit $EXIT_SUCCESS
229147e89262Smrg}
2292bd1da9d7Smrg
229347e89262Smrg$opt_help || {
2294899129b3Smrg  test "$opt_mode" = compile && func_mode_compile ${1+"$@"}
229547e89262Smrg}
2296bd1da9d7Smrg
229747e89262Smrgfunc_mode_help ()
229847e89262Smrg{
229947e89262Smrg    # We need to display help for each of the modes.
2300899129b3Smrg    case $opt_mode in
230147e89262Smrg      "")
230247e89262Smrg        # Generic help is extracted from the usage comments
230347e89262Smrg        # at the start of this file.
230447e89262Smrg        func_help
230547e89262Smrg        ;;
2306bd1da9d7Smrg
230747e89262Smrg      clean)
230847e89262Smrg        $ECHO \
230947e89262Smrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
2310bd1da9d7Smrg
231147e89262SmrgRemove files from the build directory.
2312bd1da9d7Smrg
231347e89262SmrgRM is the name of the program to use to delete files associated with each FILE
231447e89262Smrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
231547e89262Smrgto RM.
2316bd1da9d7Smrg
231747e89262SmrgIf FILE is a libtool library, object or program, all the files associated
231847e89262Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM."
231947e89262Smrg        ;;
2320bd1da9d7Smrg
232147e89262Smrg      compile)
232247e89262Smrg      $ECHO \
232347e89262Smrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
2324bd1da9d7Smrg
232547e89262SmrgCompile a source file into a libtool library object.
2326bd1da9d7Smrg
232747e89262SmrgThis mode accepts the following additional options:
2328bd1da9d7Smrg
232947e89262Smrg  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
233047e89262Smrg  -no-suppress      do not suppress compiler output for multiple passes
233147e89262Smrg  -prefer-pic       try to build PIC objects only
233247e89262Smrg  -prefer-non-pic   try to build non-PIC objects only
233347e89262Smrg  -shared           do not build a \`.o' file suitable for static linking
233447e89262Smrg  -static           only build a \`.o' file suitable for static linking
233547e89262Smrg  -Wc,FLAG          pass FLAG directly to the compiler
2336bd1da9d7Smrg
233747e89262SmrgCOMPILE-COMMAND is a command to be used in creating a \`standard' object file
233847e89262Smrgfrom the given SOURCEFILE.
2339bd1da9d7Smrg
234047e89262SmrgThe output file name is determined by removing the directory component from
234147e89262SmrgSOURCEFILE, then substituting the C source code suffix \`.c' with the
234247e89262Smrglibrary object suffix, \`.lo'."
234347e89262Smrg        ;;
2344bd1da9d7Smrg
234547e89262Smrg      execute)
234647e89262Smrg        $ECHO \
234747e89262Smrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
2348bd1da9d7Smrg
234947e89262SmrgAutomatically set library path, then run a program.
2350bd1da9d7Smrg
235147e89262SmrgThis mode accepts the following additional options:
2352bd1da9d7Smrg
235347e89262Smrg  -dlopen FILE      add the directory containing FILE to the library path
2354bd1da9d7Smrg
235547e89262SmrgThis mode sets the library path environment variable according to \`-dlopen'
235647e89262Smrgflags.
2357bd1da9d7Smrg
235847e89262SmrgIf any of the ARGS are libtool executable wrappers, then they are translated
235947e89262Smrginto their corresponding uninstalled binary, and any of their required library
236047e89262Smrgdirectories are added to the library path.
2361bd1da9d7Smrg
236247e89262SmrgThen, COMMAND is executed, with ARGS as arguments."
236347e89262Smrg        ;;
2364bd1da9d7Smrg
236547e89262Smrg      finish)
236647e89262Smrg        $ECHO \
236747e89262Smrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
2368bd1da9d7Smrg
236947e89262SmrgComplete the installation of libtool libraries.
2370bd1da9d7Smrg
237147e89262SmrgEach LIBDIR is a directory that contains libtool libraries.
2372bd1da9d7Smrg
237347e89262SmrgThe commands that this mode executes may require superuser privileges.  Use
237447e89262Smrgthe \`--dry-run' option if you just want to see what would be executed."
237547e89262Smrg        ;;
2376bd1da9d7Smrg
237747e89262Smrg      install)
237847e89262Smrg        $ECHO \
237947e89262Smrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
2380bd1da9d7Smrg
238147e89262SmrgInstall executables or libraries.
2382bd1da9d7Smrg
238347e89262SmrgINSTALL-COMMAND is the installation command.  The first component should be
238447e89262Smrgeither the \`install' or \`cp' program.
2385bd1da9d7Smrg
238647e89262SmrgThe following components of INSTALL-COMMAND are treated specially:
2387bd1da9d7Smrg
238847e89262Smrg  -inst-prefix-dir PREFIX-DIR  Use PREFIX-DIR as a staging area for installation
2389bd1da9d7Smrg
239047e89262SmrgThe rest of the components are interpreted as arguments to that command (only
239147e89262SmrgBSD-compatible install options are recognized)."
239247e89262Smrg        ;;
2393bd1da9d7Smrg
239447e89262Smrg      link)
239547e89262Smrg        $ECHO \
239647e89262Smrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
2397bd1da9d7Smrg
239847e89262SmrgLink object files or libraries together to form another library, or to
239947e89262Smrgcreate an executable program.
2400bd1da9d7Smrg
240147e89262SmrgLINK-COMMAND is a command using the C compiler that you would use to create
240247e89262Smrga program from several object files.
2403bd1da9d7Smrg
240447e89262SmrgThe following components of LINK-COMMAND are treated specially:
2405bd1da9d7Smrg
240647e89262Smrg  -all-static       do not do any dynamic linking at all
240747e89262Smrg  -avoid-version    do not add a version suffix if possible
240847e89262Smrg  -bindir BINDIR    specify path to binaries directory (for systems where
240947e89262Smrg                    libraries must be found in the PATH setting at runtime)
241047e89262Smrg  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
241147e89262Smrg  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
241247e89262Smrg  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
241347e89262Smrg  -export-symbols SYMFILE
241447e89262Smrg                    try to export only the symbols listed in SYMFILE
241547e89262Smrg  -export-symbols-regex REGEX
241647e89262Smrg                    try to export only the symbols matching REGEX
241747e89262Smrg  -LLIBDIR          search LIBDIR for required installed libraries
241847e89262Smrg  -lNAME            OUTPUT-FILE requires the installed library libNAME
241947e89262Smrg  -module           build a library that can dlopened
242047e89262Smrg  -no-fast-install  disable the fast-install mode
242147e89262Smrg  -no-install       link a not-installable executable
242247e89262Smrg  -no-undefined     declare that a library does not refer to external symbols
242347e89262Smrg  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
242447e89262Smrg  -objectlist FILE  Use a list of object files found in FILE to specify objects
242547e89262Smrg  -precious-files-regex REGEX
242647e89262Smrg                    don't remove output files matching REGEX
242747e89262Smrg  -release RELEASE  specify package release information
242847e89262Smrg  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
242947e89262Smrg  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
243047e89262Smrg  -shared           only do dynamic linking of libtool libraries
243147e89262Smrg  -shrext SUFFIX    override the standard shared library file extension
243247e89262Smrg  -static           do not do any dynamic linking of uninstalled libtool libraries
243347e89262Smrg  -static-libtool-libs
243447e89262Smrg                    do not do any dynamic linking of libtool libraries
243547e89262Smrg  -version-info CURRENT[:REVISION[:AGE]]
243647e89262Smrg                    specify library version info [each variable defaults to 0]
243747e89262Smrg  -weak LIBNAME     declare that the target provides the LIBNAME interface
243847e89262Smrg  -Wc,FLAG
243947e89262Smrg  -Xcompiler FLAG   pass linker-specific FLAG directly to the compiler
244047e89262Smrg  -Wl,FLAG
244147e89262Smrg  -Xlinker FLAG     pass linker-specific FLAG directly to the linker
244247e89262Smrg  -XCClinker FLAG   pass link-specific FLAG to the compiler driver (CC)
2443bd1da9d7Smrg
244447e89262SmrgAll other options (arguments beginning with \`-') are ignored.
2445bd1da9d7Smrg
244647e89262SmrgEvery other argument is treated as a filename.  Files ending in \`.la' are
244747e89262Smrgtreated as uninstalled libtool libraries, other files are standard or library
244847e89262Smrgobject files.
2449bd1da9d7Smrg
245047e89262SmrgIf the OUTPUT-FILE ends in \`.la', then a libtool library is created,
245147e89262Smrgonly library objects (\`.lo' files) may be specified, and \`-rpath' is
245247e89262Smrgrequired, except when creating a convenience library.
2453bd1da9d7Smrg
245447e89262SmrgIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
245547e89262Smrgusing \`ar' and \`ranlib', or on Windows using \`lib'.
24565bcb6992Smrg
245747e89262SmrgIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
245847e89262Smrgis created, otherwise an executable program is created."
245947e89262Smrg        ;;
2460bd1da9d7Smrg
246147e89262Smrg      uninstall)
246247e89262Smrg        $ECHO \
246347e89262Smrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
2464bd1da9d7Smrg
246547e89262SmrgRemove libraries from an installation directory.
2466bd1da9d7Smrg
246747e89262SmrgRM is the name of the program to use to delete files associated with each FILE
246847e89262Smrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
246947e89262Smrgto RM.
2470bd1da9d7Smrg
247147e89262SmrgIf FILE is a libtool library, all the files associated with it are deleted.
247247e89262SmrgOtherwise, only FILE itself is deleted using RM."
247347e89262Smrg        ;;
2474bd1da9d7Smrg
247547e89262Smrg      *)
2476899129b3Smrg        func_fatal_help "invalid operation mode \`$opt_mode'"
247747e89262Smrg        ;;
247847e89262Smrg    esac
2479bd1da9d7Smrg
248047e89262Smrg    echo
248147e89262Smrg    $ECHO "Try \`$progname --help' for more information about other modes."
248247e89262Smrg}
2483bd1da9d7Smrg
248447e89262Smrg# Now that we've collected a possible --mode arg, show help if necessary
248547e89262Smrgif $opt_help; then
248647e89262Smrg  if test "$opt_help" = :; then
248747e89262Smrg    func_mode_help
248847e89262Smrg  else
248947e89262Smrg    {
249047e89262Smrg      func_help noexit
2491899129b3Smrg      for opt_mode in compile link execute install finish uninstall clean; do
249247e89262Smrg	func_mode_help
249347e89262Smrg      done
249447e89262Smrg    } | sed -n '1p; 2,$s/^Usage:/  or: /p'
249547e89262Smrg    {
249647e89262Smrg      func_help noexit
2497899129b3Smrg      for opt_mode in compile link execute install finish uninstall clean; do
249847e89262Smrg	echo
249947e89262Smrg	func_mode_help
250047e89262Smrg      done
250147e89262Smrg    } |
250247e89262Smrg    sed '1d
250347e89262Smrg      /^When reporting/,/^Report/{
250447e89262Smrg	H
250547e89262Smrg	d
250647e89262Smrg      }
250747e89262Smrg      $x
250847e89262Smrg      /information about other modes/d
250947e89262Smrg      /more detailed .*MODE/d
251047e89262Smrg      s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
251147e89262Smrg  fi
251247e89262Smrg  exit $?
251347e89262Smrgfi
2514bd1da9d7Smrg
2515bd1da9d7Smrg
251647e89262Smrg# func_mode_execute arg...
251747e89262Smrgfunc_mode_execute ()
251847e89262Smrg{
251947e89262Smrg    $opt_debug
252047e89262Smrg    # The first argument is the command name.
252147e89262Smrg    cmd="$nonopt"
252247e89262Smrg    test -z "$cmd" && \
252347e89262Smrg      func_fatal_help "you must specify a COMMAND"
2524bd1da9d7Smrg
252547e89262Smrg    # Handle -dlopen flags immediately.
2526899129b3Smrg    for file in $opt_dlopen; do
252747e89262Smrg      test -f "$file" \
252847e89262Smrg	|| func_fatal_help "\`$file' is not a file"
2529bd1da9d7Smrg
253047e89262Smrg      dir=
253147e89262Smrg      case $file in
253247e89262Smrg      *.la)
2533899129b3Smrg	func_resolve_sysroot "$file"
2534899129b3Smrg	file=$func_resolve_sysroot_result
2535899129b3Smrg
253647e89262Smrg	# Check to see that this really is a libtool archive.
253747e89262Smrg	func_lalib_unsafe_p "$file" \
253847e89262Smrg	  || func_fatal_help "\`$lib' is not a valid libtool archive"
2539bd1da9d7Smrg
254047e89262Smrg	# Read the libtool library.
254147e89262Smrg	dlname=
254247e89262Smrg	library_names=
254347e89262Smrg	func_source "$file"
2544bd1da9d7Smrg
254547e89262Smrg	# Skip this library if it cannot be dlopened.
254647e89262Smrg	if test -z "$dlname"; then
254747e89262Smrg	  # Warn if it was a shared library.
254847e89262Smrg	  test -n "$library_names" && \
254947e89262Smrg	    func_warning "\`$file' was not linked with \`-export-dynamic'"
255047e89262Smrg	  continue
255147e89262Smrg	fi
2552bd1da9d7Smrg
255347e89262Smrg	func_dirname "$file" "" "."
255447e89262Smrg	dir="$func_dirname_result"
2555bd1da9d7Smrg
255647e89262Smrg	if test -f "$dir/$objdir/$dlname"; then
2557899129b3Smrg	  func_append dir "/$objdir"
255847e89262Smrg	else
255947e89262Smrg	  if test ! -f "$dir/$dlname"; then
256047e89262Smrg	    func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'"
256147e89262Smrg	  fi
256247e89262Smrg	fi
2563bd1da9d7Smrg	;;
2564bd1da9d7Smrg
256547e89262Smrg      *.lo)
256647e89262Smrg	# Just add the directory containing the .lo file.
256747e89262Smrg	func_dirname "$file" "" "."
256847e89262Smrg	dir="$func_dirname_result"
2569bd1da9d7Smrg	;;
257047e89262Smrg
257147e89262Smrg      *)
257247e89262Smrg	func_warning "\`-dlopen' is ignored for non-libtool libraries and objects"
2573bd1da9d7Smrg	continue
2574bd1da9d7Smrg	;;
257547e89262Smrg      esac
2576bd1da9d7Smrg
257747e89262Smrg      # Get the absolute pathname.
257847e89262Smrg      absdir=`cd "$dir" && pwd`
257947e89262Smrg      test -n "$absdir" && dir="$absdir"
2580bd1da9d7Smrg
258147e89262Smrg      # Now add the directory to shlibpath_var.
258247e89262Smrg      if eval "test -z \"\$$shlibpath_var\""; then
258347e89262Smrg	eval "$shlibpath_var=\"\$dir\""
258447e89262Smrg      else
258547e89262Smrg	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
258647e89262Smrg      fi
258747e89262Smrg    done
2588bd1da9d7Smrg
258947e89262Smrg    # This variable tells wrapper scripts just to set shlibpath_var
259047e89262Smrg    # rather than running their programs.
259147e89262Smrg    libtool_execute_magic="$magic"
2592bd1da9d7Smrg
259347e89262Smrg    # Check if any of the arguments is a wrapper script.
259447e89262Smrg    args=
259547e89262Smrg    for file
259647e89262Smrg    do
259747e89262Smrg      case $file in
259847e89262Smrg      -* | *.la | *.lo ) ;;
259947e89262Smrg      *)
260047e89262Smrg	# Do a test to see if this is really a libtool program.
260147e89262Smrg	if func_ltwrapper_script_p "$file"; then
260247e89262Smrg	  func_source "$file"
260347e89262Smrg	  # Transform arg to wrapped name.
260447e89262Smrg	  file="$progdir/$program"
260547e89262Smrg	elif func_ltwrapper_executable_p "$file"; then
260647e89262Smrg	  func_ltwrapper_scriptname "$file"
260747e89262Smrg	  func_source "$func_ltwrapper_scriptname_result"
260847e89262Smrg	  # Transform arg to wrapped name.
260947e89262Smrg	  file="$progdir/$program"
261047e89262Smrg	fi
2611bd1da9d7Smrg	;;
261247e89262Smrg      esac
261347e89262Smrg      # Quote arguments (to preserve shell metacharacters).
2614899129b3Smrg      func_append_quoted args "$file"
261547e89262Smrg    done
2616bd1da9d7Smrg
261747e89262Smrg    if test "X$opt_dry_run" = Xfalse; then
261847e89262Smrg      if test -n "$shlibpath_var"; then
261947e89262Smrg	# Export the shlibpath_var.
262047e89262Smrg	eval "export $shlibpath_var"
262147e89262Smrg      fi
2622bd1da9d7Smrg
262347e89262Smrg      # Restore saved environment variables
262447e89262Smrg      for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
262547e89262Smrg      do
262647e89262Smrg	eval "if test \"\${save_$lt_var+set}\" = set; then
262747e89262Smrg                $lt_var=\$save_$lt_var; export $lt_var
262847e89262Smrg	      else
262947e89262Smrg		$lt_unset $lt_var
263047e89262Smrg	      fi"
263147e89262Smrg      done
2632bd1da9d7Smrg
263347e89262Smrg      # Now prepare to actually exec the command.
263447e89262Smrg      exec_cmd="\$cmd$args"
263547e89262Smrg    else
263647e89262Smrg      # Display what would be done.
263747e89262Smrg      if test -n "$shlibpath_var"; then
263847e89262Smrg	eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
263947e89262Smrg	echo "export $shlibpath_var"
264047e89262Smrg      fi
264147e89262Smrg      $ECHO "$cmd$args"
264247e89262Smrg      exit $EXIT_SUCCESS
264347e89262Smrg    fi
264447e89262Smrg}
2645bd1da9d7Smrg
2646899129b3Smrgtest "$opt_mode" = execute && func_mode_execute ${1+"$@"}
2647bd1da9d7Smrg
2648bd1da9d7Smrg
264947e89262Smrg# func_mode_finish arg...
265047e89262Smrgfunc_mode_finish ()
265147e89262Smrg{
265247e89262Smrg    $opt_debug
2653899129b3Smrg    libs=
2654899129b3Smrg    libdirs=
265547e89262Smrg    admincmds=
2656bd1da9d7Smrg
2657899129b3Smrg    for opt in "$nonopt" ${1+"$@"}
2658899129b3Smrg    do
2659899129b3Smrg      if test -d "$opt"; then
2660899129b3Smrg	func_append libdirs " $opt"
2661899129b3Smrg
2662899129b3Smrg      elif test -f "$opt"; then
2663899129b3Smrg	if func_lalib_unsafe_p "$opt"; then
2664899129b3Smrg	  func_append libs " $opt"
2665899129b3Smrg	else
2666899129b3Smrg	  func_warning "\`$opt' is not a valid libtool archive"
2667899129b3Smrg	fi
2668899129b3Smrg
2669899129b3Smrg      else
2670899129b3Smrg	func_fatal_error "invalid argument \`$opt'"
2671899129b3Smrg      fi
2672899129b3Smrg    done
2673899129b3Smrg
2674899129b3Smrg    if test -n "$libs"; then
2675899129b3Smrg      if test -n "$lt_sysroot"; then
2676899129b3Smrg        sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"`
2677899129b3Smrg        sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;"
2678899129b3Smrg      else
2679899129b3Smrg        sysroot_cmd=
2680899129b3Smrg      fi
2681899129b3Smrg
2682899129b3Smrg      # Remove sysroot references
2683899129b3Smrg      if $opt_dry_run; then
2684899129b3Smrg        for lib in $libs; do
2685899129b3Smrg          echo "removing references to $lt_sysroot and \`=' prefixes from $lib"
2686899129b3Smrg        done
2687899129b3Smrg      else
2688899129b3Smrg        tmpdir=`func_mktempdir`
2689899129b3Smrg        for lib in $libs; do
2690899129b3Smrg	  sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
2691899129b3Smrg	    > $tmpdir/tmp-la
2692899129b3Smrg	  mv -f $tmpdir/tmp-la $lib
2693899129b3Smrg	done
2694899129b3Smrg        ${RM}r "$tmpdir"
2695899129b3Smrg      fi
2696899129b3Smrg    fi
2697bd1da9d7Smrg
2698899129b3Smrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
269947e89262Smrg      for libdir in $libdirs; do
270047e89262Smrg	if test -n "$finish_cmds"; then
270147e89262Smrg	  # Do each command in the finish commands.
270247e89262Smrg	  func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
270347e89262Smrg'"$cmd"'"'
270447e89262Smrg	fi
270547e89262Smrg	if test -n "$finish_eval"; then
270647e89262Smrg	  # Do the single finish_eval.
270747e89262Smrg	  eval cmds=\"$finish_eval\"
2708899129b3Smrg	  $opt_dry_run || eval "$cmds" || func_append admincmds "
270947e89262Smrg       $cmds"
271047e89262Smrg	fi
271147e89262Smrg      done
271247e89262Smrg    fi
2713bd1da9d7Smrg
271447e89262Smrg    # Exit here if they wanted silent mode.
271547e89262Smrg    $opt_silent && exit $EXIT_SUCCESS
2716bd1da9d7Smrg
2717899129b3Smrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
2718899129b3Smrg      echo "----------------------------------------------------------------------"
2719899129b3Smrg      echo "Libraries have been installed in:"
2720899129b3Smrg      for libdir in $libdirs; do
2721899129b3Smrg	$ECHO "   $libdir"
2722899129b3Smrg      done
2723899129b3Smrg      echo
2724899129b3Smrg      echo "If you ever happen to want to link against installed libraries"
2725899129b3Smrg      echo "in a given directory, LIBDIR, you must either use libtool, and"
2726899129b3Smrg      echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
2727899129b3Smrg      echo "flag during linking and do at least one of the following:"
2728899129b3Smrg      if test -n "$shlibpath_var"; then
2729899129b3Smrg	echo "   - add LIBDIR to the \`$shlibpath_var' environment variable"
2730899129b3Smrg	echo "     during execution"
2731899129b3Smrg      fi
2732899129b3Smrg      if test -n "$runpath_var"; then
2733899129b3Smrg	echo "   - add LIBDIR to the \`$runpath_var' environment variable"
2734899129b3Smrg	echo "     during linking"
2735899129b3Smrg      fi
2736899129b3Smrg      if test -n "$hardcode_libdir_flag_spec"; then
2737899129b3Smrg	libdir=LIBDIR
2738899129b3Smrg	eval flag=\"$hardcode_libdir_flag_spec\"
2739bd1da9d7Smrg
2740899129b3Smrg	$ECHO "   - use the \`$flag' linker flag"
2741899129b3Smrg      fi
2742899129b3Smrg      if test -n "$admincmds"; then
2743899129b3Smrg	$ECHO "   - have your system administrator run these commands:$admincmds"
2744899129b3Smrg      fi
2745899129b3Smrg      if test -f /etc/ld.so.conf; then
2746899129b3Smrg	echo "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
2747899129b3Smrg      fi
2748899129b3Smrg      echo
2749bd1da9d7Smrg
2750899129b3Smrg      echo "See any operating system documentation about shared libraries for"
2751899129b3Smrg      case $host in
2752899129b3Smrg	solaris2.[6789]|solaris2.1[0-9])
2753899129b3Smrg	  echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
2754899129b3Smrg	  echo "pages."
2755899129b3Smrg	  ;;
2756899129b3Smrg	*)
2757899129b3Smrg	  echo "more information, such as the ld(1) and ld.so(8) manual pages."
2758899129b3Smrg	  ;;
2759899129b3Smrg      esac
2760899129b3Smrg      echo "----------------------------------------------------------------------"
2761899129b3Smrg    fi
276247e89262Smrg    exit $EXIT_SUCCESS
276347e89262Smrg}
2764bd1da9d7Smrg
2765899129b3Smrgtest "$opt_mode" = finish && func_mode_finish ${1+"$@"}
2766bd1da9d7Smrg
2767bd1da9d7Smrg
276847e89262Smrg# func_mode_install arg...
276947e89262Smrgfunc_mode_install ()
277047e89262Smrg{
277147e89262Smrg    $opt_debug
277247e89262Smrg    # There may be an optional sh(1) argument at the beginning of
277347e89262Smrg    # install_prog (especially on Windows NT).
277447e89262Smrg    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
277547e89262Smrg       # Allow the use of GNU shtool's install command.
277647e89262Smrg       case $nonopt in *shtool*) :;; *) false;; esac; then
277747e89262Smrg      # Aesthetically quote it.
277847e89262Smrg      func_quote_for_eval "$nonopt"
277947e89262Smrg      install_prog="$func_quote_for_eval_result "
278047e89262Smrg      arg=$1
278147e89262Smrg      shift
278247e89262Smrg    else
278347e89262Smrg      install_prog=
278447e89262Smrg      arg=$nonopt
278547e89262Smrg    fi
2786bd1da9d7Smrg
278747e89262Smrg    # The real first argument should be the name of the installation program.
278847e89262Smrg    # Aesthetically quote it.
278947e89262Smrg    func_quote_for_eval "$arg"
2790899129b3Smrg    func_append install_prog "$func_quote_for_eval_result"
279147e89262Smrg    install_shared_prog=$install_prog
279247e89262Smrg    case " $install_prog " in
279347e89262Smrg      *[\\\ /]cp\ *) install_cp=: ;;
279447e89262Smrg      *) install_cp=false ;;
279547e89262Smrg    esac
2796bd1da9d7Smrg
279747e89262Smrg    # We need to accept at least all the BSD install flags.
279847e89262Smrg    dest=
279947e89262Smrg    files=
280047e89262Smrg    opts=
280147e89262Smrg    prev=
280247e89262Smrg    install_type=
280347e89262Smrg    isdir=no
280447e89262Smrg    stripme=
280547e89262Smrg    no_mode=:
280647e89262Smrg    for arg
280747e89262Smrg    do
280847e89262Smrg      arg2=
280947e89262Smrg      if test -n "$dest"; then
2810899129b3Smrg	func_append files " $dest"
281147e89262Smrg	dest=$arg
2812bd1da9d7Smrg	continue
281347e89262Smrg      fi
2814bd1da9d7Smrg
281547e89262Smrg      case $arg in
281647e89262Smrg      -d) isdir=yes ;;
281747e89262Smrg      -f)
281847e89262Smrg	if $install_cp; then :; else
281947e89262Smrg	  prev=$arg
2820bd1da9d7Smrg	fi
282147e89262Smrg	;;
282247e89262Smrg      -g | -m | -o)
282347e89262Smrg	prev=$arg
282447e89262Smrg	;;
282547e89262Smrg      -s)
282647e89262Smrg	stripme=" -s"
2827bd1da9d7Smrg	continue
2828bd1da9d7Smrg	;;
282947e89262Smrg      -*)
283047e89262Smrg	;;
2831bd1da9d7Smrg      *)
283247e89262Smrg	# If the previous option needed an argument, then skip it.
283347e89262Smrg	if test -n "$prev"; then
283447e89262Smrg	  if test "x$prev" = x-m && test -n "$install_override_mode"; then
283547e89262Smrg	    arg2=$install_override_mode
283647e89262Smrg	    no_mode=false
283747e89262Smrg	  fi
283847e89262Smrg	  prev=
283947e89262Smrg	else
284047e89262Smrg	  dest=$arg
284147e89262Smrg	  continue
284247e89262Smrg	fi
2843bd1da9d7Smrg	;;
284447e89262Smrg      esac
2845bd1da9d7Smrg
284647e89262Smrg      # Aesthetically quote the argument.
284747e89262Smrg      func_quote_for_eval "$arg"
2848899129b3Smrg      func_append install_prog " $func_quote_for_eval_result"
284947e89262Smrg      if test -n "$arg2"; then
285047e89262Smrg	func_quote_for_eval "$arg2"
2851bd1da9d7Smrg      fi
2852899129b3Smrg      func_append install_shared_prog " $func_quote_for_eval_result"
285347e89262Smrg    done
2854bd1da9d7Smrg
285547e89262Smrg    test -z "$install_prog" && \
285647e89262Smrg      func_fatal_help "you must specify an install program"
2857bd1da9d7Smrg
285847e89262Smrg    test -n "$prev" && \
285947e89262Smrg      func_fatal_help "the \`$prev' option requires an argument"
2860bd1da9d7Smrg
286147e89262Smrg    if test -n "$install_override_mode" && $no_mode; then
286247e89262Smrg      if $install_cp; then :; else
286347e89262Smrg	func_quote_for_eval "$install_override_mode"
2864899129b3Smrg	func_append install_shared_prog " -m $func_quote_for_eval_result"
286547e89262Smrg      fi
2866bd1da9d7Smrg    fi
2867bd1da9d7Smrg
286847e89262Smrg    if test -z "$files"; then
286947e89262Smrg      if test -z "$dest"; then
287047e89262Smrg	func_fatal_help "no file or destination specified"
287147e89262Smrg      else
287247e89262Smrg	func_fatal_help "you must specify a destination"
2873bd1da9d7Smrg      fi
2874bd1da9d7Smrg    fi
2875bd1da9d7Smrg
287647e89262Smrg    # Strip any trailing slash from the destination.
287747e89262Smrg    func_stripname '' '/' "$dest"
287847e89262Smrg    dest=$func_stripname_result
2879bd1da9d7Smrg
288047e89262Smrg    # Check to see that the destination is a directory.
288147e89262Smrg    test -d "$dest" && isdir=yes
288247e89262Smrg    if test "$isdir" = yes; then
288347e89262Smrg      destdir="$dest"
288447e89262Smrg      destname=
288547e89262Smrg    else
288647e89262Smrg      func_dirname_and_basename "$dest" "" "."
288747e89262Smrg      destdir="$func_dirname_result"
288847e89262Smrg      destname="$func_basename_result"
288947e89262Smrg
289047e89262Smrg      # Not a directory, so check to see that there is only one file specified.
289147e89262Smrg      set dummy $files; shift
289247e89262Smrg      test "$#" -gt 1 && \
289347e89262Smrg	func_fatal_help "\`$dest' is not a directory"
289447e89262Smrg    fi
289547e89262Smrg    case $destdir in
289647e89262Smrg    [\\/]* | [A-Za-z]:[\\/]*) ;;
2897bd1da9d7Smrg    *)
289847e89262Smrg      for file in $files; do
289947e89262Smrg	case $file in
290047e89262Smrg	*.lo) ;;
290147e89262Smrg	*)
290247e89262Smrg	  func_fatal_help "\`$destdir' must be an absolute directory name"
290347e89262Smrg	  ;;
290447e89262Smrg	esac
290547e89262Smrg      done
2906bd1da9d7Smrg      ;;
2907bd1da9d7Smrg    esac
2908bd1da9d7Smrg
290947e89262Smrg    # This variable tells wrapper scripts just to set variables rather
291047e89262Smrg    # than running their programs.
291147e89262Smrg    libtool_install_magic="$magic"
2912bd1da9d7Smrg
291347e89262Smrg    staticlibs=
291447e89262Smrg    future_libdirs=
291547e89262Smrg    current_libdirs=
291647e89262Smrg    for file in $files; do
2917bd1da9d7Smrg
291847e89262Smrg      # Do each installation.
291947e89262Smrg      case $file in
292047e89262Smrg      *.$libext)
292147e89262Smrg	# Do the static libraries later.
2922899129b3Smrg	func_append staticlibs " $file"
292347e89262Smrg	;;
292447e89262Smrg
292547e89262Smrg      *.la)
2926899129b3Smrg	func_resolve_sysroot "$file"
2927899129b3Smrg	file=$func_resolve_sysroot_result
2928899129b3Smrg
292947e89262Smrg	# Check to see that this really is a libtool archive.
293047e89262Smrg	func_lalib_unsafe_p "$file" \
293147e89262Smrg	  || func_fatal_help "\`$file' is not a valid libtool archive"
293247e89262Smrg
293347e89262Smrg	library_names=
293447e89262Smrg	old_library=
293547e89262Smrg	relink_command=
293647e89262Smrg	func_source "$file"
293747e89262Smrg
293847e89262Smrg	# Add the libdir to current_libdirs if it is the destination.
293947e89262Smrg	if test "X$destdir" = "X$libdir"; then
294047e89262Smrg	  case "$current_libdirs " in
294147e89262Smrg	  *" $libdir "*) ;;
2942899129b3Smrg	  *) func_append current_libdirs " $libdir" ;;
2943bd1da9d7Smrg	  esac
294447e89262Smrg	else
294547e89262Smrg	  # Note the libdir as a future libdir.
294647e89262Smrg	  case "$future_libdirs " in
294747e89262Smrg	  *" $libdir "*) ;;
2948899129b3Smrg	  *) func_append future_libdirs " $libdir" ;;
294947e89262Smrg	  esac
295047e89262Smrg	fi
2951bd1da9d7Smrg
295247e89262Smrg	func_dirname "$file" "/" ""
295347e89262Smrg	dir="$func_dirname_result"
2954899129b3Smrg	func_append dir "$objdir"
295547e89262Smrg
295647e89262Smrg	if test -n "$relink_command"; then
295747e89262Smrg	  # Determine the prefix the user has applied to our future dir.
295847e89262Smrg	  inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
295947e89262Smrg
296047e89262Smrg	  # Don't allow the user to place us outside of our expected
296147e89262Smrg	  # location b/c this prevents finding dependent libraries that
296247e89262Smrg	  # are installed to the same prefix.
296347e89262Smrg	  # At present, this check doesn't affect windows .dll's that
296447e89262Smrg	  # are installed into $libdir/../bin (currently, that works fine)
296547e89262Smrg	  # but it's something to keep an eye on.
296647e89262Smrg	  test "$inst_prefix_dir" = "$destdir" && \
296747e89262Smrg	    func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
296847e89262Smrg
296947e89262Smrg	  if test -n "$inst_prefix_dir"; then
297047e89262Smrg	    # Stick the inst_prefix_dir data into the link command.
297147e89262Smrg	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
297247e89262Smrg	  else
297347e89262Smrg	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
297447e89262Smrg	  fi
297547e89262Smrg
297647e89262Smrg	  func_warning "relinking \`$file'"
297747e89262Smrg	  func_show_eval "$relink_command" \
297847e89262Smrg	    'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
297947e89262Smrg	fi
298047e89262Smrg
298147e89262Smrg	# See the names of the shared library.
298247e89262Smrg	set dummy $library_names; shift
298347e89262Smrg	if test -n "$1"; then
298447e89262Smrg	  realname="$1"
298547e89262Smrg	  shift
298647e89262Smrg
298747e89262Smrg	  srcname="$realname"
298847e89262Smrg	  test -n "$relink_command" && srcname="$realname"T
298947e89262Smrg
299047e89262Smrg	  # Install the shared library and build the symlinks.
299147e89262Smrg	  func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
299247e89262Smrg	      'exit $?'
299347e89262Smrg	  tstripme="$stripme"
299447e89262Smrg	  case $host_os in
299547e89262Smrg	  cygwin* | mingw* | pw32* | cegcc*)
299647e89262Smrg	    case $realname in
299747e89262Smrg	    *.dll.a)
299847e89262Smrg	      tstripme=""
299947e89262Smrg	      ;;
300047e89262Smrg	    esac
3001bd1da9d7Smrg	    ;;
3002bd1da9d7Smrg	  esac
300347e89262Smrg	  if test -n "$tstripme" && test -n "$striplib"; then
300447e89262Smrg	    func_show_eval "$striplib $destdir/$realname" 'exit $?'
300547e89262Smrg	  fi
300647e89262Smrg
300747e89262Smrg	  if test "$#" -gt 0; then
300847e89262Smrg	    # Delete the old symlinks, and create new ones.
300947e89262Smrg	    # Try `ln -sf' first, because the `ln' binary might depend on
301047e89262Smrg	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
301147e89262Smrg	    # so we also need to try rm && ln -s.
301247e89262Smrg	    for linkname
301347e89262Smrg	    do
301447e89262Smrg	      test "$linkname" != "$realname" \
301547e89262Smrg		&& func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
301647e89262Smrg	    done
301747e89262Smrg	  fi
301847e89262Smrg
301947e89262Smrg	  # Do each command in the postinstall commands.
302047e89262Smrg	  lib="$destdir/$realname"
302147e89262Smrg	  func_execute_cmds "$postinstall_cmds" 'exit $?'
302247e89262Smrg	fi
302347e89262Smrg
302447e89262Smrg	# Install the pseudo-library for information purposes.
302547e89262Smrg	func_basename "$file"
302647e89262Smrg	name="$func_basename_result"
302747e89262Smrg	instname="$dir/$name"i
302847e89262Smrg	func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
302947e89262Smrg
303047e89262Smrg	# Maybe install the static library, too.
3031899129b3Smrg	test -n "$old_library" && func_append staticlibs " $dir/$old_library"
3032bd1da9d7Smrg	;;
303347e89262Smrg
303447e89262Smrg      *.lo)
303547e89262Smrg	# Install (i.e. copy) a libtool object.
303647e89262Smrg
303747e89262Smrg	# Figure out destination file name, if it wasn't already specified.
303847e89262Smrg	if test -n "$destname"; then
303947e89262Smrg	  destfile="$destdir/$destname"
304047e89262Smrg	else
304147e89262Smrg	  func_basename "$file"
304247e89262Smrg	  destfile="$func_basename_result"
304347e89262Smrg	  destfile="$destdir/$destfile"
304447e89262Smrg	fi
304547e89262Smrg
304647e89262Smrg	# Deduce the name of the destination old-style object file.
304747e89262Smrg	case $destfile in
304847e89262Smrg	*.lo)
304947e89262Smrg	  func_lo2o "$destfile"
305047e89262Smrg	  staticdest=$func_lo2o_result
3051bd1da9d7Smrg	  ;;
305247e89262Smrg	*.$objext)
305347e89262Smrg	  staticdest="$destfile"
305447e89262Smrg	  destfile=
3055bd1da9d7Smrg	  ;;
305647e89262Smrg	*)
305747e89262Smrg	  func_fatal_help "cannot copy a libtool object to \`$destfile'"
3058bd1da9d7Smrg	  ;;
305947e89262Smrg	esac
306047e89262Smrg
306147e89262Smrg	# Install the libtool object if requested.
306247e89262Smrg	test -n "$destfile" && \
306347e89262Smrg	  func_show_eval "$install_prog $file $destfile" 'exit $?'
306447e89262Smrg
306547e89262Smrg	# Install the old object if enabled.
306647e89262Smrg	if test "$build_old_libs" = yes; then
306747e89262Smrg	  # Deduce the name of the old-style object file.
306847e89262Smrg	  func_lo2o "$file"
306947e89262Smrg	  staticobj=$func_lo2o_result
307047e89262Smrg	  func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
3071bd1da9d7Smrg	fi
307247e89262Smrg	exit $EXIT_SUCCESS
307347e89262Smrg	;;
3074bd1da9d7Smrg
307547e89262Smrg      *)
307647e89262Smrg	# Figure out destination file name, if it wasn't already specified.
307747e89262Smrg	if test -n "$destname"; then
307847e89262Smrg	  destfile="$destdir/$destname"
3079bd1da9d7Smrg	else
308047e89262Smrg	  func_basename "$file"
308147e89262Smrg	  destfile="$func_basename_result"
308247e89262Smrg	  destfile="$destdir/$destfile"
3083bd1da9d7Smrg	fi
3084bd1da9d7Smrg
308547e89262Smrg	# If the file is missing, and there is a .exe on the end, strip it
308647e89262Smrg	# because it is most likely a libtool script we actually want to
308747e89262Smrg	# install
308847e89262Smrg	stripped_ext=""
308947e89262Smrg	case $file in
309047e89262Smrg	  *.exe)
309147e89262Smrg	    if test ! -f "$file"; then
309247e89262Smrg	      func_stripname '' '.exe' "$file"
309347e89262Smrg	      file=$func_stripname_result
309447e89262Smrg	      stripped_ext=".exe"
309547e89262Smrg	    fi
309647e89262Smrg	    ;;
309747e89262Smrg	esac
3098bd1da9d7Smrg
309947e89262Smrg	# Do a test to see if this is really a libtool program.
310047e89262Smrg	case $host in
310147e89262Smrg	*cygwin* | *mingw*)
310247e89262Smrg	    if func_ltwrapper_executable_p "$file"; then
310347e89262Smrg	      func_ltwrapper_scriptname "$file"
310447e89262Smrg	      wrapper=$func_ltwrapper_scriptname_result
310547e89262Smrg	    else
310647e89262Smrg	      func_stripname '' '.exe' "$file"
310747e89262Smrg	      wrapper=$func_stripname_result
310847e89262Smrg	    fi
310947e89262Smrg	    ;;
311047e89262Smrg	*)
311147e89262Smrg	    wrapper=$file
311247e89262Smrg	    ;;
311347e89262Smrg	esac
311447e89262Smrg	if func_ltwrapper_script_p "$wrapper"; then
311547e89262Smrg	  notinst_deplibs=
311647e89262Smrg	  relink_command=
3117bd1da9d7Smrg
311847e89262Smrg	  func_source "$wrapper"
3119bd1da9d7Smrg
312047e89262Smrg	  # Check the variables that should have been set.
312147e89262Smrg	  test -z "$generated_by_libtool_version" && \
312247e89262Smrg	    func_fatal_error "invalid libtool wrapper script \`$wrapper'"
3123bd1da9d7Smrg
312447e89262Smrg	  finalize=yes
312547e89262Smrg	  for lib in $notinst_deplibs; do
312647e89262Smrg	    # Check to see that each library is installed.
312747e89262Smrg	    libdir=
312847e89262Smrg	    if test -f "$lib"; then
312947e89262Smrg	      func_source "$lib"
3130bd1da9d7Smrg	    fi
313147e89262Smrg	    libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test
313247e89262Smrg	    if test -n "$libdir" && test ! -f "$libfile"; then
313347e89262Smrg	      func_warning "\`$lib' has not been installed in \`$libdir'"
313447e89262Smrg	      finalize=no
313547e89262Smrg	    fi
313647e89262Smrg	  done
3137bd1da9d7Smrg
313847e89262Smrg	  relink_command=
313947e89262Smrg	  func_source "$wrapper"
3140bd1da9d7Smrg
314147e89262Smrg	  outputname=
314247e89262Smrg	  if test "$fast_install" = no && test -n "$relink_command"; then
314347e89262Smrg	    $opt_dry_run || {
314447e89262Smrg	      if test "$finalize" = yes; then
314547e89262Smrg	        tmpdir=`func_mktempdir`
314647e89262Smrg		func_basename "$file$stripped_ext"
314747e89262Smrg		file="$func_basename_result"
314847e89262Smrg	        outputname="$tmpdir/$file"
314947e89262Smrg	        # Replace the output file specification.
315047e89262Smrg	        relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
315147e89262Smrg
315247e89262Smrg	        $opt_silent || {
315347e89262Smrg	          func_quote_for_expand "$relink_command"
315447e89262Smrg		  eval "func_echo $func_quote_for_expand_result"
315547e89262Smrg	        }
315647e89262Smrg	        if eval "$relink_command"; then :
315747e89262Smrg	          else
315847e89262Smrg		  func_error "error: relink \`$file' with the above command before installing it"
315947e89262Smrg		  $opt_dry_run || ${RM}r "$tmpdir"
316047e89262Smrg		  continue
316147e89262Smrg	        fi
316247e89262Smrg	        file="$outputname"
316347e89262Smrg	      else
316447e89262Smrg	        func_warning "cannot relink \`$file'"
316547e89262Smrg	      fi
316647e89262Smrg	    }
3167bd1da9d7Smrg	  else
316847e89262Smrg	    # Install the binary that we compiled earlier.
316947e89262Smrg	    file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
3170bd1da9d7Smrg	  fi
317147e89262Smrg	fi
3172bd1da9d7Smrg
317347e89262Smrg	# remove .exe since cygwin /usr/bin/install will append another
317447e89262Smrg	# one anyway
317547e89262Smrg	case $install_prog,$host in
317647e89262Smrg	*/usr/bin/install*,*cygwin*)
317747e89262Smrg	  case $file:$destfile in
317847e89262Smrg	  *.exe:*.exe)
317947e89262Smrg	    # this is ok
318047e89262Smrg	    ;;
318147e89262Smrg	  *.exe:*)
318247e89262Smrg	    destfile=$destfile.exe
318347e89262Smrg	    ;;
318447e89262Smrg	  *:*.exe)
318547e89262Smrg	    func_stripname '' '.exe' "$destfile"
318647e89262Smrg	    destfile=$func_stripname_result
318747e89262Smrg	    ;;
318847e89262Smrg	  esac
3189bd1da9d7Smrg	  ;;
3190bd1da9d7Smrg	esac
319147e89262Smrg	func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
319247e89262Smrg	$opt_dry_run || if test -n "$outputname"; then
319347e89262Smrg	  ${RM}r "$tmpdir"
319447e89262Smrg	fi
319547e89262Smrg	;;
319647e89262Smrg      esac
319747e89262Smrg    done
3198bd1da9d7Smrg
319947e89262Smrg    for file in $staticlibs; do
320047e89262Smrg      func_basename "$file"
320147e89262Smrg      name="$func_basename_result"
320247e89262Smrg
320347e89262Smrg      # Set up the ranlib parameters.
320447e89262Smrg      oldlib="$destdir/$name"
3205899129b3Smrg      func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
3206899129b3Smrg      tool_oldlib=$func_to_tool_file_result
320747e89262Smrg
320847e89262Smrg      func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
320947e89262Smrg
321047e89262Smrg      if test -n "$stripme" && test -n "$old_striplib"; then
3211899129b3Smrg	func_show_eval "$old_striplib $tool_oldlib" 'exit $?'
321247e89262Smrg      fi
321347e89262Smrg
321447e89262Smrg      # Do each command in the postinstall commands.
321547e89262Smrg      func_execute_cmds "$old_postinstall_cmds" 'exit $?'
321647e89262Smrg    done
321747e89262Smrg
321847e89262Smrg    test -n "$future_libdirs" && \
321947e89262Smrg      func_warning "remember to run \`$progname --finish$future_libdirs'"
322047e89262Smrg
322147e89262Smrg    if test -n "$current_libdirs"; then
322247e89262Smrg      # Maybe just do a dry run.
322347e89262Smrg      $opt_dry_run && current_libdirs=" -n$current_libdirs"
322447e89262Smrg      exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
322547e89262Smrg    else
322647e89262Smrg      exit $EXIT_SUCCESS
322747e89262Smrg    fi
322847e89262Smrg}
322947e89262Smrg
3230899129b3Smrgtest "$opt_mode" = install && func_mode_install ${1+"$@"}
323147e89262Smrg
323247e89262Smrg
323347e89262Smrg# func_generate_dlsyms outputname originator pic_p
323447e89262Smrg# Extract symbols from dlprefiles and create ${outputname}S.o with
323547e89262Smrg# a dlpreopen symbol table.
323647e89262Smrgfunc_generate_dlsyms ()
323747e89262Smrg{
323847e89262Smrg    $opt_debug
323947e89262Smrg    my_outputname="$1"
324047e89262Smrg    my_originator="$2"
324147e89262Smrg    my_pic_p="${3-no}"
324247e89262Smrg    my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'`
324347e89262Smrg    my_dlsyms=
324447e89262Smrg
324547e89262Smrg    if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
324647e89262Smrg      if test -n "$NM" && test -n "$global_symbol_pipe"; then
324747e89262Smrg	my_dlsyms="${my_outputname}S.c"
324847e89262Smrg      else
324947e89262Smrg	func_error "not configured to extract global symbols from dlpreopened files"
325047e89262Smrg      fi
325147e89262Smrg    fi
325247e89262Smrg
325347e89262Smrg    if test -n "$my_dlsyms"; then
325447e89262Smrg      case $my_dlsyms in
325547e89262Smrg      "") ;;
325647e89262Smrg      *.c)
325747e89262Smrg	# Discover the nlist of each of the dlfiles.
325847e89262Smrg	nlist="$output_objdir/${my_outputname}.nm"
325947e89262Smrg
326047e89262Smrg	func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
326147e89262Smrg
326247e89262Smrg	# Parse the name list into a source file.
326347e89262Smrg	func_verbose "creating $output_objdir/$my_dlsyms"
326447e89262Smrg
326547e89262Smrg	$opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
326647e89262Smrg/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */
326747e89262Smrg/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */
326847e89262Smrg
326947e89262Smrg#ifdef __cplusplus
327047e89262Smrgextern \"C\" {
327147e89262Smrg#endif
327247e89262Smrg
327347e89262Smrg#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
327447e89262Smrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
327547e89262Smrg#endif
327647e89262Smrg
3277899129b3Smrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
3278899129b3Smrg#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
3279899129b3Smrg/* DATA imports from DLLs on WIN32 con't be const, because runtime
3280899129b3Smrg   relocations are performed -- see ld's documentation on pseudo-relocs.  */
3281899129b3Smrg# define LT_DLSYM_CONST
3282899129b3Smrg#elif defined(__osf__)
3283899129b3Smrg/* This system does not cope well with relocations in const data.  */
3284899129b3Smrg# define LT_DLSYM_CONST
3285899129b3Smrg#else
3286899129b3Smrg# define LT_DLSYM_CONST const
3287899129b3Smrg#endif
3288899129b3Smrg
328947e89262Smrg/* External symbol declarations for the compiler. */\
329047e89262Smrg"
329147e89262Smrg
329247e89262Smrg	if test "$dlself" = yes; then
329347e89262Smrg	  func_verbose "generating symbol list for \`$output'"
329447e89262Smrg
329547e89262Smrg	  $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
329647e89262Smrg
329747e89262Smrg	  # Add our own program objects to the symbol list.
329847e89262Smrg	  progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
329947e89262Smrg	  for progfile in $progfiles; do
3300899129b3Smrg	    func_to_tool_file "$progfile" func_convert_file_msys_to_w32
3301899129b3Smrg	    func_verbose "extracting global C symbols from \`$func_to_tool_file_result'"
3302899129b3Smrg	    $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
330347e89262Smrg	  done
330447e89262Smrg
330547e89262Smrg	  if test -n "$exclude_expsyms"; then
330647e89262Smrg	    $opt_dry_run || {
330747e89262Smrg	      eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
330847e89262Smrg	      eval '$MV "$nlist"T "$nlist"'
330947e89262Smrg	    }
3310bd1da9d7Smrg	  fi
331147e89262Smrg
331247e89262Smrg	  if test -n "$export_symbols_regex"; then
331347e89262Smrg	    $opt_dry_run || {
331447e89262Smrg	      eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
331547e89262Smrg	      eval '$MV "$nlist"T "$nlist"'
331647e89262Smrg	    }
331747e89262Smrg	  fi
331847e89262Smrg
331947e89262Smrg	  # Prepare the list of exported symbols
332047e89262Smrg	  if test -z "$export_symbols"; then
332147e89262Smrg	    export_symbols="$output_objdir/$outputname.exp"
332247e89262Smrg	    $opt_dry_run || {
332347e89262Smrg	      $RM $export_symbols
332447e89262Smrg	      eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
332547e89262Smrg	      case $host in
332647e89262Smrg	      *cygwin* | *mingw* | *cegcc* )
332747e89262Smrg                eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
332847e89262Smrg                eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
332947e89262Smrg	        ;;
333047e89262Smrg	      esac
333147e89262Smrg	    }
3332bd1da9d7Smrg	  else
333347e89262Smrg	    $opt_dry_run || {
333447e89262Smrg	      eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
333547e89262Smrg	      eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
333647e89262Smrg	      eval '$MV "$nlist"T "$nlist"'
333747e89262Smrg	      case $host in
333847e89262Smrg	        *cygwin* | *mingw* | *cegcc* )
333947e89262Smrg	          eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
334047e89262Smrg	          eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
334147e89262Smrg	          ;;
334247e89262Smrg	      esac
334347e89262Smrg	    }
3344bd1da9d7Smrg	  fi
334547e89262Smrg	fi
3346bd1da9d7Smrg
334747e89262Smrg	for dlprefile in $dlprefiles; do
334847e89262Smrg	  func_verbose "extracting global C symbols from \`$dlprefile'"
334947e89262Smrg	  func_basename "$dlprefile"
335047e89262Smrg	  name="$func_basename_result"
3351899129b3Smrg          case $host in
3352899129b3Smrg	    *cygwin* | *mingw* | *cegcc* )
3353899129b3Smrg	      # if an import library, we need to obtain dlname
3354899129b3Smrg	      if func_win32_import_lib_p "$dlprefile"; then
3355899129b3Smrg	        func_tr_sh "$dlprefile"
3356899129b3Smrg	        eval "curr_lafile=\$libfile_$func_tr_sh_result"
3357899129b3Smrg	        dlprefile_dlbasename=""
3358899129b3Smrg	        if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
3359899129b3Smrg	          # Use subshell, to avoid clobbering current variable values
3360899129b3Smrg	          dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
3361899129b3Smrg	          if test -n "$dlprefile_dlname" ; then
3362899129b3Smrg	            func_basename "$dlprefile_dlname"
3363899129b3Smrg	            dlprefile_dlbasename="$func_basename_result"
3364899129b3Smrg	          else
3365899129b3Smrg	            # no lafile. user explicitly requested -dlpreopen <import library>.
3366899129b3Smrg	            $sharedlib_from_linklib_cmd "$dlprefile"
3367899129b3Smrg	            dlprefile_dlbasename=$sharedlib_from_linklib_result
3368899129b3Smrg	          fi
3369899129b3Smrg	        fi
3370899129b3Smrg	        $opt_dry_run || {
3371899129b3Smrg	          if test -n "$dlprefile_dlbasename" ; then
3372899129b3Smrg	            eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
3373899129b3Smrg	          else
3374899129b3Smrg	            func_warning "Could not compute DLL name from $name"
3375899129b3Smrg	            eval '$ECHO ": $name " >> "$nlist"'
3376899129b3Smrg	          fi
3377899129b3Smrg	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
3378899129b3Smrg	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe |
3379899129b3Smrg	            $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'"
3380899129b3Smrg	        }
3381899129b3Smrg	      else # not an import lib
3382899129b3Smrg	        $opt_dry_run || {
3383899129b3Smrg	          eval '$ECHO ": $name " >> "$nlist"'
3384899129b3Smrg	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
3385899129b3Smrg	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
3386899129b3Smrg	        }
3387899129b3Smrg	      fi
3388899129b3Smrg	    ;;
3389899129b3Smrg	    *)
3390899129b3Smrg	      $opt_dry_run || {
3391899129b3Smrg	        eval '$ECHO ": $name " >> "$nlist"'
3392899129b3Smrg	        func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
3393899129b3Smrg	        eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
3394899129b3Smrg	      }
3395899129b3Smrg	    ;;
3396899129b3Smrg          esac
339747e89262Smrg	done
339847e89262Smrg
339947e89262Smrg	$opt_dry_run || {
340047e89262Smrg	  # Make sure we have at least an empty file.
340147e89262Smrg	  test -f "$nlist" || : > "$nlist"
340247e89262Smrg
340347e89262Smrg	  if test -n "$exclude_expsyms"; then
340447e89262Smrg	    $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
340547e89262Smrg	    $MV "$nlist"T "$nlist"
3406bd1da9d7Smrg	  fi
340747e89262Smrg
340847e89262Smrg	  # Try sorting and uniquifying the output.
340947e89262Smrg	  if $GREP -v "^: " < "$nlist" |
341047e89262Smrg	      if sort -k 3 </dev/null >/dev/null 2>&1; then
341147e89262Smrg		sort -k 3
341247e89262Smrg	      else
341347e89262Smrg		sort +2
341447e89262Smrg	      fi |
341547e89262Smrg	      uniq > "$nlist"S; then
341647e89262Smrg	    :
3417bd1da9d7Smrg	  else
341847e89262Smrg	    $GREP -v "^: " < "$nlist" > "$nlist"S
3419bd1da9d7Smrg	  fi
3420bd1da9d7Smrg
342147e89262Smrg	  if test -f "$nlist"S; then
342247e89262Smrg	    eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
3423bd1da9d7Smrg	  else
342447e89262Smrg	    echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
3425bd1da9d7Smrg	  fi
3426bd1da9d7Smrg
342747e89262Smrg	  echo >> "$output_objdir/$my_dlsyms" "\
3428bd1da9d7Smrg
342947e89262Smrg/* The mapping between symbol names and symbols.  */
343047e89262Smrgtypedef struct {
343147e89262Smrg  const char *name;
343247e89262Smrg  void *address;
343347e89262Smrg} lt_dlsymlist;
3434899129b3Smrgextern LT_DLSYM_CONST lt_dlsymlist
343547e89262Smrglt_${my_prefix}_LTX_preloaded_symbols[];
3436899129b3SmrgLT_DLSYM_CONST lt_dlsymlist
343747e89262Smrglt_${my_prefix}_LTX_preloaded_symbols[] =
343847e89262Smrg{\
343947e89262Smrg  { \"$my_originator\", (void *) 0 },"
3440bd1da9d7Smrg
344147e89262Smrg	  case $need_lib_prefix in
344247e89262Smrg	  no)
344347e89262Smrg	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
344447e89262Smrg	    ;;
344547e89262Smrg	  *)
344647e89262Smrg	    eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
344747e89262Smrg	    ;;
344847e89262Smrg	  esac
344947e89262Smrg	  echo >> "$output_objdir/$my_dlsyms" "\
345047e89262Smrg  {0, (void *) 0}
345147e89262Smrg};
3452bd1da9d7Smrg
345347e89262Smrg/* This works around a problem in FreeBSD linker */
345447e89262Smrg#ifdef FREEBSD_WORKAROUND
345547e89262Smrgstatic const void *lt_preloaded_setup() {
345647e89262Smrg  return lt_${my_prefix}_LTX_preloaded_symbols;
345747e89262Smrg}
345847e89262Smrg#endif
3459bd1da9d7Smrg
346047e89262Smrg#ifdef __cplusplus
346147e89262Smrg}
346247e89262Smrg#endif\
346347e89262Smrg"
346447e89262Smrg	} # !$opt_dry_run
3465bd1da9d7Smrg
346647e89262Smrg	pic_flag_for_symtable=
346747e89262Smrg	case "$compile_command " in
346847e89262Smrg	*" -static "*) ;;
346947e89262Smrg	*)
347047e89262Smrg	  case $host in
347147e89262Smrg	  # compiling the symbol table file with pic_flag works around
347247e89262Smrg	  # a FreeBSD bug that causes programs to crash when -lm is
347347e89262Smrg	  # linked before any other PIC object.  But we must not use
347447e89262Smrg	  # pic_flag when linking with -static.  The problem exists in
347547e89262Smrg	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
3476899129b3Smrg	  *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
347747e89262Smrg	    pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
347847e89262Smrg	  *-*-hpux*)
347947e89262Smrg	    pic_flag_for_symtable=" $pic_flag"  ;;
348047e89262Smrg	  *)
348147e89262Smrg	    if test "X$my_pic_p" != Xno; then
348247e89262Smrg	      pic_flag_for_symtable=" $pic_flag"
348347e89262Smrg	    fi
348447e89262Smrg	    ;;
348547e89262Smrg	  esac
348647e89262Smrg	  ;;
348747e89262Smrg	esac
348847e89262Smrg	symtab_cflags=
348947e89262Smrg	for arg in $LTCFLAGS; do
349047e89262Smrg	  case $arg in
349147e89262Smrg	  -pie | -fpie | -fPIE) ;;
3492899129b3Smrg	  *) func_append symtab_cflags " $arg" ;;
349347e89262Smrg	  esac
349447e89262Smrg	done
3495bd1da9d7Smrg
349647e89262Smrg	# Now compile the dynamic symbol file.
349747e89262Smrg	func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
3498bd1da9d7Smrg
349947e89262Smrg	# Clean up the generated files.
350047e89262Smrg	func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"'
3501bd1da9d7Smrg
350247e89262Smrg	# Transform the symbol file into the correct name.
350347e89262Smrg	symfileobj="$output_objdir/${my_outputname}S.$objext"
350447e89262Smrg	case $host in
350547e89262Smrg	*cygwin* | *mingw* | *cegcc* )
350647e89262Smrg	  if test -f "$output_objdir/$my_outputname.def"; then
350747e89262Smrg	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
350847e89262Smrg	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
350947e89262Smrg	  else
351047e89262Smrg	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
351147e89262Smrg	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
351247e89262Smrg	  fi
351347e89262Smrg	  ;;
351447e89262Smrg	*)
351547e89262Smrg	  compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
351647e89262Smrg	  finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
351747e89262Smrg	  ;;
351847e89262Smrg	esac
351947e89262Smrg	;;
352047e89262Smrg      *)
352147e89262Smrg	func_fatal_error "unknown suffix for \`$my_dlsyms'"
352247e89262Smrg	;;
352347e89262Smrg      esac
352447e89262Smrg    else
352547e89262Smrg      # We keep going just in case the user didn't refer to
352647e89262Smrg      # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
352747e89262Smrg      # really was required.
3528bd1da9d7Smrg
352947e89262Smrg      # Nullify the symbol file.
353047e89262Smrg      compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
353147e89262Smrg      finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
353247e89262Smrg    fi
353347e89262Smrg}
3534bd1da9d7Smrg
353547e89262Smrg# func_win32_libid arg
353647e89262Smrg# return the library type of file 'arg'
353747e89262Smrg#
353847e89262Smrg# Need a lot of goo to handle *both* DLLs and import libs
353947e89262Smrg# Has to be a shell function in order to 'eat' the argument
354047e89262Smrg# that is supplied when $file_magic_command is called.
354147e89262Smrg# Despite the name, also deal with 64 bit binaries.
354247e89262Smrgfunc_win32_libid ()
354347e89262Smrg{
354447e89262Smrg  $opt_debug
354547e89262Smrg  win32_libid_type="unknown"
354647e89262Smrg  win32_fileres=`file -L $1 2>/dev/null`
354747e89262Smrg  case $win32_fileres in
354847e89262Smrg  *ar\ archive\ import\ library*) # definitely import
354947e89262Smrg    win32_libid_type="x86 archive import"
355047e89262Smrg    ;;
355147e89262Smrg  *ar\ archive*) # could be an import, or static
355247e89262Smrg    # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
355347e89262Smrg    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
355447e89262Smrg       $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
3555899129b3Smrg      func_to_tool_file "$1" func_convert_file_msys_to_w32
3556899129b3Smrg      win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
355747e89262Smrg	$SED -n -e '
355847e89262Smrg	    1,100{
355947e89262Smrg		/ I /{
356047e89262Smrg		    s,.*,import,
356147e89262Smrg		    p
356247e89262Smrg		    q
356347e89262Smrg		}
356447e89262Smrg	    }'`
356547e89262Smrg      case $win32_nmres in
356647e89262Smrg      import*)  win32_libid_type="x86 archive import";;
356747e89262Smrg      *)        win32_libid_type="x86 archive static";;
356847e89262Smrg      esac
356947e89262Smrg    fi
357047e89262Smrg    ;;
357147e89262Smrg  *DLL*)
357247e89262Smrg    win32_libid_type="x86 DLL"
357347e89262Smrg    ;;
357447e89262Smrg  *executable*) # but shell scripts are "executable" too...
357547e89262Smrg    case $win32_fileres in
357647e89262Smrg    *MS\ Windows\ PE\ Intel*)
357747e89262Smrg      win32_libid_type="x86 DLL"
357847e89262Smrg      ;;
357947e89262Smrg    esac
358047e89262Smrg    ;;
358147e89262Smrg  esac
358247e89262Smrg  $ECHO "$win32_libid_type"
358347e89262Smrg}
3584bd1da9d7Smrg
3585899129b3Smrg# func_cygming_dll_for_implib ARG
3586899129b3Smrg#
3587899129b3Smrg# Platform-specific function to extract the
3588899129b3Smrg# name of the DLL associated with the specified
3589899129b3Smrg# import library ARG.
3590899129b3Smrg# Invoked by eval'ing the libtool variable
3591899129b3Smrg#    $sharedlib_from_linklib_cmd
3592899129b3Smrg# Result is available in the variable
3593899129b3Smrg#    $sharedlib_from_linklib_result
3594899129b3Smrgfunc_cygming_dll_for_implib ()
3595899129b3Smrg{
3596899129b3Smrg  $opt_debug
3597899129b3Smrg  sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
3598899129b3Smrg}
3599899129b3Smrg
3600899129b3Smrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs
3601899129b3Smrg#
3602899129b3Smrg# The is the core of a fallback implementation of a
3603899129b3Smrg# platform-specific function to extract the name of the
3604899129b3Smrg# DLL associated with the specified import library LIBNAME.
3605899129b3Smrg#
3606899129b3Smrg# SECTION_NAME is either .idata$6 or .idata$7, depending
3607899129b3Smrg# on the platform and compiler that created the implib.
3608899129b3Smrg#
3609899129b3Smrg# Echos the name of the DLL associated with the
3610899129b3Smrg# specified import library.
3611899129b3Smrgfunc_cygming_dll_for_implib_fallback_core ()
3612899129b3Smrg{
3613899129b3Smrg  $opt_debug
3614899129b3Smrg  match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
3615899129b3Smrg  $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
3616899129b3Smrg    $SED '/^Contents of section '"$match_literal"':/{
3617899129b3Smrg      # Place marker at beginning of archive member dllname section
3618899129b3Smrg      s/.*/====MARK====/
3619899129b3Smrg      p
3620899129b3Smrg      d
3621899129b3Smrg    }
3622899129b3Smrg    # These lines can sometimes be longer than 43 characters, but
3623899129b3Smrg    # are always uninteresting
3624899129b3Smrg    /:[	 ]*file format pe[i]\{,1\}-/d
3625899129b3Smrg    /^In archive [^:]*:/d
3626899129b3Smrg    # Ensure marker is printed
3627899129b3Smrg    /^====MARK====/p
3628899129b3Smrg    # Remove all lines with less than 43 characters
3629899129b3Smrg    /^.\{43\}/!d
3630899129b3Smrg    # From remaining lines, remove first 43 characters
3631899129b3Smrg    s/^.\{43\}//' |
3632899129b3Smrg    $SED -n '
3633899129b3Smrg      # Join marker and all lines until next marker into a single line
3634899129b3Smrg      /^====MARK====/ b para
3635899129b3Smrg      H
3636899129b3Smrg      $ b para
3637899129b3Smrg      b
3638899129b3Smrg      :para
3639899129b3Smrg      x
3640899129b3Smrg      s/\n//g
3641899129b3Smrg      # Remove the marker
3642899129b3Smrg      s/^====MARK====//
3643899129b3Smrg      # Remove trailing dots and whitespace
3644899129b3Smrg      s/[\. \t]*$//
3645899129b3Smrg      # Print
3646899129b3Smrg      /./p' |
3647899129b3Smrg    # we now have a list, one entry per line, of the stringified
3648899129b3Smrg    # contents of the appropriate section of all members of the
3649899129b3Smrg    # archive which possess that section. Heuristic: eliminate
3650899129b3Smrg    # all those which have a first or second character that is
3651899129b3Smrg    # a '.' (that is, objdump's representation of an unprintable
3652899129b3Smrg    # character.) This should work for all archives with less than
3653899129b3Smrg    # 0x302f exports -- but will fail for DLLs whose name actually
3654899129b3Smrg    # begins with a literal '.' or a single character followed by
3655899129b3Smrg    # a '.'.
3656899129b3Smrg    #
3657899129b3Smrg    # Of those that remain, print the first one.
3658899129b3Smrg    $SED -e '/^\./d;/^.\./d;q'
3659899129b3Smrg}
3660899129b3Smrg
3661899129b3Smrg# func_cygming_gnu_implib_p ARG
3662899129b3Smrg# This predicate returns with zero status (TRUE) if
3663899129b3Smrg# ARG is a GNU/binutils-style import library. Returns
3664899129b3Smrg# with nonzero status (FALSE) otherwise.
3665899129b3Smrgfunc_cygming_gnu_implib_p ()
3666899129b3Smrg{
3667899129b3Smrg  $opt_debug
3668899129b3Smrg  func_to_tool_file "$1" func_convert_file_msys_to_w32
3669899129b3Smrg  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)$'`
3670899129b3Smrg  test -n "$func_cygming_gnu_implib_tmp"
3671899129b3Smrg}
3672899129b3Smrg
3673899129b3Smrg# func_cygming_ms_implib_p ARG
3674899129b3Smrg# This predicate returns with zero status (TRUE) if
3675899129b3Smrg# ARG is an MS-style import library. Returns
3676899129b3Smrg# with nonzero status (FALSE) otherwise.
3677899129b3Smrgfunc_cygming_ms_implib_p ()
3678899129b3Smrg{
3679899129b3Smrg  $opt_debug
3680899129b3Smrg  func_to_tool_file "$1" func_convert_file_msys_to_w32
3681899129b3Smrg  func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
3682899129b3Smrg  test -n "$func_cygming_ms_implib_tmp"
3683899129b3Smrg}
3684899129b3Smrg
3685899129b3Smrg# func_cygming_dll_for_implib_fallback ARG
3686899129b3Smrg# Platform-specific function to extract the
3687899129b3Smrg# name of the DLL associated with the specified
3688899129b3Smrg# import library ARG.
3689899129b3Smrg#
3690899129b3Smrg# This fallback implementation is for use when $DLLTOOL
3691899129b3Smrg# does not support the --identify-strict option.
3692899129b3Smrg# Invoked by eval'ing the libtool variable
3693899129b3Smrg#    $sharedlib_from_linklib_cmd
3694899129b3Smrg# Result is available in the variable
3695899129b3Smrg#    $sharedlib_from_linklib_result
3696899129b3Smrgfunc_cygming_dll_for_implib_fallback ()
3697899129b3Smrg{
3698899129b3Smrg  $opt_debug
3699899129b3Smrg  if func_cygming_gnu_implib_p "$1" ; then
3700899129b3Smrg    # binutils import library
3701899129b3Smrg    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
3702899129b3Smrg  elif func_cygming_ms_implib_p "$1" ; then
3703899129b3Smrg    # ms-generated import library
3704899129b3Smrg    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
3705899129b3Smrg  else
3706899129b3Smrg    # unknown
3707899129b3Smrg    sharedlib_from_linklib_result=""
3708899129b3Smrg  fi
3709899129b3Smrg}
3710bd1da9d7Smrg
3711bd1da9d7Smrg
371247e89262Smrg# func_extract_an_archive dir oldlib
371347e89262Smrgfunc_extract_an_archive ()
371447e89262Smrg{
371547e89262Smrg    $opt_debug
371647e89262Smrg    f_ex_an_ar_dir="$1"; shift
371747e89262Smrg    f_ex_an_ar_oldlib="$1"
371847e89262Smrg    if test "$lock_old_archive_extraction" = yes; then
371947e89262Smrg      lockfile=$f_ex_an_ar_oldlib.lock
372047e89262Smrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
372147e89262Smrg	func_echo "Waiting for $lockfile to be removed"
372247e89262Smrg	sleep 2
372347e89262Smrg      done
372447e89262Smrg    fi
372547e89262Smrg    func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
372647e89262Smrg		   'stat=$?; rm -f "$lockfile"; exit $stat'
372747e89262Smrg    if test "$lock_old_archive_extraction" = yes; then
372847e89262Smrg      $opt_dry_run || rm -f "$lockfile"
372947e89262Smrg    fi
373047e89262Smrg    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
373147e89262Smrg     :
373247e89262Smrg    else
373347e89262Smrg      func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
373447e89262Smrg    fi
373547e89262Smrg}
3736bd1da9d7Smrg
3737bd1da9d7Smrg
373847e89262Smrg# func_extract_archives gentop oldlib ...
373947e89262Smrgfunc_extract_archives ()
374047e89262Smrg{
374147e89262Smrg    $opt_debug
374247e89262Smrg    my_gentop="$1"; shift
374347e89262Smrg    my_oldlibs=${1+"$@"}
374447e89262Smrg    my_oldobjs=""
374547e89262Smrg    my_xlib=""
374647e89262Smrg    my_xabs=""
374747e89262Smrg    my_xdir=""
3748bd1da9d7Smrg
374947e89262Smrg    for my_xlib in $my_oldlibs; do
375047e89262Smrg      # Extract the objects.
375147e89262Smrg      case $my_xlib in
375247e89262Smrg	[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
375347e89262Smrg	*) my_xabs=`pwd`"/$my_xlib" ;;
375447e89262Smrg      esac
375547e89262Smrg      func_basename "$my_xlib"
375647e89262Smrg      my_xlib="$func_basename_result"
375747e89262Smrg      my_xlib_u=$my_xlib
375847e89262Smrg      while :; do
375947e89262Smrg        case " $extracted_archives " in
376047e89262Smrg	*" $my_xlib_u "*)
376147e89262Smrg	  func_arith $extracted_serial + 1
376247e89262Smrg	  extracted_serial=$func_arith_result
376347e89262Smrg	  my_xlib_u=lt$extracted_serial-$my_xlib ;;
376447e89262Smrg	*) break ;;
376547e89262Smrg	esac
376647e89262Smrg      done
376747e89262Smrg      extracted_archives="$extracted_archives $my_xlib_u"
376847e89262Smrg      my_xdir="$my_gentop/$my_xlib_u"
3769bd1da9d7Smrg
377047e89262Smrg      func_mkdir_p "$my_xdir"
377147e89262Smrg
377247e89262Smrg      case $host in
377347e89262Smrg      *-darwin*)
377447e89262Smrg	func_verbose "Extracting $my_xabs"
377547e89262Smrg	# Do not bother doing anything if just a dry run
377647e89262Smrg	$opt_dry_run || {
377747e89262Smrg	  darwin_orig_dir=`pwd`
377847e89262Smrg	  cd $my_xdir || exit $?
377947e89262Smrg	  darwin_archive=$my_xabs
378047e89262Smrg	  darwin_curdir=`pwd`
378147e89262Smrg	  darwin_base_archive=`basename "$darwin_archive"`
378247e89262Smrg	  darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
378347e89262Smrg	  if test -n "$darwin_arches"; then
378447e89262Smrg	    darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
378547e89262Smrg	    darwin_arch=
378647e89262Smrg	    func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
378747e89262Smrg	    for darwin_arch in  $darwin_arches ; do
378847e89262Smrg	      func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
378947e89262Smrg	      $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
379047e89262Smrg	      cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
379147e89262Smrg	      func_extract_an_archive "`pwd`" "${darwin_base_archive}"
379247e89262Smrg	      cd "$darwin_curdir"
379347e89262Smrg	      $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
379447e89262Smrg	    done # $darwin_arches
379547e89262Smrg            ## Okay now we've a bunch of thin objects, gotta fatten them up :)
379647e89262Smrg	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u`
379747e89262Smrg	    darwin_file=
379847e89262Smrg	    darwin_files=
379947e89262Smrg	    for darwin_file in $darwin_filelist; do
380047e89262Smrg	      darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`
380147e89262Smrg	      $LIPO -create -output "$darwin_file" $darwin_files
380247e89262Smrg	    done # $darwin_filelist
380347e89262Smrg	    $RM -rf unfat-$$
380447e89262Smrg	    cd "$darwin_orig_dir"
3805bd1da9d7Smrg	  else
380647e89262Smrg	    cd $darwin_orig_dir
380747e89262Smrg	    func_extract_an_archive "$my_xdir" "$my_xabs"
380847e89262Smrg	  fi # $darwin_arches
380947e89262Smrg	} # !$opt_dry_run
381047e89262Smrg	;;
381147e89262Smrg      *)
381247e89262Smrg        func_extract_an_archive "$my_xdir" "$my_xabs"
381347e89262Smrg	;;
381447e89262Smrg      esac
381547e89262Smrg      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
381647e89262Smrg    done
3817bd1da9d7Smrg
381847e89262Smrg    func_extract_archives_result="$my_oldobjs"
381947e89262Smrg}
3820bd1da9d7Smrg
3821bd1da9d7Smrg
382247e89262Smrg# func_emit_wrapper [arg=no]
382347e89262Smrg#
382447e89262Smrg# Emit a libtool wrapper script on stdout.
382547e89262Smrg# Don't directly open a file because we may want to
382647e89262Smrg# incorporate the script contents within a cygwin/mingw
382747e89262Smrg# wrapper executable.  Must ONLY be called from within
382847e89262Smrg# func_mode_link because it depends on a number of variables
382947e89262Smrg# set therein.
383047e89262Smrg#
383147e89262Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
383247e89262Smrg# variable will take.  If 'yes', then the emitted script
383347e89262Smrg# will assume that the directory in which it is stored is
383447e89262Smrg# the $objdir directory.  This is a cygwin/mingw-specific
383547e89262Smrg# behavior.
383647e89262Smrgfunc_emit_wrapper ()
383747e89262Smrg{
383847e89262Smrg	func_emit_wrapper_arg1=${1-no}
3839bd1da9d7Smrg
384047e89262Smrg	$ECHO "\
384147e89262Smrg#! $SHELL
3842bd1da9d7Smrg
384347e89262Smrg# $output - temporary wrapper script for $objdir/$outputname
384447e89262Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
384547e89262Smrg#
384647e89262Smrg# The $output program cannot be directly executed until all the libtool
384747e89262Smrg# libraries that it depends on are installed.
384847e89262Smrg#
384947e89262Smrg# This wrapper script should never be moved out of the build directory.
385047e89262Smrg# If it is, it will not operate correctly.
3851bd1da9d7Smrg
385247e89262Smrg# Sed substitution that helps us do robust quoting.  It backslashifies
385347e89262Smrg# metacharacters that are still active within double-quoted strings.
385447e89262Smrgsed_quote_subst='$sed_quote_subst'
3855bd1da9d7Smrg
385647e89262Smrg# Be Bourne compatible
385747e89262Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
385847e89262Smrg  emulate sh
385947e89262Smrg  NULLCMD=:
386047e89262Smrg  # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
386147e89262Smrg  # is contrary to our usage.  Disable this feature.
386247e89262Smrg  alias -g '\${1+\"\$@\"}'='\"\$@\"'
386347e89262Smrg  setopt NO_GLOB_SUBST
386447e89262Smrgelse
386547e89262Smrg  case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
386647e89262Smrgfi
386747e89262SmrgBIN_SH=xpg4; export BIN_SH # for Tru64
386847e89262SmrgDUALCASE=1; export DUALCASE # for MKS sh
3869bd1da9d7Smrg
387047e89262Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout
387147e89262Smrg# if CDPATH is set.
387247e89262Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
3873bd1da9d7Smrg
387447e89262Smrgrelink_command=\"$relink_command\"
3875bd1da9d7Smrg
387647e89262Smrg# This environment variable determines our operation mode.
387747e89262Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then
387847e89262Smrg  # install mode needs the following variables:
387947e89262Smrg  generated_by_libtool_version='$macro_version'
388047e89262Smrg  notinst_deplibs='$notinst_deplibs'
388147e89262Smrgelse
388247e89262Smrg  # When we are sourced in execute mode, \$file and \$ECHO are already set.
388347e89262Smrg  if test \"\$libtool_execute_magic\" != \"$magic\"; then
388447e89262Smrg    file=\"\$0\""
3885bd1da9d7Smrg
388647e89262Smrg    qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"`
388747e89262Smrg    $ECHO "\
3888bd1da9d7Smrg
388947e89262Smrg# A function that is used when there is no print builtin or printf.
389047e89262Smrgfunc_fallback_echo ()
389147e89262Smrg{
389247e89262Smrg  eval 'cat <<_LTECHO_EOF
389347e89262Smrg\$1
389447e89262Smrg_LTECHO_EOF'
389547e89262Smrg}
389647e89262Smrg    ECHO=\"$qECHO\"
389747e89262Smrg  fi
389847e89262Smrg
389947e89262Smrg# Very basic option parsing. These options are (a) specific to
390047e89262Smrg# the libtool wrapper, (b) are identical between the wrapper
390147e89262Smrg# /script/ and the wrapper /executable/ which is used only on
390247e89262Smrg# windows platforms, and (c) all begin with the string "--lt-"
390347e89262Smrg# (application programs are unlikely to have options which match
390447e89262Smrg# this pattern).
390547e89262Smrg#
390647e89262Smrg# There are only two supported options: --lt-debug and
390747e89262Smrg# --lt-dump-script. There is, deliberately, no --lt-help.
390847e89262Smrg#
390947e89262Smrg# The first argument to this parsing function should be the
391047e89262Smrg# script's $0 value, followed by "$@".
391147e89262Smrglt_option_debug=
391247e89262Smrgfunc_parse_lt_options ()
391347e89262Smrg{
391447e89262Smrg  lt_script_arg0=\$0
391547e89262Smrg  shift
391647e89262Smrg  for lt_opt
391747e89262Smrg  do
391847e89262Smrg    case \"\$lt_opt\" in
391947e89262Smrg    --lt-debug) lt_option_debug=1 ;;
392047e89262Smrg    --lt-dump-script)
392147e89262Smrg        lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
392247e89262Smrg        test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
392347e89262Smrg        lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
392447e89262Smrg        cat \"\$lt_dump_D/\$lt_dump_F\"
392547e89262Smrg        exit 0
392647e89262Smrg      ;;
392747e89262Smrg    --lt-*)
392847e89262Smrg        \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
392947e89262Smrg        exit 1
3930bd1da9d7Smrg      ;;
393147e89262Smrg    esac
393247e89262Smrg  done
3933bd1da9d7Smrg
393447e89262Smrg  # Print the debug banner immediately:
393547e89262Smrg  if test -n \"\$lt_option_debug\"; then
393647e89262Smrg    echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2
393747e89262Smrg  fi
393847e89262Smrg}
3939bd1da9d7Smrg
394047e89262Smrg# Used when --lt-debug. Prints its arguments to stdout
394147e89262Smrg# (redirection is the responsibility of the caller)
394247e89262Smrgfunc_lt_dump_args ()
394347e89262Smrg{
394447e89262Smrg  lt_dump_args_N=1;
394547e89262Smrg  for lt_arg
394647e89262Smrg  do
394747e89262Smrg    \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\"
394847e89262Smrg    lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
394947e89262Smrg  done
395047e89262Smrg}
3951bd1da9d7Smrg
395247e89262Smrg# Core function for launching the target application
395347e89262Smrgfunc_exec_program_core ()
395447e89262Smrg{
395547e89262Smrg"
395647e89262Smrg  case $host in
395747e89262Smrg  # Backslashes separate directories on plain windows
395847e89262Smrg  *-*-mingw | *-*-os2* | *-cegcc*)
395947e89262Smrg    $ECHO "\
396047e89262Smrg      if test -n \"\$lt_option_debug\"; then
396147e89262Smrg        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2
396247e89262Smrg        func_lt_dump_args \${1+\"\$@\"} 1>&2
3963bd1da9d7Smrg      fi
396447e89262Smrg      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
396547e89262Smrg"
396647e89262Smrg    ;;
3967bd1da9d7Smrg
396847e89262Smrg  *)
396947e89262Smrg    $ECHO "\
397047e89262Smrg      if test -n \"\$lt_option_debug\"; then
397147e89262Smrg        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2
397247e89262Smrg        func_lt_dump_args \${1+\"\$@\"} 1>&2
3973bd1da9d7Smrg      fi
397447e89262Smrg      exec \"\$progdir/\$program\" \${1+\"\$@\"}
397547e89262Smrg"
397647e89262Smrg    ;;
397747e89262Smrg  esac
397847e89262Smrg  $ECHO "\
397947e89262Smrg      \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
398047e89262Smrg      exit 1
398147e89262Smrg}
3982bd1da9d7Smrg
398347e89262Smrg# A function to encapsulate launching the target application
398447e89262Smrg# Strips options in the --lt-* namespace from \$@ and
398547e89262Smrg# launches target application with the remaining arguments.
398647e89262Smrgfunc_exec_program ()
398747e89262Smrg{
3988899129b3Smrg  case \" \$* \" in
3989899129b3Smrg  *\\ --lt-*)
3990899129b3Smrg    for lt_wr_arg
3991899129b3Smrg    do
3992899129b3Smrg      case \$lt_wr_arg in
3993899129b3Smrg      --lt-*) ;;
3994899129b3Smrg      *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
3995899129b3Smrg      esac
3996899129b3Smrg      shift
3997899129b3Smrg    done ;;
3998899129b3Smrg  esac
399947e89262Smrg  func_exec_program_core \${1+\"\$@\"}
400047e89262Smrg}
4001bd1da9d7Smrg
400247e89262Smrg  # Parse options
400347e89262Smrg  func_parse_lt_options \"\$0\" \${1+\"\$@\"}
4004bd1da9d7Smrg
400547e89262Smrg  # Find the directory that this script lives in.
400647e89262Smrg  thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
400747e89262Smrg  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
4008bd1da9d7Smrg
400947e89262Smrg  # Follow symbolic links until we get to the real thisdir.
401047e89262Smrg  file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
401147e89262Smrg  while test -n \"\$file\"; do
401247e89262Smrg    destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
4013bd1da9d7Smrg
401447e89262Smrg    # If there was a directory component, then change thisdir.
401547e89262Smrg    if test \"x\$destdir\" != \"x\$file\"; then
401647e89262Smrg      case \"\$destdir\" in
401747e89262Smrg      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
401847e89262Smrg      *) thisdir=\"\$thisdir/\$destdir\" ;;
401947e89262Smrg      esac
402047e89262Smrg    fi
4021bd1da9d7Smrg
402247e89262Smrg    file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
402347e89262Smrg    file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
402447e89262Smrg  done
4025bd1da9d7Smrg
402647e89262Smrg  # Usually 'no', except on cygwin/mingw when embedded into
402747e89262Smrg  # the cwrapper.
402847e89262Smrg  WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
402947e89262Smrg  if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
403047e89262Smrg    # special case for '.'
403147e89262Smrg    if test \"\$thisdir\" = \".\"; then
403247e89262Smrg      thisdir=\`pwd\`
403347e89262Smrg    fi
403447e89262Smrg    # remove .libs from thisdir
403547e89262Smrg    case \"\$thisdir\" in
403647e89262Smrg    *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
403747e89262Smrg    $objdir )   thisdir=. ;;
403847e89262Smrg    esac
403947e89262Smrg  fi
4040bd1da9d7Smrg
404147e89262Smrg  # Try to get the absolute directory name.
404247e89262Smrg  absdir=\`cd \"\$thisdir\" && pwd\`
404347e89262Smrg  test -n \"\$absdir\" && thisdir=\"\$absdir\"
404447e89262Smrg"
4045bd1da9d7Smrg
404647e89262Smrg	if test "$fast_install" = yes; then
404747e89262Smrg	  $ECHO "\
404847e89262Smrg  program=lt-'$outputname'$exeext
404947e89262Smrg  progdir=\"\$thisdir/$objdir\"
4050bd1da9d7Smrg
405147e89262Smrg  if test ! -f \"\$progdir/\$program\" ||
405247e89262Smrg     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
405347e89262Smrg       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
4054bd1da9d7Smrg
405547e89262Smrg    file=\"\$\$-\$program\"
4056bd1da9d7Smrg
405747e89262Smrg    if test ! -d \"\$progdir\"; then
405847e89262Smrg      $MKDIR \"\$progdir\"
405947e89262Smrg    else
406047e89262Smrg      $RM \"\$progdir/\$file\"
406147e89262Smrg    fi"
4062bd1da9d7Smrg
406347e89262Smrg	  $ECHO "\
4064bd1da9d7Smrg
406547e89262Smrg    # relink executable if necessary
406647e89262Smrg    if test -n \"\$relink_command\"; then
406747e89262Smrg      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
406847e89262Smrg      else
406947e89262Smrg	$ECHO \"\$relink_command_output\" >&2
407047e89262Smrg	$RM \"\$progdir/\$file\"
407147e89262Smrg	exit 1
407247e89262Smrg      fi
407347e89262Smrg    fi
4074bd1da9d7Smrg
407547e89262Smrg    $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
407647e89262Smrg    { $RM \"\$progdir/\$program\";
407747e89262Smrg      $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
407847e89262Smrg    $RM \"\$progdir/\$file\"
407947e89262Smrg  fi"
408047e89262Smrg	else
408147e89262Smrg	  $ECHO "\
408247e89262Smrg  program='$outputname'
408347e89262Smrg  progdir=\"\$thisdir/$objdir\"
408447e89262Smrg"
408547e89262Smrg	fi
4086bd1da9d7Smrg
408747e89262Smrg	$ECHO "\
4088bd1da9d7Smrg
408947e89262Smrg  if test -f \"\$progdir/\$program\"; then"
4090bd1da9d7Smrg
4091899129b3Smrg	# fixup the dll searchpath if we need to.
4092899129b3Smrg	#
4093899129b3Smrg	# Fix the DLL searchpath if we need to.  Do this before prepending
4094899129b3Smrg	# to shlibpath, because on Windows, both are PATH and uninstalled
4095899129b3Smrg	# libraries must come first.
4096899129b3Smrg	if test -n "$dllsearchpath"; then
4097899129b3Smrg	  $ECHO "\
4098899129b3Smrg    # Add the dll search path components to the executable PATH
4099899129b3Smrg    PATH=$dllsearchpath:\$PATH
4100899129b3Smrg"
4101899129b3Smrg	fi
4102899129b3Smrg
410347e89262Smrg	# Export our shlibpath_var if we have one.
410447e89262Smrg	if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
410547e89262Smrg	  $ECHO "\
410647e89262Smrg    # Add our own library path to $shlibpath_var
410747e89262Smrg    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
4108bd1da9d7Smrg
410947e89262Smrg    # Some systems cannot cope with colon-terminated $shlibpath_var
411047e89262Smrg    # The second colon is a workaround for a bug in BeOS R4 sed
411147e89262Smrg    $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
4112bd1da9d7Smrg
411347e89262Smrg    export $shlibpath_var
411447e89262Smrg"
411547e89262Smrg	fi
4116bd1da9d7Smrg
411747e89262Smrg	$ECHO "\
411847e89262Smrg    if test \"\$libtool_execute_magic\" != \"$magic\"; then
411947e89262Smrg      # Run the actual program with our arguments.
412047e89262Smrg      func_exec_program \${1+\"\$@\"}
412147e89262Smrg    fi
412247e89262Smrg  else
412347e89262Smrg    # The program doesn't exist.
412447e89262Smrg    \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
412547e89262Smrg    \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
412647e89262Smrg    \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
412747e89262Smrg    exit 1
412847e89262Smrg  fi
412947e89262Smrgfi\
413047e89262Smrg"
413147e89262Smrg}
4132bd1da9d7Smrg
4133bd1da9d7Smrg
413447e89262Smrg# func_emit_cwrapperexe_src
413547e89262Smrg# emit the source code for a wrapper executable on stdout
413647e89262Smrg# Must ONLY be called from within func_mode_link because
413747e89262Smrg# it depends on a number of variable set therein.
413847e89262Smrgfunc_emit_cwrapperexe_src ()
413947e89262Smrg{
414047e89262Smrg	cat <<EOF
4141bd1da9d7Smrg
414247e89262Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
414347e89262Smrg   Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
4144bd1da9d7Smrg
414547e89262Smrg   The $output program cannot be directly executed until all the libtool
414647e89262Smrg   libraries that it depends on are installed.
4147bd1da9d7Smrg
414847e89262Smrg   This wrapper executable should never be moved out of the build directory.
414947e89262Smrg   If it is, it will not operate correctly.
415047e89262Smrg*/
415147e89262SmrgEOF
415247e89262Smrg	    cat <<"EOF"
415347e89262Smrg#ifdef _MSC_VER
415447e89262Smrg# define _CRT_SECURE_NO_DEPRECATE 1
415547e89262Smrg#endif
415647e89262Smrg#include <stdio.h>
415747e89262Smrg#include <stdlib.h>
415847e89262Smrg#ifdef _MSC_VER
415947e89262Smrg# include <direct.h>
416047e89262Smrg# include <process.h>
416147e89262Smrg# include <io.h>
416247e89262Smrg#else
416347e89262Smrg# include <unistd.h>
416447e89262Smrg# include <stdint.h>
416547e89262Smrg# ifdef __CYGWIN__
416647e89262Smrg#  include <io.h>
416747e89262Smrg# endif
416847e89262Smrg#endif
416947e89262Smrg#include <malloc.h>
417047e89262Smrg#include <stdarg.h>
417147e89262Smrg#include <assert.h>
417247e89262Smrg#include <string.h>
417347e89262Smrg#include <ctype.h>
417447e89262Smrg#include <errno.h>
417547e89262Smrg#include <fcntl.h>
417647e89262Smrg#include <sys/stat.h>
4177bd1da9d7Smrg
417847e89262Smrg/* declarations of non-ANSI functions */
417947e89262Smrg#if defined(__MINGW32__)
418047e89262Smrg# ifdef __STRICT_ANSI__
418147e89262Smrgint _putenv (const char *);
418247e89262Smrg# endif
418347e89262Smrg#elif defined(__CYGWIN__)
418447e89262Smrg# ifdef __STRICT_ANSI__
418547e89262Smrgchar *realpath (const char *, char *);
418647e89262Smrgint putenv (char *);
418747e89262Smrgint setenv (const char *, const char *, int);
418847e89262Smrg# endif
418947e89262Smrg/* #elif defined (other platforms) ... */
419047e89262Smrg#endif
4191bd1da9d7Smrg
419247e89262Smrg/* portability defines, excluding path handling macros */
419347e89262Smrg#if defined(_MSC_VER)
419447e89262Smrg# define setmode _setmode
419547e89262Smrg# define stat    _stat
419647e89262Smrg# define chmod   _chmod
419747e89262Smrg# define getcwd  _getcwd
419847e89262Smrg# define putenv  _putenv
419947e89262Smrg# define S_IXUSR _S_IEXEC
420047e89262Smrg# ifndef _INTPTR_T_DEFINED
420147e89262Smrg#  define _INTPTR_T_DEFINED
420247e89262Smrg#  define intptr_t int
420347e89262Smrg# endif
420447e89262Smrg#elif defined(__MINGW32__)
420547e89262Smrg# define setmode _setmode
420647e89262Smrg# define stat    _stat
420747e89262Smrg# define chmod   _chmod
420847e89262Smrg# define getcwd  _getcwd
420947e89262Smrg# define putenv  _putenv
421047e89262Smrg#elif defined(__CYGWIN__)
421147e89262Smrg# define HAVE_SETENV
421247e89262Smrg# define FOPEN_WB "wb"
421347e89262Smrg/* #elif defined (other platforms) ... */
421447e89262Smrg#endif
4215bd1da9d7Smrg
421647e89262Smrg#if defined(PATH_MAX)
421747e89262Smrg# define LT_PATHMAX PATH_MAX
421847e89262Smrg#elif defined(MAXPATHLEN)
421947e89262Smrg# define LT_PATHMAX MAXPATHLEN
422047e89262Smrg#else
422147e89262Smrg# define LT_PATHMAX 1024
422247e89262Smrg#endif
4223bd1da9d7Smrg
422447e89262Smrg#ifndef S_IXOTH
422547e89262Smrg# define S_IXOTH 0
422647e89262Smrg#endif
422747e89262Smrg#ifndef S_IXGRP
422847e89262Smrg# define S_IXGRP 0
422947e89262Smrg#endif
4230bd1da9d7Smrg
423147e89262Smrg/* path handling portability macros */
423247e89262Smrg#ifndef DIR_SEPARATOR
423347e89262Smrg# define DIR_SEPARATOR '/'
423447e89262Smrg# define PATH_SEPARATOR ':'
423547e89262Smrg#endif
4236bd1da9d7Smrg
423747e89262Smrg#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
423847e89262Smrg  defined (__OS2__)
423947e89262Smrg# define HAVE_DOS_BASED_FILE_SYSTEM
424047e89262Smrg# define FOPEN_WB "wb"
424147e89262Smrg# ifndef DIR_SEPARATOR_2
424247e89262Smrg#  define DIR_SEPARATOR_2 '\\'
424347e89262Smrg# endif
424447e89262Smrg# ifndef PATH_SEPARATOR_2
424547e89262Smrg#  define PATH_SEPARATOR_2 ';'
424647e89262Smrg# endif
424747e89262Smrg#endif
4248bd1da9d7Smrg
424947e89262Smrg#ifndef DIR_SEPARATOR_2
425047e89262Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
425147e89262Smrg#else /* DIR_SEPARATOR_2 */
425247e89262Smrg# define IS_DIR_SEPARATOR(ch) \
425347e89262Smrg	(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
425447e89262Smrg#endif /* DIR_SEPARATOR_2 */
4255bd1da9d7Smrg
425647e89262Smrg#ifndef PATH_SEPARATOR_2
425747e89262Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
425847e89262Smrg#else /* PATH_SEPARATOR_2 */
425947e89262Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
426047e89262Smrg#endif /* PATH_SEPARATOR_2 */
426147e89262Smrg
426247e89262Smrg#ifndef FOPEN_WB
426347e89262Smrg# define FOPEN_WB "w"
426447e89262Smrg#endif
426547e89262Smrg#ifndef _O_BINARY
426647e89262Smrg# define _O_BINARY 0
426747e89262Smrg#endif
426847e89262Smrg
426947e89262Smrg#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
427047e89262Smrg#define XFREE(stale) do { \
427147e89262Smrg  if (stale) { free ((void *) stale); stale = 0; } \
427247e89262Smrg} while (0)
427347e89262Smrg
427447e89262Smrg#if defined(LT_DEBUGWRAPPER)
427547e89262Smrgstatic int lt_debug = 1;
427647e89262Smrg#else
427747e89262Smrgstatic int lt_debug = 0;
427847e89262Smrg#endif
427947e89262Smrg
428047e89262Smrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */
428147e89262Smrg
428247e89262Smrgvoid *xmalloc (size_t num);
428347e89262Smrgchar *xstrdup (const char *string);
428447e89262Smrgconst char *base_name (const char *name);
428547e89262Smrgchar *find_executable (const char *wrapper);
428647e89262Smrgchar *chase_symlinks (const char *pathspec);
428747e89262Smrgint make_executable (const char *path);
428847e89262Smrgint check_executable (const char *path);
428947e89262Smrgchar *strendzap (char *str, const char *pat);
429047e89262Smrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...);
429147e89262Smrgvoid lt_fatal (const char *file, int line, const char *message, ...);
429247e89262Smrgstatic const char *nonnull (const char *s);
429347e89262Smrgstatic const char *nonempty (const char *s);
429447e89262Smrgvoid lt_setenv (const char *name, const char *value);
429547e89262Smrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end);
429647e89262Smrgvoid lt_update_exe_path (const char *name, const char *value);
429747e89262Smrgvoid lt_update_lib_path (const char *name, const char *value);
429847e89262Smrgchar **prepare_spawn (char **argv);
429947e89262Smrgvoid lt_dump_script (FILE *f);
430047e89262SmrgEOF
430147e89262Smrg
430247e89262Smrg	    cat <<EOF
4303899129b3Smrgvolatile const char * MAGIC_EXE = "$magic_exe";
430447e89262Smrgconst char * LIB_PATH_VARNAME = "$shlibpath_var";
430547e89262SmrgEOF
430647e89262Smrg
430747e89262Smrg	    if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
4308899129b3Smrg              func_to_host_path "$temp_rpath"
430947e89262Smrg	      cat <<EOF
4310899129b3Smrgconst char * LIB_PATH_VALUE   = "$func_to_host_path_result";
4311bd1da9d7SmrgEOF
4312bd1da9d7Smrg	    else
431347e89262Smrg	      cat <<"EOF"
431447e89262Smrgconst char * LIB_PATH_VALUE   = "";
431547e89262SmrgEOF
4316bd1da9d7Smrg	    fi
431747e89262Smrg
431847e89262Smrg	    if test -n "$dllsearchpath"; then
4319899129b3Smrg              func_to_host_path "$dllsearchpath:"
432047e89262Smrg	      cat <<EOF
432147e89262Smrgconst char * EXE_PATH_VARNAME = "PATH";
4322899129b3Smrgconst char * EXE_PATH_VALUE   = "$func_to_host_path_result";
432347e89262SmrgEOF
4324bd1da9d7Smrg	    else
432547e89262Smrg	      cat <<"EOF"
432647e89262Smrgconst char * EXE_PATH_VARNAME = "";
432747e89262Smrgconst char * EXE_PATH_VALUE   = "";
432847e89262SmrgEOF
4329bd1da9d7Smrg	    fi
433047e89262Smrg
433147e89262Smrg	    if test "$fast_install" = yes; then
433247e89262Smrg	      cat <<EOF
433347e89262Smrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
433447e89262SmrgEOF
4335bd1da9d7Smrg	    else
433647e89262Smrg	      cat <<EOF
433747e89262Smrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
433847e89262SmrgEOF
4339bd1da9d7Smrg	    fi
4340bd1da9d7Smrg
4341bd1da9d7Smrg
434247e89262Smrg	    cat <<"EOF"
4343bd1da9d7Smrg
434447e89262Smrg#define LTWRAPPER_OPTION_PREFIX         "--lt-"
4345bd1da9d7Smrg
434647e89262Smrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
434747e89262Smrgstatic const char *dumpscript_opt       = LTWRAPPER_OPTION_PREFIX "dump-script";
434847e89262Smrgstatic const char *debug_opt            = LTWRAPPER_OPTION_PREFIX "debug";
4349bd1da9d7Smrg
435047e89262Smrgint
435147e89262Smrgmain (int argc, char *argv[])
435247e89262Smrg{
435347e89262Smrg  char **newargz;
435447e89262Smrg  int  newargc;
435547e89262Smrg  char *tmp_pathspec;
435647e89262Smrg  char *actual_cwrapper_path;
435747e89262Smrg  char *actual_cwrapper_name;
435847e89262Smrg  char *target_name;
435947e89262Smrg  char *lt_argv_zero;
436047e89262Smrg  intptr_t rval = 127;
4361bd1da9d7Smrg
436247e89262Smrg  int i;
4363bd1da9d7Smrg
436447e89262Smrg  program_name = (char *) xstrdup (base_name (argv[0]));
436547e89262Smrg  newargz = XMALLOC (char *, argc + 1);
4366bd1da9d7Smrg
436747e89262Smrg  /* very simple arg parsing; don't want to rely on getopt
436847e89262Smrg   * also, copy all non cwrapper options to newargz, except
436947e89262Smrg   * argz[0], which is handled differently
437047e89262Smrg   */
437147e89262Smrg  newargc=0;
437247e89262Smrg  for (i = 1; i < argc; i++)
437347e89262Smrg    {
437447e89262Smrg      if (strcmp (argv[i], dumpscript_opt) == 0)
437547e89262Smrg	{
437647e89262SmrgEOF
437747e89262Smrg	    case "$host" in
437847e89262Smrg	      *mingw* | *cygwin* )
437947e89262Smrg		# make stdout use "unix" line endings
438047e89262Smrg		echo "          setmode(1,_O_BINARY);"
438147e89262Smrg		;;
43825bcb6992Smrg	      esac
4383bd1da9d7Smrg
438447e89262Smrg	    cat <<"EOF"
438547e89262Smrg	  lt_dump_script (stdout);
438647e89262Smrg	  return 0;
438747e89262Smrg	}
438847e89262Smrg      if (strcmp (argv[i], debug_opt) == 0)
438947e89262Smrg	{
439047e89262Smrg          lt_debug = 1;
439147e89262Smrg          continue;
439247e89262Smrg	}
439347e89262Smrg      if (strcmp (argv[i], ltwrapper_option_prefix) == 0)
439447e89262Smrg        {
439547e89262Smrg          /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
439647e89262Smrg             namespace, but it is not one of the ones we know about and
439747e89262Smrg             have already dealt with, above (inluding dump-script), then
439847e89262Smrg             report an error. Otherwise, targets might begin to believe
439947e89262Smrg             they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
440047e89262Smrg             namespace. The first time any user complains about this, we'll
440147e89262Smrg             need to make LTWRAPPER_OPTION_PREFIX a configure-time option
440247e89262Smrg             or a configure.ac-settable value.
440347e89262Smrg           */
440447e89262Smrg          lt_fatal (__FILE__, __LINE__,
440547e89262Smrg		    "unrecognized %s option: '%s'",
440647e89262Smrg                    ltwrapper_option_prefix, argv[i]);
440747e89262Smrg        }
440847e89262Smrg      /* otherwise ... */
440947e89262Smrg      newargz[++newargc] = xstrdup (argv[i]);
441047e89262Smrg    }
441147e89262Smrg  newargz[++newargc] = NULL;
4412bd1da9d7Smrg
441347e89262SmrgEOF
441447e89262Smrg	    cat <<EOF
441547e89262Smrg  /* The GNU banner must be the first non-error debug message */
441647e89262Smrg  lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\n");
441747e89262SmrgEOF
441847e89262Smrg	    cat <<"EOF"
441947e89262Smrg  lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
442047e89262Smrg  lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name);
442147e89262Smrg
442247e89262Smrg  tmp_pathspec = find_executable (argv[0]);
442347e89262Smrg  if (tmp_pathspec == NULL)
442447e89262Smrg    lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]);
442547e89262Smrg  lt_debugprintf (__FILE__, __LINE__,
442647e89262Smrg                  "(main) found exe (before symlink chase) at: %s\n",
442747e89262Smrg		  tmp_pathspec);
442847e89262Smrg
442947e89262Smrg  actual_cwrapper_path = chase_symlinks (tmp_pathspec);
443047e89262Smrg  lt_debugprintf (__FILE__, __LINE__,
443147e89262Smrg                  "(main) found exe (after symlink chase) at: %s\n",
443247e89262Smrg		  actual_cwrapper_path);
443347e89262Smrg  XFREE (tmp_pathspec);
443447e89262Smrg
443547e89262Smrg  actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));
443647e89262Smrg  strendzap (actual_cwrapper_path, actual_cwrapper_name);
443747e89262Smrg
443847e89262Smrg  /* wrapper name transforms */
443947e89262Smrg  strendzap (actual_cwrapper_name, ".exe");
444047e89262Smrg  tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
444147e89262Smrg  XFREE (actual_cwrapper_name);
444247e89262Smrg  actual_cwrapper_name = tmp_pathspec;
444347e89262Smrg  tmp_pathspec = 0;
444447e89262Smrg
444547e89262Smrg  /* target_name transforms -- use actual target program name; might have lt- prefix */
444647e89262Smrg  target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
444747e89262Smrg  strendzap (target_name, ".exe");
444847e89262Smrg  tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
444947e89262Smrg  XFREE (target_name);
445047e89262Smrg  target_name = tmp_pathspec;
445147e89262Smrg  tmp_pathspec = 0;
445247e89262Smrg
445347e89262Smrg  lt_debugprintf (__FILE__, __LINE__,
445447e89262Smrg		  "(main) libtool target name: %s\n",
445547e89262Smrg		  target_name);
445647e89262SmrgEOF
4457bd1da9d7Smrg
445847e89262Smrg	    cat <<EOF
445947e89262Smrg  newargz[0] =
446047e89262Smrg    XMALLOC (char, (strlen (actual_cwrapper_path) +
446147e89262Smrg		    strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
446247e89262Smrg  strcpy (newargz[0], actual_cwrapper_path);
446347e89262Smrg  strcat (newargz[0], "$objdir");
446447e89262Smrg  strcat (newargz[0], "/");
446547e89262SmrgEOF
4466bd1da9d7Smrg
446747e89262Smrg	    cat <<"EOF"
446847e89262Smrg  /* stop here, and copy so we don't have to do this twice */
446947e89262Smrg  tmp_pathspec = xstrdup (newargz[0]);
4470bd1da9d7Smrg
447147e89262Smrg  /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
447247e89262Smrg  strcat (newargz[0], actual_cwrapper_name);
4473bd1da9d7Smrg
447447e89262Smrg  /* DO want the lt- prefix here if it exists, so use target_name */
447547e89262Smrg  lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
447647e89262Smrg  XFREE (tmp_pathspec);
447747e89262Smrg  tmp_pathspec = NULL;
447847e89262SmrgEOF
4479bd1da9d7Smrg
448047e89262Smrg	    case $host_os in
448147e89262Smrg	      mingw*)
448247e89262Smrg	    cat <<"EOF"
448347e89262Smrg  {
448447e89262Smrg    char* p;
448547e89262Smrg    while ((p = strchr (newargz[0], '\\')) != NULL)
448647e89262Smrg      {
448747e89262Smrg	*p = '/';
448847e89262Smrg      }
448947e89262Smrg    while ((p = strchr (lt_argv_zero, '\\')) != NULL)
449047e89262Smrg      {
449147e89262Smrg	*p = '/';
449247e89262Smrg      }
449347e89262Smrg  }
449447e89262SmrgEOF
449547e89262Smrg	    ;;
449647e89262Smrg	    esac
4497bd1da9d7Smrg
449847e89262Smrg	    cat <<"EOF"
449947e89262Smrg  XFREE (target_name);
450047e89262Smrg  XFREE (actual_cwrapper_path);
450147e89262Smrg  XFREE (actual_cwrapper_name);
4502bd1da9d7Smrg
450347e89262Smrg  lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
450447e89262Smrg  lt_setenv ("DUALCASE", "1");  /* for MSK sh */
4505899129b3Smrg  /* Update the DLL searchpath.  EXE_PATH_VALUE ($dllsearchpath) must
4506899129b3Smrg     be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath)
4507899129b3Smrg     because on Windows, both *_VARNAMEs are PATH but uninstalled
4508899129b3Smrg     libraries must come first. */
450947e89262Smrg  lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
4510899129b3Smrg  lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
4511bd1da9d7Smrg
451247e89262Smrg  lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",
451347e89262Smrg		  nonnull (lt_argv_zero));
451447e89262Smrg  for (i = 0; i < newargc; i++)
451547e89262Smrg    {
451647e89262Smrg      lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n",
451747e89262Smrg		      i, nonnull (newargz[i]));
451847e89262Smrg    }
4519bd1da9d7Smrg
452047e89262SmrgEOF
4521bd1da9d7Smrg
452247e89262Smrg	    case $host_os in
452347e89262Smrg	      mingw*)
452447e89262Smrg		cat <<"EOF"
452547e89262Smrg  /* execv doesn't actually work on mingw as expected on unix */
452647e89262Smrg  newargz = prepare_spawn (newargz);
452747e89262Smrg  rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
452847e89262Smrg  if (rval == -1)
452947e89262Smrg    {
453047e89262Smrg      /* failed to start process */
453147e89262Smrg      lt_debugprintf (__FILE__, __LINE__,
453247e89262Smrg		      "(main) failed to launch target \"%s\": %s\n",
453347e89262Smrg		      lt_argv_zero, nonnull (strerror (errno)));
453447e89262Smrg      return 127;
453547e89262Smrg    }
453647e89262Smrg  return rval;
453747e89262SmrgEOF
453847e89262Smrg		;;
453947e89262Smrg	      *)
454047e89262Smrg		cat <<"EOF"
454147e89262Smrg  execv (lt_argv_zero, newargz);
454247e89262Smrg  return rval; /* =127, but avoids unused variable warning */
454347e89262SmrgEOF
454447e89262Smrg		;;
454547e89262Smrg	    esac
4546bd1da9d7Smrg
454747e89262Smrg	    cat <<"EOF"
454847e89262Smrg}
4549bd1da9d7Smrg
455047e89262Smrgvoid *
455147e89262Smrgxmalloc (size_t num)
455247e89262Smrg{
455347e89262Smrg  void *p = (void *) malloc (num);
455447e89262Smrg  if (!p)
455547e89262Smrg    lt_fatal (__FILE__, __LINE__, "memory exhausted");
4556bd1da9d7Smrg
455747e89262Smrg  return p;
455847e89262Smrg}
4559bd1da9d7Smrg
456047e89262Smrgchar *
456147e89262Smrgxstrdup (const char *string)
456247e89262Smrg{
456347e89262Smrg  return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
456447e89262Smrg			  string) : NULL;
456547e89262Smrg}
4566bd1da9d7Smrg
456747e89262Smrgconst char *
456847e89262Smrgbase_name (const char *name)
456947e89262Smrg{
457047e89262Smrg  const char *base;
4571bd1da9d7Smrg
457247e89262Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
457347e89262Smrg  /* Skip over the disk name in MSDOS pathnames. */
457447e89262Smrg  if (isalpha ((unsigned char) name[0]) && name[1] == ':')
457547e89262Smrg    name += 2;
457647e89262Smrg#endif
4577bd1da9d7Smrg
457847e89262Smrg  for (base = name; *name; name++)
457947e89262Smrg    if (IS_DIR_SEPARATOR (*name))
458047e89262Smrg      base = name + 1;
458147e89262Smrg  return base;
458247e89262Smrg}
4583bd1da9d7Smrg
458447e89262Smrgint
458547e89262Smrgcheck_executable (const char *path)
458647e89262Smrg{
458747e89262Smrg  struct stat st;
4588bd1da9d7Smrg
458947e89262Smrg  lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n",
459047e89262Smrg                  nonempty (path));
459147e89262Smrg  if ((!path) || (!*path))
459247e89262Smrg    return 0;
4593bd1da9d7Smrg
459447e89262Smrg  if ((stat (path, &st) >= 0)
459547e89262Smrg      && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
459647e89262Smrg    return 1;
459747e89262Smrg  else
459847e89262Smrg    return 0;
459947e89262Smrg}
4600bd1da9d7Smrg
460147e89262Smrgint
460247e89262Smrgmake_executable (const char *path)
460347e89262Smrg{
460447e89262Smrg  int rval = 0;
460547e89262Smrg  struct stat st;
4606bd1da9d7Smrg
460747e89262Smrg  lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n",
460847e89262Smrg                  nonempty (path));
460947e89262Smrg  if ((!path) || (!*path))
461047e89262Smrg    return 0;
4611bd1da9d7Smrg
461247e89262Smrg  if (stat (path, &st) >= 0)
461347e89262Smrg    {
461447e89262Smrg      rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
461547e89262Smrg    }
461647e89262Smrg  return rval;
461747e89262Smrg}
4618bd1da9d7Smrg
461947e89262Smrg/* Searches for the full path of the wrapper.  Returns
462047e89262Smrg   newly allocated full path name if found, NULL otherwise
462147e89262Smrg   Does not chase symlinks, even on platforms that support them.
462247e89262Smrg*/
462347e89262Smrgchar *
462447e89262Smrgfind_executable (const char *wrapper)
462547e89262Smrg{
462647e89262Smrg  int has_slash = 0;
462747e89262Smrg  const char *p;
462847e89262Smrg  const char *p_next;
462947e89262Smrg  /* static buffer for getcwd */
463047e89262Smrg  char tmp[LT_PATHMAX + 1];
463147e89262Smrg  int tmp_len;
463247e89262Smrg  char *concat_name;
4633bd1da9d7Smrg
463447e89262Smrg  lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
463547e89262Smrg                  nonempty (wrapper));
4636bd1da9d7Smrg
463747e89262Smrg  if ((wrapper == NULL) || (*wrapper == '\0'))
463847e89262Smrg    return NULL;
4639bd1da9d7Smrg
464047e89262Smrg  /* Absolute path? */
464147e89262Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
464247e89262Smrg  if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
464347e89262Smrg    {
464447e89262Smrg      concat_name = xstrdup (wrapper);
464547e89262Smrg      if (check_executable (concat_name))
464647e89262Smrg	return concat_name;
464747e89262Smrg      XFREE (concat_name);
464847e89262Smrg    }
464947e89262Smrg  else
465047e89262Smrg    {
465147e89262Smrg#endif
465247e89262Smrg      if (IS_DIR_SEPARATOR (wrapper[0]))
465347e89262Smrg	{
465447e89262Smrg	  concat_name = xstrdup (wrapper);
465547e89262Smrg	  if (check_executable (concat_name))
465647e89262Smrg	    return concat_name;
465747e89262Smrg	  XFREE (concat_name);
465847e89262Smrg	}
465947e89262Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
466047e89262Smrg    }
466147e89262Smrg#endif
4662bd1da9d7Smrg
466347e89262Smrg  for (p = wrapper; *p; p++)
466447e89262Smrg    if (*p == '/')
466547e89262Smrg      {
466647e89262Smrg	has_slash = 1;
466747e89262Smrg	break;
466847e89262Smrg      }
466947e89262Smrg  if (!has_slash)
467047e89262Smrg    {
467147e89262Smrg      /* no slashes; search PATH */
467247e89262Smrg      const char *path = getenv ("PATH");
467347e89262Smrg      if (path != NULL)
467447e89262Smrg	{
467547e89262Smrg	  for (p = path; *p; p = p_next)
467647e89262Smrg	    {
467747e89262Smrg	      const char *q;
467847e89262Smrg	      size_t p_len;
467947e89262Smrg	      for (q = p; *q; q++)
468047e89262Smrg		if (IS_PATH_SEPARATOR (*q))
468147e89262Smrg		  break;
468247e89262Smrg	      p_len = q - p;
468347e89262Smrg	      p_next = (*q == '\0' ? q : q + 1);
468447e89262Smrg	      if (p_len == 0)
468547e89262Smrg		{
468647e89262Smrg		  /* empty path: current directory */
468747e89262Smrg		  if (getcwd (tmp, LT_PATHMAX) == NULL)
468847e89262Smrg		    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
468947e89262Smrg                              nonnull (strerror (errno)));
469047e89262Smrg		  tmp_len = strlen (tmp);
469147e89262Smrg		  concat_name =
469247e89262Smrg		    XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
469347e89262Smrg		  memcpy (concat_name, tmp, tmp_len);
469447e89262Smrg		  concat_name[tmp_len] = '/';
469547e89262Smrg		  strcpy (concat_name + tmp_len + 1, wrapper);
469647e89262Smrg		}
469747e89262Smrg	      else
469847e89262Smrg		{
469947e89262Smrg		  concat_name =
470047e89262Smrg		    XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
470147e89262Smrg		  memcpy (concat_name, p, p_len);
470247e89262Smrg		  concat_name[p_len] = '/';
470347e89262Smrg		  strcpy (concat_name + p_len + 1, wrapper);
470447e89262Smrg		}
470547e89262Smrg	      if (check_executable (concat_name))
470647e89262Smrg		return concat_name;
470747e89262Smrg	      XFREE (concat_name);
470847e89262Smrg	    }
470947e89262Smrg	}
471047e89262Smrg      /* not found in PATH; assume curdir */
471147e89262Smrg    }
471247e89262Smrg  /* Relative path | not found in path: prepend cwd */
471347e89262Smrg  if (getcwd (tmp, LT_PATHMAX) == NULL)
471447e89262Smrg    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
471547e89262Smrg              nonnull (strerror (errno)));
471647e89262Smrg  tmp_len = strlen (tmp);
471747e89262Smrg  concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
471847e89262Smrg  memcpy (concat_name, tmp, tmp_len);
471947e89262Smrg  concat_name[tmp_len] = '/';
472047e89262Smrg  strcpy (concat_name + tmp_len + 1, wrapper);
4721bd1da9d7Smrg
472247e89262Smrg  if (check_executable (concat_name))
472347e89262Smrg    return concat_name;
472447e89262Smrg  XFREE (concat_name);
472547e89262Smrg  return NULL;
472647e89262Smrg}
4727bd1da9d7Smrg
472847e89262Smrgchar *
472947e89262Smrgchase_symlinks (const char *pathspec)
473047e89262Smrg{
473147e89262Smrg#ifndef S_ISLNK
473247e89262Smrg  return xstrdup (pathspec);
473347e89262Smrg#else
473447e89262Smrg  char buf[LT_PATHMAX];
473547e89262Smrg  struct stat s;
473647e89262Smrg  char *tmp_pathspec = xstrdup (pathspec);
473747e89262Smrg  char *p;
473847e89262Smrg  int has_symlinks = 0;
473947e89262Smrg  while (strlen (tmp_pathspec) && !has_symlinks)
474047e89262Smrg    {
474147e89262Smrg      lt_debugprintf (__FILE__, __LINE__,
474247e89262Smrg		      "checking path component for symlinks: %s\n",
474347e89262Smrg		      tmp_pathspec);
474447e89262Smrg      if (lstat (tmp_pathspec, &s) == 0)
474547e89262Smrg	{
474647e89262Smrg	  if (S_ISLNK (s.st_mode) != 0)
474747e89262Smrg	    {
474847e89262Smrg	      has_symlinks = 1;
474947e89262Smrg	      break;
475047e89262Smrg	    }
4751bd1da9d7Smrg
475247e89262Smrg	  /* search backwards for last DIR_SEPARATOR */
475347e89262Smrg	  p = tmp_pathspec + strlen (tmp_pathspec) - 1;
475447e89262Smrg	  while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
475547e89262Smrg	    p--;
475647e89262Smrg	  if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
475747e89262Smrg	    {
475847e89262Smrg	      /* no more DIR_SEPARATORS left */
475947e89262Smrg	      break;
476047e89262Smrg	    }
476147e89262Smrg	  *p = '\0';
476247e89262Smrg	}
476347e89262Smrg      else
476447e89262Smrg	{
476547e89262Smrg	  lt_fatal (__FILE__, __LINE__,
476647e89262Smrg		    "error accessing file \"%s\": %s",
476747e89262Smrg		    tmp_pathspec, nonnull (strerror (errno)));
476847e89262Smrg	}
476947e89262Smrg    }
477047e89262Smrg  XFREE (tmp_pathspec);
4771bd1da9d7Smrg
477247e89262Smrg  if (!has_symlinks)
477347e89262Smrg    {
477447e89262Smrg      return xstrdup (pathspec);
477547e89262Smrg    }
4776bd1da9d7Smrg
477747e89262Smrg  tmp_pathspec = realpath (pathspec, buf);
477847e89262Smrg  if (tmp_pathspec == 0)
477947e89262Smrg    {
478047e89262Smrg      lt_fatal (__FILE__, __LINE__,
478147e89262Smrg		"could not follow symlinks for %s", pathspec);
478247e89262Smrg    }
478347e89262Smrg  return xstrdup (tmp_pathspec);
478447e89262Smrg#endif
478547e89262Smrg}
4786bd1da9d7Smrg
478747e89262Smrgchar *
478847e89262Smrgstrendzap (char *str, const char *pat)
478947e89262Smrg{
479047e89262Smrg  size_t len, patlen;
4791bd1da9d7Smrg
479247e89262Smrg  assert (str != NULL);
479347e89262Smrg  assert (pat != NULL);
4794bd1da9d7Smrg
479547e89262Smrg  len = strlen (str);
479647e89262Smrg  patlen = strlen (pat);
4797bd1da9d7Smrg
479847e89262Smrg  if (patlen <= len)
479947e89262Smrg    {
480047e89262Smrg      str += len - patlen;
480147e89262Smrg      if (strcmp (str, pat) == 0)
480247e89262Smrg	*str = '\0';
480347e89262Smrg    }
480447e89262Smrg  return str;
480547e89262Smrg}
4806bd1da9d7Smrg
480747e89262Smrgvoid
480847e89262Smrglt_debugprintf (const char *file, int line, const char *fmt, ...)
480947e89262Smrg{
481047e89262Smrg  va_list args;
481147e89262Smrg  if (lt_debug)
481247e89262Smrg    {
481347e89262Smrg      (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line);
481447e89262Smrg      va_start (args, fmt);
481547e89262Smrg      (void) vfprintf (stderr, fmt, args);
481647e89262Smrg      va_end (args);
481747e89262Smrg    }
481847e89262Smrg}
4819bd1da9d7Smrg
482047e89262Smrgstatic void
482147e89262Smrglt_error_core (int exit_status, const char *file,
482247e89262Smrg	       int line, const char *mode,
482347e89262Smrg	       const char *message, va_list ap)
482447e89262Smrg{
482547e89262Smrg  fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode);
482647e89262Smrg  vfprintf (stderr, message, ap);
482747e89262Smrg  fprintf (stderr, ".\n");
4828bd1da9d7Smrg
482947e89262Smrg  if (exit_status >= 0)
483047e89262Smrg    exit (exit_status);
483147e89262Smrg}
4832bd1da9d7Smrg
483347e89262Smrgvoid
483447e89262Smrglt_fatal (const char *file, int line, const char *message, ...)
483547e89262Smrg{
483647e89262Smrg  va_list ap;
483747e89262Smrg  va_start (ap, message);
483847e89262Smrg  lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap);
483947e89262Smrg  va_end (ap);
484047e89262Smrg}
4841bd1da9d7Smrg
484247e89262Smrgstatic const char *
484347e89262Smrgnonnull (const char *s)
484447e89262Smrg{
484547e89262Smrg  return s ? s : "(null)";
484647e89262Smrg}
4847bd1da9d7Smrg
484847e89262Smrgstatic const char *
484947e89262Smrgnonempty (const char *s)
485047e89262Smrg{
485147e89262Smrg  return (s && !*s) ? "(empty)" : nonnull (s);
485247e89262Smrg}
4853bd1da9d7Smrg
485447e89262Smrgvoid
485547e89262Smrglt_setenv (const char *name, const char *value)
485647e89262Smrg{
485747e89262Smrg  lt_debugprintf (__FILE__, __LINE__,
485847e89262Smrg		  "(lt_setenv) setting '%s' to '%s'\n",
485947e89262Smrg                  nonnull (name), nonnull (value));
486047e89262Smrg  {
486147e89262Smrg#ifdef HAVE_SETENV
486247e89262Smrg    /* always make a copy, for consistency with !HAVE_SETENV */
486347e89262Smrg    char *str = xstrdup (value);
486447e89262Smrg    setenv (name, str, 1);
486547e89262Smrg#else
486647e89262Smrg    int len = strlen (name) + 1 + strlen (value) + 1;
486747e89262Smrg    char *str = XMALLOC (char, len);
486847e89262Smrg    sprintf (str, "%s=%s", name, value);
486947e89262Smrg    if (putenv (str) != EXIT_SUCCESS)
487047e89262Smrg      {
487147e89262Smrg        XFREE (str);
487247e89262Smrg      }
487347e89262Smrg#endif
487447e89262Smrg  }
487547e89262Smrg}
4876bd1da9d7Smrg
487747e89262Smrgchar *
487847e89262Smrglt_extend_str (const char *orig_value, const char *add, int to_end)
487947e89262Smrg{
488047e89262Smrg  char *new_value;
488147e89262Smrg  if (orig_value && *orig_value)
488247e89262Smrg    {
488347e89262Smrg      int orig_value_len = strlen (orig_value);
488447e89262Smrg      int add_len = strlen (add);
488547e89262Smrg      new_value = XMALLOC (char, add_len + orig_value_len + 1);
488647e89262Smrg      if (to_end)
488747e89262Smrg        {
488847e89262Smrg          strcpy (new_value, orig_value);
488947e89262Smrg          strcpy (new_value + orig_value_len, add);
489047e89262Smrg        }
489147e89262Smrg      else
489247e89262Smrg        {
489347e89262Smrg          strcpy (new_value, add);
489447e89262Smrg          strcpy (new_value + add_len, orig_value);
489547e89262Smrg        }
489647e89262Smrg    }
489747e89262Smrg  else
489847e89262Smrg    {
489947e89262Smrg      new_value = xstrdup (add);
490047e89262Smrg    }
490147e89262Smrg  return new_value;
490247e89262Smrg}
4903bd1da9d7Smrg
490447e89262Smrgvoid
490547e89262Smrglt_update_exe_path (const char *name, const char *value)
490647e89262Smrg{
490747e89262Smrg  lt_debugprintf (__FILE__, __LINE__,
490847e89262Smrg		  "(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
490947e89262Smrg                  nonnull (name), nonnull (value));
4910bd1da9d7Smrg
491147e89262Smrg  if (name && *name && value && *value)
491247e89262Smrg    {
491347e89262Smrg      char *new_value = lt_extend_str (getenv (name), value, 0);
491447e89262Smrg      /* some systems can't cope with a ':'-terminated path #' */
491547e89262Smrg      int len = strlen (new_value);
491647e89262Smrg      while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
491747e89262Smrg        {
491847e89262Smrg          new_value[len-1] = '\0';
491947e89262Smrg        }
492047e89262Smrg      lt_setenv (name, new_value);
492147e89262Smrg      XFREE (new_value);
492247e89262Smrg    }
492347e89262Smrg}
4924bd1da9d7Smrg
492547e89262Smrgvoid
492647e89262Smrglt_update_lib_path (const char *name, const char *value)
492747e89262Smrg{
492847e89262Smrg  lt_debugprintf (__FILE__, __LINE__,
492947e89262Smrg		  "(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
493047e89262Smrg                  nonnull (name), nonnull (value));
4931bd1da9d7Smrg
493247e89262Smrg  if (name && *name && value && *value)
493347e89262Smrg    {
493447e89262Smrg      char *new_value = lt_extend_str (getenv (name), value, 0);
493547e89262Smrg      lt_setenv (name, new_value);
493647e89262Smrg      XFREE (new_value);
493747e89262Smrg    }
493847e89262Smrg}
4939bd1da9d7Smrg
494047e89262SmrgEOF
494147e89262Smrg	    case $host_os in
494247e89262Smrg	      mingw*)
494347e89262Smrg		cat <<"EOF"
494447e89262Smrg
494547e89262Smrg/* Prepares an argument vector before calling spawn().
494647e89262Smrg   Note that spawn() does not by itself call the command interpreter
494747e89262Smrg     (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
494847e89262Smrg      ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
494947e89262Smrg         GetVersionEx(&v);
495047e89262Smrg         v.dwPlatformId == VER_PLATFORM_WIN32_NT;
495147e89262Smrg      }) ? "cmd.exe" : "command.com").
495247e89262Smrg   Instead it simply concatenates the arguments, separated by ' ', and calls
495347e89262Smrg   CreateProcess().  We must quote the arguments since Win32 CreateProcess()
495447e89262Smrg   interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
495547e89262Smrg   special way:
495647e89262Smrg   - Space and tab are interpreted as delimiters. They are not treated as
495747e89262Smrg     delimiters if they are surrounded by double quotes: "...".
495847e89262Smrg   - Unescaped double quotes are removed from the input. Their only effect is
495947e89262Smrg     that within double quotes, space and tab are treated like normal
496047e89262Smrg     characters.
496147e89262Smrg   - Backslashes not followed by double quotes are not special.
496247e89262Smrg   - But 2*n+1 backslashes followed by a double quote become
496347e89262Smrg     n backslashes followed by a double quote (n >= 0):
496447e89262Smrg       \" -> "
496547e89262Smrg       \\\" -> \"
496647e89262Smrg       \\\\\" -> \\"
496747e89262Smrg */
496847e89262Smrg#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"
496947e89262Smrg#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"
497047e89262Smrgchar **
497147e89262Smrgprepare_spawn (char **argv)
497247e89262Smrg{
497347e89262Smrg  size_t argc;
497447e89262Smrg  char **new_argv;
497547e89262Smrg  size_t i;
4976bd1da9d7Smrg
497747e89262Smrg  /* Count number of arguments.  */
497847e89262Smrg  for (argc = 0; argv[argc] != NULL; argc++)
497947e89262Smrg    ;
4980bd1da9d7Smrg
498147e89262Smrg  /* Allocate new argument vector.  */
498247e89262Smrg  new_argv = XMALLOC (char *, argc + 1);
4983bd1da9d7Smrg
498447e89262Smrg  /* Put quoted arguments into the new argument vector.  */
498547e89262Smrg  for (i = 0; i < argc; i++)
498647e89262Smrg    {
498747e89262Smrg      const char *string = argv[i];
498847e89262Smrg
498947e89262Smrg      if (string[0] == '\0')
499047e89262Smrg	new_argv[i] = xstrdup ("\"\"");
499147e89262Smrg      else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
499247e89262Smrg	{
499347e89262Smrg	  int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
499447e89262Smrg	  size_t length;
499547e89262Smrg	  unsigned int backslashes;
499647e89262Smrg	  const char *s;
499747e89262Smrg	  char *quoted_string;
499847e89262Smrg	  char *p;
499947e89262Smrg
500047e89262Smrg	  length = 0;
500147e89262Smrg	  backslashes = 0;
500247e89262Smrg	  if (quote_around)
500347e89262Smrg	    length++;
500447e89262Smrg	  for (s = string; *s != '\0'; s++)
500547e89262Smrg	    {
500647e89262Smrg	      char c = *s;
500747e89262Smrg	      if (c == '"')
500847e89262Smrg		length += backslashes + 1;
500947e89262Smrg	      length++;
501047e89262Smrg	      if (c == '\\')
501147e89262Smrg		backslashes++;
501247e89262Smrg	      else
501347e89262Smrg		backslashes = 0;
501447e89262Smrg	    }
501547e89262Smrg	  if (quote_around)
501647e89262Smrg	    length += backslashes + 1;
501747e89262Smrg
501847e89262Smrg	  quoted_string = XMALLOC (char, length + 1);
501947e89262Smrg
502047e89262Smrg	  p = quoted_string;
502147e89262Smrg	  backslashes = 0;
502247e89262Smrg	  if (quote_around)
502347e89262Smrg	    *p++ = '"';
502447e89262Smrg	  for (s = string; *s != '\0'; s++)
502547e89262Smrg	    {
502647e89262Smrg	      char c = *s;
502747e89262Smrg	      if (c == '"')
502847e89262Smrg		{
502947e89262Smrg		  unsigned int j;
503047e89262Smrg		  for (j = backslashes + 1; j > 0; j--)
503147e89262Smrg		    *p++ = '\\';
503247e89262Smrg		}
503347e89262Smrg	      *p++ = c;
503447e89262Smrg	      if (c == '\\')
503547e89262Smrg		backslashes++;
503647e89262Smrg	      else
503747e89262Smrg		backslashes = 0;
503847e89262Smrg	    }
503947e89262Smrg	  if (quote_around)
504047e89262Smrg	    {
504147e89262Smrg	      unsigned int j;
504247e89262Smrg	      for (j = backslashes; j > 0; j--)
504347e89262Smrg		*p++ = '\\';
504447e89262Smrg	      *p++ = '"';
504547e89262Smrg	    }
504647e89262Smrg	  *p = '\0';
5047bd1da9d7Smrg
504847e89262Smrg	  new_argv[i] = quoted_string;
504947e89262Smrg	}
505047e89262Smrg      else
505147e89262Smrg	new_argv[i] = (char *) string;
505247e89262Smrg    }
505347e89262Smrg  new_argv[argc] = NULL;
5054bd1da9d7Smrg
505547e89262Smrg  return new_argv;
505647e89262Smrg}
505747e89262SmrgEOF
5058bd1da9d7Smrg		;;
505947e89262Smrg	    esac
5060bd1da9d7Smrg
506147e89262Smrg            cat <<"EOF"
506247e89262Smrgvoid lt_dump_script (FILE* f)
506347e89262Smrg{
506447e89262SmrgEOF
506547e89262Smrg	    func_emit_wrapper yes |
5066899129b3Smrg	      $SED -n -e '
5067899129b3Smrgs/^\(.\{79\}\)\(..*\)/\1\
5068899129b3Smrg\2/
5069899129b3Smrgh
5070899129b3Smrgs/\([\\"]\)/\\\1/g
5071899129b3Smrgs/$/\\n/
5072899129b3Smrgs/\([^\n]*\).*/  fputs ("\1", f);/p
5073899129b3Smrgg
5074899129b3SmrgD'
507547e89262Smrg            cat <<"EOF"
507647e89262Smrg}
507747e89262SmrgEOF
507847e89262Smrg}
507947e89262Smrg# end: func_emit_cwrapperexe_src
5080bd1da9d7Smrg
508147e89262Smrg# func_win32_import_lib_p ARG
508247e89262Smrg# True if ARG is an import lib, as indicated by $file_magic_cmd
508347e89262Smrgfunc_win32_import_lib_p ()
508447e89262Smrg{
508547e89262Smrg    $opt_debug
508647e89262Smrg    case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
508747e89262Smrg    *import*) : ;;
508847e89262Smrg    *) false ;;
508947e89262Smrg    esac
509047e89262Smrg}
5091bd1da9d7Smrg
509247e89262Smrg# func_mode_link arg...
509347e89262Smrgfunc_mode_link ()
509447e89262Smrg{
509547e89262Smrg    $opt_debug
509647e89262Smrg    case $host in
509747e89262Smrg    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
509847e89262Smrg      # It is impossible to link a dll without this setting, and
509947e89262Smrg      # we shouldn't force the makefile maintainer to figure out
510047e89262Smrg      # which system we are compiling for in order to pass an extra
510147e89262Smrg      # flag for every libtool invocation.
510247e89262Smrg      # allow_undefined=no
5103bd1da9d7Smrg
510447e89262Smrg      # FIXME: Unfortunately, there are problems with the above when trying
510547e89262Smrg      # to make a dll which has undefined symbols, in which case not
510647e89262Smrg      # even a static library is built.  For now, we need to specify
510747e89262Smrg      # -no-undefined on the libtool link line when we can be certain
510847e89262Smrg      # that all symbols are satisfied, otherwise we get a static library.
510947e89262Smrg      allow_undefined=yes
511047e89262Smrg      ;;
511147e89262Smrg    *)
511247e89262Smrg      allow_undefined=yes
511347e89262Smrg      ;;
511447e89262Smrg    esac
511547e89262Smrg    libtool_args=$nonopt
511647e89262Smrg    base_compile="$nonopt $@"
511747e89262Smrg    compile_command=$nonopt
511847e89262Smrg    finalize_command=$nonopt
5119bd1da9d7Smrg
512047e89262Smrg    compile_rpath=
512147e89262Smrg    finalize_rpath=
512247e89262Smrg    compile_shlibpath=
512347e89262Smrg    finalize_shlibpath=
512447e89262Smrg    convenience=
512547e89262Smrg    old_convenience=
512647e89262Smrg    deplibs=
512747e89262Smrg    old_deplibs=
512847e89262Smrg    compiler_flags=
512947e89262Smrg    linker_flags=
513047e89262Smrg    dllsearchpath=
513147e89262Smrg    lib_search_path=`pwd`
513247e89262Smrg    inst_prefix_dir=
513347e89262Smrg    new_inherited_linker_flags=
5134bd1da9d7Smrg
513547e89262Smrg    avoid_version=no
513647e89262Smrg    bindir=
513747e89262Smrg    dlfiles=
513847e89262Smrg    dlprefiles=
513947e89262Smrg    dlself=no
514047e89262Smrg    export_dynamic=no
514147e89262Smrg    export_symbols=
514247e89262Smrg    export_symbols_regex=
514347e89262Smrg    generated=
514447e89262Smrg    libobjs=
514547e89262Smrg    ltlibs=
514647e89262Smrg    module=no
514747e89262Smrg    no_install=no
514847e89262Smrg    objs=
514947e89262Smrg    non_pic_objects=
515047e89262Smrg    precious_files_regex=
515147e89262Smrg    prefer_static_libs=no
515247e89262Smrg    preload=no
515347e89262Smrg    prev=
515447e89262Smrg    prevarg=
515547e89262Smrg    release=
515647e89262Smrg    rpath=
515747e89262Smrg    xrpath=
515847e89262Smrg    perm_rpath=
515947e89262Smrg    temp_rpath=
516047e89262Smrg    thread_safe=no
516147e89262Smrg    vinfo=
516247e89262Smrg    vinfo_number=no
516347e89262Smrg    weak_libs=
516447e89262Smrg    single_module="${wl}-single_module"
516547e89262Smrg    func_infer_tag $base_compile
5166bd1da9d7Smrg
516747e89262Smrg    # We need to know -static, to get the right output filenames.
516847e89262Smrg    for arg
516947e89262Smrg    do
517047e89262Smrg      case $arg in
517147e89262Smrg      -shared)
517247e89262Smrg	test "$build_libtool_libs" != yes && \
517347e89262Smrg	  func_fatal_configuration "can not build a shared library"
517447e89262Smrg	build_old_libs=no
517547e89262Smrg	break
517647e89262Smrg	;;
517747e89262Smrg      -all-static | -static | -static-libtool-libs)
517847e89262Smrg	case $arg in
517947e89262Smrg	-all-static)
518047e89262Smrg	  if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
518147e89262Smrg	    func_warning "complete static linking is impossible in this configuration"
518247e89262Smrg	  fi
518347e89262Smrg	  if test -n "$link_static_flag"; then
518447e89262Smrg	    dlopen_self=$dlopen_self_static
518547e89262Smrg	  fi
518647e89262Smrg	  prefer_static_libs=yes
518747e89262Smrg	  ;;
518847e89262Smrg	-static)
518947e89262Smrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
519047e89262Smrg	    dlopen_self=$dlopen_self_static
519147e89262Smrg	  fi
519247e89262Smrg	  prefer_static_libs=built
519347e89262Smrg	  ;;
519447e89262Smrg	-static-libtool-libs)
519547e89262Smrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
519647e89262Smrg	    dlopen_self=$dlopen_self_static
519747e89262Smrg	  fi
519847e89262Smrg	  prefer_static_libs=yes
519947e89262Smrg	  ;;
520047e89262Smrg	esac
520147e89262Smrg	build_libtool_libs=no
520247e89262Smrg	build_old_libs=yes
520347e89262Smrg	break
520447e89262Smrg	;;
520547e89262Smrg      esac
520647e89262Smrg    done
5207bd1da9d7Smrg
520847e89262Smrg    # See if our shared archives depend on static archives.
520947e89262Smrg    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
5210bd1da9d7Smrg
521147e89262Smrg    # Go through the arguments, transforming them on the way.
521247e89262Smrg    while test "$#" -gt 0; do
521347e89262Smrg      arg="$1"
521447e89262Smrg      shift
521547e89262Smrg      func_quote_for_eval "$arg"
521647e89262Smrg      qarg=$func_quote_for_eval_unquoted_result
521747e89262Smrg      func_append libtool_args " $func_quote_for_eval_result"
5218bd1da9d7Smrg
521947e89262Smrg      # If the previous option needs an argument, assign it.
522047e89262Smrg      if test -n "$prev"; then
522147e89262Smrg	case $prev in
522247e89262Smrg	output)
522347e89262Smrg	  func_append compile_command " @OUTPUT@"
522447e89262Smrg	  func_append finalize_command " @OUTPUT@"
522547e89262Smrg	  ;;
522647e89262Smrg	esac
5227bd1da9d7Smrg
522847e89262Smrg	case $prev in
522947e89262Smrg	bindir)
523047e89262Smrg	  bindir="$arg"
523147e89262Smrg	  prev=
523247e89262Smrg	  continue
523347e89262Smrg	  ;;
523447e89262Smrg	dlfiles|dlprefiles)
523547e89262Smrg	  if test "$preload" = no; then
523647e89262Smrg	    # Add the symbol object into the linking commands.
523747e89262Smrg	    func_append compile_command " @SYMFILE@"
523847e89262Smrg	    func_append finalize_command " @SYMFILE@"
523947e89262Smrg	    preload=yes
5240bd1da9d7Smrg	  fi
524147e89262Smrg	  case $arg in
524247e89262Smrg	  *.la | *.lo) ;;  # We handle these cases below.
524347e89262Smrg	  force)
524447e89262Smrg	    if test "$dlself" = no; then
524547e89262Smrg	      dlself=needless
524647e89262Smrg	      export_dynamic=yes
5247bd1da9d7Smrg	    fi
524847e89262Smrg	    prev=
524947e89262Smrg	    continue
525047e89262Smrg	    ;;
525147e89262Smrg	  self)
525247e89262Smrg	    if test "$prev" = dlprefiles; then
525347e89262Smrg	      dlself=yes
525447e89262Smrg	    elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
525547e89262Smrg	      dlself=yes
5256bd1da9d7Smrg	    else
525747e89262Smrg	      dlself=needless
525847e89262Smrg	      export_dynamic=yes
5259bd1da9d7Smrg	    fi
526047e89262Smrg	    prev=
526147e89262Smrg	    continue
526247e89262Smrg	    ;;
526347e89262Smrg	  *)
526447e89262Smrg	    if test "$prev" = dlfiles; then
5265899129b3Smrg	      func_append dlfiles " $arg"
5266bd1da9d7Smrg	    else
5267899129b3Smrg	      func_append dlprefiles " $arg"
5268bd1da9d7Smrg	    fi
526947e89262Smrg	    prev=
527047e89262Smrg	    continue
527147e89262Smrg	    ;;
527247e89262Smrg	  esac
527347e89262Smrg	  ;;
527447e89262Smrg	expsyms)
527547e89262Smrg	  export_symbols="$arg"
527647e89262Smrg	  test -f "$arg" \
527747e89262Smrg	    || func_fatal_error "symbol file \`$arg' does not exist"
527847e89262Smrg	  prev=
527947e89262Smrg	  continue
528047e89262Smrg	  ;;
528147e89262Smrg	expsyms_regex)
528247e89262Smrg	  export_symbols_regex="$arg"
528347e89262Smrg	  prev=
528447e89262Smrg	  continue
528547e89262Smrg	  ;;
528647e89262Smrg	framework)
5287bd1da9d7Smrg	  case $host in
528847e89262Smrg	    *-*-darwin*)
528947e89262Smrg	      case "$deplibs " in
529047e89262Smrg		*" $qarg.ltframework "*) ;;
5291899129b3Smrg		*) func_append deplibs " $qarg.ltframework" # this is fixed later
529247e89262Smrg		   ;;
529347e89262Smrg	      esac
529447e89262Smrg	      ;;
5295bd1da9d7Smrg	  esac
529647e89262Smrg	  prev=
529747e89262Smrg	  continue
5298bd1da9d7Smrg	  ;;
529947e89262Smrg	inst_prefix)
530047e89262Smrg	  inst_prefix_dir="$arg"
530147e89262Smrg	  prev=
530247e89262Smrg	  continue
5303bd1da9d7Smrg	  ;;
530447e89262Smrg	objectlist)
530547e89262Smrg	  if test -f "$arg"; then
530647e89262Smrg	    save_arg=$arg
530747e89262Smrg	    moreargs=
530847e89262Smrg	    for fil in `cat "$save_arg"`
530947e89262Smrg	    do
5310899129b3Smrg#	      func_append moreargs " $fil"
531147e89262Smrg	      arg=$fil
531247e89262Smrg	      # A libtool-controlled object.
5313bd1da9d7Smrg
531447e89262Smrg	      # Check to see that this really is a libtool object.
531547e89262Smrg	      if func_lalib_unsafe_p "$arg"; then
531647e89262Smrg		pic_object=
531747e89262Smrg		non_pic_object=
5318bd1da9d7Smrg
531947e89262Smrg		# Read the .lo file
532047e89262Smrg		func_source "$arg"
5321bd1da9d7Smrg
532247e89262Smrg		if test -z "$pic_object" ||
532347e89262Smrg		   test -z "$non_pic_object" ||
532447e89262Smrg		   test "$pic_object" = none &&
532547e89262Smrg		   test "$non_pic_object" = none; then
532647e89262Smrg		  func_fatal_error "cannot find name of object for \`$arg'"
532747e89262Smrg		fi
5328bd1da9d7Smrg
532947e89262Smrg		# Extract subdirectory from the argument.
533047e89262Smrg		func_dirname "$arg" "/" ""
533147e89262Smrg		xdir="$func_dirname_result"
5332bd1da9d7Smrg
533347e89262Smrg		if test "$pic_object" != none; then
533447e89262Smrg		  # Prepend the subdirectory the object is found in.
533547e89262Smrg		  pic_object="$xdir$pic_object"
5336bd1da9d7Smrg
533747e89262Smrg		  if test "$prev" = dlfiles; then
533847e89262Smrg		    if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
5339899129b3Smrg		      func_append dlfiles " $pic_object"
534047e89262Smrg		      prev=
534147e89262Smrg		      continue
534247e89262Smrg		    else
534347e89262Smrg		      # If libtool objects are unsupported, then we need to preload.
534447e89262Smrg		      prev=dlprefiles
534547e89262Smrg		    fi
534647e89262Smrg		  fi
5347bd1da9d7Smrg
534847e89262Smrg		  # CHECK ME:  I think I busted this.  -Ossama
534947e89262Smrg		  if test "$prev" = dlprefiles; then
535047e89262Smrg		    # Preload the old-style object.
5351899129b3Smrg		    func_append dlprefiles " $pic_object"
535247e89262Smrg		    prev=
535347e89262Smrg		  fi
5354bd1da9d7Smrg
535547e89262Smrg		  # A PIC object.
535647e89262Smrg		  func_append libobjs " $pic_object"
535747e89262Smrg		  arg="$pic_object"
535847e89262Smrg		fi
5359bd1da9d7Smrg
536047e89262Smrg		# Non-PIC object.
536147e89262Smrg		if test "$non_pic_object" != none; then
536247e89262Smrg		  # Prepend the subdirectory the object is found in.
536347e89262Smrg		  non_pic_object="$xdir$non_pic_object"
5364bd1da9d7Smrg
536547e89262Smrg		  # A standard non-PIC object
536647e89262Smrg		  func_append non_pic_objects " $non_pic_object"
536747e89262Smrg		  if test -z "$pic_object" || test "$pic_object" = none ; then
536847e89262Smrg		    arg="$non_pic_object"
536947e89262Smrg		  fi
537047e89262Smrg		else
537147e89262Smrg		  # If the PIC object exists, use it instead.
537247e89262Smrg		  # $xdir was prepended to $pic_object above.
537347e89262Smrg		  non_pic_object="$pic_object"
537447e89262Smrg		  func_append non_pic_objects " $non_pic_object"
537547e89262Smrg		fi
537647e89262Smrg	      else
537747e89262Smrg		# Only an error if not doing a dry-run.
537847e89262Smrg		if $opt_dry_run; then
537947e89262Smrg		  # Extract subdirectory from the argument.
538047e89262Smrg		  func_dirname "$arg" "/" ""
538147e89262Smrg		  xdir="$func_dirname_result"
538247e89262Smrg
538347e89262Smrg		  func_lo2o "$arg"
538447e89262Smrg		  pic_object=$xdir$objdir/$func_lo2o_result
538547e89262Smrg		  non_pic_object=$xdir$func_lo2o_result
538647e89262Smrg		  func_append libobjs " $pic_object"
538747e89262Smrg		  func_append non_pic_objects " $non_pic_object"
538847e89262Smrg	        else
538947e89262Smrg		  func_fatal_error "\`$arg' is not a valid libtool object"
539047e89262Smrg		fi
539147e89262Smrg	      fi
539247e89262Smrg	    done
5393bd1da9d7Smrg	  else
539447e89262Smrg	    func_fatal_error "link input file \`$arg' does not exist"
5395bd1da9d7Smrg	  fi
539647e89262Smrg	  arg=$save_arg
539747e89262Smrg	  prev=
539847e89262Smrg	  continue
539947e89262Smrg	  ;;
540047e89262Smrg	precious_regex)
540147e89262Smrg	  precious_files_regex="$arg"
540247e89262Smrg	  prev=
540347e89262Smrg	  continue
540447e89262Smrg	  ;;
540547e89262Smrg	release)
540647e89262Smrg	  release="-$arg"
540747e89262Smrg	  prev=
540847e89262Smrg	  continue
540947e89262Smrg	  ;;
541047e89262Smrg	rpath | xrpath)
541147e89262Smrg	  # We need an absolute path.
541247e89262Smrg	  case $arg in
541347e89262Smrg	  [\\/]* | [A-Za-z]:[\\/]*) ;;
541447e89262Smrg	  *)
541547e89262Smrg	    func_fatal_error "only absolute run-paths are allowed"
541647e89262Smrg	    ;;
541747e89262Smrg	  esac
541847e89262Smrg	  if test "$prev" = rpath; then
541947e89262Smrg	    case "$rpath " in
542047e89262Smrg	    *" $arg "*) ;;
5421899129b3Smrg	    *) func_append rpath " $arg" ;;
542247e89262Smrg	    esac
5423bd1da9d7Smrg	  else
542447e89262Smrg	    case "$xrpath " in
542547e89262Smrg	    *" $arg "*) ;;
5426899129b3Smrg	    *) func_append xrpath " $arg" ;;
542747e89262Smrg	    esac
5428bd1da9d7Smrg	  fi
542947e89262Smrg	  prev=
543047e89262Smrg	  continue
543147e89262Smrg	  ;;
543247e89262Smrg	shrext)
543347e89262Smrg	  shrext_cmds="$arg"
543447e89262Smrg	  prev=
543547e89262Smrg	  continue
543647e89262Smrg	  ;;
543747e89262Smrg	weak)
5438899129b3Smrg	  func_append weak_libs " $arg"
543947e89262Smrg	  prev=
544047e89262Smrg	  continue
544147e89262Smrg	  ;;
544247e89262Smrg	xcclinker)
5443899129b3Smrg	  func_append linker_flags " $qarg"
5444899129b3Smrg	  func_append compiler_flags " $qarg"
544547e89262Smrg	  prev=
544647e89262Smrg	  func_append compile_command " $qarg"
544747e89262Smrg	  func_append finalize_command " $qarg"
544847e89262Smrg	  continue
544947e89262Smrg	  ;;
545047e89262Smrg	xcompiler)
5451899129b3Smrg	  func_append compiler_flags " $qarg"
545247e89262Smrg	  prev=
545347e89262Smrg	  func_append compile_command " $qarg"
545447e89262Smrg	  func_append finalize_command " $qarg"
545547e89262Smrg	  continue
545647e89262Smrg	  ;;
545747e89262Smrg	xlinker)
5458899129b3Smrg	  func_append linker_flags " $qarg"
5459899129b3Smrg	  func_append compiler_flags " $wl$qarg"
546047e89262Smrg	  prev=
546147e89262Smrg	  func_append compile_command " $wl$qarg"
546247e89262Smrg	  func_append finalize_command " $wl$qarg"
546347e89262Smrg	  continue
546447e89262Smrg	  ;;
546547e89262Smrg	*)
546647e89262Smrg	  eval "$prev=\"\$arg\""
546747e89262Smrg	  prev=
546847e89262Smrg	  continue
546947e89262Smrg	  ;;
5470bd1da9d7Smrg	esac
547147e89262Smrg      fi # test -n "$prev"
5472bd1da9d7Smrg
547347e89262Smrg      prevarg="$arg"
5474bd1da9d7Smrg
547547e89262Smrg      case $arg in
547647e89262Smrg      -all-static)
547747e89262Smrg	if test -n "$link_static_flag"; then
547847e89262Smrg	  # See comment for -static flag below, for more details.
547947e89262Smrg	  func_append compile_command " $link_static_flag"
548047e89262Smrg	  func_append finalize_command " $link_static_flag"
548147e89262Smrg	fi
548247e89262Smrg	continue
548347e89262Smrg	;;
5484bd1da9d7Smrg
548547e89262Smrg      -allow-undefined)
548647e89262Smrg	# FIXME: remove this flag sometime in the future.
548747e89262Smrg	func_fatal_error "\`-allow-undefined' must not be used because it is the default"
548847e89262Smrg	;;
5489bd1da9d7Smrg
549047e89262Smrg      -avoid-version)
549147e89262Smrg	avoid_version=yes
549247e89262Smrg	continue
549347e89262Smrg	;;
5494bd1da9d7Smrg
549547e89262Smrg      -bindir)
549647e89262Smrg	prev=bindir
549747e89262Smrg	continue
549847e89262Smrg	;;
5499bd1da9d7Smrg
550047e89262Smrg      -dlopen)
550147e89262Smrg	prev=dlfiles
550247e89262Smrg	continue
550347e89262Smrg	;;
5504bd1da9d7Smrg
550547e89262Smrg      -dlpreopen)
550647e89262Smrg	prev=dlprefiles
550747e89262Smrg	continue
550847e89262Smrg	;;
5509bd1da9d7Smrg
551047e89262Smrg      -export-dynamic)
551147e89262Smrg	export_dynamic=yes
551247e89262Smrg	continue
551347e89262Smrg	;;
5514bd1da9d7Smrg
551547e89262Smrg      -export-symbols | -export-symbols-regex)
551647e89262Smrg	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
551747e89262Smrg	  func_fatal_error "more than one -exported-symbols argument is not allowed"
551847e89262Smrg	fi
551947e89262Smrg	if test "X$arg" = "X-export-symbols"; then
552047e89262Smrg	  prev=expsyms
552147e89262Smrg	else
552247e89262Smrg	  prev=expsyms_regex
552347e89262Smrg	fi
552447e89262Smrg	continue
552547e89262Smrg	;;
5526bd1da9d7Smrg
552747e89262Smrg      -framework)
552847e89262Smrg	prev=framework
552947e89262Smrg	continue
553047e89262Smrg	;;
5531bd1da9d7Smrg
553247e89262Smrg      -inst-prefix-dir)
553347e89262Smrg	prev=inst_prefix
553447e89262Smrg	continue
553547e89262Smrg	;;
5536bd1da9d7Smrg
553747e89262Smrg      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
553847e89262Smrg      # so, if we see these flags be careful not to treat them like -L
553947e89262Smrg      -L[A-Z][A-Z]*:*)
554047e89262Smrg	case $with_gcc/$host in
554147e89262Smrg	no/*-*-irix* | /*-*-irix*)
554247e89262Smrg	  func_append compile_command " $arg"
554347e89262Smrg	  func_append finalize_command " $arg"
554447e89262Smrg	  ;;
554547e89262Smrg	esac
554647e89262Smrg	continue
554747e89262Smrg	;;
5548bd1da9d7Smrg
554947e89262Smrg      -L*)
5550899129b3Smrg	func_stripname "-L" '' "$arg"
5551899129b3Smrg	if test -z "$func_stripname_result"; then
555247e89262Smrg	  if test "$#" -gt 0; then
555347e89262Smrg	    func_fatal_error "require no space between \`-L' and \`$1'"
555447e89262Smrg	  else
555547e89262Smrg	    func_fatal_error "need path for \`-L' option"
555647e89262Smrg	  fi
555747e89262Smrg	fi
5558899129b3Smrg	func_resolve_sysroot "$func_stripname_result"
5559899129b3Smrg	dir=$func_resolve_sysroot_result
556047e89262Smrg	# We need an absolute path.
556147e89262Smrg	case $dir in
556247e89262Smrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
556347e89262Smrg	*)
556447e89262Smrg	  absdir=`cd "$dir" && pwd`
556547e89262Smrg	  test -z "$absdir" && \
556647e89262Smrg	    func_fatal_error "cannot determine absolute directory name of \`$dir'"
556747e89262Smrg	  dir="$absdir"
556847e89262Smrg	  ;;
556947e89262Smrg	esac
557047e89262Smrg	case "$deplibs " in
5571899129b3Smrg	*" -L$dir "* | *" $arg "*)
5572899129b3Smrg	  # Will only happen for absolute or sysroot arguments
5573899129b3Smrg	  ;;
557447e89262Smrg	*)
5575899129b3Smrg	  # Preserve sysroot, but never include relative directories
5576899129b3Smrg	  case $dir in
5577899129b3Smrg	    [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;;
5578899129b3Smrg	    *) func_append deplibs " -L$dir" ;;
5579899129b3Smrg	  esac
5580899129b3Smrg	  func_append lib_search_path " $dir"
558147e89262Smrg	  ;;
558247e89262Smrg	esac
558347e89262Smrg	case $host in
558447e89262Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
558547e89262Smrg	  testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
558647e89262Smrg	  case :$dllsearchpath: in
558747e89262Smrg	  *":$dir:"*) ;;
558847e89262Smrg	  ::) dllsearchpath=$dir;;
5589899129b3Smrg	  *) func_append dllsearchpath ":$dir";;
559047e89262Smrg	  esac
559147e89262Smrg	  case :$dllsearchpath: in
559247e89262Smrg	  *":$testbindir:"*) ;;
559347e89262Smrg	  ::) dllsearchpath=$testbindir;;
5594899129b3Smrg	  *) func_append dllsearchpath ":$testbindir";;
559547e89262Smrg	  esac
559647e89262Smrg	  ;;
559747e89262Smrg	esac
559847e89262Smrg	continue
559947e89262Smrg	;;
5600bd1da9d7Smrg
560147e89262Smrg      -l*)
560247e89262Smrg	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
560347e89262Smrg	  case $host in
560447e89262Smrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
560547e89262Smrg	    # These systems don't actually have a C or math library (as such)
560647e89262Smrg	    continue
560747e89262Smrg	    ;;
560847e89262Smrg	  *-*-os2*)
560947e89262Smrg	    # These systems don't actually have a C library (as such)
561047e89262Smrg	    test "X$arg" = "X-lc" && continue
561147e89262Smrg	    ;;
561247e89262Smrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
561347e89262Smrg	    # Do not include libc due to us having libc/libc_r.
561447e89262Smrg	    test "X$arg" = "X-lc" && continue
561547e89262Smrg	    ;;
561647e89262Smrg	  *-*-rhapsody* | *-*-darwin1.[012])
561747e89262Smrg	    # Rhapsody C and math libraries are in the System framework
5618899129b3Smrg	    func_append deplibs " System.ltframework"
561947e89262Smrg	    continue
562047e89262Smrg	    ;;
562147e89262Smrg	  *-*-sco3.2v5* | *-*-sco5v6*)
562247e89262Smrg	    # Causes problems with __ctype
562347e89262Smrg	    test "X$arg" = "X-lc" && continue
562447e89262Smrg	    ;;
562547e89262Smrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
562647e89262Smrg	    # Compiler inserts libc in the correct place for threads to work
562747e89262Smrg	    test "X$arg" = "X-lc" && continue
562847e89262Smrg	    ;;
562947e89262Smrg	  esac
563047e89262Smrg	elif test "X$arg" = "X-lc_r"; then
563147e89262Smrg	 case $host in
563247e89262Smrg	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
563347e89262Smrg	   # Do not include libc_r directly, use -pthread flag.
563447e89262Smrg	   continue
563547e89262Smrg	   ;;
563647e89262Smrg	 esac
563747e89262Smrg	fi
5638899129b3Smrg	func_append deplibs " $arg"
563947e89262Smrg	continue
564047e89262Smrg	;;
5641bd1da9d7Smrg
564247e89262Smrg      -module)
564347e89262Smrg	module=yes
564447e89262Smrg	continue
564547e89262Smrg	;;
5646bd1da9d7Smrg
564747e89262Smrg      # Tru64 UNIX uses -model [arg] to determine the layout of C++
564847e89262Smrg      # classes, name mangling, and exception handling.
564947e89262Smrg      # Darwin uses the -arch flag to determine output architecture.
5650899129b3Smrg      -model|-arch|-isysroot|--sysroot)
5651899129b3Smrg	func_append compiler_flags " $arg"
565247e89262Smrg	func_append compile_command " $arg"
565347e89262Smrg	func_append finalize_command " $arg"
565447e89262Smrg	prev=xcompiler
565547e89262Smrg	continue
565647e89262Smrg	;;
5657bd1da9d7Smrg
5658899129b3Smrg      -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
5659899129b3Smrg      |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
5660899129b3Smrg	func_append compiler_flags " $arg"
566147e89262Smrg	func_append compile_command " $arg"
566247e89262Smrg	func_append finalize_command " $arg"
566347e89262Smrg	case "$new_inherited_linker_flags " in
566447e89262Smrg	    *" $arg "*) ;;
5665899129b3Smrg	    * ) func_append new_inherited_linker_flags " $arg" ;;
566647e89262Smrg	esac
566747e89262Smrg	continue
566847e89262Smrg	;;
5669bd1da9d7Smrg
567047e89262Smrg      -multi_module)
567147e89262Smrg	single_module="${wl}-multi_module"
567247e89262Smrg	continue
567347e89262Smrg	;;
5674bd1da9d7Smrg
567547e89262Smrg      -no-fast-install)
567647e89262Smrg	fast_install=no
567747e89262Smrg	continue
567847e89262Smrg	;;
5679bd1da9d7Smrg
568047e89262Smrg      -no-install)
568147e89262Smrg	case $host in
568247e89262Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
568347e89262Smrg	  # The PATH hackery in wrapper scripts is required on Windows
568447e89262Smrg	  # and Darwin in order for the loader to find any dlls it needs.
568547e89262Smrg	  func_warning "\`-no-install' is ignored for $host"
568647e89262Smrg	  func_warning "assuming \`-no-fast-install' instead"
568747e89262Smrg	  fast_install=no
568847e89262Smrg	  ;;
568947e89262Smrg	*) no_install=yes ;;
569047e89262Smrg	esac
569147e89262Smrg	continue
569247e89262Smrg	;;
5693bd1da9d7Smrg
569447e89262Smrg      -no-undefined)
569547e89262Smrg	allow_undefined=no
569647e89262Smrg	continue
569747e89262Smrg	;;
5698bd1da9d7Smrg
569947e89262Smrg      -objectlist)
570047e89262Smrg	prev=objectlist
570147e89262Smrg	continue
570247e89262Smrg	;;
5703bd1da9d7Smrg
570447e89262Smrg      -o) prev=output ;;
5705bd1da9d7Smrg
570647e89262Smrg      -precious-files-regex)
570747e89262Smrg	prev=precious_regex
570847e89262Smrg	continue
570947e89262Smrg	;;
5710bd1da9d7Smrg
571147e89262Smrg      -release)
571247e89262Smrg	prev=release
571347e89262Smrg	continue
571447e89262Smrg	;;
5715bd1da9d7Smrg
571647e89262Smrg      -rpath)
571747e89262Smrg	prev=rpath
571847e89262Smrg	continue
571947e89262Smrg	;;
5720bd1da9d7Smrg
572147e89262Smrg      -R)
572247e89262Smrg	prev=xrpath
572347e89262Smrg	continue
572447e89262Smrg	;;
5725bd1da9d7Smrg
572647e89262Smrg      -R*)
572747e89262Smrg	func_stripname '-R' '' "$arg"
572847e89262Smrg	dir=$func_stripname_result
572947e89262Smrg	# We need an absolute path.
573047e89262Smrg	case $dir in
573147e89262Smrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
5732899129b3Smrg	=*)
5733899129b3Smrg	  func_stripname '=' '' "$dir"
5734899129b3Smrg	  dir=$lt_sysroot$func_stripname_result
5735899129b3Smrg	  ;;
573647e89262Smrg	*)
573747e89262Smrg	  func_fatal_error "only absolute run-paths are allowed"
573847e89262Smrg	  ;;
573947e89262Smrg	esac
574047e89262Smrg	case "$xrpath " in
574147e89262Smrg	*" $dir "*) ;;
5742899129b3Smrg	*) func_append xrpath " $dir" ;;
574347e89262Smrg	esac
574447e89262Smrg	continue
574547e89262Smrg	;;
5746bd1da9d7Smrg
574747e89262Smrg      -shared)
574847e89262Smrg	# The effects of -shared are defined in a previous loop.
574947e89262Smrg	continue
575047e89262Smrg	;;
5751bd1da9d7Smrg
575247e89262Smrg      -shrext)
575347e89262Smrg	prev=shrext
575447e89262Smrg	continue
575547e89262Smrg	;;
5756bd1da9d7Smrg
575747e89262Smrg      -static | -static-libtool-libs)
575847e89262Smrg	# The effects of -static are defined in a previous loop.
575947e89262Smrg	# We used to do the same as -all-static on platforms that
576047e89262Smrg	# didn't have a PIC flag, but the assumption that the effects
576147e89262Smrg	# would be equivalent was wrong.  It would break on at least
576247e89262Smrg	# Digital Unix and AIX.
576347e89262Smrg	continue
576447e89262Smrg	;;
5765bd1da9d7Smrg
576647e89262Smrg      -thread-safe)
576747e89262Smrg	thread_safe=yes
576847e89262Smrg	continue
576947e89262Smrg	;;
5770bd1da9d7Smrg
577147e89262Smrg      -version-info)
577247e89262Smrg	prev=vinfo
577347e89262Smrg	continue
577447e89262Smrg	;;
5775bd1da9d7Smrg
577647e89262Smrg      -version-number)
577747e89262Smrg	prev=vinfo
577847e89262Smrg	vinfo_number=yes
577947e89262Smrg	continue
578047e89262Smrg	;;
5781bd1da9d7Smrg
578247e89262Smrg      -weak)
578347e89262Smrg        prev=weak
578447e89262Smrg	continue
578547e89262Smrg	;;
5786bd1da9d7Smrg
578747e89262Smrg      -Wc,*)
578847e89262Smrg	func_stripname '-Wc,' '' "$arg"
578947e89262Smrg	args=$func_stripname_result
579047e89262Smrg	arg=
579147e89262Smrg	save_ifs="$IFS"; IFS=','
579247e89262Smrg	for flag in $args; do
579347e89262Smrg	  IFS="$save_ifs"
579447e89262Smrg          func_quote_for_eval "$flag"
5795899129b3Smrg	  func_append arg " $func_quote_for_eval_result"
5796899129b3Smrg	  func_append compiler_flags " $func_quote_for_eval_result"
579747e89262Smrg	done
579847e89262Smrg	IFS="$save_ifs"
579947e89262Smrg	func_stripname ' ' '' "$arg"
580047e89262Smrg	arg=$func_stripname_result
580147e89262Smrg	;;
5802bd1da9d7Smrg
580347e89262Smrg      -Wl,*)
580447e89262Smrg	func_stripname '-Wl,' '' "$arg"
580547e89262Smrg	args=$func_stripname_result
580647e89262Smrg	arg=
580747e89262Smrg	save_ifs="$IFS"; IFS=','
580847e89262Smrg	for flag in $args; do
580947e89262Smrg	  IFS="$save_ifs"
581047e89262Smrg          func_quote_for_eval "$flag"
5811899129b3Smrg	  func_append arg " $wl$func_quote_for_eval_result"
5812899129b3Smrg	  func_append compiler_flags " $wl$func_quote_for_eval_result"
5813899129b3Smrg	  func_append linker_flags " $func_quote_for_eval_result"
581447e89262Smrg	done
581547e89262Smrg	IFS="$save_ifs"
581647e89262Smrg	func_stripname ' ' '' "$arg"
581747e89262Smrg	arg=$func_stripname_result
581847e89262Smrg	;;
5819bd1da9d7Smrg
582047e89262Smrg      -Xcompiler)
582147e89262Smrg	prev=xcompiler
582247e89262Smrg	continue
582347e89262Smrg	;;
5824bd1da9d7Smrg
582547e89262Smrg      -Xlinker)
582647e89262Smrg	prev=xlinker
582747e89262Smrg	continue
582847e89262Smrg	;;
5829bd1da9d7Smrg
583047e89262Smrg      -XCClinker)
583147e89262Smrg	prev=xcclinker
583247e89262Smrg	continue
583347e89262Smrg	;;
5834bd1da9d7Smrg
583547e89262Smrg      # -msg_* for osf cc
583647e89262Smrg      -msg_*)
583747e89262Smrg	func_quote_for_eval "$arg"
583847e89262Smrg	arg="$func_quote_for_eval_result"
583947e89262Smrg	;;
5840bd1da9d7Smrg
584147e89262Smrg      # Flags to be passed through unchanged, with rationale:
584247e89262Smrg      # -64, -mips[0-9]      enable 64-bit mode for the SGI compiler
584347e89262Smrg      # -r[0-9][0-9]*        specify processor for the SGI compiler
584447e89262Smrg      # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler
584547e89262Smrg      # +DA*, +DD*           enable 64-bit mode for the HP compiler
584647e89262Smrg      # -q*                  compiler args for the IBM compiler
584747e89262Smrg      # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
584847e89262Smrg      # -F/path              path to uninstalled frameworks, gcc on darwin
584947e89262Smrg      # -p, -pg, --coverage, -fprofile-*  profiling flags for GCC
585047e89262Smrg      # @file                GCC response files
585147e89262Smrg      # -tp=*                Portland pgcc target processor selection
5852899129b3Smrg      # --sysroot=*          for sysroot support
5853899129b3Smrg      # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
585447e89262Smrg      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
5855899129b3Smrg      -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
5856899129b3Smrg      -O*|-flto*|-fwhopr*|-fuse-linker-plugin)
585747e89262Smrg        func_quote_for_eval "$arg"
585847e89262Smrg	arg="$func_quote_for_eval_result"
585947e89262Smrg        func_append compile_command " $arg"
586047e89262Smrg        func_append finalize_command " $arg"
5861899129b3Smrg        func_append compiler_flags " $arg"
586247e89262Smrg        continue
586347e89262Smrg        ;;
5864bd1da9d7Smrg
586547e89262Smrg      # Some other compiler flag.
586647e89262Smrg      -* | +*)
586747e89262Smrg        func_quote_for_eval "$arg"
586847e89262Smrg	arg="$func_quote_for_eval_result"
586947e89262Smrg	;;
5870bd1da9d7Smrg
587147e89262Smrg      *.$objext)
587247e89262Smrg	# A standard object.
5873899129b3Smrg	func_append objs " $arg"
587447e89262Smrg	;;
5875bd1da9d7Smrg
587647e89262Smrg      *.lo)
587747e89262Smrg	# A libtool-controlled object.
5878bd1da9d7Smrg
587947e89262Smrg	# Check to see that this really is a libtool object.
588047e89262Smrg	if func_lalib_unsafe_p "$arg"; then
588147e89262Smrg	  pic_object=
588247e89262Smrg	  non_pic_object=
5883bd1da9d7Smrg
588447e89262Smrg	  # Read the .lo file
588547e89262Smrg	  func_source "$arg"
5886bd1da9d7Smrg
588747e89262Smrg	  if test -z "$pic_object" ||
588847e89262Smrg	     test -z "$non_pic_object" ||
588947e89262Smrg	     test "$pic_object" = none &&
589047e89262Smrg	     test "$non_pic_object" = none; then
589147e89262Smrg	    func_fatal_error "cannot find name of object for \`$arg'"
589247e89262Smrg	  fi
58935bcb6992Smrg
589447e89262Smrg	  # Extract subdirectory from the argument.
589547e89262Smrg	  func_dirname "$arg" "/" ""
589647e89262Smrg	  xdir="$func_dirname_result"
5897bd1da9d7Smrg
589847e89262Smrg	  if test "$pic_object" != none; then
589947e89262Smrg	    # Prepend the subdirectory the object is found in.
590047e89262Smrg	    pic_object="$xdir$pic_object"
5901bd1da9d7Smrg
590247e89262Smrg	    if test "$prev" = dlfiles; then
590347e89262Smrg	      if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
5904899129b3Smrg		func_append dlfiles " $pic_object"
590547e89262Smrg		prev=
590647e89262Smrg		continue
590747e89262Smrg	      else
590847e89262Smrg		# If libtool objects are unsupported, then we need to preload.
590947e89262Smrg		prev=dlprefiles
591047e89262Smrg	      fi
591147e89262Smrg	    fi
591247e89262Smrg
591347e89262Smrg	    # CHECK ME:  I think I busted this.  -Ossama
591447e89262Smrg	    if test "$prev" = dlprefiles; then
591547e89262Smrg	      # Preload the old-style object.
5916899129b3Smrg	      func_append dlprefiles " $pic_object"
591747e89262Smrg	      prev=
591847e89262Smrg	    fi
591947e89262Smrg
592047e89262Smrg	    # A PIC object.
592147e89262Smrg	    func_append libobjs " $pic_object"
592247e89262Smrg	    arg="$pic_object"
592347e89262Smrg	  fi
592447e89262Smrg
592547e89262Smrg	  # Non-PIC object.
592647e89262Smrg	  if test "$non_pic_object" != none; then
592747e89262Smrg	    # Prepend the subdirectory the object is found in.
592847e89262Smrg	    non_pic_object="$xdir$non_pic_object"
592947e89262Smrg
593047e89262Smrg	    # A standard non-PIC object
593147e89262Smrg	    func_append non_pic_objects " $non_pic_object"
593247e89262Smrg	    if test -z "$pic_object" || test "$pic_object" = none ; then
593347e89262Smrg	      arg="$non_pic_object"
593447e89262Smrg	    fi
593547e89262Smrg	  else
593647e89262Smrg	    # If the PIC object exists, use it instead.
593747e89262Smrg	    # $xdir was prepended to $pic_object above.
593847e89262Smrg	    non_pic_object="$pic_object"
593947e89262Smrg	    func_append non_pic_objects " $non_pic_object"
594047e89262Smrg	  fi
594147e89262Smrg	else
594247e89262Smrg	  # Only an error if not doing a dry-run.
594347e89262Smrg	  if $opt_dry_run; then
594447e89262Smrg	    # Extract subdirectory from the argument.
594547e89262Smrg	    func_dirname "$arg" "/" ""
594647e89262Smrg	    xdir="$func_dirname_result"
594747e89262Smrg
594847e89262Smrg	    func_lo2o "$arg"
594947e89262Smrg	    pic_object=$xdir$objdir/$func_lo2o_result
595047e89262Smrg	    non_pic_object=$xdir$func_lo2o_result
595147e89262Smrg	    func_append libobjs " $pic_object"
595247e89262Smrg	    func_append non_pic_objects " $non_pic_object"
595347e89262Smrg	  else
595447e89262Smrg	    func_fatal_error "\`$arg' is not a valid libtool object"
595547e89262Smrg	  fi
595647e89262Smrg	fi
595747e89262Smrg	;;
595847e89262Smrg
595947e89262Smrg      *.$libext)
596047e89262Smrg	# An archive.
5961899129b3Smrg	func_append deplibs " $arg"
5962899129b3Smrg	func_append old_deplibs " $arg"
596347e89262Smrg	continue
596447e89262Smrg	;;
596547e89262Smrg
596647e89262Smrg      *.la)
596747e89262Smrg	# A libtool-controlled library.
596847e89262Smrg
5969899129b3Smrg	func_resolve_sysroot "$arg"
597047e89262Smrg	if test "$prev" = dlfiles; then
597147e89262Smrg	  # This library was specified with -dlopen.
5972899129b3Smrg	  func_append dlfiles " $func_resolve_sysroot_result"
597347e89262Smrg	  prev=
597447e89262Smrg	elif test "$prev" = dlprefiles; then
597547e89262Smrg	  # The library was specified with -dlpreopen.
5976899129b3Smrg	  func_append dlprefiles " $func_resolve_sysroot_result"
597747e89262Smrg	  prev=
597847e89262Smrg	else
5979899129b3Smrg	  func_append deplibs " $func_resolve_sysroot_result"
598047e89262Smrg	fi
598147e89262Smrg	continue
598247e89262Smrg	;;
598347e89262Smrg
598447e89262Smrg      # Some other compiler argument.
598547e89262Smrg      *)
598647e89262Smrg	# Unknown arguments in both finalize_command and compile_command need
598747e89262Smrg	# to be aesthetically quoted because they are evaled later.
598847e89262Smrg	func_quote_for_eval "$arg"
598947e89262Smrg	arg="$func_quote_for_eval_result"
599047e89262Smrg	;;
599147e89262Smrg      esac # arg
599247e89262Smrg
599347e89262Smrg      # Now actually substitute the argument into the commands.
599447e89262Smrg      if test -n "$arg"; then
599547e89262Smrg	func_append compile_command " $arg"
599647e89262Smrg	func_append finalize_command " $arg"
599747e89262Smrg      fi
599847e89262Smrg    done # argument parsing loop
599947e89262Smrg
600047e89262Smrg    test -n "$prev" && \
600147e89262Smrg      func_fatal_help "the \`$prevarg' option requires an argument"
600247e89262Smrg
600347e89262Smrg    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
600447e89262Smrg      eval arg=\"$export_dynamic_flag_spec\"
600547e89262Smrg      func_append compile_command " $arg"
600647e89262Smrg      func_append finalize_command " $arg"
600747e89262Smrg    fi
600847e89262Smrg
600947e89262Smrg    oldlibs=
601047e89262Smrg    # calculate the name of the file, without its directory
601147e89262Smrg    func_basename "$output"
601247e89262Smrg    outputname="$func_basename_result"
601347e89262Smrg    libobjs_save="$libobjs"
601447e89262Smrg
601547e89262Smrg    if test -n "$shlibpath_var"; then
601647e89262Smrg      # get the directories listed in $shlibpath_var
601747e89262Smrg      eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\`
6018bd1da9d7Smrg    else
601947e89262Smrg      shlib_search_path=
6020bd1da9d7Smrg    fi
602147e89262Smrg    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
602247e89262Smrg    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
6023bd1da9d7Smrg
602447e89262Smrg    func_dirname "$output" "/" ""
602547e89262Smrg    output_objdir="$func_dirname_result$objdir"
6026899129b3Smrg    func_to_tool_file "$output_objdir/"
6027899129b3Smrg    tool_output_objdir=$func_to_tool_file_result
602847e89262Smrg    # Create the object directory.
602947e89262Smrg    func_mkdir_p "$output_objdir"
6030bd1da9d7Smrg
603147e89262Smrg    # Determine the type of output
603247e89262Smrg    case $output in
603347e89262Smrg    "")
603447e89262Smrg      func_fatal_help "you must specify an output file"
603547e89262Smrg      ;;
603647e89262Smrg    *.$libext) linkmode=oldlib ;;
603747e89262Smrg    *.lo | *.$objext) linkmode=obj ;;
603847e89262Smrg    *.la) linkmode=lib ;;
603947e89262Smrg    *) linkmode=prog ;; # Anything else should be a program.
604047e89262Smrg    esac
604147e89262Smrg
604247e89262Smrg    specialdeplibs=
604347e89262Smrg
604447e89262Smrg    libs=
604547e89262Smrg    # Find all interdependent deplibs by searching for libraries
604647e89262Smrg    # that are linked more than once (e.g. -la -lb -la)
604747e89262Smrg    for deplib in $deplibs; do
6048899129b3Smrg      if $opt_preserve_dup_deps ; then
604947e89262Smrg	case "$libs " in
6050899129b3Smrg	*" $deplib "*) func_append specialdeplibs " $deplib" ;;
605147e89262Smrg	esac
605247e89262Smrg      fi
6053899129b3Smrg      func_append libs " $deplib"
605447e89262Smrg    done
605547e89262Smrg
605647e89262Smrg    if test "$linkmode" = lib; then
605747e89262Smrg      libs="$predeps $libs $compiler_lib_search_path $postdeps"
605847e89262Smrg
605947e89262Smrg      # Compute libraries that are listed more than once in $predeps
606047e89262Smrg      # $postdeps and mark them as special (i.e., whose duplicates are
606147e89262Smrg      # not to be eliminated).
606247e89262Smrg      pre_post_deps=
606347e89262Smrg      if $opt_duplicate_compiler_generated_deps; then
606447e89262Smrg	for pre_post_dep in $predeps $postdeps; do
606547e89262Smrg	  case "$pre_post_deps " in
6066899129b3Smrg	  *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;;
606747e89262Smrg	  esac
6068899129b3Smrg	  func_append pre_post_deps " $pre_post_dep"
606947e89262Smrg	done
607047e89262Smrg      fi
607147e89262Smrg      pre_post_deps=
607247e89262Smrg    fi
607347e89262Smrg
607447e89262Smrg    deplibs=
607547e89262Smrg    newdependency_libs=
607647e89262Smrg    newlib_search_path=
607747e89262Smrg    need_relink=no # whether we're linking any uninstalled libtool libraries
607847e89262Smrg    notinst_deplibs= # not-installed libtool libraries
607947e89262Smrg    notinst_path= # paths that contain not-installed libtool libraries
608047e89262Smrg
608147e89262Smrg    case $linkmode in
608247e89262Smrg    lib)
608347e89262Smrg	passes="conv dlpreopen link"
608447e89262Smrg	for file in $dlfiles $dlprefiles; do
608547e89262Smrg	  case $file in
608647e89262Smrg	  *.la) ;;
608747e89262Smrg	  *)
608847e89262Smrg	    func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file"
608947e89262Smrg	    ;;
609047e89262Smrg	  esac
609147e89262Smrg	done
609247e89262Smrg	;;
609347e89262Smrg    prog)
609447e89262Smrg	compile_deplibs=
609547e89262Smrg	finalize_deplibs=
609647e89262Smrg	alldeplibs=no
609747e89262Smrg	newdlfiles=
609847e89262Smrg	newdlprefiles=
609947e89262Smrg	passes="conv scan dlopen dlpreopen link"
610047e89262Smrg	;;
610147e89262Smrg    *)  passes="conv"
610247e89262Smrg	;;
610347e89262Smrg    esac
610447e89262Smrg
610547e89262Smrg    for pass in $passes; do
610647e89262Smrg      # The preopen pass in lib mode reverses $deplibs; put it back here
610747e89262Smrg      # so that -L comes before libs that need it for instance...
610847e89262Smrg      if test "$linkmode,$pass" = "lib,link"; then
610947e89262Smrg	## FIXME: Find the place where the list is rebuilt in the wrong
611047e89262Smrg	##        order, and fix it there properly
611147e89262Smrg        tmp_deplibs=
611247e89262Smrg	for deplib in $deplibs; do
611347e89262Smrg	  tmp_deplibs="$deplib $tmp_deplibs"
611447e89262Smrg	done
611547e89262Smrg	deplibs="$tmp_deplibs"
611647e89262Smrg      fi
611747e89262Smrg
611847e89262Smrg      if test "$linkmode,$pass" = "lib,link" ||
611947e89262Smrg	 test "$linkmode,$pass" = "prog,scan"; then
612047e89262Smrg	libs="$deplibs"
612147e89262Smrg	deplibs=
612247e89262Smrg      fi
612347e89262Smrg      if test "$linkmode" = prog; then
612447e89262Smrg	case $pass in
612547e89262Smrg	dlopen) libs="$dlfiles" ;;
612647e89262Smrg	dlpreopen) libs="$dlprefiles" ;;
612747e89262Smrg	link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
612847e89262Smrg	esac
612947e89262Smrg      fi
613047e89262Smrg      if test "$linkmode,$pass" = "lib,dlpreopen"; then
613147e89262Smrg	# Collect and forward deplibs of preopened libtool libs
613247e89262Smrg	for lib in $dlprefiles; do
613347e89262Smrg	  # Ignore non-libtool-libs
613447e89262Smrg	  dependency_libs=
6135899129b3Smrg	  func_resolve_sysroot "$lib"
613647e89262Smrg	  case $lib in
6137899129b3Smrg	  *.la)	func_source "$func_resolve_sysroot_result" ;;
613847e89262Smrg	  esac
613947e89262Smrg
614047e89262Smrg	  # Collect preopened libtool deplibs, except any this library
614147e89262Smrg	  # has declared as weak libs
614247e89262Smrg	  for deplib in $dependency_libs; do
614347e89262Smrg	    func_basename "$deplib"
614447e89262Smrg            deplib_base=$func_basename_result
614547e89262Smrg	    case " $weak_libs " in
614647e89262Smrg	    *" $deplib_base "*) ;;
6147899129b3Smrg	    *) func_append deplibs " $deplib" ;;
614847e89262Smrg	    esac
614947e89262Smrg	  done
615047e89262Smrg	done
615147e89262Smrg	libs="$dlprefiles"
615247e89262Smrg      fi
615347e89262Smrg      if test "$pass" = dlopen; then
615447e89262Smrg	# Collect dlpreopened libraries
615547e89262Smrg	save_deplibs="$deplibs"
615647e89262Smrg	deplibs=
615747e89262Smrg      fi
615847e89262Smrg
615947e89262Smrg      for deplib in $libs; do
616047e89262Smrg	lib=
616147e89262Smrg	found=no
616247e89262Smrg	case $deplib in
6163899129b3Smrg	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
6164899129b3Smrg        |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
616547e89262Smrg	  if test "$linkmode,$pass" = "prog,link"; then
616647e89262Smrg	    compile_deplibs="$deplib $compile_deplibs"
616747e89262Smrg	    finalize_deplibs="$deplib $finalize_deplibs"
616847e89262Smrg	  else
6169899129b3Smrg	    func_append compiler_flags " $deplib"
617047e89262Smrg	    if test "$linkmode" = lib ; then
617147e89262Smrg		case "$new_inherited_linker_flags " in
617247e89262Smrg		    *" $deplib "*) ;;
6173899129b3Smrg		    * ) func_append new_inherited_linker_flags " $deplib" ;;
617447e89262Smrg		esac
617547e89262Smrg	    fi
617647e89262Smrg	  fi
617747e89262Smrg	  continue
617847e89262Smrg	  ;;
617947e89262Smrg	-l*)
618047e89262Smrg	  if test "$linkmode" != lib && test "$linkmode" != prog; then
618147e89262Smrg	    func_warning "\`-l' is ignored for archives/objects"
618247e89262Smrg	    continue
618347e89262Smrg	  fi
618447e89262Smrg	  func_stripname '-l' '' "$deplib"
618547e89262Smrg	  name=$func_stripname_result
618647e89262Smrg	  if test "$linkmode" = lib; then
618747e89262Smrg	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
618847e89262Smrg	  else
618947e89262Smrg	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
619047e89262Smrg	  fi
619147e89262Smrg	  for searchdir in $searchdirs; do
619247e89262Smrg	    for search_ext in .la $std_shrext .so .a; do
619347e89262Smrg	      # Search the libtool library
619447e89262Smrg	      lib="$searchdir/lib${name}${search_ext}"
619547e89262Smrg	      if test -f "$lib"; then
619647e89262Smrg		if test "$search_ext" = ".la"; then
619747e89262Smrg		  found=yes
619847e89262Smrg		else
619947e89262Smrg		  found=no
620047e89262Smrg		fi
620147e89262Smrg		break 2
620247e89262Smrg	      fi
620347e89262Smrg	    done
620447e89262Smrg	  done
620547e89262Smrg	  if test "$found" != yes; then
620647e89262Smrg	    # deplib doesn't seem to be a libtool library
620747e89262Smrg	    if test "$linkmode,$pass" = "prog,link"; then
620847e89262Smrg	      compile_deplibs="$deplib $compile_deplibs"
620947e89262Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
621047e89262Smrg	    else
621147e89262Smrg	      deplibs="$deplib $deplibs"
621247e89262Smrg	      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
621347e89262Smrg	    fi
621447e89262Smrg	    continue
621547e89262Smrg	  else # deplib is a libtool library
621647e89262Smrg	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
621747e89262Smrg	    # We need to do some special things here, and not later.
621847e89262Smrg	    if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
621947e89262Smrg	      case " $predeps $postdeps " in
622047e89262Smrg	      *" $deplib "*)
622147e89262Smrg		if func_lalib_p "$lib"; then
622247e89262Smrg		  library_names=
622347e89262Smrg		  old_library=
622447e89262Smrg		  func_source "$lib"
622547e89262Smrg		  for l in $old_library $library_names; do
622647e89262Smrg		    ll="$l"
622747e89262Smrg		  done
622847e89262Smrg		  if test "X$ll" = "X$old_library" ; then # only static version available
622947e89262Smrg		    found=no
623047e89262Smrg		    func_dirname "$lib" "" "."
623147e89262Smrg		    ladir="$func_dirname_result"
623247e89262Smrg		    lib=$ladir/$old_library
623347e89262Smrg		    if test "$linkmode,$pass" = "prog,link"; then
623447e89262Smrg		      compile_deplibs="$deplib $compile_deplibs"
623547e89262Smrg		      finalize_deplibs="$deplib $finalize_deplibs"
623647e89262Smrg		    else
623747e89262Smrg		      deplibs="$deplib $deplibs"
623847e89262Smrg		      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
623947e89262Smrg		    fi
624047e89262Smrg		    continue
624147e89262Smrg		  fi
624247e89262Smrg		fi
624347e89262Smrg		;;
624447e89262Smrg	      *) ;;
624547e89262Smrg	      esac
624647e89262Smrg	    fi
624747e89262Smrg	  fi
624847e89262Smrg	  ;; # -l
624947e89262Smrg	*.ltframework)
625047e89262Smrg	  if test "$linkmode,$pass" = "prog,link"; then
625147e89262Smrg	    compile_deplibs="$deplib $compile_deplibs"
625247e89262Smrg	    finalize_deplibs="$deplib $finalize_deplibs"
625347e89262Smrg	  else
625447e89262Smrg	    deplibs="$deplib $deplibs"
625547e89262Smrg	    if test "$linkmode" = lib ; then
625647e89262Smrg		case "$new_inherited_linker_flags " in
625747e89262Smrg		    *" $deplib "*) ;;
6258899129b3Smrg		    * ) func_append new_inherited_linker_flags " $deplib" ;;
625947e89262Smrg		esac
626047e89262Smrg	    fi
626147e89262Smrg	  fi
626247e89262Smrg	  continue
626347e89262Smrg	  ;;
626447e89262Smrg	-L*)
626547e89262Smrg	  case $linkmode in
626647e89262Smrg	  lib)
626747e89262Smrg	    deplibs="$deplib $deplibs"
626847e89262Smrg	    test "$pass" = conv && continue
626947e89262Smrg	    newdependency_libs="$deplib $newdependency_libs"
627047e89262Smrg	    func_stripname '-L' '' "$deplib"
6271899129b3Smrg	    func_resolve_sysroot "$func_stripname_result"
6272899129b3Smrg	    func_append newlib_search_path " $func_resolve_sysroot_result"
627347e89262Smrg	    ;;
627447e89262Smrg	  prog)
627547e89262Smrg	    if test "$pass" = conv; then
627647e89262Smrg	      deplibs="$deplib $deplibs"
627747e89262Smrg	      continue
627847e89262Smrg	    fi
627947e89262Smrg	    if test "$pass" = scan; then
628047e89262Smrg	      deplibs="$deplib $deplibs"
628147e89262Smrg	    else
628247e89262Smrg	      compile_deplibs="$deplib $compile_deplibs"
628347e89262Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
628447e89262Smrg	    fi
628547e89262Smrg	    func_stripname '-L' '' "$deplib"
6286899129b3Smrg	    func_resolve_sysroot "$func_stripname_result"
6287899129b3Smrg	    func_append newlib_search_path " $func_resolve_sysroot_result"
628847e89262Smrg	    ;;
628947e89262Smrg	  *)
629047e89262Smrg	    func_warning "\`-L' is ignored for archives/objects"
629147e89262Smrg	    ;;
629247e89262Smrg	  esac # linkmode
629347e89262Smrg	  continue
629447e89262Smrg	  ;; # -L
629547e89262Smrg	-R*)
629647e89262Smrg	  if test "$pass" = link; then
629747e89262Smrg	    func_stripname '-R' '' "$deplib"
6298899129b3Smrg	    func_resolve_sysroot "$func_stripname_result"
6299899129b3Smrg	    dir=$func_resolve_sysroot_result
630047e89262Smrg	    # Make sure the xrpath contains only unique directories.
630147e89262Smrg	    case "$xrpath " in
630247e89262Smrg	    *" $dir "*) ;;
6303899129b3Smrg	    *) func_append xrpath " $dir" ;;
630447e89262Smrg	    esac
630547e89262Smrg	  fi
630647e89262Smrg	  deplibs="$deplib $deplibs"
630747e89262Smrg	  continue
630847e89262Smrg	  ;;
6309899129b3Smrg	*.la)
6310899129b3Smrg	  func_resolve_sysroot "$deplib"
6311899129b3Smrg	  lib=$func_resolve_sysroot_result
6312899129b3Smrg	  ;;
631347e89262Smrg	*.$libext)
631447e89262Smrg	  if test "$pass" = conv; then
631547e89262Smrg	    deplibs="$deplib $deplibs"
631647e89262Smrg	    continue
631747e89262Smrg	  fi
631847e89262Smrg	  case $linkmode in
631947e89262Smrg	  lib)
632047e89262Smrg	    # Linking convenience modules into shared libraries is allowed,
632147e89262Smrg	    # but linking other static libraries is non-portable.
632247e89262Smrg	    case " $dlpreconveniencelibs " in
632347e89262Smrg	    *" $deplib "*) ;;
632447e89262Smrg	    *)
632547e89262Smrg	      valid_a_lib=no
632647e89262Smrg	      case $deplibs_check_method in
632747e89262Smrg		match_pattern*)
632847e89262Smrg		  set dummy $deplibs_check_method; shift
632947e89262Smrg		  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
633047e89262Smrg		  if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
633147e89262Smrg		    | $EGREP "$match_pattern_regex" > /dev/null; then
633247e89262Smrg		    valid_a_lib=yes
633347e89262Smrg		  fi
633447e89262Smrg		;;
633547e89262Smrg		pass_all)
633647e89262Smrg		  valid_a_lib=yes
633747e89262Smrg		;;
633847e89262Smrg	      esac
633947e89262Smrg	      if test "$valid_a_lib" != yes; then
634047e89262Smrg		echo
634147e89262Smrg		$ECHO "*** Warning: Trying to link with static lib archive $deplib."
634247e89262Smrg		echo "*** I have the capability to make that library automatically link in when"
634347e89262Smrg		echo "*** you link to this library.  But I can only do this if you have a"
634447e89262Smrg		echo "*** shared version of the library, which you do not appear to have"
634547e89262Smrg		echo "*** because the file extensions .$libext of this argument makes me believe"
634647e89262Smrg		echo "*** that it is just a static archive that I should not use here."
634747e89262Smrg	      else
634847e89262Smrg		echo
634947e89262Smrg		$ECHO "*** Warning: Linking the shared library $output against the"
635047e89262Smrg		$ECHO "*** static library $deplib is not portable!"
635147e89262Smrg		deplibs="$deplib $deplibs"
635247e89262Smrg	      fi
635347e89262Smrg	      ;;
635447e89262Smrg	    esac
635547e89262Smrg	    continue
635647e89262Smrg	    ;;
635747e89262Smrg	  prog)
635847e89262Smrg	    if test "$pass" != link; then
635947e89262Smrg	      deplibs="$deplib $deplibs"
636047e89262Smrg	    else
636147e89262Smrg	      compile_deplibs="$deplib $compile_deplibs"
636247e89262Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
636347e89262Smrg	    fi
636447e89262Smrg	    continue
636547e89262Smrg	    ;;
636647e89262Smrg	  esac # linkmode
636747e89262Smrg	  ;; # *.$libext
636847e89262Smrg	*.lo | *.$objext)
636947e89262Smrg	  if test "$pass" = conv; then
637047e89262Smrg	    deplibs="$deplib $deplibs"
637147e89262Smrg	  elif test "$linkmode" = prog; then
637247e89262Smrg	    if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
637347e89262Smrg	      # If there is no dlopen support or we're linking statically,
637447e89262Smrg	      # we need to preload.
6375899129b3Smrg	      func_append newdlprefiles " $deplib"
637647e89262Smrg	      compile_deplibs="$deplib $compile_deplibs"
637747e89262Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
637847e89262Smrg	    else
6379899129b3Smrg	      func_append newdlfiles " $deplib"
638047e89262Smrg	    fi
638147e89262Smrg	  fi
638247e89262Smrg	  continue
638347e89262Smrg	  ;;
638447e89262Smrg	%DEPLIBS%)
638547e89262Smrg	  alldeplibs=yes
638647e89262Smrg	  continue
638747e89262Smrg	  ;;
638847e89262Smrg	esac # case $deplib
638947e89262Smrg
639047e89262Smrg	if test "$found" = yes || test -f "$lib"; then :
639147e89262Smrg	else
639247e89262Smrg	  func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'"
639347e89262Smrg	fi
639447e89262Smrg
639547e89262Smrg	# Check to see that this really is a libtool archive.
639647e89262Smrg	func_lalib_unsafe_p "$lib" \
639747e89262Smrg	  || func_fatal_error "\`$lib' is not a valid libtool archive"
639847e89262Smrg
639947e89262Smrg	func_dirname "$lib" "" "."
640047e89262Smrg	ladir="$func_dirname_result"
640147e89262Smrg
640247e89262Smrg	dlname=
640347e89262Smrg	dlopen=
640447e89262Smrg	dlpreopen=
640547e89262Smrg	libdir=
640647e89262Smrg	library_names=
640747e89262Smrg	old_library=
640847e89262Smrg	inherited_linker_flags=
640947e89262Smrg	# If the library was installed with an old release of libtool,
641047e89262Smrg	# it will not redefine variables installed, or shouldnotlink
641147e89262Smrg	installed=yes
641247e89262Smrg	shouldnotlink=no
641347e89262Smrg	avoidtemprpath=
641447e89262Smrg
641547e89262Smrg
641647e89262Smrg	# Read the .la file
641747e89262Smrg	func_source "$lib"
641847e89262Smrg
641947e89262Smrg	# Convert "-framework foo" to "foo.ltframework"
642047e89262Smrg	if test -n "$inherited_linker_flags"; then
642147e89262Smrg	  tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
642247e89262Smrg	  for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
642347e89262Smrg	    case " $new_inherited_linker_flags " in
642447e89262Smrg	      *" $tmp_inherited_linker_flag "*) ;;
6425899129b3Smrg	      *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";;
642647e89262Smrg	    esac
642747e89262Smrg	  done
642847e89262Smrg	fi
642947e89262Smrg	dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
643047e89262Smrg	if test "$linkmode,$pass" = "lib,link" ||
643147e89262Smrg	   test "$linkmode,$pass" = "prog,scan" ||
643247e89262Smrg	   { test "$linkmode" != prog && test "$linkmode" != lib; }; then
6433899129b3Smrg	  test -n "$dlopen" && func_append dlfiles " $dlopen"
6434899129b3Smrg	  test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen"
643547e89262Smrg	fi
643647e89262Smrg
643747e89262Smrg	if test "$pass" = conv; then
643847e89262Smrg	  # Only check for convenience libraries
643947e89262Smrg	  deplibs="$lib $deplibs"
644047e89262Smrg	  if test -z "$libdir"; then
644147e89262Smrg	    if test -z "$old_library"; then
644247e89262Smrg	      func_fatal_error "cannot find name of link library for \`$lib'"
644347e89262Smrg	    fi
644447e89262Smrg	    # It is a libtool convenience library, so add in its objects.
6445899129b3Smrg	    func_append convenience " $ladir/$objdir/$old_library"
6446899129b3Smrg	    func_append old_convenience " $ladir/$objdir/$old_library"
644747e89262Smrg	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
644847e89262Smrg	    func_fatal_error "\`$lib' is not a convenience library"
644947e89262Smrg	  fi
645047e89262Smrg	  tmp_libs=
645147e89262Smrg	  for deplib in $dependency_libs; do
645247e89262Smrg	    deplibs="$deplib $deplibs"
6453899129b3Smrg	    if $opt_preserve_dup_deps ; then
645447e89262Smrg	      case "$tmp_libs " in
6455899129b3Smrg	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
645647e89262Smrg	      esac
645747e89262Smrg	    fi
6458899129b3Smrg	    func_append tmp_libs " $deplib"
645947e89262Smrg	  done
646047e89262Smrg	  continue
646147e89262Smrg	fi # $pass = conv
646247e89262Smrg
646347e89262Smrg
646447e89262Smrg	# Get the name of the library we link against.
646547e89262Smrg	linklib=
6466899129b3Smrg	if test -n "$old_library" &&
6467899129b3Smrg	   { test "$prefer_static_libs" = yes ||
6468899129b3Smrg	     test "$prefer_static_libs,$installed" = "built,no"; }; then
6469899129b3Smrg	  linklib=$old_library
6470899129b3Smrg	else
6471899129b3Smrg	  for l in $old_library $library_names; do
6472899129b3Smrg	    linklib="$l"
6473899129b3Smrg	  done
6474899129b3Smrg	fi
647547e89262Smrg	if test -z "$linklib"; then
647647e89262Smrg	  func_fatal_error "cannot find name of link library for \`$lib'"
647747e89262Smrg	fi
647847e89262Smrg
647947e89262Smrg	# This library was specified with -dlopen.
648047e89262Smrg	if test "$pass" = dlopen; then
648147e89262Smrg	  if test -z "$libdir"; then
648247e89262Smrg	    func_fatal_error "cannot -dlopen a convenience library: \`$lib'"
648347e89262Smrg	  fi
648447e89262Smrg	  if test -z "$dlname" ||
648547e89262Smrg	     test "$dlopen_support" != yes ||
648647e89262Smrg	     test "$build_libtool_libs" = no; then
648747e89262Smrg	    # If there is no dlname, no dlopen support or we're linking
648847e89262Smrg	    # statically, we need to preload.  We also need to preload any
648947e89262Smrg	    # dependent libraries so libltdl's deplib preloader doesn't
649047e89262Smrg	    # bomb out in the load deplibs phase.
6491899129b3Smrg	    func_append dlprefiles " $lib $dependency_libs"
649247e89262Smrg	  else
6493899129b3Smrg	    func_append newdlfiles " $lib"
649447e89262Smrg	  fi
649547e89262Smrg	  continue
649647e89262Smrg	fi # $pass = dlopen
649747e89262Smrg
649847e89262Smrg	# We need an absolute path.
649947e89262Smrg	case $ladir in
650047e89262Smrg	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
650147e89262Smrg	*)
650247e89262Smrg	  abs_ladir=`cd "$ladir" && pwd`
650347e89262Smrg	  if test -z "$abs_ladir"; then
650447e89262Smrg	    func_warning "cannot determine absolute directory name of \`$ladir'"
650547e89262Smrg	    func_warning "passing it literally to the linker, although it might fail"
650647e89262Smrg	    abs_ladir="$ladir"
650747e89262Smrg	  fi
650847e89262Smrg	  ;;
650947e89262Smrg	esac
651047e89262Smrg	func_basename "$lib"
651147e89262Smrg	laname="$func_basename_result"
651247e89262Smrg
651347e89262Smrg	# Find the relevant object directory and library name.
651447e89262Smrg	if test "X$installed" = Xyes; then
6515899129b3Smrg	  if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
651647e89262Smrg	    func_warning "library \`$lib' was moved."
651747e89262Smrg	    dir="$ladir"
651847e89262Smrg	    absdir="$abs_ladir"
651947e89262Smrg	    libdir="$abs_ladir"
652047e89262Smrg	  else
6521899129b3Smrg	    dir="$lt_sysroot$libdir"
6522899129b3Smrg	    absdir="$lt_sysroot$libdir"
652347e89262Smrg	  fi
652447e89262Smrg	  test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
652547e89262Smrg	else
652647e89262Smrg	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
652747e89262Smrg	    dir="$ladir"
652847e89262Smrg	    absdir="$abs_ladir"
652947e89262Smrg	    # Remove this search path later
6530899129b3Smrg	    func_append notinst_path " $abs_ladir"
653147e89262Smrg	  else
653247e89262Smrg	    dir="$ladir/$objdir"
653347e89262Smrg	    absdir="$abs_ladir/$objdir"
653447e89262Smrg	    # Remove this search path later
6535899129b3Smrg	    func_append notinst_path " $abs_ladir"
653647e89262Smrg	  fi
653747e89262Smrg	fi # $installed = yes
653847e89262Smrg	func_stripname 'lib' '.la' "$laname"
653947e89262Smrg	name=$func_stripname_result
654047e89262Smrg
654147e89262Smrg	# This library was specified with -dlpreopen.
654247e89262Smrg	if test "$pass" = dlpreopen; then
654347e89262Smrg	  if test -z "$libdir" && test "$linkmode" = prog; then
654447e89262Smrg	    func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'"
654547e89262Smrg	  fi
6546899129b3Smrg	  case "$host" in
6547899129b3Smrg	    # special handling for platforms with PE-DLLs.
6548899129b3Smrg	    *cygwin* | *mingw* | *cegcc* )
6549899129b3Smrg	      # Linker will automatically link against shared library if both
6550899129b3Smrg	      # static and shared are present.  Therefore, ensure we extract
6551899129b3Smrg	      # symbols from the import library if a shared library is present
6552899129b3Smrg	      # (otherwise, the dlopen module name will be incorrect).  We do
6553899129b3Smrg	      # this by putting the import library name into $newdlprefiles.
6554899129b3Smrg	      # We recover the dlopen module name by 'saving' the la file
6555899129b3Smrg	      # name in a special purpose variable, and (later) extracting the
6556899129b3Smrg	      # dlname from the la file.
6557899129b3Smrg	      if test -n "$dlname"; then
6558899129b3Smrg	        func_tr_sh "$dir/$linklib"
6559899129b3Smrg	        eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname"
6560899129b3Smrg	        func_append newdlprefiles " $dir/$linklib"
6561899129b3Smrg	      else
6562899129b3Smrg	        func_append newdlprefiles " $dir/$old_library"
6563899129b3Smrg	        # Keep a list of preopened convenience libraries to check
6564899129b3Smrg	        # that they are being used correctly in the link pass.
6565899129b3Smrg	        test -z "$libdir" && \
6566899129b3Smrg	          func_append dlpreconveniencelibs " $dir/$old_library"
6567899129b3Smrg	      fi
6568899129b3Smrg	    ;;
6569899129b3Smrg	    * )
6570899129b3Smrg	      # Prefer using a static library (so that no silly _DYNAMIC symbols
6571899129b3Smrg	      # are required to link).
6572899129b3Smrg	      if test -n "$old_library"; then
6573899129b3Smrg	        func_append newdlprefiles " $dir/$old_library"
6574899129b3Smrg	        # Keep a list of preopened convenience libraries to check
6575899129b3Smrg	        # that they are being used correctly in the link pass.
6576899129b3Smrg	        test -z "$libdir" && \
6577899129b3Smrg	          func_append dlpreconveniencelibs " $dir/$old_library"
6578899129b3Smrg	      # Otherwise, use the dlname, so that lt_dlopen finds it.
6579899129b3Smrg	      elif test -n "$dlname"; then
6580899129b3Smrg	        func_append newdlprefiles " $dir/$dlname"
6581899129b3Smrg	      else
6582899129b3Smrg	        func_append newdlprefiles " $dir/$linklib"
6583899129b3Smrg	      fi
6584899129b3Smrg	    ;;
6585899129b3Smrg	  esac
658647e89262Smrg	fi # $pass = dlpreopen
658747e89262Smrg
658847e89262Smrg	if test -z "$libdir"; then
658947e89262Smrg	  # Link the convenience library
659047e89262Smrg	  if test "$linkmode" = lib; then
659147e89262Smrg	    deplibs="$dir/$old_library $deplibs"
659247e89262Smrg	  elif test "$linkmode,$pass" = "prog,link"; then
659347e89262Smrg	    compile_deplibs="$dir/$old_library $compile_deplibs"
659447e89262Smrg	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
659547e89262Smrg	  else
659647e89262Smrg	    deplibs="$lib $deplibs" # used for prog,scan pass
659747e89262Smrg	  fi
659847e89262Smrg	  continue
659947e89262Smrg	fi
660047e89262Smrg
660147e89262Smrg
660247e89262Smrg	if test "$linkmode" = prog && test "$pass" != link; then
6603899129b3Smrg	  func_append newlib_search_path " $ladir"
660447e89262Smrg	  deplibs="$lib $deplibs"
660547e89262Smrg
660647e89262Smrg	  linkalldeplibs=no
660747e89262Smrg	  if test "$link_all_deplibs" != no || test -z "$library_names" ||
660847e89262Smrg	     test "$build_libtool_libs" = no; then
660947e89262Smrg	    linkalldeplibs=yes
661047e89262Smrg	  fi
661147e89262Smrg
661247e89262Smrg	  tmp_libs=
661347e89262Smrg	  for deplib in $dependency_libs; do
661447e89262Smrg	    case $deplib in
661547e89262Smrg	    -L*) func_stripname '-L' '' "$deplib"
6616899129b3Smrg	         func_resolve_sysroot "$func_stripname_result"
6617899129b3Smrg	         func_append newlib_search_path " $func_resolve_sysroot_result"
661847e89262Smrg		 ;;
661947e89262Smrg	    esac
662047e89262Smrg	    # Need to link against all dependency_libs?
662147e89262Smrg	    if test "$linkalldeplibs" = yes; then
662247e89262Smrg	      deplibs="$deplib $deplibs"
662347e89262Smrg	    else
662447e89262Smrg	      # Need to hardcode shared library paths
662547e89262Smrg	      # or/and link against static libraries
662647e89262Smrg	      newdependency_libs="$deplib $newdependency_libs"
662747e89262Smrg	    fi
6628899129b3Smrg	    if $opt_preserve_dup_deps ; then
662947e89262Smrg	      case "$tmp_libs " in
6630899129b3Smrg	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
663147e89262Smrg	      esac
663247e89262Smrg	    fi
6633899129b3Smrg	    func_append tmp_libs " $deplib"
663447e89262Smrg	  done # for deplib
663547e89262Smrg	  continue
663647e89262Smrg	fi # $linkmode = prog...
663747e89262Smrg
663847e89262Smrg	if test "$linkmode,$pass" = "prog,link"; then
663947e89262Smrg	  if test -n "$library_names" &&
664047e89262Smrg	     { { test "$prefer_static_libs" = no ||
664147e89262Smrg	         test "$prefer_static_libs,$installed" = "built,yes"; } ||
664247e89262Smrg	       test -z "$old_library"; }; then
664347e89262Smrg	    # We need to hardcode the library path
664447e89262Smrg	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
664547e89262Smrg	      # Make sure the rpath contains only unique directories.
664647e89262Smrg	      case "$temp_rpath:" in
664747e89262Smrg	      *"$absdir:"*) ;;
6648899129b3Smrg	      *) func_append temp_rpath "$absdir:" ;;
664947e89262Smrg	      esac
665047e89262Smrg	    fi
665147e89262Smrg
665247e89262Smrg	    # Hardcode the library path.
665347e89262Smrg	    # Skip directories that are in the system default run-time
665447e89262Smrg	    # search path.
665547e89262Smrg	    case " $sys_lib_dlsearch_path " in
665647e89262Smrg	    *" $absdir "*) ;;
665747e89262Smrg	    *)
665847e89262Smrg	      case "$compile_rpath " in
665947e89262Smrg	      *" $absdir "*) ;;
6660899129b3Smrg	      *) func_append compile_rpath " $absdir" ;;
666147e89262Smrg	      esac
666247e89262Smrg	      ;;
666347e89262Smrg	    esac
666447e89262Smrg	    case " $sys_lib_dlsearch_path " in
666547e89262Smrg	    *" $libdir "*) ;;
666647e89262Smrg	    *)
666747e89262Smrg	      case "$finalize_rpath " in
666847e89262Smrg	      *" $libdir "*) ;;
6669899129b3Smrg	      *) func_append finalize_rpath " $libdir" ;;
667047e89262Smrg	      esac
667147e89262Smrg	      ;;
667247e89262Smrg	    esac
667347e89262Smrg	  fi # $linkmode,$pass = prog,link...
667447e89262Smrg
667547e89262Smrg	  if test "$alldeplibs" = yes &&
667647e89262Smrg	     { test "$deplibs_check_method" = pass_all ||
667747e89262Smrg	       { test "$build_libtool_libs" = yes &&
667847e89262Smrg		 test -n "$library_names"; }; }; then
667947e89262Smrg	    # We only need to search for static libraries
668047e89262Smrg	    continue
668147e89262Smrg	  fi
668247e89262Smrg	fi
668347e89262Smrg
668447e89262Smrg	link_static=no # Whether the deplib will be linked statically
668547e89262Smrg	use_static_libs=$prefer_static_libs
668647e89262Smrg	if test "$use_static_libs" = built && test "$installed" = yes; then
668747e89262Smrg	  use_static_libs=no
668847e89262Smrg	fi
668947e89262Smrg	if test -n "$library_names" &&
669047e89262Smrg	   { test "$use_static_libs" = no || test -z "$old_library"; }; then
669147e89262Smrg	  case $host in
669247e89262Smrg	  *cygwin* | *mingw* | *cegcc*)
669347e89262Smrg	      # No point in relinking DLLs because paths are not encoded
6694899129b3Smrg	      func_append notinst_deplibs " $lib"
669547e89262Smrg	      need_relink=no
669647e89262Smrg	    ;;
669747e89262Smrg	  *)
669847e89262Smrg	    if test "$installed" = no; then
6699899129b3Smrg	      func_append notinst_deplibs " $lib"
670047e89262Smrg	      need_relink=yes
670147e89262Smrg	    fi
670247e89262Smrg	    ;;
670347e89262Smrg	  esac
670447e89262Smrg	  # This is a shared library
670547e89262Smrg
670647e89262Smrg	  # Warn about portability, can't link against -module's on some
670747e89262Smrg	  # systems (darwin).  Don't bleat about dlopened modules though!
670847e89262Smrg	  dlopenmodule=""
670947e89262Smrg	  for dlpremoduletest in $dlprefiles; do
671047e89262Smrg	    if test "X$dlpremoduletest" = "X$lib"; then
671147e89262Smrg	      dlopenmodule="$dlpremoduletest"
671247e89262Smrg	      break
671347e89262Smrg	    fi
671447e89262Smrg	  done
671547e89262Smrg	  if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then
671647e89262Smrg	    echo
671747e89262Smrg	    if test "$linkmode" = prog; then
671847e89262Smrg	      $ECHO "*** Warning: Linking the executable $output against the loadable module"
671947e89262Smrg	    else
672047e89262Smrg	      $ECHO "*** Warning: Linking the shared library $output against the loadable module"
672147e89262Smrg	    fi
672247e89262Smrg	    $ECHO "*** $linklib is not portable!"
672347e89262Smrg	  fi
672447e89262Smrg	  if test "$linkmode" = lib &&
672547e89262Smrg	     test "$hardcode_into_libs" = yes; then
672647e89262Smrg	    # Hardcode the library path.
672747e89262Smrg	    # Skip directories that are in the system default run-time
672847e89262Smrg	    # search path.
672947e89262Smrg	    case " $sys_lib_dlsearch_path " in
673047e89262Smrg	    *" $absdir "*) ;;
673147e89262Smrg	    *)
673247e89262Smrg	      case "$compile_rpath " in
673347e89262Smrg	      *" $absdir "*) ;;
6734899129b3Smrg	      *) func_append compile_rpath " $absdir" ;;
673547e89262Smrg	      esac
673647e89262Smrg	      ;;
673747e89262Smrg	    esac
673847e89262Smrg	    case " $sys_lib_dlsearch_path " in
673947e89262Smrg	    *" $libdir "*) ;;
674047e89262Smrg	    *)
674147e89262Smrg	      case "$finalize_rpath " in
674247e89262Smrg	      *" $libdir "*) ;;
6743899129b3Smrg	      *) func_append finalize_rpath " $libdir" ;;
674447e89262Smrg	      esac
674547e89262Smrg	      ;;
674647e89262Smrg	    esac
674747e89262Smrg	  fi
674847e89262Smrg
674947e89262Smrg	  if test -n "$old_archive_from_expsyms_cmds"; then
675047e89262Smrg	    # figure out the soname
675147e89262Smrg	    set dummy $library_names
675247e89262Smrg	    shift
675347e89262Smrg	    realname="$1"
675447e89262Smrg	    shift
675547e89262Smrg	    libname=`eval "\\$ECHO \"$libname_spec\""`
675647e89262Smrg	    # use dlname if we got it. it's perfectly good, no?
675747e89262Smrg	    if test -n "$dlname"; then
675847e89262Smrg	      soname="$dlname"
675947e89262Smrg	    elif test -n "$soname_spec"; then
676047e89262Smrg	      # bleh windows
676147e89262Smrg	      case $host in
676247e89262Smrg	      *cygwin* | mingw* | *cegcc*)
676347e89262Smrg	        func_arith $current - $age
676447e89262Smrg		major=$func_arith_result
676547e89262Smrg		versuffix="-$major"
676647e89262Smrg		;;
676747e89262Smrg	      esac
676847e89262Smrg	      eval soname=\"$soname_spec\"
676947e89262Smrg	    else
677047e89262Smrg	      soname="$realname"
677147e89262Smrg	    fi
677247e89262Smrg
677347e89262Smrg	    # Make a new name for the extract_expsyms_cmds to use
677447e89262Smrg	    soroot="$soname"
677547e89262Smrg	    func_basename "$soroot"
677647e89262Smrg	    soname="$func_basename_result"
677747e89262Smrg	    func_stripname 'lib' '.dll' "$soname"
677847e89262Smrg	    newlib=libimp-$func_stripname_result.a
677947e89262Smrg
678047e89262Smrg	    # If the library has no export list, then create one now
678147e89262Smrg	    if test -f "$output_objdir/$soname-def"; then :
678247e89262Smrg	    else
678347e89262Smrg	      func_verbose "extracting exported symbol list from \`$soname'"
678447e89262Smrg	      func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
678547e89262Smrg	    fi
678647e89262Smrg
678747e89262Smrg	    # Create $newlib
678847e89262Smrg	    if test -f "$output_objdir/$newlib"; then :; else
678947e89262Smrg	      func_verbose "generating import library for \`$soname'"
679047e89262Smrg	      func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
679147e89262Smrg	    fi
679247e89262Smrg	    # make sure the library variables are pointing to the new library
679347e89262Smrg	    dir=$output_objdir
679447e89262Smrg	    linklib=$newlib
679547e89262Smrg	  fi # test -n "$old_archive_from_expsyms_cmds"
679647e89262Smrg
6797899129b3Smrg	  if test "$linkmode" = prog || test "$opt_mode" != relink; then
679847e89262Smrg	    add_shlibpath=
679947e89262Smrg	    add_dir=
680047e89262Smrg	    add=
680147e89262Smrg	    lib_linked=yes
680247e89262Smrg	    case $hardcode_action in
680347e89262Smrg	    immediate | unsupported)
680447e89262Smrg	      if test "$hardcode_direct" = no; then
680547e89262Smrg		add="$dir/$linklib"
680647e89262Smrg		case $host in
680747e89262Smrg		  *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
680847e89262Smrg		  *-*-sysv4*uw2*) add_dir="-L$dir" ;;
680947e89262Smrg		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
681047e89262Smrg		    *-*-unixware7*) add_dir="-L$dir" ;;
681147e89262Smrg		  *-*-darwin* )
681247e89262Smrg		    # if the lib is a (non-dlopened) module then we can not
681347e89262Smrg		    # link against it, someone is ignoring the earlier warnings
681447e89262Smrg		    if /usr/bin/file -L $add 2> /dev/null |
681547e89262Smrg			 $GREP ": [^:]* bundle" >/dev/null ; then
681647e89262Smrg		      if test "X$dlopenmodule" != "X$lib"; then
681747e89262Smrg			$ECHO "*** Warning: lib $linklib is a module, not a shared library"
681847e89262Smrg			if test -z "$old_library" ; then
681947e89262Smrg			  echo
682047e89262Smrg			  echo "*** And there doesn't seem to be a static archive available"
682147e89262Smrg			  echo "*** The link will probably fail, sorry"
682247e89262Smrg			else
682347e89262Smrg			  add="$dir/$old_library"
682447e89262Smrg			fi
682547e89262Smrg		      elif test -n "$old_library"; then
682647e89262Smrg			add="$dir/$old_library"
682747e89262Smrg		      fi
682847e89262Smrg		    fi
682947e89262Smrg		esac
683047e89262Smrg	      elif test "$hardcode_minus_L" = no; then
683147e89262Smrg		case $host in
683247e89262Smrg		*-*-sunos*) add_shlibpath="$dir" ;;
683347e89262Smrg		esac
683447e89262Smrg		add_dir="-L$dir"
683547e89262Smrg		add="-l$name"
683647e89262Smrg	      elif test "$hardcode_shlibpath_var" = no; then
683747e89262Smrg		add_shlibpath="$dir"
683847e89262Smrg		add="-l$name"
683947e89262Smrg	      else
684047e89262Smrg		lib_linked=no
684147e89262Smrg	      fi
684247e89262Smrg	      ;;
684347e89262Smrg	    relink)
684447e89262Smrg	      if test "$hardcode_direct" = yes &&
684547e89262Smrg	         test "$hardcode_direct_absolute" = no; then
684647e89262Smrg		add="$dir/$linklib"
684747e89262Smrg	      elif test "$hardcode_minus_L" = yes; then
6848899129b3Smrg		add_dir="-L$absdir"
684947e89262Smrg		# Try looking first in the location we're being installed to.
685047e89262Smrg		if test -n "$inst_prefix_dir"; then
685147e89262Smrg		  case $libdir in
685247e89262Smrg		    [\\/]*)
6853899129b3Smrg		      func_append add_dir " -L$inst_prefix_dir$libdir"
685447e89262Smrg		      ;;
685547e89262Smrg		  esac
685647e89262Smrg		fi
685747e89262Smrg		add="-l$name"
685847e89262Smrg	      elif test "$hardcode_shlibpath_var" = yes; then
685947e89262Smrg		add_shlibpath="$dir"
686047e89262Smrg		add="-l$name"
686147e89262Smrg	      else
686247e89262Smrg		lib_linked=no
686347e89262Smrg	      fi
686447e89262Smrg	      ;;
686547e89262Smrg	    *) lib_linked=no ;;
686647e89262Smrg	    esac
686747e89262Smrg
686847e89262Smrg	    if test "$lib_linked" != yes; then
686947e89262Smrg	      func_fatal_configuration "unsupported hardcode properties"
687047e89262Smrg	    fi
687147e89262Smrg
687247e89262Smrg	    if test -n "$add_shlibpath"; then
687347e89262Smrg	      case :$compile_shlibpath: in
687447e89262Smrg	      *":$add_shlibpath:"*) ;;
6875899129b3Smrg	      *) func_append compile_shlibpath "$add_shlibpath:" ;;
687647e89262Smrg	      esac
687747e89262Smrg	    fi
687847e89262Smrg	    if test "$linkmode" = prog; then
687947e89262Smrg	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
688047e89262Smrg	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
688147e89262Smrg	    else
688247e89262Smrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
688347e89262Smrg	      test -n "$add" && deplibs="$add $deplibs"
688447e89262Smrg	      if test "$hardcode_direct" != yes &&
688547e89262Smrg		 test "$hardcode_minus_L" != yes &&
688647e89262Smrg		 test "$hardcode_shlibpath_var" = yes; then
688747e89262Smrg		case :$finalize_shlibpath: in
688847e89262Smrg		*":$libdir:"*) ;;
6889899129b3Smrg		*) func_append finalize_shlibpath "$libdir:" ;;
689047e89262Smrg		esac
689147e89262Smrg	      fi
689247e89262Smrg	    fi
689347e89262Smrg	  fi
689447e89262Smrg
6895899129b3Smrg	  if test "$linkmode" = prog || test "$opt_mode" = relink; then
689647e89262Smrg	    add_shlibpath=
689747e89262Smrg	    add_dir=
689847e89262Smrg	    add=
689947e89262Smrg	    # Finalize command for both is simple: just hardcode it.
690047e89262Smrg	    if test "$hardcode_direct" = yes &&
690147e89262Smrg	       test "$hardcode_direct_absolute" = no; then
690247e89262Smrg	      add="$libdir/$linklib"
690347e89262Smrg	    elif test "$hardcode_minus_L" = yes; then
690447e89262Smrg	      add_dir="-L$libdir"
690547e89262Smrg	      add="-l$name"
690647e89262Smrg	    elif test "$hardcode_shlibpath_var" = yes; then
690747e89262Smrg	      case :$finalize_shlibpath: in
690847e89262Smrg	      *":$libdir:"*) ;;
6909899129b3Smrg	      *) func_append finalize_shlibpath "$libdir:" ;;
691047e89262Smrg	      esac
691147e89262Smrg	      add="-l$name"
691247e89262Smrg	    elif test "$hardcode_automatic" = yes; then
691347e89262Smrg	      if test -n "$inst_prefix_dir" &&
691447e89262Smrg		 test -f "$inst_prefix_dir$libdir/$linklib" ; then
691547e89262Smrg		add="$inst_prefix_dir$libdir/$linklib"
691647e89262Smrg	      else
691747e89262Smrg		add="$libdir/$linklib"
691847e89262Smrg	      fi
691947e89262Smrg	    else
692047e89262Smrg	      # We cannot seem to hardcode it, guess we'll fake it.
692147e89262Smrg	      add_dir="-L$libdir"
692247e89262Smrg	      # Try looking first in the location we're being installed to.
692347e89262Smrg	      if test -n "$inst_prefix_dir"; then
692447e89262Smrg		case $libdir in
692547e89262Smrg		  [\\/]*)
6926899129b3Smrg		    func_append add_dir " -L$inst_prefix_dir$libdir"
692747e89262Smrg		    ;;
692847e89262Smrg		esac
692947e89262Smrg	      fi
693047e89262Smrg	      add="-l$name"
693147e89262Smrg	    fi
693247e89262Smrg
693347e89262Smrg	    if test "$linkmode" = prog; then
693447e89262Smrg	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
693547e89262Smrg	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
693647e89262Smrg	    else
693747e89262Smrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
693847e89262Smrg	      test -n "$add" && deplibs="$add $deplibs"
693947e89262Smrg	    fi
694047e89262Smrg	  fi
694147e89262Smrg	elif test "$linkmode" = prog; then
694247e89262Smrg	  # Here we assume that one of hardcode_direct or hardcode_minus_L
694347e89262Smrg	  # is not unsupported.  This is valid on all known static and
694447e89262Smrg	  # shared platforms.
694547e89262Smrg	  if test "$hardcode_direct" != unsupported; then
694647e89262Smrg	    test -n "$old_library" && linklib="$old_library"
694747e89262Smrg	    compile_deplibs="$dir/$linklib $compile_deplibs"
694847e89262Smrg	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
694947e89262Smrg	  else
695047e89262Smrg	    compile_deplibs="-l$name -L$dir $compile_deplibs"
695147e89262Smrg	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
695247e89262Smrg	  fi
695347e89262Smrg	elif test "$build_libtool_libs" = yes; then
695447e89262Smrg	  # Not a shared library
695547e89262Smrg	  if test "$deplibs_check_method" != pass_all; then
695647e89262Smrg	    # We're trying link a shared library against a static one
695747e89262Smrg	    # but the system doesn't support it.
695847e89262Smrg
695947e89262Smrg	    # Just print a warning and add the library to dependency_libs so
696047e89262Smrg	    # that the program can be linked against the static library.
696147e89262Smrg	    echo
696247e89262Smrg	    $ECHO "*** Warning: This system can not link to static lib archive $lib."
696347e89262Smrg	    echo "*** I have the capability to make that library automatically link in when"
696447e89262Smrg	    echo "*** you link to this library.  But I can only do this if you have a"
696547e89262Smrg	    echo "*** shared version of the library, which you do not appear to have."
696647e89262Smrg	    if test "$module" = yes; then
696747e89262Smrg	      echo "*** But as you try to build a module library, libtool will still create "
696847e89262Smrg	      echo "*** a static module, that should work as long as the dlopening application"
696947e89262Smrg	      echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
697047e89262Smrg	      if test -z "$global_symbol_pipe"; then
697147e89262Smrg		echo
697247e89262Smrg		echo "*** However, this would only work if libtool was able to extract symbol"
697347e89262Smrg		echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
697447e89262Smrg		echo "*** not find such a program.  So, this module is probably useless."
697547e89262Smrg		echo "*** \`nm' from GNU binutils and a full rebuild may help."
697647e89262Smrg	      fi
697747e89262Smrg	      if test "$build_old_libs" = no; then
697847e89262Smrg		build_libtool_libs=module
697947e89262Smrg		build_old_libs=yes
698047e89262Smrg	      else
698147e89262Smrg		build_libtool_libs=no
698247e89262Smrg	      fi
698347e89262Smrg	    fi
698447e89262Smrg	  else
698547e89262Smrg	    deplibs="$dir/$old_library $deplibs"
698647e89262Smrg	    link_static=yes
698747e89262Smrg	  fi
698847e89262Smrg	fi # link shared/static library?
698947e89262Smrg
699047e89262Smrg	if test "$linkmode" = lib; then
699147e89262Smrg	  if test -n "$dependency_libs" &&
699247e89262Smrg	     { test "$hardcode_into_libs" != yes ||
699347e89262Smrg	       test "$build_old_libs" = yes ||
699447e89262Smrg	       test "$link_static" = yes; }; then
699547e89262Smrg	    # Extract -R from dependency_libs
699647e89262Smrg	    temp_deplibs=
699747e89262Smrg	    for libdir in $dependency_libs; do
699847e89262Smrg	      case $libdir in
699947e89262Smrg	      -R*) func_stripname '-R' '' "$libdir"
700047e89262Smrg	           temp_xrpath=$func_stripname_result
700147e89262Smrg		   case " $xrpath " in
700247e89262Smrg		   *" $temp_xrpath "*) ;;
7003899129b3Smrg		   *) func_append xrpath " $temp_xrpath";;
700447e89262Smrg		   esac;;
7005899129b3Smrg	      *) func_append temp_deplibs " $libdir";;
700647e89262Smrg	      esac
700747e89262Smrg	    done
700847e89262Smrg	    dependency_libs="$temp_deplibs"
700947e89262Smrg	  fi
701047e89262Smrg
7011899129b3Smrg	  func_append newlib_search_path " $absdir"
701247e89262Smrg	  # Link against this library
701347e89262Smrg	  test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
701447e89262Smrg	  # ... and its dependency_libs
701547e89262Smrg	  tmp_libs=
701647e89262Smrg	  for deplib in $dependency_libs; do
701747e89262Smrg	    newdependency_libs="$deplib $newdependency_libs"
7018899129b3Smrg	    case $deplib in
7019899129b3Smrg              -L*) func_stripname '-L' '' "$deplib"
7020899129b3Smrg                   func_resolve_sysroot "$func_stripname_result";;
7021899129b3Smrg              *) func_resolve_sysroot "$deplib" ;;
7022899129b3Smrg            esac
7023899129b3Smrg	    if $opt_preserve_dup_deps ; then
702447e89262Smrg	      case "$tmp_libs " in
7025899129b3Smrg	      *" $func_resolve_sysroot_result "*)
7026899129b3Smrg                func_append specialdeplibs " $func_resolve_sysroot_result" ;;
702747e89262Smrg	      esac
702847e89262Smrg	    fi
7029899129b3Smrg	    func_append tmp_libs " $func_resolve_sysroot_result"
703047e89262Smrg	  done
703147e89262Smrg
703247e89262Smrg	  if test "$link_all_deplibs" != no; then
703347e89262Smrg	    # Add the search paths of all dependency libraries
703447e89262Smrg	    for deplib in $dependency_libs; do
703547e89262Smrg	      path=
703647e89262Smrg	      case $deplib in
703747e89262Smrg	      -L*) path="$deplib" ;;
703847e89262Smrg	      *.la)
7039899129b3Smrg	        func_resolve_sysroot "$deplib"
7040899129b3Smrg	        deplib=$func_resolve_sysroot_result
704147e89262Smrg	        func_dirname "$deplib" "" "."
7042899129b3Smrg		dir=$func_dirname_result
704347e89262Smrg		# We need an absolute path.
704447e89262Smrg		case $dir in
704547e89262Smrg		[\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
704647e89262Smrg		*)
704747e89262Smrg		  absdir=`cd "$dir" && pwd`
704847e89262Smrg		  if test -z "$absdir"; then
704947e89262Smrg		    func_warning "cannot determine absolute directory name of \`$dir'"
705047e89262Smrg		    absdir="$dir"
705147e89262Smrg		  fi
705247e89262Smrg		  ;;
705347e89262Smrg		esac
705447e89262Smrg		if $GREP "^installed=no" $deplib > /dev/null; then
705547e89262Smrg		case $host in
705647e89262Smrg		*-*-darwin*)
705747e89262Smrg		  depdepl=
705847e89262Smrg		  eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
705947e89262Smrg		  if test -n "$deplibrary_names" ; then
706047e89262Smrg		    for tmp in $deplibrary_names ; do
706147e89262Smrg		      depdepl=$tmp
706247e89262Smrg		    done
706347e89262Smrg		    if test -f "$absdir/$objdir/$depdepl" ; then
706447e89262Smrg		      depdepl="$absdir/$objdir/$depdepl"
706547e89262Smrg		      darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
706647e89262Smrg                      if test -z "$darwin_install_name"; then
706747e89262Smrg                          darwin_install_name=`${OTOOL64} -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
706847e89262Smrg                      fi
7069899129b3Smrg		      func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}"
7070899129b3Smrg		      func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}"
707147e89262Smrg		      path=
707247e89262Smrg		    fi
707347e89262Smrg		  fi
707447e89262Smrg		  ;;
707547e89262Smrg		*)
707647e89262Smrg		  path="-L$absdir/$objdir"
707747e89262Smrg		  ;;
707847e89262Smrg		esac
707947e89262Smrg		else
708047e89262Smrg		  eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
708147e89262Smrg		  test -z "$libdir" && \
708247e89262Smrg		    func_fatal_error "\`$deplib' is not a valid libtool archive"
708347e89262Smrg		  test "$absdir" != "$libdir" && \
708447e89262Smrg		    func_warning "\`$deplib' seems to be moved"
708547e89262Smrg
708647e89262Smrg		  path="-L$absdir"
708747e89262Smrg		fi
708847e89262Smrg		;;
708947e89262Smrg	      esac
709047e89262Smrg	      case " $deplibs " in
709147e89262Smrg	      *" $path "*) ;;
709247e89262Smrg	      *) deplibs="$path $deplibs" ;;
709347e89262Smrg	      esac
709447e89262Smrg	    done
709547e89262Smrg	  fi # link_all_deplibs != no
709647e89262Smrg	fi # linkmode = lib
709747e89262Smrg      done # for deplib in $libs
709847e89262Smrg      if test "$pass" = link; then
709947e89262Smrg	if test "$linkmode" = "prog"; then
710047e89262Smrg	  compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
710147e89262Smrg	  finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
710247e89262Smrg	else
710347e89262Smrg	  compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
710447e89262Smrg	fi
710547e89262Smrg      fi
710647e89262Smrg      dependency_libs="$newdependency_libs"
710747e89262Smrg      if test "$pass" = dlpreopen; then
710847e89262Smrg	# Link the dlpreopened libraries before other libraries
710947e89262Smrg	for deplib in $save_deplibs; do
711047e89262Smrg	  deplibs="$deplib $deplibs"
711147e89262Smrg	done
711247e89262Smrg      fi
711347e89262Smrg      if test "$pass" != dlopen; then
711447e89262Smrg	if test "$pass" != conv; then
711547e89262Smrg	  # Make sure lib_search_path contains only unique directories.
711647e89262Smrg	  lib_search_path=
711747e89262Smrg	  for dir in $newlib_search_path; do
711847e89262Smrg	    case "$lib_search_path " in
711947e89262Smrg	    *" $dir "*) ;;
7120899129b3Smrg	    *) func_append lib_search_path " $dir" ;;
712147e89262Smrg	    esac
712247e89262Smrg	  done
712347e89262Smrg	  newlib_search_path=
712447e89262Smrg	fi
712547e89262Smrg
712647e89262Smrg	if test "$linkmode,$pass" != "prog,link"; then
712747e89262Smrg	  vars="deplibs"
712847e89262Smrg	else
712947e89262Smrg	  vars="compile_deplibs finalize_deplibs"
713047e89262Smrg	fi
713147e89262Smrg	for var in $vars dependency_libs; do
713247e89262Smrg	  # Add libraries to $var in reverse order
713347e89262Smrg	  eval tmp_libs=\"\$$var\"
713447e89262Smrg	  new_libs=
713547e89262Smrg	  for deplib in $tmp_libs; do
713647e89262Smrg	    # FIXME: Pedantically, this is the right thing to do, so
713747e89262Smrg	    #        that some nasty dependency loop isn't accidentally
713847e89262Smrg	    #        broken:
713947e89262Smrg	    #new_libs="$deplib $new_libs"
714047e89262Smrg	    # Pragmatically, this seems to cause very few problems in
714147e89262Smrg	    # practice:
714247e89262Smrg	    case $deplib in
714347e89262Smrg	    -L*) new_libs="$deplib $new_libs" ;;
714447e89262Smrg	    -R*) ;;
714547e89262Smrg	    *)
714647e89262Smrg	      # And here is the reason: when a library appears more
714747e89262Smrg	      # than once as an explicit dependence of a library, or
714847e89262Smrg	      # is implicitly linked in more than once by the
714947e89262Smrg	      # compiler, it is considered special, and multiple
715047e89262Smrg	      # occurrences thereof are not removed.  Compare this
715147e89262Smrg	      # with having the same library being listed as a
715247e89262Smrg	      # dependency of multiple other libraries: in this case,
715347e89262Smrg	      # we know (pedantically, we assume) the library does not
715447e89262Smrg	      # need to be listed more than once, so we keep only the
715547e89262Smrg	      # last copy.  This is not always right, but it is rare
715647e89262Smrg	      # enough that we require users that really mean to play
715747e89262Smrg	      # such unportable linking tricks to link the library
715847e89262Smrg	      # using -Wl,-lname, so that libtool does not consider it
715947e89262Smrg	      # for duplicate removal.
716047e89262Smrg	      case " $specialdeplibs " in
716147e89262Smrg	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
716247e89262Smrg	      *)
716347e89262Smrg		case " $new_libs " in
716447e89262Smrg		*" $deplib "*) ;;
716547e89262Smrg		*) new_libs="$deplib $new_libs" ;;
716647e89262Smrg		esac
716747e89262Smrg		;;
716847e89262Smrg	      esac
716947e89262Smrg	      ;;
717047e89262Smrg	    esac
717147e89262Smrg	  done
717247e89262Smrg	  tmp_libs=
717347e89262Smrg	  for deplib in $new_libs; do
717447e89262Smrg	    case $deplib in
717547e89262Smrg	    -L*)
717647e89262Smrg	      case " $tmp_libs " in
717747e89262Smrg	      *" $deplib "*) ;;
7178899129b3Smrg	      *) func_append tmp_libs " $deplib" ;;
717947e89262Smrg	      esac
718047e89262Smrg	      ;;
7181899129b3Smrg	    *) func_append tmp_libs " $deplib" ;;
718247e89262Smrg	    esac
718347e89262Smrg	  done
718447e89262Smrg	  eval $var=\"$tmp_libs\"
718547e89262Smrg	done # for var
718647e89262Smrg      fi
718747e89262Smrg      # Last step: remove runtime libs from dependency_libs
718847e89262Smrg      # (they stay in deplibs)
718947e89262Smrg      tmp_libs=
719047e89262Smrg      for i in $dependency_libs ; do
719147e89262Smrg	case " $predeps $postdeps $compiler_lib_search_path " in
719247e89262Smrg	*" $i "*)
719347e89262Smrg	  i=""
719447e89262Smrg	  ;;
719547e89262Smrg	esac
719647e89262Smrg	if test -n "$i" ; then
7197899129b3Smrg	  func_append tmp_libs " $i"
719847e89262Smrg	fi
719947e89262Smrg      done
720047e89262Smrg      dependency_libs=$tmp_libs
720147e89262Smrg    done # for pass
720247e89262Smrg    if test "$linkmode" = prog; then
720347e89262Smrg      dlfiles="$newdlfiles"
720447e89262Smrg    fi
720547e89262Smrg    if test "$linkmode" = prog || test "$linkmode" = lib; then
720647e89262Smrg      dlprefiles="$newdlprefiles"
720747e89262Smrg    fi
720847e89262Smrg
720947e89262Smrg    case $linkmode in
721047e89262Smrg    oldlib)
721147e89262Smrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
721247e89262Smrg	func_warning "\`-dlopen' is ignored for archives"
721347e89262Smrg      fi
721447e89262Smrg
721547e89262Smrg      case " $deplibs" in
721647e89262Smrg      *\ -l* | *\ -L*)
721747e89262Smrg	func_warning "\`-l' and \`-L' are ignored for archives" ;;
721847e89262Smrg      esac
721947e89262Smrg
722047e89262Smrg      test -n "$rpath" && \
722147e89262Smrg	func_warning "\`-rpath' is ignored for archives"
722247e89262Smrg
722347e89262Smrg      test -n "$xrpath" && \
722447e89262Smrg	func_warning "\`-R' is ignored for archives"
722547e89262Smrg
722647e89262Smrg      test -n "$vinfo" && \
722747e89262Smrg	func_warning "\`-version-info/-version-number' is ignored for archives"
722847e89262Smrg
722947e89262Smrg      test -n "$release" && \
723047e89262Smrg	func_warning "\`-release' is ignored for archives"
723147e89262Smrg
723247e89262Smrg      test -n "$export_symbols$export_symbols_regex" && \
723347e89262Smrg	func_warning "\`-export-symbols' is ignored for archives"
723447e89262Smrg
723547e89262Smrg      # Now set the variables for building old libraries.
723647e89262Smrg      build_libtool_libs=no
723747e89262Smrg      oldlibs="$output"
7238899129b3Smrg      func_append objs "$old_deplibs"
723947e89262Smrg      ;;
724047e89262Smrg
724147e89262Smrg    lib)
724247e89262Smrg      # Make sure we only generate libraries of the form `libNAME.la'.
724347e89262Smrg      case $outputname in
724447e89262Smrg      lib*)
724547e89262Smrg	func_stripname 'lib' '.la' "$outputname"
724647e89262Smrg	name=$func_stripname_result
724747e89262Smrg	eval shared_ext=\"$shrext_cmds\"
724847e89262Smrg	eval libname=\"$libname_spec\"
724947e89262Smrg	;;
725047e89262Smrg      *)
725147e89262Smrg	test "$module" = no && \
725247e89262Smrg	  func_fatal_help "libtool library \`$output' must begin with \`lib'"
725347e89262Smrg
725447e89262Smrg	if test "$need_lib_prefix" != no; then
725547e89262Smrg	  # Add the "lib" prefix for modules if required
725647e89262Smrg	  func_stripname '' '.la' "$outputname"
725747e89262Smrg	  name=$func_stripname_result
725847e89262Smrg	  eval shared_ext=\"$shrext_cmds\"
725947e89262Smrg	  eval libname=\"$libname_spec\"
726047e89262Smrg	else
726147e89262Smrg	  func_stripname '' '.la' "$outputname"
726247e89262Smrg	  libname=$func_stripname_result
726347e89262Smrg	fi
726447e89262Smrg	;;
726547e89262Smrg      esac
726647e89262Smrg
726747e89262Smrg      if test -n "$objs"; then
726847e89262Smrg	if test "$deplibs_check_method" != pass_all; then
726947e89262Smrg	  func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs"
727047e89262Smrg	else
727147e89262Smrg	  echo
727247e89262Smrg	  $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
727347e89262Smrg	  $ECHO "*** objects $objs is not portable!"
7274899129b3Smrg	  func_append libobjs " $objs"
727547e89262Smrg	fi
727647e89262Smrg      fi
727747e89262Smrg
727847e89262Smrg      test "$dlself" != no && \
727947e89262Smrg	func_warning "\`-dlopen self' is ignored for libtool libraries"
728047e89262Smrg
728147e89262Smrg      set dummy $rpath
728247e89262Smrg      shift
728347e89262Smrg      test "$#" -gt 1 && \
728447e89262Smrg	func_warning "ignoring multiple \`-rpath's for a libtool library"
728547e89262Smrg
728647e89262Smrg      install_libdir="$1"
728747e89262Smrg
728847e89262Smrg      oldlibs=
728947e89262Smrg      if test -z "$rpath"; then
729047e89262Smrg	if test "$build_libtool_libs" = yes; then
729147e89262Smrg	  # Building a libtool convenience library.
729247e89262Smrg	  # Some compilers have problems with a `.al' extension so
729347e89262Smrg	  # convenience libraries should have the same extension an
729447e89262Smrg	  # archive normally would.
729547e89262Smrg	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
729647e89262Smrg	  build_libtool_libs=convenience
729747e89262Smrg	  build_old_libs=yes
729847e89262Smrg	fi
729947e89262Smrg
730047e89262Smrg	test -n "$vinfo" && \
730147e89262Smrg	  func_warning "\`-version-info/-version-number' is ignored for convenience libraries"
730247e89262Smrg
730347e89262Smrg	test -n "$release" && \
730447e89262Smrg	  func_warning "\`-release' is ignored for convenience libraries"
730547e89262Smrg      else
730647e89262Smrg
730747e89262Smrg	# Parse the version information argument.
730847e89262Smrg	save_ifs="$IFS"; IFS=':'
730947e89262Smrg	set dummy $vinfo 0 0 0
731047e89262Smrg	shift
731147e89262Smrg	IFS="$save_ifs"
731247e89262Smrg
731347e89262Smrg	test -n "$7" && \
731447e89262Smrg	  func_fatal_help "too many parameters to \`-version-info'"
731547e89262Smrg
731647e89262Smrg	# convert absolute version numbers to libtool ages
731747e89262Smrg	# this retains compatibility with .la files and attempts
731847e89262Smrg	# to make the code below a bit more comprehensible
731947e89262Smrg
732047e89262Smrg	case $vinfo_number in
732147e89262Smrg	yes)
732247e89262Smrg	  number_major="$1"
732347e89262Smrg	  number_minor="$2"
732447e89262Smrg	  number_revision="$3"
732547e89262Smrg	  #
732647e89262Smrg	  # There are really only two kinds -- those that
732747e89262Smrg	  # use the current revision as the major version
732847e89262Smrg	  # and those that subtract age and use age as
732947e89262Smrg	  # a minor version.  But, then there is irix
733047e89262Smrg	  # which has an extra 1 added just for fun
733147e89262Smrg	  #
733247e89262Smrg	  case $version_type in
7333899129b3Smrg	  # correct linux to gnu/linux during the next big refactor
733447e89262Smrg	  darwin|linux|osf|windows|none)
733547e89262Smrg	    func_arith $number_major + $number_minor
733647e89262Smrg	    current=$func_arith_result
733747e89262Smrg	    age="$number_minor"
733847e89262Smrg	    revision="$number_revision"
733947e89262Smrg	    ;;
734047e89262Smrg	  freebsd-aout|freebsd-elf|qnx|sunos)
734147e89262Smrg	    current="$number_major"
734247e89262Smrg	    revision="$number_minor"
734347e89262Smrg	    age="0"
734447e89262Smrg	    ;;
734547e89262Smrg	  irix|nonstopux)
734647e89262Smrg	    func_arith $number_major + $number_minor
734747e89262Smrg	    current=$func_arith_result
734847e89262Smrg	    age="$number_minor"
734947e89262Smrg	    revision="$number_minor"
735047e89262Smrg	    lt_irix_increment=no
735147e89262Smrg	    ;;
735247e89262Smrg	  esac
735347e89262Smrg	  ;;
735447e89262Smrg	no)
735547e89262Smrg	  current="$1"
735647e89262Smrg	  revision="$2"
735747e89262Smrg	  age="$3"
735847e89262Smrg	  ;;
735947e89262Smrg	esac
736047e89262Smrg
736147e89262Smrg	# Check that each of the things are valid numbers.
736247e89262Smrg	case $current in
736347e89262Smrg	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]) ;;
736447e89262Smrg	*)
736547e89262Smrg	  func_error "CURRENT \`$current' must be a nonnegative integer"
736647e89262Smrg	  func_fatal_error "\`$vinfo' is not valid version information"
736747e89262Smrg	  ;;
736847e89262Smrg	esac
736947e89262Smrg
737047e89262Smrg	case $revision in
737147e89262Smrg	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]) ;;
737247e89262Smrg	*)
737347e89262Smrg	  func_error "REVISION \`$revision' must be a nonnegative integer"
737447e89262Smrg	  func_fatal_error "\`$vinfo' is not valid version information"
737547e89262Smrg	  ;;
737647e89262Smrg	esac
737747e89262Smrg
737847e89262Smrg	case $age in
737947e89262Smrg	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]) ;;
738047e89262Smrg	*)
738147e89262Smrg	  func_error "AGE \`$age' must be a nonnegative integer"
738247e89262Smrg	  func_fatal_error "\`$vinfo' is not valid version information"
738347e89262Smrg	  ;;
738447e89262Smrg	esac
738547e89262Smrg
738647e89262Smrg	if test "$age" -gt "$current"; then
738747e89262Smrg	  func_error "AGE \`$age' is greater than the current interface number \`$current'"
738847e89262Smrg	  func_fatal_error "\`$vinfo' is not valid version information"
738947e89262Smrg	fi
739047e89262Smrg
739147e89262Smrg	# Calculate the version variables.
739247e89262Smrg	major=
739347e89262Smrg	versuffix=
739447e89262Smrg	verstring=
739547e89262Smrg	case $version_type in
739647e89262Smrg	none) ;;
739747e89262Smrg
739847e89262Smrg	darwin)
739947e89262Smrg	  # Like Linux, but with the current version available in
740047e89262Smrg	  # verstring for coding it into the library header
740147e89262Smrg	  func_arith $current - $age
740247e89262Smrg	  major=.$func_arith_result
740347e89262Smrg	  versuffix="$major.$age.$revision"
740447e89262Smrg	  # Darwin ld doesn't like 0 for these options...
740547e89262Smrg	  func_arith $current + 1
740647e89262Smrg	  minor_current=$func_arith_result
740747e89262Smrg	  xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
740847e89262Smrg	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
740947e89262Smrg	  ;;
741047e89262Smrg
741147e89262Smrg	freebsd-aout)
741247e89262Smrg	  major=".$current"
741347e89262Smrg	  versuffix=".$current.$revision";
741447e89262Smrg	  ;;
741547e89262Smrg
741647e89262Smrg	freebsd-elf)
741747e89262Smrg	  major=".$current"
741847e89262Smrg	  versuffix=".$current"
741947e89262Smrg	  ;;
742047e89262Smrg
742147e89262Smrg	irix | nonstopux)
742247e89262Smrg	  if test "X$lt_irix_increment" = "Xno"; then
742347e89262Smrg	    func_arith $current - $age
742447e89262Smrg	  else
742547e89262Smrg	    func_arith $current - $age + 1
742647e89262Smrg	  fi
742747e89262Smrg	  major=$func_arith_result
742847e89262Smrg
742947e89262Smrg	  case $version_type in
743047e89262Smrg	    nonstopux) verstring_prefix=nonstopux ;;
743147e89262Smrg	    *)         verstring_prefix=sgi ;;
743247e89262Smrg	  esac
743347e89262Smrg	  verstring="$verstring_prefix$major.$revision"
743447e89262Smrg
743547e89262Smrg	  # Add in all the interfaces that we are compatible with.
743647e89262Smrg	  loop=$revision
743747e89262Smrg	  while test "$loop" -ne 0; do
743847e89262Smrg	    func_arith $revision - $loop
743947e89262Smrg	    iface=$func_arith_result
744047e89262Smrg	    func_arith $loop - 1
744147e89262Smrg	    loop=$func_arith_result
744247e89262Smrg	    verstring="$verstring_prefix$major.$iface:$verstring"
744347e89262Smrg	  done
744447e89262Smrg
744547e89262Smrg	  # Before this point, $major must not contain `.'.
744647e89262Smrg	  major=.$major
744747e89262Smrg	  versuffix="$major.$revision"
744847e89262Smrg	  ;;
744947e89262Smrg
7450899129b3Smrg	linux) # correct to gnu/linux during the next big refactor
745147e89262Smrg	  func_arith $current - $age
745247e89262Smrg	  major=.$func_arith_result
745347e89262Smrg	  versuffix="$major.$age.$revision"
745447e89262Smrg	  ;;
745547e89262Smrg
745647e89262Smrg	osf)
745747e89262Smrg	  func_arith $current - $age
745847e89262Smrg	  major=.$func_arith_result
745947e89262Smrg	  versuffix=".$current.$age.$revision"
746047e89262Smrg	  verstring="$current.$age.$revision"
746147e89262Smrg
746247e89262Smrg	  # Add in all the interfaces that we are compatible with.
746347e89262Smrg	  loop=$age
746447e89262Smrg	  while test "$loop" -ne 0; do
746547e89262Smrg	    func_arith $current - $loop
746647e89262Smrg	    iface=$func_arith_result
746747e89262Smrg	    func_arith $loop - 1
746847e89262Smrg	    loop=$func_arith_result
746947e89262Smrg	    verstring="$verstring:${iface}.0"
747047e89262Smrg	  done
747147e89262Smrg
747247e89262Smrg	  # Make executables depend on our current version.
7473899129b3Smrg	  func_append verstring ":${current}.0"
747447e89262Smrg	  ;;
747547e89262Smrg
747647e89262Smrg	qnx)
747747e89262Smrg	  major=".$current"
747847e89262Smrg	  versuffix=".$current"
747947e89262Smrg	  ;;
748047e89262Smrg
748147e89262Smrg	sunos)
748247e89262Smrg	  major=".$current"
748347e89262Smrg	  versuffix=".$current.$revision"
748447e89262Smrg	  ;;
748547e89262Smrg
748647e89262Smrg	windows)
748747e89262Smrg	  # Use '-' rather than '.', since we only want one
748847e89262Smrg	  # extension on DOS 8.3 filesystems.
748947e89262Smrg	  func_arith $current - $age
749047e89262Smrg	  major=$func_arith_result
749147e89262Smrg	  versuffix="-$major"
749247e89262Smrg	  ;;
749347e89262Smrg
749447e89262Smrg	*)
749547e89262Smrg	  func_fatal_configuration "unknown library version type \`$version_type'"
749647e89262Smrg	  ;;
749747e89262Smrg	esac
749847e89262Smrg
749947e89262Smrg	# Clear the version info if we defaulted, and they specified a release.
750047e89262Smrg	if test -z "$vinfo" && test -n "$release"; then
750147e89262Smrg	  major=
750247e89262Smrg	  case $version_type in
750347e89262Smrg	  darwin)
750447e89262Smrg	    # we can't check for "0.0" in archive_cmds due to quoting
750547e89262Smrg	    # problems, so we reset it completely
750647e89262Smrg	    verstring=
750747e89262Smrg	    ;;
750847e89262Smrg	  *)
750947e89262Smrg	    verstring="0.0"
751047e89262Smrg	    ;;
751147e89262Smrg	  esac
751247e89262Smrg	  if test "$need_version" = no; then
751347e89262Smrg	    versuffix=
751447e89262Smrg	  else
751547e89262Smrg	    versuffix=".0.0"
751647e89262Smrg	  fi
751747e89262Smrg	fi
751847e89262Smrg
751947e89262Smrg	# Remove version info from name if versioning should be avoided
752047e89262Smrg	if test "$avoid_version" = yes && test "$need_version" = no; then
752147e89262Smrg	  major=
752247e89262Smrg	  versuffix=
752347e89262Smrg	  verstring=""
752447e89262Smrg	fi
752547e89262Smrg
752647e89262Smrg	# Check to see if the archive will have undefined symbols.
752747e89262Smrg	if test "$allow_undefined" = yes; then
752847e89262Smrg	  if test "$allow_undefined_flag" = unsupported; then
752947e89262Smrg	    func_warning "undefined symbols not allowed in $host shared libraries"
753047e89262Smrg	    build_libtool_libs=no
753147e89262Smrg	    build_old_libs=yes
753247e89262Smrg	  fi
753347e89262Smrg	else
753447e89262Smrg	  # Don't allow undefined symbols.
753547e89262Smrg	  allow_undefined_flag="$no_undefined_flag"
753647e89262Smrg	fi
753747e89262Smrg
753847e89262Smrg      fi
753947e89262Smrg
754047e89262Smrg      func_generate_dlsyms "$libname" "$libname" "yes"
7541899129b3Smrg      func_append libobjs " $symfileobj"
754247e89262Smrg      test "X$libobjs" = "X " && libobjs=
754347e89262Smrg
7544899129b3Smrg      if test "$opt_mode" != relink; then
754547e89262Smrg	# Remove our outputs, but don't remove object files since they
754647e89262Smrg	# may have been created when compiling PIC objects.
754747e89262Smrg	removelist=
754847e89262Smrg	tempremovelist=`$ECHO "$output_objdir/*"`
754947e89262Smrg	for p in $tempremovelist; do
755047e89262Smrg	  case $p in
755147e89262Smrg	    *.$objext | *.gcno)
755247e89262Smrg	       ;;
755347e89262Smrg	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
755447e89262Smrg	       if test "X$precious_files_regex" != "X"; then
755547e89262Smrg		 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
755647e89262Smrg		 then
755747e89262Smrg		   continue
755847e89262Smrg		 fi
755947e89262Smrg	       fi
7560899129b3Smrg	       func_append removelist " $p"
756147e89262Smrg	       ;;
756247e89262Smrg	    *) ;;
756347e89262Smrg	  esac
756447e89262Smrg	done
756547e89262Smrg	test -n "$removelist" && \
756647e89262Smrg	  func_show_eval "${RM}r \$removelist"
756747e89262Smrg      fi
756847e89262Smrg
756947e89262Smrg      # Now set the variables for building old libraries.
757047e89262Smrg      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
7571899129b3Smrg	func_append oldlibs " $output_objdir/$libname.$libext"
757247e89262Smrg
757347e89262Smrg	# Transform .lo files to .o files.
757447e89262Smrg	oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP`
757547e89262Smrg      fi
757647e89262Smrg
757747e89262Smrg      # Eliminate all temporary directories.
757847e89262Smrg      #for path in $notinst_path; do
757947e89262Smrg      #	lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
758047e89262Smrg      #	deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
758147e89262Smrg      #	dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
758247e89262Smrg      #done
758347e89262Smrg
758447e89262Smrg      if test -n "$xrpath"; then
758547e89262Smrg	# If the user specified any rpath flags, then add them.
758647e89262Smrg	temp_xrpath=
758747e89262Smrg	for libdir in $xrpath; do
7588899129b3Smrg	  func_replace_sysroot "$libdir"
7589899129b3Smrg	  func_append temp_xrpath " -R$func_replace_sysroot_result"
759047e89262Smrg	  case "$finalize_rpath " in
759147e89262Smrg	  *" $libdir "*) ;;
7592899129b3Smrg	  *) func_append finalize_rpath " $libdir" ;;
759347e89262Smrg	  esac
759447e89262Smrg	done
759547e89262Smrg	if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
759647e89262Smrg	  dependency_libs="$temp_xrpath $dependency_libs"
759747e89262Smrg	fi
759847e89262Smrg      fi
759947e89262Smrg
760047e89262Smrg      # Make sure dlfiles contains only unique files that won't be dlpreopened
760147e89262Smrg      old_dlfiles="$dlfiles"
760247e89262Smrg      dlfiles=
760347e89262Smrg      for lib in $old_dlfiles; do
760447e89262Smrg	case " $dlprefiles $dlfiles " in
760547e89262Smrg	*" $lib "*) ;;
7606899129b3Smrg	*) func_append dlfiles " $lib" ;;
760747e89262Smrg	esac
760847e89262Smrg      done
760947e89262Smrg
761047e89262Smrg      # Make sure dlprefiles contains only unique files
761147e89262Smrg      old_dlprefiles="$dlprefiles"
761247e89262Smrg      dlprefiles=
761347e89262Smrg      for lib in $old_dlprefiles; do
761447e89262Smrg	case "$dlprefiles " in
761547e89262Smrg	*" $lib "*) ;;
7616899129b3Smrg	*) func_append dlprefiles " $lib" ;;
761747e89262Smrg	esac
761847e89262Smrg      done
761947e89262Smrg
762047e89262Smrg      if test "$build_libtool_libs" = yes; then
762147e89262Smrg	if test -n "$rpath"; then
762247e89262Smrg	  case $host in
762347e89262Smrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
762447e89262Smrg	    # these systems don't actually have a c library (as such)!
762547e89262Smrg	    ;;
762647e89262Smrg	  *-*-rhapsody* | *-*-darwin1.[012])
762747e89262Smrg	    # Rhapsody C library is in the System framework
7628899129b3Smrg	    func_append deplibs " System.ltframework"
762947e89262Smrg	    ;;
763047e89262Smrg	  *-*-netbsd*)
763147e89262Smrg	    # Don't link with libc until the a.out ld.so is fixed.
763247e89262Smrg	    ;;
763347e89262Smrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
763447e89262Smrg	    # Do not include libc due to us having libc/libc_r.
763547e89262Smrg	    ;;
763647e89262Smrg	  *-*-sco3.2v5* | *-*-sco5v6*)
763747e89262Smrg	    # Causes problems with __ctype
763847e89262Smrg	    ;;
763947e89262Smrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
764047e89262Smrg	    # Compiler inserts libc in the correct place for threads to work
764147e89262Smrg	    ;;
764247e89262Smrg	  *)
764347e89262Smrg	    # Add libc to deplibs on all other systems if necessary.
764447e89262Smrg	    if test "$build_libtool_need_lc" = "yes"; then
7645899129b3Smrg	      func_append deplibs " -lc"
764647e89262Smrg	    fi
764747e89262Smrg	    ;;
764847e89262Smrg	  esac
764947e89262Smrg	fi
765047e89262Smrg
765147e89262Smrg	# Transform deplibs into only deplibs that can be linked in shared.
765247e89262Smrg	name_save=$name
765347e89262Smrg	libname_save=$libname
765447e89262Smrg	release_save=$release
765547e89262Smrg	versuffix_save=$versuffix
765647e89262Smrg	major_save=$major
765747e89262Smrg	# I'm not sure if I'm treating the release correctly.  I think
765847e89262Smrg	# release should show up in the -l (ie -lgmp5) so we don't want to
765947e89262Smrg	# add it in twice.  Is that correct?
766047e89262Smrg	release=""
766147e89262Smrg	versuffix=""
766247e89262Smrg	major=""
766347e89262Smrg	newdeplibs=
766447e89262Smrg	droppeddeps=no
766547e89262Smrg	case $deplibs_check_method in
766647e89262Smrg	pass_all)
766747e89262Smrg	  # Don't check for shared/static.  Everything works.
766847e89262Smrg	  # This might be a little naive.  We might want to check
766947e89262Smrg	  # whether the library exists or not.  But this is on
767047e89262Smrg	  # osf3 & osf4 and I'm not really sure... Just
767147e89262Smrg	  # implementing what was already the behavior.
767247e89262Smrg	  newdeplibs=$deplibs
767347e89262Smrg	  ;;
767447e89262Smrg	test_compile)
767547e89262Smrg	  # This code stresses the "libraries are programs" paradigm to its
767647e89262Smrg	  # limits. Maybe even breaks it.  We compile a program, linking it
767747e89262Smrg	  # against the deplibs as a proxy for the library.  Then we can check
767847e89262Smrg	  # whether they linked in statically or dynamically with ldd.
767947e89262Smrg	  $opt_dry_run || $RM conftest.c
768047e89262Smrg	  cat > conftest.c <<EOF
768147e89262Smrg	  int main() { return 0; }
768247e89262SmrgEOF
768347e89262Smrg	  $opt_dry_run || $RM conftest
768447e89262Smrg	  if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
768547e89262Smrg	    ldd_output=`ldd conftest`
768647e89262Smrg	    for i in $deplibs; do
768747e89262Smrg	      case $i in
768847e89262Smrg	      -l*)
768947e89262Smrg		func_stripname -l '' "$i"
769047e89262Smrg		name=$func_stripname_result
769147e89262Smrg		if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
769247e89262Smrg		  case " $predeps $postdeps " in
769347e89262Smrg		  *" $i "*)
7694899129b3Smrg		    func_append newdeplibs " $i"
769547e89262Smrg		    i=""
769647e89262Smrg		    ;;
769747e89262Smrg		  esac
769847e89262Smrg		fi
769947e89262Smrg		if test -n "$i" ; then
770047e89262Smrg		  libname=`eval "\\$ECHO \"$libname_spec\""`
770147e89262Smrg		  deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
770247e89262Smrg		  set dummy $deplib_matches; shift
770347e89262Smrg		  deplib_match=$1
770447e89262Smrg		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
7705899129b3Smrg		    func_append newdeplibs " $i"
770647e89262Smrg		  else
770747e89262Smrg		    droppeddeps=yes
770847e89262Smrg		    echo
770947e89262Smrg		    $ECHO "*** Warning: dynamic linker does not accept needed library $i."
771047e89262Smrg		    echo "*** I have the capability to make that library automatically link in when"
771147e89262Smrg		    echo "*** you link to this library.  But I can only do this if you have a"
771247e89262Smrg		    echo "*** shared version of the library, which I believe you do not have"
771347e89262Smrg		    echo "*** because a test_compile did reveal that the linker did not use it for"
771447e89262Smrg		    echo "*** its dynamic dependency list that programs get resolved with at runtime."
771547e89262Smrg		  fi
771647e89262Smrg		fi
771747e89262Smrg		;;
771847e89262Smrg	      *)
7719899129b3Smrg		func_append newdeplibs " $i"
772047e89262Smrg		;;
772147e89262Smrg	      esac
772247e89262Smrg	    done
772347e89262Smrg	  else
772447e89262Smrg	    # Error occurred in the first compile.  Let's try to salvage
772547e89262Smrg	    # the situation: Compile a separate program for each library.
772647e89262Smrg	    for i in $deplibs; do
772747e89262Smrg	      case $i in
772847e89262Smrg	      -l*)
772947e89262Smrg		func_stripname -l '' "$i"
773047e89262Smrg		name=$func_stripname_result
773147e89262Smrg		$opt_dry_run || $RM conftest
773247e89262Smrg		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
773347e89262Smrg		  ldd_output=`ldd conftest`
773447e89262Smrg		  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
773547e89262Smrg		    case " $predeps $postdeps " in
773647e89262Smrg		    *" $i "*)
7737899129b3Smrg		      func_append newdeplibs " $i"
773847e89262Smrg		      i=""
773947e89262Smrg		      ;;
774047e89262Smrg		    esac
774147e89262Smrg		  fi
774247e89262Smrg		  if test -n "$i" ; then
774347e89262Smrg		    libname=`eval "\\$ECHO \"$libname_spec\""`
774447e89262Smrg		    deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
774547e89262Smrg		    set dummy $deplib_matches; shift
774647e89262Smrg		    deplib_match=$1
774747e89262Smrg		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
7748899129b3Smrg		      func_append newdeplibs " $i"
774947e89262Smrg		    else
775047e89262Smrg		      droppeddeps=yes
775147e89262Smrg		      echo
775247e89262Smrg		      $ECHO "*** Warning: dynamic linker does not accept needed library $i."
775347e89262Smrg		      echo "*** I have the capability to make that library automatically link in when"
775447e89262Smrg		      echo "*** you link to this library.  But I can only do this if you have a"
775547e89262Smrg		      echo "*** shared version of the library, which you do not appear to have"
775647e89262Smrg		      echo "*** because a test_compile did reveal that the linker did not use this one"
775747e89262Smrg		      echo "*** as a dynamic dependency that programs can get resolved with at runtime."
775847e89262Smrg		    fi
775947e89262Smrg		  fi
776047e89262Smrg		else
776147e89262Smrg		  droppeddeps=yes
776247e89262Smrg		  echo
776347e89262Smrg		  $ECHO "*** Warning!  Library $i is needed by this library but I was not able to"
776447e89262Smrg		  echo "*** make it link in!  You will probably need to install it or some"
776547e89262Smrg		  echo "*** library that it depends on before this library will be fully"
776647e89262Smrg		  echo "*** functional.  Installing it before continuing would be even better."
776747e89262Smrg		fi
776847e89262Smrg		;;
776947e89262Smrg	      *)
7770899129b3Smrg		func_append newdeplibs " $i"
777147e89262Smrg		;;
777247e89262Smrg	      esac
777347e89262Smrg	    done
777447e89262Smrg	  fi
777547e89262Smrg	  ;;
777647e89262Smrg	file_magic*)
777747e89262Smrg	  set dummy $deplibs_check_method; shift
777847e89262Smrg	  file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
777947e89262Smrg	  for a_deplib in $deplibs; do
778047e89262Smrg	    case $a_deplib in
778147e89262Smrg	    -l*)
778247e89262Smrg	      func_stripname -l '' "$a_deplib"
778347e89262Smrg	      name=$func_stripname_result
778447e89262Smrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
778547e89262Smrg		case " $predeps $postdeps " in
778647e89262Smrg		*" $a_deplib "*)
7787899129b3Smrg		  func_append newdeplibs " $a_deplib"
778847e89262Smrg		  a_deplib=""
778947e89262Smrg		  ;;
779047e89262Smrg		esac
779147e89262Smrg	      fi
779247e89262Smrg	      if test -n "$a_deplib" ; then
779347e89262Smrg		libname=`eval "\\$ECHO \"$libname_spec\""`
7794899129b3Smrg		if test -n "$file_magic_glob"; then
7795899129b3Smrg		  libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob`
7796899129b3Smrg		else
7797899129b3Smrg		  libnameglob=$libname
7798899129b3Smrg		fi
7799899129b3Smrg		test "$want_nocaseglob" = yes && nocaseglob=`shopt -p nocaseglob`
780047e89262Smrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
7801899129b3Smrg		  if test "$want_nocaseglob" = yes; then
7802899129b3Smrg		    shopt -s nocaseglob
7803899129b3Smrg		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
7804899129b3Smrg		    $nocaseglob
7805899129b3Smrg		  else
7806899129b3Smrg		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
7807899129b3Smrg		  fi
780847e89262Smrg		  for potent_lib in $potential_libs; do
780947e89262Smrg		      # Follow soft links.
781047e89262Smrg		      if ls -lLd "$potent_lib" 2>/dev/null |
781147e89262Smrg			 $GREP " -> " >/dev/null; then
781247e89262Smrg			continue
781347e89262Smrg		      fi
781447e89262Smrg		      # The statement above tries to avoid entering an
781547e89262Smrg		      # endless loop below, in case of cyclic links.
781647e89262Smrg		      # We might still enter an endless loop, since a link
781747e89262Smrg		      # loop can be closed while we follow links,
781847e89262Smrg		      # but so what?
781947e89262Smrg		      potlib="$potent_lib"
782047e89262Smrg		      while test -h "$potlib" 2>/dev/null; do
782147e89262Smrg			potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
782247e89262Smrg			case $potliblink in
782347e89262Smrg			[\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
782447e89262Smrg			*) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";;
782547e89262Smrg			esac
782647e89262Smrg		      done
782747e89262Smrg		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
782847e89262Smrg			 $SED -e 10q |
782947e89262Smrg			 $EGREP "$file_magic_regex" > /dev/null; then
7830899129b3Smrg			func_append newdeplibs " $a_deplib"
783147e89262Smrg			a_deplib=""
783247e89262Smrg			break 2
783347e89262Smrg		      fi
783447e89262Smrg		  done
783547e89262Smrg		done
783647e89262Smrg	      fi
783747e89262Smrg	      if test -n "$a_deplib" ; then
783847e89262Smrg		droppeddeps=yes
783947e89262Smrg		echo
784047e89262Smrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
784147e89262Smrg		echo "*** I have the capability to make that library automatically link in when"
784247e89262Smrg		echo "*** you link to this library.  But I can only do this if you have a"
784347e89262Smrg		echo "*** shared version of the library, which you do not appear to have"
784447e89262Smrg		echo "*** because I did check the linker path looking for a file starting"
784547e89262Smrg		if test -z "$potlib" ; then
784647e89262Smrg		  $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
784747e89262Smrg		else
784847e89262Smrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
784947e89262Smrg		  $ECHO "*** using a file magic. Last file checked: $potlib"
785047e89262Smrg		fi
785147e89262Smrg	      fi
785247e89262Smrg	      ;;
785347e89262Smrg	    *)
785447e89262Smrg	      # Add a -L argument.
7855899129b3Smrg	      func_append newdeplibs " $a_deplib"
785647e89262Smrg	      ;;
785747e89262Smrg	    esac
785847e89262Smrg	  done # Gone through all deplibs.
785947e89262Smrg	  ;;
786047e89262Smrg	match_pattern*)
786147e89262Smrg	  set dummy $deplibs_check_method; shift
786247e89262Smrg	  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
786347e89262Smrg	  for a_deplib in $deplibs; do
786447e89262Smrg	    case $a_deplib in
786547e89262Smrg	    -l*)
786647e89262Smrg	      func_stripname -l '' "$a_deplib"
786747e89262Smrg	      name=$func_stripname_result
786847e89262Smrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
786947e89262Smrg		case " $predeps $postdeps " in
787047e89262Smrg		*" $a_deplib "*)
7871899129b3Smrg		  func_append newdeplibs " $a_deplib"
787247e89262Smrg		  a_deplib=""
787347e89262Smrg		  ;;
787447e89262Smrg		esac
787547e89262Smrg	      fi
787647e89262Smrg	      if test -n "$a_deplib" ; then
787747e89262Smrg		libname=`eval "\\$ECHO \"$libname_spec\""`
787847e89262Smrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
787947e89262Smrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
788047e89262Smrg		  for potent_lib in $potential_libs; do
788147e89262Smrg		    potlib="$potent_lib" # see symlink-check above in file_magic test
788247e89262Smrg		    if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
788347e89262Smrg		       $EGREP "$match_pattern_regex" > /dev/null; then
7884899129b3Smrg		      func_append newdeplibs " $a_deplib"
788547e89262Smrg		      a_deplib=""
788647e89262Smrg		      break 2
788747e89262Smrg		    fi
788847e89262Smrg		  done
788947e89262Smrg		done
789047e89262Smrg	      fi
789147e89262Smrg	      if test -n "$a_deplib" ; then
789247e89262Smrg		droppeddeps=yes
789347e89262Smrg		echo
789447e89262Smrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
789547e89262Smrg		echo "*** I have the capability to make that library automatically link in when"
789647e89262Smrg		echo "*** you link to this library.  But I can only do this if you have a"
789747e89262Smrg		echo "*** shared version of the library, which you do not appear to have"
789847e89262Smrg		echo "*** because I did check the linker path looking for a file starting"
789947e89262Smrg		if test -z "$potlib" ; then
790047e89262Smrg		  $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
790147e89262Smrg		else
790247e89262Smrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
790347e89262Smrg		  $ECHO "*** using a regex pattern. Last file checked: $potlib"
790447e89262Smrg		fi
790547e89262Smrg	      fi
790647e89262Smrg	      ;;
790747e89262Smrg	    *)
790847e89262Smrg	      # Add a -L argument.
7909899129b3Smrg	      func_append newdeplibs " $a_deplib"
791047e89262Smrg	      ;;
791147e89262Smrg	    esac
791247e89262Smrg	  done # Gone through all deplibs.
791347e89262Smrg	  ;;
791447e89262Smrg	none | unknown | *)
791547e89262Smrg	  newdeplibs=""
791647e89262Smrg	  tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
791747e89262Smrg	  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
791847e89262Smrg	    for i in $predeps $postdeps ; do
791947e89262Smrg	      # can't use Xsed below, because $i might contain '/'
792047e89262Smrg	      tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"`
792147e89262Smrg	    done
792247e89262Smrg	  fi
792347e89262Smrg	  case $tmp_deplibs in
792447e89262Smrg	  *[!\	\ ]*)
792547e89262Smrg	    echo
792647e89262Smrg	    if test "X$deplibs_check_method" = "Xnone"; then
792747e89262Smrg	      echo "*** Warning: inter-library dependencies are not supported in this platform."
792847e89262Smrg	    else
792947e89262Smrg	      echo "*** Warning: inter-library dependencies are not known to be supported."
793047e89262Smrg	    fi
793147e89262Smrg	    echo "*** All declared inter-library dependencies are being dropped."
793247e89262Smrg	    droppeddeps=yes
793347e89262Smrg	    ;;
793447e89262Smrg	  esac
793547e89262Smrg	  ;;
793647e89262Smrg	esac
793747e89262Smrg	versuffix=$versuffix_save
793847e89262Smrg	major=$major_save
793947e89262Smrg	release=$release_save
794047e89262Smrg	libname=$libname_save
794147e89262Smrg	name=$name_save
794247e89262Smrg
794347e89262Smrg	case $host in
794447e89262Smrg	*-*-rhapsody* | *-*-darwin1.[012])
794547e89262Smrg	  # On Rhapsody replace the C library with the System framework
794647e89262Smrg	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
794747e89262Smrg	  ;;
794847e89262Smrg	esac
794947e89262Smrg
795047e89262Smrg	if test "$droppeddeps" = yes; then
795147e89262Smrg	  if test "$module" = yes; then
795247e89262Smrg	    echo
795347e89262Smrg	    echo "*** Warning: libtool could not satisfy all declared inter-library"
795447e89262Smrg	    $ECHO "*** dependencies of module $libname.  Therefore, libtool will create"
795547e89262Smrg	    echo "*** a static module, that should work as long as the dlopening"
795647e89262Smrg	    echo "*** application is linked with the -dlopen flag."
795747e89262Smrg	    if test -z "$global_symbol_pipe"; then
795847e89262Smrg	      echo
795947e89262Smrg	      echo "*** However, this would only work if libtool was able to extract symbol"
796047e89262Smrg	      echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
796147e89262Smrg	      echo "*** not find such a program.  So, this module is probably useless."
796247e89262Smrg	      echo "*** \`nm' from GNU binutils and a full rebuild may help."
796347e89262Smrg	    fi
796447e89262Smrg	    if test "$build_old_libs" = no; then
796547e89262Smrg	      oldlibs="$output_objdir/$libname.$libext"
796647e89262Smrg	      build_libtool_libs=module
796747e89262Smrg	      build_old_libs=yes
796847e89262Smrg	    else
796947e89262Smrg	      build_libtool_libs=no
797047e89262Smrg	    fi
797147e89262Smrg	  else
797247e89262Smrg	    echo "*** The inter-library dependencies that have been dropped here will be"
797347e89262Smrg	    echo "*** automatically added whenever a program is linked with this library"
797447e89262Smrg	    echo "*** or is declared to -dlopen it."
797547e89262Smrg
797647e89262Smrg	    if test "$allow_undefined" = no; then
797747e89262Smrg	      echo
797847e89262Smrg	      echo "*** Since this library must not contain undefined symbols,"
797947e89262Smrg	      echo "*** because either the platform does not support them or"
798047e89262Smrg	      echo "*** it was explicitly requested with -no-undefined,"
798147e89262Smrg	      echo "*** libtool will only create a static version of it."
798247e89262Smrg	      if test "$build_old_libs" = no; then
798347e89262Smrg		oldlibs="$output_objdir/$libname.$libext"
798447e89262Smrg		build_libtool_libs=module
798547e89262Smrg		build_old_libs=yes
798647e89262Smrg	      else
798747e89262Smrg		build_libtool_libs=no
798847e89262Smrg	      fi
798947e89262Smrg	    fi
799047e89262Smrg	  fi
799147e89262Smrg	fi
799247e89262Smrg	# Done checking deplibs!
799347e89262Smrg	deplibs=$newdeplibs
799447e89262Smrg      fi
799547e89262Smrg      # Time to change all our "foo.ltframework" stuff back to "-framework foo"
799647e89262Smrg      case $host in
799747e89262Smrg	*-*-darwin*)
799847e89262Smrg	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
799947e89262Smrg	  new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
800047e89262Smrg	  deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
800147e89262Smrg	  ;;
800247e89262Smrg      esac
800347e89262Smrg
800447e89262Smrg      # move library search paths that coincide with paths to not yet
800547e89262Smrg      # installed libraries to the beginning of the library search list
800647e89262Smrg      new_libs=
800747e89262Smrg      for path in $notinst_path; do
800847e89262Smrg	case " $new_libs " in
800947e89262Smrg	*" -L$path/$objdir "*) ;;
801047e89262Smrg	*)
801147e89262Smrg	  case " $deplibs " in
801247e89262Smrg	  *" -L$path/$objdir "*)
8013899129b3Smrg	    func_append new_libs " -L$path/$objdir" ;;
801447e89262Smrg	  esac
801547e89262Smrg	  ;;
801647e89262Smrg	esac
801747e89262Smrg      done
801847e89262Smrg      for deplib in $deplibs; do
801947e89262Smrg	case $deplib in
802047e89262Smrg	-L*)
802147e89262Smrg	  case " $new_libs " in
802247e89262Smrg	  *" $deplib "*) ;;
8023899129b3Smrg	  *) func_append new_libs " $deplib" ;;
802447e89262Smrg	  esac
802547e89262Smrg	  ;;
8026899129b3Smrg	*) func_append new_libs " $deplib" ;;
802747e89262Smrg	esac
802847e89262Smrg      done
802947e89262Smrg      deplibs="$new_libs"
803047e89262Smrg
803147e89262Smrg      # All the library-specific variables (install_libdir is set above).
803247e89262Smrg      library_names=
803347e89262Smrg      old_library=
803447e89262Smrg      dlname=
803547e89262Smrg
803647e89262Smrg      # Test again, we may have decided not to build it any more
803747e89262Smrg      if test "$build_libtool_libs" = yes; then
8038899129b3Smrg	# Remove ${wl} instances when linking with ld.
8039899129b3Smrg	# FIXME: should test the right _cmds variable.
8040899129b3Smrg	case $archive_cmds in
8041899129b3Smrg	  *\$LD\ *) wl= ;;
8042899129b3Smrg        esac
804347e89262Smrg	if test "$hardcode_into_libs" = yes; then
804447e89262Smrg	  # Hardcode the library paths
804547e89262Smrg	  hardcode_libdirs=
804647e89262Smrg	  dep_rpath=
804747e89262Smrg	  rpath="$finalize_rpath"
8048899129b3Smrg	  test "$opt_mode" != relink && rpath="$compile_rpath$rpath"
804947e89262Smrg	  for libdir in $rpath; do
805047e89262Smrg	    if test -n "$hardcode_libdir_flag_spec"; then
805147e89262Smrg	      if test -n "$hardcode_libdir_separator"; then
8052899129b3Smrg		func_replace_sysroot "$libdir"
8053899129b3Smrg		libdir=$func_replace_sysroot_result
805447e89262Smrg		if test -z "$hardcode_libdirs"; then
805547e89262Smrg		  hardcode_libdirs="$libdir"
805647e89262Smrg		else
805747e89262Smrg		  # Just accumulate the unique libdirs.
805847e89262Smrg		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
805947e89262Smrg		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
806047e89262Smrg		    ;;
806147e89262Smrg		  *)
8062899129b3Smrg		    func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
806347e89262Smrg		    ;;
806447e89262Smrg		  esac
806547e89262Smrg		fi
806647e89262Smrg	      else
806747e89262Smrg		eval flag=\"$hardcode_libdir_flag_spec\"
8068899129b3Smrg		func_append dep_rpath " $flag"
806947e89262Smrg	      fi
807047e89262Smrg	    elif test -n "$runpath_var"; then
807147e89262Smrg	      case "$perm_rpath " in
807247e89262Smrg	      *" $libdir "*) ;;
8073899129b3Smrg	      *) func_append perm_rpath " $libdir" ;;
807447e89262Smrg	      esac
807547e89262Smrg	    fi
807647e89262Smrg	  done
807747e89262Smrg	  # Substitute the hardcoded libdirs into the rpath.
807847e89262Smrg	  if test -n "$hardcode_libdir_separator" &&
807947e89262Smrg	     test -n "$hardcode_libdirs"; then
808047e89262Smrg	    libdir="$hardcode_libdirs"
8081899129b3Smrg	    eval "dep_rpath=\"$hardcode_libdir_flag_spec\""
808247e89262Smrg	  fi
808347e89262Smrg	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
808447e89262Smrg	    # We should set the runpath_var.
808547e89262Smrg	    rpath=
808647e89262Smrg	    for dir in $perm_rpath; do
8087899129b3Smrg	      func_append rpath "$dir:"
808847e89262Smrg	    done
808947e89262Smrg	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
809047e89262Smrg	  fi
809147e89262Smrg	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
809247e89262Smrg	fi
8093bd1da9d7Smrg
809447e89262Smrg	shlibpath="$finalize_shlibpath"
8095899129b3Smrg	test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
809647e89262Smrg	if test -n "$shlibpath"; then
809747e89262Smrg	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
809847e89262Smrg	fi
8099bd1da9d7Smrg
810047e89262Smrg	# Get the real and link names of the library.
810147e89262Smrg	eval shared_ext=\"$shrext_cmds\"
810247e89262Smrg	eval library_names=\"$library_names_spec\"
810347e89262Smrg	set dummy $library_names
810447e89262Smrg	shift
810547e89262Smrg	realname="$1"
810647e89262Smrg	shift
8107bd1da9d7Smrg
810847e89262Smrg	if test -n "$soname_spec"; then
810947e89262Smrg	  eval soname=\"$soname_spec\"
811047e89262Smrg	else
811147e89262Smrg	  soname="$realname"
811247e89262Smrg	fi
811347e89262Smrg	if test -z "$dlname"; then
811447e89262Smrg	  dlname=$soname
811547e89262Smrg	fi
8116bd1da9d7Smrg
811747e89262Smrg	lib="$output_objdir/$realname"
811847e89262Smrg	linknames=
811947e89262Smrg	for link
812047e89262Smrg	do
8121899129b3Smrg	  func_append linknames " $link"
812247e89262Smrg	done
8123bd1da9d7Smrg
812447e89262Smrg	# Use standard objects if they are pic
812547e89262Smrg	test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
812647e89262Smrg	test "X$libobjs" = "X " && libobjs=
8127bd1da9d7Smrg
812847e89262Smrg	delfiles=
812947e89262Smrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
813047e89262Smrg	  $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
813147e89262Smrg	  export_symbols="$output_objdir/$libname.uexp"
8132899129b3Smrg	  func_append delfiles " $export_symbols"
813347e89262Smrg	fi
8134bd1da9d7Smrg
813547e89262Smrg	orig_export_symbols=
813647e89262Smrg	case $host_os in
813747e89262Smrg	cygwin* | mingw* | cegcc*)
813847e89262Smrg	  if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
813947e89262Smrg	    # exporting using user supplied symfile
814047e89262Smrg	    if test "x`$SED 1q $export_symbols`" != xEXPORTS; then
814147e89262Smrg	      # and it's NOT already a .def file. Must figure out
814247e89262Smrg	      # which of the given symbols are data symbols and tag
814347e89262Smrg	      # them as such. So, trigger use of export_symbols_cmds.
814447e89262Smrg	      # export_symbols gets reassigned inside the "prepare
814547e89262Smrg	      # the list of exported symbols" if statement, so the
814647e89262Smrg	      # include_expsyms logic still works.
814747e89262Smrg	      orig_export_symbols="$export_symbols"
814847e89262Smrg	      export_symbols=
814947e89262Smrg	      always_export_symbols=yes
815047e89262Smrg	    fi
815147e89262Smrg	  fi
815247e89262Smrg	  ;;
815347e89262Smrg	esac
8154bd1da9d7Smrg
815547e89262Smrg	# Prepare the list of exported symbols
815647e89262Smrg	if test -z "$export_symbols"; then
815747e89262Smrg	  if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
815847e89262Smrg	    func_verbose "generating symbol list for \`$libname.la'"
815947e89262Smrg	    export_symbols="$output_objdir/$libname.exp"
816047e89262Smrg	    $opt_dry_run || $RM $export_symbols
816147e89262Smrg	    cmds=$export_symbols_cmds
816247e89262Smrg	    save_ifs="$IFS"; IFS='~'
8163899129b3Smrg	    for cmd1 in $cmds; do
816447e89262Smrg	      IFS="$save_ifs"
8165899129b3Smrg	      # Take the normal branch if the nm_file_list_spec branch
8166899129b3Smrg	      # doesn't work or if tool conversion is not needed.
8167899129b3Smrg	      case $nm_file_list_spec~$to_tool_file_cmd in
8168899129b3Smrg		*~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*)
8169899129b3Smrg		  try_normal_branch=yes
8170899129b3Smrg		  eval cmd=\"$cmd1\"
8171899129b3Smrg		  func_len " $cmd"
8172899129b3Smrg		  len=$func_len_result
8173899129b3Smrg		  ;;
8174899129b3Smrg		*)
8175899129b3Smrg		  try_normal_branch=no
8176899129b3Smrg		  ;;
8177899129b3Smrg	      esac
8178899129b3Smrg	      if test "$try_normal_branch" = yes \
8179899129b3Smrg		 && { test "$len" -lt "$max_cmd_len" \
8180899129b3Smrg		      || test "$max_cmd_len" -le -1; }
8181899129b3Smrg	      then
8182899129b3Smrg		func_show_eval "$cmd" 'exit $?'
8183899129b3Smrg		skipped_export=false
8184899129b3Smrg	      elif test -n "$nm_file_list_spec"; then
8185899129b3Smrg		func_basename "$output"
8186899129b3Smrg		output_la=$func_basename_result
8187899129b3Smrg		save_libobjs=$libobjs
8188899129b3Smrg		save_output=$output
8189899129b3Smrg		output=${output_objdir}/${output_la}.nm
8190899129b3Smrg		func_to_tool_file "$output"
8191899129b3Smrg		libobjs=$nm_file_list_spec$func_to_tool_file_result
8192899129b3Smrg		func_append delfiles " $output"
8193899129b3Smrg		func_verbose "creating $NM input file list: $output"
8194899129b3Smrg		for obj in $save_libobjs; do
8195899129b3Smrg		  func_to_tool_file "$obj"
8196899129b3Smrg		  $ECHO "$func_to_tool_file_result"
8197899129b3Smrg		done > "$output"
8198899129b3Smrg		eval cmd=\"$cmd1\"
819947e89262Smrg		func_show_eval "$cmd" 'exit $?'
8200899129b3Smrg		output=$save_output
8201899129b3Smrg		libobjs=$save_libobjs
820247e89262Smrg		skipped_export=false
820347e89262Smrg	      else
820447e89262Smrg		# The command line is too long to execute in one step.
820547e89262Smrg		func_verbose "using reloadable object file for export list..."
820647e89262Smrg		skipped_export=:
820747e89262Smrg		# Break out early, otherwise skipped_export may be
820847e89262Smrg		# set to false by a later but shorter cmd.
820947e89262Smrg		break
821047e89262Smrg	      fi
821147e89262Smrg	    done
821247e89262Smrg	    IFS="$save_ifs"
821347e89262Smrg	    if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then
821447e89262Smrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
821547e89262Smrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
821647e89262Smrg	    fi
821747e89262Smrg	  fi
821847e89262Smrg	fi
8219bd1da9d7Smrg
822047e89262Smrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
822147e89262Smrg	  tmp_export_symbols="$export_symbols"
822247e89262Smrg	  test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
822347e89262Smrg	  $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
822447e89262Smrg	fi
8225bd1da9d7Smrg
822647e89262Smrg	if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then
822747e89262Smrg	  # The given exports_symbols file has to be filtered, so filter it.
822847e89262Smrg	  func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
822947e89262Smrg	  # FIXME: $output_objdir/$libname.filter potentially contains lots of
823047e89262Smrg	  # 's' commands which not all seds can handle. GNU sed should be fine
823147e89262Smrg	  # though. Also, the filter scales superlinearly with the number of
823247e89262Smrg	  # global variables. join(1) would be nice here, but unfortunately
823347e89262Smrg	  # isn't a blessed tool.
823447e89262Smrg	  $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
8235899129b3Smrg	  func_append delfiles " $export_symbols $output_objdir/$libname.filter"
823647e89262Smrg	  export_symbols=$output_objdir/$libname.def
823747e89262Smrg	  $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
8238bd1da9d7Smrg	fi
8239bd1da9d7Smrg
824047e89262Smrg	tmp_deplibs=
824147e89262Smrg	for test_deplib in $deplibs; do
824247e89262Smrg	  case " $convenience " in
824347e89262Smrg	  *" $test_deplib "*) ;;
824447e89262Smrg	  *)
8245899129b3Smrg	    func_append tmp_deplibs " $test_deplib"
824647e89262Smrg	    ;;
824747e89262Smrg	  esac
824847e89262Smrg	done
824947e89262Smrg	deplibs="$tmp_deplibs"
8250bd1da9d7Smrg
825147e89262Smrg	if test -n "$convenience"; then
825247e89262Smrg	  if test -n "$whole_archive_flag_spec" &&
825347e89262Smrg	    test "$compiler_needs_object" = yes &&
825447e89262Smrg	    test -z "$libobjs"; then
825547e89262Smrg	    # extract the archives, so we have objects to list.
825647e89262Smrg	    # TODO: could optimize this to just extract one archive.
825747e89262Smrg	    whole_archive_flag_spec=
825847e89262Smrg	  fi
825947e89262Smrg	  if test -n "$whole_archive_flag_spec"; then
826047e89262Smrg	    save_libobjs=$libobjs
826147e89262Smrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
826247e89262Smrg	    test "X$libobjs" = "X " && libobjs=
826347e89262Smrg	  else
826447e89262Smrg	    gentop="$output_objdir/${outputname}x"
8265899129b3Smrg	    func_append generated " $gentop"
8266bd1da9d7Smrg
826747e89262Smrg	    func_extract_archives $gentop $convenience
8268899129b3Smrg	    func_append libobjs " $func_extract_archives_result"
826947e89262Smrg	    test "X$libobjs" = "X " && libobjs=
827047e89262Smrg	  fi
827147e89262Smrg	fi
8272bd1da9d7Smrg
827347e89262Smrg	if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
827447e89262Smrg	  eval flag=\"$thread_safe_flag_spec\"
8275899129b3Smrg	  func_append linker_flags " $flag"
827647e89262Smrg	fi
8277bd1da9d7Smrg
827847e89262Smrg	# Make a backup of the uninstalled library when relinking
8279899129b3Smrg	if test "$opt_mode" = relink; then
828047e89262Smrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
8281bd1da9d7Smrg	fi
8282bd1da9d7Smrg
828347e89262Smrg	# Do each of the archive commands.
828447e89262Smrg	if test "$module" = yes && test -n "$module_cmds" ; then
828547e89262Smrg	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
828647e89262Smrg	    eval test_cmds=\"$module_expsym_cmds\"
828747e89262Smrg	    cmds=$module_expsym_cmds
828847e89262Smrg	  else
828947e89262Smrg	    eval test_cmds=\"$module_cmds\"
829047e89262Smrg	    cmds=$module_cmds
829147e89262Smrg	  fi
829247e89262Smrg	else
829347e89262Smrg	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
829447e89262Smrg	    eval test_cmds=\"$archive_expsym_cmds\"
829547e89262Smrg	    cmds=$archive_expsym_cmds
829647e89262Smrg	  else
829747e89262Smrg	    eval test_cmds=\"$archive_cmds\"
829847e89262Smrg	    cmds=$archive_cmds
829947e89262Smrg	  fi
8300bd1da9d7Smrg	fi
8301bd1da9d7Smrg
830247e89262Smrg	if test "X$skipped_export" != "X:" &&
830347e89262Smrg	   func_len " $test_cmds" &&
830447e89262Smrg	   len=$func_len_result &&
830547e89262Smrg	   test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
830647e89262Smrg	  :
830747e89262Smrg	else
830847e89262Smrg	  # The command line is too long to link in one step, link piecewise
830947e89262Smrg	  # or, if using GNU ld and skipped_export is not :, use a linker
831047e89262Smrg	  # script.
8311bd1da9d7Smrg
831247e89262Smrg	  # Save the value of $output and $libobjs because we want to
831347e89262Smrg	  # use them later.  If we have whole_archive_flag_spec, we
831447e89262Smrg	  # want to use save_libobjs as it was before
831547e89262Smrg	  # whole_archive_flag_spec was expanded, because we can't
831647e89262Smrg	  # assume the linker understands whole_archive_flag_spec.
831747e89262Smrg	  # This may have to be revisited, in case too many
831847e89262Smrg	  # convenience libraries get linked in and end up exceeding
831947e89262Smrg	  # the spec.
832047e89262Smrg	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
832147e89262Smrg	    save_libobjs=$libobjs
832247e89262Smrg	  fi
832347e89262Smrg	  save_output=$output
832447e89262Smrg	  func_basename "$output"
832547e89262Smrg	  output_la=$func_basename_result
8326bd1da9d7Smrg
832747e89262Smrg	  # Clear the reloadable object creation command queue and
832847e89262Smrg	  # initialize k to one.
832947e89262Smrg	  test_cmds=
833047e89262Smrg	  concat_cmds=
833147e89262Smrg	  objlist=
833247e89262Smrg	  last_robj=
833347e89262Smrg	  k=1
8334bd1da9d7Smrg
833547e89262Smrg	  if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
833647e89262Smrg	    output=${output_objdir}/${output_la}.lnkscript
833747e89262Smrg	    func_verbose "creating GNU ld script: $output"
833847e89262Smrg	    echo 'INPUT (' > $output
833947e89262Smrg	    for obj in $save_libobjs
834047e89262Smrg	    do
8341899129b3Smrg	      func_to_tool_file "$obj"
8342899129b3Smrg	      $ECHO "$func_to_tool_file_result" >> $output
834347e89262Smrg	    done
834447e89262Smrg	    echo ')' >> $output
8345899129b3Smrg	    func_append delfiles " $output"
8346899129b3Smrg	    func_to_tool_file "$output"
8347899129b3Smrg	    output=$func_to_tool_file_result
834847e89262Smrg	  elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then
834947e89262Smrg	    output=${output_objdir}/${output_la}.lnk
835047e89262Smrg	    func_verbose "creating linker input file list: $output"
835147e89262Smrg	    : > $output
835247e89262Smrg	    set x $save_libobjs
835347e89262Smrg	    shift
835447e89262Smrg	    firstobj=
835547e89262Smrg	    if test "$compiler_needs_object" = yes; then
835647e89262Smrg	      firstobj="$1 "
835747e89262Smrg	      shift
835847e89262Smrg	    fi
835947e89262Smrg	    for obj
836047e89262Smrg	    do
8361899129b3Smrg	      func_to_tool_file "$obj"
8362899129b3Smrg	      $ECHO "$func_to_tool_file_result" >> $output
836347e89262Smrg	    done
8364899129b3Smrg	    func_append delfiles " $output"
8365899129b3Smrg	    func_to_tool_file "$output"
8366899129b3Smrg	    output=$firstobj\"$file_list_spec$func_to_tool_file_result\"
836747e89262Smrg	  else
836847e89262Smrg	    if test -n "$save_libobjs"; then
836947e89262Smrg	      func_verbose "creating reloadable object files..."
837047e89262Smrg	      output=$output_objdir/$output_la-${k}.$objext
837147e89262Smrg	      eval test_cmds=\"$reload_cmds\"
837247e89262Smrg	      func_len " $test_cmds"
837347e89262Smrg	      len0=$func_len_result
837447e89262Smrg	      len=$len0
837547e89262Smrg
837647e89262Smrg	      # Loop over the list of objects to be linked.
837747e89262Smrg	      for obj in $save_libobjs
837847e89262Smrg	      do
837947e89262Smrg		func_len " $obj"
838047e89262Smrg		func_arith $len + $func_len_result
838147e89262Smrg		len=$func_arith_result
838247e89262Smrg		if test "X$objlist" = X ||
838347e89262Smrg		   test "$len" -lt "$max_cmd_len"; then
838447e89262Smrg		  func_append objlist " $obj"
838547e89262Smrg		else
838647e89262Smrg		  # The command $test_cmds is almost too long, add a
838747e89262Smrg		  # command to the queue.
838847e89262Smrg		  if test "$k" -eq 1 ; then
838947e89262Smrg		    # The first file doesn't have a previous command to add.
839047e89262Smrg		    reload_objs=$objlist
839147e89262Smrg		    eval concat_cmds=\"$reload_cmds\"
839247e89262Smrg		  else
839347e89262Smrg		    # All subsequent reloadable object files will link in
839447e89262Smrg		    # the last one created.
839547e89262Smrg		    reload_objs="$objlist $last_robj"
839647e89262Smrg		    eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
839747e89262Smrg		  fi
839847e89262Smrg		  last_robj=$output_objdir/$output_la-${k}.$objext
839947e89262Smrg		  func_arith $k + 1
840047e89262Smrg		  k=$func_arith_result
840147e89262Smrg		  output=$output_objdir/$output_la-${k}.$objext
840247e89262Smrg		  objlist=" $obj"
840347e89262Smrg		  func_len " $last_robj"
840447e89262Smrg		  func_arith $len0 + $func_len_result
840547e89262Smrg		  len=$func_arith_result
840647e89262Smrg		fi
840747e89262Smrg	      done
840847e89262Smrg	      # Handle the remaining objects by creating one last
840947e89262Smrg	      # reloadable object file.  All subsequent reloadable object
841047e89262Smrg	      # files will link in the last one created.
841147e89262Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
841247e89262Smrg	      reload_objs="$objlist $last_robj"
841347e89262Smrg	      eval concat_cmds=\"\${concat_cmds}$reload_cmds\"
841447e89262Smrg	      if test -n "$last_robj"; then
841547e89262Smrg	        eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\"
841647e89262Smrg	      fi
8417899129b3Smrg	      func_append delfiles " $output"
841847e89262Smrg
841947e89262Smrg	    else
842047e89262Smrg	      output=
842147e89262Smrg	    fi
8422bd1da9d7Smrg
842347e89262Smrg	    if ${skipped_export-false}; then
842447e89262Smrg	      func_verbose "generating symbol list for \`$libname.la'"
842547e89262Smrg	      export_symbols="$output_objdir/$libname.exp"
842647e89262Smrg	      $opt_dry_run || $RM $export_symbols
842747e89262Smrg	      libobjs=$output
842847e89262Smrg	      # Append the command to create the export file.
842947e89262Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
843047e89262Smrg	      eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
843147e89262Smrg	      if test -n "$last_robj"; then
843247e89262Smrg		eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
843347e89262Smrg	      fi
843447e89262Smrg	    fi
8435bd1da9d7Smrg
843647e89262Smrg	    test -n "$save_libobjs" &&
843747e89262Smrg	      func_verbose "creating a temporary reloadable object file: $output"
8438bd1da9d7Smrg
843947e89262Smrg	    # Loop through the commands generated above and execute them.
844047e89262Smrg	    save_ifs="$IFS"; IFS='~'
844147e89262Smrg	    for cmd in $concat_cmds; do
844247e89262Smrg	      IFS="$save_ifs"
844347e89262Smrg	      $opt_silent || {
844447e89262Smrg		  func_quote_for_expand "$cmd"
844547e89262Smrg		  eval "func_echo $func_quote_for_expand_result"
844647e89262Smrg	      }
844747e89262Smrg	      $opt_dry_run || eval "$cmd" || {
844847e89262Smrg		lt_exit=$?
844947e89262Smrg
845047e89262Smrg		# Restore the uninstalled library and exit
8451899129b3Smrg		if test "$opt_mode" = relink; then
845247e89262Smrg		  ( cd "$output_objdir" && \
845347e89262Smrg		    $RM "${realname}T" && \
845447e89262Smrg		    $MV "${realname}U" "$realname" )
845547e89262Smrg		fi
8456bd1da9d7Smrg
845747e89262Smrg		exit $lt_exit
845847e89262Smrg	      }
845947e89262Smrg	    done
846047e89262Smrg	    IFS="$save_ifs"
8461bd1da9d7Smrg
846247e89262Smrg	    if test -n "$export_symbols_regex" && ${skipped_export-false}; then
846347e89262Smrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
846447e89262Smrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
8465bd1da9d7Smrg	    fi
8466bd1da9d7Smrg	  fi
8467bd1da9d7Smrg
846847e89262Smrg          if ${skipped_export-false}; then
846947e89262Smrg	    if test -n "$export_symbols" && test -n "$include_expsyms"; then
847047e89262Smrg	      tmp_export_symbols="$export_symbols"
847147e89262Smrg	      test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
847247e89262Smrg	      $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
847347e89262Smrg	    fi
8474bd1da9d7Smrg
847547e89262Smrg	    if test -n "$orig_export_symbols"; then
847647e89262Smrg	      # The given exports_symbols file has to be filtered, so filter it.
847747e89262Smrg	      func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
847847e89262Smrg	      # FIXME: $output_objdir/$libname.filter potentially contains lots of
847947e89262Smrg	      # 's' commands which not all seds can handle. GNU sed should be fine
848047e89262Smrg	      # though. Also, the filter scales superlinearly with the number of
848147e89262Smrg	      # global variables. join(1) would be nice here, but unfortunately
848247e89262Smrg	      # isn't a blessed tool.
848347e89262Smrg	      $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
8484899129b3Smrg	      func_append delfiles " $export_symbols $output_objdir/$libname.filter"
848547e89262Smrg	      export_symbols=$output_objdir/$libname.def
848647e89262Smrg	      $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
848747e89262Smrg	    fi
848847e89262Smrg	  fi
8489bd1da9d7Smrg
849047e89262Smrg	  libobjs=$output
849147e89262Smrg	  # Restore the value of output.
849247e89262Smrg	  output=$save_output
8493bd1da9d7Smrg
849447e89262Smrg	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
849547e89262Smrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
849647e89262Smrg	    test "X$libobjs" = "X " && libobjs=
849747e89262Smrg	  fi
849847e89262Smrg	  # Expand the library linking commands again to reset the
849947e89262Smrg	  # value of $libobjs for piecewise linking.
850047e89262Smrg
850147e89262Smrg	  # Do each of the archive commands.
850247e89262Smrg	  if test "$module" = yes && test -n "$module_cmds" ; then
850347e89262Smrg	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
850447e89262Smrg	      cmds=$module_expsym_cmds
8505bd1da9d7Smrg	    else
850647e89262Smrg	      cmds=$module_cmds
8507bd1da9d7Smrg	    fi
8508bd1da9d7Smrg	  else
850947e89262Smrg	    if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
851047e89262Smrg	      cmds=$archive_expsym_cmds
851147e89262Smrg	    else
851247e89262Smrg	      cmds=$archive_cmds
851347e89262Smrg	    fi
8514bd1da9d7Smrg	  fi
8515bd1da9d7Smrg	fi
8516bd1da9d7Smrg
851747e89262Smrg	if test -n "$delfiles"; then
851847e89262Smrg	  # Append the command to remove temporary files to $cmds.
851947e89262Smrg	  eval cmds=\"\$cmds~\$RM $delfiles\"
852047e89262Smrg	fi
8521bd1da9d7Smrg
852247e89262Smrg	# Add any objects from preloaded convenience libraries
852347e89262Smrg	if test -n "$dlprefiles"; then
852447e89262Smrg	  gentop="$output_objdir/${outputname}x"
8525899129b3Smrg	  func_append generated " $gentop"
8526bd1da9d7Smrg
852747e89262Smrg	  func_extract_archives $gentop $dlprefiles
8528899129b3Smrg	  func_append libobjs " $func_extract_archives_result"
852947e89262Smrg	  test "X$libobjs" = "X " && libobjs=
8530bd1da9d7Smrg	fi
8531bd1da9d7Smrg
853247e89262Smrg	save_ifs="$IFS"; IFS='~'
853347e89262Smrg	for cmd in $cmds; do
853447e89262Smrg	  IFS="$save_ifs"
853547e89262Smrg	  eval cmd=\"$cmd\"
853647e89262Smrg	  $opt_silent || {
853747e89262Smrg	    func_quote_for_expand "$cmd"
853847e89262Smrg	    eval "func_echo $func_quote_for_expand_result"
853947e89262Smrg	  }
854047e89262Smrg	  $opt_dry_run || eval "$cmd" || {
854147e89262Smrg	    lt_exit=$?
8542bd1da9d7Smrg
854347e89262Smrg	    # Restore the uninstalled library and exit
8544899129b3Smrg	    if test "$opt_mode" = relink; then
854547e89262Smrg	      ( cd "$output_objdir" && \
854647e89262Smrg	        $RM "${realname}T" && \
854747e89262Smrg		$MV "${realname}U" "$realname" )
8548bd1da9d7Smrg	    fi
8549bd1da9d7Smrg
855047e89262Smrg	    exit $lt_exit
855147e89262Smrg	  }
855247e89262Smrg	done
855347e89262Smrg	IFS="$save_ifs"
8554bd1da9d7Smrg
855547e89262Smrg	# Restore the uninstalled library and exit
8556899129b3Smrg	if test "$opt_mode" = relink; then
855747e89262Smrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
8558bd1da9d7Smrg
855947e89262Smrg	  if test -n "$convenience"; then
856047e89262Smrg	    if test -z "$whole_archive_flag_spec"; then
856147e89262Smrg	      func_show_eval '${RM}r "$gentop"'
856247e89262Smrg	    fi
856347e89262Smrg	  fi
8564bd1da9d7Smrg
856547e89262Smrg	  exit $EXIT_SUCCESS
856647e89262Smrg	fi
8567bd1da9d7Smrg
856847e89262Smrg	# Create links to the real library.
856947e89262Smrg	for linkname in $linknames; do
857047e89262Smrg	  if test "$realname" != "$linkname"; then
857147e89262Smrg	    func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
857247e89262Smrg	  fi
857347e89262Smrg	done
8574bd1da9d7Smrg
857547e89262Smrg	# If -module or -export-dynamic was specified, set the dlname.
857647e89262Smrg	if test "$module" = yes || test "$export_dynamic" = yes; then
857747e89262Smrg	  # On all known operating systems, these are identical.
857847e89262Smrg	  dlname="$soname"
857947e89262Smrg	fi
858047e89262Smrg      fi
858147e89262Smrg      ;;
8582bd1da9d7Smrg
858347e89262Smrg    obj)
858447e89262Smrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
858547e89262Smrg	func_warning "\`-dlopen' is ignored for objects"
858647e89262Smrg      fi
8587bd1da9d7Smrg
858847e89262Smrg      case " $deplibs" in
858947e89262Smrg      *\ -l* | *\ -L*)
859047e89262Smrg	func_warning "\`-l' and \`-L' are ignored for objects" ;;
859147e89262Smrg      esac
8592bd1da9d7Smrg
859347e89262Smrg      test -n "$rpath" && \
859447e89262Smrg	func_warning "\`-rpath' is ignored for objects"
8595bd1da9d7Smrg
859647e89262Smrg      test -n "$xrpath" && \
859747e89262Smrg	func_warning "\`-R' is ignored for objects"
859847e89262Smrg
859947e89262Smrg      test -n "$vinfo" && \
860047e89262Smrg	func_warning "\`-version-info' is ignored for objects"
8601bd1da9d7Smrg
860247e89262Smrg      test -n "$release" && \
860347e89262Smrg	func_warning "\`-release' is ignored for objects"
8604bd1da9d7Smrg
860547e89262Smrg      case $output in
860647e89262Smrg      *.lo)
860747e89262Smrg	test -n "$objs$old_deplibs" && \
860847e89262Smrg	  func_fatal_error "cannot build library object \`$output' from non-libtool objects"
860947e89262Smrg
861047e89262Smrg	libobj=$output
861147e89262Smrg	func_lo2o "$libobj"
861247e89262Smrg	obj=$func_lo2o_result
861347e89262Smrg	;;
861447e89262Smrg      *)
861547e89262Smrg	libobj=
861647e89262Smrg	obj="$output"
8617bd1da9d7Smrg	;;
8618bd1da9d7Smrg      esac
8619bd1da9d7Smrg
862047e89262Smrg      # Delete the old objects.
862147e89262Smrg      $opt_dry_run || $RM $obj $libobj
8622bd1da9d7Smrg
862347e89262Smrg      # Objects from convenience libraries.  This assumes
862447e89262Smrg      # single-version convenience libraries.  Whenever we create
862547e89262Smrg      # different ones for PIC/non-PIC, this we'll have to duplicate
862647e89262Smrg      # the extraction.
862747e89262Smrg      reload_conv_objs=
862847e89262Smrg      gentop=
862947e89262Smrg      # reload_cmds runs $LD directly, so let us get rid of
863047e89262Smrg      # -Wl from whole_archive_flag_spec and hope we can get by with
863147e89262Smrg      # turning comma into space..
863247e89262Smrg      wl=
8633bd1da9d7Smrg
863447e89262Smrg      if test -n "$convenience"; then
863547e89262Smrg	if test -n "$whole_archive_flag_spec"; then
863647e89262Smrg	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
863747e89262Smrg	  reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
8638bd1da9d7Smrg	else
863947e89262Smrg	  gentop="$output_objdir/${obj}x"
8640899129b3Smrg	  func_append generated " $gentop"
864147e89262Smrg
864247e89262Smrg	  func_extract_archives $gentop $convenience
864347e89262Smrg	  reload_conv_objs="$reload_objs $func_extract_archives_result"
8644bd1da9d7Smrg	fi
864547e89262Smrg      fi
8646bd1da9d7Smrg
8647899129b3Smrg      # If we're not building shared, we need to use non_pic_objs
8648899129b3Smrg      test "$build_libtool_libs" != yes && libobjs="$non_pic_objects"
8649899129b3Smrg
865047e89262Smrg      # Create the old-style object.
865147e89262Smrg      reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
8652bd1da9d7Smrg
865347e89262Smrg      output="$obj"
865447e89262Smrg      func_execute_cmds "$reload_cmds" 'exit $?'
8655bd1da9d7Smrg
865647e89262Smrg      # Exit if we aren't doing a library object file.
865747e89262Smrg      if test -z "$libobj"; then
865847e89262Smrg	if test -n "$gentop"; then
865947e89262Smrg	  func_show_eval '${RM}r "$gentop"'
866047e89262Smrg	fi
8661bd1da9d7Smrg
866247e89262Smrg	exit $EXIT_SUCCESS
8663bd1da9d7Smrg      fi
8664bd1da9d7Smrg
866547e89262Smrg      if test "$build_libtool_libs" != yes; then
866647e89262Smrg	if test -n "$gentop"; then
866747e89262Smrg	  func_show_eval '${RM}r "$gentop"'
866847e89262Smrg	fi
8669bd1da9d7Smrg
867047e89262Smrg	# Create an invalid libtool object if no PIC, so that we don't
867147e89262Smrg	# accidentally link it into a program.
867247e89262Smrg	# $show "echo timestamp > $libobj"
867347e89262Smrg	# $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
867447e89262Smrg	exit $EXIT_SUCCESS
867547e89262Smrg      fi
8676bd1da9d7Smrg
867747e89262Smrg      if test -n "$pic_flag" || test "$pic_mode" != default; then
867847e89262Smrg	# Only do commands if we really have different PIC objects.
867947e89262Smrg	reload_objs="$libobjs $reload_conv_objs"
868047e89262Smrg	output="$libobj"
868147e89262Smrg	func_execute_cmds "$reload_cmds" 'exit $?'
8682bd1da9d7Smrg      fi
868347e89262Smrg
868447e89262Smrg      if test -n "$gentop"; then
868547e89262Smrg	func_show_eval '${RM}r "$gentop"'
868647e89262Smrg      fi
868747e89262Smrg
868847e89262Smrg      exit $EXIT_SUCCESS
8689bd1da9d7Smrg      ;;
8690bd1da9d7Smrg
869147e89262Smrg    prog)
869247e89262Smrg      case $host in
869347e89262Smrg	*cygwin*) func_stripname '' '.exe' "$output"
869447e89262Smrg	          output=$func_stripname_result.exe;;
869547e89262Smrg      esac
869647e89262Smrg      test -n "$vinfo" && \
869747e89262Smrg	func_warning "\`-version-info' is ignored for programs"
8698bd1da9d7Smrg
869947e89262Smrg      test -n "$release" && \
870047e89262Smrg	func_warning "\`-release' is ignored for programs"
8701bd1da9d7Smrg
870247e89262Smrg      test "$preload" = yes \
870347e89262Smrg        && test "$dlopen_support" = unknown \
870447e89262Smrg	&& test "$dlopen_self" = unknown \
870547e89262Smrg	&& test "$dlopen_self_static" = unknown && \
870647e89262Smrg	  func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support."
870747e89262Smrg
870847e89262Smrg      case $host in
870947e89262Smrg      *-*-rhapsody* | *-*-darwin1.[012])
871047e89262Smrg	# On Rhapsody replace the C library is the System framework
871147e89262Smrg	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
871247e89262Smrg	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
8713bd1da9d7Smrg	;;
871447e89262Smrg      esac
8715bd1da9d7Smrg
871647e89262Smrg      case $host in
871747e89262Smrg      *-*-darwin*)
871847e89262Smrg	# Don't allow lazy linking, it breaks C++ global constructors
871947e89262Smrg	# But is supposedly fixed on 10.4 or later (yay!).
872047e89262Smrg	if test "$tagname" = CXX ; then
872147e89262Smrg	  case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
872247e89262Smrg	    10.[0123])
8723899129b3Smrg	      func_append compile_command " ${wl}-bind_at_load"
8724899129b3Smrg	      func_append finalize_command " ${wl}-bind_at_load"
872547e89262Smrg	    ;;
872647e89262Smrg	  esac
8727bd1da9d7Smrg	fi
872847e89262Smrg	# Time to change all our "foo.ltframework" stuff back to "-framework foo"
872947e89262Smrg	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
873047e89262Smrg	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
873147e89262Smrg	;;
873247e89262Smrg      esac
8733bd1da9d7Smrg
8734bd1da9d7Smrg
873547e89262Smrg      # move library search paths that coincide with paths to not yet
873647e89262Smrg      # installed libraries to the beginning of the library search list
873747e89262Smrg      new_libs=
873847e89262Smrg      for path in $notinst_path; do
873947e89262Smrg	case " $new_libs " in
874047e89262Smrg	*" -L$path/$objdir "*) ;;
874147e89262Smrg	*)
874247e89262Smrg	  case " $compile_deplibs " in
874347e89262Smrg	  *" -L$path/$objdir "*)
8744899129b3Smrg	    func_append new_libs " -L$path/$objdir" ;;
8745bd1da9d7Smrg	  esac
874647e89262Smrg	  ;;
874747e89262Smrg	esac
874847e89262Smrg      done
874947e89262Smrg      for deplib in $compile_deplibs; do
875047e89262Smrg	case $deplib in
875147e89262Smrg	-L*)
875247e89262Smrg	  case " $new_libs " in
875347e89262Smrg	  *" $deplib "*) ;;
8754899129b3Smrg	  *) func_append new_libs " $deplib" ;;
8755bd1da9d7Smrg	  esac
875647e89262Smrg	  ;;
8757899129b3Smrg	*) func_append new_libs " $deplib" ;;
875847e89262Smrg	esac
875947e89262Smrg      done
876047e89262Smrg      compile_deplibs="$new_libs"
8761bd1da9d7Smrg
8762bd1da9d7Smrg
8763899129b3Smrg      func_append compile_command " $compile_deplibs"
8764899129b3Smrg      func_append finalize_command " $finalize_deplibs"
8765bd1da9d7Smrg
876647e89262Smrg      if test -n "$rpath$xrpath"; then
876747e89262Smrg	# If the user specified any rpath flags, then add them.
876847e89262Smrg	for libdir in $rpath $xrpath; do
876947e89262Smrg	  # This is the magic to use -rpath.
877047e89262Smrg	  case "$finalize_rpath " in
877147e89262Smrg	  *" $libdir "*) ;;
8772899129b3Smrg	  *) func_append finalize_rpath " $libdir" ;;
877347e89262Smrg	  esac
877447e89262Smrg	done
877547e89262Smrg      fi
8776bd1da9d7Smrg
877747e89262Smrg      # Now hardcode the library paths
877847e89262Smrg      rpath=
877947e89262Smrg      hardcode_libdirs=
878047e89262Smrg      for libdir in $compile_rpath $finalize_rpath; do
878147e89262Smrg	if test -n "$hardcode_libdir_flag_spec"; then
878247e89262Smrg	  if test -n "$hardcode_libdir_separator"; then
878347e89262Smrg	    if test -z "$hardcode_libdirs"; then
878447e89262Smrg	      hardcode_libdirs="$libdir"
878547e89262Smrg	    else
878647e89262Smrg	      # Just accumulate the unique libdirs.
878747e89262Smrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
878847e89262Smrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
878947e89262Smrg		;;
879047e89262Smrg	      *)
8791899129b3Smrg		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
879247e89262Smrg		;;
879347e89262Smrg	      esac
879447e89262Smrg	    fi
8795bd1da9d7Smrg	  else
879647e89262Smrg	    eval flag=\"$hardcode_libdir_flag_spec\"
8797899129b3Smrg	    func_append rpath " $flag"
8798bd1da9d7Smrg	  fi
879947e89262Smrg	elif test -n "$runpath_var"; then
880047e89262Smrg	  case "$perm_rpath " in
880147e89262Smrg	  *" $libdir "*) ;;
8802899129b3Smrg	  *) func_append perm_rpath " $libdir" ;;
880347e89262Smrg	  esac
880447e89262Smrg	fi
880547e89262Smrg	case $host in
880647e89262Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
880747e89262Smrg	  testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'`
880847e89262Smrg	  case :$dllsearchpath: in
880947e89262Smrg	  *":$libdir:"*) ;;
881047e89262Smrg	  ::) dllsearchpath=$libdir;;
8811899129b3Smrg	  *) func_append dllsearchpath ":$libdir";;
881247e89262Smrg	  esac
881347e89262Smrg	  case :$dllsearchpath: in
881447e89262Smrg	  *":$testbindir:"*) ;;
881547e89262Smrg	  ::) dllsearchpath=$testbindir;;
8816899129b3Smrg	  *) func_append dllsearchpath ":$testbindir";;
881747e89262Smrg	  esac
881847e89262Smrg	  ;;
881947e89262Smrg	esac
882047e89262Smrg      done
882147e89262Smrg      # Substitute the hardcoded libdirs into the rpath.
882247e89262Smrg      if test -n "$hardcode_libdir_separator" &&
882347e89262Smrg	 test -n "$hardcode_libdirs"; then
882447e89262Smrg	libdir="$hardcode_libdirs"
882547e89262Smrg	eval rpath=\" $hardcode_libdir_flag_spec\"
882647e89262Smrg      fi
882747e89262Smrg      compile_rpath="$rpath"
8828bd1da9d7Smrg
882947e89262Smrg      rpath=
883047e89262Smrg      hardcode_libdirs=
883147e89262Smrg      for libdir in $finalize_rpath; do
883247e89262Smrg	if test -n "$hardcode_libdir_flag_spec"; then
883347e89262Smrg	  if test -n "$hardcode_libdir_separator"; then
883447e89262Smrg	    if test -z "$hardcode_libdirs"; then
883547e89262Smrg	      hardcode_libdirs="$libdir"
883647e89262Smrg	    else
883747e89262Smrg	      # Just accumulate the unique libdirs.
883847e89262Smrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
883947e89262Smrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
884047e89262Smrg		;;
884147e89262Smrg	      *)
8842899129b3Smrg		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
884347e89262Smrg		;;
884447e89262Smrg	      esac
884547e89262Smrg	    fi
8846bd1da9d7Smrg	  else
884747e89262Smrg	    eval flag=\"$hardcode_libdir_flag_spec\"
8848899129b3Smrg	    func_append rpath " $flag"
8849bd1da9d7Smrg	  fi
885047e89262Smrg	elif test -n "$runpath_var"; then
885147e89262Smrg	  case "$finalize_perm_rpath " in
885247e89262Smrg	  *" $libdir "*) ;;
8853899129b3Smrg	  *) func_append finalize_perm_rpath " $libdir" ;;
885447e89262Smrg	  esac
8855bd1da9d7Smrg	fi
885647e89262Smrg      done
885747e89262Smrg      # Substitute the hardcoded libdirs into the rpath.
885847e89262Smrg      if test -n "$hardcode_libdir_separator" &&
885947e89262Smrg	 test -n "$hardcode_libdirs"; then
886047e89262Smrg	libdir="$hardcode_libdirs"
886147e89262Smrg	eval rpath=\" $hardcode_libdir_flag_spec\"
886247e89262Smrg      fi
886347e89262Smrg      finalize_rpath="$rpath"
8864bd1da9d7Smrg
886547e89262Smrg      if test -n "$libobjs" && test "$build_old_libs" = yes; then
886647e89262Smrg	# Transform all the library objects into standard objects.
886747e89262Smrg	compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
886847e89262Smrg	finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
886947e89262Smrg      fi
8870bd1da9d7Smrg
887147e89262Smrg      func_generate_dlsyms "$outputname" "@PROGRAM@" "no"
8872bd1da9d7Smrg
887347e89262Smrg      # template prelinking step
887447e89262Smrg      if test -n "$prelink_cmds"; then
887547e89262Smrg	func_execute_cmds "$prelink_cmds" 'exit $?'
887647e89262Smrg      fi
8877bd1da9d7Smrg
887847e89262Smrg      wrappers_required=yes
887947e89262Smrg      case $host in
888047e89262Smrg      *cegcc* | *mingw32ce*)
888147e89262Smrg        # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
888247e89262Smrg        wrappers_required=no
888347e89262Smrg        ;;
888447e89262Smrg      *cygwin* | *mingw* )
888547e89262Smrg        if test "$build_libtool_libs" != yes; then
888647e89262Smrg          wrappers_required=no
888747e89262Smrg        fi
888847e89262Smrg        ;;
888947e89262Smrg      *)
889047e89262Smrg        if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
889147e89262Smrg          wrappers_required=no
889247e89262Smrg        fi
889347e89262Smrg        ;;
889447e89262Smrg      esac
889547e89262Smrg      if test "$wrappers_required" = no; then
889647e89262Smrg	# Replace the output file specification.
889747e89262Smrg	compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
889847e89262Smrg	link_command="$compile_command$compile_rpath"
8899bd1da9d7Smrg
890047e89262Smrg	# We have no uninstalled library dependencies, so finalize right now.
890147e89262Smrg	exit_status=0
890247e89262Smrg	func_show_eval "$link_command" 'exit_status=$?'
8903bd1da9d7Smrg
8904899129b3Smrg	if test -n "$postlink_cmds"; then
8905899129b3Smrg	  func_to_tool_file "$output"
8906899129b3Smrg	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
8907899129b3Smrg	  func_execute_cmds "$postlink_cmds" 'exit $?'
8908899129b3Smrg	fi
8909899129b3Smrg
891047e89262Smrg	# Delete the generated files.
891147e89262Smrg	if test -f "$output_objdir/${outputname}S.${objext}"; then
891247e89262Smrg	  func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"'
8913bd1da9d7Smrg	fi
8914bd1da9d7Smrg
891547e89262Smrg	exit $exit_status
891647e89262Smrg      fi
8917bd1da9d7Smrg
891847e89262Smrg      if test -n "$compile_shlibpath$finalize_shlibpath"; then
891947e89262Smrg	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
892047e89262Smrg      fi
892147e89262Smrg      if test -n "$finalize_shlibpath"; then
892247e89262Smrg	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
892347e89262Smrg      fi
8924bd1da9d7Smrg
892547e89262Smrg      compile_var=
892647e89262Smrg      finalize_var=
892747e89262Smrg      if test -n "$runpath_var"; then
892847e89262Smrg	if test -n "$perm_rpath"; then
892947e89262Smrg	  # We should set the runpath_var.
893047e89262Smrg	  rpath=
893147e89262Smrg	  for dir in $perm_rpath; do
8932899129b3Smrg	    func_append rpath "$dir:"
893347e89262Smrg	  done
893447e89262Smrg	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
8935bd1da9d7Smrg	fi
893647e89262Smrg	if test -n "$finalize_perm_rpath"; then
893747e89262Smrg	  # We should set the runpath_var.
893847e89262Smrg	  rpath=
893947e89262Smrg	  for dir in $finalize_perm_rpath; do
8940899129b3Smrg	    func_append rpath "$dir:"
894147e89262Smrg	  done
894247e89262Smrg	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
8943bd1da9d7Smrg	fi
894447e89262Smrg      fi
8945bd1da9d7Smrg
894647e89262Smrg      if test "$no_install" = yes; then
894747e89262Smrg	# We don't need to create a wrapper script.
894847e89262Smrg	link_command="$compile_var$compile_command$compile_rpath"
894947e89262Smrg	# Replace the output file specification.
895047e89262Smrg	link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
895147e89262Smrg	# Delete the old output file.
895247e89262Smrg	$opt_dry_run || $RM $output
895347e89262Smrg	# Link the executable and exit
895447e89262Smrg	func_show_eval "$link_command" 'exit $?'
8955899129b3Smrg
8956899129b3Smrg	if test -n "$postlink_cmds"; then
8957899129b3Smrg	  func_to_tool_file "$output"
8958899129b3Smrg	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
8959899129b3Smrg	  func_execute_cmds "$postlink_cmds" 'exit $?'
8960899129b3Smrg	fi
8961899129b3Smrg
8962bd1da9d7Smrg	exit $EXIT_SUCCESS
896347e89262Smrg      fi
8964bd1da9d7Smrg
896547e89262Smrg      if test "$hardcode_action" = relink; then
896647e89262Smrg	# Fast installation is not supported
896747e89262Smrg	link_command="$compile_var$compile_command$compile_rpath"
896847e89262Smrg	relink_command="$finalize_var$finalize_command$finalize_rpath"
896947e89262Smrg
897047e89262Smrg	func_warning "this platform does not like uninstalled shared libraries"
897147e89262Smrg	func_warning "\`$output' will be relinked during installation"
897247e89262Smrg      else
897347e89262Smrg	if test "$fast_install" != no; then
897447e89262Smrg	  link_command="$finalize_var$compile_command$finalize_rpath"
897547e89262Smrg	  if test "$fast_install" = yes; then
897647e89262Smrg	    relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
897747e89262Smrg	  else
897847e89262Smrg	    # fast_install is set to needless
897947e89262Smrg	    relink_command=
898047e89262Smrg	  fi
8981bd1da9d7Smrg	else
898247e89262Smrg	  link_command="$compile_var$compile_command$compile_rpath"
898347e89262Smrg	  relink_command="$finalize_var$finalize_command$finalize_rpath"
8984bd1da9d7Smrg	fi
898547e89262Smrg      fi
8986bd1da9d7Smrg
898747e89262Smrg      # Replace the output file specification.
898847e89262Smrg      link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
8989bd1da9d7Smrg
899047e89262Smrg      # Delete the old output files.
899147e89262Smrg      $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
8992bd1da9d7Smrg
899347e89262Smrg      func_show_eval "$link_command" 'exit $?'
8994bd1da9d7Smrg
8995899129b3Smrg      if test -n "$postlink_cmds"; then
8996899129b3Smrg	func_to_tool_file "$output_objdir/$outputname"
8997899129b3Smrg	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'`
8998899129b3Smrg	func_execute_cmds "$postlink_cmds" 'exit $?'
8999899129b3Smrg      fi
9000899129b3Smrg
900147e89262Smrg      # Now create the wrapper script.
900247e89262Smrg      func_verbose "creating $output"
9003bd1da9d7Smrg
900447e89262Smrg      # Quote the relink command for shipping.
900547e89262Smrg      if test -n "$relink_command"; then
900647e89262Smrg	# Preserve any variables that may affect compiler behavior
900747e89262Smrg	for var in $variables_saved_for_relink; do
900847e89262Smrg	  if eval test -z \"\${$var+set}\"; then
900947e89262Smrg	    relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
901047e89262Smrg	  elif eval var_value=\$$var; test -z "$var_value"; then
901147e89262Smrg	    relink_command="$var=; export $var; $relink_command"
9012bd1da9d7Smrg	  else
901347e89262Smrg	    func_quote_for_eval "$var_value"
901447e89262Smrg	    relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
9015bd1da9d7Smrg	  fi
901647e89262Smrg	done
901747e89262Smrg	relink_command="(cd `pwd`; $relink_command)"
901847e89262Smrg	relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
901947e89262Smrg      fi
9020bd1da9d7Smrg
902147e89262Smrg      # Only actually do things if not in dry run mode.
902247e89262Smrg      $opt_dry_run || {
902347e89262Smrg	# win32 will think the script is a binary if it has
902447e89262Smrg	# a .exe suffix, so we strip it off here.
902547e89262Smrg	case $output in
902647e89262Smrg	  *.exe) func_stripname '' '.exe' "$output"
902747e89262Smrg	         output=$func_stripname_result ;;
902847e89262Smrg	esac
902947e89262Smrg	# test for cygwin because mv fails w/o .exe extensions
903047e89262Smrg	case $host in
903147e89262Smrg	  *cygwin*)
903247e89262Smrg	    exeext=.exe
903347e89262Smrg	    func_stripname '' '.exe' "$outputname"
903447e89262Smrg	    outputname=$func_stripname_result ;;
903547e89262Smrg	  *) exeext= ;;
9036bd1da9d7Smrg	esac
903747e89262Smrg	case $host in
903847e89262Smrg	  *cygwin* | *mingw* )
903947e89262Smrg	    func_dirname_and_basename "$output" "" "."
904047e89262Smrg	    output_name=$func_basename_result
904147e89262Smrg	    output_path=$func_dirname_result
904247e89262Smrg	    cwrappersource="$output_path/$objdir/lt-$output_name.c"
904347e89262Smrg	    cwrapper="$output_path/$output_name.exe"
904447e89262Smrg	    $RM $cwrappersource $cwrapper
904547e89262Smrg	    trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
904647e89262Smrg
904747e89262Smrg	    func_emit_cwrapperexe_src > $cwrappersource
904847e89262Smrg
904947e89262Smrg	    # The wrapper executable is built using the $host compiler,
905047e89262Smrg	    # because it contains $host paths and files. If cross-
905147e89262Smrg	    # compiling, it, like the target executable, must be
905247e89262Smrg	    # executed on the $host or under an emulation environment.
905347e89262Smrg	    $opt_dry_run || {
905447e89262Smrg	      $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
905547e89262Smrg	      $STRIP $cwrapper
905647e89262Smrg	    }
9057bd1da9d7Smrg
905847e89262Smrg	    # Now, create the wrapper script for func_source use:
905947e89262Smrg	    func_ltwrapper_scriptname $cwrapper
906047e89262Smrg	    $RM $func_ltwrapper_scriptname_result
906147e89262Smrg	    trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
906247e89262Smrg	    $opt_dry_run || {
906347e89262Smrg	      # note: this script will not be executed, so do not chmod.
906447e89262Smrg	      if test "x$build" = "x$host" ; then
906547e89262Smrg		$cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
906647e89262Smrg	      else
906747e89262Smrg		func_emit_wrapper no > $func_ltwrapper_scriptname_result
906847e89262Smrg	      fi
906947e89262Smrg	    }
907047e89262Smrg	  ;;
907147e89262Smrg	  * )
907247e89262Smrg	    $RM $output
907347e89262Smrg	    trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
9074bd1da9d7Smrg
907547e89262Smrg	    func_emit_wrapper no > $output
907647e89262Smrg	    chmod +x $output
907747e89262Smrg	  ;;
907847e89262Smrg	esac
907947e89262Smrg      }
908047e89262Smrg      exit $EXIT_SUCCESS
908147e89262Smrg      ;;
908247e89262Smrg    esac
9083bd1da9d7Smrg
908447e89262Smrg    # See if we need to build an old-fashioned archive.
908547e89262Smrg    for oldlib in $oldlibs; do
9086bd1da9d7Smrg
908747e89262Smrg      if test "$build_libtool_libs" = convenience; then
908847e89262Smrg	oldobjs="$libobjs_save $symfileobj"
908947e89262Smrg	addlibs="$convenience"
909047e89262Smrg	build_libtool_libs=no
909147e89262Smrg      else
909247e89262Smrg	if test "$build_libtool_libs" = module; then
909347e89262Smrg	  oldobjs="$libobjs_save"
909447e89262Smrg	  build_libtool_libs=no
909547e89262Smrg	else
909647e89262Smrg	  oldobjs="$old_deplibs $non_pic_objects"
909747e89262Smrg	  if test "$preload" = yes && test -f "$symfileobj"; then
9098899129b3Smrg	    func_append oldobjs " $symfileobj"
909947e89262Smrg	  fi
910047e89262Smrg	fi
910147e89262Smrg	addlibs="$old_convenience"
9102bd1da9d7Smrg      fi
9103bd1da9d7Smrg
910447e89262Smrg      if test -n "$addlibs"; then
910547e89262Smrg	gentop="$output_objdir/${outputname}x"
9106899129b3Smrg	func_append generated " $gentop"
9107bd1da9d7Smrg
910847e89262Smrg	func_extract_archives $gentop $addlibs
9109899129b3Smrg	func_append oldobjs " $func_extract_archives_result"
911047e89262Smrg      fi
9111bd1da9d7Smrg
911247e89262Smrg      # Do each command in the archive commands.
911347e89262Smrg      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
911447e89262Smrg	cmds=$old_archive_from_new_cmds
911547e89262Smrg      else
9116bd1da9d7Smrg
911747e89262Smrg	# Add any objects from preloaded convenience libraries
911847e89262Smrg	if test -n "$dlprefiles"; then
911947e89262Smrg	  gentop="$output_objdir/${outputname}x"
9120899129b3Smrg	  func_append generated " $gentop"
9121bd1da9d7Smrg
912247e89262Smrg	  func_extract_archives $gentop $dlprefiles
9123899129b3Smrg	  func_append oldobjs " $func_extract_archives_result"
912447e89262Smrg	fi
9125bd1da9d7Smrg
912647e89262Smrg	# POSIX demands no paths to be encoded in archives.  We have
912747e89262Smrg	# to avoid creating archives with duplicate basenames if we
912847e89262Smrg	# might have to extract them afterwards, e.g., when creating a
912947e89262Smrg	# static archive out of a convenience library, or when linking
913047e89262Smrg	# the entirety of a libtool archive into another (currently
913147e89262Smrg	# not supported by libtool).
913247e89262Smrg	if (for obj in $oldobjs
913347e89262Smrg	    do
913447e89262Smrg	      func_basename "$obj"
913547e89262Smrg	      $ECHO "$func_basename_result"
913647e89262Smrg	    done | sort | sort -uc >/dev/null 2>&1); then
913747e89262Smrg	  :
913847e89262Smrg	else
913947e89262Smrg	  echo "copying selected object files to avoid basename conflicts..."
914047e89262Smrg	  gentop="$output_objdir/${outputname}x"
9141899129b3Smrg	  func_append generated " $gentop"
914247e89262Smrg	  func_mkdir_p "$gentop"
914347e89262Smrg	  save_oldobjs=$oldobjs
914447e89262Smrg	  oldobjs=
914547e89262Smrg	  counter=1
914647e89262Smrg	  for obj in $save_oldobjs
914747e89262Smrg	  do
914847e89262Smrg	    func_basename "$obj"
914947e89262Smrg	    objbase="$func_basename_result"
915047e89262Smrg	    case " $oldobjs " in
915147e89262Smrg	    " ") oldobjs=$obj ;;
915247e89262Smrg	    *[\ /]"$objbase "*)
915347e89262Smrg	      while :; do
915447e89262Smrg		# Make sure we don't pick an alternate name that also
915547e89262Smrg		# overlaps.
915647e89262Smrg		newobj=lt$counter-$objbase
915747e89262Smrg		func_arith $counter + 1
915847e89262Smrg		counter=$func_arith_result
915947e89262Smrg		case " $oldobjs " in
916047e89262Smrg		*[\ /]"$newobj "*) ;;
916147e89262Smrg		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
916247e89262Smrg		esac
916347e89262Smrg	      done
916447e89262Smrg	      func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
9165899129b3Smrg	      func_append oldobjs " $gentop/$newobj"
916647e89262Smrg	      ;;
9167899129b3Smrg	    *) func_append oldobjs " $obj" ;;
916847e89262Smrg	    esac
9169bd1da9d7Smrg	  done
9170bd1da9d7Smrg	fi
9171899129b3Smrg	func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
9172899129b3Smrg	tool_oldlib=$func_to_tool_file_result
917347e89262Smrg	eval cmds=\"$old_archive_cmds\"
9174bd1da9d7Smrg
917547e89262Smrg	func_len " $cmds"
917647e89262Smrg	len=$func_len_result
917747e89262Smrg	if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
917847e89262Smrg	  cmds=$old_archive_cmds
9179899129b3Smrg	elif test -n "$archiver_list_spec"; then
9180899129b3Smrg	  func_verbose "using command file archive linking..."
9181899129b3Smrg	  for obj in $oldobjs
9182899129b3Smrg	  do
9183899129b3Smrg	    func_to_tool_file "$obj"
9184899129b3Smrg	    $ECHO "$func_to_tool_file_result"
9185899129b3Smrg	  done > $output_objdir/$libname.libcmd
9186899129b3Smrg	  func_to_tool_file "$output_objdir/$libname.libcmd"
9187899129b3Smrg	  oldobjs=" $archiver_list_spec$func_to_tool_file_result"
9188899129b3Smrg	  cmds=$old_archive_cmds
918947e89262Smrg	else
919047e89262Smrg	  # the command line is too long to link in one step, link in parts
919147e89262Smrg	  func_verbose "using piecewise archive linking..."
919247e89262Smrg	  save_RANLIB=$RANLIB
919347e89262Smrg	  RANLIB=:
919447e89262Smrg	  objlist=
919547e89262Smrg	  concat_cmds=
919647e89262Smrg	  save_oldobjs=$oldobjs
919747e89262Smrg	  oldobjs=
919847e89262Smrg	  # Is there a better way of finding the last object in the list?
919947e89262Smrg	  for obj in $save_oldobjs
920047e89262Smrg	  do
920147e89262Smrg	    last_oldobj=$obj
920247e89262Smrg	  done
920347e89262Smrg	  eval test_cmds=\"$old_archive_cmds\"
920447e89262Smrg	  func_len " $test_cmds"
920547e89262Smrg	  len0=$func_len_result
920647e89262Smrg	  len=$len0
920747e89262Smrg	  for obj in $save_oldobjs
920847e89262Smrg	  do
920947e89262Smrg	    func_len " $obj"
921047e89262Smrg	    func_arith $len + $func_len_result
921147e89262Smrg	    len=$func_arith_result
921247e89262Smrg	    func_append objlist " $obj"
921347e89262Smrg	    if test "$len" -lt "$max_cmd_len"; then
921447e89262Smrg	      :
921547e89262Smrg	    else
921647e89262Smrg	      # the above command should be used before it gets too long
921747e89262Smrg	      oldobjs=$objlist
921847e89262Smrg	      if test "$obj" = "$last_oldobj" ; then
921947e89262Smrg		RANLIB=$save_RANLIB
922047e89262Smrg	      fi
922147e89262Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
922247e89262Smrg	      eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
922347e89262Smrg	      objlist=
922447e89262Smrg	      len=$len0
922547e89262Smrg	    fi
922647e89262Smrg	  done
922747e89262Smrg	  RANLIB=$save_RANLIB
922847e89262Smrg	  oldobjs=$objlist
922947e89262Smrg	  if test "X$oldobjs" = "X" ; then
923047e89262Smrg	    eval cmds=\"\$concat_cmds\"
923147e89262Smrg	  else
923247e89262Smrg	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
923347e89262Smrg	  fi
923447e89262Smrg	fi
923547e89262Smrg      fi
923647e89262Smrg      func_execute_cmds "$cmds" 'exit $?'
9237bd1da9d7Smrg    done
9238bd1da9d7Smrg
923947e89262Smrg    test -n "$generated" && \
924047e89262Smrg      func_show_eval "${RM}r$generated"
9241bd1da9d7Smrg
924247e89262Smrg    # Now create the libtool archive.
924347e89262Smrg    case $output in
924447e89262Smrg    *.la)
924547e89262Smrg      old_library=
924647e89262Smrg      test "$build_old_libs" = yes && old_library="$libname.$libext"
924747e89262Smrg      func_verbose "creating $output"
9248bd1da9d7Smrg
924947e89262Smrg      # Preserve any variables that may affect compiler behavior
925047e89262Smrg      for var in $variables_saved_for_relink; do
925147e89262Smrg	if eval test -z \"\${$var+set}\"; then
925247e89262Smrg	  relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
925347e89262Smrg	elif eval var_value=\$$var; test -z "$var_value"; then
925447e89262Smrg	  relink_command="$var=; export $var; $relink_command"
9255bd1da9d7Smrg	else
925647e89262Smrg	  func_quote_for_eval "$var_value"
925747e89262Smrg	  relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
9258bd1da9d7Smrg	fi
925947e89262Smrg      done
926047e89262Smrg      # Quote the link command for shipping.
926147e89262Smrg      relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
926247e89262Smrg      relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
926347e89262Smrg      if test "$hardcode_automatic" = yes ; then
926447e89262Smrg	relink_command=
926547e89262Smrg      fi
9266bd1da9d7Smrg
926747e89262Smrg      # Only create the output if not a dry run.
926847e89262Smrg      $opt_dry_run || {
926947e89262Smrg	for installed in no yes; do
927047e89262Smrg	  if test "$installed" = yes; then
927147e89262Smrg	    if test -z "$install_libdir"; then
927247e89262Smrg	      break
927347e89262Smrg	    fi
927447e89262Smrg	    output="$output_objdir/$outputname"i
927547e89262Smrg	    # Replace all uninstalled libtool libraries with the installed ones
927647e89262Smrg	    newdependency_libs=
927747e89262Smrg	    for deplib in $dependency_libs; do
927847e89262Smrg	      case $deplib in
927947e89262Smrg	      *.la)
928047e89262Smrg		func_basename "$deplib"
928147e89262Smrg		name="$func_basename_result"
9282899129b3Smrg		func_resolve_sysroot "$deplib"
9283899129b3Smrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result`
928447e89262Smrg		test -z "$libdir" && \
928547e89262Smrg		  func_fatal_error "\`$deplib' is not a valid libtool archive"
9286899129b3Smrg		func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"
9287899129b3Smrg		;;
9288899129b3Smrg	      -L*)
9289899129b3Smrg		func_stripname -L '' "$deplib"
9290899129b3Smrg		func_replace_sysroot "$func_stripname_result"
9291899129b3Smrg		func_append newdependency_libs " -L$func_replace_sysroot_result"
9292899129b3Smrg		;;
9293899129b3Smrg	      -R*)
9294899129b3Smrg		func_stripname -R '' "$deplib"
9295899129b3Smrg		func_replace_sysroot "$func_stripname_result"
9296899129b3Smrg		func_append newdependency_libs " -R$func_replace_sysroot_result"
929747e89262Smrg		;;
9298899129b3Smrg	      *) func_append newdependency_libs " $deplib" ;;
929947e89262Smrg	      esac
930047e89262Smrg	    done
930147e89262Smrg	    dependency_libs="$newdependency_libs"
930247e89262Smrg	    newdlfiles=
930347e89262Smrg
930447e89262Smrg	    for lib in $dlfiles; do
930547e89262Smrg	      case $lib in
930647e89262Smrg	      *.la)
930747e89262Smrg	        func_basename "$lib"
930847e89262Smrg		name="$func_basename_result"
930947e89262Smrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
931047e89262Smrg		test -z "$libdir" && \
931147e89262Smrg		  func_fatal_error "\`$lib' is not a valid libtool archive"
9312899129b3Smrg		func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name"
931347e89262Smrg		;;
9314899129b3Smrg	      *) func_append newdlfiles " $lib" ;;
931547e89262Smrg	      esac
931647e89262Smrg	    done
931747e89262Smrg	    dlfiles="$newdlfiles"
931847e89262Smrg	    newdlprefiles=
931947e89262Smrg	    for lib in $dlprefiles; do
932047e89262Smrg	      case $lib in
932147e89262Smrg	      *.la)
932247e89262Smrg		# Only pass preopened files to the pseudo-archive (for
932347e89262Smrg		# eventual linking with the app. that links it) if we
932447e89262Smrg		# didn't already link the preopened objects directly into
932547e89262Smrg		# the library:
932647e89262Smrg		func_basename "$lib"
932747e89262Smrg		name="$func_basename_result"
932847e89262Smrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
932947e89262Smrg		test -z "$libdir" && \
933047e89262Smrg		  func_fatal_error "\`$lib' is not a valid libtool archive"
9331899129b3Smrg		func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name"
933247e89262Smrg		;;
933347e89262Smrg	      esac
933447e89262Smrg	    done
933547e89262Smrg	    dlprefiles="$newdlprefiles"
933647e89262Smrg	  else
933747e89262Smrg	    newdlfiles=
933847e89262Smrg	    for lib in $dlfiles; do
933947e89262Smrg	      case $lib in
934047e89262Smrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
934147e89262Smrg		*) abs=`pwd`"/$lib" ;;
934247e89262Smrg	      esac
9343899129b3Smrg	      func_append newdlfiles " $abs"
934447e89262Smrg	    done
934547e89262Smrg	    dlfiles="$newdlfiles"
934647e89262Smrg	    newdlprefiles=
934747e89262Smrg	    for lib in $dlprefiles; do
934847e89262Smrg	      case $lib in
934947e89262Smrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
935047e89262Smrg		*) abs=`pwd`"/$lib" ;;
935147e89262Smrg	      esac
9352899129b3Smrg	      func_append newdlprefiles " $abs"
935347e89262Smrg	    done
935447e89262Smrg	    dlprefiles="$newdlprefiles"
935547e89262Smrg	  fi
935647e89262Smrg	  $RM $output
935747e89262Smrg	  # place dlname in correct position for cygwin
935847e89262Smrg	  # In fact, it would be nice if we could use this code for all target
935947e89262Smrg	  # systems that can't hard-code library paths into their executables
936047e89262Smrg	  # and that have no shared library path variable independent of PATH,
936147e89262Smrg	  # but it turns out we can't easily determine that from inspecting
936247e89262Smrg	  # libtool variables, so we have to hard-code the OSs to which it
936347e89262Smrg	  # applies here; at the moment, that means platforms that use the PE
936447e89262Smrg	  # object format with DLL files.  See the long comment at the top of
936547e89262Smrg	  # tests/bindir.at for full details.
936647e89262Smrg	  tdlname=$dlname
936747e89262Smrg	  case $host,$output,$installed,$module,$dlname in
936847e89262Smrg	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
936947e89262Smrg	      # If a -bindir argument was supplied, place the dll there.
937047e89262Smrg	      if test "x$bindir" != x ;
937147e89262Smrg	      then
937247e89262Smrg		func_relative_path "$install_libdir" "$bindir"
937347e89262Smrg		tdlname=$func_relative_path_result$dlname
937447e89262Smrg	      else
937547e89262Smrg		# Otherwise fall back on heuristic.
937647e89262Smrg		tdlname=../bin/$dlname
937747e89262Smrg	      fi
937847e89262Smrg	      ;;
937947e89262Smrg	  esac
938047e89262Smrg	  $ECHO > $output "\
938147e89262Smrg# $outputname - a libtool library file
938247e89262Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
938347e89262Smrg#
938447e89262Smrg# Please DO NOT delete this file!
938547e89262Smrg# It is necessary for linking the library.
9386bd1da9d7Smrg
938747e89262Smrg# The name that we can dlopen(3).
938847e89262Smrgdlname='$tdlname'
9389bd1da9d7Smrg
939047e89262Smrg# Names of this library.
939147e89262Smrglibrary_names='$library_names'
9392bd1da9d7Smrg
939347e89262Smrg# The name of the static archive.
939447e89262Smrgold_library='$old_library'
9395bd1da9d7Smrg
939647e89262Smrg# Linker flags that can not go in dependency_libs.
939747e89262Smrginherited_linker_flags='$new_inherited_linker_flags'
9398bd1da9d7Smrg
939947e89262Smrg# Libraries that this one depends upon.
940047e89262Smrgdependency_libs='$dependency_libs'
9401bd1da9d7Smrg
940247e89262Smrg# Names of additional weak libraries provided by this library
940347e89262Smrgweak_library_names='$weak_libs'
9404bd1da9d7Smrg
940547e89262Smrg# Version information for $libname.
940647e89262Smrgcurrent=$current
940747e89262Smrgage=$age
940847e89262Smrgrevision=$revision
9409bd1da9d7Smrg
941047e89262Smrg# Is this an already installed library?
941147e89262Smrginstalled=$installed
9412bd1da9d7Smrg
941347e89262Smrg# Should we warn about portability when linking against -modules?
941447e89262Smrgshouldnotlink=$module
9415bd1da9d7Smrg
941647e89262Smrg# Files to dlopen/dlpreopen
941747e89262Smrgdlopen='$dlfiles'
941847e89262Smrgdlpreopen='$dlprefiles'
9419bd1da9d7Smrg
942047e89262Smrg# Directory that this library needs to be installed in:
942147e89262Smrglibdir='$install_libdir'"
942247e89262Smrg	  if test "$installed" = no && test "$need_relink" = yes; then
942347e89262Smrg	    $ECHO >> $output "\
942447e89262Smrgrelink_command=\"$relink_command\""
942547e89262Smrg	  fi
942647e89262Smrg	done
942747e89262Smrg      }
9428bd1da9d7Smrg
942947e89262Smrg      # Do a symbolic link so that the libtool archive can be found in
943047e89262Smrg      # LD_LIBRARY_PATH before the program is installed.
943147e89262Smrg      func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
943247e89262Smrg      ;;
943347e89262Smrg    esac
943447e89262Smrg    exit $EXIT_SUCCESS
943547e89262Smrg}
9436bd1da9d7Smrg
9437899129b3Smrg{ test "$opt_mode" = link || test "$opt_mode" = relink; } &&
943847e89262Smrg    func_mode_link ${1+"$@"}
9439bd1da9d7Smrg
9440bd1da9d7Smrg
944147e89262Smrg# func_mode_uninstall arg...
944247e89262Smrgfunc_mode_uninstall ()
944347e89262Smrg{
944447e89262Smrg    $opt_debug
944547e89262Smrg    RM="$nonopt"
9446bd1da9d7Smrg    files=
9447bd1da9d7Smrg    rmforce=
9448bd1da9d7Smrg    exit_status=0
9449bd1da9d7Smrg
9450bd1da9d7Smrg    # This variable tells wrapper scripts just to set variables rather
9451bd1da9d7Smrg    # than running their programs.
9452bd1da9d7Smrg    libtool_install_magic="$magic"
9453bd1da9d7Smrg
9454bd1da9d7Smrg    for arg
9455bd1da9d7Smrg    do
9456bd1da9d7Smrg      case $arg in
9457899129b3Smrg      -f) func_append RM " $arg"; rmforce=yes ;;
9458899129b3Smrg      -*) func_append RM " $arg" ;;
9459899129b3Smrg      *) func_append files " $arg" ;;
9460bd1da9d7Smrg      esac
9461bd1da9d7Smrg    done
9462bd1da9d7Smrg
946347e89262Smrg    test -z "$RM" && \
946447e89262Smrg      func_fatal_help "you must specify an RM program"
9465bd1da9d7Smrg
9466bd1da9d7Smrg    rmdirs=
9467bd1da9d7Smrg
9468bd1da9d7Smrg    for file in $files; do
946947e89262Smrg      func_dirname "$file" "" "."
947047e89262Smrg      dir="$func_dirname_result"
947147e89262Smrg      if test "X$dir" = X.; then
9472899129b3Smrg	odir="$objdir"
9473bd1da9d7Smrg      else
9474899129b3Smrg	odir="$dir/$objdir"
9475bd1da9d7Smrg      fi
947647e89262Smrg      func_basename "$file"
947747e89262Smrg      name="$func_basename_result"
9478899129b3Smrg      test "$opt_mode" = uninstall && odir="$dir"
9479bd1da9d7Smrg
9480899129b3Smrg      # Remember odir for removal later, being careful to avoid duplicates
9481899129b3Smrg      if test "$opt_mode" = clean; then
9482bd1da9d7Smrg	case " $rmdirs " in
9483899129b3Smrg	  *" $odir "*) ;;
9484899129b3Smrg	  *) func_append rmdirs " $odir" ;;
9485bd1da9d7Smrg	esac
9486bd1da9d7Smrg      fi
9487bd1da9d7Smrg
9488bd1da9d7Smrg      # Don't error if the file doesn't exist and rm -f was used.
948947e89262Smrg      if { test -L "$file"; } >/dev/null 2>&1 ||
949047e89262Smrg	 { test -h "$file"; } >/dev/null 2>&1 ||
949147e89262Smrg	 test -f "$file"; then
9492bd1da9d7Smrg	:
9493bd1da9d7Smrg      elif test -d "$file"; then
9494bd1da9d7Smrg	exit_status=1
9495bd1da9d7Smrg	continue
9496bd1da9d7Smrg      elif test "$rmforce" = yes; then
9497bd1da9d7Smrg	continue
9498bd1da9d7Smrg      fi
9499bd1da9d7Smrg
9500bd1da9d7Smrg      rmfiles="$file"
9501bd1da9d7Smrg
9502bd1da9d7Smrg      case $name in
9503bd1da9d7Smrg      *.la)
9504bd1da9d7Smrg	# Possibly a libtool archive, so verify it.
950547e89262Smrg	if func_lalib_p "$file"; then
950647e89262Smrg	  func_source $dir/$name
9507bd1da9d7Smrg
9508bd1da9d7Smrg	  # Delete the libtool libraries and symlinks.
9509bd1da9d7Smrg	  for n in $library_names; do
9510899129b3Smrg	    func_append rmfiles " $odir/$n"
9511bd1da9d7Smrg	  done
9512899129b3Smrg	  test -n "$old_library" && func_append rmfiles " $odir/$old_library"
9513bd1da9d7Smrg
9514899129b3Smrg	  case "$opt_mode" in
9515bd1da9d7Smrg	  clean)
9516899129b3Smrg	    case " $library_names " in
9517bd1da9d7Smrg	    *" $dlname "*) ;;
9518899129b3Smrg	    *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;;
9519bd1da9d7Smrg	    esac
9520899129b3Smrg	    test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i"
9521bd1da9d7Smrg	    ;;
9522bd1da9d7Smrg	  uninstall)
9523bd1da9d7Smrg	    if test -n "$library_names"; then
9524bd1da9d7Smrg	      # Do each command in the postuninstall commands.
952547e89262Smrg	      func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
9526bd1da9d7Smrg	    fi
9527bd1da9d7Smrg
9528bd1da9d7Smrg	    if test -n "$old_library"; then
9529bd1da9d7Smrg	      # Do each command in the old_postuninstall commands.
953047e89262Smrg	      func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
9531bd1da9d7Smrg	    fi
9532bd1da9d7Smrg	    # FIXME: should reinstall the best remaining shared library.
9533bd1da9d7Smrg	    ;;
9534bd1da9d7Smrg	  esac
9535bd1da9d7Smrg	fi
9536bd1da9d7Smrg	;;
9537bd1da9d7Smrg
9538bd1da9d7Smrg      *.lo)
9539bd1da9d7Smrg	# Possibly a libtool object, so verify it.
954047e89262Smrg	if func_lalib_p "$file"; then
9541bd1da9d7Smrg
9542bd1da9d7Smrg	  # Read the .lo file
954347e89262Smrg	  func_source $dir/$name
9544bd1da9d7Smrg
9545bd1da9d7Smrg	  # Add PIC object to the list of files to remove.
954647e89262Smrg	  if test -n "$pic_object" &&
954747e89262Smrg	     test "$pic_object" != none; then
9548899129b3Smrg	    func_append rmfiles " $dir/$pic_object"
9549bd1da9d7Smrg	  fi
9550bd1da9d7Smrg
9551bd1da9d7Smrg	  # Add non-PIC object to the list of files to remove.
955247e89262Smrg	  if test -n "$non_pic_object" &&
955347e89262Smrg	     test "$non_pic_object" != none; then
9554899129b3Smrg	    func_append rmfiles " $dir/$non_pic_object"
9555bd1da9d7Smrg	  fi
9556bd1da9d7Smrg	fi
9557bd1da9d7Smrg	;;
9558bd1da9d7Smrg
9559bd1da9d7Smrg      *)
9560899129b3Smrg	if test "$opt_mode" = clean ; then
9561bd1da9d7Smrg	  noexename=$name
9562bd1da9d7Smrg	  case $file in
9563bd1da9d7Smrg	  *.exe)
956447e89262Smrg	    func_stripname '' '.exe' "$file"
956547e89262Smrg	    file=$func_stripname_result
956647e89262Smrg	    func_stripname '' '.exe' "$name"
956747e89262Smrg	    noexename=$func_stripname_result
9568bd1da9d7Smrg	    # $file with .exe has already been added to rmfiles,
9569bd1da9d7Smrg	    # add $file without .exe
9570899129b3Smrg	    func_append rmfiles " $file"
9571bd1da9d7Smrg	    ;;
9572bd1da9d7Smrg	  esac
9573bd1da9d7Smrg	  # Do a test to see if this is a libtool program.
957447e89262Smrg	  if func_ltwrapper_p "$file"; then
957547e89262Smrg	    if func_ltwrapper_executable_p "$file"; then
957647e89262Smrg	      func_ltwrapper_scriptname "$file"
957747e89262Smrg	      relink_command=
957847e89262Smrg	      func_source $func_ltwrapper_scriptname_result
9579899129b3Smrg	      func_append rmfiles " $func_ltwrapper_scriptname_result"
958047e89262Smrg	    else
958147e89262Smrg	      relink_command=
958247e89262Smrg	      func_source $dir/$noexename
958347e89262Smrg	    fi
9584bd1da9d7Smrg
9585bd1da9d7Smrg	    # note $name still contains .exe if it was in $file originally
9586bd1da9d7Smrg	    # as does the version of $file that was added into $rmfiles
9587899129b3Smrg	    func_append rmfiles " $odir/$name $odir/${name}S.${objext}"
9588bd1da9d7Smrg	    if test "$fast_install" = yes && test -n "$relink_command"; then
9589899129b3Smrg	      func_append rmfiles " $odir/lt-$name"
9590bd1da9d7Smrg	    fi
9591bd1da9d7Smrg	    if test "X$noexename" != "X$name" ; then
9592899129b3Smrg	      func_append rmfiles " $odir/lt-${noexename}.c"
9593bd1da9d7Smrg	    fi
9594bd1da9d7Smrg	  fi
9595bd1da9d7Smrg	fi
9596bd1da9d7Smrg	;;
9597bd1da9d7Smrg      esac
959847e89262Smrg      func_show_eval "$RM $rmfiles" 'exit_status=1'
9599bd1da9d7Smrg    done
9600bd1da9d7Smrg
9601bd1da9d7Smrg    # Try to remove the ${objdir}s in the directories where we deleted files
9602bd1da9d7Smrg    for dir in $rmdirs; do
9603bd1da9d7Smrg      if test -d "$dir"; then
960447e89262Smrg	func_show_eval "rmdir $dir >/dev/null 2>&1"
9605bd1da9d7Smrg      fi
9606bd1da9d7Smrg    done
9607bd1da9d7Smrg
9608bd1da9d7Smrg    exit $exit_status
960947e89262Smrg}
9610bd1da9d7Smrg
9611899129b3Smrg{ test "$opt_mode" = uninstall || test "$opt_mode" = clean; } &&
961247e89262Smrg    func_mode_uninstall ${1+"$@"}
9613bd1da9d7Smrg
9614899129b3Smrgtest -z "$opt_mode" && {
961547e89262Smrg  help="$generic_help"
961647e89262Smrg  func_fatal_help "you must specify a MODE"
961747e89262Smrg}
961847e89262Smrg
961947e89262Smrgtest -z "$exec_cmd" && \
9620899129b3Smrg  func_fatal_help "invalid operation mode \`$opt_mode'"
9621bd1da9d7Smrg
9622bd1da9d7Smrgif test -n "$exec_cmd"; then
962347e89262Smrg  eval exec "$exec_cmd"
9624bd1da9d7Smrg  exit $EXIT_FAILURE
9625bd1da9d7Smrgfi
9626bd1da9d7Smrg
962747e89262Smrgexit $exit_status
9628bd1da9d7Smrg
9629bd1da9d7Smrg
9630bd1da9d7Smrg# The TAGs below are defined such that we never get into a situation
9631bd1da9d7Smrg# in which we disable both kinds of libraries.  Given conflicting
9632bd1da9d7Smrg# choices, we go for a static library, that is the most portable,
9633bd1da9d7Smrg# since we can't tell whether shared libraries were disabled because
9634bd1da9d7Smrg# the user asked for that or because the platform doesn't support
9635bd1da9d7Smrg# them.  This is particularly important on AIX, because we don't
9636bd1da9d7Smrg# support having both static and shared libraries enabled at the same
9637bd1da9d7Smrg# time on that platform, so we default to a shared-only configuration.
9638bd1da9d7Smrg# If a disable-shared tag is given, we'll fallback to a static-only
9639bd1da9d7Smrg# configuration.  But we'll never go from static-only to shared-only.
9640bd1da9d7Smrg
9641bd1da9d7Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
964247e89262Smrgbuild_libtool_libs=no
964347e89262Smrgbuild_old_libs=yes
9644bd1da9d7Smrg# ### END LIBTOOL TAG CONFIG: disable-shared
9645bd1da9d7Smrg
9646bd1da9d7Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static
964747e89262Smrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
9648bd1da9d7Smrg# ### END LIBTOOL TAG CONFIG: disable-static
9649bd1da9d7Smrg
9650bd1da9d7Smrg# Local Variables:
9651bd1da9d7Smrg# mode:shell-script
9652bd1da9d7Smrg# sh-indentation:2
9653bd1da9d7Smrg# End:
965447e89262Smrg# vi:sw=2
965547e89262Smrg
9656