ltmain.sh revision b789ec8a
1c27c18e8Smrg
2b789ec8aSmrg# libtool (GNU libtool) 2.4
3c27c18e8Smrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
4c27c18e8Smrg
537eb1ca1Smrg# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006,
637eb1ca1Smrg# 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
7c27c18e8Smrg# This is free software; see the source for copying conditions.  There is NO
8c27c18e8Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9c27c18e8Smrg
10c27c18e8Smrg# GNU Libtool is free software; you can redistribute it and/or modify
11c43cc173Smrg# it under the terms of the GNU General Public License as published by
12c43cc173Smrg# the Free Software Foundation; either version 2 of the License, or
13c43cc173Smrg# (at your option) any later version.
14c43cc173Smrg#
15c27c18e8Smrg# As a special exception to the GNU General Public License,
16c27c18e8Smrg# if you distribute this file as part of a program or library that
17c27c18e8Smrg# is built using GNU Libtool, you may include this file under the
18c27c18e8Smrg# same distribution terms that you use for the rest of that program.
19c27c18e8Smrg#
20c27c18e8Smrg# GNU Libtool is distributed in the hope that it will be useful, but
21c43cc173Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of
22c43cc173Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
23c43cc173Smrg# General Public License for more details.
24c43cc173Smrg#
25c43cc173Smrg# You should have received a copy of the GNU General Public License
26c27c18e8Smrg# along with GNU Libtool; see the file COPYING.  If not, a copy
27c27c18e8Smrg# can be downloaded from http://www.gnu.org/licenses/gpl.html,
28c27c18e8Smrg# or obtained by writing to the Free Software Foundation, Inc.,
29c27c18e8Smrg# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
30c43cc173Smrg
31c27c18e8Smrg# Usage: $progname [OPTION]... [MODE-ARG]...
32c27c18e8Smrg#
33c27c18e8Smrg# Provide generalized library-building support services.
34c27c18e8Smrg#
3537eb1ca1Smrg#       --config             show all configuration variables
3637eb1ca1Smrg#       --debug              enable verbose shell tracing
3737eb1ca1Smrg#   -n, --dry-run            display commands without modifying any files
3837eb1ca1Smrg#       --features           display basic configuration information and exit
3937eb1ca1Smrg#       --mode=MODE          use operation mode MODE
4037eb1ca1Smrg#       --preserve-dup-deps  don't remove duplicate dependency libraries
4137eb1ca1Smrg#       --quiet, --silent    don't print informational messages
4237eb1ca1Smrg#       --no-quiet, --no-silent
4337eb1ca1Smrg#                            print informational messages (default)
4437eb1ca1Smrg#       --tag=TAG            use configuration variables from tag TAG
4537eb1ca1Smrg#   -v, --verbose            print more informational messages than default
4637eb1ca1Smrg#       --no-verbose         don't print the extra informational messages
4737eb1ca1Smrg#       --version            print version information
4837eb1ca1Smrg#   -h, --help, --help-all   print short, long, or detailed help message
49c27c18e8Smrg#
50c27c18e8Smrg# MODE must be one of the following:
51c27c18e8Smrg#
5237eb1ca1Smrg#         clean              remove files from the build directory
5337eb1ca1Smrg#         compile            compile a source file into a libtool object
5437eb1ca1Smrg#         execute            automatically set library path, then run a program
5537eb1ca1Smrg#         finish             complete the installation of libtool libraries
5637eb1ca1Smrg#         install            install libraries or executables
5737eb1ca1Smrg#         link               create a library or an executable
5837eb1ca1Smrg#         uninstall          remove libraries from an installed directory
59c27c18e8Smrg#
6037eb1ca1Smrg# MODE-ARGS vary depending on the MODE.  When passed as first option,
6137eb1ca1Smrg# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that.
62c27c18e8Smrg# Try `$progname --help --mode=MODE' for a more detailed description of MODE.
63c27c18e8Smrg#
64c27c18e8Smrg# When reporting a bug, please describe a test case to reproduce it and
65c27c18e8Smrg# include the following information:
66c27c18e8Smrg#
6737eb1ca1Smrg#         host-triplet:	$host
6837eb1ca1Smrg#         shell:		$SHELL
6937eb1ca1Smrg#         compiler:		$LTCC
7037eb1ca1Smrg#         compiler flags:		$LTCFLAGS
7137eb1ca1Smrg#         linker:		$LD (gnu? $with_gnu_ld)
72b789ec8aSmrg#         $progname:	(GNU libtool) 2.4
7337eb1ca1Smrg#         automake:	$automake_version
7437eb1ca1Smrg#         autoconf:	$autoconf_version
75c27c18e8Smrg#
76c27c18e8Smrg# Report bugs to <bug-libtool@gnu.org>.
77b789ec8aSmrg# GNU libtool home page: <http://www.gnu.org/software/libtool/>.
78b789ec8aSmrg# General help using GNU software: <http://www.gnu.org/gethelp/>.
79c43cc173Smrg
8037eb1ca1SmrgPROGRAM=libtool
81c43cc173SmrgPACKAGE=libtool
82b789ec8aSmrgVERSION=2.4
83c27c18e8SmrgTIMESTAMP=""
84b789ec8aSmrgpackage_revision=1.3293
8521e67964Smrg
86c27c18e8Smrg# Be Bourne compatible
8721e67964Smrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
8821e67964Smrg  emulate sh
8921e67964Smrg  NULLCMD=:
9021e67964Smrg  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
9121e67964Smrg  # is contrary to our usage.  Disable this feature.
9221e67964Smrg  alias -g '${1+"$@"}'='"$@"'
93c43cc173Smrg  setopt NO_GLOB_SUBST
9421e67964Smrgelse
9521e67964Smrg  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
96c43cc173Smrgfi
9721e67964SmrgBIN_SH=xpg4; export BIN_SH # for Tru64
9821e67964SmrgDUALCASE=1; export DUALCASE # for MKS sh
99c43cc173Smrg
10037eb1ca1Smrg# A function that is used when there is no print builtin or printf.
10137eb1ca1Smrgfunc_fallback_echo ()
10237eb1ca1Smrg{
10337eb1ca1Smrg  eval 'cat <<_LTECHO_EOF
10437eb1ca1Smrg$1
10537eb1ca1Smrg_LTECHO_EOF'
10637eb1ca1Smrg}
10737eb1ca1Smrg
108c27c18e8Smrg# NLS nuisances: We save the old values to restore during execute mode.
109c27c18e8Smrglt_user_locale=
110c27c18e8Smrglt_safe_locale=
111c27c18e8Smrgfor lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
11221e67964Smrgdo
11321e67964Smrg  eval "if test \"\${$lt_var+set}\" = set; then
114c27c18e8Smrg          save_$lt_var=\$$lt_var
115c27c18e8Smrg          $lt_var=C
11621e67964Smrg	  export $lt_var
117c27c18e8Smrg	  lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\"
118c27c18e8Smrg	  lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
11921e67964Smrg	fi"
12021e67964Smrgdone
12137eb1ca1SmrgLC_ALL=C
12237eb1ca1SmrgLANGUAGE=C
12337eb1ca1Smrgexport LANGUAGE LC_ALL
124c43cc173Smrg
125c27c18e8Smrg$lt_unset CDPATH
126c27c18e8Smrg
127c27c18e8Smrg
12837eb1ca1Smrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
12937eb1ca1Smrg# is ksh but when the shell is invoked as "sh" and the current value of
13037eb1ca1Smrg# the _XPG environment variable is not equal to 1 (one), the special
13137eb1ca1Smrg# positional parameter $0, within a function call, is the name of the
13237eb1ca1Smrg# function.
13337eb1ca1Smrgprogpath="$0"
134c27c18e8Smrg
135c27c18e8Smrg
136c27c18e8Smrg
137c27c18e8Smrg: ${CP="cp -f"}
13837eb1ca1Smrgtest "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'}
139c27c18e8Smrg: ${EGREP="/bin/grep -E"}
140c27c18e8Smrg: ${FGREP="/bin/grep -F"}
141c27c18e8Smrg: ${GREP="/bin/grep"}
142c27c18e8Smrg: ${LN_S="ln -s"}
143c27c18e8Smrg: ${MAKE="make"}
144c27c18e8Smrg: ${MKDIR="mkdir"}
145c27c18e8Smrg: ${MV="mv -f"}
146c27c18e8Smrg: ${RM="rm -f"}
147c27c18e8Smrg: ${SED="/bin/sed"}
148c27c18e8Smrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
149c27c18e8Smrg: ${Xsed="$SED -e 1s/^X//"}
150c27c18e8Smrg
151c27c18e8Smrg# Global variables:
152c27c18e8SmrgEXIT_SUCCESS=0
153c27c18e8SmrgEXIT_FAILURE=1
154c27c18e8SmrgEXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
155c27c18e8SmrgEXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
156c27c18e8Smrg
157c27c18e8Smrgexit_status=$EXIT_SUCCESS
158c27c18e8Smrg
159c43cc173Smrg# Make sure IFS has a sensible default
160c43cc173Smrglt_nl='
161c43cc173Smrg'
162c43cc173SmrgIFS=" 	$lt_nl"
163c43cc173Smrg
164c27c18e8Smrgdirname="s,/[^/]*$,,"
165c27c18e8Smrgbasename="s,^.*/,,"
166c27c18e8Smrg
167b789ec8aSmrg# func_dirname file append nondir_replacement
168b789ec8aSmrg# Compute the dirname of FILE.  If nonempty, add APPEND to the result,
169b789ec8aSmrg# otherwise set result to NONDIR_REPLACEMENT.
170b789ec8aSmrgfunc_dirname ()
171b789ec8aSmrg{
172b789ec8aSmrg    func_dirname_result=`$ECHO "${1}" | $SED "$dirname"`
173b789ec8aSmrg    if test "X$func_dirname_result" = "X${1}"; then
174b789ec8aSmrg      func_dirname_result="${3}"
175b789ec8aSmrg    else
176b789ec8aSmrg      func_dirname_result="$func_dirname_result${2}"
177b789ec8aSmrg    fi
178b789ec8aSmrg} # func_dirname may be replaced by extended shell implementation
179b789ec8aSmrg
180b789ec8aSmrg
181b789ec8aSmrg# func_basename file
182b789ec8aSmrgfunc_basename ()
183b789ec8aSmrg{
184b789ec8aSmrg    func_basename_result=`$ECHO "${1}" | $SED "$basename"`
185b789ec8aSmrg} # func_basename may be replaced by extended shell implementation
186b789ec8aSmrg
187b789ec8aSmrg
188c27c18e8Smrg# func_dirname_and_basename file append nondir_replacement
189c27c18e8Smrg# perform func_basename and func_dirname in a single function
190c27c18e8Smrg# call:
191c27c18e8Smrg#   dirname:  Compute the dirname of FILE.  If nonempty,
192c27c18e8Smrg#             add APPEND to the result, otherwise set result
193c27c18e8Smrg#             to NONDIR_REPLACEMENT.
194c27c18e8Smrg#             value returned in "$func_dirname_result"
195c27c18e8Smrg#   basename: Compute filename of FILE.
196c27c18e8Smrg#             value retuned in "$func_basename_result"
197c27c18e8Smrg# Implementation must be kept synchronized with func_dirname
198c27c18e8Smrg# and func_basename. For efficiency, we do not delegate to
199c27c18e8Smrg# those functions but instead duplicate the functionality here.
200c27c18e8Smrgfunc_dirname_and_basename ()
201c27c18e8Smrg{
202b789ec8aSmrg    # Extract subdirectory from the argument.
203b789ec8aSmrg    func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"`
204b789ec8aSmrg    if test "X$func_dirname_result" = "X${1}"; then
205b789ec8aSmrg      func_dirname_result="${3}"
206b789ec8aSmrg    else
207b789ec8aSmrg      func_dirname_result="$func_dirname_result${2}"
208b789ec8aSmrg    fi
209b789ec8aSmrg    func_basename_result=`$ECHO "${1}" | $SED -e "$basename"`
210b789ec8aSmrg} # func_dirname_and_basename may be replaced by extended shell implementation
211b789ec8aSmrg
212b789ec8aSmrg
213b789ec8aSmrg# func_stripname prefix suffix name
214b789ec8aSmrg# strip PREFIX and SUFFIX off of NAME.
215b789ec8aSmrg# PREFIX and SUFFIX must not contain globbing or regex special
216b789ec8aSmrg# characters, hashes, percent signs, but SUFFIX may contain a leading
217b789ec8aSmrg# dot (in which case that matches only a dot).
218b789ec8aSmrg# func_strip_suffix prefix name
219b789ec8aSmrgfunc_stripname ()
220b789ec8aSmrg{
221b789ec8aSmrg    case ${2} in
222b789ec8aSmrg      .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;;
223b789ec8aSmrg      *)  func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;;
224b789ec8aSmrg    esac
225b789ec8aSmrg} # func_stripname may be replaced by extended shell implementation
226c43cc173Smrg
227c27c18e8Smrg
22837eb1ca1Smrg# These SED scripts presuppose an absolute path with a trailing slash.
22937eb1ca1Smrgpathcar='s,^/\([^/]*\).*$,\1,'
23037eb1ca1Smrgpathcdr='s,^/[^/]*,,'
23137eb1ca1Smrgremovedotparts=':dotsl
23237eb1ca1Smrg		s@/\./@/@g
23337eb1ca1Smrg		t dotsl
23437eb1ca1Smrg		s,/\.$,/,'
23537eb1ca1Smrgcollapseslashes='s@/\{1,\}@/@g'
23637eb1ca1Smrgfinalslash='s,/*$,/,'
23737eb1ca1Smrg
23837eb1ca1Smrg# func_normal_abspath PATH
23937eb1ca1Smrg# Remove doubled-up and trailing slashes, "." path components,
24037eb1ca1Smrg# and cancel out any ".." path components in PATH after making
24137eb1ca1Smrg# it an absolute path.
24237eb1ca1Smrg#             value returned in "$func_normal_abspath_result"
24337eb1ca1Smrgfunc_normal_abspath ()
24437eb1ca1Smrg{
24537eb1ca1Smrg  # Start from root dir and reassemble the path.
24637eb1ca1Smrg  func_normal_abspath_result=
24737eb1ca1Smrg  func_normal_abspath_tpath=$1
24837eb1ca1Smrg  func_normal_abspath_altnamespace=
24937eb1ca1Smrg  case $func_normal_abspath_tpath in
25037eb1ca1Smrg    "")
25137eb1ca1Smrg      # Empty path, that just means $cwd.
25237eb1ca1Smrg      func_stripname '' '/' "`pwd`"
25337eb1ca1Smrg      func_normal_abspath_result=$func_stripname_result
25437eb1ca1Smrg      return
25537eb1ca1Smrg    ;;
25637eb1ca1Smrg    # The next three entries are used to spot a run of precisely
25737eb1ca1Smrg    # two leading slashes without using negated character classes;
25837eb1ca1Smrg    # we take advantage of case's first-match behaviour.
25937eb1ca1Smrg    ///*)
26037eb1ca1Smrg      # Unusual form of absolute path, do nothing.
26137eb1ca1Smrg    ;;
26237eb1ca1Smrg    //*)
26337eb1ca1Smrg      # Not necessarily an ordinary path; POSIX reserves leading '//'
26437eb1ca1Smrg      # and for example Cygwin uses it to access remote file shares
26537eb1ca1Smrg      # over CIFS/SMB, so we conserve a leading double slash if found.
26637eb1ca1Smrg      func_normal_abspath_altnamespace=/
26737eb1ca1Smrg    ;;
26837eb1ca1Smrg    /*)
26937eb1ca1Smrg      # Absolute path, do nothing.
27037eb1ca1Smrg    ;;
27137eb1ca1Smrg    *)
27237eb1ca1Smrg      # Relative path, prepend $cwd.
27337eb1ca1Smrg      func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
27437eb1ca1Smrg    ;;
27537eb1ca1Smrg  esac
27637eb1ca1Smrg  # Cancel out all the simple stuff to save iterations.  We also want
27737eb1ca1Smrg  # the path to end with a slash for ease of parsing, so make sure
27837eb1ca1Smrg  # there is one (and only one) here.
27937eb1ca1Smrg  func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
28037eb1ca1Smrg        -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"`
28137eb1ca1Smrg  while :; do
28237eb1ca1Smrg    # Processed it all yet?
28337eb1ca1Smrg    if test "$func_normal_abspath_tpath" = / ; then
28437eb1ca1Smrg      # If we ascended to the root using ".." the result may be empty now.
28537eb1ca1Smrg      if test -z "$func_normal_abspath_result" ; then
28637eb1ca1Smrg        func_normal_abspath_result=/
28737eb1ca1Smrg      fi
28837eb1ca1Smrg      break
28937eb1ca1Smrg    fi
29037eb1ca1Smrg    func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
29137eb1ca1Smrg        -e "$pathcar"`
29237eb1ca1Smrg    func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
29337eb1ca1Smrg        -e "$pathcdr"`
29437eb1ca1Smrg    # Figure out what to do with it
29537eb1ca1Smrg    case $func_normal_abspath_tcomponent in
29637eb1ca1Smrg      "")
29737eb1ca1Smrg        # Trailing empty path component, ignore it.
29837eb1ca1Smrg      ;;
29937eb1ca1Smrg      ..)
30037eb1ca1Smrg        # Parent dir; strip last assembled component from result.
30137eb1ca1Smrg        func_dirname "$func_normal_abspath_result"
30237eb1ca1Smrg        func_normal_abspath_result=$func_dirname_result
30337eb1ca1Smrg      ;;
30437eb1ca1Smrg      *)
30537eb1ca1Smrg        # Actual path component, append it.
30637eb1ca1Smrg        func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent
30737eb1ca1Smrg      ;;
30837eb1ca1Smrg    esac
30937eb1ca1Smrg  done
31037eb1ca1Smrg  # Restore leading double-slash if one was found on entry.
31137eb1ca1Smrg  func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
31237eb1ca1Smrg}
31337eb1ca1Smrg
31437eb1ca1Smrg# func_relative_path SRCDIR DSTDIR
31537eb1ca1Smrg# generates a relative path from SRCDIR to DSTDIR, with a trailing
31637eb1ca1Smrg# slash if non-empty, suitable for immediately appending a filename
31737eb1ca1Smrg# without needing to append a separator.
31837eb1ca1Smrg#             value returned in "$func_relative_path_result"
31937eb1ca1Smrgfunc_relative_path ()
32037eb1ca1Smrg{
32137eb1ca1Smrg  func_relative_path_result=
32237eb1ca1Smrg  func_normal_abspath "$1"
32337eb1ca1Smrg  func_relative_path_tlibdir=$func_normal_abspath_result
32437eb1ca1Smrg  func_normal_abspath "$2"
32537eb1ca1Smrg  func_relative_path_tbindir=$func_normal_abspath_result
32637eb1ca1Smrg
32737eb1ca1Smrg  # Ascend the tree starting from libdir
32837eb1ca1Smrg  while :; do
32937eb1ca1Smrg    # check if we have found a prefix of bindir
33037eb1ca1Smrg    case $func_relative_path_tbindir in
33137eb1ca1Smrg      $func_relative_path_tlibdir)
33237eb1ca1Smrg        # found an exact match
33337eb1ca1Smrg        func_relative_path_tcancelled=
33437eb1ca1Smrg        break
33537eb1ca1Smrg        ;;
33637eb1ca1Smrg      $func_relative_path_tlibdir*)
33737eb1ca1Smrg        # found a matching prefix
33837eb1ca1Smrg        func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
33937eb1ca1Smrg        func_relative_path_tcancelled=$func_stripname_result
34037eb1ca1Smrg        if test -z "$func_relative_path_result"; then
34137eb1ca1Smrg          func_relative_path_result=.
34237eb1ca1Smrg        fi
34337eb1ca1Smrg        break
34437eb1ca1Smrg        ;;
34537eb1ca1Smrg      *)
34637eb1ca1Smrg        func_dirname $func_relative_path_tlibdir
34737eb1ca1Smrg        func_relative_path_tlibdir=${func_dirname_result}
34837eb1ca1Smrg        if test "x$func_relative_path_tlibdir" = x ; then
34937eb1ca1Smrg          # Have to descend all the way to the root!
35037eb1ca1Smrg          func_relative_path_result=../$func_relative_path_result
35137eb1ca1Smrg          func_relative_path_tcancelled=$func_relative_path_tbindir
35237eb1ca1Smrg          break
35337eb1ca1Smrg        fi
35437eb1ca1Smrg        func_relative_path_result=../$func_relative_path_result
35537eb1ca1Smrg        ;;
35637eb1ca1Smrg    esac
35737eb1ca1Smrg  done
35837eb1ca1Smrg
35937eb1ca1Smrg  # Now calculate path; take care to avoid doubling-up slashes.
36037eb1ca1Smrg  func_stripname '' '/' "$func_relative_path_result"
36137eb1ca1Smrg  func_relative_path_result=$func_stripname_result
36237eb1ca1Smrg  func_stripname '/' '/' "$func_relative_path_tcancelled"
36337eb1ca1Smrg  if test "x$func_stripname_result" != x ; then
36437eb1ca1Smrg    func_relative_path_result=${func_relative_path_result}/${func_stripname_result}
36537eb1ca1Smrg  fi
36637eb1ca1Smrg
36737eb1ca1Smrg  # Normalisation. If bindir is libdir, return empty string,
36837eb1ca1Smrg  # else relative path ending with a slash; either way, target
36937eb1ca1Smrg  # file name can be directly appended.
37037eb1ca1Smrg  if test ! -z "$func_relative_path_result"; then
37137eb1ca1Smrg    func_stripname './' '' "$func_relative_path_result/"
37237eb1ca1Smrg    func_relative_path_result=$func_stripname_result
37337eb1ca1Smrg  fi
37437eb1ca1Smrg}
375c27c18e8Smrg
376c27c18e8Smrg# The name of this program:
377c27c18e8Smrgfunc_dirname_and_basename "$progpath"
378c27c18e8Smrgprogname=$func_basename_result
379c27c18e8Smrg
380c27c18e8Smrg# Make sure we have an absolute path for reexecution:
381c27c18e8Smrgcase $progpath in
382c27c18e8Smrg  [\\/]*|[A-Za-z]:\\*) ;;
383c27c18e8Smrg  *[\\/]*)
384c27c18e8Smrg     progdir=$func_dirname_result
385c27c18e8Smrg     progdir=`cd "$progdir" && pwd`
386c27c18e8Smrg     progpath="$progdir/$progname"
387c27c18e8Smrg     ;;
388c27c18e8Smrg  *)
389c27c18e8Smrg     save_IFS="$IFS"
390c27c18e8Smrg     IFS=:
391c27c18e8Smrg     for progdir in $PATH; do
392c27c18e8Smrg       IFS="$save_IFS"
393c27c18e8Smrg       test -x "$progdir/$progname" && break
394c27c18e8Smrg     done
395c27c18e8Smrg     IFS="$save_IFS"
396c27c18e8Smrg     test -n "$progdir" || progdir=`pwd`
397c27c18e8Smrg     progpath="$progdir/$progname"
398c27c18e8Smrg     ;;
399c27c18e8Smrgesac
400c27c18e8Smrg
401c27c18e8Smrg# Sed substitution that helps us do robust quoting.  It backslashifies
402c27c18e8Smrg# metacharacters that are still active within double-quoted strings.
403c27c18e8SmrgXsed="${SED}"' -e 1s/^X//'
404c27c18e8Smrgsed_quote_subst='s/\([`"$\\]\)/\\\1/g'
405c27c18e8Smrg
406c27c18e8Smrg# Same as above, but do not quote variable references.
407c27c18e8Smrgdouble_quote_subst='s/\(["`\\]\)/\\\1/g'
408c27c18e8Smrg
409b789ec8aSmrg# Sed substitution that turns a string into a regex matching for the
410b789ec8aSmrg# string literally.
411b789ec8aSmrgsed_make_literal_regex='s,[].[^$\\*\/],\\&,g'
412b789ec8aSmrg
413b789ec8aSmrg# Sed substitution that converts a w32 file name or path
414b789ec8aSmrg# which contains forward slashes, into one that contains
415b789ec8aSmrg# (escaped) backslashes.  A very naive implementation.
416b789ec8aSmrglt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
417b789ec8aSmrg
418c27c18e8Smrg# Re-`\' parameter expansions in output of double_quote_subst that were
419c27c18e8Smrg# `\'-ed in input to the same.  If an odd number of `\' preceded a '$'
420c27c18e8Smrg# in input to double_quote_subst, that '$' was protected from expansion.
421c27c18e8Smrg# Since each input `\' is now two `\'s, look for any number of runs of
422c27c18e8Smrg# four `\'s followed by two `\'s and then a '$'.  `\' that '$'.
423c27c18e8Smrgbs='\\'
424c27c18e8Smrgbs2='\\\\'
425c27c18e8Smrgbs4='\\\\\\\\'
426c27c18e8Smrgdollar='\$'
427c27c18e8Smrgsed_double_backslash="\
428c27c18e8Smrg  s/$bs4/&\\
429c27c18e8Smrg/g
430c27c18e8Smrg  s/^$bs2$dollar/$bs&/
431c27c18e8Smrg  s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
432c27c18e8Smrg  s/\n//g"
433c27c18e8Smrg
434c27c18e8Smrg# Standard options:
435c27c18e8Smrgopt_dry_run=false
436c27c18e8Smrgopt_help=false
437c27c18e8Smrgopt_quiet=false
438c27c18e8Smrgopt_verbose=false
439c27c18e8Smrgopt_warning=:
440c27c18e8Smrg
441c27c18e8Smrg# func_echo arg...
442c27c18e8Smrg# Echo program name prefixed message, along with the current mode
443c27c18e8Smrg# name if it has been set yet.
444c27c18e8Smrgfunc_echo ()
445c27c18e8Smrg{
446b789ec8aSmrg    $ECHO "$progname: ${opt_mode+$opt_mode: }$*"
447c27c18e8Smrg}
448c27c18e8Smrg
449c27c18e8Smrg# func_verbose arg...
450c27c18e8Smrg# Echo program name prefixed message in verbose mode only.
451c27c18e8Smrgfunc_verbose ()
452c27c18e8Smrg{
453c27c18e8Smrg    $opt_verbose && func_echo ${1+"$@"}
454c27c18e8Smrg
455c27c18e8Smrg    # A bug in bash halts the script if the last line of a function
456c27c18e8Smrg    # fails when set -e is in force, so we need another command to
457c27c18e8Smrg    # work around that:
458c27c18e8Smrg    :
459c27c18e8Smrg}
460c27c18e8Smrg
46137eb1ca1Smrg# func_echo_all arg...
46237eb1ca1Smrg# Invoke $ECHO with all args, space-separated.
46337eb1ca1Smrgfunc_echo_all ()
46437eb1ca1Smrg{
46537eb1ca1Smrg    $ECHO "$*"
46637eb1ca1Smrg}
46737eb1ca1Smrg
468c27c18e8Smrg# func_error arg...
469c27c18e8Smrg# Echo program name prefixed message to standard error.
470c27c18e8Smrgfunc_error ()
471c27c18e8Smrg{
472b789ec8aSmrg    $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2
473c27c18e8Smrg}
474c27c18e8Smrg
475c27c18e8Smrg# func_warning arg...
476c27c18e8Smrg# Echo program name prefixed warning message to standard error.
477c27c18e8Smrgfunc_warning ()
478c27c18e8Smrg{
479b789ec8aSmrg    $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2
480c27c18e8Smrg
481c27c18e8Smrg    # bash bug again:
482c27c18e8Smrg    :
483c27c18e8Smrg}
484c27c18e8Smrg
485c27c18e8Smrg# func_fatal_error arg...
486c27c18e8Smrg# Echo program name prefixed message to standard error, and exit.
487c27c18e8Smrgfunc_fatal_error ()
488c27c18e8Smrg{
489c27c18e8Smrg    func_error ${1+"$@"}
490c27c18e8Smrg    exit $EXIT_FAILURE
491c27c18e8Smrg}
492c27c18e8Smrg
493c27c18e8Smrg# func_fatal_help arg...
494c27c18e8Smrg# Echo program name prefixed message to standard error, followed by
495c27c18e8Smrg# a help hint, and exit.
496c27c18e8Smrgfunc_fatal_help ()
497c27c18e8Smrg{
498c27c18e8Smrg    func_error ${1+"$@"}
499c27c18e8Smrg    func_fatal_error "$help"
500c27c18e8Smrg}
501c27c18e8Smrghelp="Try \`$progname --help' for more information."  ## default
502c27c18e8Smrg
503c27c18e8Smrg
504c27c18e8Smrg# func_grep expression filename
505c27c18e8Smrg# Check whether EXPRESSION matches any line of FILENAME, without output.
506c27c18e8Smrgfunc_grep ()
507c27c18e8Smrg{
508c27c18e8Smrg    $GREP "$1" "$2" >/dev/null 2>&1
509c27c18e8Smrg}
510c27c18e8Smrg
511c27c18e8Smrg
512c27c18e8Smrg# func_mkdir_p directory-path
513c27c18e8Smrg# Make sure the entire path to DIRECTORY-PATH is available.
514c27c18e8Smrgfunc_mkdir_p ()
515c27c18e8Smrg{
516c27c18e8Smrg    my_directory_path="$1"
517c27c18e8Smrg    my_dir_list=
518c27c18e8Smrg
519c27c18e8Smrg    if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
520c27c18e8Smrg
521c27c18e8Smrg      # Protect directory names starting with `-'
522c27c18e8Smrg      case $my_directory_path in
523c27c18e8Smrg        -*) my_directory_path="./$my_directory_path" ;;
524c27c18e8Smrg      esac
525c27c18e8Smrg
526c27c18e8Smrg      # While some portion of DIR does not yet exist...
527c27c18e8Smrg      while test ! -d "$my_directory_path"; do
528c27c18e8Smrg        # ...make a list in topmost first order.  Use a colon delimited
529c27c18e8Smrg	# list incase some portion of path contains whitespace.
530c27c18e8Smrg        my_dir_list="$my_directory_path:$my_dir_list"
531c27c18e8Smrg
532c27c18e8Smrg        # If the last portion added has no slash in it, the list is done
533c27c18e8Smrg        case $my_directory_path in */*) ;; *) break ;; esac
534c27c18e8Smrg
535c27c18e8Smrg        # ...otherwise throw away the child directory and loop
53637eb1ca1Smrg        my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"`
537c27c18e8Smrg      done
53837eb1ca1Smrg      my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'`
539c27c18e8Smrg
540c27c18e8Smrg      save_mkdir_p_IFS="$IFS"; IFS=':'
541c27c18e8Smrg      for my_dir in $my_dir_list; do
542c27c18e8Smrg	IFS="$save_mkdir_p_IFS"
543c27c18e8Smrg        # mkdir can fail with a `File exist' error if two processes
544c27c18e8Smrg        # try to create one of the directories concurrently.  Don't
545c27c18e8Smrg        # stop in that case!
546c27c18e8Smrg        $MKDIR "$my_dir" 2>/dev/null || :
547c27c18e8Smrg      done
548c27c18e8Smrg      IFS="$save_mkdir_p_IFS"
549c27c18e8Smrg
550c27c18e8Smrg      # Bail out if we (or some other process) failed to create a directory.
551c27c18e8Smrg      test -d "$my_directory_path" || \
552c27c18e8Smrg        func_fatal_error "Failed to create \`$1'"
553c27c18e8Smrg    fi
554c27c18e8Smrg}
555c43cc173Smrg
556c43cc173Smrg
557c43cc173Smrg# func_mktempdir [string]
558c43cc173Smrg# Make a temporary directory that won't clash with other running
559c43cc173Smrg# libtool processes, and avoids race conditions if possible.  If
560c43cc173Smrg# given, STRING is the basename for that directory.
561c43cc173Smrgfunc_mktempdir ()
562c43cc173Smrg{
563c43cc173Smrg    my_template="${TMPDIR-/tmp}/${1-$progname}"
564c43cc173Smrg
565c27c18e8Smrg    if test "$opt_dry_run" = ":"; then
566c43cc173Smrg      # Return a directory name, but don't create it in dry-run mode
567c43cc173Smrg      my_tmpdir="${my_template}-$$"
568c43cc173Smrg    else
569c43cc173Smrg
570c43cc173Smrg      # If mktemp works, use that first and foremost
571c43cc173Smrg      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
572c43cc173Smrg
573c43cc173Smrg      if test ! -d "$my_tmpdir"; then
574c27c18e8Smrg        # Failing that, at least try and use $RANDOM to avoid a race
575c27c18e8Smrg        my_tmpdir="${my_template}-${RANDOM-0}$$"
576c43cc173Smrg
577c27c18e8Smrg        save_mktempdir_umask=`umask`
578c27c18e8Smrg        umask 0077
579c27c18e8Smrg        $MKDIR "$my_tmpdir"
580c27c18e8Smrg        umask $save_mktempdir_umask
581c43cc173Smrg      fi
582c43cc173Smrg
583c43cc173Smrg      # If we're not in dry-run mode, bomb out on failure
584c27c18e8Smrg      test -d "$my_tmpdir" || \
585c27c18e8Smrg        func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
586c43cc173Smrg    fi
587c43cc173Smrg
58837eb1ca1Smrg    $ECHO "$my_tmpdir"
589c43cc173Smrg}
590c43cc173Smrg
591c43cc173Smrg
592c27c18e8Smrg# func_quote_for_eval arg
593c27c18e8Smrg# Aesthetically quote ARG to be evaled later.
594c27c18e8Smrg# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
595c27c18e8Smrg# is double-quoted, suitable for a subsequent eval, whereas
596c27c18e8Smrg# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
597c27c18e8Smrg# which are still active within double quotes backslashified.
598c27c18e8Smrgfunc_quote_for_eval ()
599c43cc173Smrg{
600c27c18e8Smrg    case $1 in
601c27c18e8Smrg      *[\\\`\"\$]*)
60237eb1ca1Smrg	func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;;
603c27c18e8Smrg      *)
604c27c18e8Smrg        func_quote_for_eval_unquoted_result="$1" ;;
605c27c18e8Smrg    esac
606c27c18e8Smrg
607c27c18e8Smrg    case $func_quote_for_eval_unquoted_result in
608c27c18e8Smrg      # Double-quote args containing shell metacharacters to delay
609c27c18e8Smrg      # word splitting, command substitution and and variable
610c27c18e8Smrg      # expansion for a subsequent eval.
611c27c18e8Smrg      # Many Bourne shells cannot handle close brackets correctly
612c27c18e8Smrg      # in scan sets, so we specify it separately.
613c27c18e8Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
614c27c18e8Smrg        func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
615c27c18e8Smrg        ;;
616c27c18e8Smrg      *)
617c27c18e8Smrg        func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
618c43cc173Smrg    esac
619c43cc173Smrg}
620c43cc173Smrg
621c43cc173Smrg
622c27c18e8Smrg# func_quote_for_expand arg
623c27c18e8Smrg# Aesthetically quote ARG to be evaled later; same as above,
624c27c18e8Smrg# but do not quote variable references.
625c27c18e8Smrgfunc_quote_for_expand ()
626c43cc173Smrg{
627c27c18e8Smrg    case $1 in
628c27c18e8Smrg      *[\\\`\"]*)
62937eb1ca1Smrg	my_arg=`$ECHO "$1" | $SED \
630c27c18e8Smrg	    -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
631c43cc173Smrg      *)
632c27c18e8Smrg        my_arg="$1" ;;
633c27c18e8Smrg    esac
634c27c18e8Smrg
635c27c18e8Smrg    case $my_arg in
636c27c18e8Smrg      # Double-quote args containing shell metacharacters to delay
637c27c18e8Smrg      # word splitting and command substitution for a subsequent eval.
638c27c18e8Smrg      # Many Bourne shells cannot handle close brackets correctly
639c27c18e8Smrg      # in scan sets, so we specify it separately.
640c27c18e8Smrg      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
641c27c18e8Smrg        my_arg="\"$my_arg\""
642c27c18e8Smrg        ;;
643c27c18e8Smrg    esac
644c27c18e8Smrg
645c27c18e8Smrg    func_quote_for_expand_result="$my_arg"
646c43cc173Smrg}
647c43cc173Smrg
648c43cc173Smrg
649c27c18e8Smrg# func_show_eval cmd [fail_exp]
650c27c18e8Smrg# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
651c27c18e8Smrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
652c27c18e8Smrg# is given, then evaluate it.
653c27c18e8Smrgfunc_show_eval ()
654c43cc173Smrg{
655c27c18e8Smrg    my_cmd="$1"
656c27c18e8Smrg    my_fail_exp="${2-:}"
657c43cc173Smrg
658c27c18e8Smrg    ${opt_silent-false} || {
659c27c18e8Smrg      func_quote_for_expand "$my_cmd"
660c27c18e8Smrg      eval "func_echo $func_quote_for_expand_result"
661c27c18e8Smrg    }
662c27c18e8Smrg
663c27c18e8Smrg    if ${opt_dry_run-false}; then :; else
664c27c18e8Smrg      eval "$my_cmd"
665c27c18e8Smrg      my_status=$?
666c27c18e8Smrg      if test "$my_status" -eq 0; then :; else
667c27c18e8Smrg	eval "(exit $my_status); $my_fail_exp"
668c27c18e8Smrg      fi
669c43cc173Smrg    fi
670c43cc173Smrg}
671c43cc173Smrg
672c27c18e8Smrg
673c27c18e8Smrg# func_show_eval_locale cmd [fail_exp]
674c27c18e8Smrg# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
675c27c18e8Smrg# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
676c27c18e8Smrg# is given, then evaluate it.  Use the saved locale for evaluation.
677c27c18e8Smrgfunc_show_eval_locale ()
678c43cc173Smrg{
679c27c18e8Smrg    my_cmd="$1"
680c27c18e8Smrg    my_fail_exp="${2-:}"
681c27c18e8Smrg
682c27c18e8Smrg    ${opt_silent-false} || {
683c27c18e8Smrg      func_quote_for_expand "$my_cmd"
684c27c18e8Smrg      eval "func_echo $func_quote_for_expand_result"
685c27c18e8Smrg    }
686c27c18e8Smrg
687c27c18e8Smrg    if ${opt_dry_run-false}; then :; else
688c27c18e8Smrg      eval "$lt_user_locale
689c27c18e8Smrg	    $my_cmd"
690c27c18e8Smrg      my_status=$?
691c27c18e8Smrg      eval "$lt_safe_locale"
692c27c18e8Smrg      if test "$my_status" -eq 0; then :; else
693c27c18e8Smrg	eval "(exit $my_status); $my_fail_exp"
694c27c18e8Smrg      fi
695c43cc173Smrg    fi
696c27c18e8Smrg}
697c43cc173Smrg
698b789ec8aSmrg# func_tr_sh
699b789ec8aSmrg# Turn $1 into a string suitable for a shell variable name.
700b789ec8aSmrg# Result is stored in $func_tr_sh_result.  All characters
701b789ec8aSmrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further,
702b789ec8aSmrg# if $1 begins with a digit, a '_' is prepended as well.
703b789ec8aSmrgfunc_tr_sh ()
704b789ec8aSmrg{
705b789ec8aSmrg  case $1 in
706b789ec8aSmrg  [0-9]* | *[!a-zA-Z0-9_]*)
707b789ec8aSmrg    func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'`
708b789ec8aSmrg    ;;
709b789ec8aSmrg  * )
710b789ec8aSmrg    func_tr_sh_result=$1
711b789ec8aSmrg    ;;
712b789ec8aSmrg  esac
713b789ec8aSmrg}
714b789ec8aSmrg
715c43cc173Smrg
716c27c18e8Smrg# func_version
717c27c18e8Smrg# Echo version message to standard output and exit.
718c27c18e8Smrgfunc_version ()
719c27c18e8Smrg{
720b789ec8aSmrg    $opt_debug
721b789ec8aSmrg
72237eb1ca1Smrg    $SED -n '/(C)/!b go
72337eb1ca1Smrg	:more
72437eb1ca1Smrg	/\./!{
72537eb1ca1Smrg	  N
72637eb1ca1Smrg	  s/\n# / /
72737eb1ca1Smrg	  b more
72837eb1ca1Smrg	}
72937eb1ca1Smrg	:go
73037eb1ca1Smrg	/^# '$PROGRAM' (GNU /,/# warranty; / {
731c27c18e8Smrg        s/^# //
732c27c18e8Smrg	s/^# *$//
733c27c18e8Smrg        s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
734c27c18e8Smrg        p
735c27c18e8Smrg     }' < "$progpath"
736c27c18e8Smrg     exit $?
737c27c18e8Smrg}
738c27c18e8Smrg
739c27c18e8Smrg# func_usage
740c27c18e8Smrg# Echo short help message to standard output and exit.
741c27c18e8Smrgfunc_usage ()
742c27c18e8Smrg{
743b789ec8aSmrg    $opt_debug
744b789ec8aSmrg
74537eb1ca1Smrg    $SED -n '/^# Usage:/,/^#  *.*--help/ {
746c27c18e8Smrg        s/^# //
747c27c18e8Smrg	s/^# *$//
748c27c18e8Smrg	s/\$progname/'$progname'/
749c27c18e8Smrg	p
750c27c18e8Smrg    }' < "$progpath"
75137eb1ca1Smrg    echo
752c27c18e8Smrg    $ECHO "run \`$progname --help | more' for full usage"
753c27c18e8Smrg    exit $?
754c27c18e8Smrg}
755c27c18e8Smrg
75637eb1ca1Smrg# func_help [NOEXIT]
75737eb1ca1Smrg# Echo long help message to standard output and exit,
75837eb1ca1Smrg# unless 'noexit' is passed as argument.
759c27c18e8Smrgfunc_help ()
760c27c18e8Smrg{
761b789ec8aSmrg    $opt_debug
762b789ec8aSmrg
763c27c18e8Smrg    $SED -n '/^# Usage:/,/# Report bugs to/ {
764b789ec8aSmrg	:print
765c27c18e8Smrg        s/^# //
766c27c18e8Smrg	s/^# *$//
767c27c18e8Smrg	s*\$progname*'$progname'*
768c27c18e8Smrg	s*\$host*'"$host"'*
769c27c18e8Smrg	s*\$SHELL*'"$SHELL"'*
770c27c18e8Smrg	s*\$LTCC*'"$LTCC"'*
771c27c18e8Smrg	s*\$LTCFLAGS*'"$LTCFLAGS"'*
772c27c18e8Smrg	s*\$LD*'"$LD"'*
773c27c18e8Smrg	s/\$with_gnu_ld/'"$with_gnu_ld"'/
774c27c18e8Smrg	s/\$automake_version/'"`(automake --version) 2>/dev/null |$SED 1q`"'/
775c27c18e8Smrg	s/\$autoconf_version/'"`(autoconf --version) 2>/dev/null |$SED 1q`"'/
776c27c18e8Smrg	p
777b789ec8aSmrg	d
778b789ec8aSmrg     }
779b789ec8aSmrg     /^# .* home page:/b print
780b789ec8aSmrg     /^# General help using/b print
781b789ec8aSmrg     ' < "$progpath"
78237eb1ca1Smrg    ret=$?
78337eb1ca1Smrg    if test -z "$1"; then
78437eb1ca1Smrg      exit $ret
78537eb1ca1Smrg    fi
786c27c18e8Smrg}
787c27c18e8Smrg
788c27c18e8Smrg# func_missing_arg argname
789c27c18e8Smrg# Echo program name prefixed message to standard error and set global
790c27c18e8Smrg# exit_cmd.
791c27c18e8Smrgfunc_missing_arg ()
792c27c18e8Smrg{
793b789ec8aSmrg    $opt_debug
794b789ec8aSmrg
79537eb1ca1Smrg    func_error "missing argument for $1."
796c27c18e8Smrg    exit_cmd=exit
797c43cc173Smrg}
798c43cc173Smrg
799c43cc173Smrg
800b789ec8aSmrg# func_split_short_opt shortopt
801b789ec8aSmrg# Set func_split_short_opt_name and func_split_short_opt_arg shell
802b789ec8aSmrg# variables after splitting SHORTOPT after the 2nd character.
803b789ec8aSmrgfunc_split_short_opt ()
804b789ec8aSmrg{
805b789ec8aSmrg    my_sed_short_opt='1s/^\(..\).*$/\1/;q'
806b789ec8aSmrg    my_sed_short_rest='1s/^..\(.*\)$/\1/;q'
807b789ec8aSmrg
808b789ec8aSmrg    func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"`
809b789ec8aSmrg    func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"`
810b789ec8aSmrg} # func_split_short_opt may be replaced by extended shell implementation
811b789ec8aSmrg
812b789ec8aSmrg
813b789ec8aSmrg# func_split_long_opt longopt
814b789ec8aSmrg# Set func_split_long_opt_name and func_split_long_opt_arg shell
815b789ec8aSmrg# variables after splitting LONGOPT at the `=' sign.
816b789ec8aSmrgfunc_split_long_opt ()
817b789ec8aSmrg{
818b789ec8aSmrg    my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q'
819b789ec8aSmrg    my_sed_long_arg='1s/^--[^=]*=//'
820b789ec8aSmrg
821b789ec8aSmrg    func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"`
822b789ec8aSmrg    func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"`
823b789ec8aSmrg} # func_split_long_opt may be replaced by extended shell implementation
824b789ec8aSmrg
825b789ec8aSmrgexit_cmd=:
826c43cc173Smrg
827c27c18e8Smrg
828c27c18e8Smrg
829c27c18e8Smrg
830c43cc173Smrg
831c27c18e8Smrgmagic="%%%MAGIC variable%%%"
832c27c18e8Smrgmagic_exe="%%%MAGIC EXE variable%%%"
833c43cc173Smrg
834c27c18e8Smrg# Global variables.
835c27c18e8Smrgnonopt=
836c27c18e8Smrgpreserve_args=
837c27c18e8Smrglo2o="s/\\.lo\$/.${objext}/"
838c27c18e8Smrgo2lo="s/\\.${objext}\$/.lo/"
839c27c18e8Smrgextracted_archives=
840c27c18e8Smrgextracted_serial=0
841c43cc173Smrg
842c27c18e8Smrg# If this variable is set in any of the actions, the command in it
843c27c18e8Smrg# will be execed at the end.  This prevents here-documents from being
844c27c18e8Smrg# left over by shells.
845c27c18e8Smrgexec_cmd=
846c27c18e8Smrg
847b789ec8aSmrg# func_append var value
848b789ec8aSmrg# Append VALUE to the end of shell variable VAR.
849b789ec8aSmrgfunc_append ()
850b789ec8aSmrg{
851b789ec8aSmrg    eval "${1}=\$${1}\${2}"
852b789ec8aSmrg} # func_append may be replaced by extended shell implementation
853b789ec8aSmrg
854b789ec8aSmrg# func_append_quoted var value
855b789ec8aSmrg# Quote VALUE and append to the end of shell variable VAR, separated
856b789ec8aSmrg# by a space.
857b789ec8aSmrgfunc_append_quoted ()
858b789ec8aSmrg{
859b789ec8aSmrg    func_quote_for_eval "${2}"
860b789ec8aSmrg    eval "${1}=\$${1}\\ \$func_quote_for_eval_result"
861b789ec8aSmrg} # func_append_quoted may be replaced by extended shell implementation
862b789ec8aSmrg
863b789ec8aSmrg
864b789ec8aSmrg# func_arith arithmetic-term...
865b789ec8aSmrgfunc_arith ()
866b789ec8aSmrg{
867b789ec8aSmrg    func_arith_result=`expr "${@}"`
868b789ec8aSmrg} # func_arith may be replaced by extended shell implementation
869b789ec8aSmrg
870b789ec8aSmrg
871b789ec8aSmrg# func_len string
872b789ec8aSmrg# STRING may not start with a hyphen.
873b789ec8aSmrgfunc_len ()
874b789ec8aSmrg{
875b789ec8aSmrg    func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len`
876b789ec8aSmrg} # func_len may be replaced by extended shell implementation
877b789ec8aSmrg
878b789ec8aSmrg
879b789ec8aSmrg# func_lo2o object
880b789ec8aSmrgfunc_lo2o ()
881b789ec8aSmrg{
882b789ec8aSmrg    func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"`
883b789ec8aSmrg} # func_lo2o may be replaced by extended shell implementation
884b789ec8aSmrg
885b789ec8aSmrg
886b789ec8aSmrg# func_xform libobj-or-source
887b789ec8aSmrgfunc_xform ()
888b789ec8aSmrg{
889b789ec8aSmrg    func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'`
890b789ec8aSmrg} # func_xform may be replaced by extended shell implementation
891b789ec8aSmrg
892b789ec8aSmrg
893c27c18e8Smrg# func_fatal_configuration arg...
894c27c18e8Smrg# Echo program name prefixed message to standard error, followed by
895c27c18e8Smrg# a configuration failure hint, and exit.
896c27c18e8Smrgfunc_fatal_configuration ()
897c27c18e8Smrg{
898c27c18e8Smrg    func_error ${1+"$@"}
899c27c18e8Smrg    func_error "See the $PACKAGE documentation for more information."
900c27c18e8Smrg    func_fatal_error "Fatal configuration error."
901c27c18e8Smrg}
902c43cc173Smrg
90321e67964Smrg
904c27c18e8Smrg# func_config
905c27c18e8Smrg# Display the configuration for all the tags in this script.
906c27c18e8Smrgfunc_config ()
907c27c18e8Smrg{
908c27c18e8Smrg    re_begincf='^# ### BEGIN LIBTOOL'
909c27c18e8Smrg    re_endcf='^# ### END LIBTOOL'
910c27c18e8Smrg
911c27c18e8Smrg    # Default configuration.
912c27c18e8Smrg    $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
913c43cc173Smrg
914c43cc173Smrg    # Now print the configurations for the tags.
915c43cc173Smrg    for tagname in $taglist; do
916c27c18e8Smrg      $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
917c43cc173Smrg    done
918c43cc173Smrg
919c27c18e8Smrg    exit $?
920c27c18e8Smrg}
921c43cc173Smrg
922c27c18e8Smrg# func_features
923c27c18e8Smrg# Display the features supported by this script.
924c27c18e8Smrgfunc_features ()
925c27c18e8Smrg{
92637eb1ca1Smrg    echo "host: $host"
927c43cc173Smrg    if test "$build_libtool_libs" = yes; then
92837eb1ca1Smrg      echo "enable shared libraries"
929c43cc173Smrg    else
93037eb1ca1Smrg      echo "disable shared libraries"
931c43cc173Smrg    fi
932c43cc173Smrg    if test "$build_old_libs" = yes; then
93337eb1ca1Smrg      echo "enable static libraries"
934c43cc173Smrg    else
93537eb1ca1Smrg      echo "disable static libraries"
936c43cc173Smrg    fi
937c27c18e8Smrg
938c43cc173Smrg    exit $?
939c27c18e8Smrg}
940c43cc173Smrg
941c27c18e8Smrg# func_enable_tag tagname
942c27c18e8Smrg# Verify that TAGNAME is valid, and either flag an error and exit, or
943c27c18e8Smrg# enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
944c27c18e8Smrg# variable here.
945c27c18e8Smrgfunc_enable_tag ()
946c27c18e8Smrg{
947c27c18e8Smrg  # Global variable:
948c27c18e8Smrg  tagname="$1"
949c43cc173Smrg
950c27c18e8Smrg  re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
951c27c18e8Smrg  re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
952c27c18e8Smrg  sed_extractcf="/$re_begincf/,/$re_endcf/p"
953c43cc173Smrg
954c27c18e8Smrg  # Validate tagname.
955c27c18e8Smrg  case $tagname in
956c27c18e8Smrg    *[!-_A-Za-z0-9,/]*)
957c27c18e8Smrg      func_fatal_error "invalid tag name: $tagname"
958c27c18e8Smrg      ;;
959c27c18e8Smrg  esac
960c43cc173Smrg
961c27c18e8Smrg  # Don't test for the "default" C tag, as we know it's
962c27c18e8Smrg  # there but not specially marked.
963c27c18e8Smrg  case $tagname in
964c27c18e8Smrg    CC) ;;
965c27c18e8Smrg    *)
966c27c18e8Smrg      if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
967c27c18e8Smrg	taglist="$taglist $tagname"
968c27c18e8Smrg
969c27c18e8Smrg	# Evaluate the configuration.  Be careful to quote the path
970c27c18e8Smrg	# and the sed script, to avoid splitting on whitespace, but
971c27c18e8Smrg	# also don't use non-portable quotes within backquotes within
972c27c18e8Smrg	# quotes we have to do it in 2 steps:
973c27c18e8Smrg	extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
974c27c18e8Smrg	eval "$extractedcf"
975c27c18e8Smrg      else
976c27c18e8Smrg	func_error "ignoring unknown tag $tagname"
977c27c18e8Smrg      fi
978c27c18e8Smrg      ;;
979c27c18e8Smrg  esac
980c27c18e8Smrg}
981c27c18e8Smrg
982b789ec8aSmrg# func_check_version_match
983b789ec8aSmrg# Ensure that we are using m4 macros, and libtool script from the same
984b789ec8aSmrg# release of libtool.
985b789ec8aSmrgfunc_check_version_match ()
986c27c18e8Smrg{
987b789ec8aSmrg  if test "$package_revision" != "$macro_revision"; then
988b789ec8aSmrg    if test "$VERSION" != "$macro_version"; then
989b789ec8aSmrg      if test -z "$macro_version"; then
990b789ec8aSmrg        cat >&2 <<_LT_EOF
991b789ec8aSmrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
992b789ec8aSmrg$progname: definition of this LT_INIT comes from an older release.
993b789ec8aSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
994b789ec8aSmrg$progname: and run autoconf again.
995b789ec8aSmrg_LT_EOF
996b789ec8aSmrg      else
997b789ec8aSmrg        cat >&2 <<_LT_EOF
998b789ec8aSmrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
999b789ec8aSmrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
1000b789ec8aSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
1001b789ec8aSmrg$progname: and run autoconf again.
1002b789ec8aSmrg_LT_EOF
1003b789ec8aSmrg      fi
1004b789ec8aSmrg    else
1005b789ec8aSmrg      cat >&2 <<_LT_EOF
1006b789ec8aSmrg$progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
1007b789ec8aSmrg$progname: but the definition of this LT_INIT comes from revision $macro_revision.
1008b789ec8aSmrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision
1009b789ec8aSmrg$progname: of $PACKAGE $VERSION and run autoconf again.
1010b789ec8aSmrg_LT_EOF
1011b789ec8aSmrg    fi
1012c43cc173Smrg
1013b789ec8aSmrg    exit $EXIT_MISMATCH
1014b789ec8aSmrg  fi
1015b789ec8aSmrg}
1016b789ec8aSmrg
1017b789ec8aSmrg
1018b789ec8aSmrg# Shorthand for --mode=foo, only valid as the first argument
1019b789ec8aSmrgcase $1 in
1020b789ec8aSmrgclean|clea|cle|cl)
1021b789ec8aSmrg  shift; set dummy --mode clean ${1+"$@"}; shift
1022b789ec8aSmrg  ;;
1023b789ec8aSmrgcompile|compil|compi|comp|com|co|c)
1024b789ec8aSmrg  shift; set dummy --mode compile ${1+"$@"}; shift
1025b789ec8aSmrg  ;;
1026b789ec8aSmrgexecute|execut|execu|exec|exe|ex|e)
1027b789ec8aSmrg  shift; set dummy --mode execute ${1+"$@"}; shift
1028b789ec8aSmrg  ;;
1029b789ec8aSmrgfinish|finis|fini|fin|fi|f)
1030b789ec8aSmrg  shift; set dummy --mode finish ${1+"$@"}; shift
1031b789ec8aSmrg  ;;
1032b789ec8aSmrginstall|instal|insta|inst|ins|in|i)
1033b789ec8aSmrg  shift; set dummy --mode install ${1+"$@"}; shift
1034b789ec8aSmrg  ;;
1035b789ec8aSmrglink|lin|li|l)
1036b789ec8aSmrg  shift; set dummy --mode link ${1+"$@"}; shift
1037b789ec8aSmrg  ;;
1038b789ec8aSmrguninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
1039b789ec8aSmrg  shift; set dummy --mode uninstall ${1+"$@"}; shift
1040b789ec8aSmrg  ;;
1041b789ec8aSmrgesac
1042c43cc173Smrg
1043b789ec8aSmrg
1044b789ec8aSmrg
1045b789ec8aSmrg# Option defaults:
1046b789ec8aSmrgopt_debug=:
1047b789ec8aSmrgopt_dry_run=false
1048b789ec8aSmrgopt_config=false
1049b789ec8aSmrgopt_preserve_dup_deps=false
1050b789ec8aSmrgopt_features=false
1051b789ec8aSmrgopt_finish=false
1052b789ec8aSmrgopt_help=false
1053b789ec8aSmrgopt_help_all=false
1054b789ec8aSmrgopt_silent=:
1055b789ec8aSmrgopt_verbose=:
1056b789ec8aSmrgopt_silent=false
1057b789ec8aSmrgopt_verbose=false
1058b789ec8aSmrg
1059b789ec8aSmrg
1060b789ec8aSmrg# Parse options once, thoroughly.  This comes as soon as possible in the
1061b789ec8aSmrg# script to make things like `--version' happen as quickly as we can.
1062b789ec8aSmrg{
1063b789ec8aSmrg  # this just eases exit handling
1064b789ec8aSmrg  while test $# -gt 0; do
1065c27c18e8Smrg    opt="$1"
1066c27c18e8Smrg    shift
1067c27c18e8Smrg    case $opt in
1068b789ec8aSmrg      --debug|-x)	opt_debug='set -x'
1069c27c18e8Smrg			func_echo "enabling shell trace mode"
1070c27c18e8Smrg			$opt_debug
1071c27c18e8Smrg			;;
1072b789ec8aSmrg      --dry-run|--dryrun|-n)
1073b789ec8aSmrg			opt_dry_run=:
1074c27c18e8Smrg			;;
1075b789ec8aSmrg      --config)
1076b789ec8aSmrg			opt_config=:
1077b789ec8aSmrgfunc_config
1078b789ec8aSmrg			;;
1079b789ec8aSmrg      --dlopen|-dlopen)
1080b789ec8aSmrg			optarg="$1"
1081b789ec8aSmrg			opt_dlopen="${opt_dlopen+$opt_dlopen
1082b789ec8aSmrg}$optarg"
1083c27c18e8Smrg			shift
1084c27c18e8Smrg			;;
1085c27c18e8Smrg      --preserve-dup-deps)
1086b789ec8aSmrg			opt_preserve_dup_deps=:
108737eb1ca1Smrg			;;
1088b789ec8aSmrg      --features)
1089b789ec8aSmrg			opt_features=:
1090b789ec8aSmrgfunc_features
1091c27c18e8Smrg			;;
1092b789ec8aSmrg      --finish)
1093b789ec8aSmrg			opt_finish=:
1094b789ec8aSmrgset dummy --mode finish ${1+"$@"}; shift
1095b789ec8aSmrg			;;
1096b789ec8aSmrg      --help)
1097b789ec8aSmrg			opt_help=:
1098b789ec8aSmrg			;;
1099b789ec8aSmrg      --help-all)
1100b789ec8aSmrg			opt_help_all=:
1101b789ec8aSmrgopt_help=': help-all'
1102b789ec8aSmrg			;;
1103b789ec8aSmrg      --mode)
1104b789ec8aSmrg			test $# = 0 && func_missing_arg $opt && break
1105b789ec8aSmrg			optarg="$1"
1106b789ec8aSmrg			opt_mode="$optarg"
1107b789ec8aSmrgcase $optarg in
1108b789ec8aSmrg  # Valid mode arguments:
1109b789ec8aSmrg  clean|compile|execute|finish|install|link|relink|uninstall) ;;
1110b789ec8aSmrg
1111b789ec8aSmrg  # Catch anything else as an error
1112b789ec8aSmrg  *) func_error "invalid argument for $opt"
1113b789ec8aSmrg     exit_cmd=exit
1114b789ec8aSmrg     break
1115b789ec8aSmrg     ;;
1116b789ec8aSmrgesac
1117b789ec8aSmrg			shift
1118b789ec8aSmrg			;;
1119b789ec8aSmrg      --no-silent|--no-quiet)
1120c27c18e8Smrg			opt_silent=false
1121b789ec8aSmrgfunc_append preserve_args " $opt"
112237eb1ca1Smrg			;;
1123b789ec8aSmrg      --no-verbose)
112437eb1ca1Smrg			opt_verbose=false
1125b789ec8aSmrgfunc_append preserve_args " $opt"
1126c27c18e8Smrg			;;
1127b789ec8aSmrg      --silent|--quiet)
1128b789ec8aSmrg			opt_silent=:
1129b789ec8aSmrgfunc_append preserve_args " $opt"
1130b789ec8aSmrg        opt_verbose=false
1131b789ec8aSmrg			;;
1132b789ec8aSmrg      --verbose|-v)
1133b789ec8aSmrg			opt_verbose=:
1134b789ec8aSmrgfunc_append preserve_args " $opt"
1135b789ec8aSmrgopt_silent=false
1136b789ec8aSmrg			;;
1137b789ec8aSmrg      --tag)
1138b789ec8aSmrg			test $# = 0 && func_missing_arg $opt && break
1139b789ec8aSmrg			optarg="$1"
1140b789ec8aSmrg			opt_tag="$optarg"
1141b789ec8aSmrgfunc_append preserve_args " $opt $optarg"
1142b789ec8aSmrgfunc_enable_tag "$optarg"
1143c27c18e8Smrg			shift
1144c27c18e8Smrg			;;
1145c27c18e8Smrg
1146b789ec8aSmrg      -\?|-h)		func_usage				;;
1147b789ec8aSmrg      --help)		func_help				;;
1148b789ec8aSmrg      --version)	func_version				;;
1149b789ec8aSmrg
1150c27c18e8Smrg      # Separate optargs to long options:
1151b789ec8aSmrg      --*=*)
1152b789ec8aSmrg			func_split_long_opt "$opt"
1153b789ec8aSmrg			set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"}
1154c27c18e8Smrg			shift
1155c27c18e8Smrg			;;
1156c27c18e8Smrg
1157b789ec8aSmrg      # Separate non-argument short options:
1158b789ec8aSmrg      -\?*|-h*|-n*|-v*)
1159b789ec8aSmrg			func_split_short_opt "$opt"
1160b789ec8aSmrg			set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"}
1161b789ec8aSmrg			shift
1162c27c18e8Smrg			;;
1163b789ec8aSmrg
1164b789ec8aSmrg      --)		break					;;
1165b789ec8aSmrg      -*)		func_fatal_help "unrecognized option \`$opt'" ;;
1166b789ec8aSmrg      *)		set dummy "$opt" ${1+"$@"};	shift; break  ;;
1167c27c18e8Smrg    esac
1168c27c18e8Smrg  done
1169c27c18e8Smrg
1170b789ec8aSmrg  # Validate options:
1171b789ec8aSmrg
1172b789ec8aSmrg  # save first non-option argument
1173b789ec8aSmrg  if test "$#" -gt 0; then
1174b789ec8aSmrg    nonopt="$opt"
1175b789ec8aSmrg    shift
1176b789ec8aSmrg  fi
1177b789ec8aSmrg
1178b789ec8aSmrg  # preserve --debug
1179b789ec8aSmrg  test "$opt_debug" = : || func_append preserve_args " --debug"
1180c27c18e8Smrg
1181c27c18e8Smrg  case $host in
1182c27c18e8Smrg    *cygwin* | *mingw* | *pw32* | *cegcc*)
1183c27c18e8Smrg      # don't eliminate duplications in $postdeps and $predeps
1184c27c18e8Smrg      opt_duplicate_compiler_generated_deps=:
1185c43cc173Smrg      ;;
1186c43cc173Smrg    *)
1187b789ec8aSmrg      opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
1188c27c18e8Smrg      ;;
1189c27c18e8Smrg  esac
1190c43cc173Smrg
1191b789ec8aSmrg  $opt_help || {
1192b789ec8aSmrg    # Sanity checks first:
1193b789ec8aSmrg    func_check_version_match
1194c27c18e8Smrg
1195b789ec8aSmrg    if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
1196b789ec8aSmrg      func_fatal_configuration "not configured to build any kind of library"
1197c27c18e8Smrg    fi
1198c27c18e8Smrg
1199b789ec8aSmrg    # Darwin sucks
1200b789ec8aSmrg    eval std_shrext=\"$shrext_cmds\"
1201c27c18e8Smrg
1202b789ec8aSmrg    # Only execute mode is allowed to have -dlopen flags.
1203b789ec8aSmrg    if test -n "$opt_dlopen" && test "$opt_mode" != execute; then
1204b789ec8aSmrg      func_error "unrecognized option \`-dlopen'"
1205b789ec8aSmrg      $ECHO "$help" 1>&2
1206b789ec8aSmrg      exit $EXIT_FAILURE
1207b789ec8aSmrg    fi
1208c27c18e8Smrg
1209b789ec8aSmrg    # Change the help message to a mode-specific one.
1210b789ec8aSmrg    generic_help="$help"
1211b789ec8aSmrg    help="Try \`$progname --help --mode=$opt_mode' for more information."
1212b789ec8aSmrg  }
1213c27c18e8Smrg
1214c27c18e8Smrg
1215b789ec8aSmrg  # Bail if the options were screwed
1216b789ec8aSmrg  $exit_cmd $EXIT_FAILURE
1217b789ec8aSmrg}
1218c27c18e8Smrg
1219c27c18e8Smrg
1220c43cc173Smrg
1221c43cc173Smrg
1222b789ec8aSmrg## ----------- ##
1223b789ec8aSmrg##    Main.    ##
1224b789ec8aSmrg## ----------- ##
1225c43cc173Smrg
1226c27c18e8Smrg# func_lalib_p file
1227c27c18e8Smrg# True iff FILE is a libtool `.la' library or `.lo' object file.
1228c27c18e8Smrg# This function is only a basic sanity check; it will hardly flush out
1229c27c18e8Smrg# determined imposters.
1230c27c18e8Smrgfunc_lalib_p ()
1231c27c18e8Smrg{
1232c27c18e8Smrg    test -f "$1" &&
1233c27c18e8Smrg      $SED -e 4q "$1" 2>/dev/null \
1234c27c18e8Smrg        | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
1235c27c18e8Smrg}
1236c43cc173Smrg
1237c27c18e8Smrg# func_lalib_unsafe_p file
1238c27c18e8Smrg# True iff FILE is a libtool `.la' library or `.lo' object file.
1239c27c18e8Smrg# This function implements the same check as func_lalib_p without
1240c27c18e8Smrg# resorting to external programs.  To this end, it redirects stdin and
1241c27c18e8Smrg# closes it afterwards, without saving the original file descriptor.
1242c27c18e8Smrg# As a safety measure, use it only where a negative result would be
1243c27c18e8Smrg# fatal anyway.  Works if `file' does not exist.
1244c27c18e8Smrgfunc_lalib_unsafe_p ()
1245c27c18e8Smrg{
1246c27c18e8Smrg    lalib_p=no
1247c27c18e8Smrg    if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
1248c27c18e8Smrg	for lalib_p_l in 1 2 3 4
1249c27c18e8Smrg	do
1250c27c18e8Smrg	    read lalib_p_line
1251c27c18e8Smrg	    case "$lalib_p_line" in
1252c27c18e8Smrg		\#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
1253c27c18e8Smrg	    esac
1254c27c18e8Smrg	done
1255c27c18e8Smrg	exec 0<&5 5<&-
1256c27c18e8Smrg    fi
1257c27c18e8Smrg    test "$lalib_p" = yes
1258c27c18e8Smrg}
1259c43cc173Smrg
1260c27c18e8Smrg# func_ltwrapper_script_p file
1261c27c18e8Smrg# True iff FILE is a libtool wrapper script
1262c27c18e8Smrg# This function is only a basic sanity check; it will hardly flush out
1263c27c18e8Smrg# determined imposters.
1264c27c18e8Smrgfunc_ltwrapper_script_p ()
1265c27c18e8Smrg{
1266c27c18e8Smrg    func_lalib_p "$1"
1267c27c18e8Smrg}
1268c43cc173Smrg
1269c27c18e8Smrg# func_ltwrapper_executable_p file
1270c27c18e8Smrg# True iff FILE is a libtool wrapper executable
1271c27c18e8Smrg# This function is only a basic sanity check; it will hardly flush out
1272c27c18e8Smrg# determined imposters.
1273c27c18e8Smrgfunc_ltwrapper_executable_p ()
1274c27c18e8Smrg{
1275c27c18e8Smrg    func_ltwrapper_exec_suffix=
1276c27c18e8Smrg    case $1 in
1277c27c18e8Smrg    *.exe) ;;
1278c27c18e8Smrg    *) func_ltwrapper_exec_suffix=.exe ;;
1279c27c18e8Smrg    esac
1280c27c18e8Smrg    $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
1281c27c18e8Smrg}
1282c43cc173Smrg
1283c27c18e8Smrg# func_ltwrapper_scriptname file
1284c27c18e8Smrg# Assumes file is an ltwrapper_executable
1285c27c18e8Smrg# uses $file to determine the appropriate filename for a
1286c27c18e8Smrg# temporary ltwrapper_script.
1287c27c18e8Smrgfunc_ltwrapper_scriptname ()
1288c27c18e8Smrg{
1289b789ec8aSmrg    func_dirname_and_basename "$1" "" "."
1290b789ec8aSmrg    func_stripname '' '.exe' "$func_basename_result"
1291b789ec8aSmrg    func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper"
1292c27c18e8Smrg}
1293c27c18e8Smrg
1294c27c18e8Smrg# func_ltwrapper_p file
1295c27c18e8Smrg# True iff FILE is a libtool wrapper script or wrapper executable
1296c27c18e8Smrg# This function is only a basic sanity check; it will hardly flush out
1297c27c18e8Smrg# determined imposters.
1298c27c18e8Smrgfunc_ltwrapper_p ()
1299c27c18e8Smrg{
1300c27c18e8Smrg    func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
1301c27c18e8Smrg}
1302c27c18e8Smrg
1303c27c18e8Smrg
1304c27c18e8Smrg# func_execute_cmds commands fail_cmd
1305c27c18e8Smrg# Execute tilde-delimited COMMANDS.
1306c27c18e8Smrg# If FAIL_CMD is given, eval that upon failure.
1307c27c18e8Smrg# FAIL_CMD may read-access the current command in variable CMD!
1308c27c18e8Smrgfunc_execute_cmds ()
1309c27c18e8Smrg{
1310c27c18e8Smrg    $opt_debug
1311c27c18e8Smrg    save_ifs=$IFS; IFS='~'
1312c27c18e8Smrg    for cmd in $1; do
1313c27c18e8Smrg      IFS=$save_ifs
1314c27c18e8Smrg      eval cmd=\"$cmd\"
1315c27c18e8Smrg      func_show_eval "$cmd" "${2-:}"
1316c27c18e8Smrg    done
1317c27c18e8Smrg    IFS=$save_ifs
1318c27c18e8Smrg}
1319c27c18e8Smrg
1320c27c18e8Smrg
1321c27c18e8Smrg# func_source file
1322c27c18e8Smrg# Source FILE, adding directory component if necessary.
1323c27c18e8Smrg# Note that it is not necessary on cygwin/mingw to append a dot to
1324c27c18e8Smrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe
1325c27c18e8Smrg# behavior happens only for exec(3), not for open(2)!  Also, sourcing
1326c27c18e8Smrg# `FILE.' does not work on cygwin managed mounts.
1327c27c18e8Smrgfunc_source ()
1328c27c18e8Smrg{
1329c27c18e8Smrg    $opt_debug
1330c27c18e8Smrg    case $1 in
1331c27c18e8Smrg    */* | *\\*)	. "$1" ;;
1332c27c18e8Smrg    *)		. "./$1" ;;
1333c27c18e8Smrg    esac
1334c27c18e8Smrg}
1335c27c18e8Smrg
1336c27c18e8Smrg
1337b789ec8aSmrg# func_resolve_sysroot PATH
1338b789ec8aSmrg# Replace a leading = in PATH with a sysroot.  Store the result into
1339b789ec8aSmrg# func_resolve_sysroot_result
1340b789ec8aSmrgfunc_resolve_sysroot ()
1341b789ec8aSmrg{
1342b789ec8aSmrg  func_resolve_sysroot_result=$1
1343b789ec8aSmrg  case $func_resolve_sysroot_result in
1344b789ec8aSmrg  =*)
1345b789ec8aSmrg    func_stripname '=' '' "$func_resolve_sysroot_result"
1346b789ec8aSmrg    func_resolve_sysroot_result=$lt_sysroot$func_stripname_result
1347b789ec8aSmrg    ;;
1348b789ec8aSmrg  esac
1349b789ec8aSmrg}
1350b789ec8aSmrg
1351b789ec8aSmrg# func_replace_sysroot PATH
1352b789ec8aSmrg# If PATH begins with the sysroot, replace it with = and
1353b789ec8aSmrg# store the result into func_replace_sysroot_result.
1354b789ec8aSmrgfunc_replace_sysroot ()
1355b789ec8aSmrg{
1356b789ec8aSmrg  case "$lt_sysroot:$1" in
1357b789ec8aSmrg  ?*:"$lt_sysroot"*)
1358b789ec8aSmrg    func_stripname "$lt_sysroot" '' "$1"
1359b789ec8aSmrg    func_replace_sysroot_result="=$func_stripname_result"
1360b789ec8aSmrg    ;;
1361b789ec8aSmrg  *)
1362b789ec8aSmrg    # Including no sysroot.
1363b789ec8aSmrg    func_replace_sysroot_result=$1
1364b789ec8aSmrg    ;;
1365b789ec8aSmrg  esac
1366b789ec8aSmrg}
1367b789ec8aSmrg
1368c27c18e8Smrg# func_infer_tag arg
1369c27c18e8Smrg# Infer tagged configuration to use if any are available and
1370c27c18e8Smrg# if one wasn't chosen via the "--tag" command line option.
1371c27c18e8Smrg# Only attempt this if the compiler in the base compile
1372c27c18e8Smrg# command doesn't match the default compiler.
1373c27c18e8Smrg# arg is usually of the form 'gcc ...'
1374c27c18e8Smrgfunc_infer_tag ()
1375c27c18e8Smrg{
1376c27c18e8Smrg    $opt_debug
1377c27c18e8Smrg    if test -n "$available_tags" && test -z "$tagname"; then
1378c27c18e8Smrg      CC_quoted=
1379c27c18e8Smrg      for arg in $CC; do
1380b789ec8aSmrg	func_append_quoted CC_quoted "$arg"
1381c27c18e8Smrg      done
138237eb1ca1Smrg      CC_expanded=`func_echo_all $CC`
138337eb1ca1Smrg      CC_quoted_expanded=`func_echo_all $CC_quoted`
1384c27c18e8Smrg      case $@ in
1385c27c18e8Smrg      # Blanks in the command may have been stripped by the calling shell,
1386c27c18e8Smrg      # but not from the CC environment variable when configure was run.
138737eb1ca1Smrg      " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
138837eb1ca1Smrg      " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
1389c27c18e8Smrg      # Blanks at the start of $base_compile will cause this to fail
1390c27c18e8Smrg      # if we don't check for them as well.
1391c27c18e8Smrg      *)
1392c27c18e8Smrg	for z in $available_tags; do
1393c27c18e8Smrg	  if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
1394c27c18e8Smrg	    # Evaluate the configuration.
1395c27c18e8Smrg	    eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
1396c27c18e8Smrg	    CC_quoted=
1397c27c18e8Smrg	    for arg in $CC; do
1398c27c18e8Smrg	      # Double-quote args containing other shell metacharacters.
1399b789ec8aSmrg	      func_append_quoted CC_quoted "$arg"
1400c27c18e8Smrg	    done
140137eb1ca1Smrg	    CC_expanded=`func_echo_all $CC`
140237eb1ca1Smrg	    CC_quoted_expanded=`func_echo_all $CC_quoted`
1403c27c18e8Smrg	    case "$@ " in
140437eb1ca1Smrg	    " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
140537eb1ca1Smrg	    " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
1406c27c18e8Smrg	      # The compiler in the base compile command matches
1407c27c18e8Smrg	      # the one in the tagged configuration.
1408c27c18e8Smrg	      # Assume this is the tagged configuration we want.
1409c27c18e8Smrg	      tagname=$z
1410c27c18e8Smrg	      break
1411c27c18e8Smrg	      ;;
1412c27c18e8Smrg	    esac
1413c27c18e8Smrg	  fi
1414c27c18e8Smrg	done
1415c27c18e8Smrg	# If $tagname still isn't set, then no tagged configuration
1416c27c18e8Smrg	# was found and let the user know that the "--tag" command
1417c27c18e8Smrg	# line option must be used.
1418c27c18e8Smrg	if test -z "$tagname"; then
1419c27c18e8Smrg	  func_echo "unable to infer tagged configuration"
1420c27c18e8Smrg	  func_fatal_error "specify a tag with \`--tag'"
1421c27c18e8Smrg#	else
1422c27c18e8Smrg#	  func_verbose "using $tagname tagged configuration"
1423c27c18e8Smrg	fi
1424c27c18e8Smrg	;;
1425c27c18e8Smrg      esac
1426c27c18e8Smrg    fi
1427c27c18e8Smrg}
1428c27c18e8Smrg
1429c27c18e8Smrg
1430c27c18e8Smrg
1431b789ec8aSmrg# func_write_libtool_object output_name pic_name nonpic_name
1432b789ec8aSmrg# Create a libtool object file (analogous to a ".la" file),
1433b789ec8aSmrg# but don't create it if we're doing a dry run.
1434b789ec8aSmrgfunc_write_libtool_object ()
1435b789ec8aSmrg{
1436b789ec8aSmrg    write_libobj=${1}
1437b789ec8aSmrg    if test "$build_libtool_libs" = yes; then
1438b789ec8aSmrg      write_lobj=\'${2}\'
1439b789ec8aSmrg    else
1440b789ec8aSmrg      write_lobj=none
1441b789ec8aSmrg    fi
1442b789ec8aSmrg
1443b789ec8aSmrg    if test "$build_old_libs" = yes; then
1444b789ec8aSmrg      write_oldobj=\'${3}\'
1445b789ec8aSmrg    else
1446b789ec8aSmrg      write_oldobj=none
1447b789ec8aSmrg    fi
1448b789ec8aSmrg
1449b789ec8aSmrg    $opt_dry_run || {
1450b789ec8aSmrg      cat >${write_libobj}T <<EOF
1451b789ec8aSmrg# $write_libobj - a libtool object file
1452b789ec8aSmrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
1453b789ec8aSmrg#
1454b789ec8aSmrg# Please DO NOT delete this file!
1455b789ec8aSmrg# It is necessary for linking the library.
1456b789ec8aSmrg
1457b789ec8aSmrg# Name of the PIC object.
1458b789ec8aSmrgpic_object=$write_lobj
1459b789ec8aSmrg
1460b789ec8aSmrg# Name of the non-PIC object
1461b789ec8aSmrgnon_pic_object=$write_oldobj
1462b789ec8aSmrg
1463b789ec8aSmrgEOF
1464b789ec8aSmrg      $MV "${write_libobj}T" "${write_libobj}"
1465b789ec8aSmrg    }
1466b789ec8aSmrg}
1467b789ec8aSmrg
1468b789ec8aSmrg
1469b789ec8aSmrg##################################################
1470b789ec8aSmrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS #
1471b789ec8aSmrg##################################################
1472b789ec8aSmrg
1473b789ec8aSmrg# func_convert_core_file_wine_to_w32 ARG
1474b789ec8aSmrg# Helper function used by file name conversion functions when $build is *nix,
1475b789ec8aSmrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a
1476b789ec8aSmrg# correctly configured wine environment available, with the winepath program
1477b789ec8aSmrg# in $build's $PATH.
1478b789ec8aSmrg#
1479b789ec8aSmrg# ARG is the $build file name to be converted to w32 format.
1480b789ec8aSmrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will
1481b789ec8aSmrg# be empty on error (or when ARG is empty)
1482b789ec8aSmrgfunc_convert_core_file_wine_to_w32 ()
1483b789ec8aSmrg{
1484b789ec8aSmrg  $opt_debug
1485b789ec8aSmrg  func_convert_core_file_wine_to_w32_result="$1"
1486b789ec8aSmrg  if test -n "$1"; then
1487b789ec8aSmrg    # Unfortunately, winepath does not exit with a non-zero error code, so we
1488b789ec8aSmrg    # are forced to check the contents of stdout. On the other hand, if the
1489b789ec8aSmrg    # command is not found, the shell will set an exit code of 127 and print
1490b789ec8aSmrg    # *an error message* to stdout. So we must check for both error code of
1491b789ec8aSmrg    # zero AND non-empty stdout, which explains the odd construction:
1492b789ec8aSmrg    func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
1493b789ec8aSmrg    if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then
1494b789ec8aSmrg      func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
1495b789ec8aSmrg        $SED -e "$lt_sed_naive_backslashify"`
1496b789ec8aSmrg    else
1497b789ec8aSmrg      func_convert_core_file_wine_to_w32_result=
1498b789ec8aSmrg    fi
1499b789ec8aSmrg  fi
1500b789ec8aSmrg}
1501b789ec8aSmrg# end: func_convert_core_file_wine_to_w32
1502b789ec8aSmrg
1503b789ec8aSmrg
1504b789ec8aSmrg# func_convert_core_path_wine_to_w32 ARG
1505b789ec8aSmrg# Helper function used by path conversion functions when $build is *nix, and
1506b789ec8aSmrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly
1507b789ec8aSmrg# configured wine environment available, with the winepath program in $build's
1508b789ec8aSmrg# $PATH. Assumes ARG has no leading or trailing path separator characters.
1509b789ec8aSmrg#
1510b789ec8aSmrg# ARG is path to be converted from $build format to win32.
1511b789ec8aSmrg# Result is available in $func_convert_core_path_wine_to_w32_result.
1512b789ec8aSmrg# Unconvertible file (directory) names in ARG are skipped; if no directory names
1513b789ec8aSmrg# are convertible, then the result may be empty.
1514b789ec8aSmrgfunc_convert_core_path_wine_to_w32 ()
1515b789ec8aSmrg{
1516b789ec8aSmrg  $opt_debug
1517b789ec8aSmrg  # unfortunately, winepath doesn't convert paths, only file names
1518b789ec8aSmrg  func_convert_core_path_wine_to_w32_result=""
1519b789ec8aSmrg  if test -n "$1"; then
1520b789ec8aSmrg    oldIFS=$IFS
1521b789ec8aSmrg    IFS=:
1522b789ec8aSmrg    for func_convert_core_path_wine_to_w32_f in $1; do
1523b789ec8aSmrg      IFS=$oldIFS
1524b789ec8aSmrg      func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
1525b789ec8aSmrg      if test -n "$func_convert_core_file_wine_to_w32_result" ; then
1526b789ec8aSmrg        if test -z "$func_convert_core_path_wine_to_w32_result"; then
1527b789ec8aSmrg          func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result"
1528b789ec8aSmrg        else
1529b789ec8aSmrg          func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
1530b789ec8aSmrg        fi
1531b789ec8aSmrg      fi
1532b789ec8aSmrg    done
1533b789ec8aSmrg    IFS=$oldIFS
1534b789ec8aSmrg  fi
1535b789ec8aSmrg}
1536b789ec8aSmrg# end: func_convert_core_path_wine_to_w32
1537b789ec8aSmrg
1538b789ec8aSmrg
1539b789ec8aSmrg# func_cygpath ARGS...
1540b789ec8aSmrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when
1541b789ec8aSmrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2)
1542b789ec8aSmrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or
1543b789ec8aSmrg# (2), returns the Cygwin file name or path in func_cygpath_result (input
1544b789ec8aSmrg# file name or path is assumed to be in w32 format, as previously converted
1545b789ec8aSmrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name
1546b789ec8aSmrg# or path in func_cygpath_result (input file name or path is assumed to be in
1547b789ec8aSmrg# Cygwin format). Returns an empty string on error.
1548b789ec8aSmrg#
1549b789ec8aSmrg# ARGS are passed to cygpath, with the last one being the file name or path to
1550b789ec8aSmrg# be converted.
1551b789ec8aSmrg#
1552b789ec8aSmrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH
1553b789ec8aSmrg# environment variable; do not put it in $PATH.
1554b789ec8aSmrgfunc_cygpath ()
1555b789ec8aSmrg{
1556b789ec8aSmrg  $opt_debug
1557b789ec8aSmrg  if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
1558b789ec8aSmrg    func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
1559b789ec8aSmrg    if test "$?" -ne 0; then
1560b789ec8aSmrg      # on failure, ensure result is empty
1561b789ec8aSmrg      func_cygpath_result=
1562b789ec8aSmrg    fi
1563b789ec8aSmrg  else
1564b789ec8aSmrg    func_cygpath_result=
1565b789ec8aSmrg    func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'"
1566b789ec8aSmrg  fi
1567b789ec8aSmrg}
1568b789ec8aSmrg#end: func_cygpath
1569b789ec8aSmrg
1570b789ec8aSmrg
1571b789ec8aSmrg# func_convert_core_msys_to_w32 ARG
1572b789ec8aSmrg# Convert file name or path ARG from MSYS format to w32 format.  Return
1573b789ec8aSmrg# result in func_convert_core_msys_to_w32_result.
1574b789ec8aSmrgfunc_convert_core_msys_to_w32 ()
1575b789ec8aSmrg{
1576b789ec8aSmrg  $opt_debug
1577b789ec8aSmrg  # awkward: cmd appends spaces to result
1578b789ec8aSmrg  func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
1579b789ec8aSmrg    $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"`
1580b789ec8aSmrg}
1581b789ec8aSmrg#end: func_convert_core_msys_to_w32
1582b789ec8aSmrg
1583b789ec8aSmrg
1584b789ec8aSmrg# func_convert_file_check ARG1 ARG2
1585b789ec8aSmrg# Verify that ARG1 (a file name in $build format) was converted to $host
1586b789ec8aSmrg# format in ARG2. Otherwise, emit an error message, but continue (resetting
1587b789ec8aSmrg# func_to_host_file_result to ARG1).
1588b789ec8aSmrgfunc_convert_file_check ()
1589b789ec8aSmrg{
1590b789ec8aSmrg  $opt_debug
1591b789ec8aSmrg  if test -z "$2" && test -n "$1" ; then
1592b789ec8aSmrg    func_error "Could not determine host file name corresponding to"
1593b789ec8aSmrg    func_error "  \`$1'"
1594b789ec8aSmrg    func_error "Continuing, but uninstalled executables may not work."
1595b789ec8aSmrg    # Fallback:
1596b789ec8aSmrg    func_to_host_file_result="$1"
1597b789ec8aSmrg  fi
1598b789ec8aSmrg}
1599b789ec8aSmrg# end func_convert_file_check
1600b789ec8aSmrg
1601b789ec8aSmrg
1602b789ec8aSmrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH
1603b789ec8aSmrg# Verify that FROM_PATH (a path in $build format) was converted to $host
1604b789ec8aSmrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting
1605b789ec8aSmrg# func_to_host_file_result to a simplistic fallback value (see below).
1606b789ec8aSmrgfunc_convert_path_check ()
1607b789ec8aSmrg{
1608b789ec8aSmrg  $opt_debug
1609b789ec8aSmrg  if test -z "$4" && test -n "$3"; then
1610b789ec8aSmrg    func_error "Could not determine the host path corresponding to"
1611b789ec8aSmrg    func_error "  \`$3'"
1612b789ec8aSmrg    func_error "Continuing, but uninstalled executables may not work."
1613b789ec8aSmrg    # Fallback.  This is a deliberately simplistic "conversion" and
1614b789ec8aSmrg    # should not be "improved".  See libtool.info.
1615b789ec8aSmrg    if test "x$1" != "x$2"; then
1616b789ec8aSmrg      lt_replace_pathsep_chars="s|$1|$2|g"
1617b789ec8aSmrg      func_to_host_path_result=`echo "$3" |
1618b789ec8aSmrg        $SED -e "$lt_replace_pathsep_chars"`
1619b789ec8aSmrg    else
1620b789ec8aSmrg      func_to_host_path_result="$3"
1621b789ec8aSmrg    fi
1622b789ec8aSmrg  fi
1623b789ec8aSmrg}
1624b789ec8aSmrg# end func_convert_path_check
1625b789ec8aSmrg
1626b789ec8aSmrg
1627b789ec8aSmrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG
1628b789ec8aSmrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT
1629b789ec8aSmrg# and appending REPL if ORIG matches BACKPAT.
1630b789ec8aSmrgfunc_convert_path_front_back_pathsep ()
1631b789ec8aSmrg{
1632b789ec8aSmrg  $opt_debug
1633b789ec8aSmrg  case $4 in
1634b789ec8aSmrg  $1 ) func_to_host_path_result="$3$func_to_host_path_result"
1635b789ec8aSmrg    ;;
1636b789ec8aSmrg  esac
1637b789ec8aSmrg  case $4 in
1638b789ec8aSmrg  $2 ) func_append func_to_host_path_result "$3"
1639b789ec8aSmrg    ;;
1640b789ec8aSmrg  esac
1641b789ec8aSmrg}
1642b789ec8aSmrg# end func_convert_path_front_back_pathsep
1643b789ec8aSmrg
1644b789ec8aSmrg
1645b789ec8aSmrg##################################################
1646b789ec8aSmrg# $build to $host FILE NAME CONVERSION FUNCTIONS #
1647b789ec8aSmrg##################################################
1648b789ec8aSmrg# invoked via `$to_host_file_cmd ARG'
1649b789ec8aSmrg#
1650b789ec8aSmrg# In each case, ARG is the path to be converted from $build to $host format.
1651b789ec8aSmrg# Result will be available in $func_to_host_file_result.
1652b789ec8aSmrg
1653b789ec8aSmrg
1654b789ec8aSmrg# func_to_host_file ARG
1655b789ec8aSmrg# Converts the file name ARG from $build format to $host format. Return result
1656b789ec8aSmrg# in func_to_host_file_result.
1657b789ec8aSmrgfunc_to_host_file ()
1658b789ec8aSmrg{
1659b789ec8aSmrg  $opt_debug
1660b789ec8aSmrg  $to_host_file_cmd "$1"
1661b789ec8aSmrg}
1662b789ec8aSmrg# end func_to_host_file
1663b789ec8aSmrg
1664b789ec8aSmrg
1665b789ec8aSmrg# func_to_tool_file ARG LAZY
1666b789ec8aSmrg# converts the file name ARG from $build format to toolchain format. Return
1667b789ec8aSmrg# result in func_to_tool_file_result.  If the conversion in use is listed
1668b789ec8aSmrg# in (the comma separated) LAZY, no conversion takes place.
1669b789ec8aSmrgfunc_to_tool_file ()
1670b789ec8aSmrg{
1671b789ec8aSmrg  $opt_debug
1672b789ec8aSmrg  case ,$2, in
1673b789ec8aSmrg    *,"$to_tool_file_cmd",*)
1674b789ec8aSmrg      func_to_tool_file_result=$1
1675b789ec8aSmrg      ;;
1676b789ec8aSmrg    *)
1677b789ec8aSmrg      $to_tool_file_cmd "$1"
1678b789ec8aSmrg      func_to_tool_file_result=$func_to_host_file_result
1679b789ec8aSmrg      ;;
1680b789ec8aSmrg  esac
1681b789ec8aSmrg}
1682b789ec8aSmrg# end func_to_tool_file
1683b789ec8aSmrg
1684b789ec8aSmrg
1685b789ec8aSmrg# func_convert_file_noop ARG
1686b789ec8aSmrg# Copy ARG to func_to_host_file_result.
1687b789ec8aSmrgfunc_convert_file_noop ()
1688b789ec8aSmrg{
1689b789ec8aSmrg  func_to_host_file_result="$1"
1690b789ec8aSmrg}
1691b789ec8aSmrg# end func_convert_file_noop
1692b789ec8aSmrg
1693b789ec8aSmrg
1694b789ec8aSmrg# func_convert_file_msys_to_w32 ARG
1695b789ec8aSmrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic
1696b789ec8aSmrg# conversion to w32 is not available inside the cwrapper.  Returns result in
1697b789ec8aSmrg# func_to_host_file_result.
1698b789ec8aSmrgfunc_convert_file_msys_to_w32 ()
1699b789ec8aSmrg{
1700b789ec8aSmrg  $opt_debug
1701b789ec8aSmrg  func_to_host_file_result="$1"
1702b789ec8aSmrg  if test -n "$1"; then
1703b789ec8aSmrg    func_convert_core_msys_to_w32 "$1"
1704b789ec8aSmrg    func_to_host_file_result="$func_convert_core_msys_to_w32_result"
1705b789ec8aSmrg  fi
1706b789ec8aSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
1707b789ec8aSmrg}
1708b789ec8aSmrg# end func_convert_file_msys_to_w32
1709b789ec8aSmrg
1710b789ec8aSmrg
1711b789ec8aSmrg# func_convert_file_cygwin_to_w32 ARG
1712b789ec8aSmrg# Convert file name ARG from Cygwin to w32 format.  Returns result in
1713b789ec8aSmrg# func_to_host_file_result.
1714b789ec8aSmrgfunc_convert_file_cygwin_to_w32 ()
1715b789ec8aSmrg{
1716b789ec8aSmrg  $opt_debug
1717b789ec8aSmrg  func_to_host_file_result="$1"
1718b789ec8aSmrg  if test -n "$1"; then
1719b789ec8aSmrg    # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
1720b789ec8aSmrg    # LT_CYGPATH in this case.
1721b789ec8aSmrg    func_to_host_file_result=`cygpath -m "$1"`
1722b789ec8aSmrg  fi
1723b789ec8aSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
1724b789ec8aSmrg}
1725b789ec8aSmrg# end func_convert_file_cygwin_to_w32
1726b789ec8aSmrg
1727b789ec8aSmrg
1728b789ec8aSmrg# func_convert_file_nix_to_w32 ARG
1729b789ec8aSmrg# Convert file name ARG from *nix to w32 format.  Requires a wine environment
1730b789ec8aSmrg# and a working winepath. Returns result in func_to_host_file_result.
1731b789ec8aSmrgfunc_convert_file_nix_to_w32 ()
1732b789ec8aSmrg{
1733b789ec8aSmrg  $opt_debug
1734b789ec8aSmrg  func_to_host_file_result="$1"
1735b789ec8aSmrg  if test -n "$1"; then
1736b789ec8aSmrg    func_convert_core_file_wine_to_w32 "$1"
1737b789ec8aSmrg    func_to_host_file_result="$func_convert_core_file_wine_to_w32_result"
1738b789ec8aSmrg  fi
1739b789ec8aSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
1740b789ec8aSmrg}
1741b789ec8aSmrg# end func_convert_file_nix_to_w32
1742b789ec8aSmrg
1743b789ec8aSmrg
1744b789ec8aSmrg# func_convert_file_msys_to_cygwin ARG
1745b789ec8aSmrg# Convert file name ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
1746b789ec8aSmrg# Returns result in func_to_host_file_result.
1747b789ec8aSmrgfunc_convert_file_msys_to_cygwin ()
1748b789ec8aSmrg{
1749b789ec8aSmrg  $opt_debug
1750b789ec8aSmrg  func_to_host_file_result="$1"
1751b789ec8aSmrg  if test -n "$1"; then
1752b789ec8aSmrg    func_convert_core_msys_to_w32 "$1"
1753b789ec8aSmrg    func_cygpath -u "$func_convert_core_msys_to_w32_result"
1754b789ec8aSmrg    func_to_host_file_result="$func_cygpath_result"
1755b789ec8aSmrg  fi
1756b789ec8aSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
1757b789ec8aSmrg}
1758b789ec8aSmrg# end func_convert_file_msys_to_cygwin
1759b789ec8aSmrg
1760b789ec8aSmrg
1761b789ec8aSmrg# func_convert_file_nix_to_cygwin ARG
1762b789ec8aSmrg# Convert file name ARG from *nix to Cygwin format.  Requires Cygwin installed
1763b789ec8aSmrg# in a wine environment, working winepath, and LT_CYGPATH set.  Returns result
1764b789ec8aSmrg# in func_to_host_file_result.
1765b789ec8aSmrgfunc_convert_file_nix_to_cygwin ()
1766b789ec8aSmrg{
1767b789ec8aSmrg  $opt_debug
1768b789ec8aSmrg  func_to_host_file_result="$1"
1769b789ec8aSmrg  if test -n "$1"; then
1770b789ec8aSmrg    # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
1771b789ec8aSmrg    func_convert_core_file_wine_to_w32 "$1"
1772b789ec8aSmrg    func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
1773b789ec8aSmrg    func_to_host_file_result="$func_cygpath_result"
1774b789ec8aSmrg  fi
1775b789ec8aSmrg  func_convert_file_check "$1" "$func_to_host_file_result"
1776b789ec8aSmrg}
1777b789ec8aSmrg# end func_convert_file_nix_to_cygwin
1778b789ec8aSmrg
1779b789ec8aSmrg
1780b789ec8aSmrg#############################################
1781b789ec8aSmrg# $build to $host PATH CONVERSION FUNCTIONS #
1782b789ec8aSmrg#############################################
1783b789ec8aSmrg# invoked via `$to_host_path_cmd ARG'
1784b789ec8aSmrg#
1785b789ec8aSmrg# In each case, ARG is the path to be converted from $build to $host format.
1786b789ec8aSmrg# The result will be available in $func_to_host_path_result.
1787b789ec8aSmrg#
1788b789ec8aSmrg# Path separators are also converted from $build format to $host format.  If
1789b789ec8aSmrg# ARG begins or ends with a path separator character, it is preserved (but
1790b789ec8aSmrg# converted to $host format) on output.
1791b789ec8aSmrg#
1792b789ec8aSmrg# All path conversion functions are named using the following convention:
1793b789ec8aSmrg#   file name conversion function    : func_convert_file_X_to_Y ()
1794b789ec8aSmrg#   path conversion function         : func_convert_path_X_to_Y ()
1795b789ec8aSmrg# where, for any given $build/$host combination the 'X_to_Y' value is the
1796b789ec8aSmrg# same.  If conversion functions are added for new $build/$host combinations,
1797b789ec8aSmrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd
1798b789ec8aSmrg# will break.
1799b789ec8aSmrg
1800b789ec8aSmrg
1801b789ec8aSmrg# func_init_to_host_path_cmd
1802b789ec8aSmrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the
1803b789ec8aSmrg# appropriate value, based on the value of $to_host_file_cmd.
1804b789ec8aSmrgto_host_path_cmd=
1805b789ec8aSmrgfunc_init_to_host_path_cmd ()
1806b789ec8aSmrg{
1807b789ec8aSmrg  $opt_debug
1808b789ec8aSmrg  if test -z "$to_host_path_cmd"; then
1809b789ec8aSmrg    func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
1810b789ec8aSmrg    to_host_path_cmd="func_convert_path_${func_stripname_result}"
1811b789ec8aSmrg  fi
1812b789ec8aSmrg}
1813b789ec8aSmrg
1814b789ec8aSmrg
1815b789ec8aSmrg# func_to_host_path ARG
1816b789ec8aSmrg# Converts the path ARG from $build format to $host format. Return result
1817b789ec8aSmrg# in func_to_host_path_result.
1818b789ec8aSmrgfunc_to_host_path ()
1819b789ec8aSmrg{
1820b789ec8aSmrg  $opt_debug
1821b789ec8aSmrg  func_init_to_host_path_cmd
1822b789ec8aSmrg  $to_host_path_cmd "$1"
1823b789ec8aSmrg}
1824b789ec8aSmrg# end func_to_host_path
1825b789ec8aSmrg
1826b789ec8aSmrg
1827b789ec8aSmrg# func_convert_path_noop ARG
1828b789ec8aSmrg# Copy ARG to func_to_host_path_result.
1829b789ec8aSmrgfunc_convert_path_noop ()
1830b789ec8aSmrg{
1831b789ec8aSmrg  func_to_host_path_result="$1"
1832b789ec8aSmrg}
1833b789ec8aSmrg# end func_convert_path_noop
1834b789ec8aSmrg
1835b789ec8aSmrg
1836b789ec8aSmrg# func_convert_path_msys_to_w32 ARG
1837b789ec8aSmrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic
1838b789ec8aSmrg# conversion to w32 is not available inside the cwrapper.  Returns result in
1839b789ec8aSmrg# func_to_host_path_result.
1840b789ec8aSmrgfunc_convert_path_msys_to_w32 ()
1841c27c18e8Smrg{
1842b789ec8aSmrg  $opt_debug
1843b789ec8aSmrg  func_to_host_path_result="$1"
1844b789ec8aSmrg  if test -n "$1"; then
1845b789ec8aSmrg    # Remove leading and trailing path separator characters from ARG.  MSYS
1846b789ec8aSmrg    # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
1847b789ec8aSmrg    # and winepath ignores them completely.
1848b789ec8aSmrg    func_stripname : : "$1"
1849b789ec8aSmrg    func_to_host_path_tmp1=$func_stripname_result
1850b789ec8aSmrg    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
1851b789ec8aSmrg    func_to_host_path_result="$func_convert_core_msys_to_w32_result"
1852b789ec8aSmrg    func_convert_path_check : ";" \
1853b789ec8aSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1854b789ec8aSmrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
1855b789ec8aSmrg  fi
1856b789ec8aSmrg}
1857b789ec8aSmrg# end func_convert_path_msys_to_w32
1858c27c18e8Smrg
1859c27c18e8Smrg
1860b789ec8aSmrg# func_convert_path_cygwin_to_w32 ARG
1861b789ec8aSmrg# Convert path ARG from Cygwin to w32 format.  Returns result in
1862b789ec8aSmrg# func_to_host_file_result.
1863b789ec8aSmrgfunc_convert_path_cygwin_to_w32 ()
1864b789ec8aSmrg{
1865b789ec8aSmrg  $opt_debug
1866b789ec8aSmrg  func_to_host_path_result="$1"
1867b789ec8aSmrg  if test -n "$1"; then
1868b789ec8aSmrg    # See func_convert_path_msys_to_w32:
1869b789ec8aSmrg    func_stripname : : "$1"
1870b789ec8aSmrg    func_to_host_path_tmp1=$func_stripname_result
1871b789ec8aSmrg    func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"`
1872b789ec8aSmrg    func_convert_path_check : ";" \
1873b789ec8aSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1874b789ec8aSmrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
1875b789ec8aSmrg  fi
1876b789ec8aSmrg}
1877b789ec8aSmrg# end func_convert_path_cygwin_to_w32
1878c27c18e8Smrg
1879c27c18e8Smrg
1880b789ec8aSmrg# func_convert_path_nix_to_w32 ARG
1881b789ec8aSmrg# Convert path ARG from *nix to w32 format.  Requires a wine environment and
1882b789ec8aSmrg# a working winepath.  Returns result in func_to_host_file_result.
1883b789ec8aSmrgfunc_convert_path_nix_to_w32 ()
1884b789ec8aSmrg{
1885b789ec8aSmrg  $opt_debug
1886b789ec8aSmrg  func_to_host_path_result="$1"
1887b789ec8aSmrg  if test -n "$1"; then
1888b789ec8aSmrg    # See func_convert_path_msys_to_w32:
1889b789ec8aSmrg    func_stripname : : "$1"
1890b789ec8aSmrg    func_to_host_path_tmp1=$func_stripname_result
1891b789ec8aSmrg    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
1892b789ec8aSmrg    func_to_host_path_result="$func_convert_core_path_wine_to_w32_result"
1893b789ec8aSmrg    func_convert_path_check : ";" \
1894b789ec8aSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1895b789ec8aSmrg    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
1896b789ec8aSmrg  fi
1897b789ec8aSmrg}
1898b789ec8aSmrg# end func_convert_path_nix_to_w32
1899c27c18e8Smrg
1900b789ec8aSmrg
1901b789ec8aSmrg# func_convert_path_msys_to_cygwin ARG
1902b789ec8aSmrg# Convert path ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
1903b789ec8aSmrg# Returns result in func_to_host_file_result.
1904b789ec8aSmrgfunc_convert_path_msys_to_cygwin ()
1905b789ec8aSmrg{
1906b789ec8aSmrg  $opt_debug
1907b789ec8aSmrg  func_to_host_path_result="$1"
1908b789ec8aSmrg  if test -n "$1"; then
1909b789ec8aSmrg    # See func_convert_path_msys_to_w32:
1910b789ec8aSmrg    func_stripname : : "$1"
1911b789ec8aSmrg    func_to_host_path_tmp1=$func_stripname_result
1912b789ec8aSmrg    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
1913b789ec8aSmrg    func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
1914b789ec8aSmrg    func_to_host_path_result="$func_cygpath_result"
1915b789ec8aSmrg    func_convert_path_check : : \
1916b789ec8aSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1917b789ec8aSmrg    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
1918b789ec8aSmrg  fi
1919b789ec8aSmrg}
1920b789ec8aSmrg# end func_convert_path_msys_to_cygwin
1921b789ec8aSmrg
1922b789ec8aSmrg
1923b789ec8aSmrg# func_convert_path_nix_to_cygwin ARG
1924b789ec8aSmrg# Convert path ARG from *nix to Cygwin format.  Requires Cygwin installed in a
1925b789ec8aSmrg# a wine environment, working winepath, and LT_CYGPATH set.  Returns result in
1926b789ec8aSmrg# func_to_host_file_result.
1927b789ec8aSmrgfunc_convert_path_nix_to_cygwin ()
1928b789ec8aSmrg{
1929b789ec8aSmrg  $opt_debug
1930b789ec8aSmrg  func_to_host_path_result="$1"
1931b789ec8aSmrg  if test -n "$1"; then
1932b789ec8aSmrg    # Remove leading and trailing path separator characters from
1933b789ec8aSmrg    # ARG. msys behavior is inconsistent here, cygpath turns them
1934b789ec8aSmrg    # into '.;' and ';.', and winepath ignores them completely.
1935b789ec8aSmrg    func_stripname : : "$1"
1936b789ec8aSmrg    func_to_host_path_tmp1=$func_stripname_result
1937b789ec8aSmrg    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
1938b789ec8aSmrg    func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
1939b789ec8aSmrg    func_to_host_path_result="$func_cygpath_result"
1940b789ec8aSmrg    func_convert_path_check : : \
1941b789ec8aSmrg      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1942b789ec8aSmrg    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
1943b789ec8aSmrg  fi
1944c27c18e8Smrg}
1945b789ec8aSmrg# end func_convert_path_nix_to_cygwin
1946b789ec8aSmrg
1947c27c18e8Smrg
1948c27c18e8Smrg# func_mode_compile arg...
1949c27c18e8Smrgfunc_mode_compile ()
1950c27c18e8Smrg{
1951c27c18e8Smrg    $opt_debug
1952c27c18e8Smrg    # Get the compilation command and the source file.
1953c27c18e8Smrg    base_compile=
1954c27c18e8Smrg    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
1955c27c18e8Smrg    suppress_opt=yes
1956c27c18e8Smrg    suppress_output=
1957c27c18e8Smrg    arg_mode=normal
1958c27c18e8Smrg    libobj=
1959c27c18e8Smrg    later=
1960c27c18e8Smrg    pie_flag=
1961c27c18e8Smrg
1962c27c18e8Smrg    for arg
1963c27c18e8Smrg    do
1964c27c18e8Smrg      case $arg_mode in
1965c27c18e8Smrg      arg  )
1966c27c18e8Smrg	# do not "continue".  Instead, add this to base_compile
1967c27c18e8Smrg	lastarg="$arg"
1968c27c18e8Smrg	arg_mode=normal
1969c27c18e8Smrg	;;
1970c27c18e8Smrg
1971c27c18e8Smrg      target )
1972c27c18e8Smrg	libobj="$arg"
1973c27c18e8Smrg	arg_mode=normal
1974c27c18e8Smrg	continue
1975c27c18e8Smrg	;;
1976c27c18e8Smrg
1977c27c18e8Smrg      normal )
1978c27c18e8Smrg	# Accept any command-line options.
1979c27c18e8Smrg	case $arg in
1980c27c18e8Smrg	-o)
1981c27c18e8Smrg	  test -n "$libobj" && \
1982c27c18e8Smrg	    func_fatal_error "you cannot specify \`-o' more than once"
1983c27c18e8Smrg	  arg_mode=target
1984c27c18e8Smrg	  continue
1985c27c18e8Smrg	  ;;
1986c27c18e8Smrg
1987c27c18e8Smrg	-pie | -fpie | -fPIE)
1988b789ec8aSmrg          func_append pie_flag " $arg"
1989c27c18e8Smrg	  continue
1990c27c18e8Smrg	  ;;
1991c27c18e8Smrg
1992c27c18e8Smrg	-shared | -static | -prefer-pic | -prefer-non-pic)
1993b789ec8aSmrg	  func_append later " $arg"
1994c27c18e8Smrg	  continue
1995c27c18e8Smrg	  ;;
1996c27c18e8Smrg
1997c27c18e8Smrg	-no-suppress)
1998c43cc173Smrg	  suppress_opt=no
1999c43cc173Smrg	  continue
2000c43cc173Smrg	  ;;
2001c43cc173Smrg
2002c43cc173Smrg	-Xcompiler)
2003c43cc173Smrg	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
2004c43cc173Smrg	  continue      #  The current "srcfile" will either be retained or
2005c43cc173Smrg	  ;;            #  replaced later.  I would guess that would be a bug.
2006c43cc173Smrg
2007c43cc173Smrg	-Wc,*)
2008c27c18e8Smrg	  func_stripname '-Wc,' '' "$arg"
2009c27c18e8Smrg	  args=$func_stripname_result
2010c43cc173Smrg	  lastarg=
2011c43cc173Smrg	  save_ifs="$IFS"; IFS=','
2012c27c18e8Smrg	  for arg in $args; do
2013c43cc173Smrg	    IFS="$save_ifs"
2014b789ec8aSmrg	    func_append_quoted lastarg "$arg"
2015c43cc173Smrg	  done
2016c43cc173Smrg	  IFS="$save_ifs"
2017c27c18e8Smrg	  func_stripname ' ' '' "$lastarg"
2018c27c18e8Smrg	  lastarg=$func_stripname_result
2019c43cc173Smrg
2020c43cc173Smrg	  # Add the arguments to base_compile.
2021b789ec8aSmrg	  func_append base_compile " $lastarg"
2022c43cc173Smrg	  continue
2023c43cc173Smrg	  ;;
2024c43cc173Smrg
2025c27c18e8Smrg	*)
2026c43cc173Smrg	  # Accept the current argument as the source file.
2027c43cc173Smrg	  # The previous "srcfile" becomes the current argument.
2028c43cc173Smrg	  #
2029c43cc173Smrg	  lastarg="$srcfile"
2030c43cc173Smrg	  srcfile="$arg"
2031c43cc173Smrg	  ;;
2032c43cc173Smrg	esac  #  case $arg
2033c43cc173Smrg	;;
2034c43cc173Smrg      esac    #  case $arg_mode
2035c43cc173Smrg
2036c43cc173Smrg      # Aesthetically quote the previous argument.
2037b789ec8aSmrg      func_append_quoted base_compile "$lastarg"
2038c43cc173Smrg    done # for arg
2039c43cc173Smrg
2040c43cc173Smrg    case $arg_mode in
2041c43cc173Smrg    arg)
2042c27c18e8Smrg      func_fatal_error "you must specify an argument for -Xcompile"
2043c43cc173Smrg      ;;
2044c43cc173Smrg    target)
2045c27c18e8Smrg      func_fatal_error "you must specify a target with \`-o'"
2046c43cc173Smrg      ;;
2047c43cc173Smrg    *)
2048c43cc173Smrg      # Get the name of the library object.
2049c27c18e8Smrg      test -z "$libobj" && {
2050c27c18e8Smrg	func_basename "$srcfile"
2051c27c18e8Smrg	libobj="$func_basename_result"
2052c27c18e8Smrg      }
2053c43cc173Smrg      ;;
2054c43cc173Smrg    esac
2055c43cc173Smrg
2056c43cc173Smrg    # Recognize several different file suffixes.
2057c43cc173Smrg    # If the user specifies -o file.o, it is replaced with file.lo
2058c43cc173Smrg    case $libobj in
2059c27c18e8Smrg    *.[cCFSifmso] | \
2060c27c18e8Smrg    *.ada | *.adb | *.ads | *.asm | \
2061c27c18e8Smrg    *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
206237eb1ca1Smrg    *.[fF][09]? | *.for | *.java | *.obj | *.sx | *.cu | *.cup)
2063c27c18e8Smrg      func_xform "$libobj"
2064c27c18e8Smrg      libobj=$func_xform_result
2065c27c18e8Smrg      ;;
2066c43cc173Smrg    esac
2067c43cc173Smrg
2068c43cc173Smrg    case $libobj in
2069c27c18e8Smrg    *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
2070c43cc173Smrg    *)
2071c27c18e8Smrg      func_fatal_error "cannot determine name of library object from \`$libobj'"
2072c43cc173Smrg      ;;
2073c43cc173Smrg    esac
2074c43cc173Smrg
2075c43cc173Smrg    func_infer_tag $base_compile
2076c43cc173Smrg
2077c43cc173Smrg    for arg in $later; do
2078c43cc173Smrg      case $arg in
2079c27c18e8Smrg      -shared)
2080c27c18e8Smrg	test "$build_libtool_libs" != yes && \
2081c27c18e8Smrg	  func_fatal_configuration "can not build a shared library"
2082c27c18e8Smrg	build_old_libs=no
2083c27c18e8Smrg	continue
2084c27c18e8Smrg	;;
2085c27c18e8Smrg
2086c43cc173Smrg      -static)
2087c27c18e8Smrg	build_libtool_libs=no
2088c43cc173Smrg	build_old_libs=yes
2089c43cc173Smrg	continue
2090c43cc173Smrg	;;
2091c43cc173Smrg
2092c43cc173Smrg      -prefer-pic)
2093c43cc173Smrg	pic_mode=yes
2094c43cc173Smrg	continue
2095c43cc173Smrg	;;
2096c43cc173Smrg
2097c43cc173Smrg      -prefer-non-pic)
2098c43cc173Smrg	pic_mode=no
2099c43cc173Smrg	continue
2100c43cc173Smrg	;;
2101c43cc173Smrg      esac
2102c43cc173Smrg    done
2103c43cc173Smrg
2104c27c18e8Smrg    func_quote_for_eval "$libobj"
2105c27c18e8Smrg    test "X$libobj" != "X$func_quote_for_eval_result" \
2106c27c18e8Smrg      && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'	 &()|`$[]' \
2107c27c18e8Smrg      && func_warning "libobj name \`$libobj' may not contain shell special characters."
2108c27c18e8Smrg    func_dirname_and_basename "$obj" "/" ""
2109c27c18e8Smrg    objname="$func_basename_result"
2110c27c18e8Smrg    xdir="$func_dirname_result"
2111c43cc173Smrg    lobj=${xdir}$objdir/$objname
2112c43cc173Smrg
2113c27c18e8Smrg    test -z "$base_compile" && \
2114c27c18e8Smrg      func_fatal_help "you must specify a compilation command"
2115c43cc173Smrg
2116c43cc173Smrg    # Delete any leftover library objects.
2117c43cc173Smrg    if test "$build_old_libs" = yes; then
2118c43cc173Smrg      removelist="$obj $lobj $libobj ${libobj}T"
2119c43cc173Smrg    else
2120c43cc173Smrg      removelist="$lobj $libobj ${libobj}T"
2121c43cc173Smrg    fi
2122c43cc173Smrg
2123c43cc173Smrg    # On Cygwin there's no "real" PIC flag so we must build both object types
2124c43cc173Smrg    case $host_os in
2125c27c18e8Smrg    cygwin* | mingw* | pw32* | os2* | cegcc*)
2126c43cc173Smrg      pic_mode=default
2127c43cc173Smrg      ;;
2128c43cc173Smrg    esac
2129c43cc173Smrg    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
2130c43cc173Smrg      # non-PIC code in shared libraries is not supported
2131c43cc173Smrg      pic_mode=default
2132c43cc173Smrg    fi
2133c43cc173Smrg
2134c43cc173Smrg    # Calculate the filename of the output object if compiler does
2135c43cc173Smrg    # not support -o with -c
2136c43cc173Smrg    if test "$compiler_c_o" = no; then
213737eb1ca1Smrg      output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext}
2138c43cc173Smrg      lockfile="$output_obj.lock"
2139c43cc173Smrg    else
2140c43cc173Smrg      output_obj=
2141c43cc173Smrg      need_locks=no
2142c43cc173Smrg      lockfile=
2143c43cc173Smrg    fi
2144c43cc173Smrg
2145c43cc173Smrg    # Lock this critical section if it is needed
2146c43cc173Smrg    # We use this script file to make the link, it avoids creating a new file
2147c43cc173Smrg    if test "$need_locks" = yes; then
2148c27c18e8Smrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
2149c27c18e8Smrg	func_echo "Waiting for $lockfile to be removed"
2150c43cc173Smrg	sleep 2
2151c43cc173Smrg      done
2152c43cc173Smrg    elif test "$need_locks" = warn; then
2153c43cc173Smrg      if test -f "$lockfile"; then
2154c27c18e8Smrg	$ECHO "\
2155c43cc173Smrg*** ERROR, $lockfile exists and contains:
2156c43cc173Smrg`cat $lockfile 2>/dev/null`
2157c43cc173Smrg
2158c43cc173SmrgThis indicates that another process is trying to use the same
2159c43cc173Smrgtemporary object file, and libtool could not work around it because
2160c43cc173Smrgyour compiler does not support \`-c' and \`-o' together.  If you
2161c43cc173Smrgrepeat this compilation, it may succeed, by chance, but you had better
2162c43cc173Smrgavoid parallel builds (make -j) in this platform, or get a better
2163c43cc173Smrgcompiler."
2164c43cc173Smrg
2165c27c18e8Smrg	$opt_dry_run || $RM $removelist
2166c43cc173Smrg	exit $EXIT_FAILURE
2167c43cc173Smrg      fi
2168b789ec8aSmrg      func_append removelist " $output_obj"
2169c27c18e8Smrg      $ECHO "$srcfile" > "$lockfile"
2170c43cc173Smrg    fi
2171c43cc173Smrg
2172c27c18e8Smrg    $opt_dry_run || $RM $removelist
2173b789ec8aSmrg    func_append removelist " $lockfile"
2174c27c18e8Smrg    trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
2175c27c18e8Smrg
2176b789ec8aSmrg    func_to_tool_file "$srcfile" func_convert_file_msys_to_w32
2177b789ec8aSmrg    srcfile=$func_to_tool_file_result
2178c27c18e8Smrg    func_quote_for_eval "$srcfile"
2179c27c18e8Smrg    qsrcfile=$func_quote_for_eval_result
2180c43cc173Smrg
2181c43cc173Smrg    # Only build a PIC object if we are building libtool libraries.
2182c43cc173Smrg    if test "$build_libtool_libs" = yes; then
2183c43cc173Smrg      # Without this assignment, base_compile gets emptied.
2184c43cc173Smrg      fbsd_hideous_sh_bug=$base_compile
2185c43cc173Smrg
2186c43cc173Smrg      if test "$pic_mode" != no; then
2187c43cc173Smrg	command="$base_compile $qsrcfile $pic_flag"
2188c43cc173Smrg      else
2189c43cc173Smrg	# Don't build PIC code
2190c43cc173Smrg	command="$base_compile $qsrcfile"
2191c43cc173Smrg      fi
2192c43cc173Smrg
2193c27c18e8Smrg      func_mkdir_p "$xdir$objdir"
2194c43cc173Smrg
2195c43cc173Smrg      if test -z "$output_obj"; then
2196c43cc173Smrg	# Place PIC objects in $objdir
2197b789ec8aSmrg	func_append command " -o $lobj"
2198c43cc173Smrg      fi
2199c43cc173Smrg
2200c27c18e8Smrg      func_show_eval_locale "$command"	\
2201c27c18e8Smrg          'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
2202c43cc173Smrg
2203c43cc173Smrg      if test "$need_locks" = warn &&
2204c43cc173Smrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
2205c27c18e8Smrg	$ECHO "\
2206c43cc173Smrg*** ERROR, $lockfile contains:
2207c43cc173Smrg`cat $lockfile 2>/dev/null`
2208c43cc173Smrg
2209c43cc173Smrgbut it should contain:
2210c43cc173Smrg$srcfile
2211c43cc173Smrg
2212c43cc173SmrgThis indicates that another process is trying to use the same
2213c43cc173Smrgtemporary object file, and libtool could not work around it because
2214c43cc173Smrgyour compiler does not support \`-c' and \`-o' together.  If you
2215c43cc173Smrgrepeat this compilation, it may succeed, by chance, but you had better
2216c43cc173Smrgavoid parallel builds (make -j) in this platform, or get a better
2217c43cc173Smrgcompiler."
2218c43cc173Smrg
2219c27c18e8Smrg	$opt_dry_run || $RM $removelist
2220c43cc173Smrg	exit $EXIT_FAILURE
2221c43cc173Smrg      fi
2222c43cc173Smrg
2223c43cc173Smrg      # Just move the object if needed, then go on to compile the next one
2224c43cc173Smrg      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
2225c27c18e8Smrg	func_show_eval '$MV "$output_obj" "$lobj"' \
2226c27c18e8Smrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
2227c43cc173Smrg      fi
2228c43cc173Smrg
2229c43cc173Smrg      # Allow error messages only from the first compilation.
2230c43cc173Smrg      if test "$suppress_opt" = yes; then
2231c27c18e8Smrg	suppress_output=' >/dev/null 2>&1'
2232c43cc173Smrg      fi
2233c43cc173Smrg    fi
2234c43cc173Smrg
2235c43cc173Smrg    # Only build a position-dependent object if we build old libraries.
2236c43cc173Smrg    if test "$build_old_libs" = yes; then
2237c43cc173Smrg      if test "$pic_mode" != yes; then
2238c43cc173Smrg	# Don't build PIC code
2239c27c18e8Smrg	command="$base_compile $qsrcfile$pie_flag"
2240c43cc173Smrg      else
2241c43cc173Smrg	command="$base_compile $qsrcfile $pic_flag"
2242c43cc173Smrg      fi
2243c43cc173Smrg      if test "$compiler_c_o" = yes; then
2244b789ec8aSmrg	func_append command " -o $obj"
2245c43cc173Smrg      fi
2246c43cc173Smrg
2247c43cc173Smrg      # Suppress compiler output if we already did a PIC compilation.
2248b789ec8aSmrg      func_append command "$suppress_output"
2249c27c18e8Smrg      func_show_eval_locale "$command" \
2250c27c18e8Smrg        '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
2251c43cc173Smrg
2252c43cc173Smrg      if test "$need_locks" = warn &&
2253c43cc173Smrg	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
2254c27c18e8Smrg	$ECHO "\
2255c43cc173Smrg*** ERROR, $lockfile contains:
2256c43cc173Smrg`cat $lockfile 2>/dev/null`
2257c43cc173Smrg
2258c43cc173Smrgbut it should contain:
2259c43cc173Smrg$srcfile
2260c43cc173Smrg
2261c43cc173SmrgThis indicates that another process is trying to use the same
2262c43cc173Smrgtemporary object file, and libtool could not work around it because
2263c43cc173Smrgyour compiler does not support \`-c' and \`-o' together.  If you
2264c43cc173Smrgrepeat this compilation, it may succeed, by chance, but you had better
2265c43cc173Smrgavoid parallel builds (make -j) in this platform, or get a better
2266c43cc173Smrgcompiler."
2267c43cc173Smrg
2268c27c18e8Smrg	$opt_dry_run || $RM $removelist
2269c43cc173Smrg	exit $EXIT_FAILURE
2270c43cc173Smrg      fi
2271c43cc173Smrg
2272c43cc173Smrg      # Just move the object if needed
2273c43cc173Smrg      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
2274c27c18e8Smrg	func_show_eval '$MV "$output_obj" "$obj"' \
2275c27c18e8Smrg	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
2276c43cc173Smrg      fi
2277c43cc173Smrg    fi
2278c43cc173Smrg
2279c27c18e8Smrg    $opt_dry_run || {
2280c27c18e8Smrg      func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
2281c43cc173Smrg
2282c27c18e8Smrg      # Unlock the critical section if it was locked
2283c27c18e8Smrg      if test "$need_locks" != no; then
2284c27c18e8Smrg	removelist=$lockfile
2285c27c18e8Smrg        $RM "$lockfile"
2286c27c18e8Smrg      fi
2287c27c18e8Smrg    }
2288c43cc173Smrg
2289c43cc173Smrg    exit $EXIT_SUCCESS
2290c27c18e8Smrg}
2291c43cc173Smrg
2292c27c18e8Smrg$opt_help || {
2293b789ec8aSmrg  test "$opt_mode" = compile && func_mode_compile ${1+"$@"}
2294c27c18e8Smrg}
2295c43cc173Smrg
2296c27c18e8Smrgfunc_mode_help ()
2297c27c18e8Smrg{
2298c27c18e8Smrg    # We need to display help for each of the modes.
2299b789ec8aSmrg    case $opt_mode in
2300c27c18e8Smrg      "")
2301c27c18e8Smrg        # Generic help is extracted from the usage comments
2302c27c18e8Smrg        # at the start of this file.
2303c27c18e8Smrg        func_help
2304c27c18e8Smrg        ;;
2305c43cc173Smrg
2306c27c18e8Smrg      clean)
2307c27c18e8Smrg        $ECHO \
2308c27c18e8Smrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
2309c43cc173Smrg
2310c27c18e8SmrgRemove files from the build directory.
2311c43cc173Smrg
2312c27c18e8SmrgRM is the name of the program to use to delete files associated with each FILE
2313c27c18e8Smrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
2314c27c18e8Smrgto RM.
2315c43cc173Smrg
2316c27c18e8SmrgIf FILE is a libtool library, object or program, all the files associated
2317c27c18e8Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM."
2318c27c18e8Smrg        ;;
2319c43cc173Smrg
2320c27c18e8Smrg      compile)
2321c27c18e8Smrg      $ECHO \
2322c27c18e8Smrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
2323c43cc173Smrg
2324c27c18e8SmrgCompile a source file into a libtool library object.
2325c43cc173Smrg
2326c27c18e8SmrgThis mode accepts the following additional options:
2327c43cc173Smrg
2328c27c18e8Smrg  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
2329c27c18e8Smrg  -no-suppress      do not suppress compiler output for multiple passes
233037eb1ca1Smrg  -prefer-pic       try to build PIC objects only
233137eb1ca1Smrg  -prefer-non-pic   try to build non-PIC objects only
2332c27c18e8Smrg  -shared           do not build a \`.o' file suitable for static linking
2333c27c18e8Smrg  -static           only build a \`.o' file suitable for static linking
233437eb1ca1Smrg  -Wc,FLAG          pass FLAG directly to the compiler
2335c43cc173Smrg
2336c27c18e8SmrgCOMPILE-COMMAND is a command to be used in creating a \`standard' object file
2337c27c18e8Smrgfrom the given SOURCEFILE.
2338c43cc173Smrg
2339c27c18e8SmrgThe output file name is determined by removing the directory component from
2340c27c18e8SmrgSOURCEFILE, then substituting the C source code suffix \`.c' with the
2341c27c18e8Smrglibrary object suffix, \`.lo'."
2342c27c18e8Smrg        ;;
2343c43cc173Smrg
2344c27c18e8Smrg      execute)
2345c27c18e8Smrg        $ECHO \
2346c27c18e8Smrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
2347c43cc173Smrg
2348c27c18e8SmrgAutomatically set library path, then run a program.
2349c43cc173Smrg
2350c27c18e8SmrgThis mode accepts the following additional options:
2351c43cc173Smrg
2352c27c18e8Smrg  -dlopen FILE      add the directory containing FILE to the library path
2353c43cc173Smrg
2354c27c18e8SmrgThis mode sets the library path environment variable according to \`-dlopen'
2355c27c18e8Smrgflags.
2356c43cc173Smrg
2357c27c18e8SmrgIf any of the ARGS are libtool executable wrappers, then they are translated
2358c27c18e8Smrginto their corresponding uninstalled binary, and any of their required library
2359c27c18e8Smrgdirectories are added to the library path.
2360c43cc173Smrg
2361c27c18e8SmrgThen, COMMAND is executed, with ARGS as arguments."
2362c27c18e8Smrg        ;;
2363c43cc173Smrg
2364c27c18e8Smrg      finish)
2365c27c18e8Smrg        $ECHO \
2366c27c18e8Smrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
2367c43cc173Smrg
2368c27c18e8SmrgComplete the installation of libtool libraries.
2369c43cc173Smrg
2370c27c18e8SmrgEach LIBDIR is a directory that contains libtool libraries.
2371c43cc173Smrg
2372c27c18e8SmrgThe commands that this mode executes may require superuser privileges.  Use
2373c27c18e8Smrgthe \`--dry-run' option if you just want to see what would be executed."
2374c27c18e8Smrg        ;;
2375c43cc173Smrg
2376c27c18e8Smrg      install)
2377c27c18e8Smrg        $ECHO \
2378c27c18e8Smrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
2379c43cc173Smrg
2380c27c18e8SmrgInstall executables or libraries.
2381c43cc173Smrg
2382c27c18e8SmrgINSTALL-COMMAND is the installation command.  The first component should be
2383c27c18e8Smrgeither the \`install' or \`cp' program.
2384c43cc173Smrg
2385c27c18e8SmrgThe following components of INSTALL-COMMAND are treated specially:
2386c43cc173Smrg
238737eb1ca1Smrg  -inst-prefix-dir PREFIX-DIR  Use PREFIX-DIR as a staging area for installation
2388c43cc173Smrg
2389c27c18e8SmrgThe rest of the components are interpreted as arguments to that command (only
2390c27c18e8SmrgBSD-compatible install options are recognized)."
2391c27c18e8Smrg        ;;
2392c43cc173Smrg
2393c27c18e8Smrg      link)
2394c27c18e8Smrg        $ECHO \
2395c27c18e8Smrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
2396c43cc173Smrg
2397c27c18e8SmrgLink object files or libraries together to form another library, or to
2398c27c18e8Smrgcreate an executable program.
2399c43cc173Smrg
2400c27c18e8SmrgLINK-COMMAND is a command using the C compiler that you would use to create
2401c27c18e8Smrga program from several object files.
2402c43cc173Smrg
2403c27c18e8SmrgThe following components of LINK-COMMAND are treated specially:
2404c43cc173Smrg
2405c27c18e8Smrg  -all-static       do not do any dynamic linking at all
2406c27c18e8Smrg  -avoid-version    do not add a version suffix if possible
240737eb1ca1Smrg  -bindir BINDIR    specify path to binaries directory (for systems where
240837eb1ca1Smrg                    libraries must be found in the PATH setting at runtime)
2409c27c18e8Smrg  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
2410c27c18e8Smrg  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
2411c27c18e8Smrg  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
2412c27c18e8Smrg  -export-symbols SYMFILE
2413c27c18e8Smrg                    try to export only the symbols listed in SYMFILE
2414c27c18e8Smrg  -export-symbols-regex REGEX
2415c27c18e8Smrg                    try to export only the symbols matching REGEX
2416c27c18e8Smrg  -LLIBDIR          search LIBDIR for required installed libraries
2417c27c18e8Smrg  -lNAME            OUTPUT-FILE requires the installed library libNAME
2418c27c18e8Smrg  -module           build a library that can dlopened
2419c27c18e8Smrg  -no-fast-install  disable the fast-install mode
2420c27c18e8Smrg  -no-install       link a not-installable executable
2421c27c18e8Smrg  -no-undefined     declare that a library does not refer to external symbols
2422c27c18e8Smrg  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
2423c27c18e8Smrg  -objectlist FILE  Use a list of object files found in FILE to specify objects
2424c27c18e8Smrg  -precious-files-regex REGEX
2425c27c18e8Smrg                    don't remove output files matching REGEX
2426c27c18e8Smrg  -release RELEASE  specify package release information
2427c27c18e8Smrg  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
2428c27c18e8Smrg  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
2429c27c18e8Smrg  -shared           only do dynamic linking of libtool libraries
2430c27c18e8Smrg  -shrext SUFFIX    override the standard shared library file extension
2431c27c18e8Smrg  -static           do not do any dynamic linking of uninstalled libtool libraries
2432c27c18e8Smrg  -static-libtool-libs
2433c27c18e8Smrg                    do not do any dynamic linking of libtool libraries
2434c27c18e8Smrg  -version-info CURRENT[:REVISION[:AGE]]
2435c27c18e8Smrg                    specify library version info [each variable defaults to 0]
2436c27c18e8Smrg  -weak LIBNAME     declare that the target provides the LIBNAME interface
243737eb1ca1Smrg  -Wc,FLAG
243837eb1ca1Smrg  -Xcompiler FLAG   pass linker-specific FLAG directly to the compiler
243937eb1ca1Smrg  -Wl,FLAG
244037eb1ca1Smrg  -Xlinker FLAG     pass linker-specific FLAG directly to the linker
244137eb1ca1Smrg  -XCClinker FLAG   pass link-specific FLAG to the compiler driver (CC)
2442c43cc173Smrg
2443c27c18e8SmrgAll other options (arguments beginning with \`-') are ignored.
2444c43cc173Smrg
2445c27c18e8SmrgEvery other argument is treated as a filename.  Files ending in \`.la' are
2446c27c18e8Smrgtreated as uninstalled libtool libraries, other files are standard or library
2447c27c18e8Smrgobject files.
2448c43cc173Smrg
2449c27c18e8SmrgIf the OUTPUT-FILE ends in \`.la', then a libtool library is created,
2450c27c18e8Smrgonly library objects (\`.lo' files) may be specified, and \`-rpath' is
2451c27c18e8Smrgrequired, except when creating a convenience library.
2452c43cc173Smrg
2453c27c18e8SmrgIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
2454c27c18e8Smrgusing \`ar' and \`ranlib', or on Windows using \`lib'.
2455c43cc173Smrg
2456c27c18e8SmrgIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
2457c27c18e8Smrgis created, otherwise an executable program is created."
2458c43cc173Smrg        ;;
2459c43cc173Smrg
2460c27c18e8Smrg      uninstall)
2461c27c18e8Smrg        $ECHO \
2462c27c18e8Smrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
2463c43cc173Smrg
2464c27c18e8SmrgRemove libraries from an installation directory.
2465c43cc173Smrg
2466c27c18e8SmrgRM is the name of the program to use to delete files associated with each FILE
2467c27c18e8Smrg(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
2468c27c18e8Smrgto RM.
2469c43cc173Smrg
2470c27c18e8SmrgIf FILE is a libtool library, all the files associated with it are deleted.
2471c27c18e8SmrgOtherwise, only FILE itself is deleted using RM."
2472c27c18e8Smrg        ;;
2473c43cc173Smrg
2474c27c18e8Smrg      *)
2475b789ec8aSmrg        func_fatal_help "invalid operation mode \`$opt_mode'"
2476c27c18e8Smrg        ;;
2477c27c18e8Smrg    esac
2478c43cc173Smrg
247937eb1ca1Smrg    echo
2480c27c18e8Smrg    $ECHO "Try \`$progname --help' for more information about other modes."
2481c27c18e8Smrg}
2482c43cc173Smrg
248337eb1ca1Smrg# Now that we've collected a possible --mode arg, show help if necessary
248437eb1ca1Smrgif $opt_help; then
248537eb1ca1Smrg  if test "$opt_help" = :; then
248637eb1ca1Smrg    func_mode_help
248737eb1ca1Smrg  else
248837eb1ca1Smrg    {
248937eb1ca1Smrg      func_help noexit
2490b789ec8aSmrg      for opt_mode in compile link execute install finish uninstall clean; do
249137eb1ca1Smrg	func_mode_help
249237eb1ca1Smrg      done
249337eb1ca1Smrg    } | sed -n '1p; 2,$s/^Usage:/  or: /p'
249437eb1ca1Smrg    {
249537eb1ca1Smrg      func_help noexit
2496b789ec8aSmrg      for opt_mode in compile link execute install finish uninstall clean; do
249737eb1ca1Smrg	echo
249837eb1ca1Smrg	func_mode_help
249937eb1ca1Smrg      done
250037eb1ca1Smrg    } |
250137eb1ca1Smrg    sed '1d
250237eb1ca1Smrg      /^When reporting/,/^Report/{
250337eb1ca1Smrg	H
250437eb1ca1Smrg	d
250537eb1ca1Smrg      }
250637eb1ca1Smrg      $x
250737eb1ca1Smrg      /information about other modes/d
250837eb1ca1Smrg      /more detailed .*MODE/d
250937eb1ca1Smrg      s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
251037eb1ca1Smrg  fi
251137eb1ca1Smrg  exit $?
251237eb1ca1Smrgfi
2513c43cc173Smrg
2514c43cc173Smrg
2515c27c18e8Smrg# func_mode_execute arg...
2516c27c18e8Smrgfunc_mode_execute ()
2517c27c18e8Smrg{
2518c27c18e8Smrg    $opt_debug
2519c27c18e8Smrg    # The first argument is the command name.
2520c27c18e8Smrg    cmd="$nonopt"
2521c27c18e8Smrg    test -z "$cmd" && \
2522c27c18e8Smrg      func_fatal_help "you must specify a COMMAND"
2523c43cc173Smrg
2524c27c18e8Smrg    # Handle -dlopen flags immediately.
2525b789ec8aSmrg    for file in $opt_dlopen; do
2526c27c18e8Smrg      test -f "$file" \
2527c27c18e8Smrg	|| func_fatal_help "\`$file' is not a file"
2528c43cc173Smrg
2529c27c18e8Smrg      dir=
2530c27c18e8Smrg      case $file in
2531c27c18e8Smrg      *.la)
2532b789ec8aSmrg	func_resolve_sysroot "$file"
2533b789ec8aSmrg	file=$func_resolve_sysroot_result
2534b789ec8aSmrg
2535c27c18e8Smrg	# Check to see that this really is a libtool archive.
2536c27c18e8Smrg	func_lalib_unsafe_p "$file" \
2537c27c18e8Smrg	  || func_fatal_help "\`$lib' is not a valid libtool archive"
2538c43cc173Smrg
2539c27c18e8Smrg	# Read the libtool library.
2540c27c18e8Smrg	dlname=
2541c27c18e8Smrg	library_names=
2542c27c18e8Smrg	func_source "$file"
2543c43cc173Smrg
2544c27c18e8Smrg	# Skip this library if it cannot be dlopened.
2545c27c18e8Smrg	if test -z "$dlname"; then
2546c27c18e8Smrg	  # Warn if it was a shared library.
2547c27c18e8Smrg	  test -n "$library_names" && \
2548c27c18e8Smrg	    func_warning "\`$file' was not linked with \`-export-dynamic'"
2549c27c18e8Smrg	  continue
2550c27c18e8Smrg	fi
2551c43cc173Smrg
2552c27c18e8Smrg	func_dirname "$file" "" "."
2553c27c18e8Smrg	dir="$func_dirname_result"
2554c43cc173Smrg
2555c27c18e8Smrg	if test -f "$dir/$objdir/$dlname"; then
2556b789ec8aSmrg	  func_append dir "/$objdir"
2557c27c18e8Smrg	else
2558c27c18e8Smrg	  if test ! -f "$dir/$dlname"; then
2559c27c18e8Smrg	    func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'"
2560c27c18e8Smrg	  fi
2561c27c18e8Smrg	fi
2562c43cc173Smrg	;;
2563c43cc173Smrg
2564c27c18e8Smrg      *.lo)
2565c27c18e8Smrg	# Just add the directory containing the .lo file.
2566c27c18e8Smrg	func_dirname "$file" "" "."
2567c27c18e8Smrg	dir="$func_dirname_result"
2568c43cc173Smrg	;;
2569c43cc173Smrg
2570c27c18e8Smrg      *)
2571c27c18e8Smrg	func_warning "\`-dlopen' is ignored for non-libtool libraries and objects"
2572c43cc173Smrg	continue
2573c43cc173Smrg	;;
2574c27c18e8Smrg      esac
2575c43cc173Smrg
2576c27c18e8Smrg      # Get the absolute pathname.
2577c27c18e8Smrg      absdir=`cd "$dir" && pwd`
2578c27c18e8Smrg      test -n "$absdir" && dir="$absdir"
2579c43cc173Smrg
2580c27c18e8Smrg      # Now add the directory to shlibpath_var.
2581c27c18e8Smrg      if eval "test -z \"\$$shlibpath_var\""; then
2582c27c18e8Smrg	eval "$shlibpath_var=\"\$dir\""
2583c27c18e8Smrg      else
2584c27c18e8Smrg	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
2585c27c18e8Smrg      fi
2586c27c18e8Smrg    done
2587c43cc173Smrg
2588c27c18e8Smrg    # This variable tells wrapper scripts just to set shlibpath_var
2589c27c18e8Smrg    # rather than running their programs.
2590c27c18e8Smrg    libtool_execute_magic="$magic"
2591c43cc173Smrg
2592c27c18e8Smrg    # Check if any of the arguments is a wrapper script.
2593c27c18e8Smrg    args=
2594c27c18e8Smrg    for file
2595c27c18e8Smrg    do
2596c27c18e8Smrg      case $file in
259737eb1ca1Smrg      -* | *.la | *.lo ) ;;
2598c27c18e8Smrg      *)
2599c27c18e8Smrg	# Do a test to see if this is really a libtool program.
2600c27c18e8Smrg	if func_ltwrapper_script_p "$file"; then
2601c27c18e8Smrg	  func_source "$file"
2602c27c18e8Smrg	  # Transform arg to wrapped name.
2603c27c18e8Smrg	  file="$progdir/$program"
2604c27c18e8Smrg	elif func_ltwrapper_executable_p "$file"; then
2605c27c18e8Smrg	  func_ltwrapper_scriptname "$file"
2606c27c18e8Smrg	  func_source "$func_ltwrapper_scriptname_result"
2607c27c18e8Smrg	  # Transform arg to wrapped name.
2608c27c18e8Smrg	  file="$progdir/$program"
2609c27c18e8Smrg	fi
2610c27c18e8Smrg	;;
2611c27c18e8Smrg      esac
2612c27c18e8Smrg      # Quote arguments (to preserve shell metacharacters).
2613b789ec8aSmrg      func_append_quoted args "$file"
2614c27c18e8Smrg    done
2615c43cc173Smrg
2616c27c18e8Smrg    if test "X$opt_dry_run" = Xfalse; then
2617c27c18e8Smrg      if test -n "$shlibpath_var"; then
2618c27c18e8Smrg	# Export the shlibpath_var.
2619c27c18e8Smrg	eval "export $shlibpath_var"
2620c27c18e8Smrg      fi
2621c43cc173Smrg
2622c27c18e8Smrg      # Restore saved environment variables
2623c27c18e8Smrg      for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
2624c27c18e8Smrg      do
2625c27c18e8Smrg	eval "if test \"\${save_$lt_var+set}\" = set; then
2626c27c18e8Smrg                $lt_var=\$save_$lt_var; export $lt_var
2627c43cc173Smrg	      else
2628c27c18e8Smrg		$lt_unset $lt_var
2629c27c18e8Smrg	      fi"
2630c27c18e8Smrg      done
2631c43cc173Smrg
2632c27c18e8Smrg      # Now prepare to actually exec the command.
2633c27c18e8Smrg      exec_cmd="\$cmd$args"
2634c27c18e8Smrg    else
2635c27c18e8Smrg      # Display what would be done.
2636c27c18e8Smrg      if test -n "$shlibpath_var"; then
2637c27c18e8Smrg	eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
263837eb1ca1Smrg	echo "export $shlibpath_var"
2639c27c18e8Smrg      fi
2640c27c18e8Smrg      $ECHO "$cmd$args"
2641c27c18e8Smrg      exit $EXIT_SUCCESS
2642c27c18e8Smrg    fi
2643c27c18e8Smrg}
2644c43cc173Smrg
2645b789ec8aSmrgtest "$opt_mode" = execute && func_mode_execute ${1+"$@"}
2646c43cc173Smrg
2647c43cc173Smrg
2648c27c18e8Smrg# func_mode_finish arg...
2649c27c18e8Smrgfunc_mode_finish ()
2650c27c18e8Smrg{
2651c27c18e8Smrg    $opt_debug
2652b789ec8aSmrg    libs=
2653b789ec8aSmrg    libdirs=
2654c27c18e8Smrg    admincmds=
2655c43cc173Smrg
2656b789ec8aSmrg    for opt in "$nonopt" ${1+"$@"}
2657b789ec8aSmrg    do
2658b789ec8aSmrg      if test -d "$opt"; then
2659b789ec8aSmrg	func_append libdirs " $opt"
2660b789ec8aSmrg
2661b789ec8aSmrg      elif test -f "$opt"; then
2662b789ec8aSmrg	if func_lalib_unsafe_p "$opt"; then
2663b789ec8aSmrg	  func_append libs " $opt"
2664b789ec8aSmrg	else
2665b789ec8aSmrg	  func_warning "\`$opt' is not a valid libtool archive"
2666b789ec8aSmrg	fi
2667b789ec8aSmrg
2668b789ec8aSmrg      else
2669b789ec8aSmrg	func_fatal_error "invalid argument \`$opt'"
2670b789ec8aSmrg      fi
2671b789ec8aSmrg    done
2672b789ec8aSmrg
2673b789ec8aSmrg    if test -n "$libs"; then
2674b789ec8aSmrg      if test -n "$lt_sysroot"; then
2675b789ec8aSmrg        sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"`
2676b789ec8aSmrg        sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;"
2677b789ec8aSmrg      else
2678b789ec8aSmrg        sysroot_cmd=
2679b789ec8aSmrg      fi
2680b789ec8aSmrg
2681b789ec8aSmrg      # Remove sysroot references
2682b789ec8aSmrg      if $opt_dry_run; then
2683b789ec8aSmrg        for lib in $libs; do
2684b789ec8aSmrg          echo "removing references to $lt_sysroot and \`=' prefixes from $lib"
2685b789ec8aSmrg        done
2686b789ec8aSmrg      else
2687b789ec8aSmrg        tmpdir=`func_mktempdir`
2688b789ec8aSmrg        for lib in $libs; do
2689b789ec8aSmrg	  sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
2690b789ec8aSmrg	    > $tmpdir/tmp-la
2691b789ec8aSmrg	  mv -f $tmpdir/tmp-la $lib
2692b789ec8aSmrg	done
2693b789ec8aSmrg        ${RM}r "$tmpdir"
2694b789ec8aSmrg      fi
2695b789ec8aSmrg    fi
2696c43cc173Smrg
2697b789ec8aSmrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
2698c27c18e8Smrg      for libdir in $libdirs; do
2699c27c18e8Smrg	if test -n "$finish_cmds"; then
2700c27c18e8Smrg	  # Do each command in the finish commands.
2701c27c18e8Smrg	  func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
2702c27c18e8Smrg'"$cmd"'"'
2703c43cc173Smrg	fi
2704c27c18e8Smrg	if test -n "$finish_eval"; then
2705c27c18e8Smrg	  # Do the single finish_eval.
2706c27c18e8Smrg	  eval cmds=\"$finish_eval\"
2707b789ec8aSmrg	  $opt_dry_run || eval "$cmds" || func_append admincmds "
2708c27c18e8Smrg       $cmds"
2709c27c18e8Smrg	fi
2710c27c18e8Smrg      done
2711c27c18e8Smrg    fi
2712c43cc173Smrg
2713c27c18e8Smrg    # Exit here if they wanted silent mode.
2714c27c18e8Smrg    $opt_silent && exit $EXIT_SUCCESS
2715c43cc173Smrg
2716b789ec8aSmrg    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
2717b789ec8aSmrg      echo "----------------------------------------------------------------------"
2718b789ec8aSmrg      echo "Libraries have been installed in:"
2719b789ec8aSmrg      for libdir in $libdirs; do
2720b789ec8aSmrg	$ECHO "   $libdir"
2721b789ec8aSmrg      done
2722b789ec8aSmrg      echo
2723b789ec8aSmrg      echo "If you ever happen to want to link against installed libraries"
2724b789ec8aSmrg      echo "in a given directory, LIBDIR, you must either use libtool, and"
2725b789ec8aSmrg      echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
2726b789ec8aSmrg      echo "flag during linking and do at least one of the following:"
2727b789ec8aSmrg      if test -n "$shlibpath_var"; then
2728b789ec8aSmrg	echo "   - add LIBDIR to the \`$shlibpath_var' environment variable"
2729b789ec8aSmrg	echo "     during execution"
2730b789ec8aSmrg      fi
2731b789ec8aSmrg      if test -n "$runpath_var"; then
2732b789ec8aSmrg	echo "   - add LIBDIR to the \`$runpath_var' environment variable"
2733b789ec8aSmrg	echo "     during linking"
2734b789ec8aSmrg      fi
2735b789ec8aSmrg      if test -n "$hardcode_libdir_flag_spec"; then
2736b789ec8aSmrg	libdir=LIBDIR
2737b789ec8aSmrg	eval flag=\"$hardcode_libdir_flag_spec\"
2738c43cc173Smrg
2739b789ec8aSmrg	$ECHO "   - use the \`$flag' linker flag"
2740b789ec8aSmrg      fi
2741b789ec8aSmrg      if test -n "$admincmds"; then
2742b789ec8aSmrg	$ECHO "   - have your system administrator run these commands:$admincmds"
2743b789ec8aSmrg      fi
2744b789ec8aSmrg      if test -f /etc/ld.so.conf; then
2745b789ec8aSmrg	echo "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
2746b789ec8aSmrg      fi
2747b789ec8aSmrg      echo
2748c27c18e8Smrg
2749b789ec8aSmrg      echo "See any operating system documentation about shared libraries for"
2750b789ec8aSmrg      case $host in
2751b789ec8aSmrg	solaris2.[6789]|solaris2.1[0-9])
2752b789ec8aSmrg	  echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
2753b789ec8aSmrg	  echo "pages."
2754b789ec8aSmrg	  ;;
2755b789ec8aSmrg	*)
2756b789ec8aSmrg	  echo "more information, such as the ld(1) and ld.so(8) manual pages."
2757b789ec8aSmrg	  ;;
2758b789ec8aSmrg      esac
2759b789ec8aSmrg      echo "----------------------------------------------------------------------"
2760b789ec8aSmrg    fi
2761c27c18e8Smrg    exit $EXIT_SUCCESS
2762c27c18e8Smrg}
2763c27c18e8Smrg
2764b789ec8aSmrgtest "$opt_mode" = finish && func_mode_finish ${1+"$@"}
2765c27c18e8Smrg
2766c27c18e8Smrg
2767c27c18e8Smrg# func_mode_install arg...
2768c27c18e8Smrgfunc_mode_install ()
2769c27c18e8Smrg{
2770c27c18e8Smrg    $opt_debug
2771c27c18e8Smrg    # There may be an optional sh(1) argument at the beginning of
2772c27c18e8Smrg    # install_prog (especially on Windows NT).
2773c27c18e8Smrg    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
2774c27c18e8Smrg       # Allow the use of GNU shtool's install command.
277537eb1ca1Smrg       case $nonopt in *shtool*) :;; *) false;; esac; then
2776c27c18e8Smrg      # Aesthetically quote it.
2777c27c18e8Smrg      func_quote_for_eval "$nonopt"
2778c27c18e8Smrg      install_prog="$func_quote_for_eval_result "
2779c27c18e8Smrg      arg=$1
2780c27c18e8Smrg      shift
2781c27c18e8Smrg    else
2782c27c18e8Smrg      install_prog=
2783c27c18e8Smrg      arg=$nonopt
2784c27c18e8Smrg    fi
2785c27c18e8Smrg
2786c27c18e8Smrg    # The real first argument should be the name of the installation program.
2787c27c18e8Smrg    # Aesthetically quote it.
2788c27c18e8Smrg    func_quote_for_eval "$arg"
2789b789ec8aSmrg    func_append install_prog "$func_quote_for_eval_result"
279037eb1ca1Smrg    install_shared_prog=$install_prog
279137eb1ca1Smrg    case " $install_prog " in
279237eb1ca1Smrg      *[\\\ /]cp\ *) install_cp=: ;;
279337eb1ca1Smrg      *) install_cp=false ;;
279437eb1ca1Smrg    esac
2795c27c18e8Smrg
2796c27c18e8Smrg    # We need to accept at least all the BSD install flags.
2797c27c18e8Smrg    dest=
2798c27c18e8Smrg    files=
2799c27c18e8Smrg    opts=
2800c27c18e8Smrg    prev=
2801c27c18e8Smrg    install_type=
2802c27c18e8Smrg    isdir=no
2803c27c18e8Smrg    stripme=
280437eb1ca1Smrg    no_mode=:
2805c27c18e8Smrg    for arg
2806c27c18e8Smrg    do
280737eb1ca1Smrg      arg2=
2808c27c18e8Smrg      if test -n "$dest"; then
2809b789ec8aSmrg	func_append files " $dest"
2810c27c18e8Smrg	dest=$arg
2811c27c18e8Smrg	continue
2812c27c18e8Smrg      fi
2813c27c18e8Smrg
2814c27c18e8Smrg      case $arg in
2815c27c18e8Smrg      -d) isdir=yes ;;
2816c27c18e8Smrg      -f)
281737eb1ca1Smrg	if $install_cp; then :; else
281837eb1ca1Smrg	  prev=$arg
281937eb1ca1Smrg	fi
2820c27c18e8Smrg	;;
2821c27c18e8Smrg      -g | -m | -o)
2822c27c18e8Smrg	prev=$arg
2823c27c18e8Smrg	;;
2824c27c18e8Smrg      -s)
2825c27c18e8Smrg	stripme=" -s"
2826c27c18e8Smrg	continue
2827c27c18e8Smrg	;;
2828c27c18e8Smrg      -*)
2829c27c18e8Smrg	;;
2830c27c18e8Smrg      *)
2831c27c18e8Smrg	# If the previous option needed an argument, then skip it.
2832c27c18e8Smrg	if test -n "$prev"; then
283337eb1ca1Smrg	  if test "x$prev" = x-m && test -n "$install_override_mode"; then
283437eb1ca1Smrg	    arg2=$install_override_mode
283537eb1ca1Smrg	    no_mode=false
283637eb1ca1Smrg	  fi
2837c43cc173Smrg	  prev=
2838c43cc173Smrg	else
2839c27c18e8Smrg	  dest=$arg
2840c27c18e8Smrg	  continue
2841c43cc173Smrg	fi
2842c43cc173Smrg	;;
2843c27c18e8Smrg      esac
2844c43cc173Smrg
2845c27c18e8Smrg      # Aesthetically quote the argument.
2846c27c18e8Smrg      func_quote_for_eval "$arg"
2847b789ec8aSmrg      func_append install_prog " $func_quote_for_eval_result"
284837eb1ca1Smrg      if test -n "$arg2"; then
284937eb1ca1Smrg	func_quote_for_eval "$arg2"
285037eb1ca1Smrg      fi
2851b789ec8aSmrg      func_append install_shared_prog " $func_quote_for_eval_result"
2852c27c18e8Smrg    done
2853c43cc173Smrg
2854c27c18e8Smrg    test -z "$install_prog" && \
2855c27c18e8Smrg      func_fatal_help "you must specify an install program"
2856c43cc173Smrg
2857c27c18e8Smrg    test -n "$prev" && \
2858c27c18e8Smrg      func_fatal_help "the \`$prev' option requires an argument"
2859c43cc173Smrg
286037eb1ca1Smrg    if test -n "$install_override_mode" && $no_mode; then
286137eb1ca1Smrg      if $install_cp; then :; else
286237eb1ca1Smrg	func_quote_for_eval "$install_override_mode"
2863b789ec8aSmrg	func_append install_shared_prog " -m $func_quote_for_eval_result"
286437eb1ca1Smrg      fi
286537eb1ca1Smrg    fi
286637eb1ca1Smrg
2867c27c18e8Smrg    if test -z "$files"; then
2868c27c18e8Smrg      if test -z "$dest"; then
2869c27c18e8Smrg	func_fatal_help "no file or destination specified"
2870c27c18e8Smrg      else
2871c27c18e8Smrg	func_fatal_help "you must specify a destination"
2872c27c18e8Smrg      fi
2873c43cc173Smrg    fi
2874c43cc173Smrg
2875c27c18e8Smrg    # Strip any trailing slash from the destination.
2876c27c18e8Smrg    func_stripname '' '/' "$dest"
2877c27c18e8Smrg    dest=$func_stripname_result
2878c43cc173Smrg
2879c27c18e8Smrg    # Check to see that the destination is a directory.
2880c27c18e8Smrg    test -d "$dest" && isdir=yes
2881c27c18e8Smrg    if test "$isdir" = yes; then
2882c27c18e8Smrg      destdir="$dest"
2883c27c18e8Smrg      destname=
2884c43cc173Smrg    else
2885c27c18e8Smrg      func_dirname_and_basename "$dest" "" "."
2886c27c18e8Smrg      destdir="$func_dirname_result"
2887c27c18e8Smrg      destname="$func_basename_result"
2888c43cc173Smrg
2889c27c18e8Smrg      # Not a directory, so check to see that there is only one file specified.
2890c27c18e8Smrg      set dummy $files; shift
2891c27c18e8Smrg      test "$#" -gt 1 && \
2892c27c18e8Smrg	func_fatal_help "\`$dest' is not a directory"
2893c43cc173Smrg    fi
2894c27c18e8Smrg    case $destdir in
2895c27c18e8Smrg    [\\/]* | [A-Za-z]:[\\/]*) ;;
2896c43cc173Smrg    *)
2897c27c18e8Smrg      for file in $files; do
2898c27c18e8Smrg	case $file in
2899c27c18e8Smrg	*.lo) ;;
2900c27c18e8Smrg	*)
2901c27c18e8Smrg	  func_fatal_help "\`$destdir' must be an absolute directory name"
2902c27c18e8Smrg	  ;;
2903c27c18e8Smrg	esac
2904c27c18e8Smrg      done
2905c43cc173Smrg      ;;
2906c43cc173Smrg    esac
2907c43cc173Smrg
2908c27c18e8Smrg    # This variable tells wrapper scripts just to set variables rather
2909c27c18e8Smrg    # than running their programs.
2910c27c18e8Smrg    libtool_install_magic="$magic"
2911c43cc173Smrg
2912c27c18e8Smrg    staticlibs=
2913c27c18e8Smrg    future_libdirs=
2914c27c18e8Smrg    current_libdirs=
2915c27c18e8Smrg    for file in $files; do
2916c43cc173Smrg
2917c27c18e8Smrg      # Do each installation.
2918c27c18e8Smrg      case $file in
2919c27c18e8Smrg      *.$libext)
2920c27c18e8Smrg	# Do the static libraries later.
2921b789ec8aSmrg	func_append staticlibs " $file"
2922c27c18e8Smrg	;;
2923c27c18e8Smrg
2924c27c18e8Smrg      *.la)
2925b789ec8aSmrg	func_resolve_sysroot "$file"
2926b789ec8aSmrg	file=$func_resolve_sysroot_result
2927b789ec8aSmrg
2928c27c18e8Smrg	# Check to see that this really is a libtool archive.
2929c27c18e8Smrg	func_lalib_unsafe_p "$file" \
2930c27c18e8Smrg	  || func_fatal_help "\`$file' is not a valid libtool archive"
2931c27c18e8Smrg
2932c27c18e8Smrg	library_names=
2933c27c18e8Smrg	old_library=
2934c27c18e8Smrg	relink_command=
2935c27c18e8Smrg	func_source "$file"
2936c27c18e8Smrg
2937c27c18e8Smrg	# Add the libdir to current_libdirs if it is the destination.
2938c27c18e8Smrg	if test "X$destdir" = "X$libdir"; then
2939c27c18e8Smrg	  case "$current_libdirs " in
2940c27c18e8Smrg	  *" $libdir "*) ;;
2941b789ec8aSmrg	  *) func_append current_libdirs " $libdir" ;;
2942c43cc173Smrg	  esac
2943c27c18e8Smrg	else
2944c27c18e8Smrg	  # Note the libdir as a future libdir.
2945c27c18e8Smrg	  case "$future_libdirs " in
2946c27c18e8Smrg	  *" $libdir "*) ;;
2947b789ec8aSmrg	  *) func_append future_libdirs " $libdir" ;;
2948c27c18e8Smrg	  esac
2949c27c18e8Smrg	fi
2950c43cc173Smrg
2951c27c18e8Smrg	func_dirname "$file" "/" ""
2952c27c18e8Smrg	dir="$func_dirname_result"
2953b789ec8aSmrg	func_append dir "$objdir"
2954c27c18e8Smrg
2955c27c18e8Smrg	if test -n "$relink_command"; then
2956c27c18e8Smrg	  # Determine the prefix the user has applied to our future dir.
295737eb1ca1Smrg	  inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
2958c27c18e8Smrg
2959c27c18e8Smrg	  # Don't allow the user to place us outside of our expected
2960c27c18e8Smrg	  # location b/c this prevents finding dependent libraries that
2961c27c18e8Smrg	  # are installed to the same prefix.
2962c27c18e8Smrg	  # At present, this check doesn't affect windows .dll's that
2963c27c18e8Smrg	  # are installed into $libdir/../bin (currently, that works fine)
2964c27c18e8Smrg	  # but it's something to keep an eye on.
2965c27c18e8Smrg	  test "$inst_prefix_dir" = "$destdir" && \
2966c27c18e8Smrg	    func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
2967c27c18e8Smrg
2968c27c18e8Smrg	  if test -n "$inst_prefix_dir"; then
2969c27c18e8Smrg	    # Stick the inst_prefix_dir data into the link command.
297037eb1ca1Smrg	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
2971c27c18e8Smrg	  else
297237eb1ca1Smrg	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
2973c27c18e8Smrg	  fi
2974c27c18e8Smrg
2975c27c18e8Smrg	  func_warning "relinking \`$file'"
2976c27c18e8Smrg	  func_show_eval "$relink_command" \
2977c27c18e8Smrg	    'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
2978c27c18e8Smrg	fi
2979c27c18e8Smrg
2980c27c18e8Smrg	# See the names of the shared library.
2981c27c18e8Smrg	set dummy $library_names; shift
2982c27c18e8Smrg	if test -n "$1"; then
2983c27c18e8Smrg	  realname="$1"
2984c27c18e8Smrg	  shift
2985c27c18e8Smrg
2986c27c18e8Smrg	  srcname="$realname"
2987c27c18e8Smrg	  test -n "$relink_command" && srcname="$realname"T
2988c27c18e8Smrg
2989c27c18e8Smrg	  # Install the shared library and build the symlinks.
299037eb1ca1Smrg	  func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
2991c27c18e8Smrg	      'exit $?'
2992c27c18e8Smrg	  tstripme="$stripme"
2993c27c18e8Smrg	  case $host_os in
2994c27c18e8Smrg	  cygwin* | mingw* | pw32* | cegcc*)
2995c27c18e8Smrg	    case $realname in
2996c27c18e8Smrg	    *.dll.a)
2997c27c18e8Smrg	      tstripme=""
2998c27c18e8Smrg	      ;;
2999c27c18e8Smrg	    esac
3000c43cc173Smrg	    ;;
3001c43cc173Smrg	  esac
3002c27c18e8Smrg	  if test -n "$tstripme" && test -n "$striplib"; then
3003c27c18e8Smrg	    func_show_eval "$striplib $destdir/$realname" 'exit $?'
3004c43cc173Smrg	  fi
3005c27c18e8Smrg
3006c27c18e8Smrg	  if test "$#" -gt 0; then
3007c27c18e8Smrg	    # Delete the old symlinks, and create new ones.
3008c27c18e8Smrg	    # Try `ln -sf' first, because the `ln' binary might depend on
3009c27c18e8Smrg	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
3010c27c18e8Smrg	    # so we also need to try rm && ln -s.
3011c27c18e8Smrg	    for linkname
3012c27c18e8Smrg	    do
3013c27c18e8Smrg	      test "$linkname" != "$realname" \
3014c27c18e8Smrg		&& func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
3015c43cc173Smrg	    done
3016c43cc173Smrg	  fi
3017c43cc173Smrg
3018c27c18e8Smrg	  # Do each command in the postinstall commands.
3019c27c18e8Smrg	  lib="$destdir/$realname"
3020c27c18e8Smrg	  func_execute_cmds "$postinstall_cmds" 'exit $?'
3021c43cc173Smrg	fi
3022c43cc173Smrg
3023c27c18e8Smrg	# Install the pseudo-library for information purposes.
3024c27c18e8Smrg	func_basename "$file"
3025c27c18e8Smrg	name="$func_basename_result"
3026c27c18e8Smrg	instname="$dir/$name"i
3027c27c18e8Smrg	func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
3028c43cc173Smrg
3029c27c18e8Smrg	# Maybe install the static library, too.
3030b789ec8aSmrg	test -n "$old_library" && func_append staticlibs " $dir/$old_library"
3031c27c18e8Smrg	;;
3032c43cc173Smrg
3033c27c18e8Smrg      *.lo)
3034c27c18e8Smrg	# Install (i.e. copy) a libtool object.
3035c43cc173Smrg
3036c27c18e8Smrg	# Figure out destination file name, if it wasn't already specified.
3037c27c18e8Smrg	if test -n "$destname"; then
3038c27c18e8Smrg	  destfile="$destdir/$destname"
3039c27c18e8Smrg	else
3040c27c18e8Smrg	  func_basename "$file"
3041c27c18e8Smrg	  destfile="$func_basename_result"
3042c27c18e8Smrg	  destfile="$destdir/$destfile"
3043c43cc173Smrg	fi
3044c43cc173Smrg
3045c27c18e8Smrg	# Deduce the name of the destination old-style object file.
3046c27c18e8Smrg	case $destfile in
3047c27c18e8Smrg	*.lo)
3048c27c18e8Smrg	  func_lo2o "$destfile"
3049c27c18e8Smrg	  staticdest=$func_lo2o_result
3050c27c18e8Smrg	  ;;
3051c27c18e8Smrg	*.$objext)
3052c27c18e8Smrg	  staticdest="$destfile"
3053c27c18e8Smrg	  destfile=
3054c27c18e8Smrg	  ;;
3055c27c18e8Smrg	*)
3056c27c18e8Smrg	  func_fatal_help "cannot copy a libtool object to \`$destfile'"
3057c27c18e8Smrg	  ;;
3058c27c18e8Smrg	esac
3059c43cc173Smrg
3060c27c18e8Smrg	# Install the libtool object if requested.
3061c27c18e8Smrg	test -n "$destfile" && \
3062c27c18e8Smrg	  func_show_eval "$install_prog $file $destfile" 'exit $?'
3063c43cc173Smrg
3064c27c18e8Smrg	# Install the old object if enabled.
3065c27c18e8Smrg	if test "$build_old_libs" = yes; then
3066c27c18e8Smrg	  # Deduce the name of the old-style object file.
3067c27c18e8Smrg	  func_lo2o "$file"
3068c27c18e8Smrg	  staticobj=$func_lo2o_result
3069c27c18e8Smrg	  func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
3070c43cc173Smrg	fi
3071c27c18e8Smrg	exit $EXIT_SUCCESS
3072c27c18e8Smrg	;;
3073c43cc173Smrg
3074c27c18e8Smrg      *)
3075c27c18e8Smrg	# Figure out destination file name, if it wasn't already specified.
3076c27c18e8Smrg	if test -n "$destname"; then
3077c27c18e8Smrg	  destfile="$destdir/$destname"
3078c27c18e8Smrg	else
3079c27c18e8Smrg	  func_basename "$file"
3080c27c18e8Smrg	  destfile="$func_basename_result"
3081c27c18e8Smrg	  destfile="$destdir/$destfile"
3082c27c18e8Smrg	fi
3083c43cc173Smrg
3084c27c18e8Smrg	# If the file is missing, and there is a .exe on the end, strip it
3085c27c18e8Smrg	# because it is most likely a libtool script we actually want to
3086c27c18e8Smrg	# install
3087c27c18e8Smrg	stripped_ext=""
3088c27c18e8Smrg	case $file in
3089c27c18e8Smrg	  *.exe)
3090c27c18e8Smrg	    if test ! -f "$file"; then
3091c27c18e8Smrg	      func_stripname '' '.exe' "$file"
3092c27c18e8Smrg	      file=$func_stripname_result
3093c27c18e8Smrg	      stripped_ext=".exe"
3094c27c18e8Smrg	    fi
3095c27c18e8Smrg	    ;;
3096c27c18e8Smrg	esac
3097c27c18e8Smrg
3098c27c18e8Smrg	# Do a test to see if this is really a libtool program.
3099c27c18e8Smrg	case $host in
3100c27c18e8Smrg	*cygwin* | *mingw*)
3101c27c18e8Smrg	    if func_ltwrapper_executable_p "$file"; then
3102c27c18e8Smrg	      func_ltwrapper_scriptname "$file"
3103c27c18e8Smrg	      wrapper=$func_ltwrapper_scriptname_result
3104c27c18e8Smrg	    else
3105c27c18e8Smrg	      func_stripname '' '.exe' "$file"
3106c27c18e8Smrg	      wrapper=$func_stripname_result
3107c27c18e8Smrg	    fi
3108c27c18e8Smrg	    ;;
3109c43cc173Smrg	*)
3110c27c18e8Smrg	    wrapper=$file
3111c27c18e8Smrg	    ;;
3112c27c18e8Smrg	esac
3113c27c18e8Smrg	if func_ltwrapper_script_p "$wrapper"; then
3114c27c18e8Smrg	  notinst_deplibs=
3115c27c18e8Smrg	  relink_command=
3116c27c18e8Smrg
3117c27c18e8Smrg	  func_source "$wrapper"
3118c27c18e8Smrg
3119c27c18e8Smrg	  # Check the variables that should have been set.
3120c27c18e8Smrg	  test -z "$generated_by_libtool_version" && \
3121c27c18e8Smrg	    func_fatal_error "invalid libtool wrapper script \`$wrapper'"
3122c27c18e8Smrg
3123c27c18e8Smrg	  finalize=yes
3124c27c18e8Smrg	  for lib in $notinst_deplibs; do
3125c27c18e8Smrg	    # Check to see that each library is installed.
3126c27c18e8Smrg	    libdir=
3127c27c18e8Smrg	    if test -f "$lib"; then
3128c27c18e8Smrg	      func_source "$lib"
3129c27c18e8Smrg	    fi
313037eb1ca1Smrg	    libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test
3131c27c18e8Smrg	    if test -n "$libdir" && test ! -f "$libfile"; then
3132c27c18e8Smrg	      func_warning "\`$lib' has not been installed in \`$libdir'"
3133c27c18e8Smrg	      finalize=no
3134c27c18e8Smrg	    fi
3135c27c18e8Smrg	  done
3136c27c18e8Smrg
3137c27c18e8Smrg	  relink_command=
3138c27c18e8Smrg	  func_source "$wrapper"
3139c27c18e8Smrg
3140c27c18e8Smrg	  outputname=
3141c27c18e8Smrg	  if test "$fast_install" = no && test -n "$relink_command"; then
3142c27c18e8Smrg	    $opt_dry_run || {
3143c27c18e8Smrg	      if test "$finalize" = yes; then
3144c27c18e8Smrg	        tmpdir=`func_mktempdir`
3145c27c18e8Smrg		func_basename "$file$stripped_ext"
3146c27c18e8Smrg		file="$func_basename_result"
3147c27c18e8Smrg	        outputname="$tmpdir/$file"
3148c27c18e8Smrg	        # Replace the output file specification.
314937eb1ca1Smrg	        relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
3150c27c18e8Smrg
3151c27c18e8Smrg	        $opt_silent || {
3152c27c18e8Smrg	          func_quote_for_expand "$relink_command"
3153c27c18e8Smrg		  eval "func_echo $func_quote_for_expand_result"
3154c27c18e8Smrg	        }
3155c27c18e8Smrg	        if eval "$relink_command"; then :
3156c27c18e8Smrg	          else
3157c27c18e8Smrg		  func_error "error: relink \`$file' with the above command before installing it"
3158c27c18e8Smrg		  $opt_dry_run || ${RM}r "$tmpdir"
3159c27c18e8Smrg		  continue
3160c27c18e8Smrg	        fi
3161c27c18e8Smrg	        file="$outputname"
3162c27c18e8Smrg	      else
3163c27c18e8Smrg	        func_warning "cannot relink \`$file'"
3164c27c18e8Smrg	      fi
3165c27c18e8Smrg	    }
3166c27c18e8Smrg	  else
3167c27c18e8Smrg	    # Install the binary that we compiled earlier.
316837eb1ca1Smrg	    file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
3169c43cc173Smrg	  fi
3170c27c18e8Smrg	fi
3171c27c18e8Smrg
3172c27c18e8Smrg	# remove .exe since cygwin /usr/bin/install will append another
3173c27c18e8Smrg	# one anyway
3174c27c18e8Smrg	case $install_prog,$host in
3175c27c18e8Smrg	*/usr/bin/install*,*cygwin*)
3176c27c18e8Smrg	  case $file:$destfile in
3177c27c18e8Smrg	  *.exe:*.exe)
3178c27c18e8Smrg	    # this is ok
3179c27c18e8Smrg	    ;;
3180c27c18e8Smrg	  *.exe:*)
3181c27c18e8Smrg	    destfile=$destfile.exe
3182c27c18e8Smrg	    ;;
3183c27c18e8Smrg	  *:*.exe)
3184c27c18e8Smrg	    func_stripname '' '.exe' "$destfile"
3185c27c18e8Smrg	    destfile=$func_stripname_result
3186c27c18e8Smrg	    ;;
3187c27c18e8Smrg	  esac
3188c43cc173Smrg	  ;;
3189c43cc173Smrg	esac
3190c27c18e8Smrg	func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
3191c27c18e8Smrg	$opt_dry_run || if test -n "$outputname"; then
3192c27c18e8Smrg	  ${RM}r "$tmpdir"
3193c27c18e8Smrg	fi
3194c27c18e8Smrg	;;
3195c27c18e8Smrg      esac
3196c27c18e8Smrg    done
3197c43cc173Smrg
3198c27c18e8Smrg    for file in $staticlibs; do
3199c27c18e8Smrg      func_basename "$file"
3200c27c18e8Smrg      name="$func_basename_result"
3201c27c18e8Smrg
3202c27c18e8Smrg      # Set up the ranlib parameters.
3203c27c18e8Smrg      oldlib="$destdir/$name"
3204c27c18e8Smrg
3205c27c18e8Smrg      func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
3206c27c18e8Smrg
3207c27c18e8Smrg      if test -n "$stripme" && test -n "$old_striplib"; then
3208c27c18e8Smrg	func_show_eval "$old_striplib $oldlib" 'exit $?'
3209c27c18e8Smrg      fi
3210c27c18e8Smrg
3211c27c18e8Smrg      # Do each command in the postinstall commands.
3212c27c18e8Smrg      func_execute_cmds "$old_postinstall_cmds" 'exit $?'
3213c27c18e8Smrg    done
3214c27c18e8Smrg
3215c27c18e8Smrg    test -n "$future_libdirs" && \
3216c27c18e8Smrg      func_warning "remember to run \`$progname --finish$future_libdirs'"
3217c27c18e8Smrg
3218c27c18e8Smrg    if test -n "$current_libdirs"; then
3219c27c18e8Smrg      # Maybe just do a dry run.
3220c27c18e8Smrg      $opt_dry_run && current_libdirs=" -n$current_libdirs"
3221c27c18e8Smrg      exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
3222c27c18e8Smrg    else
3223c27c18e8Smrg      exit $EXIT_SUCCESS
3224c27c18e8Smrg    fi
3225c27c18e8Smrg}
3226c27c18e8Smrg
3227b789ec8aSmrgtest "$opt_mode" = install && func_mode_install ${1+"$@"}
3228c27c18e8Smrg
3229c27c18e8Smrg
3230c27c18e8Smrg# func_generate_dlsyms outputname originator pic_p
3231c27c18e8Smrg# Extract symbols from dlprefiles and create ${outputname}S.o with
3232c27c18e8Smrg# a dlpreopen symbol table.
3233c27c18e8Smrgfunc_generate_dlsyms ()
3234c27c18e8Smrg{
3235c27c18e8Smrg    $opt_debug
3236c27c18e8Smrg    my_outputname="$1"
3237c27c18e8Smrg    my_originator="$2"
3238c27c18e8Smrg    my_pic_p="${3-no}"
3239c27c18e8Smrg    my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'`
3240c27c18e8Smrg    my_dlsyms=
3241c27c18e8Smrg
3242c27c18e8Smrg    if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
3243c27c18e8Smrg      if test -n "$NM" && test -n "$global_symbol_pipe"; then
3244c27c18e8Smrg	my_dlsyms="${my_outputname}S.c"
3245c27c18e8Smrg      else
3246c27c18e8Smrg	func_error "not configured to extract global symbols from dlpreopened files"
3247c27c18e8Smrg      fi
3248c27c18e8Smrg    fi
3249c27c18e8Smrg
3250c27c18e8Smrg    if test -n "$my_dlsyms"; then
3251c27c18e8Smrg      case $my_dlsyms in
3252c27c18e8Smrg      "") ;;
3253c27c18e8Smrg      *.c)
3254c27c18e8Smrg	# Discover the nlist of each of the dlfiles.
3255c27c18e8Smrg	nlist="$output_objdir/${my_outputname}.nm"
3256c27c18e8Smrg
3257c27c18e8Smrg	func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
3258c27c18e8Smrg
3259c27c18e8Smrg	# Parse the name list into a source file.
3260c27c18e8Smrg	func_verbose "creating $output_objdir/$my_dlsyms"
3261c27c18e8Smrg
3262c27c18e8Smrg	$opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
3263c27c18e8Smrg/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */
3264c27c18e8Smrg/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */
3265c27c18e8Smrg
3266c27c18e8Smrg#ifdef __cplusplus
3267c27c18e8Smrgextern \"C\" {
3268c27c18e8Smrg#endif
3269c27c18e8Smrg
327037eb1ca1Smrg#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
327137eb1ca1Smrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
327237eb1ca1Smrg#endif
327337eb1ca1Smrg
3274b789ec8aSmrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
3275b789ec8aSmrg#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
3276b789ec8aSmrg/* DATA imports from DLLs on WIN32 con't be const, because runtime
3277b789ec8aSmrg   relocations are performed -- see ld's documentation on pseudo-relocs.  */
3278b789ec8aSmrg# define LT_DLSYM_CONST
3279b789ec8aSmrg#elif defined(__osf__)
3280b789ec8aSmrg/* This system does not cope well with relocations in const data.  */
3281b789ec8aSmrg# define LT_DLSYM_CONST
3282b789ec8aSmrg#else
3283b789ec8aSmrg# define LT_DLSYM_CONST const
3284b789ec8aSmrg#endif
3285b789ec8aSmrg
3286c27c18e8Smrg/* External symbol declarations for the compiler. */\
3287c27c18e8Smrg"
3288c27c18e8Smrg
3289c27c18e8Smrg	if test "$dlself" = yes; then
3290c27c18e8Smrg	  func_verbose "generating symbol list for \`$output'"
3291c27c18e8Smrg
3292c27c18e8Smrg	  $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
3293c27c18e8Smrg
3294c27c18e8Smrg	  # Add our own program objects to the symbol list.
329537eb1ca1Smrg	  progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
3296c27c18e8Smrg	  for progfile in $progfiles; do
3297b789ec8aSmrg	    func_to_tool_file "$progfile" func_convert_file_msys_to_w32
3298b789ec8aSmrg	    func_verbose "extracting global C symbols from \`$func_to_tool_file_result'"
3299b789ec8aSmrg	    $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
3300c27c18e8Smrg	  done
3301c27c18e8Smrg
3302c27c18e8Smrg	  if test -n "$exclude_expsyms"; then
3303c27c18e8Smrg	    $opt_dry_run || {
3304c27c18e8Smrg	      eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
3305c27c18e8Smrg	      eval '$MV "$nlist"T "$nlist"'
3306c27c18e8Smrg	    }
3307c43cc173Smrg	  fi
3308c27c18e8Smrg
3309c27c18e8Smrg	  if test -n "$export_symbols_regex"; then
3310c27c18e8Smrg	    $opt_dry_run || {
3311c27c18e8Smrg	      eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
3312c27c18e8Smrg	      eval '$MV "$nlist"T "$nlist"'
3313c27c18e8Smrg	    }
3314c27c18e8Smrg	  fi
3315c27c18e8Smrg
3316c27c18e8Smrg	  # Prepare the list of exported symbols
3317c27c18e8Smrg	  if test -z "$export_symbols"; then
3318c27c18e8Smrg	    export_symbols="$output_objdir/$outputname.exp"
3319c27c18e8Smrg	    $opt_dry_run || {
3320c27c18e8Smrg	      $RM $export_symbols
3321c27c18e8Smrg	      eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
3322c27c18e8Smrg	      case $host in
3323c27c18e8Smrg	      *cygwin* | *mingw* | *cegcc* )
3324c27c18e8Smrg                eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
3325c27c18e8Smrg                eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
3326c27c18e8Smrg	        ;;
3327c27c18e8Smrg	      esac
3328c27c18e8Smrg	    }
3329c43cc173Smrg	  else
3330c27c18e8Smrg	    $opt_dry_run || {
3331c27c18e8Smrg	      eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
3332c27c18e8Smrg	      eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
3333c27c18e8Smrg	      eval '$MV "$nlist"T "$nlist"'
3334c27c18e8Smrg	      case $host in
333537eb1ca1Smrg	        *cygwin* | *mingw* | *cegcc* )
3336c27c18e8Smrg	          eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
3337c27c18e8Smrg	          eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
3338c27c18e8Smrg	          ;;
3339c27c18e8Smrg	      esac
3340c27c18e8Smrg	    }
3341c43cc173Smrg	  fi
3342c27c18e8Smrg	fi
3343c43cc173Smrg
3344c27c18e8Smrg	for dlprefile in $dlprefiles; do
3345c27c18e8Smrg	  func_verbose "extracting global C symbols from \`$dlprefile'"
3346c27c18e8Smrg	  func_basename "$dlprefile"
3347c27c18e8Smrg	  name="$func_basename_result"
3348b789ec8aSmrg          case $host in
3349b789ec8aSmrg	    *cygwin* | *mingw* | *cegcc* )
3350b789ec8aSmrg	      # if an import library, we need to obtain dlname
3351b789ec8aSmrg	      if func_win32_import_lib_p "$dlprefile"; then
3352b789ec8aSmrg	        func_tr_sh "$dlprefile"
3353b789ec8aSmrg	        eval "curr_lafile=\$libfile_$func_tr_sh_result"
3354b789ec8aSmrg	        dlprefile_dlbasename=""
3355b789ec8aSmrg	        if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
3356b789ec8aSmrg	          # Use subshell, to avoid clobbering current variable values
3357b789ec8aSmrg	          dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
3358b789ec8aSmrg	          if test -n "$dlprefile_dlname" ; then
3359b789ec8aSmrg	            func_basename "$dlprefile_dlname"
3360b789ec8aSmrg	            dlprefile_dlbasename="$func_basename_result"
3361b789ec8aSmrg	          else
3362b789ec8aSmrg	            # no lafile. user explicitly requested -dlpreopen <import library>.
3363b789ec8aSmrg	            $sharedlib_from_linklib_cmd "$dlprefile"
3364b789ec8aSmrg	            dlprefile_dlbasename=$sharedlib_from_linklib_result
3365b789ec8aSmrg	          fi
3366b789ec8aSmrg	        fi
3367b789ec8aSmrg	        $opt_dry_run || {
3368b789ec8aSmrg	          if test -n "$dlprefile_dlbasename" ; then
3369b789ec8aSmrg	            eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
3370b789ec8aSmrg	          else
3371b789ec8aSmrg	            func_warning "Could not compute DLL name from $name"
3372b789ec8aSmrg	            eval '$ECHO ": $name " >> "$nlist"'
3373b789ec8aSmrg	          fi
3374b789ec8aSmrg	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
3375b789ec8aSmrg	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe |
3376b789ec8aSmrg	            $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'"
3377b789ec8aSmrg	        }
3378b789ec8aSmrg	      else # not an import lib
3379b789ec8aSmrg	        $opt_dry_run || {
3380b789ec8aSmrg	          eval '$ECHO ": $name " >> "$nlist"'
3381b789ec8aSmrg	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
3382b789ec8aSmrg	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
3383b789ec8aSmrg	        }
3384b789ec8aSmrg	      fi
3385b789ec8aSmrg	    ;;
3386b789ec8aSmrg	    *)
3387b789ec8aSmrg	      $opt_dry_run || {
3388b789ec8aSmrg	        eval '$ECHO ": $name " >> "$nlist"'
3389b789ec8aSmrg	        func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
3390b789ec8aSmrg	        eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
3391b789ec8aSmrg	      }
3392b789ec8aSmrg	    ;;
3393b789ec8aSmrg          esac
3394c27c18e8Smrg	done
3395c27c18e8Smrg
3396c27c18e8Smrg	$opt_dry_run || {
3397c27c18e8Smrg	  # Make sure we have at least an empty file.
3398c27c18e8Smrg	  test -f "$nlist" || : > "$nlist"
3399c27c18e8Smrg
3400c27c18e8Smrg	  if test -n "$exclude_expsyms"; then
3401c27c18e8Smrg	    $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
3402c27c18e8Smrg	    $MV "$nlist"T "$nlist"
3403c43cc173Smrg	  fi
3404c27c18e8Smrg
3405c27c18e8Smrg	  # Try sorting and uniquifying the output.
3406c27c18e8Smrg	  if $GREP -v "^: " < "$nlist" |
3407c27c18e8Smrg	      if sort -k 3 </dev/null >/dev/null 2>&1; then
3408c27c18e8Smrg		sort -k 3
3409c27c18e8Smrg	      else
3410c27c18e8Smrg		sort +2
3411c27c18e8Smrg	      fi |
3412c27c18e8Smrg	      uniq > "$nlist"S; then
3413c27c18e8Smrg	    :
3414c43cc173Smrg	  else
3415c27c18e8Smrg	    $GREP -v "^: " < "$nlist" > "$nlist"S
3416c43cc173Smrg	  fi
3417c43cc173Smrg
3418c27c18e8Smrg	  if test -f "$nlist"S; then
3419c27c18e8Smrg	    eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
3420c43cc173Smrg	  else
342137eb1ca1Smrg	    echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
3422c43cc173Smrg	  fi
3423c43cc173Smrg
342437eb1ca1Smrg	  echo >> "$output_objdir/$my_dlsyms" "\
3425c43cc173Smrg
3426c27c18e8Smrg/* The mapping between symbol names and symbols.  */
3427c27c18e8Smrgtypedef struct {
3428c27c18e8Smrg  const char *name;
3429c27c18e8Smrg  void *address;
3430c27c18e8Smrg} lt_dlsymlist;
3431b789ec8aSmrgextern LT_DLSYM_CONST lt_dlsymlist
3432c27c18e8Smrglt_${my_prefix}_LTX_preloaded_symbols[];
3433b789ec8aSmrgLT_DLSYM_CONST lt_dlsymlist
3434c27c18e8Smrglt_${my_prefix}_LTX_preloaded_symbols[] =
3435c27c18e8Smrg{\
3436c27c18e8Smrg  { \"$my_originator\", (void *) 0 },"
3437c43cc173Smrg
3438c27c18e8Smrg	  case $need_lib_prefix in
3439c27c18e8Smrg	  no)
3440c27c18e8Smrg	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
3441c27c18e8Smrg	    ;;
3442c27c18e8Smrg	  *)
3443c27c18e8Smrg	    eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
3444c27c18e8Smrg	    ;;
3445c27c18e8Smrg	  esac
344637eb1ca1Smrg	  echo >> "$output_objdir/$my_dlsyms" "\
3447c27c18e8Smrg  {0, (void *) 0}
3448c27c18e8Smrg};
3449c43cc173Smrg
3450c27c18e8Smrg/* This works around a problem in FreeBSD linker */
3451c27c18e8Smrg#ifdef FREEBSD_WORKAROUND
3452c27c18e8Smrgstatic const void *lt_preloaded_setup() {
3453c27c18e8Smrg  return lt_${my_prefix}_LTX_preloaded_symbols;
3454c27c18e8Smrg}
3455c27c18e8Smrg#endif
3456c43cc173Smrg
3457c27c18e8Smrg#ifdef __cplusplus
3458c27c18e8Smrg}
3459c27c18e8Smrg#endif\
3460c27c18e8Smrg"
3461c27c18e8Smrg	} # !$opt_dry_run
3462c43cc173Smrg
3463c27c18e8Smrg	pic_flag_for_symtable=
3464c27c18e8Smrg	case "$compile_command " in
3465c27c18e8Smrg	*" -static "*) ;;
3466c27c18e8Smrg	*)
3467c27c18e8Smrg	  case $host in
3468c27c18e8Smrg	  # compiling the symbol table file with pic_flag works around
3469c27c18e8Smrg	  # a FreeBSD bug that causes programs to crash when -lm is
3470c27c18e8Smrg	  # linked before any other PIC object.  But we must not use
3471c27c18e8Smrg	  # pic_flag when linking with -static.  The problem exists in
3472c27c18e8Smrg	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
3473c27c18e8Smrg	  *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
3474c27c18e8Smrg	    pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
3475c27c18e8Smrg	  *-*-hpux*)
3476c27c18e8Smrg	    pic_flag_for_symtable=" $pic_flag"  ;;
3477c27c18e8Smrg	  *)
3478c27c18e8Smrg	    if test "X$my_pic_p" != Xno; then
3479c27c18e8Smrg	      pic_flag_for_symtable=" $pic_flag"
3480c27c18e8Smrg	    fi
3481c27c18e8Smrg	    ;;
3482c27c18e8Smrg	  esac
3483c27c18e8Smrg	  ;;
3484c27c18e8Smrg	esac
3485c27c18e8Smrg	symtab_cflags=
3486c27c18e8Smrg	for arg in $LTCFLAGS; do
3487c27c18e8Smrg	  case $arg in
3488c27c18e8Smrg	  -pie | -fpie | -fPIE) ;;
3489b789ec8aSmrg	  *) func_append symtab_cflags " $arg" ;;
3490c27c18e8Smrg	  esac
3491c27c18e8Smrg	done
3492c43cc173Smrg
3493c27c18e8Smrg	# Now compile the dynamic symbol file.
3494c27c18e8Smrg	func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
3495c43cc173Smrg
3496c27c18e8Smrg	# Clean up the generated files.
3497c27c18e8Smrg	func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"'
3498c43cc173Smrg
3499c27c18e8Smrg	# Transform the symbol file into the correct name.
3500c27c18e8Smrg	symfileobj="$output_objdir/${my_outputname}S.$objext"
3501c27c18e8Smrg	case $host in
3502c27c18e8Smrg	*cygwin* | *mingw* | *cegcc* )
3503c27c18e8Smrg	  if test -f "$output_objdir/$my_outputname.def"; then
350437eb1ca1Smrg	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
350537eb1ca1Smrg	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
3506c27c18e8Smrg	  else
350737eb1ca1Smrg	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
350837eb1ca1Smrg	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3509c27c18e8Smrg	  fi
3510c27c18e8Smrg	  ;;
3511c27c18e8Smrg	*)
351237eb1ca1Smrg	  compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
351337eb1ca1Smrg	  finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3514c27c18e8Smrg	  ;;
3515c27c18e8Smrg	esac
3516c27c18e8Smrg	;;
3517c27c18e8Smrg      *)
3518c27c18e8Smrg	func_fatal_error "unknown suffix for \`$my_dlsyms'"
3519c27c18e8Smrg	;;
3520c27c18e8Smrg      esac
3521c27c18e8Smrg    else
3522c27c18e8Smrg      # We keep going just in case the user didn't refer to
3523c27c18e8Smrg      # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
3524c27c18e8Smrg      # really was required.
3525c43cc173Smrg
3526c27c18e8Smrg      # Nullify the symbol file.
352737eb1ca1Smrg      compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
352837eb1ca1Smrg      finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
3529c27c18e8Smrg    fi
3530c27c18e8Smrg}
3531c43cc173Smrg
3532c27c18e8Smrg# func_win32_libid arg
3533c27c18e8Smrg# return the library type of file 'arg'
3534c27c18e8Smrg#
3535c27c18e8Smrg# Need a lot of goo to handle *both* DLLs and import libs
3536c27c18e8Smrg# Has to be a shell function in order to 'eat' the argument
3537c27c18e8Smrg# that is supplied when $file_magic_command is called.
353837eb1ca1Smrg# Despite the name, also deal with 64 bit binaries.
3539c27c18e8Smrgfunc_win32_libid ()
3540c27c18e8Smrg{
3541c27c18e8Smrg  $opt_debug
3542c27c18e8Smrg  win32_libid_type="unknown"
3543c27c18e8Smrg  win32_fileres=`file -L $1 2>/dev/null`
3544c27c18e8Smrg  case $win32_fileres in
3545c27c18e8Smrg  *ar\ archive\ import\ library*) # definitely import
3546c27c18e8Smrg    win32_libid_type="x86 archive import"
3547c27c18e8Smrg    ;;
3548c27c18e8Smrg  *ar\ archive*) # could be an import, or static
354937eb1ca1Smrg    # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
3550c27c18e8Smrg    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
355137eb1ca1Smrg       $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
3552b789ec8aSmrg      func_to_tool_file "$1" func_convert_file_msys_to_w32
3553b789ec8aSmrg      win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
3554c27c18e8Smrg	$SED -n -e '
3555c27c18e8Smrg	    1,100{
3556c27c18e8Smrg		/ I /{
3557c27c18e8Smrg		    s,.*,import,
3558c27c18e8Smrg		    p
3559c27c18e8Smrg		    q
3560c27c18e8Smrg		}
3561c27c18e8Smrg	    }'`
3562c27c18e8Smrg      case $win32_nmres in
3563c27c18e8Smrg      import*)  win32_libid_type="x86 archive import";;
3564c27c18e8Smrg      *)        win32_libid_type="x86 archive static";;
3565c27c18e8Smrg      esac
3566c27c18e8Smrg    fi
3567c27c18e8Smrg    ;;
3568c27c18e8Smrg  *DLL*)
3569c27c18e8Smrg    win32_libid_type="x86 DLL"
3570c27c18e8Smrg    ;;
3571c27c18e8Smrg  *executable*) # but shell scripts are "executable" too...
3572c27c18e8Smrg    case $win32_fileres in
3573c27c18e8Smrg    *MS\ Windows\ PE\ Intel*)
3574c27c18e8Smrg      win32_libid_type="x86 DLL"
3575c27c18e8Smrg      ;;
3576c27c18e8Smrg    esac
3577c27c18e8Smrg    ;;
3578c27c18e8Smrg  esac
3579c27c18e8Smrg  $ECHO "$win32_libid_type"
3580c27c18e8Smrg}
3581c43cc173Smrg
3582b789ec8aSmrg# func_cygming_dll_for_implib ARG
3583b789ec8aSmrg#
3584b789ec8aSmrg# Platform-specific function to extract the
3585b789ec8aSmrg# name of the DLL associated with the specified
3586b789ec8aSmrg# import library ARG.
3587b789ec8aSmrg# Invoked by eval'ing the libtool variable
3588b789ec8aSmrg#    $sharedlib_from_linklib_cmd
3589b789ec8aSmrg# Result is available in the variable
3590b789ec8aSmrg#    $sharedlib_from_linklib_result
3591b789ec8aSmrgfunc_cygming_dll_for_implib ()
3592b789ec8aSmrg{
3593b789ec8aSmrg  $opt_debug
3594b789ec8aSmrg  sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
3595b789ec8aSmrg}
3596b789ec8aSmrg
3597b789ec8aSmrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs
3598b789ec8aSmrg#
3599b789ec8aSmrg# The is the core of a fallback implementation of a
3600b789ec8aSmrg# platform-specific function to extract the name of the
3601b789ec8aSmrg# DLL associated with the specified import library LIBNAME.
3602b789ec8aSmrg#
3603b789ec8aSmrg# SECTION_NAME is either .idata$6 or .idata$7, depending
3604b789ec8aSmrg# on the platform and compiler that created the implib.
3605b789ec8aSmrg#
3606b789ec8aSmrg# Echos the name of the DLL associated with the
3607b789ec8aSmrg# specified import library.
3608b789ec8aSmrgfunc_cygming_dll_for_implib_fallback_core ()
3609b789ec8aSmrg{
3610b789ec8aSmrg  $opt_debug
3611b789ec8aSmrg  match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
3612b789ec8aSmrg  $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
3613b789ec8aSmrg    $SED '/^Contents of section '"$match_literal"':/{
3614b789ec8aSmrg      # Place marker at beginning of archive member dllname section
3615b789ec8aSmrg      s/.*/====MARK====/
3616b789ec8aSmrg      p
3617b789ec8aSmrg      d
3618b789ec8aSmrg    }
3619b789ec8aSmrg    # These lines can sometimes be longer than 43 characters, but
3620b789ec8aSmrg    # are always uninteresting
3621b789ec8aSmrg    /:[	 ]*file format pe[i]\{,1\}-/d
3622b789ec8aSmrg    /^In archive [^:]*:/d
3623b789ec8aSmrg    # Ensure marker is printed
3624b789ec8aSmrg    /^====MARK====/p
3625b789ec8aSmrg    # Remove all lines with less than 43 characters
3626b789ec8aSmrg    /^.\{43\}/!d
3627b789ec8aSmrg    # From remaining lines, remove first 43 characters
3628b789ec8aSmrg    s/^.\{43\}//' |
3629b789ec8aSmrg    $SED -n '
3630b789ec8aSmrg      # Join marker and all lines until next marker into a single line
3631b789ec8aSmrg      /^====MARK====/ b para
3632b789ec8aSmrg      H
3633b789ec8aSmrg      $ b para
3634b789ec8aSmrg      b
3635b789ec8aSmrg      :para
3636b789ec8aSmrg      x
3637b789ec8aSmrg      s/\n//g
3638b789ec8aSmrg      # Remove the marker
3639b789ec8aSmrg      s/^====MARK====//
3640b789ec8aSmrg      # Remove trailing dots and whitespace
3641b789ec8aSmrg      s/[\. \t]*$//
3642b789ec8aSmrg      # Print
3643b789ec8aSmrg      /./p' |
3644b789ec8aSmrg    # we now have a list, one entry per line, of the stringified
3645b789ec8aSmrg    # contents of the appropriate section of all members of the
3646b789ec8aSmrg    # archive which possess that section. Heuristic: eliminate
3647b789ec8aSmrg    # all those which have a first or second character that is
3648b789ec8aSmrg    # a '.' (that is, objdump's representation of an unprintable
3649b789ec8aSmrg    # character.) This should work for all archives with less than
3650b789ec8aSmrg    # 0x302f exports -- but will fail for DLLs whose name actually
3651b789ec8aSmrg    # begins with a literal '.' or a single character followed by
3652b789ec8aSmrg    # a '.'.
3653b789ec8aSmrg    #
3654b789ec8aSmrg    # Of those that remain, print the first one.
3655b789ec8aSmrg    $SED -e '/^\./d;/^.\./d;q'
3656b789ec8aSmrg}
3657b789ec8aSmrg
3658b789ec8aSmrg# func_cygming_gnu_implib_p ARG
3659b789ec8aSmrg# This predicate returns with zero status (TRUE) if
3660b789ec8aSmrg# ARG is a GNU/binutils-style import library. Returns
3661b789ec8aSmrg# with nonzero status (FALSE) otherwise.
3662b789ec8aSmrgfunc_cygming_gnu_implib_p ()
3663b789ec8aSmrg{
3664b789ec8aSmrg  $opt_debug
3665b789ec8aSmrg  func_to_tool_file "$1" func_convert_file_msys_to_w32
3666b789ec8aSmrg  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)$'`
3667b789ec8aSmrg  test -n "$func_cygming_gnu_implib_tmp"
3668b789ec8aSmrg}
3669b789ec8aSmrg
3670b789ec8aSmrg# func_cygming_ms_implib_p ARG
3671b789ec8aSmrg# This predicate returns with zero status (TRUE) if
3672b789ec8aSmrg# ARG is an MS-style import library. Returns
3673b789ec8aSmrg# with nonzero status (FALSE) otherwise.
3674b789ec8aSmrgfunc_cygming_ms_implib_p ()
3675b789ec8aSmrg{
3676b789ec8aSmrg  $opt_debug
3677b789ec8aSmrg  func_to_tool_file "$1" func_convert_file_msys_to_w32
3678b789ec8aSmrg  func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
3679b789ec8aSmrg  test -n "$func_cygming_ms_implib_tmp"
3680b789ec8aSmrg}
3681b789ec8aSmrg
3682b789ec8aSmrg# func_cygming_dll_for_implib_fallback ARG
3683b789ec8aSmrg# Platform-specific function to extract the
3684b789ec8aSmrg# name of the DLL associated with the specified
3685b789ec8aSmrg# import library ARG.
3686b789ec8aSmrg#
3687b789ec8aSmrg# This fallback implementation is for use when $DLLTOOL
3688b789ec8aSmrg# does not support the --identify-strict option.
3689b789ec8aSmrg# Invoked by eval'ing the libtool variable
3690b789ec8aSmrg#    $sharedlib_from_linklib_cmd
3691b789ec8aSmrg# Result is available in the variable
3692b789ec8aSmrg#    $sharedlib_from_linklib_result
3693b789ec8aSmrgfunc_cygming_dll_for_implib_fallback ()
3694b789ec8aSmrg{
3695b789ec8aSmrg  $opt_debug
3696b789ec8aSmrg  if func_cygming_gnu_implib_p "$1" ; then
3697b789ec8aSmrg    # binutils import library
3698b789ec8aSmrg    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
3699b789ec8aSmrg  elif func_cygming_ms_implib_p "$1" ; then
3700b789ec8aSmrg    # ms-generated import library
3701b789ec8aSmrg    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
3702b789ec8aSmrg  else
3703b789ec8aSmrg    # unknown
3704b789ec8aSmrg    sharedlib_from_linklib_result=""
3705b789ec8aSmrg  fi
3706b789ec8aSmrg}
3707c43cc173Smrg
3708c43cc173Smrg
3709c27c18e8Smrg# func_extract_an_archive dir oldlib
3710c27c18e8Smrgfunc_extract_an_archive ()
3711c27c18e8Smrg{
3712c27c18e8Smrg    $opt_debug
3713c27c18e8Smrg    f_ex_an_ar_dir="$1"; shift
3714c27c18e8Smrg    f_ex_an_ar_oldlib="$1"
371537eb1ca1Smrg    if test "$lock_old_archive_extraction" = yes; then
371637eb1ca1Smrg      lockfile=$f_ex_an_ar_oldlib.lock
371737eb1ca1Smrg      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
371837eb1ca1Smrg	func_echo "Waiting for $lockfile to be removed"
371937eb1ca1Smrg	sleep 2
372037eb1ca1Smrg      done
372137eb1ca1Smrg    fi
372237eb1ca1Smrg    func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
372337eb1ca1Smrg		   'stat=$?; rm -f "$lockfile"; exit $stat'
372437eb1ca1Smrg    if test "$lock_old_archive_extraction" = yes; then
372537eb1ca1Smrg      $opt_dry_run || rm -f "$lockfile"
372637eb1ca1Smrg    fi
3727c27c18e8Smrg    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
3728c27c18e8Smrg     :
3729c27c18e8Smrg    else
3730c27c18e8Smrg      func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
3731c27c18e8Smrg    fi
3732c27c18e8Smrg}
3733c43cc173Smrg
3734c43cc173Smrg
3735c27c18e8Smrg# func_extract_archives gentop oldlib ...
3736c27c18e8Smrgfunc_extract_archives ()
3737c27c18e8Smrg{
3738c27c18e8Smrg    $opt_debug
3739c27c18e8Smrg    my_gentop="$1"; shift
3740c27c18e8Smrg    my_oldlibs=${1+"$@"}
3741c27c18e8Smrg    my_oldobjs=""
3742c27c18e8Smrg    my_xlib=""
3743c27c18e8Smrg    my_xabs=""
3744c27c18e8Smrg    my_xdir=""
3745c43cc173Smrg
3746c27c18e8Smrg    for my_xlib in $my_oldlibs; do
3747c27c18e8Smrg      # Extract the objects.
3748c27c18e8Smrg      case $my_xlib in
3749c27c18e8Smrg	[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
3750c27c18e8Smrg	*) my_xabs=`pwd`"/$my_xlib" ;;
3751c27c18e8Smrg      esac
3752c27c18e8Smrg      func_basename "$my_xlib"
3753c27c18e8Smrg      my_xlib="$func_basename_result"
3754c27c18e8Smrg      my_xlib_u=$my_xlib
3755c27c18e8Smrg      while :; do
3756c27c18e8Smrg        case " $extracted_archives " in
3757c27c18e8Smrg	*" $my_xlib_u "*)
3758c27c18e8Smrg	  func_arith $extracted_serial + 1
3759c27c18e8Smrg	  extracted_serial=$func_arith_result
3760c27c18e8Smrg	  my_xlib_u=lt$extracted_serial-$my_xlib ;;
3761c27c18e8Smrg	*) break ;;
3762c27c18e8Smrg	esac
3763c27c18e8Smrg      done
3764c27c18e8Smrg      extracted_archives="$extracted_archives $my_xlib_u"
3765c27c18e8Smrg      my_xdir="$my_gentop/$my_xlib_u"
3766c43cc173Smrg
3767c27c18e8Smrg      func_mkdir_p "$my_xdir"
3768c27c18e8Smrg
3769c27c18e8Smrg      case $host in
3770c27c18e8Smrg      *-darwin*)
3771c27c18e8Smrg	func_verbose "Extracting $my_xabs"
3772c27c18e8Smrg	# Do not bother doing anything if just a dry run
3773c27c18e8Smrg	$opt_dry_run || {
3774c27c18e8Smrg	  darwin_orig_dir=`pwd`
3775c27c18e8Smrg	  cd $my_xdir || exit $?
3776c27c18e8Smrg	  darwin_archive=$my_xabs
3777c27c18e8Smrg	  darwin_curdir=`pwd`
3778c27c18e8Smrg	  darwin_base_archive=`basename "$darwin_archive"`
3779c27c18e8Smrg	  darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
3780c27c18e8Smrg	  if test -n "$darwin_arches"; then
3781c27c18e8Smrg	    darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
3782c27c18e8Smrg	    darwin_arch=
3783c27c18e8Smrg	    func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
3784c27c18e8Smrg	    for darwin_arch in  $darwin_arches ; do
3785c27c18e8Smrg	      func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
3786c27c18e8Smrg	      $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
3787c27c18e8Smrg	      cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
3788c27c18e8Smrg	      func_extract_an_archive "`pwd`" "${darwin_base_archive}"
3789c27c18e8Smrg	      cd "$darwin_curdir"
3790c27c18e8Smrg	      $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
3791c27c18e8Smrg	    done # $darwin_arches
3792c27c18e8Smrg            ## Okay now we've a bunch of thin objects, gotta fatten them up :)
3793c27c18e8Smrg	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u`
3794c27c18e8Smrg	    darwin_file=
3795c27c18e8Smrg	    darwin_files=
3796c27c18e8Smrg	    for darwin_file in $darwin_filelist; do
379737eb1ca1Smrg	      darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`
3798c27c18e8Smrg	      $LIPO -create -output "$darwin_file" $darwin_files
3799c27c18e8Smrg	    done # $darwin_filelist
3800c27c18e8Smrg	    $RM -rf unfat-$$
3801c27c18e8Smrg	    cd "$darwin_orig_dir"
3802c43cc173Smrg	  else
3803c27c18e8Smrg	    cd $darwin_orig_dir
3804c27c18e8Smrg	    func_extract_an_archive "$my_xdir" "$my_xabs"
3805c27c18e8Smrg	  fi # $darwin_arches
3806c27c18e8Smrg	} # !$opt_dry_run
3807c27c18e8Smrg	;;
3808c27c18e8Smrg      *)
3809c27c18e8Smrg        func_extract_an_archive "$my_xdir" "$my_xabs"
3810c27c18e8Smrg	;;
3811c27c18e8Smrg      esac
381237eb1ca1Smrg      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
3813c27c18e8Smrg    done
3814c43cc173Smrg
3815c27c18e8Smrg    func_extract_archives_result="$my_oldobjs"
3816c27c18e8Smrg}
3817c43cc173Smrg
3818c43cc173Smrg
381937eb1ca1Smrg# func_emit_wrapper [arg=no]
382037eb1ca1Smrg#
382137eb1ca1Smrg# Emit a libtool wrapper script on stdout.
382237eb1ca1Smrg# Don't directly open a file because we may want to
382337eb1ca1Smrg# incorporate the script contents within a cygwin/mingw
382437eb1ca1Smrg# wrapper executable.  Must ONLY be called from within
382537eb1ca1Smrg# func_mode_link because it depends on a number of variables
382637eb1ca1Smrg# set therein.
3827c27c18e8Smrg#
382837eb1ca1Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
382937eb1ca1Smrg# variable will take.  If 'yes', then the emitted script
383037eb1ca1Smrg# will assume that the directory in which it is stored is
383137eb1ca1Smrg# the $objdir directory.  This is a cygwin/mingw-specific
383237eb1ca1Smrg# behavior.
383337eb1ca1Smrgfunc_emit_wrapper ()
3834c27c18e8Smrg{
383537eb1ca1Smrg	func_emit_wrapper_arg1=${1-no}
3836c43cc173Smrg
3837c27c18e8Smrg	$ECHO "\
3838c27c18e8Smrg#! $SHELL
3839c43cc173Smrg
3840c27c18e8Smrg# $output - temporary wrapper script for $objdir/$outputname
3841c27c18e8Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
3842c27c18e8Smrg#
3843c27c18e8Smrg# The $output program cannot be directly executed until all the libtool
3844c27c18e8Smrg# libraries that it depends on are installed.
3845c27c18e8Smrg#
3846c27c18e8Smrg# This wrapper script should never be moved out of the build directory.
3847c27c18e8Smrg# If it is, it will not operate correctly.
3848c43cc173Smrg
3849c27c18e8Smrg# Sed substitution that helps us do robust quoting.  It backslashifies
3850c27c18e8Smrg# metacharacters that are still active within double-quoted strings.
3851c27c18e8Smrgsed_quote_subst='$sed_quote_subst'
3852c43cc173Smrg
3853c27c18e8Smrg# Be Bourne compatible
3854c27c18e8Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
3855c27c18e8Smrg  emulate sh
3856c27c18e8Smrg  NULLCMD=:
3857c27c18e8Smrg  # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
3858c27c18e8Smrg  # is contrary to our usage.  Disable this feature.
3859c27c18e8Smrg  alias -g '\${1+\"\$@\"}'='\"\$@\"'
3860c27c18e8Smrg  setopt NO_GLOB_SUBST
3861c27c18e8Smrgelse
3862c27c18e8Smrg  case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
3863c27c18e8Smrgfi
3864c27c18e8SmrgBIN_SH=xpg4; export BIN_SH # for Tru64
3865c27c18e8SmrgDUALCASE=1; export DUALCASE # for MKS sh
3866c43cc173Smrg
3867c27c18e8Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout
3868c27c18e8Smrg# if CDPATH is set.
3869c27c18e8Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
3870c43cc173Smrg
3871c27c18e8Smrgrelink_command=\"$relink_command\"
3872c43cc173Smrg
3873c27c18e8Smrg# This environment variable determines our operation mode.
3874c27c18e8Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then
3875c27c18e8Smrg  # install mode needs the following variables:
3876c27c18e8Smrg  generated_by_libtool_version='$macro_version'
3877c27c18e8Smrg  notinst_deplibs='$notinst_deplibs'
3878c27c18e8Smrgelse
3879c27c18e8Smrg  # When we are sourced in execute mode, \$file and \$ECHO are already set.
3880c27c18e8Smrg  if test \"\$libtool_execute_magic\" != \"$magic\"; then
388137eb1ca1Smrg    file=\"\$0\""
388237eb1ca1Smrg
388337eb1ca1Smrg    qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"`
388437eb1ca1Smrg    $ECHO "\
388537eb1ca1Smrg
388637eb1ca1Smrg# A function that is used when there is no print builtin or printf.
388737eb1ca1Smrgfunc_fallback_echo ()
388837eb1ca1Smrg{
388937eb1ca1Smrg  eval 'cat <<_LTECHO_EOF
389037eb1ca1Smrg\$1
389137eb1ca1Smrg_LTECHO_EOF'
389237eb1ca1Smrg}
389337eb1ca1Smrg    ECHO=\"$qECHO\"
389437eb1ca1Smrg  fi
389537eb1ca1Smrg
389637eb1ca1Smrg# Very basic option parsing. These options are (a) specific to
389737eb1ca1Smrg# the libtool wrapper, (b) are identical between the wrapper
389837eb1ca1Smrg# /script/ and the wrapper /executable/ which is used only on
389937eb1ca1Smrg# windows platforms, and (c) all begin with the string "--lt-"
390037eb1ca1Smrg# (application programs are unlikely to have options which match
390137eb1ca1Smrg# this pattern).
390237eb1ca1Smrg#
390337eb1ca1Smrg# There are only two supported options: --lt-debug and
390437eb1ca1Smrg# --lt-dump-script. There is, deliberately, no --lt-help.
390537eb1ca1Smrg#
390637eb1ca1Smrg# The first argument to this parsing function should be the
390737eb1ca1Smrg# script's $0 value, followed by "$@".
390837eb1ca1Smrglt_option_debug=
390937eb1ca1Smrgfunc_parse_lt_options ()
391037eb1ca1Smrg{
391137eb1ca1Smrg  lt_script_arg0=\$0
391237eb1ca1Smrg  shift
391337eb1ca1Smrg  for lt_opt
391437eb1ca1Smrg  do
391537eb1ca1Smrg    case \"\$lt_opt\" in
391637eb1ca1Smrg    --lt-debug) lt_option_debug=1 ;;
391737eb1ca1Smrg    --lt-dump-script)
391837eb1ca1Smrg        lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
391937eb1ca1Smrg        test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
392037eb1ca1Smrg        lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
392137eb1ca1Smrg        cat \"\$lt_dump_D/\$lt_dump_F\"
392237eb1ca1Smrg        exit 0
392337eb1ca1Smrg      ;;
392437eb1ca1Smrg    --lt-*)
392537eb1ca1Smrg        \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
392637eb1ca1Smrg        exit 1
392737eb1ca1Smrg      ;;
392837eb1ca1Smrg    esac
392937eb1ca1Smrg  done
393037eb1ca1Smrg
393137eb1ca1Smrg  # Print the debug banner immediately:
393237eb1ca1Smrg  if test -n \"\$lt_option_debug\"; then
393337eb1ca1Smrg    echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2
393437eb1ca1Smrg  fi
393537eb1ca1Smrg}
393637eb1ca1Smrg
393737eb1ca1Smrg# Used when --lt-debug. Prints its arguments to stdout
393837eb1ca1Smrg# (redirection is the responsibility of the caller)
393937eb1ca1Smrgfunc_lt_dump_args ()
394037eb1ca1Smrg{
394137eb1ca1Smrg  lt_dump_args_N=1;
394237eb1ca1Smrg  for lt_arg
394337eb1ca1Smrg  do
394437eb1ca1Smrg    \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\"
394537eb1ca1Smrg    lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
394637eb1ca1Smrg  done
394737eb1ca1Smrg}
394837eb1ca1Smrg
394937eb1ca1Smrg# Core function for launching the target application
395037eb1ca1Smrgfunc_exec_program_core ()
395137eb1ca1Smrg{
3952c27c18e8Smrg"
395337eb1ca1Smrg  case $host in
395437eb1ca1Smrg  # Backslashes separate directories on plain windows
395537eb1ca1Smrg  *-*-mingw | *-*-os2* | *-cegcc*)
395637eb1ca1Smrg    $ECHO "\
395737eb1ca1Smrg      if test -n \"\$lt_option_debug\"; then
395837eb1ca1Smrg        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2
395937eb1ca1Smrg        func_lt_dump_args \${1+\"\$@\"} 1>&2
396037eb1ca1Smrg      fi
396137eb1ca1Smrg      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
396237eb1ca1Smrg"
396337eb1ca1Smrg    ;;
396437eb1ca1Smrg
396537eb1ca1Smrg  *)
396637eb1ca1Smrg    $ECHO "\
396737eb1ca1Smrg      if test -n \"\$lt_option_debug\"; then
396837eb1ca1Smrg        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2
396937eb1ca1Smrg        func_lt_dump_args \${1+\"\$@\"} 1>&2
397037eb1ca1Smrg      fi
397137eb1ca1Smrg      exec \"\$progdir/\$program\" \${1+\"\$@\"}
397237eb1ca1Smrg"
397337eb1ca1Smrg    ;;
397437eb1ca1Smrg  esac
397537eb1ca1Smrg  $ECHO "\
397637eb1ca1Smrg      \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
397737eb1ca1Smrg      exit 1
397837eb1ca1Smrg}
397937eb1ca1Smrg
398037eb1ca1Smrg# A function to encapsulate launching the target application
398137eb1ca1Smrg# Strips options in the --lt-* namespace from \$@ and
398237eb1ca1Smrg# launches target application with the remaining arguments.
398337eb1ca1Smrgfunc_exec_program ()
398437eb1ca1Smrg{
398537eb1ca1Smrg  for lt_wr_arg
398637eb1ca1Smrg  do
398737eb1ca1Smrg    case \$lt_wr_arg in
398837eb1ca1Smrg    --lt-*) ;;
398937eb1ca1Smrg    *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
399037eb1ca1Smrg    esac
399137eb1ca1Smrg    shift
399237eb1ca1Smrg  done
399337eb1ca1Smrg  func_exec_program_core \${1+\"\$@\"}
399437eb1ca1Smrg}
399537eb1ca1Smrg
399637eb1ca1Smrg  # Parse options
399737eb1ca1Smrg  func_parse_lt_options \"\$0\" \${1+\"\$@\"}
3998c43cc173Smrg
3999c27c18e8Smrg  # Find the directory that this script lives in.
400037eb1ca1Smrg  thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
4001c27c18e8Smrg  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
4002c43cc173Smrg
4003c27c18e8Smrg  # Follow symbolic links until we get to the real thisdir.
400437eb1ca1Smrg  file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
4005c27c18e8Smrg  while test -n \"\$file\"; do
400637eb1ca1Smrg    destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
4007c27c18e8Smrg
4008c27c18e8Smrg    # If there was a directory component, then change thisdir.
4009c27c18e8Smrg    if test \"x\$destdir\" != \"x\$file\"; then
4010c27c18e8Smrg      case \"\$destdir\" in
4011c27c18e8Smrg      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
4012c27c18e8Smrg      *) thisdir=\"\$thisdir/\$destdir\" ;;
4013c43cc173Smrg      esac
4014c27c18e8Smrg    fi
4015c43cc173Smrg
401637eb1ca1Smrg    file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
401737eb1ca1Smrg    file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
4018c27c18e8Smrg  done
4019c43cc173Smrg
4020c27c18e8Smrg  # Usually 'no', except on cygwin/mingw when embedded into
4021c27c18e8Smrg  # the cwrapper.
402237eb1ca1Smrg  WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
4023c27c18e8Smrg  if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
4024c27c18e8Smrg    # special case for '.'
4025c27c18e8Smrg    if test \"\$thisdir\" = \".\"; then
4026c27c18e8Smrg      thisdir=\`pwd\`
4027c27c18e8Smrg    fi
4028c27c18e8Smrg    # remove .libs from thisdir
4029c27c18e8Smrg    case \"\$thisdir\" in
403037eb1ca1Smrg    *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
4031c27c18e8Smrg    $objdir )   thisdir=. ;;
4032c27c18e8Smrg    esac
4033c27c18e8Smrg  fi
4034c27c18e8Smrg
4035c27c18e8Smrg  # Try to get the absolute directory name.
4036c27c18e8Smrg  absdir=\`cd \"\$thisdir\" && pwd\`
4037c27c18e8Smrg  test -n \"\$absdir\" && thisdir=\"\$absdir\"
4038c27c18e8Smrg"
4039c27c18e8Smrg
4040c27c18e8Smrg	if test "$fast_install" = yes; then
4041c27c18e8Smrg	  $ECHO "\
4042c27c18e8Smrg  program=lt-'$outputname'$exeext
4043c27c18e8Smrg  progdir=\"\$thisdir/$objdir\"
4044c27c18e8Smrg
4045c27c18e8Smrg  if test ! -f \"\$progdir/\$program\" ||
4046c27c18e8Smrg     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
4047c27c18e8Smrg       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
4048c27c18e8Smrg
4049c27c18e8Smrg    file=\"\$\$-\$program\"
4050c27c18e8Smrg
4051c27c18e8Smrg    if test ! -d \"\$progdir\"; then
4052c27c18e8Smrg      $MKDIR \"\$progdir\"
4053c27c18e8Smrg    else
4054c27c18e8Smrg      $RM \"\$progdir/\$file\"
4055c27c18e8Smrg    fi"
4056c27c18e8Smrg
4057c27c18e8Smrg	  $ECHO "\
4058c27c18e8Smrg
4059c27c18e8Smrg    # relink executable if necessary
4060c27c18e8Smrg    if test -n \"\$relink_command\"; then
4061c27c18e8Smrg      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
4062c27c18e8Smrg      else
4063c27c18e8Smrg	$ECHO \"\$relink_command_output\" >&2
4064c27c18e8Smrg	$RM \"\$progdir/\$file\"
4065c27c18e8Smrg	exit 1
4066c43cc173Smrg      fi
4067c27c18e8Smrg    fi
4068c43cc173Smrg
4069c27c18e8Smrg    $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
4070c27c18e8Smrg    { $RM \"\$progdir/\$program\";
4071c27c18e8Smrg      $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
4072c27c18e8Smrg    $RM \"\$progdir/\$file\"
4073c27c18e8Smrg  fi"
4074c27c18e8Smrg	else
4075c27c18e8Smrg	  $ECHO "\
4076c27c18e8Smrg  program='$outputname'
4077c27c18e8Smrg  progdir=\"\$thisdir/$objdir\"
4078c27c18e8Smrg"
4079c43cc173Smrg	fi
4080c43cc173Smrg
4081c27c18e8Smrg	$ECHO "\
4082c27c18e8Smrg
4083c27c18e8Smrg  if test -f \"\$progdir/\$program\"; then"
4084c27c18e8Smrg
4085b789ec8aSmrg	# fixup the dll searchpath if we need to.
4086b789ec8aSmrg	#
4087b789ec8aSmrg	# Fix the DLL searchpath if we need to.  Do this before prepending
4088b789ec8aSmrg	# to shlibpath, because on Windows, both are PATH and uninstalled
4089b789ec8aSmrg	# libraries must come first.
4090b789ec8aSmrg	if test -n "$dllsearchpath"; then
4091b789ec8aSmrg	  $ECHO "\
4092b789ec8aSmrg    # Add the dll search path components to the executable PATH
4093b789ec8aSmrg    PATH=$dllsearchpath:\$PATH
4094b789ec8aSmrg"
4095b789ec8aSmrg	fi
4096b789ec8aSmrg
4097c27c18e8Smrg	# Export our shlibpath_var if we have one.
4098c27c18e8Smrg	if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
4099c27c18e8Smrg	  $ECHO "\
4100c27c18e8Smrg    # Add our own library path to $shlibpath_var
4101c27c18e8Smrg    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
4102c27c18e8Smrg
4103c27c18e8Smrg    # Some systems cannot cope with colon-terminated $shlibpath_var
4104c27c18e8Smrg    # The second colon is a workaround for a bug in BeOS R4 sed
410537eb1ca1Smrg    $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
4106c27c18e8Smrg
4107c27c18e8Smrg    export $shlibpath_var
4108c27c18e8Smrg"
4109c43cc173Smrg	fi
4110c43cc173Smrg
4111c27c18e8Smrg	$ECHO "\
4112c27c18e8Smrg    if test \"\$libtool_execute_magic\" != \"$magic\"; then
4113c27c18e8Smrg      # Run the actual program with our arguments.
411437eb1ca1Smrg      func_exec_program \${1+\"\$@\"}
4115c27c18e8Smrg    fi
4116c27c18e8Smrg  else
4117c27c18e8Smrg    # The program doesn't exist.
4118c27c18e8Smrg    \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
4119c27c18e8Smrg    \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
412037eb1ca1Smrg    \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
4121c27c18e8Smrg    exit 1
4122c27c18e8Smrg  fi
4123c27c18e8Smrgfi\
4124c27c18e8Smrg"
4125c27c18e8Smrg}
4126c43cc173Smrg
4127c43cc173Smrg
4128c27c18e8Smrg# func_emit_cwrapperexe_src
4129c27c18e8Smrg# emit the source code for a wrapper executable on stdout
4130c27c18e8Smrg# Must ONLY be called from within func_mode_link because
4131c27c18e8Smrg# it depends on a number of variable set therein.
4132c27c18e8Smrgfunc_emit_cwrapperexe_src ()
4133c27c18e8Smrg{
4134c27c18e8Smrg	cat <<EOF
4135c43cc173Smrg
4136c27c18e8Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
4137c27c18e8Smrg   Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
4138c43cc173Smrg
4139c27c18e8Smrg   The $output program cannot be directly executed until all the libtool
4140c27c18e8Smrg   libraries that it depends on are installed.
4141c43cc173Smrg
4142c27c18e8Smrg   This wrapper executable should never be moved out of the build directory.
4143c27c18e8Smrg   If it is, it will not operate correctly.
4144c27c18e8Smrg*/
4145c27c18e8SmrgEOF
4146c27c18e8Smrg	    cat <<"EOF"
414737eb1ca1Smrg#ifdef _MSC_VER
414837eb1ca1Smrg# define _CRT_SECURE_NO_DEPRECATE 1
414937eb1ca1Smrg#endif
4150c27c18e8Smrg#include <stdio.h>
4151c27c18e8Smrg#include <stdlib.h>
4152c27c18e8Smrg#ifdef _MSC_VER
4153c27c18e8Smrg# include <direct.h>
4154c27c18e8Smrg# include <process.h>
4155c27c18e8Smrg# include <io.h>
4156c27c18e8Smrg#else
4157c27c18e8Smrg# include <unistd.h>
4158c27c18e8Smrg# include <stdint.h>
4159c27c18e8Smrg# ifdef __CYGWIN__
4160c27c18e8Smrg#  include <io.h>
4161c27c18e8Smrg# endif
4162c27c18e8Smrg#endif
4163c27c18e8Smrg#include <malloc.h>
4164c27c18e8Smrg#include <stdarg.h>
4165c27c18e8Smrg#include <assert.h>
4166c27c18e8Smrg#include <string.h>
4167c27c18e8Smrg#include <ctype.h>
4168c27c18e8Smrg#include <errno.h>
4169c27c18e8Smrg#include <fcntl.h>
4170c27c18e8Smrg#include <sys/stat.h>
4171c43cc173Smrg
417237eb1ca1Smrg/* declarations of non-ANSI functions */
417337eb1ca1Smrg#if defined(__MINGW32__)
417437eb1ca1Smrg# ifdef __STRICT_ANSI__
417537eb1ca1Smrgint _putenv (const char *);
417637eb1ca1Smrg# endif
417737eb1ca1Smrg#elif defined(__CYGWIN__)
417837eb1ca1Smrg# ifdef __STRICT_ANSI__
417937eb1ca1Smrgchar *realpath (const char *, char *);
418037eb1ca1Smrgint putenv (char *);
418137eb1ca1Smrgint setenv (const char *, const char *, int);
418237eb1ca1Smrg# endif
418337eb1ca1Smrg/* #elif defined (other platforms) ... */
418437eb1ca1Smrg#endif
418537eb1ca1Smrg
418637eb1ca1Smrg/* portability defines, excluding path handling macros */
418737eb1ca1Smrg#if defined(_MSC_VER)
418837eb1ca1Smrg# define setmode _setmode
418937eb1ca1Smrg# define stat    _stat
419037eb1ca1Smrg# define chmod   _chmod
419137eb1ca1Smrg# define getcwd  _getcwd
419237eb1ca1Smrg# define putenv  _putenv
419337eb1ca1Smrg# define S_IXUSR _S_IEXEC
419437eb1ca1Smrg# ifndef _INTPTR_T_DEFINED
419537eb1ca1Smrg#  define _INTPTR_T_DEFINED
419637eb1ca1Smrg#  define intptr_t int
419737eb1ca1Smrg# endif
419837eb1ca1Smrg#elif defined(__MINGW32__)
419937eb1ca1Smrg# define setmode _setmode
420037eb1ca1Smrg# define stat    _stat
420137eb1ca1Smrg# define chmod   _chmod
420237eb1ca1Smrg# define getcwd  _getcwd
420337eb1ca1Smrg# define putenv  _putenv
420437eb1ca1Smrg#elif defined(__CYGWIN__)
420537eb1ca1Smrg# define HAVE_SETENV
420637eb1ca1Smrg# define FOPEN_WB "wb"
420737eb1ca1Smrg/* #elif defined (other platforms) ... */
420837eb1ca1Smrg#endif
420937eb1ca1Smrg
4210c27c18e8Smrg#if defined(PATH_MAX)
4211c27c18e8Smrg# define LT_PATHMAX PATH_MAX
4212c27c18e8Smrg#elif defined(MAXPATHLEN)
4213c27c18e8Smrg# define LT_PATHMAX MAXPATHLEN
4214c27c18e8Smrg#else
4215c27c18e8Smrg# define LT_PATHMAX 1024
4216c27c18e8Smrg#endif
4217c43cc173Smrg
4218c27c18e8Smrg#ifndef S_IXOTH
4219c27c18e8Smrg# define S_IXOTH 0
4220c27c18e8Smrg#endif
4221c27c18e8Smrg#ifndef S_IXGRP
4222c27c18e8Smrg# define S_IXGRP 0
4223c27c18e8Smrg#endif
4224c43cc173Smrg
422537eb1ca1Smrg/* path handling portability macros */
4226c27c18e8Smrg#ifndef DIR_SEPARATOR
4227c27c18e8Smrg# define DIR_SEPARATOR '/'
4228c27c18e8Smrg# define PATH_SEPARATOR ':'
4229c27c18e8Smrg#endif
4230c43cc173Smrg
4231c27c18e8Smrg#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
4232c27c18e8Smrg  defined (__OS2__)
4233c27c18e8Smrg# define HAVE_DOS_BASED_FILE_SYSTEM
4234c27c18e8Smrg# define FOPEN_WB "wb"
4235c27c18e8Smrg# ifndef DIR_SEPARATOR_2
4236c27c18e8Smrg#  define DIR_SEPARATOR_2 '\\'
4237c27c18e8Smrg# endif
4238c27c18e8Smrg# ifndef PATH_SEPARATOR_2
4239c27c18e8Smrg#  define PATH_SEPARATOR_2 ';'
4240c27c18e8Smrg# endif
4241c27c18e8Smrg#endif
4242c43cc173Smrg
4243c27c18e8Smrg#ifndef DIR_SEPARATOR_2
4244c27c18e8Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
4245c27c18e8Smrg#else /* DIR_SEPARATOR_2 */
4246c27c18e8Smrg# define IS_DIR_SEPARATOR(ch) \
4247c27c18e8Smrg	(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
4248c27c18e8Smrg#endif /* DIR_SEPARATOR_2 */
4249c43cc173Smrg
4250c27c18e8Smrg#ifndef PATH_SEPARATOR_2
4251c27c18e8Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
4252c27c18e8Smrg#else /* PATH_SEPARATOR_2 */
4253c27c18e8Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
4254c27c18e8Smrg#endif /* PATH_SEPARATOR_2 */
4255c43cc173Smrg
4256c27c18e8Smrg#ifndef FOPEN_WB
4257c27c18e8Smrg# define FOPEN_WB "w"
4258c27c18e8Smrg#endif
4259c27c18e8Smrg#ifndef _O_BINARY
4260c27c18e8Smrg# define _O_BINARY 0
4261c27c18e8Smrg#endif
4262c43cc173Smrg
4263c27c18e8Smrg#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
4264c27c18e8Smrg#define XFREE(stale) do { \
4265c27c18e8Smrg  if (stale) { free ((void *) stale); stale = 0; } \
4266c27c18e8Smrg} while (0)
4267c43cc173Smrg
426837eb1ca1Smrg#if defined(LT_DEBUGWRAPPER)
426937eb1ca1Smrgstatic int lt_debug = 1;
4270c27c18e8Smrg#else
427137eb1ca1Smrgstatic int lt_debug = 0;
4272c27c18e8Smrg#endif
4273c43cc173Smrg
427437eb1ca1Smrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */
4275c43cc173Smrg
4276c27c18e8Smrgvoid *xmalloc (size_t num);
4277c27c18e8Smrgchar *xstrdup (const char *string);
4278c27c18e8Smrgconst char *base_name (const char *name);
4279c27c18e8Smrgchar *find_executable (const char *wrapper);
4280c27c18e8Smrgchar *chase_symlinks (const char *pathspec);
4281c27c18e8Smrgint make_executable (const char *path);
4282c27c18e8Smrgint check_executable (const char *path);
4283c27c18e8Smrgchar *strendzap (char *str, const char *pat);
428437eb1ca1Smrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...);
428537eb1ca1Smrgvoid lt_fatal (const char *file, int line, const char *message, ...);
428637eb1ca1Smrgstatic const char *nonnull (const char *s);
428737eb1ca1Smrgstatic const char *nonempty (const char *s);
4288c27c18e8Smrgvoid lt_setenv (const char *name, const char *value);
4289c27c18e8Smrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end);
4290c27c18e8Smrgvoid lt_update_exe_path (const char *name, const char *value);
4291c27c18e8Smrgvoid lt_update_lib_path (const char *name, const char *value);
429237eb1ca1Smrgchar **prepare_spawn (char **argv);
429337eb1ca1Smrgvoid lt_dump_script (FILE *f);
4294c27c18e8SmrgEOF
4295c27c18e8Smrg
4296c27c18e8Smrg	    cat <<EOF
4297b789ec8aSmrgvolatile const char * MAGIC_EXE = "$magic_exe";
4298c27c18e8Smrgconst char * LIB_PATH_VARNAME = "$shlibpath_var";
4299c27c18e8SmrgEOF
4300c43cc173Smrg
4301c27c18e8Smrg	    if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
4302b789ec8aSmrg              func_to_host_path "$temp_rpath"
4303c27c18e8Smrg	      cat <<EOF
4304b789ec8aSmrgconst char * LIB_PATH_VALUE   = "$func_to_host_path_result";
4305c27c18e8SmrgEOF
4306c27c18e8Smrg	    else
4307c27c18e8Smrg	      cat <<"EOF"
4308c27c18e8Smrgconst char * LIB_PATH_VALUE   = "";
4309c27c18e8SmrgEOF
4310c27c18e8Smrg	    fi
4311c43cc173Smrg
4312c27c18e8Smrg	    if test -n "$dllsearchpath"; then
4313b789ec8aSmrg              func_to_host_path "$dllsearchpath:"
4314c27c18e8Smrg	      cat <<EOF
4315c27c18e8Smrgconst char * EXE_PATH_VARNAME = "PATH";
4316b789ec8aSmrgconst char * EXE_PATH_VALUE   = "$func_to_host_path_result";
4317c27c18e8SmrgEOF
4318c27c18e8Smrg	    else
4319c27c18e8Smrg	      cat <<"EOF"
4320c27c18e8Smrgconst char * EXE_PATH_VARNAME = "";
4321c27c18e8Smrgconst char * EXE_PATH_VALUE   = "";
4322c27c18e8SmrgEOF
4323c27c18e8Smrg	    fi
4324c43cc173Smrg
4325c27c18e8Smrg	    if test "$fast_install" = yes; then
4326c27c18e8Smrg	      cat <<EOF
4327c27c18e8Smrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
4328c27c18e8SmrgEOF
4329c27c18e8Smrg	    else
4330c27c18e8Smrg	      cat <<EOF
4331c27c18e8Smrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
4332c27c18e8SmrgEOF
4333c27c18e8Smrg	    fi
4334c43cc173Smrg
4335c43cc173Smrg
4336c27c18e8Smrg	    cat <<"EOF"
4337c43cc173Smrg
4338c27c18e8Smrg#define LTWRAPPER_OPTION_PREFIX         "--lt-"
4339c43cc173Smrg
4340c27c18e8Smrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
4341c27c18e8Smrgstatic const char *dumpscript_opt       = LTWRAPPER_OPTION_PREFIX "dump-script";
434237eb1ca1Smrgstatic const char *debug_opt            = LTWRAPPER_OPTION_PREFIX "debug";
4343c27c18e8Smrg
4344c27c18e8Smrgint
4345c27c18e8Smrgmain (int argc, char *argv[])
4346c27c18e8Smrg{
4347c27c18e8Smrg  char **newargz;
4348c27c18e8Smrg  int  newargc;
4349c27c18e8Smrg  char *tmp_pathspec;
4350c27c18e8Smrg  char *actual_cwrapper_path;
4351c27c18e8Smrg  char *actual_cwrapper_name;
4352c27c18e8Smrg  char *target_name;
4353c27c18e8Smrg  char *lt_argv_zero;
4354c27c18e8Smrg  intptr_t rval = 127;
4355c27c18e8Smrg
4356c27c18e8Smrg  int i;
4357c27c18e8Smrg
4358c27c18e8Smrg  program_name = (char *) xstrdup (base_name (argv[0]));
435937eb1ca1Smrg  newargz = XMALLOC (char *, argc + 1);
4360c27c18e8Smrg
436137eb1ca1Smrg  /* very simple arg parsing; don't want to rely on getopt
436237eb1ca1Smrg   * also, copy all non cwrapper options to newargz, except
436337eb1ca1Smrg   * argz[0], which is handled differently
436437eb1ca1Smrg   */
436537eb1ca1Smrg  newargc=0;
4366c27c18e8Smrg  for (i = 1; i < argc; i++)
4367c27c18e8Smrg    {
4368c27c18e8Smrg      if (strcmp (argv[i], dumpscript_opt) == 0)
4369c27c18e8Smrg	{
4370c27c18e8SmrgEOF
4371c27c18e8Smrg	    case "$host" in
4372c27c18e8Smrg	      *mingw* | *cygwin* )
4373c27c18e8Smrg		# make stdout use "unix" line endings
4374c27c18e8Smrg		echo "          setmode(1,_O_BINARY);"
4375c27c18e8Smrg		;;
4376c27c18e8Smrg	      esac
4377c27c18e8Smrg
4378c27c18e8Smrg	    cat <<"EOF"
437937eb1ca1Smrg	  lt_dump_script (stdout);
4380c27c18e8Smrg	  return 0;
4381c27c18e8Smrg	}
438237eb1ca1Smrg      if (strcmp (argv[i], debug_opt) == 0)
438337eb1ca1Smrg	{
438437eb1ca1Smrg          lt_debug = 1;
438537eb1ca1Smrg          continue;
438637eb1ca1Smrg	}
438737eb1ca1Smrg      if (strcmp (argv[i], ltwrapper_option_prefix) == 0)
438837eb1ca1Smrg        {
438937eb1ca1Smrg          /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
439037eb1ca1Smrg             namespace, but it is not one of the ones we know about and
439137eb1ca1Smrg             have already dealt with, above (inluding dump-script), then
439237eb1ca1Smrg             report an error. Otherwise, targets might begin to believe
439337eb1ca1Smrg             they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
439437eb1ca1Smrg             namespace. The first time any user complains about this, we'll
439537eb1ca1Smrg             need to make LTWRAPPER_OPTION_PREFIX a configure-time option
439637eb1ca1Smrg             or a configure.ac-settable value.
439737eb1ca1Smrg           */
439837eb1ca1Smrg          lt_fatal (__FILE__, __LINE__,
439937eb1ca1Smrg		    "unrecognized %s option: '%s'",
440037eb1ca1Smrg                    ltwrapper_option_prefix, argv[i]);
440137eb1ca1Smrg        }
440237eb1ca1Smrg      /* otherwise ... */
440337eb1ca1Smrg      newargz[++newargc] = xstrdup (argv[i]);
4404c27c18e8Smrg    }
440537eb1ca1Smrg  newargz[++newargc] = NULL;
440637eb1ca1Smrg
440737eb1ca1SmrgEOF
440837eb1ca1Smrg	    cat <<EOF
440937eb1ca1Smrg  /* The GNU banner must be the first non-error debug message */
441037eb1ca1Smrg  lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\n");
441137eb1ca1SmrgEOF
441237eb1ca1Smrg	    cat <<"EOF"
441337eb1ca1Smrg  lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
441437eb1ca1Smrg  lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name);
4415c27c18e8Smrg
4416c27c18e8Smrg  tmp_pathspec = find_executable (argv[0]);
4417c27c18e8Smrg  if (tmp_pathspec == NULL)
441837eb1ca1Smrg    lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]);
441937eb1ca1Smrg  lt_debugprintf (__FILE__, __LINE__,
442037eb1ca1Smrg                  "(main) found exe (before symlink chase) at: %s\n",
442137eb1ca1Smrg		  tmp_pathspec);
4422c27c18e8Smrg
4423c27c18e8Smrg  actual_cwrapper_path = chase_symlinks (tmp_pathspec);
442437eb1ca1Smrg  lt_debugprintf (__FILE__, __LINE__,
442537eb1ca1Smrg                  "(main) found exe (after symlink chase) at: %s\n",
442637eb1ca1Smrg		  actual_cwrapper_path);
4427c27c18e8Smrg  XFREE (tmp_pathspec);
4428c27c18e8Smrg
442937eb1ca1Smrg  actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));
4430c27c18e8Smrg  strendzap (actual_cwrapper_path, actual_cwrapper_name);
4431c27c18e8Smrg
4432c27c18e8Smrg  /* wrapper name transforms */
4433c27c18e8Smrg  strendzap (actual_cwrapper_name, ".exe");
4434c27c18e8Smrg  tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
4435c27c18e8Smrg  XFREE (actual_cwrapper_name);
4436c27c18e8Smrg  actual_cwrapper_name = tmp_pathspec;
4437c27c18e8Smrg  tmp_pathspec = 0;
4438c27c18e8Smrg
4439c27c18e8Smrg  /* target_name transforms -- use actual target program name; might have lt- prefix */
4440c27c18e8Smrg  target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
4441c27c18e8Smrg  strendzap (target_name, ".exe");
4442c27c18e8Smrg  tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
4443c27c18e8Smrg  XFREE (target_name);
4444c27c18e8Smrg  target_name = tmp_pathspec;
4445c27c18e8Smrg  tmp_pathspec = 0;
4446c27c18e8Smrg
444737eb1ca1Smrg  lt_debugprintf (__FILE__, __LINE__,
444837eb1ca1Smrg		  "(main) libtool target name: %s\n",
444937eb1ca1Smrg		  target_name);
4450c27c18e8SmrgEOF
4451c27c18e8Smrg
4452c27c18e8Smrg	    cat <<EOF
4453c27c18e8Smrg  newargz[0] =
4454c27c18e8Smrg    XMALLOC (char, (strlen (actual_cwrapper_path) +
4455c27c18e8Smrg		    strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
4456c27c18e8Smrg  strcpy (newargz[0], actual_cwrapper_path);
4457c27c18e8Smrg  strcat (newargz[0], "$objdir");
4458c27c18e8Smrg  strcat (newargz[0], "/");
4459c27c18e8SmrgEOF
4460c27c18e8Smrg
4461c27c18e8Smrg	    cat <<"EOF"
4462c27c18e8Smrg  /* stop here, and copy so we don't have to do this twice */
4463c27c18e8Smrg  tmp_pathspec = xstrdup (newargz[0]);
4464c27c18e8Smrg
4465c27c18e8Smrg  /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
4466c27c18e8Smrg  strcat (newargz[0], actual_cwrapper_name);
4467c27c18e8Smrg
4468c27c18e8Smrg  /* DO want the lt- prefix here if it exists, so use target_name */
4469c27c18e8Smrg  lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
4470c27c18e8Smrg  XFREE (tmp_pathspec);
4471c27c18e8Smrg  tmp_pathspec = NULL;
4472c27c18e8SmrgEOF
4473c27c18e8Smrg
4474c27c18e8Smrg	    case $host_os in
4475c27c18e8Smrg	      mingw*)
4476c27c18e8Smrg	    cat <<"EOF"
4477c27c18e8Smrg  {
4478c27c18e8Smrg    char* p;
4479c27c18e8Smrg    while ((p = strchr (newargz[0], '\\')) != NULL)
4480c27c18e8Smrg      {
4481c27c18e8Smrg	*p = '/';
4482c27c18e8Smrg      }
4483c27c18e8Smrg    while ((p = strchr (lt_argv_zero, '\\')) != NULL)
4484c27c18e8Smrg      {
4485c27c18e8Smrg	*p = '/';
4486c27c18e8Smrg      }
4487c27c18e8Smrg  }
4488c27c18e8SmrgEOF
4489c43cc173Smrg	    ;;
4490c27c18e8Smrg	    esac
4491c27c18e8Smrg
4492c27c18e8Smrg	    cat <<"EOF"
4493c27c18e8Smrg  XFREE (target_name);
4494c27c18e8Smrg  XFREE (actual_cwrapper_path);
4495c27c18e8Smrg  XFREE (actual_cwrapper_name);
4496c27c18e8Smrg
4497c27c18e8Smrg  lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
4498c27c18e8Smrg  lt_setenv ("DUALCASE", "1");  /* for MSK sh */
4499b789ec8aSmrg  /* Update the DLL searchpath.  EXE_PATH_VALUE ($dllsearchpath) must
4500b789ec8aSmrg     be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath)
4501b789ec8aSmrg     because on Windows, both *_VARNAMEs are PATH but uninstalled
4502b789ec8aSmrg     libraries must come first. */
4503c27c18e8Smrg  lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
4504b789ec8aSmrg  lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
4505c27c18e8Smrg
450637eb1ca1Smrg  lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",
450737eb1ca1Smrg		  nonnull (lt_argv_zero));
4508c27c18e8Smrg  for (i = 0; i < newargc; i++)
4509c27c18e8Smrg    {
451037eb1ca1Smrg      lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n",
451137eb1ca1Smrg		      i, nonnull (newargz[i]));
4512c27c18e8Smrg    }
4513c43cc173Smrg
4514c43cc173SmrgEOF
4515c43cc173Smrg
4516c27c18e8Smrg	    case $host_os in
4517c27c18e8Smrg	      mingw*)
4518c27c18e8Smrg		cat <<"EOF"
4519c27c18e8Smrg  /* execv doesn't actually work on mingw as expected on unix */
452037eb1ca1Smrg  newargz = prepare_spawn (newargz);
4521c27c18e8Smrg  rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
4522c27c18e8Smrg  if (rval == -1)
4523c27c18e8Smrg    {
4524c27c18e8Smrg      /* failed to start process */
452537eb1ca1Smrg      lt_debugprintf (__FILE__, __LINE__,
452637eb1ca1Smrg		      "(main) failed to launch target \"%s\": %s\n",
452737eb1ca1Smrg		      lt_argv_zero, nonnull (strerror (errno)));
4528c27c18e8Smrg      return 127;
4529c27c18e8Smrg    }
4530c27c18e8Smrg  return rval;
4531c27c18e8SmrgEOF
4532c27c18e8Smrg		;;
4533c27c18e8Smrg	      *)
4534c27c18e8Smrg		cat <<"EOF"
4535c27c18e8Smrg  execv (lt_argv_zero, newargz);
4536c27c18e8Smrg  return rval; /* =127, but avoids unused variable warning */
4537c27c18e8SmrgEOF
4538c27c18e8Smrg		;;
4539c27c18e8Smrg	    esac
4540c43cc173Smrg
4541c27c18e8Smrg	    cat <<"EOF"
4542c27c18e8Smrg}
4543c43cc173Smrg
4544c27c18e8Smrgvoid *
4545c27c18e8Smrgxmalloc (size_t num)
4546c27c18e8Smrg{
4547c27c18e8Smrg  void *p = (void *) malloc (num);
4548c27c18e8Smrg  if (!p)
454937eb1ca1Smrg    lt_fatal (__FILE__, __LINE__, "memory exhausted");
4550c43cc173Smrg
4551c27c18e8Smrg  return p;
4552c27c18e8Smrg}
4553c43cc173Smrg
4554c27c18e8Smrgchar *
4555c27c18e8Smrgxstrdup (const char *string)
4556c27c18e8Smrg{
4557c27c18e8Smrg  return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
4558c27c18e8Smrg			  string) : NULL;
4559c27c18e8Smrg}
4560c43cc173Smrg
4561c27c18e8Smrgconst char *
4562c27c18e8Smrgbase_name (const char *name)
4563c27c18e8Smrg{
4564c27c18e8Smrg  const char *base;
4565c43cc173Smrg
4566c27c18e8Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4567c27c18e8Smrg  /* Skip over the disk name in MSDOS pathnames. */
4568c27c18e8Smrg  if (isalpha ((unsigned char) name[0]) && name[1] == ':')
4569c27c18e8Smrg    name += 2;
4570c27c18e8Smrg#endif
4571c43cc173Smrg
4572c27c18e8Smrg  for (base = name; *name; name++)
4573c27c18e8Smrg    if (IS_DIR_SEPARATOR (*name))
4574c27c18e8Smrg      base = name + 1;
4575c27c18e8Smrg  return base;
4576c27c18e8Smrg}
4577c43cc173Smrg
4578c27c18e8Smrgint
4579c27c18e8Smrgcheck_executable (const char *path)
4580c27c18e8Smrg{
4581c27c18e8Smrg  struct stat st;
4582c43cc173Smrg
458337eb1ca1Smrg  lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n",
458437eb1ca1Smrg                  nonempty (path));
4585c27c18e8Smrg  if ((!path) || (!*path))
4586c27c18e8Smrg    return 0;
4587c43cc173Smrg
4588c27c18e8Smrg  if ((stat (path, &st) >= 0)
4589c27c18e8Smrg      && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
4590c27c18e8Smrg    return 1;
4591c27c18e8Smrg  else
4592c27c18e8Smrg    return 0;
4593c27c18e8Smrg}
4594c43cc173Smrg
4595c27c18e8Smrgint
4596c27c18e8Smrgmake_executable (const char *path)
4597c27c18e8Smrg{
4598c27c18e8Smrg  int rval = 0;
4599c27c18e8Smrg  struct stat st;
4600c43cc173Smrg
460137eb1ca1Smrg  lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n",
460237eb1ca1Smrg                  nonempty (path));
4603c27c18e8Smrg  if ((!path) || (!*path))
4604c27c18e8Smrg    return 0;
4605c43cc173Smrg
4606c27c18e8Smrg  if (stat (path, &st) >= 0)
4607c27c18e8Smrg    {
4608c27c18e8Smrg      rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
4609c27c18e8Smrg    }
4610c27c18e8Smrg  return rval;
4611c27c18e8Smrg}
4612c43cc173Smrg
4613c27c18e8Smrg/* Searches for the full path of the wrapper.  Returns
4614c27c18e8Smrg   newly allocated full path name if found, NULL otherwise
4615c27c18e8Smrg   Does not chase symlinks, even on platforms that support them.
4616c27c18e8Smrg*/
4617c27c18e8Smrgchar *
4618c27c18e8Smrgfind_executable (const char *wrapper)
4619c27c18e8Smrg{
4620c27c18e8Smrg  int has_slash = 0;
4621c27c18e8Smrg  const char *p;
4622c27c18e8Smrg  const char *p_next;
4623c27c18e8Smrg  /* static buffer for getcwd */
4624c27c18e8Smrg  char tmp[LT_PATHMAX + 1];
4625c27c18e8Smrg  int tmp_len;
4626c27c18e8Smrg  char *concat_name;
4627c43cc173Smrg
462837eb1ca1Smrg  lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
462937eb1ca1Smrg                  nonempty (wrapper));
4630c43cc173Smrg
4631c27c18e8Smrg  if ((wrapper == NULL) || (*wrapper == '\0'))
4632c27c18e8Smrg    return NULL;
4633c43cc173Smrg
4634c27c18e8Smrg  /* Absolute path? */
4635c27c18e8Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4636c27c18e8Smrg  if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
4637c27c18e8Smrg    {
4638c27c18e8Smrg      concat_name = xstrdup (wrapper);
4639c27c18e8Smrg      if (check_executable (concat_name))
4640c27c18e8Smrg	return concat_name;
4641c27c18e8Smrg      XFREE (concat_name);
4642c27c18e8Smrg    }
4643c27c18e8Smrg  else
4644c27c18e8Smrg    {
4645c27c18e8Smrg#endif
4646c27c18e8Smrg      if (IS_DIR_SEPARATOR (wrapper[0]))
4647c27c18e8Smrg	{
4648c27c18e8Smrg	  concat_name = xstrdup (wrapper);
4649c27c18e8Smrg	  if (check_executable (concat_name))
4650c27c18e8Smrg	    return concat_name;
4651c27c18e8Smrg	  XFREE (concat_name);
4652c27c18e8Smrg	}
4653c27c18e8Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4654c27c18e8Smrg    }
4655c27c18e8Smrg#endif
4656c43cc173Smrg
4657c27c18e8Smrg  for (p = wrapper; *p; p++)
4658c27c18e8Smrg    if (*p == '/')
4659c27c18e8Smrg      {
4660c27c18e8Smrg	has_slash = 1;
4661c27c18e8Smrg	break;
4662c27c18e8Smrg      }
4663c27c18e8Smrg  if (!has_slash)
4664c27c18e8Smrg    {
4665c27c18e8Smrg      /* no slashes; search PATH */
4666c27c18e8Smrg      const char *path = getenv ("PATH");
4667c27c18e8Smrg      if (path != NULL)
4668c27c18e8Smrg	{
4669c27c18e8Smrg	  for (p = path; *p; p = p_next)
4670c27c18e8Smrg	    {
4671c27c18e8Smrg	      const char *q;
4672c27c18e8Smrg	      size_t p_len;
4673c27c18e8Smrg	      for (q = p; *q; q++)
4674c27c18e8Smrg		if (IS_PATH_SEPARATOR (*q))
4675c27c18e8Smrg		  break;
4676c27c18e8Smrg	      p_len = q - p;
4677c27c18e8Smrg	      p_next = (*q == '\0' ? q : q + 1);
4678c27c18e8Smrg	      if (p_len == 0)
4679c27c18e8Smrg		{
4680c27c18e8Smrg		  /* empty path: current directory */
4681c27c18e8Smrg		  if (getcwd (tmp, LT_PATHMAX) == NULL)
468237eb1ca1Smrg		    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
468337eb1ca1Smrg                              nonnull (strerror (errno)));
4684c27c18e8Smrg		  tmp_len = strlen (tmp);
4685c27c18e8Smrg		  concat_name =
4686c27c18e8Smrg		    XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
4687c27c18e8Smrg		  memcpy (concat_name, tmp, tmp_len);
4688c27c18e8Smrg		  concat_name[tmp_len] = '/';
4689c27c18e8Smrg		  strcpy (concat_name + tmp_len + 1, wrapper);
4690c27c18e8Smrg		}
4691c27c18e8Smrg	      else
4692c27c18e8Smrg		{
4693c27c18e8Smrg		  concat_name =
4694c27c18e8Smrg		    XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
4695c27c18e8Smrg		  memcpy (concat_name, p, p_len);
4696c27c18e8Smrg		  concat_name[p_len] = '/';
4697c27c18e8Smrg		  strcpy (concat_name + p_len + 1, wrapper);
4698c27c18e8Smrg		}
4699c27c18e8Smrg	      if (check_executable (concat_name))
4700c27c18e8Smrg		return concat_name;
4701c27c18e8Smrg	      XFREE (concat_name);
4702c27c18e8Smrg	    }
4703c27c18e8Smrg	}
4704c27c18e8Smrg      /* not found in PATH; assume curdir */
4705c27c18e8Smrg    }
4706c27c18e8Smrg  /* Relative path | not found in path: prepend cwd */
4707c27c18e8Smrg  if (getcwd (tmp, LT_PATHMAX) == NULL)
470837eb1ca1Smrg    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
470937eb1ca1Smrg              nonnull (strerror (errno)));
4710c27c18e8Smrg  tmp_len = strlen (tmp);
4711c27c18e8Smrg  concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
4712c27c18e8Smrg  memcpy (concat_name, tmp, tmp_len);
4713c27c18e8Smrg  concat_name[tmp_len] = '/';
4714c27c18e8Smrg  strcpy (concat_name + tmp_len + 1, wrapper);
4715c43cc173Smrg
4716c27c18e8Smrg  if (check_executable (concat_name))
4717c27c18e8Smrg    return concat_name;
4718c27c18e8Smrg  XFREE (concat_name);
4719c27c18e8Smrg  return NULL;
4720c27c18e8Smrg}
4721c43cc173Smrg
4722c27c18e8Smrgchar *
4723c27c18e8Smrgchase_symlinks (const char *pathspec)
4724c27c18e8Smrg{
4725c27c18e8Smrg#ifndef S_ISLNK
4726c27c18e8Smrg  return xstrdup (pathspec);
4727c27c18e8Smrg#else
4728c27c18e8Smrg  char buf[LT_PATHMAX];
4729c27c18e8Smrg  struct stat s;
4730c27c18e8Smrg  char *tmp_pathspec = xstrdup (pathspec);
4731c27c18e8Smrg  char *p;
4732c27c18e8Smrg  int has_symlinks = 0;
4733c27c18e8Smrg  while (strlen (tmp_pathspec) && !has_symlinks)
4734c27c18e8Smrg    {
473537eb1ca1Smrg      lt_debugprintf (__FILE__, __LINE__,
473637eb1ca1Smrg		      "checking path component for symlinks: %s\n",
473737eb1ca1Smrg		      tmp_pathspec);
4738c27c18e8Smrg      if (lstat (tmp_pathspec, &s) == 0)
4739c27c18e8Smrg	{
4740c27c18e8Smrg	  if (S_ISLNK (s.st_mode) != 0)
4741c27c18e8Smrg	    {
4742c27c18e8Smrg	      has_symlinks = 1;
4743c27c18e8Smrg	      break;
4744c27c18e8Smrg	    }
4745c43cc173Smrg
4746c27c18e8Smrg	  /* search backwards for last DIR_SEPARATOR */
4747c27c18e8Smrg	  p = tmp_pathspec + strlen (tmp_pathspec) - 1;
4748c27c18e8Smrg	  while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
4749c27c18e8Smrg	    p--;
4750c27c18e8Smrg	  if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
4751c27c18e8Smrg	    {
4752c27c18e8Smrg	      /* no more DIR_SEPARATORS left */
4753c27c18e8Smrg	      break;
4754c27c18e8Smrg	    }
4755c27c18e8Smrg	  *p = '\0';
4756c27c18e8Smrg	}
4757c27c18e8Smrg      else
4758c27c18e8Smrg	{
475937eb1ca1Smrg	  lt_fatal (__FILE__, __LINE__,
476037eb1ca1Smrg		    "error accessing file \"%s\": %s",
476137eb1ca1Smrg		    tmp_pathspec, nonnull (strerror (errno)));
4762c27c18e8Smrg	}
4763c27c18e8Smrg    }
4764c27c18e8Smrg  XFREE (tmp_pathspec);
4765c43cc173Smrg
4766c27c18e8Smrg  if (!has_symlinks)
4767c27c18e8Smrg    {
4768c27c18e8Smrg      return xstrdup (pathspec);
4769c27c18e8Smrg    }
4770c43cc173Smrg
4771c27c18e8Smrg  tmp_pathspec = realpath (pathspec, buf);
4772c27c18e8Smrg  if (tmp_pathspec == 0)
4773c27c18e8Smrg    {
477437eb1ca1Smrg      lt_fatal (__FILE__, __LINE__,
477537eb1ca1Smrg		"could not follow symlinks for %s", pathspec);
4776c27c18e8Smrg    }
4777c27c18e8Smrg  return xstrdup (tmp_pathspec);
4778c27c18e8Smrg#endif
4779c27c18e8Smrg}
4780c43cc173Smrg
4781c27c18e8Smrgchar *
4782c27c18e8Smrgstrendzap (char *str, const char *pat)
4783c27c18e8Smrg{
4784c27c18e8Smrg  size_t len, patlen;
4785c43cc173Smrg
4786c27c18e8Smrg  assert (str != NULL);
4787c27c18e8Smrg  assert (pat != NULL);
4788c43cc173Smrg
4789c27c18e8Smrg  len = strlen (str);
4790c27c18e8Smrg  patlen = strlen (pat);
4791c43cc173Smrg
4792c27c18e8Smrg  if (patlen <= len)
4793c27c18e8Smrg    {
4794c27c18e8Smrg      str += len - patlen;
4795c27c18e8Smrg      if (strcmp (str, pat) == 0)
4796c27c18e8Smrg	*str = '\0';
4797c27c18e8Smrg    }
4798c27c18e8Smrg  return str;
4799c27c18e8Smrg}
4800c43cc173Smrg
480137eb1ca1Smrgvoid
480237eb1ca1Smrglt_debugprintf (const char *file, int line, const char *fmt, ...)
480337eb1ca1Smrg{
480437eb1ca1Smrg  va_list args;
480537eb1ca1Smrg  if (lt_debug)
480637eb1ca1Smrg    {
480737eb1ca1Smrg      (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line);
480837eb1ca1Smrg      va_start (args, fmt);
480937eb1ca1Smrg      (void) vfprintf (stderr, fmt, args);
481037eb1ca1Smrg      va_end (args);
481137eb1ca1Smrg    }
481237eb1ca1Smrg}
481337eb1ca1Smrg
4814c27c18e8Smrgstatic void
481537eb1ca1Smrglt_error_core (int exit_status, const char *file,
481637eb1ca1Smrg	       int line, const char *mode,
4817c27c18e8Smrg	       const char *message, va_list ap)
4818c27c18e8Smrg{
481937eb1ca1Smrg  fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode);
4820c27c18e8Smrg  vfprintf (stderr, message, ap);
4821c27c18e8Smrg  fprintf (stderr, ".\n");
4822c43cc173Smrg
4823c27c18e8Smrg  if (exit_status >= 0)
4824c27c18e8Smrg    exit (exit_status);
4825c27c18e8Smrg}
4826c43cc173Smrg
4827c27c18e8Smrgvoid
482837eb1ca1Smrglt_fatal (const char *file, int line, const char *message, ...)
4829c27c18e8Smrg{
4830c27c18e8Smrg  va_list ap;
4831c27c18e8Smrg  va_start (ap, message);
483237eb1ca1Smrg  lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap);
4833c27c18e8Smrg  va_end (ap);
4834c27c18e8Smrg}
4835c43cc173Smrg
483637eb1ca1Smrgstatic const char *
483737eb1ca1Smrgnonnull (const char *s)
483837eb1ca1Smrg{
483937eb1ca1Smrg  return s ? s : "(null)";
484037eb1ca1Smrg}
484137eb1ca1Smrg
484237eb1ca1Smrgstatic const char *
484337eb1ca1Smrgnonempty (const char *s)
484437eb1ca1Smrg{
484537eb1ca1Smrg  return (s && !*s) ? "(empty)" : nonnull (s);
484637eb1ca1Smrg}
484737eb1ca1Smrg
4848c27c18e8Smrgvoid
4849c27c18e8Smrglt_setenv (const char *name, const char *value)
4850c27c18e8Smrg{
485137eb1ca1Smrg  lt_debugprintf (__FILE__, __LINE__,
485237eb1ca1Smrg		  "(lt_setenv) setting '%s' to '%s'\n",
485337eb1ca1Smrg                  nonnull (name), nonnull (value));
4854c27c18e8Smrg  {
4855c27c18e8Smrg#ifdef HAVE_SETENV
4856c27c18e8Smrg    /* always make a copy, for consistency with !HAVE_SETENV */
4857c27c18e8Smrg    char *str = xstrdup (value);
4858c27c18e8Smrg    setenv (name, str, 1);
4859c27c18e8Smrg#else
4860c27c18e8Smrg    int len = strlen (name) + 1 + strlen (value) + 1;
4861c27c18e8Smrg    char *str = XMALLOC (char, len);
4862c27c18e8Smrg    sprintf (str, "%s=%s", name, value);
4863c27c18e8Smrg    if (putenv (str) != EXIT_SUCCESS)
4864c27c18e8Smrg      {
4865c27c18e8Smrg        XFREE (str);
4866c27c18e8Smrg      }
4867c27c18e8Smrg#endif
4868c27c18e8Smrg  }
4869c27c18e8Smrg}
4870c43cc173Smrg
4871c27c18e8Smrgchar *
4872c27c18e8Smrglt_extend_str (const char *orig_value, const char *add, int to_end)
4873c27c18e8Smrg{
4874c27c18e8Smrg  char *new_value;
4875c27c18e8Smrg  if (orig_value && *orig_value)
4876c27c18e8Smrg    {
4877c27c18e8Smrg      int orig_value_len = strlen (orig_value);
4878c27c18e8Smrg      int add_len = strlen (add);
4879c27c18e8Smrg      new_value = XMALLOC (char, add_len + orig_value_len + 1);
4880c27c18e8Smrg      if (to_end)
4881c27c18e8Smrg        {
4882c27c18e8Smrg          strcpy (new_value, orig_value);
4883c27c18e8Smrg          strcpy (new_value + orig_value_len, add);
4884c27c18e8Smrg        }
4885c27c18e8Smrg      else
4886c27c18e8Smrg        {
4887c27c18e8Smrg          strcpy (new_value, add);
4888c27c18e8Smrg          strcpy (new_value + add_len, orig_value);
4889c27c18e8Smrg        }
4890c27c18e8Smrg    }
4891c27c18e8Smrg  else
4892c27c18e8Smrg    {
4893c27c18e8Smrg      new_value = xstrdup (add);
4894c27c18e8Smrg    }
4895c27c18e8Smrg  return new_value;
4896c27c18e8Smrg}
4897c43cc173Smrg
4898c27c18e8Smrgvoid
4899c27c18e8Smrglt_update_exe_path (const char *name, const char *value)
4900c27c18e8Smrg{
490137eb1ca1Smrg  lt_debugprintf (__FILE__, __LINE__,
490237eb1ca1Smrg		  "(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
490337eb1ca1Smrg                  nonnull (name), nonnull (value));
4904c43cc173Smrg
4905c27c18e8Smrg  if (name && *name && value && *value)
4906c27c18e8Smrg    {
4907c27c18e8Smrg      char *new_value = lt_extend_str (getenv (name), value, 0);
4908c27c18e8Smrg      /* some systems can't cope with a ':'-terminated path #' */
4909c27c18e8Smrg      int len = strlen (new_value);
4910c27c18e8Smrg      while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
4911c27c18e8Smrg        {
4912c27c18e8Smrg          new_value[len-1] = '\0';
4913c27c18e8Smrg        }
4914c27c18e8Smrg      lt_setenv (name, new_value);
4915c27c18e8Smrg      XFREE (new_value);
4916c27c18e8Smrg    }
4917c27c18e8Smrg}
4918c43cc173Smrg
4919c27c18e8Smrgvoid
4920c27c18e8Smrglt_update_lib_path (const char *name, const char *value)
4921c27c18e8Smrg{
492237eb1ca1Smrg  lt_debugprintf (__FILE__, __LINE__,
492337eb1ca1Smrg		  "(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
492437eb1ca1Smrg                  nonnull (name), nonnull (value));
4925c43cc173Smrg
4926c27c18e8Smrg  if (name && *name && value && *value)
4927c27c18e8Smrg    {
4928c27c18e8Smrg      char *new_value = lt_extend_str (getenv (name), value, 0);
4929c27c18e8Smrg      lt_setenv (name, new_value);
4930c27c18e8Smrg      XFREE (new_value);
4931c27c18e8Smrg    }
4932c27c18e8Smrg}
4933c43cc173Smrg
493437eb1ca1SmrgEOF
493537eb1ca1Smrg	    case $host_os in
493637eb1ca1Smrg	      mingw*)
493737eb1ca1Smrg		cat <<"EOF"
493837eb1ca1Smrg
493937eb1ca1Smrg/* Prepares an argument vector before calling spawn().
494037eb1ca1Smrg   Note that spawn() does not by itself call the command interpreter
494137eb1ca1Smrg     (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
494237eb1ca1Smrg      ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
494337eb1ca1Smrg         GetVersionEx(&v);
494437eb1ca1Smrg         v.dwPlatformId == VER_PLATFORM_WIN32_NT;
494537eb1ca1Smrg      }) ? "cmd.exe" : "command.com").
494637eb1ca1Smrg   Instead it simply concatenates the arguments, separated by ' ', and calls
494737eb1ca1Smrg   CreateProcess().  We must quote the arguments since Win32 CreateProcess()
494837eb1ca1Smrg   interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
494937eb1ca1Smrg   special way:
495037eb1ca1Smrg   - Space and tab are interpreted as delimiters. They are not treated as
495137eb1ca1Smrg     delimiters if they are surrounded by double quotes: "...".
495237eb1ca1Smrg   - Unescaped double quotes are removed from the input. Their only effect is
495337eb1ca1Smrg     that within double quotes, space and tab are treated like normal
495437eb1ca1Smrg     characters.
495537eb1ca1Smrg   - Backslashes not followed by double quotes are not special.
495637eb1ca1Smrg   - But 2*n+1 backslashes followed by a double quote become
495737eb1ca1Smrg     n backslashes followed by a double quote (n >= 0):
495837eb1ca1Smrg       \" -> "
495937eb1ca1Smrg       \\\" -> \"
496037eb1ca1Smrg       \\\\\" -> \\"
496137eb1ca1Smrg */
496237eb1ca1Smrg#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"
496337eb1ca1Smrg#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"
496437eb1ca1Smrgchar **
496537eb1ca1Smrgprepare_spawn (char **argv)
496637eb1ca1Smrg{
496737eb1ca1Smrg  size_t argc;
496837eb1ca1Smrg  char **new_argv;
496937eb1ca1Smrg  size_t i;
497037eb1ca1Smrg
497137eb1ca1Smrg  /* Count number of arguments.  */
497237eb1ca1Smrg  for (argc = 0; argv[argc] != NULL; argc++)
497337eb1ca1Smrg    ;
497437eb1ca1Smrg
497537eb1ca1Smrg  /* Allocate new argument vector.  */
497637eb1ca1Smrg  new_argv = XMALLOC (char *, argc + 1);
497737eb1ca1Smrg
497837eb1ca1Smrg  /* Put quoted arguments into the new argument vector.  */
497937eb1ca1Smrg  for (i = 0; i < argc; i++)
498037eb1ca1Smrg    {
498137eb1ca1Smrg      const char *string = argv[i];
498237eb1ca1Smrg
498337eb1ca1Smrg      if (string[0] == '\0')
498437eb1ca1Smrg	new_argv[i] = xstrdup ("\"\"");
498537eb1ca1Smrg      else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
498637eb1ca1Smrg	{
498737eb1ca1Smrg	  int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
498837eb1ca1Smrg	  size_t length;
498937eb1ca1Smrg	  unsigned int backslashes;
499037eb1ca1Smrg	  const char *s;
499137eb1ca1Smrg	  char *quoted_string;
499237eb1ca1Smrg	  char *p;
499337eb1ca1Smrg
499437eb1ca1Smrg	  length = 0;
499537eb1ca1Smrg	  backslashes = 0;
499637eb1ca1Smrg	  if (quote_around)
499737eb1ca1Smrg	    length++;
499837eb1ca1Smrg	  for (s = string; *s != '\0'; s++)
499937eb1ca1Smrg	    {
500037eb1ca1Smrg	      char c = *s;
500137eb1ca1Smrg	      if (c == '"')
500237eb1ca1Smrg		length += backslashes + 1;
500337eb1ca1Smrg	      length++;
500437eb1ca1Smrg	      if (c == '\\')
500537eb1ca1Smrg		backslashes++;
500637eb1ca1Smrg	      else
500737eb1ca1Smrg		backslashes = 0;
500837eb1ca1Smrg	    }
500937eb1ca1Smrg	  if (quote_around)
501037eb1ca1Smrg	    length += backslashes + 1;
501137eb1ca1Smrg
501237eb1ca1Smrg	  quoted_string = XMALLOC (char, length + 1);
501337eb1ca1Smrg
501437eb1ca1Smrg	  p = quoted_string;
501537eb1ca1Smrg	  backslashes = 0;
501637eb1ca1Smrg	  if (quote_around)
501737eb1ca1Smrg	    *p++ = '"';
501837eb1ca1Smrg	  for (s = string; *s != '\0'; s++)
501937eb1ca1Smrg	    {
502037eb1ca1Smrg	      char c = *s;
502137eb1ca1Smrg	      if (c == '"')
502237eb1ca1Smrg		{
502337eb1ca1Smrg		  unsigned int j;
502437eb1ca1Smrg		  for (j = backslashes + 1; j > 0; j--)
502537eb1ca1Smrg		    *p++ = '\\';
502637eb1ca1Smrg		}
502737eb1ca1Smrg	      *p++ = c;
502837eb1ca1Smrg	      if (c == '\\')
502937eb1ca1Smrg		backslashes++;
503037eb1ca1Smrg	      else
503137eb1ca1Smrg		backslashes = 0;
503237eb1ca1Smrg	    }
503337eb1ca1Smrg	  if (quote_around)
503437eb1ca1Smrg	    {
503537eb1ca1Smrg	      unsigned int j;
503637eb1ca1Smrg	      for (j = backslashes; j > 0; j--)
503737eb1ca1Smrg		*p++ = '\\';
503837eb1ca1Smrg	      *p++ = '"';
503937eb1ca1Smrg	    }
504037eb1ca1Smrg	  *p = '\0';
504137eb1ca1Smrg
504237eb1ca1Smrg	  new_argv[i] = quoted_string;
504337eb1ca1Smrg	}
504437eb1ca1Smrg      else
504537eb1ca1Smrg	new_argv[i] = (char *) string;
504637eb1ca1Smrg    }
504737eb1ca1Smrg  new_argv[argc] = NULL;
504837eb1ca1Smrg
504937eb1ca1Smrg  return new_argv;
505037eb1ca1Smrg}
505137eb1ca1SmrgEOF
505237eb1ca1Smrg		;;
505337eb1ca1Smrg	    esac
505437eb1ca1Smrg
505537eb1ca1Smrg            cat <<"EOF"
505637eb1ca1Smrgvoid lt_dump_script (FILE* f)
505737eb1ca1Smrg{
505837eb1ca1SmrgEOF
505937eb1ca1Smrg	    func_emit_wrapper yes |
506037eb1ca1Smrg              $SED -e 's/\([\\"]\)/\\\1/g' \
506137eb1ca1Smrg	           -e 's/^/  fputs ("/' -e 's/$/\\n", f);/'
5062c43cc173Smrg
506337eb1ca1Smrg            cat <<"EOF"
506437eb1ca1Smrg}
5065c27c18e8SmrgEOF
5066c27c18e8Smrg}
5067c27c18e8Smrg# end: func_emit_cwrapperexe_src
5068c43cc173Smrg
506937eb1ca1Smrg# func_win32_import_lib_p ARG
507037eb1ca1Smrg# True if ARG is an import lib, as indicated by $file_magic_cmd
507137eb1ca1Smrgfunc_win32_import_lib_p ()
507237eb1ca1Smrg{
507337eb1ca1Smrg    $opt_debug
507437eb1ca1Smrg    case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
507537eb1ca1Smrg    *import*) : ;;
507637eb1ca1Smrg    *) false ;;
507737eb1ca1Smrg    esac
507837eb1ca1Smrg}
507937eb1ca1Smrg
5080c27c18e8Smrg# func_mode_link arg...
5081c27c18e8Smrgfunc_mode_link ()
5082c27c18e8Smrg{
5083c27c18e8Smrg    $opt_debug
5084c27c18e8Smrg    case $host in
5085c27c18e8Smrg    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
5086c27c18e8Smrg      # It is impossible to link a dll without this setting, and
5087c27c18e8Smrg      # we shouldn't force the makefile maintainer to figure out
5088c27c18e8Smrg      # which system we are compiling for in order to pass an extra
5089c27c18e8Smrg      # flag for every libtool invocation.
5090c27c18e8Smrg      # allow_undefined=no
5091c43cc173Smrg
5092c27c18e8Smrg      # FIXME: Unfortunately, there are problems with the above when trying
5093c27c18e8Smrg      # to make a dll which has undefined symbols, in which case not
5094c27c18e8Smrg      # even a static library is built.  For now, we need to specify
5095c27c18e8Smrg      # -no-undefined on the libtool link line when we can be certain
5096c27c18e8Smrg      # that all symbols are satisfied, otherwise we get a static library.
5097c27c18e8Smrg      allow_undefined=yes
5098c27c18e8Smrg      ;;
5099c27c18e8Smrg    *)
5100c27c18e8Smrg      allow_undefined=yes
5101c27c18e8Smrg      ;;
5102c27c18e8Smrg    esac
5103c27c18e8Smrg    libtool_args=$nonopt
5104c27c18e8Smrg    base_compile="$nonopt $@"
5105c27c18e8Smrg    compile_command=$nonopt
5106c27c18e8Smrg    finalize_command=$nonopt
5107c43cc173Smrg
5108c27c18e8Smrg    compile_rpath=
5109c27c18e8Smrg    finalize_rpath=
5110c27c18e8Smrg    compile_shlibpath=
5111c27c18e8Smrg    finalize_shlibpath=
5112c27c18e8Smrg    convenience=
5113c27c18e8Smrg    old_convenience=
5114c27c18e8Smrg    deplibs=
5115c27c18e8Smrg    old_deplibs=
5116c27c18e8Smrg    compiler_flags=
5117c27c18e8Smrg    linker_flags=
5118c27c18e8Smrg    dllsearchpath=
5119c27c18e8Smrg    lib_search_path=`pwd`
5120c27c18e8Smrg    inst_prefix_dir=
5121c27c18e8Smrg    new_inherited_linker_flags=
5122c43cc173Smrg
5123c27c18e8Smrg    avoid_version=no
512437eb1ca1Smrg    bindir=
5125c27c18e8Smrg    dlfiles=
5126c27c18e8Smrg    dlprefiles=
5127c27c18e8Smrg    dlself=no
5128c27c18e8Smrg    export_dynamic=no
5129c27c18e8Smrg    export_symbols=
5130c27c18e8Smrg    export_symbols_regex=
5131c27c18e8Smrg    generated=
5132c27c18e8Smrg    libobjs=
5133c27c18e8Smrg    ltlibs=
5134c27c18e8Smrg    module=no
5135c27c18e8Smrg    no_install=no
5136c27c18e8Smrg    objs=
5137c27c18e8Smrg    non_pic_objects=
5138c27c18e8Smrg    precious_files_regex=
5139c27c18e8Smrg    prefer_static_libs=no
5140c27c18e8Smrg    preload=no
5141c27c18e8Smrg    prev=
5142c27c18e8Smrg    prevarg=
5143c27c18e8Smrg    release=
5144c27c18e8Smrg    rpath=
5145c27c18e8Smrg    xrpath=
5146c27c18e8Smrg    perm_rpath=
5147c27c18e8Smrg    temp_rpath=
5148c27c18e8Smrg    thread_safe=no
5149c27c18e8Smrg    vinfo=
5150c27c18e8Smrg    vinfo_number=no
5151c27c18e8Smrg    weak_libs=
5152c27c18e8Smrg    single_module="${wl}-single_module"
5153c27c18e8Smrg    func_infer_tag $base_compile
5154c43cc173Smrg
5155c27c18e8Smrg    # We need to know -static, to get the right output filenames.
5156c27c18e8Smrg    for arg
5157c27c18e8Smrg    do
5158c27c18e8Smrg      case $arg in
5159c27c18e8Smrg      -shared)
5160c27c18e8Smrg	test "$build_libtool_libs" != yes && \
5161c27c18e8Smrg	  func_fatal_configuration "can not build a shared library"
5162c27c18e8Smrg	build_old_libs=no
5163c27c18e8Smrg	break
5164c27c18e8Smrg	;;
5165c27c18e8Smrg      -all-static | -static | -static-libtool-libs)
5166c27c18e8Smrg	case $arg in
5167c27c18e8Smrg	-all-static)
5168c27c18e8Smrg	  if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
5169c27c18e8Smrg	    func_warning "complete static linking is impossible in this configuration"
5170c27c18e8Smrg	  fi
5171c27c18e8Smrg	  if test -n "$link_static_flag"; then
5172c27c18e8Smrg	    dlopen_self=$dlopen_self_static
5173c27c18e8Smrg	  fi
5174c27c18e8Smrg	  prefer_static_libs=yes
5175c27c18e8Smrg	  ;;
5176c27c18e8Smrg	-static)
5177c27c18e8Smrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
5178c27c18e8Smrg	    dlopen_self=$dlopen_self_static
5179c27c18e8Smrg	  fi
5180c27c18e8Smrg	  prefer_static_libs=built
5181c27c18e8Smrg	  ;;
5182c27c18e8Smrg	-static-libtool-libs)
5183c27c18e8Smrg	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
5184c27c18e8Smrg	    dlopen_self=$dlopen_self_static
5185c27c18e8Smrg	  fi
5186c27c18e8Smrg	  prefer_static_libs=yes
5187c27c18e8Smrg	  ;;
5188c27c18e8Smrg	esac
5189c27c18e8Smrg	build_libtool_libs=no
5190c27c18e8Smrg	build_old_libs=yes
5191c27c18e8Smrg	break
5192c43cc173Smrg	;;
5193c43cc173Smrg      esac
5194c27c18e8Smrg    done
5195c43cc173Smrg
5196c27c18e8Smrg    # See if our shared archives depend on static archives.
5197c27c18e8Smrg    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
5198c43cc173Smrg
5199c27c18e8Smrg    # Go through the arguments, transforming them on the way.
5200c27c18e8Smrg    while test "$#" -gt 0; do
5201c27c18e8Smrg      arg="$1"
5202c27c18e8Smrg      shift
5203c27c18e8Smrg      func_quote_for_eval "$arg"
5204c27c18e8Smrg      qarg=$func_quote_for_eval_unquoted_result
5205c27c18e8Smrg      func_append libtool_args " $func_quote_for_eval_result"
5206c43cc173Smrg
5207c27c18e8Smrg      # If the previous option needs an argument, assign it.
5208c27c18e8Smrg      if test -n "$prev"; then
5209c27c18e8Smrg	case $prev in
5210c27c18e8Smrg	output)
5211c27c18e8Smrg	  func_append compile_command " @OUTPUT@"
5212c27c18e8Smrg	  func_append finalize_command " @OUTPUT@"
5213c43cc173Smrg	  ;;
5214c43cc173Smrg	esac
5215c43cc173Smrg
5216c27c18e8Smrg	case $prev in
521737eb1ca1Smrg	bindir)
521837eb1ca1Smrg	  bindir="$arg"
521937eb1ca1Smrg	  prev=
522037eb1ca1Smrg	  continue
522137eb1ca1Smrg	  ;;
5222c27c18e8Smrg	dlfiles|dlprefiles)
5223c27c18e8Smrg	  if test "$preload" = no; then
5224c27c18e8Smrg	    # Add the symbol object into the linking commands.
5225c27c18e8Smrg	    func_append compile_command " @SYMFILE@"
5226c27c18e8Smrg	    func_append finalize_command " @SYMFILE@"
5227c27c18e8Smrg	    preload=yes
5228c27c18e8Smrg	  fi
5229c27c18e8Smrg	  case $arg in
5230c27c18e8Smrg	  *.la | *.lo) ;;  # We handle these cases below.
5231c27c18e8Smrg	  force)
5232c27c18e8Smrg	    if test "$dlself" = no; then
5233c27c18e8Smrg	      dlself=needless
5234c27c18e8Smrg	      export_dynamic=yes
5235c27c18e8Smrg	    fi
5236c27c18e8Smrg	    prev=
5237c27c18e8Smrg	    continue
5238c27c18e8Smrg	    ;;
5239c27c18e8Smrg	  self)
5240c27c18e8Smrg	    if test "$prev" = dlprefiles; then
5241c27c18e8Smrg	      dlself=yes
5242c27c18e8Smrg	    elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
5243c27c18e8Smrg	      dlself=yes
5244c43cc173Smrg	    else
5245c27c18e8Smrg	      dlself=needless
5246c27c18e8Smrg	      export_dynamic=yes
5247c43cc173Smrg	    fi
5248c27c18e8Smrg	    prev=
5249c27c18e8Smrg	    continue
5250c27c18e8Smrg	    ;;
5251c27c18e8Smrg	  *)
5252c27c18e8Smrg	    if test "$prev" = dlfiles; then
5253b789ec8aSmrg	      func_append dlfiles " $arg"
5254c27c18e8Smrg	    else
5255b789ec8aSmrg	      func_append dlprefiles " $arg"
5256c27c18e8Smrg	    fi
5257c27c18e8Smrg	    prev=
5258c27c18e8Smrg	    continue
5259c27c18e8Smrg	    ;;
5260c43cc173Smrg	  esac
5261c43cc173Smrg	  ;;
5262c27c18e8Smrg	expsyms)
5263c27c18e8Smrg	  export_symbols="$arg"
5264c27c18e8Smrg	  test -f "$arg" \
5265c27c18e8Smrg	    || func_fatal_error "symbol file \`$arg' does not exist"
5266c27c18e8Smrg	  prev=
5267c27c18e8Smrg	  continue
5268c27c18e8Smrg	  ;;
5269c27c18e8Smrg	expsyms_regex)
5270c27c18e8Smrg	  export_symbols_regex="$arg"
5271c27c18e8Smrg	  prev=
5272c27c18e8Smrg	  continue
5273c27c18e8Smrg	  ;;
5274c27c18e8Smrg	framework)
5275c27c18e8Smrg	  case $host in
5276c27c18e8Smrg	    *-*-darwin*)
5277c27c18e8Smrg	      case "$deplibs " in
5278c27c18e8Smrg		*" $qarg.ltframework "*) ;;
5279b789ec8aSmrg		*) func_append deplibs " $qarg.ltframework" # this is fixed later
5280c27c18e8Smrg		   ;;
5281c43cc173Smrg	      esac
5282c27c18e8Smrg	      ;;
5283c43cc173Smrg	  esac
5284c27c18e8Smrg	  prev=
5285c27c18e8Smrg	  continue
5286c27c18e8Smrg	  ;;
5287c27c18e8Smrg	inst_prefix)
5288c27c18e8Smrg	  inst_prefix_dir="$arg"
5289c27c18e8Smrg	  prev=
5290c27c18e8Smrg	  continue
5291c27c18e8Smrg	  ;;
5292c27c18e8Smrg	objectlist)
5293c27c18e8Smrg	  if test -f "$arg"; then
5294c27c18e8Smrg	    save_arg=$arg
5295c27c18e8Smrg	    moreargs=
5296c27c18e8Smrg	    for fil in `cat "$save_arg"`
5297c27c18e8Smrg	    do
5298b789ec8aSmrg#	      func_append moreargs " $fil"
5299c27c18e8Smrg	      arg=$fil
5300c27c18e8Smrg	      # A libtool-controlled object.
5301c43cc173Smrg
5302c27c18e8Smrg	      # Check to see that this really is a libtool object.
5303c27c18e8Smrg	      if func_lalib_unsafe_p "$arg"; then
5304c27c18e8Smrg		pic_object=
5305c27c18e8Smrg		non_pic_object=
5306c43cc173Smrg
5307c27c18e8Smrg		# Read the .lo file
5308c27c18e8Smrg		func_source "$arg"
5309c43cc173Smrg
5310c27c18e8Smrg		if test -z "$pic_object" ||
5311c27c18e8Smrg		   test -z "$non_pic_object" ||
5312c27c18e8Smrg		   test "$pic_object" = none &&
5313c27c18e8Smrg		   test "$non_pic_object" = none; then
5314c27c18e8Smrg		  func_fatal_error "cannot find name of object for \`$arg'"
5315c27c18e8Smrg		fi
5316c43cc173Smrg
5317c27c18e8Smrg		# Extract subdirectory from the argument.
5318c27c18e8Smrg		func_dirname "$arg" "/" ""
5319c27c18e8Smrg		xdir="$func_dirname_result"
5320c43cc173Smrg
5321c27c18e8Smrg		if test "$pic_object" != none; then
5322c27c18e8Smrg		  # Prepend the subdirectory the object is found in.
5323c27c18e8Smrg		  pic_object="$xdir$pic_object"
5324c43cc173Smrg
5325c27c18e8Smrg		  if test "$prev" = dlfiles; then
5326c27c18e8Smrg		    if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
5327b789ec8aSmrg		      func_append dlfiles " $pic_object"
5328c27c18e8Smrg		      prev=
5329c27c18e8Smrg		      continue
5330c27c18e8Smrg		    else
5331c27c18e8Smrg		      # If libtool objects are unsupported, then we need to preload.
5332c27c18e8Smrg		      prev=dlprefiles
5333c27c18e8Smrg		    fi
5334c27c18e8Smrg		  fi
5335c43cc173Smrg
5336c27c18e8Smrg		  # CHECK ME:  I think I busted this.  -Ossama
5337c27c18e8Smrg		  if test "$prev" = dlprefiles; then
5338c27c18e8Smrg		    # Preload the old-style object.
5339b789ec8aSmrg		    func_append dlprefiles " $pic_object"
5340c27c18e8Smrg		    prev=
5341c27c18e8Smrg		  fi
5342c43cc173Smrg
5343c27c18e8Smrg		  # A PIC object.
5344c27c18e8Smrg		  func_append libobjs " $pic_object"
5345c27c18e8Smrg		  arg="$pic_object"
5346c27c18e8Smrg		fi
5347c43cc173Smrg
5348c27c18e8Smrg		# Non-PIC object.
5349c27c18e8Smrg		if test "$non_pic_object" != none; then
5350c27c18e8Smrg		  # Prepend the subdirectory the object is found in.
5351c27c18e8Smrg		  non_pic_object="$xdir$non_pic_object"
5352c43cc173Smrg
5353c27c18e8Smrg		  # A standard non-PIC object
5354c27c18e8Smrg		  func_append non_pic_objects " $non_pic_object"
5355c27c18e8Smrg		  if test -z "$pic_object" || test "$pic_object" = none ; then
5356c27c18e8Smrg		    arg="$non_pic_object"
5357c27c18e8Smrg		  fi
5358c27c18e8Smrg		else
5359c27c18e8Smrg		  # If the PIC object exists, use it instead.
5360c27c18e8Smrg		  # $xdir was prepended to $pic_object above.
5361c27c18e8Smrg		  non_pic_object="$pic_object"
5362c27c18e8Smrg		  func_append non_pic_objects " $non_pic_object"
5363c27c18e8Smrg		fi
5364c27c18e8Smrg	      else
5365c27c18e8Smrg		# Only an error if not doing a dry-run.
5366c27c18e8Smrg		if $opt_dry_run; then
5367c27c18e8Smrg		  # Extract subdirectory from the argument.
5368c27c18e8Smrg		  func_dirname "$arg" "/" ""
5369c27c18e8Smrg		  xdir="$func_dirname_result"
5370c27c18e8Smrg
5371c27c18e8Smrg		  func_lo2o "$arg"
5372c27c18e8Smrg		  pic_object=$xdir$objdir/$func_lo2o_result
5373c27c18e8Smrg		  non_pic_object=$xdir$func_lo2o_result
5374c27c18e8Smrg		  func_append libobjs " $pic_object"
5375c27c18e8Smrg		  func_append non_pic_objects " $non_pic_object"
5376c27c18e8Smrg	        else
5377c27c18e8Smrg		  func_fatal_error "\`$arg' is not a valid libtool object"
5378c27c18e8Smrg		fi
5379c27c18e8Smrg	      fi
5380c43cc173Smrg	    done
5381c27c18e8Smrg	  else
5382c27c18e8Smrg	    func_fatal_error "link input file \`$arg' does not exist"
5383c43cc173Smrg	  fi
5384c27c18e8Smrg	  arg=$save_arg
5385c27c18e8Smrg	  prev=
5386c27c18e8Smrg	  continue
5387c27c18e8Smrg	  ;;
5388c27c18e8Smrg	precious_regex)
5389c27c18e8Smrg	  precious_files_regex="$arg"
5390c27c18e8Smrg	  prev=
5391c27c18e8Smrg	  continue
5392c27c18e8Smrg	  ;;
5393c27c18e8Smrg	release)
5394c27c18e8Smrg	  release="-$arg"
5395c27c18e8Smrg	  prev=
5396c27c18e8Smrg	  continue
5397c27c18e8Smrg	  ;;
5398c27c18e8Smrg	rpath | xrpath)
5399c27c18e8Smrg	  # We need an absolute path.
5400c27c18e8Smrg	  case $arg in
5401c27c18e8Smrg	  [\\/]* | [A-Za-z]:[\\/]*) ;;
5402c27c18e8Smrg	  *)
5403c27c18e8Smrg	    func_fatal_error "only absolute run-paths are allowed"
5404c27c18e8Smrg	    ;;
5405c43cc173Smrg	  esac
5406c27c18e8Smrg	  if test "$prev" = rpath; then
5407c27c18e8Smrg	    case "$rpath " in
5408c27c18e8Smrg	    *" $arg "*) ;;
5409b789ec8aSmrg	    *) func_append rpath " $arg" ;;
5410c27c18e8Smrg	    esac
5411c27c18e8Smrg	  else
5412c27c18e8Smrg	    case "$xrpath " in
5413c27c18e8Smrg	    *" $arg "*) ;;
5414b789ec8aSmrg	    *) func_append xrpath " $arg" ;;
5415c27c18e8Smrg	    esac
5416c27c18e8Smrg	  fi
5417c27c18e8Smrg	  prev=
5418c27c18e8Smrg	  continue
5419c27c18e8Smrg	  ;;
5420c27c18e8Smrg	shrext)
5421c27c18e8Smrg	  shrext_cmds="$arg"
5422c27c18e8Smrg	  prev=
5423c27c18e8Smrg	  continue
5424c27c18e8Smrg	  ;;
5425c27c18e8Smrg	weak)
5426b789ec8aSmrg	  func_append weak_libs " $arg"
5427c27c18e8Smrg	  prev=
5428c27c18e8Smrg	  continue
5429c27c18e8Smrg	  ;;
5430c27c18e8Smrg	xcclinker)
5431b789ec8aSmrg	  func_append linker_flags " $qarg"
5432b789ec8aSmrg	  func_append compiler_flags " $qarg"
5433c27c18e8Smrg	  prev=
5434c27c18e8Smrg	  func_append compile_command " $qarg"
5435c27c18e8Smrg	  func_append finalize_command " $qarg"
5436c27c18e8Smrg	  continue
5437c27c18e8Smrg	  ;;
5438c27c18e8Smrg	xcompiler)
5439b789ec8aSmrg	  func_append compiler_flags " $qarg"
5440c27c18e8Smrg	  prev=
5441c27c18e8Smrg	  func_append compile_command " $qarg"
5442c27c18e8Smrg	  func_append finalize_command " $qarg"
5443c27c18e8Smrg	  continue
5444c27c18e8Smrg	  ;;
5445c27c18e8Smrg	xlinker)
5446b789ec8aSmrg	  func_append linker_flags " $qarg"
5447b789ec8aSmrg	  func_append compiler_flags " $wl$qarg"
5448c27c18e8Smrg	  prev=
5449c27c18e8Smrg	  func_append compile_command " $wl$qarg"
5450c27c18e8Smrg	  func_append finalize_command " $wl$qarg"
5451c27c18e8Smrg	  continue
5452c43cc173Smrg	  ;;
5453c43cc173Smrg	*)
5454c27c18e8Smrg	  eval "$prev=\"\$arg\""
5455c27c18e8Smrg	  prev=
5456c27c18e8Smrg	  continue
5457c43cc173Smrg	  ;;
5458c43cc173Smrg	esac
5459c27c18e8Smrg      fi # test -n "$prev"
5460c43cc173Smrg
5461c27c18e8Smrg      prevarg="$arg"
5462c43cc173Smrg
5463c27c18e8Smrg      case $arg in
5464c27c18e8Smrg      -all-static)
5465c27c18e8Smrg	if test -n "$link_static_flag"; then
5466c27c18e8Smrg	  # See comment for -static flag below, for more details.
5467c27c18e8Smrg	  func_append compile_command " $link_static_flag"
5468c27c18e8Smrg	  func_append finalize_command " $link_static_flag"
5469c43cc173Smrg	fi
5470c27c18e8Smrg	continue
5471c27c18e8Smrg	;;
5472c43cc173Smrg
5473c27c18e8Smrg      -allow-undefined)
5474c27c18e8Smrg	# FIXME: remove this flag sometime in the future.
5475c27c18e8Smrg	func_fatal_error "\`-allow-undefined' must not be used because it is the default"
5476c27c18e8Smrg	;;
5477c43cc173Smrg
5478c27c18e8Smrg      -avoid-version)
5479c27c18e8Smrg	avoid_version=yes
5480c27c18e8Smrg	continue
5481c27c18e8Smrg	;;
5482c43cc173Smrg
548337eb1ca1Smrg      -bindir)
548437eb1ca1Smrg	prev=bindir
548537eb1ca1Smrg	continue
548637eb1ca1Smrg	;;
548737eb1ca1Smrg
5488c27c18e8Smrg      -dlopen)
5489c27c18e8Smrg	prev=dlfiles
5490c27c18e8Smrg	continue
5491c27c18e8Smrg	;;
5492c43cc173Smrg
5493c27c18e8Smrg      -dlpreopen)
5494c27c18e8Smrg	prev=dlprefiles
5495c27c18e8Smrg	continue
5496c27c18e8Smrg	;;
5497c43cc173Smrg
5498c27c18e8Smrg      -export-dynamic)
5499c27c18e8Smrg	export_dynamic=yes
5500c27c18e8Smrg	continue
5501c27c18e8Smrg	;;
5502c43cc173Smrg
5503c27c18e8Smrg      -export-symbols | -export-symbols-regex)
5504c27c18e8Smrg	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
5505c27c18e8Smrg	  func_fatal_error "more than one -exported-symbols argument is not allowed"
5506c27c18e8Smrg	fi
5507c27c18e8Smrg	if test "X$arg" = "X-export-symbols"; then
5508c27c18e8Smrg	  prev=expsyms
5509c43cc173Smrg	else
5510c27c18e8Smrg	  prev=expsyms_regex
5511c43cc173Smrg	fi
5512c27c18e8Smrg	continue
5513c27c18e8Smrg	;;
5514c43cc173Smrg
5515c27c18e8Smrg      -framework)
5516c27c18e8Smrg	prev=framework
5517c27c18e8Smrg	continue
5518c27c18e8Smrg	;;
5519c43cc173Smrg
5520c27c18e8Smrg      -inst-prefix-dir)
5521c27c18e8Smrg	prev=inst_prefix
5522c27c18e8Smrg	continue
5523c27c18e8Smrg	;;
5524c43cc173Smrg
5525c27c18e8Smrg      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
5526c27c18e8Smrg      # so, if we see these flags be careful not to treat them like -L
5527c27c18e8Smrg      -L[A-Z][A-Z]*:*)
5528c27c18e8Smrg	case $with_gcc/$host in
5529c27c18e8Smrg	no/*-*-irix* | /*-*-irix*)
5530c27c18e8Smrg	  func_append compile_command " $arg"
5531c27c18e8Smrg	  func_append finalize_command " $arg"
5532c27c18e8Smrg	  ;;
5533c27c18e8Smrg	esac
5534c27c18e8Smrg	continue
5535c27c18e8Smrg	;;
5536c43cc173Smrg
5537c27c18e8Smrg      -L*)
5538b789ec8aSmrg	func_stripname "-L" '' "$arg"
5539b789ec8aSmrg	if test -z "$func_stripname_result"; then
5540c27c18e8Smrg	  if test "$#" -gt 0; then
5541c27c18e8Smrg	    func_fatal_error "require no space between \`-L' and \`$1'"
5542c43cc173Smrg	  else
5543c27c18e8Smrg	    func_fatal_error "need path for \`-L' option"
5544c43cc173Smrg	  fi
5545c27c18e8Smrg	fi
5546b789ec8aSmrg	func_resolve_sysroot "$func_stripname_result"
5547b789ec8aSmrg	dir=$func_resolve_sysroot_result
5548c27c18e8Smrg	# We need an absolute path.
5549c27c18e8Smrg	case $dir in
5550c27c18e8Smrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
5551c27c18e8Smrg	*)
5552c27c18e8Smrg	  absdir=`cd "$dir" && pwd`
5553c27c18e8Smrg	  test -z "$absdir" && \
5554c27c18e8Smrg	    func_fatal_error "cannot determine absolute directory name of \`$dir'"
5555c27c18e8Smrg	  dir="$absdir"
5556c27c18e8Smrg	  ;;
5557c43cc173Smrg	esac
5558c27c18e8Smrg	case "$deplibs " in
5559b789ec8aSmrg	*" -L$dir "* | *" $arg "*)
5560b789ec8aSmrg	  # Will only happen for absolute or sysroot arguments
5561b789ec8aSmrg	  ;;
5562c27c18e8Smrg	*)
5563b789ec8aSmrg	  # Preserve sysroot, but never include relative directories
5564b789ec8aSmrg	  case $dir in
5565b789ec8aSmrg	    [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;;
5566b789ec8aSmrg	    *) func_append deplibs " -L$dir" ;;
5567b789ec8aSmrg	  esac
5568b789ec8aSmrg	  func_append lib_search_path " $dir"
5569c27c18e8Smrg	  ;;
5570c43cc173Smrg	esac
5571c43cc173Smrg	case $host in
5572c27c18e8Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
557337eb1ca1Smrg	  testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
5574c27c18e8Smrg	  case :$dllsearchpath: in
5575c27c18e8Smrg	  *":$dir:"*) ;;
5576c27c18e8Smrg	  ::) dllsearchpath=$dir;;
5577b789ec8aSmrg	  *) func_append dllsearchpath ":$dir";;
5578c27c18e8Smrg	  esac
5579c27c18e8Smrg	  case :$dllsearchpath: in
5580c27c18e8Smrg	  *":$testbindir:"*) ;;
5581c27c18e8Smrg	  ::) dllsearchpath=$testbindir;;
5582b789ec8aSmrg	  *) func_append dllsearchpath ":$testbindir";;
5583c27c18e8Smrg	  esac
5584c27c18e8Smrg	  ;;
5585c43cc173Smrg	esac
5586c27c18e8Smrg	continue
5587c27c18e8Smrg	;;
5588c43cc173Smrg
5589c27c18e8Smrg      -l*)
5590c27c18e8Smrg	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
5591c27c18e8Smrg	  case $host in
559237eb1ca1Smrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
5593c27c18e8Smrg	    # These systems don't actually have a C or math library (as such)
5594c27c18e8Smrg	    continue
5595c27c18e8Smrg	    ;;
5596c27c18e8Smrg	  *-*-os2*)
5597c27c18e8Smrg	    # These systems don't actually have a C library (as such)
5598c27c18e8Smrg	    test "X$arg" = "X-lc" && continue
5599c27c18e8Smrg	    ;;
5600c27c18e8Smrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
5601c27c18e8Smrg	    # Do not include libc due to us having libc/libc_r.
5602c27c18e8Smrg	    test "X$arg" = "X-lc" && continue
5603c27c18e8Smrg	    ;;
5604c27c18e8Smrg	  *-*-rhapsody* | *-*-darwin1.[012])
5605c27c18e8Smrg	    # Rhapsody C and math libraries are in the System framework
5606b789ec8aSmrg	    func_append deplibs " System.ltframework"
5607c27c18e8Smrg	    continue
5608c27c18e8Smrg	    ;;
5609c27c18e8Smrg	  *-*-sco3.2v5* | *-*-sco5v6*)
5610c27c18e8Smrg	    # Causes problems with __ctype
5611c27c18e8Smrg	    test "X$arg" = "X-lc" && continue
5612c27c18e8Smrg	    ;;
5613c27c18e8Smrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
5614c27c18e8Smrg	    # Compiler inserts libc in the correct place for threads to work
5615c27c18e8Smrg	    test "X$arg" = "X-lc" && continue
5616c27c18e8Smrg	    ;;
5617c27c18e8Smrg	  esac
5618c27c18e8Smrg	elif test "X$arg" = "X-lc_r"; then
5619c27c18e8Smrg	 case $host in
5620c27c18e8Smrg	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
5621c27c18e8Smrg	   # Do not include libc_r directly, use -pthread flag.
5622c27c18e8Smrg	   continue
5623c27c18e8Smrg	   ;;
5624c27c18e8Smrg	 esac
5625c27c18e8Smrg	fi
5626b789ec8aSmrg	func_append deplibs " $arg"
5627c27c18e8Smrg	continue
5628c27c18e8Smrg	;;
5629c43cc173Smrg
5630c27c18e8Smrg      -module)
5631c27c18e8Smrg	module=yes
5632c27c18e8Smrg	continue
5633c27c18e8Smrg	;;
5634c43cc173Smrg
5635c27c18e8Smrg      # Tru64 UNIX uses -model [arg] to determine the layout of C++
5636c27c18e8Smrg      # classes, name mangling, and exception handling.
5637c27c18e8Smrg      # Darwin uses the -arch flag to determine output architecture.
5638b789ec8aSmrg      -model|-arch|-isysroot|--sysroot)
5639b789ec8aSmrg	func_append compiler_flags " $arg"
5640c27c18e8Smrg	func_append compile_command " $arg"
5641c27c18e8Smrg	func_append finalize_command " $arg"
5642c27c18e8Smrg	prev=xcompiler
5643c27c18e8Smrg	continue
5644c27c18e8Smrg	;;
5645c43cc173Smrg
5646c27c18e8Smrg      -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
5647b789ec8aSmrg	func_append compiler_flags " $arg"
5648c27c18e8Smrg	func_append compile_command " $arg"
5649c27c18e8Smrg	func_append finalize_command " $arg"
5650c27c18e8Smrg	case "$new_inherited_linker_flags " in
5651c27c18e8Smrg	    *" $arg "*) ;;
5652b789ec8aSmrg	    * ) func_append new_inherited_linker_flags " $arg" ;;
5653c27c18e8Smrg	esac
5654c27c18e8Smrg	continue
5655c27c18e8Smrg	;;
5656c43cc173Smrg
5657c27c18e8Smrg      -multi_module)
5658c27c18e8Smrg	single_module="${wl}-multi_module"
5659c27c18e8Smrg	continue
5660c27c18e8Smrg	;;
5661c43cc173Smrg
5662c27c18e8Smrg      -no-fast-install)
5663c27c18e8Smrg	fast_install=no
5664c27c18e8Smrg	continue
5665c27c18e8Smrg	;;
5666c43cc173Smrg
5667c27c18e8Smrg      -no-install)
5668c27c18e8Smrg	case $host in
5669c27c18e8Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
5670c27c18e8Smrg	  # The PATH hackery in wrapper scripts is required on Windows
5671c27c18e8Smrg	  # and Darwin in order for the loader to find any dlls it needs.
5672c27c18e8Smrg	  func_warning "\`-no-install' is ignored for $host"
5673c27c18e8Smrg	  func_warning "assuming \`-no-fast-install' instead"
5674c27c18e8Smrg	  fast_install=no
5675c27c18e8Smrg	  ;;
5676c27c18e8Smrg	*) no_install=yes ;;
5677c27c18e8Smrg	esac
5678c27c18e8Smrg	continue
5679c27c18e8Smrg	;;
5680c43cc173Smrg
5681c27c18e8Smrg      -no-undefined)
5682c27c18e8Smrg	allow_undefined=no
5683c27c18e8Smrg	continue
5684c27c18e8Smrg	;;
5685c43cc173Smrg
5686c27c18e8Smrg      -objectlist)
5687c27c18e8Smrg	prev=objectlist
5688c27c18e8Smrg	continue
5689c27c18e8Smrg	;;
5690c43cc173Smrg
5691c27c18e8Smrg      -o) prev=output ;;
5692c43cc173Smrg
5693c27c18e8Smrg      -precious-files-regex)
5694c27c18e8Smrg	prev=precious_regex
5695c27c18e8Smrg	continue
5696c27c18e8Smrg	;;
5697c43cc173Smrg
5698c27c18e8Smrg      -release)
5699c27c18e8Smrg	prev=release
5700c27c18e8Smrg	continue
5701c27c18e8Smrg	;;
5702c43cc173Smrg
5703c27c18e8Smrg      -rpath)
5704c27c18e8Smrg	prev=rpath
5705c27c18e8Smrg	continue
5706c27c18e8Smrg	;;
5707c43cc173Smrg
5708c27c18e8Smrg      -R)
5709c27c18e8Smrg	prev=xrpath
5710c27c18e8Smrg	continue
5711c27c18e8Smrg	;;
5712c43cc173Smrg
5713c27c18e8Smrg      -R*)
5714c27c18e8Smrg	func_stripname '-R' '' "$arg"
5715c27c18e8Smrg	dir=$func_stripname_result
5716c27c18e8Smrg	# We need an absolute path.
5717c27c18e8Smrg	case $dir in
5718c27c18e8Smrg	[\\/]* | [A-Za-z]:[\\/]*) ;;
5719b789ec8aSmrg	=*)
5720b789ec8aSmrg	  func_stripname '=' '' "$dir"
5721b789ec8aSmrg	  dir=$lt_sysroot$func_stripname_result
5722b789ec8aSmrg	  ;;
5723c27c18e8Smrg	*)
5724c27c18e8Smrg	  func_fatal_error "only absolute run-paths are allowed"
5725c27c18e8Smrg	  ;;
5726c27c18e8Smrg	esac
5727c27c18e8Smrg	case "$xrpath " in
5728c27c18e8Smrg	*" $dir "*) ;;
5729b789ec8aSmrg	*) func_append xrpath " $dir" ;;
5730c27c18e8Smrg	esac
5731c27c18e8Smrg	continue
5732c27c18e8Smrg	;;
5733c43cc173Smrg
5734c27c18e8Smrg      -shared)
5735c27c18e8Smrg	# The effects of -shared are defined in a previous loop.
5736c27c18e8Smrg	continue
5737c27c18e8Smrg	;;
5738c43cc173Smrg
5739c27c18e8Smrg      -shrext)
5740c27c18e8Smrg	prev=shrext
5741c27c18e8Smrg	continue
5742c27c18e8Smrg	;;
5743c43cc173Smrg
5744c27c18e8Smrg      -static | -static-libtool-libs)
5745c27c18e8Smrg	# The effects of -static are defined in a previous loop.
5746c27c18e8Smrg	# We used to do the same as -all-static on platforms that
5747c27c18e8Smrg	# didn't have a PIC flag, but the assumption that the effects
5748c27c18e8Smrg	# would be equivalent was wrong.  It would break on at least
5749c27c18e8Smrg	# Digital Unix and AIX.
5750c27c18e8Smrg	continue
5751c27c18e8Smrg	;;
5752c43cc173Smrg
5753c27c18e8Smrg      -thread-safe)
5754c27c18e8Smrg	thread_safe=yes
5755c27c18e8Smrg	continue
5756c27c18e8Smrg	;;
5757c43cc173Smrg
5758c27c18e8Smrg      -version-info)
5759c27c18e8Smrg	prev=vinfo
5760c27c18e8Smrg	continue
5761c27c18e8Smrg	;;
5762c43cc173Smrg
5763c27c18e8Smrg      -version-number)
5764c27c18e8Smrg	prev=vinfo
5765c27c18e8Smrg	vinfo_number=yes
5766c27c18e8Smrg	continue
5767c27c18e8Smrg	;;
5768c43cc173Smrg
5769c27c18e8Smrg      -weak)
5770c27c18e8Smrg        prev=weak
5771c27c18e8Smrg	continue
5772c27c18e8Smrg	;;
5773c43cc173Smrg
5774c27c18e8Smrg      -Wc,*)
5775c27c18e8Smrg	func_stripname '-Wc,' '' "$arg"
5776c27c18e8Smrg	args=$func_stripname_result
5777c27c18e8Smrg	arg=
5778c27c18e8Smrg	save_ifs="$IFS"; IFS=','
5779c27c18e8Smrg	for flag in $args; do
5780c27c18e8Smrg	  IFS="$save_ifs"
5781c27c18e8Smrg          func_quote_for_eval "$flag"
5782b789ec8aSmrg	  func_append arg " $func_quote_for_eval_result"
5783b789ec8aSmrg	  func_append compiler_flags " $func_quote_for_eval_result"
5784c27c18e8Smrg	done
5785c27c18e8Smrg	IFS="$save_ifs"
5786c27c18e8Smrg	func_stripname ' ' '' "$arg"
5787c27c18e8Smrg	arg=$func_stripname_result
5788c27c18e8Smrg	;;
5789c43cc173Smrg
5790c27c18e8Smrg      -Wl,*)
5791c27c18e8Smrg	func_stripname '-Wl,' '' "$arg"
5792c27c18e8Smrg	args=$func_stripname_result
5793c27c18e8Smrg	arg=
5794c27c18e8Smrg	save_ifs="$IFS"; IFS=','
5795c27c18e8Smrg	for flag in $args; do
5796c27c18e8Smrg	  IFS="$save_ifs"
5797c27c18e8Smrg          func_quote_for_eval "$flag"
5798b789ec8aSmrg	  func_append arg " $wl$func_quote_for_eval_result"
5799b789ec8aSmrg	  func_append compiler_flags " $wl$func_quote_for_eval_result"
5800b789ec8aSmrg	  func_append linker_flags " $func_quote_for_eval_result"
5801c27c18e8Smrg	done
5802c27c18e8Smrg	IFS="$save_ifs"
5803c27c18e8Smrg	func_stripname ' ' '' "$arg"
5804c27c18e8Smrg	arg=$func_stripname_result
5805c27c18e8Smrg	;;
5806c43cc173Smrg
5807c27c18e8Smrg      -Xcompiler)
5808c27c18e8Smrg	prev=xcompiler
5809c27c18e8Smrg	continue
5810c27c18e8Smrg	;;
5811c43cc173Smrg
5812c27c18e8Smrg      -Xlinker)
5813c27c18e8Smrg	prev=xlinker
5814c27c18e8Smrg	continue
5815c27c18e8Smrg	;;
5816c43cc173Smrg
5817c27c18e8Smrg      -XCClinker)
5818c27c18e8Smrg	prev=xcclinker
5819c27c18e8Smrg	continue
5820c27c18e8Smrg	;;
5821c43cc173Smrg
5822c27c18e8Smrg      # -msg_* for osf cc
5823c27c18e8Smrg      -msg_*)
5824c27c18e8Smrg	func_quote_for_eval "$arg"
5825c27c18e8Smrg	arg="$func_quote_for_eval_result"
5826c27c18e8Smrg	;;
5827c43cc173Smrg
582837eb1ca1Smrg      # Flags to be passed through unchanged, with rationale:
582937eb1ca1Smrg      # -64, -mips[0-9]      enable 64-bit mode for the SGI compiler
583037eb1ca1Smrg      # -r[0-9][0-9]*        specify processor for the SGI compiler
583137eb1ca1Smrg      # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler
583237eb1ca1Smrg      # +DA*, +DD*           enable 64-bit mode for the HP compiler
583337eb1ca1Smrg      # -q*                  compiler args for the IBM compiler
583437eb1ca1Smrg      # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
583537eb1ca1Smrg      # -F/path              path to uninstalled frameworks, gcc on darwin
583637eb1ca1Smrg      # -p, -pg, --coverage, -fprofile-*  profiling flags for GCC
583737eb1ca1Smrg      # @file                GCC response files
583837eb1ca1Smrg      # -tp=*                Portland pgcc target processor selection
5839b789ec8aSmrg      # --sysroot=*          for sysroot support
5840b789ec8aSmrg      # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
5841c27c18e8Smrg      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
5842b789ec8aSmrg      -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
5843b789ec8aSmrg      -O*|-flto*|-fwhopr*|-fuse-linker-plugin)
5844c27c18e8Smrg        func_quote_for_eval "$arg"
5845c27c18e8Smrg	arg="$func_quote_for_eval_result"
5846c27c18e8Smrg        func_append compile_command " $arg"
5847c27c18e8Smrg        func_append finalize_command " $arg"
5848b789ec8aSmrg        func_append compiler_flags " $arg"
5849c27c18e8Smrg        continue
5850c27c18e8Smrg        ;;
5851c43cc173Smrg
5852c27c18e8Smrg      # Some other compiler flag.
5853c27c18e8Smrg      -* | +*)
5854c27c18e8Smrg        func_quote_for_eval "$arg"
5855c27c18e8Smrg	arg="$func_quote_for_eval_result"
5856c27c18e8Smrg	;;
5857c43cc173Smrg
5858c27c18e8Smrg      *.$objext)
5859c27c18e8Smrg	# A standard object.
5860b789ec8aSmrg	func_append objs " $arg"
5861c27c18e8Smrg	;;
5862c43cc173Smrg
5863c27c18e8Smrg      *.lo)
5864c27c18e8Smrg	# A libtool-controlled object.
5865c43cc173Smrg
5866c27c18e8Smrg	# Check to see that this really is a libtool object.
5867c27c18e8Smrg	if func_lalib_unsafe_p "$arg"; then
5868c27c18e8Smrg	  pic_object=
5869c27c18e8Smrg	  non_pic_object=
5870c43cc173Smrg
5871c27c18e8Smrg	  # Read the .lo file
5872c27c18e8Smrg	  func_source "$arg"
5873c43cc173Smrg
5874c27c18e8Smrg	  if test -z "$pic_object" ||
5875c27c18e8Smrg	     test -z "$non_pic_object" ||
5876c27c18e8Smrg	     test "$pic_object" = none &&
5877c27c18e8Smrg	     test "$non_pic_object" = none; then
5878c27c18e8Smrg	    func_fatal_error "cannot find name of object for \`$arg'"
5879c27c18e8Smrg	  fi
5880c43cc173Smrg
5881c27c18e8Smrg	  # Extract subdirectory from the argument.
5882c27c18e8Smrg	  func_dirname "$arg" "/" ""
5883c27c18e8Smrg	  xdir="$func_dirname_result"
5884c43cc173Smrg
5885c27c18e8Smrg	  if test "$pic_object" != none; then
5886c27c18e8Smrg	    # Prepend the subdirectory the object is found in.
5887c27c18e8Smrg	    pic_object="$xdir$pic_object"
5888c43cc173Smrg
5889c27c18e8Smrg	    if test "$prev" = dlfiles; then
5890c27c18e8Smrg	      if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
5891b789ec8aSmrg		func_append dlfiles " $pic_object"
5892c27c18e8Smrg		prev=
5893c27c18e8Smrg		continue
5894c27c18e8Smrg	      else
5895c27c18e8Smrg		# If libtool objects are unsupported, then we need to preload.
5896c27c18e8Smrg		prev=dlprefiles
5897c27c18e8Smrg	      fi
5898c27c18e8Smrg	    fi
5899c43cc173Smrg
5900c27c18e8Smrg	    # CHECK ME:  I think I busted this.  -Ossama
5901c27c18e8Smrg	    if test "$prev" = dlprefiles; then
5902c27c18e8Smrg	      # Preload the old-style object.
5903b789ec8aSmrg	      func_append dlprefiles " $pic_object"
5904c27c18e8Smrg	      prev=
5905c27c18e8Smrg	    fi
5906c43cc173Smrg
5907c27c18e8Smrg	    # A PIC object.
5908c27c18e8Smrg	    func_append libobjs " $pic_object"
5909c27c18e8Smrg	    arg="$pic_object"
5910c27c18e8Smrg	  fi
5911c43cc173Smrg
5912c27c18e8Smrg	  # Non-PIC object.
5913c27c18e8Smrg	  if test "$non_pic_object" != none; then
5914c27c18e8Smrg	    # Prepend the subdirectory the object is found in.
5915c27c18e8Smrg	    non_pic_object="$xdir$non_pic_object"
5916c43cc173Smrg
5917c27c18e8Smrg	    # A standard non-PIC object
5918c27c18e8Smrg	    func_append non_pic_objects " $non_pic_object"
5919c27c18e8Smrg	    if test -z "$pic_object" || test "$pic_object" = none ; then
5920c27c18e8Smrg	      arg="$non_pic_object"
5921c27c18e8Smrg	    fi
5922c27c18e8Smrg	  else
5923c27c18e8Smrg	    # If the PIC object exists, use it instead.
5924c27c18e8Smrg	    # $xdir was prepended to $pic_object above.
5925c27c18e8Smrg	    non_pic_object="$pic_object"
5926c27c18e8Smrg	    func_append non_pic_objects " $non_pic_object"
5927c27c18e8Smrg	  fi
5928c27c18e8Smrg	else
5929c27c18e8Smrg	  # Only an error if not doing a dry-run.
5930c27c18e8Smrg	  if $opt_dry_run; then
5931c27c18e8Smrg	    # Extract subdirectory from the argument.
5932c27c18e8Smrg	    func_dirname "$arg" "/" ""
5933c27c18e8Smrg	    xdir="$func_dirname_result"
5934c27c18e8Smrg
5935c27c18e8Smrg	    func_lo2o "$arg"
5936c27c18e8Smrg	    pic_object=$xdir$objdir/$func_lo2o_result
5937c27c18e8Smrg	    non_pic_object=$xdir$func_lo2o_result
5938c27c18e8Smrg	    func_append libobjs " $pic_object"
5939c27c18e8Smrg	    func_append non_pic_objects " $non_pic_object"
5940c27c18e8Smrg	  else
5941c27c18e8Smrg	    func_fatal_error "\`$arg' is not a valid libtool object"
5942c27c18e8Smrg	  fi
5943c27c18e8Smrg	fi
5944c27c18e8Smrg	;;
5945c43cc173Smrg
5946c27c18e8Smrg      *.$libext)
5947c27c18e8Smrg	# An archive.
5948b789ec8aSmrg	func_append deplibs " $arg"
5949b789ec8aSmrg	func_append old_deplibs " $arg"
5950c27c18e8Smrg	continue
5951c27c18e8Smrg	;;
5952c43cc173Smrg
5953c27c18e8Smrg      *.la)
5954c27c18e8Smrg	# A libtool-controlled library.
5955c43cc173Smrg
5956b789ec8aSmrg	func_resolve_sysroot "$arg"
5957c27c18e8Smrg	if test "$prev" = dlfiles; then
5958c27c18e8Smrg	  # This library was specified with -dlopen.
5959b789ec8aSmrg	  func_append dlfiles " $func_resolve_sysroot_result"
5960c27c18e8Smrg	  prev=
5961c27c18e8Smrg	elif test "$prev" = dlprefiles; then
5962c27c18e8Smrg	  # The library was specified with -dlpreopen.
5963b789ec8aSmrg	  func_append dlprefiles " $func_resolve_sysroot_result"
5964c27c18e8Smrg	  prev=
5965c27c18e8Smrg	else
5966b789ec8aSmrg	  func_append deplibs " $func_resolve_sysroot_result"
5967c27c18e8Smrg	fi
5968c27c18e8Smrg	continue
5969c27c18e8Smrg	;;
5970c43cc173Smrg
5971c27c18e8Smrg      # Some other compiler argument.
5972c27c18e8Smrg      *)
5973c27c18e8Smrg	# Unknown arguments in both finalize_command and compile_command need
5974c27c18e8Smrg	# to be aesthetically quoted because they are evaled later.
5975c27c18e8Smrg	func_quote_for_eval "$arg"
5976c27c18e8Smrg	arg="$func_quote_for_eval_result"
5977c27c18e8Smrg	;;
5978c27c18e8Smrg      esac # arg
5979c43cc173Smrg
5980c27c18e8Smrg      # Now actually substitute the argument into the commands.
5981c27c18e8Smrg      if test -n "$arg"; then
5982c27c18e8Smrg	func_append compile_command " $arg"
5983c27c18e8Smrg	func_append finalize_command " $arg"
5984c27c18e8Smrg      fi
5985c27c18e8Smrg    done # argument parsing loop
598621e67964Smrg
5987c27c18e8Smrg    test -n "$prev" && \
5988c27c18e8Smrg      func_fatal_help "the \`$prevarg' option requires an argument"
5989c43cc173Smrg
5990c27c18e8Smrg    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
5991c27c18e8Smrg      eval arg=\"$export_dynamic_flag_spec\"
5992c27c18e8Smrg      func_append compile_command " $arg"
5993c27c18e8Smrg      func_append finalize_command " $arg"
5994c27c18e8Smrg    fi
5995c43cc173Smrg
5996c27c18e8Smrg    oldlibs=
5997c27c18e8Smrg    # calculate the name of the file, without its directory
5998c27c18e8Smrg    func_basename "$output"
5999c27c18e8Smrg    outputname="$func_basename_result"
6000c27c18e8Smrg    libobjs_save="$libobjs"
6001c27c18e8Smrg
6002c27c18e8Smrg    if test -n "$shlibpath_var"; then
6003c27c18e8Smrg      # get the directories listed in $shlibpath_var
600437eb1ca1Smrg      eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\`
6005c43cc173Smrg    else
6006c27c18e8Smrg      shlib_search_path=
6007c43cc173Smrg    fi
6008c27c18e8Smrg    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
6009c27c18e8Smrg    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
6010c43cc173Smrg
6011c27c18e8Smrg    func_dirname "$output" "/" ""
6012c27c18e8Smrg    output_objdir="$func_dirname_result$objdir"
6013b789ec8aSmrg    func_to_tool_file "$output_objdir/"
6014b789ec8aSmrg    tool_output_objdir=$func_to_tool_file_result
6015c27c18e8Smrg    # Create the object directory.
6016c27c18e8Smrg    func_mkdir_p "$output_objdir"
6017c43cc173Smrg
6018c27c18e8Smrg    # Determine the type of output
6019c27c18e8Smrg    case $output in
6020c27c18e8Smrg    "")
6021c27c18e8Smrg      func_fatal_help "you must specify an output file"
6022c27c18e8Smrg      ;;
6023c27c18e8Smrg    *.$libext) linkmode=oldlib ;;
6024c27c18e8Smrg    *.lo | *.$objext) linkmode=obj ;;
6025c27c18e8Smrg    *.la) linkmode=lib ;;
6026c27c18e8Smrg    *) linkmode=prog ;; # Anything else should be a program.
6027c27c18e8Smrg    esac
6028c27c18e8Smrg
6029c27c18e8Smrg    specialdeplibs=
6030c27c18e8Smrg
6031c27c18e8Smrg    libs=
6032c27c18e8Smrg    # Find all interdependent deplibs by searching for libraries
6033c27c18e8Smrg    # that are linked more than once (e.g. -la -lb -la)
6034c27c18e8Smrg    for deplib in $deplibs; do
6035b789ec8aSmrg      if $opt_preserve_dup_deps ; then
6036c27c18e8Smrg	case "$libs " in
6037b789ec8aSmrg	*" $deplib "*) func_append specialdeplibs " $deplib" ;;
6038c27c18e8Smrg	esac
6039c27c18e8Smrg      fi
6040b789ec8aSmrg      func_append libs " $deplib"
6041c27c18e8Smrg    done
6042c27c18e8Smrg
6043c27c18e8Smrg    if test "$linkmode" = lib; then
6044c27c18e8Smrg      libs="$predeps $libs $compiler_lib_search_path $postdeps"
6045c27c18e8Smrg
6046c27c18e8Smrg      # Compute libraries that are listed more than once in $predeps
6047c27c18e8Smrg      # $postdeps and mark them as special (i.e., whose duplicates are
6048c27c18e8Smrg      # not to be eliminated).
6049c27c18e8Smrg      pre_post_deps=
6050c27c18e8Smrg      if $opt_duplicate_compiler_generated_deps; then
6051c27c18e8Smrg	for pre_post_dep in $predeps $postdeps; do
6052c27c18e8Smrg	  case "$pre_post_deps " in
6053b789ec8aSmrg	  *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;;
6054c27c18e8Smrg	  esac
6055b789ec8aSmrg	  func_append pre_post_deps " $pre_post_dep"
6056c27c18e8Smrg	done
6057c27c18e8Smrg      fi
6058c27c18e8Smrg      pre_post_deps=
6059c27c18e8Smrg    fi
6060c27c18e8Smrg
6061c27c18e8Smrg    deplibs=
6062c27c18e8Smrg    newdependency_libs=
6063c27c18e8Smrg    newlib_search_path=
6064c27c18e8Smrg    need_relink=no # whether we're linking any uninstalled libtool libraries
6065c27c18e8Smrg    notinst_deplibs= # not-installed libtool libraries
6066c27c18e8Smrg    notinst_path= # paths that contain not-installed libtool libraries
6067c27c18e8Smrg
6068c27c18e8Smrg    case $linkmode in
6069c27c18e8Smrg    lib)
6070c27c18e8Smrg	passes="conv dlpreopen link"
6071c27c18e8Smrg	for file in $dlfiles $dlprefiles; do
6072c27c18e8Smrg	  case $file in
6073c27c18e8Smrg	  *.la) ;;
6074c27c18e8Smrg	  *)
6075c27c18e8Smrg	    func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file"
6076c27c18e8Smrg	    ;;
6077c27c18e8Smrg	  esac
6078c27c18e8Smrg	done
6079c27c18e8Smrg	;;
6080c27c18e8Smrg    prog)
6081c27c18e8Smrg	compile_deplibs=
6082c27c18e8Smrg	finalize_deplibs=
6083c27c18e8Smrg	alldeplibs=no
6084c27c18e8Smrg	newdlfiles=
6085c27c18e8Smrg	newdlprefiles=
6086c27c18e8Smrg	passes="conv scan dlopen dlpreopen link"
6087c27c18e8Smrg	;;
6088c27c18e8Smrg    *)  passes="conv"
6089c27c18e8Smrg	;;
6090c27c18e8Smrg    esac
6091c27c18e8Smrg
6092c27c18e8Smrg    for pass in $passes; do
6093c27c18e8Smrg      # The preopen pass in lib mode reverses $deplibs; put it back here
6094c27c18e8Smrg      # so that -L comes before libs that need it for instance...
6095c27c18e8Smrg      if test "$linkmode,$pass" = "lib,link"; then
6096c27c18e8Smrg	## FIXME: Find the place where the list is rebuilt in the wrong
6097c27c18e8Smrg	##        order, and fix it there properly
6098c27c18e8Smrg        tmp_deplibs=
6099c27c18e8Smrg	for deplib in $deplibs; do
6100c27c18e8Smrg	  tmp_deplibs="$deplib $tmp_deplibs"
6101c27c18e8Smrg	done
6102c27c18e8Smrg	deplibs="$tmp_deplibs"
6103c27c18e8Smrg      fi
6104c27c18e8Smrg
6105c27c18e8Smrg      if test "$linkmode,$pass" = "lib,link" ||
6106c27c18e8Smrg	 test "$linkmode,$pass" = "prog,scan"; then
6107c27c18e8Smrg	libs="$deplibs"
6108c27c18e8Smrg	deplibs=
6109c27c18e8Smrg      fi
6110c27c18e8Smrg      if test "$linkmode" = prog; then
6111c27c18e8Smrg	case $pass in
6112c27c18e8Smrg	dlopen) libs="$dlfiles" ;;
6113c27c18e8Smrg	dlpreopen) libs="$dlprefiles" ;;
6114c27c18e8Smrg	link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
6115c27c18e8Smrg	esac
6116c27c18e8Smrg      fi
6117c27c18e8Smrg      if test "$linkmode,$pass" = "lib,dlpreopen"; then
6118c27c18e8Smrg	# Collect and forward deplibs of preopened libtool libs
6119c27c18e8Smrg	for lib in $dlprefiles; do
6120c27c18e8Smrg	  # Ignore non-libtool-libs
6121c27c18e8Smrg	  dependency_libs=
6122b789ec8aSmrg	  func_resolve_sysroot "$lib"
6123c27c18e8Smrg	  case $lib in
6124b789ec8aSmrg	  *.la)	func_source "$func_resolve_sysroot_result" ;;
6125c27c18e8Smrg	  esac
6126c27c18e8Smrg
6127c27c18e8Smrg	  # Collect preopened libtool deplibs, except any this library
6128c27c18e8Smrg	  # has declared as weak libs
6129c27c18e8Smrg	  for deplib in $dependency_libs; do
613037eb1ca1Smrg	    func_basename "$deplib"
613137eb1ca1Smrg            deplib_base=$func_basename_result
6132c27c18e8Smrg	    case " $weak_libs " in
6133c27c18e8Smrg	    *" $deplib_base "*) ;;
6134b789ec8aSmrg	    *) func_append deplibs " $deplib" ;;
6135c27c18e8Smrg	    esac
6136c27c18e8Smrg	  done
6137c27c18e8Smrg	done
6138c27c18e8Smrg	libs="$dlprefiles"
6139c27c18e8Smrg      fi
6140c27c18e8Smrg      if test "$pass" = dlopen; then
6141c27c18e8Smrg	# Collect dlpreopened libraries
6142c27c18e8Smrg	save_deplibs="$deplibs"
6143c27c18e8Smrg	deplibs=
6144c27c18e8Smrg      fi
6145c27c18e8Smrg
6146c27c18e8Smrg      for deplib in $libs; do
6147c27c18e8Smrg	lib=
6148c27c18e8Smrg	found=no
6149c27c18e8Smrg	case $deplib in
6150c27c18e8Smrg	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
6151c27c18e8Smrg	  if test "$linkmode,$pass" = "prog,link"; then
6152c27c18e8Smrg	    compile_deplibs="$deplib $compile_deplibs"
6153c27c18e8Smrg	    finalize_deplibs="$deplib $finalize_deplibs"
6154c27c18e8Smrg	  else
6155b789ec8aSmrg	    func_append compiler_flags " $deplib"
6156c27c18e8Smrg	    if test "$linkmode" = lib ; then
6157c27c18e8Smrg		case "$new_inherited_linker_flags " in
6158c27c18e8Smrg		    *" $deplib "*) ;;
6159b789ec8aSmrg		    * ) func_append new_inherited_linker_flags " $deplib" ;;
6160c27c18e8Smrg		esac
6161c27c18e8Smrg	    fi
6162c27c18e8Smrg	  fi
6163c27c18e8Smrg	  continue
6164c27c18e8Smrg	  ;;
6165c27c18e8Smrg	-l*)
6166c27c18e8Smrg	  if test "$linkmode" != lib && test "$linkmode" != prog; then
6167c27c18e8Smrg	    func_warning "\`-l' is ignored for archives/objects"
6168c27c18e8Smrg	    continue
6169c27c18e8Smrg	  fi
6170c27c18e8Smrg	  func_stripname '-l' '' "$deplib"
6171c27c18e8Smrg	  name=$func_stripname_result
6172c27c18e8Smrg	  if test "$linkmode" = lib; then
6173c27c18e8Smrg	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
6174c27c18e8Smrg	  else
6175c27c18e8Smrg	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
6176c27c18e8Smrg	  fi
6177c27c18e8Smrg	  for searchdir in $searchdirs; do
6178c27c18e8Smrg	    for search_ext in .la $std_shrext .so .a; do
6179c27c18e8Smrg	      # Search the libtool library
6180c27c18e8Smrg	      lib="$searchdir/lib${name}${search_ext}"
6181c27c18e8Smrg	      if test -f "$lib"; then
6182c27c18e8Smrg		if test "$search_ext" = ".la"; then
6183c27c18e8Smrg		  found=yes
6184c27c18e8Smrg		else
6185c27c18e8Smrg		  found=no
6186c27c18e8Smrg		fi
6187c27c18e8Smrg		break 2
6188c27c18e8Smrg	      fi
6189c27c18e8Smrg	    done
6190c27c18e8Smrg	  done
6191c27c18e8Smrg	  if test "$found" != yes; then
6192c27c18e8Smrg	    # deplib doesn't seem to be a libtool library
6193c27c18e8Smrg	    if test "$linkmode,$pass" = "prog,link"; then
6194c27c18e8Smrg	      compile_deplibs="$deplib $compile_deplibs"
6195c27c18e8Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
6196c27c18e8Smrg	    else
6197c27c18e8Smrg	      deplibs="$deplib $deplibs"
6198c27c18e8Smrg	      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
6199c27c18e8Smrg	    fi
6200c27c18e8Smrg	    continue
6201c27c18e8Smrg	  else # deplib is a libtool library
6202c27c18e8Smrg	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
6203c27c18e8Smrg	    # We need to do some special things here, and not later.
6204c27c18e8Smrg	    if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6205c27c18e8Smrg	      case " $predeps $postdeps " in
6206c27c18e8Smrg	      *" $deplib "*)
6207c27c18e8Smrg		if func_lalib_p "$lib"; then
6208c27c18e8Smrg		  library_names=
6209c27c18e8Smrg		  old_library=
6210c27c18e8Smrg		  func_source "$lib"
6211c27c18e8Smrg		  for l in $old_library $library_names; do
6212c27c18e8Smrg		    ll="$l"
6213c27c18e8Smrg		  done
6214c27c18e8Smrg		  if test "X$ll" = "X$old_library" ; then # only static version available
6215c27c18e8Smrg		    found=no
6216c27c18e8Smrg		    func_dirname "$lib" "" "."
6217c27c18e8Smrg		    ladir="$func_dirname_result"
6218c27c18e8Smrg		    lib=$ladir/$old_library
6219c27c18e8Smrg		    if test "$linkmode,$pass" = "prog,link"; then
6220c27c18e8Smrg		      compile_deplibs="$deplib $compile_deplibs"
6221c27c18e8Smrg		      finalize_deplibs="$deplib $finalize_deplibs"
6222c27c18e8Smrg		    else
6223c27c18e8Smrg		      deplibs="$deplib $deplibs"
6224c27c18e8Smrg		      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
6225c27c18e8Smrg		    fi
6226c27c18e8Smrg		    continue
6227c27c18e8Smrg		  fi
6228c27c18e8Smrg		fi
6229c27c18e8Smrg		;;
6230c27c18e8Smrg	      *) ;;
6231c27c18e8Smrg	      esac
6232c27c18e8Smrg	    fi
6233c27c18e8Smrg	  fi
6234c27c18e8Smrg	  ;; # -l
6235c27c18e8Smrg	*.ltframework)
6236c27c18e8Smrg	  if test "$linkmode,$pass" = "prog,link"; then
6237c27c18e8Smrg	    compile_deplibs="$deplib $compile_deplibs"
6238c27c18e8Smrg	    finalize_deplibs="$deplib $finalize_deplibs"
6239c27c18e8Smrg	  else
6240c27c18e8Smrg	    deplibs="$deplib $deplibs"
6241c27c18e8Smrg	    if test "$linkmode" = lib ; then
6242c27c18e8Smrg		case "$new_inherited_linker_flags " in
6243c27c18e8Smrg		    *" $deplib "*) ;;
6244b789ec8aSmrg		    * ) func_append new_inherited_linker_flags " $deplib" ;;
6245c27c18e8Smrg		esac
6246c27c18e8Smrg	    fi
6247c27c18e8Smrg	  fi
6248c27c18e8Smrg	  continue
6249c27c18e8Smrg	  ;;
6250c27c18e8Smrg	-L*)
6251c27c18e8Smrg	  case $linkmode in
6252c27c18e8Smrg	  lib)
6253c27c18e8Smrg	    deplibs="$deplib $deplibs"
6254c27c18e8Smrg	    test "$pass" = conv && continue
6255c27c18e8Smrg	    newdependency_libs="$deplib $newdependency_libs"
6256c27c18e8Smrg	    func_stripname '-L' '' "$deplib"
6257b789ec8aSmrg	    func_resolve_sysroot "$func_stripname_result"
6258b789ec8aSmrg	    func_append newlib_search_path " $func_resolve_sysroot_result"
6259c27c18e8Smrg	    ;;
6260c27c18e8Smrg	  prog)
6261c27c18e8Smrg	    if test "$pass" = conv; then
6262c27c18e8Smrg	      deplibs="$deplib $deplibs"
6263c27c18e8Smrg	      continue
6264c27c18e8Smrg	    fi
6265c27c18e8Smrg	    if test "$pass" = scan; then
6266c27c18e8Smrg	      deplibs="$deplib $deplibs"
6267c27c18e8Smrg	    else
6268c27c18e8Smrg	      compile_deplibs="$deplib $compile_deplibs"
6269c27c18e8Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
6270c27c18e8Smrg	    fi
6271c27c18e8Smrg	    func_stripname '-L' '' "$deplib"
6272b789ec8aSmrg	    func_resolve_sysroot "$func_stripname_result"
6273b789ec8aSmrg	    func_append newlib_search_path " $func_resolve_sysroot_result"
6274c27c18e8Smrg	    ;;
6275c27c18e8Smrg	  *)
6276c27c18e8Smrg	    func_warning "\`-L' is ignored for archives/objects"
6277c27c18e8Smrg	    ;;
6278c27c18e8Smrg	  esac # linkmode
6279c27c18e8Smrg	  continue
6280c27c18e8Smrg	  ;; # -L
6281c27c18e8Smrg	-R*)
6282c27c18e8Smrg	  if test "$pass" = link; then
6283c27c18e8Smrg	    func_stripname '-R' '' "$deplib"
6284b789ec8aSmrg	    func_resolve_sysroot "$func_stripname_result"
6285b789ec8aSmrg	    dir=$func_resolve_sysroot_result
6286c27c18e8Smrg	    # Make sure the xrpath contains only unique directories.
6287c27c18e8Smrg	    case "$xrpath " in
6288c27c18e8Smrg	    *" $dir "*) ;;
6289b789ec8aSmrg	    *) func_append xrpath " $dir" ;;
6290c27c18e8Smrg	    esac
6291c27c18e8Smrg	  fi
6292c27c18e8Smrg	  deplibs="$deplib $deplibs"
6293c27c18e8Smrg	  continue
6294c27c18e8Smrg	  ;;
6295b789ec8aSmrg	*.la)
6296b789ec8aSmrg	  func_resolve_sysroot "$deplib"
6297b789ec8aSmrg	  lib=$func_resolve_sysroot_result
6298b789ec8aSmrg	  ;;
6299c27c18e8Smrg	*.$libext)
6300c27c18e8Smrg	  if test "$pass" = conv; then
6301c27c18e8Smrg	    deplibs="$deplib $deplibs"
6302c27c18e8Smrg	    continue
6303c27c18e8Smrg	  fi
6304c27c18e8Smrg	  case $linkmode in
6305c27c18e8Smrg	  lib)
6306c27c18e8Smrg	    # Linking convenience modules into shared libraries is allowed,
6307c27c18e8Smrg	    # but linking other static libraries is non-portable.
6308c27c18e8Smrg	    case " $dlpreconveniencelibs " in
6309c27c18e8Smrg	    *" $deplib "*) ;;
6310c27c18e8Smrg	    *)
6311c27c18e8Smrg	      valid_a_lib=no
6312c27c18e8Smrg	      case $deplibs_check_method in
6313c27c18e8Smrg		match_pattern*)
6314c27c18e8Smrg		  set dummy $deplibs_check_method; shift
6315c27c18e8Smrg		  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
631637eb1ca1Smrg		  if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
6317c27c18e8Smrg		    | $EGREP "$match_pattern_regex" > /dev/null; then
6318c27c18e8Smrg		    valid_a_lib=yes
6319c27c18e8Smrg		  fi
6320c27c18e8Smrg		;;
6321c27c18e8Smrg		pass_all)
6322c27c18e8Smrg		  valid_a_lib=yes
6323c27c18e8Smrg		;;
6324c27c18e8Smrg	      esac
6325c27c18e8Smrg	      if test "$valid_a_lib" != yes; then
632637eb1ca1Smrg		echo
6327c27c18e8Smrg		$ECHO "*** Warning: Trying to link with static lib archive $deplib."
632837eb1ca1Smrg		echo "*** I have the capability to make that library automatically link in when"
632937eb1ca1Smrg		echo "*** you link to this library.  But I can only do this if you have a"
633037eb1ca1Smrg		echo "*** shared version of the library, which you do not appear to have"
633137eb1ca1Smrg		echo "*** because the file extensions .$libext of this argument makes me believe"
633237eb1ca1Smrg		echo "*** that it is just a static archive that I should not use here."
6333c27c18e8Smrg	      else
633437eb1ca1Smrg		echo
6335c27c18e8Smrg		$ECHO "*** Warning: Linking the shared library $output against the"
6336c27c18e8Smrg		$ECHO "*** static library $deplib is not portable!"
6337c27c18e8Smrg		deplibs="$deplib $deplibs"
6338c27c18e8Smrg	      fi
6339c27c18e8Smrg	      ;;
6340c27c18e8Smrg	    esac
6341c27c18e8Smrg	    continue
6342c27c18e8Smrg	    ;;
6343c27c18e8Smrg	  prog)
6344c27c18e8Smrg	    if test "$pass" != link; then
6345c27c18e8Smrg	      deplibs="$deplib $deplibs"
6346c27c18e8Smrg	    else
6347c27c18e8Smrg	      compile_deplibs="$deplib $compile_deplibs"
6348c27c18e8Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
6349c27c18e8Smrg	    fi
6350c27c18e8Smrg	    continue
6351c27c18e8Smrg	    ;;
6352c27c18e8Smrg	  esac # linkmode
6353c27c18e8Smrg	  ;; # *.$libext
6354c27c18e8Smrg	*.lo | *.$objext)
6355c27c18e8Smrg	  if test "$pass" = conv; then
6356c27c18e8Smrg	    deplibs="$deplib $deplibs"
6357c27c18e8Smrg	  elif test "$linkmode" = prog; then
6358c27c18e8Smrg	    if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
6359c27c18e8Smrg	      # If there is no dlopen support or we're linking statically,
6360c27c18e8Smrg	      # we need to preload.
6361b789ec8aSmrg	      func_append newdlprefiles " $deplib"
6362c27c18e8Smrg	      compile_deplibs="$deplib $compile_deplibs"
6363c27c18e8Smrg	      finalize_deplibs="$deplib $finalize_deplibs"
6364c27c18e8Smrg	    else
6365b789ec8aSmrg	      func_append newdlfiles " $deplib"
6366c27c18e8Smrg	    fi
6367c27c18e8Smrg	  fi
6368c27c18e8Smrg	  continue
6369c27c18e8Smrg	  ;;
6370c27c18e8Smrg	%DEPLIBS%)
6371c27c18e8Smrg	  alldeplibs=yes
6372c27c18e8Smrg	  continue
6373c27c18e8Smrg	  ;;
6374c27c18e8Smrg	esac # case $deplib
6375c27c18e8Smrg
6376c27c18e8Smrg	if test "$found" = yes || test -f "$lib"; then :
6377c27c18e8Smrg	else
6378c27c18e8Smrg	  func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'"
6379c27c18e8Smrg	fi
6380c27c18e8Smrg
6381c27c18e8Smrg	# Check to see that this really is a libtool archive.
6382c27c18e8Smrg	func_lalib_unsafe_p "$lib" \
6383c27c18e8Smrg	  || func_fatal_error "\`$lib' is not a valid libtool archive"
6384c27c18e8Smrg
6385c27c18e8Smrg	func_dirname "$lib" "" "."
6386c27c18e8Smrg	ladir="$func_dirname_result"
6387c27c18e8Smrg
6388c27c18e8Smrg	dlname=
6389c27c18e8Smrg	dlopen=
6390c27c18e8Smrg	dlpreopen=
6391c27c18e8Smrg	libdir=
6392c27c18e8Smrg	library_names=
6393c27c18e8Smrg	old_library=
6394c27c18e8Smrg	inherited_linker_flags=
6395c27c18e8Smrg	# If the library was installed with an old release of libtool,
6396c27c18e8Smrg	# it will not redefine variables installed, or shouldnotlink
6397c27c18e8Smrg	installed=yes
6398c27c18e8Smrg	shouldnotlink=no
6399c27c18e8Smrg	avoidtemprpath=
6400c27c18e8Smrg
6401c27c18e8Smrg
6402c27c18e8Smrg	# Read the .la file
6403c27c18e8Smrg	func_source "$lib"
6404c27c18e8Smrg
6405c27c18e8Smrg	# Convert "-framework foo" to "foo.ltframework"
6406c27c18e8Smrg	if test -n "$inherited_linker_flags"; then
640737eb1ca1Smrg	  tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
6408c27c18e8Smrg	  for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
6409c27c18e8Smrg	    case " $new_inherited_linker_flags " in
6410c27c18e8Smrg	      *" $tmp_inherited_linker_flag "*) ;;
6411b789ec8aSmrg	      *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";;
6412c27c18e8Smrg	    esac
6413c27c18e8Smrg	  done
6414c27c18e8Smrg	fi
641537eb1ca1Smrg	dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
6416c27c18e8Smrg	if test "$linkmode,$pass" = "lib,link" ||
6417c27c18e8Smrg	   test "$linkmode,$pass" = "prog,scan" ||
6418c27c18e8Smrg	   { test "$linkmode" != prog && test "$linkmode" != lib; }; then
6419b789ec8aSmrg	  test -n "$dlopen" && func_append dlfiles " $dlopen"
6420b789ec8aSmrg	  test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen"
6421c27c18e8Smrg	fi
6422c27c18e8Smrg
6423c27c18e8Smrg	if test "$pass" = conv; then
6424c27c18e8Smrg	  # Only check for convenience libraries
6425c27c18e8Smrg	  deplibs="$lib $deplibs"
6426c27c18e8Smrg	  if test -z "$libdir"; then
6427c27c18e8Smrg	    if test -z "$old_library"; then
6428c27c18e8Smrg	      func_fatal_error "cannot find name of link library for \`$lib'"
6429c27c18e8Smrg	    fi
6430c27c18e8Smrg	    # It is a libtool convenience library, so add in its objects.
6431b789ec8aSmrg	    func_append convenience " $ladir/$objdir/$old_library"
6432b789ec8aSmrg	    func_append old_convenience " $ladir/$objdir/$old_library"
6433c27c18e8Smrg	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
6434c27c18e8Smrg	    func_fatal_error "\`$lib' is not a convenience library"
6435c27c18e8Smrg	  fi
6436c27c18e8Smrg	  tmp_libs=
6437c27c18e8Smrg	  for deplib in $dependency_libs; do
6438c27c18e8Smrg	    deplibs="$deplib $deplibs"
6439b789ec8aSmrg	    if $opt_preserve_dup_deps ; then
6440c27c18e8Smrg	      case "$tmp_libs " in
6441b789ec8aSmrg	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
6442c27c18e8Smrg	      esac
6443c27c18e8Smrg	    fi
6444b789ec8aSmrg	    func_append tmp_libs " $deplib"
6445c27c18e8Smrg	  done
6446c27c18e8Smrg	  continue
6447c27c18e8Smrg	fi # $pass = conv
6448c27c18e8Smrg
6449c27c18e8Smrg
6450c27c18e8Smrg	# Get the name of the library we link against.
6451c27c18e8Smrg	linklib=
6452b789ec8aSmrg	if test -n "$old_library" &&
6453b789ec8aSmrg	   { test "$prefer_static_libs" = yes ||
6454b789ec8aSmrg	     test "$prefer_static_libs,$installed" = "built,no"; }; then
6455b789ec8aSmrg	  linklib=$old_library
6456b789ec8aSmrg	else
6457b789ec8aSmrg	  for l in $old_library $library_names; do
6458b789ec8aSmrg	    linklib="$l"
6459b789ec8aSmrg	  done
6460b789ec8aSmrg	fi
6461c27c18e8Smrg	if test -z "$linklib"; then
6462c27c18e8Smrg	  func_fatal_error "cannot find name of link library for \`$lib'"
6463c27c18e8Smrg	fi
6464c27c18e8Smrg
6465c27c18e8Smrg	# This library was specified with -dlopen.
6466c27c18e8Smrg	if test "$pass" = dlopen; then
6467c27c18e8Smrg	  if test -z "$libdir"; then
6468c27c18e8Smrg	    func_fatal_error "cannot -dlopen a convenience library: \`$lib'"
6469c27c18e8Smrg	  fi
6470c27c18e8Smrg	  if test -z "$dlname" ||
6471c27c18e8Smrg	     test "$dlopen_support" != yes ||
6472c27c18e8Smrg	     test "$build_libtool_libs" = no; then
6473c27c18e8Smrg	    # If there is no dlname, no dlopen support or we're linking
6474c27c18e8Smrg	    # statically, we need to preload.  We also need to preload any
6475c27c18e8Smrg	    # dependent libraries so libltdl's deplib preloader doesn't
6476c27c18e8Smrg	    # bomb out in the load deplibs phase.
6477b789ec8aSmrg	    func_append dlprefiles " $lib $dependency_libs"
6478c27c18e8Smrg	  else
6479b789ec8aSmrg	    func_append newdlfiles " $lib"
6480c27c18e8Smrg	  fi
6481c27c18e8Smrg	  continue
6482c27c18e8Smrg	fi # $pass = dlopen
6483c27c18e8Smrg
6484c27c18e8Smrg	# We need an absolute path.
6485c27c18e8Smrg	case $ladir in
6486c27c18e8Smrg	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
6487c27c18e8Smrg	*)
6488c27c18e8Smrg	  abs_ladir=`cd "$ladir" && pwd`
6489c27c18e8Smrg	  if test -z "$abs_ladir"; then
6490c27c18e8Smrg	    func_warning "cannot determine absolute directory name of \`$ladir'"
6491c27c18e8Smrg	    func_warning "passing it literally to the linker, although it might fail"
6492c27c18e8Smrg	    abs_ladir="$ladir"
6493c27c18e8Smrg	  fi
6494c27c18e8Smrg	  ;;
6495c27c18e8Smrg	esac
6496c27c18e8Smrg	func_basename "$lib"
6497c27c18e8Smrg	laname="$func_basename_result"
6498c27c18e8Smrg
6499c27c18e8Smrg	# Find the relevant object directory and library name.
6500c27c18e8Smrg	if test "X$installed" = Xyes; then
6501b789ec8aSmrg	  if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
6502c27c18e8Smrg	    func_warning "library \`$lib' was moved."
6503c27c18e8Smrg	    dir="$ladir"
6504c27c18e8Smrg	    absdir="$abs_ladir"
6505c27c18e8Smrg	    libdir="$abs_ladir"
6506c27c18e8Smrg	  else
6507b789ec8aSmrg	    dir="$lt_sysroot$libdir"
6508b789ec8aSmrg	    absdir="$lt_sysroot$libdir"
6509c27c18e8Smrg	  fi
6510c27c18e8Smrg	  test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
6511c27c18e8Smrg	else
6512c27c18e8Smrg	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
6513c27c18e8Smrg	    dir="$ladir"
6514c27c18e8Smrg	    absdir="$abs_ladir"
6515c27c18e8Smrg	    # Remove this search path later
6516b789ec8aSmrg	    func_append notinst_path " $abs_ladir"
6517c27c18e8Smrg	  else
6518c27c18e8Smrg	    dir="$ladir/$objdir"
6519c27c18e8Smrg	    absdir="$abs_ladir/$objdir"
6520c27c18e8Smrg	    # Remove this search path later
6521b789ec8aSmrg	    func_append notinst_path " $abs_ladir"
6522c27c18e8Smrg	  fi
6523c27c18e8Smrg	fi # $installed = yes
6524c27c18e8Smrg	func_stripname 'lib' '.la' "$laname"
6525c27c18e8Smrg	name=$func_stripname_result
6526c27c18e8Smrg
6527c27c18e8Smrg	# This library was specified with -dlpreopen.
6528c27c18e8Smrg	if test "$pass" = dlpreopen; then
6529c27c18e8Smrg	  if test -z "$libdir" && test "$linkmode" = prog; then
6530c27c18e8Smrg	    func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'"
6531c27c18e8Smrg	  fi
6532b789ec8aSmrg	  case "$host" in
6533b789ec8aSmrg	    # special handling for platforms with PE-DLLs.
6534b789ec8aSmrg	    *cygwin* | *mingw* | *cegcc* )
6535b789ec8aSmrg	      # Linker will automatically link against shared library if both
6536b789ec8aSmrg	      # static and shared are present.  Therefore, ensure we extract
6537b789ec8aSmrg	      # symbols from the import library if a shared library is present
6538b789ec8aSmrg	      # (otherwise, the dlopen module name will be incorrect).  We do
6539b789ec8aSmrg	      # this by putting the import library name into $newdlprefiles.
6540b789ec8aSmrg	      # We recover the dlopen module name by 'saving' the la file
6541b789ec8aSmrg	      # name in a special purpose variable, and (later) extracting the
6542b789ec8aSmrg	      # dlname from the la file.
6543b789ec8aSmrg	      if test -n "$dlname"; then
6544b789ec8aSmrg	        func_tr_sh "$dir/$linklib"
6545b789ec8aSmrg	        eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname"
6546b789ec8aSmrg	        func_append newdlprefiles " $dir/$linklib"
6547b789ec8aSmrg	      else
6548b789ec8aSmrg	        func_append newdlprefiles " $dir/$old_library"
6549b789ec8aSmrg	        # Keep a list of preopened convenience libraries to check
6550b789ec8aSmrg	        # that they are being used correctly in the link pass.
6551b789ec8aSmrg	        test -z "$libdir" && \
6552b789ec8aSmrg	          func_append dlpreconveniencelibs " $dir/$old_library"
6553b789ec8aSmrg	      fi
6554b789ec8aSmrg	    ;;
6555b789ec8aSmrg	    * )
6556b789ec8aSmrg	      # Prefer using a static library (so that no silly _DYNAMIC symbols
6557b789ec8aSmrg	      # are required to link).
6558b789ec8aSmrg	      if test -n "$old_library"; then
6559b789ec8aSmrg	        func_append newdlprefiles " $dir/$old_library"
6560b789ec8aSmrg	        # Keep a list of preopened convenience libraries to check
6561b789ec8aSmrg	        # that they are being used correctly in the link pass.
6562b789ec8aSmrg	        test -z "$libdir" && \
6563b789ec8aSmrg	          func_append dlpreconveniencelibs " $dir/$old_library"
6564b789ec8aSmrg	      # Otherwise, use the dlname, so that lt_dlopen finds it.
6565b789ec8aSmrg	      elif test -n "$dlname"; then
6566b789ec8aSmrg	        func_append newdlprefiles " $dir/$dlname"
6567b789ec8aSmrg	      else
6568b789ec8aSmrg	        func_append newdlprefiles " $dir/$linklib"
6569b789ec8aSmrg	      fi
6570b789ec8aSmrg	    ;;
6571b789ec8aSmrg	  esac
6572c27c18e8Smrg	fi # $pass = dlpreopen
6573c27c18e8Smrg
6574c27c18e8Smrg	if test -z "$libdir"; then
6575c27c18e8Smrg	  # Link the convenience library
6576c27c18e8Smrg	  if test "$linkmode" = lib; then
6577c27c18e8Smrg	    deplibs="$dir/$old_library $deplibs"
6578c27c18e8Smrg	  elif test "$linkmode,$pass" = "prog,link"; then
6579c27c18e8Smrg	    compile_deplibs="$dir/$old_library $compile_deplibs"
6580c27c18e8Smrg	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
6581c27c18e8Smrg	  else
6582c27c18e8Smrg	    deplibs="$lib $deplibs" # used for prog,scan pass
6583c27c18e8Smrg	  fi
6584c27c18e8Smrg	  continue
6585c27c18e8Smrg	fi
6586c27c18e8Smrg
6587c27c18e8Smrg
6588c27c18e8Smrg	if test "$linkmode" = prog && test "$pass" != link; then
6589b789ec8aSmrg	  func_append newlib_search_path " $ladir"
6590c27c18e8Smrg	  deplibs="$lib $deplibs"
6591c27c18e8Smrg
6592c27c18e8Smrg	  linkalldeplibs=no
6593c27c18e8Smrg	  if test "$link_all_deplibs" != no || test -z "$library_names" ||
6594c27c18e8Smrg	     test "$build_libtool_libs" = no; then
6595c27c18e8Smrg	    linkalldeplibs=yes
6596c27c18e8Smrg	  fi
6597c27c18e8Smrg
6598c27c18e8Smrg	  tmp_libs=
6599c27c18e8Smrg	  for deplib in $dependency_libs; do
6600c27c18e8Smrg	    case $deplib in
6601c27c18e8Smrg	    -L*) func_stripname '-L' '' "$deplib"
6602b789ec8aSmrg	         func_resolve_sysroot "$func_stripname_result"
6603b789ec8aSmrg	         func_append newlib_search_path " $func_resolve_sysroot_result"
6604c27c18e8Smrg		 ;;
6605c27c18e8Smrg	    esac
6606c27c18e8Smrg	    # Need to link against all dependency_libs?
6607c27c18e8Smrg	    if test "$linkalldeplibs" = yes; then
6608c27c18e8Smrg	      deplibs="$deplib $deplibs"
6609c27c18e8Smrg	    else
6610c27c18e8Smrg	      # Need to hardcode shared library paths
6611c27c18e8Smrg	      # or/and link against static libraries
6612c27c18e8Smrg	      newdependency_libs="$deplib $newdependency_libs"
6613c27c18e8Smrg	    fi
6614b789ec8aSmrg	    if $opt_preserve_dup_deps ; then
6615c27c18e8Smrg	      case "$tmp_libs " in
6616b789ec8aSmrg	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
6617c27c18e8Smrg	      esac
6618c27c18e8Smrg	    fi
6619b789ec8aSmrg	    func_append tmp_libs " $deplib"
6620c27c18e8Smrg	  done # for deplib
6621c27c18e8Smrg	  continue
6622c27c18e8Smrg	fi # $linkmode = prog...
6623c27c18e8Smrg
6624c27c18e8Smrg	if test "$linkmode,$pass" = "prog,link"; then
6625c27c18e8Smrg	  if test -n "$library_names" &&
6626c27c18e8Smrg	     { { test "$prefer_static_libs" = no ||
6627c27c18e8Smrg	         test "$prefer_static_libs,$installed" = "built,yes"; } ||
6628c27c18e8Smrg	       test -z "$old_library"; }; then
6629c27c18e8Smrg	    # We need to hardcode the library path
6630c27c18e8Smrg	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
6631c27c18e8Smrg	      # Make sure the rpath contains only unique directories.
6632c27c18e8Smrg	      case "$temp_rpath:" in
6633c27c18e8Smrg	      *"$absdir:"*) ;;
6634b789ec8aSmrg	      *) func_append temp_rpath "$absdir:" ;;
6635c27c18e8Smrg	      esac
6636c27c18e8Smrg	    fi
6637c27c18e8Smrg
6638c27c18e8Smrg	    # Hardcode the library path.
6639c27c18e8Smrg	    # Skip directories that are in the system default run-time
6640c27c18e8Smrg	    # search path.
6641c27c18e8Smrg	    case " $sys_lib_dlsearch_path " in
6642c27c18e8Smrg	    *" $absdir "*) ;;
6643c27c18e8Smrg	    *)
6644c27c18e8Smrg	      case "$compile_rpath " in
6645c27c18e8Smrg	      *" $absdir "*) ;;
6646b789ec8aSmrg	      *) func_append compile_rpath " $absdir" ;;
6647c27c18e8Smrg	      esac
6648c27c18e8Smrg	      ;;
6649c27c18e8Smrg	    esac
6650c27c18e8Smrg	    case " $sys_lib_dlsearch_path " in
6651c27c18e8Smrg	    *" $libdir "*) ;;
6652c27c18e8Smrg	    *)
6653c27c18e8Smrg	      case "$finalize_rpath " in
6654c27c18e8Smrg	      *" $libdir "*) ;;
6655b789ec8aSmrg	      *) func_append finalize_rpath " $libdir" ;;
6656c27c18e8Smrg	      esac
6657c27c18e8Smrg	      ;;
6658c27c18e8Smrg	    esac
6659c27c18e8Smrg	  fi # $linkmode,$pass = prog,link...
6660c27c18e8Smrg
6661c27c18e8Smrg	  if test "$alldeplibs" = yes &&
6662c27c18e8Smrg	     { test "$deplibs_check_method" = pass_all ||
6663c27c18e8Smrg	       { test "$build_libtool_libs" = yes &&
6664c27c18e8Smrg		 test -n "$library_names"; }; }; then
6665c27c18e8Smrg	    # We only need to search for static libraries
6666c27c18e8Smrg	    continue
6667c27c18e8Smrg	  fi
6668c27c18e8Smrg	fi
6669c27c18e8Smrg
6670c27c18e8Smrg	link_static=no # Whether the deplib will be linked statically
6671c27c18e8Smrg	use_static_libs=$prefer_static_libs
6672c27c18e8Smrg	if test "$use_static_libs" = built && test "$installed" = yes; then
6673c27c18e8Smrg	  use_static_libs=no
6674c27c18e8Smrg	fi
6675c27c18e8Smrg	if test -n "$library_names" &&
6676c27c18e8Smrg	   { test "$use_static_libs" = no || test -z "$old_library"; }; then
6677c27c18e8Smrg	  case $host in
6678c27c18e8Smrg	  *cygwin* | *mingw* | *cegcc*)
6679c27c18e8Smrg	      # No point in relinking DLLs because paths are not encoded
6680b789ec8aSmrg	      func_append notinst_deplibs " $lib"
6681c27c18e8Smrg	      need_relink=no
6682c27c18e8Smrg	    ;;
6683c27c18e8Smrg	  *)
6684c27c18e8Smrg	    if test "$installed" = no; then
6685b789ec8aSmrg	      func_append notinst_deplibs " $lib"
6686c27c18e8Smrg	      need_relink=yes
6687c27c18e8Smrg	    fi
6688c27c18e8Smrg	    ;;
6689c27c18e8Smrg	  esac
6690c27c18e8Smrg	  # This is a shared library
6691c27c18e8Smrg
6692c27c18e8Smrg	  # Warn about portability, can't link against -module's on some
6693c27c18e8Smrg	  # systems (darwin).  Don't bleat about dlopened modules though!
6694c27c18e8Smrg	  dlopenmodule=""
6695c27c18e8Smrg	  for dlpremoduletest in $dlprefiles; do
6696c27c18e8Smrg	    if test "X$dlpremoduletest" = "X$lib"; then
6697c27c18e8Smrg	      dlopenmodule="$dlpremoduletest"
6698c27c18e8Smrg	      break
6699c27c18e8Smrg	    fi
6700c27c18e8Smrg	  done
6701c27c18e8Smrg	  if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then
670237eb1ca1Smrg	    echo
6703c27c18e8Smrg	    if test "$linkmode" = prog; then
6704c27c18e8Smrg	      $ECHO "*** Warning: Linking the executable $output against the loadable module"
6705c27c18e8Smrg	    else
6706c27c18e8Smrg	      $ECHO "*** Warning: Linking the shared library $output against the loadable module"
6707c27c18e8Smrg	    fi
6708c27c18e8Smrg	    $ECHO "*** $linklib is not portable!"
6709c27c18e8Smrg	  fi
6710c27c18e8Smrg	  if test "$linkmode" = lib &&
6711c27c18e8Smrg	     test "$hardcode_into_libs" = yes; then
6712c27c18e8Smrg	    # Hardcode the library path.
6713c27c18e8Smrg	    # Skip directories that are in the system default run-time
6714c27c18e8Smrg	    # search path.
6715c27c18e8Smrg	    case " $sys_lib_dlsearch_path " in
6716c27c18e8Smrg	    *" $absdir "*) ;;
6717c27c18e8Smrg	    *)
6718c27c18e8Smrg	      case "$compile_rpath " in
6719c27c18e8Smrg	      *" $absdir "*) ;;
6720b789ec8aSmrg	      *) func_append compile_rpath " $absdir" ;;
6721c27c18e8Smrg	      esac
6722c27c18e8Smrg	      ;;
6723c27c18e8Smrg	    esac
6724c27c18e8Smrg	    case " $sys_lib_dlsearch_path " in
6725c27c18e8Smrg	    *" $libdir "*) ;;
6726c27c18e8Smrg	    *)
6727c27c18e8Smrg	      case "$finalize_rpath " in
6728c27c18e8Smrg	      *" $libdir "*) ;;
6729b789ec8aSmrg	      *) func_append finalize_rpath " $libdir" ;;
6730c27c18e8Smrg	      esac
6731c27c18e8Smrg	      ;;
6732c27c18e8Smrg	    esac
6733c27c18e8Smrg	  fi
6734c27c18e8Smrg
6735c27c18e8Smrg	  if test -n "$old_archive_from_expsyms_cmds"; then
6736c27c18e8Smrg	    # figure out the soname
6737c27c18e8Smrg	    set dummy $library_names
6738c27c18e8Smrg	    shift
6739c27c18e8Smrg	    realname="$1"
6740c27c18e8Smrg	    shift
6741c27c18e8Smrg	    libname=`eval "\\$ECHO \"$libname_spec\""`
6742c27c18e8Smrg	    # use dlname if we got it. it's perfectly good, no?
6743c27c18e8Smrg	    if test -n "$dlname"; then
6744c27c18e8Smrg	      soname="$dlname"
6745c27c18e8Smrg	    elif test -n "$soname_spec"; then
6746c27c18e8Smrg	      # bleh windows
6747c27c18e8Smrg	      case $host in
6748c27c18e8Smrg	      *cygwin* | mingw* | *cegcc*)
6749c27c18e8Smrg	        func_arith $current - $age
6750c27c18e8Smrg		major=$func_arith_result
6751c27c18e8Smrg		versuffix="-$major"
6752c27c18e8Smrg		;;
6753c27c18e8Smrg	      esac
6754c27c18e8Smrg	      eval soname=\"$soname_spec\"
6755c27c18e8Smrg	    else
6756c27c18e8Smrg	      soname="$realname"
6757c27c18e8Smrg	    fi
6758c27c18e8Smrg
6759c27c18e8Smrg	    # Make a new name for the extract_expsyms_cmds to use
6760c27c18e8Smrg	    soroot="$soname"
6761c27c18e8Smrg	    func_basename "$soroot"
6762c27c18e8Smrg	    soname="$func_basename_result"
6763c27c18e8Smrg	    func_stripname 'lib' '.dll' "$soname"
6764c27c18e8Smrg	    newlib=libimp-$func_stripname_result.a
6765c27c18e8Smrg
6766c27c18e8Smrg	    # If the library has no export list, then create one now
6767c27c18e8Smrg	    if test -f "$output_objdir/$soname-def"; then :
6768c27c18e8Smrg	    else
6769c27c18e8Smrg	      func_verbose "extracting exported symbol list from \`$soname'"
6770c27c18e8Smrg	      func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
6771c27c18e8Smrg	    fi
6772c27c18e8Smrg
6773c27c18e8Smrg	    # Create $newlib
6774c27c18e8Smrg	    if test -f "$output_objdir/$newlib"; then :; else
6775c27c18e8Smrg	      func_verbose "generating import library for \`$soname'"
6776c27c18e8Smrg	      func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
6777c27c18e8Smrg	    fi
6778c27c18e8Smrg	    # make sure the library variables are pointing to the new library
6779c27c18e8Smrg	    dir=$output_objdir
6780c27c18e8Smrg	    linklib=$newlib
6781c27c18e8Smrg	  fi # test -n "$old_archive_from_expsyms_cmds"
6782c27c18e8Smrg
6783b789ec8aSmrg	  if test "$linkmode" = prog || test "$opt_mode" != relink; then
6784c27c18e8Smrg	    add_shlibpath=
6785c27c18e8Smrg	    add_dir=
6786c27c18e8Smrg	    add=
6787c27c18e8Smrg	    lib_linked=yes
6788c27c18e8Smrg	    case $hardcode_action in
6789c27c18e8Smrg	    immediate | unsupported)
6790c27c18e8Smrg	      if test "$hardcode_direct" = no; then
6791c27c18e8Smrg		add="$dir/$linklib"
6792c27c18e8Smrg		case $host in
6793c27c18e8Smrg		  *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
6794c27c18e8Smrg		  *-*-sysv4*uw2*) add_dir="-L$dir" ;;
6795c27c18e8Smrg		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
6796c27c18e8Smrg		    *-*-unixware7*) add_dir="-L$dir" ;;
6797c27c18e8Smrg		  *-*-darwin* )
6798c27c18e8Smrg		    # if the lib is a (non-dlopened) module then we can not
6799c27c18e8Smrg		    # link against it, someone is ignoring the earlier warnings
6800c27c18e8Smrg		    if /usr/bin/file -L $add 2> /dev/null |
6801c27c18e8Smrg			 $GREP ": [^:]* bundle" >/dev/null ; then
6802c27c18e8Smrg		      if test "X$dlopenmodule" != "X$lib"; then
6803c27c18e8Smrg			$ECHO "*** Warning: lib $linklib is a module, not a shared library"
6804c27c18e8Smrg			if test -z "$old_library" ; then
680537eb1ca1Smrg			  echo
680637eb1ca1Smrg			  echo "*** And there doesn't seem to be a static archive available"
680737eb1ca1Smrg			  echo "*** The link will probably fail, sorry"
6808c27c18e8Smrg			else
6809c27c18e8Smrg			  add="$dir/$old_library"
6810c27c18e8Smrg			fi
6811c27c18e8Smrg		      elif test -n "$old_library"; then
6812c27c18e8Smrg			add="$dir/$old_library"
6813c27c18e8Smrg		      fi
6814c27c18e8Smrg		    fi
6815c27c18e8Smrg		esac
6816c27c18e8Smrg	      elif test "$hardcode_minus_L" = no; then
6817c27c18e8Smrg		case $host in
6818c27c18e8Smrg		*-*-sunos*) add_shlibpath="$dir" ;;
6819c27c18e8Smrg		esac
6820c27c18e8Smrg		add_dir="-L$dir"
6821c27c18e8Smrg		add="-l$name"
6822c27c18e8Smrg	      elif test "$hardcode_shlibpath_var" = no; then
6823c27c18e8Smrg		add_shlibpath="$dir"
6824c27c18e8Smrg		add="-l$name"
6825c27c18e8Smrg	      else
6826c27c18e8Smrg		lib_linked=no
6827c27c18e8Smrg	      fi
6828c27c18e8Smrg	      ;;
6829c27c18e8Smrg	    relink)
6830c27c18e8Smrg	      if test "$hardcode_direct" = yes &&
6831c27c18e8Smrg	         test "$hardcode_direct_absolute" = no; then
6832c27c18e8Smrg		add="$dir/$linklib"
6833c27c18e8Smrg	      elif test "$hardcode_minus_L" = yes; then
6834c27c18e8Smrg		add_dir="-L$dir"
6835c27c18e8Smrg		# Try looking first in the location we're being installed to.
6836c27c18e8Smrg		if test -n "$inst_prefix_dir"; then
6837c27c18e8Smrg		  case $libdir in
6838c27c18e8Smrg		    [\\/]*)
6839b789ec8aSmrg		      func_append add_dir " -L$inst_prefix_dir$libdir"
6840c27c18e8Smrg		      ;;
6841c27c18e8Smrg		  esac
6842c27c18e8Smrg		fi
6843c27c18e8Smrg		add="-l$name"
6844c27c18e8Smrg	      elif test "$hardcode_shlibpath_var" = yes; then
6845c27c18e8Smrg		add_shlibpath="$dir"
6846c27c18e8Smrg		add="-l$name"
6847c27c18e8Smrg	      else
6848c27c18e8Smrg		lib_linked=no
6849c27c18e8Smrg	      fi
6850c27c18e8Smrg	      ;;
6851c27c18e8Smrg	    *) lib_linked=no ;;
6852c27c18e8Smrg	    esac
6853c27c18e8Smrg
6854c27c18e8Smrg	    if test "$lib_linked" != yes; then
6855c27c18e8Smrg	      func_fatal_configuration "unsupported hardcode properties"
6856c27c18e8Smrg	    fi
6857c27c18e8Smrg
6858c27c18e8Smrg	    if test -n "$add_shlibpath"; then
6859c27c18e8Smrg	      case :$compile_shlibpath: in
6860c27c18e8Smrg	      *":$add_shlibpath:"*) ;;
6861b789ec8aSmrg	      *) func_append compile_shlibpath "$add_shlibpath:" ;;
6862c27c18e8Smrg	      esac
6863c27c18e8Smrg	    fi
6864c27c18e8Smrg	    if test "$linkmode" = prog; then
6865c27c18e8Smrg	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
6866c27c18e8Smrg	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
6867c27c18e8Smrg	    else
6868c27c18e8Smrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
6869c27c18e8Smrg	      test -n "$add" && deplibs="$add $deplibs"
6870c27c18e8Smrg	      if test "$hardcode_direct" != yes &&
6871c27c18e8Smrg		 test "$hardcode_minus_L" != yes &&
6872c27c18e8Smrg		 test "$hardcode_shlibpath_var" = yes; then
6873c27c18e8Smrg		case :$finalize_shlibpath: in
6874c27c18e8Smrg		*":$libdir:"*) ;;
6875b789ec8aSmrg		*) func_append finalize_shlibpath "$libdir:" ;;
6876c27c18e8Smrg		esac
6877c27c18e8Smrg	      fi
6878c27c18e8Smrg	    fi
6879c27c18e8Smrg	  fi
6880c27c18e8Smrg
6881b789ec8aSmrg	  if test "$linkmode" = prog || test "$opt_mode" = relink; then
6882c27c18e8Smrg	    add_shlibpath=
6883c27c18e8Smrg	    add_dir=
6884c27c18e8Smrg	    add=
6885c27c18e8Smrg	    # Finalize command for both is simple: just hardcode it.
6886c27c18e8Smrg	    if test "$hardcode_direct" = yes &&
6887c27c18e8Smrg	       test "$hardcode_direct_absolute" = no; then
6888c27c18e8Smrg	      add="$libdir/$linklib"
6889c27c18e8Smrg	    elif test "$hardcode_minus_L" = yes; then
6890c27c18e8Smrg	      add_dir="-L$libdir"
6891c27c18e8Smrg	      add="-l$name"
6892c27c18e8Smrg	    elif test "$hardcode_shlibpath_var" = yes; then
6893c27c18e8Smrg	      case :$finalize_shlibpath: in
6894c27c18e8Smrg	      *":$libdir:"*) ;;
6895b789ec8aSmrg	      *) func_append finalize_shlibpath "$libdir:" ;;
6896c27c18e8Smrg	      esac
6897c27c18e8Smrg	      add="-l$name"
6898c27c18e8Smrg	    elif test "$hardcode_automatic" = yes; then
6899c27c18e8Smrg	      if test -n "$inst_prefix_dir" &&
6900c27c18e8Smrg		 test -f "$inst_prefix_dir$libdir/$linklib" ; then
6901c27c18e8Smrg		add="$inst_prefix_dir$libdir/$linklib"
6902c27c18e8Smrg	      else
6903c27c18e8Smrg		add="$libdir/$linklib"
6904c27c18e8Smrg	      fi
6905c27c18e8Smrg	    else
6906c27c18e8Smrg	      # We cannot seem to hardcode it, guess we'll fake it.
6907c27c18e8Smrg	      add_dir="-L$libdir"
6908c27c18e8Smrg	      # Try looking first in the location we're being installed to.
6909c27c18e8Smrg	      if test -n "$inst_prefix_dir"; then
6910c27c18e8Smrg		case $libdir in
6911c27c18e8Smrg		  [\\/]*)
6912b789ec8aSmrg		    func_append add_dir " -L$inst_prefix_dir$libdir"
6913c27c18e8Smrg		    ;;
6914c27c18e8Smrg		esac
6915c27c18e8Smrg	      fi
6916c27c18e8Smrg	      add="-l$name"
6917c27c18e8Smrg	    fi
6918c27c18e8Smrg
6919c27c18e8Smrg	    if test "$linkmode" = prog; then
6920c27c18e8Smrg	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
6921c27c18e8Smrg	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
6922c27c18e8Smrg	    else
6923c27c18e8Smrg	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
6924c27c18e8Smrg	      test -n "$add" && deplibs="$add $deplibs"
6925c27c18e8Smrg	    fi
6926c27c18e8Smrg	  fi
6927c27c18e8Smrg	elif test "$linkmode" = prog; then
6928c27c18e8Smrg	  # Here we assume that one of hardcode_direct or hardcode_minus_L
6929c27c18e8Smrg	  # is not unsupported.  This is valid on all known static and
6930c27c18e8Smrg	  # shared platforms.
6931c27c18e8Smrg	  if test "$hardcode_direct" != unsupported; then
6932c27c18e8Smrg	    test -n "$old_library" && linklib="$old_library"
6933c27c18e8Smrg	    compile_deplibs="$dir/$linklib $compile_deplibs"
6934c27c18e8Smrg	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
6935c27c18e8Smrg	  else
6936c27c18e8Smrg	    compile_deplibs="-l$name -L$dir $compile_deplibs"
6937c27c18e8Smrg	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
6938c27c18e8Smrg	  fi
6939c27c18e8Smrg	elif test "$build_libtool_libs" = yes; then
6940c27c18e8Smrg	  # Not a shared library
6941c27c18e8Smrg	  if test "$deplibs_check_method" != pass_all; then
6942c27c18e8Smrg	    # We're trying link a shared library against a static one
6943c27c18e8Smrg	    # but the system doesn't support it.
6944c27c18e8Smrg
6945c27c18e8Smrg	    # Just print a warning and add the library to dependency_libs so
6946c27c18e8Smrg	    # that the program can be linked against the static library.
694737eb1ca1Smrg	    echo
6948c27c18e8Smrg	    $ECHO "*** Warning: This system can not link to static lib archive $lib."
694937eb1ca1Smrg	    echo "*** I have the capability to make that library automatically link in when"
695037eb1ca1Smrg	    echo "*** you link to this library.  But I can only do this if you have a"
695137eb1ca1Smrg	    echo "*** shared version of the library, which you do not appear to have."
6952c27c18e8Smrg	    if test "$module" = yes; then
695337eb1ca1Smrg	      echo "*** But as you try to build a module library, libtool will still create "
695437eb1ca1Smrg	      echo "*** a static module, that should work as long as the dlopening application"
695537eb1ca1Smrg	      echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
6956c27c18e8Smrg	      if test -z "$global_symbol_pipe"; then
695737eb1ca1Smrg		echo
695837eb1ca1Smrg		echo "*** However, this would only work if libtool was able to extract symbol"
695937eb1ca1Smrg		echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
696037eb1ca1Smrg		echo "*** not find such a program.  So, this module is probably useless."
696137eb1ca1Smrg		echo "*** \`nm' from GNU binutils and a full rebuild may help."
6962c27c18e8Smrg	      fi
6963c27c18e8Smrg	      if test "$build_old_libs" = no; then
6964c27c18e8Smrg		build_libtool_libs=module
6965c27c18e8Smrg		build_old_libs=yes
6966c27c18e8Smrg	      else
6967c27c18e8Smrg		build_libtool_libs=no
6968c27c18e8Smrg	      fi
6969c27c18e8Smrg	    fi
6970c27c18e8Smrg	  else
6971c27c18e8Smrg	    deplibs="$dir/$old_library $deplibs"
6972c27c18e8Smrg	    link_static=yes
6973c27c18e8Smrg	  fi
6974c27c18e8Smrg	fi # link shared/static library?
6975c27c18e8Smrg
6976c27c18e8Smrg	if test "$linkmode" = lib; then
6977c27c18e8Smrg	  if test -n "$dependency_libs" &&
6978c27c18e8Smrg	     { test "$hardcode_into_libs" != yes ||
6979c27c18e8Smrg	       test "$build_old_libs" = yes ||
6980c27c18e8Smrg	       test "$link_static" = yes; }; then
6981c27c18e8Smrg	    # Extract -R from dependency_libs
6982c27c18e8Smrg	    temp_deplibs=
6983c27c18e8Smrg	    for libdir in $dependency_libs; do
6984c27c18e8Smrg	      case $libdir in
6985c27c18e8Smrg	      -R*) func_stripname '-R' '' "$libdir"
6986c27c18e8Smrg	           temp_xrpath=$func_stripname_result
6987c27c18e8Smrg		   case " $xrpath " in
6988c27c18e8Smrg		   *" $temp_xrpath "*) ;;
6989b789ec8aSmrg		   *) func_append xrpath " $temp_xrpath";;
6990c27c18e8Smrg		   esac;;
6991b789ec8aSmrg	      *) func_append temp_deplibs " $libdir";;
6992c27c18e8Smrg	      esac
6993c27c18e8Smrg	    done
6994c27c18e8Smrg	    dependency_libs="$temp_deplibs"
6995c27c18e8Smrg	  fi
6996c27c18e8Smrg
6997b789ec8aSmrg	  func_append newlib_search_path " $absdir"
6998c27c18e8Smrg	  # Link against this library
6999c27c18e8Smrg	  test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
7000c27c18e8Smrg	  # ... and its dependency_libs
7001c27c18e8Smrg	  tmp_libs=
7002c27c18e8Smrg	  for deplib in $dependency_libs; do
7003c27c18e8Smrg	    newdependency_libs="$deplib $newdependency_libs"
7004b789ec8aSmrg	    case $deplib in
7005b789ec8aSmrg              -L*) func_stripname '-L' '' "$deplib"
7006b789ec8aSmrg                   func_resolve_sysroot "$func_stripname_result";;
7007b789ec8aSmrg              *) func_resolve_sysroot "$deplib" ;;
7008b789ec8aSmrg            esac
7009b789ec8aSmrg	    if $opt_preserve_dup_deps ; then
7010c27c18e8Smrg	      case "$tmp_libs " in
7011b789ec8aSmrg	      *" $func_resolve_sysroot_result "*)
7012b789ec8aSmrg                func_append specialdeplibs " $func_resolve_sysroot_result" ;;
7013c27c18e8Smrg	      esac
7014c27c18e8Smrg	    fi
7015b789ec8aSmrg	    func_append tmp_libs " $func_resolve_sysroot_result"
7016c27c18e8Smrg	  done
7017c27c18e8Smrg
7018c27c18e8Smrg	  if test "$link_all_deplibs" != no; then
7019c27c18e8Smrg	    # Add the search paths of all dependency libraries
7020c27c18e8Smrg	    for deplib in $dependency_libs; do
702137eb1ca1Smrg	      path=
7022c27c18e8Smrg	      case $deplib in
7023c27c18e8Smrg	      -L*) path="$deplib" ;;
7024c27c18e8Smrg	      *.la)
7025b789ec8aSmrg	        func_resolve_sysroot "$deplib"
7026b789ec8aSmrg	        deplib=$func_resolve_sysroot_result
7027c27c18e8Smrg	        func_dirname "$deplib" "" "."
7028b789ec8aSmrg		dir=$func_dirname_result
7029c27c18e8Smrg		# We need an absolute path.
7030c27c18e8Smrg		case $dir in
7031c27c18e8Smrg		[\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
7032c27c18e8Smrg		*)
7033c27c18e8Smrg		  absdir=`cd "$dir" && pwd`
7034c27c18e8Smrg		  if test -z "$absdir"; then
7035c27c18e8Smrg		    func_warning "cannot determine absolute directory name of \`$dir'"
7036c27c18e8Smrg		    absdir="$dir"
7037c27c18e8Smrg		  fi
7038c27c18e8Smrg		  ;;
7039c27c18e8Smrg		esac
7040c27c18e8Smrg		if $GREP "^installed=no" $deplib > /dev/null; then
7041c27c18e8Smrg		case $host in
7042c27c18e8Smrg		*-*-darwin*)
7043c27c18e8Smrg		  depdepl=
7044c27c18e8Smrg		  eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
7045c27c18e8Smrg		  if test -n "$deplibrary_names" ; then
7046c27c18e8Smrg		    for tmp in $deplibrary_names ; do
7047c27c18e8Smrg		      depdepl=$tmp
7048c27c18e8Smrg		    done
7049c27c18e8Smrg		    if test -f "$absdir/$objdir/$depdepl" ; then
7050c27c18e8Smrg		      depdepl="$absdir/$objdir/$depdepl"
7051c27c18e8Smrg		      darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
7052c27c18e8Smrg                      if test -z "$darwin_install_name"; then
7053c27c18e8Smrg                          darwin_install_name=`${OTOOL64} -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
7054c27c18e8Smrg                      fi
7055b789ec8aSmrg		      func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}"
7056b789ec8aSmrg		      func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}"
7057c27c18e8Smrg		      path=
7058c27c18e8Smrg		    fi
7059c27c18e8Smrg		  fi
7060c27c18e8Smrg		  ;;
7061c27c18e8Smrg		*)
7062c27c18e8Smrg		  path="-L$absdir/$objdir"
7063c27c18e8Smrg		  ;;
7064c27c18e8Smrg		esac
7065c27c18e8Smrg		else
7066c27c18e8Smrg		  eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
7067c27c18e8Smrg		  test -z "$libdir" && \
7068c27c18e8Smrg		    func_fatal_error "\`$deplib' is not a valid libtool archive"
7069c27c18e8Smrg		  test "$absdir" != "$libdir" && \
7070c27c18e8Smrg		    func_warning "\`$deplib' seems to be moved"
7071c27c18e8Smrg
7072c27c18e8Smrg		  path="-L$absdir"
7073c27c18e8Smrg		fi
7074c27c18e8Smrg		;;
7075c27c18e8Smrg	      esac
7076c27c18e8Smrg	      case " $deplibs " in
7077c27c18e8Smrg	      *" $path "*) ;;
7078c27c18e8Smrg	      *) deplibs="$path $deplibs" ;;
7079c27c18e8Smrg	      esac
7080c27c18e8Smrg	    done
7081c27c18e8Smrg	  fi # link_all_deplibs != no
7082c27c18e8Smrg	fi # linkmode = lib
7083c27c18e8Smrg      done # for deplib in $libs
7084c27c18e8Smrg      if test "$pass" = link; then
7085c27c18e8Smrg	if test "$linkmode" = "prog"; then
7086c27c18e8Smrg	  compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
7087c27c18e8Smrg	  finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
7088c27c18e8Smrg	else
708937eb1ca1Smrg	  compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
7090c27c18e8Smrg	fi
7091c27c18e8Smrg      fi
7092c27c18e8Smrg      dependency_libs="$newdependency_libs"
7093c27c18e8Smrg      if test "$pass" = dlpreopen; then
7094c27c18e8Smrg	# Link the dlpreopened libraries before other libraries
7095c27c18e8Smrg	for deplib in $save_deplibs; do
7096c27c18e8Smrg	  deplibs="$deplib $deplibs"
7097c27c18e8Smrg	done
7098c27c18e8Smrg      fi
7099c27c18e8Smrg      if test "$pass" != dlopen; then
7100c27c18e8Smrg	if test "$pass" != conv; then
7101c27c18e8Smrg	  # Make sure lib_search_path contains only unique directories.
7102c27c18e8Smrg	  lib_search_path=
7103c27c18e8Smrg	  for dir in $newlib_search_path; do
7104c27c18e8Smrg	    case "$lib_search_path " in
7105c27c18e8Smrg	    *" $dir "*) ;;
7106b789ec8aSmrg	    *) func_append lib_search_path " $dir" ;;
7107c27c18e8Smrg	    esac
7108c27c18e8Smrg	  done
7109c27c18e8Smrg	  newlib_search_path=
7110c27c18e8Smrg	fi
7111c27c18e8Smrg
7112c27c18e8Smrg	if test "$linkmode,$pass" != "prog,link"; then
7113c27c18e8Smrg	  vars="deplibs"
7114c27c18e8Smrg	else
7115c27c18e8Smrg	  vars="compile_deplibs finalize_deplibs"
7116c27c18e8Smrg	fi
7117c27c18e8Smrg	for var in $vars dependency_libs; do
7118c27c18e8Smrg	  # Add libraries to $var in reverse order
7119c27c18e8Smrg	  eval tmp_libs=\"\$$var\"
7120c27c18e8Smrg	  new_libs=
7121c27c18e8Smrg	  for deplib in $tmp_libs; do
7122c27c18e8Smrg	    # FIXME: Pedantically, this is the right thing to do, so
7123c27c18e8Smrg	    #        that some nasty dependency loop isn't accidentally
7124c27c18e8Smrg	    #        broken:
7125c27c18e8Smrg	    #new_libs="$deplib $new_libs"
7126c27c18e8Smrg	    # Pragmatically, this seems to cause very few problems in
7127c27c18e8Smrg	    # practice:
7128c27c18e8Smrg	    case $deplib in
7129c27c18e8Smrg	    -L*) new_libs="$deplib $new_libs" ;;
7130c27c18e8Smrg	    -R*) ;;
7131c27c18e8Smrg	    *)
7132c27c18e8Smrg	      # And here is the reason: when a library appears more
7133c27c18e8Smrg	      # than once as an explicit dependence of a library, or
7134c27c18e8Smrg	      # is implicitly linked in more than once by the
7135c27c18e8Smrg	      # compiler, it is considered special, and multiple
7136c27c18e8Smrg	      # occurrences thereof are not removed.  Compare this
7137c27c18e8Smrg	      # with having the same library being listed as a
7138c27c18e8Smrg	      # dependency of multiple other libraries: in this case,
7139c27c18e8Smrg	      # we know (pedantically, we assume) the library does not
7140c27c18e8Smrg	      # need to be listed more than once, so we keep only the
7141c27c18e8Smrg	      # last copy.  This is not always right, but it is rare
7142c27c18e8Smrg	      # enough that we require users that really mean to play
7143c27c18e8Smrg	      # such unportable linking tricks to link the library
7144c27c18e8Smrg	      # using -Wl,-lname, so that libtool does not consider it
7145c27c18e8Smrg	      # for duplicate removal.
7146c27c18e8Smrg	      case " $specialdeplibs " in
7147c27c18e8Smrg	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
7148c27c18e8Smrg	      *)
7149c27c18e8Smrg		case " $new_libs " in
7150c27c18e8Smrg		*" $deplib "*) ;;
7151c27c18e8Smrg		*) new_libs="$deplib $new_libs" ;;
7152c27c18e8Smrg		esac
7153c27c18e8Smrg		;;
7154c27c18e8Smrg	      esac
7155c27c18e8Smrg	      ;;
7156c27c18e8Smrg	    esac
7157c27c18e8Smrg	  done
7158c27c18e8Smrg	  tmp_libs=
7159c27c18e8Smrg	  for deplib in $new_libs; do
7160c27c18e8Smrg	    case $deplib in
7161c27c18e8Smrg	    -L*)
7162c27c18e8Smrg	      case " $tmp_libs " in
7163c27c18e8Smrg	      *" $deplib "*) ;;
7164b789ec8aSmrg	      *) func_append tmp_libs " $deplib" ;;
7165c27c18e8Smrg	      esac
7166c27c18e8Smrg	      ;;
7167b789ec8aSmrg	    *) func_append tmp_libs " $deplib" ;;
7168c27c18e8Smrg	    esac
7169c27c18e8Smrg	  done
7170c27c18e8Smrg	  eval $var=\"$tmp_libs\"
7171c27c18e8Smrg	done # for var
7172c27c18e8Smrg      fi
7173c27c18e8Smrg      # Last step: remove runtime libs from dependency_libs
7174c27c18e8Smrg      # (they stay in deplibs)
7175c27c18e8Smrg      tmp_libs=
7176c27c18e8Smrg      for i in $dependency_libs ; do
7177c27c18e8Smrg	case " $predeps $postdeps $compiler_lib_search_path " in
7178c27c18e8Smrg	*" $i "*)
7179c27c18e8Smrg	  i=""
7180c27c18e8Smrg	  ;;
7181c27c18e8Smrg	esac
7182c27c18e8Smrg	if test -n "$i" ; then
7183b789ec8aSmrg	  func_append tmp_libs " $i"
7184c27c18e8Smrg	fi
7185c27c18e8Smrg      done
7186c27c18e8Smrg      dependency_libs=$tmp_libs
7187c27c18e8Smrg    done # for pass
7188c27c18e8Smrg    if test "$linkmode" = prog; then
7189c27c18e8Smrg      dlfiles="$newdlfiles"
7190c27c18e8Smrg    fi
7191c27c18e8Smrg    if test "$linkmode" = prog || test "$linkmode" = lib; then
7192c27c18e8Smrg      dlprefiles="$newdlprefiles"
7193c27c18e8Smrg    fi
7194c27c18e8Smrg
7195c27c18e8Smrg    case $linkmode in
7196c27c18e8Smrg    oldlib)
7197c27c18e8Smrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
7198c27c18e8Smrg	func_warning "\`-dlopen' is ignored for archives"
7199c27c18e8Smrg      fi
7200c27c18e8Smrg
7201c27c18e8Smrg      case " $deplibs" in
7202c27c18e8Smrg      *\ -l* | *\ -L*)
7203c27c18e8Smrg	func_warning "\`-l' and \`-L' are ignored for archives" ;;
7204c27c18e8Smrg      esac
7205c27c18e8Smrg
7206c27c18e8Smrg      test -n "$rpath" && \
7207c27c18e8Smrg	func_warning "\`-rpath' is ignored for archives"
7208c27c18e8Smrg
7209c27c18e8Smrg      test -n "$xrpath" && \
7210c27c18e8Smrg	func_warning "\`-R' is ignored for archives"
7211c27c18e8Smrg
7212c27c18e8Smrg      test -n "$vinfo" && \
7213c27c18e8Smrg	func_warning "\`-version-info/-version-number' is ignored for archives"
7214c27c18e8Smrg
7215c27c18e8Smrg      test -n "$release" && \
7216c27c18e8Smrg	func_warning "\`-release' is ignored for archives"
7217c27c18e8Smrg
7218c27c18e8Smrg      test -n "$export_symbols$export_symbols_regex" && \
7219c27c18e8Smrg	func_warning "\`-export-symbols' is ignored for archives"
7220c27c18e8Smrg
7221c27c18e8Smrg      # Now set the variables for building old libraries.
7222c27c18e8Smrg      build_libtool_libs=no
7223c27c18e8Smrg      oldlibs="$output"
7224b789ec8aSmrg      func_append objs "$old_deplibs"
7225c27c18e8Smrg      ;;
7226c27c18e8Smrg
7227c27c18e8Smrg    lib)
7228c27c18e8Smrg      # Make sure we only generate libraries of the form `libNAME.la'.
7229c27c18e8Smrg      case $outputname in
7230c27c18e8Smrg      lib*)
7231c27c18e8Smrg	func_stripname 'lib' '.la' "$outputname"
7232c27c18e8Smrg	name=$func_stripname_result
7233c27c18e8Smrg	eval shared_ext=\"$shrext_cmds\"
7234c27c18e8Smrg	eval libname=\"$libname_spec\"
7235c27c18e8Smrg	;;
7236c27c18e8Smrg      *)
7237c27c18e8Smrg	test "$module" = no && \
7238c27c18e8Smrg	  func_fatal_help "libtool library \`$output' must begin with \`lib'"
7239c27c18e8Smrg
7240c27c18e8Smrg	if test "$need_lib_prefix" != no; then
7241c27c18e8Smrg	  # Add the "lib" prefix for modules if required
7242c27c18e8Smrg	  func_stripname '' '.la' "$outputname"
7243c27c18e8Smrg	  name=$func_stripname_result
7244c27c18e8Smrg	  eval shared_ext=\"$shrext_cmds\"
7245c27c18e8Smrg	  eval libname=\"$libname_spec\"
7246c27c18e8Smrg	else
7247c27c18e8Smrg	  func_stripname '' '.la' "$outputname"
7248c27c18e8Smrg	  libname=$func_stripname_result
7249c27c18e8Smrg	fi
7250c27c18e8Smrg	;;
7251c27c18e8Smrg      esac
7252c27c18e8Smrg
7253c27c18e8Smrg      if test -n "$objs"; then
7254c27c18e8Smrg	if test "$deplibs_check_method" != pass_all; then
7255c27c18e8Smrg	  func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs"
7256c27c18e8Smrg	else
725737eb1ca1Smrg	  echo
7258c27c18e8Smrg	  $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
7259c27c18e8Smrg	  $ECHO "*** objects $objs is not portable!"
7260b789ec8aSmrg	  func_append libobjs " $objs"
7261c27c18e8Smrg	fi
7262c27c18e8Smrg      fi
7263c27c18e8Smrg
7264c27c18e8Smrg      test "$dlself" != no && \
7265c27c18e8Smrg	func_warning "\`-dlopen self' is ignored for libtool libraries"
7266c27c18e8Smrg
7267c27c18e8Smrg      set dummy $rpath
7268c27c18e8Smrg      shift
7269c27c18e8Smrg      test "$#" -gt 1 && \
7270c27c18e8Smrg	func_warning "ignoring multiple \`-rpath's for a libtool library"
7271c27c18e8Smrg
7272c27c18e8Smrg      install_libdir="$1"
7273c27c18e8Smrg
7274c27c18e8Smrg      oldlibs=
7275c27c18e8Smrg      if test -z "$rpath"; then
7276c27c18e8Smrg	if test "$build_libtool_libs" = yes; then
7277c27c18e8Smrg	  # Building a libtool convenience library.
7278c27c18e8Smrg	  # Some compilers have problems with a `.al' extension so
7279c27c18e8Smrg	  # convenience libraries should have the same extension an
7280c27c18e8Smrg	  # archive normally would.
7281c27c18e8Smrg	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
7282c27c18e8Smrg	  build_libtool_libs=convenience
7283c27c18e8Smrg	  build_old_libs=yes
7284c27c18e8Smrg	fi
7285c27c18e8Smrg
7286c27c18e8Smrg	test -n "$vinfo" && \
7287c27c18e8Smrg	  func_warning "\`-version-info/-version-number' is ignored for convenience libraries"
7288c27c18e8Smrg
7289c27c18e8Smrg	test -n "$release" && \
7290c27c18e8Smrg	  func_warning "\`-release' is ignored for convenience libraries"
7291c27c18e8Smrg      else
7292c27c18e8Smrg
7293c27c18e8Smrg	# Parse the version information argument.
7294c27c18e8Smrg	save_ifs="$IFS"; IFS=':'
7295c27c18e8Smrg	set dummy $vinfo 0 0 0
7296c27c18e8Smrg	shift
7297c27c18e8Smrg	IFS="$save_ifs"
7298c27c18e8Smrg
7299c27c18e8Smrg	test -n "$7" && \
7300c27c18e8Smrg	  func_fatal_help "too many parameters to \`-version-info'"
7301c27c18e8Smrg
7302c27c18e8Smrg	# convert absolute version numbers to libtool ages
7303c27c18e8Smrg	# this retains compatibility with .la files and attempts
7304c27c18e8Smrg	# to make the code below a bit more comprehensible
7305c27c18e8Smrg
7306c27c18e8Smrg	case $vinfo_number in
7307c27c18e8Smrg	yes)
7308c27c18e8Smrg	  number_major="$1"
7309c27c18e8Smrg	  number_minor="$2"
7310c27c18e8Smrg	  number_revision="$3"
7311c27c18e8Smrg	  #
7312c27c18e8Smrg	  # There are really only two kinds -- those that
7313c27c18e8Smrg	  # use the current revision as the major version
7314c27c18e8Smrg	  # and those that subtract age and use age as
7315c27c18e8Smrg	  # a minor version.  But, then there is irix
7316c27c18e8Smrg	  # which has an extra 1 added just for fun
7317c27c18e8Smrg	  #
7318c27c18e8Smrg	  case $version_type in
7319c27c18e8Smrg	  darwin|linux|osf|windows|none)
7320c27c18e8Smrg	    func_arith $number_major + $number_minor
7321c27c18e8Smrg	    current=$func_arith_result
7322c27c18e8Smrg	    age="$number_minor"
7323c27c18e8Smrg	    revision="$number_revision"
7324c27c18e8Smrg	    ;;
732537eb1ca1Smrg	  freebsd-aout|freebsd-elf|qnx|sunos)
7326c27c18e8Smrg	    current="$number_major"
7327c27c18e8Smrg	    revision="$number_minor"
7328c27c18e8Smrg	    age="0"
7329c27c18e8Smrg	    ;;
7330c27c18e8Smrg	  irix|nonstopux)
7331c27c18e8Smrg	    func_arith $number_major + $number_minor
7332c27c18e8Smrg	    current=$func_arith_result
7333c27c18e8Smrg	    age="$number_minor"
7334c27c18e8Smrg	    revision="$number_minor"
7335c27c18e8Smrg	    lt_irix_increment=no
7336c27c18e8Smrg	    ;;
7337c27c18e8Smrg	  esac
7338c27c18e8Smrg	  ;;
7339c27c18e8Smrg	no)
7340c27c18e8Smrg	  current="$1"
7341c27c18e8Smrg	  revision="$2"
7342c27c18e8Smrg	  age="$3"
7343c27c18e8Smrg	  ;;
7344c27c18e8Smrg	esac
7345c27c18e8Smrg
7346c27c18e8Smrg	# Check that each of the things are valid numbers.
7347c27c18e8Smrg	case $current in
7348c27c18e8Smrg	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]) ;;
7349c27c18e8Smrg	*)
7350c27c18e8Smrg	  func_error "CURRENT \`$current' must be a nonnegative integer"
7351c27c18e8Smrg	  func_fatal_error "\`$vinfo' is not valid version information"
7352c27c18e8Smrg	  ;;
7353c27c18e8Smrg	esac
7354c27c18e8Smrg
7355c27c18e8Smrg	case $revision in
7356c27c18e8Smrg	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]) ;;
7357c27c18e8Smrg	*)
7358c27c18e8Smrg	  func_error "REVISION \`$revision' must be a nonnegative integer"
7359c27c18e8Smrg	  func_fatal_error "\`$vinfo' is not valid version information"
7360c27c18e8Smrg	  ;;
7361c27c18e8Smrg	esac
7362c27c18e8Smrg
7363c27c18e8Smrg	case $age in
7364c27c18e8Smrg	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]) ;;
7365c27c18e8Smrg	*)
7366c27c18e8Smrg	  func_error "AGE \`$age' must be a nonnegative integer"
7367c27c18e8Smrg	  func_fatal_error "\`$vinfo' is not valid version information"
7368c27c18e8Smrg	  ;;
7369c27c18e8Smrg	esac
7370c27c18e8Smrg
7371c27c18e8Smrg	if test "$age" -gt "$current"; then
7372c27c18e8Smrg	  func_error "AGE \`$age' is greater than the current interface number \`$current'"
7373c27c18e8Smrg	  func_fatal_error "\`$vinfo' is not valid version information"
7374c27c18e8Smrg	fi
7375c27c18e8Smrg
7376c27c18e8Smrg	# Calculate the version variables.
7377c27c18e8Smrg	major=
7378c27c18e8Smrg	versuffix=
7379c27c18e8Smrg	verstring=
7380c27c18e8Smrg	case $version_type in
7381c27c18e8Smrg	none) ;;
7382c27c18e8Smrg
7383c27c18e8Smrg	darwin)
7384c27c18e8Smrg	  # Like Linux, but with the current version available in
7385c27c18e8Smrg	  # verstring for coding it into the library header
7386c27c18e8Smrg	  func_arith $current - $age
7387c27c18e8Smrg	  major=.$func_arith_result
7388c27c18e8Smrg	  versuffix="$major.$age.$revision"
7389c27c18e8Smrg	  # Darwin ld doesn't like 0 for these options...
7390c27c18e8Smrg	  func_arith $current + 1
7391c27c18e8Smrg	  minor_current=$func_arith_result
7392c27c18e8Smrg	  xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
7393c27c18e8Smrg	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
7394c27c18e8Smrg	  ;;
7395c27c18e8Smrg
7396c27c18e8Smrg	freebsd-aout)
7397c27c18e8Smrg	  major=".$current"
7398c27c18e8Smrg	  versuffix=".$current.$revision";
7399c27c18e8Smrg	  ;;
7400c27c18e8Smrg
7401c27c18e8Smrg	freebsd-elf)
7402c27c18e8Smrg	  major=".$current"
7403c27c18e8Smrg	  versuffix=".$current"
7404c27c18e8Smrg	  ;;
7405c27c18e8Smrg
7406c27c18e8Smrg	irix | nonstopux)
7407c27c18e8Smrg	  if test "X$lt_irix_increment" = "Xno"; then
7408c27c18e8Smrg	    func_arith $current - $age
7409c27c18e8Smrg	  else
7410c27c18e8Smrg	    func_arith $current - $age + 1
7411c27c18e8Smrg	  fi
7412c27c18e8Smrg	  major=$func_arith_result
7413c27c18e8Smrg
7414c27c18e8Smrg	  case $version_type in
7415c27c18e8Smrg	    nonstopux) verstring_prefix=nonstopux ;;
7416c27c18e8Smrg	    *)         verstring_prefix=sgi ;;
7417c27c18e8Smrg	  esac
7418c27c18e8Smrg	  verstring="$verstring_prefix$major.$revision"
7419c27c18e8Smrg
7420c27c18e8Smrg	  # Add in all the interfaces that we are compatible with.
7421c27c18e8Smrg	  loop=$revision
7422c27c18e8Smrg	  while test "$loop" -ne 0; do
7423c27c18e8Smrg	    func_arith $revision - $loop
7424c27c18e8Smrg	    iface=$func_arith_result
7425c27c18e8Smrg	    func_arith $loop - 1
7426c27c18e8Smrg	    loop=$func_arith_result
7427c27c18e8Smrg	    verstring="$verstring_prefix$major.$iface:$verstring"
7428c27c18e8Smrg	  done
7429c27c18e8Smrg
7430c27c18e8Smrg	  # Before this point, $major must not contain `.'.
7431c27c18e8Smrg	  major=.$major
7432c27c18e8Smrg	  versuffix="$major.$revision"
7433c27c18e8Smrg	  ;;
7434c27c18e8Smrg
7435c27c18e8Smrg	linux)
7436c27c18e8Smrg	  func_arith $current - $age
7437c27c18e8Smrg	  major=.$func_arith_result
7438c27c18e8Smrg	  versuffix="$major.$age.$revision"
7439c27c18e8Smrg	  ;;
7440c27c18e8Smrg
7441c27c18e8Smrg	osf)
7442c27c18e8Smrg	  func_arith $current - $age
7443c27c18e8Smrg	  major=.$func_arith_result
7444c27c18e8Smrg	  versuffix=".$current.$age.$revision"
7445c27c18e8Smrg	  verstring="$current.$age.$revision"
7446c27c18e8Smrg
7447c27c18e8Smrg	  # Add in all the interfaces that we are compatible with.
7448c27c18e8Smrg	  loop=$age
7449c27c18e8Smrg	  while test "$loop" -ne 0; do
7450c27c18e8Smrg	    func_arith $current - $loop
7451c27c18e8Smrg	    iface=$func_arith_result
7452c27c18e8Smrg	    func_arith $loop - 1
7453c27c18e8Smrg	    loop=$func_arith_result
7454c27c18e8Smrg	    verstring="$verstring:${iface}.0"
7455c27c18e8Smrg	  done
7456c27c18e8Smrg
7457c27c18e8Smrg	  # Make executables depend on our current version.
7458b789ec8aSmrg	  func_append verstring ":${current}.0"
7459c27c18e8Smrg	  ;;
7460c27c18e8Smrg
7461c27c18e8Smrg	qnx)
7462c27c18e8Smrg	  major=".$current"
7463c27c18e8Smrg	  versuffix=".$current"
7464c27c18e8Smrg	  ;;
7465c27c18e8Smrg
7466c27c18e8Smrg	sunos)
7467c27c18e8Smrg	  major=".$current"
7468c27c18e8Smrg	  versuffix=".$current.$revision"
7469c27c18e8Smrg	  ;;
7470c27c18e8Smrg
7471c27c18e8Smrg	windows)
7472c27c18e8Smrg	  # Use '-' rather than '.', since we only want one
7473c27c18e8Smrg	  # extension on DOS 8.3 filesystems.
7474c27c18e8Smrg	  func_arith $current - $age
7475c27c18e8Smrg	  major=$func_arith_result
7476c27c18e8Smrg	  versuffix="-$major"
7477c27c18e8Smrg	  ;;
7478c27c18e8Smrg
7479c27c18e8Smrg	*)
7480c27c18e8Smrg	  func_fatal_configuration "unknown library version type \`$version_type'"
7481c27c18e8Smrg	  ;;
7482c27c18e8Smrg	esac
7483c27c18e8Smrg
7484c27c18e8Smrg	# Clear the version info if we defaulted, and they specified a release.
7485c27c18e8Smrg	if test -z "$vinfo" && test -n "$release"; then
7486c27c18e8Smrg	  major=
7487c27c18e8Smrg	  case $version_type in
7488c27c18e8Smrg	  darwin)
7489c27c18e8Smrg	    # we can't check for "0.0" in archive_cmds due to quoting
7490c27c18e8Smrg	    # problems, so we reset it completely
7491c27c18e8Smrg	    verstring=
7492c27c18e8Smrg	    ;;
7493c27c18e8Smrg	  *)
7494c27c18e8Smrg	    verstring="0.0"
7495c27c18e8Smrg	    ;;
7496c27c18e8Smrg	  esac
7497c27c18e8Smrg	  if test "$need_version" = no; then
7498c27c18e8Smrg	    versuffix=
7499c27c18e8Smrg	  else
7500c27c18e8Smrg	    versuffix=".0.0"
7501c27c18e8Smrg	  fi
7502c27c18e8Smrg	fi
7503c27c18e8Smrg
7504c27c18e8Smrg	# Remove version info from name if versioning should be avoided
7505c27c18e8Smrg	if test "$avoid_version" = yes && test "$need_version" = no; then
7506c27c18e8Smrg	  major=
7507c27c18e8Smrg	  versuffix=
7508c27c18e8Smrg	  verstring=""
7509c27c18e8Smrg	fi
7510c27c18e8Smrg
7511c27c18e8Smrg	# Check to see if the archive will have undefined symbols.
7512c27c18e8Smrg	if test "$allow_undefined" = yes; then
7513c27c18e8Smrg	  if test "$allow_undefined_flag" = unsupported; then
7514c27c18e8Smrg	    func_warning "undefined symbols not allowed in $host shared libraries"
7515c27c18e8Smrg	    build_libtool_libs=no
7516c27c18e8Smrg	    build_old_libs=yes
7517c27c18e8Smrg	  fi
7518c27c18e8Smrg	else
7519c27c18e8Smrg	  # Don't allow undefined symbols.
7520c27c18e8Smrg	  allow_undefined_flag="$no_undefined_flag"
7521c27c18e8Smrg	fi
7522c27c18e8Smrg
7523c27c18e8Smrg      fi
7524c27c18e8Smrg
7525c27c18e8Smrg      func_generate_dlsyms "$libname" "$libname" "yes"
7526b789ec8aSmrg      func_append libobjs " $symfileobj"
7527c27c18e8Smrg      test "X$libobjs" = "X " && libobjs=
7528c27c18e8Smrg
7529b789ec8aSmrg      if test "$opt_mode" != relink; then
7530c27c18e8Smrg	# Remove our outputs, but don't remove object files since they
7531c27c18e8Smrg	# may have been created when compiling PIC objects.
7532c27c18e8Smrg	removelist=
7533c27c18e8Smrg	tempremovelist=`$ECHO "$output_objdir/*"`
7534c27c18e8Smrg	for p in $tempremovelist; do
7535c27c18e8Smrg	  case $p in
7536c27c18e8Smrg	    *.$objext | *.gcno)
7537c27c18e8Smrg	       ;;
7538c27c18e8Smrg	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
7539c27c18e8Smrg	       if test "X$precious_files_regex" != "X"; then
7540c27c18e8Smrg		 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
7541c27c18e8Smrg		 then
7542c27c18e8Smrg		   continue
7543c27c18e8Smrg		 fi
7544c27c18e8Smrg	       fi
7545b789ec8aSmrg	       func_append removelist " $p"
7546c27c18e8Smrg	       ;;
7547c27c18e8Smrg	    *) ;;
7548c27c18e8Smrg	  esac
7549c27c18e8Smrg	done
7550c27c18e8Smrg	test -n "$removelist" && \
7551c27c18e8Smrg	  func_show_eval "${RM}r \$removelist"
7552c27c18e8Smrg      fi
7553c27c18e8Smrg
7554c27c18e8Smrg      # Now set the variables for building old libraries.
7555c27c18e8Smrg      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
7556b789ec8aSmrg	func_append oldlibs " $output_objdir/$libname.$libext"
7557c27c18e8Smrg
7558c27c18e8Smrg	# Transform .lo files to .o files.
755937eb1ca1Smrg	oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP`
7560c27c18e8Smrg      fi
7561c27c18e8Smrg
7562c27c18e8Smrg      # Eliminate all temporary directories.
7563c27c18e8Smrg      #for path in $notinst_path; do
756437eb1ca1Smrg      #	lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
756537eb1ca1Smrg      #	deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
756637eb1ca1Smrg      #	dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
7567c27c18e8Smrg      #done
7568c27c18e8Smrg
7569c27c18e8Smrg      if test -n "$xrpath"; then
7570c27c18e8Smrg	# If the user specified any rpath flags, then add them.
7571c27c18e8Smrg	temp_xrpath=
7572c27c18e8Smrg	for libdir in $xrpath; do
7573b789ec8aSmrg	  func_replace_sysroot "$libdir"
7574b789ec8aSmrg	  func_append temp_xrpath " -R$func_replace_sysroot_result"
7575c27c18e8Smrg	  case "$finalize_rpath " in
7576c27c18e8Smrg	  *" $libdir "*) ;;
7577b789ec8aSmrg	  *) func_append finalize_rpath " $libdir" ;;
7578c27c18e8Smrg	  esac
7579c27c18e8Smrg	done
7580c27c18e8Smrg	if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
7581c27c18e8Smrg	  dependency_libs="$temp_xrpath $dependency_libs"
7582c27c18e8Smrg	fi
7583c27c18e8Smrg      fi
7584c27c18e8Smrg
7585c27c18e8Smrg      # Make sure dlfiles contains only unique files that won't be dlpreopened
7586c27c18e8Smrg      old_dlfiles="$dlfiles"
7587c27c18e8Smrg      dlfiles=
7588c27c18e8Smrg      for lib in $old_dlfiles; do
7589c27c18e8Smrg	case " $dlprefiles $dlfiles " in
7590c27c18e8Smrg	*" $lib "*) ;;
7591b789ec8aSmrg	*) func_append dlfiles " $lib" ;;
7592c27c18e8Smrg	esac
7593c27c18e8Smrg      done
7594c27c18e8Smrg
7595c27c18e8Smrg      # Make sure dlprefiles contains only unique files
7596c27c18e8Smrg      old_dlprefiles="$dlprefiles"
7597c27c18e8Smrg      dlprefiles=
7598c27c18e8Smrg      for lib in $old_dlprefiles; do
7599c27c18e8Smrg	case "$dlprefiles " in
7600c27c18e8Smrg	*" $lib "*) ;;
7601b789ec8aSmrg	*) func_append dlprefiles " $lib" ;;
7602c27c18e8Smrg	esac
7603c27c18e8Smrg      done
7604c27c18e8Smrg
7605c27c18e8Smrg      if test "$build_libtool_libs" = yes; then
7606c27c18e8Smrg	if test -n "$rpath"; then
7607c27c18e8Smrg	  case $host in
760837eb1ca1Smrg	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
7609c27c18e8Smrg	    # these systems don't actually have a c library (as such)!
7610c27c18e8Smrg	    ;;
7611c27c18e8Smrg	  *-*-rhapsody* | *-*-darwin1.[012])
7612c27c18e8Smrg	    # Rhapsody C library is in the System framework
7613b789ec8aSmrg	    func_append deplibs " System.ltframework"
7614c27c18e8Smrg	    ;;
7615c27c18e8Smrg	  *-*-netbsd*)
7616c27c18e8Smrg	    # Don't link with libc until the a.out ld.so is fixed.
7617c27c18e8Smrg	    ;;
7618c27c18e8Smrg	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
7619c27c18e8Smrg	    # Do not include libc due to us having libc/libc_r.
7620c27c18e8Smrg	    ;;
7621c27c18e8Smrg	  *-*-sco3.2v5* | *-*-sco5v6*)
7622c27c18e8Smrg	    # Causes problems with __ctype
7623c27c18e8Smrg	    ;;
7624c27c18e8Smrg	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
7625c27c18e8Smrg	    # Compiler inserts libc in the correct place for threads to work
7626c27c18e8Smrg	    ;;
7627c27c18e8Smrg	  *)
7628c27c18e8Smrg	    # Add libc to deplibs on all other systems if necessary.
7629c27c18e8Smrg	    if test "$build_libtool_need_lc" = "yes"; then
7630b789ec8aSmrg	      func_append deplibs " -lc"
7631c27c18e8Smrg	    fi
7632c27c18e8Smrg	    ;;
7633c27c18e8Smrg	  esac
7634c27c18e8Smrg	fi
7635c27c18e8Smrg
7636c27c18e8Smrg	# Transform deplibs into only deplibs that can be linked in shared.
7637c27c18e8Smrg	name_save=$name
7638c27c18e8Smrg	libname_save=$libname
7639c27c18e8Smrg	release_save=$release
7640c27c18e8Smrg	versuffix_save=$versuffix
7641c27c18e8Smrg	major_save=$major
7642c27c18e8Smrg	# I'm not sure if I'm treating the release correctly.  I think
7643c27c18e8Smrg	# release should show up in the -l (ie -lgmp5) so we don't want to
7644c27c18e8Smrg	# add it in twice.  Is that correct?
7645c27c18e8Smrg	release=""
7646c27c18e8Smrg	versuffix=""
7647c27c18e8Smrg	major=""
7648c27c18e8Smrg	newdeplibs=
7649c27c18e8Smrg	droppeddeps=no
7650c27c18e8Smrg	case $deplibs_check_method in
7651c27c18e8Smrg	pass_all)
7652c27c18e8Smrg	  # Don't check for shared/static.  Everything works.
7653c27c18e8Smrg	  # This might be a little naive.  We might want to check
7654c27c18e8Smrg	  # whether the library exists or not.  But this is on
7655c27c18e8Smrg	  # osf3 & osf4 and I'm not really sure... Just
7656c27c18e8Smrg	  # implementing what was already the behavior.
7657c27c18e8Smrg	  newdeplibs=$deplibs
7658c27c18e8Smrg	  ;;
7659c27c18e8Smrg	test_compile)
7660c27c18e8Smrg	  # This code stresses the "libraries are programs" paradigm to its
7661c27c18e8Smrg	  # limits. Maybe even breaks it.  We compile a program, linking it
7662c27c18e8Smrg	  # against the deplibs as a proxy for the library.  Then we can check
7663c27c18e8Smrg	  # whether they linked in statically or dynamically with ldd.
7664c27c18e8Smrg	  $opt_dry_run || $RM conftest.c
7665c27c18e8Smrg	  cat > conftest.c <<EOF
7666c27c18e8Smrg	  int main() { return 0; }
7667c27c18e8SmrgEOF
7668c27c18e8Smrg	  $opt_dry_run || $RM conftest
7669c27c18e8Smrg	  if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
7670c27c18e8Smrg	    ldd_output=`ldd conftest`
7671c27c18e8Smrg	    for i in $deplibs; do
7672c27c18e8Smrg	      case $i in
7673c27c18e8Smrg	      -l*)
7674c27c18e8Smrg		func_stripname -l '' "$i"
7675c27c18e8Smrg		name=$func_stripname_result
7676c27c18e8Smrg		if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7677c27c18e8Smrg		  case " $predeps $postdeps " in
7678c27c18e8Smrg		  *" $i "*)
7679b789ec8aSmrg		    func_append newdeplibs " $i"
7680c27c18e8Smrg		    i=""
7681c27c18e8Smrg		    ;;
7682c27c18e8Smrg		  esac
7683c27c18e8Smrg		fi
7684c27c18e8Smrg		if test -n "$i" ; then
7685c27c18e8Smrg		  libname=`eval "\\$ECHO \"$libname_spec\""`
7686c27c18e8Smrg		  deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
7687c27c18e8Smrg		  set dummy $deplib_matches; shift
7688c27c18e8Smrg		  deplib_match=$1
7689c27c18e8Smrg		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
7690b789ec8aSmrg		    func_append newdeplibs " $i"
7691c27c18e8Smrg		  else
7692c27c18e8Smrg		    droppeddeps=yes
769337eb1ca1Smrg		    echo
7694c27c18e8Smrg		    $ECHO "*** Warning: dynamic linker does not accept needed library $i."
769537eb1ca1Smrg		    echo "*** I have the capability to make that library automatically link in when"
769637eb1ca1Smrg		    echo "*** you link to this library.  But I can only do this if you have a"
769737eb1ca1Smrg		    echo "*** shared version of the library, which I believe you do not have"
769837eb1ca1Smrg		    echo "*** because a test_compile did reveal that the linker did not use it for"
769937eb1ca1Smrg		    echo "*** its dynamic dependency list that programs get resolved with at runtime."
7700c27c18e8Smrg		  fi
7701c27c18e8Smrg		fi
7702c27c18e8Smrg		;;
7703c27c18e8Smrg	      *)
7704b789ec8aSmrg		func_append newdeplibs " $i"
7705c27c18e8Smrg		;;
7706c27c18e8Smrg	      esac
7707c27c18e8Smrg	    done
7708c27c18e8Smrg	  else
7709c27c18e8Smrg	    # Error occurred in the first compile.  Let's try to salvage
7710c27c18e8Smrg	    # the situation: Compile a separate program for each library.
7711c27c18e8Smrg	    for i in $deplibs; do
7712c27c18e8Smrg	      case $i in
7713c27c18e8Smrg	      -l*)
7714c27c18e8Smrg		func_stripname -l '' "$i"
7715c27c18e8Smrg		name=$func_stripname_result
7716c27c18e8Smrg		$opt_dry_run || $RM conftest
7717c27c18e8Smrg		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
7718c27c18e8Smrg		  ldd_output=`ldd conftest`
7719c27c18e8Smrg		  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7720c27c18e8Smrg		    case " $predeps $postdeps " in
7721c27c18e8Smrg		    *" $i "*)
7722b789ec8aSmrg		      func_append newdeplibs " $i"
7723c27c18e8Smrg		      i=""
7724c27c18e8Smrg		      ;;
7725c27c18e8Smrg		    esac
7726c27c18e8Smrg		  fi
7727c27c18e8Smrg		  if test -n "$i" ; then
7728c27c18e8Smrg		    libname=`eval "\\$ECHO \"$libname_spec\""`
7729c27c18e8Smrg		    deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
7730c27c18e8Smrg		    set dummy $deplib_matches; shift
7731c27c18e8Smrg		    deplib_match=$1
7732c27c18e8Smrg		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
7733b789ec8aSmrg		      func_append newdeplibs " $i"
7734c27c18e8Smrg		    else
7735c27c18e8Smrg		      droppeddeps=yes
773637eb1ca1Smrg		      echo
7737c27c18e8Smrg		      $ECHO "*** Warning: dynamic linker does not accept needed library $i."
773837eb1ca1Smrg		      echo "*** I have the capability to make that library automatically link in when"
773937eb1ca1Smrg		      echo "*** you link to this library.  But I can only do this if you have a"
774037eb1ca1Smrg		      echo "*** shared version of the library, which you do not appear to have"
774137eb1ca1Smrg		      echo "*** because a test_compile did reveal that the linker did not use this one"
774237eb1ca1Smrg		      echo "*** as a dynamic dependency that programs can get resolved with at runtime."
7743c27c18e8Smrg		    fi
7744c27c18e8Smrg		  fi
7745c27c18e8Smrg		else
7746c27c18e8Smrg		  droppeddeps=yes
774737eb1ca1Smrg		  echo
7748c27c18e8Smrg		  $ECHO "*** Warning!  Library $i is needed by this library but I was not able to"
774937eb1ca1Smrg		  echo "*** make it link in!  You will probably need to install it or some"
775037eb1ca1Smrg		  echo "*** library that it depends on before this library will be fully"
775137eb1ca1Smrg		  echo "*** functional.  Installing it before continuing would be even better."
7752c27c18e8Smrg		fi
7753c27c18e8Smrg		;;
7754c27c18e8Smrg	      *)
7755b789ec8aSmrg		func_append newdeplibs " $i"
7756c27c18e8Smrg		;;
7757c27c18e8Smrg	      esac
7758c27c18e8Smrg	    done
7759c27c18e8Smrg	  fi
7760c27c18e8Smrg	  ;;
7761c27c18e8Smrg	file_magic*)
7762c27c18e8Smrg	  set dummy $deplibs_check_method; shift
7763c27c18e8Smrg	  file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
7764c27c18e8Smrg	  for a_deplib in $deplibs; do
7765c27c18e8Smrg	    case $a_deplib in
7766c27c18e8Smrg	    -l*)
7767c27c18e8Smrg	      func_stripname -l '' "$a_deplib"
7768c27c18e8Smrg	      name=$func_stripname_result
7769c27c18e8Smrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7770c27c18e8Smrg		case " $predeps $postdeps " in
7771c27c18e8Smrg		*" $a_deplib "*)
7772b789ec8aSmrg		  func_append newdeplibs " $a_deplib"
7773c27c18e8Smrg		  a_deplib=""
7774c27c18e8Smrg		  ;;
7775c27c18e8Smrg		esac
7776c27c18e8Smrg	      fi
7777c27c18e8Smrg	      if test -n "$a_deplib" ; then
7778c27c18e8Smrg		libname=`eval "\\$ECHO \"$libname_spec\""`
7779b789ec8aSmrg		if test -n "$file_magic_glob"; then
7780b789ec8aSmrg		  libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob`
7781b789ec8aSmrg		else
7782b789ec8aSmrg		  libnameglob=$libname
7783b789ec8aSmrg		fi
7784b789ec8aSmrg		test "$want_nocaseglob" = yes && nocaseglob=`shopt -p nocaseglob`
7785c27c18e8Smrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
7786b789ec8aSmrg		  if test "$want_nocaseglob" = yes; then
7787b789ec8aSmrg		    shopt -s nocaseglob
7788b789ec8aSmrg		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
7789b789ec8aSmrg		    $nocaseglob
7790b789ec8aSmrg		  else
7791b789ec8aSmrg		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
7792b789ec8aSmrg		  fi
7793c27c18e8Smrg		  for potent_lib in $potential_libs; do
7794c27c18e8Smrg		      # Follow soft links.
7795c27c18e8Smrg		      if ls -lLd "$potent_lib" 2>/dev/null |
7796c27c18e8Smrg			 $GREP " -> " >/dev/null; then
7797c27c18e8Smrg			continue
7798c27c18e8Smrg		      fi
7799c27c18e8Smrg		      # The statement above tries to avoid entering an
7800c27c18e8Smrg		      # endless loop below, in case of cyclic links.
7801c27c18e8Smrg		      # We might still enter an endless loop, since a link
7802c27c18e8Smrg		      # loop can be closed while we follow links,
7803c27c18e8Smrg		      # but so what?
7804c27c18e8Smrg		      potlib="$potent_lib"
7805c27c18e8Smrg		      while test -h "$potlib" 2>/dev/null; do
7806c27c18e8Smrg			potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
7807c27c18e8Smrg			case $potliblink in
7808c27c18e8Smrg			[\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
780937eb1ca1Smrg			*) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";;
7810c27c18e8Smrg			esac
7811c27c18e8Smrg		      done
7812c27c18e8Smrg		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
7813c27c18e8Smrg			 $SED -e 10q |
7814c27c18e8Smrg			 $EGREP "$file_magic_regex" > /dev/null; then
7815b789ec8aSmrg			func_append newdeplibs " $a_deplib"
7816c27c18e8Smrg			a_deplib=""
7817c27c18e8Smrg			break 2
7818c27c18e8Smrg		      fi
7819c27c18e8Smrg		  done
7820c27c18e8Smrg		done
7821c27c18e8Smrg	      fi
7822c27c18e8Smrg	      if test -n "$a_deplib" ; then
7823c27c18e8Smrg		droppeddeps=yes
782437eb1ca1Smrg		echo
7825c27c18e8Smrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
782637eb1ca1Smrg		echo "*** I have the capability to make that library automatically link in when"
782737eb1ca1Smrg		echo "*** you link to this library.  But I can only do this if you have a"
782837eb1ca1Smrg		echo "*** shared version of the library, which you do not appear to have"
782937eb1ca1Smrg		echo "*** because I did check the linker path looking for a file starting"
7830c27c18e8Smrg		if test -z "$potlib" ; then
7831c27c18e8Smrg		  $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
7832c27c18e8Smrg		else
7833c27c18e8Smrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
7834c27c18e8Smrg		  $ECHO "*** using a file magic. Last file checked: $potlib"
7835c27c18e8Smrg		fi
7836c27c18e8Smrg	      fi
7837c27c18e8Smrg	      ;;
7838c27c18e8Smrg	    *)
7839c27c18e8Smrg	      # Add a -L argument.
7840b789ec8aSmrg	      func_append newdeplibs " $a_deplib"
7841c27c18e8Smrg	      ;;
7842c27c18e8Smrg	    esac
7843c27c18e8Smrg	  done # Gone through all deplibs.
7844c27c18e8Smrg	  ;;
7845c27c18e8Smrg	match_pattern*)
7846c27c18e8Smrg	  set dummy $deplibs_check_method; shift
7847c27c18e8Smrg	  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
7848c27c18e8Smrg	  for a_deplib in $deplibs; do
7849c27c18e8Smrg	    case $a_deplib in
7850c27c18e8Smrg	    -l*)
7851c27c18e8Smrg	      func_stripname -l '' "$a_deplib"
7852c27c18e8Smrg	      name=$func_stripname_result
7853c27c18e8Smrg	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7854c27c18e8Smrg		case " $predeps $postdeps " in
7855c27c18e8Smrg		*" $a_deplib "*)
7856b789ec8aSmrg		  func_append newdeplibs " $a_deplib"
7857c27c18e8Smrg		  a_deplib=""
7858c27c18e8Smrg		  ;;
7859c27c18e8Smrg		esac
7860c27c18e8Smrg	      fi
7861c27c18e8Smrg	      if test -n "$a_deplib" ; then
7862c27c18e8Smrg		libname=`eval "\\$ECHO \"$libname_spec\""`
7863c27c18e8Smrg		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
7864c27c18e8Smrg		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
7865c27c18e8Smrg		  for potent_lib in $potential_libs; do
7866c27c18e8Smrg		    potlib="$potent_lib" # see symlink-check above in file_magic test
786737eb1ca1Smrg		    if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
7868c27c18e8Smrg		       $EGREP "$match_pattern_regex" > /dev/null; then
7869b789ec8aSmrg		      func_append newdeplibs " $a_deplib"
7870c27c18e8Smrg		      a_deplib=""
7871c27c18e8Smrg		      break 2
7872c27c18e8Smrg		    fi
7873c27c18e8Smrg		  done
7874c27c18e8Smrg		done
7875c27c18e8Smrg	      fi
7876c27c18e8Smrg	      if test -n "$a_deplib" ; then
7877c27c18e8Smrg		droppeddeps=yes
787837eb1ca1Smrg		echo
7879c27c18e8Smrg		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
788037eb1ca1Smrg		echo "*** I have the capability to make that library automatically link in when"
788137eb1ca1Smrg		echo "*** you link to this library.  But I can only do this if you have a"
788237eb1ca1Smrg		echo "*** shared version of the library, which you do not appear to have"
788337eb1ca1Smrg		echo "*** because I did check the linker path looking for a file starting"
7884c27c18e8Smrg		if test -z "$potlib" ; then
7885c27c18e8Smrg		  $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
7886c27c18e8Smrg		else
7887c27c18e8Smrg		  $ECHO "*** with $libname and none of the candidates passed a file format test"
7888c27c18e8Smrg		  $ECHO "*** using a regex pattern. Last file checked: $potlib"
7889c27c18e8Smrg		fi
7890c27c18e8Smrg	      fi
7891c27c18e8Smrg	      ;;
7892c27c18e8Smrg	    *)
7893c27c18e8Smrg	      # Add a -L argument.
7894b789ec8aSmrg	      func_append newdeplibs " $a_deplib"
7895c27c18e8Smrg	      ;;
7896c27c18e8Smrg	    esac
7897c27c18e8Smrg	  done # Gone through all deplibs.
7898c27c18e8Smrg	  ;;
7899c27c18e8Smrg	none | unknown | *)
7900c27c18e8Smrg	  newdeplibs=""
790137eb1ca1Smrg	  tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
7902c27c18e8Smrg	  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7903c27c18e8Smrg	    for i in $predeps $postdeps ; do
7904c27c18e8Smrg	      # can't use Xsed below, because $i might contain '/'
790537eb1ca1Smrg	      tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"`
7906c27c18e8Smrg	    done
7907c27c18e8Smrg	  fi
790837eb1ca1Smrg	  case $tmp_deplibs in
790937eb1ca1Smrg	  *[!\	\ ]*)
791037eb1ca1Smrg	    echo
7911c27c18e8Smrg	    if test "X$deplibs_check_method" = "Xnone"; then
791237eb1ca1Smrg	      echo "*** Warning: inter-library dependencies are not supported in this platform."
7913c27c18e8Smrg	    else
791437eb1ca1Smrg	      echo "*** Warning: inter-library dependencies are not known to be supported."
7915c27c18e8Smrg	    fi
791637eb1ca1Smrg	    echo "*** All declared inter-library dependencies are being dropped."
7917c27c18e8Smrg	    droppeddeps=yes
791837eb1ca1Smrg	    ;;
791937eb1ca1Smrg	  esac
7920c27c18e8Smrg	  ;;
7921c27c18e8Smrg	esac
7922c27c18e8Smrg	versuffix=$versuffix_save
7923c27c18e8Smrg	major=$major_save
7924c27c18e8Smrg	release=$release_save
7925c27c18e8Smrg	libname=$libname_save
7926c27c18e8Smrg	name=$name_save
7927c27c18e8Smrg
7928c27c18e8Smrg	case $host in
7929c27c18e8Smrg	*-*-rhapsody* | *-*-darwin1.[012])
7930c27c18e8Smrg	  # On Rhapsody replace the C library with the System framework
793137eb1ca1Smrg	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
7932c27c18e8Smrg	  ;;
7933c27c18e8Smrg	esac
7934c27c18e8Smrg
7935c27c18e8Smrg	if test "$droppeddeps" = yes; then
7936c27c18e8Smrg	  if test "$module" = yes; then
793737eb1ca1Smrg	    echo
793837eb1ca1Smrg	    echo "*** Warning: libtool could not satisfy all declared inter-library"
7939c27c18e8Smrg	    $ECHO "*** dependencies of module $libname.  Therefore, libtool will create"
794037eb1ca1Smrg	    echo "*** a static module, that should work as long as the dlopening"
794137eb1ca1Smrg	    echo "*** application is linked with the -dlopen flag."
7942c27c18e8Smrg	    if test -z "$global_symbol_pipe"; then
794337eb1ca1Smrg	      echo
794437eb1ca1Smrg	      echo "*** However, this would only work if libtool was able to extract symbol"
794537eb1ca1Smrg	      echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
794637eb1ca1Smrg	      echo "*** not find such a program.  So, this module is probably useless."
794737eb1ca1Smrg	      echo "*** \`nm' from GNU binutils and a full rebuild may help."
7948c27c18e8Smrg	    fi
7949c27c18e8Smrg	    if test "$build_old_libs" = no; then
7950c27c18e8Smrg	      oldlibs="$output_objdir/$libname.$libext"
7951c27c18e8Smrg	      build_libtool_libs=module
7952c27c18e8Smrg	      build_old_libs=yes
7953c27c18e8Smrg	    else
7954c27c18e8Smrg	      build_libtool_libs=no
7955c27c18e8Smrg	    fi
7956c27c18e8Smrg	  else
795737eb1ca1Smrg	    echo "*** The inter-library dependencies that have been dropped here will be"
795837eb1ca1Smrg	    echo "*** automatically added whenever a program is linked with this library"
795937eb1ca1Smrg	    echo "*** or is declared to -dlopen it."
7960c27c18e8Smrg
7961c27c18e8Smrg	    if test "$allow_undefined" = no; then
796237eb1ca1Smrg	      echo
796337eb1ca1Smrg	      echo "*** Since this library must not contain undefined symbols,"
796437eb1ca1Smrg	      echo "*** because either the platform does not support them or"
796537eb1ca1Smrg	      echo "*** it was explicitly requested with -no-undefined,"
796637eb1ca1Smrg	      echo "*** libtool will only create a static version of it."
7967c27c18e8Smrg	      if test "$build_old_libs" = no; then
7968c27c18e8Smrg		oldlibs="$output_objdir/$libname.$libext"
7969c27c18e8Smrg		build_libtool_libs=module
7970c27c18e8Smrg		build_old_libs=yes
7971c27c18e8Smrg	      else
7972c27c18e8Smrg		build_libtool_libs=no
7973c27c18e8Smrg	      fi
7974c27c18e8Smrg	    fi
7975c27c18e8Smrg	  fi
7976c27c18e8Smrg	fi
7977c27c18e8Smrg	# Done checking deplibs!
7978c27c18e8Smrg	deplibs=$newdeplibs
7979c27c18e8Smrg      fi
7980c27c18e8Smrg      # Time to change all our "foo.ltframework" stuff back to "-framework foo"
7981c27c18e8Smrg      case $host in
7982c27c18e8Smrg	*-*-darwin*)
798337eb1ca1Smrg	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
798437eb1ca1Smrg	  new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
798537eb1ca1Smrg	  deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
7986c27c18e8Smrg	  ;;
7987c27c18e8Smrg      esac
7988c27c18e8Smrg
7989c27c18e8Smrg      # move library search paths that coincide with paths to not yet
7990c27c18e8Smrg      # installed libraries to the beginning of the library search list
7991c27c18e8Smrg      new_libs=
7992c27c18e8Smrg      for path in $notinst_path; do
7993c27c18e8Smrg	case " $new_libs " in
7994c27c18e8Smrg	*" -L$path/$objdir "*) ;;
7995c27c18e8Smrg	*)
7996c27c18e8Smrg	  case " $deplibs " in
7997c27c18e8Smrg	  *" -L$path/$objdir "*)
7998b789ec8aSmrg	    func_append new_libs " -L$path/$objdir" ;;
7999c27c18e8Smrg	  esac
8000c27c18e8Smrg	  ;;
8001c27c18e8Smrg	esac
8002c27c18e8Smrg      done
8003c27c18e8Smrg      for deplib in $deplibs; do
8004c27c18e8Smrg	case $deplib in
8005c27c18e8Smrg	-L*)
8006c27c18e8Smrg	  case " $new_libs " in
8007c27c18e8Smrg	  *" $deplib "*) ;;
8008b789ec8aSmrg	  *) func_append new_libs " $deplib" ;;
8009c27c18e8Smrg	  esac
8010c27c18e8Smrg	  ;;
8011b789ec8aSmrg	*) func_append new_libs " $deplib" ;;
8012c27c18e8Smrg	esac
8013c27c18e8Smrg      done
8014c27c18e8Smrg      deplibs="$new_libs"
8015c27c18e8Smrg
8016c27c18e8Smrg      # All the library-specific variables (install_libdir is set above).
8017c27c18e8Smrg      library_names=
8018c27c18e8Smrg      old_library=
8019c27c18e8Smrg      dlname=
8020c27c18e8Smrg
8021c27c18e8Smrg      # Test again, we may have decided not to build it any more
8022c27c18e8Smrg      if test "$build_libtool_libs" = yes; then
8023c27c18e8Smrg	if test "$hardcode_into_libs" = yes; then
8024c27c18e8Smrg	  # Hardcode the library paths
8025c27c18e8Smrg	  hardcode_libdirs=
8026c27c18e8Smrg	  dep_rpath=
8027c27c18e8Smrg	  rpath="$finalize_rpath"
8028b789ec8aSmrg	  test "$opt_mode" != relink && rpath="$compile_rpath$rpath"
8029c27c18e8Smrg	  for libdir in $rpath; do
8030c27c18e8Smrg	    if test -n "$hardcode_libdir_flag_spec"; then
8031c27c18e8Smrg	      if test -n "$hardcode_libdir_separator"; then
8032b789ec8aSmrg		func_replace_sysroot "$libdir"
8033b789ec8aSmrg		libdir=$func_replace_sysroot_result
8034c27c18e8Smrg		if test -z "$hardcode_libdirs"; then
8035c27c18e8Smrg		  hardcode_libdirs="$libdir"
8036c27c18e8Smrg		else
8037c27c18e8Smrg		  # Just accumulate the unique libdirs.
8038c27c18e8Smrg		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
8039c27c18e8Smrg		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
8040c27c18e8Smrg		    ;;
8041c27c18e8Smrg		  *)
8042b789ec8aSmrg		    func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
8043c27c18e8Smrg		    ;;
8044c27c18e8Smrg		  esac
8045c27c18e8Smrg		fi
8046c27c18e8Smrg	      else
8047c27c18e8Smrg		eval flag=\"$hardcode_libdir_flag_spec\"
8048b789ec8aSmrg		func_append dep_rpath " $flag"
8049c27c18e8Smrg	      fi
8050c27c18e8Smrg	    elif test -n "$runpath_var"; then
8051c27c18e8Smrg	      case "$perm_rpath " in
8052c27c18e8Smrg	      *" $libdir "*) ;;
8053b789ec8aSmrg	      *) func_apped perm_rpath " $libdir" ;;
8054c27c18e8Smrg	      esac
8055c27c18e8Smrg	    fi
8056c27c18e8Smrg	  done
8057c27c18e8Smrg	  # Substitute the hardcoded libdirs into the rpath.
8058c27c18e8Smrg	  if test -n "$hardcode_libdir_separator" &&
8059c27c18e8Smrg	     test -n "$hardcode_libdirs"; then
8060c27c18e8Smrg	    libdir="$hardcode_libdirs"
8061c27c18e8Smrg	    if test -n "$hardcode_libdir_flag_spec_ld"; then
8062c27c18e8Smrg	      eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\"
8063c27c18e8Smrg	    else
8064c27c18e8Smrg	      eval dep_rpath=\"$hardcode_libdir_flag_spec\"
8065c27c18e8Smrg	    fi
8066c27c18e8Smrg	  fi
8067c27c18e8Smrg	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
8068c27c18e8Smrg	    # We should set the runpath_var.
8069c27c18e8Smrg	    rpath=
8070c27c18e8Smrg	    for dir in $perm_rpath; do
8071b789ec8aSmrg	      func_append rpath "$dir:"
8072c27c18e8Smrg	    done
8073c27c18e8Smrg	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
8074c27c18e8Smrg	  fi
8075c27c18e8Smrg	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
8076c27c18e8Smrg	fi
8077c43cc173Smrg
8078c27c18e8Smrg	shlibpath="$finalize_shlibpath"
8079b789ec8aSmrg	test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
8080c27c18e8Smrg	if test -n "$shlibpath"; then
8081c27c18e8Smrg	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
8082c27c18e8Smrg	fi
8083c43cc173Smrg
8084c27c18e8Smrg	# Get the real and link names of the library.
8085c27c18e8Smrg	eval shared_ext=\"$shrext_cmds\"
8086c27c18e8Smrg	eval library_names=\"$library_names_spec\"
8087c27c18e8Smrg	set dummy $library_names
8088c27c18e8Smrg	shift
8089c27c18e8Smrg	realname="$1"
8090c27c18e8Smrg	shift
8091c43cc173Smrg
8092c27c18e8Smrg	if test -n "$soname_spec"; then
8093c27c18e8Smrg	  eval soname=\"$soname_spec\"
8094c27c18e8Smrg	else
8095c27c18e8Smrg	  soname="$realname"
8096c27c18e8Smrg	fi
8097c27c18e8Smrg	if test -z "$dlname"; then
8098c27c18e8Smrg	  dlname=$soname
8099c27c18e8Smrg	fi
8100c43cc173Smrg
8101c27c18e8Smrg	lib="$output_objdir/$realname"
8102c27c18e8Smrg	linknames=
8103c27c18e8Smrg	for link
8104c27c18e8Smrg	do
8105b789ec8aSmrg	  func_append linknames " $link"
8106c27c18e8Smrg	done
8107c43cc173Smrg
8108c27c18e8Smrg	# Use standard objects if they are pic
810937eb1ca1Smrg	test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
8110c27c18e8Smrg	test "X$libobjs" = "X " && libobjs=
8111c43cc173Smrg
8112c27c18e8Smrg	delfiles=
8113c27c18e8Smrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
8114c27c18e8Smrg	  $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
8115c27c18e8Smrg	  export_symbols="$output_objdir/$libname.uexp"
8116b789ec8aSmrg	  func_append delfiles " $export_symbols"
8117c27c18e8Smrg	fi
8118c43cc173Smrg
8119c27c18e8Smrg	orig_export_symbols=
8120c27c18e8Smrg	case $host_os in
8121c27c18e8Smrg	cygwin* | mingw* | cegcc*)
8122c27c18e8Smrg	  if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
8123c27c18e8Smrg	    # exporting using user supplied symfile
8124c27c18e8Smrg	    if test "x`$SED 1q $export_symbols`" != xEXPORTS; then
8125c27c18e8Smrg	      # and it's NOT already a .def file. Must figure out
8126c27c18e8Smrg	      # which of the given symbols are data symbols and tag
8127c27c18e8Smrg	      # them as such. So, trigger use of export_symbols_cmds.
8128c27c18e8Smrg	      # export_symbols gets reassigned inside the "prepare
8129c27c18e8Smrg	      # the list of exported symbols" if statement, so the
8130c27c18e8Smrg	      # include_expsyms logic still works.
8131c27c18e8Smrg	      orig_export_symbols="$export_symbols"
8132c27c18e8Smrg	      export_symbols=
8133c27c18e8Smrg	      always_export_symbols=yes
8134c27c18e8Smrg	    fi
8135c27c18e8Smrg	  fi
8136c27c18e8Smrg	  ;;
8137c27c18e8Smrg	esac
8138c43cc173Smrg
8139c27c18e8Smrg	# Prepare the list of exported symbols
8140c27c18e8Smrg	if test -z "$export_symbols"; then
8141c27c18e8Smrg	  if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
8142c27c18e8Smrg	    func_verbose "generating symbol list for \`$libname.la'"
8143c27c18e8Smrg	    export_symbols="$output_objdir/$libname.exp"
8144c27c18e8Smrg	    $opt_dry_run || $RM $export_symbols
8145c27c18e8Smrg	    cmds=$export_symbols_cmds
8146c27c18e8Smrg	    save_ifs="$IFS"; IFS='~'
8147b789ec8aSmrg	    for cmd1 in $cmds; do
8148c27c18e8Smrg	      IFS="$save_ifs"
8149b789ec8aSmrg	      # Take the normal branch if the nm_file_list_spec branch
8150b789ec8aSmrg	      # doesn't work or if tool conversion is not needed.
8151b789ec8aSmrg	      case $nm_file_list_spec~$to_tool_file_cmd in
8152b789ec8aSmrg		*~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*)
8153b789ec8aSmrg		  try_normal_branch=yes
8154b789ec8aSmrg		  eval cmd=\"$cmd1\"
8155b789ec8aSmrg		  func_len " $cmd"
8156b789ec8aSmrg		  len=$func_len_result
8157b789ec8aSmrg		  ;;
8158b789ec8aSmrg		*)
8159b789ec8aSmrg		  try_normal_branch=no
8160b789ec8aSmrg		  ;;
8161b789ec8aSmrg	      esac
8162b789ec8aSmrg	      if test "$try_normal_branch" = yes \
8163b789ec8aSmrg		 && { test "$len" -lt "$max_cmd_len" \
8164b789ec8aSmrg		      || test "$max_cmd_len" -le -1; }
8165b789ec8aSmrg	      then
8166b789ec8aSmrg		func_show_eval "$cmd" 'exit $?'
8167b789ec8aSmrg		skipped_export=false
8168b789ec8aSmrg	      elif test -n "$nm_file_list_spec"; then
8169b789ec8aSmrg		func_basename "$output"
8170b789ec8aSmrg		output_la=$func_basename_result
8171b789ec8aSmrg		save_libobjs=$libobjs
8172b789ec8aSmrg		save_output=$output
8173b789ec8aSmrg		output=${output_objdir}/${output_la}.nm
8174b789ec8aSmrg		func_to_tool_file "$output"
8175b789ec8aSmrg		libobjs=$nm_file_list_spec$func_to_tool_file_result
8176b789ec8aSmrg		func_append delfiles " $output"
8177b789ec8aSmrg		func_verbose "creating $NM input file list: $output"
8178b789ec8aSmrg		for obj in $save_libobjs; do
8179b789ec8aSmrg		  func_to_tool_file "$obj"
8180b789ec8aSmrg		  $ECHO "$func_to_tool_file_result"
8181b789ec8aSmrg		done > "$output"
8182b789ec8aSmrg		eval cmd=\"$cmd1\"
8183c27c18e8Smrg		func_show_eval "$cmd" 'exit $?'
8184b789ec8aSmrg		output=$save_output
8185b789ec8aSmrg		libobjs=$save_libobjs
8186c27c18e8Smrg		skipped_export=false
8187c27c18e8Smrg	      else
8188c27c18e8Smrg		# The command line is too long to execute in one step.
8189c27c18e8Smrg		func_verbose "using reloadable object file for export list..."
8190c27c18e8Smrg		skipped_export=:
8191c27c18e8Smrg		# Break out early, otherwise skipped_export may be
8192c27c18e8Smrg		# set to false by a later but shorter cmd.
8193c27c18e8Smrg		break
8194c27c18e8Smrg	      fi
8195c27c18e8Smrg	    done
8196c27c18e8Smrg	    IFS="$save_ifs"
8197c27c18e8Smrg	    if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then
8198c27c18e8Smrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
8199c27c18e8Smrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
8200c27c18e8Smrg	    fi
8201c27c18e8Smrg	  fi
8202c27c18e8Smrg	fi
8203c43cc173Smrg
8204c27c18e8Smrg	if test -n "$export_symbols" && test -n "$include_expsyms"; then
8205c27c18e8Smrg	  tmp_export_symbols="$export_symbols"
8206c27c18e8Smrg	  test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
820737eb1ca1Smrg	  $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
8208c27c18e8Smrg	fi
8209c43cc173Smrg
8210c27c18e8Smrg	if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then
8211c27c18e8Smrg	  # The given exports_symbols file has to be filtered, so filter it.
8212c27c18e8Smrg	  func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
8213c27c18e8Smrg	  # FIXME: $output_objdir/$libname.filter potentially contains lots of
8214c27c18e8Smrg	  # 's' commands which not all seds can handle. GNU sed should be fine
8215c27c18e8Smrg	  # though. Also, the filter scales superlinearly with the number of
8216c27c18e8Smrg	  # global variables. join(1) would be nice here, but unfortunately
8217c27c18e8Smrg	  # isn't a blessed tool.
8218c27c18e8Smrg	  $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
8219b789ec8aSmrg	  func_append delfiles " $export_symbols $output_objdir/$libname.filter"
8220c27c18e8Smrg	  export_symbols=$output_objdir/$libname.def
8221c27c18e8Smrg	  $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
8222c43cc173Smrg	fi
8223c43cc173Smrg
8224c27c18e8Smrg	tmp_deplibs=
8225c27c18e8Smrg	for test_deplib in $deplibs; do
8226c27c18e8Smrg	  case " $convenience " in
8227c27c18e8Smrg	  *" $test_deplib "*) ;;
8228c27c18e8Smrg	  *)
8229b789ec8aSmrg	    func_append tmp_deplibs " $test_deplib"
8230c27c18e8Smrg	    ;;
8231c27c18e8Smrg	  esac
8232c27c18e8Smrg	done
8233c27c18e8Smrg	deplibs="$tmp_deplibs"
8234c43cc173Smrg
8235c27c18e8Smrg	if test -n "$convenience"; then
8236c27c18e8Smrg	  if test -n "$whole_archive_flag_spec" &&
8237c27c18e8Smrg	    test "$compiler_needs_object" = yes &&
8238c27c18e8Smrg	    test -z "$libobjs"; then
8239c27c18e8Smrg	    # extract the archives, so we have objects to list.
8240c27c18e8Smrg	    # TODO: could optimize this to just extract one archive.
8241c27c18e8Smrg	    whole_archive_flag_spec=
8242c27c18e8Smrg	  fi
8243c27c18e8Smrg	  if test -n "$whole_archive_flag_spec"; then
8244c27c18e8Smrg	    save_libobjs=$libobjs
8245c27c18e8Smrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
8246c27c18e8Smrg	    test "X$libobjs" = "X " && libobjs=
8247c27c18e8Smrg	  else
8248c27c18e8Smrg	    gentop="$output_objdir/${outputname}x"
8249b789ec8aSmrg	    func_append generated " $gentop"
8250c43cc173Smrg
8251c27c18e8Smrg	    func_extract_archives $gentop $convenience
8252b789ec8aSmrg	    func_append libobjs " $func_extract_archives_result"
8253c27c18e8Smrg	    test "X$libobjs" = "X " && libobjs=
8254c27c18e8Smrg	  fi
8255c27c18e8Smrg	fi
8256c43cc173Smrg
8257c27c18e8Smrg	if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
8258c27c18e8Smrg	  eval flag=\"$thread_safe_flag_spec\"
8259b789ec8aSmrg	  func_append linker_flags " $flag"
8260c27c18e8Smrg	fi
8261c43cc173Smrg
8262c27c18e8Smrg	# Make a backup of the uninstalled library when relinking
8263b789ec8aSmrg	if test "$opt_mode" = relink; then
8264c27c18e8Smrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
8265c43cc173Smrg	fi
8266c43cc173Smrg
8267c27c18e8Smrg	# Do each of the archive commands.
8268c27c18e8Smrg	if test "$module" = yes && test -n "$module_cmds" ; then
8269c27c18e8Smrg	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
8270c27c18e8Smrg	    eval test_cmds=\"$module_expsym_cmds\"
8271c27c18e8Smrg	    cmds=$module_expsym_cmds
8272c27c18e8Smrg	  else
8273c27c18e8Smrg	    eval test_cmds=\"$module_cmds\"
8274c27c18e8Smrg	    cmds=$module_cmds
8275c27c18e8Smrg	  fi
8276c27c18e8Smrg	else
8277c27c18e8Smrg	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
8278c27c18e8Smrg	    eval test_cmds=\"$archive_expsym_cmds\"
8279c27c18e8Smrg	    cmds=$archive_expsym_cmds
8280c27c18e8Smrg	  else
8281c27c18e8Smrg	    eval test_cmds=\"$archive_cmds\"
8282c27c18e8Smrg	    cmds=$archive_cmds
8283c27c18e8Smrg	  fi
8284c43cc173Smrg	fi
8285c43cc173Smrg
8286c27c18e8Smrg	if test "X$skipped_export" != "X:" &&
8287c27c18e8Smrg	   func_len " $test_cmds" &&
8288c27c18e8Smrg	   len=$func_len_result &&
8289c27c18e8Smrg	   test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
8290c27c18e8Smrg	  :
8291c27c18e8Smrg	else
8292c27c18e8Smrg	  # The command line is too long to link in one step, link piecewise
8293c27c18e8Smrg	  # or, if using GNU ld and skipped_export is not :, use a linker
8294c27c18e8Smrg	  # script.
8295c43cc173Smrg
8296c27c18e8Smrg	  # Save the value of $output and $libobjs because we want to
8297c27c18e8Smrg	  # use them later.  If we have whole_archive_flag_spec, we
8298c27c18e8Smrg	  # want to use save_libobjs as it was before
8299c27c18e8Smrg	  # whole_archive_flag_spec was expanded, because we can't
8300c27c18e8Smrg	  # assume the linker understands whole_archive_flag_spec.
8301c27c18e8Smrg	  # This may have to be revisited, in case too many
8302c27c18e8Smrg	  # convenience libraries get linked in and end up exceeding
8303c27c18e8Smrg	  # the spec.
8304c27c18e8Smrg	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
8305c27c18e8Smrg	    save_libobjs=$libobjs
8306c27c18e8Smrg	  fi
8307c27c18e8Smrg	  save_output=$output
830837eb1ca1Smrg	  func_basename "$output"
830937eb1ca1Smrg	  output_la=$func_basename_result
8310c43cc173Smrg
8311c27c18e8Smrg	  # Clear the reloadable object creation command queue and
8312c27c18e8Smrg	  # initialize k to one.
8313c27c18e8Smrg	  test_cmds=
8314c27c18e8Smrg	  concat_cmds=
8315c27c18e8Smrg	  objlist=
8316c27c18e8Smrg	  last_robj=
8317c27c18e8Smrg	  k=1
8318c43cc173Smrg
8319c27c18e8Smrg	  if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
8320c27c18e8Smrg	    output=${output_objdir}/${output_la}.lnkscript
8321c27c18e8Smrg	    func_verbose "creating GNU ld script: $output"
832237eb1ca1Smrg	    echo 'INPUT (' > $output
8323c27c18e8Smrg	    for obj in $save_libobjs
8324c27c18e8Smrg	    do
8325b789ec8aSmrg	      func_to_tool_file "$obj"
8326b789ec8aSmrg	      $ECHO "$func_to_tool_file_result" >> $output
8327c27c18e8Smrg	    done
832837eb1ca1Smrg	    echo ')' >> $output
8329b789ec8aSmrg	    func_append delfiles " $output"
8330b789ec8aSmrg	    func_to_tool_file "$output"
8331b789ec8aSmrg	    output=$func_to_tool_file_result
8332c27c18e8Smrg	  elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then
8333c27c18e8Smrg	    output=${output_objdir}/${output_la}.lnk
8334c27c18e8Smrg	    func_verbose "creating linker input file list: $output"
8335c27c18e8Smrg	    : > $output
8336c27c18e8Smrg	    set x $save_libobjs
8337c27c18e8Smrg	    shift
8338c27c18e8Smrg	    firstobj=
8339c27c18e8Smrg	    if test "$compiler_needs_object" = yes; then
8340c27c18e8Smrg	      firstobj="$1 "
8341c27c18e8Smrg	      shift
8342c27c18e8Smrg	    fi
8343c27c18e8Smrg	    for obj
8344c27c18e8Smrg	    do
8345b789ec8aSmrg	      func_to_tool_file "$obj"
8346b789ec8aSmrg	      $ECHO "$func_to_tool_file_result" >> $output
8347c27c18e8Smrg	    done
8348b789ec8aSmrg	    func_append delfiles " $output"
8349b789ec8aSmrg	    func_to_tool_file "$output"
8350b789ec8aSmrg	    output=$firstobj\"$file_list_spec$func_to_tool_file_result\"
8351c27c18e8Smrg	  else
8352c27c18e8Smrg	    if test -n "$save_libobjs"; then
8353c27c18e8Smrg	      func_verbose "creating reloadable object files..."
8354c27c18e8Smrg	      output=$output_objdir/$output_la-${k}.$objext
8355c27c18e8Smrg	      eval test_cmds=\"$reload_cmds\"
8356c27c18e8Smrg	      func_len " $test_cmds"
8357c27c18e8Smrg	      len0=$func_len_result
8358c27c18e8Smrg	      len=$len0
8359c27c18e8Smrg
8360c27c18e8Smrg	      # Loop over the list of objects to be linked.
8361c27c18e8Smrg	      for obj in $save_libobjs
8362c27c18e8Smrg	      do
8363c27c18e8Smrg		func_len " $obj"
8364c27c18e8Smrg		func_arith $len + $func_len_result
8365c27c18e8Smrg		len=$func_arith_result
8366c27c18e8Smrg		if test "X$objlist" = X ||
8367c27c18e8Smrg		   test "$len" -lt "$max_cmd_len"; then
8368c27c18e8Smrg		  func_append objlist " $obj"
8369c27c18e8Smrg		else
8370c27c18e8Smrg		  # The command $test_cmds is almost too long, add a
8371c27c18e8Smrg		  # command to the queue.
8372c27c18e8Smrg		  if test "$k" -eq 1 ; then
8373c27c18e8Smrg		    # The first file doesn't have a previous command to add.
837437eb1ca1Smrg		    reload_objs=$objlist
837537eb1ca1Smrg		    eval concat_cmds=\"$reload_cmds\"
8376c27c18e8Smrg		  else
8377c27c18e8Smrg		    # All subsequent reloadable object files will link in
8378c27c18e8Smrg		    # the last one created.
837937eb1ca1Smrg		    reload_objs="$objlist $last_robj"
838037eb1ca1Smrg		    eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
8381c27c18e8Smrg		  fi
8382c27c18e8Smrg		  last_robj=$output_objdir/$output_la-${k}.$objext
8383c27c18e8Smrg		  func_arith $k + 1
8384c27c18e8Smrg		  k=$func_arith_result
8385c27c18e8Smrg		  output=$output_objdir/$output_la-${k}.$objext
838637eb1ca1Smrg		  objlist=" $obj"
8387c27c18e8Smrg		  func_len " $last_robj"
8388c27c18e8Smrg		  func_arith $len0 + $func_len_result
8389c27c18e8Smrg		  len=$func_arith_result
8390c27c18e8Smrg		fi
8391c27c18e8Smrg	      done
8392c27c18e8Smrg	      # Handle the remaining objects by creating one last
8393c27c18e8Smrg	      # reloadable object file.  All subsequent reloadable object
8394c27c18e8Smrg	      # files will link in the last one created.
8395c27c18e8Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
839637eb1ca1Smrg	      reload_objs="$objlist $last_robj"
839737eb1ca1Smrg	      eval concat_cmds=\"\${concat_cmds}$reload_cmds\"
8398c27c18e8Smrg	      if test -n "$last_robj"; then
8399c27c18e8Smrg	        eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\"
8400c27c18e8Smrg	      fi
8401b789ec8aSmrg	      func_append delfiles " $output"
8402c43cc173Smrg
8403c27c18e8Smrg	    else
8404c27c18e8Smrg	      output=
8405c27c18e8Smrg	    fi
8406c27c18e8Smrg
8407c27c18e8Smrg	    if ${skipped_export-false}; then
8408c27c18e8Smrg	      func_verbose "generating symbol list for \`$libname.la'"
8409c27c18e8Smrg	      export_symbols="$output_objdir/$libname.exp"
8410c27c18e8Smrg	      $opt_dry_run || $RM $export_symbols
8411c27c18e8Smrg	      libobjs=$output
8412c27c18e8Smrg	      # Append the command to create the export file.
8413c27c18e8Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
8414c27c18e8Smrg	      eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
8415c27c18e8Smrg	      if test -n "$last_robj"; then
8416c27c18e8Smrg		eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
8417c27c18e8Smrg	      fi
8418c27c18e8Smrg	    fi
8419c43cc173Smrg
8420c27c18e8Smrg	    test -n "$save_libobjs" &&
8421c27c18e8Smrg	      func_verbose "creating a temporary reloadable object file: $output"
8422c43cc173Smrg
8423c27c18e8Smrg	    # Loop through the commands generated above and execute them.
8424c27c18e8Smrg	    save_ifs="$IFS"; IFS='~'
8425c27c18e8Smrg	    for cmd in $concat_cmds; do
8426c27c18e8Smrg	      IFS="$save_ifs"
8427c27c18e8Smrg	      $opt_silent || {
8428c27c18e8Smrg		  func_quote_for_expand "$cmd"
8429c27c18e8Smrg		  eval "func_echo $func_quote_for_expand_result"
8430c27c18e8Smrg	      }
8431c27c18e8Smrg	      $opt_dry_run || eval "$cmd" || {
8432c27c18e8Smrg		lt_exit=$?
8433c27c18e8Smrg
8434c27c18e8Smrg		# Restore the uninstalled library and exit
8435b789ec8aSmrg		if test "$opt_mode" = relink; then
8436c27c18e8Smrg		  ( cd "$output_objdir" && \
8437c27c18e8Smrg		    $RM "${realname}T" && \
8438c27c18e8Smrg		    $MV "${realname}U" "$realname" )
8439c27c18e8Smrg		fi
8440c43cc173Smrg
8441c27c18e8Smrg		exit $lt_exit
8442c27c18e8Smrg	      }
8443c27c18e8Smrg	    done
8444c27c18e8Smrg	    IFS="$save_ifs"
8445c43cc173Smrg
8446c27c18e8Smrg	    if test -n "$export_symbols_regex" && ${skipped_export-false}; then
8447c27c18e8Smrg	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
8448c27c18e8Smrg	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
8449c43cc173Smrg	    fi
8450c43cc173Smrg	  fi
8451c43cc173Smrg
8452c27c18e8Smrg          if ${skipped_export-false}; then
8453c27c18e8Smrg	    if test -n "$export_symbols" && test -n "$include_expsyms"; then
8454c27c18e8Smrg	      tmp_export_symbols="$export_symbols"
8455c27c18e8Smrg	      test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
845637eb1ca1Smrg	      $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
8457c27c18e8Smrg	    fi
8458c43cc173Smrg
8459c27c18e8Smrg	    if test -n "$orig_export_symbols"; then
8460c27c18e8Smrg	      # The given exports_symbols file has to be filtered, so filter it.
8461c27c18e8Smrg	      func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
8462c27c18e8Smrg	      # FIXME: $output_objdir/$libname.filter potentially contains lots of
8463c27c18e8Smrg	      # 's' commands which not all seds can handle. GNU sed should be fine
8464c27c18e8Smrg	      # though. Also, the filter scales superlinearly with the number of
8465c27c18e8Smrg	      # global variables. join(1) would be nice here, but unfortunately
8466c27c18e8Smrg	      # isn't a blessed tool.
8467c27c18e8Smrg	      $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
8468b789ec8aSmrg	      func_append delfiles " $export_symbols $output_objdir/$libname.filter"
8469c27c18e8Smrg	      export_symbols=$output_objdir/$libname.def
8470c27c18e8Smrg	      $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
8471c27c18e8Smrg	    fi
8472c27c18e8Smrg	  fi
8473c43cc173Smrg
8474c27c18e8Smrg	  libobjs=$output
8475c27c18e8Smrg	  # Restore the value of output.
8476c27c18e8Smrg	  output=$save_output
8477c43cc173Smrg
8478c27c18e8Smrg	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
8479c27c18e8Smrg	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
8480c27c18e8Smrg	    test "X$libobjs" = "X " && libobjs=
8481c27c18e8Smrg	  fi
8482c27c18e8Smrg	  # Expand the library linking commands again to reset the
8483c27c18e8Smrg	  # value of $libobjs for piecewise linking.
8484c27c18e8Smrg
8485c27c18e8Smrg	  # Do each of the archive commands.
8486c27c18e8Smrg	  if test "$module" = yes && test -n "$module_cmds" ; then
8487c27c18e8Smrg	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
8488c27c18e8Smrg	      cmds=$module_expsym_cmds
8489c43cc173Smrg	    else
8490c27c18e8Smrg	      cmds=$module_cmds
8491c43cc173Smrg	    fi
8492c43cc173Smrg	  else
8493c27c18e8Smrg	    if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
8494c27c18e8Smrg	      cmds=$archive_expsym_cmds
8495c27c18e8Smrg	    else
8496c27c18e8Smrg	      cmds=$archive_cmds
8497c27c18e8Smrg	    fi
8498c43cc173Smrg	  fi
8499c43cc173Smrg	fi
8500c43cc173Smrg
8501c27c18e8Smrg	if test -n "$delfiles"; then
8502c27c18e8Smrg	  # Append the command to remove temporary files to $cmds.
8503c27c18e8Smrg	  eval cmds=\"\$cmds~\$RM $delfiles\"
8504c27c18e8Smrg	fi
8505c43cc173Smrg
8506c27c18e8Smrg	# Add any objects from preloaded convenience libraries
8507c27c18e8Smrg	if test -n "$dlprefiles"; then
8508c27c18e8Smrg	  gentop="$output_objdir/${outputname}x"
8509b789ec8aSmrg	  func_append generated " $gentop"
8510c43cc173Smrg
8511c27c18e8Smrg	  func_extract_archives $gentop $dlprefiles
8512b789ec8aSmrg	  func_append libobjs " $func_extract_archives_result"
8513c27c18e8Smrg	  test "X$libobjs" = "X " && libobjs=
8514c43cc173Smrg	fi
8515c43cc173Smrg
8516c27c18e8Smrg	save_ifs="$IFS"; IFS='~'
8517c27c18e8Smrg	for cmd in $cmds; do
8518c27c18e8Smrg	  IFS="$save_ifs"
8519c27c18e8Smrg	  eval cmd=\"$cmd\"
8520c27c18e8Smrg	  $opt_silent || {
8521c27c18e8Smrg	    func_quote_for_expand "$cmd"
8522c27c18e8Smrg	    eval "func_echo $func_quote_for_expand_result"
8523c27c18e8Smrg	  }
8524c27c18e8Smrg	  $opt_dry_run || eval "$cmd" || {
8525c27c18e8Smrg	    lt_exit=$?
8526c43cc173Smrg
8527c27c18e8Smrg	    # Restore the uninstalled library and exit
8528b789ec8aSmrg	    if test "$opt_mode" = relink; then
8529c27c18e8Smrg	      ( cd "$output_objdir" && \
8530c27c18e8Smrg	        $RM "${realname}T" && \
8531c27c18e8Smrg		$MV "${realname}U" "$realname" )
8532c43cc173Smrg	    fi
8533c43cc173Smrg
8534c27c18e8Smrg	    exit $lt_exit
8535c27c18e8Smrg	  }
8536c27c18e8Smrg	done
8537c27c18e8Smrg	IFS="$save_ifs"
8538c43cc173Smrg
8539c27c18e8Smrg	# Restore the uninstalled library and exit
8540b789ec8aSmrg	if test "$opt_mode" = relink; then
8541c27c18e8Smrg	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
8542c43cc173Smrg
8543c27c18e8Smrg	  if test -n "$convenience"; then
8544c27c18e8Smrg	    if test -z "$whole_archive_flag_spec"; then
8545c27c18e8Smrg	      func_show_eval '${RM}r "$gentop"'
8546c27c18e8Smrg	    fi
8547c27c18e8Smrg	  fi
8548c43cc173Smrg
8549c27c18e8Smrg	  exit $EXIT_SUCCESS
8550c27c18e8Smrg	fi
8551c43cc173Smrg
8552c27c18e8Smrg	# Create links to the real library.
8553c27c18e8Smrg	for linkname in $linknames; do
8554c27c18e8Smrg	  if test "$realname" != "$linkname"; then
8555c27c18e8Smrg	    func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
8556c43cc173Smrg	  fi
8557c43cc173Smrg	done
8558c43cc173Smrg
8559c27c18e8Smrg	# If -module or -export-dynamic was specified, set the dlname.
8560c27c18e8Smrg	if test "$module" = yes || test "$export_dynamic" = yes; then
8561c27c18e8Smrg	  # On all known operating systems, these are identical.
8562c27c18e8Smrg	  dlname="$soname"
8563c27c18e8Smrg	fi
8564c27c18e8Smrg      fi
8565c43cc173Smrg      ;;
8566c43cc173Smrg
8567c27c18e8Smrg    obj)
8568c27c18e8Smrg      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
8569c27c18e8Smrg	func_warning "\`-dlopen' is ignored for objects"
8570c27c18e8Smrg      fi
8571c43cc173Smrg
8572c27c18e8Smrg      case " $deplibs" in
8573c27c18e8Smrg      *\ -l* | *\ -L*)
8574c27c18e8Smrg	func_warning "\`-l' and \`-L' are ignored for objects" ;;
8575c43cc173Smrg      esac
8576c43cc173Smrg
8577c27c18e8Smrg      test -n "$rpath" && \
8578c27c18e8Smrg	func_warning "\`-rpath' is ignored for objects"
8579c43cc173Smrg
8580c27c18e8Smrg      test -n "$xrpath" && \
8581c27c18e8Smrg	func_warning "\`-R' is ignored for objects"
8582c43cc173Smrg
8583c27c18e8Smrg      test -n "$vinfo" && \
8584c27c18e8Smrg	func_warning "\`-version-info' is ignored for objects"
8585c27c18e8Smrg
8586c27c18e8Smrg      test -n "$release" && \
8587c27c18e8Smrg	func_warning "\`-release' is ignored for objects"
8588c27c18e8Smrg
8589c27c18e8Smrg      case $output in
8590c27c18e8Smrg      *.lo)
8591c27c18e8Smrg	test -n "$objs$old_deplibs" && \
8592c27c18e8Smrg	  func_fatal_error "cannot build library object \`$output' from non-libtool objects"
8593c27c18e8Smrg
8594c27c18e8Smrg	libobj=$output
8595c27c18e8Smrg	func_lo2o "$libobj"
8596c27c18e8Smrg	obj=$func_lo2o_result
8597c43cc173Smrg	;;
8598c43cc173Smrg      *)
8599c27c18e8Smrg	libobj=
8600c27c18e8Smrg	obj="$output"
8601c43cc173Smrg	;;
8602c43cc173Smrg      esac
8603c43cc173Smrg
8604c27c18e8Smrg      # Delete the old objects.
8605c27c18e8Smrg      $opt_dry_run || $RM $obj $libobj
8606c43cc173Smrg
8607c27c18e8Smrg      # Objects from convenience libraries.  This assumes
8608c27c18e8Smrg      # single-version convenience libraries.  Whenever we create
8609c27c18e8Smrg      # different ones for PIC/non-PIC, this we'll have to duplicate
8610c27c18e8Smrg      # the extraction.
8611c27c18e8Smrg      reload_conv_objs=
8612c27c18e8Smrg      gentop=
8613c27c18e8Smrg      # reload_cmds runs $LD directly, so let us get rid of
8614c27c18e8Smrg      # -Wl from whole_archive_flag_spec and hope we can get by with
8615c27c18e8Smrg      # turning comma into space..
8616c27c18e8Smrg      wl=
8617c43cc173Smrg
8618c27c18e8Smrg      if test -n "$convenience"; then
8619c27c18e8Smrg	if test -n "$whole_archive_flag_spec"; then
8620c27c18e8Smrg	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
862137eb1ca1Smrg	  reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
8622c27c18e8Smrg	else
8623c27c18e8Smrg	  gentop="$output_objdir/${obj}x"
8624b789ec8aSmrg	  func_append generated " $gentop"
8625c43cc173Smrg
8626c27c18e8Smrg	  func_extract_archives $gentop $convenience
8627c27c18e8Smrg	  reload_conv_objs="$reload_objs $func_extract_archives_result"
8628c27c18e8Smrg	fi
8629c43cc173Smrg      fi
8630c43cc173Smrg
8631b789ec8aSmrg      # If we're not building shared, we need to use non_pic_objs
8632b789ec8aSmrg      test "$build_libtool_libs" != yes && libobjs="$non_pic_objects"
8633b789ec8aSmrg
8634c27c18e8Smrg      # Create the old-style object.
863537eb1ca1Smrg      reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
8636c43cc173Smrg
8637c27c18e8Smrg      output="$obj"
8638c27c18e8Smrg      func_execute_cmds "$reload_cmds" 'exit $?'
8639c43cc173Smrg
8640c27c18e8Smrg      # Exit if we aren't doing a library object file.
8641c27c18e8Smrg      if test -z "$libobj"; then
8642c27c18e8Smrg	if test -n "$gentop"; then
8643c27c18e8Smrg	  func_show_eval '${RM}r "$gentop"'
8644c27c18e8Smrg	fi
8645c27c18e8Smrg
8646c27c18e8Smrg	exit $EXIT_SUCCESS
8647c43cc173Smrg      fi
8648c27c18e8Smrg
8649c27c18e8Smrg      if test "$build_libtool_libs" != yes; then
8650c27c18e8Smrg	if test -n "$gentop"; then
8651c27c18e8Smrg	  func_show_eval '${RM}r "$gentop"'
8652c27c18e8Smrg	fi
8653c27c18e8Smrg
8654c27c18e8Smrg	# Create an invalid libtool object if no PIC, so that we don't
8655c27c18e8Smrg	# accidentally link it into a program.
8656c27c18e8Smrg	# $show "echo timestamp > $libobj"
8657c27c18e8Smrg	# $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
8658c27c18e8Smrg	exit $EXIT_SUCCESS
8659c27c18e8Smrg      fi
8660c27c18e8Smrg
8661c27c18e8Smrg      if test -n "$pic_flag" || test "$pic_mode" != default; then
8662c27c18e8Smrg	# Only do commands if we really have different PIC objects.
8663c27c18e8Smrg	reload_objs="$libobjs $reload_conv_objs"
8664c27c18e8Smrg	output="$libobj"
8665c27c18e8Smrg	func_execute_cmds "$reload_cmds" 'exit $?'
8666c27c18e8Smrg      fi
8667c27c18e8Smrg
8668c27c18e8Smrg      if test -n "$gentop"; then
8669c27c18e8Smrg	func_show_eval '${RM}r "$gentop"'
8670c27c18e8Smrg      fi
8671c27c18e8Smrg
8672c27c18e8Smrg      exit $EXIT_SUCCESS
8673c43cc173Smrg      ;;
8674c43cc173Smrg
8675c27c18e8Smrg    prog)
8676c27c18e8Smrg      case $host in
8677c27c18e8Smrg	*cygwin*) func_stripname '' '.exe' "$output"
8678c27c18e8Smrg	          output=$func_stripname_result.exe;;
8679c27c18e8Smrg      esac
8680c27c18e8Smrg      test -n "$vinfo" && \
8681c27c18e8Smrg	func_warning "\`-version-info' is ignored for programs"
8682c43cc173Smrg
8683c27c18e8Smrg      test -n "$release" && \
8684c27c18e8Smrg	func_warning "\`-release' is ignored for programs"
8685c43cc173Smrg
8686c27c18e8Smrg      test "$preload" = yes \
8687c27c18e8Smrg        && test "$dlopen_support" = unknown \
8688c27c18e8Smrg	&& test "$dlopen_self" = unknown \
8689c27c18e8Smrg	&& test "$dlopen_self_static" = unknown && \
8690c27c18e8Smrg	  func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support."
8691c27c18e8Smrg
8692c27c18e8Smrg      case $host in
8693c27c18e8Smrg      *-*-rhapsody* | *-*-darwin1.[012])
8694c27c18e8Smrg	# On Rhapsody replace the C library is the System framework
869537eb1ca1Smrg	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
869637eb1ca1Smrg	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
8697c43cc173Smrg	;;
8698c27c18e8Smrg      esac
8699c43cc173Smrg
8700c27c18e8Smrg      case $host in
8701c27c18e8Smrg      *-*-darwin*)
8702c27c18e8Smrg	# Don't allow lazy linking, it breaks C++ global constructors
8703c27c18e8Smrg	# But is supposedly fixed on 10.4 or later (yay!).
8704c27c18e8Smrg	if test "$tagname" = CXX ; then
8705c27c18e8Smrg	  case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
8706c27c18e8Smrg	    10.[0123])
8707b789ec8aSmrg	      func_append compile_command " ${wl}-bind_at_load"
8708b789ec8aSmrg	      func_append finalize_command " ${wl}-bind_at_load"
8709c27c18e8Smrg	    ;;
8710c27c18e8Smrg	  esac
8711c43cc173Smrg	fi
8712c27c18e8Smrg	# Time to change all our "foo.ltframework" stuff back to "-framework foo"
871337eb1ca1Smrg	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
871437eb1ca1Smrg	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8715c27c18e8Smrg	;;
8716c27c18e8Smrg      esac
8717c43cc173Smrg
8718c43cc173Smrg
8719c27c18e8Smrg      # move library search paths that coincide with paths to not yet
8720c27c18e8Smrg      # installed libraries to the beginning of the library search list
8721c27c18e8Smrg      new_libs=
8722c27c18e8Smrg      for path in $notinst_path; do
8723c27c18e8Smrg	case " $new_libs " in
8724c27c18e8Smrg	*" -L$path/$objdir "*) ;;
8725c27c18e8Smrg	*)
8726c27c18e8Smrg	  case " $compile_deplibs " in
8727c27c18e8Smrg	  *" -L$path/$objdir "*)
8728b789ec8aSmrg	    func_append new_libs " -L$path/$objdir" ;;
8729c43cc173Smrg	  esac
8730c27c18e8Smrg	  ;;
8731c27c18e8Smrg	esac
8732c27c18e8Smrg      done
8733c27c18e8Smrg      for deplib in $compile_deplibs; do
8734c27c18e8Smrg	case $deplib in
8735c27c18e8Smrg	-L*)
8736c27c18e8Smrg	  case " $new_libs " in
8737c27c18e8Smrg	  *" $deplib "*) ;;
8738b789ec8aSmrg	  *) func_append new_libs " $deplib" ;;
8739c43cc173Smrg	  esac
8740c27c18e8Smrg	  ;;
8741b789ec8aSmrg	*) func_append new_libs " $deplib" ;;
8742c27c18e8Smrg	esac
8743c27c18e8Smrg      done
8744c27c18e8Smrg      compile_deplibs="$new_libs"
8745c43cc173Smrg
8746c43cc173Smrg
8747b789ec8aSmrg      func_append compile_command " $compile_deplibs"
8748b789ec8aSmrg      func_append finalize_command " $finalize_deplibs"
8749c43cc173Smrg
8750c27c18e8Smrg      if test -n "$rpath$xrpath"; then
8751c27c18e8Smrg	# If the user specified any rpath flags, then add them.
8752c27c18e8Smrg	for libdir in $rpath $xrpath; do
8753c27c18e8Smrg	  # This is the magic to use -rpath.
8754c27c18e8Smrg	  case "$finalize_rpath " in
8755c27c18e8Smrg	  *" $libdir "*) ;;
8756b789ec8aSmrg	  *) func_append finalize_rpath " $libdir" ;;
8757c27c18e8Smrg	  esac
8758c27c18e8Smrg	done
8759c27c18e8Smrg      fi
8760c43cc173Smrg
8761c27c18e8Smrg      # Now hardcode the library paths
8762c27c18e8Smrg      rpath=
8763c27c18e8Smrg      hardcode_libdirs=
8764c27c18e8Smrg      for libdir in $compile_rpath $finalize_rpath; do
8765c27c18e8Smrg	if test -n "$hardcode_libdir_flag_spec"; then
8766c27c18e8Smrg	  if test -n "$hardcode_libdir_separator"; then
8767c27c18e8Smrg	    if test -z "$hardcode_libdirs"; then
8768c27c18e8Smrg	      hardcode_libdirs="$libdir"
8769c27c18e8Smrg	    else
8770c27c18e8Smrg	      # Just accumulate the unique libdirs.
8771c27c18e8Smrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
8772c27c18e8Smrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
8773c27c18e8Smrg		;;
8774c27c18e8Smrg	      *)
8775b789ec8aSmrg		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
8776c27c18e8Smrg		;;
8777c27c18e8Smrg	      esac
8778c27c18e8Smrg	    fi
8779c43cc173Smrg	  else
8780c27c18e8Smrg	    eval flag=\"$hardcode_libdir_flag_spec\"
8781b789ec8aSmrg	    func_append rpath " $flag"
8782c43cc173Smrg	  fi
8783c27c18e8Smrg	elif test -n "$runpath_var"; then
8784c27c18e8Smrg	  case "$perm_rpath " in
8785c27c18e8Smrg	  *" $libdir "*) ;;
8786b789ec8aSmrg	  *) func_append perm_rpath " $libdir" ;;
8787c27c18e8Smrg	  esac
8788c27c18e8Smrg	fi
8789c27c18e8Smrg	case $host in
8790c27c18e8Smrg	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
8791c27c18e8Smrg	  testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'`
8792c27c18e8Smrg	  case :$dllsearchpath: in
8793c27c18e8Smrg	  *":$libdir:"*) ;;
8794c27c18e8Smrg	  ::) dllsearchpath=$libdir;;
8795b789ec8aSmrg	  *) func_append dllsearchpath ":$libdir";;
8796c27c18e8Smrg	  esac
8797c27c18e8Smrg	  case :$dllsearchpath: in
8798c27c18e8Smrg	  *":$testbindir:"*) ;;
8799c27c18e8Smrg	  ::) dllsearchpath=$testbindir;;
8800b789ec8aSmrg	  *) func_append dllsearchpath ":$testbindir";;
8801c27c18e8Smrg	  esac
8802c27c18e8Smrg	  ;;
8803c27c18e8Smrg	esac
8804c27c18e8Smrg      done
8805c27c18e8Smrg      # Substitute the hardcoded libdirs into the rpath.
8806c27c18e8Smrg      if test -n "$hardcode_libdir_separator" &&
8807c27c18e8Smrg	 test -n "$hardcode_libdirs"; then
8808c27c18e8Smrg	libdir="$hardcode_libdirs"
8809c27c18e8Smrg	eval rpath=\" $hardcode_libdir_flag_spec\"
8810c27c18e8Smrg      fi
8811c27c18e8Smrg      compile_rpath="$rpath"
8812c43cc173Smrg
8813c27c18e8Smrg      rpath=
8814c27c18e8Smrg      hardcode_libdirs=
8815c27c18e8Smrg      for libdir in $finalize_rpath; do
8816c27c18e8Smrg	if test -n "$hardcode_libdir_flag_spec"; then
8817c27c18e8Smrg	  if test -n "$hardcode_libdir_separator"; then
8818c27c18e8Smrg	    if test -z "$hardcode_libdirs"; then
8819c27c18e8Smrg	      hardcode_libdirs="$libdir"
8820c27c18e8Smrg	    else
8821c27c18e8Smrg	      # Just accumulate the unique libdirs.
8822c27c18e8Smrg	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
8823c27c18e8Smrg	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
8824c27c18e8Smrg		;;
8825c27c18e8Smrg	      *)
8826b789ec8aSmrg		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
8827c27c18e8Smrg		;;
8828c27c18e8Smrg	      esac
8829c27c18e8Smrg	    fi
8830c43cc173Smrg	  else
8831c27c18e8Smrg	    eval flag=\"$hardcode_libdir_flag_spec\"
8832b789ec8aSmrg	    func_append rpath " $flag"
8833c43cc173Smrg	  fi
8834c27c18e8Smrg	elif test -n "$runpath_var"; then
8835c27c18e8Smrg	  case "$finalize_perm_rpath " in
8836c27c18e8Smrg	  *" $libdir "*) ;;
8837b789ec8aSmrg	  *) func_append finalize_perm_rpath " $libdir" ;;
8838c27c18e8Smrg	  esac
8839c43cc173Smrg	fi
8840c27c18e8Smrg      done
8841c27c18e8Smrg      # Substitute the hardcoded libdirs into the rpath.
8842c27c18e8Smrg      if test -n "$hardcode_libdir_separator" &&
8843c27c18e8Smrg	 test -n "$hardcode_libdirs"; then
8844c27c18e8Smrg	libdir="$hardcode_libdirs"
8845c27c18e8Smrg	eval rpath=\" $hardcode_libdir_flag_spec\"
8846c27c18e8Smrg      fi
8847c27c18e8Smrg      finalize_rpath="$rpath"
8848c43cc173Smrg
8849c27c18e8Smrg      if test -n "$libobjs" && test "$build_old_libs" = yes; then
8850c27c18e8Smrg	# Transform all the library objects into standard objects.
885137eb1ca1Smrg	compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
885237eb1ca1Smrg	finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
8853c27c18e8Smrg      fi
8854c43cc173Smrg
8855c27c18e8Smrg      func_generate_dlsyms "$outputname" "@PROGRAM@" "no"
8856c43cc173Smrg
8857c27c18e8Smrg      # template prelinking step
8858c27c18e8Smrg      if test -n "$prelink_cmds"; then
8859c27c18e8Smrg	func_execute_cmds "$prelink_cmds" 'exit $?'
8860c27c18e8Smrg      fi
8861c43cc173Smrg
8862c27c18e8Smrg      wrappers_required=yes
8863c27c18e8Smrg      case $host in
886437eb1ca1Smrg      *cegcc* | *mingw32ce*)
886537eb1ca1Smrg        # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
886637eb1ca1Smrg        wrappers_required=no
886737eb1ca1Smrg        ;;
8868c27c18e8Smrg      *cygwin* | *mingw* )
8869c27c18e8Smrg        if test "$build_libtool_libs" != yes; then
8870c27c18e8Smrg          wrappers_required=no
8871c27c18e8Smrg        fi
8872c27c18e8Smrg        ;;
8873c27c18e8Smrg      *)
8874c27c18e8Smrg        if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
8875c27c18e8Smrg          wrappers_required=no
8876c27c18e8Smrg        fi
8877c27c18e8Smrg        ;;
8878c27c18e8Smrg      esac
8879c27c18e8Smrg      if test "$wrappers_required" = no; then
8880c27c18e8Smrg	# Replace the output file specification.
888137eb1ca1Smrg	compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
8882c27c18e8Smrg	link_command="$compile_command$compile_rpath"
8883c43cc173Smrg
8884c27c18e8Smrg	# We have no uninstalled library dependencies, so finalize right now.
8885c27c18e8Smrg	exit_status=0
8886c27c18e8Smrg	func_show_eval "$link_command" 'exit_status=$?'
8887c43cc173Smrg
8888b789ec8aSmrg	if test -n "$postlink_cmds"; then
8889b789ec8aSmrg	  func_to_tool_file "$output"
8890b789ec8aSmrg	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
8891b789ec8aSmrg	  func_execute_cmds "$postlink_cmds" 'exit $?'
8892b789ec8aSmrg	fi
8893b789ec8aSmrg
8894c27c18e8Smrg	# Delete the generated files.
8895c27c18e8Smrg	if test -f "$output_objdir/${outputname}S.${objext}"; then
8896c27c18e8Smrg	  func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"'
8897c43cc173Smrg	fi
8898c43cc173Smrg
8899c27c18e8Smrg	exit $exit_status
8900c27c18e8Smrg      fi
8901c43cc173Smrg
8902c27c18e8Smrg      if test -n "$compile_shlibpath$finalize_shlibpath"; then
8903c27c18e8Smrg	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
8904c27c18e8Smrg      fi
8905c27c18e8Smrg      if test -n "$finalize_shlibpath"; then
8906c27c18e8Smrg	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
8907c27c18e8Smrg      fi
8908c43cc173Smrg
8909c27c18e8Smrg      compile_var=
8910c27c18e8Smrg      finalize_var=
8911c27c18e8Smrg      if test -n "$runpath_var"; then
8912c27c18e8Smrg	if test -n "$perm_rpath"; then
8913c27c18e8Smrg	  # We should set the runpath_var.
8914c27c18e8Smrg	  rpath=
8915c27c18e8Smrg	  for dir in $perm_rpath; do
8916b789ec8aSmrg	    func_append rpath "$dir:"
8917c27c18e8Smrg	  done
8918c27c18e8Smrg	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
8919c43cc173Smrg	fi
8920c27c18e8Smrg	if test -n "$finalize_perm_rpath"; then
8921c27c18e8Smrg	  # We should set the runpath_var.
8922c27c18e8Smrg	  rpath=
8923c27c18e8Smrg	  for dir in $finalize_perm_rpath; do
8924b789ec8aSmrg	    func_append rpath "$dir:"
8925c27c18e8Smrg	  done
8926c27c18e8Smrg	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
8927c43cc173Smrg	fi
8928c27c18e8Smrg      fi
8929c43cc173Smrg
8930c27c18e8Smrg      if test "$no_install" = yes; then
8931c27c18e8Smrg	# We don't need to create a wrapper script.
8932c27c18e8Smrg	link_command="$compile_var$compile_command$compile_rpath"
8933c27c18e8Smrg	# Replace the output file specification.
893437eb1ca1Smrg	link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
8935c27c18e8Smrg	# Delete the old output file.
8936c27c18e8Smrg	$opt_dry_run || $RM $output
8937c27c18e8Smrg	# Link the executable and exit
8938c27c18e8Smrg	func_show_eval "$link_command" 'exit $?'
8939b789ec8aSmrg
8940b789ec8aSmrg	if test -n "$postlink_cmds"; then
8941b789ec8aSmrg	  func_to_tool_file "$output"
8942b789ec8aSmrg	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
8943b789ec8aSmrg	  func_execute_cmds "$postlink_cmds" 'exit $?'
8944b789ec8aSmrg	fi
8945b789ec8aSmrg
8946c43cc173Smrg	exit $EXIT_SUCCESS
8947c27c18e8Smrg      fi
8948c43cc173Smrg
8949c27c18e8Smrg      if test "$hardcode_action" = relink; then
8950c27c18e8Smrg	# Fast installation is not supported
8951c27c18e8Smrg	link_command="$compile_var$compile_command$compile_rpath"
8952c27c18e8Smrg	relink_command="$finalize_var$finalize_command$finalize_rpath"
8953c27c18e8Smrg
8954c27c18e8Smrg	func_warning "this platform does not like uninstalled shared libraries"
8955c27c18e8Smrg	func_warning "\`$output' will be relinked during installation"
8956c27c18e8Smrg      else
8957c27c18e8Smrg	if test "$fast_install" != no; then
8958c27c18e8Smrg	  link_command="$finalize_var$compile_command$finalize_rpath"
8959c27c18e8Smrg	  if test "$fast_install" = yes; then
896037eb1ca1Smrg	    relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
8961c27c18e8Smrg	  else
8962c27c18e8Smrg	    # fast_install is set to needless
8963c27c18e8Smrg	    relink_command=
8964c27c18e8Smrg	  fi
8965c43cc173Smrg	else
8966c27c18e8Smrg	  link_command="$compile_var$compile_command$compile_rpath"
8967c27c18e8Smrg	  relink_command="$finalize_var$finalize_command$finalize_rpath"
8968c43cc173Smrg	fi
8969c27c18e8Smrg      fi
8970c43cc173Smrg
8971c27c18e8Smrg      # Replace the output file specification.
897237eb1ca1Smrg      link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
8973c43cc173Smrg
8974c27c18e8Smrg      # Delete the old output files.
8975c27c18e8Smrg      $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
8976c43cc173Smrg
8977c27c18e8Smrg      func_show_eval "$link_command" 'exit $?'
8978c43cc173Smrg
8979b789ec8aSmrg      if test -n "$postlink_cmds"; then
8980b789ec8aSmrg	func_to_tool_file "$output_objdir/$outputname"
8981b789ec8aSmrg	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'`
8982b789ec8aSmrg	func_execute_cmds "$postlink_cmds" 'exit $?'
8983b789ec8aSmrg      fi
8984b789ec8aSmrg
8985c27c18e8Smrg      # Now create the wrapper script.
8986c27c18e8Smrg      func_verbose "creating $output"
8987c43cc173Smrg
8988c27c18e8Smrg      # Quote the relink command for shipping.
8989c27c18e8Smrg      if test -n "$relink_command"; then
8990c27c18e8Smrg	# Preserve any variables that may affect compiler behavior
8991c27c18e8Smrg	for var in $variables_saved_for_relink; do
8992c27c18e8Smrg	  if eval test -z \"\${$var+set}\"; then
8993c27c18e8Smrg	    relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
8994c27c18e8Smrg	  elif eval var_value=\$$var; test -z "$var_value"; then
8995c27c18e8Smrg	    relink_command="$var=; export $var; $relink_command"
8996c43cc173Smrg	  else
8997c27c18e8Smrg	    func_quote_for_eval "$var_value"
8998c27c18e8Smrg	    relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
8999c43cc173Smrg	  fi
9000c27c18e8Smrg	done
9001c27c18e8Smrg	relink_command="(cd `pwd`; $relink_command)"
900237eb1ca1Smrg	relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
9003c27c18e8Smrg      fi
9004c27c18e8Smrg
9005c27c18e8Smrg      # Only actually do things if not in dry run mode.
9006c27c18e8Smrg      $opt_dry_run || {
9007c27c18e8Smrg	# win32 will think the script is a binary if it has
9008c27c18e8Smrg	# a .exe suffix, so we strip it off here.
9009c27c18e8Smrg	case $output in
9010c27c18e8Smrg	  *.exe) func_stripname '' '.exe' "$output"
9011c27c18e8Smrg	         output=$func_stripname_result ;;
9012c27c18e8Smrg	esac
9013c27c18e8Smrg	# test for cygwin because mv fails w/o .exe extensions
9014c27c18e8Smrg	case $host in
9015c27c18e8Smrg	  *cygwin*)
9016c27c18e8Smrg	    exeext=.exe
9017c27c18e8Smrg	    func_stripname '' '.exe' "$outputname"
9018c27c18e8Smrg	    outputname=$func_stripname_result ;;
9019c27c18e8Smrg	  *) exeext= ;;
9020c43cc173Smrg	esac
9021c27c18e8Smrg	case $host in
9022c27c18e8Smrg	  *cygwin* | *mingw* )
9023c27c18e8Smrg	    func_dirname_and_basename "$output" "" "."
9024c27c18e8Smrg	    output_name=$func_basename_result
9025c27c18e8Smrg	    output_path=$func_dirname_result
9026c27c18e8Smrg	    cwrappersource="$output_path/$objdir/lt-$output_name.c"
9027c27c18e8Smrg	    cwrapper="$output_path/$output_name.exe"
9028c27c18e8Smrg	    $RM $cwrappersource $cwrapper
9029c27c18e8Smrg	    trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
9030c27c18e8Smrg
9031c27c18e8Smrg	    func_emit_cwrapperexe_src > $cwrappersource
9032c27c18e8Smrg
9033c27c18e8Smrg	    # The wrapper executable is built using the $host compiler,
9034c27c18e8Smrg	    # because it contains $host paths and files. If cross-
9035c27c18e8Smrg	    # compiling, it, like the target executable, must be
9036c27c18e8Smrg	    # executed on the $host or under an emulation environment.
9037c27c18e8Smrg	    $opt_dry_run || {
9038c27c18e8Smrg	      $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
9039c27c18e8Smrg	      $STRIP $cwrapper
9040c27c18e8Smrg	    }
9041c43cc173Smrg
9042c27c18e8Smrg	    # Now, create the wrapper script for func_source use:
9043c27c18e8Smrg	    func_ltwrapper_scriptname $cwrapper
9044c27c18e8Smrg	    $RM $func_ltwrapper_scriptname_result
9045c27c18e8Smrg	    trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
9046c27c18e8Smrg	    $opt_dry_run || {
9047c27c18e8Smrg	      # note: this script will not be executed, so do not chmod.
9048c27c18e8Smrg	      if test "x$build" = "x$host" ; then
9049c27c18e8Smrg		$cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
9050c27c18e8Smrg	      else
9051c27c18e8Smrg		func_emit_wrapper no > $func_ltwrapper_scriptname_result
9052c27c18e8Smrg	      fi
9053c27c18e8Smrg	    }
9054c27c18e8Smrg	  ;;
9055c27c18e8Smrg	  * )
9056c27c18e8Smrg	    $RM $output
9057c27c18e8Smrg	    trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
9058c43cc173Smrg
9059c27c18e8Smrg	    func_emit_wrapper no > $output
9060c27c18e8Smrg	    chmod +x $output
9061c27c18e8Smrg	  ;;
9062c27c18e8Smrg	esac
9063c27c18e8Smrg      }
9064c27c18e8Smrg      exit $EXIT_SUCCESS
9065c27c18e8Smrg      ;;
9066c27c18e8Smrg    esac
9067c43cc173Smrg
9068c27c18e8Smrg    # See if we need to build an old-fashioned archive.
9069c27c18e8Smrg    for oldlib in $oldlibs; do
9070c43cc173Smrg
9071c27c18e8Smrg      if test "$build_libtool_libs" = convenience; then
9072c27c18e8Smrg	oldobjs="$libobjs_save $symfileobj"
9073c27c18e8Smrg	addlibs="$convenience"
9074c27c18e8Smrg	build_libtool_libs=no
9075c27c18e8Smrg      else
9076c27c18e8Smrg	if test "$build_libtool_libs" = module; then
9077c27c18e8Smrg	  oldobjs="$libobjs_save"
9078c27c18e8Smrg	  build_libtool_libs=no
9079c27c18e8Smrg	else
9080c27c18e8Smrg	  oldobjs="$old_deplibs $non_pic_objects"
9081c27c18e8Smrg	  if test "$preload" = yes && test -f "$symfileobj"; then
9082b789ec8aSmrg	    func_append oldobjs " $symfileobj"
9083c27c18e8Smrg	  fi
9084c27c18e8Smrg	fi
9085c27c18e8Smrg	addlibs="$old_convenience"
9086c43cc173Smrg      fi
9087c43cc173Smrg
9088c27c18e8Smrg      if test -n "$addlibs"; then
9089c27c18e8Smrg	gentop="$output_objdir/${outputname}x"
9090b789ec8aSmrg	func_append generated " $gentop"
9091c43cc173Smrg
9092c27c18e8Smrg	func_extract_archives $gentop $addlibs
9093b789ec8aSmrg	func_append oldobjs " $func_extract_archives_result"
9094c27c18e8Smrg      fi
9095c43cc173Smrg
9096c27c18e8Smrg      # Do each command in the archive commands.
9097c27c18e8Smrg      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
9098c27c18e8Smrg	cmds=$old_archive_from_new_cmds
9099c27c18e8Smrg      else
9100c43cc173Smrg
9101c27c18e8Smrg	# Add any objects from preloaded convenience libraries
9102c27c18e8Smrg	if test -n "$dlprefiles"; then
9103c27c18e8Smrg	  gentop="$output_objdir/${outputname}x"
9104b789ec8aSmrg	  func_append generated " $gentop"
9105c43cc173Smrg
9106c27c18e8Smrg	  func_extract_archives $gentop $dlprefiles
9107b789ec8aSmrg	  func_append oldobjs " $func_extract_archives_result"
9108c27c18e8Smrg	fi
9109c43cc173Smrg
9110c27c18e8Smrg	# POSIX demands no paths to be encoded in archives.  We have
9111c27c18e8Smrg	# to avoid creating archives with duplicate basenames if we
9112c27c18e8Smrg	# might have to extract them afterwards, e.g., when creating a
9113c27c18e8Smrg	# static archive out of a convenience library, or when linking
9114c27c18e8Smrg	# the entirety of a libtool archive into another (currently
9115c27c18e8Smrg	# not supported by libtool).
9116c27c18e8Smrg	if (for obj in $oldobjs
9117c27c18e8Smrg	    do
9118c27c18e8Smrg	      func_basename "$obj"
9119c27c18e8Smrg	      $ECHO "$func_basename_result"
9120c27c18e8Smrg	    done | sort | sort -uc >/dev/null 2>&1); then
9121c27c18e8Smrg	  :
9122c27c18e8Smrg	else
912337eb1ca1Smrg	  echo "copying selected object files to avoid basename conflicts..."
9124c27c18e8Smrg	  gentop="$output_objdir/${outputname}x"
9125b789ec8aSmrg	  func_append generated " $gentop"
9126c27c18e8Smrg	  func_mkdir_p "$gentop"
9127c27c18e8Smrg	  save_oldobjs=$oldobjs
9128c27c18e8Smrg	  oldobjs=
9129c27c18e8Smrg	  counter=1
9130c27c18e8Smrg	  for obj in $save_oldobjs
9131c27c18e8Smrg	  do
9132c27c18e8Smrg	    func_basename "$obj"
9133c27c18e8Smrg	    objbase="$func_basename_result"
9134c27c18e8Smrg	    case " $oldobjs " in
9135c27c18e8Smrg	    " ") oldobjs=$obj ;;
9136c27c18e8Smrg	    *[\ /]"$objbase "*)
9137c27c18e8Smrg	      while :; do
9138c27c18e8Smrg		# Make sure we don't pick an alternate name that also
9139c27c18e8Smrg		# overlaps.
9140c27c18e8Smrg		newobj=lt$counter-$objbase
9141c27c18e8Smrg		func_arith $counter + 1
9142c27c18e8Smrg		counter=$func_arith_result
9143c27c18e8Smrg		case " $oldobjs " in
9144c27c18e8Smrg		*[\ /]"$newobj "*) ;;
9145c27c18e8Smrg		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
9146c27c18e8Smrg		esac
9147c27c18e8Smrg	      done
9148c27c18e8Smrg	      func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
9149b789ec8aSmrg	      func_append oldobjs " $gentop/$newobj"
9150c27c18e8Smrg	      ;;
9151b789ec8aSmrg	    *) func_append oldobjs " $obj" ;;
9152c27c18e8Smrg	    esac
9153c43cc173Smrg	  done
9154c43cc173Smrg	fi
9155c27c18e8Smrg	eval cmds=\"$old_archive_cmds\"
9156c43cc173Smrg
9157c27c18e8Smrg	func_len " $cmds"
9158c27c18e8Smrg	len=$func_len_result
9159c27c18e8Smrg	if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
9160c27c18e8Smrg	  cmds=$old_archive_cmds
9161b789ec8aSmrg	elif test -n "$archiver_list_spec"; then
9162b789ec8aSmrg	  func_verbose "using command file archive linking..."
9163b789ec8aSmrg	  for obj in $oldobjs
9164b789ec8aSmrg	  do
9165b789ec8aSmrg	    func_to_tool_file "$obj"
9166b789ec8aSmrg	    $ECHO "$func_to_tool_file_result"
9167b789ec8aSmrg	  done > $output_objdir/$libname.libcmd
9168b789ec8aSmrg	  func_to_tool_file "$output_objdir/$libname.libcmd"
9169b789ec8aSmrg	  oldobjs=" $archiver_list_spec$func_to_tool_file_result"
9170b789ec8aSmrg	  cmds=$old_archive_cmds
9171c27c18e8Smrg	else
9172c27c18e8Smrg	  # the command line is too long to link in one step, link in parts
9173c27c18e8Smrg	  func_verbose "using piecewise archive linking..."
9174c27c18e8Smrg	  save_RANLIB=$RANLIB
9175c27c18e8Smrg	  RANLIB=:
9176c27c18e8Smrg	  objlist=
9177c27c18e8Smrg	  concat_cmds=
9178c27c18e8Smrg	  save_oldobjs=$oldobjs
9179c27c18e8Smrg	  oldobjs=
9180c27c18e8Smrg	  # Is there a better way of finding the last object in the list?
9181c27c18e8Smrg	  for obj in $save_oldobjs
9182c27c18e8Smrg	  do
9183c27c18e8Smrg	    last_oldobj=$obj
9184c27c18e8Smrg	  done
9185c27c18e8Smrg	  eval test_cmds=\"$old_archive_cmds\"
9186c27c18e8Smrg	  func_len " $test_cmds"
9187c27c18e8Smrg	  len0=$func_len_result
9188c27c18e8Smrg	  len=$len0
9189c27c18e8Smrg	  for obj in $save_oldobjs
9190c27c18e8Smrg	  do
9191c27c18e8Smrg	    func_len " $obj"
9192c27c18e8Smrg	    func_arith $len + $func_len_result
9193c27c18e8Smrg	    len=$func_arith_result
9194c27c18e8Smrg	    func_append objlist " $obj"
9195c27c18e8Smrg	    if test "$len" -lt "$max_cmd_len"; then
9196c27c18e8Smrg	      :
9197c27c18e8Smrg	    else
9198c27c18e8Smrg	      # the above command should be used before it gets too long
9199c27c18e8Smrg	      oldobjs=$objlist
9200c27c18e8Smrg	      if test "$obj" = "$last_oldobj" ; then
9201c27c18e8Smrg		RANLIB=$save_RANLIB
9202c27c18e8Smrg	      fi
9203c27c18e8Smrg	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
9204c27c18e8Smrg	      eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
9205c27c18e8Smrg	      objlist=
9206c27c18e8Smrg	      len=$len0
9207c27c18e8Smrg	    fi
9208c27c18e8Smrg	  done
9209c27c18e8Smrg	  RANLIB=$save_RANLIB
9210c27c18e8Smrg	  oldobjs=$objlist
9211c27c18e8Smrg	  if test "X$oldobjs" = "X" ; then
9212c27c18e8Smrg	    eval cmds=\"\$concat_cmds\"
9213c27c18e8Smrg	  else
9214c27c18e8Smrg	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
9215c27c18e8Smrg	  fi
9216c27c18e8Smrg	fi
9217c27c18e8Smrg      fi
9218c27c18e8Smrg      func_execute_cmds "$cmds" 'exit $?'
9219c43cc173Smrg    done
9220c43cc173Smrg
9221c27c18e8Smrg    test -n "$generated" && \
9222c27c18e8Smrg      func_show_eval "${RM}r$generated"
9223c43cc173Smrg
9224c27c18e8Smrg    # Now create the libtool archive.
9225c27c18e8Smrg    case $output in
9226c27c18e8Smrg    *.la)
9227c27c18e8Smrg      old_library=
9228c27c18e8Smrg      test "$build_old_libs" = yes && old_library="$libname.$libext"
9229c27c18e8Smrg      func_verbose "creating $output"
9230c43cc173Smrg
9231c27c18e8Smrg      # Preserve any variables that may affect compiler behavior
9232c27c18e8Smrg      for var in $variables_saved_for_relink; do
9233c27c18e8Smrg	if eval test -z \"\${$var+set}\"; then
9234c27c18e8Smrg	  relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
9235c27c18e8Smrg	elif eval var_value=\$$var; test -z "$var_value"; then
9236c27c18e8Smrg	  relink_command="$var=; export $var; $relink_command"
9237c43cc173Smrg	else
9238c27c18e8Smrg	  func_quote_for_eval "$var_value"
9239c27c18e8Smrg	  relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
9240c43cc173Smrg	fi
9241c27c18e8Smrg      done
9242c27c18e8Smrg      # Quote the link command for shipping.
9243c27c18e8Smrg      relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
924437eb1ca1Smrg      relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
9245c27c18e8Smrg      if test "$hardcode_automatic" = yes ; then
9246c27c18e8Smrg	relink_command=
9247c27c18e8Smrg      fi
9248c43cc173Smrg
9249c27c18e8Smrg      # Only create the output if not a dry run.
9250c27c18e8Smrg      $opt_dry_run || {
9251c27c18e8Smrg	for installed in no yes; do
9252c27c18e8Smrg	  if test "$installed" = yes; then
9253c27c18e8Smrg	    if test -z "$install_libdir"; then
9254c27c18e8Smrg	      break
9255c27c18e8Smrg	    fi
9256c27c18e8Smrg	    output="$output_objdir/$outputname"i
9257c27c18e8Smrg	    # Replace all uninstalled libtool libraries with the installed ones
9258c27c18e8Smrg	    newdependency_libs=
9259c27c18e8Smrg	    for deplib in $dependency_libs; do
9260c27c18e8Smrg	      case $deplib in
9261c27c18e8Smrg	      *.la)
9262c27c18e8Smrg		func_basename "$deplib"
9263c27c18e8Smrg		name="$func_basename_result"
9264c27c18e8Smrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
9265c27c18e8Smrg		test -z "$libdir" && \
9266c27c18e8Smrg		  func_fatal_error "\`$deplib' is not a valid libtool archive"
9267b789ec8aSmrg		func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"
9268b789ec8aSmrg		;;
9269b789ec8aSmrg	      -L*)
9270b789ec8aSmrg		func_stripname -L '' "$deplib"
9271b789ec8aSmrg		func_replace_sysroot "$func_stripname_result"
9272b789ec8aSmrg		func_append newdependency_libs " -L$func_replace_sysroot_result"
9273b789ec8aSmrg		;;
9274b789ec8aSmrg	      -R*)
9275b789ec8aSmrg		func_stripname -R '' "$deplib"
9276b789ec8aSmrg		func_replace_sysroot "$func_stripname_result"
9277b789ec8aSmrg		func_append newdependency_libs " -R$func_replace_sysroot_result"
9278c27c18e8Smrg		;;
9279b789ec8aSmrg	      *) func_append newdependency_libs " $deplib" ;;
9280c27c18e8Smrg	      esac
9281c27c18e8Smrg	    done
9282c27c18e8Smrg	    dependency_libs="$newdependency_libs"
9283c27c18e8Smrg	    newdlfiles=
9284c27c18e8Smrg
9285c27c18e8Smrg	    for lib in $dlfiles; do
9286c27c18e8Smrg	      case $lib in
9287c27c18e8Smrg	      *.la)
9288c27c18e8Smrg	        func_basename "$lib"
9289c27c18e8Smrg		name="$func_basename_result"
9290c27c18e8Smrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
9291c27c18e8Smrg		test -z "$libdir" && \
9292c27c18e8Smrg		  func_fatal_error "\`$lib' is not a valid libtool archive"
9293b789ec8aSmrg		func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name"
9294c27c18e8Smrg		;;
9295b789ec8aSmrg	      *) func_append newdlfiles " $lib" ;;
9296c27c18e8Smrg	      esac
9297c27c18e8Smrg	    done
9298c27c18e8Smrg	    dlfiles="$newdlfiles"
9299c27c18e8Smrg	    newdlprefiles=
9300c27c18e8Smrg	    for lib in $dlprefiles; do
9301c27c18e8Smrg	      case $lib in
9302c27c18e8Smrg	      *.la)
9303c27c18e8Smrg		# Only pass preopened files to the pseudo-archive (for
9304c27c18e8Smrg		# eventual linking with the app. that links it) if we
9305c27c18e8Smrg		# didn't already link the preopened objects directly into
9306c27c18e8Smrg		# the library:
9307c27c18e8Smrg		func_basename "$lib"
9308c27c18e8Smrg		name="$func_basename_result"
9309c27c18e8Smrg		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
9310c27c18e8Smrg		test -z "$libdir" && \
9311c27c18e8Smrg		  func_fatal_error "\`$lib' is not a valid libtool archive"
9312b789ec8aSmrg		func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name"
9313c27c18e8Smrg		;;
9314c27c18e8Smrg	      esac
9315c27c18e8Smrg	    done
9316c27c18e8Smrg	    dlprefiles="$newdlprefiles"
9317c27c18e8Smrg	  else
9318c27c18e8Smrg	    newdlfiles=
9319c27c18e8Smrg	    for lib in $dlfiles; do
9320c27c18e8Smrg	      case $lib in
9321c27c18e8Smrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
9322c27c18e8Smrg		*) abs=`pwd`"/$lib" ;;
9323c27c18e8Smrg	      esac
9324b789ec8aSmrg	      func_append newdlfiles " $abs"
9325c27c18e8Smrg	    done
9326c27c18e8Smrg	    dlfiles="$newdlfiles"
9327c27c18e8Smrg	    newdlprefiles=
9328c27c18e8Smrg	    for lib in $dlprefiles; do
9329c27c18e8Smrg	      case $lib in
9330c27c18e8Smrg		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
9331c27c18e8Smrg		*) abs=`pwd`"/$lib" ;;
9332c27c18e8Smrg	      esac
9333b789ec8aSmrg	      func_append newdlprefiles " $abs"
9334c27c18e8Smrg	    done
9335c27c18e8Smrg	    dlprefiles="$newdlprefiles"
9336c27c18e8Smrg	  fi
9337c27c18e8Smrg	  $RM $output
9338c27c18e8Smrg	  # place dlname in correct position for cygwin
933937eb1ca1Smrg	  # In fact, it would be nice if we could use this code for all target
934037eb1ca1Smrg	  # systems that can't hard-code library paths into their executables
934137eb1ca1Smrg	  # and that have no shared library path variable independent of PATH,
934237eb1ca1Smrg	  # but it turns out we can't easily determine that from inspecting
934337eb1ca1Smrg	  # libtool variables, so we have to hard-code the OSs to which it
934437eb1ca1Smrg	  # applies here; at the moment, that means platforms that use the PE
934537eb1ca1Smrg	  # object format with DLL files.  See the long comment at the top of
934637eb1ca1Smrg	  # tests/bindir.at for full details.
9347c27c18e8Smrg	  tdlname=$dlname
9348c27c18e8Smrg	  case $host,$output,$installed,$module,$dlname in
934937eb1ca1Smrg	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
935037eb1ca1Smrg	      # If a -bindir argument was supplied, place the dll there.
935137eb1ca1Smrg	      if test "x$bindir" != x ;
935237eb1ca1Smrg	      then
935337eb1ca1Smrg		func_relative_path "$install_libdir" "$bindir"
935437eb1ca1Smrg		tdlname=$func_relative_path_result$dlname
935537eb1ca1Smrg	      else
935637eb1ca1Smrg		# Otherwise fall back on heuristic.
935737eb1ca1Smrg		tdlname=../bin/$dlname
935837eb1ca1Smrg	      fi
935937eb1ca1Smrg	      ;;
9360c27c18e8Smrg	  esac
9361c27c18e8Smrg	  $ECHO > $output "\
9362c27c18e8Smrg# $outputname - a libtool library file
9363c27c18e8Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
9364c27c18e8Smrg#
9365c27c18e8Smrg# Please DO NOT delete this file!
9366c27c18e8Smrg# It is necessary for linking the library.
9367c43cc173Smrg
9368c27c18e8Smrg# The name that we can dlopen(3).
9369c27c18e8Smrgdlname='$tdlname'
9370c43cc173Smrg
9371c27c18e8Smrg# Names of this library.
9372c27c18e8Smrglibrary_names='$library_names'
9373c43cc173Smrg
9374c27c18e8Smrg# The name of the static archive.
9375c27c18e8Smrgold_library='$old_library'
9376c43cc173Smrg
9377c27c18e8Smrg# Linker flags that can not go in dependency_libs.
9378c27c18e8Smrginherited_linker_flags='$new_inherited_linker_flags'
9379c43cc173Smrg
9380c27c18e8Smrg# Libraries that this one depends upon.
9381c27c18e8Smrgdependency_libs='$dependency_libs'
9382c43cc173Smrg
9383c27c18e8Smrg# Names of additional weak libraries provided by this library
9384c27c18e8Smrgweak_library_names='$weak_libs'
9385c43cc173Smrg
9386c27c18e8Smrg# Version information for $libname.
9387c27c18e8Smrgcurrent=$current
9388c27c18e8Smrgage=$age
9389c27c18e8Smrgrevision=$revision
9390c43cc173Smrg
9391c27c18e8Smrg# Is this an already installed library?
9392c27c18e8Smrginstalled=$installed
9393c43cc173Smrg
9394c27c18e8Smrg# Should we warn about portability when linking against -modules?
9395c27c18e8Smrgshouldnotlink=$module
9396c43cc173Smrg
9397c27c18e8Smrg# Files to dlopen/dlpreopen
9398c27c18e8Smrgdlopen='$dlfiles'
9399c27c18e8Smrgdlpreopen='$dlprefiles'
9400c43cc173Smrg
9401c27c18e8Smrg# Directory that this library needs to be installed in:
9402c27c18e8Smrglibdir='$install_libdir'"
9403c27c18e8Smrg	  if test "$installed" = no && test "$need_relink" = yes; then
9404c27c18e8Smrg	    $ECHO >> $output "\
9405c27c18e8Smrgrelink_command=\"$relink_command\""
9406c27c18e8Smrg	  fi
9407c27c18e8Smrg	done
9408c27c18e8Smrg      }
9409c43cc173Smrg
9410c27c18e8Smrg      # Do a symbolic link so that the libtool archive can be found in
9411c27c18e8Smrg      # LD_LIBRARY_PATH before the program is installed.
9412c27c18e8Smrg      func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
9413c27c18e8Smrg      ;;
9414c27c18e8Smrg    esac
9415c27c18e8Smrg    exit $EXIT_SUCCESS
9416c27c18e8Smrg}
9417c43cc173Smrg
9418b789ec8aSmrg{ test "$opt_mode" = link || test "$opt_mode" = relink; } &&
9419c27c18e8Smrg    func_mode_link ${1+"$@"}
9420c43cc173Smrg
9421c43cc173Smrg
9422c27c18e8Smrg# func_mode_uninstall arg...
9423c27c18e8Smrgfunc_mode_uninstall ()
9424c27c18e8Smrg{
9425c27c18e8Smrg    $opt_debug
9426c27c18e8Smrg    RM="$nonopt"
9427c43cc173Smrg    files=
9428c43cc173Smrg    rmforce=
9429c43cc173Smrg    exit_status=0
9430c43cc173Smrg
9431c43cc173Smrg    # This variable tells wrapper scripts just to set variables rather
9432c43cc173Smrg    # than running their programs.
9433c43cc173Smrg    libtool_install_magic="$magic"
9434c43cc173Smrg
9435c43cc173Smrg    for arg
9436c43cc173Smrg    do
9437c43cc173Smrg      case $arg in
9438b789ec8aSmrg      -f) func_append RM " $arg"; rmforce=yes ;;
9439b789ec8aSmrg      -*) func_append RM " $arg" ;;
9440b789ec8aSmrg      *) func_append files " $arg" ;;
9441c43cc173Smrg      esac
9442c43cc173Smrg    done
9443c43cc173Smrg
9444c27c18e8Smrg    test -z "$RM" && \
9445c27c18e8Smrg      func_fatal_help "you must specify an RM program"
9446c43cc173Smrg
9447c43cc173Smrg    rmdirs=
9448c43cc173Smrg
9449c43cc173Smrg    for file in $files; do
9450c27c18e8Smrg      func_dirname "$file" "" "."
9451c27c18e8Smrg      dir="$func_dirname_result"
9452c27c18e8Smrg      if test "X$dir" = X.; then
9453b789ec8aSmrg	odir="$objdir"
9454c43cc173Smrg      else
9455b789ec8aSmrg	odir="$dir/$objdir"
9456c43cc173Smrg      fi
9457c27c18e8Smrg      func_basename "$file"
9458c27c18e8Smrg      name="$func_basename_result"
9459b789ec8aSmrg      test "$opt_mode" = uninstall && odir="$dir"
9460c43cc173Smrg
9461b789ec8aSmrg      # Remember odir for removal later, being careful to avoid duplicates
9462b789ec8aSmrg      if test "$opt_mode" = clean; then
9463c43cc173Smrg	case " $rmdirs " in
9464b789ec8aSmrg	  *" $odir "*) ;;
9465b789ec8aSmrg	  *) func_append rmdirs " $odir" ;;
9466c43cc173Smrg	esac
9467c43cc173Smrg      fi
9468c43cc173Smrg
9469c43cc173Smrg      # Don't error if the file doesn't exist and rm -f was used.
9470c27c18e8Smrg      if { test -L "$file"; } >/dev/null 2>&1 ||
9471c27c18e8Smrg	 { test -h "$file"; } >/dev/null 2>&1 ||
9472c27c18e8Smrg	 test -f "$file"; then
9473c43cc173Smrg	:
9474c43cc173Smrg      elif test -d "$file"; then
9475c43cc173Smrg	exit_status=1
9476c43cc173Smrg	continue
9477c43cc173Smrg      elif test "$rmforce" = yes; then
9478c43cc173Smrg	continue
9479c43cc173Smrg      fi
9480c43cc173Smrg
9481c43cc173Smrg      rmfiles="$file"
9482c43cc173Smrg
9483c43cc173Smrg      case $name in
9484c43cc173Smrg      *.la)
9485c43cc173Smrg	# Possibly a libtool archive, so verify it.
9486c27c18e8Smrg	if func_lalib_p "$file"; then
9487c27c18e8Smrg	  func_source $dir/$name
9488c43cc173Smrg
9489c43cc173Smrg	  # Delete the libtool libraries and symlinks.
9490c43cc173Smrg	  for n in $library_names; do
9491b789ec8aSmrg	    func_append rmfiles " $odir/$n"
9492c43cc173Smrg	  done
9493b789ec8aSmrg	  test -n "$old_library" && func_append rmfiles " $odir/$old_library"
9494c43cc173Smrg
9495b789ec8aSmrg	  case "$opt_mode" in
9496c43cc173Smrg	  clean)
9497b789ec8aSmrg	    case " $library_names " in
9498c43cc173Smrg	    *" $dlname "*) ;;
9499b789ec8aSmrg	    *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;;
9500c43cc173Smrg	    esac
9501b789ec8aSmrg	    test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i"
9502c43cc173Smrg	    ;;
9503c43cc173Smrg	  uninstall)
9504c43cc173Smrg	    if test -n "$library_names"; then
9505c43cc173Smrg	      # Do each command in the postuninstall commands.
9506c27c18e8Smrg	      func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
9507c43cc173Smrg	    fi
9508c43cc173Smrg
9509c43cc173Smrg	    if test -n "$old_library"; then
9510c43cc173Smrg	      # Do each command in the old_postuninstall commands.
9511c27c18e8Smrg	      func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
9512c43cc173Smrg	    fi
9513c43cc173Smrg	    # FIXME: should reinstall the best remaining shared library.
9514c43cc173Smrg	    ;;
9515c43cc173Smrg	  esac
9516c43cc173Smrg	fi
9517c43cc173Smrg	;;
9518c43cc173Smrg
9519c43cc173Smrg      *.lo)
9520c43cc173Smrg	# Possibly a libtool object, so verify it.
9521c27c18e8Smrg	if func_lalib_p "$file"; then
9522c43cc173Smrg
9523c43cc173Smrg	  # Read the .lo file
9524c27c18e8Smrg	  func_source $dir/$name
9525c43cc173Smrg
9526c43cc173Smrg	  # Add PIC object to the list of files to remove.
9527c27c18e8Smrg	  if test -n "$pic_object" &&
9528c27c18e8Smrg	     test "$pic_object" != none; then
9529b789ec8aSmrg	    func_append rmfiles " $dir/$pic_object"
9530c43cc173Smrg	  fi
9531c43cc173Smrg
9532c43cc173Smrg	  # Add non-PIC object to the list of files to remove.
9533c27c18e8Smrg	  if test -n "$non_pic_object" &&
9534c27c18e8Smrg	     test "$non_pic_object" != none; then
9535b789ec8aSmrg	    func_append rmfiles " $dir/$non_pic_object"
9536c43cc173Smrg	  fi
9537c43cc173Smrg	fi
9538c43cc173Smrg	;;
9539c43cc173Smrg
9540c43cc173Smrg      *)
9541b789ec8aSmrg	if test "$opt_mode" = clean ; then
9542c43cc173Smrg	  noexename=$name
9543c43cc173Smrg	  case $file in
9544c43cc173Smrg	  *.exe)
9545c27c18e8Smrg	    func_stripname '' '.exe' "$file"
9546c27c18e8Smrg	    file=$func_stripname_result
9547c27c18e8Smrg	    func_stripname '' '.exe' "$name"
9548c27c18e8Smrg	    noexename=$func_stripname_result
9549c43cc173Smrg	    # $file with .exe has already been added to rmfiles,
9550c43cc173Smrg	    # add $file without .exe
9551b789ec8aSmrg	    func_append rmfiles " $file"
9552c43cc173Smrg	    ;;
9553c43cc173Smrg	  esac
9554c43cc173Smrg	  # Do a test to see if this is a libtool program.
9555c27c18e8Smrg	  if func_ltwrapper_p "$file"; then
9556c27c18e8Smrg	    if func_ltwrapper_executable_p "$file"; then
9557c27c18e8Smrg	      func_ltwrapper_scriptname "$file"
9558c27c18e8Smrg	      relink_command=
9559c27c18e8Smrg	      func_source $func_ltwrapper_scriptname_result
9560b789ec8aSmrg	      func_append rmfiles " $func_ltwrapper_scriptname_result"
9561c27c18e8Smrg	    else
9562c27c18e8Smrg	      relink_command=
9563c27c18e8Smrg	      func_source $dir/$noexename
9564c27c18e8Smrg	    fi
9565c43cc173Smrg
9566c43cc173Smrg	    # note $name still contains .exe if it was in $file originally
9567c43cc173Smrg	    # as does the version of $file that was added into $rmfiles
9568b789ec8aSmrg	    func_append rmfiles " $odir/$name $odir/${name}S.${objext}"
9569c43cc173Smrg	    if test "$fast_install" = yes && test -n "$relink_command"; then
9570b789ec8aSmrg	      func_append rmfiles " $odir/lt-$name"
9571c43cc173Smrg	    fi
9572c43cc173Smrg	    if test "X$noexename" != "X$name" ; then
9573b789ec8aSmrg	      func_append rmfiles " $odir/lt-${noexename}.c"
9574c43cc173Smrg	    fi
9575c43cc173Smrg	  fi
9576c43cc173Smrg	fi
9577c43cc173Smrg	;;
9578c43cc173Smrg      esac
9579c27c18e8Smrg      func_show_eval "$RM $rmfiles" 'exit_status=1'
9580c43cc173Smrg    done
9581c43cc173Smrg
9582c43cc173Smrg    # Try to remove the ${objdir}s in the directories where we deleted files
9583c43cc173Smrg    for dir in $rmdirs; do
9584c43cc173Smrg      if test -d "$dir"; then
9585c27c18e8Smrg	func_show_eval "rmdir $dir >/dev/null 2>&1"
9586c43cc173Smrg      fi
9587c43cc173Smrg    done
9588c43cc173Smrg
9589c43cc173Smrg    exit $exit_status
9590c27c18e8Smrg}
9591c43cc173Smrg
9592b789ec8aSmrg{ test "$opt_mode" = uninstall || test "$opt_mode" = clean; } &&
9593c27c18e8Smrg    func_mode_uninstall ${1+"$@"}
9594c43cc173Smrg
9595b789ec8aSmrgtest -z "$opt_mode" && {
9596c27c18e8Smrg  help="$generic_help"
9597c27c18e8Smrg  func_fatal_help "you must specify a MODE"
9598c27c18e8Smrg}
9599c27c18e8Smrg
9600c27c18e8Smrgtest -z "$exec_cmd" && \
9601b789ec8aSmrg  func_fatal_help "invalid operation mode \`$opt_mode'"
9602c43cc173Smrg
9603c43cc173Smrgif test -n "$exec_cmd"; then
9604c27c18e8Smrg  eval exec "$exec_cmd"
9605c43cc173Smrg  exit $EXIT_FAILURE
9606c43cc173Smrgfi
9607c43cc173Smrg
9608c27c18e8Smrgexit $exit_status
9609c43cc173Smrg
9610c43cc173Smrg
9611c43cc173Smrg# The TAGs below are defined such that we never get into a situation
9612c43cc173Smrg# in which we disable both kinds of libraries.  Given conflicting
9613c43cc173Smrg# choices, we go for a static library, that is the most portable,
9614c43cc173Smrg# since we can't tell whether shared libraries were disabled because
9615c43cc173Smrg# the user asked for that or because the platform doesn't support
9616c43cc173Smrg# them.  This is particularly important on AIX, because we don't
9617c43cc173Smrg# support having both static and shared libraries enabled at the same
9618c43cc173Smrg# time on that platform, so we default to a shared-only configuration.
9619c43cc173Smrg# If a disable-shared tag is given, we'll fallback to a static-only
9620c43cc173Smrg# configuration.  But we'll never go from static-only to shared-only.
9621c43cc173Smrg
9622c43cc173Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
9623c27c18e8Smrgbuild_libtool_libs=no
9624c27c18e8Smrgbuild_old_libs=yes
9625c43cc173Smrg# ### END LIBTOOL TAG CONFIG: disable-shared
9626c43cc173Smrg
9627c43cc173Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static
9628c27c18e8Smrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
9629c43cc173Smrg# ### END LIBTOOL TAG CONFIG: disable-static
9630c43cc173Smrg
9631c43cc173Smrg# Local Variables:
9632c43cc173Smrg# mode:shell-script
9633c43cc173Smrg# sh-indentation:2
9634c43cc173Smrg# End:
9635c27c18e8Smrg# vi:sw=2
9636c27c18e8Smrg
9637