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