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