1244390Srwatson
2244390Srwatson# libtool (GNU libtool) 2.4.2
3244390Srwatson# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
4244390Srwatson
5173143Srwatson# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006,
6244390Srwatson# 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
7244390Srwatson# This is free software; see the source for copying conditions.  There is NO
8244390Srwatson# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9244390Srwatson
10244390Srwatson# GNU Libtool is free software; you can redistribute it and/or modify
11156283Srwatson# it under the terms of the GNU General Public License as published by
12156283Srwatson# the Free Software Foundation; either version 2 of the License, or
13156283Srwatson# (at your option) any later version.
14156283Srwatson#
15244390Srwatson# As a special exception to the GNU General Public License,
16244390Srwatson# if you distribute this file as part of a program or library that
17244390Srwatson# is built using GNU Libtool, you may include this file under the
18244390Srwatson# same distribution terms that you use for the rest of that program.
19244390Srwatson#
20244390Srwatson# GNU Libtool is distributed in the hope that it will be useful, but
21156283Srwatson# WITHOUT ANY WARRANTY; without even the implied warranty of
22156283Srwatson# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
23156283Srwatson# General Public License for more details.
24156283Srwatson#
25156283Srwatson# You should have received a copy of the GNU General Public License
26244390Srwatson# along with GNU Libtool; see the file COPYING.  If not, a copy
27244390Srwatson# can be downloaded from http://www.gnu.org/licenses/gpl.html,
28244390Srwatson# or obtained by writing to the Free Software Foundation, Inc.,
29244390Srwatson# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
30244390Srwatson
31244390Srwatson# Usage: $progname [OPTION]... [MODE-ARG]...
32156283Srwatson#
33244390Srwatson# Provide generalized library-building support services.
34244390Srwatson#
35244390Srwatson#       --config             show all configuration variables
36244390Srwatson#       --debug              enable verbose shell tracing
37244390Srwatson#   -n, --dry-run            display commands without modifying any files
38244390Srwatson#       --features           display basic configuration information and exit
39244390Srwatson#       --mode=MODE          use operation mode MODE
40244390Srwatson#       --preserve-dup-deps  don't remove duplicate dependency libraries
41244390Srwatson#       --quiet, --silent    don't print informational messages
42244390Srwatson#       --no-quiet, --no-silent
43244390Srwatson#                            print informational messages (default)
44244390Srwatson#       --no-warn            don't display warning messages
45244390Srwatson#       --tag=TAG            use configuration variables from tag TAG
46244390Srwatson#   -v, --verbose            print more informational messages than default
47244390Srwatson#       --no-verbose         don't print the extra informational messages
48244390Srwatson#       --version            print version information
49244390Srwatson#   -h, --help, --help-all   print short, long, or detailed help message
50244390Srwatson#
51244390Srwatson# MODE must be one of the following:
52244390Srwatson#
53244390Srwatson#         clean              remove files from the build directory
54244390Srwatson#         compile            compile a source file into a libtool object
55244390Srwatson#         execute            automatically set library path, then run a program
56244390Srwatson#         finish             complete the installation of libtool libraries
57244390Srwatson#         install            install libraries or executables
58244390Srwatson#         link               create a library or an executable
59244390Srwatson#         uninstall          remove libraries from an installed directory
60244390Srwatson#
61244390Srwatson# MODE-ARGS vary depending on the MODE.  When passed as first option,
62244390Srwatson# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that.
63244390Srwatson# Try `$progname --help --mode=MODE' for a more detailed description of MODE.
64244390Srwatson#
65244390Srwatson# When reporting a bug, please describe a test case to reproduce it and
66244390Srwatson# include the following information:
67244390Srwatson#
68244390Srwatson#         host-triplet:	$host
69244390Srwatson#         shell:		$SHELL
70244390Srwatson#         compiler:		$LTCC
71244390Srwatson#         compiler flags:		$LTCFLAGS
72244390Srwatson#         linker:		$LD (gnu? $with_gnu_ld)
73244390Srwatson#         $progname:	(GNU libtool) 2.4.2
74244390Srwatson#         automake:	$automake_version
75244390Srwatson#         autoconf:	$autoconf_version
76244390Srwatson#
77244390Srwatson# Report bugs to <bug-libtool@gnu.org>.
78244390Srwatson# GNU libtool home page: <http://www.gnu.org/software/libtool/>.
79244390Srwatson# General help using GNU software: <http://www.gnu.org/gethelp/>.
80156283Srwatson
81244390SrwatsonPROGRAM=libtool
82156283SrwatsonPACKAGE=libtool
83244390SrwatsonVERSION=2.4.2
84244390SrwatsonTIMESTAMP=""
85244390Srwatsonpackage_revision=1.3337
86156283Srwatson
87244390Srwatson# Be Bourne compatible
88173143Srwatsonif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
89173143Srwatson  emulate sh
90173143Srwatson  NULLCMD=:
91173143Srwatson  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
92173143Srwatson  # is contrary to our usage.  Disable this feature.
93173143Srwatson  alias -g '${1+"$@"}'='"$@"'
94156283Srwatson  setopt NO_GLOB_SUBST
95173143Srwatsonelse
96173143Srwatson  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
97156283Srwatsonfi
98173143SrwatsonBIN_SH=xpg4; export BIN_SH # for Tru64
99173143SrwatsonDUALCASE=1; export DUALCASE # for MKS sh
100156283Srwatson
101244390Srwatson# A function that is used when there is no print builtin or printf.
102244390Srwatsonfunc_fallback_echo ()
103244390Srwatson{
104244390Srwatson  eval 'cat <<_LTECHO_EOF
105244390Srwatson$1
106244390Srwatson_LTECHO_EOF'
107244390Srwatson}
108156283Srwatson
109244390Srwatson# NLS nuisances: We save the old values to restore during execute mode.
110244390Srwatsonlt_user_locale=
111244390Srwatsonlt_safe_locale=
112191273Srwatsonfor lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
113173143Srwatsondo
114173143Srwatson  eval "if test \"\${$lt_var+set}\" = set; then
115244390Srwatson          save_$lt_var=\$$lt_var
116244390Srwatson          $lt_var=C
117173143Srwatson	  export $lt_var
118244390Srwatson	  lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\"
119244390Srwatson	  lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
120173143Srwatson	fi"
121173143Srwatsondone
122244390SrwatsonLC_ALL=C
123244390SrwatsonLANGUAGE=C
124244390Srwatsonexport LANGUAGE LC_ALL
125156283Srwatson
126244390Srwatson$lt_unset CDPATH
127191273Srwatson
128244390Srwatson
129244390Srwatson# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
130244390Srwatson# is ksh but when the shell is invoked as "sh" and the current value of
131244390Srwatson# the _XPG environment variable is not equal to 1 (one), the special
132244390Srwatson# positional parameter $0, within a function call, is the name of the
133244390Srwatson# function.
134244390Srwatsonprogpath="$0"
135244390Srwatson
136244390Srwatson
137244390Srwatson
138244390Srwatson: ${CP="cp -f"}
139244390Srwatsontest "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'}
140244390Srwatson: ${MAKE="make"}
141244390Srwatson: ${MKDIR="mkdir"}
142244390Srwatson: ${MV="mv -f"}
143244390Srwatson: ${RM="rm -f"}
144244390Srwatson: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
145244390Srwatson: ${Xsed="$SED -e 1s/^X//"}
146244390Srwatson
147244390Srwatson# Global variables:
148244390SrwatsonEXIT_SUCCESS=0
149244390SrwatsonEXIT_FAILURE=1
150244390SrwatsonEXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
151244390SrwatsonEXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
152244390Srwatson
153244390Srwatsonexit_status=$EXIT_SUCCESS
154244390Srwatson
155156283Srwatson# Make sure IFS has a sensible default
156156283Srwatsonlt_nl='
157156283Srwatson'
158156283SrwatsonIFS=" 	$lt_nl"
159156283Srwatson
160244390Srwatsondirname="s,/[^/]*$,,"
161244390Srwatsonbasename="s,^.*/,,"
162156283Srwatson
163244390Srwatson# func_dirname file append nondir_replacement
164244390Srwatson# Compute the dirname of FILE.  If nonempty, add APPEND to the result,
165244390Srwatson# otherwise set result to NONDIR_REPLACEMENT.
166244390Srwatsonfunc_dirname ()
167244390Srwatson{
168244390Srwatson    func_dirname_result=`$ECHO "${1}" | $SED "$dirname"`
169244390Srwatson    if test "X$func_dirname_result" = "X${1}"; then
170244390Srwatson      func_dirname_result="${3}"
171244390Srwatson    else
172244390Srwatson      func_dirname_result="$func_dirname_result${2}"
173244390Srwatson    fi
174244390Srwatson} # func_dirname may be replaced by extended shell implementation
175156283Srwatson
176156283Srwatson
177244390Srwatson# func_basename file
178244390Srwatsonfunc_basename ()
179244390Srwatson{
180244390Srwatson    func_basename_result=`$ECHO "${1}" | $SED "$basename"`
181244390Srwatson} # func_basename may be replaced by extended shell implementation
182244390Srwatson
183244390Srwatson
184244390Srwatson# func_dirname_and_basename file append nondir_replacement
185244390Srwatson# perform func_basename and func_dirname in a single function
186244390Srwatson# call:
187244390Srwatson#   dirname:  Compute the dirname of FILE.  If nonempty,
188244390Srwatson#             add APPEND to the result, otherwise set result
189244390Srwatson#             to NONDIR_REPLACEMENT.
190244390Srwatson#             value returned in "$func_dirname_result"
191244390Srwatson#   basename: Compute filename of FILE.
192244390Srwatson#             value retuned in "$func_basename_result"
193244390Srwatson# Implementation must be kept synchronized with func_dirname
194244390Srwatson# and func_basename. For efficiency, we do not delegate to
195244390Srwatson# those functions but instead duplicate the functionality here.
196244390Srwatsonfunc_dirname_and_basename ()
197244390Srwatson{
198244390Srwatson    # Extract subdirectory from the argument.
199244390Srwatson    func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"`
200244390Srwatson    if test "X$func_dirname_result" = "X${1}"; then
201244390Srwatson      func_dirname_result="${3}"
202244390Srwatson    else
203244390Srwatson      func_dirname_result="$func_dirname_result${2}"
204244390Srwatson    fi
205244390Srwatson    func_basename_result=`$ECHO "${1}" | $SED -e "$basename"`
206244390Srwatson} # func_dirname_and_basename may be replaced by extended shell implementation
207244390Srwatson
208244390Srwatson
209244390Srwatson# func_stripname prefix suffix name
210244390Srwatson# strip PREFIX and SUFFIX off of NAME.
211244390Srwatson# PREFIX and SUFFIX must not contain globbing or regex special
212244390Srwatson# characters, hashes, percent signs, but SUFFIX may contain a leading
213244390Srwatson# dot (in which case that matches only a dot).
214244390Srwatson# func_strip_suffix prefix name
215244390Srwatsonfunc_stripname ()
216244390Srwatson{
217244390Srwatson    case ${2} in
218244390Srwatson      .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;;
219244390Srwatson      *)  func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;;
220244390Srwatson    esac
221244390Srwatson} # func_stripname may be replaced by extended shell implementation
222244390Srwatson
223244390Srwatson
224244390Srwatson# These SED scripts presuppose an absolute path with a trailing slash.
225244390Srwatsonpathcar='s,^/\([^/]*\).*$,\1,'
226244390Srwatsonpathcdr='s,^/[^/]*,,'
227244390Srwatsonremovedotparts=':dotsl
228244390Srwatson		s@/\./@/@g
229244390Srwatson		t dotsl
230244390Srwatson		s,/\.$,/,'
231244390Srwatsoncollapseslashes='s@/\{1,\}@/@g'
232244390Srwatsonfinalslash='s,/*$,/,'
233244390Srwatson
234244390Srwatson# func_normal_abspath PATH
235244390Srwatson# Remove doubled-up and trailing slashes, "." path components,
236244390Srwatson# and cancel out any ".." path components in PATH after making
237244390Srwatson# it an absolute path.
238244390Srwatson#             value returned in "$func_normal_abspath_result"
239244390Srwatsonfunc_normal_abspath ()
240244390Srwatson{
241244390Srwatson  # Start from root dir and reassemble the path.
242244390Srwatson  func_normal_abspath_result=
243244390Srwatson  func_normal_abspath_tpath=$1
244244390Srwatson  func_normal_abspath_altnamespace=
245244390Srwatson  case $func_normal_abspath_tpath in
246244390Srwatson    "")
247244390Srwatson      # Empty path, that just means $cwd.
248244390Srwatson      func_stripname '' '/' "`pwd`"
249244390Srwatson      func_normal_abspath_result=$func_stripname_result
250244390Srwatson      return
251244390Srwatson    ;;
252244390Srwatson    # The next three entries are used to spot a run of precisely
253244390Srwatson    # two leading slashes without using negated character classes;
254244390Srwatson    # we take advantage of case's first-match behaviour.
255244390Srwatson    ///*)
256244390Srwatson      # Unusual form of absolute path, do nothing.
257244390Srwatson    ;;
258244390Srwatson    //*)
259244390Srwatson      # Not necessarily an ordinary path; POSIX reserves leading '//'
260244390Srwatson      # and for example Cygwin uses it to access remote file shares
261244390Srwatson      # over CIFS/SMB, so we conserve a leading double slash if found.
262244390Srwatson      func_normal_abspath_altnamespace=/
263244390Srwatson    ;;
264244390Srwatson    /*)
265244390Srwatson      # Absolute path, do nothing.
266244390Srwatson    ;;
267244390Srwatson    *)
268244390Srwatson      # Relative path, prepend $cwd.
269244390Srwatson      func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
270244390Srwatson    ;;
271244390Srwatson  esac
272244390Srwatson  # Cancel out all the simple stuff to save iterations.  We also want
273244390Srwatson  # the path to end with a slash for ease of parsing, so make sure
274244390Srwatson  # there is one (and only one) here.
275244390Srwatson  func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
276244390Srwatson        -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"`
277244390Srwatson  while :; do
278244390Srwatson    # Processed it all yet?
279244390Srwatson    if test "$func_normal_abspath_tpath" = / ; then
280244390Srwatson      # If we ascended to the root using ".." the result may be empty now.
281244390Srwatson      if test -z "$func_normal_abspath_result" ; then
282244390Srwatson        func_normal_abspath_result=/
283244390Srwatson      fi
284244390Srwatson      break
285244390Srwatson    fi
286244390Srwatson    func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
287244390Srwatson        -e "$pathcar"`
288244390Srwatson    func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
289244390Srwatson        -e "$pathcdr"`
290244390Srwatson    # Figure out what to do with it
291244390Srwatson    case $func_normal_abspath_tcomponent in
292244390Srwatson      "")
293244390Srwatson        # Trailing empty path component, ignore it.
294244390Srwatson      ;;
295244390Srwatson      ..)
296244390Srwatson        # Parent dir; strip last assembled component from result.
297244390Srwatson        func_dirname "$func_normal_abspath_result"
298244390Srwatson        func_normal_abspath_result=$func_dirname_result
299244390Srwatson      ;;
300244390Srwatson      *)
301244390Srwatson        # Actual path component, append it.
302244390Srwatson        func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent
303244390Srwatson      ;;
304244390Srwatson    esac
305244390Srwatson  done
306244390Srwatson  # Restore leading double-slash if one was found on entry.
307244390Srwatson  func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
308244390Srwatson}
309244390Srwatson
310244390Srwatson# func_relative_path SRCDIR DSTDIR
311244390Srwatson# generates a relative path from SRCDIR to DSTDIR, with a trailing
312244390Srwatson# slash if non-empty, suitable for immediately appending a filename
313244390Srwatson# without needing to append a separator.
314244390Srwatson#             value returned in "$func_relative_path_result"
315244390Srwatsonfunc_relative_path ()
316244390Srwatson{
317244390Srwatson  func_relative_path_result=
318244390Srwatson  func_normal_abspath "$1"
319244390Srwatson  func_relative_path_tlibdir=$func_normal_abspath_result
320244390Srwatson  func_normal_abspath "$2"
321244390Srwatson  func_relative_path_tbindir=$func_normal_abspath_result
322244390Srwatson
323244390Srwatson  # Ascend the tree starting from libdir
324244390Srwatson  while :; do
325244390Srwatson    # check if we have found a prefix of bindir
326244390Srwatson    case $func_relative_path_tbindir in
327244390Srwatson      $func_relative_path_tlibdir)
328244390Srwatson        # found an exact match
329244390Srwatson        func_relative_path_tcancelled=
330244390Srwatson        break
331244390Srwatson        ;;
332244390Srwatson      $func_relative_path_tlibdir*)
333244390Srwatson        # found a matching prefix
334244390Srwatson        func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
335244390Srwatson        func_relative_path_tcancelled=$func_stripname_result
336244390Srwatson        if test -z "$func_relative_path_result"; then
337244390Srwatson          func_relative_path_result=.
338244390Srwatson        fi
339244390Srwatson        break
340244390Srwatson        ;;
341244390Srwatson      *)
342244390Srwatson        func_dirname $func_relative_path_tlibdir
343244390Srwatson        func_relative_path_tlibdir=${func_dirname_result}
344244390Srwatson        if test "x$func_relative_path_tlibdir" = x ; then
345244390Srwatson          # Have to descend all the way to the root!
346244390Srwatson          func_relative_path_result=../$func_relative_path_result
347244390Srwatson          func_relative_path_tcancelled=$func_relative_path_tbindir
348244390Srwatson          break
349244390Srwatson        fi
350244390Srwatson        func_relative_path_result=../$func_relative_path_result
351244390Srwatson        ;;
352244390Srwatson    esac
353244390Srwatson  done
354244390Srwatson
355244390Srwatson  # Now calculate path; take care to avoid doubling-up slashes.
356244390Srwatson  func_stripname '' '/' "$func_relative_path_result"
357244390Srwatson  func_relative_path_result=$func_stripname_result
358244390Srwatson  func_stripname '/' '/' "$func_relative_path_tcancelled"
359244390Srwatson  if test "x$func_stripname_result" != x ; then
360244390Srwatson    func_relative_path_result=${func_relative_path_result}/${func_stripname_result}
361244390Srwatson  fi
362244390Srwatson
363244390Srwatson  # Normalisation. If bindir is libdir, return empty string,
364244390Srwatson  # else relative path ending with a slash; either way, target
365244390Srwatson  # file name can be directly appended.
366244390Srwatson  if test ! -z "$func_relative_path_result"; then
367244390Srwatson    func_stripname './' '' "$func_relative_path_result/"
368244390Srwatson    func_relative_path_result=$func_stripname_result
369244390Srwatson  fi
370244390Srwatson}
371244390Srwatson
372244390Srwatson# The name of this program:
373244390Srwatsonfunc_dirname_and_basename "$progpath"
374244390Srwatsonprogname=$func_basename_result
375244390Srwatson
376244390Srwatson# Make sure we have an absolute path for reexecution:
377244390Srwatsoncase $progpath in
378244390Srwatson  [\\/]*|[A-Za-z]:\\*) ;;
379244390Srwatson  *[\\/]*)
380244390Srwatson     progdir=$func_dirname_result
381244390Srwatson     progdir=`cd "$progdir" && pwd`
382244390Srwatson     progpath="$progdir/$progname"
383244390Srwatson     ;;
384244390Srwatson  *)
385244390Srwatson     save_IFS="$IFS"
386244390Srwatson     IFS=${PATH_SEPARATOR-:}
387244390Srwatson     for progdir in $PATH; do
388244390Srwatson       IFS="$save_IFS"
389244390Srwatson       test -x "$progdir/$progname" && break
390244390Srwatson     done
391244390Srwatson     IFS="$save_IFS"
392244390Srwatson     test -n "$progdir" || progdir=`pwd`
393244390Srwatson     progpath="$progdir/$progname"
394244390Srwatson     ;;
395244390Srwatsonesac
396244390Srwatson
397244390Srwatson# Sed substitution that helps us do robust quoting.  It backslashifies
398244390Srwatson# metacharacters that are still active within double-quoted strings.
399244390SrwatsonXsed="${SED}"' -e 1s/^X//'
400244390Srwatsonsed_quote_subst='s/\([`"$\\]\)/\\\1/g'
401244390Srwatson
402244390Srwatson# Same as above, but do not quote variable references.
403244390Srwatsondouble_quote_subst='s/\(["`\\]\)/\\\1/g'
404244390Srwatson
405244390Srwatson# Sed substitution that turns a string into a regex matching for the
406244390Srwatson# string literally.
407244390Srwatsonsed_make_literal_regex='s,[].[^$\\*\/],\\&,g'
408244390Srwatson
409244390Srwatson# Sed substitution that converts a w32 file name or path
410244390Srwatson# which contains forward slashes, into one that contains
411244390Srwatson# (escaped) backslashes.  A very naive implementation.
412244390Srwatsonlt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
413244390Srwatson
414244390Srwatson# Re-`\' parameter expansions in output of double_quote_subst that were
415244390Srwatson# `\'-ed in input to the same.  If an odd number of `\' preceded a '$'
416244390Srwatson# in input to double_quote_subst, that '$' was protected from expansion.
417244390Srwatson# Since each input `\' is now two `\'s, look for any number of runs of
418244390Srwatson# four `\'s followed by two `\'s and then a '$'.  `\' that '$'.
419244390Srwatsonbs='\\'
420244390Srwatsonbs2='\\\\'
421244390Srwatsonbs4='\\\\\\\\'
422244390Srwatsondollar='\$'
423244390Srwatsonsed_double_backslash="\
424244390Srwatson  s/$bs4/&\\
425244390Srwatson/g
426244390Srwatson  s/^$bs2$dollar/$bs&/
427244390Srwatson  s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
428244390Srwatson  s/\n//g"
429244390Srwatson
430244390Srwatson# Standard options:
431244390Srwatsonopt_dry_run=false
432244390Srwatsonopt_help=false
433244390Srwatsonopt_quiet=false
434244390Srwatsonopt_verbose=false
435244390Srwatsonopt_warning=:
436244390Srwatson
437244390Srwatson# func_echo arg...
438244390Srwatson# Echo program name prefixed message, along with the current mode
439244390Srwatson# name if it has been set yet.
440244390Srwatsonfunc_echo ()
441244390Srwatson{
442244390Srwatson    $ECHO "$progname: ${opt_mode+$opt_mode: }$*"
443244390Srwatson}
444244390Srwatson
445244390Srwatson# func_verbose arg...
446244390Srwatson# Echo program name prefixed message in verbose mode only.
447244390Srwatsonfunc_verbose ()
448244390Srwatson{
449244390Srwatson    $opt_verbose && func_echo ${1+"$@"}
450244390Srwatson
451244390Srwatson    # A bug in bash halts the script if the last line of a function
452244390Srwatson    # fails when set -e is in force, so we need another command to
453244390Srwatson    # work around that:
454244390Srwatson    :
455244390Srwatson}
456244390Srwatson
457244390Srwatson# func_echo_all arg...
458244390Srwatson# Invoke $ECHO with all args, space-separated.
459244390Srwatsonfunc_echo_all ()
460244390Srwatson{
461244390Srwatson    $ECHO "$*"
462244390Srwatson}
463244390Srwatson
464244390Srwatson# func_error arg...
465244390Srwatson# Echo program name prefixed message to standard error.
466244390Srwatsonfunc_error ()
467244390Srwatson{
468244390Srwatson    $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2
469244390Srwatson}
470244390Srwatson
471244390Srwatson# func_warning arg...
472244390Srwatson# Echo program name prefixed warning message to standard error.
473244390Srwatsonfunc_warning ()
474244390Srwatson{
475244390Srwatson    $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2
476244390Srwatson
477244390Srwatson    # bash bug again:
478244390Srwatson    :
479244390Srwatson}
480244390Srwatson
481244390Srwatson# func_fatal_error arg...
482244390Srwatson# Echo program name prefixed message to standard error, and exit.
483244390Srwatsonfunc_fatal_error ()
484244390Srwatson{
485244390Srwatson    func_error ${1+"$@"}
486244390Srwatson    exit $EXIT_FAILURE
487244390Srwatson}
488244390Srwatson
489244390Srwatson# func_fatal_help arg...
490244390Srwatson# Echo program name prefixed message to standard error, followed by
491244390Srwatson# a help hint, and exit.
492244390Srwatsonfunc_fatal_help ()
493244390Srwatson{
494244390Srwatson    func_error ${1+"$@"}
495244390Srwatson    func_fatal_error "$help"
496244390Srwatson}
497244390Srwatsonhelp="Try \`$progname --help' for more information."  ## default
498244390Srwatson
499244390Srwatson
500244390Srwatson# func_grep expression filename
501244390Srwatson# Check whether EXPRESSION matches any line of FILENAME, without output.
502244390Srwatsonfunc_grep ()
503244390Srwatson{
504244390Srwatson    $GREP "$1" "$2" >/dev/null 2>&1
505244390Srwatson}
506244390Srwatson
507244390Srwatson
508244390Srwatson# func_mkdir_p directory-path
509244390Srwatson# Make sure the entire path to DIRECTORY-PATH is available.
510244390Srwatsonfunc_mkdir_p ()
511244390Srwatson{
512244390Srwatson    my_directory_path="$1"
513244390Srwatson    my_dir_list=
514244390Srwatson
515244390Srwatson    if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
516244390Srwatson
517244390Srwatson      # Protect directory names starting with `-'
518244390Srwatson      case $my_directory_path in
519244390Srwatson        -*) my_directory_path="./$my_directory_path" ;;
520244390Srwatson      esac
521244390Srwatson
522244390Srwatson      # While some portion of DIR does not yet exist...
523244390Srwatson      while test ! -d "$my_directory_path"; do
524244390Srwatson        # ...make a list in topmost first order.  Use a colon delimited
525244390Srwatson	# list incase some portion of path contains whitespace.
526244390Srwatson        my_dir_list="$my_directory_path:$my_dir_list"
527244390Srwatson
528244390Srwatson        # If the last portion added has no slash in it, the list is done
529244390Srwatson        case $my_directory_path in */*) ;; *) break ;; esac
530244390Srwatson
531244390Srwatson        # ...otherwise throw away the child directory and loop
532244390Srwatson        my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"`
533244390Srwatson      done
534244390Srwatson      my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'`
535244390Srwatson
536244390Srwatson      save_mkdir_p_IFS="$IFS"; IFS=':'
537244390Srwatson      for my_dir in $my_dir_list; do
538244390Srwatson	IFS="$save_mkdir_p_IFS"
539244390Srwatson        # mkdir can fail with a `File exist' error if two processes
540244390Srwatson        # try to create one of the directories concurrently.  Don't
541244390Srwatson        # stop in that case!
542244390Srwatson        $MKDIR "$my_dir" 2>/dev/null || :
543244390Srwatson      done
544244390Srwatson      IFS="$save_mkdir_p_IFS"
545244390Srwatson
546244390Srwatson      # Bail out if we (or some other process) failed to create a directory.
547244390Srwatson      test -d "$my_directory_path" || \
548244390Srwatson        func_fatal_error "Failed to create \`$1'"
549244390Srwatson    fi
550244390Srwatson}
551244390Srwatson
552244390Srwatson
553159985Srwatson# func_mktempdir [string]
554159985Srwatson# Make a temporary directory that won't clash with other running
555159985Srwatson# libtool processes, and avoids race conditions if possible.  If
556159985Srwatson# given, STRING is the basename for that directory.
557159985Srwatsonfunc_mktempdir ()
558159985Srwatson{
559159985Srwatson    my_template="${TMPDIR-/tmp}/${1-$progname}"
560159985Srwatson
561244390Srwatson    if test "$opt_dry_run" = ":"; then
562159985Srwatson      # Return a directory name, but don't create it in dry-run mode
563159985Srwatson      my_tmpdir="${my_template}-$$"
564159985Srwatson    else
565159985Srwatson
566159985Srwatson      # If mktemp works, use that first and foremost
567159985Srwatson      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
568159985Srwatson
569159985Srwatson      if test ! -d "$my_tmpdir"; then
570244390Srwatson        # Failing that, at least try and use $RANDOM to avoid a race
571244390Srwatson        my_tmpdir="${my_template}-${RANDOM-0}$$"
572159985Srwatson
573244390Srwatson        save_mktempdir_umask=`umask`
574244390Srwatson        umask 0077
575244390Srwatson        $MKDIR "$my_tmpdir"
576244390Srwatson        umask $save_mktempdir_umask
577159985Srwatson      fi
578159985Srwatson
579159985Srwatson      # If we're not in dry-run mode, bomb out on failure
580244390Srwatson      test -d "$my_tmpdir" || \
581244390Srwatson        func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
582159985Srwatson    fi
583159985Srwatson
584244390Srwatson    $ECHO "$my_tmpdir"
585159985Srwatson}
586159985Srwatson
587159985Srwatson
588244390Srwatson# func_quote_for_eval arg
589244390Srwatson# Aesthetically quote ARG to be evaled later.
590244390Srwatson# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
591244390Srwatson# is double-quoted, suitable for a subsequent eval, whereas
592244390Srwatson# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
593244390Srwatson# which are still active within double quotes backslashified.
594244390Srwatsonfunc_quote_for_eval ()
595156283Srwatson{
596244390Srwatson    case $1 in
597244390Srwatson      *[\\\`\"\$]*)
598244390Srwatson	func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;;
599244390Srwatson      *)
600244390Srwatson        func_quote_for_eval_unquoted_result="$1" ;;
601244390Srwatson    esac
602244390Srwatson
603244390Srwatson    case $func_quote_for_eval_unquoted_result in
604244390Srwatson      # Double-quote args containing shell metacharacters to delay
605244390Srwatson      # word splitting, command substitution and and variable
606244390Srwatson      # expansion for a subsequent eval.
607244390Srwatson      # Many Bourne shells cannot handle close brackets correctly
608244390Srwatson      # in scan sets, so we specify it separately.
609244390Srwatson      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
610244390Srwatson        func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
611244390Srwatson        ;;
612244390Srwatson      *)
613244390Srwatson        func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
614244390Srwatson    esac
615244390Srwatson}
616244390Srwatson
617244390Srwatson
618244390Srwatson# func_quote_for_expand arg
619244390Srwatson# Aesthetically quote ARG to be evaled later; same as above,
620244390Srwatson# but do not quote variable references.
621244390Srwatsonfunc_quote_for_expand ()
622244390Srwatson{
623244390Srwatson    case $1 in
624244390Srwatson      *[\\\`\"]*)
625244390Srwatson	my_arg=`$ECHO "$1" | $SED \
626244390Srwatson	    -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
627244390Srwatson      *)
628244390Srwatson        my_arg="$1" ;;
629244390Srwatson    esac
630244390Srwatson
631244390Srwatson    case $my_arg in
632244390Srwatson      # Double-quote args containing shell metacharacters to delay
633244390Srwatson      # word splitting and command substitution for a subsequent eval.
634244390Srwatson      # Many Bourne shells cannot handle close brackets correctly
635244390Srwatson      # in scan sets, so we specify it separately.
636244390Srwatson      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
637244390Srwatson        my_arg="\"$my_arg\""
638244390Srwatson        ;;
639244390Srwatson    esac
640244390Srwatson
641244390Srwatson    func_quote_for_expand_result="$my_arg"
642244390Srwatson}
643244390Srwatson
644244390Srwatson
645244390Srwatson# func_show_eval cmd [fail_exp]
646244390Srwatson# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
647244390Srwatson# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
648244390Srwatson# is given, then evaluate it.
649244390Srwatsonfunc_show_eval ()
650244390Srwatson{
651244390Srwatson    my_cmd="$1"
652244390Srwatson    my_fail_exp="${2-:}"
653244390Srwatson
654244390Srwatson    ${opt_silent-false} || {
655244390Srwatson      func_quote_for_expand "$my_cmd"
656244390Srwatson      eval "func_echo $func_quote_for_expand_result"
657244390Srwatson    }
658244390Srwatson
659244390Srwatson    if ${opt_dry_run-false}; then :; else
660244390Srwatson      eval "$my_cmd"
661244390Srwatson      my_status=$?
662244390Srwatson      if test "$my_status" -eq 0; then :; else
663244390Srwatson	eval "(exit $my_status); $my_fail_exp"
664244390Srwatson      fi
665156283Srwatson    fi
666244390Srwatson}
667244390Srwatson
668244390Srwatson
669244390Srwatson# func_show_eval_locale cmd [fail_exp]
670244390Srwatson# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
671244390Srwatson# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
672244390Srwatson# is given, then evaluate it.  Use the saved locale for evaluation.
673244390Srwatsonfunc_show_eval_locale ()
674244390Srwatson{
675244390Srwatson    my_cmd="$1"
676244390Srwatson    my_fail_exp="${2-:}"
677244390Srwatson
678244390Srwatson    ${opt_silent-false} || {
679244390Srwatson      func_quote_for_expand "$my_cmd"
680244390Srwatson      eval "func_echo $func_quote_for_expand_result"
681244390Srwatson    }
682244390Srwatson
683244390Srwatson    if ${opt_dry_run-false}; then :; else
684244390Srwatson      eval "$lt_user_locale
685244390Srwatson	    $my_cmd"
686244390Srwatson      my_status=$?
687244390Srwatson      eval "$lt_safe_locale"
688244390Srwatson      if test "$my_status" -eq 0; then :; else
689244390Srwatson	eval "(exit $my_status); $my_fail_exp"
690244390Srwatson      fi
691244390Srwatson    fi
692244390Srwatson}
693244390Srwatson
694244390Srwatson# func_tr_sh
695244390Srwatson# Turn $1 into a string suitable for a shell variable name.
696244390Srwatson# Result is stored in $func_tr_sh_result.  All characters
697244390Srwatson# not in the set a-zA-Z0-9_ are replaced with '_'. Further,
698244390Srwatson# if $1 begins with a digit, a '_' is prepended as well.
699244390Srwatsonfunc_tr_sh ()
700244390Srwatson{
701244390Srwatson  case $1 in
702244390Srwatson  [0-9]* | *[!a-zA-Z0-9_]*)
703244390Srwatson    func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'`
704156283Srwatson    ;;
705244390Srwatson  * )
706244390Srwatson    func_tr_sh_result=$1
707156283Srwatson    ;;
708244390Srwatson  esac
709244390Srwatson}
710244390Srwatson
711244390Srwatson
712244390Srwatson# func_version
713244390Srwatson# Echo version message to standard output and exit.
714244390Srwatsonfunc_version ()
715244390Srwatson{
716244390Srwatson    $opt_debug
717244390Srwatson
718244390Srwatson    $SED -n '/(C)/!b go
719244390Srwatson	:more
720244390Srwatson	/\./!{
721244390Srwatson	  N
722244390Srwatson	  s/\n# / /
723244390Srwatson	  b more
724244390Srwatson	}
725244390Srwatson	:go
726244390Srwatson	/^# '$PROGRAM' (GNU /,/# warranty; / {
727244390Srwatson        s/^# //
728244390Srwatson	s/^# *$//
729244390Srwatson        s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
730244390Srwatson        p
731244390Srwatson     }' < "$progpath"
732244390Srwatson     exit $?
733244390Srwatson}
734244390Srwatson
735244390Srwatson# func_usage
736244390Srwatson# Echo short help message to standard output and exit.
737244390Srwatsonfunc_usage ()
738244390Srwatson{
739244390Srwatson    $opt_debug
740244390Srwatson
741244390Srwatson    $SED -n '/^# Usage:/,/^#  *.*--help/ {
742244390Srwatson        s/^# //
743244390Srwatson	s/^# *$//
744244390Srwatson	s/\$progname/'$progname'/
745244390Srwatson	p
746244390Srwatson    }' < "$progpath"
747244390Srwatson    echo
748244390Srwatson    $ECHO "run \`$progname --help | more' for full usage"
749244390Srwatson    exit $?
750244390Srwatson}
751244390Srwatson
752244390Srwatson# func_help [NOEXIT]
753244390Srwatson# Echo long help message to standard output and exit,
754244390Srwatson# unless 'noexit' is passed as argument.
755244390Srwatsonfunc_help ()
756244390Srwatson{
757244390Srwatson    $opt_debug
758244390Srwatson
759244390Srwatson    $SED -n '/^# Usage:/,/# Report bugs to/ {
760244390Srwatson	:print
761244390Srwatson        s/^# //
762244390Srwatson	s/^# *$//
763244390Srwatson	s*\$progname*'$progname'*
764244390Srwatson	s*\$host*'"$host"'*
765244390Srwatson	s*\$SHELL*'"$SHELL"'*
766244390Srwatson	s*\$LTCC*'"$LTCC"'*
767244390Srwatson	s*\$LTCFLAGS*'"$LTCFLAGS"'*
768244390Srwatson	s*\$LD*'"$LD"'*
769244390Srwatson	s/\$with_gnu_ld/'"$with_gnu_ld"'/
770244390Srwatson	s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/
771244390Srwatson	s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/
772244390Srwatson	p
773244390Srwatson	d
774244390Srwatson     }
775244390Srwatson     /^# .* home page:/b print
776244390Srwatson     /^# General help using/b print
777244390Srwatson     ' < "$progpath"
778244390Srwatson    ret=$?
779244390Srwatson    if test -z "$1"; then
780244390Srwatson      exit $ret
781244390Srwatson    fi
782244390Srwatson}
783244390Srwatson
784244390Srwatson# func_missing_arg argname
785244390Srwatson# Echo program name prefixed message to standard error and set global
786244390Srwatson# exit_cmd.
787244390Srwatsonfunc_missing_arg ()
788244390Srwatson{
789244390Srwatson    $opt_debug
790244390Srwatson
791244390Srwatson    func_error "missing argument for $1."
792244390Srwatson    exit_cmd=exit
793244390Srwatson}
794244390Srwatson
795244390Srwatson
796244390Srwatson# func_split_short_opt shortopt
797244390Srwatson# Set func_split_short_opt_name and func_split_short_opt_arg shell
798244390Srwatson# variables after splitting SHORTOPT after the 2nd character.
799244390Srwatsonfunc_split_short_opt ()
800244390Srwatson{
801244390Srwatson    my_sed_short_opt='1s/^\(..\).*$/\1/;q'
802244390Srwatson    my_sed_short_rest='1s/^..\(.*\)$/\1/;q'
803244390Srwatson
804244390Srwatson    func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"`
805244390Srwatson    func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"`
806244390Srwatson} # func_split_short_opt may be replaced by extended shell implementation
807244390Srwatson
808244390Srwatson
809244390Srwatson# func_split_long_opt longopt
810244390Srwatson# Set func_split_long_opt_name and func_split_long_opt_arg shell
811244390Srwatson# variables after splitting LONGOPT at the `=' sign.
812244390Srwatsonfunc_split_long_opt ()
813244390Srwatson{
814244390Srwatson    my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q'
815244390Srwatson    my_sed_long_arg='1s/^--[^=]*=//'
816244390Srwatson
817244390Srwatson    func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"`
818244390Srwatson    func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"`
819244390Srwatson} # func_split_long_opt may be replaced by extended shell implementation
820244390Srwatson
821244390Srwatsonexit_cmd=:
822244390Srwatson
823244390Srwatson
824244390Srwatson
825244390Srwatson
826244390Srwatson
827244390Srwatsonmagic="%%%MAGIC variable%%%"
828244390Srwatsonmagic_exe="%%%MAGIC EXE variable%%%"
829244390Srwatson
830244390Srwatson# Global variables.
831244390Srwatsonnonopt=
832244390Srwatsonpreserve_args=
833244390Srwatsonlo2o="s/\\.lo\$/.${objext}/"
834244390Srwatsono2lo="s/\\.${objext}\$/.lo/"
835244390Srwatsonextracted_archives=
836244390Srwatsonextracted_serial=0
837244390Srwatson
838244390Srwatson# If this variable is set in any of the actions, the command in it
839244390Srwatson# will be execed at the end.  This prevents here-documents from being
840244390Srwatson# left over by shells.
841244390Srwatsonexec_cmd=
842244390Srwatson
843244390Srwatson# func_append var value
844244390Srwatson# Append VALUE to the end of shell variable VAR.
845244390Srwatsonfunc_append ()
846244390Srwatson{
847244390Srwatson    eval "${1}=\$${1}\${2}"
848244390Srwatson} # func_append may be replaced by extended shell implementation
849244390Srwatson
850244390Srwatson# func_append_quoted var value
851244390Srwatson# Quote VALUE and append to the end of shell variable VAR, separated
852244390Srwatson# by a space.
853244390Srwatsonfunc_append_quoted ()
854244390Srwatson{
855244390Srwatson    func_quote_for_eval "${2}"
856244390Srwatson    eval "${1}=\$${1}\\ \$func_quote_for_eval_result"
857244390Srwatson} # func_append_quoted may be replaced by extended shell implementation
858244390Srwatson
859244390Srwatson
860244390Srwatson# func_arith arithmetic-term...
861244390Srwatsonfunc_arith ()
862244390Srwatson{
863244390Srwatson    func_arith_result=`expr "${@}"`
864244390Srwatson} # func_arith may be replaced by extended shell implementation
865244390Srwatson
866244390Srwatson
867244390Srwatson# func_len string
868244390Srwatson# STRING may not start with a hyphen.
869244390Srwatsonfunc_len ()
870244390Srwatson{
871244390Srwatson    func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len`
872244390Srwatson} # func_len may be replaced by extended shell implementation
873244390Srwatson
874244390Srwatson
875244390Srwatson# func_lo2o object
876244390Srwatsonfunc_lo2o ()
877244390Srwatson{
878244390Srwatson    func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"`
879244390Srwatson} # func_lo2o may be replaced by extended shell implementation
880244390Srwatson
881244390Srwatson
882244390Srwatson# func_xform libobj-or-source
883244390Srwatsonfunc_xform ()
884244390Srwatson{
885244390Srwatson    func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'`
886244390Srwatson} # func_xform may be replaced by extended shell implementation
887244390Srwatson
888244390Srwatson
889244390Srwatson# func_fatal_configuration arg...
890244390Srwatson# Echo program name prefixed message to standard error, followed by
891244390Srwatson# a configuration failure hint, and exit.
892244390Srwatsonfunc_fatal_configuration ()
893244390Srwatson{
894244390Srwatson    func_error ${1+"$@"}
895244390Srwatson    func_error "See the $PACKAGE documentation for more information."
896244390Srwatson    func_fatal_error "Fatal configuration error."
897244390Srwatson}
898244390Srwatson
899244390Srwatson
900244390Srwatson# func_config
901244390Srwatson# Display the configuration for all the tags in this script.
902244390Srwatsonfunc_config ()
903244390Srwatson{
904244390Srwatson    re_begincf='^# ### BEGIN LIBTOOL'
905244390Srwatson    re_endcf='^# ### END LIBTOOL'
906244390Srwatson
907244390Srwatson    # Default configuration.
908244390Srwatson    $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
909244390Srwatson
910244390Srwatson    # Now print the configurations for the tags.
911244390Srwatson    for tagname in $taglist; do
912244390Srwatson      $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
913244390Srwatson    done
914244390Srwatson
915244390Srwatson    exit $?
916244390Srwatson}
917244390Srwatson
918244390Srwatson# func_features
919244390Srwatson# Display the features supported by this script.
920244390Srwatsonfunc_features ()
921244390Srwatson{
922244390Srwatson    echo "host: $host"
923244390Srwatson    if test "$build_libtool_libs" = yes; then
924244390Srwatson      echo "enable shared libraries"
925244390Srwatson    else
926244390Srwatson      echo "disable shared libraries"
927244390Srwatson    fi
928244390Srwatson    if test "$build_old_libs" = yes; then
929244390Srwatson      echo "enable static libraries"
930244390Srwatson    else
931244390Srwatson      echo "disable static libraries"
932244390Srwatson    fi
933244390Srwatson
934244390Srwatson    exit $?
935244390Srwatson}
936244390Srwatson
937244390Srwatson# func_enable_tag tagname
938244390Srwatson# Verify that TAGNAME is valid, and either flag an error and exit, or
939244390Srwatson# enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
940244390Srwatson# variable here.
941244390Srwatsonfunc_enable_tag ()
942244390Srwatson{
943244390Srwatson  # Global variable:
944244390Srwatson  tagname="$1"
945244390Srwatson
946244390Srwatson  re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
947244390Srwatson  re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
948244390Srwatson  sed_extractcf="/$re_begincf/,/$re_endcf/p"
949244390Srwatson
950244390Srwatson  # Validate tagname.
951244390Srwatson  case $tagname in
952244390Srwatson    *[!-_A-Za-z0-9,/]*)
953244390Srwatson      func_fatal_error "invalid tag name: $tagname"
954156283Srwatson      ;;
955244390Srwatson  esac
956244390Srwatson
957244390Srwatson  # Don't test for the "default" C tag, as we know it's
958244390Srwatson  # there but not specially marked.
959244390Srwatson  case $tagname in
960244390Srwatson    CC) ;;
961244390Srwatson    *)
962244390Srwatson      if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
963244390Srwatson	taglist="$taglist $tagname"
964244390Srwatson
965244390Srwatson	# Evaluate the configuration.  Be careful to quote the path
966244390Srwatson	# and the sed script, to avoid splitting on whitespace, but
967244390Srwatson	# also don't use non-portable quotes within backquotes within
968244390Srwatson	# quotes we have to do it in 2 steps:
969244390Srwatson	extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
970244390Srwatson	eval "$extractedcf"
971244390Srwatson      else
972244390Srwatson	func_error "ignoring unknown tag $tagname"
973244390Srwatson      fi
974244390Srwatson      ;;
975244390Srwatson  esac
976244390Srwatson}
977244390Srwatson
978244390Srwatson# func_check_version_match
979244390Srwatson# Ensure that we are using m4 macros, and libtool script from the same
980244390Srwatson# release of libtool.
981244390Srwatsonfunc_check_version_match ()
982244390Srwatson{
983244390Srwatson  if test "$package_revision" != "$macro_revision"; then
984244390Srwatson    if test "$VERSION" != "$macro_version"; then
985244390Srwatson      if test -z "$macro_version"; then
986244390Srwatson        cat >&2 <<_LT_EOF
987244390Srwatson$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
988244390Srwatson$progname: definition of this LT_INIT comes from an older release.
989244390Srwatson$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
990244390Srwatson$progname: and run autoconf again.
991244390Srwatson_LT_EOF
992244390Srwatson      else
993244390Srwatson        cat >&2 <<_LT_EOF
994244390Srwatson$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
995244390Srwatson$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
996244390Srwatson$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
997244390Srwatson$progname: and run autoconf again.
998244390Srwatson_LT_EOF
999244390Srwatson      fi
1000244390Srwatson    else
1001244390Srwatson      cat >&2 <<_LT_EOF
1002244390Srwatson$progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
1003244390Srwatson$progname: but the definition of this LT_INIT comes from revision $macro_revision.
1004244390Srwatson$progname: You should recreate aclocal.m4 with macros from revision $package_revision
1005244390Srwatson$progname: of $PACKAGE $VERSION and run autoconf again.
1006244390Srwatson_LT_EOF
1007244390Srwatson    fi
1008244390Srwatson
1009244390Srwatson    exit $EXIT_MISMATCH
1010244390Srwatson  fi
1011244390Srwatson}
1012244390Srwatson
1013244390Srwatson
1014244390Srwatson# Shorthand for --mode=foo, only valid as the first argument
1015244390Srwatsoncase $1 in
1016244390Srwatsonclean|clea|cle|cl)
1017244390Srwatson  shift; set dummy --mode clean ${1+"$@"}; shift
1018244390Srwatson  ;;
1019244390Srwatsoncompile|compil|compi|comp|com|co|c)
1020244390Srwatson  shift; set dummy --mode compile ${1+"$@"}; shift
1021244390Srwatson  ;;
1022244390Srwatsonexecute|execut|execu|exec|exe|ex|e)
1023244390Srwatson  shift; set dummy --mode execute ${1+"$@"}; shift
1024244390Srwatson  ;;
1025244390Srwatsonfinish|finis|fini|fin|fi|f)
1026244390Srwatson  shift; set dummy --mode finish ${1+"$@"}; shift
1027244390Srwatson  ;;
1028244390Srwatsoninstall|instal|insta|inst|ins|in|i)
1029244390Srwatson  shift; set dummy --mode install ${1+"$@"}; shift
1030244390Srwatson  ;;
1031244390Srwatsonlink|lin|li|l)
1032244390Srwatson  shift; set dummy --mode link ${1+"$@"}; shift
1033244390Srwatson  ;;
1034244390Srwatsonuninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
1035244390Srwatson  shift; set dummy --mode uninstall ${1+"$@"}; shift
1036244390Srwatson  ;;
1037244390Srwatsonesac
1038244390Srwatson
1039244390Srwatson
1040244390Srwatson
1041244390Srwatson# Option defaults:
1042244390Srwatsonopt_debug=:
1043244390Srwatsonopt_dry_run=false
1044244390Srwatsonopt_config=false
1045244390Srwatsonopt_preserve_dup_deps=false
1046244390Srwatsonopt_features=false
1047244390Srwatsonopt_finish=false
1048244390Srwatsonopt_help=false
1049244390Srwatsonopt_help_all=false
1050244390Srwatsonopt_silent=:
1051244390Srwatsonopt_warning=:
1052244390Srwatsonopt_verbose=:
1053244390Srwatsonopt_silent=false
1054244390Srwatsonopt_verbose=false
1055244390Srwatson
1056244390Srwatson
1057244390Srwatson# Parse options once, thoroughly.  This comes as soon as possible in the
1058244390Srwatson# script to make things like `--version' happen as quickly as we can.
1059244390Srwatson{
1060244390Srwatson  # this just eases exit handling
1061244390Srwatson  while test $# -gt 0; do
1062244390Srwatson    opt="$1"
1063244390Srwatson    shift
1064244390Srwatson    case $opt in
1065244390Srwatson      --debug|-x)	opt_debug='set -x'
1066244390Srwatson			func_echo "enabling shell trace mode"
1067244390Srwatson			$opt_debug
1068244390Srwatson			;;
1069244390Srwatson      --dry-run|--dryrun|-n)
1070244390Srwatson			opt_dry_run=:
1071244390Srwatson			;;
1072244390Srwatson      --config)
1073244390Srwatson			opt_config=:
1074244390Srwatsonfunc_config
1075244390Srwatson			;;
1076244390Srwatson      --dlopen|-dlopen)
1077244390Srwatson			optarg="$1"
1078244390Srwatson			opt_dlopen="${opt_dlopen+$opt_dlopen
1079244390Srwatson}$optarg"
1080244390Srwatson			shift
1081244390Srwatson			;;
1082244390Srwatson      --preserve-dup-deps)
1083244390Srwatson			opt_preserve_dup_deps=:
1084244390Srwatson			;;
1085244390Srwatson      --features)
1086244390Srwatson			opt_features=:
1087244390Srwatsonfunc_features
1088244390Srwatson			;;
1089244390Srwatson      --finish)
1090244390Srwatson			opt_finish=:
1091244390Srwatsonset dummy --mode finish ${1+"$@"}; shift
1092244390Srwatson			;;
1093244390Srwatson      --help)
1094244390Srwatson			opt_help=:
1095244390Srwatson			;;
1096244390Srwatson      --help-all)
1097244390Srwatson			opt_help_all=:
1098244390Srwatsonopt_help=': help-all'
1099244390Srwatson			;;
1100244390Srwatson      --mode)
1101244390Srwatson			test $# = 0 && func_missing_arg $opt && break
1102244390Srwatson			optarg="$1"
1103244390Srwatson			opt_mode="$optarg"
1104244390Srwatsoncase $optarg in
1105244390Srwatson  # Valid mode arguments:
1106244390Srwatson  clean|compile|execute|finish|install|link|relink|uninstall) ;;
1107244390Srwatson
1108244390Srwatson  # Catch anything else as an error
1109244390Srwatson  *) func_error "invalid argument for $opt"
1110244390Srwatson     exit_cmd=exit
1111244390Srwatson     break
1112244390Srwatson     ;;
1113244390Srwatsonesac
1114244390Srwatson			shift
1115244390Srwatson			;;
1116244390Srwatson      --no-silent|--no-quiet)
1117244390Srwatson			opt_silent=false
1118244390Srwatsonfunc_append preserve_args " $opt"
1119244390Srwatson			;;
1120244390Srwatson      --no-warning|--no-warn)
1121244390Srwatson			opt_warning=false
1122244390Srwatsonfunc_append preserve_args " $opt"
1123244390Srwatson			;;
1124244390Srwatson      --no-verbose)
1125244390Srwatson			opt_verbose=false
1126244390Srwatsonfunc_append preserve_args " $opt"
1127244390Srwatson			;;
1128244390Srwatson      --silent|--quiet)
1129244390Srwatson			opt_silent=:
1130244390Srwatsonfunc_append preserve_args " $opt"
1131244390Srwatson        opt_verbose=false
1132244390Srwatson			;;
1133244390Srwatson      --verbose|-v)
1134244390Srwatson			opt_verbose=:
1135244390Srwatsonfunc_append preserve_args " $opt"
1136244390Srwatsonopt_silent=false
1137244390Srwatson			;;
1138244390Srwatson      --tag)
1139244390Srwatson			test $# = 0 && func_missing_arg $opt && break
1140244390Srwatson			optarg="$1"
1141244390Srwatson			opt_tag="$optarg"
1142244390Srwatsonfunc_append preserve_args " $opt $optarg"
1143244390Srwatsonfunc_enable_tag "$optarg"
1144244390Srwatson			shift
1145244390Srwatson			;;
1146244390Srwatson
1147244390Srwatson      -\?|-h)		func_usage				;;
1148244390Srwatson      --help)		func_help				;;
1149244390Srwatson      --version)	func_version				;;
1150244390Srwatson
1151244390Srwatson      # Separate optargs to long options:
1152244390Srwatson      --*=*)
1153244390Srwatson			func_split_long_opt "$opt"
1154244390Srwatson			set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"}
1155244390Srwatson			shift
1156244390Srwatson			;;
1157244390Srwatson
1158244390Srwatson      # Separate non-argument short options:
1159244390Srwatson      -\?*|-h*|-n*|-v*)
1160244390Srwatson			func_split_short_opt "$opt"
1161244390Srwatson			set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"}
1162244390Srwatson			shift
1163244390Srwatson			;;
1164244390Srwatson
1165244390Srwatson      --)		break					;;
1166244390Srwatson      -*)		func_fatal_help "unrecognized option \`$opt'" ;;
1167244390Srwatson      *)		set dummy "$opt" ${1+"$@"};	shift; break  ;;
1168156283Srwatson    esac
1169244390Srwatson  done
1170244390Srwatson
1171244390Srwatson  # Validate options:
1172244390Srwatson
1173244390Srwatson  # save first non-option argument
1174244390Srwatson  if test "$#" -gt 0; then
1175244390Srwatson    nonopt="$opt"
1176244390Srwatson    shift
1177244390Srwatson  fi
1178244390Srwatson
1179244390Srwatson  # preserve --debug
1180244390Srwatson  test "$opt_debug" = : || func_append preserve_args " --debug"
1181244390Srwatson
1182244390Srwatson  case $host in
1183244390Srwatson    *cygwin* | *mingw* | *pw32* | *cegcc*)
1184244390Srwatson      # don't eliminate duplications in $postdeps and $predeps
1185244390Srwatson      opt_duplicate_compiler_generated_deps=:
1186244390Srwatson      ;;
1187244390Srwatson    *)
1188244390Srwatson      opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
1189244390Srwatson      ;;
1190244390Srwatson  esac
1191244390Srwatson
1192244390Srwatson  $opt_help || {
1193244390Srwatson    # Sanity checks first:
1194244390Srwatson    func_check_version_match
1195244390Srwatson
1196244390Srwatson    if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
1197244390Srwatson      func_fatal_configuration "not configured to build any kind of library"
1198244390Srwatson    fi
1199244390Srwatson
1200244390Srwatson    # Darwin sucks
1201244390Srwatson    eval std_shrext=\"$shrext_cmds\"
1202244390Srwatson
1203244390Srwatson    # Only execute mode is allowed to have -dlopen flags.
1204244390Srwatson    if test -n "$opt_dlopen" && test "$opt_mode" != execute; then
1205244390Srwatson      func_error "unrecognized option \`-dlopen'"
1206244390Srwatson      $ECHO "$help" 1>&2
1207244390Srwatson      exit $EXIT_FAILURE
1208244390Srwatson    fi
1209244390Srwatson
1210244390Srwatson    # Change the help message to a mode-specific one.
1211244390Srwatson    generic_help="$help"
1212244390Srwatson    help="Try \`$progname --help --mode=$opt_mode' for more information."
1213244390Srwatson  }
1214244390Srwatson
1215244390Srwatson
1216244390Srwatson  # Bail if the options were screwed
1217244390Srwatson  $exit_cmd $EXIT_FAILURE
1218244390Srwatson}
1219244390Srwatson
1220244390Srwatson
1221244390Srwatson
1222244390Srwatson
1223244390Srwatson## ----------- ##
1224244390Srwatson##    Main.    ##
1225244390Srwatson## ----------- ##
1226244390Srwatson
1227244390Srwatson# func_lalib_p file
1228244390Srwatson# True iff FILE is a libtool `.la' library or `.lo' object file.
1229244390Srwatson# This function is only a basic sanity check; it will hardly flush out
1230244390Srwatson# determined imposters.
1231244390Srwatsonfunc_lalib_p ()
1232244390Srwatson{
1233244390Srwatson    test -f "$1" &&
1234244390Srwatson      $SED -e 4q "$1" 2>/dev/null \
1235244390Srwatson        | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
1236244390Srwatson}
1237244390Srwatson
1238244390Srwatson# func_lalib_unsafe_p file
1239244390Srwatson# True iff FILE is a libtool `.la' library or `.lo' object file.
1240244390Srwatson# This function implements the same check as func_lalib_p without
1241244390Srwatson# resorting to external programs.  To this end, it redirects stdin and
1242244390Srwatson# closes it afterwards, without saving the original file descriptor.
1243244390Srwatson# As a safety measure, use it only where a negative result would be
1244244390Srwatson# fatal anyway.  Works if `file' does not exist.
1245244390Srwatsonfunc_lalib_unsafe_p ()
1246244390Srwatson{
1247244390Srwatson    lalib_p=no
1248244390Srwatson    if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
1249244390Srwatson	for lalib_p_l in 1 2 3 4
1250244390Srwatson	do
1251244390Srwatson	    read lalib_p_line
1252244390Srwatson	    case "$lalib_p_line" in
1253244390Srwatson		\#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
1254244390Srwatson	    esac
1255244390Srwatson	done
1256244390Srwatson	exec 0<&5 5<&-
1257244390Srwatson    fi
1258244390Srwatson    test "$lalib_p" = yes
1259244390Srwatson}
1260244390Srwatson
1261244390Srwatson# func_ltwrapper_script_p file
1262244390Srwatson# True iff FILE is a libtool wrapper script
1263244390Srwatson# This function is only a basic sanity check; it will hardly flush out
1264244390Srwatson# determined imposters.
1265244390Srwatsonfunc_ltwrapper_script_p ()
1266244390Srwatson{
1267244390Srwatson    func_lalib_p "$1"
1268244390Srwatson}
1269244390Srwatson
1270244390Srwatson# func_ltwrapper_executable_p file
1271244390Srwatson# True iff FILE is a libtool wrapper executable
1272244390Srwatson# This function is only a basic sanity check; it will hardly flush out
1273244390Srwatson# determined imposters.
1274244390Srwatsonfunc_ltwrapper_executable_p ()
1275244390Srwatson{
1276244390Srwatson    func_ltwrapper_exec_suffix=
1277244390Srwatson    case $1 in
1278244390Srwatson    *.exe) ;;
1279244390Srwatson    *) func_ltwrapper_exec_suffix=.exe ;;
1280244390Srwatson    esac
1281244390Srwatson    $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
1282244390Srwatson}
1283244390Srwatson
1284244390Srwatson# func_ltwrapper_scriptname file
1285244390Srwatson# Assumes file is an ltwrapper_executable
1286244390Srwatson# uses $file to determine the appropriate filename for a
1287244390Srwatson# temporary ltwrapper_script.
1288244390Srwatsonfunc_ltwrapper_scriptname ()
1289244390Srwatson{
1290244390Srwatson    func_dirname_and_basename "$1" "" "."
1291244390Srwatson    func_stripname '' '.exe' "$func_basename_result"
1292244390Srwatson    func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper"
1293244390Srwatson}
1294244390Srwatson
1295244390Srwatson# func_ltwrapper_p file
1296244390Srwatson# True iff FILE is a libtool wrapper script or wrapper executable
1297244390Srwatson# This function is only a basic sanity check; it will hardly flush out
1298244390Srwatson# determined imposters.
1299244390Srwatsonfunc_ltwrapper_p ()
1300244390Srwatson{
1301244390Srwatson    func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
1302244390Srwatson}
1303244390Srwatson
1304244390Srwatson
1305244390Srwatson# func_execute_cmds commands fail_cmd
1306244390Srwatson# Execute tilde-delimited COMMANDS.
1307244390Srwatson# If FAIL_CMD is given, eval that upon failure.
1308244390Srwatson# FAIL_CMD may read-access the current command in variable CMD!
1309244390Srwatsonfunc_execute_cmds ()
1310244390Srwatson{
1311244390Srwatson    $opt_debug
1312244390Srwatson    save_ifs=$IFS; IFS='~'
1313244390Srwatson    for cmd in $1; do
1314244390Srwatson      IFS=$save_ifs
1315244390Srwatson      eval cmd=\"$cmd\"
1316244390Srwatson      func_show_eval "$cmd" "${2-:}"
1317244390Srwatson    done
1318244390Srwatson    IFS=$save_ifs
1319244390Srwatson}
1320244390Srwatson
1321244390Srwatson
1322244390Srwatson# func_source file
1323244390Srwatson# Source FILE, adding directory component if necessary.
1324244390Srwatson# Note that it is not necessary on cygwin/mingw to append a dot to
1325244390Srwatson# FILE even if both FILE and FILE.exe exist: automatic-append-.exe
1326244390Srwatson# behavior happens only for exec(3), not for open(2)!  Also, sourcing
1327244390Srwatson# `FILE.' does not work on cygwin managed mounts.
1328244390Srwatsonfunc_source ()
1329244390Srwatson{
1330244390Srwatson    $opt_debug
1331244390Srwatson    case $1 in
1332244390Srwatson    */* | *\\*)	. "$1" ;;
1333244390Srwatson    *)		. "./$1" ;;
1334244390Srwatson    esac
1335244390Srwatson}
1336244390Srwatson
1337244390Srwatson
1338244390Srwatson# func_resolve_sysroot PATH
1339244390Srwatson# Replace a leading = in PATH with a sysroot.  Store the result into
1340244390Srwatson# func_resolve_sysroot_result
1341244390Srwatsonfunc_resolve_sysroot ()
1342244390Srwatson{
1343244390Srwatson  func_resolve_sysroot_result=$1
1344244390Srwatson  case $func_resolve_sysroot_result in
1345244390Srwatson  =*)
1346244390Srwatson    func_stripname '=' '' "$func_resolve_sysroot_result"
1347244390Srwatson    func_resolve_sysroot_result=$lt_sysroot$func_stripname_result
1348156283Srwatson    ;;
1349156283Srwatson  esac
1350156283Srwatson}
1351156283Srwatson
1352244390Srwatson# func_replace_sysroot PATH
1353244390Srwatson# If PATH begins with the sysroot, replace it with = and
1354244390Srwatson# store the result into func_replace_sysroot_result.
1355244390Srwatsonfunc_replace_sysroot ()
1356244390Srwatson{
1357244390Srwatson  case "$lt_sysroot:$1" in
1358244390Srwatson  ?*:"$lt_sysroot"*)
1359244390Srwatson    func_stripname "$lt_sysroot" '' "$1"
1360244390Srwatson    func_replace_sysroot_result="=$func_stripname_result"
1361244390Srwatson    ;;
1362244390Srwatson  *)
1363244390Srwatson    # Including no sysroot.
1364244390Srwatson    func_replace_sysroot_result=$1
1365244390Srwatson    ;;
1366244390Srwatson  esac
1367244390Srwatson}
1368156283Srwatson
1369156283Srwatson# func_infer_tag arg
1370156283Srwatson# Infer tagged configuration to use if any are available and
1371156283Srwatson# if one wasn't chosen via the "--tag" command line option.
1372156283Srwatson# Only attempt this if the compiler in the base compile
1373156283Srwatson# command doesn't match the default compiler.
1374156283Srwatson# arg is usually of the form 'gcc ...'
1375156283Srwatsonfunc_infer_tag ()
1376156283Srwatson{
1377244390Srwatson    $opt_debug
1378244390Srwatson
1379159985Srwatson    # FreeBSD-specific: where we install compilers with non-standard names
1380244390Srwatson    tag_compilers_CC="*cc cc* *gcc gcc* clang"
1381244390Srwatson    tag_compilers_CXX="*c++ c++* *g++ g++* clang++"
1382159985Srwatson    base_compiler=`set -- "$@"; echo $1`
1383159985Srwatson
1384159985Srwatson    # If $tagname isn't set, then try to infer if the default "CC" tag applies
1385159985Srwatson    if test -z "$tagname"; then
1386159985Srwatson      for zp in $tag_compilers_CC; do
1387159985Srwatson        case $base_compiler in
1388159985Srwatson	 $zp) tagname="CC"; break;;
1389159985Srwatson	esac
1390159985Srwatson      done
1391159985Srwatson    fi
1392159985Srwatson
1393156283Srwatson    if test -n "$available_tags" && test -z "$tagname"; then
1394156283Srwatson      CC_quoted=
1395156283Srwatson      for arg in $CC; do
1396244390Srwatson	func_append_quoted CC_quoted "$arg"
1397156283Srwatson      done
1398244390Srwatson      CC_expanded=`func_echo_all $CC`
1399244390Srwatson      CC_quoted_expanded=`func_echo_all $CC_quoted`
1400156283Srwatson      case $@ in
1401156283Srwatson      # Blanks in the command may have been stripped by the calling shell,
1402156283Srwatson      # but not from the CC environment variable when configure was run.
1403244390Srwatson      " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
1404244390Srwatson      " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
1405156283Srwatson      # Blanks at the start of $base_compile will cause this to fail
1406156283Srwatson      # if we don't check for them as well.
1407156283Srwatson      *)
1408156283Srwatson	for z in $available_tags; do
1409244390Srwatson	  if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
1410156283Srwatson	    # Evaluate the configuration.
1411156283Srwatson	    eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
1412156283Srwatson	    CC_quoted=
1413156283Srwatson	    for arg in $CC; do
1414244390Srwatson	      # Double-quote args containing other shell metacharacters.
1415244390Srwatson	      func_append_quoted CC_quoted "$arg"
1416244390Srwatson	    done
1417244390Srwatson	    CC_expanded=`func_echo_all $CC`
1418244390Srwatson	    CC_quoted_expanded=`func_echo_all $CC_quoted`
1419156283Srwatson	    case "$@ " in
1420244390Srwatson	    " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
1421244390Srwatson	    " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
1422156283Srwatson	      # The compiler in the base compile command matches
1423156283Srwatson	      # the one in the tagged configuration.
1424156283Srwatson	      # Assume this is the tagged configuration we want.
1425156283Srwatson	      tagname=$z
1426156283Srwatson	      break
1427156283Srwatson	      ;;
1428156283Srwatson	    esac
1429159985Srwatson
1430159985Srwatson	    # FreeBSD-specific: try compilers based on inferred tag
1431159985Srwatson	    if test -z "$tagname"; then
1432159985Srwatson	      eval "tag_compilers=\$tag_compilers_${z}"
1433159985Srwatson	      if test -n "$tag_compilers"; then
1434159985Srwatson		for zp in $tag_compilers; do
1435159985Srwatson		  case $base_compiler in   
1436159985Srwatson		    $zp) tagname=$z; break;;
1437159985Srwatson		  esac
1438159985Srwatson		done
1439159985Srwatson		if test -n "$tagname"; then
1440159985Srwatson		  break
1441159985Srwatson		fi
1442159985Srwatson	      fi
1443159985Srwatson            fi
1444159985Srwatson          fi
1445156283Srwatson	done
1446156283Srwatson	# If $tagname still isn't set, then no tagged configuration
1447156283Srwatson	# was found and let the user know that the "--tag" command
1448156283Srwatson	# line option must be used.
1449156283Srwatson	if test -z "$tagname"; then
1450244390Srwatson	  func_echo "unable to infer tagged configuration"
1451244390Srwatson	  func_fatal_error "specify a tag with \`--tag'"
1452244390Srwatson#	else
1453244390Srwatson#	  func_verbose "using $tagname tagged configuration"
1454156283Srwatson	fi
1455156283Srwatson	;;
1456156283Srwatson      esac
1457156283Srwatson    fi
1458156283Srwatson}
1459156283Srwatson
1460156283Srwatson
1461244390Srwatson
1462244390Srwatson# func_write_libtool_object output_name pic_name nonpic_name
1463244390Srwatson# Create a libtool object file (analogous to a ".la" file),
1464244390Srwatson# but don't create it if we're doing a dry run.
1465244390Srwatsonfunc_write_libtool_object ()
1466156283Srwatson{
1467244390Srwatson    write_libobj=${1}
1468244390Srwatson    if test "$build_libtool_libs" = yes; then
1469244390Srwatson      write_lobj=\'${2}\'
1470244390Srwatson    else
1471244390Srwatson      write_lobj=none
1472244390Srwatson    fi
1473156283Srwatson
1474244390Srwatson    if test "$build_old_libs" = yes; then
1475244390Srwatson      write_oldobj=\'${3}\'
1476156283Srwatson    else
1477244390Srwatson      write_oldobj=none
1478156283Srwatson    fi
1479244390Srwatson
1480244390Srwatson    $opt_dry_run || {
1481244390Srwatson      cat >${write_libobj}T <<EOF
1482244390Srwatson# $write_libobj - a libtool object file
1483244390Srwatson# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
1484244390Srwatson#
1485244390Srwatson# Please DO NOT delete this file!
1486244390Srwatson# It is necessary for linking the library.
1487244390Srwatson
1488244390Srwatson# Name of the PIC object.
1489244390Srwatsonpic_object=$write_lobj
1490244390Srwatson
1491244390Srwatson# Name of the non-PIC object
1492244390Srwatsonnon_pic_object=$write_oldobj
1493244390Srwatson
1494244390SrwatsonEOF
1495244390Srwatson      $MV "${write_libobj}T" "${write_libobj}"
1496244390Srwatson    }
1497156283Srwatson}
1498156283Srwatson
1499244390Srwatson
1500244390Srwatson##################################################
1501244390Srwatson# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS #
1502244390Srwatson##################################################
1503244390Srwatson
1504244390Srwatson# func_convert_core_file_wine_to_w32 ARG
1505244390Srwatson# Helper function used by file name conversion functions when $build is *nix,
1506244390Srwatson# and $host is mingw, cygwin, or some other w32 environment. Relies on a
1507244390Srwatson# correctly configured wine environment available, with the winepath program
1508244390Srwatson# in $build's $PATH.
1509244390Srwatson#
1510244390Srwatson# ARG is the $build file name to be converted to w32 format.
1511244390Srwatson# Result is available in $func_convert_core_file_wine_to_w32_result, and will
1512244390Srwatson# be empty on error (or when ARG is empty)
1513244390Srwatsonfunc_convert_core_file_wine_to_w32 ()
1514156283Srwatson{
1515244390Srwatson  $opt_debug
1516244390Srwatson  func_convert_core_file_wine_to_w32_result="$1"
1517244390Srwatson  if test -n "$1"; then
1518244390Srwatson    # Unfortunately, winepath does not exit with a non-zero error code, so we
1519244390Srwatson    # are forced to check the contents of stdout. On the other hand, if the
1520244390Srwatson    # command is not found, the shell will set an exit code of 127 and print
1521244390Srwatson    # *an error message* to stdout. So we must check for both error code of
1522244390Srwatson    # zero AND non-empty stdout, which explains the odd construction:
1523244390Srwatson    func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
1524244390Srwatson    if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then
1525244390Srwatson      func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
1526244390Srwatson        $SED -e "$lt_sed_naive_backslashify"`
1527244390Srwatson    else
1528244390Srwatson      func_convert_core_file_wine_to_w32_result=
1529156283Srwatson    fi
1530244390Srwatson  fi
1531244390Srwatson}
1532244390Srwatson# end: func_convert_core_file_wine_to_w32
1533156283Srwatson
1534156283Srwatson
1535244390Srwatson# func_convert_core_path_wine_to_w32 ARG
1536244390Srwatson# Helper function used by path conversion functions when $build is *nix, and
1537244390Srwatson# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly
1538244390Srwatson# configured wine environment available, with the winepath program in $build's
1539244390Srwatson# $PATH. Assumes ARG has no leading or trailing path separator characters.
1540244390Srwatson#
1541244390Srwatson# ARG is path to be converted from $build format to win32.
1542244390Srwatson# Result is available in $func_convert_core_path_wine_to_w32_result.
1543244390Srwatson# Unconvertible file (directory) names in ARG are skipped; if no directory names
1544244390Srwatson# are convertible, then the result may be empty.
1545244390Srwatsonfunc_convert_core_path_wine_to_w32 ()
1546244390Srwatson{
1547244390Srwatson  $opt_debug
1548244390Srwatson  # unfortunately, winepath doesn't convert paths, only file names
1549244390Srwatson  func_convert_core_path_wine_to_w32_result=""
1550244390Srwatson  if test -n "$1"; then
1551244390Srwatson    oldIFS=$IFS
1552244390Srwatson    IFS=:
1553244390Srwatson    for func_convert_core_path_wine_to_w32_f in $1; do
1554244390Srwatson      IFS=$oldIFS
1555244390Srwatson      func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
1556244390Srwatson      if test -n "$func_convert_core_file_wine_to_w32_result" ; then
1557244390Srwatson        if test -z "$func_convert_core_path_wine_to_w32_result"; then
1558244390Srwatson          func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result"
1559244390Srwatson        else
1560244390Srwatson          func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
1561244390Srwatson        fi
1562156283Srwatson      fi
1563156283Srwatson    done
1564244390Srwatson    IFS=$oldIFS
1565244390Srwatson  fi
1566156283Srwatson}
1567244390Srwatson# end: func_convert_core_path_wine_to_w32
1568156283Srwatson
1569156283Srwatson
1570244390Srwatson# func_cygpath ARGS...
1571244390Srwatson# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when
1572244390Srwatson# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2)
1573244390Srwatson# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or
1574244390Srwatson# (2), returns the Cygwin file name or path in func_cygpath_result (input
1575244390Srwatson# file name or path is assumed to be in w32 format, as previously converted
1576244390Srwatson# from $build's *nix or MSYS format). In case (3), returns the w32 file name
1577244390Srwatson# or path in func_cygpath_result (input file name or path is assumed to be in
1578244390Srwatson# Cygwin format). Returns an empty string on error.
1579244390Srwatson#
1580244390Srwatson# ARGS are passed to cygpath, with the last one being the file name or path to
1581244390Srwatson# be converted.
1582244390Srwatson#
1583244390Srwatson# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH
1584244390Srwatson# environment variable; do not put it in $PATH.
1585244390Srwatsonfunc_cygpath ()
1586244390Srwatson{
1587244390Srwatson  $opt_debug
1588244390Srwatson  if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
1589244390Srwatson    func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
1590244390Srwatson    if test "$?" -ne 0; then
1591244390Srwatson      # on failure, ensure result is empty
1592244390Srwatson      func_cygpath_result=
1593244390Srwatson    fi
1594244390Srwatson  else
1595244390Srwatson    func_cygpath_result=
1596244390Srwatson    func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'"
1597244390Srwatson  fi
1598244390Srwatson}
1599244390Srwatson#end: func_cygpath
1600159985Srwatson
1601156283Srwatson
1602244390Srwatson# func_convert_core_msys_to_w32 ARG
1603244390Srwatson# Convert file name or path ARG from MSYS format to w32 format.  Return
1604244390Srwatson# result in func_convert_core_msys_to_w32_result.
1605244390Srwatsonfunc_convert_core_msys_to_w32 ()
1606244390Srwatson{
1607244390Srwatson  $opt_debug
1608244390Srwatson  # awkward: cmd appends spaces to result
1609244390Srwatson  func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
1610244390Srwatson    $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"`
1611244390Srwatson}
1612244390Srwatson#end: func_convert_core_msys_to_w32
1613244390Srwatson
1614244390Srwatson
1615244390Srwatson# func_convert_file_check ARG1 ARG2
1616244390Srwatson# Verify that ARG1 (a file name in $build format) was converted to $host
1617244390Srwatson# format in ARG2. Otherwise, emit an error message, but continue (resetting
1618244390Srwatson# func_to_host_file_result to ARG1).
1619244390Srwatsonfunc_convert_file_check ()
1620244390Srwatson{
1621244390Srwatson  $opt_debug
1622244390Srwatson  if test -z "$2" && test -n "$1" ; then
1623244390Srwatson    func_error "Could not determine host file name corresponding to"
1624244390Srwatson    func_error "  \`$1'"
1625244390Srwatson    func_error "Continuing, but uninstalled executables may not work."
1626244390Srwatson    # Fallback:
1627244390Srwatson    func_to_host_file_result="$1"
1628244390Srwatson  fi
1629244390Srwatson}
1630244390Srwatson# end func_convert_file_check
1631244390Srwatson
1632244390Srwatson
1633244390Srwatson# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH
1634244390Srwatson# Verify that FROM_PATH (a path in $build format) was converted to $host
1635244390Srwatson# format in TO_PATH. Otherwise, emit an error message, but continue, resetting
1636244390Srwatson# func_to_host_file_result to a simplistic fallback value (see below).
1637244390Srwatsonfunc_convert_path_check ()
1638244390Srwatson{
1639244390Srwatson  $opt_debug
1640244390Srwatson  if test -z "$4" && test -n "$3"; then
1641244390Srwatson    func_error "Could not determine the host path corresponding to"
1642244390Srwatson    func_error "  \`$3'"
1643244390Srwatson    func_error "Continuing, but uninstalled executables may not work."
1644244390Srwatson    # Fallback.  This is a deliberately simplistic "conversion" and
1645244390Srwatson    # should not be "improved".  See libtool.info.
1646244390Srwatson    if test "x$1" != "x$2"; then
1647244390Srwatson      lt_replace_pathsep_chars="s|$1|$2|g"
1648244390Srwatson      func_to_host_path_result=`echo "$3" |
1649244390Srwatson        $SED -e "$lt_replace_pathsep_chars"`
1650244390Srwatson    else
1651244390Srwatson      func_to_host_path_result="$3"
1652244390Srwatson    fi
1653244390Srwatson  fi
1654244390Srwatson}
1655244390Srwatson# end func_convert_path_check
1656244390Srwatson
1657244390Srwatson
1658244390Srwatson# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG
1659244390Srwatson# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT
1660244390Srwatson# and appending REPL if ORIG matches BACKPAT.
1661244390Srwatsonfunc_convert_path_front_back_pathsep ()
1662244390Srwatson{
1663244390Srwatson  $opt_debug
1664244390Srwatson  case $4 in
1665244390Srwatson  $1 ) func_to_host_path_result="$3$func_to_host_path_result"
1666244390Srwatson    ;;
1667156283Srwatson  esac
1668244390Srwatson  case $4 in
1669244390Srwatson  $2 ) func_append func_to_host_path_result "$3"
1670244390Srwatson    ;;
1671244390Srwatson  esac
1672244390Srwatson}
1673244390Srwatson# end func_convert_path_front_back_pathsep
1674156283Srwatson
1675156283Srwatson
1676244390Srwatson##################################################
1677244390Srwatson# $build to $host FILE NAME CONVERSION FUNCTIONS #
1678244390Srwatson##################################################
1679244390Srwatson# invoked via `$to_host_file_cmd ARG'
1680244390Srwatson#
1681244390Srwatson# In each case, ARG is the path to be converted from $build to $host format.
1682244390Srwatson# Result will be available in $func_to_host_file_result.
1683156283Srwatson
1684244390Srwatson
1685244390Srwatson# func_to_host_file ARG
1686244390Srwatson# Converts the file name ARG from $build format to $host format. Return result
1687244390Srwatson# in func_to_host_file_result.
1688244390Srwatsonfunc_to_host_file ()
1689244390Srwatson{
1690244390Srwatson  $opt_debug
1691244390Srwatson  $to_host_file_cmd "$1"
1692244390Srwatson}
1693244390Srwatson# end func_to_host_file
1694244390Srwatson
1695244390Srwatson
1696244390Srwatson# func_to_tool_file ARG LAZY
1697244390Srwatson# converts the file name ARG from $build format to toolchain format. Return
1698244390Srwatson# result in func_to_tool_file_result.  If the conversion in use is listed
1699244390Srwatson# in (the comma separated) LAZY, no conversion takes place.
1700244390Srwatsonfunc_to_tool_file ()
1701244390Srwatson{
1702244390Srwatson  $opt_debug
1703244390Srwatson  case ,$2, in
1704244390Srwatson    *,"$to_tool_file_cmd",*)
1705244390Srwatson      func_to_tool_file_result=$1
1706156283Srwatson      ;;
1707156283Srwatson    *)
1708244390Srwatson      $to_tool_file_cmd "$1"
1709244390Srwatson      func_to_tool_file_result=$func_to_host_file_result
1710156283Srwatson      ;;
1711244390Srwatson  esac
1712244390Srwatson}
1713244390Srwatson# end func_to_tool_file
1714156283Srwatson
1715244390Srwatson
1716244390Srwatson# func_convert_file_noop ARG
1717244390Srwatson# Copy ARG to func_to_host_file_result.
1718244390Srwatsonfunc_convert_file_noop ()
1719244390Srwatson{
1720244390Srwatson  func_to_host_file_result="$1"
1721244390Srwatson}
1722244390Srwatson# end func_convert_file_noop
1723244390Srwatson
1724244390Srwatson
1725244390Srwatson# func_convert_file_msys_to_w32 ARG
1726244390Srwatson# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic
1727244390Srwatson# conversion to w32 is not available inside the cwrapper.  Returns result in
1728244390Srwatson# func_to_host_file_result.
1729244390Srwatsonfunc_convert_file_msys_to_w32 ()
1730244390Srwatson{
1731244390Srwatson  $opt_debug
1732244390Srwatson  func_to_host_file_result="$1"
1733244390Srwatson  if test -n "$1"; then
1734244390Srwatson    func_convert_core_msys_to_w32 "$1"
1735244390Srwatson    func_to_host_file_result="$func_convert_core_msys_to_w32_result"
1736156283Srwatson  fi
1737244390Srwatson  func_convert_file_check "$1" "$func_to_host_file_result"
1738244390Srwatson}
1739244390Srwatson# end func_convert_file_msys_to_w32
1740156283Srwatson
1741156283Srwatson
1742244390Srwatson# func_convert_file_cygwin_to_w32 ARG
1743244390Srwatson# Convert file name ARG from Cygwin to w32 format.  Returns result in
1744244390Srwatson# func_to_host_file_result.
1745244390Srwatsonfunc_convert_file_cygwin_to_w32 ()
1746244390Srwatson{
1747244390Srwatson  $opt_debug
1748244390Srwatson  func_to_host_file_result="$1"
1749244390Srwatson  if test -n "$1"; then
1750244390Srwatson    # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
1751244390Srwatson    # LT_CYGPATH in this case.
1752244390Srwatson    func_to_host_file_result=`cygpath -m "$1"`
1753244390Srwatson  fi
1754244390Srwatson  func_convert_file_check "$1" "$func_to_host_file_result"
1755244390Srwatson}
1756244390Srwatson# end func_convert_file_cygwin_to_w32
1757173143Srwatson
1758156283Srwatson
1759244390Srwatson# func_convert_file_nix_to_w32 ARG
1760244390Srwatson# Convert file name ARG from *nix to w32 format.  Requires a wine environment
1761244390Srwatson# and a working winepath. Returns result in func_to_host_file_result.
1762244390Srwatsonfunc_convert_file_nix_to_w32 ()
1763244390Srwatson{
1764244390Srwatson  $opt_debug
1765244390Srwatson  func_to_host_file_result="$1"
1766244390Srwatson  if test -n "$1"; then
1767244390Srwatson    func_convert_core_file_wine_to_w32 "$1"
1768244390Srwatson    func_to_host_file_result="$func_convert_core_file_wine_to_w32_result"
1769244390Srwatson  fi
1770244390Srwatson  func_convert_file_check "$1" "$func_to_host_file_result"
1771244390Srwatson}
1772244390Srwatson# end func_convert_file_nix_to_w32
1773156283Srwatson
1774156283Srwatson
1775244390Srwatson# func_convert_file_msys_to_cygwin ARG
1776244390Srwatson# Convert file name ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
1777244390Srwatson# Returns result in func_to_host_file_result.
1778244390Srwatsonfunc_convert_file_msys_to_cygwin ()
1779244390Srwatson{
1780244390Srwatson  $opt_debug
1781244390Srwatson  func_to_host_file_result="$1"
1782244390Srwatson  if test -n "$1"; then
1783244390Srwatson    func_convert_core_msys_to_w32 "$1"
1784244390Srwatson    func_cygpath -u "$func_convert_core_msys_to_w32_result"
1785244390Srwatson    func_to_host_file_result="$func_cygpath_result"
1786244390Srwatson  fi
1787244390Srwatson  func_convert_file_check "$1" "$func_to_host_file_result"
1788244390Srwatson}
1789244390Srwatson# end func_convert_file_msys_to_cygwin
1790156283Srwatson
1791156283Srwatson
1792244390Srwatson# func_convert_file_nix_to_cygwin ARG
1793244390Srwatson# Convert file name ARG from *nix to Cygwin format.  Requires Cygwin installed
1794244390Srwatson# in a wine environment, working winepath, and LT_CYGPATH set.  Returns result
1795244390Srwatson# in func_to_host_file_result.
1796244390Srwatsonfunc_convert_file_nix_to_cygwin ()
1797244390Srwatson{
1798244390Srwatson  $opt_debug
1799244390Srwatson  func_to_host_file_result="$1"
1800244390Srwatson  if test -n "$1"; then
1801244390Srwatson    # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
1802244390Srwatson    func_convert_core_file_wine_to_w32 "$1"
1803244390Srwatson    func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
1804244390Srwatson    func_to_host_file_result="$func_cygpath_result"
1805244390Srwatson  fi
1806244390Srwatson  func_convert_file_check "$1" "$func_to_host_file_result"
1807244390Srwatson}
1808244390Srwatson# end func_convert_file_nix_to_cygwin
1809156283Srwatson
1810156283Srwatson
1811244390Srwatson#############################################
1812244390Srwatson# $build to $host PATH CONVERSION FUNCTIONS #
1813244390Srwatson#############################################
1814244390Srwatson# invoked via `$to_host_path_cmd ARG'
1815244390Srwatson#
1816244390Srwatson# In each case, ARG is the path to be converted from $build to $host format.
1817244390Srwatson# The result will be available in $func_to_host_path_result.
1818244390Srwatson#
1819244390Srwatson# Path separators are also converted from $build format to $host format.  If
1820244390Srwatson# ARG begins or ends with a path separator character, it is preserved (but
1821244390Srwatson# converted to $host format) on output.
1822244390Srwatson#
1823244390Srwatson# All path conversion functions are named using the following convention:
1824244390Srwatson#   file name conversion function    : func_convert_file_X_to_Y ()
1825244390Srwatson#   path conversion function         : func_convert_path_X_to_Y ()
1826244390Srwatson# where, for any given $build/$host combination the 'X_to_Y' value is the
1827244390Srwatson# same.  If conversion functions are added for new $build/$host combinations,
1828244390Srwatson# the two new functions must follow this pattern, or func_init_to_host_path_cmd
1829244390Srwatson# will break.
1830156283Srwatson
1831156283Srwatson
1832244390Srwatson# func_init_to_host_path_cmd
1833244390Srwatson# Ensures that function "pointer" variable $to_host_path_cmd is set to the
1834244390Srwatson# appropriate value, based on the value of $to_host_file_cmd.
1835244390Srwatsonto_host_path_cmd=
1836244390Srwatsonfunc_init_to_host_path_cmd ()
1837244390Srwatson{
1838244390Srwatson  $opt_debug
1839244390Srwatson  if test -z "$to_host_path_cmd"; then
1840244390Srwatson    func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
1841244390Srwatson    to_host_path_cmd="func_convert_path_${func_stripname_result}"
1842244390Srwatson  fi
1843244390Srwatson}
1844156283Srwatson
1845156283Srwatson
1846244390Srwatson# func_to_host_path ARG
1847244390Srwatson# Converts the path ARG from $build format to $host format. Return result
1848244390Srwatson# in func_to_host_path_result.
1849244390Srwatsonfunc_to_host_path ()
1850244390Srwatson{
1851244390Srwatson  $opt_debug
1852244390Srwatson  func_init_to_host_path_cmd
1853244390Srwatson  $to_host_path_cmd "$1"
1854244390Srwatson}
1855244390Srwatson# end func_to_host_path
1856156283Srwatson
1857156283Srwatson
1858244390Srwatson# func_convert_path_noop ARG
1859244390Srwatson# Copy ARG to func_to_host_path_result.
1860244390Srwatsonfunc_convert_path_noop ()
1861244390Srwatson{
1862244390Srwatson  func_to_host_path_result="$1"
1863244390Srwatson}
1864244390Srwatson# end func_convert_path_noop
1865156283Srwatson
1866159985Srwatson
1867244390Srwatson# func_convert_path_msys_to_w32 ARG
1868244390Srwatson# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic
1869244390Srwatson# conversion to w32 is not available inside the cwrapper.  Returns result in
1870244390Srwatson# func_to_host_path_result.
1871244390Srwatsonfunc_convert_path_msys_to_w32 ()
1872244390Srwatson{
1873244390Srwatson  $opt_debug
1874244390Srwatson  func_to_host_path_result="$1"
1875244390Srwatson  if test -n "$1"; then
1876244390Srwatson    # Remove leading and trailing path separator characters from ARG.  MSYS
1877244390Srwatson    # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
1878244390Srwatson    # and winepath ignores them completely.
1879244390Srwatson    func_stripname : : "$1"
1880244390Srwatson    func_to_host_path_tmp1=$func_stripname_result
1881244390Srwatson    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
1882244390Srwatson    func_to_host_path_result="$func_convert_core_msys_to_w32_result"
1883244390Srwatson    func_convert_path_check : ";" \
1884244390Srwatson      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1885244390Srwatson    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
1886244390Srwatson  fi
1887244390Srwatson}
1888244390Srwatson# end func_convert_path_msys_to_w32
1889156283Srwatson
1890156283Srwatson
1891244390Srwatson# func_convert_path_cygwin_to_w32 ARG
1892244390Srwatson# Convert path ARG from Cygwin to w32 format.  Returns result in
1893244390Srwatson# func_to_host_file_result.
1894244390Srwatsonfunc_convert_path_cygwin_to_w32 ()
1895244390Srwatson{
1896244390Srwatson  $opt_debug
1897244390Srwatson  func_to_host_path_result="$1"
1898244390Srwatson  if test -n "$1"; then
1899244390Srwatson    # See func_convert_path_msys_to_w32:
1900244390Srwatson    func_stripname : : "$1"
1901244390Srwatson    func_to_host_path_tmp1=$func_stripname_result
1902244390Srwatson    func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"`
1903244390Srwatson    func_convert_path_check : ";" \
1904244390Srwatson      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1905244390Srwatson    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
1906244390Srwatson  fi
1907244390Srwatson}
1908244390Srwatson# end func_convert_path_cygwin_to_w32
1909156283Srwatson
1910244390Srwatson
1911244390Srwatson# func_convert_path_nix_to_w32 ARG
1912244390Srwatson# Convert path ARG from *nix to w32 format.  Requires a wine environment and
1913244390Srwatson# a working winepath.  Returns result in func_to_host_file_result.
1914244390Srwatsonfunc_convert_path_nix_to_w32 ()
1915244390Srwatson{
1916244390Srwatson  $opt_debug
1917244390Srwatson  func_to_host_path_result="$1"
1918244390Srwatson  if test -n "$1"; then
1919244390Srwatson    # See func_convert_path_msys_to_w32:
1920244390Srwatson    func_stripname : : "$1"
1921244390Srwatson    func_to_host_path_tmp1=$func_stripname_result
1922244390Srwatson    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
1923244390Srwatson    func_to_host_path_result="$func_convert_core_path_wine_to_w32_result"
1924244390Srwatson    func_convert_path_check : ";" \
1925244390Srwatson      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1926244390Srwatson    func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
1927156283Srwatson  fi
1928244390Srwatson}
1929244390Srwatson# end func_convert_path_nix_to_w32
1930156283Srwatson
1931244390Srwatson
1932244390Srwatson# func_convert_path_msys_to_cygwin ARG
1933244390Srwatson# Convert path ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
1934244390Srwatson# Returns result in func_to_host_file_result.
1935244390Srwatsonfunc_convert_path_msys_to_cygwin ()
1936244390Srwatson{
1937244390Srwatson  $opt_debug
1938244390Srwatson  func_to_host_path_result="$1"
1939244390Srwatson  if test -n "$1"; then
1940244390Srwatson    # See func_convert_path_msys_to_w32:
1941244390Srwatson    func_stripname : : "$1"
1942244390Srwatson    func_to_host_path_tmp1=$func_stripname_result
1943244390Srwatson    func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
1944244390Srwatson    func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
1945244390Srwatson    func_to_host_path_result="$func_cygpath_result"
1946244390Srwatson    func_convert_path_check : : \
1947244390Srwatson      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1948244390Srwatson    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
1949156283Srwatson  fi
1950244390Srwatson}
1951244390Srwatson# end func_convert_path_msys_to_cygwin
1952156283Srwatson
1953156283Srwatson
1954244390Srwatson# func_convert_path_nix_to_cygwin ARG
1955244390Srwatson# Convert path ARG from *nix to Cygwin format.  Requires Cygwin installed in a
1956244390Srwatson# a wine environment, working winepath, and LT_CYGPATH set.  Returns result in
1957244390Srwatson# func_to_host_file_result.
1958244390Srwatsonfunc_convert_path_nix_to_cygwin ()
1959244390Srwatson{
1960244390Srwatson  $opt_debug
1961244390Srwatson  func_to_host_path_result="$1"
1962244390Srwatson  if test -n "$1"; then
1963244390Srwatson    # Remove leading and trailing path separator characters from
1964244390Srwatson    # ARG. msys behavior is inconsistent here, cygpath turns them
1965244390Srwatson    # into '.;' and ';.', and winepath ignores them completely.
1966244390Srwatson    func_stripname : : "$1"
1967244390Srwatson    func_to_host_path_tmp1=$func_stripname_result
1968244390Srwatson    func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
1969244390Srwatson    func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
1970244390Srwatson    func_to_host_path_result="$func_cygpath_result"
1971244390Srwatson    func_convert_path_check : : \
1972244390Srwatson      "$func_to_host_path_tmp1" "$func_to_host_path_result"
1973244390Srwatson    func_convert_path_front_back_pathsep ":*" "*:" : "$1"
1974244390Srwatson  fi
1975244390Srwatson}
1976244390Srwatson# end func_convert_path_nix_to_cygwin
1977244390Srwatson
1978244390Srwatson
1979244390Srwatson# func_mode_compile arg...
1980244390Srwatsonfunc_mode_compile ()
1981244390Srwatson{
1982244390Srwatson    $opt_debug
1983156283Srwatson    # Get the compilation command and the source file.
1984156283Srwatson    base_compile=
1985156283Srwatson    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
1986156283Srwatson    suppress_opt=yes
1987156283Srwatson    suppress_output=
1988156283Srwatson    arg_mode=normal
1989156283Srwatson    libobj=
1990156283Srwatson    later=
1991244390Srwatson    pie_flag=
1992156283Srwatson
1993156283Srwatson    for arg
1994156283Srwatson    do
1995156283Srwatson      case $arg_mode in
1996156283Srwatson      arg  )
1997156283Srwatson	# do not "continue".  Instead, add this to base_compile
1998156283Srwatson	lastarg="$arg"
1999156283Srwatson	arg_mode=normal
2000156283Srwatson	;;
2001156283Srwatson
2002156283Srwatson      target )
2003156283Srwatson	libobj="$arg"
2004156283Srwatson	arg_mode=normal
2005156283Srwatson	continue
2006156283Srwatson	;;
2007156283Srwatson
2008156283Srwatson      normal )
2009156283Srwatson	# Accept any command-line options.
2010156283Srwatson	case $arg in
2011156283Srwatson	-o)
2012244390Srwatson	  test -n "$libobj" && \
2013244390Srwatson	    func_fatal_error "you cannot specify \`-o' more than once"
2014156283Srwatson	  arg_mode=target
2015156283Srwatson	  continue
2016156283Srwatson	  ;;
2017156283Srwatson
2018244390Srwatson	-pie | -fpie | -fPIE)
2019244390Srwatson          func_append pie_flag " $arg"
2020156283Srwatson	  continue
2021156283Srwatson	  ;;
2022156283Srwatson
2023244390Srwatson	-shared | -static | -prefer-pic | -prefer-non-pic)
2024244390Srwatson	  func_append later " $arg"
2025244390Srwatson	  continue
2026244390Srwatson	  ;;
2027244390Srwatson
2028156283Srwatson	-no-suppress)
2029156283Srwatson	  suppress_opt=no
2030156283Srwatson	  continue
2031156283Srwatson	  ;;
2032156283Srwatson
2033156283Srwatson	-Xcompiler)
2034156283Srwatson	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
2035156283Srwatson	  continue      #  The current "srcfile" will either be retained or
2036156283Srwatson	  ;;            #  replaced later.  I would guess that would be a bug.
2037156283Srwatson
2038156283Srwatson	-Wc,*)
2039244390Srwatson	  func_stripname '-Wc,' '' "$arg"
2040244390Srwatson	  args=$func_stripname_result
2041156283Srwatson	  lastarg=
2042156283Srwatson	  save_ifs="$IFS"; IFS=','
2043244390Srwatson	  for arg in $args; do
2044156283Srwatson	    IFS="$save_ifs"
2045244390Srwatson	    func_append_quoted lastarg "$arg"
2046156283Srwatson	  done
2047156283Srwatson	  IFS="$save_ifs"
2048244390Srwatson	  func_stripname ' ' '' "$lastarg"
2049244390Srwatson	  lastarg=$func_stripname_result
2050156283Srwatson
2051156283Srwatson	  # Add the arguments to base_compile.
2052244390Srwatson	  func_append base_compile " $lastarg"
2053156283Srwatson	  continue
2054156283Srwatson	  ;;
2055156283Srwatson
2056244390Srwatson	*)
2057156283Srwatson	  # Accept the current argument as the source file.
2058156283Srwatson	  # The previous "srcfile" becomes the current argument.
2059156283Srwatson	  #
2060156283Srwatson	  lastarg="$srcfile"
2061156283Srwatson	  srcfile="$arg"
2062156283Srwatson	  ;;
2063156283Srwatson	esac  #  case $arg
2064156283Srwatson	;;
2065156283Srwatson      esac    #  case $arg_mode
2066156283Srwatson
2067156283Srwatson      # Aesthetically quote the previous argument.
2068244390Srwatson      func_append_quoted base_compile "$lastarg"
2069156283Srwatson    done # for arg
2070156283Srwatson
2071156283Srwatson    case $arg_mode in
2072156283Srwatson    arg)
2073244390Srwatson      func_fatal_error "you must specify an argument for -Xcompile"
2074156283Srwatson      ;;
2075156283Srwatson    target)
2076244390Srwatson      func_fatal_error "you must specify a target with \`-o'"
2077156283Srwatson      ;;
2078156283Srwatson    *)
2079156283Srwatson      # Get the name of the library object.
2080244390Srwatson      test -z "$libobj" && {
2081244390Srwatson	func_basename "$srcfile"
2082244390Srwatson	libobj="$func_basename_result"
2083244390Srwatson      }
2084156283Srwatson      ;;
2085156283Srwatson    esac
2086156283Srwatson
2087156283Srwatson    # Recognize several different file suffixes.
2088156283Srwatson    # If the user specifies -o file.o, it is replaced with file.lo
2089156283Srwatson    case $libobj in
2090244390Srwatson    *.[cCFSifmso] | \
2091244390Srwatson    *.ada | *.adb | *.ads | *.asm | \
2092244390Srwatson    *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
2093244390Srwatson    *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup)
2094244390Srwatson      func_xform "$libobj"
2095244390Srwatson      libobj=$func_xform_result
2096244390Srwatson      ;;
2097156283Srwatson    esac
2098156283Srwatson
2099156283Srwatson    case $libobj in
2100244390Srwatson    *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
2101156283Srwatson    *)
2102244390Srwatson      func_fatal_error "cannot determine name of library object from \`$libobj'"
2103156283Srwatson      ;;
2104156283Srwatson    esac
2105156283Srwatson
2106156283Srwatson    func_infer_tag $base_compile
2107156283Srwatson
2108156283Srwatson    for arg in $later; do
2109156283Srwatson      case $arg in
2110244390Srwatson      -shared)
2111244390Srwatson	test "$build_libtool_libs" != yes && \
2112244390Srwatson	  func_fatal_configuration "can not build a shared library"
2113244390Srwatson	build_old_libs=no
2114244390Srwatson	continue
2115244390Srwatson	;;
2116244390Srwatson
2117156283Srwatson      -static)
2118244390Srwatson	build_libtool_libs=no
2119156283Srwatson	build_old_libs=yes
2120156283Srwatson	continue
2121156283Srwatson	;;
2122156283Srwatson
2123156283Srwatson      -prefer-pic)
2124156283Srwatson	pic_mode=yes
2125156283Srwatson	continue
2126156283Srwatson	;;
2127156283Srwatson
2128156283Srwatson      -prefer-non-pic)
2129156283Srwatson	pic_mode=no
2130156283Srwatson	continue
2131156283Srwatson	;;
2132156283Srwatson      esac
2133156283Srwatson    done
2134156283Srwatson
2135244390Srwatson    func_quote_for_eval "$libobj"
2136244390Srwatson    test "X$libobj" != "X$func_quote_for_eval_result" \
2137244390Srwatson      && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'	 &()|`$[]' \
2138244390Srwatson      && func_warning "libobj name \`$libobj' may not contain shell special characters."
2139244390Srwatson    func_dirname_and_basename "$obj" "/" ""
2140244390Srwatson    objname="$func_basename_result"
2141244390Srwatson    xdir="$func_dirname_result"
2142156283Srwatson    lobj=${xdir}$objdir/$objname
2143156283Srwatson
2144244390Srwatson    test -z "$base_compile" && \
2145244390Srwatson      func_fatal_help "you must specify a compilation command"
2146156283Srwatson
2147156283Srwatson    # Delete any leftover library objects.
2148156283Srwatson    if test "$build_old_libs" = yes; then
2149156283Srwatson      removelist="$obj $lobj $libobj ${libobj}T"
2150156283Srwatson    else
2151156283Srwatson      removelist="$lobj $libobj ${libobj}T"
2152156283Srwatson    fi
2153156283Srwatson
2154156283Srwatson    # On Cygwin there's no "real" PIC flag so we must build both object types
2155156283Srwatson    case $host_os in
2156244390Srwatson    cygwin* | mingw* | pw32* | os2* | cegcc*)
2157156283Srwatson      pic_mode=default
2158156283Srwatson      ;;
2159156283Srwatson    esac
2160156283Srwatson    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
2161156283Srwatson      # non-PIC code in shared libraries is not supported
2162156283Srwatson      pic_mode=default
2163156283Srwatson    fi
2164156283Srwatson
2165156283Srwatson    # Calculate the filename of the output object if compiler does
2166156283Srwatson    # not support -o with -c
2167156283Srwatson    if test "$compiler_c_o" = no; then
2168244390Srwatson      output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext}
2169156283Srwatson      lockfile="$output_obj.lock"
2170156283Srwatson    else
2171156283Srwatson      output_obj=
2172156283Srwatson      need_locks=no
2173156283Srwatson      lockfile=
2174156283Srwatson    fi
2175156283Srwatson
2176156283Srwatson    # Lock this critical section if it is needed
2177156283Srwatson    # We use this script file to make the link, it avoids creating a new file
2178156283Srwatson    if test "$need_locks" = yes; then
2179244390Srwatson      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
2180244390Srwatson	func_echo "Waiting for $lockfile to be removed"
2181156283Srwatson	sleep 2
2182156283Srwatson      done
2183156283Srwatson    elif test "$need_locks" = warn; then
2184156283Srwatson      if test -f "$lockfile"; then
2185244390Srwatson	$ECHO "\
2186156283Srwatson*** ERROR, $lockfile exists and contains:
2187156283Srwatson`cat $lockfile 2>/dev/null`
2188156283Srwatson
2189156283SrwatsonThis indicates that another process is trying to use the same
2190156283Srwatsontemporary object file, and libtool could not work around it because
2191156283Srwatsonyour compiler does not support \`-c' and \`-o' together.  If you
2192156283Srwatsonrepeat this compilation, it may succeed, by chance, but you had better
2193156283Srwatsonavoid parallel builds (make -j) in this platform, or get a better
2194156283Srwatsoncompiler."
2195156283Srwatson
2196244390Srwatson	$opt_dry_run || $RM $removelist
2197156283Srwatson	exit $EXIT_FAILURE
2198156283Srwatson      fi
2199244390Srwatson      func_append removelist " $output_obj"
2200244390Srwatson      $ECHO "$srcfile" > "$lockfile"
2201156283Srwatson    fi
2202156283Srwatson
2203244390Srwatson    $opt_dry_run || $RM $removelist
2204244390Srwatson    func_append removelist " $lockfile"
2205244390Srwatson    trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
2206156283Srwatson
2207244390Srwatson    func_to_tool_file "$srcfile" func_convert_file_msys_to_w32
2208244390Srwatson    srcfile=$func_to_tool_file_result
2209244390Srwatson    func_quote_for_eval "$srcfile"
2210244390Srwatson    qsrcfile=$func_quote_for_eval_result
2211156283Srwatson
2212156283Srwatson    # Only build a PIC object if we are building libtool libraries.
2213156283Srwatson    if test "$build_libtool_libs" = yes; then
2214156283Srwatson      # Without this assignment, base_compile gets emptied.
2215156283Srwatson      fbsd_hideous_sh_bug=$base_compile
2216156283Srwatson
2217156283Srwatson      if test "$pic_mode" != no; then
2218156283Srwatson	command="$base_compile $qsrcfile $pic_flag"
2219156283Srwatson      else
2220156283Srwatson	# Don't build PIC code
2221156283Srwatson	command="$base_compile $qsrcfile"
2222156283Srwatson      fi
2223156283Srwatson
2224244390Srwatson      func_mkdir_p "$xdir$objdir"
2225156283Srwatson
2226156283Srwatson      if test -z "$output_obj"; then
2227156283Srwatson	# Place PIC objects in $objdir
2228244390Srwatson	func_append command " -o $lobj"
2229156283Srwatson      fi
2230156283Srwatson
2231244390Srwatson      func_show_eval_locale "$command"	\
2232244390Srwatson          'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
2233156283Srwatson
2234156283Srwatson      if test "$need_locks" = warn &&
2235156283Srwatson	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
2236244390Srwatson	$ECHO "\
2237156283Srwatson*** ERROR, $lockfile contains:
2238156283Srwatson`cat $lockfile 2>/dev/null`
2239156283Srwatson
2240156283Srwatsonbut it should contain:
2241156283Srwatson$srcfile
2242156283Srwatson
2243156283SrwatsonThis indicates that another process is trying to use the same
2244156283Srwatsontemporary object file, and libtool could not work around it because
2245156283Srwatsonyour compiler does not support \`-c' and \`-o' together.  If you
2246156283Srwatsonrepeat this compilation, it may succeed, by chance, but you had better
2247156283Srwatsonavoid parallel builds (make -j) in this platform, or get a better
2248156283Srwatsoncompiler."
2249156283Srwatson
2250244390Srwatson	$opt_dry_run || $RM $removelist
2251156283Srwatson	exit $EXIT_FAILURE
2252156283Srwatson      fi
2253156283Srwatson
2254156283Srwatson      # Just move the object if needed, then go on to compile the next one
2255156283Srwatson      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
2256244390Srwatson	func_show_eval '$MV "$output_obj" "$lobj"' \
2257244390Srwatson	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
2258156283Srwatson      fi
2259156283Srwatson
2260156283Srwatson      # Allow error messages only from the first compilation.
2261156283Srwatson      if test "$suppress_opt" = yes; then
2262244390Srwatson	suppress_output=' >/dev/null 2>&1'
2263156283Srwatson      fi
2264156283Srwatson    fi
2265156283Srwatson
2266156283Srwatson    # Only build a position-dependent object if we build old libraries.
2267156283Srwatson    if test "$build_old_libs" = yes; then
2268156283Srwatson      if test "$pic_mode" != yes; then
2269156283Srwatson	# Don't build PIC code
2270244390Srwatson	command="$base_compile $qsrcfile$pie_flag"
2271156283Srwatson      else
2272156283Srwatson	command="$base_compile $qsrcfile $pic_flag"
2273156283Srwatson      fi
2274156283Srwatson      if test "$compiler_c_o" = yes; then
2275244390Srwatson	func_append command " -o $obj"
2276156283Srwatson      fi
2277156283Srwatson
2278156283Srwatson      # Suppress compiler output if we already did a PIC compilation.
2279244390Srwatson      func_append command "$suppress_output"
2280244390Srwatson      func_show_eval_locale "$command" \
2281244390Srwatson        '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
2282156283Srwatson
2283156283Srwatson      if test "$need_locks" = warn &&
2284156283Srwatson	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
2285244390Srwatson	$ECHO "\
2286156283Srwatson*** ERROR, $lockfile contains:
2287156283Srwatson`cat $lockfile 2>/dev/null`
2288156283Srwatson
2289156283Srwatsonbut it should contain:
2290156283Srwatson$srcfile
2291156283Srwatson
2292156283SrwatsonThis indicates that another process is trying to use the same
2293156283Srwatsontemporary object file, and libtool could not work around it because
2294156283Srwatsonyour compiler does not support \`-c' and \`-o' together.  If you
2295156283Srwatsonrepeat this compilation, it may succeed, by chance, but you had better
2296156283Srwatsonavoid parallel builds (make -j) in this platform, or get a better
2297156283Srwatsoncompiler."
2298156283Srwatson
2299244390Srwatson	$opt_dry_run || $RM $removelist
2300156283Srwatson	exit $EXIT_FAILURE
2301156283Srwatson      fi
2302156283Srwatson
2303156283Srwatson      # Just move the object if needed
2304156283Srwatson      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
2305244390Srwatson	func_show_eval '$MV "$output_obj" "$obj"' \
2306244390Srwatson	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
2307244390Srwatson      fi
2308244390Srwatson    fi
2309244390Srwatson
2310244390Srwatson    $opt_dry_run || {
2311244390Srwatson      func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
2312244390Srwatson
2313244390Srwatson      # Unlock the critical section if it was locked
2314244390Srwatson      if test "$need_locks" != no; then
2315244390Srwatson	removelist=$lockfile
2316244390Srwatson        $RM "$lockfile"
2317244390Srwatson      fi
2318244390Srwatson    }
2319244390Srwatson
2320244390Srwatson    exit $EXIT_SUCCESS
2321244390Srwatson}
2322244390Srwatson
2323244390Srwatson$opt_help || {
2324244390Srwatson  test "$opt_mode" = compile && func_mode_compile ${1+"$@"}
2325244390Srwatson}
2326244390Srwatson
2327244390Srwatsonfunc_mode_help ()
2328244390Srwatson{
2329244390Srwatson    # We need to display help for each of the modes.
2330244390Srwatson    case $opt_mode in
2331244390Srwatson      "")
2332244390Srwatson        # Generic help is extracted from the usage comments
2333244390Srwatson        # at the start of this file.
2334244390Srwatson        func_help
2335244390Srwatson        ;;
2336244390Srwatson
2337244390Srwatson      clean)
2338244390Srwatson        $ECHO \
2339244390Srwatson"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
2340244390Srwatson
2341244390SrwatsonRemove files from the build directory.
2342244390Srwatson
2343244390SrwatsonRM is the name of the program to use to delete files associated with each FILE
2344244390Srwatson(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
2345244390Srwatsonto RM.
2346244390Srwatson
2347244390SrwatsonIf FILE is a libtool library, object or program, all the files associated
2348244390Srwatsonwith it are deleted. Otherwise, only FILE itself is deleted using RM."
2349244390Srwatson        ;;
2350244390Srwatson
2351244390Srwatson      compile)
2352244390Srwatson      $ECHO \
2353244390Srwatson"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
2354244390Srwatson
2355244390SrwatsonCompile a source file into a libtool library object.
2356244390Srwatson
2357244390SrwatsonThis mode accepts the following additional options:
2358244390Srwatson
2359244390Srwatson  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
2360244390Srwatson  -no-suppress      do not suppress compiler output for multiple passes
2361244390Srwatson  -prefer-pic       try to build PIC objects only
2362244390Srwatson  -prefer-non-pic   try to build non-PIC objects only
2363244390Srwatson  -shared           do not build a \`.o' file suitable for static linking
2364244390Srwatson  -static           only build a \`.o' file suitable for static linking
2365244390Srwatson  -Wc,FLAG          pass FLAG directly to the compiler
2366244390Srwatson
2367244390SrwatsonCOMPILE-COMMAND is a command to be used in creating a \`standard' object file
2368244390Srwatsonfrom the given SOURCEFILE.
2369244390Srwatson
2370244390SrwatsonThe output file name is determined by removing the directory component from
2371244390SrwatsonSOURCEFILE, then substituting the C source code suffix \`.c' with the
2372244390Srwatsonlibrary object suffix, \`.lo'."
2373244390Srwatson        ;;
2374244390Srwatson
2375244390Srwatson      execute)
2376244390Srwatson        $ECHO \
2377244390Srwatson"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
2378244390Srwatson
2379244390SrwatsonAutomatically set library path, then run a program.
2380244390Srwatson
2381244390SrwatsonThis mode accepts the following additional options:
2382244390Srwatson
2383244390Srwatson  -dlopen FILE      add the directory containing FILE to the library path
2384244390Srwatson
2385244390SrwatsonThis mode sets the library path environment variable according to \`-dlopen'
2386244390Srwatsonflags.
2387244390Srwatson
2388244390SrwatsonIf any of the ARGS are libtool executable wrappers, then they are translated
2389244390Srwatsoninto their corresponding uninstalled binary, and any of their required library
2390244390Srwatsondirectories are added to the library path.
2391244390Srwatson
2392244390SrwatsonThen, COMMAND is executed, with ARGS as arguments."
2393244390Srwatson        ;;
2394244390Srwatson
2395244390Srwatson      finish)
2396244390Srwatson        $ECHO \
2397244390Srwatson"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
2398244390Srwatson
2399244390SrwatsonComplete the installation of libtool libraries.
2400244390Srwatson
2401244390SrwatsonEach LIBDIR is a directory that contains libtool libraries.
2402244390Srwatson
2403244390SrwatsonThe commands that this mode executes may require superuser privileges.  Use
2404244390Srwatsonthe \`--dry-run' option if you just want to see what would be executed."
2405244390Srwatson        ;;
2406244390Srwatson
2407244390Srwatson      install)
2408244390Srwatson        $ECHO \
2409244390Srwatson"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
2410244390Srwatson
2411244390SrwatsonInstall executables or libraries.
2412244390Srwatson
2413244390SrwatsonINSTALL-COMMAND is the installation command.  The first component should be
2414244390Srwatsoneither the \`install' or \`cp' program.
2415244390Srwatson
2416244390SrwatsonThe following components of INSTALL-COMMAND are treated specially:
2417244390Srwatson
2418244390Srwatson  -inst-prefix-dir PREFIX-DIR  Use PREFIX-DIR as a staging area for installation
2419244390Srwatson
2420244390SrwatsonThe rest of the components are interpreted as arguments to that command (only
2421244390SrwatsonBSD-compatible install options are recognized)."
2422244390Srwatson        ;;
2423244390Srwatson
2424244390Srwatson      link)
2425244390Srwatson        $ECHO \
2426244390Srwatson"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
2427244390Srwatson
2428244390SrwatsonLink object files or libraries together to form another library, or to
2429244390Srwatsoncreate an executable program.
2430244390Srwatson
2431244390SrwatsonLINK-COMMAND is a command using the C compiler that you would use to create
2432244390Srwatsona program from several object files.
2433244390Srwatson
2434244390SrwatsonThe following components of LINK-COMMAND are treated specially:
2435244390Srwatson
2436244390Srwatson  -all-static       do not do any dynamic linking at all
2437244390Srwatson  -avoid-version    do not add a version suffix if possible
2438244390Srwatson  -bindir BINDIR    specify path to binaries directory (for systems where
2439244390Srwatson                    libraries must be found in the PATH setting at runtime)
2440244390Srwatson  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
2441244390Srwatson  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
2442244390Srwatson  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
2443244390Srwatson  -export-symbols SYMFILE
2444244390Srwatson                    try to export only the symbols listed in SYMFILE
2445244390Srwatson  -export-symbols-regex REGEX
2446244390Srwatson                    try to export only the symbols matching REGEX
2447244390Srwatson  -LLIBDIR          search LIBDIR for required installed libraries
2448244390Srwatson  -lNAME            OUTPUT-FILE requires the installed library libNAME
2449244390Srwatson  -module           build a library that can dlopened
2450244390Srwatson  -no-fast-install  disable the fast-install mode
2451244390Srwatson  -no-install       link a not-installable executable
2452244390Srwatson  -no-undefined     declare that a library does not refer to external symbols
2453244390Srwatson  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
2454244390Srwatson  -objectlist FILE  Use a list of object files found in FILE to specify objects
2455244390Srwatson  -precious-files-regex REGEX
2456244390Srwatson                    don't remove output files matching REGEX
2457244390Srwatson  -release RELEASE  specify package release information
2458244390Srwatson  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
2459244390Srwatson  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
2460244390Srwatson  -shared           only do dynamic linking of libtool libraries
2461244390Srwatson  -shrext SUFFIX    override the standard shared library file extension
2462244390Srwatson  -static           do not do any dynamic linking of uninstalled libtool libraries
2463244390Srwatson  -static-libtool-libs
2464244390Srwatson                    do not do any dynamic linking of libtool libraries
2465244390Srwatson  -version-info CURRENT[:REVISION[:AGE]]
2466244390Srwatson                    specify library version info [each variable defaults to 0]
2467244390Srwatson  -weak LIBNAME     declare that the target provides the LIBNAME interface
2468244390Srwatson  -Wc,FLAG
2469244390Srwatson  -Xcompiler FLAG   pass linker-specific FLAG directly to the compiler
2470244390Srwatson  -Wl,FLAG
2471244390Srwatson  -Xlinker FLAG     pass linker-specific FLAG directly to the linker
2472244390Srwatson  -XCClinker FLAG   pass link-specific FLAG to the compiler driver (CC)
2473244390Srwatson
2474244390SrwatsonAll other options (arguments beginning with \`-') are ignored.
2475244390Srwatson
2476244390SrwatsonEvery other argument is treated as a filename.  Files ending in \`.la' are
2477244390Srwatsontreated as uninstalled libtool libraries, other files are standard or library
2478244390Srwatsonobject files.
2479244390Srwatson
2480244390SrwatsonIf the OUTPUT-FILE ends in \`.la', then a libtool library is created,
2481244390Srwatsononly library objects (\`.lo' files) may be specified, and \`-rpath' is
2482244390Srwatsonrequired, except when creating a convenience library.
2483244390Srwatson
2484244390SrwatsonIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
2485244390Srwatsonusing \`ar' and \`ranlib', or on Windows using \`lib'.
2486244390Srwatson
2487244390SrwatsonIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
2488244390Srwatsonis created, otherwise an executable program is created."
2489244390Srwatson        ;;
2490244390Srwatson
2491244390Srwatson      uninstall)
2492244390Srwatson        $ECHO \
2493244390Srwatson"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
2494244390Srwatson
2495244390SrwatsonRemove libraries from an installation directory.
2496244390Srwatson
2497244390SrwatsonRM is the name of the program to use to delete files associated with each FILE
2498244390Srwatson(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
2499244390Srwatsonto RM.
2500244390Srwatson
2501244390SrwatsonIf FILE is a libtool library, all the files associated with it are deleted.
2502244390SrwatsonOtherwise, only FILE itself is deleted using RM."
2503244390Srwatson        ;;
2504244390Srwatson
2505244390Srwatson      *)
2506244390Srwatson        func_fatal_help "invalid operation mode \`$opt_mode'"
2507244390Srwatson        ;;
2508244390Srwatson    esac
2509244390Srwatson
2510244390Srwatson    echo
2511244390Srwatson    $ECHO "Try \`$progname --help' for more information about other modes."
2512244390Srwatson}
2513244390Srwatson
2514244390Srwatson# Now that we've collected a possible --mode arg, show help if necessary
2515244390Srwatsonif $opt_help; then
2516244390Srwatson  if test "$opt_help" = :; then
2517244390Srwatson    func_mode_help
2518244390Srwatson  else
2519244390Srwatson    {
2520244390Srwatson      func_help noexit
2521244390Srwatson      for opt_mode in compile link execute install finish uninstall clean; do
2522244390Srwatson	func_mode_help
2523244390Srwatson      done
2524244390Srwatson    } | sed -n '1p; 2,$s/^Usage:/  or: /p'
2525244390Srwatson    {
2526244390Srwatson      func_help noexit
2527244390Srwatson      for opt_mode in compile link execute install finish uninstall clean; do
2528244390Srwatson	echo
2529244390Srwatson	func_mode_help
2530244390Srwatson      done
2531244390Srwatson    } |
2532244390Srwatson    sed '1d
2533244390Srwatson      /^When reporting/,/^Report/{
2534244390Srwatson	H
2535244390Srwatson	d
2536244390Srwatson      }
2537244390Srwatson      $x
2538244390Srwatson      /information about other modes/d
2539244390Srwatson      /more detailed .*MODE/d
2540244390Srwatson      s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
2541244390Srwatson  fi
2542244390Srwatson  exit $?
2543244390Srwatsonfi
2544244390Srwatson
2545244390Srwatson
2546244390Srwatson# func_mode_execute arg...
2547244390Srwatsonfunc_mode_execute ()
2548244390Srwatson{
2549244390Srwatson    $opt_debug
2550244390Srwatson    # The first argument is the command name.
2551244390Srwatson    cmd="$nonopt"
2552244390Srwatson    test -z "$cmd" && \
2553244390Srwatson      func_fatal_help "you must specify a COMMAND"
2554244390Srwatson
2555244390Srwatson    # Handle -dlopen flags immediately.
2556244390Srwatson    for file in $opt_dlopen; do
2557244390Srwatson      test -f "$file" \
2558244390Srwatson	|| func_fatal_help "\`$file' is not a file"
2559244390Srwatson
2560244390Srwatson      dir=
2561244390Srwatson      case $file in
2562244390Srwatson      *.la)
2563244390Srwatson	func_resolve_sysroot "$file"
2564244390Srwatson	file=$func_resolve_sysroot_result
2565244390Srwatson
2566244390Srwatson	# Check to see that this really is a libtool archive.
2567244390Srwatson	func_lalib_unsafe_p "$file" \
2568244390Srwatson	  || func_fatal_help "\`$lib' is not a valid libtool archive"
2569244390Srwatson
2570244390Srwatson	# Read the libtool library.
2571244390Srwatson	dlname=
2572244390Srwatson	library_names=
2573244390Srwatson	func_source "$file"
2574244390Srwatson
2575244390Srwatson	# Skip this library if it cannot be dlopened.
2576244390Srwatson	if test -z "$dlname"; then
2577244390Srwatson	  # Warn if it was a shared library.
2578244390Srwatson	  test -n "$library_names" && \
2579244390Srwatson	    func_warning "\`$file' was not linked with \`-export-dynamic'"
2580244390Srwatson	  continue
2581244390Srwatson	fi
2582244390Srwatson
2583244390Srwatson	func_dirname "$file" "" "."
2584244390Srwatson	dir="$func_dirname_result"
2585244390Srwatson
2586244390Srwatson	if test -f "$dir/$objdir/$dlname"; then
2587244390Srwatson	  func_append dir "/$objdir"
2588156283Srwatson	else
2589244390Srwatson	  if test ! -f "$dir/$dlname"; then
2590244390Srwatson	    func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'"
2591244390Srwatson	  fi
2592156283Srwatson	fi
2593244390Srwatson	;;
2594244390Srwatson
2595244390Srwatson      *.lo)
2596244390Srwatson	# Just add the directory containing the .lo file.
2597244390Srwatson	func_dirname "$file" "" "."
2598244390Srwatson	dir="$func_dirname_result"
2599244390Srwatson	;;
2600244390Srwatson
2601244390Srwatson      *)
2602244390Srwatson	func_warning "\`-dlopen' is ignored for non-libtool libraries and objects"
2603244390Srwatson	continue
2604244390Srwatson	;;
2605244390Srwatson      esac
2606244390Srwatson
2607244390Srwatson      # Get the absolute pathname.
2608244390Srwatson      absdir=`cd "$dir" && pwd`
2609244390Srwatson      test -n "$absdir" && dir="$absdir"
2610244390Srwatson
2611244390Srwatson      # Now add the directory to shlibpath_var.
2612244390Srwatson      if eval "test -z \"\$$shlibpath_var\""; then
2613244390Srwatson	eval "$shlibpath_var=\"\$dir\""
2614244390Srwatson      else
2615244390Srwatson	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
2616156283Srwatson      fi
2617244390Srwatson    done
2618156283Srwatson
2619244390Srwatson    # This variable tells wrapper scripts just to set shlibpath_var
2620244390Srwatson    # rather than running their programs.
2621244390Srwatson    libtool_execute_magic="$magic"
2622156283Srwatson
2623244390Srwatson    # Check if any of the arguments is a wrapper script.
2624244390Srwatson    args=
2625244390Srwatson    for file
2626244390Srwatson    do
2627244390Srwatson      case $file in
2628244390Srwatson      -* | *.la | *.lo ) ;;
2629244390Srwatson      *)
2630244390Srwatson	# Do a test to see if this is really a libtool program.
2631244390Srwatson	if func_ltwrapper_script_p "$file"; then
2632244390Srwatson	  func_source "$file"
2633244390Srwatson	  # Transform arg to wrapped name.
2634244390Srwatson	  file="$progdir/$program"
2635244390Srwatson	elif func_ltwrapper_executable_p "$file"; then
2636244390Srwatson	  func_ltwrapper_scriptname "$file"
2637244390Srwatson	  func_source "$func_ltwrapper_scriptname_result"
2638244390Srwatson	  # Transform arg to wrapped name.
2639244390Srwatson	  file="$progdir/$program"
2640244390Srwatson	fi
2641244390Srwatson	;;
2642244390Srwatson      esac
2643244390Srwatson      # Quote arguments (to preserve shell metacharacters).
2644244390Srwatson      func_append_quoted args "$file"
2645244390Srwatson    done
2646244390Srwatson
2647244390Srwatson    if test "X$opt_dry_run" = Xfalse; then
2648244390Srwatson      if test -n "$shlibpath_var"; then
2649244390Srwatson	# Export the shlibpath_var.
2650244390Srwatson	eval "export $shlibpath_var"
2651244390Srwatson      fi
2652244390Srwatson
2653244390Srwatson      # Restore saved environment variables
2654244390Srwatson      for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
2655244390Srwatson      do
2656244390Srwatson	eval "if test \"\${save_$lt_var+set}\" = set; then
2657244390Srwatson                $lt_var=\$save_$lt_var; export $lt_var
2658244390Srwatson	      else
2659244390Srwatson		$lt_unset $lt_var
2660244390Srwatson	      fi"
2661244390Srwatson      done
2662244390Srwatson
2663244390Srwatson      # Now prepare to actually exec the command.
2664244390Srwatson      exec_cmd="\$cmd$args"
2665156283Srwatson    else
2666244390Srwatson      # Display what would be done.
2667244390Srwatson      if test -n "$shlibpath_var"; then
2668244390Srwatson	eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
2669244390Srwatson	echo "export $shlibpath_var"
2670244390Srwatson      fi
2671244390Srwatson      $ECHO "$cmd$args"
2672244390Srwatson      exit $EXIT_SUCCESS
2673244390Srwatson    fi
2674244390Srwatson}
2675156283Srwatson
2676244390Srwatsontest "$opt_mode" = execute && func_mode_execute ${1+"$@"}
2677244390Srwatson
2678244390Srwatson
2679244390Srwatson# func_mode_finish arg...
2680244390Srwatsonfunc_mode_finish ()
2681244390Srwatson{
2682244390Srwatson    $opt_debug
2683244390Srwatson    libs=
2684244390Srwatson    libdirs=
2685244390Srwatson    admincmds=
2686244390Srwatson
2687244390Srwatson    for opt in "$nonopt" ${1+"$@"}
2688244390Srwatson    do
2689244390Srwatson      if test -d "$opt"; then
2690244390Srwatson	func_append libdirs " $opt"
2691244390Srwatson
2692244390Srwatson      elif test -f "$opt"; then
2693244390Srwatson	if func_lalib_unsafe_p "$opt"; then
2694244390Srwatson	  func_append libs " $opt"
2695244390Srwatson	else
2696244390Srwatson	  func_warning "\`$opt' is not a valid libtool archive"
2697244390Srwatson	fi
2698244390Srwatson
2699244390Srwatson      else
2700244390Srwatson	func_fatal_error "invalid argument \`$opt'"
2701244390Srwatson      fi
2702244390Srwatson    done
2703244390Srwatson
2704244390Srwatson    if test -n "$libs"; then
2705244390Srwatson      if test -n "$lt_sysroot"; then
2706244390Srwatson        sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"`
2707244390Srwatson        sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;"
2708244390Srwatson      else
2709244390Srwatson        sysroot_cmd=
2710244390Srwatson      fi
2711244390Srwatson
2712244390Srwatson      # Remove sysroot references
2713244390Srwatson      if $opt_dry_run; then
2714244390Srwatson        for lib in $libs; do
2715244390Srwatson          echo "removing references to $lt_sysroot and \`=' prefixes from $lib"
2716244390Srwatson        done
2717244390Srwatson      else
2718244390Srwatson        tmpdir=`func_mktempdir`
2719244390Srwatson        for lib in $libs; do
2720244390Srwatson	  sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
2721244390Srwatson	    > $tmpdir/tmp-la
2722244390Srwatson	  mv -f $tmpdir/tmp-la $lib
2723244390Srwatson	done
2724244390Srwatson        ${RM}r "$tmpdir"
2725244390Srwatson      fi
2726156283Srwatson    fi
2727156283Srwatson
2728244390Srwatson    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
2729244390Srwatson      for libdir in $libdirs; do
2730244390Srwatson	if test -n "$finish_cmds"; then
2731244390Srwatson	  # Do each command in the finish commands.
2732244390Srwatson	  func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
2733244390Srwatson'"$cmd"'"'
2734244390Srwatson	fi
2735244390Srwatson	if test -n "$finish_eval"; then
2736244390Srwatson	  # Do the single finish_eval.
2737244390Srwatson	  eval cmds=\"$finish_eval\"
2738244390Srwatson	  $opt_dry_run || eval "$cmds" || func_append admincmds "
2739244390Srwatson       $cmds"
2740244390Srwatson	fi
2741244390Srwatson      done
2742244390Srwatson    fi
2743156283Srwatson
2744244390Srwatson    # Exit here if they wanted silent mode.
2745244390Srwatson    $opt_silent && exit $EXIT_SUCCESS
2746244390Srwatson
2747244390Srwatson    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
2748244390Srwatson      echo "----------------------------------------------------------------------"
2749244390Srwatson      echo "Libraries have been installed in:"
2750244390Srwatson      for libdir in $libdirs; do
2751244390Srwatson	$ECHO "   $libdir"
2752244390Srwatson      done
2753244390Srwatson      echo
2754244390Srwatson      echo "If you ever happen to want to link against installed libraries"
2755244390Srwatson      echo "in a given directory, LIBDIR, you must either use libtool, and"
2756244390Srwatson      echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
2757244390Srwatson      echo "flag during linking and do at least one of the following:"
2758244390Srwatson      if test -n "$shlibpath_var"; then
2759244390Srwatson	echo "   - add LIBDIR to the \`$shlibpath_var' environment variable"
2760244390Srwatson	echo "     during execution"
2761244390Srwatson      fi
2762244390Srwatson      if test -n "$runpath_var"; then
2763244390Srwatson	echo "   - add LIBDIR to the \`$runpath_var' environment variable"
2764244390Srwatson	echo "     during linking"
2765244390Srwatson      fi
2766244390Srwatson      if test -n "$hardcode_libdir_flag_spec"; then
2767244390Srwatson	libdir=LIBDIR
2768244390Srwatson	eval flag=\"$hardcode_libdir_flag_spec\"
2769244390Srwatson
2770244390Srwatson	$ECHO "   - use the \`$flag' linker flag"
2771244390Srwatson      fi
2772244390Srwatson      if test -n "$admincmds"; then
2773244390Srwatson	$ECHO "   - have your system administrator run these commands:$admincmds"
2774244390Srwatson      fi
2775244390Srwatson      if test -f /etc/ld.so.conf; then
2776244390Srwatson	echo "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
2777244390Srwatson      fi
2778244390Srwatson      echo
2779244390Srwatson
2780244390Srwatson      echo "See any operating system documentation about shared libraries for"
2781244390Srwatson      case $host in
2782244390Srwatson	solaris2.[6789]|solaris2.1[0-9])
2783244390Srwatson	  echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
2784244390Srwatson	  echo "pages."
2785244390Srwatson	  ;;
2786244390Srwatson	*)
2787244390Srwatson	  echo "more information, such as the ld(1) and ld.so(8) manual pages."
2788244390Srwatson	  ;;
2789244390Srwatson      esac
2790244390Srwatson      echo "----------------------------------------------------------------------"
2791156283Srwatson    fi
2792244390Srwatson    exit $EXIT_SUCCESS
2793244390Srwatson}
2794156283Srwatson
2795244390Srwatsontest "$opt_mode" = finish && func_mode_finish ${1+"$@"}
2796244390Srwatson
2797244390Srwatson
2798244390Srwatson# func_mode_install arg...
2799244390Srwatsonfunc_mode_install ()
2800244390Srwatson{
2801244390Srwatson    $opt_debug
2802244390Srwatson    # There may be an optional sh(1) argument at the beginning of
2803244390Srwatson    # install_prog (especially on Windows NT).
2804244390Srwatson    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
2805244390Srwatson       # Allow the use of GNU shtool's install command.
2806244390Srwatson       case $nonopt in *shtool*) :;; *) false;; esac; then
2807244390Srwatson      # Aesthetically quote it.
2808244390Srwatson      func_quote_for_eval "$nonopt"
2809244390Srwatson      install_prog="$func_quote_for_eval_result "
2810244390Srwatson      arg=$1
2811244390Srwatson      shift
2812244390Srwatson    else
2813244390Srwatson      install_prog=
2814244390Srwatson      arg=$nonopt
2815244390Srwatson    fi
2816244390Srwatson
2817244390Srwatson    # The real first argument should be the name of the installation program.
2818244390Srwatson    # Aesthetically quote it.
2819244390Srwatson    func_quote_for_eval "$arg"
2820244390Srwatson    func_append install_prog "$func_quote_for_eval_result"
2821244390Srwatson    install_shared_prog=$install_prog
2822244390Srwatson    case " $install_prog " in
2823244390Srwatson      *[\\\ /]cp\ *) install_cp=: ;;
2824244390Srwatson      *) install_cp=false ;;
2825244390Srwatson    esac
2826244390Srwatson
2827244390Srwatson    # We need to accept at least all the BSD install flags.
2828244390Srwatson    dest=
2829244390Srwatson    files=
2830244390Srwatson    opts=
2831244390Srwatson    prev=
2832244390Srwatson    install_type=
2833244390Srwatson    isdir=no
2834244390Srwatson    stripme=
2835244390Srwatson    no_mode=:
2836244390Srwatson    for arg
2837244390Srwatson    do
2838244390Srwatson      arg2=
2839244390Srwatson      if test -n "$dest"; then
2840244390Srwatson	func_append files " $dest"
2841244390Srwatson	dest=$arg
2842244390Srwatson	continue
2843244390Srwatson      fi
2844244390Srwatson
2845244390Srwatson      case $arg in
2846244390Srwatson      -d) isdir=yes ;;
2847244390Srwatson      -f)
2848244390Srwatson	if $install_cp; then :; else
2849244390Srwatson	  prev=$arg
2850244390Srwatson	fi
2851244390Srwatson	;;
2852244390Srwatson      -g | -m | -o)
2853244390Srwatson	prev=$arg
2854244390Srwatson	;;
2855244390Srwatson      -s)
2856244390Srwatson	stripme=" -s"
2857244390Srwatson	continue
2858244390Srwatson	;;
2859244390Srwatson      -*)
2860244390Srwatson	;;
2861244390Srwatson      *)
2862244390Srwatson	# If the previous option needed an argument, then skip it.
2863244390Srwatson	if test -n "$prev"; then
2864244390Srwatson	  if test "x$prev" = x-m && test -n "$install_override_mode"; then
2865244390Srwatson	    arg2=$install_override_mode
2866244390Srwatson	    no_mode=false
2867244390Srwatson	  fi
2868244390Srwatson	  prev=
2869244390Srwatson	else
2870244390Srwatson	  dest=$arg
2871244390Srwatson	  continue
2872244390Srwatson	fi
2873244390Srwatson	;;
2874244390Srwatson      esac
2875244390Srwatson
2876244390Srwatson      # Aesthetically quote the argument.
2877244390Srwatson      func_quote_for_eval "$arg"
2878244390Srwatson      func_append install_prog " $func_quote_for_eval_result"
2879244390Srwatson      if test -n "$arg2"; then
2880244390Srwatson	func_quote_for_eval "$arg2"
2881244390Srwatson      fi
2882244390Srwatson      func_append install_shared_prog " $func_quote_for_eval_result"
2883244390Srwatson    done
2884244390Srwatson
2885244390Srwatson    test -z "$install_prog" && \
2886244390Srwatson      func_fatal_help "you must specify an install program"
2887244390Srwatson
2888244390Srwatson    test -n "$prev" && \
2889244390Srwatson      func_fatal_help "the \`$prev' option requires an argument"
2890244390Srwatson
2891244390Srwatson    if test -n "$install_override_mode" && $no_mode; then
2892244390Srwatson      if $install_cp; then :; else
2893244390Srwatson	func_quote_for_eval "$install_override_mode"
2894244390Srwatson	func_append install_shared_prog " -m $func_quote_for_eval_result"
2895244390Srwatson      fi
2896244390Srwatson    fi
2897244390Srwatson
2898244390Srwatson    if test -z "$files"; then
2899244390Srwatson      if test -z "$dest"; then
2900244390Srwatson	func_fatal_help "no file or destination specified"
2901244390Srwatson      else
2902244390Srwatson	func_fatal_help "you must specify a destination"
2903244390Srwatson      fi
2904244390Srwatson    fi
2905244390Srwatson
2906244390Srwatson    # Strip any trailing slash from the destination.
2907244390Srwatson    func_stripname '' '/' "$dest"
2908244390Srwatson    dest=$func_stripname_result
2909244390Srwatson
2910244390Srwatson    # Check to see that the destination is a directory.
2911244390Srwatson    test -d "$dest" && isdir=yes
2912244390Srwatson    if test "$isdir" = yes; then
2913244390Srwatson      destdir="$dest"
2914244390Srwatson      destname=
2915244390Srwatson    else
2916244390Srwatson      func_dirname_and_basename "$dest" "" "."
2917244390Srwatson      destdir="$func_dirname_result"
2918244390Srwatson      destname="$func_basename_result"
2919244390Srwatson
2920244390Srwatson      # Not a directory, so check to see that there is only one file specified.
2921244390Srwatson      set dummy $files; shift
2922244390Srwatson      test "$#" -gt 1 && \
2923244390Srwatson	func_fatal_help "\`$dest' is not a directory"
2924244390Srwatson    fi
2925244390Srwatson    case $destdir in
2926244390Srwatson    [\\/]* | [A-Za-z]:[\\/]*) ;;
2927244390Srwatson    *)
2928244390Srwatson      for file in $files; do
2929244390Srwatson	case $file in
2930244390Srwatson	*.lo) ;;
2931244390Srwatson	*)
2932244390Srwatson	  func_fatal_help "\`$destdir' must be an absolute directory name"
2933244390Srwatson	  ;;
2934244390Srwatson	esac
2935244390Srwatson      done
2936244390Srwatson      ;;
2937244390Srwatson    esac
2938244390Srwatson
2939244390Srwatson    # This variable tells wrapper scripts just to set variables rather
2940244390Srwatson    # than running their programs.
2941244390Srwatson    libtool_install_magic="$magic"
2942244390Srwatson
2943244390Srwatson    staticlibs=
2944244390Srwatson    future_libdirs=
2945244390Srwatson    current_libdirs=
2946244390Srwatson    for file in $files; do
2947244390Srwatson
2948244390Srwatson      # Do each installation.
2949244390Srwatson      case $file in
2950244390Srwatson      *.$libext)
2951244390Srwatson	# Do the static libraries later.
2952244390Srwatson	func_append staticlibs " $file"
2953244390Srwatson	;;
2954244390Srwatson
2955244390Srwatson      *.la)
2956244390Srwatson	func_resolve_sysroot "$file"
2957244390Srwatson	file=$func_resolve_sysroot_result
2958244390Srwatson
2959244390Srwatson	# Check to see that this really is a libtool archive.
2960244390Srwatson	func_lalib_unsafe_p "$file" \
2961244390Srwatson	  || func_fatal_help "\`$file' is not a valid libtool archive"
2962244390Srwatson
2963244390Srwatson	library_names=
2964244390Srwatson	old_library=
2965244390Srwatson	relink_command=
2966244390Srwatson	func_source "$file"
2967244390Srwatson
2968244390Srwatson	# Add the libdir to current_libdirs if it is the destination.
2969244390Srwatson	if test "X$destdir" = "X$libdir"; then
2970244390Srwatson	  case "$current_libdirs " in
2971244390Srwatson	  *" $libdir "*) ;;
2972244390Srwatson	  *) func_append current_libdirs " $libdir" ;;
2973244390Srwatson	  esac
2974244390Srwatson	else
2975244390Srwatson	  # Note the libdir as a future libdir.
2976244390Srwatson	  case "$future_libdirs " in
2977244390Srwatson	  *" $libdir "*) ;;
2978244390Srwatson	  *) func_append future_libdirs " $libdir" ;;
2979244390Srwatson	  esac
2980244390Srwatson	fi
2981244390Srwatson
2982244390Srwatson	func_dirname "$file" "/" ""
2983244390Srwatson	dir="$func_dirname_result"
2984244390Srwatson	func_append dir "$objdir"
2985244390Srwatson
2986244390Srwatson	if test -n "$relink_command"; then
2987244390Srwatson	  # Determine the prefix the user has applied to our future dir.
2988244390Srwatson	  inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
2989244390Srwatson
2990244390Srwatson	  # Don't allow the user to place us outside of our expected
2991244390Srwatson	  # location b/c this prevents finding dependent libraries that
2992244390Srwatson	  # are installed to the same prefix.
2993244390Srwatson	  # At present, this check doesn't affect windows .dll's that
2994244390Srwatson	  # are installed into $libdir/../bin (currently, that works fine)
2995244390Srwatson	  # but it's something to keep an eye on.
2996244390Srwatson	  test "$inst_prefix_dir" = "$destdir" && \
2997244390Srwatson	    func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
2998244390Srwatson
2999244390Srwatson	  if test -n "$inst_prefix_dir"; then
3000244390Srwatson	    # Stick the inst_prefix_dir data into the link command.
3001244390Srwatson	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
3002244390Srwatson	  else
3003244390Srwatson	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
3004244390Srwatson	  fi
3005244390Srwatson
3006244390Srwatson	  func_warning "relinking \`$file'"
3007244390Srwatson	  func_show_eval "$relink_command" \
3008244390Srwatson	    'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
3009244390Srwatson	fi
3010244390Srwatson
3011244390Srwatson	# See the names of the shared library.
3012244390Srwatson	set dummy $library_names; shift
3013244390Srwatson	if test -n "$1"; then
3014244390Srwatson	  realname="$1"
3015244390Srwatson	  shift
3016244390Srwatson
3017244390Srwatson	  srcname="$realname"
3018244390Srwatson	  test -n "$relink_command" && srcname="$realname"T
3019244390Srwatson
3020244390Srwatson	  # Install the shared library and build the symlinks.
3021244390Srwatson	  func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
3022244390Srwatson	      'exit $?'
3023244390Srwatson	  tstripme="$stripme"
3024244390Srwatson	  case $host_os in
3025244390Srwatson	  cygwin* | mingw* | pw32* | cegcc*)
3026244390Srwatson	    case $realname in
3027244390Srwatson	    *.dll.a)
3028244390Srwatson	      tstripme=""
3029244390Srwatson	      ;;
3030244390Srwatson	    esac
3031244390Srwatson	    ;;
3032244390Srwatson	  esac
3033244390Srwatson	  if test -n "$tstripme" && test -n "$striplib"; then
3034244390Srwatson	    func_show_eval "$striplib $destdir/$realname" 'exit $?'
3035244390Srwatson	  fi
3036244390Srwatson
3037244390Srwatson	  if test "$#" -gt 0; then
3038244390Srwatson	    # Delete the old symlinks, and create new ones.
3039244390Srwatson	    # Try `ln -sf' first, because the `ln' binary might depend on
3040244390Srwatson	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
3041244390Srwatson	    # so we also need to try rm && ln -s.
3042244390Srwatson	    for linkname
3043244390Srwatson	    do
3044244390Srwatson	      test "$linkname" != "$realname" \
3045244390Srwatson		&& func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
3046244390Srwatson	    done
3047244390Srwatson	  fi
3048244390Srwatson
3049244390Srwatson	  # Do each command in the postinstall commands.
3050244390Srwatson	  lib="$destdir/$realname"
3051244390Srwatson	  func_execute_cmds "$postinstall_cmds" 'exit $?'
3052244390Srwatson	fi
3053244390Srwatson
3054244390Srwatson	# Install the pseudo-library for information purposes.
3055244390Srwatson	func_basename "$file"
3056244390Srwatson	name="$func_basename_result"
3057244390Srwatson	instname="$dir/$name"i
3058244390Srwatson	func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
3059244390Srwatson
3060244390Srwatson	# Maybe install the static library, too.
3061244390Srwatson	test -n "$old_library" && func_append staticlibs " $dir/$old_library"
3062244390Srwatson	;;
3063244390Srwatson
3064244390Srwatson      *.lo)
3065244390Srwatson	# Install (i.e. copy) a libtool object.
3066244390Srwatson
3067244390Srwatson	# Figure out destination file name, if it wasn't already specified.
3068244390Srwatson	if test -n "$destname"; then
3069244390Srwatson	  destfile="$destdir/$destname"
3070244390Srwatson	else
3071244390Srwatson	  func_basename "$file"
3072244390Srwatson	  destfile="$func_basename_result"
3073244390Srwatson	  destfile="$destdir/$destfile"
3074244390Srwatson	fi
3075244390Srwatson
3076244390Srwatson	# Deduce the name of the destination old-style object file.
3077244390Srwatson	case $destfile in
3078244390Srwatson	*.lo)
3079244390Srwatson	  func_lo2o "$destfile"
3080244390Srwatson	  staticdest=$func_lo2o_result
3081244390Srwatson	  ;;
3082244390Srwatson	*.$objext)
3083244390Srwatson	  staticdest="$destfile"
3084244390Srwatson	  destfile=
3085244390Srwatson	  ;;
3086244390Srwatson	*)
3087244390Srwatson	  func_fatal_help "cannot copy a libtool object to \`$destfile'"
3088244390Srwatson	  ;;
3089244390Srwatson	esac
3090244390Srwatson
3091244390Srwatson	# Install the libtool object if requested.
3092244390Srwatson	test -n "$destfile" && \
3093244390Srwatson	  func_show_eval "$install_prog $file $destfile" 'exit $?'
3094244390Srwatson
3095244390Srwatson	# Install the old object if enabled.
3096244390Srwatson	if test "$build_old_libs" = yes; then
3097244390Srwatson	  # Deduce the name of the old-style object file.
3098244390Srwatson	  func_lo2o "$file"
3099244390Srwatson	  staticobj=$func_lo2o_result
3100244390Srwatson	  func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
3101244390Srwatson	fi
3102244390Srwatson	exit $EXIT_SUCCESS
3103244390Srwatson	;;
3104244390Srwatson
3105244390Srwatson      *)
3106244390Srwatson	# Figure out destination file name, if it wasn't already specified.
3107244390Srwatson	if test -n "$destname"; then
3108244390Srwatson	  destfile="$destdir/$destname"
3109244390Srwatson	else
3110244390Srwatson	  func_basename "$file"
3111244390Srwatson	  destfile="$func_basename_result"
3112244390Srwatson	  destfile="$destdir/$destfile"
3113244390Srwatson	fi
3114244390Srwatson
3115244390Srwatson	# If the file is missing, and there is a .exe on the end, strip it
3116244390Srwatson	# because it is most likely a libtool script we actually want to
3117244390Srwatson	# install
3118244390Srwatson	stripped_ext=""
3119244390Srwatson	case $file in
3120244390Srwatson	  *.exe)
3121244390Srwatson	    if test ! -f "$file"; then
3122244390Srwatson	      func_stripname '' '.exe' "$file"
3123244390Srwatson	      file=$func_stripname_result
3124244390Srwatson	      stripped_ext=".exe"
3125244390Srwatson	    fi
3126244390Srwatson	    ;;
3127244390Srwatson	esac
3128244390Srwatson
3129244390Srwatson	# Do a test to see if this is really a libtool program.
3130244390Srwatson	case $host in
3131244390Srwatson	*cygwin* | *mingw*)
3132244390Srwatson	    if func_ltwrapper_executable_p "$file"; then
3133244390Srwatson	      func_ltwrapper_scriptname "$file"
3134244390Srwatson	      wrapper=$func_ltwrapper_scriptname_result
3135244390Srwatson	    else
3136244390Srwatson	      func_stripname '' '.exe' "$file"
3137244390Srwatson	      wrapper=$func_stripname_result
3138244390Srwatson	    fi
3139244390Srwatson	    ;;
3140244390Srwatson	*)
3141244390Srwatson	    wrapper=$file
3142244390Srwatson	    ;;
3143244390Srwatson	esac
3144244390Srwatson	if func_ltwrapper_script_p "$wrapper"; then
3145244390Srwatson	  notinst_deplibs=
3146244390Srwatson	  relink_command=
3147244390Srwatson
3148244390Srwatson	  func_source "$wrapper"
3149244390Srwatson
3150244390Srwatson	  # Check the variables that should have been set.
3151244390Srwatson	  test -z "$generated_by_libtool_version" && \
3152244390Srwatson	    func_fatal_error "invalid libtool wrapper script \`$wrapper'"
3153244390Srwatson
3154244390Srwatson	  finalize=yes
3155244390Srwatson	  for lib in $notinst_deplibs; do
3156244390Srwatson	    # Check to see that each library is installed.
3157244390Srwatson	    libdir=
3158244390Srwatson	    if test -f "$lib"; then
3159244390Srwatson	      func_source "$lib"
3160244390Srwatson	    fi
3161244390Srwatson	    libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test
3162244390Srwatson	    if test -n "$libdir" && test ! -f "$libfile"; then
3163244390Srwatson	      func_warning "\`$lib' has not been installed in \`$libdir'"
3164244390Srwatson	      finalize=no
3165244390Srwatson	    fi
3166244390Srwatson	  done
3167244390Srwatson
3168244390Srwatson	  relink_command=
3169244390Srwatson	  func_source "$wrapper"
3170244390Srwatson
3171244390Srwatson	  outputname=
3172244390Srwatson	  if test "$fast_install" = no && test -n "$relink_command"; then
3173244390Srwatson	    $opt_dry_run || {
3174244390Srwatson	      if test "$finalize" = yes; then
3175244390Srwatson	        tmpdir=`func_mktempdir`
3176244390Srwatson		func_basename "$file$stripped_ext"
3177244390Srwatson		file="$func_basename_result"
3178244390Srwatson	        outputname="$tmpdir/$file"
3179244390Srwatson	        # Replace the output file specification.
3180244390Srwatson	        relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
3181244390Srwatson
3182244390Srwatson	        $opt_silent || {
3183244390Srwatson	          func_quote_for_expand "$relink_command"
3184244390Srwatson		  eval "func_echo $func_quote_for_expand_result"
3185244390Srwatson	        }
3186244390Srwatson	        if eval "$relink_command"; then :
3187244390Srwatson	          else
3188244390Srwatson		  func_error "error: relink \`$file' with the above command before installing it"
3189244390Srwatson		  $opt_dry_run || ${RM}r "$tmpdir"
3190244390Srwatson		  continue
3191244390Srwatson	        fi
3192244390Srwatson	        file="$outputname"
3193244390Srwatson	      else
3194244390Srwatson	        func_warning "cannot relink \`$file'"
3195244390Srwatson	      fi
3196244390Srwatson	    }
3197244390Srwatson	  else
3198244390Srwatson	    # Install the binary that we compiled earlier.
3199244390Srwatson	    file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
3200244390Srwatson	  fi
3201244390Srwatson	fi
3202244390Srwatson
3203244390Srwatson	# remove .exe since cygwin /usr/bin/install will append another
3204244390Srwatson	# one anyway
3205244390Srwatson	case $install_prog,$host in
3206244390Srwatson	*/usr/bin/install*,*cygwin*)
3207244390Srwatson	  case $file:$destfile in
3208244390Srwatson	  *.exe:*.exe)
3209244390Srwatson	    # this is ok
3210244390Srwatson	    ;;
3211244390Srwatson	  *.exe:*)
3212244390Srwatson	    destfile=$destfile.exe
3213244390Srwatson	    ;;
3214244390Srwatson	  *:*.exe)
3215244390Srwatson	    func_stripname '' '.exe' "$destfile"
3216244390Srwatson	    destfile=$func_stripname_result
3217244390Srwatson	    ;;
3218244390Srwatson	  esac
3219244390Srwatson	  ;;
3220244390Srwatson	esac
3221244390Srwatson	func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
3222244390Srwatson	$opt_dry_run || if test -n "$outputname"; then
3223244390Srwatson	  ${RM}r "$tmpdir"
3224244390Srwatson	fi
3225244390Srwatson	;;
3226244390Srwatson      esac
3227244390Srwatson    done
3228244390Srwatson
3229244390Srwatson    for file in $staticlibs; do
3230244390Srwatson      func_basename "$file"
3231244390Srwatson      name="$func_basename_result"
3232244390Srwatson
3233244390Srwatson      # Set up the ranlib parameters.
3234244390Srwatson      oldlib="$destdir/$name"
3235244390Srwatson      func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
3236244390Srwatson      tool_oldlib=$func_to_tool_file_result
3237244390Srwatson
3238244390Srwatson      func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
3239244390Srwatson
3240244390Srwatson      if test -n "$stripme" && test -n "$old_striplib"; then
3241244390Srwatson	func_show_eval "$old_striplib $tool_oldlib" 'exit $?'
3242244390Srwatson      fi
3243244390Srwatson
3244244390Srwatson      # Do each command in the postinstall commands.
3245244390Srwatson      func_execute_cmds "$old_postinstall_cmds" 'exit $?'
3246244390Srwatson    done
3247244390Srwatson
3248244390Srwatson    test -n "$future_libdirs" && \
3249244390Srwatson      func_warning "remember to run \`$progname --finish$future_libdirs'"
3250244390Srwatson
3251244390Srwatson    if test -n "$current_libdirs"; then
3252244390Srwatson      # Maybe just do a dry run.
3253244390Srwatson      $opt_dry_run && current_libdirs=" -n$current_libdirs"
3254244390Srwatson      exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
3255244390Srwatson    else
3256244390Srwatson      exit $EXIT_SUCCESS
3257244390Srwatson    fi
3258244390Srwatson}
3259244390Srwatson
3260244390Srwatsontest "$opt_mode" = install && func_mode_install ${1+"$@"}
3261244390Srwatson
3262244390Srwatson
3263244390Srwatson# func_generate_dlsyms outputname originator pic_p
3264244390Srwatson# Extract symbols from dlprefiles and create ${outputname}S.o with
3265244390Srwatson# a dlpreopen symbol table.
3266244390Srwatsonfunc_generate_dlsyms ()
3267244390Srwatson{
3268244390Srwatson    $opt_debug
3269244390Srwatson    my_outputname="$1"
3270244390Srwatson    my_originator="$2"
3271244390Srwatson    my_pic_p="${3-no}"
3272244390Srwatson    my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'`
3273244390Srwatson    my_dlsyms=
3274244390Srwatson
3275244390Srwatson    if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
3276244390Srwatson      if test -n "$NM" && test -n "$global_symbol_pipe"; then
3277244390Srwatson	my_dlsyms="${my_outputname}S.c"
3278244390Srwatson      else
3279244390Srwatson	func_error "not configured to extract global symbols from dlpreopened files"
3280244390Srwatson      fi
3281244390Srwatson    fi
3282244390Srwatson
3283244390Srwatson    if test -n "$my_dlsyms"; then
3284244390Srwatson      case $my_dlsyms in
3285244390Srwatson      "") ;;
3286244390Srwatson      *.c)
3287244390Srwatson	# Discover the nlist of each of the dlfiles.
3288244390Srwatson	nlist="$output_objdir/${my_outputname}.nm"
3289244390Srwatson
3290244390Srwatson	func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
3291244390Srwatson
3292244390Srwatson	# Parse the name list into a source file.
3293244390Srwatson	func_verbose "creating $output_objdir/$my_dlsyms"
3294244390Srwatson
3295244390Srwatson	$opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
3296244390Srwatson/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */
3297244390Srwatson/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */
3298244390Srwatson
3299244390Srwatson#ifdef __cplusplus
3300244390Srwatsonextern \"C\" {
3301244390Srwatson#endif
3302244390Srwatson
3303244390Srwatson#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
3304244390Srwatson#pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
3305244390Srwatson#endif
3306244390Srwatson
3307244390Srwatson/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
3308244390Srwatson#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
3309244390Srwatson/* DATA imports from DLLs on WIN32 con't be const, because runtime
3310244390Srwatson   relocations are performed -- see ld's documentation on pseudo-relocs.  */
3311244390Srwatson# define LT_DLSYM_CONST
3312244390Srwatson#elif defined(__osf__)
3313244390Srwatson/* This system does not cope well with relocations in const data.  */
3314244390Srwatson# define LT_DLSYM_CONST
3315244390Srwatson#else
3316244390Srwatson# define LT_DLSYM_CONST const
3317244390Srwatson#endif
3318244390Srwatson
3319244390Srwatson/* External symbol declarations for the compiler. */\
3320244390Srwatson"
3321244390Srwatson
3322244390Srwatson	if test "$dlself" = yes; then
3323244390Srwatson	  func_verbose "generating symbol list for \`$output'"
3324244390Srwatson
3325244390Srwatson	  $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
3326244390Srwatson
3327244390Srwatson	  # Add our own program objects to the symbol list.
3328244390Srwatson	  progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
3329244390Srwatson	  for progfile in $progfiles; do
3330244390Srwatson	    func_to_tool_file "$progfile" func_convert_file_msys_to_w32
3331244390Srwatson	    func_verbose "extracting global C symbols from \`$func_to_tool_file_result'"
3332244390Srwatson	    $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
3333244390Srwatson	  done
3334244390Srwatson
3335244390Srwatson	  if test -n "$exclude_expsyms"; then
3336244390Srwatson	    $opt_dry_run || {
3337244390Srwatson	      eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
3338244390Srwatson	      eval '$MV "$nlist"T "$nlist"'
3339244390Srwatson	    }
3340244390Srwatson	  fi
3341244390Srwatson
3342244390Srwatson	  if test -n "$export_symbols_regex"; then
3343244390Srwatson	    $opt_dry_run || {
3344244390Srwatson	      eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
3345244390Srwatson	      eval '$MV "$nlist"T "$nlist"'
3346244390Srwatson	    }
3347244390Srwatson	  fi
3348244390Srwatson
3349244390Srwatson	  # Prepare the list of exported symbols
3350244390Srwatson	  if test -z "$export_symbols"; then
3351244390Srwatson	    export_symbols="$output_objdir/$outputname.exp"
3352244390Srwatson	    $opt_dry_run || {
3353244390Srwatson	      $RM $export_symbols
3354244390Srwatson	      eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
3355244390Srwatson	      case $host in
3356244390Srwatson	      *cygwin* | *mingw* | *cegcc* )
3357244390Srwatson                eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
3358244390Srwatson                eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
3359244390Srwatson	        ;;
3360244390Srwatson	      esac
3361244390Srwatson	    }
3362244390Srwatson	  else
3363244390Srwatson	    $opt_dry_run || {
3364244390Srwatson	      eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
3365244390Srwatson	      eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
3366244390Srwatson	      eval '$MV "$nlist"T "$nlist"'
3367244390Srwatson	      case $host in
3368244390Srwatson	        *cygwin* | *mingw* | *cegcc* )
3369244390Srwatson	          eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
3370244390Srwatson	          eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
3371244390Srwatson	          ;;
3372244390Srwatson	      esac
3373244390Srwatson	    }
3374244390Srwatson	  fi
3375244390Srwatson	fi
3376244390Srwatson
3377244390Srwatson	for dlprefile in $dlprefiles; do
3378244390Srwatson	  func_verbose "extracting global C symbols from \`$dlprefile'"
3379244390Srwatson	  func_basename "$dlprefile"
3380244390Srwatson	  name="$func_basename_result"
3381244390Srwatson          case $host in
3382244390Srwatson	    *cygwin* | *mingw* | *cegcc* )
3383244390Srwatson	      # if an import library, we need to obtain dlname
3384244390Srwatson	      if func_win32_import_lib_p "$dlprefile"; then
3385244390Srwatson	        func_tr_sh "$dlprefile"
3386244390Srwatson	        eval "curr_lafile=\$libfile_$func_tr_sh_result"
3387244390Srwatson	        dlprefile_dlbasename=""
3388244390Srwatson	        if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
3389244390Srwatson	          # Use subshell, to avoid clobbering current variable values
3390244390Srwatson	          dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
3391244390Srwatson	          if test -n "$dlprefile_dlname" ; then
3392244390Srwatson	            func_basename "$dlprefile_dlname"
3393244390Srwatson	            dlprefile_dlbasename="$func_basename_result"
3394244390Srwatson	          else
3395244390Srwatson	            # no lafile. user explicitly requested -dlpreopen <import library>.
3396244390Srwatson	            $sharedlib_from_linklib_cmd "$dlprefile"
3397244390Srwatson	            dlprefile_dlbasename=$sharedlib_from_linklib_result
3398244390Srwatson	          fi
3399244390Srwatson	        fi
3400244390Srwatson	        $opt_dry_run || {
3401244390Srwatson	          if test -n "$dlprefile_dlbasename" ; then
3402244390Srwatson	            eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
3403244390Srwatson	          else
3404244390Srwatson	            func_warning "Could not compute DLL name from $name"
3405244390Srwatson	            eval '$ECHO ": $name " >> "$nlist"'
3406244390Srwatson	          fi
3407244390Srwatson	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
3408244390Srwatson	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe |
3409244390Srwatson	            $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'"
3410244390Srwatson	        }
3411244390Srwatson	      else # not an import lib
3412244390Srwatson	        $opt_dry_run || {
3413244390Srwatson	          eval '$ECHO ": $name " >> "$nlist"'
3414244390Srwatson	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
3415244390Srwatson	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
3416244390Srwatson	        }
3417244390Srwatson	      fi
3418244390Srwatson	    ;;
3419244390Srwatson	    *)
3420244390Srwatson	      $opt_dry_run || {
3421244390Srwatson	        eval '$ECHO ": $name " >> "$nlist"'
3422244390Srwatson	        func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
3423244390Srwatson	        eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
3424244390Srwatson	      }
3425244390Srwatson	    ;;
3426244390Srwatson          esac
3427244390Srwatson	done
3428244390Srwatson
3429244390Srwatson	$opt_dry_run || {
3430244390Srwatson	  # Make sure we have at least an empty file.
3431244390Srwatson	  test -f "$nlist" || : > "$nlist"
3432244390Srwatson
3433244390Srwatson	  if test -n "$exclude_expsyms"; then
3434244390Srwatson	    $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
3435244390Srwatson	    $MV "$nlist"T "$nlist"
3436244390Srwatson	  fi
3437244390Srwatson
3438244390Srwatson	  # Try sorting and uniquifying the output.
3439244390Srwatson	  if $GREP -v "^: " < "$nlist" |
3440244390Srwatson	      if sort -k 3 </dev/null >/dev/null 2>&1; then
3441244390Srwatson		sort -k 3
3442244390Srwatson	      else
3443244390Srwatson		sort +2
3444244390Srwatson	      fi |
3445244390Srwatson	      uniq > "$nlist"S; then
3446244390Srwatson	    :
3447244390Srwatson	  else
3448244390Srwatson	    $GREP -v "^: " < "$nlist" > "$nlist"S
3449244390Srwatson	  fi
3450244390Srwatson
3451244390Srwatson	  if test -f "$nlist"S; then
3452244390Srwatson	    eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
3453244390Srwatson	  else
3454244390Srwatson	    echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
3455244390Srwatson	  fi
3456244390Srwatson
3457244390Srwatson	  echo >> "$output_objdir/$my_dlsyms" "\
3458244390Srwatson
3459244390Srwatson/* The mapping between symbol names and symbols.  */
3460244390Srwatsontypedef struct {
3461244390Srwatson  const char *name;
3462244390Srwatson  void *address;
3463244390Srwatson} lt_dlsymlist;
3464244390Srwatsonextern LT_DLSYM_CONST lt_dlsymlist
3465244390Srwatsonlt_${my_prefix}_LTX_preloaded_symbols[];
3466244390SrwatsonLT_DLSYM_CONST lt_dlsymlist
3467244390Srwatsonlt_${my_prefix}_LTX_preloaded_symbols[] =
3468244390Srwatson{\
3469244390Srwatson  { \"$my_originator\", (void *) 0 },"
3470244390Srwatson
3471244390Srwatson	  case $need_lib_prefix in
3472244390Srwatson	  no)
3473244390Srwatson	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
3474244390Srwatson	    ;;
3475244390Srwatson	  *)
3476244390Srwatson	    eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
3477244390Srwatson	    ;;
3478244390Srwatson	  esac
3479244390Srwatson	  echo >> "$output_objdir/$my_dlsyms" "\
3480244390Srwatson  {0, (void *) 0}
3481244390Srwatson};
3482244390Srwatson
3483244390Srwatson/* This works around a problem in FreeBSD linker */
3484244390Srwatson#ifdef FREEBSD_WORKAROUND
3485244390Srwatsonstatic const void *lt_preloaded_setup() {
3486244390Srwatson  return lt_${my_prefix}_LTX_preloaded_symbols;
3487244390Srwatson}
3488244390Srwatson#endif
3489244390Srwatson
3490244390Srwatson#ifdef __cplusplus
3491244390Srwatson}
3492244390Srwatson#endif\
3493244390Srwatson"
3494244390Srwatson	} # !$opt_dry_run
3495244390Srwatson
3496244390Srwatson	pic_flag_for_symtable=
3497244390Srwatson	case "$compile_command " in
3498244390Srwatson	*" -static "*) ;;
3499244390Srwatson	*)
3500244390Srwatson	  case $host in
3501244390Srwatson	  # compiling the symbol table file with pic_flag works around
3502244390Srwatson	  # a FreeBSD bug that causes programs to crash when -lm is
3503244390Srwatson	  # linked before any other PIC object.  But we must not use
3504244390Srwatson	  # pic_flag when linking with -static.  The problem exists in
3505244390Srwatson	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
3506244390Srwatson	  *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
3507244390Srwatson	    pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
3508244390Srwatson	  *-*-hpux*)
3509244390Srwatson	    pic_flag_for_symtable=" $pic_flag"  ;;
3510244390Srwatson	  *)
3511244390Srwatson	    if test "X$my_pic_p" != Xno; then
3512244390Srwatson	      pic_flag_for_symtable=" $pic_flag"
3513244390Srwatson	    fi
3514244390Srwatson	    ;;
3515244390Srwatson	  esac
3516244390Srwatson	  ;;
3517244390Srwatson	esac
3518244390Srwatson	symtab_cflags=
3519244390Srwatson	for arg in $LTCFLAGS; do
3520244390Srwatson	  case $arg in
3521244390Srwatson	  -pie | -fpie | -fPIE) ;;
3522244390Srwatson	  *) func_append symtab_cflags " $arg" ;;
3523244390Srwatson	  esac
3524244390Srwatson	done
3525244390Srwatson
3526244390Srwatson	# Now compile the dynamic symbol file.
3527244390Srwatson	func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
3528244390Srwatson
3529244390Srwatson	# Clean up the generated files.
3530244390Srwatson	func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"'
3531244390Srwatson
3532244390Srwatson	# Transform the symbol file into the correct name.
3533244390Srwatson	symfileobj="$output_objdir/${my_outputname}S.$objext"
3534244390Srwatson	case $host in
3535244390Srwatson	*cygwin* | *mingw* | *cegcc* )
3536244390Srwatson	  if test -f "$output_objdir/$my_outputname.def"; then
3537244390Srwatson	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
3538244390Srwatson	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
3539244390Srwatson	  else
3540244390Srwatson	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3541244390Srwatson	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3542244390Srwatson	  fi
3543244390Srwatson	  ;;
3544244390Srwatson	*)
3545244390Srwatson	  compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3546244390Srwatson	  finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3547244390Srwatson	  ;;
3548244390Srwatson	esac
3549244390Srwatson	;;
3550244390Srwatson      *-*-freebsd*)
3551244390Srwatson	# FreeBSD doesn't need this...
3552244390Srwatson	;;
3553244390Srwatson      *)
3554244390Srwatson	func_fatal_error "unknown suffix for \`$my_dlsyms'"
3555244390Srwatson	;;
3556244390Srwatson      esac
3557244390Srwatson    else
3558244390Srwatson      # We keep going just in case the user didn't refer to
3559244390Srwatson      # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
3560244390Srwatson      # really was required.
3561244390Srwatson
3562244390Srwatson      # Nullify the symbol file.
3563244390Srwatson      compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
3564244390Srwatson      finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
3565244390Srwatson    fi
3566244390Srwatson}
3567244390Srwatson
3568244390Srwatson# func_win32_libid arg
3569244390Srwatson# return the library type of file 'arg'
3570244390Srwatson#
3571244390Srwatson# Need a lot of goo to handle *both* DLLs and import libs
3572244390Srwatson# Has to be a shell function in order to 'eat' the argument
3573244390Srwatson# that is supplied when $file_magic_command is called.
3574244390Srwatson# Despite the name, also deal with 64 bit binaries.
3575244390Srwatsonfunc_win32_libid ()
3576244390Srwatson{
3577244390Srwatson  $opt_debug
3578244390Srwatson  win32_libid_type="unknown"
3579244390Srwatson  win32_fileres=`file -L $1 2>/dev/null`
3580244390Srwatson  case $win32_fileres in
3581244390Srwatson  *ar\ archive\ import\ library*) # definitely import
3582244390Srwatson    win32_libid_type="x86 archive import"
3583156283Srwatson    ;;
3584244390Srwatson  *ar\ archive*) # could be an import, or static
3585244390Srwatson    # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
3586244390Srwatson    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
3587244390Srwatson       $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
3588244390Srwatson      func_to_tool_file "$1" func_convert_file_msys_to_w32
3589244390Srwatson      win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
3590244390Srwatson	$SED -n -e '
3591244390Srwatson	    1,100{
3592244390Srwatson		/ I /{
3593244390Srwatson		    s,.*,import,
3594244390Srwatson		    p
3595244390Srwatson		    q
3596244390Srwatson		}
3597244390Srwatson	    }'`
3598244390Srwatson      case $win32_nmres in
3599244390Srwatson      import*)  win32_libid_type="x86 archive import";;
3600244390Srwatson      *)        win32_libid_type="x86 archive static";;
3601244390Srwatson      esac
3602244390Srwatson    fi
3603244390Srwatson    ;;
3604244390Srwatson  *DLL*)
3605244390Srwatson    win32_libid_type="x86 DLL"
3606244390Srwatson    ;;
3607244390Srwatson  *executable*) # but shell scripts are "executable" too...
3608244390Srwatson    case $win32_fileres in
3609244390Srwatson    *MS\ Windows\ PE\ Intel*)
3610244390Srwatson      win32_libid_type="x86 DLL"
3611244390Srwatson      ;;
3612244390Srwatson    esac
3613244390Srwatson    ;;
3614244390Srwatson  esac
3615244390Srwatson  $ECHO "$win32_libid_type"
3616244390Srwatson}
3617156283Srwatson
3618244390Srwatson# func_cygming_dll_for_implib ARG
3619244390Srwatson#
3620244390Srwatson# Platform-specific function to extract the
3621244390Srwatson# name of the DLL associated with the specified
3622244390Srwatson# import library ARG.
3623244390Srwatson# Invoked by eval'ing the libtool variable
3624244390Srwatson#    $sharedlib_from_linklib_cmd
3625244390Srwatson# Result is available in the variable
3626244390Srwatson#    $sharedlib_from_linklib_result
3627244390Srwatsonfunc_cygming_dll_for_implib ()
3628244390Srwatson{
3629244390Srwatson  $opt_debug
3630244390Srwatson  sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
3631244390Srwatson}
3632244390Srwatson
3633244390Srwatson# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs
3634244390Srwatson#
3635244390Srwatson# The is the core of a fallback implementation of a
3636244390Srwatson# platform-specific function to extract the name of the
3637244390Srwatson# DLL associated with the specified import library LIBNAME.
3638244390Srwatson#
3639244390Srwatson# SECTION_NAME is either .idata$6 or .idata$7, depending
3640244390Srwatson# on the platform and compiler that created the implib.
3641244390Srwatson#
3642244390Srwatson# Echos the name of the DLL associated with the
3643244390Srwatson# specified import library.
3644244390Srwatsonfunc_cygming_dll_for_implib_fallback_core ()
3645244390Srwatson{
3646244390Srwatson  $opt_debug
3647244390Srwatson  match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
3648244390Srwatson  $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
3649244390Srwatson    $SED '/^Contents of section '"$match_literal"':/{
3650244390Srwatson      # Place marker at beginning of archive member dllname section
3651244390Srwatson      s/.*/====MARK====/
3652244390Srwatson      p
3653244390Srwatson      d
3654244390Srwatson    }
3655244390Srwatson    # These lines can sometimes be longer than 43 characters, but
3656244390Srwatson    # are always uninteresting
3657244390Srwatson    /:[	 ]*file format pe[i]\{,1\}-/d
3658244390Srwatson    /^In archive [^:]*:/d
3659244390Srwatson    # Ensure marker is printed
3660244390Srwatson    /^====MARK====/p
3661244390Srwatson    # Remove all lines with less than 43 characters
3662244390Srwatson    /^.\{43\}/!d
3663244390Srwatson    # From remaining lines, remove first 43 characters
3664244390Srwatson    s/^.\{43\}//' |
3665244390Srwatson    $SED -n '
3666244390Srwatson      # Join marker and all lines until next marker into a single line
3667244390Srwatson      /^====MARK====/ b para
3668244390Srwatson      H
3669244390Srwatson      $ b para
3670244390Srwatson      b
3671244390Srwatson      :para
3672244390Srwatson      x
3673244390Srwatson      s/\n//g
3674244390Srwatson      # Remove the marker
3675244390Srwatson      s/^====MARK====//
3676244390Srwatson      # Remove trailing dots and whitespace
3677244390Srwatson      s/[\. \t]*$//
3678244390Srwatson      # Print
3679244390Srwatson      /./p' |
3680244390Srwatson    # we now have a list, one entry per line, of the stringified
3681244390Srwatson    # contents of the appropriate section of all members of the
3682244390Srwatson    # archive which possess that section. Heuristic: eliminate
3683244390Srwatson    # all those which have a first or second character that is
3684244390Srwatson    # a '.' (that is, objdump's representation of an unprintable
3685244390Srwatson    # character.) This should work for all archives with less than
3686244390Srwatson    # 0x302f exports -- but will fail for DLLs whose name actually
3687244390Srwatson    # begins with a literal '.' or a single character followed by
3688244390Srwatson    # a '.'.
3689244390Srwatson    #
3690244390Srwatson    # Of those that remain, print the first one.
3691244390Srwatson    $SED -e '/^\./d;/^.\./d;q'
3692244390Srwatson}
3693244390Srwatson
3694244390Srwatson# func_cygming_gnu_implib_p ARG
3695244390Srwatson# This predicate returns with zero status (TRUE) if
3696244390Srwatson# ARG is a GNU/binutils-style import library. Returns
3697244390Srwatson# with nonzero status (FALSE) otherwise.
3698244390Srwatsonfunc_cygming_gnu_implib_p ()
3699244390Srwatson{
3700244390Srwatson  $opt_debug
3701244390Srwatson  func_to_tool_file "$1" func_convert_file_msys_to_w32
3702244390Srwatson  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)$'`
3703244390Srwatson  test -n "$func_cygming_gnu_implib_tmp"
3704244390Srwatson}
3705244390Srwatson
3706244390Srwatson# func_cygming_ms_implib_p ARG
3707244390Srwatson# This predicate returns with zero status (TRUE) if
3708244390Srwatson# ARG is an MS-style import library. Returns
3709244390Srwatson# with nonzero status (FALSE) otherwise.
3710244390Srwatsonfunc_cygming_ms_implib_p ()
3711244390Srwatson{
3712244390Srwatson  $opt_debug
3713244390Srwatson  func_to_tool_file "$1" func_convert_file_msys_to_w32
3714244390Srwatson  func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
3715244390Srwatson  test -n "$func_cygming_ms_implib_tmp"
3716244390Srwatson}
3717244390Srwatson
3718244390Srwatson# func_cygming_dll_for_implib_fallback ARG
3719244390Srwatson# Platform-specific function to extract the
3720244390Srwatson# name of the DLL associated with the specified
3721244390Srwatson# import library ARG.
3722244390Srwatson#
3723244390Srwatson# This fallback implementation is for use when $DLLTOOL
3724244390Srwatson# does not support the --identify-strict option.
3725244390Srwatson# Invoked by eval'ing the libtool variable
3726244390Srwatson#    $sharedlib_from_linklib_cmd
3727244390Srwatson# Result is available in the variable
3728244390Srwatson#    $sharedlib_from_linklib_result
3729244390Srwatsonfunc_cygming_dll_for_implib_fallback ()
3730244390Srwatson{
3731244390Srwatson  $opt_debug
3732244390Srwatson  if func_cygming_gnu_implib_p "$1" ; then
3733244390Srwatson    # binutils import library
3734244390Srwatson    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
3735244390Srwatson  elif func_cygming_ms_implib_p "$1" ; then
3736244390Srwatson    # ms-generated import library
3737244390Srwatson    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
3738244390Srwatson  else
3739244390Srwatson    # unknown
3740244390Srwatson    sharedlib_from_linklib_result=""
3741244390Srwatson  fi
3742244390Srwatson}
3743244390Srwatson
3744244390Srwatson
3745244390Srwatson# func_extract_an_archive dir oldlib
3746244390Srwatsonfunc_extract_an_archive ()
3747244390Srwatson{
3748244390Srwatson    $opt_debug
3749244390Srwatson    f_ex_an_ar_dir="$1"; shift
3750244390Srwatson    f_ex_an_ar_oldlib="$1"
3751244390Srwatson    if test "$lock_old_archive_extraction" = yes; then
3752244390Srwatson      lockfile=$f_ex_an_ar_oldlib.lock
3753244390Srwatson      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
3754244390Srwatson	func_echo "Waiting for $lockfile to be removed"
3755244390Srwatson	sleep 2
3756244390Srwatson      done
3757244390Srwatson    fi
3758244390Srwatson    func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
3759244390Srwatson		   'stat=$?; rm -f "$lockfile"; exit $stat'
3760244390Srwatson    if test "$lock_old_archive_extraction" = yes; then
3761244390Srwatson      $opt_dry_run || rm -f "$lockfile"
3762244390Srwatson    fi
3763244390Srwatson    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
3764244390Srwatson     :
3765244390Srwatson    else
3766244390Srwatson      func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
3767244390Srwatson    fi
3768244390Srwatson}
3769244390Srwatson
3770244390Srwatson
3771244390Srwatson# func_extract_archives gentop oldlib ...
3772244390Srwatsonfunc_extract_archives ()
3773244390Srwatson{
3774244390Srwatson    $opt_debug
3775244390Srwatson    my_gentop="$1"; shift
3776244390Srwatson    my_oldlibs=${1+"$@"}
3777244390Srwatson    my_oldobjs=""
3778244390Srwatson    my_xlib=""
3779244390Srwatson    my_xabs=""
3780244390Srwatson    my_xdir=""
3781244390Srwatson
3782244390Srwatson    for my_xlib in $my_oldlibs; do
3783244390Srwatson      # Extract the objects.
3784244390Srwatson      case $my_xlib in
3785244390Srwatson	[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
3786244390Srwatson	*) my_xabs=`pwd`"/$my_xlib" ;;
3787244390Srwatson      esac
3788244390Srwatson      func_basename "$my_xlib"
3789244390Srwatson      my_xlib="$func_basename_result"
3790244390Srwatson      my_xlib_u=$my_xlib
3791244390Srwatson      while :; do
3792244390Srwatson        case " $extracted_archives " in
3793244390Srwatson	*" $my_xlib_u "*)
3794244390Srwatson	  func_arith $extracted_serial + 1
3795244390Srwatson	  extracted_serial=$func_arith_result
3796244390Srwatson	  my_xlib_u=lt$extracted_serial-$my_xlib ;;
3797244390Srwatson	*) break ;;
3798244390Srwatson	esac
3799244390Srwatson      done
3800244390Srwatson      extracted_archives="$extracted_archives $my_xlib_u"
3801244390Srwatson      my_xdir="$my_gentop/$my_xlib_u"
3802244390Srwatson
3803244390Srwatson      func_mkdir_p "$my_xdir"
3804244390Srwatson
3805244390Srwatson      case $host in
3806244390Srwatson      *-darwin*)
3807244390Srwatson	func_verbose "Extracting $my_xabs"
3808244390Srwatson	# Do not bother doing anything if just a dry run
3809244390Srwatson	$opt_dry_run || {
3810244390Srwatson	  darwin_orig_dir=`pwd`
3811244390Srwatson	  cd $my_xdir || exit $?
3812244390Srwatson	  darwin_archive=$my_xabs
3813244390Srwatson	  darwin_curdir=`pwd`
3814244390Srwatson	  darwin_base_archive=`basename "$darwin_archive"`
3815244390Srwatson	  darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
3816244390Srwatson	  if test -n "$darwin_arches"; then
3817244390Srwatson	    darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
3818244390Srwatson	    darwin_arch=
3819244390Srwatson	    func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
3820244390Srwatson	    for darwin_arch in  $darwin_arches ; do
3821244390Srwatson	      func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
3822244390Srwatson	      $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
3823244390Srwatson	      cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
3824244390Srwatson	      func_extract_an_archive "`pwd`" "${darwin_base_archive}"
3825244390Srwatson	      cd "$darwin_curdir"
3826244390Srwatson	      $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
3827244390Srwatson	    done # $darwin_arches
3828244390Srwatson            ## Okay now we've a bunch of thin objects, gotta fatten them up :)
3829244390Srwatson	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u`
3830244390Srwatson	    darwin_file=
3831244390Srwatson	    darwin_files=
3832244390Srwatson	    for darwin_file in $darwin_filelist; do
3833244390Srwatson	      darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`
3834244390Srwatson	      $LIPO -create -output "$darwin_file" $darwin_files
3835244390Srwatson	    done # $darwin_filelist
3836244390Srwatson	    $RM -rf unfat-$$
3837244390Srwatson	    cd "$darwin_orig_dir"
3838244390Srwatson	  else
3839244390Srwatson	    cd $darwin_orig_dir
3840244390Srwatson	    func_extract_an_archive "$my_xdir" "$my_xabs"
3841244390Srwatson	  fi # $darwin_arches
3842244390Srwatson	} # !$opt_dry_run
3843244390Srwatson	;;
3844244390Srwatson      *)
3845244390Srwatson        func_extract_an_archive "$my_xdir" "$my_xabs"
3846244390Srwatson	;;
3847244390Srwatson      esac
3848244390Srwatson      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
3849244390Srwatson    done
3850244390Srwatson
3851244390Srwatson    func_extract_archives_result="$my_oldobjs"
3852244390Srwatson}
3853244390Srwatson
3854244390Srwatson
3855244390Srwatson# func_emit_wrapper [arg=no]
3856244390Srwatson#
3857244390Srwatson# Emit a libtool wrapper script on stdout.
3858244390Srwatson# Don't directly open a file because we may want to
3859244390Srwatson# incorporate the script contents within a cygwin/mingw
3860244390Srwatson# wrapper executable.  Must ONLY be called from within
3861244390Srwatson# func_mode_link because it depends on a number of variables
3862244390Srwatson# set therein.
3863244390Srwatson#
3864244390Srwatson# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
3865244390Srwatson# variable will take.  If 'yes', then the emitted script
3866244390Srwatson# will assume that the directory in which it is stored is
3867244390Srwatson# the $objdir directory.  This is a cygwin/mingw-specific
3868244390Srwatson# behavior.
3869244390Srwatsonfunc_emit_wrapper ()
3870244390Srwatson{
3871244390Srwatson	func_emit_wrapper_arg1=${1-no}
3872244390Srwatson
3873244390Srwatson	$ECHO "\
3874244390Srwatson#! $SHELL
3875244390Srwatson
3876244390Srwatson# $output - temporary wrapper script for $objdir/$outputname
3877244390Srwatson# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
3878244390Srwatson#
3879244390Srwatson# The $output program cannot be directly executed until all the libtool
3880244390Srwatson# libraries that it depends on are installed.
3881244390Srwatson#
3882244390Srwatson# This wrapper script should never be moved out of the build directory.
3883244390Srwatson# If it is, it will not operate correctly.
3884244390Srwatson
3885244390Srwatson# Sed substitution that helps us do robust quoting.  It backslashifies
3886244390Srwatson# metacharacters that are still active within double-quoted strings.
3887244390Srwatsonsed_quote_subst='$sed_quote_subst'
3888244390Srwatson
3889244390Srwatson# Be Bourne compatible
3890244390Srwatsonif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
3891244390Srwatson  emulate sh
3892244390Srwatson  NULLCMD=:
3893244390Srwatson  # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
3894244390Srwatson  # is contrary to our usage.  Disable this feature.
3895244390Srwatson  alias -g '\${1+\"\$@\"}'='\"\$@\"'
3896244390Srwatson  setopt NO_GLOB_SUBST
3897244390Srwatsonelse
3898244390Srwatson  case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
3899244390Srwatsonfi
3900244390SrwatsonBIN_SH=xpg4; export BIN_SH # for Tru64
3901244390SrwatsonDUALCASE=1; export DUALCASE # for MKS sh
3902244390Srwatson
3903244390Srwatson# The HP-UX ksh and POSIX shell print the target directory to stdout
3904244390Srwatson# if CDPATH is set.
3905244390Srwatson(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
3906244390Srwatson
3907244390Srwatsonrelink_command=\"$relink_command\"
3908244390Srwatson
3909244390Srwatson# This environment variable determines our operation mode.
3910244390Srwatsonif test \"\$libtool_install_magic\" = \"$magic\"; then
3911244390Srwatson  # install mode needs the following variables:
3912244390Srwatson  generated_by_libtool_version='$macro_version'
3913244390Srwatson  notinst_deplibs='$notinst_deplibs'
3914244390Srwatsonelse
3915244390Srwatson  # When we are sourced in execute mode, \$file and \$ECHO are already set.
3916244390Srwatson  if test \"\$libtool_execute_magic\" != \"$magic\"; then
3917244390Srwatson    file=\"\$0\""
3918244390Srwatson
3919244390Srwatson    qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"`
3920244390Srwatson    $ECHO "\
3921244390Srwatson
3922244390Srwatson# A function that is used when there is no print builtin or printf.
3923244390Srwatsonfunc_fallback_echo ()
3924244390Srwatson{
3925244390Srwatson  eval 'cat <<_LTECHO_EOF
3926244390Srwatson\$1
3927244390Srwatson_LTECHO_EOF'
3928244390Srwatson}
3929244390Srwatson    ECHO=\"$qECHO\"
3930244390Srwatson  fi
3931244390Srwatson
3932244390Srwatson# Very basic option parsing. These options are (a) specific to
3933244390Srwatson# the libtool wrapper, (b) are identical between the wrapper
3934244390Srwatson# /script/ and the wrapper /executable/ which is used only on
3935244390Srwatson# windows platforms, and (c) all begin with the string "--lt-"
3936244390Srwatson# (application programs are unlikely to have options which match
3937244390Srwatson# this pattern).
3938244390Srwatson#
3939244390Srwatson# There are only two supported options: --lt-debug and
3940244390Srwatson# --lt-dump-script. There is, deliberately, no --lt-help.
3941244390Srwatson#
3942244390Srwatson# The first argument to this parsing function should be the
3943244390Srwatson# script's $0 value, followed by "$@".
3944244390Srwatsonlt_option_debug=
3945244390Srwatsonfunc_parse_lt_options ()
3946244390Srwatson{
3947244390Srwatson  lt_script_arg0=\$0
3948244390Srwatson  shift
3949244390Srwatson  for lt_opt
3950244390Srwatson  do
3951244390Srwatson    case \"\$lt_opt\" in
3952244390Srwatson    --lt-debug) lt_option_debug=1 ;;
3953244390Srwatson    --lt-dump-script)
3954244390Srwatson        lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
3955244390Srwatson        test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
3956244390Srwatson        lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
3957244390Srwatson        cat \"\$lt_dump_D/\$lt_dump_F\"
3958244390Srwatson        exit 0
3959244390Srwatson      ;;
3960244390Srwatson    --lt-*)
3961244390Srwatson        \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
3962244390Srwatson        exit 1
3963244390Srwatson      ;;
3964244390Srwatson    esac
3965244390Srwatson  done
3966244390Srwatson
3967244390Srwatson  # Print the debug banner immediately:
3968244390Srwatson  if test -n \"\$lt_option_debug\"; then
3969244390Srwatson    echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2
3970244390Srwatson  fi
3971244390Srwatson}
3972244390Srwatson
3973244390Srwatson# Used when --lt-debug. Prints its arguments to stdout
3974244390Srwatson# (redirection is the responsibility of the caller)
3975244390Srwatsonfunc_lt_dump_args ()
3976244390Srwatson{
3977244390Srwatson  lt_dump_args_N=1;
3978244390Srwatson  for lt_arg
3979244390Srwatson  do
3980244390Srwatson    \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\"
3981244390Srwatson    lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
3982244390Srwatson  done
3983244390Srwatson}
3984244390Srwatson
3985244390Srwatson# Core function for launching the target application
3986244390Srwatsonfunc_exec_program_core ()
3987244390Srwatson{
3988244390Srwatson"
3989244390Srwatson  case $host in
3990244390Srwatson  # Backslashes separate directories on plain windows
3991244390Srwatson  *-*-mingw | *-*-os2* | *-cegcc*)
3992244390Srwatson    $ECHO "\
3993244390Srwatson      if test -n \"\$lt_option_debug\"; then
3994244390Srwatson        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2
3995244390Srwatson        func_lt_dump_args \${1+\"\$@\"} 1>&2
3996244390Srwatson      fi
3997244390Srwatson      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
3998244390Srwatson"
3999244390Srwatson    ;;
4000244390Srwatson
4001244390Srwatson  *)
4002244390Srwatson    $ECHO "\
4003244390Srwatson      if test -n \"\$lt_option_debug\"; then
4004244390Srwatson        \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2
4005244390Srwatson        func_lt_dump_args \${1+\"\$@\"} 1>&2
4006244390Srwatson      fi
4007244390Srwatson      exec \"\$progdir/\$program\" \${1+\"\$@\"}
4008244390Srwatson"
4009244390Srwatson    ;;
4010244390Srwatson  esac
4011244390Srwatson  $ECHO "\
4012244390Srwatson      \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
4013244390Srwatson      exit 1
4014244390Srwatson}
4015244390Srwatson
4016244390Srwatson# A function to encapsulate launching the target application
4017244390Srwatson# Strips options in the --lt-* namespace from \$@ and
4018244390Srwatson# launches target application with the remaining arguments.
4019244390Srwatsonfunc_exec_program ()
4020244390Srwatson{
4021244390Srwatson  case \" \$* \" in
4022244390Srwatson  *\\ --lt-*)
4023244390Srwatson    for lt_wr_arg
4024244390Srwatson    do
4025244390Srwatson      case \$lt_wr_arg in
4026244390Srwatson      --lt-*) ;;
4027244390Srwatson      *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
4028244390Srwatson      esac
4029244390Srwatson      shift
4030244390Srwatson    done ;;
4031244390Srwatson  esac
4032244390Srwatson  func_exec_program_core \${1+\"\$@\"}
4033244390Srwatson}
4034244390Srwatson
4035244390Srwatson  # Parse options
4036244390Srwatson  func_parse_lt_options \"\$0\" \${1+\"\$@\"}
4037244390Srwatson
4038244390Srwatson  # Find the directory that this script lives in.
4039244390Srwatson  thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
4040244390Srwatson  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
4041244390Srwatson
4042244390Srwatson  # Follow symbolic links until we get to the real thisdir.
4043244390Srwatson  file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
4044244390Srwatson  while test -n \"\$file\"; do
4045244390Srwatson    destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
4046244390Srwatson
4047244390Srwatson    # If there was a directory component, then change thisdir.
4048244390Srwatson    if test \"x\$destdir\" != \"x\$file\"; then
4049244390Srwatson      case \"\$destdir\" in
4050244390Srwatson      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
4051244390Srwatson      *) thisdir=\"\$thisdir/\$destdir\" ;;
4052244390Srwatson      esac
4053244390Srwatson    fi
4054244390Srwatson
4055244390Srwatson    file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
4056244390Srwatson    file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
4057244390Srwatson  done
4058244390Srwatson
4059244390Srwatson  # Usually 'no', except on cygwin/mingw when embedded into
4060244390Srwatson  # the cwrapper.
4061244390Srwatson  WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
4062244390Srwatson  if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
4063244390Srwatson    # special case for '.'
4064244390Srwatson    if test \"\$thisdir\" = \".\"; then
4065244390Srwatson      thisdir=\`pwd\`
4066244390Srwatson    fi
4067244390Srwatson    # remove .libs from thisdir
4068244390Srwatson    case \"\$thisdir\" in
4069244390Srwatson    *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
4070244390Srwatson    $objdir )   thisdir=. ;;
4071244390Srwatson    esac
4072244390Srwatson  fi
4073244390Srwatson
4074244390Srwatson  # Try to get the absolute directory name.
4075244390Srwatson  absdir=\`cd \"\$thisdir\" && pwd\`
4076244390Srwatson  test -n \"\$absdir\" && thisdir=\"\$absdir\"
4077244390Srwatson"
4078244390Srwatson
4079244390Srwatson	if test "$fast_install" = yes; then
4080244390Srwatson	  $ECHO "\
4081244390Srwatson  program=lt-'$outputname'$exeext
4082244390Srwatson  progdir=\"\$thisdir/$objdir\"
4083244390Srwatson
4084244390Srwatson  if test ! -f \"\$progdir/\$program\" ||
4085244390Srwatson     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
4086244390Srwatson       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
4087244390Srwatson
4088244390Srwatson    file=\"\$\$-\$program\"
4089244390Srwatson
4090244390Srwatson    if test ! -d \"\$progdir\"; then
4091244390Srwatson      $MKDIR \"\$progdir\"
4092244390Srwatson    else
4093244390Srwatson      $RM \"\$progdir/\$file\"
4094244390Srwatson    fi"
4095244390Srwatson
4096244390Srwatson	  $ECHO "\
4097244390Srwatson
4098244390Srwatson    # relink executable if necessary
4099244390Srwatson    if test -n \"\$relink_command\"; then
4100244390Srwatson      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
4101244390Srwatson      else
4102244390Srwatson	$ECHO \"\$relink_command_output\" >&2
4103244390Srwatson	$RM \"\$progdir/\$file\"
4104244390Srwatson	exit 1
4105244390Srwatson      fi
4106244390Srwatson    fi
4107244390Srwatson
4108244390Srwatson    $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
4109244390Srwatson    { $RM \"\$progdir/\$program\";
4110244390Srwatson      $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
4111244390Srwatson    $RM \"\$progdir/\$file\"
4112244390Srwatson  fi"
4113244390Srwatson	else
4114244390Srwatson	  $ECHO "\
4115244390Srwatson  program='$outputname'
4116244390Srwatson  progdir=\"\$thisdir/$objdir\"
4117244390Srwatson"
4118244390Srwatson	fi
4119244390Srwatson
4120244390Srwatson	$ECHO "\
4121244390Srwatson
4122244390Srwatson  if test -f \"\$progdir/\$program\"; then"
4123244390Srwatson
4124244390Srwatson	# fixup the dll searchpath if we need to.
4125244390Srwatson	#
4126244390Srwatson	# Fix the DLL searchpath if we need to.  Do this before prepending
4127244390Srwatson	# to shlibpath, because on Windows, both are PATH and uninstalled
4128244390Srwatson	# libraries must come first.
4129244390Srwatson	if test -n "$dllsearchpath"; then
4130244390Srwatson	  $ECHO "\
4131244390Srwatson    # Add the dll search path components to the executable PATH
4132244390Srwatson    PATH=$dllsearchpath:\$PATH
4133244390Srwatson"
4134244390Srwatson	fi
4135244390Srwatson
4136244390Srwatson	# Export our shlibpath_var if we have one.
4137244390Srwatson	if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
4138244390Srwatson	  $ECHO "\
4139244390Srwatson    # Add our own library path to $shlibpath_var
4140244390Srwatson    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
4141244390Srwatson
4142244390Srwatson    # Some systems cannot cope with colon-terminated $shlibpath_var
4143244390Srwatson    # The second colon is a workaround for a bug in BeOS R4 sed
4144244390Srwatson    $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
4145244390Srwatson
4146244390Srwatson    export $shlibpath_var
4147244390Srwatson"
4148244390Srwatson	fi
4149244390Srwatson
4150244390Srwatson	$ECHO "\
4151244390Srwatson    if test \"\$libtool_execute_magic\" != \"$magic\"; then
4152244390Srwatson      # Run the actual program with our arguments.
4153244390Srwatson      func_exec_program \${1+\"\$@\"}
4154244390Srwatson    fi
4155244390Srwatson  else
4156244390Srwatson    # The program doesn't exist.
4157244390Srwatson    \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
4158244390Srwatson    \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
4159244390Srwatson    \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
4160244390Srwatson    exit 1
4161244390Srwatson  fi
4162244390Srwatsonfi\
4163244390Srwatson"
4164244390Srwatson}
4165244390Srwatson
4166244390Srwatson
4167244390Srwatson# func_emit_cwrapperexe_src
4168244390Srwatson# emit the source code for a wrapper executable on stdout
4169244390Srwatson# Must ONLY be called from within func_mode_link because
4170244390Srwatson# it depends on a number of variable set therein.
4171244390Srwatsonfunc_emit_cwrapperexe_src ()
4172244390Srwatson{
4173244390Srwatson	cat <<EOF
4174244390Srwatson
4175244390Srwatson/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
4176244390Srwatson   Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
4177244390Srwatson
4178244390Srwatson   The $output program cannot be directly executed until all the libtool
4179244390Srwatson   libraries that it depends on are installed.
4180244390Srwatson
4181244390Srwatson   This wrapper executable should never be moved out of the build directory.
4182244390Srwatson   If it is, it will not operate correctly.
4183244390Srwatson*/
4184244390SrwatsonEOF
4185244390Srwatson	    cat <<"EOF"
4186244390Srwatson#ifdef _MSC_VER
4187244390Srwatson# define _CRT_SECURE_NO_DEPRECATE 1
4188244390Srwatson#endif
4189244390Srwatson#include <stdio.h>
4190244390Srwatson#include <stdlib.h>
4191244390Srwatson#ifdef _MSC_VER
4192244390Srwatson# include <direct.h>
4193244390Srwatson# include <process.h>
4194244390Srwatson# include <io.h>
4195244390Srwatson#else
4196244390Srwatson# include <unistd.h>
4197244390Srwatson# include <stdint.h>
4198244390Srwatson# ifdef __CYGWIN__
4199244390Srwatson#  include <io.h>
4200244390Srwatson# endif
4201244390Srwatson#endif
4202244390Srwatson#include <malloc.h>
4203244390Srwatson#include <stdarg.h>
4204244390Srwatson#include <assert.h>
4205244390Srwatson#include <string.h>
4206244390Srwatson#include <ctype.h>
4207244390Srwatson#include <errno.h>
4208244390Srwatson#include <fcntl.h>
4209244390Srwatson#include <sys/stat.h>
4210244390Srwatson
4211244390Srwatson/* declarations of non-ANSI functions */
4212244390Srwatson#if defined(__MINGW32__)
4213244390Srwatson# ifdef __STRICT_ANSI__
4214244390Srwatsonint _putenv (const char *);
4215244390Srwatson# endif
4216244390Srwatson#elif defined(__CYGWIN__)
4217244390Srwatson# ifdef __STRICT_ANSI__
4218244390Srwatsonchar *realpath (const char *, char *);
4219244390Srwatsonint putenv (char *);
4220244390Srwatsonint setenv (const char *, const char *, int);
4221244390Srwatson# endif
4222244390Srwatson/* #elif defined (other platforms) ... */
4223244390Srwatson#endif
4224244390Srwatson
4225244390Srwatson/* portability defines, excluding path handling macros */
4226244390Srwatson#if defined(_MSC_VER)
4227244390Srwatson# define setmode _setmode
4228244390Srwatson# define stat    _stat
4229244390Srwatson# define chmod   _chmod
4230244390Srwatson# define getcwd  _getcwd
4231244390Srwatson# define putenv  _putenv
4232244390Srwatson# define S_IXUSR _S_IEXEC
4233244390Srwatson# ifndef _INTPTR_T_DEFINED
4234244390Srwatson#  define _INTPTR_T_DEFINED
4235244390Srwatson#  define intptr_t int
4236244390Srwatson# endif
4237244390Srwatson#elif defined(__MINGW32__)
4238244390Srwatson# define setmode _setmode
4239244390Srwatson# define stat    _stat
4240244390Srwatson# define chmod   _chmod
4241244390Srwatson# define getcwd  _getcwd
4242244390Srwatson# define putenv  _putenv
4243244390Srwatson#elif defined(__CYGWIN__)
4244244390Srwatson# define HAVE_SETENV
4245244390Srwatson# define FOPEN_WB "wb"
4246244390Srwatson/* #elif defined (other platforms) ... */
4247244390Srwatson#endif
4248244390Srwatson
4249244390Srwatson#if defined(PATH_MAX)
4250244390Srwatson# define LT_PATHMAX PATH_MAX
4251244390Srwatson#elif defined(MAXPATHLEN)
4252244390Srwatson# define LT_PATHMAX MAXPATHLEN
4253244390Srwatson#else
4254244390Srwatson# define LT_PATHMAX 1024
4255244390Srwatson#endif
4256244390Srwatson
4257244390Srwatson#ifndef S_IXOTH
4258244390Srwatson# define S_IXOTH 0
4259244390Srwatson#endif
4260244390Srwatson#ifndef S_IXGRP
4261244390Srwatson# define S_IXGRP 0
4262244390Srwatson#endif
4263244390Srwatson
4264244390Srwatson/* path handling portability macros */
4265244390Srwatson#ifndef DIR_SEPARATOR
4266244390Srwatson# define DIR_SEPARATOR '/'
4267244390Srwatson# define PATH_SEPARATOR ':'
4268244390Srwatson#endif
4269244390Srwatson
4270244390Srwatson#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
4271244390Srwatson  defined (__OS2__)
4272244390Srwatson# define HAVE_DOS_BASED_FILE_SYSTEM
4273244390Srwatson# define FOPEN_WB "wb"
4274244390Srwatson# ifndef DIR_SEPARATOR_2
4275244390Srwatson#  define DIR_SEPARATOR_2 '\\'
4276244390Srwatson# endif
4277244390Srwatson# ifndef PATH_SEPARATOR_2
4278244390Srwatson#  define PATH_SEPARATOR_2 ';'
4279244390Srwatson# endif
4280244390Srwatson#endif
4281244390Srwatson
4282244390Srwatson#ifndef DIR_SEPARATOR_2
4283244390Srwatson# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
4284244390Srwatson#else /* DIR_SEPARATOR_2 */
4285244390Srwatson# define IS_DIR_SEPARATOR(ch) \
4286244390Srwatson	(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
4287244390Srwatson#endif /* DIR_SEPARATOR_2 */
4288244390Srwatson
4289244390Srwatson#ifndef PATH_SEPARATOR_2
4290244390Srwatson# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
4291244390Srwatson#else /* PATH_SEPARATOR_2 */
4292244390Srwatson# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
4293244390Srwatson#endif /* PATH_SEPARATOR_2 */
4294244390Srwatson
4295244390Srwatson#ifndef FOPEN_WB
4296244390Srwatson# define FOPEN_WB "w"
4297244390Srwatson#endif
4298244390Srwatson#ifndef _O_BINARY
4299244390Srwatson# define _O_BINARY 0
4300244390Srwatson#endif
4301244390Srwatson
4302244390Srwatson#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
4303244390Srwatson#define XFREE(stale) do { \
4304244390Srwatson  if (stale) { free ((void *) stale); stale = 0; } \
4305244390Srwatson} while (0)
4306244390Srwatson
4307244390Srwatson#if defined(LT_DEBUGWRAPPER)
4308244390Srwatsonstatic int lt_debug = 1;
4309244390Srwatson#else
4310244390Srwatsonstatic int lt_debug = 0;
4311244390Srwatson#endif
4312244390Srwatson
4313244390Srwatsonconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */
4314244390Srwatson
4315244390Srwatsonvoid *xmalloc (size_t num);
4316244390Srwatsonchar *xstrdup (const char *string);
4317244390Srwatsonconst char *base_name (const char *name);
4318244390Srwatsonchar *find_executable (const char *wrapper);
4319244390Srwatsonchar *chase_symlinks (const char *pathspec);
4320244390Srwatsonint make_executable (const char *path);
4321244390Srwatsonint check_executable (const char *path);
4322244390Srwatsonchar *strendzap (char *str, const char *pat);
4323244390Srwatsonvoid lt_debugprintf (const char *file, int line, const char *fmt, ...);
4324244390Srwatsonvoid lt_fatal (const char *file, int line, const char *message, ...);
4325244390Srwatsonstatic const char *nonnull (const char *s);
4326244390Srwatsonstatic const char *nonempty (const char *s);
4327244390Srwatsonvoid lt_setenv (const char *name, const char *value);
4328244390Srwatsonchar *lt_extend_str (const char *orig_value, const char *add, int to_end);
4329244390Srwatsonvoid lt_update_exe_path (const char *name, const char *value);
4330244390Srwatsonvoid lt_update_lib_path (const char *name, const char *value);
4331244390Srwatsonchar **prepare_spawn (char **argv);
4332244390Srwatsonvoid lt_dump_script (FILE *f);
4333244390SrwatsonEOF
4334244390Srwatson
4335244390Srwatson	    cat <<EOF
4336244390Srwatsonvolatile const char * MAGIC_EXE = "$magic_exe";
4337244390Srwatsonconst char * LIB_PATH_VARNAME = "$shlibpath_var";
4338244390SrwatsonEOF
4339244390Srwatson
4340244390Srwatson	    if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
4341244390Srwatson              func_to_host_path "$temp_rpath"
4342244390Srwatson	      cat <<EOF
4343244390Srwatsonconst char * LIB_PATH_VALUE   = "$func_to_host_path_result";
4344244390SrwatsonEOF
4345244390Srwatson	    else
4346244390Srwatson	      cat <<"EOF"
4347244390Srwatsonconst char * LIB_PATH_VALUE   = "";
4348244390SrwatsonEOF
4349244390Srwatson	    fi
4350244390Srwatson
4351244390Srwatson	    if test -n "$dllsearchpath"; then
4352244390Srwatson              func_to_host_path "$dllsearchpath:"
4353244390Srwatson	      cat <<EOF
4354244390Srwatsonconst char * EXE_PATH_VARNAME = "PATH";
4355244390Srwatsonconst char * EXE_PATH_VALUE   = "$func_to_host_path_result";
4356244390SrwatsonEOF
4357244390Srwatson	    else
4358244390Srwatson	      cat <<"EOF"
4359244390Srwatsonconst char * EXE_PATH_VARNAME = "";
4360244390Srwatsonconst char * EXE_PATH_VALUE   = "";
4361244390SrwatsonEOF
4362244390Srwatson	    fi
4363244390Srwatson
4364244390Srwatson	    if test "$fast_install" = yes; then
4365244390Srwatson	      cat <<EOF
4366244390Srwatsonconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
4367244390SrwatsonEOF
4368244390Srwatson	    else
4369244390Srwatson	      cat <<EOF
4370244390Srwatsonconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
4371244390SrwatsonEOF
4372244390Srwatson	    fi
4373244390Srwatson
4374244390Srwatson
4375244390Srwatson	    cat <<"EOF"
4376244390Srwatson
4377244390Srwatson#define LTWRAPPER_OPTION_PREFIX         "--lt-"
4378244390Srwatson
4379244390Srwatsonstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
4380244390Srwatsonstatic const char *dumpscript_opt       = LTWRAPPER_OPTION_PREFIX "dump-script";
4381244390Srwatsonstatic const char *debug_opt            = LTWRAPPER_OPTION_PREFIX "debug";
4382244390Srwatson
4383244390Srwatsonint
4384244390Srwatsonmain (int argc, char *argv[])
4385244390Srwatson{
4386244390Srwatson  char **newargz;
4387244390Srwatson  int  newargc;
4388244390Srwatson  char *tmp_pathspec;
4389244390Srwatson  char *actual_cwrapper_path;
4390244390Srwatson  char *actual_cwrapper_name;
4391244390Srwatson  char *target_name;
4392244390Srwatson  char *lt_argv_zero;
4393244390Srwatson  intptr_t rval = 127;
4394244390Srwatson
4395244390Srwatson  int i;
4396244390Srwatson
4397244390Srwatson  program_name = (char *) xstrdup (base_name (argv[0]));
4398244390Srwatson  newargz = XMALLOC (char *, argc + 1);
4399244390Srwatson
4400244390Srwatson  /* very simple arg parsing; don't want to rely on getopt
4401244390Srwatson   * also, copy all non cwrapper options to newargz, except
4402244390Srwatson   * argz[0], which is handled differently
4403244390Srwatson   */
4404244390Srwatson  newargc=0;
4405244390Srwatson  for (i = 1; i < argc; i++)
4406244390Srwatson    {
4407244390Srwatson      if (strcmp (argv[i], dumpscript_opt) == 0)
4408244390Srwatson	{
4409244390SrwatsonEOF
4410244390Srwatson	    case "$host" in
4411244390Srwatson	      *mingw* | *cygwin* )
4412244390Srwatson		# make stdout use "unix" line endings
4413244390Srwatson		echo "          setmode(1,_O_BINARY);"
4414244390Srwatson		;;
4415244390Srwatson	      esac
4416244390Srwatson
4417244390Srwatson	    cat <<"EOF"
4418244390Srwatson	  lt_dump_script (stdout);
4419244390Srwatson	  return 0;
4420244390Srwatson	}
4421244390Srwatson      if (strcmp (argv[i], debug_opt) == 0)
4422244390Srwatson	{
4423244390Srwatson          lt_debug = 1;
4424244390Srwatson          continue;
4425244390Srwatson	}
4426244390Srwatson      if (strcmp (argv[i], ltwrapper_option_prefix) == 0)
4427244390Srwatson        {
4428244390Srwatson          /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
4429244390Srwatson             namespace, but it is not one of the ones we know about and
4430244390Srwatson             have already dealt with, above (inluding dump-script), then
4431244390Srwatson             report an error. Otherwise, targets might begin to believe
4432244390Srwatson             they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
4433244390Srwatson             namespace. The first time any user complains about this, we'll
4434244390Srwatson             need to make LTWRAPPER_OPTION_PREFIX a configure-time option
4435244390Srwatson             or a configure.ac-settable value.
4436244390Srwatson           */
4437244390Srwatson          lt_fatal (__FILE__, __LINE__,
4438244390Srwatson		    "unrecognized %s option: '%s'",
4439244390Srwatson                    ltwrapper_option_prefix, argv[i]);
4440244390Srwatson        }
4441244390Srwatson      /* otherwise ... */
4442244390Srwatson      newargz[++newargc] = xstrdup (argv[i]);
4443244390Srwatson    }
4444244390Srwatson  newargz[++newargc] = NULL;
4445244390Srwatson
4446244390SrwatsonEOF
4447244390Srwatson	    cat <<EOF
4448244390Srwatson  /* The GNU banner must be the first non-error debug message */
4449244390Srwatson  lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\n");
4450244390SrwatsonEOF
4451244390Srwatson	    cat <<"EOF"
4452244390Srwatson  lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
4453244390Srwatson  lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name);
4454244390Srwatson
4455244390Srwatson  tmp_pathspec = find_executable (argv[0]);
4456244390Srwatson  if (tmp_pathspec == NULL)
4457244390Srwatson    lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]);
4458244390Srwatson  lt_debugprintf (__FILE__, __LINE__,
4459244390Srwatson                  "(main) found exe (before symlink chase) at: %s\n",
4460244390Srwatson		  tmp_pathspec);
4461244390Srwatson
4462244390Srwatson  actual_cwrapper_path = chase_symlinks (tmp_pathspec);
4463244390Srwatson  lt_debugprintf (__FILE__, __LINE__,
4464244390Srwatson                  "(main) found exe (after symlink chase) at: %s\n",
4465244390Srwatson		  actual_cwrapper_path);
4466244390Srwatson  XFREE (tmp_pathspec);
4467244390Srwatson
4468244390Srwatson  actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));
4469244390Srwatson  strendzap (actual_cwrapper_path, actual_cwrapper_name);
4470244390Srwatson
4471244390Srwatson  /* wrapper name transforms */
4472244390Srwatson  strendzap (actual_cwrapper_name, ".exe");
4473244390Srwatson  tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
4474244390Srwatson  XFREE (actual_cwrapper_name);
4475244390Srwatson  actual_cwrapper_name = tmp_pathspec;
4476244390Srwatson  tmp_pathspec = 0;
4477244390Srwatson
4478244390Srwatson  /* target_name transforms -- use actual target program name; might have lt- prefix */
4479244390Srwatson  target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
4480244390Srwatson  strendzap (target_name, ".exe");
4481244390Srwatson  tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
4482244390Srwatson  XFREE (target_name);
4483244390Srwatson  target_name = tmp_pathspec;
4484244390Srwatson  tmp_pathspec = 0;
4485244390Srwatson
4486244390Srwatson  lt_debugprintf (__FILE__, __LINE__,
4487244390Srwatson		  "(main) libtool target name: %s\n",
4488244390Srwatson		  target_name);
4489244390SrwatsonEOF
4490244390Srwatson
4491244390Srwatson	    cat <<EOF
4492244390Srwatson  newargz[0] =
4493244390Srwatson    XMALLOC (char, (strlen (actual_cwrapper_path) +
4494244390Srwatson		    strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
4495244390Srwatson  strcpy (newargz[0], actual_cwrapper_path);
4496244390Srwatson  strcat (newargz[0], "$objdir");
4497244390Srwatson  strcat (newargz[0], "/");
4498244390SrwatsonEOF
4499244390Srwatson
4500244390Srwatson	    cat <<"EOF"
4501244390Srwatson  /* stop here, and copy so we don't have to do this twice */
4502244390Srwatson  tmp_pathspec = xstrdup (newargz[0]);
4503244390Srwatson
4504244390Srwatson  /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
4505244390Srwatson  strcat (newargz[0], actual_cwrapper_name);
4506244390Srwatson
4507244390Srwatson  /* DO want the lt- prefix here if it exists, so use target_name */
4508244390Srwatson  lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
4509244390Srwatson  XFREE (tmp_pathspec);
4510244390Srwatson  tmp_pathspec = NULL;
4511244390SrwatsonEOF
4512244390Srwatson
4513244390Srwatson	    case $host_os in
4514244390Srwatson	      mingw*)
4515244390Srwatson	    cat <<"EOF"
4516244390Srwatson  {
4517244390Srwatson    char* p;
4518244390Srwatson    while ((p = strchr (newargz[0], '\\')) != NULL)
4519244390Srwatson      {
4520244390Srwatson	*p = '/';
4521244390Srwatson      }
4522244390Srwatson    while ((p = strchr (lt_argv_zero, '\\')) != NULL)
4523244390Srwatson      {
4524244390Srwatson	*p = '/';
4525244390Srwatson      }
4526244390Srwatson  }
4527244390SrwatsonEOF
4528244390Srwatson	    ;;
4529244390Srwatson	    esac
4530244390Srwatson
4531244390Srwatson	    cat <<"EOF"
4532244390Srwatson  XFREE (target_name);
4533244390Srwatson  XFREE (actual_cwrapper_path);
4534244390Srwatson  XFREE (actual_cwrapper_name);
4535244390Srwatson
4536244390Srwatson  lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
4537244390Srwatson  lt_setenv ("DUALCASE", "1");  /* for MSK sh */
4538244390Srwatson  /* Update the DLL searchpath.  EXE_PATH_VALUE ($dllsearchpath) must
4539244390Srwatson     be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath)
4540244390Srwatson     because on Windows, both *_VARNAMEs are PATH but uninstalled
4541244390Srwatson     libraries must come first. */
4542244390Srwatson  lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
4543244390Srwatson  lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
4544244390Srwatson
4545244390Srwatson  lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",
4546244390Srwatson		  nonnull (lt_argv_zero));
4547244390Srwatson  for (i = 0; i < newargc; i++)
4548244390Srwatson    {
4549244390Srwatson      lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n",
4550244390Srwatson		      i, nonnull (newargz[i]));
4551244390Srwatson    }
4552244390Srwatson
4553244390SrwatsonEOF
4554244390Srwatson
4555244390Srwatson	    case $host_os in
4556244390Srwatson	      mingw*)
4557244390Srwatson		cat <<"EOF"
4558244390Srwatson  /* execv doesn't actually work on mingw as expected on unix */
4559244390Srwatson  newargz = prepare_spawn (newargz);
4560244390Srwatson  rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
4561244390Srwatson  if (rval == -1)
4562244390Srwatson    {
4563244390Srwatson      /* failed to start process */
4564244390Srwatson      lt_debugprintf (__FILE__, __LINE__,
4565244390Srwatson		      "(main) failed to launch target \"%s\": %s\n",
4566244390Srwatson		      lt_argv_zero, nonnull (strerror (errno)));
4567244390Srwatson      return 127;
4568244390Srwatson    }
4569244390Srwatson  return rval;
4570244390SrwatsonEOF
4571244390Srwatson		;;
4572244390Srwatson	      *)
4573244390Srwatson		cat <<"EOF"
4574244390Srwatson  execv (lt_argv_zero, newargz);
4575244390Srwatson  return rval; /* =127, but avoids unused variable warning */
4576244390SrwatsonEOF
4577244390Srwatson		;;
4578244390Srwatson	    esac
4579244390Srwatson
4580244390Srwatson	    cat <<"EOF"
4581244390Srwatson}
4582244390Srwatson
4583244390Srwatsonvoid *
4584244390Srwatsonxmalloc (size_t num)
4585244390Srwatson{
4586244390Srwatson  void *p = (void *) malloc (num);
4587244390Srwatson  if (!p)
4588244390Srwatson    lt_fatal (__FILE__, __LINE__, "memory exhausted");
4589244390Srwatson
4590244390Srwatson  return p;
4591244390Srwatson}
4592244390Srwatson
4593244390Srwatsonchar *
4594244390Srwatsonxstrdup (const char *string)
4595244390Srwatson{
4596244390Srwatson  return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
4597244390Srwatson			  string) : NULL;
4598244390Srwatson}
4599244390Srwatson
4600244390Srwatsonconst char *
4601244390Srwatsonbase_name (const char *name)
4602244390Srwatson{
4603244390Srwatson  const char *base;
4604244390Srwatson
4605244390Srwatson#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4606244390Srwatson  /* Skip over the disk name in MSDOS pathnames. */
4607244390Srwatson  if (isalpha ((unsigned char) name[0]) && name[1] == ':')
4608244390Srwatson    name += 2;
4609244390Srwatson#endif
4610244390Srwatson
4611244390Srwatson  for (base = name; *name; name++)
4612244390Srwatson    if (IS_DIR_SEPARATOR (*name))
4613244390Srwatson      base = name + 1;
4614244390Srwatson  return base;
4615244390Srwatson}
4616244390Srwatson
4617244390Srwatsonint
4618244390Srwatsoncheck_executable (const char *path)
4619244390Srwatson{
4620244390Srwatson  struct stat st;
4621244390Srwatson
4622244390Srwatson  lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n",
4623244390Srwatson                  nonempty (path));
4624244390Srwatson  if ((!path) || (!*path))
4625244390Srwatson    return 0;
4626244390Srwatson
4627244390Srwatson  if ((stat (path, &st) >= 0)
4628244390Srwatson      && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
4629244390Srwatson    return 1;
4630244390Srwatson  else
4631244390Srwatson    return 0;
4632244390Srwatson}
4633244390Srwatson
4634244390Srwatsonint
4635244390Srwatsonmake_executable (const char *path)
4636244390Srwatson{
4637244390Srwatson  int rval = 0;
4638244390Srwatson  struct stat st;
4639244390Srwatson
4640244390Srwatson  lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n",
4641244390Srwatson                  nonempty (path));
4642244390Srwatson  if ((!path) || (!*path))
4643244390Srwatson    return 0;
4644244390Srwatson
4645244390Srwatson  if (stat (path, &st) >= 0)
4646244390Srwatson    {
4647244390Srwatson      rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
4648244390Srwatson    }
4649244390Srwatson  return rval;
4650244390Srwatson}
4651244390Srwatson
4652244390Srwatson/* Searches for the full path of the wrapper.  Returns
4653244390Srwatson   newly allocated full path name if found, NULL otherwise
4654244390Srwatson   Does not chase symlinks, even on platforms that support them.
4655244390Srwatson*/
4656244390Srwatsonchar *
4657244390Srwatsonfind_executable (const char *wrapper)
4658244390Srwatson{
4659244390Srwatson  int has_slash = 0;
4660244390Srwatson  const char *p;
4661244390Srwatson  const char *p_next;
4662244390Srwatson  /* static buffer for getcwd */
4663244390Srwatson  char tmp[LT_PATHMAX + 1];
4664244390Srwatson  int tmp_len;
4665244390Srwatson  char *concat_name;
4666244390Srwatson
4667244390Srwatson  lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
4668244390Srwatson                  nonempty (wrapper));
4669244390Srwatson
4670244390Srwatson  if ((wrapper == NULL) || (*wrapper == '\0'))
4671244390Srwatson    return NULL;
4672244390Srwatson
4673244390Srwatson  /* Absolute path? */
4674244390Srwatson#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4675244390Srwatson  if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
4676244390Srwatson    {
4677244390Srwatson      concat_name = xstrdup (wrapper);
4678244390Srwatson      if (check_executable (concat_name))
4679244390Srwatson	return concat_name;
4680244390Srwatson      XFREE (concat_name);
4681244390Srwatson    }
4682244390Srwatson  else
4683244390Srwatson    {
4684244390Srwatson#endif
4685244390Srwatson      if (IS_DIR_SEPARATOR (wrapper[0]))
4686244390Srwatson	{
4687244390Srwatson	  concat_name = xstrdup (wrapper);
4688244390Srwatson	  if (check_executable (concat_name))
4689244390Srwatson	    return concat_name;
4690244390Srwatson	  XFREE (concat_name);
4691244390Srwatson	}
4692244390Srwatson#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4693244390Srwatson    }
4694244390Srwatson#endif
4695244390Srwatson
4696244390Srwatson  for (p = wrapper; *p; p++)
4697244390Srwatson    if (*p == '/')
4698244390Srwatson      {
4699244390Srwatson	has_slash = 1;
4700244390Srwatson	break;
4701244390Srwatson      }
4702244390Srwatson  if (!has_slash)
4703244390Srwatson    {
4704244390Srwatson      /* no slashes; search PATH */
4705244390Srwatson      const char *path = getenv ("PATH");
4706244390Srwatson      if (path != NULL)
4707244390Srwatson	{
4708244390Srwatson	  for (p = path; *p; p = p_next)
4709244390Srwatson	    {
4710244390Srwatson	      const char *q;
4711244390Srwatson	      size_t p_len;
4712244390Srwatson	      for (q = p; *q; q++)
4713244390Srwatson		if (IS_PATH_SEPARATOR (*q))
4714244390Srwatson		  break;
4715244390Srwatson	      p_len = q - p;
4716244390Srwatson	      p_next = (*q == '\0' ? q : q + 1);
4717244390Srwatson	      if (p_len == 0)
4718244390Srwatson		{
4719244390Srwatson		  /* empty path: current directory */
4720244390Srwatson		  if (getcwd (tmp, LT_PATHMAX) == NULL)
4721244390Srwatson		    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
4722244390Srwatson                              nonnull (strerror (errno)));
4723244390Srwatson		  tmp_len = strlen (tmp);
4724244390Srwatson		  concat_name =
4725244390Srwatson		    XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
4726244390Srwatson		  memcpy (concat_name, tmp, tmp_len);
4727244390Srwatson		  concat_name[tmp_len] = '/';
4728244390Srwatson		  strcpy (concat_name + tmp_len + 1, wrapper);
4729244390Srwatson		}
4730244390Srwatson	      else
4731244390Srwatson		{
4732244390Srwatson		  concat_name =
4733244390Srwatson		    XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
4734244390Srwatson		  memcpy (concat_name, p, p_len);
4735244390Srwatson		  concat_name[p_len] = '/';
4736244390Srwatson		  strcpy (concat_name + p_len + 1, wrapper);
4737244390Srwatson		}
4738244390Srwatson	      if (check_executable (concat_name))
4739244390Srwatson		return concat_name;
4740244390Srwatson	      XFREE (concat_name);
4741244390Srwatson	    }
4742244390Srwatson	}
4743244390Srwatson      /* not found in PATH; assume curdir */
4744244390Srwatson    }
4745244390Srwatson  /* Relative path | not found in path: prepend cwd */
4746244390Srwatson  if (getcwd (tmp, LT_PATHMAX) == NULL)
4747244390Srwatson    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
4748244390Srwatson              nonnull (strerror (errno)));
4749244390Srwatson  tmp_len = strlen (tmp);
4750244390Srwatson  concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
4751244390Srwatson  memcpy (concat_name, tmp, tmp_len);
4752244390Srwatson  concat_name[tmp_len] = '/';
4753244390Srwatson  strcpy (concat_name + tmp_len + 1, wrapper);
4754244390Srwatson
4755244390Srwatson  if (check_executable (concat_name))
4756244390Srwatson    return concat_name;
4757244390Srwatson  XFREE (concat_name);
4758244390Srwatson  return NULL;
4759244390Srwatson}
4760244390Srwatson
4761244390Srwatsonchar *
4762244390Srwatsonchase_symlinks (const char *pathspec)
4763244390Srwatson{
4764244390Srwatson#ifndef S_ISLNK
4765244390Srwatson  return xstrdup (pathspec);
4766244390Srwatson#else
4767244390Srwatson  char buf[LT_PATHMAX];
4768244390Srwatson  struct stat s;
4769244390Srwatson  char *tmp_pathspec = xstrdup (pathspec);
4770244390Srwatson  char *p;
4771244390Srwatson  int has_symlinks = 0;
4772244390Srwatson  while (strlen (tmp_pathspec) && !has_symlinks)
4773244390Srwatson    {
4774244390Srwatson      lt_debugprintf (__FILE__, __LINE__,
4775244390Srwatson		      "checking path component for symlinks: %s\n",
4776244390Srwatson		      tmp_pathspec);
4777244390Srwatson      if (lstat (tmp_pathspec, &s) == 0)
4778244390Srwatson	{
4779244390Srwatson	  if (S_ISLNK (s.st_mode) != 0)
4780244390Srwatson	    {
4781244390Srwatson	      has_symlinks = 1;
4782244390Srwatson	      break;
4783244390Srwatson	    }
4784244390Srwatson
4785244390Srwatson	  /* search backwards for last DIR_SEPARATOR */
4786244390Srwatson	  p = tmp_pathspec + strlen (tmp_pathspec) - 1;
4787244390Srwatson	  while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
4788244390Srwatson	    p--;
4789244390Srwatson	  if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
4790244390Srwatson	    {
4791244390Srwatson	      /* no more DIR_SEPARATORS left */
4792244390Srwatson	      break;
4793244390Srwatson	    }
4794244390Srwatson	  *p = '\0';
4795244390Srwatson	}
4796244390Srwatson      else
4797244390Srwatson	{
4798244390Srwatson	  lt_fatal (__FILE__, __LINE__,
4799244390Srwatson		    "error accessing file \"%s\": %s",
4800244390Srwatson		    tmp_pathspec, nonnull (strerror (errno)));
4801244390Srwatson	}
4802244390Srwatson    }
4803244390Srwatson  XFREE (tmp_pathspec);
4804244390Srwatson
4805244390Srwatson  if (!has_symlinks)
4806244390Srwatson    {
4807244390Srwatson      return xstrdup (pathspec);
4808244390Srwatson    }
4809244390Srwatson
4810244390Srwatson  tmp_pathspec = realpath (pathspec, buf);
4811244390Srwatson  if (tmp_pathspec == 0)
4812244390Srwatson    {
4813244390Srwatson      lt_fatal (__FILE__, __LINE__,
4814244390Srwatson		"could not follow symlinks for %s", pathspec);
4815244390Srwatson    }
4816244390Srwatson  return xstrdup (tmp_pathspec);
4817244390Srwatson#endif
4818244390Srwatson}
4819244390Srwatson
4820244390Srwatsonchar *
4821244390Srwatsonstrendzap (char *str, const char *pat)
4822244390Srwatson{
4823244390Srwatson  size_t len, patlen;
4824244390Srwatson
4825244390Srwatson  assert (str != NULL);
4826244390Srwatson  assert (pat != NULL);
4827244390Srwatson
4828244390Srwatson  len = strlen (str);
4829244390Srwatson  patlen = strlen (pat);
4830244390Srwatson
4831244390Srwatson  if (patlen <= len)
4832244390Srwatson    {
4833244390Srwatson      str += len - patlen;
4834244390Srwatson      if (strcmp (str, pat) == 0)
4835244390Srwatson	*str = '\0';
4836244390Srwatson    }
4837244390Srwatson  return str;
4838244390Srwatson}
4839244390Srwatson
4840244390Srwatsonvoid
4841244390Srwatsonlt_debugprintf (const char *file, int line, const char *fmt, ...)
4842244390Srwatson{
4843244390Srwatson  va_list args;
4844244390Srwatson  if (lt_debug)
4845244390Srwatson    {
4846244390Srwatson      (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line);
4847244390Srwatson      va_start (args, fmt);
4848244390Srwatson      (void) vfprintf (stderr, fmt, args);
4849244390Srwatson      va_end (args);
4850244390Srwatson    }
4851244390Srwatson}
4852244390Srwatson
4853244390Srwatsonstatic void
4854244390Srwatsonlt_error_core (int exit_status, const char *file,
4855244390Srwatson	       int line, const char *mode,
4856244390Srwatson	       const char *message, va_list ap)
4857244390Srwatson{
4858244390Srwatson  fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode);
4859244390Srwatson  vfprintf (stderr, message, ap);
4860244390Srwatson  fprintf (stderr, ".\n");
4861244390Srwatson
4862244390Srwatson  if (exit_status >= 0)
4863244390Srwatson    exit (exit_status);
4864244390Srwatson}
4865244390Srwatson
4866244390Srwatsonvoid
4867244390Srwatsonlt_fatal (const char *file, int line, const char *message, ...)
4868244390Srwatson{
4869244390Srwatson  va_list ap;
4870244390Srwatson  va_start (ap, message);
4871244390Srwatson  lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap);
4872244390Srwatson  va_end (ap);
4873244390Srwatson}
4874244390Srwatson
4875244390Srwatsonstatic const char *
4876244390Srwatsonnonnull (const char *s)
4877244390Srwatson{
4878244390Srwatson  return s ? s : "(null)";
4879244390Srwatson}
4880244390Srwatson
4881244390Srwatsonstatic const char *
4882244390Srwatsonnonempty (const char *s)
4883244390Srwatson{
4884244390Srwatson  return (s && !*s) ? "(empty)" : nonnull (s);
4885244390Srwatson}
4886244390Srwatson
4887244390Srwatsonvoid
4888244390Srwatsonlt_setenv (const char *name, const char *value)
4889244390Srwatson{
4890244390Srwatson  lt_debugprintf (__FILE__, __LINE__,
4891244390Srwatson		  "(lt_setenv) setting '%s' to '%s'\n",
4892244390Srwatson                  nonnull (name), nonnull (value));
4893244390Srwatson  {
4894244390Srwatson#ifdef HAVE_SETENV
4895244390Srwatson    /* always make a copy, for consistency with !HAVE_SETENV */
4896244390Srwatson    char *str = xstrdup (value);
4897244390Srwatson    setenv (name, str, 1);
4898244390Srwatson#else
4899244390Srwatson    int len = strlen (name) + 1 + strlen (value) + 1;
4900244390Srwatson    char *str = XMALLOC (char, len);
4901244390Srwatson    sprintf (str, "%s=%s", name, value);
4902244390Srwatson    if (putenv (str) != EXIT_SUCCESS)
4903244390Srwatson      {
4904244390Srwatson        XFREE (str);
4905244390Srwatson      }
4906244390Srwatson#endif
4907244390Srwatson  }
4908244390Srwatson}
4909244390Srwatson
4910244390Srwatsonchar *
4911244390Srwatsonlt_extend_str (const char *orig_value, const char *add, int to_end)
4912244390Srwatson{
4913244390Srwatson  char *new_value;
4914244390Srwatson  if (orig_value && *orig_value)
4915244390Srwatson    {
4916244390Srwatson      int orig_value_len = strlen (orig_value);
4917244390Srwatson      int add_len = strlen (add);
4918244390Srwatson      new_value = XMALLOC (char, add_len + orig_value_len + 1);
4919244390Srwatson      if (to_end)
4920244390Srwatson        {
4921244390Srwatson          strcpy (new_value, orig_value);
4922244390Srwatson          strcpy (new_value + orig_value_len, add);
4923244390Srwatson        }
4924244390Srwatson      else
4925244390Srwatson        {
4926244390Srwatson          strcpy (new_value, add);
4927244390Srwatson          strcpy (new_value + add_len, orig_value);
4928244390Srwatson        }
4929244390Srwatson    }
4930244390Srwatson  else
4931244390Srwatson    {
4932244390Srwatson      new_value = xstrdup (add);
4933244390Srwatson    }
4934244390Srwatson  return new_value;
4935244390Srwatson}
4936244390Srwatson
4937244390Srwatsonvoid
4938244390Srwatsonlt_update_exe_path (const char *name, const char *value)
4939244390Srwatson{
4940244390Srwatson  lt_debugprintf (__FILE__, __LINE__,
4941244390Srwatson		  "(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
4942244390Srwatson                  nonnull (name), nonnull (value));
4943244390Srwatson
4944244390Srwatson  if (name && *name && value && *value)
4945244390Srwatson    {
4946244390Srwatson      char *new_value = lt_extend_str (getenv (name), value, 0);
4947244390Srwatson      /* some systems can't cope with a ':'-terminated path #' */
4948244390Srwatson      int len = strlen (new_value);
4949244390Srwatson      while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
4950244390Srwatson        {
4951244390Srwatson          new_value[len-1] = '\0';
4952244390Srwatson        }
4953244390Srwatson      lt_setenv (name, new_value);
4954244390Srwatson      XFREE (new_value);
4955244390Srwatson    }
4956244390Srwatson}
4957244390Srwatson
4958244390Srwatsonvoid
4959244390Srwatsonlt_update_lib_path (const char *name, const char *value)
4960244390Srwatson{
4961244390Srwatson  lt_debugprintf (__FILE__, __LINE__,
4962244390Srwatson		  "(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
4963244390Srwatson                  nonnull (name), nonnull (value));
4964244390Srwatson
4965244390Srwatson  if (name && *name && value && *value)
4966244390Srwatson    {
4967244390Srwatson      char *new_value = lt_extend_str (getenv (name), value, 0);
4968244390Srwatson      lt_setenv (name, new_value);
4969244390Srwatson      XFREE (new_value);
4970244390Srwatson    }
4971244390Srwatson}
4972244390Srwatson
4973244390SrwatsonEOF
4974244390Srwatson	    case $host_os in
4975244390Srwatson	      mingw*)
4976244390Srwatson		cat <<"EOF"
4977244390Srwatson
4978244390Srwatson/* Prepares an argument vector before calling spawn().
4979244390Srwatson   Note that spawn() does not by itself call the command interpreter
4980244390Srwatson     (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
4981244390Srwatson      ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
4982244390Srwatson         GetVersionEx(&v);
4983244390Srwatson         v.dwPlatformId == VER_PLATFORM_WIN32_NT;
4984244390Srwatson      }) ? "cmd.exe" : "command.com").
4985244390Srwatson   Instead it simply concatenates the arguments, separated by ' ', and calls
4986244390Srwatson   CreateProcess().  We must quote the arguments since Win32 CreateProcess()
4987244390Srwatson   interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
4988244390Srwatson   special way:
4989244390Srwatson   - Space and tab are interpreted as delimiters. They are not treated as
4990244390Srwatson     delimiters if they are surrounded by double quotes: "...".
4991244390Srwatson   - Unescaped double quotes are removed from the input. Their only effect is
4992244390Srwatson     that within double quotes, space and tab are treated like normal
4993244390Srwatson     characters.
4994244390Srwatson   - Backslashes not followed by double quotes are not special.
4995244390Srwatson   - But 2*n+1 backslashes followed by a double quote become
4996244390Srwatson     n backslashes followed by a double quote (n >= 0):
4997244390Srwatson       \" -> "
4998244390Srwatson       \\\" -> \"
4999244390Srwatson       \\\\\" -> \\"
5000244390Srwatson */
5001244390Srwatson#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"
5002244390Srwatson#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"
5003244390Srwatsonchar **
5004244390Srwatsonprepare_spawn (char **argv)
5005244390Srwatson{
5006244390Srwatson  size_t argc;
5007244390Srwatson  char **new_argv;
5008244390Srwatson  size_t i;
5009244390Srwatson
5010244390Srwatson  /* Count number of arguments.  */
5011244390Srwatson  for (argc = 0; argv[argc] != NULL; argc++)
5012244390Srwatson    ;
5013244390Srwatson
5014244390Srwatson  /* Allocate new argument vector.  */
5015244390Srwatson  new_argv = XMALLOC (char *, argc + 1);
5016244390Srwatson
5017244390Srwatson  /* Put quoted arguments into the new argument vector.  */
5018244390Srwatson  for (i = 0; i < argc; i++)
5019244390Srwatson    {
5020244390Srwatson      const char *string = argv[i];
5021244390Srwatson
5022244390Srwatson      if (string[0] == '\0')
5023244390Srwatson	new_argv[i] = xstrdup ("\"\"");
5024244390Srwatson      else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
5025244390Srwatson	{
5026244390Srwatson	  int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
5027244390Srwatson	  size_t length;
5028244390Srwatson	  unsigned int backslashes;
5029244390Srwatson	  const char *s;
5030244390Srwatson	  char *quoted_string;
5031244390Srwatson	  char *p;
5032244390Srwatson
5033244390Srwatson	  length = 0;
5034244390Srwatson	  backslashes = 0;
5035244390Srwatson	  if (quote_around)
5036244390Srwatson	    length++;
5037244390Srwatson	  for (s = string; *s != '\0'; s++)
5038244390Srwatson	    {
5039244390Srwatson	      char c = *s;
5040244390Srwatson	      if (c == '"')
5041244390Srwatson		length += backslashes + 1;
5042244390Srwatson	      length++;
5043244390Srwatson	      if (c == '\\')
5044244390Srwatson		backslashes++;
5045244390Srwatson	      else
5046244390Srwatson		backslashes = 0;
5047244390Srwatson	    }
5048244390Srwatson	  if (quote_around)
5049244390Srwatson	    length += backslashes + 1;
5050244390Srwatson
5051244390Srwatson	  quoted_string = XMALLOC (char, length + 1);
5052244390Srwatson
5053244390Srwatson	  p = quoted_string;
5054244390Srwatson	  backslashes = 0;
5055244390Srwatson	  if (quote_around)
5056244390Srwatson	    *p++ = '"';
5057244390Srwatson	  for (s = string; *s != '\0'; s++)
5058244390Srwatson	    {
5059244390Srwatson	      char c = *s;
5060244390Srwatson	      if (c == '"')
5061244390Srwatson		{
5062244390Srwatson		  unsigned int j;
5063244390Srwatson		  for (j = backslashes + 1; j > 0; j--)
5064244390Srwatson		    *p++ = '\\';
5065244390Srwatson		}
5066244390Srwatson	      *p++ = c;
5067244390Srwatson	      if (c == '\\')
5068244390Srwatson		backslashes++;
5069244390Srwatson	      else
5070244390Srwatson		backslashes = 0;
5071244390Srwatson	    }
5072244390Srwatson	  if (quote_around)
5073244390Srwatson	    {
5074244390Srwatson	      unsigned int j;
5075244390Srwatson	      for (j = backslashes; j > 0; j--)
5076244390Srwatson		*p++ = '\\';
5077244390Srwatson	      *p++ = '"';
5078244390Srwatson	    }
5079244390Srwatson	  *p = '\0';
5080244390Srwatson
5081244390Srwatson	  new_argv[i] = quoted_string;
5082244390Srwatson	}
5083244390Srwatson      else
5084244390Srwatson	new_argv[i] = (char *) string;
5085244390Srwatson    }
5086244390Srwatson  new_argv[argc] = NULL;
5087244390Srwatson
5088244390Srwatson  return new_argv;
5089244390Srwatson}
5090244390SrwatsonEOF
5091244390Srwatson		;;
5092244390Srwatson	    esac
5093244390Srwatson
5094244390Srwatson            cat <<"EOF"
5095244390Srwatsonvoid lt_dump_script (FILE* f)
5096244390Srwatson{
5097244390SrwatsonEOF
5098244390Srwatson	    func_emit_wrapper yes |
5099244390Srwatson	      $SED -n -e '
5100244390Srwatsons/^\(.\{79\}\)\(..*\)/\1\
5101244390Srwatson\2/
5102244390Srwatsonh
5103244390Srwatsons/\([\\"]\)/\\\1/g
5104244390Srwatsons/$/\\n/
5105244390Srwatsons/\([^\n]*\).*/  fputs ("\1", f);/p
5106244390Srwatsong
5107244390SrwatsonD'
5108244390Srwatson            cat <<"EOF"
5109244390Srwatson}
5110244390SrwatsonEOF
5111244390Srwatson}
5112244390Srwatson# end: func_emit_cwrapperexe_src
5113244390Srwatson
5114244390Srwatson# func_win32_import_lib_p ARG
5115244390Srwatson# True if ARG is an import lib, as indicated by $file_magic_cmd
5116244390Srwatsonfunc_win32_import_lib_p ()
5117244390Srwatson{
5118244390Srwatson    $opt_debug
5119244390Srwatson    case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
5120244390Srwatson    *import*) : ;;
5121244390Srwatson    *) false ;;
5122244390Srwatson    esac
5123244390Srwatson}
5124244390Srwatson
5125244390Srwatson# func_mode_link arg...
5126244390Srwatsonfunc_mode_link ()
5127244390Srwatson{
5128244390Srwatson    $opt_debug
5129156283Srwatson    case $host in
5130244390Srwatson    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
5131156283Srwatson      # It is impossible to link a dll without this setting, and
5132156283Srwatson      # we shouldn't force the makefile maintainer to figure out
5133156283Srwatson      # which system we are compiling for in order to pass an extra
5134156283Srwatson      # flag for every libtool invocation.
5135156283Srwatson      # allow_undefined=no
5136156283Srwatson
5137156283Srwatson      # FIXME: Unfortunately, there are problems with the above when trying
5138156283Srwatson      # to make a dll which has undefined symbols, in which case not
5139156283Srwatson      # even a static library is built.  For now, we need to specify
5140156283Srwatson      # -no-undefined on the libtool link line when we can be certain
5141156283Srwatson      # that all symbols are satisfied, otherwise we get a static library.
5142156283Srwatson      allow_undefined=yes
5143156283Srwatson      ;;
5144156283Srwatson    *)
5145156283Srwatson      allow_undefined=yes
5146156283Srwatson      ;;
5147156283Srwatson    esac
5148244390Srwatson    libtool_args=$nonopt
5149156283Srwatson    base_compile="$nonopt $@"
5150244390Srwatson    compile_command=$nonopt
5151244390Srwatson    finalize_command=$nonopt
5152156283Srwatson
5153156283Srwatson    compile_rpath=
5154156283Srwatson    finalize_rpath=
5155156283Srwatson    compile_shlibpath=
5156156283Srwatson    finalize_shlibpath=
5157156283Srwatson    convenience=
5158156283Srwatson    old_convenience=
5159156283Srwatson    deplibs=
5160156283Srwatson    old_deplibs=
5161156283Srwatson    compiler_flags=
5162156283Srwatson    linker_flags=
5163156283Srwatson    dllsearchpath=
5164156283Srwatson    lib_search_path=`pwd`
5165156283Srwatson    inst_prefix_dir=
5166244390Srwatson    new_inherited_linker_flags=
5167156283Srwatson
5168156283Srwatson    avoid_version=no
5169244390Srwatson    bindir=
5170156283Srwatson    dlfiles=
5171156283Srwatson    dlprefiles=
5172156283Srwatson    dlself=no
5173156283Srwatson    export_dynamic=no
5174156283Srwatson    export_symbols=
5175156283Srwatson    export_symbols_regex=
5176156283Srwatson    generated=
5177156283Srwatson    libobjs=
5178156283Srwatson    ltlibs=
5179156283Srwatson    module=no
5180156283Srwatson    no_install=no
5181156283Srwatson    objs=
5182156283Srwatson    non_pic_objects=
5183156283Srwatson    precious_files_regex=
5184156283Srwatson    prefer_static_libs=no
5185156283Srwatson    preload=no
5186156283Srwatson    prev=
5187156283Srwatson    prevarg=
5188156283Srwatson    release=
5189156283Srwatson    rpath=
5190156283Srwatson    xrpath=
5191156283Srwatson    perm_rpath=
5192156283Srwatson    temp_rpath=
5193156283Srwatson    thread_safe=no
5194156283Srwatson    vinfo=
5195156283Srwatson    vinfo_number=no
5196244390Srwatson    weak_libs=
5197191273Srwatson    single_module="${wl}-single_module"
5198156283Srwatson    func_infer_tag $base_compile
5199156283Srwatson
5200156283Srwatson    # We need to know -static, to get the right output filenames.
5201156283Srwatson    for arg
5202156283Srwatson    do
5203156283Srwatson      case $arg in
5204244390Srwatson      -shared)
5205244390Srwatson	test "$build_libtool_libs" != yes && \
5206244390Srwatson	  func_fatal_configuration "can not build a shared library"
5207244390Srwatson	build_old_libs=no
5208244390Srwatson	break
5209244390Srwatson	;;
5210173143Srwatson      -all-static | -static | -static-libtool-libs)
5211173143Srwatson	case $arg in
5212173143Srwatson	-all-static)
5213156283Srwatson	  if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
5214244390Srwatson	    func_warning "complete static linking is impossible in this configuration"
5215156283Srwatson	  fi
5216156283Srwatson	  if test -n "$link_static_flag"; then
5217156283Srwatson	    dlopen_self=$dlopen_self_static
5218156283Srwatson	  fi
5219159985Srwatson	  prefer_static_libs=yes
5220173143Srwatson	  ;;
5221173143Srwatson	-static)
5222156283Srwatson	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
5223156283Srwatson	    dlopen_self=$dlopen_self_static
5224156283Srwatson	  fi
5225159985Srwatson	  prefer_static_libs=built
5226173143Srwatson	  ;;
5227173143Srwatson	-static-libtool-libs)
5228173143Srwatson	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
5229173143Srwatson	    dlopen_self=$dlopen_self_static
5230173143Srwatson	  fi
5231173143Srwatson	  prefer_static_libs=yes
5232173143Srwatson	  ;;
5233173143Srwatson	esac
5234156283Srwatson	build_libtool_libs=no
5235156283Srwatson	build_old_libs=yes
5236156283Srwatson	break
5237156283Srwatson	;;
5238156283Srwatson      esac
5239156283Srwatson    done
5240156283Srwatson
5241156283Srwatson    # See if our shared archives depend on static archives.
5242156283Srwatson    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
5243156283Srwatson
5244156283Srwatson    # Go through the arguments, transforming them on the way.
5245156283Srwatson    while test "$#" -gt 0; do
5246156283Srwatson      arg="$1"
5247156283Srwatson      shift
5248244390Srwatson      func_quote_for_eval "$arg"
5249244390Srwatson      qarg=$func_quote_for_eval_unquoted_result
5250244390Srwatson      func_append libtool_args " $func_quote_for_eval_result"
5251156283Srwatson
5252156283Srwatson      # If the previous option needs an argument, assign it.
5253156283Srwatson      if test -n "$prev"; then
5254156283Srwatson	case $prev in
5255156283Srwatson	output)
5256244390Srwatson	  func_append compile_command " @OUTPUT@"
5257244390Srwatson	  func_append finalize_command " @OUTPUT@"
5258156283Srwatson	  ;;
5259156283Srwatson	esac
5260156283Srwatson
5261156283Srwatson	case $prev in
5262244390Srwatson	bindir)
5263244390Srwatson	  bindir="$arg"
5264244390Srwatson	  prev=
5265244390Srwatson	  continue
5266244390Srwatson	  ;;
5267156283Srwatson	dlfiles|dlprefiles)
5268156283Srwatson	  if test "$preload" = no; then
5269156283Srwatson	    # Add the symbol object into the linking commands.
5270244390Srwatson	    func_append compile_command " @SYMFILE@"
5271244390Srwatson	    func_append finalize_command " @SYMFILE@"
5272156283Srwatson	    preload=yes
5273156283Srwatson	  fi
5274156283Srwatson	  case $arg in
5275156283Srwatson	  *.la | *.lo) ;;  # We handle these cases below.
5276156283Srwatson	  force)
5277156283Srwatson	    if test "$dlself" = no; then
5278156283Srwatson	      dlself=needless
5279156283Srwatson	      export_dynamic=yes
5280156283Srwatson	    fi
5281156283Srwatson	    prev=
5282156283Srwatson	    continue
5283156283Srwatson	    ;;
5284156283Srwatson	  self)
5285156283Srwatson	    if test "$prev" = dlprefiles; then
5286156283Srwatson	      dlself=yes
5287156283Srwatson	    elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
5288156283Srwatson	      dlself=yes
5289156283Srwatson	    else
5290156283Srwatson	      dlself=needless
5291156283Srwatson	      export_dynamic=yes
5292156283Srwatson	    fi
5293156283Srwatson	    prev=
5294156283Srwatson	    continue
5295156283Srwatson	    ;;
5296156283Srwatson	  *)
5297156283Srwatson	    if test "$prev" = dlfiles; then
5298244390Srwatson	      func_append dlfiles " $arg"
5299156283Srwatson	    else
5300244390Srwatson	      func_append dlprefiles " $arg"
5301156283Srwatson	    fi
5302156283Srwatson	    prev=
5303156283Srwatson	    continue
5304156283Srwatson	    ;;
5305156283Srwatson	  esac
5306156283Srwatson	  ;;
5307156283Srwatson	expsyms)
5308156283Srwatson	  export_symbols="$arg"
5309244390Srwatson	  test -f "$arg" \
5310244390Srwatson	    || func_fatal_error "symbol file \`$arg' does not exist"
5311156283Srwatson	  prev=
5312156283Srwatson	  continue
5313156283Srwatson	  ;;
5314156283Srwatson	expsyms_regex)
5315156283Srwatson	  export_symbols_regex="$arg"
5316156283Srwatson	  prev=
5317156283Srwatson	  continue
5318156283Srwatson	  ;;
5319244390Srwatson	framework)
5320244390Srwatson	  case $host in
5321244390Srwatson	    *-*-darwin*)
5322244390Srwatson	      case "$deplibs " in
5323244390Srwatson		*" $qarg.ltframework "*) ;;
5324244390Srwatson		*) func_append deplibs " $qarg.ltframework" # this is fixed later
5325244390Srwatson		   ;;
5326244390Srwatson	      esac
5327244390Srwatson	      ;;
5328244390Srwatson	  esac
5329156283Srwatson	  prev=
5330156283Srwatson	  continue
5331156283Srwatson	  ;;
5332244390Srwatson	inst_prefix)
5333244390Srwatson	  inst_prefix_dir="$arg"
5334156283Srwatson	  prev=
5335156283Srwatson	  continue
5336156283Srwatson	  ;;
5337156283Srwatson	objectlist)
5338156283Srwatson	  if test -f "$arg"; then
5339156283Srwatson	    save_arg=$arg
5340156283Srwatson	    moreargs=
5341244390Srwatson	    for fil in `cat "$save_arg"`
5342156283Srwatson	    do
5343244390Srwatson#	      func_append moreargs " $fil"
5344156283Srwatson	      arg=$fil
5345156283Srwatson	      # A libtool-controlled object.
5346156283Srwatson
5347156283Srwatson	      # Check to see that this really is a libtool object.
5348244390Srwatson	      if func_lalib_unsafe_p "$arg"; then
5349156283Srwatson		pic_object=
5350156283Srwatson		non_pic_object=
5351156283Srwatson
5352156283Srwatson		# Read the .lo file
5353244390Srwatson		func_source "$arg"
5354156283Srwatson
5355244390Srwatson		if test -z "$pic_object" ||
5356156283Srwatson		   test -z "$non_pic_object" ||
5357244390Srwatson		   test "$pic_object" = none &&
5358156283Srwatson		   test "$non_pic_object" = none; then
5359244390Srwatson		  func_fatal_error "cannot find name of object for \`$arg'"
5360156283Srwatson		fi
5361156283Srwatson
5362156283Srwatson		# Extract subdirectory from the argument.
5363244390Srwatson		func_dirname "$arg" "/" ""
5364244390Srwatson		xdir="$func_dirname_result"
5365156283Srwatson
5366156283Srwatson		if test "$pic_object" != none; then
5367156283Srwatson		  # Prepend the subdirectory the object is found in.
5368156283Srwatson		  pic_object="$xdir$pic_object"
5369156283Srwatson
5370156283Srwatson		  if test "$prev" = dlfiles; then
5371156283Srwatson		    if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
5372244390Srwatson		      func_append dlfiles " $pic_object"
5373156283Srwatson		      prev=
5374156283Srwatson		      continue
5375156283Srwatson		    else
5376156283Srwatson		      # If libtool objects are unsupported, then we need to preload.
5377156283Srwatson		      prev=dlprefiles
5378156283Srwatson		    fi
5379156283Srwatson		  fi
5380156283Srwatson
5381156283Srwatson		  # CHECK ME:  I think I busted this.  -Ossama
5382156283Srwatson		  if test "$prev" = dlprefiles; then
5383156283Srwatson		    # Preload the old-style object.
5384244390Srwatson		    func_append dlprefiles " $pic_object"
5385156283Srwatson		    prev=
5386156283Srwatson		  fi
5387156283Srwatson
5388156283Srwatson		  # A PIC object.
5389244390Srwatson		  func_append libobjs " $pic_object"
5390156283Srwatson		  arg="$pic_object"
5391156283Srwatson		fi
5392156283Srwatson
5393156283Srwatson		# Non-PIC object.
5394156283Srwatson		if test "$non_pic_object" != none; then
5395156283Srwatson		  # Prepend the subdirectory the object is found in.
5396156283Srwatson		  non_pic_object="$xdir$non_pic_object"
5397156283Srwatson
5398156283Srwatson		  # A standard non-PIC object
5399244390Srwatson		  func_append non_pic_objects " $non_pic_object"
5400156283Srwatson		  if test -z "$pic_object" || test "$pic_object" = none ; then
5401156283Srwatson		    arg="$non_pic_object"
5402156283Srwatson		  fi
5403159985Srwatson		else
5404159985Srwatson		  # If the PIC object exists, use it instead.
5405159985Srwatson		  # $xdir was prepended to $pic_object above.
5406159985Srwatson		  non_pic_object="$pic_object"
5407244390Srwatson		  func_append non_pic_objects " $non_pic_object"
5408156283Srwatson		fi
5409156283Srwatson	      else
5410156283Srwatson		# Only an error if not doing a dry-run.
5411244390Srwatson		if $opt_dry_run; then
5412156283Srwatson		  # Extract subdirectory from the argument.
5413244390Srwatson		  func_dirname "$arg" "/" ""
5414244390Srwatson		  xdir="$func_dirname_result"
5415156283Srwatson
5416244390Srwatson		  func_lo2o "$arg"
5417244390Srwatson		  pic_object=$xdir$objdir/$func_lo2o_result
5418244390Srwatson		  non_pic_object=$xdir$func_lo2o_result
5419244390Srwatson		  func_append libobjs " $pic_object"
5420244390Srwatson		  func_append non_pic_objects " $non_pic_object"
5421244390Srwatson	        else
5422244390Srwatson		  func_fatal_error "\`$arg' is not a valid libtool object"
5423156283Srwatson		fi
5424156283Srwatson	      fi
5425156283Srwatson	    done
5426156283Srwatson	  else
5427244390Srwatson	    func_fatal_error "link input file \`$arg' does not exist"
5428156283Srwatson	  fi
5429156283Srwatson	  arg=$save_arg
5430156283Srwatson	  prev=
5431156283Srwatson	  continue
5432156283Srwatson	  ;;
5433244390Srwatson	precious_regex)
5434244390Srwatson	  precious_files_regex="$arg"
5435244390Srwatson	  prev=
5436244390Srwatson	  continue
5437244390Srwatson	  ;;
5438244390Srwatson	release)
5439244390Srwatson	  release="-$arg"
5440244390Srwatson	  prev=
5441244390Srwatson	  continue
5442244390Srwatson	  ;;
5443156283Srwatson	rpath | xrpath)
5444156283Srwatson	  # We need an absolute path.
5445156283Srwatson	  case $arg in
5446156283Srwatson	  [\\/]* | [A-Za-z]:[\\/]*) ;;
5447156283Srwatson	  *)
5448244390Srwatson	    func_fatal_error "only absolute run-paths are allowed"
5449156283Srwatson	    ;;
5450156283Srwatson	  esac
5451156283Srwatson	  if test "$prev" = rpath; then
5452156283Srwatson	    case "$rpath " in
5453156283Srwatson	    *" $arg "*) ;;
5454244390Srwatson	    *) func_append rpath " $arg" ;;
5455156283Srwatson	    esac
5456156283Srwatson	  else
5457156283Srwatson	    case "$xrpath " in
5458156283Srwatson	    *" $arg "*) ;;
5459244390Srwatson	    *) func_append xrpath " $arg" ;;
5460156283Srwatson	    esac
5461156283Srwatson	  fi
5462156283Srwatson	  prev=
5463156283Srwatson	  continue
5464156283Srwatson	  ;;
5465244390Srwatson	shrext)
5466244390Srwatson	  shrext_cmds="$arg"
5467156283Srwatson	  prev=
5468156283Srwatson	  continue
5469156283Srwatson	  ;;
5470244390Srwatson	weak)
5471244390Srwatson	  func_append weak_libs " $arg"
5472156283Srwatson	  prev=
5473156283Srwatson	  continue
5474156283Srwatson	  ;;
5475156283Srwatson	xcclinker)
5476244390Srwatson	  func_append linker_flags " $qarg"
5477244390Srwatson	  func_append compiler_flags " $qarg"
5478156283Srwatson	  prev=
5479244390Srwatson	  func_append compile_command " $qarg"
5480244390Srwatson	  func_append finalize_command " $qarg"
5481156283Srwatson	  continue
5482156283Srwatson	  ;;
5483244390Srwatson	xcompiler)
5484244390Srwatson	  func_append compiler_flags " $qarg"
5485156283Srwatson	  prev=
5486244390Srwatson	  func_append compile_command " $qarg"
5487244390Srwatson	  func_append finalize_command " $qarg"
5488156283Srwatson	  continue
5489156283Srwatson	  ;;
5490244390Srwatson	xlinker)
5491244390Srwatson	  func_append linker_flags " $qarg"
5492244390Srwatson	  func_append compiler_flags " $wl$qarg"
5493156283Srwatson	  prev=
5494244390Srwatson	  func_append compile_command " $wl$qarg"
5495244390Srwatson	  func_append finalize_command " $wl$qarg"
5496156283Srwatson	  continue
5497156283Srwatson	  ;;
5498156283Srwatson	*)
5499156283Srwatson	  eval "$prev=\"\$arg\""
5500156283Srwatson	  prev=
5501156283Srwatson	  continue
5502156283Srwatson	  ;;
5503156283Srwatson	esac
5504156283Srwatson      fi # test -n "$prev"
5505156283Srwatson
5506156283Srwatson      prevarg="$arg"
5507156283Srwatson
5508156283Srwatson      case $arg in
5509156283Srwatson      -all-static)
5510156283Srwatson	if test -n "$link_static_flag"; then
5511244390Srwatson	  # See comment for -static flag below, for more details.
5512244390Srwatson	  func_append compile_command " $link_static_flag"
5513244390Srwatson	  func_append finalize_command " $link_static_flag"
5514156283Srwatson	fi
5515156283Srwatson	continue
5516156283Srwatson	;;
5517156283Srwatson
5518156283Srwatson      -allow-undefined)
5519156283Srwatson	# FIXME: remove this flag sometime in the future.
5520244390Srwatson	func_fatal_error "\`-allow-undefined' must not be used because it is the default"
5521156283Srwatson	;;
5522156283Srwatson
5523156283Srwatson      -avoid-version)
5524156283Srwatson	avoid_version=yes
5525156283Srwatson	continue
5526156283Srwatson	;;
5527156283Srwatson
5528244390Srwatson      -bindir)
5529244390Srwatson	prev=bindir
5530244390Srwatson	continue
5531244390Srwatson	;;
5532244390Srwatson
5533156283Srwatson      -dlopen)
5534156283Srwatson	prev=dlfiles
5535156283Srwatson	continue
5536156283Srwatson	;;
5537156283Srwatson
5538156283Srwatson      -dlpreopen)
5539156283Srwatson	prev=dlprefiles
5540156283Srwatson	continue
5541156283Srwatson	;;
5542156283Srwatson
5543156283Srwatson      -export-dynamic)
5544156283Srwatson	export_dynamic=yes
5545156283Srwatson	continue
5546156283Srwatson	;;
5547156283Srwatson
5548156283Srwatson      -export-symbols | -export-symbols-regex)
5549156283Srwatson	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
5550244390Srwatson	  func_fatal_error "more than one -exported-symbols argument is not allowed"
5551156283Srwatson	fi
5552156283Srwatson	if test "X$arg" = "X-export-symbols"; then
5553156283Srwatson	  prev=expsyms
5554156283Srwatson	else
5555156283Srwatson	  prev=expsyms_regex
5556156283Srwatson	fi
5557156283Srwatson	continue
5558156283Srwatson	;;
5559156283Srwatson
5560244390Srwatson      -framework)
5561244390Srwatson	prev=framework
5562159985Srwatson	continue
5563159985Srwatson	;;
5564156283Srwatson
5565156283Srwatson      -inst-prefix-dir)
5566156283Srwatson	prev=inst_prefix
5567156283Srwatson	continue
5568156283Srwatson	;;
5569156283Srwatson
5570156283Srwatson      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
5571156283Srwatson      # so, if we see these flags be careful not to treat them like -L
5572156283Srwatson      -L[A-Z][A-Z]*:*)
5573156283Srwatson	case $with_gcc/$host in
5574156283Srwatson	no/*-*-irix* | /*-*-irix*)
5575244390Srwatson	  func_append compile_command " $arg"
5576244390Srwatson	  func_append finalize_command " $arg"
5577156283Srwatson	  ;;
5578156283Srwatson	esac
5579156283Srwatson	continue
5580156283Srwatson	;;
5581156283Srwatson
5582156283Srwatson      -L*)
5583244390Srwatson	func_stripname "-L" '' "$arg"
5584244390Srwatson	if test -z "$func_stripname_result"; then
5585244390Srwatson	  if test "$#" -gt 0; then
5586244390Srwatson	    func_fatal_error "require no space between \`-L' and \`$1'"
5587244390Srwatson	  else
5588244390Srwatson	    func_fatal_error "need path for \`-L' option"
5589244390Srwatson	  fi
5590244390Srwatson	fi
5591244390Srwatson	func_resolve_sysroot "$func_stripname_result"
5592244390Srwatson	dir=$func_resolve_sysroot_result
5593156283Srwatson	# We need an absolute path.
5594156283Srwatson	case $dir in
5595156283Srwatson	[\\/]* | [A-Za-z]:[\\/]*) ;;
5596156283Srwatson	*)
5597156283Srwatson	  absdir=`cd "$dir" && pwd`
5598244390Srwatson	  test -z "$absdir" && \
5599244390Srwatson	    func_fatal_error "cannot determine absolute directory name of \`$dir'"
5600156283Srwatson	  dir="$absdir"
5601156283Srwatson	  ;;
5602156283Srwatson	esac
5603156283Srwatson	case "$deplibs " in
5604244390Srwatson	*" -L$dir "* | *" $arg "*)
5605244390Srwatson	  # Will only happen for absolute or sysroot arguments
5606244390Srwatson	  ;;
5607156283Srwatson	*)
5608244390Srwatson	  # Preserve sysroot, but never include relative directories
5609244390Srwatson	  case $dir in
5610244390Srwatson	    [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;;
5611244390Srwatson	    *) func_append deplibs " -L$dir" ;;
5612244390Srwatson	  esac
5613244390Srwatson	  func_append lib_search_path " $dir"
5614156283Srwatson	  ;;
5615156283Srwatson	esac
5616156283Srwatson	case $host in
5617244390Srwatson	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
5618244390Srwatson	  testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
5619156283Srwatson	  case :$dllsearchpath: in
5620156283Srwatson	  *":$dir:"*) ;;
5621244390Srwatson	  ::) dllsearchpath=$dir;;
5622244390Srwatson	  *) func_append dllsearchpath ":$dir";;
5623156283Srwatson	  esac
5624159985Srwatson	  case :$dllsearchpath: in
5625159985Srwatson	  *":$testbindir:"*) ;;
5626244390Srwatson	  ::) dllsearchpath=$testbindir;;
5627244390Srwatson	  *) func_append dllsearchpath ":$testbindir";;
5628159985Srwatson	  esac
5629156283Srwatson	  ;;
5630156283Srwatson	esac
5631244390Srwatson	deplibs="$deplibs $arg"
5632156283Srwatson	continue
5633156283Srwatson	;;
5634156283Srwatson
5635156283Srwatson      -l*)
5636156283Srwatson	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
5637156283Srwatson	  case $host in
5638244390Srwatson	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
5639156283Srwatson	    # These systems don't actually have a C or math library (as such)
5640156283Srwatson	    continue
5641156283Srwatson	    ;;
5642159985Srwatson	  *-*-os2*)
5643156283Srwatson	    # These systems don't actually have a C library (as such)
5644156283Srwatson	    test "X$arg" = "X-lc" && continue
5645156283Srwatson	    ;;
5646156283Srwatson	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
5647156283Srwatson	    # Do not include libc due to us having libc/libc_r.
5648156283Srwatson	    test "X$arg" = "X-lc" && continue
5649156283Srwatson	    ;;
5650156283Srwatson	  *-*-rhapsody* | *-*-darwin1.[012])
5651156283Srwatson	    # Rhapsody C and math libraries are in the System framework
5652244390Srwatson	    func_append deplibs " System.ltframework"
5653156283Srwatson	    continue
5654159985Srwatson	    ;;
5655159985Srwatson	  *-*-sco3.2v5* | *-*-sco5v6*)
5656159985Srwatson	    # Causes problems with __ctype
5657159985Srwatson	    test "X$arg" = "X-lc" && continue
5658159985Srwatson	    ;;
5659159985Srwatson	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
5660159985Srwatson	    # Compiler inserts libc in the correct place for threads to work
5661159985Srwatson	    test "X$arg" = "X-lc" && continue
5662159985Srwatson	    ;;
5663156283Srwatson	  esac
5664156283Srwatson	elif test "X$arg" = "X-lc_r"; then
5665156283Srwatson	 case $host in
5666156283Srwatson	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
5667156283Srwatson	   # Do not include libc_r directly, use -pthread flag.
5668156283Srwatson	   continue
5669156283Srwatson	   ;;
5670156283Srwatson	 esac
5671156283Srwatson	fi
5672244390Srwatson	func_append deplibs " $arg"
5673156283Srwatson	continue
5674156283Srwatson	;;
5675156283Srwatson
5676244390Srwatson      -module)
5677244390Srwatson	module=yes
5678244390Srwatson	continue
5679244390Srwatson	;;
5680244390Srwatson
5681156283Srwatson      # Tru64 UNIX uses -model [arg] to determine the layout of C++
5682156283Srwatson      # classes, name mangling, and exception handling.
5683244390Srwatson      # Darwin uses the -arch flag to determine output architecture.
5684244390Srwatson      -model|-arch|-isysroot|--sysroot)
5685244390Srwatson	func_append compiler_flags " $arg"
5686244390Srwatson	func_append compile_command " $arg"
5687244390Srwatson	func_append finalize_command " $arg"
5688156283Srwatson	prev=xcompiler
5689156283Srwatson	continue
5690156283Srwatson	;;
5691156283Srwatson
5692244390Srwatson      -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
5693244390Srwatson      |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
5694244390Srwatson	func_append compiler_flags " $arg"
5695244390Srwatson	func_append compile_command " $arg"
5696244390Srwatson	func_append finalize_command " $arg"
5697244390Srwatson	case "$new_inherited_linker_flags " in
5698244390Srwatson	    *" $arg "*) ;;
5699244390Srwatson	    * ) func_append new_inherited_linker_flags " $arg" ;;
5700244390Srwatson	esac
5701156283Srwatson	continue
5702156283Srwatson	;;
5703156283Srwatson
5704191273Srwatson      -multi_module)
5705191273Srwatson	single_module="${wl}-multi_module"
5706191273Srwatson	continue
5707191273Srwatson	;;
5708191273Srwatson
5709156283Srwatson      -no-fast-install)
5710156283Srwatson	fast_install=no
5711156283Srwatson	continue
5712156283Srwatson	;;
5713156283Srwatson
5714156283Srwatson      -no-install)
5715156283Srwatson	case $host in
5716244390Srwatson	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
5717156283Srwatson	  # The PATH hackery in wrapper scripts is required on Windows
5718173143Srwatson	  # and Darwin in order for the loader to find any dlls it needs.
5719244390Srwatson	  func_warning "\`-no-install' is ignored for $host"
5720244390Srwatson	  func_warning "assuming \`-no-fast-install' instead"
5721156283Srwatson	  fast_install=no
5722156283Srwatson	  ;;
5723156283Srwatson	*) no_install=yes ;;
5724156283Srwatson	esac
5725156283Srwatson	continue
5726156283Srwatson	;;
5727156283Srwatson
5728156283Srwatson      -no-undefined)
5729156283Srwatson	allow_undefined=no
5730156283Srwatson	continue
5731156283Srwatson	;;
5732156283Srwatson
5733156283Srwatson      -objectlist)
5734156283Srwatson	prev=objectlist
5735156283Srwatson	continue
5736156283Srwatson	;;
5737156283Srwatson
5738156283Srwatson      -o) prev=output ;;
5739156283Srwatson
5740156283Srwatson      -precious-files-regex)
5741156283Srwatson	prev=precious_regex
5742156283Srwatson	continue
5743156283Srwatson	;;
5744156283Srwatson
5745156283Srwatson      -release)
5746156283Srwatson	prev=release
5747156283Srwatson	continue
5748156283Srwatson	;;
5749156283Srwatson
5750156283Srwatson      -rpath)
5751156283Srwatson	prev=rpath
5752156283Srwatson	continue
5753156283Srwatson	;;
5754156283Srwatson
5755156283Srwatson      -R)
5756156283Srwatson	prev=xrpath
5757156283Srwatson	continue
5758156283Srwatson	;;
5759156283Srwatson
5760156283Srwatson      -R*)
5761244390Srwatson	func_stripname '-R' '' "$arg"
5762244390Srwatson	dir=$func_stripname_result
5763156283Srwatson	# We need an absolute path.
5764156283Srwatson	case $dir in
5765156283Srwatson	[\\/]* | [A-Za-z]:[\\/]*) ;;
5766244390Srwatson	=*)
5767244390Srwatson	  func_stripname '=' '' "$dir"
5768244390Srwatson	  dir=$lt_sysroot$func_stripname_result
5769244390Srwatson	  ;;
5770156283Srwatson	*)
5771244390Srwatson	  func_fatal_error "only absolute run-paths are allowed"
5772156283Srwatson	  ;;
5773156283Srwatson	esac
5774156283Srwatson	case "$xrpath " in
5775156283Srwatson	*" $dir "*) ;;
5776244390Srwatson	*) func_append xrpath " $dir" ;;
5777156283Srwatson	esac
5778156283Srwatson	continue
5779156283Srwatson	;;
5780156283Srwatson
5781244390Srwatson      -shared)
5782244390Srwatson	# The effects of -shared are defined in a previous loop.
5783244390Srwatson	continue
5784244390Srwatson	;;
5785244390Srwatson
5786244390Srwatson      -shrext)
5787244390Srwatson	prev=shrext
5788244390Srwatson	continue
5789244390Srwatson	;;
5790244390Srwatson
5791173143Srwatson      -static | -static-libtool-libs)
5792156283Srwatson	# The effects of -static are defined in a previous loop.
5793156283Srwatson	# We used to do the same as -all-static on platforms that
5794156283Srwatson	# didn't have a PIC flag, but the assumption that the effects
5795156283Srwatson	# would be equivalent was wrong.  It would break on at least
5796156283Srwatson	# Digital Unix and AIX.
5797156283Srwatson	continue
5798156283Srwatson	;;
5799156283Srwatson
5800156283Srwatson      -thread-safe)
5801156283Srwatson	thread_safe=yes
5802156283Srwatson	continue
5803156283Srwatson	;;
5804156283Srwatson
5805156283Srwatson      -version-info)
5806156283Srwatson	prev=vinfo
5807156283Srwatson	continue
5808156283Srwatson	;;
5809244390Srwatson
5810156283Srwatson      -version-number)
5811156283Srwatson	prev=vinfo
5812156283Srwatson	vinfo_number=yes
5813156283Srwatson	continue
5814156283Srwatson	;;
5815156283Srwatson
5816244390Srwatson      -weak)
5817244390Srwatson        prev=weak
5818244390Srwatson	continue
5819244390Srwatson	;;
5820244390Srwatson
5821156283Srwatson      -Wc,*)
5822244390Srwatson	func_stripname '-Wc,' '' "$arg"
5823244390Srwatson	args=$func_stripname_result
5824156283Srwatson	arg=
5825156283Srwatson	save_ifs="$IFS"; IFS=','
5826156283Srwatson	for flag in $args; do
5827156283Srwatson	  IFS="$save_ifs"
5828244390Srwatson          func_quote_for_eval "$flag"
5829244390Srwatson	  func_append arg " $func_quote_for_eval_result"
5830244390Srwatson	  func_append compiler_flags " $func_quote_for_eval_result"
5831156283Srwatson	done
5832156283Srwatson	IFS="$save_ifs"
5833244390Srwatson	func_stripname ' ' '' "$arg"
5834244390Srwatson	arg=$func_stripname_result
5835156283Srwatson	;;
5836156283Srwatson
5837156283Srwatson      -Wl,*)
5838244390Srwatson	func_stripname '-Wl,' '' "$arg"
5839244390Srwatson	args=$func_stripname_result
5840156283Srwatson	arg=
5841156283Srwatson	save_ifs="$IFS"; IFS=','
5842156283Srwatson	for flag in $args; do
5843156283Srwatson	  IFS="$save_ifs"
5844244390Srwatson          func_quote_for_eval "$flag"
5845244390Srwatson	  func_append arg " $wl$func_quote_for_eval_result"
5846244390Srwatson	  func_append compiler_flags " $wl$func_quote_for_eval_result"
5847244390Srwatson	  func_append linker_flags " $func_quote_for_eval_result"
5848156283Srwatson	done
5849156283Srwatson	IFS="$save_ifs"
5850244390Srwatson	func_stripname ' ' '' "$arg"
5851244390Srwatson	arg=$func_stripname_result
5852156283Srwatson	;;
5853156283Srwatson
5854156283Srwatson      -Xcompiler)
5855156283Srwatson	prev=xcompiler
5856156283Srwatson	continue
5857156283Srwatson	;;
5858156283Srwatson
5859156283Srwatson      -Xlinker)
5860156283Srwatson	prev=xlinker
5861156283Srwatson	continue
5862156283Srwatson	;;
5863156283Srwatson
5864156283Srwatson      -XCClinker)
5865156283Srwatson	prev=xcclinker
5866156283Srwatson	continue
5867156283Srwatson	;;
5868156283Srwatson
5869244390Srwatson      # -msg_* for osf cc
5870244390Srwatson      -msg_*)
5871244390Srwatson	func_quote_for_eval "$arg"
5872244390Srwatson	arg="$func_quote_for_eval_result"
5873244390Srwatson	;;
5874244390Srwatson
5875244390Srwatson      # Flags to be passed through unchanged, with rationale:
5876244390Srwatson      # -64, -mips[0-9]      enable 64-bit mode for the SGI compiler
5877244390Srwatson      # -r[0-9][0-9]*        specify processor for the SGI compiler
5878244390Srwatson      # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler
5879244390Srwatson      # +DA*, +DD*           enable 64-bit mode for the HP compiler
5880244390Srwatson      # -q*                  compiler args for the IBM compiler
5881244390Srwatson      # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
5882244390Srwatson      # -F/path              path to uninstalled frameworks, gcc on darwin
5883244390Srwatson      # -p, -pg, --coverage, -fprofile-*  profiling flags for GCC
5884244390Srwatson      # @file                GCC response files
5885244390Srwatson      # -tp=*                Portland pgcc target processor selection
5886244390Srwatson      # --sysroot=*          for sysroot support
5887244390Srwatson      # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
5888244390Srwatson      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
5889244390Srwatson      -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
5890244390Srwatson      -O*|-flto*|-fwhopr*|-fuse-linker-plugin)
5891244390Srwatson        func_quote_for_eval "$arg"
5892244390Srwatson	arg="$func_quote_for_eval_result"
5893244390Srwatson        func_append compile_command " $arg"
5894244390Srwatson        func_append finalize_command " $arg"
5895244390Srwatson        func_append compiler_flags " $arg"
5896244390Srwatson        continue
5897244390Srwatson        ;;
5898244390Srwatson
5899156283Srwatson      # Some other compiler flag.
5900156283Srwatson      -* | +*)
5901244390Srwatson        func_quote_for_eval "$arg"
5902244390Srwatson	arg="$func_quote_for_eval_result"
5903156283Srwatson	;;
5904156283Srwatson
5905156283Srwatson      *.$objext)
5906156283Srwatson	# A standard object.
5907244390Srwatson	func_append objs " $arg"
5908156283Srwatson	;;
5909156283Srwatson
5910156283Srwatson      *.lo)
5911156283Srwatson	# A libtool-controlled object.
5912156283Srwatson
5913156283Srwatson	# Check to see that this really is a libtool object.
5914244390Srwatson	if func_lalib_unsafe_p "$arg"; then
5915156283Srwatson	  pic_object=
5916156283Srwatson	  non_pic_object=
5917156283Srwatson
5918156283Srwatson	  # Read the .lo file
5919244390Srwatson	  func_source "$arg"
5920156283Srwatson
5921244390Srwatson	  if test -z "$pic_object" ||
5922156283Srwatson	     test -z "$non_pic_object" ||
5923244390Srwatson	     test "$pic_object" = none &&
5924156283Srwatson	     test "$non_pic_object" = none; then
5925244390Srwatson	    func_fatal_error "cannot find name of object for \`$arg'"
5926156283Srwatson	  fi
5927156283Srwatson
5928156283Srwatson	  # Extract subdirectory from the argument.
5929244390Srwatson	  func_dirname "$arg" "/" ""
5930244390Srwatson	  xdir="$func_dirname_result"
5931156283Srwatson
5932156283Srwatson	  if test "$pic_object" != none; then
5933156283Srwatson	    # Prepend the subdirectory the object is found in.
5934156283Srwatson	    pic_object="$xdir$pic_object"
5935156283Srwatson
5936156283Srwatson	    if test "$prev" = dlfiles; then
5937156283Srwatson	      if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
5938244390Srwatson		func_append dlfiles " $pic_object"
5939156283Srwatson		prev=
5940156283Srwatson		continue
5941156283Srwatson	      else
5942156283Srwatson		# If libtool objects are unsupported, then we need to preload.
5943156283Srwatson		prev=dlprefiles
5944156283Srwatson	      fi
5945156283Srwatson	    fi
5946156283Srwatson
5947156283Srwatson	    # CHECK ME:  I think I busted this.  -Ossama
5948156283Srwatson	    if test "$prev" = dlprefiles; then
5949156283Srwatson	      # Preload the old-style object.
5950244390Srwatson	      func_append dlprefiles " $pic_object"
5951156283Srwatson	      prev=
5952156283Srwatson	    fi
5953156283Srwatson
5954156283Srwatson	    # A PIC object.
5955244390Srwatson	    func_append libobjs " $pic_object"
5956156283Srwatson	    arg="$pic_object"
5957156283Srwatson	  fi
5958156283Srwatson
5959156283Srwatson	  # Non-PIC object.
5960156283Srwatson	  if test "$non_pic_object" != none; then
5961156283Srwatson	    # Prepend the subdirectory the object is found in.
5962156283Srwatson	    non_pic_object="$xdir$non_pic_object"
5963156283Srwatson
5964156283Srwatson	    # A standard non-PIC object
5965244390Srwatson	    func_append non_pic_objects " $non_pic_object"
5966156283Srwatson	    if test -z "$pic_object" || test "$pic_object" = none ; then
5967156283Srwatson	      arg="$non_pic_object"
5968156283Srwatson	    fi
5969159985Srwatson	  else
5970159985Srwatson	    # If the PIC object exists, use it instead.
5971159985Srwatson	    # $xdir was prepended to $pic_object above.
5972159985Srwatson	    non_pic_object="$pic_object"
5973244390Srwatson	    func_append non_pic_objects " $non_pic_object"
5974156283Srwatson	  fi
5975156283Srwatson	else
5976156283Srwatson	  # Only an error if not doing a dry-run.
5977244390Srwatson	  if $opt_dry_run; then
5978156283Srwatson	    # Extract subdirectory from the argument.
5979244390Srwatson	    func_dirname "$arg" "/" ""
5980244390Srwatson	    xdir="$func_dirname_result"
5981156283Srwatson
5982244390Srwatson	    func_lo2o "$arg"
5983244390Srwatson	    pic_object=$xdir$objdir/$func_lo2o_result
5984244390Srwatson	    non_pic_object=$xdir$func_lo2o_result
5985244390Srwatson	    func_append libobjs " $pic_object"
5986244390Srwatson	    func_append non_pic_objects " $non_pic_object"
5987244390Srwatson	  else
5988244390Srwatson	    func_fatal_error "\`$arg' is not a valid libtool object"
5989156283Srwatson	  fi
5990156283Srwatson	fi
5991156283Srwatson	;;
5992156283Srwatson
5993156283Srwatson      *.$libext)
5994156283Srwatson	# An archive.
5995244390Srwatson	func_append deplibs " $arg"
5996244390Srwatson	func_append old_deplibs " $arg"
5997156283Srwatson	continue
5998156283Srwatson	;;
5999156283Srwatson
6000156283Srwatson      *.la)
6001156283Srwatson	# A libtool-controlled library.
6002156283Srwatson
6003244390Srwatson	func_resolve_sysroot "$arg"
6004156283Srwatson	if test "$prev" = dlfiles; then
6005156283Srwatson	  # This library was specified with -dlopen.
6006244390Srwatson	  func_append dlfiles " $func_resolve_sysroot_result"
6007156283Srwatson	  prev=
6008156283Srwatson	elif test "$prev" = dlprefiles; then
6009156283Srwatson	  # The library was specified with -dlpreopen.
6010244390Srwatson	  func_append dlprefiles " $func_resolve_sysroot_result"
6011156283Srwatson	  prev=
6012156283Srwatson	else
6013244390Srwatson	  func_append deplibs " $func_resolve_sysroot_result"
6014156283Srwatson	fi
6015156283Srwatson	continue
6016156283Srwatson	;;
6017156283Srwatson
6018156283Srwatson      # Some other compiler argument.
6019156283Srwatson      *)
6020156283Srwatson	# Unknown arguments in both finalize_command and compile_command need
6021156283Srwatson	# to be aesthetically quoted because they are evaled later.
6022244390Srwatson	func_quote_for_eval "$arg"
6023244390Srwatson	arg="$func_quote_for_eval_result"
6024156283Srwatson	;;
6025156283Srwatson      esac # arg
6026156283Srwatson
6027156283Srwatson      # Now actually substitute the argument into the commands.
6028156283Srwatson      if test -n "$arg"; then
6029244390Srwatson	func_append compile_command " $arg"
6030244390Srwatson	func_append finalize_command " $arg"
6031156283Srwatson      fi
6032156283Srwatson    done # argument parsing loop
6033156283Srwatson
6034244390Srwatson    test -n "$prev" && \
6035244390Srwatson      func_fatal_help "the \`$prevarg' option requires an argument"
6036156283Srwatson
6037156283Srwatson    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
6038156283Srwatson      eval arg=\"$export_dynamic_flag_spec\"
6039244390Srwatson      func_append compile_command " $arg"
6040244390Srwatson      func_append finalize_command " $arg"
6041156283Srwatson    fi
6042156283Srwatson
6043156283Srwatson    oldlibs=
6044156283Srwatson    # calculate the name of the file, without its directory
6045244390Srwatson    func_basename "$output"
6046244390Srwatson    outputname="$func_basename_result"
6047156283Srwatson    libobjs_save="$libobjs"
6048156283Srwatson
6049156283Srwatson    if test -n "$shlibpath_var"; then
6050156283Srwatson      # get the directories listed in $shlibpath_var
6051244390Srwatson      eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\`
6052156283Srwatson    else
6053156283Srwatson      shlib_search_path=
6054156283Srwatson    fi
6055156283Srwatson    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
6056156283Srwatson    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
6057156283Srwatson
6058244390Srwatson    func_dirname "$output" "/" ""
6059244390Srwatson    output_objdir="$func_dirname_result$objdir"
6060244390Srwatson    func_to_tool_file "$output_objdir/"
6061244390Srwatson    tool_output_objdir=$func_to_tool_file_result
6062156283Srwatson    # Create the object directory.
6063244390Srwatson    func_mkdir_p "$output_objdir"
6064156283Srwatson
6065156283Srwatson    # Determine the type of output
6066156283Srwatson    case $output in
6067156283Srwatson    "")
6068244390Srwatson      func_fatal_help "you must specify an output file"
6069156283Srwatson      ;;
6070156283Srwatson    *.$libext) linkmode=oldlib ;;
6071156283Srwatson    *.lo | *.$objext) linkmode=obj ;;
6072156283Srwatson    *.la) linkmode=lib ;;
6073156283Srwatson    *) linkmode=prog ;; # Anything else should be a program.
6074156283Srwatson    esac
6075156283Srwatson
6076156283Srwatson    specialdeplibs=
6077156283Srwatson
6078156283Srwatson    libs=
6079156283Srwatson    # Find all interdependent deplibs by searching for libraries
6080156283Srwatson    # that are linked more than once (e.g. -la -lb -la)
6081156283Srwatson    for deplib in $deplibs; do
6082244390Srwatson      if $opt_preserve_dup_deps ; then
6083156283Srwatson	case "$libs " in
6084244390Srwatson	*" $deplib "*) func_append specialdeplibs " $deplib" ;;
6085156283Srwatson	esac
6086156283Srwatson      fi
6087244390Srwatson      func_append libs " $deplib"
6088156283Srwatson    done
6089156283Srwatson
6090156283Srwatson    if test "$linkmode" = lib; then
6091156283Srwatson      libs="$predeps $libs $compiler_lib_search_path $postdeps"
6092156283Srwatson
6093156283Srwatson      # Compute libraries that are listed more than once in $predeps
6094156283Srwatson      # $postdeps and mark them as special (i.e., whose duplicates are
6095156283Srwatson      # not to be eliminated).
6096156283Srwatson      pre_post_deps=
6097244390Srwatson      if $opt_duplicate_compiler_generated_deps; then
6098156283Srwatson	for pre_post_dep in $predeps $postdeps; do
6099156283Srwatson	  case "$pre_post_deps " in
6100244390Srwatson	  *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;;
6101156283Srwatson	  esac
6102244390Srwatson	  func_append pre_post_deps " $pre_post_dep"
6103156283Srwatson	done
6104156283Srwatson      fi
6105156283Srwatson      pre_post_deps=
6106156283Srwatson    fi
6107156283Srwatson
6108156283Srwatson    deplibs=
6109156283Srwatson    newdependency_libs=
6110156283Srwatson    newlib_search_path=
6111156283Srwatson    need_relink=no # whether we're linking any uninstalled libtool libraries
6112156283Srwatson    notinst_deplibs= # not-installed libtool libraries
6113244390Srwatson    notinst_path= # paths that contain not-installed libtool libraries
6114244390Srwatson
6115156283Srwatson    case $linkmode in
6116156283Srwatson    lib)
6117244390Srwatson	passes="conv dlpreopen link"
6118156283Srwatson	for file in $dlfiles $dlprefiles; do
6119156283Srwatson	  case $file in
6120156283Srwatson	  *.la) ;;
6121156283Srwatson	  *)
6122244390Srwatson	    func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file"
6123156283Srwatson	    ;;
6124156283Srwatson	  esac
6125156283Srwatson	done
6126156283Srwatson	;;
6127156283Srwatson    prog)
6128156283Srwatson	compile_deplibs=
6129156283Srwatson	finalize_deplibs=
6130156283Srwatson	alldeplibs=no
6131156283Srwatson	newdlfiles=
6132156283Srwatson	newdlprefiles=
6133156283Srwatson	passes="conv scan dlopen dlpreopen link"
6134156283Srwatson	;;
6135156283Srwatson    *)  passes="conv"
6136156283Srwatson	;;
6137156283Srwatson    esac
6138244390Srwatson
6139156283Srwatson    for pass in $passes; do
6140244390Srwatson      # The preopen pass in lib mode reverses $deplibs; put it back here
6141244390Srwatson      # so that -L comes before libs that need it for instance...
6142244390Srwatson      if test "$linkmode,$pass" = "lib,link"; then
6143244390Srwatson	## FIXME: Find the place where the list is rebuilt in the wrong
6144244390Srwatson	##        order, and fix it there properly
6145244390Srwatson        tmp_deplibs=
6146244390Srwatson	for deplib in $deplibs; do
6147244390Srwatson	  tmp_deplibs="$deplib $tmp_deplibs"
6148244390Srwatson	done
6149244390Srwatson	deplibs="$tmp_deplibs"
6150244390Srwatson      fi
6151244390Srwatson
6152156283Srwatson      if test "$linkmode,$pass" = "lib,link" ||
6153156283Srwatson	 test "$linkmode,$pass" = "prog,scan"; then
6154156283Srwatson	libs="$deplibs"
6155156283Srwatson	deplibs=
6156156283Srwatson      fi
6157156283Srwatson      if test "$linkmode" = prog; then
6158156283Srwatson	case $pass in
6159156283Srwatson	dlopen) libs="$dlfiles" ;;
6160156283Srwatson	dlpreopen) libs="$dlprefiles" ;;
6161156283Srwatson	link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
6162156283Srwatson	esac
6163156283Srwatson      fi
6164244390Srwatson      if test "$linkmode,$pass" = "lib,dlpreopen"; then
6165244390Srwatson	# Collect and forward deplibs of preopened libtool libs
6166244390Srwatson	for lib in $dlprefiles; do
6167244390Srwatson	  # Ignore non-libtool-libs
6168244390Srwatson	  dependency_libs=
6169244390Srwatson	  func_resolve_sysroot "$lib"
6170244390Srwatson	  case $lib in
6171244390Srwatson	  *.la)	func_source "$func_resolve_sysroot_result" ;;
6172244390Srwatson	  esac
6173244390Srwatson
6174244390Srwatson	  # Collect preopened libtool deplibs, except any this library
6175244390Srwatson	  # has declared as weak libs
6176244390Srwatson	  for deplib in $dependency_libs; do
6177244390Srwatson	    func_basename "$deplib"
6178244390Srwatson            deplib_base=$func_basename_result
6179244390Srwatson	    case " $weak_libs " in
6180244390Srwatson	    *" $deplib_base "*) ;;
6181244390Srwatson	    *) func_append deplibs " $deplib" ;;
6182244390Srwatson	    esac
6183244390Srwatson	  done
6184244390Srwatson	done
6185244390Srwatson	libs="$dlprefiles"
6186244390Srwatson      fi
6187156283Srwatson      if test "$pass" = dlopen; then
6188156283Srwatson	# Collect dlpreopened libraries
6189156283Srwatson	save_deplibs="$deplibs"
6190156283Srwatson	deplibs=
6191156283Srwatson      fi
6192244390Srwatson
6193156283Srwatson      for deplib in $libs; do
6194156283Srwatson	lib=
6195156283Srwatson	found=no
6196156283Srwatson	case $deplib in
6197244390Srwatson	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
6198244390Srwatson        |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
6199156283Srwatson	  if test "$linkmode,$pass" = "prog,link"; then
6200156283Srwatson	    compile_deplibs="$deplib $compile_deplibs"
6201156283Srwatson	    finalize_deplibs="$deplib $finalize_deplibs"
6202156283Srwatson	  else
6203244390Srwatson	    func_append compiler_flags " $deplib"
6204156283Srwatson	  fi
6205159985Srwatson
6206159985Srwatson	  case $linkmode in
6207159985Srwatson	  lib)
6208159985Srwatson	    deplibs="$deplib $deplibs"
6209159985Srwatson	    test "$pass" = conv && continue
6210159985Srwatson	    newdependency_libs="$deplib $newdependency_libs"
6211159985Srwatson	    ;;
6212159985Srwatson	  prog)
6213159985Srwatson	    if test "$pass" = conv; then
6214159985Srwatson	      deplibs="$deplib $deplibs"
6215159985Srwatson	      continue
6216159985Srwatson	    fi
6217159985Srwatson	    if test "$pass" = scan; then
6218159985Srwatson	      deplibs="$deplib $deplibs"
6219159985Srwatson	    else
6220159985Srwatson	      compile_deplibs="$deplib $compile_deplibs"
6221159985Srwatson	      finalize_deplibs="$deplib $finalize_deplibs"
6222159985Srwatson	    fi
6223159985Srwatson	    ;;
6224159985Srwatson	  *)
6225159985Srwatson	    ;;
6226159985Srwatson	  esac # linkmode
6227159985Srwatson
6228156283Srwatson	  continue
6229156283Srwatson	  ;;
6230156283Srwatson	-l*)
6231156283Srwatson	  if test "$linkmode" != lib && test "$linkmode" != prog; then
6232244390Srwatson	    func_warning "\`-l' is ignored for archives/objects"
6233156283Srwatson	    continue
6234156283Srwatson	  fi
6235244390Srwatson	  func_stripname '-l' '' "$deplib"
6236244390Srwatson	  name=$func_stripname_result
6237191273Srwatson	  if test "$linkmode" = lib; then
6238191273Srwatson	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
6239191273Srwatson	  else
6240191273Srwatson	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
6241191273Srwatson	  fi
6242191273Srwatson	  for searchdir in $searchdirs; do
6243156283Srwatson	    for search_ext in .la $std_shrext .so .a; do
6244156283Srwatson	      # Search the libtool library
6245156283Srwatson	      lib="$searchdir/lib${name}${search_ext}"
6246156283Srwatson	      if test -f "$lib"; then
6247156283Srwatson		if test "$search_ext" = ".la"; then
6248156283Srwatson		  found=yes
6249156283Srwatson		else
6250156283Srwatson		  found=no
6251156283Srwatson		fi
6252156283Srwatson		break 2
6253156283Srwatson	      fi
6254156283Srwatson	    done
6255156283Srwatson	  done
6256156283Srwatson	  if test "$found" != yes; then
6257156283Srwatson	    # deplib doesn't seem to be a libtool library
6258156283Srwatson	    if test "$linkmode,$pass" = "prog,link"; then
6259156283Srwatson	      compile_deplibs="$deplib $compile_deplibs"
6260156283Srwatson	      finalize_deplibs="$deplib $finalize_deplibs"
6261156283Srwatson	    else
6262156283Srwatson	      deplibs="$deplib $deplibs"
6263156283Srwatson	      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
6264156283Srwatson	    fi
6265156283Srwatson	    continue
6266156283Srwatson	  else # deplib is a libtool library
6267156283Srwatson	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
6268156283Srwatson	    # We need to do some special things here, and not later.
6269156283Srwatson	    if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6270156283Srwatson	      case " $predeps $postdeps " in
6271156283Srwatson	      *" $deplib "*)
6272244390Srwatson		if func_lalib_p "$lib"; then
6273156283Srwatson		  library_names=
6274156283Srwatson		  old_library=
6275244390Srwatson		  func_source "$lib"
6276156283Srwatson		  for l in $old_library $library_names; do
6277156283Srwatson		    ll="$l"
6278156283Srwatson		  done
6279156283Srwatson		  if test "X$ll" = "X$old_library" ; then # only static version available
6280156283Srwatson		    found=no
6281244390Srwatson		    func_dirname "$lib" "" "."
6282244390Srwatson		    ladir="$func_dirname_result"
6283156283Srwatson		    lib=$ladir/$old_library
6284156283Srwatson		    if test "$linkmode,$pass" = "prog,link"; then
6285156283Srwatson		      compile_deplibs="$deplib $compile_deplibs"
6286156283Srwatson		      finalize_deplibs="$deplib $finalize_deplibs"
6287156283Srwatson		    else
6288156283Srwatson		      deplibs="$deplib $deplibs"
6289156283Srwatson		      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
6290156283Srwatson		    fi
6291156283Srwatson		    continue
6292156283Srwatson		  fi
6293156283Srwatson		fi
6294244390Srwatson		;;
6295156283Srwatson	      *) ;;
6296156283Srwatson	      esac
6297156283Srwatson	    fi
6298156283Srwatson	  fi
6299156283Srwatson	  ;; # -l
6300244390Srwatson	*.ltframework)
6301244390Srwatson	  if test "$linkmode,$pass" = "prog,link"; then
6302244390Srwatson	    compile_deplibs="$deplib $compile_deplibs"
6303244390Srwatson	    finalize_deplibs="$deplib $finalize_deplibs"
6304244390Srwatson	  else
6305244390Srwatson	    deplibs="$deplib $deplibs"
6306244390Srwatson	    if test "$linkmode" = lib ; then
6307244390Srwatson		case "$new_inherited_linker_flags " in
6308244390Srwatson		    *" $deplib "*) ;;
6309244390Srwatson		    * ) func_append new_inherited_linker_flags " $deplib" ;;
6310244390Srwatson		esac
6311244390Srwatson	    fi
6312244390Srwatson	  fi
6313244390Srwatson	  continue
6314244390Srwatson	  ;;
6315156283Srwatson	-L*)
6316156283Srwatson	  case $linkmode in
6317156283Srwatson	  lib)
6318156283Srwatson	    deplibs="$deplib $deplibs"
6319156283Srwatson	    test "$pass" = conv && continue
6320156283Srwatson	    newdependency_libs="$deplib $newdependency_libs"
6321244390Srwatson	    func_stripname '-L' '' "$deplib"
6322244390Srwatson	    func_resolve_sysroot "$func_stripname_result"
6323244390Srwatson	    func_append newlib_search_path " $func_resolve_sysroot_result"
6324156283Srwatson	    ;;
6325156283Srwatson	  prog)
6326156283Srwatson	    if test "$pass" = conv; then
6327156283Srwatson	      deplibs="$deplib $deplibs"
6328156283Srwatson	      continue
6329156283Srwatson	    fi
6330156283Srwatson	    if test "$pass" = scan; then
6331156283Srwatson	      deplibs="$deplib $deplibs"
6332156283Srwatson	    else
6333156283Srwatson	      compile_deplibs="$deplib $compile_deplibs"
6334156283Srwatson	      finalize_deplibs="$deplib $finalize_deplibs"
6335156283Srwatson	    fi
6336244390Srwatson	    func_stripname '-L' '' "$deplib"
6337244390Srwatson	    func_resolve_sysroot "$func_stripname_result"
6338244390Srwatson	    func_append newlib_search_path " $func_resolve_sysroot_result"
6339156283Srwatson	    ;;
6340156283Srwatson	  *)
6341244390Srwatson	    func_warning "\`-L' is ignored for archives/objects"
6342156283Srwatson	    ;;
6343156283Srwatson	  esac # linkmode
6344156283Srwatson	  continue
6345156283Srwatson	  ;; # -L
6346156283Srwatson	-R*)
6347156283Srwatson	  if test "$pass" = link; then
6348244390Srwatson	    func_stripname '-R' '' "$deplib"
6349244390Srwatson	    func_resolve_sysroot "$func_stripname_result"
6350244390Srwatson	    dir=$func_resolve_sysroot_result
6351156283Srwatson	    # Make sure the xrpath contains only unique directories.
6352156283Srwatson	    case "$xrpath " in
6353156283Srwatson	    *" $dir "*) ;;
6354244390Srwatson	    *) func_append xrpath " $dir" ;;
6355156283Srwatson	    esac
6356156283Srwatson	  fi
6357156283Srwatson	  deplibs="$deplib $deplibs"
6358156283Srwatson	  continue
6359156283Srwatson	  ;;
6360244390Srwatson	*.la)
6361244390Srwatson	  func_resolve_sysroot "$deplib"
6362244390Srwatson	  lib=$func_resolve_sysroot_result
6363244390Srwatson	  ;;
6364156283Srwatson	*.$libext)
6365156283Srwatson	  if test "$pass" = conv; then
6366156283Srwatson	    deplibs="$deplib $deplibs"
6367156283Srwatson	    continue
6368156283Srwatson	  fi
6369156283Srwatson	  case $linkmode in
6370156283Srwatson	  lib)
6371244390Srwatson	    # Linking convenience modules into shared libraries is allowed,
6372244390Srwatson	    # but linking other static libraries is non-portable.
6373244390Srwatson	    case " $dlpreconveniencelibs " in
6374244390Srwatson	    *" $deplib "*) ;;
6375244390Srwatson	    *)
6376244390Srwatson	      valid_a_lib=no
6377244390Srwatson	      case $deplibs_check_method in
6378244390Srwatson		match_pattern*)
6379244390Srwatson		  set dummy $deplibs_check_method; shift
6380244390Srwatson		  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
6381244390Srwatson		  if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
6382156283Srwatson		    | $EGREP "$match_pattern_regex" > /dev/null; then
6383244390Srwatson		    valid_a_lib=yes
6384244390Srwatson		  fi
6385244390Srwatson		;;
6386244390Srwatson		pass_all)
6387156283Srwatson		  valid_a_lib=yes
6388156283Srwatson		;;
6389244390Srwatson	      esac
6390244390Srwatson	      if test "$valid_a_lib" != yes; then
6391244390Srwatson		echo
6392244390Srwatson		$ECHO "*** Warning: Trying to link with static lib archive $deplib."
6393244390Srwatson		echo "*** I have the capability to make that library automatically link in when"
6394244390Srwatson		echo "*** you link to this library.  But I can only do this if you have a"
6395244390Srwatson		echo "*** shared version of the library, which you do not appear to have"
6396244390Srwatson		echo "*** because the file extensions .$libext of this argument makes me believe"
6397244390Srwatson		echo "*** that it is just a static archive that I should not use here."
6398244390Srwatson	      else
6399244390Srwatson		echo
6400244390Srwatson		$ECHO "*** Warning: Linking the shared library $output against the"
6401244390Srwatson		$ECHO "*** static library $deplib is not portable!"
6402244390Srwatson		deplibs="$deplib $deplibs"
6403244390Srwatson	      fi
6404244390Srwatson	      ;;
6405244390Srwatson	    esac
6406156283Srwatson	    continue
6407156283Srwatson	    ;;
6408156283Srwatson	  prog)
6409156283Srwatson	    if test "$pass" != link; then
6410156283Srwatson	      deplibs="$deplib $deplibs"
6411156283Srwatson	    else
6412156283Srwatson	      compile_deplibs="$deplib $compile_deplibs"
6413156283Srwatson	      finalize_deplibs="$deplib $finalize_deplibs"
6414156283Srwatson	    fi
6415156283Srwatson	    continue
6416156283Srwatson	    ;;
6417156283Srwatson	  esac # linkmode
6418156283Srwatson	  ;; # *.$libext
6419156283Srwatson	*.lo | *.$objext)
6420156283Srwatson	  if test "$pass" = conv; then
6421156283Srwatson	    deplibs="$deplib $deplibs"
6422156283Srwatson	  elif test "$linkmode" = prog; then
6423156283Srwatson	    if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
6424156283Srwatson	      # If there is no dlopen support or we're linking statically,
6425156283Srwatson	      # we need to preload.
6426244390Srwatson	      func_append newdlprefiles " $deplib"
6427156283Srwatson	      compile_deplibs="$deplib $compile_deplibs"
6428156283Srwatson	      finalize_deplibs="$deplib $finalize_deplibs"
6429156283Srwatson	    else
6430244390Srwatson	      func_append newdlfiles " $deplib"
6431156283Srwatson	    fi
6432156283Srwatson	  fi
6433156283Srwatson	  continue
6434156283Srwatson	  ;;
6435156283Srwatson	%DEPLIBS%)
6436156283Srwatson	  alldeplibs=yes
6437156283Srwatson	  continue
6438156283Srwatson	  ;;
6439156283Srwatson	esac # case $deplib
6440244390Srwatson
6441156283Srwatson	if test "$found" = yes || test -f "$lib"; then :
6442156283Srwatson	else
6443244390Srwatson	  func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'"
6444156283Srwatson	fi
6445156283Srwatson
6446156283Srwatson	# Check to see that this really is a libtool archive.
6447244390Srwatson	func_lalib_unsafe_p "$lib" \
6448244390Srwatson	  || func_fatal_error "\`$lib' is not a valid libtool archive"
6449156283Srwatson
6450244390Srwatson	func_dirname "$lib" "" "."
6451244390Srwatson	ladir="$func_dirname_result"
6452156283Srwatson
6453156283Srwatson	dlname=
6454156283Srwatson	dlopen=
6455156283Srwatson	dlpreopen=
6456156283Srwatson	libdir=
6457156283Srwatson	library_names=
6458156283Srwatson	old_library=
6459244390Srwatson	inherited_linker_flags=
6460156283Srwatson	# If the library was installed with an old release of libtool,
6461156283Srwatson	# it will not redefine variables installed, or shouldnotlink
6462156283Srwatson	installed=yes
6463156283Srwatson	shouldnotlink=no
6464156283Srwatson	avoidtemprpath=
6465156283Srwatson
6466156283Srwatson
6467156283Srwatson	# Read the .la file
6468244390Srwatson	func_source "$lib"
6469156283Srwatson
6470244390Srwatson	# Convert "-framework foo" to "foo.ltframework"
6471244390Srwatson	if test -n "$inherited_linker_flags"; then
6472244390Srwatson	  tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
6473244390Srwatson	  for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
6474244390Srwatson	    case " $new_inherited_linker_flags " in
6475244390Srwatson	      *" $tmp_inherited_linker_flag "*) ;;
6476244390Srwatson	      *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";;
6477244390Srwatson	    esac
6478244390Srwatson	  done
6479244390Srwatson	fi
6480244390Srwatson	dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
6481156283Srwatson	if test "$linkmode,$pass" = "lib,link" ||
6482156283Srwatson	   test "$linkmode,$pass" = "prog,scan" ||
6483156283Srwatson	   { test "$linkmode" != prog && test "$linkmode" != lib; }; then
6484244390Srwatson	  test -n "$dlopen" && func_append dlfiles " $dlopen"
6485244390Srwatson	  test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen"
6486156283Srwatson	fi
6487156283Srwatson
6488156283Srwatson	if test "$pass" = conv; then
6489156283Srwatson	  # Only check for convenience libraries
6490156283Srwatson	  deplibs="$lib $deplibs"
6491156283Srwatson	  if test -z "$libdir"; then
6492156283Srwatson	    if test -z "$old_library"; then
6493244390Srwatson	      func_fatal_error "cannot find name of link library for \`$lib'"
6494156283Srwatson	    fi
6495156283Srwatson	    # It is a libtool convenience library, so add in its objects.
6496244390Srwatson	    func_append convenience " $ladir/$objdir/$old_library"
6497244390Srwatson	    func_append old_convenience " $ladir/$objdir/$old_library"
6498156283Srwatson	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
6499244390Srwatson	    func_fatal_error "\`$lib' is not a convenience library"
6500156283Srwatson	  fi
6501244390Srwatson	  tmp_libs=
6502244390Srwatson	  for deplib in $dependency_libs; do
6503244390Srwatson	    deplibs="$deplib $deplibs"
6504244390Srwatson	    if $opt_preserve_dup_deps ; then
6505244390Srwatson	      case "$tmp_libs " in
6506244390Srwatson	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
6507244390Srwatson	      esac
6508244390Srwatson	    fi
6509244390Srwatson	    func_append tmp_libs " $deplib"
6510244390Srwatson	  done
6511156283Srwatson	  continue
6512156283Srwatson	fi # $pass = conv
6513156283Srwatson
6514156283Srwatson
6515156283Srwatson	# Get the name of the library we link against.
6516156283Srwatson	linklib=
6517244390Srwatson	if test -n "$old_library" &&
6518244390Srwatson	   { test "$prefer_static_libs" = yes ||
6519244390Srwatson	     test "$prefer_static_libs,$installed" = "built,no"; }; then
6520244390Srwatson	  linklib=$old_library
6521244390Srwatson	else
6522244390Srwatson	  for l in $old_library $library_names; do
6523244390Srwatson	    linklib="$l"
6524244390Srwatson	  done
6525244390Srwatson	fi
6526156283Srwatson	if test -z "$linklib"; then
6527244390Srwatson	  func_fatal_error "cannot find name of link library for \`$lib'"
6528156283Srwatson	fi
6529156283Srwatson
6530156283Srwatson	# This library was specified with -dlopen.
6531156283Srwatson	if test "$pass" = dlopen; then
6532156283Srwatson	  if test -z "$libdir"; then
6533244390Srwatson	    func_fatal_error "cannot -dlopen a convenience library: \`$lib'"
6534156283Srwatson	  fi
6535156283Srwatson	  if test -z "$dlname" ||
6536156283Srwatson	     test "$dlopen_support" != yes ||
6537156283Srwatson	     test "$build_libtool_libs" = no; then
6538156283Srwatson	    # If there is no dlname, no dlopen support or we're linking
6539156283Srwatson	    # statically, we need to preload.  We also need to preload any
6540156283Srwatson	    # dependent libraries so libltdl's deplib preloader doesn't
6541156283Srwatson	    # bomb out in the load deplibs phase.
6542244390Srwatson	    func_append dlprefiles " $lib $dependency_libs"
6543156283Srwatson	  else
6544244390Srwatson	    func_append newdlfiles " $lib"
6545156283Srwatson	  fi
6546156283Srwatson	  continue
6547156283Srwatson	fi # $pass = dlopen
6548156283Srwatson
6549156283Srwatson	# We need an absolute path.
6550156283Srwatson	case $ladir in
6551156283Srwatson	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
6552156283Srwatson	*)
6553156283Srwatson	  abs_ladir=`cd "$ladir" && pwd`
6554156283Srwatson	  if test -z "$abs_ladir"; then
6555244390Srwatson	    func_warning "cannot determine absolute directory name of \`$ladir'"
6556244390Srwatson	    func_warning "passing it literally to the linker, although it might fail"
6557156283Srwatson	    abs_ladir="$ladir"
6558156283Srwatson	  fi
6559156283Srwatson	  ;;
6560156283Srwatson	esac
6561244390Srwatson	func_basename "$lib"
6562244390Srwatson	laname="$func_basename_result"
6563156283Srwatson
6564156283Srwatson	# Find the relevant object directory and library name.
6565156283Srwatson	if test "X$installed" = Xyes; then
6566244390Srwatson	  if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
6567244390Srwatson	    func_warning "library \`$lib' was moved."
6568156283Srwatson	    dir="$ladir"
6569156283Srwatson	    absdir="$abs_ladir"
6570156283Srwatson	    libdir="$abs_ladir"
6571156283Srwatson	  else
6572244390Srwatson	    dir="$lt_sysroot$libdir"
6573244390Srwatson	    absdir="$lt_sysroot$libdir"
6574156283Srwatson	  fi
6575156283Srwatson	  test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
6576156283Srwatson	else
6577156283Srwatson	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
6578156283Srwatson	    dir="$ladir"
6579156283Srwatson	    absdir="$abs_ladir"
6580156283Srwatson	    # Remove this search path later
6581244390Srwatson	    func_append notinst_path " $abs_ladir"
6582156283Srwatson	  else
6583156283Srwatson	    dir="$ladir/$objdir"
6584156283Srwatson	    absdir="$abs_ladir/$objdir"
6585156283Srwatson	    # Remove this search path later
6586244390Srwatson	    func_append notinst_path " $abs_ladir"
6587156283Srwatson	  fi
6588156283Srwatson	fi # $installed = yes
6589244390Srwatson	func_stripname 'lib' '.la' "$laname"
6590244390Srwatson	name=$func_stripname_result
6591156283Srwatson
6592156283Srwatson	# This library was specified with -dlpreopen.
6593156283Srwatson	if test "$pass" = dlpreopen; then
6594244390Srwatson	  if test -z "$libdir" && test "$linkmode" = prog; then
6595244390Srwatson	    func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'"
6596156283Srwatson	  fi
6597244390Srwatson	  case "$host" in
6598244390Srwatson	    # special handling for platforms with PE-DLLs.
6599244390Srwatson	    *cygwin* | *mingw* | *cegcc* )
6600244390Srwatson	      # Linker will automatically link against shared library if both
6601244390Srwatson	      # static and shared are present.  Therefore, ensure we extract
6602244390Srwatson	      # symbols from the import library if a shared library is present
6603244390Srwatson	      # (otherwise, the dlopen module name will be incorrect).  We do
6604244390Srwatson	      # this by putting the import library name into $newdlprefiles.
6605244390Srwatson	      # We recover the dlopen module name by 'saving' the la file
6606244390Srwatson	      # name in a special purpose variable, and (later) extracting the
6607244390Srwatson	      # dlname from the la file.
6608244390Srwatson	      if test -n "$dlname"; then
6609244390Srwatson	        func_tr_sh "$dir/$linklib"
6610244390Srwatson	        eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname"
6611244390Srwatson	        func_append newdlprefiles " $dir/$linklib"
6612244390Srwatson	      else
6613244390Srwatson	        func_append newdlprefiles " $dir/$old_library"
6614244390Srwatson	        # Keep a list of preopened convenience libraries to check
6615244390Srwatson	        # that they are being used correctly in the link pass.
6616244390Srwatson	        test -z "$libdir" && \
6617244390Srwatson	          func_append dlpreconveniencelibs " $dir/$old_library"
6618244390Srwatson	      fi
6619244390Srwatson	    ;;
6620244390Srwatson	    * )
6621244390Srwatson	      # Prefer using a static library (so that no silly _DYNAMIC symbols
6622244390Srwatson	      # are required to link).
6623244390Srwatson	      if test -n "$old_library"; then
6624244390Srwatson	        func_append newdlprefiles " $dir/$old_library"
6625244390Srwatson	        # Keep a list of preopened convenience libraries to check
6626244390Srwatson	        # that they are being used correctly in the link pass.
6627244390Srwatson	        test -z "$libdir" && \
6628244390Srwatson	          func_append dlpreconveniencelibs " $dir/$old_library"
6629244390Srwatson	      # Otherwise, use the dlname, so that lt_dlopen finds it.
6630244390Srwatson	      elif test -n "$dlname"; then
6631244390Srwatson	        func_append newdlprefiles " $dir/$dlname"
6632244390Srwatson	      else
6633244390Srwatson	        func_append newdlprefiles " $dir/$linklib"
6634244390Srwatson	      fi
6635244390Srwatson	    ;;
6636244390Srwatson	  esac
6637156283Srwatson	fi # $pass = dlpreopen
6638156283Srwatson
6639156283Srwatson	if test -z "$libdir"; then
6640156283Srwatson	  # Link the convenience library
6641156283Srwatson	  if test "$linkmode" = lib; then
6642156283Srwatson	    deplibs="$dir/$old_library $deplibs"
6643156283Srwatson	  elif test "$linkmode,$pass" = "prog,link"; then
6644156283Srwatson	    compile_deplibs="$dir/$old_library $compile_deplibs"
6645156283Srwatson	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
6646156283Srwatson	  else
6647156283Srwatson	    deplibs="$lib $deplibs" # used for prog,scan pass
6648156283Srwatson	  fi
6649156283Srwatson	  continue
6650156283Srwatson	fi
6651156283Srwatson
6652156283Srwatson
6653156283Srwatson	if test "$linkmode" = prog && test "$pass" != link; then
6654244390Srwatson	  func_append newlib_search_path " $ladir"
6655156283Srwatson	  deplibs="$lib $deplibs"
6656156283Srwatson
6657156283Srwatson	  linkalldeplibs=no
6658156283Srwatson	  if test "$link_all_deplibs" != no || test -z "$library_names" ||
6659156283Srwatson	     test "$build_libtool_libs" = no; then
6660156283Srwatson	    linkalldeplibs=yes
6661156283Srwatson	  fi
6662156283Srwatson
6663156283Srwatson	  tmp_libs=
6664156283Srwatson	  for deplib in $dependency_libs; do
6665156283Srwatson	    case $deplib in
6666244390Srwatson	    -L*) func_stripname '-L' '' "$deplib"
6667244390Srwatson	         func_resolve_sysroot "$func_stripname_result"
6668244390Srwatson	         func_append newlib_search_path " $func_resolve_sysroot_result"
6669244390Srwatson		 ;;
6670156283Srwatson	    esac
6671156283Srwatson	    # Need to link against all dependency_libs?
6672156283Srwatson	    if test "$linkalldeplibs" = yes; then
6673156283Srwatson	      deplibs="$deplib $deplibs"
6674156283Srwatson	    else
6675156283Srwatson	      # Need to hardcode shared library paths
6676156283Srwatson	      # or/and link against static libraries
6677156283Srwatson	      newdependency_libs="$deplib $newdependency_libs"
6678156283Srwatson	    fi
6679244390Srwatson	    if $opt_preserve_dup_deps ; then
6680156283Srwatson	      case "$tmp_libs " in
6681244390Srwatson	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
6682156283Srwatson	      esac
6683156283Srwatson	    fi
6684244390Srwatson	    func_append tmp_libs " $deplib"
6685156283Srwatson	  done # for deplib
6686156283Srwatson	  continue
6687156283Srwatson	fi # $linkmode = prog...
6688156283Srwatson
6689156283Srwatson	if test "$linkmode,$pass" = "prog,link"; then
6690156283Srwatson	  if test -n "$library_names" &&
6691173143Srwatson	     { { test "$prefer_static_libs" = no ||
6692244390Srwatson	         test "$prefer_static_libs,$installed" = "built,yes"; } ||
6693173143Srwatson	       test -z "$old_library"; }; then
6694156283Srwatson	    # We need to hardcode the library path
6695156283Srwatson	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
6696156283Srwatson	      # Make sure the rpath contains only unique directories.
6697244390Srwatson	      case "$temp_rpath:" in
6698244390Srwatson	      *"$absdir:"*) ;;
6699244390Srwatson	      *) func_append temp_rpath "$absdir:" ;;
6700156283Srwatson	      esac
6701156283Srwatson	    fi
6702156283Srwatson
6703156283Srwatson	    # Hardcode the library path.
6704156283Srwatson	    # Skip directories that are in the system default run-time
6705156283Srwatson	    # search path.
6706156283Srwatson	    case " $sys_lib_dlsearch_path " in
6707156283Srwatson	    *" $absdir "*) ;;
6708156283Srwatson	    *)
6709156283Srwatson	      case "$compile_rpath " in
6710156283Srwatson	      *" $absdir "*) ;;
6711244390Srwatson	      *) func_append compile_rpath " $absdir" ;;
6712156283Srwatson	      esac
6713156283Srwatson	      ;;
6714156283Srwatson	    esac
6715156283Srwatson	    case " $sys_lib_dlsearch_path " in
6716156283Srwatson	    *" $libdir "*) ;;
6717156283Srwatson	    *)
6718156283Srwatson	      case "$finalize_rpath " in
6719156283Srwatson	      *" $libdir "*) ;;
6720244390Srwatson	      *) func_append finalize_rpath " $libdir" ;;
6721156283Srwatson	      esac
6722156283Srwatson	      ;;
6723156283Srwatson	    esac
6724156283Srwatson	  fi # $linkmode,$pass = prog,link...
6725156283Srwatson
6726156283Srwatson	  if test "$alldeplibs" = yes &&
6727156283Srwatson	     { test "$deplibs_check_method" = pass_all ||
6728156283Srwatson	       { test "$build_libtool_libs" = yes &&
6729156283Srwatson		 test -n "$library_names"; }; }; then
6730156283Srwatson	    # We only need to search for static libraries
6731156283Srwatson	    continue
6732156283Srwatson	  fi
6733156283Srwatson	fi
6734156283Srwatson
6735156283Srwatson	link_static=no # Whether the deplib will be linked statically
6736159985Srwatson	use_static_libs=$prefer_static_libs
6737244390Srwatson	if test "$use_static_libs" = built && test "$installed" = yes; then
6738159985Srwatson	  use_static_libs=no
6739159985Srwatson	fi
6740156283Srwatson	if test -n "$library_names" &&
6741159985Srwatson	   { test "$use_static_libs" = no || test -z "$old_library"; }; then
6742244390Srwatson	  case $host in
6743244390Srwatson	  *cygwin* | *mingw* | *cegcc*)
6744244390Srwatson	      # No point in relinking DLLs because paths are not encoded
6745244390Srwatson	      func_append notinst_deplibs " $lib"
6746244390Srwatson	      need_relink=no
6747244390Srwatson	    ;;
6748244390Srwatson	  *)
6749244390Srwatson	    if test "$installed" = no; then
6750244390Srwatson	      func_append notinst_deplibs " $lib"
6751244390Srwatson	      need_relink=yes
6752244390Srwatson	    fi
6753244390Srwatson	    ;;
6754244390Srwatson	  esac
6755156283Srwatson	  # This is a shared library
6756156283Srwatson
6757244390Srwatson	  # Warn about portability, can't link against -module's on some
6758244390Srwatson	  # systems (darwin).  Don't bleat about dlopened modules though!
6759244390Srwatson	  dlopenmodule=""
6760244390Srwatson	  for dlpremoduletest in $dlprefiles; do
6761244390Srwatson	    if test "X$dlpremoduletest" = "X$lib"; then
6762244390Srwatson	      dlopenmodule="$dlpremoduletest"
6763244390Srwatson	      break
6764244390Srwatson	    fi
6765244390Srwatson	  done
6766244390Srwatson	  if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then
6767244390Srwatson	    echo
6768156283Srwatson	    if test "$linkmode" = prog; then
6769244390Srwatson	      $ECHO "*** Warning: Linking the executable $output against the loadable module"
6770156283Srwatson	    else
6771244390Srwatson	      $ECHO "*** Warning: Linking the shared library $output against the loadable module"
6772156283Srwatson	    fi
6773244390Srwatson	    $ECHO "*** $linklib is not portable!"
6774156283Srwatson	  fi
6775156283Srwatson	  if test "$linkmode" = lib &&
6776156283Srwatson	     test "$hardcode_into_libs" = yes; then
6777156283Srwatson	    # Hardcode the library path.
6778156283Srwatson	    # Skip directories that are in the system default run-time
6779156283Srwatson	    # search path.
6780156283Srwatson	    case " $sys_lib_dlsearch_path " in
6781156283Srwatson	    *" $absdir "*) ;;
6782156283Srwatson	    *)
6783156283Srwatson	      case "$compile_rpath " in
6784156283Srwatson	      *" $absdir "*) ;;
6785244390Srwatson	      *) func_append compile_rpath " $absdir" ;;
6786156283Srwatson	      esac
6787156283Srwatson	      ;;
6788156283Srwatson	    esac
6789156283Srwatson	    case " $sys_lib_dlsearch_path " in
6790156283Srwatson	    *" $libdir "*) ;;
6791156283Srwatson	    *)
6792156283Srwatson	      case "$finalize_rpath " in
6793156283Srwatson	      *" $libdir "*) ;;
6794244390Srwatson	      *) func_append finalize_rpath " $libdir" ;;
6795156283Srwatson	      esac
6796156283Srwatson	      ;;
6797156283Srwatson	    esac
6798156283Srwatson	  fi
6799156283Srwatson
6800156283Srwatson	  if test -n "$old_archive_from_expsyms_cmds"; then
6801156283Srwatson	    # figure out the soname
6802156283Srwatson	    set dummy $library_names
6803244390Srwatson	    shift
6804244390Srwatson	    realname="$1"
6805244390Srwatson	    shift
6806244390Srwatson	    libname=`eval "\\$ECHO \"$libname_spec\""`
6807156283Srwatson	    # use dlname if we got it. it's perfectly good, no?
6808156283Srwatson	    if test -n "$dlname"; then
6809156283Srwatson	      soname="$dlname"
6810156283Srwatson	    elif test -n "$soname_spec"; then
6811156283Srwatson	      # bleh windows
6812156283Srwatson	      case $host in
6813244390Srwatson	      *cygwin* | mingw* | *cegcc*)
6814244390Srwatson	        func_arith $current - $age
6815244390Srwatson		major=$func_arith_result
6816156283Srwatson		versuffix="-$major"
6817156283Srwatson		;;
6818156283Srwatson	      esac
6819156283Srwatson	      eval soname=\"$soname_spec\"
6820156283Srwatson	    else
6821156283Srwatson	      soname="$realname"
6822156283Srwatson	    fi
6823156283Srwatson
6824156283Srwatson	    # Make a new name for the extract_expsyms_cmds to use
6825156283Srwatson	    soroot="$soname"
6826244390Srwatson	    func_basename "$soroot"
6827244390Srwatson	    soname="$func_basename_result"
6828244390Srwatson	    func_stripname 'lib' '.dll' "$soname"
6829244390Srwatson	    newlib=libimp-$func_stripname_result.a
6830156283Srwatson
6831156283Srwatson	    # If the library has no export list, then create one now
6832156283Srwatson	    if test -f "$output_objdir/$soname-def"; then :
6833156283Srwatson	    else
6834244390Srwatson	      func_verbose "extracting exported symbol list from \`$soname'"
6835244390Srwatson	      func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
6836156283Srwatson	    fi
6837156283Srwatson
6838156283Srwatson	    # Create $newlib
6839156283Srwatson	    if test -f "$output_objdir/$newlib"; then :; else
6840244390Srwatson	      func_verbose "generating import library for \`$soname'"
6841244390Srwatson	      func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
6842156283Srwatson	    fi
6843156283Srwatson	    # make sure the library variables are pointing to the new library
6844156283Srwatson	    dir=$output_objdir
6845156283Srwatson	    linklib=$newlib
6846156283Srwatson	  fi # test -n "$old_archive_from_expsyms_cmds"
6847156283Srwatson
6848244390Srwatson	  if test "$linkmode" = prog || test "$opt_mode" != relink; then
6849156283Srwatson	    add_shlibpath=
6850156283Srwatson	    add_dir=
6851156283Srwatson	    add=
6852156283Srwatson	    lib_linked=yes
6853156283Srwatson	    case $hardcode_action in
6854156283Srwatson	    immediate | unsupported)
6855156283Srwatson	      if test "$hardcode_direct" = no; then
6856156283Srwatson		add="$dir/$linklib"
6857156283Srwatson		case $host in
6858159985Srwatson		  *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
6859159985Srwatson		  *-*-sysv4*uw2*) add_dir="-L$dir" ;;
6860159985Srwatson		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
6861159985Srwatson		    *-*-unixware7*) add_dir="-L$dir" ;;
6862156283Srwatson		  *-*-darwin* )
6863244390Srwatson		    # if the lib is a (non-dlopened) module then we can not
6864244390Srwatson		    # link against it, someone is ignoring the earlier warnings
6865159985Srwatson		    if /usr/bin/file -L $add 2> /dev/null |
6866244390Srwatson			 $GREP ": [^:]* bundle" >/dev/null ; then
6867244390Srwatson		      if test "X$dlopenmodule" != "X$lib"; then
6868244390Srwatson			$ECHO "*** Warning: lib $linklib is a module, not a shared library"
6869244390Srwatson			if test -z "$old_library" ; then
6870244390Srwatson			  echo
6871244390Srwatson			  echo "*** And there doesn't seem to be a static archive available"
6872244390Srwatson			  echo "*** The link will probably fail, sorry"
6873244390Srwatson			else
6874244390Srwatson			  add="$dir/$old_library"
6875244390Srwatson			fi
6876244390Srwatson		      elif test -n "$old_library"; then
6877244390Srwatson			add="$dir/$old_library"
6878156283Srwatson		      fi
6879156283Srwatson		    fi
6880156283Srwatson		esac
6881156283Srwatson	      elif test "$hardcode_minus_L" = no; then
6882156283Srwatson		case $host in
6883156283Srwatson		*-*-sunos*) add_shlibpath="$dir" ;;
6884156283Srwatson		esac
6885156283Srwatson		add_dir="-L$dir"
6886156283Srwatson		add="-l$name"
6887156283Srwatson	      elif test "$hardcode_shlibpath_var" = no; then
6888156283Srwatson		add_shlibpath="$dir"
6889156283Srwatson		add="-l$name"
6890156283Srwatson	      else
6891156283Srwatson		lib_linked=no
6892156283Srwatson	      fi
6893156283Srwatson	      ;;
6894156283Srwatson	    relink)
6895244390Srwatson	      if test "$hardcode_direct" = yes &&
6896244390Srwatson	         test "$hardcode_direct_absolute" = no; then
6897156283Srwatson		add="$dir/$linklib"
6898156283Srwatson	      elif test "$hardcode_minus_L" = yes; then
6899244390Srwatson		add_dir="-L$absdir"
6900156283Srwatson		# Try looking first in the location we're being installed to.
6901156283Srwatson		if test -n "$inst_prefix_dir"; then
6902156283Srwatson		  case $libdir in
6903156283Srwatson		    [\\/]*)
6904244390Srwatson		      func_append add_dir " -L$inst_prefix_dir$libdir"
6905156283Srwatson		      ;;
6906156283Srwatson		  esac
6907156283Srwatson		fi
6908156283Srwatson		add="-l$name"
6909156283Srwatson	      elif test "$hardcode_shlibpath_var" = yes; then
6910156283Srwatson		add_shlibpath="$dir"
6911156283Srwatson		add="-l$name"
6912156283Srwatson	      else
6913156283Srwatson		lib_linked=no
6914156283Srwatson	      fi
6915156283Srwatson	      ;;
6916156283Srwatson	    *) lib_linked=no ;;
6917156283Srwatson	    esac
6918156283Srwatson
6919156283Srwatson	    if test "$lib_linked" != yes; then
6920244390Srwatson	      func_fatal_configuration "unsupported hardcode properties"
6921156283Srwatson	    fi
6922156283Srwatson
6923156283Srwatson	    if test -n "$add_shlibpath"; then
6924156283Srwatson	      case :$compile_shlibpath: in
6925156283Srwatson	      *":$add_shlibpath:"*) ;;
6926244390Srwatson	      *) func_append compile_shlibpath "$add_shlibpath:" ;;
6927156283Srwatson	      esac
6928156283Srwatson	    fi
6929156283Srwatson	    if test "$linkmode" = prog; then
6930156283Srwatson	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
6931156283Srwatson	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
6932156283Srwatson	    else
6933156283Srwatson	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
6934156283Srwatson	      test -n "$add" && deplibs="$add $deplibs"
6935244390Srwatson	      if test "$hardcode_direct" != yes &&
6936244390Srwatson		 test "$hardcode_minus_L" != yes &&
6937156283Srwatson		 test "$hardcode_shlibpath_var" = yes; then
6938156283Srwatson		case :$finalize_shlibpath: in
6939156283Srwatson		*":$libdir:"*) ;;
6940244390Srwatson		*) func_append finalize_shlibpath "$libdir:" ;;
6941156283Srwatson		esac
6942156283Srwatson	      fi
6943156283Srwatson	    fi
6944156283Srwatson	  fi
6945156283Srwatson
6946244390Srwatson	  if test "$linkmode" = prog || test "$opt_mode" = relink; then
6947156283Srwatson	    add_shlibpath=
6948156283Srwatson	    add_dir=
6949156283Srwatson	    add=
6950156283Srwatson	    # Finalize command for both is simple: just hardcode it.
6951244390Srwatson	    if test "$hardcode_direct" = yes &&
6952244390Srwatson	       test "$hardcode_direct_absolute" = no; then
6953156283Srwatson	      add="$libdir/$linklib"
6954156283Srwatson	    elif test "$hardcode_minus_L" = yes; then
6955156283Srwatson	      add_dir="-L$libdir"
6956156283Srwatson	      add="-l$name"
6957156283Srwatson	    elif test "$hardcode_shlibpath_var" = yes; then
6958156283Srwatson	      case :$finalize_shlibpath: in
6959156283Srwatson	      *":$libdir:"*) ;;
6960244390Srwatson	      *) func_append finalize_shlibpath "$libdir:" ;;
6961156283Srwatson	      esac
6962156283Srwatson	      add="-l$name"
6963156283Srwatson	    elif test "$hardcode_automatic" = yes; then
6964156283Srwatson	      if test -n "$inst_prefix_dir" &&
6965156283Srwatson		 test -f "$inst_prefix_dir$libdir/$linklib" ; then
6966244390Srwatson		add="$inst_prefix_dir$libdir/$linklib"
6967156283Srwatson	      else
6968244390Srwatson		add="$libdir/$linklib"
6969156283Srwatson	      fi
6970156283Srwatson	    else
6971156283Srwatson	      # We cannot seem to hardcode it, guess we'll fake it.
6972156283Srwatson	      add_dir="-L$libdir"
6973156283Srwatson	      # Try looking first in the location we're being installed to.
6974156283Srwatson	      if test -n "$inst_prefix_dir"; then
6975156283Srwatson		case $libdir in
6976156283Srwatson		  [\\/]*)
6977244390Srwatson		    func_append add_dir " -L$inst_prefix_dir$libdir"
6978156283Srwatson		    ;;
6979156283Srwatson		esac
6980156283Srwatson	      fi
6981156283Srwatson	      add="-l$name"
6982156283Srwatson	    fi
6983156283Srwatson
6984156283Srwatson	    if test "$linkmode" = prog; then
6985156283Srwatson	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
6986156283Srwatson	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
6987156283Srwatson	    else
6988156283Srwatson	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
6989156283Srwatson	      test -n "$add" && deplibs="$add $deplibs"
6990156283Srwatson	    fi
6991156283Srwatson	  fi
6992156283Srwatson	elif test "$linkmode" = prog; then
6993156283Srwatson	  # Here we assume that one of hardcode_direct or hardcode_minus_L
6994156283Srwatson	  # is not unsupported.  This is valid on all known static and
6995156283Srwatson	  # shared platforms.
6996156283Srwatson	  if test "$hardcode_direct" != unsupported; then
6997156283Srwatson	    test -n "$old_library" && linklib="$old_library"
6998156283Srwatson	    compile_deplibs="$dir/$linklib $compile_deplibs"
6999156283Srwatson	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
7000156283Srwatson	  else
7001156283Srwatson	    compile_deplibs="-l$name -L$dir $compile_deplibs"
7002156283Srwatson	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
7003156283Srwatson	  fi
7004156283Srwatson	elif test "$build_libtool_libs" = yes; then
7005156283Srwatson	  # Not a shared library
7006156283Srwatson	  if test "$deplibs_check_method" != pass_all; then
7007156283Srwatson	    # We're trying link a shared library against a static one
7008156283Srwatson	    # but the system doesn't support it.
7009156283Srwatson
7010156283Srwatson	    # Just print a warning and add the library to dependency_libs so
7011156283Srwatson	    # that the program can be linked against the static library.
7012244390Srwatson	    echo
7013244390Srwatson	    $ECHO "*** Warning: This system can not link to static lib archive $lib."
7014244390Srwatson	    echo "*** I have the capability to make that library automatically link in when"
7015244390Srwatson	    echo "*** you link to this library.  But I can only do this if you have a"
7016244390Srwatson	    echo "*** shared version of the library, which you do not appear to have."
7017156283Srwatson	    if test "$module" = yes; then
7018244390Srwatson	      echo "*** But as you try to build a module library, libtool will still create "
7019244390Srwatson	      echo "*** a static module, that should work as long as the dlopening application"
7020244390Srwatson	      echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
7021156283Srwatson	      if test -z "$global_symbol_pipe"; then
7022244390Srwatson		echo
7023244390Srwatson		echo "*** However, this would only work if libtool was able to extract symbol"
7024244390Srwatson		echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
7025244390Srwatson		echo "*** not find such a program.  So, this module is probably useless."
7026244390Srwatson		echo "*** \`nm' from GNU binutils and a full rebuild may help."
7027156283Srwatson	      fi
7028156283Srwatson	      if test "$build_old_libs" = no; then
7029156283Srwatson		build_libtool_libs=module
7030156283Srwatson		build_old_libs=yes
7031156283Srwatson	      else
7032156283Srwatson		build_libtool_libs=no
7033156283Srwatson	      fi
7034156283Srwatson	    fi
7035156283Srwatson	  else
7036156283Srwatson	    deplibs="$dir/$old_library $deplibs"
7037156283Srwatson	    link_static=yes
7038156283Srwatson	  fi
7039156283Srwatson	fi # link shared/static library?
7040156283Srwatson
7041156283Srwatson	if test "$linkmode" = lib; then
7042156283Srwatson	  if test -n "$dependency_libs" &&
7043156283Srwatson	     { test "$hardcode_into_libs" != yes ||
7044156283Srwatson	       test "$build_old_libs" = yes ||
7045156283Srwatson	       test "$link_static" = yes; }; then
7046156283Srwatson	    # Extract -R from dependency_libs
7047156283Srwatson	    temp_deplibs=
7048156283Srwatson	    for libdir in $dependency_libs; do
7049156283Srwatson	      case $libdir in
7050244390Srwatson	      -R*) func_stripname '-R' '' "$libdir"
7051244390Srwatson	           temp_xrpath=$func_stripname_result
7052156283Srwatson		   case " $xrpath " in
7053156283Srwatson		   *" $temp_xrpath "*) ;;
7054244390Srwatson		   *) func_append xrpath " $temp_xrpath";;
7055156283Srwatson		   esac;;
7056244390Srwatson	      *) func_append temp_deplibs " $libdir";;
7057156283Srwatson	      esac
7058156283Srwatson	    done
7059156283Srwatson	    dependency_libs="$temp_deplibs"
7060156283Srwatson	  fi
7061156283Srwatson
7062244390Srwatson	  func_append newlib_search_path " $absdir"
7063156283Srwatson	  # Link against this library
7064156283Srwatson	  test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
7065156283Srwatson	  # ... and its dependency_libs
7066156283Srwatson	  tmp_libs=
7067156283Srwatson	  for deplib in $dependency_libs; do
7068156283Srwatson	    newdependency_libs="$deplib $newdependency_libs"
7069244390Srwatson	    case $deplib in
7070244390Srwatson              -L*) func_stripname '-L' '' "$deplib"
7071244390Srwatson                   func_resolve_sysroot "$func_stripname_result";;
7072244390Srwatson              *) func_resolve_sysroot "$deplib" ;;
7073244390Srwatson            esac
7074244390Srwatson	    if $opt_preserve_dup_deps ; then
7075156283Srwatson	      case "$tmp_libs " in
7076244390Srwatson	      *" $func_resolve_sysroot_result "*)
7077244390Srwatson                func_append specialdeplibs " $func_resolve_sysroot_result" ;;
7078156283Srwatson	      esac
7079156283Srwatson	    fi
7080244390Srwatson	    func_append tmp_libs " $func_resolve_sysroot_result"
7081156283Srwatson	  done
7082156283Srwatson
7083156283Srwatson	  if test "$link_all_deplibs" != no; then
7084156283Srwatson	    # Add the search paths of all dependency libraries
7085156283Srwatson	    for deplib in $dependency_libs; do
7086244390Srwatson	      path=
7087156283Srwatson	      case $deplib in
7088156283Srwatson	      -L*) path="$deplib" ;;
7089156283Srwatson	      *.la)
7090244390Srwatson	        func_resolve_sysroot "$deplib"
7091244390Srwatson	        deplib=$func_resolve_sysroot_result
7092244390Srwatson	        func_dirname "$deplib" "" "."
7093244390Srwatson		dir=$func_dirname_result
7094156283Srwatson		# We need an absolute path.
7095156283Srwatson		case $dir in
7096156283Srwatson		[\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
7097156283Srwatson		*)
7098156283Srwatson		  absdir=`cd "$dir" && pwd`
7099156283Srwatson		  if test -z "$absdir"; then
7100244390Srwatson		    func_warning "cannot determine absolute directory name of \`$dir'"
7101156283Srwatson		    absdir="$dir"
7102156283Srwatson		  fi
7103156283Srwatson		  ;;
7104156283Srwatson		esac
7105244390Srwatson		if $GREP "^installed=no" $deplib > /dev/null; then
7106156283Srwatson		case $host in
7107156283Srwatson		*-*-darwin*)
7108244390Srwatson		  depdepl=
7109156283Srwatson		  eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
7110156283Srwatson		  if test -n "$deplibrary_names" ; then
7111156283Srwatson		    for tmp in $deplibrary_names ; do
7112156283Srwatson		      depdepl=$tmp
7113156283Srwatson		    done
7114244390Srwatson		    if test -f "$absdir/$objdir/$depdepl" ; then
7115244390Srwatson		      depdepl="$absdir/$objdir/$depdepl"
7116244390Srwatson		      darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
7117244390Srwatson                      if test -z "$darwin_install_name"; then
7118244390Srwatson                          darwin_install_name=`${OTOOL64} -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
7119244390Srwatson                      fi
7120244390Srwatson		      func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}"
7121244390Srwatson		      func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}"
7122244390Srwatson		      path=
7123156283Srwatson		    fi
7124156283Srwatson		  fi
7125156283Srwatson		  ;;
7126156283Srwatson		*)
7127244390Srwatson		  path="-L$absdir/$objdir"
7128156283Srwatson		  ;;
7129156283Srwatson		esac
7130244390Srwatson		else
7131244390Srwatson		  eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
7132244390Srwatson		  test -z "$libdir" && \
7133244390Srwatson		    func_fatal_error "\`$deplib' is not a valid libtool archive"
7134244390Srwatson		  test "$absdir" != "$libdir" && \
7135244390Srwatson		    func_warning "\`$deplib' seems to be moved"
7136244390Srwatson
7137244390Srwatson		  path="-L$absdir"
7138244390Srwatson		fi
7139156283Srwatson		;;
7140156283Srwatson	      esac
7141156283Srwatson	      case " $deplibs " in
7142156283Srwatson	      *" $path "*) ;;
7143156283Srwatson	      *) deplibs="$path $deplibs" ;;
7144156283Srwatson	      esac
7145156283Srwatson	    done
7146156283Srwatson	  fi # link_all_deplibs != no
7147156283Srwatson	fi # linkmode = lib
7148156283Srwatson      done # for deplib in $libs
7149244390Srwatson      if test "$pass" = link; then
7150244390Srwatson	if test "$linkmode" = "prog"; then
7151244390Srwatson	  compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
7152244390Srwatson	  finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
7153244390Srwatson	else
7154244390Srwatson	  compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
7155244390Srwatson	fi
7156244390Srwatson      fi
7157156283Srwatson      dependency_libs="$newdependency_libs"
7158156283Srwatson      if test "$pass" = dlpreopen; then
7159156283Srwatson	# Link the dlpreopened libraries before other libraries
7160156283Srwatson	for deplib in $save_deplibs; do
7161156283Srwatson	  deplibs="$deplib $deplibs"
7162156283Srwatson	done
7163156283Srwatson      fi
7164156283Srwatson      if test "$pass" != dlopen; then
7165156283Srwatson	if test "$pass" != conv; then
7166156283Srwatson	  # Make sure lib_search_path contains only unique directories.
7167156283Srwatson	  lib_search_path=
7168156283Srwatson	  for dir in $newlib_search_path; do
7169156283Srwatson	    case "$lib_search_path " in
7170156283Srwatson	    *" $dir "*) ;;
7171244390Srwatson	    *) func_append lib_search_path " $dir" ;;
7172156283Srwatson	    esac
7173156283Srwatson	  done
7174156283Srwatson	  newlib_search_path=
7175156283Srwatson	fi
7176156283Srwatson
7177156283Srwatson	if test "$linkmode,$pass" != "prog,link"; then
7178156283Srwatson	  vars="deplibs"
7179156283Srwatson	else
7180156283Srwatson	  vars="compile_deplibs finalize_deplibs"
7181156283Srwatson	fi
7182156283Srwatson	for var in $vars dependency_libs; do
7183156283Srwatson	  # Add libraries to $var in reverse order
7184156283Srwatson	  eval tmp_libs=\"\$$var\"
7185156283Srwatson	  new_libs=
7186156283Srwatson	  for deplib in $tmp_libs; do
7187156283Srwatson	    # FIXME: Pedantically, this is the right thing to do, so
7188156283Srwatson	    #        that some nasty dependency loop isn't accidentally
7189156283Srwatson	    #        broken:
7190156283Srwatson	    #new_libs="$deplib $new_libs"
7191156283Srwatson	    # Pragmatically, this seems to cause very few problems in
7192156283Srwatson	    # practice:
7193156283Srwatson	    case $deplib in
7194156283Srwatson	    -L*) new_libs="$deplib $new_libs" ;;
7195156283Srwatson	    -R*) ;;
7196156283Srwatson	    *)
7197156283Srwatson	      # And here is the reason: when a library appears more
7198156283Srwatson	      # than once as an explicit dependence of a library, or
7199156283Srwatson	      # is implicitly linked in more than once by the
7200156283Srwatson	      # compiler, it is considered special, and multiple
7201156283Srwatson	      # occurrences thereof are not removed.  Compare this
7202156283Srwatson	      # with having the same library being listed as a
7203156283Srwatson	      # dependency of multiple other libraries: in this case,
7204156283Srwatson	      # we know (pedantically, we assume) the library does not
7205156283Srwatson	      # need to be listed more than once, so we keep only the
7206156283Srwatson	      # last copy.  This is not always right, but it is rare
7207156283Srwatson	      # enough that we require users that really mean to play
7208156283Srwatson	      # such unportable linking tricks to link the library
7209156283Srwatson	      # using -Wl,-lname, so that libtool does not consider it
7210156283Srwatson	      # for duplicate removal.
7211156283Srwatson	      case " $specialdeplibs " in
7212156283Srwatson	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
7213156283Srwatson	      *)
7214156283Srwatson		case " $new_libs " in
7215156283Srwatson		*" $deplib "*) ;;
7216156283Srwatson		*) new_libs="$deplib $new_libs" ;;
7217156283Srwatson		esac
7218156283Srwatson		;;
7219156283Srwatson	      esac
7220156283Srwatson	      ;;
7221156283Srwatson	    esac
7222156283Srwatson	  done
7223156283Srwatson	  tmp_libs=
7224156283Srwatson	  for deplib in $new_libs; do
7225156283Srwatson	    case $deplib in
7226156283Srwatson	    -L*)
7227156283Srwatson	      case " $tmp_libs " in
7228156283Srwatson	      *" $deplib "*) ;;
7229244390Srwatson	      *) func_append tmp_libs " $deplib" ;;
7230156283Srwatson	      esac
7231156283Srwatson	      ;;
7232244390Srwatson	    *) func_append tmp_libs " $deplib" ;;
7233156283Srwatson	    esac
7234156283Srwatson	  done
7235156283Srwatson	  eval $var=\"$tmp_libs\"
7236156283Srwatson	done # for var
7237156283Srwatson      fi
7238156283Srwatson      # Last step: remove runtime libs from dependency_libs
7239156283Srwatson      # (they stay in deplibs)
7240156283Srwatson      tmp_libs=
7241156283Srwatson      for i in $dependency_libs ; do
7242156283Srwatson	case " $predeps $postdeps $compiler_lib_search_path " in
7243156283Srwatson	*" $i "*)
7244156283Srwatson	  i=""
7245156283Srwatson	  ;;
7246156283Srwatson	esac
7247156283Srwatson	if test -n "$i" ; then
7248244390Srwatson	  func_append tmp_libs " $i"
7249156283Srwatson	fi
7250156283Srwatson      done
7251156283Srwatson      dependency_libs=$tmp_libs
7252156283Srwatson    done # for pass
7253156283Srwatson    if test "$linkmode" = prog; then
7254156283Srwatson      dlfiles="$newdlfiles"
7255244390Srwatson    fi
7256244390Srwatson    if test "$linkmode" = prog || test "$linkmode" = lib; then
7257156283Srwatson      dlprefiles="$newdlprefiles"
7258156283Srwatson    fi
7259156283Srwatson
7260156283Srwatson    case $linkmode in
7261156283Srwatson    oldlib)
7262244390Srwatson      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
7263244390Srwatson	func_warning "\`-dlopen' is ignored for archives"
7264244390Srwatson      fi
7265244390Srwatson
7266191273Srwatson      case " $deplibs" in
7267191273Srwatson      *\ -l* | *\ -L*)
7268244390Srwatson	func_warning "\`-l' and \`-L' are ignored for archives" ;;
7269191273Srwatson      esac
7270156283Srwatson
7271244390Srwatson      test -n "$rpath" && \
7272244390Srwatson	func_warning "\`-rpath' is ignored for archives"
7273156283Srwatson
7274244390Srwatson      test -n "$xrpath" && \
7275244390Srwatson	func_warning "\`-R' is ignored for archives"
7276156283Srwatson
7277244390Srwatson      test -n "$vinfo" && \
7278244390Srwatson	func_warning "\`-version-info/-version-number' is ignored for archives"
7279156283Srwatson
7280244390Srwatson      test -n "$release" && \
7281244390Srwatson	func_warning "\`-release' is ignored for archives"
7282156283Srwatson
7283244390Srwatson      test -n "$export_symbols$export_symbols_regex" && \
7284244390Srwatson	func_warning "\`-export-symbols' is ignored for archives"
7285156283Srwatson
7286156283Srwatson      # Now set the variables for building old libraries.
7287156283Srwatson      build_libtool_libs=no
7288156283Srwatson      oldlibs="$output"
7289244390Srwatson      func_append objs "$old_deplibs"
7290156283Srwatson      ;;
7291156283Srwatson
7292156283Srwatson    lib)
7293156283Srwatson      # Make sure we only generate libraries of the form `libNAME.la'.
7294156283Srwatson      case $outputname in
7295156283Srwatson      lib*)
7296244390Srwatson	func_stripname 'lib' '.la' "$outputname"
7297244390Srwatson	name=$func_stripname_result
7298156283Srwatson	eval shared_ext=\"$shrext_cmds\"
7299156283Srwatson	eval libname=\"$libname_spec\"
7300156283Srwatson	;;
7301156283Srwatson      *)
7302244390Srwatson	test "$module" = no && \
7303244390Srwatson	  func_fatal_help "libtool library \`$output' must begin with \`lib'"
7304244390Srwatson
7305156283Srwatson	if test "$need_lib_prefix" != no; then
7306156283Srwatson	  # Add the "lib" prefix for modules if required
7307244390Srwatson	  func_stripname '' '.la' "$outputname"
7308244390Srwatson	  name=$func_stripname_result
7309156283Srwatson	  eval shared_ext=\"$shrext_cmds\"
7310156283Srwatson	  eval libname=\"$libname_spec\"
7311156283Srwatson	else
7312244390Srwatson	  func_stripname '' '.la' "$outputname"
7313244390Srwatson	  libname=$func_stripname_result
7314156283Srwatson	fi
7315156283Srwatson	;;
7316156283Srwatson      esac
7317156283Srwatson
7318156283Srwatson      if test -n "$objs"; then
7319156283Srwatson	if test "$deplibs_check_method" != pass_all; then
7320244390Srwatson	  func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs"
7321156283Srwatson	else
7322244390Srwatson	  echo
7323244390Srwatson	  $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
7324244390Srwatson	  $ECHO "*** objects $objs is not portable!"
7325244390Srwatson	  func_append libobjs " $objs"
7326156283Srwatson	fi
7327156283Srwatson      fi
7328156283Srwatson
7329244390Srwatson      test "$dlself" != no && \
7330244390Srwatson	func_warning "\`-dlopen self' is ignored for libtool libraries"
7331156283Srwatson
7332156283Srwatson      set dummy $rpath
7333244390Srwatson      shift
7334244390Srwatson      test "$#" -gt 1 && \
7335244390Srwatson	func_warning "ignoring multiple \`-rpath's for a libtool library"
7336156283Srwatson
7337244390Srwatson      install_libdir="$1"
7338244390Srwatson
7339156283Srwatson      oldlibs=
7340156283Srwatson      if test -z "$rpath"; then
7341156283Srwatson	if test "$build_libtool_libs" = yes; then
7342156283Srwatson	  # Building a libtool convenience library.
7343156283Srwatson	  # Some compilers have problems with a `.al' extension so
7344156283Srwatson	  # convenience libraries should have the same extension an
7345156283Srwatson	  # archive normally would.
7346156283Srwatson	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
7347156283Srwatson	  build_libtool_libs=convenience
7348156283Srwatson	  build_old_libs=yes
7349156283Srwatson	fi
7350156283Srwatson
7351244390Srwatson	test -n "$vinfo" && \
7352244390Srwatson	  func_warning "\`-version-info/-version-number' is ignored for convenience libraries"
7353156283Srwatson
7354244390Srwatson	test -n "$release" && \
7355244390Srwatson	  func_warning "\`-release' is ignored for convenience libraries"
7356156283Srwatson      else
7357156283Srwatson
7358156283Srwatson	# Parse the version information argument.
7359156283Srwatson	save_ifs="$IFS"; IFS=':'
7360156283Srwatson	set dummy $vinfo 0 0 0
7361244390Srwatson	shift
7362156283Srwatson	IFS="$save_ifs"
7363156283Srwatson
7364244390Srwatson	test -n "$7" && \
7365244390Srwatson	  func_fatal_help "too many parameters to \`-version-info'"
7366156283Srwatson
7367156283Srwatson	# convert absolute version numbers to libtool ages
7368156283Srwatson	# this retains compatibility with .la files and attempts
7369156283Srwatson	# to make the code below a bit more comprehensible
7370156283Srwatson
7371156283Srwatson	case $vinfo_number in
7372156283Srwatson	yes)
7373244390Srwatson	  number_major="$1"
7374244390Srwatson	  number_minor="$2"
7375244390Srwatson	  number_revision="$3"
7376156283Srwatson	  #
7377156283Srwatson	  # There are really only two kinds -- those that
7378156283Srwatson	  # use the current revision as the major version
7379156283Srwatson	  # and those that subtract age and use age as
7380156283Srwatson	  # a minor version.  But, then there is irix
7381156283Srwatson	  # which has an extra 1 added just for fun
7382156283Srwatson	  #
7383156283Srwatson	  case $version_type in
7384244390Srwatson	  # correct linux to gnu/linux during the next big refactor
7385173143Srwatson	  darwin|linux|osf|windows|none)
7386244390Srwatson	    func_arith $number_major + $number_minor
7387244390Srwatson	    current=$func_arith_result
7388156283Srwatson	    age="$number_minor"
7389156283Srwatson	    revision="$number_revision"
7390156283Srwatson	    ;;
7391244390Srwatson	  freebsd-aout|freebsd-elf|qnx|sunos)
7392156283Srwatson	    current="$number_major"
7393156283Srwatson	    revision="$number_minor"
7394156283Srwatson	    age="0"
7395156283Srwatson	    ;;
7396156283Srwatson	  irix|nonstopux)
7397244390Srwatson	    func_arith $number_major + $number_minor
7398244390Srwatson	    current=$func_arith_result
7399156283Srwatson	    age="$number_minor"
7400156283Srwatson	    revision="$number_minor"
7401173143Srwatson	    lt_irix_increment=no
7402156283Srwatson	    ;;
7403156283Srwatson	  esac
7404156283Srwatson	  ;;
7405156283Srwatson	no)
7406244390Srwatson	  current="$1"
7407244390Srwatson	  revision="$2"
7408244390Srwatson	  age="$3"
7409156283Srwatson	  ;;
7410156283Srwatson	esac
7411156283Srwatson
7412156283Srwatson	# Check that each of the things are valid numbers.
7413156283Srwatson	case $current in
7414156283Srwatson	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]) ;;
7415156283Srwatson	*)
7416244390Srwatson	  func_error "CURRENT \`$current' must be a nonnegative integer"
7417244390Srwatson	  func_fatal_error "\`$vinfo' is not valid version information"
7418156283Srwatson	  ;;
7419156283Srwatson	esac
7420156283Srwatson
7421156283Srwatson	case $revision in
7422156283Srwatson	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]) ;;
7423156283Srwatson	*)
7424244390Srwatson	  func_error "REVISION \`$revision' must be a nonnegative integer"
7425244390Srwatson	  func_fatal_error "\`$vinfo' is not valid version information"
7426156283Srwatson	  ;;
7427156283Srwatson	esac
7428156283Srwatson
7429156283Srwatson	case $age in
7430156283Srwatson	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]) ;;
7431156283Srwatson	*)
7432244390Srwatson	  func_error "AGE \`$age' must be a nonnegative integer"
7433244390Srwatson	  func_fatal_error "\`$vinfo' is not valid version information"
7434156283Srwatson	  ;;
7435156283Srwatson	esac
7436156283Srwatson
7437156283Srwatson	if test "$age" -gt "$current"; then
7438244390Srwatson	  func_error "AGE \`$age' is greater than the current interface number \`$current'"
7439244390Srwatson	  func_fatal_error "\`$vinfo' is not valid version information"
7440156283Srwatson	fi
7441156283Srwatson
7442156283Srwatson	# Calculate the version variables.
7443156283Srwatson	major=
7444156283Srwatson	versuffix=
7445156283Srwatson	verstring=
7446156283Srwatson	case $version_type in
7447156283Srwatson	none) ;;
7448156283Srwatson
7449156283Srwatson	darwin)
7450156283Srwatson	  # Like Linux, but with the current version available in
7451156283Srwatson	  # verstring for coding it into the library header
7452244390Srwatson	  func_arith $current - $age
7453244390Srwatson	  major=.$func_arith_result
7454156283Srwatson	  versuffix="$major.$age.$revision"
7455156283Srwatson	  # Darwin ld doesn't like 0 for these options...
7456244390Srwatson	  func_arith $current + 1
7457244390Srwatson	  minor_current=$func_arith_result
7458173143Srwatson	  xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
7459173143Srwatson	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
7460156283Srwatson	  ;;
7461156283Srwatson
7462156283Srwatson	freebsd-aout)
7463156283Srwatson	  major=".$current"
7464156283Srwatson	  versuffix=".$current.$revision";
7465156283Srwatson	  ;;
7466156283Srwatson
7467156283Srwatson	freebsd-elf)
7468156283Srwatson	  major=".$current"
7469244390Srwatson	  versuffix=".$current"
7470156283Srwatson	  ;;
7471156283Srwatson
7472156283Srwatson	irix | nonstopux)
7473173143Srwatson	  if test "X$lt_irix_increment" = "Xno"; then
7474244390Srwatson	    func_arith $current - $age
7475173143Srwatson	  else
7476244390Srwatson	    func_arith $current - $age + 1
7477173143Srwatson	  fi
7478244390Srwatson	  major=$func_arith_result
7479244390Srwatson
7480156283Srwatson	  case $version_type in
7481156283Srwatson	    nonstopux) verstring_prefix=nonstopux ;;
7482156283Srwatson	    *)         verstring_prefix=sgi ;;
7483156283Srwatson	  esac
7484156283Srwatson	  verstring="$verstring_prefix$major.$revision"
7485156283Srwatson
7486156283Srwatson	  # Add in all the interfaces that we are compatible with.
7487156283Srwatson	  loop=$revision
7488156283Srwatson	  while test "$loop" -ne 0; do
7489244390Srwatson	    func_arith $revision - $loop
7490244390Srwatson	    iface=$func_arith_result
7491244390Srwatson	    func_arith $loop - 1
7492244390Srwatson	    loop=$func_arith_result
7493156283Srwatson	    verstring="$verstring_prefix$major.$iface:$verstring"
7494156283Srwatson	  done
7495156283Srwatson
7496156283Srwatson	  # Before this point, $major must not contain `.'.
7497156283Srwatson	  major=.$major
7498156283Srwatson	  versuffix="$major.$revision"
7499156283Srwatson	  ;;
7500156283Srwatson
7501244390Srwatson	linux) # correct to gnu/linux during the next big refactor
7502244390Srwatson	  func_arith $current - $age
7503244390Srwatson	  major=.$func_arith_result
7504156283Srwatson	  versuffix="$major.$age.$revision"
7505156283Srwatson	  ;;
7506156283Srwatson
7507156283Srwatson	osf)
7508244390Srwatson	  func_arith $current - $age
7509244390Srwatson	  major=.$func_arith_result
7510156283Srwatson	  versuffix=".$current.$age.$revision"
7511156283Srwatson	  verstring="$current.$age.$revision"
7512156283Srwatson
7513156283Srwatson	  # Add in all the interfaces that we are compatible with.
7514156283Srwatson	  loop=$age
7515156283Srwatson	  while test "$loop" -ne 0; do
7516244390Srwatson	    func_arith $current - $loop
7517244390Srwatson	    iface=$func_arith_result
7518244390Srwatson	    func_arith $loop - 1
7519244390Srwatson	    loop=$func_arith_result
7520156283Srwatson	    verstring="$verstring:${iface}.0"
7521156283Srwatson	  done
7522156283Srwatson
7523156283Srwatson	  # Make executables depend on our current version.
7524244390Srwatson	  func_append verstring ":${current}.0"
7525156283Srwatson	  ;;
7526156283Srwatson
7527244390Srwatson	qnx)
7528244390Srwatson	  major=".$current"
7529244390Srwatson	  versuffix=".$current"
7530244390Srwatson	  ;;
7531244390Srwatson
7532156283Srwatson	sunos)
7533156283Srwatson	  major=".$current"
7534156283Srwatson	  versuffix=".$current.$revision"
7535156283Srwatson	  ;;
7536156283Srwatson
7537156283Srwatson	windows)
7538156283Srwatson	  # Use '-' rather than '.', since we only want one
7539156283Srwatson	  # extension on DOS 8.3 filesystems.
7540244390Srwatson	  func_arith $current - $age
7541244390Srwatson	  major=$func_arith_result
7542156283Srwatson	  versuffix="-$major"
7543156283Srwatson	  ;;
7544156283Srwatson
7545156283Srwatson	*)
7546244390Srwatson	  func_fatal_configuration "unknown library version type \`$version_type'"
7547156283Srwatson	  ;;
7548156283Srwatson	esac
7549156283Srwatson
7550156283Srwatson	# Clear the version info if we defaulted, and they specified a release.
7551156283Srwatson	if test -z "$vinfo" && test -n "$release"; then
7552156283Srwatson	  major=
7553156283Srwatson	  case $version_type in
7554156283Srwatson	  darwin)
7555156283Srwatson	    # we can't check for "0.0" in archive_cmds due to quoting
7556156283Srwatson	    # problems, so we reset it completely
7557156283Srwatson	    verstring=
7558156283Srwatson	    ;;
7559156283Srwatson	  *)
7560156283Srwatson	    verstring="0.0"
7561156283Srwatson	    ;;
7562156283Srwatson	  esac
7563156283Srwatson	  if test "$need_version" = no; then
7564156283Srwatson	    versuffix=
7565156283Srwatson	  else
7566156283Srwatson	    versuffix=".0.0"
7567156283Srwatson	  fi
7568156283Srwatson	fi
7569156283Srwatson
7570156283Srwatson	# Remove version info from name if versioning should be avoided
7571156283Srwatson	if test "$avoid_version" = yes && test "$need_version" = no; then
7572156283Srwatson	  major=
7573156283Srwatson	  versuffix=
7574156283Srwatson	  verstring=""
7575156283Srwatson	fi
7576156283Srwatson
7577156283Srwatson	# Check to see if the archive will have undefined symbols.
7578156283Srwatson	if test "$allow_undefined" = yes; then
7579156283Srwatson	  if test "$allow_undefined_flag" = unsupported; then
7580244390Srwatson	    func_warning "undefined symbols not allowed in $host shared libraries"
7581156283Srwatson	    build_libtool_libs=no
7582156283Srwatson	    build_old_libs=yes
7583156283Srwatson	  fi
7584156283Srwatson	else
7585156283Srwatson	  # Don't allow undefined symbols.
7586156283Srwatson	  allow_undefined_flag="$no_undefined_flag"
7587156283Srwatson	fi
7588244390Srwatson
7589156283Srwatson      fi
7590156283Srwatson
7591244390Srwatson      func_generate_dlsyms "$libname" "$libname" "yes"
7592244390Srwatson      func_append libobjs " $symfileobj"
7593244390Srwatson      test "X$libobjs" = "X " && libobjs=
7594244390Srwatson
7595244390Srwatson      if test "$opt_mode" != relink; then
7596156283Srwatson	# Remove our outputs, but don't remove object files since they
7597156283Srwatson	# may have been created when compiling PIC objects.
7598156283Srwatson	removelist=
7599244390Srwatson	tempremovelist=`$ECHO "$output_objdir/*"`
7600156283Srwatson	for p in $tempremovelist; do
7601156283Srwatson	  case $p in
7602244390Srwatson	    *.$objext | *.gcno)
7603156283Srwatson	       ;;
7604156283Srwatson	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
7605156283Srwatson	       if test "X$precious_files_regex" != "X"; then
7606244390Srwatson		 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
7607244390Srwatson		 then
7608156283Srwatson		   continue
7609156283Srwatson		 fi
7610156283Srwatson	       fi
7611244390Srwatson	       func_append removelist " $p"
7612156283Srwatson	       ;;
7613156283Srwatson	    *) ;;
7614156283Srwatson	  esac
7615156283Srwatson	done
7616244390Srwatson	test -n "$removelist" && \
7617244390Srwatson	  func_show_eval "${RM}r \$removelist"
7618156283Srwatson      fi
7619156283Srwatson
7620156283Srwatson      # Now set the variables for building old libraries.
7621156283Srwatson      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
7622244390Srwatson	func_append oldlibs " $output_objdir/$libname.$libext"
7623156283Srwatson
7624156283Srwatson	# Transform .lo files to .o files.
7625244390Srwatson	oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP`
7626156283Srwatson      fi
7627156283Srwatson
7628156283Srwatson      # Eliminate all temporary directories.
7629173143Srwatson      #for path in $notinst_path; do
7630244390Srwatson      #	lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
7631244390Srwatson      #	deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
7632244390Srwatson      #	dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
7633173143Srwatson      #done
7634156283Srwatson
7635156283Srwatson      if test -n "$xrpath"; then
7636156283Srwatson	# If the user specified any rpath flags, then add them.
7637156283Srwatson	temp_xrpath=
7638156283Srwatson	for libdir in $xrpath; do
7639244390Srwatson	  func_replace_sysroot "$libdir"
7640244390Srwatson	  func_append temp_xrpath " -R$func_replace_sysroot_result"
7641156283Srwatson	  case "$finalize_rpath " in
7642156283Srwatson	  *" $libdir "*) ;;
7643244390Srwatson	  *) func_append finalize_rpath " $libdir" ;;
7644156283Srwatson	  esac
7645156283Srwatson	done
7646156283Srwatson	if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
7647156283Srwatson	  dependency_libs="$temp_xrpath $dependency_libs"
7648156283Srwatson	fi
7649156283Srwatson      fi
7650156283Srwatson
7651156283Srwatson      # Make sure dlfiles contains only unique files that won't be dlpreopened
7652156283Srwatson      old_dlfiles="$dlfiles"
7653156283Srwatson      dlfiles=
7654156283Srwatson      for lib in $old_dlfiles; do
7655156283Srwatson	case " $dlprefiles $dlfiles " in
7656156283Srwatson	*" $lib "*) ;;
7657244390Srwatson	*) func_append dlfiles " $lib" ;;
7658156283Srwatson	esac
7659156283Srwatson      done
7660156283Srwatson
7661156283Srwatson      # Make sure dlprefiles contains only unique files
7662156283Srwatson      old_dlprefiles="$dlprefiles"
7663156283Srwatson      dlprefiles=
7664156283Srwatson      for lib in $old_dlprefiles; do
7665156283Srwatson	case "$dlprefiles " in
7666156283Srwatson	*" $lib "*) ;;
7667244390Srwatson	*) func_append dlprefiles " $lib" ;;
7668156283Srwatson	esac
7669156283Srwatson      done
7670156283Srwatson
7671156283Srwatson      if test "$build_libtool_libs" = yes; then
7672156283Srwatson	if test -n "$rpath"; then
7673156283Srwatson	  case $host in
7674244390Srwatson	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
7675156283Srwatson	    # these systems don't actually have a c library (as such)!
7676156283Srwatson	    ;;
7677156283Srwatson	  *-*-rhapsody* | *-*-darwin1.[012])
7678156283Srwatson	    # Rhapsody C library is in the System framework
7679244390Srwatson	    func_append deplibs " System.ltframework"
7680156283Srwatson	    ;;
7681156283Srwatson	  *-*-netbsd*)
7682156283Srwatson	    # Don't link with libc until the a.out ld.so is fixed.
7683156283Srwatson	    ;;
7684156283Srwatson	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
7685156283Srwatson	    # Do not include libc due to us having libc/libc_r.
7686156283Srwatson	    ;;
7687159985Srwatson	  *-*-sco3.2v5* | *-*-sco5v6*)
7688159985Srwatson	    # Causes problems with __ctype
7689159985Srwatson	    ;;
7690159985Srwatson	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
7691159985Srwatson	    # Compiler inserts libc in the correct place for threads to work
7692159985Srwatson	    ;;
7693244390Srwatson	  *)
7694156283Srwatson	    # Add libc to deplibs on all other systems if necessary.
7695156283Srwatson	    if test "$build_libtool_need_lc" = "yes"; then
7696244390Srwatson	      func_append deplibs " -lc"
7697156283Srwatson	    fi
7698156283Srwatson	    ;;
7699156283Srwatson	  esac
7700156283Srwatson	fi
7701156283Srwatson
7702156283Srwatson	# Transform deplibs into only deplibs that can be linked in shared.
7703156283Srwatson	name_save=$name
7704156283Srwatson	libname_save=$libname
7705156283Srwatson	release_save=$release
7706156283Srwatson	versuffix_save=$versuffix
7707156283Srwatson	major_save=$major
7708156283Srwatson	# I'm not sure if I'm treating the release correctly.  I think
7709156283Srwatson	# release should show up in the -l (ie -lgmp5) so we don't want to
7710156283Srwatson	# add it in twice.  Is that correct?
7711156283Srwatson	release=""
7712156283Srwatson	versuffix=""
7713156283Srwatson	major=""
7714156283Srwatson	newdeplibs=
7715156283Srwatson	droppeddeps=no
7716156283Srwatson	case $deplibs_check_method in
7717156283Srwatson	pass_all)
7718156283Srwatson	  # Don't check for shared/static.  Everything works.
7719156283Srwatson	  # This might be a little naive.  We might want to check
7720156283Srwatson	  # whether the library exists or not.  But this is on
7721156283Srwatson	  # osf3 & osf4 and I'm not really sure... Just
7722156283Srwatson	  # implementing what was already the behavior.
7723156283Srwatson	  newdeplibs=$deplibs
7724156283Srwatson	  ;;
7725156283Srwatson	test_compile)
7726156283Srwatson	  # This code stresses the "libraries are programs" paradigm to its
7727156283Srwatson	  # limits. Maybe even breaks it.  We compile a program, linking it
7728156283Srwatson	  # against the deplibs as a proxy for the library.  Then we can check
7729156283Srwatson	  # whether they linked in statically or dynamically with ldd.
7730244390Srwatson	  $opt_dry_run || $RM conftest.c
7731156283Srwatson	  cat > conftest.c <<EOF
7732156283Srwatson	  int main() { return 0; }
7733156283SrwatsonEOF
7734244390Srwatson	  $opt_dry_run || $RM conftest
7735173143Srwatson	  if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
7736156283Srwatson	    ldd_output=`ldd conftest`
7737156283Srwatson	    for i in $deplibs; do
7738244390Srwatson	      case $i in
7739244390Srwatson	      -l*)
7740244390Srwatson		func_stripname -l '' "$i"
7741244390Srwatson		name=$func_stripname_result
7742156283Srwatson		if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7743156283Srwatson		  case " $predeps $postdeps " in
7744156283Srwatson		  *" $i "*)
7745244390Srwatson		    func_append newdeplibs " $i"
7746156283Srwatson		    i=""
7747156283Srwatson		    ;;
7748156283Srwatson		  esac
7749244390Srwatson		fi
7750156283Srwatson		if test -n "$i" ; then
7751244390Srwatson		  libname=`eval "\\$ECHO \"$libname_spec\""`
7752244390Srwatson		  deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
7753244390Srwatson		  set dummy $deplib_matches; shift
7754244390Srwatson		  deplib_match=$1
7755156283Srwatson		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
7756244390Srwatson		    func_append newdeplibs " $i"
7757156283Srwatson		  else
7758156283Srwatson		    droppeddeps=yes
7759244390Srwatson		    echo
7760244390Srwatson		    $ECHO "*** Warning: dynamic linker does not accept needed library $i."
7761244390Srwatson		    echo "*** I have the capability to make that library automatically link in when"
7762244390Srwatson		    echo "*** you link to this library.  But I can only do this if you have a"
7763244390Srwatson		    echo "*** shared version of the library, which I believe you do not have"
7764244390Srwatson		    echo "*** because a test_compile did reveal that the linker did not use it for"
7765244390Srwatson		    echo "*** its dynamic dependency list that programs get resolved with at runtime."
7766156283Srwatson		  fi
7767156283Srwatson		fi
7768244390Srwatson		;;
7769244390Srwatson	      *)
7770244390Srwatson		func_append newdeplibs " $i"
7771244390Srwatson		;;
7772244390Srwatson	      esac
7773156283Srwatson	    done
7774156283Srwatson	  else
7775156283Srwatson	    # Error occurred in the first compile.  Let's try to salvage
7776156283Srwatson	    # the situation: Compile a separate program for each library.
7777156283Srwatson	    for i in $deplibs; do
7778244390Srwatson	      case $i in
7779244390Srwatson	      -l*)
7780244390Srwatson		func_stripname -l '' "$i"
7781244390Srwatson		name=$func_stripname_result
7782244390Srwatson		$opt_dry_run || $RM conftest
7783173143Srwatson		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
7784156283Srwatson		  ldd_output=`ldd conftest`
7785156283Srwatson		  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7786156283Srwatson		    case " $predeps $postdeps " in
7787156283Srwatson		    *" $i "*)
7788244390Srwatson		      func_append newdeplibs " $i"
7789156283Srwatson		      i=""
7790156283Srwatson		      ;;
7791156283Srwatson		    esac
7792156283Srwatson		  fi
7793156283Srwatson		  if test -n "$i" ; then
7794244390Srwatson		    libname=`eval "\\$ECHO \"$libname_spec\""`
7795244390Srwatson		    deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
7796244390Srwatson		    set dummy $deplib_matches; shift
7797244390Srwatson		    deplib_match=$1
7798156283Srwatson		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
7799244390Srwatson		      func_append newdeplibs " $i"
7800156283Srwatson		    else
7801156283Srwatson		      droppeddeps=yes
7802244390Srwatson		      echo
7803244390Srwatson		      $ECHO "*** Warning: dynamic linker does not accept needed library $i."
7804244390Srwatson		      echo "*** I have the capability to make that library automatically link in when"
7805244390Srwatson		      echo "*** you link to this library.  But I can only do this if you have a"
7806244390Srwatson		      echo "*** shared version of the library, which you do not appear to have"
7807244390Srwatson		      echo "*** because a test_compile did reveal that the linker did not use this one"
7808244390Srwatson		      echo "*** as a dynamic dependency that programs can get resolved with at runtime."
7809156283Srwatson		    fi
7810156283Srwatson		  fi
7811156283Srwatson		else
7812156283Srwatson		  droppeddeps=yes
7813244390Srwatson		  echo
7814244390Srwatson		  $ECHO "*** Warning!  Library $i is needed by this library but I was not able to"
7815244390Srwatson		  echo "*** make it link in!  You will probably need to install it or some"
7816244390Srwatson		  echo "*** library that it depends on before this library will be fully"
7817244390Srwatson		  echo "*** functional.  Installing it before continuing would be even better."
7818156283Srwatson		fi
7819244390Srwatson		;;
7820244390Srwatson	      *)
7821244390Srwatson		func_append newdeplibs " $i"
7822244390Srwatson		;;
7823244390Srwatson	      esac
7824156283Srwatson	    done
7825156283Srwatson	  fi
7826156283Srwatson	  ;;
7827156283Srwatson	file_magic*)
7828244390Srwatson	  set dummy $deplibs_check_method; shift
7829244390Srwatson	  file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
7830156283Srwatson	  for a_deplib in $deplibs; do
7831244390Srwatson	    case $a_deplib in
7832244390Srwatson	    -l*)
7833244390Srwatson	      func_stripname -l '' "$a_deplib"
7834244390Srwatson	      name=$func_stripname_result
7835156283Srwatson	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7836156283Srwatson		case " $predeps $postdeps " in
7837156283Srwatson		*" $a_deplib "*)
7838244390Srwatson		  func_append newdeplibs " $a_deplib"
7839156283Srwatson		  a_deplib=""
7840156283Srwatson		  ;;
7841156283Srwatson		esac
7842156283Srwatson	      fi
7843156283Srwatson	      if test -n "$a_deplib" ; then
7844244390Srwatson		libname=`eval "\\$ECHO \"$libname_spec\""`
7845244390Srwatson		if test -n "$file_magic_glob"; then
7846244390Srwatson		  libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob`
7847244390Srwatson		else
7848244390Srwatson		  libnameglob=$libname
7849244390Srwatson		fi
7850244390Srwatson		test "$want_nocaseglob" = yes && nocaseglob=`shopt -p nocaseglob`
7851156283Srwatson		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
7852244390Srwatson		  if test "$want_nocaseglob" = yes; then
7853244390Srwatson		    shopt -s nocaseglob
7854244390Srwatson		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
7855244390Srwatson		    $nocaseglob
7856244390Srwatson		  else
7857244390Srwatson		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
7858244390Srwatson		  fi
7859156283Srwatson		  for potent_lib in $potential_libs; do
7860156283Srwatson		      # Follow soft links.
7861244390Srwatson		      if ls -lLd "$potent_lib" 2>/dev/null |
7862244390Srwatson			 $GREP " -> " >/dev/null; then
7863156283Srwatson			continue
7864156283Srwatson		      fi
7865156283Srwatson		      # The statement above tries to avoid entering an
7866156283Srwatson		      # endless loop below, in case of cyclic links.
7867156283Srwatson		      # We might still enter an endless loop, since a link
7868156283Srwatson		      # loop can be closed while we follow links,
7869156283Srwatson		      # but so what?
7870156283Srwatson		      potlib="$potent_lib"
7871156283Srwatson		      while test -h "$potlib" 2>/dev/null; do
7872156283Srwatson			potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
7873156283Srwatson			case $potliblink in
7874156283Srwatson			[\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
7875244390Srwatson			*) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";;
7876156283Srwatson			esac
7877156283Srwatson		      done
7878244390Srwatson		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
7879244390Srwatson			 $SED -e 10q |
7880244390Srwatson			 $EGREP "$file_magic_regex" > /dev/null; then
7881244390Srwatson			func_append newdeplibs " $a_deplib"
7882156283Srwatson			a_deplib=""
7883156283Srwatson			break 2
7884156283Srwatson		      fi
7885156283Srwatson		  done
7886156283Srwatson		done
7887156283Srwatson	      fi
7888156283Srwatson	      if test -n "$a_deplib" ; then
7889156283Srwatson		droppeddeps=yes
7890244390Srwatson		echo
7891244390Srwatson		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
7892244390Srwatson		echo "*** I have the capability to make that library automatically link in when"
7893244390Srwatson		echo "*** you link to this library.  But I can only do this if you have a"
7894244390Srwatson		echo "*** shared version of the library, which you do not appear to have"
7895244390Srwatson		echo "*** because I did check the linker path looking for a file starting"
7896156283Srwatson		if test -z "$potlib" ; then
7897244390Srwatson		  $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
7898156283Srwatson		else
7899244390Srwatson		  $ECHO "*** with $libname and none of the candidates passed a file format test"
7900244390Srwatson		  $ECHO "*** using a file magic. Last file checked: $potlib"
7901156283Srwatson		fi
7902156283Srwatson	      fi
7903244390Srwatson	      ;;
7904244390Srwatson	    *)
7905156283Srwatson	      # Add a -L argument.
7906244390Srwatson	      func_append newdeplibs " $a_deplib"
7907244390Srwatson	      ;;
7908244390Srwatson	    esac
7909156283Srwatson	  done # Gone through all deplibs.
7910156283Srwatson	  ;;
7911156283Srwatson	match_pattern*)
7912244390Srwatson	  set dummy $deplibs_check_method; shift
7913244390Srwatson	  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
7914156283Srwatson	  for a_deplib in $deplibs; do
7915244390Srwatson	    case $a_deplib in
7916244390Srwatson	    -l*)
7917244390Srwatson	      func_stripname -l '' "$a_deplib"
7918244390Srwatson	      name=$func_stripname_result
7919156283Srwatson	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7920156283Srwatson		case " $predeps $postdeps " in
7921156283Srwatson		*" $a_deplib "*)
7922244390Srwatson		  func_append newdeplibs " $a_deplib"
7923156283Srwatson		  a_deplib=""
7924156283Srwatson		  ;;
7925156283Srwatson		esac
7926156283Srwatson	      fi
7927156283Srwatson	      if test -n "$a_deplib" ; then
7928244390Srwatson		libname=`eval "\\$ECHO \"$libname_spec\""`
7929156283Srwatson		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
7930156283Srwatson		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
7931156283Srwatson		  for potent_lib in $potential_libs; do
7932156283Srwatson		    potlib="$potent_lib" # see symlink-check above in file_magic test
7933244390Srwatson		    if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
7934244390Srwatson		       $EGREP "$match_pattern_regex" > /dev/null; then
7935244390Srwatson		      func_append newdeplibs " $a_deplib"
7936156283Srwatson		      a_deplib=""
7937156283Srwatson		      break 2
7938156283Srwatson		    fi
7939156283Srwatson		  done
7940156283Srwatson		done
7941156283Srwatson	      fi
7942156283Srwatson	      if test -n "$a_deplib" ; then
7943156283Srwatson		droppeddeps=yes
7944244390Srwatson		echo
7945244390Srwatson		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
7946244390Srwatson		echo "*** I have the capability to make that library automatically link in when"
7947244390Srwatson		echo "*** you link to this library.  But I can only do this if you have a"
7948244390Srwatson		echo "*** shared version of the library, which you do not appear to have"
7949244390Srwatson		echo "*** because I did check the linker path looking for a file starting"
7950156283Srwatson		if test -z "$potlib" ; then
7951244390Srwatson		  $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
7952156283Srwatson		else
7953244390Srwatson		  $ECHO "*** with $libname and none of the candidates passed a file format test"
7954244390Srwatson		  $ECHO "*** using a regex pattern. Last file checked: $potlib"
7955156283Srwatson		fi
7956156283Srwatson	      fi
7957244390Srwatson	      ;;
7958244390Srwatson	    *)
7959156283Srwatson	      # Add a -L argument.
7960244390Srwatson	      func_append newdeplibs " $a_deplib"
7961244390Srwatson	      ;;
7962244390Srwatson	    esac
7963156283Srwatson	  done # Gone through all deplibs.
7964156283Srwatson	  ;;
7965156283Srwatson	none | unknown | *)
7966156283Srwatson	  newdeplibs=""
7967244390Srwatson	  tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
7968156283Srwatson	  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7969156283Srwatson	    for i in $predeps $postdeps ; do
7970156283Srwatson	      # can't use Xsed below, because $i might contain '/'
7971244390Srwatson	      tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"`
7972156283Srwatson	    done
7973156283Srwatson	  fi
7974244390Srwatson	  case $tmp_deplibs in
7975244390Srwatson	  *[!\	\ ]*)
7976244390Srwatson	    echo
7977156283Srwatson	    if test "X$deplibs_check_method" = "Xnone"; then
7978244390Srwatson	      echo "*** Warning: inter-library dependencies are not supported in this platform."
7979156283Srwatson	    else
7980244390Srwatson	      echo "*** Warning: inter-library dependencies are not known to be supported."
7981156283Srwatson	    fi
7982244390Srwatson	    echo "*** All declared inter-library dependencies are being dropped."
7983156283Srwatson	    droppeddeps=yes
7984244390Srwatson	    ;;
7985244390Srwatson	  esac
7986156283Srwatson	  ;;
7987156283Srwatson	esac
7988156283Srwatson	versuffix=$versuffix_save
7989156283Srwatson	major=$major_save
7990156283Srwatson	release=$release_save
7991156283Srwatson	libname=$libname_save
7992156283Srwatson	name=$name_save
7993156283Srwatson
7994156283Srwatson	case $host in
7995156283Srwatson	*-*-rhapsody* | *-*-darwin1.[012])
7996244390Srwatson	  # On Rhapsody replace the C library with the System framework
7997244390Srwatson	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
7998156283Srwatson	  ;;
7999156283Srwatson	esac
8000156283Srwatson
8001156283Srwatson	if test "$droppeddeps" = yes; then
8002156283Srwatson	  if test "$module" = yes; then
8003244390Srwatson	    echo
8004244390Srwatson	    echo "*** Warning: libtool could not satisfy all declared inter-library"
8005244390Srwatson	    $ECHO "*** dependencies of module $libname.  Therefore, libtool will create"
8006244390Srwatson	    echo "*** a static module, that should work as long as the dlopening"
8007244390Srwatson	    echo "*** application is linked with the -dlopen flag."
8008156283Srwatson	    if test -z "$global_symbol_pipe"; then
8009244390Srwatson	      echo
8010244390Srwatson	      echo "*** However, this would only work if libtool was able to extract symbol"
8011244390Srwatson	      echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
8012244390Srwatson	      echo "*** not find such a program.  So, this module is probably useless."
8013244390Srwatson	      echo "*** \`nm' from GNU binutils and a full rebuild may help."
8014156283Srwatson	    fi
8015156283Srwatson	    if test "$build_old_libs" = no; then
8016156283Srwatson	      oldlibs="$output_objdir/$libname.$libext"
8017156283Srwatson	      build_libtool_libs=module
8018156283Srwatson	      build_old_libs=yes
8019156283Srwatson	    else
8020156283Srwatson	      build_libtool_libs=no
8021156283Srwatson	    fi
8022156283Srwatson	  else
8023244390Srwatson	    echo "*** The inter-library dependencies that have been dropped here will be"
8024244390Srwatson	    echo "*** automatically added whenever a program is linked with this library"
8025244390Srwatson	    echo "*** or is declared to -dlopen it."
8026156283Srwatson
8027156283Srwatson	    if test "$allow_undefined" = no; then
8028244390Srwatson	      echo
8029244390Srwatson	      echo "*** Since this library must not contain undefined symbols,"
8030244390Srwatson	      echo "*** because either the platform does not support them or"
8031244390Srwatson	      echo "*** it was explicitly requested with -no-undefined,"
8032244390Srwatson	      echo "*** libtool will only create a static version of it."
8033156283Srwatson	      if test "$build_old_libs" = no; then
8034156283Srwatson		oldlibs="$output_objdir/$libname.$libext"
8035156283Srwatson		build_libtool_libs=module
8036156283Srwatson		build_old_libs=yes
8037156283Srwatson	      else
8038156283Srwatson		build_libtool_libs=no
8039156283Srwatson	      fi
8040156283Srwatson	    fi
8041156283Srwatson	  fi
8042156283Srwatson	fi
8043156283Srwatson	# Done checking deplibs!
8044156283Srwatson	deplibs=$newdeplibs
8045156283Srwatson      fi
8046244390Srwatson      # Time to change all our "foo.ltframework" stuff back to "-framework foo"
8047244390Srwatson      case $host in
8048244390Srwatson	*-*-darwin*)
8049244390Srwatson	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8050244390Srwatson	  new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8051244390Srwatson	  deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8052244390Srwatson	  ;;
8053244390Srwatson      esac
8054156283Srwatson
8055159985Srwatson      # move library search paths that coincide with paths to not yet
8056159985Srwatson      # installed libraries to the beginning of the library search list
8057159985Srwatson      new_libs=
8058159985Srwatson      for path in $notinst_path; do
8059159985Srwatson	case " $new_libs " in
8060159985Srwatson	*" -L$path/$objdir "*) ;;
8061159985Srwatson	*)
8062159985Srwatson	  case " $deplibs " in
8063159985Srwatson	  *" -L$path/$objdir "*)
8064244390Srwatson	    func_append new_libs " -L$path/$objdir" ;;
8065159985Srwatson	  esac
8066159985Srwatson	  ;;
8067159985Srwatson	esac
8068159985Srwatson      done
8069159985Srwatson      for deplib in $deplibs; do
8070159985Srwatson	case $deplib in
8071159985Srwatson	-L*)
8072159985Srwatson	  case " $new_libs " in
8073159985Srwatson	  *" $deplib "*) ;;
8074244390Srwatson	  *) func_append new_libs " $deplib" ;;
8075159985Srwatson	  esac
8076159985Srwatson	  ;;
8077244390Srwatson	*) func_append new_libs " $deplib" ;;
8078159985Srwatson	esac
8079159985Srwatson      done
8080159985Srwatson      deplibs="$new_libs"
8081159985Srwatson
8082156283Srwatson      # All the library-specific variables (install_libdir is set above).
8083156283Srwatson      library_names=
8084156283Srwatson      old_library=
8085156283Srwatson      dlname=
8086156283Srwatson
8087156283Srwatson      # Test again, we may have decided not to build it any more
8088156283Srwatson      if test "$build_libtool_libs" = yes; then
8089244390Srwatson	# Remove ${wl} instances when linking with ld.
8090244390Srwatson	# FIXME: should test the right _cmds variable.
8091244390Srwatson	case $archive_cmds in
8092244390Srwatson	  *\$LD\ *) wl= ;;
8093244390Srwatson        esac
8094156283Srwatson	if test "$hardcode_into_libs" = yes; then
8095156283Srwatson	  # Hardcode the library paths
8096156283Srwatson	  hardcode_libdirs=
8097156283Srwatson	  dep_rpath=
8098156283Srwatson	  rpath="$finalize_rpath"
8099244390Srwatson	  test "$opt_mode" != relink && rpath="$compile_rpath$rpath"
8100156283Srwatson	  for libdir in $rpath; do
8101156283Srwatson	    if test -n "$hardcode_libdir_flag_spec"; then
8102156283Srwatson	      if test -n "$hardcode_libdir_separator"; then
8103244390Srwatson		func_replace_sysroot "$libdir"
8104244390Srwatson		libdir=$func_replace_sysroot_result
8105156283Srwatson		if test -z "$hardcode_libdirs"; then
8106156283Srwatson		  hardcode_libdirs="$libdir"
8107156283Srwatson		else
8108156283Srwatson		  # Just accumulate the unique libdirs.
8109156283Srwatson		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
8110156283Srwatson		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
8111156283Srwatson		    ;;
8112156283Srwatson		  *)
8113244390Srwatson		    func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
8114156283Srwatson		    ;;
8115156283Srwatson		  esac
8116156283Srwatson		fi
8117156283Srwatson	      else
8118156283Srwatson		eval flag=\"$hardcode_libdir_flag_spec\"
8119244390Srwatson		func_append dep_rpath " $flag"
8120156283Srwatson	      fi
8121156283Srwatson	    elif test -n "$runpath_var"; then
8122156283Srwatson	      case "$perm_rpath " in
8123156283Srwatson	      *" $libdir "*) ;;
8124244390Srwatson	      *) func_append perm_rpath " $libdir" ;;
8125156283Srwatson	      esac
8126156283Srwatson	    fi
8127156283Srwatson	  done
8128156283Srwatson	  # Substitute the hardcoded libdirs into the rpath.
8129156283Srwatson	  if test -n "$hardcode_libdir_separator" &&
8130156283Srwatson	     test -n "$hardcode_libdirs"; then
8131156283Srwatson	    libdir="$hardcode_libdirs"
8132244390Srwatson	    eval "dep_rpath=\"$hardcode_libdir_flag_spec\""
8133156283Srwatson	  fi
8134156283Srwatson	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
8135156283Srwatson	    # We should set the runpath_var.
8136156283Srwatson	    rpath=
8137156283Srwatson	    for dir in $perm_rpath; do
8138244390Srwatson	      func_append rpath "$dir:"
8139156283Srwatson	    done
8140156283Srwatson	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
8141156283Srwatson	  fi
8142156283Srwatson	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
8143156283Srwatson	fi
8144156283Srwatson
8145156283Srwatson	shlibpath="$finalize_shlibpath"
8146244390Srwatson	test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
8147156283Srwatson	if test -n "$shlibpath"; then
8148156283Srwatson	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
8149156283Srwatson	fi
8150156283Srwatson
8151156283Srwatson	# Get the real and link names of the library.
8152156283Srwatson	eval shared_ext=\"$shrext_cmds\"
8153156283Srwatson	eval library_names=\"$library_names_spec\"
8154156283Srwatson	set dummy $library_names
8155244390Srwatson	shift
8156244390Srwatson	realname="$1"
8157244390Srwatson	shift
8158156283Srwatson
8159156283Srwatson	if test -n "$soname_spec"; then
8160156283Srwatson	  eval soname=\"$soname_spec\"
8161156283Srwatson	else
8162156283Srwatson	  soname="$realname"
8163156283Srwatson	fi
8164156283Srwatson	if test -z "$dlname"; then
8165156283Srwatson	  dlname=$soname
8166156283Srwatson	fi
8167156283Srwatson
8168156283Srwatson	lib="$output_objdir/$realname"
8169159985Srwatson	linknames=
8170156283Srwatson	for link
8171156283Srwatson	do
8172244390Srwatson	  func_append linknames " $link"
8173156283Srwatson	done
8174156283Srwatson
8175156283Srwatson	# Use standard objects if they are pic
8176244390Srwatson	test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
8177244390Srwatson	test "X$libobjs" = "X " && libobjs=
8178156283Srwatson
8179244390Srwatson	delfiles=
8180244390Srwatson	if test -n "$export_symbols" && test -n "$include_expsyms"; then
8181244390Srwatson	  $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
8182244390Srwatson	  export_symbols="$output_objdir/$libname.uexp"
8183244390Srwatson	  func_append delfiles " $export_symbols"
8184244390Srwatson	fi
8185244390Srwatson
8186244390Srwatson	orig_export_symbols=
8187244390Srwatson	case $host_os in
8188244390Srwatson	cygwin* | mingw* | cegcc*)
8189244390Srwatson	  if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
8190244390Srwatson	    # exporting using user supplied symfile
8191244390Srwatson	    if test "x`$SED 1q $export_symbols`" != xEXPORTS; then
8192244390Srwatson	      # and it's NOT already a .def file. Must figure out
8193244390Srwatson	      # which of the given symbols are data symbols and tag
8194244390Srwatson	      # them as such. So, trigger use of export_symbols_cmds.
8195244390Srwatson	      # export_symbols gets reassigned inside the "prepare
8196244390Srwatson	      # the list of exported symbols" if statement, so the
8197244390Srwatson	      # include_expsyms logic still works.
8198244390Srwatson	      orig_export_symbols="$export_symbols"
8199244390Srwatson	      export_symbols=
8200244390Srwatson	      always_export_symbols=yes
8201244390Srwatson	    fi
8202244390Srwatson	  fi
8203244390Srwatson	  ;;
8204244390Srwatson	esac
8205244390Srwatson
8206156283Srwatson	# Prepare the list of exported symbols
8207156283Srwatson	if test -z "$export_symbols"; then
8208156283Srwatson	  if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
8209244390Srwatson	    func_verbose "generating symbol list for \`$libname.la'"
8210156283Srwatson	    export_symbols="$output_objdir/$libname.exp"
8211244390Srwatson	    $opt_dry_run || $RM $export_symbols
8212156283Srwatson	    cmds=$export_symbols_cmds
8213156283Srwatson	    save_ifs="$IFS"; IFS='~'
8214244390Srwatson	    for cmd1 in $cmds; do
8215156283Srwatson	      IFS="$save_ifs"
8216244390Srwatson	      # Take the normal branch if the nm_file_list_spec branch
8217244390Srwatson	      # doesn't work or if tool conversion is not needed.
8218244390Srwatson	      case $nm_file_list_spec~$to_tool_file_cmd in
8219244390Srwatson		*~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*)
8220244390Srwatson		  try_normal_branch=yes
8221244390Srwatson		  eval cmd=\"$cmd1\"
8222244390Srwatson		  func_len " $cmd"
8223244390Srwatson		  len=$func_len_result
8224244390Srwatson		  ;;
8225244390Srwatson		*)
8226244390Srwatson		  try_normal_branch=no
8227244390Srwatson		  ;;
8228244390Srwatson	      esac
8229244390Srwatson	      if test "$try_normal_branch" = yes \
8230244390Srwatson		 && { test "$len" -lt "$max_cmd_len" \
8231244390Srwatson		      || test "$max_cmd_len" -le -1; }
8232244390Srwatson	      then
8233244390Srwatson		func_show_eval "$cmd" 'exit $?'
8234244390Srwatson		skipped_export=false
8235244390Srwatson	      elif test -n "$nm_file_list_spec"; then
8236244390Srwatson		func_basename "$output"
8237244390Srwatson		output_la=$func_basename_result
8238244390Srwatson		save_libobjs=$libobjs
8239244390Srwatson		save_output=$output
8240244390Srwatson		output=${output_objdir}/${output_la}.nm
8241244390Srwatson		func_to_tool_file "$output"
8242244390Srwatson		libobjs=$nm_file_list_spec$func_to_tool_file_result
8243244390Srwatson		func_append delfiles " $output"
8244244390Srwatson		func_verbose "creating $NM input file list: $output"
8245244390Srwatson		for obj in $save_libobjs; do
8246244390Srwatson		  func_to_tool_file "$obj"
8247244390Srwatson		  $ECHO "$func_to_tool_file_result"
8248244390Srwatson		done > "$output"
8249244390Srwatson		eval cmd=\"$cmd1\"
8250244390Srwatson		func_show_eval "$cmd" 'exit $?'
8251244390Srwatson		output=$save_output
8252244390Srwatson		libobjs=$save_libobjs
8253244390Srwatson		skipped_export=false
8254156283Srwatson	      else
8255244390Srwatson		# The command line is too long to execute in one step.
8256244390Srwatson		func_verbose "using reloadable object file for export list..."
8257244390Srwatson		skipped_export=:
8258156283Srwatson		# Break out early, otherwise skipped_export may be
8259156283Srwatson		# set to false by a later but shorter cmd.
8260156283Srwatson		break
8261156283Srwatson	      fi
8262156283Srwatson	    done
8263156283Srwatson	    IFS="$save_ifs"
8264244390Srwatson	    if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then
8265244390Srwatson	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
8266244390Srwatson	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
8267156283Srwatson	    fi
8268156283Srwatson	  fi
8269156283Srwatson	fi
8270156283Srwatson
8271156283Srwatson	if test -n "$export_symbols" && test -n "$include_expsyms"; then
8272244390Srwatson	  tmp_export_symbols="$export_symbols"
8273244390Srwatson	  test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
8274244390Srwatson	  $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
8275156283Srwatson	fi
8276156283Srwatson
8277244390Srwatson	if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then
8278244390Srwatson	  # The given exports_symbols file has to be filtered, so filter it.
8279244390Srwatson	  func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
8280244390Srwatson	  # FIXME: $output_objdir/$libname.filter potentially contains lots of
8281244390Srwatson	  # 's' commands which not all seds can handle. GNU sed should be fine
8282244390Srwatson	  # though. Also, the filter scales superlinearly with the number of
8283244390Srwatson	  # global variables. join(1) would be nice here, but unfortunately
8284244390Srwatson	  # isn't a blessed tool.
8285244390Srwatson	  $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
8286244390Srwatson	  func_append delfiles " $export_symbols $output_objdir/$libname.filter"
8287244390Srwatson	  export_symbols=$output_objdir/$libname.def
8288244390Srwatson	  $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
8289244390Srwatson	fi
8290244390Srwatson
8291156283Srwatson	tmp_deplibs=
8292156283Srwatson	for test_deplib in $deplibs; do
8293244390Srwatson	  case " $convenience " in
8294244390Srwatson	  *" $test_deplib "*) ;;
8295244390Srwatson	  *)
8296244390Srwatson	    func_append tmp_deplibs " $test_deplib"
8297244390Srwatson	    ;;
8298244390Srwatson	  esac
8299156283Srwatson	done
8300156283Srwatson	deplibs="$tmp_deplibs"
8301156283Srwatson
8302156283Srwatson	if test -n "$convenience"; then
8303244390Srwatson	  if test -n "$whole_archive_flag_spec" &&
8304244390Srwatson	    test "$compiler_needs_object" = yes &&
8305244390Srwatson	    test -z "$libobjs"; then
8306244390Srwatson	    # extract the archives, so we have objects to list.
8307244390Srwatson	    # TODO: could optimize this to just extract one archive.
8308244390Srwatson	    whole_archive_flag_spec=
8309244390Srwatson	  fi
8310156283Srwatson	  if test -n "$whole_archive_flag_spec"; then
8311156283Srwatson	    save_libobjs=$libobjs
8312156283Srwatson	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
8313244390Srwatson	    test "X$libobjs" = "X " && libobjs=
8314156283Srwatson	  else
8315156283Srwatson	    gentop="$output_objdir/${outputname}x"
8316244390Srwatson	    func_append generated " $gentop"
8317156283Srwatson
8318156283Srwatson	    func_extract_archives $gentop $convenience
8319244390Srwatson	    func_append libobjs " $func_extract_archives_result"
8320244390Srwatson	    test "X$libobjs" = "X " && libobjs=
8321156283Srwatson	  fi
8322156283Srwatson	fi
8323244390Srwatson
8324156283Srwatson	if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
8325156283Srwatson	  eval flag=\"$thread_safe_flag_spec\"
8326244390Srwatson	  func_append linker_flags " $flag"
8327156283Srwatson	fi
8328156283Srwatson
8329156283Srwatson	# Make a backup of the uninstalled library when relinking
8330244390Srwatson	if test "$opt_mode" = relink; then
8331244390Srwatson	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
8332156283Srwatson	fi
8333156283Srwatson
8334156283Srwatson	# Do each of the archive commands.
8335156283Srwatson	if test "$module" = yes && test -n "$module_cmds" ; then
8336156283Srwatson	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
8337156283Srwatson	    eval test_cmds=\"$module_expsym_cmds\"
8338156283Srwatson	    cmds=$module_expsym_cmds
8339156283Srwatson	  else
8340156283Srwatson	    eval test_cmds=\"$module_cmds\"
8341156283Srwatson	    cmds=$module_cmds
8342156283Srwatson	  fi
8343156283Srwatson	else
8344244390Srwatson	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
8345244390Srwatson	    eval test_cmds=\"$archive_expsym_cmds\"
8346244390Srwatson	    cmds=$archive_expsym_cmds
8347244390Srwatson	  else
8348244390Srwatson	    eval test_cmds=\"$archive_cmds\"
8349244390Srwatson	    cmds=$archive_cmds
8350156283Srwatson	  fi
8351156283Srwatson	fi
8352156283Srwatson
8353156283Srwatson	if test "X$skipped_export" != "X:" &&
8354244390Srwatson	   func_len " $test_cmds" &&
8355244390Srwatson	   len=$func_len_result &&
8356244390Srwatson	   test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
8357156283Srwatson	  :
8358156283Srwatson	else
8359244390Srwatson	  # The command line is too long to link in one step, link piecewise
8360244390Srwatson	  # or, if using GNU ld and skipped_export is not :, use a linker
8361244390Srwatson	  # script.
8362156283Srwatson
8363156283Srwatson	  # Save the value of $output and $libobjs because we want to
8364156283Srwatson	  # use them later.  If we have whole_archive_flag_spec, we
8365156283Srwatson	  # want to use save_libobjs as it was before
8366156283Srwatson	  # whole_archive_flag_spec was expanded, because we can't
8367156283Srwatson	  # assume the linker understands whole_archive_flag_spec.
8368156283Srwatson	  # This may have to be revisited, in case too many
8369156283Srwatson	  # convenience libraries get linked in and end up exceeding
8370156283Srwatson	  # the spec.
8371156283Srwatson	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
8372156283Srwatson	    save_libobjs=$libobjs
8373156283Srwatson	  fi
8374156283Srwatson	  save_output=$output
8375244390Srwatson	  func_basename "$output"
8376244390Srwatson	  output_la=$func_basename_result
8377156283Srwatson
8378156283Srwatson	  # Clear the reloadable object creation command queue and
8379156283Srwatson	  # initialize k to one.
8380156283Srwatson	  test_cmds=
8381156283Srwatson	  concat_cmds=
8382156283Srwatson	  objlist=
8383156283Srwatson	  last_robj=
8384156283Srwatson	  k=1
8385244390Srwatson
8386244390Srwatson	  if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
8387244390Srwatson	    output=${output_objdir}/${output_la}.lnkscript
8388244390Srwatson	    func_verbose "creating GNU ld script: $output"
8389244390Srwatson	    echo 'INPUT (' > $output
8390244390Srwatson	    for obj in $save_libobjs
8391244390Srwatson	    do
8392244390Srwatson	      func_to_tool_file "$obj"
8393244390Srwatson	      $ECHO "$func_to_tool_file_result" >> $output
8394244390Srwatson	    done
8395244390Srwatson	    echo ')' >> $output
8396244390Srwatson	    func_append delfiles " $output"
8397244390Srwatson	    func_to_tool_file "$output"
8398244390Srwatson	    output=$func_to_tool_file_result
8399244390Srwatson	  elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then
8400244390Srwatson	    output=${output_objdir}/${output_la}.lnk
8401244390Srwatson	    func_verbose "creating linker input file list: $output"
8402244390Srwatson	    : > $output
8403244390Srwatson	    set x $save_libobjs
8404244390Srwatson	    shift
8405244390Srwatson	    firstobj=
8406244390Srwatson	    if test "$compiler_needs_object" = yes; then
8407244390Srwatson	      firstobj="$1 "
8408244390Srwatson	      shift
8409244390Srwatson	    fi
8410244390Srwatson	    for obj
8411244390Srwatson	    do
8412244390Srwatson	      func_to_tool_file "$obj"
8413244390Srwatson	      $ECHO "$func_to_tool_file_result" >> $output
8414244390Srwatson	    done
8415244390Srwatson	    func_append delfiles " $output"
8416244390Srwatson	    func_to_tool_file "$output"
8417244390Srwatson	    output=$firstobj\"$file_list_spec$func_to_tool_file_result\"
8418244390Srwatson	  else
8419244390Srwatson	    if test -n "$save_libobjs"; then
8420244390Srwatson	      func_verbose "creating reloadable object files..."
8421244390Srwatson	      output=$output_objdir/$output_la-${k}.$objext
8422244390Srwatson	      eval test_cmds=\"$reload_cmds\"
8423244390Srwatson	      func_len " $test_cmds"
8424244390Srwatson	      len0=$func_len_result
8425244390Srwatson	      len=$len0
8426244390Srwatson
8427244390Srwatson	      # Loop over the list of objects to be linked.
8428244390Srwatson	      for obj in $save_libobjs
8429244390Srwatson	      do
8430244390Srwatson		func_len " $obj"
8431244390Srwatson		func_arith $len + $func_len_result
8432244390Srwatson		len=$func_arith_result
8433244390Srwatson		if test "X$objlist" = X ||
8434244390Srwatson		   test "$len" -lt "$max_cmd_len"; then
8435244390Srwatson		  func_append objlist " $obj"
8436244390Srwatson		else
8437244390Srwatson		  # The command $test_cmds is almost too long, add a
8438244390Srwatson		  # command to the queue.
8439244390Srwatson		  if test "$k" -eq 1 ; then
8440244390Srwatson		    # The first file doesn't have a previous command to add.
8441244390Srwatson		    reload_objs=$objlist
8442244390Srwatson		    eval concat_cmds=\"$reload_cmds\"
8443244390Srwatson		  else
8444244390Srwatson		    # All subsequent reloadable object files will link in
8445244390Srwatson		    # the last one created.
8446244390Srwatson		    reload_objs="$objlist $last_robj"
8447244390Srwatson		    eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
8448244390Srwatson		  fi
8449244390Srwatson		  last_robj=$output_objdir/$output_la-${k}.$objext
8450244390Srwatson		  func_arith $k + 1
8451244390Srwatson		  k=$func_arith_result
8452244390Srwatson		  output=$output_objdir/$output_la-${k}.$objext
8453244390Srwatson		  objlist=" $obj"
8454244390Srwatson		  func_len " $last_robj"
8455244390Srwatson		  func_arith $len0 + $func_len_result
8456244390Srwatson		  len=$func_arith_result
8457244390Srwatson		fi
8458244390Srwatson	      done
8459244390Srwatson	      # Handle the remaining objects by creating one last
8460244390Srwatson	      # reloadable object file.  All subsequent reloadable object
8461244390Srwatson	      # files will link in the last one created.
8462244390Srwatson	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
8463244390Srwatson	      reload_objs="$objlist $last_robj"
8464244390Srwatson	      eval concat_cmds=\"\${concat_cmds}$reload_cmds\"
8465244390Srwatson	      if test -n "$last_robj"; then
8466244390Srwatson	        eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\"
8467244390Srwatson	      fi
8468244390Srwatson	      func_append delfiles " $output"
8469244390Srwatson
8470156283Srwatson	    else
8471244390Srwatson	      output=
8472244390Srwatson	    fi
8473244390Srwatson
8474244390Srwatson	    if ${skipped_export-false}; then
8475244390Srwatson	      func_verbose "generating symbol list for \`$libname.la'"
8476244390Srwatson	      export_symbols="$output_objdir/$libname.exp"
8477244390Srwatson	      $opt_dry_run || $RM $export_symbols
8478244390Srwatson	      libobjs=$output
8479244390Srwatson	      # Append the command to create the export file.
8480244390Srwatson	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
8481244390Srwatson	      eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
8482244390Srwatson	      if test -n "$last_robj"; then
8483244390Srwatson		eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
8484156283Srwatson	      fi
8485156283Srwatson	    fi
8486156283Srwatson
8487244390Srwatson	    test -n "$save_libobjs" &&
8488244390Srwatson	      func_verbose "creating a temporary reloadable object file: $output"
8489156283Srwatson
8490244390Srwatson	    # Loop through the commands generated above and execute them.
8491244390Srwatson	    save_ifs="$IFS"; IFS='~'
8492244390Srwatson	    for cmd in $concat_cmds; do
8493244390Srwatson	      IFS="$save_ifs"
8494244390Srwatson	      $opt_silent || {
8495244390Srwatson		  func_quote_for_expand "$cmd"
8496244390Srwatson		  eval "func_echo $func_quote_for_expand_result"
8497244390Srwatson	      }
8498244390Srwatson	      $opt_dry_run || eval "$cmd" || {
8499244390Srwatson		lt_exit=$?
8500156283Srwatson
8501244390Srwatson		# Restore the uninstalled library and exit
8502244390Srwatson		if test "$opt_mode" = relink; then
8503244390Srwatson		  ( cd "$output_objdir" && \
8504244390Srwatson		    $RM "${realname}T" && \
8505244390Srwatson		    $MV "${realname}U" "$realname" )
8506244390Srwatson		fi
8507156283Srwatson
8508244390Srwatson		exit $lt_exit
8509244390Srwatson	      }
8510244390Srwatson	    done
8511156283Srwatson	    IFS="$save_ifs"
8512156283Srwatson
8513244390Srwatson	    if test -n "$export_symbols_regex" && ${skipped_export-false}; then
8514244390Srwatson	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
8515244390Srwatson	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
8516244390Srwatson	    fi
8517244390Srwatson	  fi
8518244390Srwatson
8519244390Srwatson          if ${skipped_export-false}; then
8520244390Srwatson	    if test -n "$export_symbols" && test -n "$include_expsyms"; then
8521244390Srwatson	      tmp_export_symbols="$export_symbols"
8522244390Srwatson	      test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
8523244390Srwatson	      $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
8524244390Srwatson	    fi
8525244390Srwatson
8526244390Srwatson	    if test -n "$orig_export_symbols"; then
8527244390Srwatson	      # The given exports_symbols file has to be filtered, so filter it.
8528244390Srwatson	      func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
8529244390Srwatson	      # FIXME: $output_objdir/$libname.filter potentially contains lots of
8530244390Srwatson	      # 's' commands which not all seds can handle. GNU sed should be fine
8531244390Srwatson	      # though. Also, the filter scales superlinearly with the number of
8532244390Srwatson	      # global variables. join(1) would be nice here, but unfortunately
8533244390Srwatson	      # isn't a blessed tool.
8534244390Srwatson	      $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
8535244390Srwatson	      func_append delfiles " $export_symbols $output_objdir/$libname.filter"
8536244390Srwatson	      export_symbols=$output_objdir/$libname.def
8537244390Srwatson	      $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
8538244390Srwatson	    fi
8539244390Srwatson	  fi
8540244390Srwatson
8541156283Srwatson	  libobjs=$output
8542156283Srwatson	  # Restore the value of output.
8543156283Srwatson	  output=$save_output
8544156283Srwatson
8545156283Srwatson	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
8546156283Srwatson	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
8547244390Srwatson	    test "X$libobjs" = "X " && libobjs=
8548156283Srwatson	  fi
8549156283Srwatson	  # Expand the library linking commands again to reset the
8550156283Srwatson	  # value of $libobjs for piecewise linking.
8551156283Srwatson
8552156283Srwatson	  # Do each of the archive commands.
8553156283Srwatson	  if test "$module" = yes && test -n "$module_cmds" ; then
8554156283Srwatson	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
8555156283Srwatson	      cmds=$module_expsym_cmds
8556156283Srwatson	    else
8557156283Srwatson	      cmds=$module_cmds
8558156283Srwatson	    fi
8559156283Srwatson	  else
8560244390Srwatson	    if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
8561244390Srwatson	      cmds=$archive_expsym_cmds
8562244390Srwatson	    else
8563244390Srwatson	      cmds=$archive_cmds
8564156283Srwatson	    fi
8565156283Srwatson	  fi
8566244390Srwatson	fi
8567156283Srwatson
8568244390Srwatson	if test -n "$delfiles"; then
8569244390Srwatson	  # Append the command to remove temporary files to $cmds.
8570244390Srwatson	  eval cmds=\"\$cmds~\$RM $delfiles\"
8571156283Srwatson	fi
8572244390Srwatson
8573244390Srwatson	# Add any objects from preloaded convenience libraries
8574244390Srwatson	if test -n "$dlprefiles"; then
8575244390Srwatson	  gentop="$output_objdir/${outputname}x"
8576244390Srwatson	  func_append generated " $gentop"
8577244390Srwatson
8578244390Srwatson	  func_extract_archives $gentop $dlprefiles
8579244390Srwatson	  func_append libobjs " $func_extract_archives_result"
8580244390Srwatson	  test "X$libobjs" = "X " && libobjs=
8581244390Srwatson	fi
8582244390Srwatson
8583156283Srwatson	save_ifs="$IFS"; IFS='~'
8584156283Srwatson	for cmd in $cmds; do
8585156283Srwatson	  IFS="$save_ifs"
8586156283Srwatson	  eval cmd=\"$cmd\"
8587244390Srwatson	  $opt_silent || {
8588244390Srwatson	    func_quote_for_expand "$cmd"
8589244390Srwatson	    eval "func_echo $func_quote_for_expand_result"
8590244390Srwatson	  }
8591244390Srwatson	  $opt_dry_run || eval "$cmd" || {
8592156283Srwatson	    lt_exit=$?
8593156283Srwatson
8594156283Srwatson	    # Restore the uninstalled library and exit
8595244390Srwatson	    if test "$opt_mode" = relink; then
8596244390Srwatson	      ( cd "$output_objdir" && \
8597244390Srwatson	        $RM "${realname}T" && \
8598244390Srwatson		$MV "${realname}U" "$realname" )
8599156283Srwatson	    fi
8600156283Srwatson
8601156283Srwatson	    exit $lt_exit
8602156283Srwatson	  }
8603156283Srwatson	done
8604156283Srwatson	IFS="$save_ifs"
8605156283Srwatson
8606156283Srwatson	# Restore the uninstalled library and exit
8607244390Srwatson	if test "$opt_mode" = relink; then
8608244390Srwatson	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
8609156283Srwatson
8610156283Srwatson	  if test -n "$convenience"; then
8611156283Srwatson	    if test -z "$whole_archive_flag_spec"; then
8612244390Srwatson	      func_show_eval '${RM}r "$gentop"'
8613156283Srwatson	    fi
8614156283Srwatson	  fi
8615156283Srwatson
8616156283Srwatson	  exit $EXIT_SUCCESS
8617156283Srwatson	fi
8618156283Srwatson
8619156283Srwatson	# Create links to the real library.
8620156283Srwatson	for linkname in $linknames; do
8621156283Srwatson	  if test "$realname" != "$linkname"; then
8622244390Srwatson	    func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
8623156283Srwatson	  fi
8624156283Srwatson	done
8625156283Srwatson
8626156283Srwatson	# If -module or -export-dynamic was specified, set the dlname.
8627156283Srwatson	if test "$module" = yes || test "$export_dynamic" = yes; then
8628156283Srwatson	  # On all known operating systems, these are identical.
8629156283Srwatson	  dlname="$soname"
8630156283Srwatson	fi
8631156283Srwatson      fi
8632156283Srwatson      ;;
8633156283Srwatson
8634156283Srwatson    obj)
8635244390Srwatson      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
8636244390Srwatson	func_warning "\`-dlopen' is ignored for objects"
8637244390Srwatson      fi
8638244390Srwatson
8639191273Srwatson      case " $deplibs" in
8640191273Srwatson      *\ -l* | *\ -L*)
8641244390Srwatson	func_warning "\`-l' and \`-L' are ignored for objects" ;;
8642191273Srwatson      esac
8643156283Srwatson
8644244390Srwatson      test -n "$rpath" && \
8645244390Srwatson	func_warning "\`-rpath' is ignored for objects"
8646156283Srwatson
8647244390Srwatson      test -n "$xrpath" && \
8648244390Srwatson	func_warning "\`-R' is ignored for objects"
8649156283Srwatson
8650244390Srwatson      test -n "$vinfo" && \
8651244390Srwatson	func_warning "\`-version-info' is ignored for objects"
8652156283Srwatson
8653244390Srwatson      test -n "$release" && \
8654244390Srwatson	func_warning "\`-release' is ignored for objects"
8655156283Srwatson
8656156283Srwatson      case $output in
8657156283Srwatson      *.lo)
8658244390Srwatson	test -n "$objs$old_deplibs" && \
8659244390Srwatson	  func_fatal_error "cannot build library object \`$output' from non-libtool objects"
8660244390Srwatson
8661244390Srwatson	libobj=$output
8662244390Srwatson	func_lo2o "$libobj"
8663244390Srwatson	obj=$func_lo2o_result
8664156283Srwatson	;;
8665156283Srwatson      *)
8666156283Srwatson	libobj=
8667156283Srwatson	obj="$output"
8668156283Srwatson	;;
8669156283Srwatson      esac
8670156283Srwatson
8671156283Srwatson      # Delete the old objects.
8672244390Srwatson      $opt_dry_run || $RM $obj $libobj
8673156283Srwatson
8674156283Srwatson      # Objects from convenience libraries.  This assumes
8675156283Srwatson      # single-version convenience libraries.  Whenever we create
8676156283Srwatson      # different ones for PIC/non-PIC, this we'll have to duplicate
8677156283Srwatson      # the extraction.
8678156283Srwatson      reload_conv_objs=
8679156283Srwatson      gentop=
8680156283Srwatson      # reload_cmds runs $LD directly, so let us get rid of
8681173143Srwatson      # -Wl from whole_archive_flag_spec and hope we can get by with
8682173143Srwatson      # turning comma into space..
8683156283Srwatson      wl=
8684156283Srwatson
8685156283Srwatson      if test -n "$convenience"; then
8686156283Srwatson	if test -n "$whole_archive_flag_spec"; then
8687173143Srwatson	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
8688244390Srwatson	  reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
8689156283Srwatson	else
8690156283Srwatson	  gentop="$output_objdir/${obj}x"
8691244390Srwatson	  func_append generated " $gentop"
8692156283Srwatson
8693156283Srwatson	  func_extract_archives $gentop $convenience
8694156283Srwatson	  reload_conv_objs="$reload_objs $func_extract_archives_result"
8695156283Srwatson	fi
8696156283Srwatson      fi
8697156283Srwatson
8698244390Srwatson      # If we're not building shared, we need to use non_pic_objs
8699244390Srwatson      test "$build_libtool_libs" != yes && libobjs="$non_pic_objects"
8700244390Srwatson
8701156283Srwatson      # Create the old-style object.
8702244390Srwatson      reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
8703156283Srwatson
8704156283Srwatson      output="$obj"
8705244390Srwatson      func_execute_cmds "$reload_cmds" 'exit $?'
8706156283Srwatson
8707156283Srwatson      # Exit if we aren't doing a library object file.
8708156283Srwatson      if test -z "$libobj"; then
8709156283Srwatson	if test -n "$gentop"; then
8710244390Srwatson	  func_show_eval '${RM}r "$gentop"'
8711156283Srwatson	fi
8712156283Srwatson
8713156283Srwatson	exit $EXIT_SUCCESS
8714156283Srwatson      fi
8715156283Srwatson
8716156283Srwatson      if test "$build_libtool_libs" != yes; then
8717156283Srwatson	if test -n "$gentop"; then
8718244390Srwatson	  func_show_eval '${RM}r "$gentop"'
8719156283Srwatson	fi
8720156283Srwatson
8721156283Srwatson	# Create an invalid libtool object if no PIC, so that we don't
8722156283Srwatson	# accidentally link it into a program.
8723156283Srwatson	# $show "echo timestamp > $libobj"
8724244390Srwatson	# $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
8725156283Srwatson	exit $EXIT_SUCCESS
8726156283Srwatson      fi
8727156283Srwatson
8728156283Srwatson      if test -n "$pic_flag" || test "$pic_mode" != default; then
8729156283Srwatson	# Only do commands if we really have different PIC objects.
8730156283Srwatson	reload_objs="$libobjs $reload_conv_objs"
8731156283Srwatson	output="$libobj"
8732244390Srwatson	func_execute_cmds "$reload_cmds" 'exit $?'
8733156283Srwatson      fi
8734156283Srwatson
8735156283Srwatson      if test -n "$gentop"; then
8736244390Srwatson	func_show_eval '${RM}r "$gentop"'
8737156283Srwatson      fi
8738156283Srwatson
8739156283Srwatson      exit $EXIT_SUCCESS
8740156283Srwatson      ;;
8741156283Srwatson
8742156283Srwatson    prog)
8743156283Srwatson      case $host in
8744244390Srwatson	*cygwin*) func_stripname '' '.exe' "$output"
8745244390Srwatson	          output=$func_stripname_result.exe;;
8746156283Srwatson      esac
8747244390Srwatson      test -n "$vinfo" && \
8748244390Srwatson	func_warning "\`-version-info' is ignored for programs"
8749156283Srwatson
8750244390Srwatson      test -n "$release" && \
8751244390Srwatson	func_warning "\`-release' is ignored for programs"
8752156283Srwatson
8753244390Srwatson      test "$preload" = yes \
8754244390Srwatson        && test "$dlopen_support" = unknown \
8755244390Srwatson	&& test "$dlopen_self" = unknown \
8756244390Srwatson	&& test "$dlopen_self_static" = unknown && \
8757244390Srwatson	  func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support."
8758156283Srwatson
8759156283Srwatson      case $host in
8760156283Srwatson      *-*-rhapsody* | *-*-darwin1.[012])
8761156283Srwatson	# On Rhapsody replace the C library is the System framework
8762244390Srwatson	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
8763244390Srwatson	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
8764156283Srwatson	;;
8765156283Srwatson      esac
8766156283Srwatson
8767156283Srwatson      case $host in
8768244390Srwatson      *-*-darwin*)
8769244390Srwatson	# Don't allow lazy linking, it breaks C++ global constructors
8770244390Srwatson	# But is supposedly fixed on 10.4 or later (yay!).
8771244390Srwatson	if test "$tagname" = CXX ; then
8772244390Srwatson	  case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
8773244390Srwatson	    10.[0123])
8774244390Srwatson	      func_append compile_command " ${wl}-bind_at_load"
8775244390Srwatson	      func_append finalize_command " ${wl}-bind_at_load"
8776244390Srwatson	    ;;
8777244390Srwatson	  esac
8778244390Srwatson	fi
8779244390Srwatson	# Time to change all our "foo.ltframework" stuff back to "-framework foo"
8780244390Srwatson	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8781244390Srwatson	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8782244390Srwatson	;;
8783156283Srwatson      esac
8784156283Srwatson
8785159985Srwatson
8786159985Srwatson      # move library search paths that coincide with paths to not yet
8787159985Srwatson      # installed libraries to the beginning of the library search list
8788159985Srwatson      new_libs=
8789159985Srwatson      for path in $notinst_path; do
8790159985Srwatson	case " $new_libs " in
8791159985Srwatson	*" -L$path/$objdir "*) ;;
8792159985Srwatson	*)
8793159985Srwatson	  case " $compile_deplibs " in
8794159985Srwatson	  *" -L$path/$objdir "*)
8795244390Srwatson	    func_append new_libs " -L$path/$objdir" ;;
8796159985Srwatson	  esac
8797159985Srwatson	  ;;
8798159985Srwatson	esac
8799159985Srwatson      done
8800159985Srwatson      for deplib in $compile_deplibs; do
8801159985Srwatson	case $deplib in
8802159985Srwatson	-L*)
8803159985Srwatson	  case " $new_libs " in
8804159985Srwatson	  *" $deplib "*) ;;
8805244390Srwatson	  *) func_append new_libs " $deplib" ;;
8806159985Srwatson	  esac
8807159985Srwatson	  ;;
8808244390Srwatson	*) func_append new_libs " $deplib" ;;
8809159985Srwatson	esac
8810159985Srwatson      done
8811159985Srwatson      compile_deplibs="$new_libs"
8812159985Srwatson
8813159985Srwatson
8814244390Srwatson      func_append compile_command " $compile_deplibs"
8815244390Srwatson      func_append finalize_command " $finalize_deplibs"
8816156283Srwatson
8817156283Srwatson      if test -n "$rpath$xrpath"; then
8818156283Srwatson	# If the user specified any rpath flags, then add them.
8819156283Srwatson	for libdir in $rpath $xrpath; do
8820156283Srwatson	  # This is the magic to use -rpath.
8821156283Srwatson	  case "$finalize_rpath " in
8822156283Srwatson	  *" $libdir "*) ;;
8823244390Srwatson	  *) func_append finalize_rpath " $libdir" ;;
8824156283Srwatson	  esac
8825156283Srwatson	done
8826156283Srwatson      fi
8827156283Srwatson
8828156283Srwatson      # Now hardcode the library paths
8829156283Srwatson      rpath=
8830156283Srwatson      hardcode_libdirs=
8831156283Srwatson      for libdir in $compile_rpath $finalize_rpath; do
8832156283Srwatson	if test -n "$hardcode_libdir_flag_spec"; then
8833156283Srwatson	  if test -n "$hardcode_libdir_separator"; then
8834156283Srwatson	    if test -z "$hardcode_libdirs"; then
8835156283Srwatson	      hardcode_libdirs="$libdir"
8836156283Srwatson	    else
8837156283Srwatson	      # Just accumulate the unique libdirs.
8838156283Srwatson	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
8839156283Srwatson	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
8840156283Srwatson		;;
8841156283Srwatson	      *)
8842244390Srwatson		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
8843156283Srwatson		;;
8844156283Srwatson	      esac
8845156283Srwatson	    fi
8846156283Srwatson	  else
8847156283Srwatson	    eval flag=\"$hardcode_libdir_flag_spec\"
8848244390Srwatson	    func_append rpath " $flag"
8849156283Srwatson	  fi
8850156283Srwatson	elif test -n "$runpath_var"; then
8851156283Srwatson	  case "$perm_rpath " in
8852156283Srwatson	  *" $libdir "*) ;;
8853244390Srwatson	  *) func_append perm_rpath " $libdir" ;;
8854156283Srwatson	  esac
8855156283Srwatson	fi
8856156283Srwatson	case $host in
8857244390Srwatson	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
8858244390Srwatson	  testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'`
8859156283Srwatson	  case :$dllsearchpath: in
8860156283Srwatson	  *":$libdir:"*) ;;
8861244390Srwatson	  ::) dllsearchpath=$libdir;;
8862244390Srwatson	  *) func_append dllsearchpath ":$libdir";;
8863156283Srwatson	  esac
8864159985Srwatson	  case :$dllsearchpath: in
8865159985Srwatson	  *":$testbindir:"*) ;;
8866244390Srwatson	  ::) dllsearchpath=$testbindir;;
8867244390Srwatson	  *) func_append dllsearchpath ":$testbindir";;
8868159985Srwatson	  esac
8869156283Srwatson	  ;;
8870156283Srwatson	esac
8871156283Srwatson      done
8872156283Srwatson      # Substitute the hardcoded libdirs into the rpath.
8873156283Srwatson      if test -n "$hardcode_libdir_separator" &&
8874156283Srwatson	 test -n "$hardcode_libdirs"; then
8875156283Srwatson	libdir="$hardcode_libdirs"
8876156283Srwatson	eval rpath=\" $hardcode_libdir_flag_spec\"
8877156283Srwatson      fi
8878156283Srwatson      compile_rpath="$rpath"
8879156283Srwatson
8880156283Srwatson      rpath=
8881156283Srwatson      hardcode_libdirs=
8882156283Srwatson      for libdir in $finalize_rpath; do
8883156283Srwatson	if test -n "$hardcode_libdir_flag_spec"; then
8884156283Srwatson	  if test -n "$hardcode_libdir_separator"; then
8885156283Srwatson	    if test -z "$hardcode_libdirs"; then
8886156283Srwatson	      hardcode_libdirs="$libdir"
8887156283Srwatson	    else
8888156283Srwatson	      # Just accumulate the unique libdirs.
8889156283Srwatson	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
8890156283Srwatson	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
8891156283Srwatson		;;
8892156283Srwatson	      *)
8893244390Srwatson		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
8894156283Srwatson		;;
8895156283Srwatson	      esac
8896156283Srwatson	    fi
8897156283Srwatson	  else
8898156283Srwatson	    eval flag=\"$hardcode_libdir_flag_spec\"
8899244390Srwatson	    func_append rpath " $flag"
8900156283Srwatson	  fi
8901156283Srwatson	elif test -n "$runpath_var"; then
8902156283Srwatson	  case "$finalize_perm_rpath " in
8903156283Srwatson	  *" $libdir "*) ;;
8904244390Srwatson	  *) func_append finalize_perm_rpath " $libdir" ;;
8905156283Srwatson	  esac
8906156283Srwatson	fi
8907156283Srwatson      done
8908156283Srwatson      # Substitute the hardcoded libdirs into the rpath.
8909156283Srwatson      if test -n "$hardcode_libdir_separator" &&
8910156283Srwatson	 test -n "$hardcode_libdirs"; then
8911156283Srwatson	libdir="$hardcode_libdirs"
8912156283Srwatson	eval rpath=\" $hardcode_libdir_flag_spec\"
8913156283Srwatson      fi
8914156283Srwatson      finalize_rpath="$rpath"
8915156283Srwatson
8916156283Srwatson      if test -n "$libobjs" && test "$build_old_libs" = yes; then
8917156283Srwatson	# Transform all the library objects into standard objects.
8918244390Srwatson	compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
8919244390Srwatson	finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
8920156283Srwatson      fi
8921156283Srwatson
8922244390Srwatson      func_generate_dlsyms "$outputname" "@PROGRAM@" "no"
8923156283Srwatson
8924244390Srwatson      # template prelinking step
8925244390Srwatson      if test -n "$prelink_cmds"; then
8926244390Srwatson	func_execute_cmds "$prelink_cmds" 'exit $?'
8927156283Srwatson      fi
8928156283Srwatson
8929244390Srwatson      wrappers_required=yes
8930244390Srwatson      case $host in
8931244390Srwatson      *cegcc* | *mingw32ce*)
8932244390Srwatson        # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
8933244390Srwatson        wrappers_required=no
8934244390Srwatson        ;;
8935244390Srwatson      *cygwin* | *mingw* )
8936244390Srwatson        if test "$build_libtool_libs" != yes; then
8937244390Srwatson          wrappers_required=no
8938244390Srwatson        fi
8939244390Srwatson        ;;
8940244390Srwatson      *)
8941244390Srwatson        if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
8942244390Srwatson          wrappers_required=no
8943244390Srwatson        fi
8944244390Srwatson        ;;
8945244390Srwatson      esac
8946244390Srwatson      if test "$wrappers_required" = no; then
8947156283Srwatson	# Replace the output file specification.
8948244390Srwatson	compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
8949156283Srwatson	link_command="$compile_command$compile_rpath"
8950156283Srwatson
8951156283Srwatson	# We have no uninstalled library dependencies, so finalize right now.
8952244390Srwatson	exit_status=0
8953244390Srwatson	func_show_eval "$link_command" 'exit_status=$?'
8954156283Srwatson
8955244390Srwatson	if test -n "$postlink_cmds"; then
8956244390Srwatson	  func_to_tool_file "$output"
8957244390Srwatson	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
8958244390Srwatson	  func_execute_cmds "$postlink_cmds" 'exit $?'
8959244390Srwatson	fi
8960244390Srwatson
8961156283Srwatson	# Delete the generated files.
8962244390Srwatson	if test -f "$output_objdir/${outputname}S.${objext}"; then
8963244390Srwatson	  func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"'
8964156283Srwatson	fi
8965156283Srwatson
8966159985Srwatson	exit $exit_status
8967156283Srwatson      fi
8968156283Srwatson
8969156283Srwatson      if test -n "$compile_shlibpath$finalize_shlibpath"; then
8970156283Srwatson	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
8971156283Srwatson      fi
8972156283Srwatson      if test -n "$finalize_shlibpath"; then
8973156283Srwatson	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
8974156283Srwatson      fi
8975156283Srwatson
8976156283Srwatson      compile_var=
8977156283Srwatson      finalize_var=
8978156283Srwatson      if test -n "$runpath_var"; then
8979156283Srwatson	if test -n "$perm_rpath"; then
8980156283Srwatson	  # We should set the runpath_var.
8981156283Srwatson	  rpath=
8982156283Srwatson	  for dir in $perm_rpath; do
8983244390Srwatson	    func_append rpath "$dir:"
8984156283Srwatson	  done
8985156283Srwatson	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
8986156283Srwatson	fi
8987156283Srwatson	if test -n "$finalize_perm_rpath"; then
8988156283Srwatson	  # We should set the runpath_var.
8989156283Srwatson	  rpath=
8990156283Srwatson	  for dir in $finalize_perm_rpath; do
8991244390Srwatson	    func_append rpath "$dir:"
8992156283Srwatson	  done
8993156283Srwatson	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
8994156283Srwatson	fi
8995156283Srwatson      fi
8996156283Srwatson
8997156283Srwatson      if test "$no_install" = yes; then
8998156283Srwatson	# We don't need to create a wrapper script.
8999156283Srwatson	link_command="$compile_var$compile_command$compile_rpath"
9000156283Srwatson	# Replace the output file specification.
9001244390Srwatson	link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
9002156283Srwatson	# Delete the old output file.
9003244390Srwatson	$opt_dry_run || $RM $output
9004156283Srwatson	# Link the executable and exit
9005244390Srwatson	func_show_eval "$link_command" 'exit $?'
9006244390Srwatson
9007244390Srwatson	if test -n "$postlink_cmds"; then
9008244390Srwatson	  func_to_tool_file "$output"
9009244390Srwatson	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
9010244390Srwatson	  func_execute_cmds "$postlink_cmds" 'exit $?'
9011244390Srwatson	fi
9012244390Srwatson
9013156283Srwatson	exit $EXIT_SUCCESS
9014156283Srwatson      fi
9015156283Srwatson
9016156283Srwatson      if test "$hardcode_action" = relink; then
9017156283Srwatson	# Fast installation is not supported
9018156283Srwatson	link_command="$compile_var$compile_command$compile_rpath"
9019156283Srwatson	relink_command="$finalize_var$finalize_command$finalize_rpath"
9020156283Srwatson
9021244390Srwatson	func_warning "this platform does not like uninstalled shared libraries"
9022244390Srwatson	func_warning "\`$output' will be relinked during installation"
9023156283Srwatson      else
9024156283Srwatson	if test "$fast_install" != no; then
9025156283Srwatson	  link_command="$finalize_var$compile_command$finalize_rpath"
9026156283Srwatson	  if test "$fast_install" = yes; then
9027244390Srwatson	    relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
9028156283Srwatson	  else
9029156283Srwatson	    # fast_install is set to needless
9030156283Srwatson	    relink_command=
9031156283Srwatson	  fi
9032156283Srwatson	else
9033156283Srwatson	  link_command="$compile_var$compile_command$compile_rpath"
9034156283Srwatson	  relink_command="$finalize_var$finalize_command$finalize_rpath"
9035156283Srwatson	fi
9036156283Srwatson      fi
9037156283Srwatson
9038156283Srwatson      # Replace the output file specification.
9039244390Srwatson      link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
9040156283Srwatson
9041156283Srwatson      # Delete the old output files.
9042244390Srwatson      $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
9043156283Srwatson
9044244390Srwatson      func_show_eval "$link_command" 'exit $?'
9045156283Srwatson
9046244390Srwatson      if test -n "$postlink_cmds"; then
9047244390Srwatson	func_to_tool_file "$output_objdir/$outputname"
9048244390Srwatson	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'`
9049244390Srwatson	func_execute_cmds "$postlink_cmds" 'exit $?'
9050244390Srwatson      fi
9051244390Srwatson
9052156283Srwatson      # Now create the wrapper script.
9053244390Srwatson      func_verbose "creating $output"
9054156283Srwatson
9055156283Srwatson      # Quote the relink command for shipping.
9056156283Srwatson      if test -n "$relink_command"; then
9057156283Srwatson	# Preserve any variables that may affect compiler behavior
9058156283Srwatson	for var in $variables_saved_for_relink; do
9059156283Srwatson	  if eval test -z \"\${$var+set}\"; then
9060244390Srwatson	    relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
9061156283Srwatson	  elif eval var_value=\$$var; test -z "$var_value"; then
9062156283Srwatson	    relink_command="$var=; export $var; $relink_command"
9063156283Srwatson	  else
9064244390Srwatson	    func_quote_for_eval "$var_value"
9065244390Srwatson	    relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
9066156283Srwatson	  fi
9067156283Srwatson	done
9068156283Srwatson	relink_command="(cd `pwd`; $relink_command)"
9069244390Srwatson	relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
9070156283Srwatson      fi
9071156283Srwatson
9072244390Srwatson      # Only actually do things if not in dry run mode.
9073244390Srwatson      $opt_dry_run || {
9074156283Srwatson	# win32 will think the script is a binary if it has
9075156283Srwatson	# a .exe suffix, so we strip it off here.
9076156283Srwatson	case $output in
9077244390Srwatson	  *.exe) func_stripname '' '.exe' "$output"
9078244390Srwatson	         output=$func_stripname_result ;;
9079156283Srwatson	esac
9080156283Srwatson	# test for cygwin because mv fails w/o .exe extensions
9081156283Srwatson	case $host in
9082156283Srwatson	  *cygwin*)
9083156283Srwatson	    exeext=.exe
9084244390Srwatson	    func_stripname '' '.exe' "$outputname"
9085244390Srwatson	    outputname=$func_stripname_result ;;
9086156283Srwatson	  *) exeext= ;;
9087156283Srwatson	esac
9088156283Srwatson	case $host in
9089156283Srwatson	  *cygwin* | *mingw* )
9090244390Srwatson	    func_dirname_and_basename "$output" "" "."
9091244390Srwatson	    output_name=$func_basename_result
9092244390Srwatson	    output_path=$func_dirname_result
9093244390Srwatson	    cwrappersource="$output_path/$objdir/lt-$output_name.c"
9094244390Srwatson	    cwrapper="$output_path/$output_name.exe"
9095244390Srwatson	    $RM $cwrappersource $cwrapper
9096244390Srwatson	    trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
9097156283Srwatson
9098244390Srwatson	    func_emit_cwrapperexe_src > $cwrappersource
9099156283Srwatson
9100244390Srwatson	    # The wrapper executable is built using the $host compiler,
9101244390Srwatson	    # because it contains $host paths and files. If cross-
9102244390Srwatson	    # compiling, it, like the target executable, must be
9103244390Srwatson	    # executed on the $host or under an emulation environment.
9104244390Srwatson	    $opt_dry_run || {
9105244390Srwatson	      $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
9106244390Srwatson	      $STRIP $cwrapper
9107244390Srwatson	    }
9108156283Srwatson
9109244390Srwatson	    # Now, create the wrapper script for func_source use:
9110244390Srwatson	    func_ltwrapper_scriptname $cwrapper
9111244390Srwatson	    $RM $func_ltwrapper_scriptname_result
9112244390Srwatson	    trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
9113244390Srwatson	    $opt_dry_run || {
9114244390Srwatson	      # note: this script will not be executed, so do not chmod.
9115244390Srwatson	      if test "x$build" = "x$host" ; then
9116244390Srwatson		$cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
9117244390Srwatson	      else
9118244390Srwatson		func_emit_wrapper no > $func_ltwrapper_scriptname_result
9119244390Srwatson	      fi
9120244390Srwatson	    }
9121156283Srwatson	  ;;
9122244390Srwatson	  * )
9123244390Srwatson	    $RM $output
9124244390Srwatson	    trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
9125156283Srwatson
9126244390Srwatson	    func_emit_wrapper no > $output
9127244390Srwatson	    chmod +x $output
9128156283Srwatson	  ;;
9129156283Srwatson	esac
9130244390Srwatson      }
9131156283Srwatson      exit $EXIT_SUCCESS
9132156283Srwatson      ;;
9133156283Srwatson    esac
9134156283Srwatson
9135156283Srwatson    # See if we need to build an old-fashioned archive.
9136156283Srwatson    for oldlib in $oldlibs; do
9137156283Srwatson
9138156283Srwatson      if test "$build_libtool_libs" = convenience; then
9139244390Srwatson	oldobjs="$libobjs_save $symfileobj"
9140156283Srwatson	addlibs="$convenience"
9141156283Srwatson	build_libtool_libs=no
9142156283Srwatson      else
9143156283Srwatson	if test "$build_libtool_libs" = module; then
9144156283Srwatson	  oldobjs="$libobjs_save"
9145156283Srwatson	  build_libtool_libs=no
9146156283Srwatson	else
9147156283Srwatson	  oldobjs="$old_deplibs $non_pic_objects"
9148244390Srwatson	  if test "$preload" = yes && test -f "$symfileobj"; then
9149244390Srwatson	    func_append oldobjs " $symfileobj"
9150244390Srwatson	  fi
9151156283Srwatson	fi
9152156283Srwatson	addlibs="$old_convenience"
9153156283Srwatson      fi
9154156283Srwatson
9155156283Srwatson      if test -n "$addlibs"; then
9156156283Srwatson	gentop="$output_objdir/${outputname}x"
9157244390Srwatson	func_append generated " $gentop"
9158156283Srwatson
9159156283Srwatson	func_extract_archives $gentop $addlibs
9160244390Srwatson	func_append oldobjs " $func_extract_archives_result"
9161156283Srwatson      fi
9162156283Srwatson
9163156283Srwatson      # Do each command in the archive commands.
9164156283Srwatson      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
9165244390Srwatson	cmds=$old_archive_from_new_cmds
9166156283Srwatson      else
9167244390Srwatson
9168244390Srwatson	# Add any objects from preloaded convenience libraries
9169244390Srwatson	if test -n "$dlprefiles"; then
9170244390Srwatson	  gentop="$output_objdir/${outputname}x"
9171244390Srwatson	  func_append generated " $gentop"
9172244390Srwatson
9173244390Srwatson	  func_extract_archives $gentop $dlprefiles
9174244390Srwatson	  func_append oldobjs " $func_extract_archives_result"
9175244390Srwatson	fi
9176244390Srwatson
9177156283Srwatson	# POSIX demands no paths to be encoded in archives.  We have
9178156283Srwatson	# to avoid creating archives with duplicate basenames if we
9179156283Srwatson	# might have to extract them afterwards, e.g., when creating a
9180156283Srwatson	# static archive out of a convenience library, or when linking
9181156283Srwatson	# the entirety of a libtool archive into another (currently
9182156283Srwatson	# not supported by libtool).
9183156283Srwatson	if (for obj in $oldobjs
9184156283Srwatson	    do
9185244390Srwatson	      func_basename "$obj"
9186244390Srwatson	      $ECHO "$func_basename_result"
9187156283Srwatson	    done | sort | sort -uc >/dev/null 2>&1); then
9188156283Srwatson	  :
9189156283Srwatson	else
9190244390Srwatson	  echo "copying selected object files to avoid basename conflicts..."
9191244390Srwatson	  gentop="$output_objdir/${outputname}x"
9192244390Srwatson	  func_append generated " $gentop"
9193244390Srwatson	  func_mkdir_p "$gentop"
9194156283Srwatson	  save_oldobjs=$oldobjs
9195156283Srwatson	  oldobjs=
9196156283Srwatson	  counter=1
9197156283Srwatson	  for obj in $save_oldobjs
9198156283Srwatson	  do
9199244390Srwatson	    func_basename "$obj"
9200244390Srwatson	    objbase="$func_basename_result"
9201156283Srwatson	    case " $oldobjs " in
9202156283Srwatson	    " ") oldobjs=$obj ;;
9203156283Srwatson	    *[\ /]"$objbase "*)
9204156283Srwatson	      while :; do
9205156283Srwatson		# Make sure we don't pick an alternate name that also
9206156283Srwatson		# overlaps.
9207156283Srwatson		newobj=lt$counter-$objbase
9208244390Srwatson		func_arith $counter + 1
9209244390Srwatson		counter=$func_arith_result
9210156283Srwatson		case " $oldobjs " in
9211156283Srwatson		*[\ /]"$newobj "*) ;;
9212156283Srwatson		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
9213156283Srwatson		esac
9214156283Srwatson	      done
9215244390Srwatson	      func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
9216244390Srwatson	      func_append oldobjs " $gentop/$newobj"
9217156283Srwatson	      ;;
9218244390Srwatson	    *) func_append oldobjs " $obj" ;;
9219156283Srwatson	    esac
9220156283Srwatson	  done
9221156283Srwatson	fi
9222244390Srwatson	func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
9223244390Srwatson	tool_oldlib=$func_to_tool_file_result
9224156283Srwatson	eval cmds=\"$old_archive_cmds\"
9225156283Srwatson
9226244390Srwatson	func_len " $cmds"
9227244390Srwatson	len=$func_len_result
9228244390Srwatson	if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
9229156283Srwatson	  cmds=$old_archive_cmds
9230244390Srwatson	elif test -n "$archiver_list_spec"; then
9231244390Srwatson	  func_verbose "using command file archive linking..."
9232244390Srwatson	  for obj in $oldobjs
9233244390Srwatson	  do
9234244390Srwatson	    func_to_tool_file "$obj"
9235244390Srwatson	    $ECHO "$func_to_tool_file_result"
9236244390Srwatson	  done > $output_objdir/$libname.libcmd
9237244390Srwatson	  func_to_tool_file "$output_objdir/$libname.libcmd"
9238244390Srwatson	  oldobjs=" $archiver_list_spec$func_to_tool_file_result"
9239244390Srwatson	  cmds=$old_archive_cmds
9240156283Srwatson	else
9241156283Srwatson	  # the command line is too long to link in one step, link in parts
9242244390Srwatson	  func_verbose "using piecewise archive linking..."
9243156283Srwatson	  save_RANLIB=$RANLIB
9244156283Srwatson	  RANLIB=:
9245156283Srwatson	  objlist=
9246156283Srwatson	  concat_cmds=
9247156283Srwatson	  save_oldobjs=$oldobjs
9248244390Srwatson	  oldobjs=
9249156283Srwatson	  # Is there a better way of finding the last object in the list?
9250156283Srwatson	  for obj in $save_oldobjs
9251156283Srwatson	  do
9252156283Srwatson	    last_oldobj=$obj
9253156283Srwatson	  done
9254244390Srwatson	  eval test_cmds=\"$old_archive_cmds\"
9255244390Srwatson	  func_len " $test_cmds"
9256244390Srwatson	  len0=$func_len_result
9257244390Srwatson	  len=$len0
9258156283Srwatson	  for obj in $save_oldobjs
9259156283Srwatson	  do
9260244390Srwatson	    func_len " $obj"
9261244390Srwatson	    func_arith $len + $func_len_result
9262244390Srwatson	    len=$func_arith_result
9263244390Srwatson	    func_append objlist " $obj"
9264244390Srwatson	    if test "$len" -lt "$max_cmd_len"; then
9265156283Srwatson	      :
9266156283Srwatson	    else
9267156283Srwatson	      # the above command should be used before it gets too long
9268156283Srwatson	      oldobjs=$objlist
9269156283Srwatson	      if test "$obj" = "$last_oldobj" ; then
9270244390Srwatson		RANLIB=$save_RANLIB
9271156283Srwatson	      fi
9272156283Srwatson	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
9273156283Srwatson	      eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
9274156283Srwatson	      objlist=
9275244390Srwatson	      len=$len0
9276156283Srwatson	    fi
9277156283Srwatson	  done
9278156283Srwatson	  RANLIB=$save_RANLIB
9279156283Srwatson	  oldobjs=$objlist
9280156283Srwatson	  if test "X$oldobjs" = "X" ; then
9281156283Srwatson	    eval cmds=\"\$concat_cmds\"
9282156283Srwatson	  else
9283156283Srwatson	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
9284156283Srwatson	  fi
9285156283Srwatson	fi
9286156283Srwatson      fi
9287244390Srwatson      func_execute_cmds "$cmds" 'exit $?'
9288156283Srwatson    done
9289156283Srwatson
9290244390Srwatson    test -n "$generated" && \
9291244390Srwatson      func_show_eval "${RM}r$generated"
9292156283Srwatson
9293156283Srwatson    # Now create the libtool archive.
9294156283Srwatson    case $output in
9295156283Srwatson    *.la)
9296156283Srwatson      old_library=
9297156283Srwatson      test "$build_old_libs" = yes && old_library="$libname.$libext"
9298244390Srwatson      func_verbose "creating $output"
9299156283Srwatson
9300156283Srwatson      # Preserve any variables that may affect compiler behavior
9301156283Srwatson      for var in $variables_saved_for_relink; do
9302156283Srwatson	if eval test -z \"\${$var+set}\"; then
9303244390Srwatson	  relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
9304156283Srwatson	elif eval var_value=\$$var; test -z "$var_value"; then
9305156283Srwatson	  relink_command="$var=; export $var; $relink_command"
9306156283Srwatson	else
9307244390Srwatson	  func_quote_for_eval "$var_value"
9308244390Srwatson	  relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
9309156283Srwatson	fi
9310156283Srwatson      done
9311156283Srwatson      # Quote the link command for shipping.
9312156283Srwatson      relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
9313244390Srwatson      relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
9314156283Srwatson      if test "$hardcode_automatic" = yes ; then
9315156283Srwatson	relink_command=
9316156283Srwatson      fi
9317156283Srwatson
9318156283Srwatson      # Only create the output if not a dry run.
9319244390Srwatson      $opt_dry_run || {
9320156283Srwatson	for installed in no yes; do
9321156283Srwatson	  if test "$installed" = yes; then
9322156283Srwatson	    if test -z "$install_libdir"; then
9323156283Srwatson	      break
9324156283Srwatson	    fi
9325156283Srwatson	    output="$output_objdir/$outputname"i
9326156283Srwatson	    # Replace all uninstalled libtool libraries with the installed ones
9327156283Srwatson	    newdependency_libs=
9328156283Srwatson	    for deplib in $dependency_libs; do
9329156283Srwatson	      case $deplib in
9330156283Srwatson	      *.la)
9331244390Srwatson		func_basename "$deplib"
9332244390Srwatson		name="$func_basename_result"
9333244390Srwatson		func_resolve_sysroot "$deplib"
9334244390Srwatson		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result`
9335244390Srwatson		test -z "$libdir" && \
9336244390Srwatson		  func_fatal_error "\`$deplib' is not a valid libtool archive"
9337244390Srwatson		func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"
9338156283Srwatson		;;
9339244390Srwatson	      -L*)
9340244390Srwatson		func_stripname -L '' "$deplib"
9341244390Srwatson		func_replace_sysroot "$func_stripname_result"
9342244390Srwatson		func_append newdependency_libs " -L$func_replace_sysroot_result"
9343244390Srwatson		;;
9344244390Srwatson	      -R*)
9345244390Srwatson		func_stripname -R '' "$deplib"
9346244390Srwatson		func_replace_sysroot "$func_stripname_result"
9347244390Srwatson		func_append newdependency_libs " -R$func_replace_sysroot_result"
9348244390Srwatson		;;
9349244390Srwatson	      *) func_append newdependency_libs " $deplib" ;;
9350156283Srwatson	      esac
9351156283Srwatson	    done
9352156283Srwatson	    dependency_libs="$newdependency_libs"
9353156283Srwatson	    newdlfiles=
9354244390Srwatson
9355156283Srwatson	    for lib in $dlfiles; do
9356244390Srwatson	      case $lib in
9357244390Srwatson	      *.la)
9358244390Srwatson	        func_basename "$lib"
9359244390Srwatson		name="$func_basename_result"
9360244390Srwatson		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
9361244390Srwatson		test -z "$libdir" && \
9362244390Srwatson		  func_fatal_error "\`$lib' is not a valid libtool archive"
9363244390Srwatson		func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name"
9364244390Srwatson		;;
9365244390Srwatson	      *) func_append newdlfiles " $lib" ;;
9366244390Srwatson	      esac
9367156283Srwatson	    done
9368156283Srwatson	    dlfiles="$newdlfiles"
9369156283Srwatson	    newdlprefiles=
9370156283Srwatson	    for lib in $dlprefiles; do
9371244390Srwatson	      case $lib in
9372244390Srwatson	      *.la)
9373244390Srwatson		# Only pass preopened files to the pseudo-archive (for
9374244390Srwatson		# eventual linking with the app. that links it) if we
9375244390Srwatson		# didn't already link the preopened objects directly into
9376244390Srwatson		# the library:
9377244390Srwatson		func_basename "$lib"
9378244390Srwatson		name="$func_basename_result"
9379244390Srwatson		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
9380244390Srwatson		test -z "$libdir" && \
9381244390Srwatson		  func_fatal_error "\`$lib' is not a valid libtool archive"
9382244390Srwatson		func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name"
9383244390Srwatson		;;
9384244390Srwatson	      esac
9385156283Srwatson	    done
9386156283Srwatson	    dlprefiles="$newdlprefiles"
9387156283Srwatson	  else
9388156283Srwatson	    newdlfiles=
9389156283Srwatson	    for lib in $dlfiles; do
9390156283Srwatson	      case $lib in
9391156283Srwatson		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
9392156283Srwatson		*) abs=`pwd`"/$lib" ;;
9393156283Srwatson	      esac
9394244390Srwatson	      func_append newdlfiles " $abs"
9395156283Srwatson	    done
9396156283Srwatson	    dlfiles="$newdlfiles"
9397156283Srwatson	    newdlprefiles=
9398156283Srwatson	    for lib in $dlprefiles; do
9399156283Srwatson	      case $lib in
9400156283Srwatson		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
9401156283Srwatson		*) abs=`pwd`"/$lib" ;;
9402156283Srwatson	      esac
9403244390Srwatson	      func_append newdlprefiles " $abs"
9404156283Srwatson	    done
9405156283Srwatson	    dlprefiles="$newdlprefiles"
9406156283Srwatson	  fi
9407244390Srwatson	  $RM $output
9408156283Srwatson	  # place dlname in correct position for cygwin
9409244390Srwatson	  # In fact, it would be nice if we could use this code for all target
9410244390Srwatson	  # systems that can't hard-code library paths into their executables
9411244390Srwatson	  # and that have no shared library path variable independent of PATH,
9412244390Srwatson	  # but it turns out we can't easily determine that from inspecting
9413244390Srwatson	  # libtool variables, so we have to hard-code the OSs to which it
9414244390Srwatson	  # applies here; at the moment, that means platforms that use the PE
9415244390Srwatson	  # object format with DLL files.  See the long comment at the top of
9416244390Srwatson	  # tests/bindir.at for full details.
9417156283Srwatson	  tdlname=$dlname
9418156283Srwatson	  case $host,$output,$installed,$module,$dlname in
9419244390Srwatson	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
9420244390Srwatson	      # If a -bindir argument was supplied, place the dll there.
9421244390Srwatson	      if test "x$bindir" != x ;
9422244390Srwatson	      then
9423244390Srwatson		func_relative_path "$install_libdir" "$bindir"
9424244390Srwatson		tdlname=$func_relative_path_result$dlname
9425244390Srwatson	      else
9426244390Srwatson		# Otherwise fall back on heuristic.
9427244390Srwatson		tdlname=../bin/$dlname
9428244390Srwatson	      fi
9429244390Srwatson	      ;;
9430156283Srwatson	  esac
9431244390Srwatson	  $ECHO > $output "\
9432156283Srwatson# $outputname - a libtool library file
9433244390Srwatson# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
9434156283Srwatson#
9435156283Srwatson# Please DO NOT delete this file!
9436156283Srwatson# It is necessary for linking the library.
9437156283Srwatson
9438156283Srwatson# The name that we can dlopen(3).
9439156283Srwatsondlname='$tdlname'
9440156283Srwatson
9441156283Srwatson# Names of this library.
9442156283Srwatsonlibrary_names='$library_names'
9443156283Srwatson
9444156283Srwatson# The name of the static archive.
9445156283Srwatsonold_library='$old_library'
9446156283Srwatson
9447244390Srwatson# Linker flags that can not go in dependency_libs.
9448244390Srwatsoninherited_linker_flags='$new_inherited_linker_flags'
9449244390Srwatson
9450156283Srwatson# Libraries that this one depends upon.
9451156283Srwatsondependency_libs='$dependency_libs'
9452156283Srwatson
9453244390Srwatson# Names of additional weak libraries provided by this library
9454244390Srwatsonweak_library_names='$weak_libs'
9455244390Srwatson
9456156283Srwatson# Version information for $libname.
9457156283Srwatsoncurrent=$current
9458156283Srwatsonage=$age
9459156283Srwatsonrevision=$revision
9460156283Srwatson
9461156283Srwatson# Is this an already installed library?
9462156283Srwatsoninstalled=$installed
9463156283Srwatson
9464156283Srwatson# Should we warn about portability when linking against -modules?
9465156283Srwatsonshouldnotlink=$module
9466156283Srwatson
9467156283Srwatson# Files to dlopen/dlpreopen
9468156283Srwatsondlopen='$dlfiles'
9469156283Srwatsondlpreopen='$dlprefiles'
9470156283Srwatson
9471156283Srwatson# Directory that this library needs to be installed in:
9472156283Srwatsonlibdir='$install_libdir'"
9473156283Srwatson	  if test "$installed" = no && test "$need_relink" = yes; then
9474244390Srwatson	    $ECHO >> $output "\
9475156283Srwatsonrelink_command=\"$relink_command\""
9476156283Srwatson	  fi
9477156283Srwatson	done
9478244390Srwatson      }
9479156283Srwatson
9480156283Srwatson      # Do a symbolic link so that the libtool archive can be found in
9481156283Srwatson      # LD_LIBRARY_PATH before the program is installed.
9482244390Srwatson      func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
9483156283Srwatson      ;;
9484156283Srwatson    esac
9485156283Srwatson    exit $EXIT_SUCCESS
9486244390Srwatson}
9487156283Srwatson
9488244390Srwatson{ test "$opt_mode" = link || test "$opt_mode" = relink; } &&
9489244390Srwatson    func_mode_link ${1+"$@"}
9490156283Srwatson
9491156283Srwatson
9492244390Srwatson# func_mode_uninstall arg...
9493244390Srwatsonfunc_mode_uninstall ()
9494244390Srwatson{
9495244390Srwatson    $opt_debug
9496244390Srwatson    RM="$nonopt"
9497156283Srwatson    files=
9498156283Srwatson    rmforce=
9499156283Srwatson    exit_status=0
9500156283Srwatson
9501156283Srwatson    # This variable tells wrapper scripts just to set variables rather
9502156283Srwatson    # than running their programs.
9503156283Srwatson    libtool_install_magic="$magic"
9504156283Srwatson
9505156283Srwatson    for arg
9506156283Srwatson    do
9507156283Srwatson      case $arg in
9508244390Srwatson      -f) func_append RM " $arg"; rmforce=yes ;;
9509244390Srwatson      -*) func_append RM " $arg" ;;
9510244390Srwatson      *) func_append files " $arg" ;;
9511156283Srwatson      esac
9512156283Srwatson    done
9513156283Srwatson
9514244390Srwatson    test -z "$RM" && \
9515244390Srwatson      func_fatal_help "you must specify an RM program"
9516156283Srwatson
9517156283Srwatson    rmdirs=
9518156283Srwatson
9519156283Srwatson    for file in $files; do
9520244390Srwatson      func_dirname "$file" "" "."
9521244390Srwatson      dir="$func_dirname_result"
9522244390Srwatson      if test "X$dir" = X.; then
9523244390Srwatson	odir="$objdir"
9524156283Srwatson      else
9525244390Srwatson	odir="$dir/$objdir"
9526156283Srwatson      fi
9527244390Srwatson      func_basename "$file"
9528244390Srwatson      name="$func_basename_result"
9529244390Srwatson      test "$opt_mode" = uninstall && odir="$dir"
9530156283Srwatson
9531244390Srwatson      # Remember odir for removal later, being careful to avoid duplicates
9532244390Srwatson      if test "$opt_mode" = clean; then
9533156283Srwatson	case " $rmdirs " in
9534244390Srwatson	  *" $odir "*) ;;
9535244390Srwatson	  *) func_append rmdirs " $odir" ;;
9536156283Srwatson	esac
9537156283Srwatson      fi
9538156283Srwatson
9539156283Srwatson      # Don't error if the file doesn't exist and rm -f was used.
9540244390Srwatson      if { test -L "$file"; } >/dev/null 2>&1 ||
9541244390Srwatson	 { test -h "$file"; } >/dev/null 2>&1 ||
9542244390Srwatson	 test -f "$file"; then
9543156283Srwatson	:
9544156283Srwatson      elif test -d "$file"; then
9545156283Srwatson	exit_status=1
9546156283Srwatson	continue
9547156283Srwatson      elif test "$rmforce" = yes; then
9548156283Srwatson	continue
9549156283Srwatson      fi
9550156283Srwatson
9551156283Srwatson      rmfiles="$file"
9552156283Srwatson
9553156283Srwatson      case $name in
9554156283Srwatson      *.la)
9555156283Srwatson	# Possibly a libtool archive, so verify it.
9556244390Srwatson	if func_lalib_p "$file"; then
9557244390Srwatson	  func_source $dir/$name
9558156283Srwatson
9559156283Srwatson	  # Delete the libtool libraries and symlinks.
9560156283Srwatson	  for n in $library_names; do
9561244390Srwatson	    func_append rmfiles " $odir/$n"
9562156283Srwatson	  done
9563244390Srwatson	  test -n "$old_library" && func_append rmfiles " $odir/$old_library"
9564156283Srwatson
9565244390Srwatson	  case "$opt_mode" in
9566159985Srwatson	  clean)
9567244390Srwatson	    case " $library_names " in
9568159985Srwatson	    *" $dlname "*) ;;
9569244390Srwatson	    *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;;
9570159985Srwatson	    esac
9571244390Srwatson	    test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i"
9572159985Srwatson	    ;;
9573159985Srwatson	  uninstall)
9574156283Srwatson	    if test -n "$library_names"; then
9575156283Srwatson	      # Do each command in the postuninstall commands.
9576244390Srwatson	      func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
9577156283Srwatson	    fi
9578156283Srwatson
9579156283Srwatson	    if test -n "$old_library"; then
9580156283Srwatson	      # Do each command in the old_postuninstall commands.
9581244390Srwatson	      func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
9582156283Srwatson	    fi
9583156283Srwatson	    # FIXME: should reinstall the best remaining shared library.
9584159985Srwatson	    ;;
9585159985Srwatson	  esac
9586156283Srwatson	fi
9587156283Srwatson	;;
9588156283Srwatson
9589156283Srwatson      *.lo)
9590156283Srwatson	# Possibly a libtool object, so verify it.
9591244390Srwatson	if func_lalib_p "$file"; then
9592156283Srwatson
9593156283Srwatson	  # Read the .lo file
9594244390Srwatson	  func_source $dir/$name
9595156283Srwatson
9596156283Srwatson	  # Add PIC object to the list of files to remove.
9597244390Srwatson	  if test -n "$pic_object" &&
9598244390Srwatson	     test "$pic_object" != none; then
9599244390Srwatson	    func_append rmfiles " $dir/$pic_object"
9600156283Srwatson	  fi
9601156283Srwatson
9602156283Srwatson	  # Add non-PIC object to the list of files to remove.
9603244390Srwatson	  if test -n "$non_pic_object" &&
9604244390Srwatson	     test "$non_pic_object" != none; then
9605244390Srwatson	    func_append rmfiles " $dir/$non_pic_object"
9606156283Srwatson	  fi
9607156283Srwatson	fi
9608156283Srwatson	;;
9609156283Srwatson
9610156283Srwatson      *)
9611244390Srwatson	if test "$opt_mode" = clean ; then
9612156283Srwatson	  noexename=$name
9613156283Srwatson	  case $file in
9614156283Srwatson	  *.exe)
9615244390Srwatson	    func_stripname '' '.exe' "$file"
9616244390Srwatson	    file=$func_stripname_result
9617244390Srwatson	    func_stripname '' '.exe' "$name"
9618244390Srwatson	    noexename=$func_stripname_result
9619156283Srwatson	    # $file with .exe has already been added to rmfiles,
9620156283Srwatson	    # add $file without .exe
9621244390Srwatson	    func_append rmfiles " $file"
9622156283Srwatson	    ;;
9623156283Srwatson	  esac
9624156283Srwatson	  # Do a test to see if this is a libtool program.
9625244390Srwatson	  if func_ltwrapper_p "$file"; then
9626244390Srwatson	    if func_ltwrapper_executable_p "$file"; then
9627244390Srwatson	      func_ltwrapper_scriptname "$file"
9628244390Srwatson	      relink_command=
9629244390Srwatson	      func_source $func_ltwrapper_scriptname_result
9630244390Srwatson	      func_append rmfiles " $func_ltwrapper_scriptname_result"
9631244390Srwatson	    else
9632244390Srwatson	      relink_command=
9633244390Srwatson	      func_source $dir/$noexename
9634244390Srwatson	    fi
9635156283Srwatson
9636156283Srwatson	    # note $name still contains .exe if it was in $file originally
9637156283Srwatson	    # as does the version of $file that was added into $rmfiles
9638244390Srwatson	    func_append rmfiles " $odir/$name $odir/${name}S.${objext}"
9639156283Srwatson	    if test "$fast_install" = yes && test -n "$relink_command"; then
9640244390Srwatson	      func_append rmfiles " $odir/lt-$name"
9641156283Srwatson	    fi
9642156283Srwatson	    if test "X$noexename" != "X$name" ; then
9643244390Srwatson	      func_append rmfiles " $odir/lt-${noexename}.c"
9644156283Srwatson	    fi
9645156283Srwatson	  fi
9646156283Srwatson	fi
9647156283Srwatson	;;
9648156283Srwatson      esac
9649244390Srwatson      func_show_eval "$RM $rmfiles" 'exit_status=1'
9650156283Srwatson    done
9651156283Srwatson
9652156283Srwatson    # Try to remove the ${objdir}s in the directories where we deleted files
9653156283Srwatson    for dir in $rmdirs; do
9654156283Srwatson      if test -d "$dir"; then
9655244390Srwatson	func_show_eval "rmdir $dir >/dev/null 2>&1"
9656156283Srwatson      fi
9657156283Srwatson    done
9658156283Srwatson
9659156283Srwatson    exit $exit_status
9660244390Srwatson}
9661156283Srwatson
9662244390Srwatson{ test "$opt_mode" = uninstall || test "$opt_mode" = clean; } &&
9663244390Srwatson    func_mode_uninstall ${1+"$@"}
9664156283Srwatson
9665244390Srwatsontest -z "$opt_mode" && {
9666244390Srwatson  help="$generic_help"
9667244390Srwatson  func_fatal_help "you must specify a MODE"
9668244390Srwatson}
9669156283Srwatson
9670244390Srwatsontest -z "$exec_cmd" && \
9671244390Srwatson  func_fatal_help "invalid operation mode \`$opt_mode'"
9672244390Srwatson
9673156283Srwatsonif test -n "$exec_cmd"; then
9674244390Srwatson  eval exec "$exec_cmd"
9675156283Srwatson  exit $EXIT_FAILURE
9676156283Srwatsonfi
9677156283Srwatson
9678244390Srwatsonexit $exit_status
9679156283Srwatson
9680156283Srwatson
9681156283Srwatson# The TAGs below are defined such that we never get into a situation
9682156283Srwatson# in which we disable both kinds of libraries.  Given conflicting
9683156283Srwatson# choices, we go for a static library, that is the most portable,
9684156283Srwatson# since we can't tell whether shared libraries were disabled because
9685156283Srwatson# the user asked for that or because the platform doesn't support
9686156283Srwatson# them.  This is particularly important on AIX, because we don't
9687156283Srwatson# support having both static and shared libraries enabled at the same
9688156283Srwatson# time on that platform, so we default to a shared-only configuration.
9689156283Srwatson# If a disable-shared tag is given, we'll fallback to a static-only
9690156283Srwatson# configuration.  But we'll never go from static-only to shared-only.
9691156283Srwatson
9692156283Srwatson# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
9693244390Srwatsonbuild_libtool_libs=no
9694244390Srwatsonbuild_old_libs=yes
9695156283Srwatson# ### END LIBTOOL TAG CONFIG: disable-shared
9696156283Srwatson
9697156283Srwatson# ### BEGIN LIBTOOL TAG CONFIG: disable-static
9698244390Srwatsonbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
9699156283Srwatson# ### END LIBTOOL TAG CONFIG: disable-static
9700156283Srwatson
9701156283Srwatson# Local Variables:
9702156283Srwatson# mode:shell-script
9703156283Srwatson# sh-indentation:2
9704156283Srwatson# End:
9705244390Srwatson# vi:sw=2
9706244390Srwatson
9707