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